@wormhole-foundation/wormhole-connect 3.0.1-beta.6-development → 3.0.1-beta.7-development

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/dist/assets/{evm-CP2QogPh.js → evm-Daw1hnd1.js} +1 -1
  2. package/dist/assets/{tokens-p0GcG7JT.js → tokens-CD1l6Xjr.js} +13 -13
  3. package/dist/main.js +81 -81
  4. package/dist/src/AppRouter.d.ts.map +1 -1
  5. package/dist/src/components/AssetBadge.d.ts.map +1 -1
  6. package/dist/src/components/ConfigurablePageHeader.d.ts +4 -0
  7. package/dist/src/components/ConfigurablePageHeader.d.ts.map +1 -0
  8. package/dist/src/components/SampleApp/index.d.ts.map +1 -1
  9. package/dist/src/components/v3/AlertBanner.d.ts +14 -0
  10. package/dist/src/components/v3/AlertBanner.d.ts.map +1 -0
  11. package/dist/src/components/v3/Button.d.ts +22 -0
  12. package/dist/src/components/v3/Button.d.ts.map +1 -0
  13. package/dist/src/config/ui.d.ts +1 -1
  14. package/dist/src/config/ui.d.ts.map +1 -1
  15. package/dist/src/hooks/useAmountValidation.d.ts +2 -2
  16. package/dist/src/hooks/useAmountValidation.d.ts.map +1 -1
  17. package/dist/src/icons/Clock.d.ts +5 -0
  18. package/dist/src/icons/Clock.d.ts.map +1 -0
  19. package/dist/src/icons/SwapVertical.d.ts +5 -0
  20. package/dist/src/icons/SwapVertical.d.ts.map +1 -0
  21. package/dist/src/icons/TokenIcons.d.ts +1 -1
  22. package/dist/src/icons/TokenIcons.d.ts.map +1 -1
  23. package/dist/src/theme.d.ts +10 -3
  24. package/dist/src/theme.d.ts.map +1 -1
  25. package/dist/src/views/v3/Bridge/AmountInput/index.d.ts +21 -0
  26. package/dist/src/views/v3/Bridge/AmountInput/index.d.ts.map +1 -0
  27. package/dist/src/views/v3/Bridge/AmountValidationError.d.ts +11 -0
  28. package/dist/src/views/v3/Bridge/AmountValidationError.d.ts.map +1 -0
  29. package/dist/src/views/v3/Bridge/AssetPicker/ChainList.d.ts +16 -0
  30. package/dist/src/views/v3/Bridge/AssetPicker/ChainList.d.ts.map +1 -0
  31. package/dist/src/views/v3/Bridge/AssetPicker/PickerBottomSheet.d.ts +31 -0
  32. package/dist/src/views/v3/Bridge/AssetPicker/PickerBottomSheet.d.ts.map +1 -0
  33. package/dist/src/views/v3/Bridge/AssetPicker/PickerModal.d.ts +32 -0
  34. package/dist/src/views/v3/Bridge/AssetPicker/PickerModal.d.ts.map +1 -0
  35. package/dist/src/views/v3/Bridge/AssetPicker/SearchableList/SearchInput.d.ts +11 -0
  36. package/dist/src/views/v3/Bridge/AssetPicker/SearchableList/SearchInput.d.ts.map +1 -0
  37. package/dist/src/views/v3/Bridge/AssetPicker/SearchableList/index.d.ts +20 -0
  38. package/dist/src/views/v3/Bridge/AssetPicker/SearchableList/index.d.ts.map +1 -0
  39. package/dist/src/views/v3/Bridge/AssetPicker/TokenItem.d.ts +16 -0
  40. package/dist/src/views/v3/Bridge/AssetPicker/TokenItem.d.ts.map +1 -0
  41. package/dist/src/views/v3/Bridge/AssetPicker/TokenList.d.ts +24 -0
  42. package/dist/src/views/v3/Bridge/AssetPicker/TokenList.d.ts.map +1 -0
  43. package/dist/src/views/v3/Bridge/AssetPicker/index.d.ts +32 -0
  44. package/dist/src/views/v3/Bridge/AssetPicker/index.d.ts.map +1 -0
  45. package/dist/src/views/v3/Bridge/GasSlider/index.d.ts +11 -0
  46. package/dist/src/views/v3/Bridge/GasSlider/index.d.ts.map +1 -0
  47. package/dist/src/views/v3/Bridge/Routes/RouteBadge.d.ts +9 -0
  48. package/dist/src/views/v3/Bridge/Routes/RouteBadge.d.ts.map +1 -0
  49. package/dist/src/views/v3/Bridge/Routes/RoutesBottomSheet.d.ts +26 -0
  50. package/dist/src/views/v3/Bridge/Routes/RoutesBottomSheet.d.ts.map +1 -0
  51. package/dist/src/views/v3/Bridge/Routes/RoutesList.d.ts +20 -0
  52. package/dist/src/views/v3/Bridge/Routes/RoutesList.d.ts.map +1 -0
  53. package/dist/src/views/v3/Bridge/Routes/RoutesModal.d.ts +25 -0
  54. package/dist/src/views/v3/Bridge/Routes/RoutesModal.d.ts.map +1 -0
  55. package/dist/src/views/v3/Bridge/Routes/SingleRoute.d.ts +17 -0
  56. package/dist/src/views/v3/Bridge/Routes/SingleRoute.d.ts.map +1 -0
  57. package/dist/src/views/v3/Bridge/Routes/index.d.ts +13 -0
  58. package/dist/src/views/v3/Bridge/Routes/index.d.ts.map +1 -0
  59. package/dist/src/views/v3/Bridge/SwapInputs/index.d.ts +5 -0
  60. package/dist/src/views/v3/Bridge/SwapInputs/index.d.ts.map +1 -0
  61. package/dist/src/views/v3/Bridge/WalletConnector/Controller.d.ts +8 -0
  62. package/dist/src/views/v3/Bridge/WalletConnector/Controller.d.ts.map +1 -0
  63. package/dist/src/views/v3/Bridge/WalletConnector/ExplorerLink.d.ts +10 -0
  64. package/dist/src/views/v3/Bridge/WalletConnector/ExplorerLink.d.ts.map +1 -0
  65. package/dist/src/views/v3/Bridge/WalletConnector/Sidebar.d.ts +11 -0
  66. package/dist/src/views/v3/Bridge/WalletConnector/Sidebar.d.ts.map +1 -0
  67. package/dist/src/views/v3/Bridge/WalletConnector/index.d.ts +11 -0
  68. package/dist/src/views/v3/Bridge/WalletConnector/index.d.ts.map +1 -0
  69. package/dist/src/views/v3/Bridge/index.d.ts +5 -0
  70. package/dist/src/views/v3/Bridge/index.d.ts.map +1 -0
  71. package/dist/src/views/v3/Redeem/TransactionDetails/index.d.ts +4 -0
  72. package/dist/src/views/v3/Redeem/TransactionDetails/index.d.ts.map +1 -0
  73. package/dist/src/views/v3/Redeem/index.d.ts +5 -0
  74. package/dist/src/views/v3/Redeem/index.d.ts.map +1 -0
  75. package/dist/src/views/v3/TxHistory/Item/index.d.ts +8 -0
  76. package/dist/src/views/v3/TxHistory/Item/index.d.ts.map +1 -0
  77. package/dist/src/views/v3/TxHistory/Widget/Item.d.ts +9 -0
  78. package/dist/src/views/v3/TxHistory/Widget/Item.d.ts.map +1 -0
  79. package/dist/src/views/v3/TxHistory/Widget/index.d.ts +6 -0
  80. package/dist/src/views/v3/TxHistory/Widget/index.d.ts.map +1 -0
  81. package/dist/src/views/v3/TxHistory/index.d.ts +4 -0
  82. package/dist/src/views/v3/TxHistory/index.d.ts.map +1 -0
  83. package/lib/{account-DtI49BC9.mjs → account-BXlWsVcD.mjs} +1 -1
  84. package/lib/{account-BNVdeY3i.js → account-D3Whnyky.js} +1 -1
  85. package/lib/address-B2sdpJNe.js +1 -0
  86. package/lib/{address-DHjpQ41W.js → address-CFAt6HNS.js} +1 -1
  87. package/lib/{address-C4qO2bMD.mjs → address-CZArADcj.mjs} +1 -1
  88. package/lib/{address-BJhcbdG9.mjs → address-DPWm1fbw.mjs} +212 -205
  89. package/lib/{address-XxuWo72f.js → address-DpQlJQKV.js} +7 -7
  90. package/lib/{address-QpeLv2yn.mjs → address-YYxpimx3.mjs} +277 -276
  91. package/lib/{aptos-BPPwy9CZ.js → aptos-BQFrxLpU.js} +1 -1
  92. package/lib/{aptos-b3ytowip.js → aptos-C6eC7BKq.js} +2 -2
  93. package/lib/{aptos-C8FBg3S2.mjs → aptos-DNhNK-_f.mjs} +7 -7
  94. package/lib/{aptos-ButqYPXo.mjs → aptos-YbewU4Io.mjs} +3 -3
  95. package/lib/{basic-YNjcoRfK.js → basic-BH3rU0o2.js} +1 -1
  96. package/lib/{basic-BDC-Dz2c.mjs → basic-CVEIWCYi.mjs} +2 -2
  97. package/lib/{basic-B5VNsnap.mjs → basic-D3Mgm4Qb.mjs} +2 -2
  98. package/lib/{basic-BR_WJgiZ.js → basic-kfvhCLeC.js} +1 -1
  99. package/lib/{blake2b-5ZGBTE8v.mjs → blake2b-BFJ9US29.mjs} +7 -7
  100. package/lib/{blake2b-BJ4wVK7V.js → blake2b-aUiblHhG.js} +1 -1
  101. package/lib/{browser-ponyfill-C53najnL.js → browser-ponyfill-BeX4lPJd.js} +1 -1
  102. package/lib/{browser-ponyfill-CuZzL5JS.mjs → browser-ponyfill-Cn2t1qf7.mjs} +1 -1
  103. package/lib/{chain-B7MIR9_r.mjs → chain-D5okRkwk.mjs} +1 -1
  104. package/lib/{chain-CSpjwyBt.js → chain-Dme8n2tA.js} +1 -1
  105. package/lib/{chunk-KJH4KKG6-qC3BvugF.mjs → chunk-KJH4KKG6-DTOJZuhY.mjs} +144 -144
  106. package/lib/{chunk-KJH4KKG6-B9iq51o1.js → chunk-KJH4KKG6-HfCF1Kt-.js} +1 -1
  107. package/lib/{constants-DWhraRof.mjs → constants-BHQAYN6w.mjs} +3 -3
  108. package/lib/{constants-BA7a60_u.js → constants-BsKTcZQ3.js} +1 -1
  109. package/lib/{contract-D4Vzf62E.mjs → contract-CjL0DzEO.mjs} +39 -39
  110. package/lib/{contract-CQnkFb54.js → contract-DPL0fm8A.js} +1 -1
  111. package/lib/{core-DY8-r2Jo.mjs → core-C67jLszg.mjs} +7 -7
  112. package/lib/{core-DzA-Itto.js → core-DmZlgGHj.js} +3 -3
  113. package/lib/{create-CtvZoy0X.mjs → create-BlfwwO0_.mjs} +3 -3
  114. package/lib/{create-DCJBhyHG.js → create-CovWyutZ.js} +1 -1
  115. package/lib/{evm-BvQ1H4_y.js → evm-BWTWGvAv.js} +2 -2
  116. package/lib/{evm-Dn0xYGMV.mjs → evm-BohuNM6V.mjs} +9 -9
  117. package/lib/{evm-CrfP3Qfk.js → evm-CqywsvEZ.js} +2 -2
  118. package/lib/{evm-BfefVZFh.mjs → evm-M0ImOGaN.mjs} +7 -7
  119. package/lib/executor.js +1 -1
  120. package/lib/executor.mjs +46 -46
  121. package/lib/hosted.js +1 -1
  122. package/lib/hosted.mjs +1 -1
  123. package/lib/{index-CnCmR4Uj.js → index-2CmAUr-U.js} +1 -1
  124. package/lib/{index-DF2WGKez.js → index-85b_tiAE.js} +1 -1
  125. package/lib/{index-Ct88Toxl.mjs → index-95FB4Qgc.mjs} +3 -3
  126. package/lib/{index-lN-puZih.js → index-B7ho7Pb6.js} +1 -1
  127. package/lib/{index-DbPhljz1.mjs → index-BAUIp5vX.mjs} +15 -15
  128. package/lib/{index-DQp_O8iB.mjs → index-BCZtiDee.mjs} +4 -4
  129. package/lib/{index-BiS8vv7E.mjs → index-BGq4wC4S.mjs} +1 -1
  130. package/lib/{index-CBHIr2qc.mjs → index-BQuPDPUZ.mjs} +14 -14
  131. package/lib/{index-C1NzL1cw.mjs → index-BSj3tfTR.mjs} +3 -3
  132. package/lib/{index-CbVRI3aO.mjs → index-BV1jWLbR.mjs} +40 -40
  133. package/lib/{index-CXwf1C77.mjs → index-BXk8QNCQ.mjs} +6 -6
  134. package/lib/{index-DwX86vgy.mjs → index-BcAk5RDV.mjs} +31 -31
  135. package/lib/{index-BarjntIo.mjs → index-BgOkhLJ5.mjs} +4 -4
  136. package/lib/{index-BjbPJ-9w.js → index-BkPAiliF.js} +1 -1
  137. package/lib/{index-DLilRB-O.js → index-Bn-q9qez.js} +1 -1
  138. package/lib/{index-3pNz5RJC.js → index-Bt7K1A1Q.js} +1 -1
  139. package/lib/{index-BrjiGZLN.mjs → index-C-NwpT7M.mjs} +4 -4
  140. package/lib/{index-B2oGf_0Z.js → index-C7dcnZ_Y.js} +1 -1
  141. package/lib/{index-BuxGl_Bi.js → index-C9Mdci2_.js} +1 -1
  142. package/lib/index-CBBfcDND.js +335 -0
  143. package/lib/{index-BGsoGuxr.js → index-CGjibiRn.js} +1 -1
  144. package/lib/{index-Yra08X_i.js → index-CJ_ewe88.js} +1 -1
  145. package/lib/{index-CS1x3lLl.mjs → index-CMyIX4q3.mjs} +1 -1
  146. package/lib/{index-C6plXYir.mjs → index-CPq5TByt.mjs} +31052 -27169
  147. package/lib/{index-Czoo2lwG.mjs → index-Cd2G9Q0O.mjs} +2 -2
  148. package/lib/{index-iXUxUBar.js → index-D8YqkJyN.js} +1 -1
  149. package/lib/{index-BG9uNreI.js → index-DMtTF3lo.js} +1 -1
  150. package/lib/{index-DrcGXX5n.mjs → index-DRZtHRGC.mjs} +5 -5
  151. package/lib/{index-BZsgCHbh.js → index-DSFtUxH1.js} +1 -1
  152. package/lib/{index-B9Jj-myq.mjs → index-DYspQsyV.mjs} +4 -4
  153. package/lib/{index-BPdR4VSR.mjs → index-Difh_8Uq.mjs} +35 -35
  154. package/lib/{index-D2-kSqKC.mjs → index-Dl11esS0.mjs} +12 -12
  155. package/lib/{index-Dg1FDsF7.js → index-DlZQ535U.js} +1 -1
  156. package/lib/{index-DPZNqrkJ.mjs → index-DnaDROoD.mjs} +3 -3
  157. package/lib/{index-C6deIq6M.js → index-DocFg1hF.js} +1 -1
  158. package/lib/{index-BHv9flJb.js → index-DpEQBLtA.js} +1 -1
  159. package/lib/{index-OjOZm9KZ.mjs → index-DpSdWR-Q.mjs} +19 -19
  160. package/lib/{index-DCIXsPdt.js → index-DzxRHhWq.js} +1 -1
  161. package/lib/{index-BYNs7o4U.js → index-LMdITOCB.js} +1 -1
  162. package/lib/{index-C3JpIduu.js → index-cT-KFIxA.js} +1 -1
  163. package/lib/{index-TWJ3iDnH.js → index-k6e49slq.js} +1 -1
  164. package/lib/{index-t4mLpVUg.mjs → index-uuu1viWa.mjs} +1 -1
  165. package/lib/{index.es-CGmlPDhv.js → index.es-BYFwv7lT.js} +1 -1
  166. package/lib/{index.es-Cv23C4D_.mjs → index.es-BhhigIOQ.mjs} +3 -3
  167. package/lib/{index.es-C-nP3Wu4.mjs → index.es-DGqzeimm.mjs} +5 -5
  168. package/lib/{index.es-DOcp1QIZ.js → index.es-Fc3_m80E.js} +3 -3
  169. package/lib/index.js +1 -1
  170. package/lib/index.mjs +2 -2
  171. package/lib/mayan.js +9 -2
  172. package/lib/mayan.mjs +21900 -18117
  173. package/lib/{mint-DDRe5tvc.js → mint-C2AsTCD2.js} +1 -1
  174. package/lib/{mint-CwWYApOB.mjs → mint-CLB7p3ZL.mjs} +2 -2
  175. package/lib/ntt.js +1 -1
  176. package/lib/ntt.mjs +2370 -2323
  177. package/lib/{platform-Cdz3d-G9.js → platform-Cl1b31bn.js} +1 -1
  178. package/lib/{platform-C2My6P6V.js → platform-DV62YjSS.js} +1 -1
  179. package/lib/{platform-CkZe-n0U.js → platform-Dw5tN12f.js} +1 -1
  180. package/lib/{platform-B0QvkHbE.mjs → platform-bCY3DvqI.mjs} +14 -14
  181. package/lib/{platform-lg76WojY.mjs → platform-mkzPOtcO.mjs} +42 -21
  182. package/lib/{platform-IW8iV_CA.mjs → platform-pX0KL6zm.mjs} +6 -6
  183. package/lib/{provider-jsonrpc-Bd_Ha8XL.js → provider-jsonrpc-B0bAKP-a.js} +1 -1
  184. package/lib/{provider-jsonrpc-BXNY8lbA.mjs → provider-jsonrpc-DwKu1fjn.mjs} +120 -120
  185. package/lib/{secp256k1-BaYwfoJI.js → secp256k1-1EcPGQYM.js} +1 -1
  186. package/lib/{secp256k1-etdIygIN.mjs → secp256k1-6Zr6y_zm.mjs} +1 -1
  187. package/lib/{secp256k1-D3q9LbdQ.js → secp256k1-7IiVcfA7.js} +1 -1
  188. package/lib/{secp256k1-luy_3ZLQ.mjs → secp256k1-BeZAjIBs.mjs} +1 -1
  189. package/lib/{secp256k1-Cplgnjin.mjs → secp256k1-DXI-6Erh.mjs} +1 -1
  190. package/lib/{secp256k1-CuaGNRQC.js → secp256k1-Y38qxq0y.js} +1 -1
  191. package/lib/{signer-DKbAIeFy.mjs → signer-CzGPDOMI.mjs} +20 -20
  192. package/lib/{signer-BrSuBAB7.js → signer-D6-3r3Sp.js} +1 -1
  193. package/lib/{solana-BnirZbTQ.js → solana-Da7iWCux.js} +4 -4
  194. package/lib/solana-mjJtTggS.js +1 -0
  195. package/lib/{solana-DR8_Oms-.mjs → solana-os3Osxo6.mjs} +10 -10
  196. package/lib/solana-vo_l-zLm.mjs +18 -0
  197. package/lib/{solanaEmbed.esm-fUPiKqY3.mjs → solanaEmbed.esm-BBnVqCsz.mjs} +2 -2
  198. package/lib/{solanaEmbed.esm-BKWwcEou.js → solanaEmbed.esm-RhVD6vLR.js} +1 -1
  199. package/lib/src/AppRouter.d.ts.map +1 -1
  200. package/lib/src/components/AssetBadge.d.ts.map +1 -1
  201. package/lib/src/components/ConfigurablePageHeader.d.ts +4 -0
  202. package/lib/src/components/ConfigurablePageHeader.d.ts.map +1 -0
  203. package/lib/src/components/SampleApp/index.d.ts.map +1 -1
  204. package/lib/src/components/v3/AlertBanner.d.ts +14 -0
  205. package/lib/src/components/v3/AlertBanner.d.ts.map +1 -0
  206. package/lib/src/components/v3/Button.d.ts +22 -0
  207. package/lib/src/components/v3/Button.d.ts.map +1 -0
  208. package/lib/src/config/ui.d.ts +1 -1
  209. package/lib/src/config/ui.d.ts.map +1 -1
  210. package/lib/src/hooks/useAmountValidation.d.ts +2 -2
  211. package/lib/src/hooks/useAmountValidation.d.ts.map +1 -1
  212. package/lib/src/icons/Clock.d.ts +5 -0
  213. package/lib/src/icons/Clock.d.ts.map +1 -0
  214. package/lib/src/icons/SwapVertical.d.ts +5 -0
  215. package/lib/src/icons/SwapVertical.d.ts.map +1 -0
  216. package/lib/src/icons/TokenIcons.d.ts +1 -1
  217. package/lib/src/icons/TokenIcons.d.ts.map +1 -1
  218. package/lib/src/theme.d.ts +10 -3
  219. package/lib/src/theme.d.ts.map +1 -1
  220. package/lib/src/views/v3/Bridge/AmountInput/index.d.ts +21 -0
  221. package/lib/src/views/v3/Bridge/AmountInput/index.d.ts.map +1 -0
  222. package/lib/src/views/v3/Bridge/AmountValidationError.d.ts +11 -0
  223. package/lib/src/views/v3/Bridge/AmountValidationError.d.ts.map +1 -0
  224. package/lib/src/views/v3/Bridge/AssetPicker/ChainList.d.ts +16 -0
  225. package/lib/src/views/v3/Bridge/AssetPicker/ChainList.d.ts.map +1 -0
  226. package/lib/src/views/v3/Bridge/AssetPicker/PickerBottomSheet.d.ts +31 -0
  227. package/lib/src/views/v3/Bridge/AssetPicker/PickerBottomSheet.d.ts.map +1 -0
  228. package/lib/src/views/v3/Bridge/AssetPicker/PickerModal.d.ts +32 -0
  229. package/lib/src/views/v3/Bridge/AssetPicker/PickerModal.d.ts.map +1 -0
  230. package/lib/src/views/v3/Bridge/AssetPicker/SearchableList/SearchInput.d.ts +11 -0
  231. package/lib/src/views/v3/Bridge/AssetPicker/SearchableList/SearchInput.d.ts.map +1 -0
  232. package/lib/src/views/v3/Bridge/AssetPicker/SearchableList/index.d.ts +20 -0
  233. package/lib/src/views/v3/Bridge/AssetPicker/SearchableList/index.d.ts.map +1 -0
  234. package/lib/src/views/v3/Bridge/AssetPicker/TokenItem.d.ts +16 -0
  235. package/lib/src/views/v3/Bridge/AssetPicker/TokenItem.d.ts.map +1 -0
  236. package/lib/src/views/v3/Bridge/AssetPicker/TokenList.d.ts +24 -0
  237. package/lib/src/views/v3/Bridge/AssetPicker/TokenList.d.ts.map +1 -0
  238. package/lib/src/views/v3/Bridge/AssetPicker/index.d.ts +32 -0
  239. package/lib/src/views/v3/Bridge/AssetPicker/index.d.ts.map +1 -0
  240. package/lib/src/views/v3/Bridge/GasSlider/index.d.ts +11 -0
  241. package/lib/src/views/v3/Bridge/GasSlider/index.d.ts.map +1 -0
  242. package/lib/src/views/v3/Bridge/Routes/RouteBadge.d.ts +9 -0
  243. package/lib/src/views/v3/Bridge/Routes/RouteBadge.d.ts.map +1 -0
  244. package/lib/src/views/v3/Bridge/Routes/RoutesBottomSheet.d.ts +26 -0
  245. package/lib/src/views/v3/Bridge/Routes/RoutesBottomSheet.d.ts.map +1 -0
  246. package/lib/src/views/v3/Bridge/Routes/RoutesList.d.ts +20 -0
  247. package/lib/src/views/v3/Bridge/Routes/RoutesList.d.ts.map +1 -0
  248. package/lib/src/views/v3/Bridge/Routes/RoutesModal.d.ts +25 -0
  249. package/lib/src/views/v3/Bridge/Routes/RoutesModal.d.ts.map +1 -0
  250. package/lib/src/views/v3/Bridge/Routes/SingleRoute.d.ts +17 -0
  251. package/lib/src/views/v3/Bridge/Routes/SingleRoute.d.ts.map +1 -0
  252. package/lib/src/views/v3/Bridge/Routes/index.d.ts +13 -0
  253. package/lib/src/views/v3/Bridge/Routes/index.d.ts.map +1 -0
  254. package/lib/src/views/v3/Bridge/SwapInputs/index.d.ts +5 -0
  255. package/lib/src/views/v3/Bridge/SwapInputs/index.d.ts.map +1 -0
  256. package/lib/src/views/v3/Bridge/WalletConnector/Controller.d.ts +8 -0
  257. package/lib/src/views/v3/Bridge/WalletConnector/Controller.d.ts.map +1 -0
  258. package/lib/src/views/v3/Bridge/WalletConnector/ExplorerLink.d.ts +10 -0
  259. package/lib/src/views/v3/Bridge/WalletConnector/ExplorerLink.d.ts.map +1 -0
  260. package/lib/src/views/v3/Bridge/WalletConnector/Sidebar.d.ts +11 -0
  261. package/lib/src/views/v3/Bridge/WalletConnector/Sidebar.d.ts.map +1 -0
  262. package/lib/src/views/v3/Bridge/WalletConnector/index.d.ts +11 -0
  263. package/lib/src/views/v3/Bridge/WalletConnector/index.d.ts.map +1 -0
  264. package/lib/src/views/v3/Bridge/index.d.ts +5 -0
  265. package/lib/src/views/v3/Bridge/index.d.ts.map +1 -0
  266. package/lib/src/views/v3/Redeem/TransactionDetails/index.d.ts +4 -0
  267. package/lib/src/views/v3/Redeem/TransactionDetails/index.d.ts.map +1 -0
  268. package/lib/src/views/v3/Redeem/index.d.ts +5 -0
  269. package/lib/src/views/v3/Redeem/index.d.ts.map +1 -0
  270. package/lib/src/views/v3/TxHistory/Item/index.d.ts +8 -0
  271. package/lib/src/views/v3/TxHistory/Item/index.d.ts.map +1 -0
  272. package/lib/src/views/v3/TxHistory/Widget/Item.d.ts +9 -0
  273. package/lib/src/views/v3/TxHistory/Widget/Item.d.ts.map +1 -0
  274. package/lib/src/views/v3/TxHistory/Widget/index.d.ts +6 -0
  275. package/lib/src/views/v3/TxHistory/Widget/index.d.ts.map +1 -0
  276. package/lib/src/views/v3/TxHistory/index.d.ts +4 -0
  277. package/lib/src/views/v3/TxHistory/index.d.ts.map +1 -0
  278. package/lib/{sui-BTGAAvA9.js → sui-BCWT_MP3.js} +1 -1
  279. package/lib/{sui-BBqJwRM0.mjs → sui-CFKprzku.mjs} +3 -3
  280. package/lib/{sui-DTftSE5y.js → sui-CO5gTC2j.js} +1 -1
  281. package/lib/{sui-DAYuRjfB.mjs → sui-rzSF8U-3.mjs} +33 -33
  282. package/lib/{tokens-tq3iPasz.js → tokens-D2BbVV4x.js} +1 -1
  283. package/lib/{tokens-Bdu7ORRI.mjs → tokens-D74pLzp3.mjs} +3 -3
  284. package/lib/{units-Brhe0Yro.mjs → units-BGcsq4mJ.mjs} +24 -24
  285. package/lib/{units-CMwYFpwc.js → units-CFxZtEkH.js} +1 -1
  286. package/lib/{unsignedTransaction-Brbbx5Uc.mjs → unsignedTransaction-BHbKxuLa.mjs} +14 -14
  287. package/lib/{unsignedTransaction-q5Fk1S0o.js → unsignedTransaction-D14ic9We.js} +1 -1
  288. package/lib/{w3m-modal-BfRfCY9F.js → w3m-modal-253PNp3t.js} +1 -1
  289. package/lib/{w3m-modal-CtPzALaO.mjs → w3m-modal-BXoUHiVS.mjs} +2 -2
  290. package/lib/{w3m-modal-BhCXAHBR.js → w3m-modal-Dr98fjep.js} +1 -1
  291. package/lib/{w3m-modal-Dbhbe_NS.mjs → w3m-modal-vJ0TMybJ.mjs} +2 -2
  292. package/lib/{web3-Atnj-SZ3.mjs → web3-C7dEQmtr.mjs} +6 -6
  293. package/lib/{web3-DinKgkT9.js → web3-Co7tl8ed.js} +1 -1
  294. package/package.json +32 -33
  295. package/lib/address-BWzhA9di.js +0 -1
  296. package/lib/index-BjP-grbs.js +0 -299
  297. package/lib/solana-D_QkC8QG.mjs +0 -18
  298. package/lib/solana-pu7cIYt0.js +0 -1
@@ -1,5 +1,5 @@
1
- "use strict";var qb=Object.defineProperty;var Bb=(s,e,t)=>e in s?qb(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var At=(s,e,t)=>Bb(s,typeof e!="symbol"?e+"":e,t);const A=require("./address-XxuWo72f.js"),oe=require("./index-BjP-grbs.js"),Hb=require("./util-G2vxTeU2.js"),Wb=require("./wallets-5qGJd8Hk.js"),xa=require("./unsignedTransaction-q5Fk1S0o.js"),Tu=require("./signer-BrSuBAB7.js"),u=require("./index.es-CGmlPDhv.js"),k=require("./lit-element-Bij_rEQt.js");require("./browser-ponyfill-C53najnL.js");const yn=require("./http-NcnC3Lp_.js");class Dt extends Error{constructor(e,t){super(e),this.error=t}}class Li extends Dt{constructor(){super(...arguments),this.name="WalletNotReadyError"}}class Vb extends Dt{constructor(){super(...arguments),this.name="WalletLoadError"}}class un extends Dt{constructor(){super(...arguments),this.name="WalletConfigError"}}class cc extends Dt{constructor(){super(...arguments),this.name="WalletConnectionError"}}class ff extends Dt{constructor(){super(...arguments),this.name="WalletDisconnectedError"}}class ko extends Dt{constructor(){super(...arguments),this.name="WalletDisconnectionError"}}class Ns extends Dt{constructor(){super(...arguments),this.name="WalletAccountError"}}class yr extends Dt{constructor(){super(...arguments),this.name="WalletPublicKeyError"}}class Ge extends Dt{constructor(){super(...arguments),this.name="WalletNotConnectedError"}}class rr extends Dt{constructor(){super(...arguments),this.name="WalletSendTransactionError"}}class rt extends Dt{constructor(){super(...arguments),this.name="WalletSignTransactionError"}}class jo extends Dt{constructor(){super(...arguments),this.name="WalletSignMessageError"}}class Pu extends Dt{constructor(){super(...arguments),this.name="WalletSignInError"}}class Kb extends Dt{constructor(){super(...arguments),this.name="WalletWindowClosedError"}}var ge;(function(s){s.Installed="Installed",s.NotDetected="NotDetected",s.Loadable="Loadable",s.Unsupported="Unsupported"})(ge||(ge={}));class yf extends A.EventEmitter{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,i={}){const r=this.publicKey;if(!r)throw new Ge;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:i.preflightCommitment,minContextSlot:i.minContextSlot})).blockhash,e}}function Ro(s){if(typeof window>"u"||typeof document>"u")return;const e=[];function t(){if(s())for(const n of e)n()}const i=setInterval(t,1e3);e.push(()=>clearInterval(i)),document.readyState==="loading"&&(document.addEventListener("DOMContentLoaded",t,{once:!0}),e.push(()=>document.removeEventListener("DOMContentLoaded",t))),document.readyState!=="complete"&&(window.addEventListener("load",t,{once:!0}),e.push(()=>window.removeEventListener("load",t))),t()}function ui(s){return"version"in s}class $h extends yf{async sendTransaction(e,t,i={}){let r=!0;try{if(ui(e)){if(!this.supportedTransactionVersions)throw new rr("Sending versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(e.version))throw new rr(`Sending transaction version ${e.version} isn't supported by this wallet`);try{e=await this.signTransaction(e);const n=e.serialize();return await t.sendRawTransaction(n,i)}catch(n){throw n instanceof rt?(r=!1,n):new rr(n==null?void 0:n.message,n)}}else try{const{signers:n,...o}=i;e=await this.prepareTransaction(e,t,o),n!=null&&n.length&&e.partialSign(...n),e=await this.signTransaction(e);const a=e.serialize();return await t.sendRawTransaction(a,o)}catch(n){throw n instanceof rt?(r=!1,n):new rr(n==null?void 0:n.message,n)}}catch(n){throw r&&this.emit("error",n),n}}async signAllTransactions(e){for(const i of e)if(ui(i)){if(!this.supportedTransactionVersions)throw new rt("Signing versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(i.version))throw new rt(`Signing transaction version ${i.version} isn't supported by this wallet`)}const t=[];for(const i of e)t.push(await this.signTransaction(i));return t}}class Uo extends $h{}const Pi="solana:signAndSendTransaction",xc="solana:signIn",Ln="solana:signMessage",Mt="solana:signTransaction",wf="standard:connect",$u="standard:disconnect",mf="standard:events";function Gb(s){return wf in s.features&&mf in s.features&&(Pi in s.features||Mt in s.features)}var Ao;(function(s){s.Mainnet="mainnet-beta",s.Testnet="testnet",s.Devnet="devnet"})(Ao||(Ao={}));const Yb="Bitget";class Qb extends Uo{constructor(e={}){super(),this.name=Yb,this.url="https://web3.bitget.com",this.icon="data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIHdpZHRoPSIyNTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxmaWx0ZXIgaWQ9ImEiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiIgZmlsdGVyVW5pdHM9InVzZXJTcGFjZU9uVXNlIiBoZWlnaHQ9IjQ1MS40MzEiIHdpZHRoPSI1NjkuNTU4IiB4PSItOTAuMjQxMSIgeT0iLTY5LjczNjkiPjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+PGZlQmxlbmQgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iQmFja2dyb3VuZEltYWdlRml4IiBtb2RlPSJub3JtYWwiIHJlc3VsdD0ic2hhcGUiLz48ZmVHYXVzc2lhbkJsdXIgcmVzdWx0PSJlZmZlY3QxX2ZvcmVncm91bmRCbHVyXzIwMzVfMTEwNiIgc3RkRGV2aWF0aW9uPSI0OS4yMzA4Ii8+PC9maWx0ZXI+PGZpbHRlciBpZD0iYiIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGhlaWdodD0iMzcxLjUwNyIgd2lkdGg9IjM1MS41OTYiIHg9Ii0xNjAuNTExIiB5PSItMTY1Ljk4NyI+PGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz48ZmVCbGVuZCBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIG1vZGU9Im5vcm1hbCIgcmVzdWx0PSJzaGFwZSIvPjxmZUdhdXNzaWFuQmx1ciByZXN1bHQ9ImVmZmVjdDFfZm9yZWdyb3VuZEJsdXJfMjAzNV8xMTA2IiBzdGREZXZpYXRpb249IjQ5LjIzMDgiLz48L2ZpbHRlcj48ZmlsdGVyIGlkPSJjIiBjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM9InNSR0IiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaGVpZ2h0PSI0MjQuNDUyIiB3aWR0aD0iNDQ0Ljg1MSIgeD0iLTI0MS4wNzgiIHk9IjY3LjY0MiI+PGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz48ZmVCbGVuZCBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIG1vZGU9Im5vcm1hbCIgcmVzdWx0PSJzaGFwZSIvPjxmZUdhdXNzaWFuQmx1ciByZXN1bHQ9ImVmZmVjdDFfZm9yZWdyb3VuZEJsdXJfMjAzNV8xMTA2IiBzdGREZXZpYXRpb249IjQ5LjIzMDgiLz48L2ZpbHRlcj48ZmlsdGVyIGlkPSJkIiBjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM9InNSR0IiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaGVpZ2h0PSIzODUuMTA1IiB3aWR0aD0iNDMwLjE5MSIgeD0iLTIwLjM5NjgiIHk9Ii0yNDIuNzU4Ij48ZmVGbG9vZCBmbG9vZC1vcGFjaXR5PSIwIiByZXN1bHQ9IkJhY2tncm91bmRJbWFnZUZpeCIvPjxmZUJsZW5kIGluPSJTb3VyY2VHcmFwaGljIiBpbjI9IkJhY2tncm91bmRJbWFnZUZpeCIgbW9kZT0ibm9ybWFsIiByZXN1bHQ9InNoYXBlIi8+PGZlR2F1c3NpYW5CbHVyIHJlc3VsdD0iZWZmZWN0MV9mb3JlZ3JvdW5kQmx1cl8yMDM1XzExMDYiIHN0ZERldmlhdGlvbj0iNDkuMjMwOCIvPjwvZmlsdGVyPjxjbGlwUGF0aCBpZD0iZSI+PHBhdGggZD0ibTAgMGgyNTZ2MjU2aC0yNTZ6Ii8+PC9jbGlwUGF0aD48ZyBjbGlwLXBhdGg9InVybCgjZSkiPjxwYXRoIGQ9Im0wIDBoMjU2djI1NmgtMjU2eiIgZmlsbD0iIzU0ZmZmNSIvPjxnIGZpbHRlcj0idXJsKCNhKSI+PHBhdGggZD0ibTEzLjQ4MDYgMTk4LjYwNWMtNDIuODA4MiAxMjAuNDM4IDE4Ni4xODA0IDg2LjQyMiAzMDYuMDI2NCA1NC4zNTkgMTIyLjY1OC00MC43MDUgMzcuODc5LTIyMC4xMzcxLTUwLjA5Mi0yMjQuMTA4Mi04Ny45NzItMy45NzExIDEwLjkwNyA4Mi45NjgyLTYzLjgyIDEwNy44MDAyLTc0LjcyNyAyNC44MzEtMTM4LjYwNDMtODguNTk3Ny0xOTIuMTE0NCA2MS45NDl6IiBmaWxsPSIjZmZmIi8+PC9nPjxnIGZpbHRlcj0idXJsKCNiKSI+PHBhdGggZD0ibTg1LjUxMTgtNDUuODIyNWMtMjIuNDU1Ni02MS4zNTM1LTEwMi40MzA3IDIxLjgyNzItMTM5LjYxMTMgNzEuMDg2OC0zNS40NjU3IDUzLjU4MzYgNTcuMTA4ODcgOTkuODg3NyA5My40MjAzIDc0Ljc3MjcgMzYuMzExNS0yNS4xMTQzLTMxLjU0NjMyLTMwLjAwMDctOS45NS02Mi42NTg1IDIxLjU5NjMtMzIuNjU3NzQgODQuMjEwMi02LjUwOSA1Ni4xNDEtODMuMjAxeiIgZmlsbD0iIzAwZmZmMCIgZmlsbC1vcGFjaXR5PSIuNjciLz48L2c+PGcgZmlsdGVyPSJ1cmwoI2MpIj48cGF0aCBkPSJtOTYuNDc5NiAyMjUuNDI0Yy0zMC42Mjk0LTEwMy4wNjEtMTYyLjU2MTQtNDguNzg3LTIyNC42OTg2LTguNzY3LTU5Ljc3MSA0Ny4zODUgODIuMTQ3OSAxODMuNjkxIDE0MS4wOTE1IDE3Ni43MTkgNTguOTQzNi02Ljk3My00Ny4yODQzLTY2LjMxMS0xMC44ODU0OC05NS4yMDYgMzYuMzk4NzgtMjguODk0IDEzMi43Nzg5OCA1Ni4wNzkgOTQuNDkyNTgtNzIuNzQ2eiIgZmlsbD0iIzlkODFmZiIvPjwvZz48ZyBmaWx0ZXI9InVybCgjZCkiPjxwYXRoIGQ9Im0yODIuMTItMTA3LjM1M2MtNjYuMDczLTc4LjY3OC0xNjAuNjU3LTEzLjYxNy0xOTkuNjkwNCAyOC43NDgzLTM0LjE1NTcgNDcuOTYwMSAxNDEuODQ1NCAxMzUuODM1OSAxOTAuNjkxNCAxMjAuNzc2MSA0OC44NDctMTUuMDU5OS02Ni42MDktNDYuMjIxNzgtNDUuODI0LTc1LjQ1OTMgMjAuNzg1LTI5LjIzNzYgMTM3LjQxNSAyNC4yODIyNCA1NC44MjMtNzQuMDY1MXoiIGZpbGw9IiM0ZDk0ZmYiLz48L2c+PHBhdGggY2xpcC1ydWxlPSJldmVub2RkIiBkPSJtOTMuMTg5IDE1Mi44MzZoNDMuNDg1bC00OS40NjU0LTQ5Ljc4NSA1MC4xMDE0LTQ5Ljc4NDcgMTMuNjQ1LTEzLjI2NjNoLTQ1LjEzNmwtNTcuNDgzMSA1Ny43NzczYy0yLjkwMSAyLjkxMTctMi44ODYxIDcuNjI0Ny4wMjk3IDEwLjUyMTd6bTI2LjE0MS00OS42NjhoLS4zMzVsLjMzMS0uMDA0em0wIDAgNDkuNDYxIDQ5Ljc4MS01MC4xMDEgNDkuNzg1LTEzLjY0NSAxMy4yNjZoNDUuMTM1bDU3LjQ4NC01Ny43NzRjMi45MDEtMi45MTIgMi44ODYtNy42MjQtLjAzLTEwLjUyMWwtNDQuODIzLTQ0LjUzN3oiIGZpbGw9IiMwMDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ge.Unsupported&&Ro(()=>{var t,i;return(i=(t=window.bitkeep)==null?void 0:t.solana)!=null&&i.isBitKeep?(this._readyState=ge.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Installed)throw new Li;this._connecting=!0;const e=window.bitkeep.solana;let t;try{t=await e.getAccount()}catch(r){throw new Ns(r==null?void 0:r.message,r)}let i;try{i=new A.PublicKey(t)}catch(r){throw new yr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(t){this.emit("error",new ko(t==null?void 0:t.message,t))}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signTransaction(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signAllTransactions(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Ge;try{const{signature:i}=await t.signMessage(e);return i}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const Zb="Clover";class Jb extends Uo{constructor(e={}){super(),this.name=Zb,this.url="https://clv.org",this.icon="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTM2LjQ4IDBIMTEuNTJDNS4xNTc2OCAwIDAgNS4xNTc2OCAwIDExLjUyVjM2LjQ4QzAgNDIuODQyMyA1LjE1NzY4IDQ4IDExLjUyIDQ4SDM2LjQ4QzQyLjg0MjMgNDggNDggNDIuODQyMyA0OCAzNi40OFYxMS41MkM0OCA1LjE1NzY4IDQyLjg0MjMgMCAzNi40OCAwWiIgZmlsbD0idXJsKCNwYWludDBfbGluZWFyXzc5MTBfMTYzMzUxKSIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTI0LjAwMDYgMzkuMzYwNkMzMi40ODM3IDM5LjM2MDYgMzkuMzYwNiAzMi40ODM3IDM5LjM2MDYgMjQuMDAwNkMzOS4zNjA2IDE1LjUxNzUgMzIuNDgzNyA4LjY0MDYyIDI0LjAwMDYgOC42NDA2MkMxNS41MTc1IDguNjQwNjIgOC42NDA2MiAxNS41MTc1IDguNjQwNjIgMjQuMDAwNkM4LjY0MDYyIDMyLjQ4MzcgMTUuNTE3NSAzOS4zNjA2IDI0LjAwMDYgMzkuMzYwNlpNMjEuMjg5OSAxNS44Njg4SDI2LjcxMVYyMS4zNDdIMjEuMjkwNFYyNi42NTRIMjYuNzExVjMyLjEzMjJIMjEuMjg5OVYyNi44MjUySDE1Ljg2OTNWMjEuMzQ3SDIxLjI4OTlWMTUuODY4OFpNMjYuNzEyIDIxLjM0N0gzMi4xMzMxVjI2LjgyNTJIMjYuNzEyVjIxLjM0N1oiIGZpbGw9ImJsYWNrIi8+CjxkZWZzPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfNzkxMF8xNjMzNTEiIHgxPSI0OCIgeTE9Ii0xLjQzMDUxZS0wNiIgeDI9IjEuNDMwNTFlLTA2IiB5Mj0iNDgiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0E5RkZFMCIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM4NkQ1RkYiLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4=",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ge.Unsupported&&Ro(()=>{var t;return(t=window.clover_solana)!=null&&t.isCloverWallet?(this._readyState=ge.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Installed)throw new Li;this._connecting=!0;const e=window.clover_solana;let t;try{t=await e.getAccount()}catch(r){throw new Ns(r==null?void 0:r.message,r)}let i;try{i=new A.PublicKey(t)}catch(r){throw new yr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){this._wallet&&(this._wallet=null,this._publicKey=null),this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signTransaction(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signAllTransactions(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Ge;try{const{signature:i}=await t.signMessage(e);return Uint8Array.from(i)}catch(i){throw new jo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}function Xb(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let l=0;l<e.length;l++)e[l]=255;for(let l=0;l<s.length;l++){const h=s.charAt(l),d=h.charCodeAt(0);if(e[d]!==255)throw new TypeError(h+" is ambiguous");e[d]=l}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";let h=0,d=0,p=0;const f=l.length;for(;p!==f&&l[p]===0;)p++,h++;const g=(f-p)*n+1>>>0,y=new Uint8Array(g);for(;p!==f;){let w=l[p],N=0;for(let _=g-1;(w!==0||N<d)&&_!==-1;_--,N++)w+=256*y[_]>>>0,y[_]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");d=N,p++}let v=g-d;for(;v!==g&&y[v]===0;)v++;let b=i.repeat(h);for(;v<g;++v)b+=s.charAt(y[v]);return b}function a(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;let h=0,d=0,p=0;for(;l[h]===i;)d++,h++;const f=(l.length-h)*r+1>>>0,g=new Uint8Array(f);for(;h<l.length;){const w=l.charCodeAt(h);if(w>255)return;let N=e[w];if(N===255)return;let _=0;for(let C=f-1;(N!==0||_<p)&&C!==-1;C--,_++)N+=t*g[C]>>>0,g[C]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");p=_,h++}let y=f-p;for(;y!==f&&g[y]===0;)y++;const v=new Uint8Array(d+(f-y));let b=d;for(;y!==f;)v[b++]=g[y++];return v}function c(l){const h=a(l);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var ev="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Oc=Xb(ev),tv="Coin98";class sv extends Uo{constructor(e={}){super(),this.name=tv,this.url="https://coin98.com",this.icon="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA3NiA3NSI+CiAgPGRlZnM+CiAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImEiIHgxPSIxMDEuNjgxJSIgeDI9Ii0xLjU1NyUiIHkxPSIxNS4yNjglIiB5Mj0iODQuOTE3JSI+CiAgICAgIDxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiNGMUQ5NjEiLz4KICAgICAgPHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjQ0RBMTQ2Ii8+CiAgICA8L2xpbmVhckdyYWRpZW50PgogIDwvZGVmcz4KICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgPHJlY3Qgd2lkdGg9Ijc1IiBoZWlnaHQ9Ijc1IiBmaWxsPSIjMDAwIiByeD0iMTYiLz4KICAgIDxwYXRoIGZpbGw9InVybCgjYSkiIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTYxLjQ0IDBhMTMuNzE0IDEzLjcxNCAwIDAgMSA5LjY4IDQuMDEgMTMuNjYxIDEzLjY2MSAwIDAgMSA0LjAwOCA5LjY2OHY0Ny42NDZhMTMuNjYgMTMuNjYgMCAwIDEtNC4wMDcgOS42NjZBMTMuNzEzIDEzLjcxMyAwIDAgMSA2MS40NCA3NUgxMy42ODZhMTMuNzEzIDEzLjcxMyAwIDAgMS05LjY4LTQuMDFBMTMuNjYgMTMuNjYgMCAwIDEgMCA2MS4zMjRWMTMuNjc4YzAtMy42MjUgMS40NC03LjEwMiA0LjAwNy05LjY2N0ExMy43MTQgMTMuNzE0IDAgMCAxIDEzLjY4NyAwWk0yMC4wNjMgNDYuMjMxaC00LjgyNWExMC4wMzIgMTAuMDMyIDAgMCAwIDIuOTQ2IDcuMDg2IDEwLjA3IDEwLjA3IDAgMCAwIDcuMSAyLjk0MiAxMC4wNjUgMTAuMDY1IDAgMCAwIDcuMTA4LTIuOTM1IDEwLjAzIDEwLjAzIDAgMCAwIDIuOTQ2LTcuMDkzaC00LjgyNGE1LjIwNyA1LjIwNyAwIDAgMS0xLjUzIDMuNjg4IDUuMjI1IDUuMjI1IDAgMCAxLTMuNjk2IDEuNTI4IDUuMjM0IDUuMjM0IDAgMCAxLTMuNjk1LTEuNTI4IDUuMjEzIDUuMjEzIDAgMCAxLTEuNTMtMy42ODhaTTU0LjMzIDMzLjcxNmExMS43NjMgMTEuNzYzIDAgMCAwLTEyLjc5OSAyLjUzOEExMS42OTcgMTEuNjk3IDAgMCAwIDM4Ljk5IDQ5LjAzYTExLjcyMyAxMS43MjMgMCAwIDAgNC4zMjggNS4yNTkgMTEuNzU3IDExLjc1NyAwIDAgMCA2LjUyNiAxLjk3IDExLjc2NiAxMS43NjYgMCAwIDAgOC4yOS0zLjQzNSAxMS43MiAxMS43MiAwIDAgMCAzLjQ0Mi04LjI3NCAxMS43MDIgMTEuNzAyIDAgMCAwLTEuOTc1LTYuNTE0IDExLjczNiAxMS43MzYgMCAwIDAtNS4yNjktNC4zMlptLTQuNDg4IDMuOTJhNi45MzcgNi45MzcgMCAwIDEgNC45IDIuMDI1IDYuOTEgNi45MSAwIDAgMSAyLjAyOCA0Ljg5MiA2Ljg5NyA2Ljg5NyAwIDAgMS0xLjE3IDMuODM0IDYuOTMyIDYuOTMyIDAgMCAxLTEwLjY0MyAxLjA0MiA2LjkwMiA2LjkwMiAwIDAgMS0xLjUtNy41MjIgNi45MDkgNi45MDkgMCAwIDEgMi41NDQtMy4xIDYuOTI4IDYuOTI4IDAgMCAxIDMuODQxLTEuMTY3Wm0uMTcgNC41NTJhMi40MzEgMi40MzEgMCAwIDAtMi4yNDEgMS4xNTQgMi40MTggMi40MTggMCAwIDAtLjM1NiAxLjI1NyAyLjM5NSAyLjM5NSAwIDAgMCAxLjYxOSAyLjI5djEuNzUzaDEuNjE4di0xLjc1NGEyLjQyNyAyLjQyNyAwIDAgMCAxLjU5NC0xLjk1IDIuNDE4IDIuNDE4IDAgMCAwLTEtMi4zMSAyLjQzMSAyLjQzMSAwIDAgMC0xLjIzNC0uNDRabS0yMC4yMi0yMi41NTJhMTEuNzYyIDExLjc2MiAwIDAgMC0xMi43OTYgMi41MzEgMTEuNjk3IDExLjY5NyAwIDAgMC0yLjU1NCAxMi43NjkgMTEuNzIzIDExLjcyMyAwIDAgMCA0LjMyIDUuMjYyIDExLjc1NyAxMS43NTcgMCAwIDAgMTQuODI1LTEuNDQ2IDExLjcxNyAxMS43MTcgMCAwIDAgMy40NDUtOC4yODQgMTEuNzAzIDExLjcwMyAwIDAgMC0xLjk3NC02LjUxMiAxMS43MzYgMTEuNzM2IDAgMCAwLTUuMjY2LTQuMzJabS00LjUxIDMuOTE3YTYuOTQ1IDYuOTQ1IDAgMCAxIDQuODk3IDIuMDI5IDYuOTE4IDYuOTE4IDAgMCAxIDIuMDMyIDQuODg2IDYuOTA2IDYuOTA2IDAgMCAxLTEuMTY4IDMuODQyIDYuOTQgNi45NCAwIDAgMS0xMC42NiAxLjA0OCA2LjkxMSA2LjkxMSAwIDAgMS0xLjUtNy41MzYgNi45MTggNi45MTggMCAwIDEgMi41NS0zLjEwMyA2LjkzNyA2LjkzNyAwIDAgMSAzLjg1LTEuMTY2Wm0yNC41Ni00LjgxYTEwLjA1OSAxMC4wNTkgMCAwIDAtNy4xMDMgMi45NCAxMC4wMiAxMC4wMiAwIDAgMC0yLjk0IDcuMDkgOS45IDkuOSAwIDAgMCAxLjIzIDQuNzk1IDEzLjU3NSAxMy41NzUgMCAwIDEgNC4yMTQtMi4zMjIgNS4wODIgNS4wODIgMCAwIDEtLjYyNS0yLjQ3NyA1LjIwNiA1LjIwNiAwIDAgMSAxLjUwMy0zLjczNiA1LjIyMyA1LjIyMyAwIDAgMSAzLjcyMi0xLjU1NCA1LjIzNCA1LjIzNCAwIDAgMSAzLjcyIDEuNTU0IDUuMjEzIDUuMjEzIDAgMCAxIDEuNTA1IDMuNzM2IDUuMjc5IDUuMjc5IDAgMCAxLS42MjMgMi40NzMgMTMuNTc0IDEzLjU3NCAwIDAgMSA0LjIxMyAyLjMyMiA5LjkwMyA5LjkwMyAwIDAgMCAxLjIzLTQuNzk1IDEwLjAzMiAxMC4wMzIgMCAwIDAtMi45NDYtNy4wODYgMTAuMDcgMTAuMDcgMCAwIDAtNy4xLTIuOTRabS0yMy43NSA3Ljk5aC0xLjYxN3YxLjc1YTIuNDE5IDIuNDE5IDAgMCAwLTEuNTgyIDIuNjg3IDIuNDE0IDIuNDE0IDAgMCAwIDIuMzkgMi4wMDYgMi40NSAyLjQ1IDAgMCAwIDEuNTU1LS41NzQgMi40MTQgMi40MTQgMCAwIDAtLjc0Ni00LjExOXYtMS43NVoiLz4KICA8L2c+Cjwvc3ZnPgo=",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ge.Unsupported&&Ro(()=>{var t;return(t=window.coin98)!=null&&t.sol?(this._readyState=ge.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get connected(){var e;return!!((e=this._wallet)!=null&&e.isConnected())}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Installed)throw new Li;this._connecting=!0;const e=window.coin98.sol;let t;try{t=(await e.connect())[0]}catch(r){throw new Ns(r==null?void 0:r.message,r)}let i;try{i=new A.PublicKey(t)}catch(r){throw new yr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(t){this.emit("error",new ko(t==null?void 0:t.message,t))}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Ge;try{const i=await t.request({method:"sol_sign",params:[e]}),r=new A.PublicKey(i.publicKey),n=Oc.decode(i.signature);return e.addSignature(r,A.dist.Buffer.from(n)),e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Ge;try{const i=await t.request({method:"sol_signAllTransactions",params:[e]}),r=new A.PublicKey(i.publicKey),n=i.signatures;return e.map((o,a)=>{const c=Oc.decode(n[a]);return o.addSignature(r,A.dist.Buffer.from(c)),o})}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Ge;try{const i=await t.request({method:"sol_signMessage",params:[e]});return Oc.decode(i.signature)}catch(i){throw new jo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const iv="Nightly";class rv extends Uo{constructor(){super(),this.name=iv,this.url="https://nightly.app",this.icon="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOTYiIGhlaWdodD0iOTYiIHZpZXdCb3g9IjAgMCA5NiA5NiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTQ4IDk2Qzc0LjUwOTcgOTYgOTYgNzQuNTA5NyA5NiA0OEM5NiAyMS40OTAzIDc0LjUwOTcgMCA0OCAwQzIxLjQ5MDMgMCAwIDIxLjQ5MDMgMCA0OEMwIDc0LjUwOTcgMjEuNDkwMyA5NiA0OCA5NloiIGZpbGw9IiM2RDczRjgiLz4KPHBhdGggZD0iTTQ4IDg1LjYzNTZDNDggODUuNjM1NiA1Mi40NTMzIDg1LjYzNTYgNTUuNDQgODIuNTg2N0M1OC45MTU1IDc5LjI4MDEgNTcuMzUxMSA3NS40MzEyIDYyLjI3NTUgNzEuNDMxMkM2Ni45ODY2IDY3LjY0NDUgNzIuOTI0NCA3MC4zMzc5IDcyLjkyNDQgNzAuMzM3OUM3Ny4wMjIyIDYyLjEyNDUgNzQuNzkxMSA1Mi41NjkgNzQuNzkxMSA1Mi41NjlDODEuNzY4OCAzNC4yNTc5IDc1Ljk2NDQgMjEuMTU1NyA3NC40NDQ0IDE3LjM2MDFDNjkuNDQ4OCAyNC4zMzc5IDYzLjE5MTEgMjkuMTczNCA1NS43OTU1IDMyLjQwOUM1My4yMjY2IDMxLjcwNjggNTAuNTk1NSAzMS4zMzM0IDQ4IDMxLjM2MDFDNDUuNDEzMyAzMS4zMzM0IDQyLjc3MzMgMzEuNzA2OCA0MC4yMDQ0IDMyLjQwOUMzMi44MTc3IDI5LjE2NDUgMjYuNTUxMSAyNC4zMzc5IDIxLjU1NTUgMTcuMzYwMUMyMC4wMzU1IDIxLjE1NTcgMTQuMjMxMSAzNC4yNTc5IDIxLjIwODkgNTIuNTY5QzIxLjIwODkgNTIuNTY5IDE4Ljk3NzggNjIuMTI0NSAyMy4wNzU1IDcwLjMzNzlDMjMuMDc1NSA3MC4zMzc5IDI5LjAxMzMgNjcuNjQ0NSAzMy43MjQ0IDcxLjQzMTJDMzguNjU3NyA3NS40MzEyIDM3LjA4NDQgNzkuMjgwMSA0MC41NiA4Mi41ODY3QzQzLjU0NjYgODUuNjM1NiA0OCA4NS42MzU2IDQ4IDg1LjYzNTZaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNNDIuNDc5OSA2NS4yOThDNDIuMjkzMyA1OS4yMTggMzYuMzAyMSA1Ny4yNjI0IDMyLjIxMzMgNTkuODIyNEMzMi4yMTMzIDU5LjgyMjQgMzIuODUzMyA2Mi40MzU4IDM1LjgzOTkgNjMuNzUxM0MzOC4yNzU1IDY0LjgyNjkgMzkuMzI0NCA2My4zODY5IDQyLjQ3OTkgNjUuMjk4WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNMjIuNDk3NyAyMy4wOTM1QzIwLjA4ODggMzEuNTQ2OCAyMS4xMjg4IDQyLjI0MDIgMjQuOTMzMyA1MC4wMjY5QzI4LjgyNjYgNDcuMjcxMyAzMi45MTU1IDQzLjAxMzUgMzUuMDkzMyAzOC41MDY5QzI5Ljk2NDQgMzQuNzExMyAyNS42NjIyIDMxLjEwMjQgMjIuNDk3NyAyMy4wOTM1WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNNTMuNTE5OSA2NS4yOThDNTMuNzA2NiA1OS4yMTggNTkuNjk3NyA1Ny4yNjI0IDYzLjc4NjYgNTkuODIyNEM2My43ODY2IDU5LjgyMjQgNjMuMTQ2NiA2Mi40MzU4IDYwLjE1OTkgNjMuNzUxM0M1Ny43MjQzIDY0LjgyNjkgNTYuNjc1NSA2My4zODY5IDUzLjUxOTkgNjUuMjk4WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNNzMuNTAyMiAyMy4wOTM1Qzc1LjkxMTEgMzEuNTQ2OCA3NC44NzExIDQyLjI0MDIgNzEuMDY2NiA1MC4wMjY5QzY3LjE3MzMgNDcuMjcxMyA2My4wODQ0IDQzLjAxMzUgNjAuOTA2NiAzOC41MDY5QzY2LjAzNTUgMzQuNzExMyA3MC4zMzc3IDMxLjEwMjQgNzMuNTAyMiAyMy4wOTM1WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNNDcuOTk5OSA4NS4zMDY5QzUwLjE0MDQgODUuMzA2OSA1MS44NzU1IDgzLjc3ODcgNTEuODc1NSA4MS44OTM2QzUxLjg3NTUgODAuMDA4NCA1MC4xNDA0IDc4LjQ4MDIgNDcuOTk5OSA3OC40ODAyQzQ1Ljg1OTUgNzguNDgwMiA0NC4xMjQ0IDgwLjAwODQgNDQuMTI0NCA4MS44OTM2QzQ0LjEyNDQgODMuNzc4NyA0NS44NTk1IDg1LjMwNjkgNDcuOTk5OSA4NS4zMDY5WiIgZmlsbD0iIzdCODFGOSIvPgo8L3N2Zz4K",this.supportedTransactionVersions=new Set(["legacy",0]),this._readyState=typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.NotDetected,this._connecting=!1,this._publicKey=null,this._wallet=null,this._readyState!==ge.Unsupported&&Ro(()=>{var e;return(e=window==null?void 0:window.nightly)!=null&&e.solana?(this._readyState=ge.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get connecting(){return this._connecting}get readyState(){return this._readyState}get publicKey(){return this._publicKey}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Installed)throw new Li;this._connecting=!0;const e=window.nightly.solana;try{await e.connect()}catch(i){throw new cc(i==null?void 0:i.message,i)}if(e.publicKey.toString()==="11111111111111111111111111111111")throw new Ns;let t;try{t=new A.PublicKey(e.publicKey.toBytes())}catch(i){throw new yr(i==null?void 0:i.message,i)}this._wallet=e,this._publicKey=t,this.emit("connect",t)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch{this.emit("error",new ff)}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signTransaction(e)}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signAllTransactions(e)}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Ge;try{return t.signMessage(new TextDecoder().decode(e))}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const Mu="solana:mainnet",nv="solana:devnet",ov="solana:testnet",av="solana:localnet",cv="Solong";class lv extends $h{constructor(e={}){super(),this.name=cv,this.url="https://solongwallet.io",this.icon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAGlklEQVR4Ae3bA5DsyhfH8TNr49r2/du2bdu2bdu2zcdNrm3b9toz533rvctUn3Umk9p01WfdvVW/6nROBxJVS1rSkpa0pCUtaUlLWtKSpl4VXos3GJ4sujQFuUKfWl+qT730arzB8Ex9YksKcgXjFOCVeIPhBYydB8mawQ+yiGC8n0EN6zAVcgXhpQjoq1DDdsyDAAB9Pwo1HMC9INk0FIM8Bt1Qh9WohQQCvD+BtEMdtmC8I7y5aIE67MV0SBwDvB3qsE/UHwMJIpC/QB1OYiLEEeCPoQ7nMRcSwwDrao3Zl8aTIEGEUYlL0IAMXuQOr66UvsegDm+ExDJAPNiafSg0AlyIbmjAWX1aQzEkiH6T0QkNaEdpnAN8NNRhPcSF9e9el2ebBhyAuNBvGtLQgIuQOAd4D6jDMRQbM3AmOqEBDfq0xjJIEP3GohkakEFVjAP0y401sAsLnAE+pb6EsC5AA9J4sHsG+kX0PQR1eFJ8AwTWQh0+DjFm4a1Qh2/AOoz/BHX4ZdwD/CDU4aioX2GUMW+AOnB2bqiBBDHe86EOTYw5GRKJwQ/ijUM91OGTxgysxSmowzeNw7j08m5DHX4l7Igg2TY0g9hbLBZ+f7oxC98CdWjDvYzD+MVQh07GfEQsZyDgVWA71OGvorfnQQCAcqaYUFZDHW6j/itAoB70GcergzqsEa0rhGTTEA7mP0koK4xdyeOMmvBBhJU2zsjPMw7lu9O3zShpXheHk4hhcZ4w26AOG4RSxDiUfwZ12KdPqy+FBDHeV6EOZxizIg6HsMGbiQ5jdjzBXRfeefGg3tgbv9BYC0fhZE7sjUMY9Pf9rdcI5XtQh39BjBA/C3VYnM0zcgiDek+GOhzh93mQoMs7kIxze/eMhnxIEOPNM9bcFtTEeAb6I419axu/m2CsgxU4Aw1A/UxIUM/bO/9+cVkDDd5x42x8N1iH8Taow0NhHcZLoQ5Pi/MMzDMW+DTu7g6vIY9AdkAdHmaUMyn6roA6PD22AeLB6DbWplHG7LubfY+kfiIkiH5T0AJ1uFtMA1xUzOc1UIclzvCeXF+o7DygDlvds29RgVVzYj+K4xhgEX4NdcjgecE++rSL+ZdLmIxRB77Ose7l4XPIQB3eF8M60C/n8++ghltE/QLIFfqUiyUE8kOoYSW7jmLIFXeN4X0NaajDDlG/NG6XswrxKdxu+G/weh27j3wCej9uN9zEOjc3sObl4S243XBLhDfWE0mAMQjwZfhxDng7pG/8Sj4/ER/Gd/BdfBhPRGW2A/wxNAfcBOnFCHwZZ6GGs/gqapMAb/QEnIT20Uk8IQkQeB7aof3UihcM9wDvhyboANHXv1+IdWBOB2hsIftto+iSPEif8aGPcjrA50GHyPMiOIT9B/N5apaMgQT8D2poxMdwt8s+hkao4X9ZDxBTIdHwy/h8AeqQxhMhAU9BB9ThPMqHTYCYjU6owy3uPstSfL4Z6uZPC+Mk8gOomz8DEg3vXshAHb4MMXwZarhXGDPwa739w2j48623BPAniOFPUMPsMAL8INTw9AgDrLZOCmjFPEjA3WD1aUJVGAG+CGr4ECRCy6GGg3iyaF0+n/PwFByEGpaJ+qkw1sB7QA3/hUTozdBetFymvXhTWGVMOc7bp36/FhKRamNW9dcxZmpZiI+32ad+vAQSoWejGzpAXXh22Fek3wY1rDD2kVnijR3ExYQMPgkJOUB/nFW0Is3vnw6JhlHX9a4N70Iq/ACBv0MNu7J9WxHw7jaA2deFOtw32zeVHtHLWvMN0dtSkOzwS3spYy7iH1hx2d/wYdyTvnkR3BdeQjjerVBDN14JyZIfQWH5RC7e1rw32npZV54LCc+SPD5/HgqYD3WW5+gTqt6X+rA4v0701hRkKF0+bL+HTM9Hgv/MHH60wyvHWigsafwA1ZAhMguLoL34kbDcQEI1uAH8mcbuxPHImf8i5EMGxqvER9EI7cUqVMTl0Y6HoxHaBzvxNkyC9EEe7oEv4Sy0D/YQ+IS4ver1JNT38z7sWnwbb8TT8Cg8Gs/Gu/Ar7EEXtI/2ud7Ni0GAYCbiJDQiazA57k9nTcdqaJb9UtSvitXbmjavCJ9AMzRkJ/B80boUJBLhDe7Nw1/QCR1i9fgKRg6HByzvjZ/hInQQMjiCT2PSMHxC1a/l8wvwGxyG9kEaW/EtPI4xiiE5JcLrd6PxcLwM78SH8EG8Fc/H/UUXVUByGh8SSYBJgEmASYCJJMAkwBi6A3xCqZhiBz8+AAAAAElFTkSuQmCC",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ge.Unsupported&&Ro(()=>window.solong?(this._readyState=ge.Installed,this.emit("readyStateChange",this._readyState),!0):!1)}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get connected(){var e;return!!((e=this._wallet)!=null&&e.currentAccount)}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Installed)throw new Li;this._connecting=!0;const e=window.solong;let t;try{t=await e.selectAccount()}catch(r){throw new Ns(r==null?void 0:r.message,r)}let i;try{i=new A.PublicKey(t)}catch(r){throw new yr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){this._wallet&&(this._wallet=null,this._publicKey=null),this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signTransaction(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const hv="Torus";class uv extends Uo{constructor({params:e={showTorusButton:!1}}={params:{showTorusButton:!1}}){super(),this.name=hv,this.url="https://tor.us",this.icon="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzMiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMyAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYuNSIgY3k9IjE2IiByPSIxNiIgZmlsbD0iIzAzNjRGRiIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTExLjIxODYgOS40OTIxOUMxMC40NTM5IDkuNDkyMTkgOS44MzM5OCAxMC4xMTIxIDkuODMzOTggMTAuODc2OFYxMi40ODk4QzkuODMzOTggMTMuMjU0NSAxMC40NTM5IDEzLjg3NDQgMTEuMjE4NiAxMy44NzQ0SDEzLjY2ODRWMjIuODk3NkMxMy42Njg0IDIzLjY2MjMgMTQuMjg4MyAyNC4yODIyIDE1LjA1MyAyNC4yODIySDE2LjY2NkMxNy40MzA3IDI0LjI4MjIgMTguMDUwNiAyMy42NjIzIDE4LjA1MDYgMjIuODk3NlYxMi41MDE1QzE4LjA1MDYgMTIuNDk3NiAxOC4wNTA2IDEyLjQ5MzcgMTguMDUwNiAxMi40ODk4VjEwLjg3NjhDMTguMDUwNiAxMC4xMTIxIDE3LjQzMDcgOS40OTIxOSAxNi42NjYgOS40OTIxOUgxNS4wNTNIMTEuMjE4NloiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik0yMS4zMzc2IDEzLjg3NDRDMjIuNTQ3NyAxMy44NzQ0IDIzLjUyODcgMTIuODkzNCAyMy41Mjg3IDExLjY4MzNDMjMuNTI4NyAxMC40NzMyIDIyLjU0NzcgOS40OTIxOSAyMS4zMzc2IDkuNDkyMTlDMjAuMTI3NSA5LjQ5MjE5IDE5LjE0NjUgMTAuNDczMiAxOS4xNDY1IDExLjY4MzNDMTkuMTQ2NSAxMi44OTM0IDIwLjEyNzUgMTMuODc0NCAyMS4zMzc2IDEzLjg3NDRaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.Loadable,this._connecting=!1,this._wallet=null,this._publicKey=null,this._params=e}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get connected(){var e;return!!((e=this._wallet)!=null&&e.isLoggedIn)}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Loadable)throw new Li;this._connecting=!0;let e;try{e=(await Promise.resolve().then(()=>require("./solanaEmbed.esm-BKWwcEou.js"))).default}catch(n){throw new Vb(n==null?void 0:n.message,n)}let t;try{t=window.torus||new e}catch(n){throw new un(n==null?void 0:n.message,n)}if(!t.isInitialized)try{await t.init(this._params)}catch(n){throw new cc(n==null?void 0:n.message,n)}let i;try{i=await t.login()}catch(n){throw new Ns(n==null?void 0:n.message,n)}let r;try{r=new A.PublicKey(i[0])}catch(n){throw new yr(n==null?void 0:n.message,n)}this._wallet=t,this._publicKey=r,this.emit("connect",r)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{e.isLoggedIn&&await e.cleanUp()}catch(t){this.emit("error",new ko(t==null?void 0:t.message,t))}}this.emit("disconnect")}async sendTransaction(e,t,i={}){try{const r=this._wallet;if(!r)throw new Ge;try{const{signers:n,...o}=i;e=await this.prepareTransaction(e,t,o),n!=null&&n.length&&e.partialSign(...n),o.preflightCommitment=o.preflightCommitment||t.commitment;const{signature:a}=await r.signAndSendTransaction(e,o);return a}catch(n){throw n instanceof Dt?n:new rr(n==null?void 0:n.message,n)}}catch(r){throw this.emit("error",r),r}}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signTransaction(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signAllTransactions(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signMessage(e)}catch(i){throw new jo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}function Dc(s){switch(s){case"processed":case"confirmed":case"finalized":case void 0:return s;case"recent":return"processed";case"single":case"singleGossip":return"confirmed";case"max":case"root":return"finalized";default:return}}const dv="https://api.mainnet-beta.solana.com";function pv(s){return s.includes(dv)?Mu:/\bdevnet\b/i.test(s)?nv:/\btestnet\b/i.test(s)?ov:/\blocalhost\b/i.test(s)||/\b127\.0\.0\.1\b/.test(s)?av:Mu}var Ba;(function(s){s.Mainnet="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",s.Devnet="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",s.Deprecated_Mainnet="solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",s.Deprecated_Devnet="solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"})(Ba||(Ba={}));var Is;(function(s){s.signTransaction="solana_signTransaction",s.signMessage="solana_signMessage",s.signAndSendTransaction="solana_signAndSendTransaction",s.signAndSendAllTransactions="solana_signAndSendAllTransactions",s.signAllTransactions="solana_signAllTransactions"})(Is||(Is={}));const gt={Mainnet:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",Devnet:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",Deprecated_Mainnet:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",Deprecated_Devnet:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"};var gv=Object.defineProperty,fv=(s,e,t)=>e in s?gv(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,xu=(s,e,t)=>fv(s,typeof e!="symbol"?e+"":e,t);let yv=class extends u.IEvents{constructor(e){super(),this.opts=e,xu(this,"protocol","wc"),xu(this,"version",2)}};var wv=Object.defineProperty,mv=(s,e,t)=>e in s?wv(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,bv=(s,e,t)=>mv(s,e+"",t);let vv=class extends u.IEvents{constructor(e,t){super(),this.core=e,this.logger=t,bv(this,"records",new Map)}},Iv=class{constructor(e,t){this.logger=e,this.core=t}},Ev=class extends u.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}},Nv=class extends u.IEvents{constructor(e){super()}},Av=class{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}},_v=class extends u.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}},Cv=class extends u.IEvents{constructor(e,t){super(),this.core=e,this.logger=t}},Sv=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},Tv=class{constructor(e,t){this.projectId=e,this.logger=t}},Pv=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};function _o(s,{strict:e=!0}={}){return!s||typeof s!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(s):s.startsWith("0x")}function Ou(s){return _o(s,{strict:!1})?Math.ceil((s.length-2)/2):s.length}const bf="2.23.2";let zn={getDocsUrl:({docsBaseUrl:s,docsPath:e="",docsSlug:t})=>e?`${s??"https://viem.sh"}${e}${t?`#${t}`:""}`:void 0,version:`viem@${bf}`},lc=class Cl extends Error{constructor(e,t={}){var a;const i=(()=>{var c;return t.cause instanceof Cl?t.cause.details:(c=t.cause)!=null&&c.message?t.cause.message:t.details})(),r=t.cause instanceof Cl&&t.cause.docsPath||t.docsPath,n=(a=zn.getDocsUrl)==null?void 0:a.call(zn,{...t,docsPath:r}),o=[e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...i?[`Details: ${i}`]:[],...zn.version?[`Version: ${zn.version}`]:[]].join(`
2
- `);super(o,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=bf}walk(e){return vf(this,e)}};function vf(s,e){return e!=null&&e(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause!==void 0?vf(s.cause,e):e?null:s}let If=class extends lc{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}};function Sn(s,{dir:e,size:t=32}={}){return typeof s=="string"?$v(s,{dir:e,size:t}):Mv(s,{dir:e,size:t})}function $v(s,{dir:e,size:t=32}={}){if(t===null)return s;const i=s.replace("0x","");if(i.length>t*2)throw new If({size:Math.ceil(i.length/2),targetSize:t,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](t*2,"0")}`}function Mv(s,{dir:e,size:t=32}={}){if(t===null)return s;if(s.length>t)throw new If({size:s.length,targetSize:t,type:"bytes"});const i=new Uint8Array(t);for(let r=0;r<t;r++){const n=e==="right";i[n?r:t-r-1]=s[n?r:s.length-r-1]}return i}let xv=class extends lc{constructor({max:e,min:t,signed:i,size:r,value:n}){super(`Number "${n}" is not in safe ${r?`${r*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}},Ov=class extends lc{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function Tn(s,{size:e}){if(Ou(s)>e)throw new Ov({givenSize:Ou(s),maxSize:e})}function Sl(s,e={}){const{signed:t}=e;e.size&&Tn(s,{size:e.size});const i=BigInt(s);if(!t)return i;const r=(s.length-2)/2,n=(1n<<BigInt(r)*8n-1n)-1n;return i<=n?i:i-BigInt(`0x${"f".padStart(r*2,"f")}`)-1n}function Dv(s,e={}){return Number(Sl(s,e))}const kv=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function Tl(s,e={}){return typeof s=="number"||typeof s=="bigint"?Nf(s,e):typeof s=="string"?Uv(s,e):typeof s=="boolean"?jv(s,e):Ef(s,e)}function jv(s,e={}){const t=`0x${Number(s)}`;return typeof e.size=="number"?(Tn(t,{size:e.size}),Sn(t,{size:e.size})):t}function Ef(s,e={}){let t="";for(let r=0;r<s.length;r++)t+=kv[s[r]];const i=`0x${t}`;return typeof e.size=="number"?(Tn(i,{size:e.size}),Sn(i,{dir:"right",size:e.size})):i}function Nf(s,e={}){const{signed:t,size:i}=e,r=BigInt(s);let n;i?t?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof s=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&t?-n-1n:0;if(n&&r>n||r<o){const c=typeof s=="bigint"?"n":"";throw new xv({max:n?`${n}${c}`:void 0,min:`${o}${c}`,signed:t,size:i,value:`${s}${c}`})}const a=`0x${(t&&r<0?(1n<<BigInt(i*8))+BigInt(r):r).toString(16)}`;return i?Sn(a,{size:i}):a}const Rv=new TextEncoder;function Uv(s,e={}){const t=Rv.encode(s);return Ef(t,e)}const Lv=new TextEncoder;function zv(s,e={}){return typeof s=="number"||typeof s=="bigint"?qv(s,e):typeof s=="boolean"?Fv(s,e):_o(s)?Af(s,e):_f(s,e)}function Fv(s,e={}){const t=new Uint8Array(1);return t[0]=Number(s),typeof e.size=="number"?(Tn(t,{size:e.size}),Sn(t,{size:e.size})):t}const si={zero:48,nine:57,A:65,F:70,a:97,f:102};function Du(s){if(s>=si.zero&&s<=si.nine)return s-si.zero;if(s>=si.A&&s<=si.F)return s-(si.A-10);if(s>=si.a&&s<=si.f)return s-(si.a-10)}function Af(s,e={}){let t=s;e.size&&(Tn(t,{size:e.size}),t=Sn(t,{dir:"right",size:e.size}));let i=t.slice(2);i.length%2&&(i=`0${i}`);const r=i.length/2,n=new Uint8Array(r);for(let o=0,a=0;o<r;o++){const c=Du(i.charCodeAt(a++)),l=Du(i.charCodeAt(a++));if(c===void 0||l===void 0)throw new lc(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);n[o]=c*16+l}return n}function qv(s,e){const t=Nf(s,e);return Af(t)}function _f(s,e={}){const t=Lv.encode(s);return typeof e.size=="number"?(Tn(t,{size:e.size}),Sn(t,{dir:"right",size:e.size})):t}function Ha(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function Bv(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Lo(s,...e){if(!Bv(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function Hv(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ha(s.outputLen),Ha(s.blockLen)}function Pl(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function Cf(s,e){Lo(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const la=BigInt(2**32-1),ku=BigInt(32);function Wv(s,e=!1){return e?{h:Number(s&la),l:Number(s>>ku&la)}:{h:Number(s>>ku&la)|0,l:Number(s&la)|0}}function Vv(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=Wv(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const Kv=(s,e,t)=>s<<t|e>>>32-t,Gv=(s,e,t)=>e<<t|s>>>32-t,Yv=(s,e,t)=>e<<t-32|s>>>64-t,Qv=(s,e,t)=>s<<t-32|e>>>64-t,Ar=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Zv(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function Jv(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Xv(s,e){return s<<32-e|s>>>e}const ju=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function e0(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Ru(s){for(let e=0;e<s.length;e++)s[e]=e0(s[e])}function t0(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function Mh(s){return typeof s=="string"&&(s=t0(s)),Lo(s),s}function s0(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Lo(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}let Sf=class{clone(){return this._cloneInto()}};function Tf(s){const e=i=>s().update(Mh(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function i0(s=32){if(Ar&&typeof Ar.getRandomValues=="function")return Ar.getRandomValues(new Uint8Array(s));if(Ar&&typeof Ar.randomBytes=="function")return Ar.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const Pf=[],$f=[],Mf=[],r0=BigInt(0),Fn=BigInt(1),n0=BigInt(2),o0=BigInt(7),a0=BigInt(256),c0=BigInt(113);for(let s=0,e=Fn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],Pf.push(2*(5*i+t)),$f.push((s+1)*(s+2)/2%64);let r=r0;for(let n=0;n<7;n++)e=(e<<Fn^(e>>o0)*c0)%a0,e&n0&&(r^=Fn<<(Fn<<BigInt(n))-Fn);Mf.push(r)}const[l0,h0]=Vv(Mf,!0),Uu=(s,e,t)=>t>32?Yv(s,e,t):Kv(s,e,t),Lu=(s,e,t)=>t>32?Qv(s,e,t):Gv(s,e,t);function u0(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],d=Uu(l,h,1)^t[a],p=Lu(l,h,1)^t[a+1];for(let f=0;f<50;f+=10)s[o+f]^=d,s[o+f+1]^=p}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=$f[o],c=Uu(r,n,a),l=Lu(r,n,a),h=Pf[o];r=s[h],n=s[h+1],s[h]=c,s[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=l0[i],s[1]^=h0[i]}t.fill(0)}let d0=class xf extends Sf{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ha(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Zv(this.state)}keccak(){ju||Ru(this.state32),u0(this.state32,this.rounds),ju||Ru(this.state32),this.posOut=0,this.pos=0}update(e){Pl(this);const{blockLen:t,state:i}=this;e=Mh(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Pl(this,!1),Lo(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ha(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Cf(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new xf(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const p0=(s,e,t)=>Tf(()=>new d0(e,s,t)),g0=p0(1,136,256/8);function Of(s,e){const t=e||"hex",i=g0(_o(s,{strict:!1})?zv(s):s);return t==="bytes"?i:Tl(i)}let f0=class extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}};const kc=new f0(8192);function y0(s,e){if(kc.has(`${s}.${e}`))return kc.get(`${s}.${e}`);const t=s.substring(2).toLowerCase(),i=Of(_f(t),"bytes"),r=t.split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(i[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const n=`0x${r.join("")}`;return kc.set(`${s}.${e}`,n),n}function w0(s){const e=Of(`0x${s.substring(4)}`).substring(26);return y0(`0x${e}`)}async function m0({hash:s,signature:e}){const t=_o(s)?s:Tl(s),{secp256k1:i}=await Promise.resolve().then(()=>require("./secp256k1-BaYwfoJI.js"));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:l,s:h,v:d,yParity:p}=e,f=Number(p??d),g=zu(f);return new i.Signature(Sl(l),Sl(h)).addRecoveryBit(g)}const o=_o(e)?e:Tl(e),a=Dv(`0x${o.slice(130)}`),c=zu(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(t.substring(2)).toHex(!1)}`}function zu(s){if(s===0||s===1)return s;if(s===27)return 0;if(s===28)return 1;throw new Error("Invalid yParityOrV value")}async function b0({hash:s,signature:e}){return w0(await m0({hash:s,signature:e}))}var Df=oe.requireElliptic();const kf=":";function wn(s){const[e,t]=s.split(kf);return{namespace:e,reference:t}}function v0(s){const[e,t,i]=s.split(kf);return{namespace:e,reference:t,address:i}}function jf(s,e){return s.includes(":")?[s]:e.chains||[]}const I0="ReactNative",ls={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},E0="js";function Wa(){return typeof A.dist.process<"u"&&typeof A.dist.process.versions<"u"&&typeof A.dist.process.versions.node<"u"}function zi(){return!u.getDocument_1()&&!!u.getNavigator_1()&&navigator.product===I0}function N0(){return zi()&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Platform)<"u"&&(A.dist.global==null?void 0:A.dist.global.Platform.OS)==="android"}function A0(){return zi()&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Platform)<"u"&&(A.dist.global==null?void 0:A.dist.global.Platform.OS)==="ios"}function zo(){return!Wa()&&!!u.getNavigator_1()&&!!u.getDocument_1()}function Fo(){return zi()?ls.reactNative:Wa()?ls.node:zo()?ls.browser:ls.unknown}function Fu(){var s;try{return zi()&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Application)<"u"?(s=A.dist.global.Application)==null?void 0:s.applicationId:void 0}catch{return}}function _0(s,e){const t=new URLSearchParams(s);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const r=e[i];r!==void 0&&t.set(i,r)}return t.toString()}function Rf(){return u.getWindowMetadata_1()||{name:"",description:"",url:"",icons:[""]}}function C0(){if(Fo()===ls.reactNative&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Platform)<"u"){const{OS:t,Version:i}=A.dist.global.Platform;return[t,i].join("-")}const s=u.detect();if(s===null)return"unknown";const e=s.os?s.os.replace(" ","").toLowerCase():"unknown";return s.type==="browser"?[e,s.name,s.version].join("-"):[e,s.version].join("-")}function S0(){var s;const e=Fo();return e===ls.browser?[e,((s=u.getLocation_1())==null?void 0:s.host)||"unknown"].join(":"):e}function Uf(s,e,t){const i=C0(),r=S0();return[[s,e].join("-"),[E0,t].join("-"),i,r].join("/")}function T0({protocol:s,version:e,relayUrl:t,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=t.split("?"),h=Uf(s,e,i),d={auth:r,ua:h,projectId:n,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},p=_0(l[1]||"",d);return l[0]+"?"+p}function nr(s,e){return s.filter(t=>e.includes(t)).length===s.length}function Lf(s){return Object.fromEntries(s.entries())}function zf(s){return new Map(Object.entries(s))}function Zi(s=u.cjs.FIVE_MINUTES,e){const t=u.cjs.toMiliseconds(s||u.cjs.FIVE_MINUTES);let i,r,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&r&&(clearTimeout(n),r(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},t),i=a,r=c})}}function $i(s,e,t){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(t)),e);try{const o=await s;i(o)}catch(o){r(o)}clearTimeout(n)})}function Ff(s,e){if(typeof e=="string"&&e.startsWith(`${s}:`))return e;if(s.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(s.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${s}`)}function P0(s){return Ff("topic",s)}function $0(s){return Ff("id",s)}function qf(s){const[e,t]=s.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function dt(s,e){return u.cjs.fromMiliseconds(Date.now()+u.cjs.toMiliseconds(s))}function Ci(s){return Date.now()>=u.cjs.toMiliseconds(s)}function $e(s,e){return`${s}${e?`:${e}`:""}`}function Oa(s=[],e=[]){return[...new Set([...s,...e])]}async function M0({id:s,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const r=typeof t=="string"?JSON.parse(t):t,n=r==null?void 0:r.href;if(typeof n!="string")return;const o=x0(n,s,e),a=Fo();if(a===ls.browser){if(!((i=u.getDocument_1())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}O0(o)}else a===ls.reactNative&&typeof(A.dist.global==null?void 0:A.dist.global.Linking)<"u"&&await A.dist.global.Linking.openURL(o)}catch(r){console.error(r)}}function x0(s,e,t){const i=`requestId=${e}&sessionTopic=${t}`;s.endsWith("/")&&(s=s.slice(0,-1));let r=`${s}`;if(s.startsWith("https://t.me")){const n=s.includes("?")?"&startapp=":"?startapp=";r=`${r}${n}${R0(i,!0)}`}else r=`${r}/wc?${i}`;return r}function O0(s){let e="_self";j0()?e="_top":(k0()||s.startsWith("https://")||s.startsWith("http://"))&&(e="_blank"),window.open(s,e,"noreferrer noopener")}async function D0(s,e){let t="";try{if(zo()&&(t=localStorage.getItem(e),t))return t;t=await s.getItem(e)}catch(i){console.error(i)}return t}function qu(s,e){if(!s.includes(e))return null;const t=s.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Bu(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}function xh(){return typeof A.dist.process<"u"&&A.dist.process.env.IS_VITEST==="true"}function k0(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function j0(){try{return window.self!==window.top}catch{return!1}}function R0(s,e=!1){const t=A.dist.Buffer.from(s).toString("base64");return e?t.replace(/[=]/g,""):t}function Bf(s){return A.dist.Buffer.from(s,"base64").toString("utf-8")}function U0(s){return new Promise(e=>setTimeout(e,s))}function Co(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function L0(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function hc(s,...e){if(!L0(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function Oh(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Co(s.outputLen),Co(s.blockLen)}function In(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function Hf(s,e){hc(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const ha=BigInt(2**32-1),Hu=BigInt(32);function z0(s,e=!1){return e?{h:Number(s&ha),l:Number(s>>Hu&ha)}:{h:Number(s>>Hu&ha)|0,l:Number(s&ha)|0}}function F0(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=z0(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const q0=(s,e,t)=>s<<t|e>>>32-t,B0=(s,e,t)=>e<<t|s>>>32-t,H0=(s,e,t)=>e<<t-32|s>>>64-t,W0=(s,e,t)=>s<<t-32|e>>>64-t,_r=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function V0(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function jc(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function zs(s,e){return s<<32-e|s>>>e}const Wu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function K0(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Vu(s){for(let e=0;e<s.length;e++)s[e]=K0(s[e])}function G0(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function En(s){return typeof s=="string"&&(s=G0(s)),hc(s),s}let Dh=class{clone(){return this._cloneInto()}};function Wf(s){const e=i=>s().update(En(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function qo(s=32){if(_r&&typeof _r.getRandomValues=="function")return _r.getRandomValues(new Uint8Array(s));if(_r&&typeof _r.randomBytes=="function")return _r.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const Vf=[],Kf=[],Gf=[],Y0=BigInt(0),qn=BigInt(1),Q0=BigInt(2),Z0=BigInt(7),J0=BigInt(256),X0=BigInt(113);for(let s=0,e=qn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],Vf.push(2*(5*i+t)),Kf.push((s+1)*(s+2)/2%64);let r=Y0;for(let n=0;n<7;n++)e=(e<<qn^(e>>Z0)*X0)%J0,e&Q0&&(r^=qn<<(qn<<BigInt(n))-qn);Gf.push(r)}const[eI,tI]=F0(Gf,!0),Ku=(s,e,t)=>t>32?H0(s,e,t):q0(s,e,t),Gu=(s,e,t)=>t>32?W0(s,e,t):B0(s,e,t);function sI(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],d=Ku(l,h,1)^t[a],p=Gu(l,h,1)^t[a+1];for(let f=0;f<50;f+=10)s[o+f]^=d,s[o+f+1]^=p}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=Kf[o],c=Ku(r,n,a),l=Gu(r,n,a),h=Vf[o];r=s[h],n=s[h+1],s[h]=c,s[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=eI[i],s[1]^=tI[i]}t.fill(0)}let iI=class Yf extends Dh{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Co(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=V0(this.state)}keccak(){Wu||Vu(this.state32),sI(this.state32,this.rounds),Wu||Vu(this.state32),this.posOut=0,this.pos=0}update(e){In(this);const{blockLen:t,state:i}=this;e=En(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){In(this,!1),hc(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Co(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Hf(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new Yf(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const rI=(s,e,t)=>Wf(()=>new iI(e,s,t)),nI=rI(1,136,256/8),oI="https://rpc.walletconnect.org/v1";function Qf(s){const e=`Ethereum Signed Message:
1
+ "use strict";var qb=Object.defineProperty;var Bb=(s,e,t)=>e in s?qb(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var At=(s,e,t)=>Bb(s,typeof e!="symbol"?e+"":e,t);const A=require("./address-DpQlJQKV.js"),oe=require("./index-CBBfcDND.js"),Hb=require("./util-G2vxTeU2.js"),Wb=require("./wallets-5qGJd8Hk.js"),xa=require("./unsignedTransaction-D14ic9We.js"),Tu=require("./signer-D6-3r3Sp.js"),u=require("./index.es-BYFwv7lT.js"),k=require("./lit-element-Bij_rEQt.js");require("./browser-ponyfill-BeX4lPJd.js");const yn=require("./http-NcnC3Lp_.js");class Dt extends Error{constructor(e,t){super(e),this.error=t}}class Li extends Dt{constructor(){super(...arguments),this.name="WalletNotReadyError"}}class Vb extends Dt{constructor(){super(...arguments),this.name="WalletLoadError"}}class un extends Dt{constructor(){super(...arguments),this.name="WalletConfigError"}}class cc extends Dt{constructor(){super(...arguments),this.name="WalletConnectionError"}}class ff extends Dt{constructor(){super(...arguments),this.name="WalletDisconnectedError"}}class ko extends Dt{constructor(){super(...arguments),this.name="WalletDisconnectionError"}}class Ns extends Dt{constructor(){super(...arguments),this.name="WalletAccountError"}}class yr extends Dt{constructor(){super(...arguments),this.name="WalletPublicKeyError"}}class Ge extends Dt{constructor(){super(...arguments),this.name="WalletNotConnectedError"}}class rr extends Dt{constructor(){super(...arguments),this.name="WalletSendTransactionError"}}class rt extends Dt{constructor(){super(...arguments),this.name="WalletSignTransactionError"}}class jo extends Dt{constructor(){super(...arguments),this.name="WalletSignMessageError"}}class Pu extends Dt{constructor(){super(...arguments),this.name="WalletSignInError"}}class Kb extends Dt{constructor(){super(...arguments),this.name="WalletWindowClosedError"}}var ge;(function(s){s.Installed="Installed",s.NotDetected="NotDetected",s.Loadable="Loadable",s.Unsupported="Unsupported"})(ge||(ge={}));class yf extends A.EventEmitter{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,i={}){const r=this.publicKey;if(!r)throw new Ge;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:i.preflightCommitment,minContextSlot:i.minContextSlot})).blockhash,e}}function Ro(s){if(typeof window>"u"||typeof document>"u")return;const e=[];function t(){if(s())for(const n of e)n()}const i=setInterval(t,1e3);e.push(()=>clearInterval(i)),document.readyState==="loading"&&(document.addEventListener("DOMContentLoaded",t,{once:!0}),e.push(()=>document.removeEventListener("DOMContentLoaded",t))),document.readyState!=="complete"&&(window.addEventListener("load",t,{once:!0}),e.push(()=>window.removeEventListener("load",t))),t()}function ui(s){return"version"in s}class $h extends yf{async sendTransaction(e,t,i={}){let r=!0;try{if(ui(e)){if(!this.supportedTransactionVersions)throw new rr("Sending versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(e.version))throw new rr(`Sending transaction version ${e.version} isn't supported by this wallet`);try{e=await this.signTransaction(e);const n=e.serialize();return await t.sendRawTransaction(n,i)}catch(n){throw n instanceof rt?(r=!1,n):new rr(n==null?void 0:n.message,n)}}else try{const{signers:n,...o}=i;e=await this.prepareTransaction(e,t,o),n!=null&&n.length&&e.partialSign(...n),e=await this.signTransaction(e);const a=e.serialize();return await t.sendRawTransaction(a,o)}catch(n){throw n instanceof rt?(r=!1,n):new rr(n==null?void 0:n.message,n)}}catch(n){throw r&&this.emit("error",n),n}}async signAllTransactions(e){for(const i of e)if(ui(i)){if(!this.supportedTransactionVersions)throw new rt("Signing versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(i.version))throw new rt(`Signing transaction version ${i.version} isn't supported by this wallet`)}const t=[];for(const i of e)t.push(await this.signTransaction(i));return t}}class Uo extends $h{}const Pi="solana:signAndSendTransaction",xc="solana:signIn",Ln="solana:signMessage",Mt="solana:signTransaction",wf="standard:connect",$u="standard:disconnect",mf="standard:events";function Gb(s){return wf in s.features&&mf in s.features&&(Pi in s.features||Mt in s.features)}var Ao;(function(s){s.Mainnet="mainnet-beta",s.Testnet="testnet",s.Devnet="devnet"})(Ao||(Ao={}));const Yb="Bitget";class Qb extends Uo{constructor(e={}){super(),this.name=Yb,this.url="https://web3.bitget.com",this.icon="data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIHdpZHRoPSIyNTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxmaWx0ZXIgaWQ9ImEiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiIgZmlsdGVyVW5pdHM9InVzZXJTcGFjZU9uVXNlIiBoZWlnaHQ9IjQ1MS40MzEiIHdpZHRoPSI1NjkuNTU4IiB4PSItOTAuMjQxMSIgeT0iLTY5LjczNjkiPjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+PGZlQmxlbmQgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iQmFja2dyb3VuZEltYWdlRml4IiBtb2RlPSJub3JtYWwiIHJlc3VsdD0ic2hhcGUiLz48ZmVHYXVzc2lhbkJsdXIgcmVzdWx0PSJlZmZlY3QxX2ZvcmVncm91bmRCbHVyXzIwMzVfMTEwNiIgc3RkRGV2aWF0aW9uPSI0OS4yMzA4Ii8+PC9maWx0ZXI+PGZpbHRlciBpZD0iYiIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGhlaWdodD0iMzcxLjUwNyIgd2lkdGg9IjM1MS41OTYiIHg9Ii0xNjAuNTExIiB5PSItMTY1Ljk4NyI+PGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz48ZmVCbGVuZCBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIG1vZGU9Im5vcm1hbCIgcmVzdWx0PSJzaGFwZSIvPjxmZUdhdXNzaWFuQmx1ciByZXN1bHQ9ImVmZmVjdDFfZm9yZWdyb3VuZEJsdXJfMjAzNV8xMTA2IiBzdGREZXZpYXRpb249IjQ5LjIzMDgiLz48L2ZpbHRlcj48ZmlsdGVyIGlkPSJjIiBjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM9InNSR0IiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaGVpZ2h0PSI0MjQuNDUyIiB3aWR0aD0iNDQ0Ljg1MSIgeD0iLTI0MS4wNzgiIHk9IjY3LjY0MiI+PGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz48ZmVCbGVuZCBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIG1vZGU9Im5vcm1hbCIgcmVzdWx0PSJzaGFwZSIvPjxmZUdhdXNzaWFuQmx1ciByZXN1bHQ9ImVmZmVjdDFfZm9yZWdyb3VuZEJsdXJfMjAzNV8xMTA2IiBzdGREZXZpYXRpb249IjQ5LjIzMDgiLz48L2ZpbHRlcj48ZmlsdGVyIGlkPSJkIiBjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM9InNSR0IiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaGVpZ2h0PSIzODUuMTA1IiB3aWR0aD0iNDMwLjE5MSIgeD0iLTIwLjM5NjgiIHk9Ii0yNDIuNzU4Ij48ZmVGbG9vZCBmbG9vZC1vcGFjaXR5PSIwIiByZXN1bHQ9IkJhY2tncm91bmRJbWFnZUZpeCIvPjxmZUJsZW5kIGluPSJTb3VyY2VHcmFwaGljIiBpbjI9IkJhY2tncm91bmRJbWFnZUZpeCIgbW9kZT0ibm9ybWFsIiByZXN1bHQ9InNoYXBlIi8+PGZlR2F1c3NpYW5CbHVyIHJlc3VsdD0iZWZmZWN0MV9mb3JlZ3JvdW5kQmx1cl8yMDM1XzExMDYiIHN0ZERldmlhdGlvbj0iNDkuMjMwOCIvPjwvZmlsdGVyPjxjbGlwUGF0aCBpZD0iZSI+PHBhdGggZD0ibTAgMGgyNTZ2MjU2aC0yNTZ6Ii8+PC9jbGlwUGF0aD48ZyBjbGlwLXBhdGg9InVybCgjZSkiPjxwYXRoIGQ9Im0wIDBoMjU2djI1NmgtMjU2eiIgZmlsbD0iIzU0ZmZmNSIvPjxnIGZpbHRlcj0idXJsKCNhKSI+PHBhdGggZD0ibTEzLjQ4MDYgMTk4LjYwNWMtNDIuODA4MiAxMjAuNDM4IDE4Ni4xODA0IDg2LjQyMiAzMDYuMDI2NCA1NC4zNTkgMTIyLjY1OC00MC43MDUgMzcuODc5LTIyMC4xMzcxLTUwLjA5Mi0yMjQuMTA4Mi04Ny45NzItMy45NzExIDEwLjkwNyA4Mi45NjgyLTYzLjgyIDEwNy44MDAyLTc0LjcyNyAyNC44MzEtMTM4LjYwNDMtODguNTk3Ny0xOTIuMTE0NCA2MS45NDl6IiBmaWxsPSIjZmZmIi8+PC9nPjxnIGZpbHRlcj0idXJsKCNiKSI+PHBhdGggZD0ibTg1LjUxMTgtNDUuODIyNWMtMjIuNDU1Ni02MS4zNTM1LTEwMi40MzA3IDIxLjgyNzItMTM5LjYxMTMgNzEuMDg2OC0zNS40NjU3IDUzLjU4MzYgNTcuMTA4ODcgOTkuODg3NyA5My40MjAzIDc0Ljc3MjcgMzYuMzExNS0yNS4xMTQzLTMxLjU0NjMyLTMwLjAwMDctOS45NS02Mi42NTg1IDIxLjU5NjMtMzIuNjU3NzQgODQuMjEwMi02LjUwOSA1Ni4xNDEtODMuMjAxeiIgZmlsbD0iIzAwZmZmMCIgZmlsbC1vcGFjaXR5PSIuNjciLz48L2c+PGcgZmlsdGVyPSJ1cmwoI2MpIj48cGF0aCBkPSJtOTYuNDc5NiAyMjUuNDI0Yy0zMC42Mjk0LTEwMy4wNjEtMTYyLjU2MTQtNDguNzg3LTIyNC42OTg2LTguNzY3LTU5Ljc3MSA0Ny4zODUgODIuMTQ3OSAxODMuNjkxIDE0MS4wOTE1IDE3Ni43MTkgNTguOTQzNi02Ljk3My00Ny4yODQzLTY2LjMxMS0xMC44ODU0OC05NS4yMDYgMzYuMzk4NzgtMjguODk0IDEzMi43Nzg5OCA1Ni4wNzkgOTQuNDkyNTgtNzIuNzQ2eiIgZmlsbD0iIzlkODFmZiIvPjwvZz48ZyBmaWx0ZXI9InVybCgjZCkiPjxwYXRoIGQ9Im0yODIuMTItMTA3LjM1M2MtNjYuMDczLTc4LjY3OC0xNjAuNjU3LTEzLjYxNy0xOTkuNjkwNCAyOC43NDgzLTM0LjE1NTcgNDcuOTYwMSAxNDEuODQ1NCAxMzUuODM1OSAxOTAuNjkxNCAxMjAuNzc2MSA0OC44NDctMTUuMDU5OS02Ni42MDktNDYuMjIxNzgtNDUuODI0LTc1LjQ1OTMgMjAuNzg1LTI5LjIzNzYgMTM3LjQxNSAyNC4yODIyNCA1NC44MjMtNzQuMDY1MXoiIGZpbGw9IiM0ZDk0ZmYiLz48L2c+PHBhdGggY2xpcC1ydWxlPSJldmVub2RkIiBkPSJtOTMuMTg5IDE1Mi44MzZoNDMuNDg1bC00OS40NjU0LTQ5Ljc4NSA1MC4xMDE0LTQ5Ljc4NDcgMTMuNjQ1LTEzLjI2NjNoLTQ1LjEzNmwtNTcuNDgzMSA1Ny43NzczYy0yLjkwMSAyLjkxMTctMi44ODYxIDcuNjI0Ny4wMjk3IDEwLjUyMTd6bTI2LjE0MS00OS42NjhoLS4zMzVsLjMzMS0uMDA0em0wIDAgNDkuNDYxIDQ5Ljc4MS01MC4xMDEgNDkuNzg1LTEzLjY0NSAxMy4yNjZoNDUuMTM1bDU3LjQ4NC01Ny43NzRjMi45MDEtMi45MTIgMi44ODYtNy42MjQtLjAzLTEwLjUyMWwtNDQuODIzLTQ0LjUzN3oiIGZpbGw9IiMwMDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ge.Unsupported&&Ro(()=>{var t,i;return(i=(t=window.bitkeep)==null?void 0:t.solana)!=null&&i.isBitKeep?(this._readyState=ge.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Installed)throw new Li;this._connecting=!0;const e=window.bitkeep.solana;let t;try{t=await e.getAccount()}catch(r){throw new Ns(r==null?void 0:r.message,r)}let i;try{i=new A.PublicKey(t)}catch(r){throw new yr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(t){this.emit("error",new ko(t==null?void 0:t.message,t))}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signTransaction(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signAllTransactions(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Ge;try{const{signature:i}=await t.signMessage(e);return i}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const Zb="Clover";class Jb extends Uo{constructor(e={}){super(),this.name=Zb,this.url="https://clv.org",this.icon="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTM2LjQ4IDBIMTEuNTJDNS4xNTc2OCAwIDAgNS4xNTc2OCAwIDExLjUyVjM2LjQ4QzAgNDIuODQyMyA1LjE1NzY4IDQ4IDExLjUyIDQ4SDM2LjQ4QzQyLjg0MjMgNDggNDggNDIuODQyMyA0OCAzNi40OFYxMS41MkM0OCA1LjE1NzY4IDQyLjg0MjMgMCAzNi40OCAwWiIgZmlsbD0idXJsKCNwYWludDBfbGluZWFyXzc5MTBfMTYzMzUxKSIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTI0LjAwMDYgMzkuMzYwNkMzMi40ODM3IDM5LjM2MDYgMzkuMzYwNiAzMi40ODM3IDM5LjM2MDYgMjQuMDAwNkMzOS4zNjA2IDE1LjUxNzUgMzIuNDgzNyA4LjY0MDYyIDI0LjAwMDYgOC42NDA2MkMxNS41MTc1IDguNjQwNjIgOC42NDA2MiAxNS41MTc1IDguNjQwNjIgMjQuMDAwNkM4LjY0MDYyIDMyLjQ4MzcgMTUuNTE3NSAzOS4zNjA2IDI0LjAwMDYgMzkuMzYwNlpNMjEuMjg5OSAxNS44Njg4SDI2LjcxMVYyMS4zNDdIMjEuMjkwNFYyNi42NTRIMjYuNzExVjMyLjEzMjJIMjEuMjg5OVYyNi44MjUySDE1Ljg2OTNWMjEuMzQ3SDIxLjI4OTlWMTUuODY4OFpNMjYuNzEyIDIxLjM0N0gzMi4xMzMxVjI2LjgyNTJIMjYuNzEyVjIxLjM0N1oiIGZpbGw9ImJsYWNrIi8+CjxkZWZzPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfNzkxMF8xNjMzNTEiIHgxPSI0OCIgeTE9Ii0xLjQzMDUxZS0wNiIgeDI9IjEuNDMwNTFlLTA2IiB5Mj0iNDgiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0E5RkZFMCIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM4NkQ1RkYiLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4=",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ge.Unsupported&&Ro(()=>{var t;return(t=window.clover_solana)!=null&&t.isCloverWallet?(this._readyState=ge.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Installed)throw new Li;this._connecting=!0;const e=window.clover_solana;let t;try{t=await e.getAccount()}catch(r){throw new Ns(r==null?void 0:r.message,r)}let i;try{i=new A.PublicKey(t)}catch(r){throw new yr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){this._wallet&&(this._wallet=null,this._publicKey=null),this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signTransaction(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signAllTransactions(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Ge;try{const{signature:i}=await t.signMessage(e);return Uint8Array.from(i)}catch(i){throw new jo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}function Xb(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let l=0;l<e.length;l++)e[l]=255;for(let l=0;l<s.length;l++){const h=s.charAt(l),d=h.charCodeAt(0);if(e[d]!==255)throw new TypeError(h+" is ambiguous");e[d]=l}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";let h=0,d=0,p=0;const f=l.length;for(;p!==f&&l[p]===0;)p++,h++;const g=(f-p)*n+1>>>0,y=new Uint8Array(g);for(;p!==f;){let w=l[p],N=0;for(let _=g-1;(w!==0||N<d)&&_!==-1;_--,N++)w+=256*y[_]>>>0,y[_]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");d=N,p++}let v=g-d;for(;v!==g&&y[v]===0;)v++;let b=i.repeat(h);for(;v<g;++v)b+=s.charAt(y[v]);return b}function a(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;let h=0,d=0,p=0;for(;l[h]===i;)d++,h++;const f=(l.length-h)*r+1>>>0,g=new Uint8Array(f);for(;h<l.length;){const w=l.charCodeAt(h);if(w>255)return;let N=e[w];if(N===255)return;let _=0;for(let C=f-1;(N!==0||_<p)&&C!==-1;C--,_++)N+=t*g[C]>>>0,g[C]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");p=_,h++}let y=f-p;for(;y!==f&&g[y]===0;)y++;const v=new Uint8Array(d+(f-y));let b=d;for(;y!==f;)v[b++]=g[y++];return v}function c(l){const h=a(l);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var ev="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Oc=Xb(ev),tv="Coin98";class sv extends Uo{constructor(e={}){super(),this.name=tv,this.url="https://coin98.com",this.icon="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA3NiA3NSI+CiAgPGRlZnM+CiAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImEiIHgxPSIxMDEuNjgxJSIgeDI9Ii0xLjU1NyUiIHkxPSIxNS4yNjglIiB5Mj0iODQuOTE3JSI+CiAgICAgIDxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiNGMUQ5NjEiLz4KICAgICAgPHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjQ0RBMTQ2Ii8+CiAgICA8L2xpbmVhckdyYWRpZW50PgogIDwvZGVmcz4KICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgPHJlY3Qgd2lkdGg9Ijc1IiBoZWlnaHQ9Ijc1IiBmaWxsPSIjMDAwIiByeD0iMTYiLz4KICAgIDxwYXRoIGZpbGw9InVybCgjYSkiIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTYxLjQ0IDBhMTMuNzE0IDEzLjcxNCAwIDAgMSA5LjY4IDQuMDEgMTMuNjYxIDEzLjY2MSAwIDAgMSA0LjAwOCA5LjY2OHY0Ny42NDZhMTMuNjYgMTMuNjYgMCAwIDEtNC4wMDcgOS42NjZBMTMuNzEzIDEzLjcxMyAwIDAgMSA2MS40NCA3NUgxMy42ODZhMTMuNzEzIDEzLjcxMyAwIDAgMS05LjY4LTQuMDFBMTMuNjYgMTMuNjYgMCAwIDEgMCA2MS4zMjRWMTMuNjc4YzAtMy42MjUgMS40NC03LjEwMiA0LjAwNy05LjY2N0ExMy43MTQgMTMuNzE0IDAgMCAxIDEzLjY4NyAwWk0yMC4wNjMgNDYuMjMxaC00LjgyNWExMC4wMzIgMTAuMDMyIDAgMCAwIDIuOTQ2IDcuMDg2IDEwLjA3IDEwLjA3IDAgMCAwIDcuMSAyLjk0MiAxMC4wNjUgMTAuMDY1IDAgMCAwIDcuMTA4LTIuOTM1IDEwLjAzIDEwLjAzIDAgMCAwIDIuOTQ2LTcuMDkzaC00LjgyNGE1LjIwNyA1LjIwNyAwIDAgMS0xLjUzIDMuNjg4IDUuMjI1IDUuMjI1IDAgMCAxLTMuNjk2IDEuNTI4IDUuMjM0IDUuMjM0IDAgMCAxLTMuNjk1LTEuNTI4IDUuMjEzIDUuMjEzIDAgMCAxLTEuNTMtMy42ODhaTTU0LjMzIDMzLjcxNmExMS43NjMgMTEuNzYzIDAgMCAwLTEyLjc5OSAyLjUzOEExMS42OTcgMTEuNjk3IDAgMCAwIDM4Ljk5IDQ5LjAzYTExLjcyMyAxMS43MjMgMCAwIDAgNC4zMjggNS4yNTkgMTEuNzU3IDExLjc1NyAwIDAgMCA2LjUyNiAxLjk3IDExLjc2NiAxMS43NjYgMCAwIDAgOC4yOS0zLjQzNSAxMS43MiAxMS43MiAwIDAgMCAzLjQ0Mi04LjI3NCAxMS43MDIgMTEuNzAyIDAgMCAwLTEuOTc1LTYuNTE0IDExLjczNiAxMS43MzYgMCAwIDAtNS4yNjktNC4zMlptLTQuNDg4IDMuOTJhNi45MzcgNi45MzcgMCAwIDEgNC45IDIuMDI1IDYuOTEgNi45MSAwIDAgMSAyLjAyOCA0Ljg5MiA2Ljg5NyA2Ljg5NyAwIDAgMS0xLjE3IDMuODM0IDYuOTMyIDYuOTMyIDAgMCAxLTEwLjY0MyAxLjA0MiA2LjkwMiA2LjkwMiAwIDAgMS0xLjUtNy41MjIgNi45MDkgNi45MDkgMCAwIDEgMi41NDQtMy4xIDYuOTI4IDYuOTI4IDAgMCAxIDMuODQxLTEuMTY3Wm0uMTcgNC41NTJhMi40MzEgMi40MzEgMCAwIDAtMi4yNDEgMS4xNTQgMi40MTggMi40MTggMCAwIDAtLjM1NiAxLjI1NyAyLjM5NSAyLjM5NSAwIDAgMCAxLjYxOSAyLjI5djEuNzUzaDEuNjE4di0xLjc1NGEyLjQyNyAyLjQyNyAwIDAgMCAxLjU5NC0xLjk1IDIuNDE4IDIuNDE4IDAgMCAwLTEtMi4zMSAyLjQzMSAyLjQzMSAwIDAgMC0xLjIzNC0uNDRabS0yMC4yMi0yMi41NTJhMTEuNzYyIDExLjc2MiAwIDAgMC0xMi43OTYgMi41MzEgMTEuNjk3IDExLjY5NyAwIDAgMC0yLjU1NCAxMi43NjkgMTEuNzIzIDExLjcyMyAwIDAgMCA0LjMyIDUuMjYyIDExLjc1NyAxMS43NTcgMCAwIDAgMTQuODI1LTEuNDQ2IDExLjcxNyAxMS43MTcgMCAwIDAgMy40NDUtOC4yODQgMTEuNzAzIDExLjcwMyAwIDAgMC0xLjk3NC02LjUxMiAxMS43MzYgMTEuNzM2IDAgMCAwLTUuMjY2LTQuMzJabS00LjUxIDMuOTE3YTYuOTQ1IDYuOTQ1IDAgMCAxIDQuODk3IDIuMDI5IDYuOTE4IDYuOTE4IDAgMCAxIDIuMDMyIDQuODg2IDYuOTA2IDYuOTA2IDAgMCAxLTEuMTY4IDMuODQyIDYuOTQgNi45NCAwIDAgMS0xMC42NiAxLjA0OCA2LjkxMSA2LjkxMSAwIDAgMS0xLjUtNy41MzYgNi45MTggNi45MTggMCAwIDEgMi41NS0zLjEwMyA2LjkzNyA2LjkzNyAwIDAgMSAzLjg1LTEuMTY2Wm0yNC41Ni00LjgxYTEwLjA1OSAxMC4wNTkgMCAwIDAtNy4xMDMgMi45NCAxMC4wMiAxMC4wMiAwIDAgMC0yLjk0IDcuMDkgOS45IDkuOSAwIDAgMCAxLjIzIDQuNzk1IDEzLjU3NSAxMy41NzUgMCAwIDEgNC4yMTQtMi4zMjIgNS4wODIgNS4wODIgMCAwIDEtLjYyNS0yLjQ3NyA1LjIwNiA1LjIwNiAwIDAgMSAxLjUwMy0zLjczNiA1LjIyMyA1LjIyMyAwIDAgMSAzLjcyMi0xLjU1NCA1LjIzNCA1LjIzNCAwIDAgMSAzLjcyIDEuNTU0IDUuMjEzIDUuMjEzIDAgMCAxIDEuNTA1IDMuNzM2IDUuMjc5IDUuMjc5IDAgMCAxLS42MjMgMi40NzMgMTMuNTc0IDEzLjU3NCAwIDAgMSA0LjIxMyAyLjMyMiA5LjkwMyA5LjkwMyAwIDAgMCAxLjIzLTQuNzk1IDEwLjAzMiAxMC4wMzIgMCAwIDAtMi45NDYtNy4wODYgMTAuMDcgMTAuMDcgMCAwIDAtNy4xLTIuOTRabS0yMy43NSA3Ljk5aC0xLjYxN3YxLjc1YTIuNDE5IDIuNDE5IDAgMCAwLTEuNTgyIDIuNjg3IDIuNDE0IDIuNDE0IDAgMCAwIDIuMzkgMi4wMDYgMi40NSAyLjQ1IDAgMCAwIDEuNTU1LS41NzQgMi40MTQgMi40MTQgMCAwIDAtLjc0Ni00LjExOXYtMS43NVoiLz4KICA8L2c+Cjwvc3ZnPgo=",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ge.Unsupported&&Ro(()=>{var t;return(t=window.coin98)!=null&&t.sol?(this._readyState=ge.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get connected(){var e;return!!((e=this._wallet)!=null&&e.isConnected())}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Installed)throw new Li;this._connecting=!0;const e=window.coin98.sol;let t;try{t=(await e.connect())[0]}catch(r){throw new Ns(r==null?void 0:r.message,r)}let i;try{i=new A.PublicKey(t)}catch(r){throw new yr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(t){this.emit("error",new ko(t==null?void 0:t.message,t))}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Ge;try{const i=await t.request({method:"sol_sign",params:[e]}),r=new A.PublicKey(i.publicKey),n=Oc.decode(i.signature);return e.addSignature(r,A.dist.Buffer.from(n)),e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Ge;try{const i=await t.request({method:"sol_signAllTransactions",params:[e]}),r=new A.PublicKey(i.publicKey),n=i.signatures;return e.map((o,a)=>{const c=Oc.decode(n[a]);return o.addSignature(r,A.dist.Buffer.from(c)),o})}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Ge;try{const i=await t.request({method:"sol_signMessage",params:[e]});return Oc.decode(i.signature)}catch(i){throw new jo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const iv="Nightly";class rv extends Uo{constructor(){super(),this.name=iv,this.url="https://nightly.app",this.icon="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOTYiIGhlaWdodD0iOTYiIHZpZXdCb3g9IjAgMCA5NiA5NiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTQ4IDk2Qzc0LjUwOTcgOTYgOTYgNzQuNTA5NyA5NiA0OEM5NiAyMS40OTAzIDc0LjUwOTcgMCA0OCAwQzIxLjQ5MDMgMCAwIDIxLjQ5MDMgMCA0OEMwIDc0LjUwOTcgMjEuNDkwMyA5NiA0OCA5NloiIGZpbGw9IiM2RDczRjgiLz4KPHBhdGggZD0iTTQ4IDg1LjYzNTZDNDggODUuNjM1NiA1Mi40NTMzIDg1LjYzNTYgNTUuNDQgODIuNTg2N0M1OC45MTU1IDc5LjI4MDEgNTcuMzUxMSA3NS40MzEyIDYyLjI3NTUgNzEuNDMxMkM2Ni45ODY2IDY3LjY0NDUgNzIuOTI0NCA3MC4zMzc5IDcyLjkyNDQgNzAuMzM3OUM3Ny4wMjIyIDYyLjEyNDUgNzQuNzkxMSA1Mi41NjkgNzQuNzkxMSA1Mi41NjlDODEuNzY4OCAzNC4yNTc5IDc1Ljk2NDQgMjEuMTU1NyA3NC40NDQ0IDE3LjM2MDFDNjkuNDQ4OCAyNC4zMzc5IDYzLjE5MTEgMjkuMTczNCA1NS43OTU1IDMyLjQwOUM1My4yMjY2IDMxLjcwNjggNTAuNTk1NSAzMS4zMzM0IDQ4IDMxLjM2MDFDNDUuNDEzMyAzMS4zMzM0IDQyLjc3MzMgMzEuNzA2OCA0MC4yMDQ0IDMyLjQwOUMzMi44MTc3IDI5LjE2NDUgMjYuNTUxMSAyNC4zMzc5IDIxLjU1NTUgMTcuMzYwMUMyMC4wMzU1IDIxLjE1NTcgMTQuMjMxMSAzNC4yNTc5IDIxLjIwODkgNTIuNTY5QzIxLjIwODkgNTIuNTY5IDE4Ljk3NzggNjIuMTI0NSAyMy4wNzU1IDcwLjMzNzlDMjMuMDc1NSA3MC4zMzc5IDI5LjAxMzMgNjcuNjQ0NSAzMy43MjQ0IDcxLjQzMTJDMzguNjU3NyA3NS40MzEyIDM3LjA4NDQgNzkuMjgwMSA0MC41NiA4Mi41ODY3QzQzLjU0NjYgODUuNjM1NiA0OCA4NS42MzU2IDQ4IDg1LjYzNTZaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNNDIuNDc5OSA2NS4yOThDNDIuMjkzMyA1OS4yMTggMzYuMzAyMSA1Ny4yNjI0IDMyLjIxMzMgNTkuODIyNEMzMi4yMTMzIDU5LjgyMjQgMzIuODUzMyA2Mi40MzU4IDM1LjgzOTkgNjMuNzUxM0MzOC4yNzU1IDY0LjgyNjkgMzkuMzI0NCA2My4zODY5IDQyLjQ3OTkgNjUuMjk4WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNMjIuNDk3NyAyMy4wOTM1QzIwLjA4ODggMzEuNTQ2OCAyMS4xMjg4IDQyLjI0MDIgMjQuOTMzMyA1MC4wMjY5QzI4LjgyNjYgNDcuMjcxMyAzMi45MTU1IDQzLjAxMzUgMzUuMDkzMyAzOC41MDY5QzI5Ljk2NDQgMzQuNzExMyAyNS42NjIyIDMxLjEwMjQgMjIuNDk3NyAyMy4wOTM1WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNNTMuNTE5OSA2NS4yOThDNTMuNzA2NiA1OS4yMTggNTkuNjk3NyA1Ny4yNjI0IDYzLjc4NjYgNTkuODIyNEM2My43ODY2IDU5LjgyMjQgNjMuMTQ2NiA2Mi40MzU4IDYwLjE1OTkgNjMuNzUxM0M1Ny43MjQzIDY0LjgyNjkgNTYuNjc1NSA2My4zODY5IDUzLjUxOTkgNjUuMjk4WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNNzMuNTAyMiAyMy4wOTM1Qzc1LjkxMTEgMzEuNTQ2OCA3NC44NzExIDQyLjI0MDIgNzEuMDY2NiA1MC4wMjY5QzY3LjE3MzMgNDcuMjcxMyA2My4wODQ0IDQzLjAxMzUgNjAuOTA2NiAzOC41MDY5QzY2LjAzNTUgMzQuNzExMyA3MC4zMzc3IDMxLjEwMjQgNzMuNTAyMiAyMy4wOTM1WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNNDcuOTk5OSA4NS4zMDY5QzUwLjE0MDQgODUuMzA2OSA1MS44NzU1IDgzLjc3ODcgNTEuODc1NSA4MS44OTM2QzUxLjg3NTUgODAuMDA4NCA1MC4xNDA0IDc4LjQ4MDIgNDcuOTk5OSA3OC40ODAyQzQ1Ljg1OTUgNzguNDgwMiA0NC4xMjQ0IDgwLjAwODQgNDQuMTI0NCA4MS44OTM2QzQ0LjEyNDQgODMuNzc4NyA0NS44NTk1IDg1LjMwNjkgNDcuOTk5OSA4NS4zMDY5WiIgZmlsbD0iIzdCODFGOSIvPgo8L3N2Zz4K",this.supportedTransactionVersions=new Set(["legacy",0]),this._readyState=typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.NotDetected,this._connecting=!1,this._publicKey=null,this._wallet=null,this._readyState!==ge.Unsupported&&Ro(()=>{var e;return(e=window==null?void 0:window.nightly)!=null&&e.solana?(this._readyState=ge.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get connecting(){return this._connecting}get readyState(){return this._readyState}get publicKey(){return this._publicKey}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Installed)throw new Li;this._connecting=!0;const e=window.nightly.solana;try{await e.connect()}catch(i){throw new cc(i==null?void 0:i.message,i)}if(e.publicKey.toString()==="11111111111111111111111111111111")throw new Ns;let t;try{t=new A.PublicKey(e.publicKey.toBytes())}catch(i){throw new yr(i==null?void 0:i.message,i)}this._wallet=e,this._publicKey=t,this.emit("connect",t)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch{this.emit("error",new ff)}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signTransaction(e)}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signAllTransactions(e)}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Ge;try{return t.signMessage(new TextDecoder().decode(e))}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const Mu="solana:mainnet",nv="solana:devnet",ov="solana:testnet",av="solana:localnet",cv="Solong";class lv extends $h{constructor(e={}){super(),this.name=cv,this.url="https://solongwallet.io",this.icon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAGlklEQVR4Ae3bA5DsyhfH8TNr49r2/du2bdu2bdu2zcdNrm3b9toz533rvctUn3Umk9p01WfdvVW/6nROBxJVS1rSkpa0pCUtaUlLWtKSpl4VXos3GJ4sujQFuUKfWl+qT730arzB8Ex9YksKcgXjFOCVeIPhBYydB8mawQ+yiGC8n0EN6zAVcgXhpQjoq1DDdsyDAAB9Pwo1HMC9INk0FIM8Bt1Qh9WohQQCvD+BtEMdtmC8I7y5aIE67MV0SBwDvB3qsE/UHwMJIpC/QB1OYiLEEeCPoQ7nMRcSwwDrao3Zl8aTIEGEUYlL0IAMXuQOr66UvsegDm+ExDJAPNiafSg0AlyIbmjAWX1aQzEkiH6T0QkNaEdpnAN8NNRhPcSF9e9el2ebBhyAuNBvGtLQgIuQOAd4D6jDMRQbM3AmOqEBDfq0xjJIEP3GohkakEFVjAP0y401sAsLnAE+pb6EsC5AA9J4sHsG+kX0PQR1eFJ8AwTWQh0+DjFm4a1Qh2/AOoz/BHX4ZdwD/CDU4aioX2GUMW+AOnB2bqiBBDHe86EOTYw5GRKJwQ/ijUM91OGTxgysxSmowzeNw7j08m5DHX4l7Igg2TY0g9hbLBZ+f7oxC98CdWjDvYzD+MVQh07GfEQsZyDgVWA71OGvorfnQQCAcqaYUFZDHW6j/itAoB70GcergzqsEa0rhGTTEA7mP0koK4xdyeOMmvBBhJU2zsjPMw7lu9O3zShpXheHk4hhcZ4w26AOG4RSxDiUfwZ12KdPqy+FBDHeV6EOZxizIg6HsMGbiQ5jdjzBXRfeefGg3tgbv9BYC0fhZE7sjUMY9Pf9rdcI5XtQh39BjBA/C3VYnM0zcgiDek+GOhzh93mQoMs7kIxze/eMhnxIEOPNM9bcFtTEeAb6I419axu/m2CsgxU4Aw1A/UxIUM/bO/9+cVkDDd5x42x8N1iH8Taow0NhHcZLoQ5Pi/MMzDMW+DTu7g6vIY9AdkAdHmaUMyn6roA6PD22AeLB6DbWplHG7LubfY+kfiIkiH5T0AJ1uFtMA1xUzOc1UIclzvCeXF+o7DygDlvds29RgVVzYj+K4xhgEX4NdcjgecE++rSL+ZdLmIxRB77Ose7l4XPIQB3eF8M60C/n8++ghltE/QLIFfqUiyUE8kOoYSW7jmLIFXeN4X0NaajDDlG/NG6XswrxKdxu+G/weh27j3wCej9uN9zEOjc3sObl4S243XBLhDfWE0mAMQjwZfhxDng7pG/8Sj4/ER/Gd/BdfBhPRGW2A/wxNAfcBOnFCHwZZ6GGs/gqapMAb/QEnIT20Uk8IQkQeB7aof3UihcM9wDvhyboANHXv1+IdWBOB2hsIftto+iSPEif8aGPcjrA50GHyPMiOIT9B/N5apaMgQT8D2poxMdwt8s+hkao4X9ZDxBTIdHwy/h8AeqQxhMhAU9BB9ThPMqHTYCYjU6owy3uPstSfL4Z6uZPC+Mk8gOomz8DEg3vXshAHb4MMXwZarhXGDPwa739w2j48623BPAniOFPUMPsMAL8INTw9AgDrLZOCmjFPEjA3WD1aUJVGAG+CGr4ECRCy6GGg3iyaF0+n/PwFByEGpaJ+qkw1sB7QA3/hUTozdBetFymvXhTWGVMOc7bp36/FhKRamNW9dcxZmpZiI+32ad+vAQSoWejGzpAXXh22Fek3wY1rDD2kVnijR3ExYQMPgkJOUB/nFW0Is3vnw6JhlHX9a4N70Iq/ACBv0MNu7J9WxHw7jaA2deFOtw32zeVHtHLWvMN0dtSkOzwS3spYy7iH1hx2d/wYdyTvnkR3BdeQjjerVBDN14JyZIfQWH5RC7e1rw32npZV54LCc+SPD5/HgqYD3WW5+gTqt6X+rA4v0701hRkKF0+bL+HTM9Hgv/MHH60wyvHWigsafwA1ZAhMguLoL34kbDcQEI1uAH8mcbuxPHImf8i5EMGxqvER9EI7cUqVMTl0Y6HoxHaBzvxNkyC9EEe7oEv4Sy0D/YQ+IS4ver1JNT38z7sWnwbb8TT8Cg8Gs/Gu/Ar7EEXtI/2ud7Ni0GAYCbiJDQiazA57k9nTcdqaJb9UtSvitXbmjavCJ9AMzRkJ/B80boUJBLhDe7Nw1/QCR1i9fgKRg6HByzvjZ/hInQQMjiCT2PSMHxC1a/l8wvwGxyG9kEaW/EtPI4xiiE5JcLrd6PxcLwM78SH8EG8Fc/H/UUXVUByGh8SSYBJgEmASYCJJMAkwBi6A3xCqZhiBz8+AAAAAElFTkSuQmCC",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ge.Unsupported&&Ro(()=>window.solong?(this._readyState=ge.Installed,this.emit("readyStateChange",this._readyState),!0):!1)}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get connected(){var e;return!!((e=this._wallet)!=null&&e.currentAccount)}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Installed)throw new Li;this._connecting=!0;const e=window.solong;let t;try{t=await e.selectAccount()}catch(r){throw new Ns(r==null?void 0:r.message,r)}let i;try{i=new A.PublicKey(t)}catch(r){throw new yr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){this._wallet&&(this._wallet=null,this._publicKey=null),this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signTransaction(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const hv="Torus";class uv extends Uo{constructor({params:e={showTorusButton:!1}}={params:{showTorusButton:!1}}){super(),this.name=hv,this.url="https://tor.us",this.icon="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzMiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMyAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYuNSIgY3k9IjE2IiByPSIxNiIgZmlsbD0iIzAzNjRGRiIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTExLjIxODYgOS40OTIxOUMxMC40NTM5IDkuNDkyMTkgOS44MzM5OCAxMC4xMTIxIDkuODMzOTggMTAuODc2OFYxMi40ODk4QzkuODMzOTggMTMuMjU0NSAxMC40NTM5IDEzLjg3NDQgMTEuMjE4NiAxMy44NzQ0SDEzLjY2ODRWMjIuODk3NkMxMy42Njg0IDIzLjY2MjMgMTQuMjg4MyAyNC4yODIyIDE1LjA1MyAyNC4yODIySDE2LjY2NkMxNy40MzA3IDI0LjI4MjIgMTguMDUwNiAyMy42NjIzIDE4LjA1MDYgMjIuODk3NlYxMi41MDE1QzE4LjA1MDYgMTIuNDk3NiAxOC4wNTA2IDEyLjQ5MzcgMTguMDUwNiAxMi40ODk4VjEwLjg3NjhDMTguMDUwNiAxMC4xMTIxIDE3LjQzMDcgOS40OTIxOSAxNi42NjYgOS40OTIxOUgxNS4wNTNIMTEuMjE4NloiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik0yMS4zMzc2IDEzLjg3NDRDMjIuNTQ3NyAxMy44NzQ0IDIzLjUyODcgMTIuODkzNCAyMy41Mjg3IDExLjY4MzNDMjMuNTI4NyAxMC40NzMyIDIyLjU0NzcgOS40OTIxOSAyMS4zMzc2IDkuNDkyMTlDMjAuMTI3NSA5LjQ5MjE5IDE5LjE0NjUgMTAuNDczMiAxOS4xNDY1IDExLjY4MzNDMTkuMTQ2NSAxMi44OTM0IDIwLjEyNzUgMTMuODc0NCAyMS4zMzc2IDEzLjg3NDRaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.Loadable,this._connecting=!1,this._wallet=null,this._publicKey=null,this._params=e}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get connected(){var e;return!!((e=this._wallet)!=null&&e.isLoggedIn)}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Loadable)throw new Li;this._connecting=!0;let e;try{e=(await Promise.resolve().then(()=>require("./solanaEmbed.esm-RhVD6vLR.js"))).default}catch(n){throw new Vb(n==null?void 0:n.message,n)}let t;try{t=window.torus||new e}catch(n){throw new un(n==null?void 0:n.message,n)}if(!t.isInitialized)try{await t.init(this._params)}catch(n){throw new cc(n==null?void 0:n.message,n)}let i;try{i=await t.login()}catch(n){throw new Ns(n==null?void 0:n.message,n)}let r;try{r=new A.PublicKey(i[0])}catch(n){throw new yr(n==null?void 0:n.message,n)}this._wallet=t,this._publicKey=r,this.emit("connect",r)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{e.isLoggedIn&&await e.cleanUp()}catch(t){this.emit("error",new ko(t==null?void 0:t.message,t))}}this.emit("disconnect")}async sendTransaction(e,t,i={}){try{const r=this._wallet;if(!r)throw new Ge;try{const{signers:n,...o}=i;e=await this.prepareTransaction(e,t,o),n!=null&&n.length&&e.partialSign(...n),o.preflightCommitment=o.preflightCommitment||t.commitment;const{signature:a}=await r.signAndSendTransaction(e,o);return a}catch(n){throw n instanceof Dt?n:new rr(n==null?void 0:n.message,n)}}catch(r){throw this.emit("error",r),r}}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signTransaction(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signAllTransactions(e)||e}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Ge;try{return await t.signMessage(e)}catch(i){throw new jo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}function Dc(s){switch(s){case"processed":case"confirmed":case"finalized":case void 0:return s;case"recent":return"processed";case"single":case"singleGossip":return"confirmed";case"max":case"root":return"finalized";default:return}}const dv="https://api.mainnet-beta.solana.com";function pv(s){return s.includes(dv)?Mu:/\bdevnet\b/i.test(s)?nv:/\btestnet\b/i.test(s)?ov:/\blocalhost\b/i.test(s)||/\b127\.0\.0\.1\b/.test(s)?av:Mu}var Ba;(function(s){s.Mainnet="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",s.Devnet="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",s.Deprecated_Mainnet="solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",s.Deprecated_Devnet="solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"})(Ba||(Ba={}));var Is;(function(s){s.signTransaction="solana_signTransaction",s.signMessage="solana_signMessage",s.signAndSendTransaction="solana_signAndSendTransaction",s.signAndSendAllTransactions="solana_signAndSendAllTransactions",s.signAllTransactions="solana_signAllTransactions"})(Is||(Is={}));const gt={Mainnet:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",Devnet:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",Deprecated_Mainnet:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",Deprecated_Devnet:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"};var gv=Object.defineProperty,fv=(s,e,t)=>e in s?gv(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,xu=(s,e,t)=>fv(s,typeof e!="symbol"?e+"":e,t);let yv=class extends u.IEvents{constructor(e){super(),this.opts=e,xu(this,"protocol","wc"),xu(this,"version",2)}};var wv=Object.defineProperty,mv=(s,e,t)=>e in s?wv(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,bv=(s,e,t)=>mv(s,e+"",t);let vv=class extends u.IEvents{constructor(e,t){super(),this.core=e,this.logger=t,bv(this,"records",new Map)}},Iv=class{constructor(e,t){this.logger=e,this.core=t}},Ev=class extends u.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}},Nv=class extends u.IEvents{constructor(e){super()}},Av=class{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}},_v=class extends u.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}},Cv=class extends u.IEvents{constructor(e,t){super(),this.core=e,this.logger=t}},Sv=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},Tv=class{constructor(e,t){this.projectId=e,this.logger=t}},Pv=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};function _o(s,{strict:e=!0}={}){return!s||typeof s!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(s):s.startsWith("0x")}function Ou(s){return _o(s,{strict:!1})?Math.ceil((s.length-2)/2):s.length}const bf="2.23.2";let zn={getDocsUrl:({docsBaseUrl:s,docsPath:e="",docsSlug:t})=>e?`${s??"https://viem.sh"}${e}${t?`#${t}`:""}`:void 0,version:`viem@${bf}`},lc=class Cl extends Error{constructor(e,t={}){var a;const i=(()=>{var c;return t.cause instanceof Cl?t.cause.details:(c=t.cause)!=null&&c.message?t.cause.message:t.details})(),r=t.cause instanceof Cl&&t.cause.docsPath||t.docsPath,n=(a=zn.getDocsUrl)==null?void 0:a.call(zn,{...t,docsPath:r}),o=[e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...i?[`Details: ${i}`]:[],...zn.version?[`Version: ${zn.version}`]:[]].join(`
2
+ `);super(o,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=bf}walk(e){return vf(this,e)}};function vf(s,e){return e!=null&&e(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause!==void 0?vf(s.cause,e):e?null:s}let If=class extends lc{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}};function Sn(s,{dir:e,size:t=32}={}){return typeof s=="string"?$v(s,{dir:e,size:t}):Mv(s,{dir:e,size:t})}function $v(s,{dir:e,size:t=32}={}){if(t===null)return s;const i=s.replace("0x","");if(i.length>t*2)throw new If({size:Math.ceil(i.length/2),targetSize:t,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](t*2,"0")}`}function Mv(s,{dir:e,size:t=32}={}){if(t===null)return s;if(s.length>t)throw new If({size:s.length,targetSize:t,type:"bytes"});const i=new Uint8Array(t);for(let r=0;r<t;r++){const n=e==="right";i[n?r:t-r-1]=s[n?r:s.length-r-1]}return i}let xv=class extends lc{constructor({max:e,min:t,signed:i,size:r,value:n}){super(`Number "${n}" is not in safe ${r?`${r*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}},Ov=class extends lc{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function Tn(s,{size:e}){if(Ou(s)>e)throw new Ov({givenSize:Ou(s),maxSize:e})}function Sl(s,e={}){const{signed:t}=e;e.size&&Tn(s,{size:e.size});const i=BigInt(s);if(!t)return i;const r=(s.length-2)/2,n=(1n<<BigInt(r)*8n-1n)-1n;return i<=n?i:i-BigInt(`0x${"f".padStart(r*2,"f")}`)-1n}function Dv(s,e={}){return Number(Sl(s,e))}const kv=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function Tl(s,e={}){return typeof s=="number"||typeof s=="bigint"?Nf(s,e):typeof s=="string"?Uv(s,e):typeof s=="boolean"?jv(s,e):Ef(s,e)}function jv(s,e={}){const t=`0x${Number(s)}`;return typeof e.size=="number"?(Tn(t,{size:e.size}),Sn(t,{size:e.size})):t}function Ef(s,e={}){let t="";for(let r=0;r<s.length;r++)t+=kv[s[r]];const i=`0x${t}`;return typeof e.size=="number"?(Tn(i,{size:e.size}),Sn(i,{dir:"right",size:e.size})):i}function Nf(s,e={}){const{signed:t,size:i}=e,r=BigInt(s);let n;i?t?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof s=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&t?-n-1n:0;if(n&&r>n||r<o){const c=typeof s=="bigint"?"n":"";throw new xv({max:n?`${n}${c}`:void 0,min:`${o}${c}`,signed:t,size:i,value:`${s}${c}`})}const a=`0x${(t&&r<0?(1n<<BigInt(i*8))+BigInt(r):r).toString(16)}`;return i?Sn(a,{size:i}):a}const Rv=new TextEncoder;function Uv(s,e={}){const t=Rv.encode(s);return Ef(t,e)}const Lv=new TextEncoder;function zv(s,e={}){return typeof s=="number"||typeof s=="bigint"?qv(s,e):typeof s=="boolean"?Fv(s,e):_o(s)?Af(s,e):_f(s,e)}function Fv(s,e={}){const t=new Uint8Array(1);return t[0]=Number(s),typeof e.size=="number"?(Tn(t,{size:e.size}),Sn(t,{size:e.size})):t}const si={zero:48,nine:57,A:65,F:70,a:97,f:102};function Du(s){if(s>=si.zero&&s<=si.nine)return s-si.zero;if(s>=si.A&&s<=si.F)return s-(si.A-10);if(s>=si.a&&s<=si.f)return s-(si.a-10)}function Af(s,e={}){let t=s;e.size&&(Tn(t,{size:e.size}),t=Sn(t,{dir:"right",size:e.size}));let i=t.slice(2);i.length%2&&(i=`0${i}`);const r=i.length/2,n=new Uint8Array(r);for(let o=0,a=0;o<r;o++){const c=Du(i.charCodeAt(a++)),l=Du(i.charCodeAt(a++));if(c===void 0||l===void 0)throw new lc(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);n[o]=c*16+l}return n}function qv(s,e){const t=Nf(s,e);return Af(t)}function _f(s,e={}){const t=Lv.encode(s);return typeof e.size=="number"?(Tn(t,{size:e.size}),Sn(t,{dir:"right",size:e.size})):t}function Ha(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function Bv(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Lo(s,...e){if(!Bv(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function Hv(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ha(s.outputLen),Ha(s.blockLen)}function Pl(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function Cf(s,e){Lo(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const la=BigInt(2**32-1),ku=BigInt(32);function Wv(s,e=!1){return e?{h:Number(s&la),l:Number(s>>ku&la)}:{h:Number(s>>ku&la)|0,l:Number(s&la)|0}}function Vv(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=Wv(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const Kv=(s,e,t)=>s<<t|e>>>32-t,Gv=(s,e,t)=>e<<t|s>>>32-t,Yv=(s,e,t)=>e<<t-32|s>>>64-t,Qv=(s,e,t)=>s<<t-32|e>>>64-t,Ar=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Zv(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function Jv(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Xv(s,e){return s<<32-e|s>>>e}const ju=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function e0(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Ru(s){for(let e=0;e<s.length;e++)s[e]=e0(s[e])}function t0(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function Mh(s){return typeof s=="string"&&(s=t0(s)),Lo(s),s}function s0(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Lo(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}let Sf=class{clone(){return this._cloneInto()}};function Tf(s){const e=i=>s().update(Mh(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function i0(s=32){if(Ar&&typeof Ar.getRandomValues=="function")return Ar.getRandomValues(new Uint8Array(s));if(Ar&&typeof Ar.randomBytes=="function")return Ar.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const Pf=[],$f=[],Mf=[],r0=BigInt(0),Fn=BigInt(1),n0=BigInt(2),o0=BigInt(7),a0=BigInt(256),c0=BigInt(113);for(let s=0,e=Fn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],Pf.push(2*(5*i+t)),$f.push((s+1)*(s+2)/2%64);let r=r0;for(let n=0;n<7;n++)e=(e<<Fn^(e>>o0)*c0)%a0,e&n0&&(r^=Fn<<(Fn<<BigInt(n))-Fn);Mf.push(r)}const[l0,h0]=Vv(Mf,!0),Uu=(s,e,t)=>t>32?Yv(s,e,t):Kv(s,e,t),Lu=(s,e,t)=>t>32?Qv(s,e,t):Gv(s,e,t);function u0(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],d=Uu(l,h,1)^t[a],p=Lu(l,h,1)^t[a+1];for(let f=0;f<50;f+=10)s[o+f]^=d,s[o+f+1]^=p}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=$f[o],c=Uu(r,n,a),l=Lu(r,n,a),h=Pf[o];r=s[h],n=s[h+1],s[h]=c,s[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=l0[i],s[1]^=h0[i]}t.fill(0)}let d0=class xf extends Sf{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ha(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Zv(this.state)}keccak(){ju||Ru(this.state32),u0(this.state32,this.rounds),ju||Ru(this.state32),this.posOut=0,this.pos=0}update(e){Pl(this);const{blockLen:t,state:i}=this;e=Mh(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Pl(this,!1),Lo(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ha(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Cf(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new xf(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const p0=(s,e,t)=>Tf(()=>new d0(e,s,t)),g0=p0(1,136,256/8);function Of(s,e){const t=e||"hex",i=g0(_o(s,{strict:!1})?zv(s):s);return t==="bytes"?i:Tl(i)}let f0=class extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}};const kc=new f0(8192);function y0(s,e){if(kc.has(`${s}.${e}`))return kc.get(`${s}.${e}`);const t=s.substring(2).toLowerCase(),i=Of(_f(t),"bytes"),r=t.split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(i[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const n=`0x${r.join("")}`;return kc.set(`${s}.${e}`,n),n}function w0(s){const e=Of(`0x${s.substring(4)}`).substring(26);return y0(`0x${e}`)}async function m0({hash:s,signature:e}){const t=_o(s)?s:Tl(s),{secp256k1:i}=await Promise.resolve().then(()=>require("./secp256k1-1EcPGQYM.js"));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:l,s:h,v:d,yParity:p}=e,f=Number(p??d),g=zu(f);return new i.Signature(Sl(l),Sl(h)).addRecoveryBit(g)}const o=_o(e)?e:Tl(e),a=Dv(`0x${o.slice(130)}`),c=zu(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(t.substring(2)).toHex(!1)}`}function zu(s){if(s===0||s===1)return s;if(s===27)return 0;if(s===28)return 1;throw new Error("Invalid yParityOrV value")}async function b0({hash:s,signature:e}){return w0(await m0({hash:s,signature:e}))}var Df=oe.requireElliptic();const kf=":";function wn(s){const[e,t]=s.split(kf);return{namespace:e,reference:t}}function v0(s){const[e,t,i]=s.split(kf);return{namespace:e,reference:t,address:i}}function jf(s,e){return s.includes(":")?[s]:e.chains||[]}const I0="ReactNative",ls={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},E0="js";function Wa(){return typeof A.dist.process<"u"&&typeof A.dist.process.versions<"u"&&typeof A.dist.process.versions.node<"u"}function zi(){return!u.getDocument_1()&&!!u.getNavigator_1()&&navigator.product===I0}function N0(){return zi()&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Platform)<"u"&&(A.dist.global==null?void 0:A.dist.global.Platform.OS)==="android"}function A0(){return zi()&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Platform)<"u"&&(A.dist.global==null?void 0:A.dist.global.Platform.OS)==="ios"}function zo(){return!Wa()&&!!u.getNavigator_1()&&!!u.getDocument_1()}function Fo(){return zi()?ls.reactNative:Wa()?ls.node:zo()?ls.browser:ls.unknown}function Fu(){var s;try{return zi()&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Application)<"u"?(s=A.dist.global.Application)==null?void 0:s.applicationId:void 0}catch{return}}function _0(s,e){const t=new URLSearchParams(s);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const r=e[i];r!==void 0&&t.set(i,r)}return t.toString()}function Rf(){return u.getWindowMetadata_1()||{name:"",description:"",url:"",icons:[""]}}function C0(){if(Fo()===ls.reactNative&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Platform)<"u"){const{OS:t,Version:i}=A.dist.global.Platform;return[t,i].join("-")}const s=u.detect();if(s===null)return"unknown";const e=s.os?s.os.replace(" ","").toLowerCase():"unknown";return s.type==="browser"?[e,s.name,s.version].join("-"):[e,s.version].join("-")}function S0(){var s;const e=Fo();return e===ls.browser?[e,((s=u.getLocation_1())==null?void 0:s.host)||"unknown"].join(":"):e}function Uf(s,e,t){const i=C0(),r=S0();return[[s,e].join("-"),[E0,t].join("-"),i,r].join("/")}function T0({protocol:s,version:e,relayUrl:t,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=t.split("?"),h=Uf(s,e,i),d={auth:r,ua:h,projectId:n,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},p=_0(l[1]||"",d);return l[0]+"?"+p}function nr(s,e){return s.filter(t=>e.includes(t)).length===s.length}function Lf(s){return Object.fromEntries(s.entries())}function zf(s){return new Map(Object.entries(s))}function Zi(s=u.cjs.FIVE_MINUTES,e){const t=u.cjs.toMiliseconds(s||u.cjs.FIVE_MINUTES);let i,r,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&r&&(clearTimeout(n),r(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},t),i=a,r=c})}}function $i(s,e,t){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(t)),e);try{const o=await s;i(o)}catch(o){r(o)}clearTimeout(n)})}function Ff(s,e){if(typeof e=="string"&&e.startsWith(`${s}:`))return e;if(s.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(s.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${s}`)}function P0(s){return Ff("topic",s)}function $0(s){return Ff("id",s)}function qf(s){const[e,t]=s.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function dt(s,e){return u.cjs.fromMiliseconds(Date.now()+u.cjs.toMiliseconds(s))}function Ci(s){return Date.now()>=u.cjs.toMiliseconds(s)}function $e(s,e){return`${s}${e?`:${e}`:""}`}function Oa(s=[],e=[]){return[...new Set([...s,...e])]}async function M0({id:s,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const r=typeof t=="string"?JSON.parse(t):t,n=r==null?void 0:r.href;if(typeof n!="string")return;const o=x0(n,s,e),a=Fo();if(a===ls.browser){if(!((i=u.getDocument_1())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}O0(o)}else a===ls.reactNative&&typeof(A.dist.global==null?void 0:A.dist.global.Linking)<"u"&&await A.dist.global.Linking.openURL(o)}catch(r){console.error(r)}}function x0(s,e,t){const i=`requestId=${e}&sessionTopic=${t}`;s.endsWith("/")&&(s=s.slice(0,-1));let r=`${s}`;if(s.startsWith("https://t.me")){const n=s.includes("?")?"&startapp=":"?startapp=";r=`${r}${n}${R0(i,!0)}`}else r=`${r}/wc?${i}`;return r}function O0(s){let e="_self";j0()?e="_top":(k0()||s.startsWith("https://")||s.startsWith("http://"))&&(e="_blank"),window.open(s,e,"noreferrer noopener")}async function D0(s,e){let t="";try{if(zo()&&(t=localStorage.getItem(e),t))return t;t=await s.getItem(e)}catch(i){console.error(i)}return t}function qu(s,e){if(!s.includes(e))return null;const t=s.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Bu(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}function xh(){return typeof A.dist.process<"u"&&A.dist.process.env.IS_VITEST==="true"}function k0(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function j0(){try{return window.self!==window.top}catch{return!1}}function R0(s,e=!1){const t=A.dist.Buffer.from(s).toString("base64");return e?t.replace(/[=]/g,""):t}function Bf(s){return A.dist.Buffer.from(s,"base64").toString("utf-8")}function U0(s){return new Promise(e=>setTimeout(e,s))}function Co(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function L0(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function hc(s,...e){if(!L0(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function Oh(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Co(s.outputLen),Co(s.blockLen)}function In(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function Hf(s,e){hc(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const ha=BigInt(2**32-1),Hu=BigInt(32);function z0(s,e=!1){return e?{h:Number(s&ha),l:Number(s>>Hu&ha)}:{h:Number(s>>Hu&ha)|0,l:Number(s&ha)|0}}function F0(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=z0(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const q0=(s,e,t)=>s<<t|e>>>32-t,B0=(s,e,t)=>e<<t|s>>>32-t,H0=(s,e,t)=>e<<t-32|s>>>64-t,W0=(s,e,t)=>s<<t-32|e>>>64-t,_r=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function V0(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function jc(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function zs(s,e){return s<<32-e|s>>>e}const Wu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function K0(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Vu(s){for(let e=0;e<s.length;e++)s[e]=K0(s[e])}function G0(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function En(s){return typeof s=="string"&&(s=G0(s)),hc(s),s}let Dh=class{clone(){return this._cloneInto()}};function Wf(s){const e=i=>s().update(En(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function qo(s=32){if(_r&&typeof _r.getRandomValues=="function")return _r.getRandomValues(new Uint8Array(s));if(_r&&typeof _r.randomBytes=="function")return _r.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const Vf=[],Kf=[],Gf=[],Y0=BigInt(0),qn=BigInt(1),Q0=BigInt(2),Z0=BigInt(7),J0=BigInt(256),X0=BigInt(113);for(let s=0,e=qn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],Vf.push(2*(5*i+t)),Kf.push((s+1)*(s+2)/2%64);let r=Y0;for(let n=0;n<7;n++)e=(e<<qn^(e>>Z0)*X0)%J0,e&Q0&&(r^=qn<<(qn<<BigInt(n))-qn);Gf.push(r)}const[eI,tI]=F0(Gf,!0),Ku=(s,e,t)=>t>32?H0(s,e,t):q0(s,e,t),Gu=(s,e,t)=>t>32?W0(s,e,t):B0(s,e,t);function sI(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],d=Ku(l,h,1)^t[a],p=Gu(l,h,1)^t[a+1];for(let f=0;f<50;f+=10)s[o+f]^=d,s[o+f+1]^=p}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=Kf[o],c=Ku(r,n,a),l=Gu(r,n,a),h=Vf[o];r=s[h],n=s[h+1],s[h]=c,s[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=eI[i],s[1]^=tI[i]}t.fill(0)}let iI=class Yf extends Dh{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Co(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=V0(this.state)}keccak(){Wu||Vu(this.state32),sI(this.state32,this.rounds),Wu||Vu(this.state32),this.posOut=0,this.pos=0}update(e){In(this);const{blockLen:t,state:i}=this;e=En(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){In(this,!1),hc(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Co(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Hf(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new Yf(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const rI=(s,e,t)=>Wf(()=>new iI(e,s,t)),nI=rI(1,136,256/8),oI="https://rpc.walletconnect.org/v1";function Qf(s){const e=`Ethereum Signed Message:
3
3
  ${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+A.dist.Buffer.from(nI(t)).toString("hex")}async function aI(s,e,t,i,r,n){switch(t.t){case"eip191":return await cI(s,e,t.s);case"eip1271":return await lI(s,e,t.s,i,r,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}async function cI(s,e,t){return(await b0({hash:Qf(e),signature:t})).toLowerCase()===s.toLowerCase()}async function lI(s,e,t,i,r,n){const o=wn(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l="0000000000000000000000000000000000000000000000000000000000000041",h=t.substring(2),d=Qf(e).substring(2),p=a+d+c+l+h,f=await fetch(`${n||oI}/?chainId=${i}&projectId=${r}`,{method:"POST",body:JSON.stringify({id:hI(),jsonrpc:"2.0",method:"eth_call",params:[{to:s,data:p},"latest"]})}),{result:g}=await f.json();return g?g.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function hI(){return Date.now()+Math.floor(Math.random()*1e3)}var uI=Object.defineProperty,dI=Object.defineProperties,pI=Object.getOwnPropertyDescriptors,Yu=Object.getOwnPropertySymbols,gI=Object.prototype.hasOwnProperty,fI=Object.prototype.propertyIsEnumerable,Qu=(s,e,t)=>e in s?uI(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,yI=(s,e)=>{for(var t in e||(e={}))gI.call(e,t)&&Qu(s,t,e[t]);if(Yu)for(var t of Yu(e))fI.call(e,t)&&Qu(s,t,e[t]);return s},wI=(s,e)=>dI(s,pI(e));const mI="did:pkh:",kh=s=>s==null?void 0:s.split(":"),bI=s=>{const e=s&&kh(s);if(e)return s.includes(mI)?e[3]:e[1]},$l=s=>{const e=s&&kh(s);if(e)return e[2]+":"+e[3]},Va=s=>{const e=s&&kh(s);if(e)return e.pop()};async function Zu(s){const{cacao:e,projectId:t}=s,{s:i,p:r}=e,n=Zf(r,r.iss),o=Va(r.iss);return await aI(o,n,i,$l(r.iss),t)}const Zf=(s,e)=>{const t=`${s.domain} wants you to sign in with your Ethereum account:`,i=Va(e);if(!s.aud&&!s.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let r=s.statement||void 0;const n=`URI: ${s.aud||s.uri}`,o=`Version: ${s.version}`,a=`Chain ID: ${bI(e)}`,c=`Nonce: ${s.nonce}`,l=`Issued At: ${s.iat}`,h=s.exp?`Expiration Time: ${s.exp}`:void 0,d=s.nbf?`Not Before: ${s.nbf}`:void 0,p=s.requestId?`Request ID: ${s.requestId}`:void 0,f=s.resources?`Resources:${s.resources.map(y=>`
4
4
  - ${y}`).join("")}`:void 0,g=Da(s.resources);if(g){const y=So(g);r=TI(r,y)}return[t,i,"",r,"",n,o,a,c,l,h,d,p,f].filter(y=>y!=null).join(`
5
5
  `)};function vI(s){return A.dist.Buffer.from(JSON.stringify(s)).toString("base64")}function II(s){return JSON.parse(A.dist.Buffer.from(s,"base64").toString("utf-8"))}function lr(s){if(!s)throw new Error("No recap provided, value is undefined");if(!s.att)throw new Error("No `att` property found");const e=Object.keys(s.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{const i=s.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(r=>{const n=i[r];if(!Array.isArray(n))throw new Error(`Ability limits ${r} must be an array of objects, found: ${n}`);if(!n.length)throw new Error(`Value of ${r} is empty array, must be an array with objects`);n.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${r}) must be an array of objects, found: ${o}`)})})})}function EI(s,e,t,i={}){return t==null||t.sort((r,n)=>r.localeCompare(n)),{att:{[s]:NI(e,t,i)}}}function NI(s,e,t={}){e=e==null?void 0:e.sort((r,n)=>r.localeCompare(n));const i=e.map(r=>({[`${s}/${r}`]:[t]}));return Object.assign({},...i)}function Jf(s){return lr(s),`urn:recap:${vI(s).replace(/=/g,"")}`}function So(s){const e=II(s.replace("urn:recap:",""));return lr(e),e}function AI(s,e,t){const i=EI(s,e,t);return Jf(i)}function _I(s){return s&&s.includes("urn:recap:")}function CI(s,e){const t=So(s),i=So(e),r=SI(t,i);return Jf(r)}function SI(s,e){lr(s),lr(e);const t=Object.keys(s.att).concat(Object.keys(e.att)).sort((r,n)=>r.localeCompare(n)),i={att:{}};return t.forEach(r=>{var n,o;Object.keys(((n=s.att)==null?void 0:n[r])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[r])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,l;i.att[r]=wI(yI({},i.att[r]),{[a]:((c=s.att[r])==null?void 0:c[a])||((l=e.att[r])==null?void 0:l[a])})})}),i}function TI(s="",e){lr(e);const t="I further authorize the stated URI to perform the following actions on my behalf: ";if(s.includes(t))return s;const i=[];let r=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(d=>({ability:d.split("/")[0],action:d.split("/")[1]}));c.sort((d,p)=>d.action.localeCompare(p.action));const l={};c.forEach(d=>{l[d.ability]||(l[d.ability]=[]),l[d.ability].push(d.action)});const h=Object.keys(l).map(d=>(r++,`(${r}) '${d}': '${l[d].join("', '")}' for '${a}'.`));i.push(h.join(", ").replace(".,","."))});const n=i.join(" "),o=`${t}${n}`;return`${s?s+" ":""}${o}`}function Ju(s){var e;const t=So(s);lr(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(r=>r.split("/")[1]):[]}function Xu(s){const e=So(s);lr(e);const t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(r=>{var n;(n=r==null?void 0:r[0])!=null&&n.chains&&t.push(r[0].chains)})}),[...new Set(t.flat())]}function Da(s){if(!s)return;const e=s==null?void 0:s[s.length-1];return _I(e)?e:void 0}function Rc(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function Xf(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function as(s,...e){if(!Xf(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function ed(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function PI(s,e){as(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function td(s){if(typeof s!="boolean")throw new Error(`boolean expected, not ${s}`)}const ki=s=>new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)),$I=s=>new DataView(s.buffer,s.byteOffset,s.byteLength),MI=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!MI)throw new Error("Non little-endian hardware is not supported");function xI(s){if(typeof s!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(s))}function Ml(s){if(typeof s=="string")s=xI(s);else if(Xf(s))s=xl(s);else throw new Error("Uint8Array expected, got "+typeof s);return s}function OI(s,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(s,e)}function DI(s,e){if(s.length!==e.length)return!1;let t=0;for(let i=0;i<s.length;i++)t|=s[i]^e[i];return t===0}const kI=(s,e)=>{function t(i,...r){if(as(i),s.nonceLength!==void 0){const l=r[0];if(!l)throw new Error("nonce / iv required");s.varSizeNonce?as(l):as(l,s.nonceLength)}const n=s.tagLength;n&&r[1]!==void 0&&as(r[1]);const o=e(i,...r),a=(l,h)=>{if(h!==void 0){if(l!==2)throw new Error("cipher output not supported");as(h)}};let c=!1;return{encrypt(l,h){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,as(l),a(o.encrypt.length,h),o.encrypt(l,h)},decrypt(l,h){if(as(l),n&&l.length<n)throw new Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,h),o.decrypt(l,h)}}}return Object.assign(t,s),t};function sd(s,e,t=!0){if(e===void 0)return new Uint8Array(s);if(e.length!==s)throw new Error("invalid output length, expected "+s+", got: "+e.length);if(t&&!jI(e))throw new Error("invalid output, must be aligned");return e}function id(s,e,t,i){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(t>>r&n),a=Number(t&n);s.setUint32(e+4,o,i),s.setUint32(e+0,a,i)}function jI(s){return s.byteOffset%4===0}function xl(s){return Uint8Array.from(s)}function Nn(...s){for(let e=0;e<s.length;e++)s[e].fill(0)}const ey=s=>Uint8Array.from(s.split("").map(e=>e.charCodeAt(0))),RI=ey("expand 16-byte k"),UI=ey("expand 32-byte k"),LI=ki(RI),zI=ki(UI);function Ee(s,e){return s<<e|s>>>32-e}function Ol(s){return s.byteOffset%4===0}const ua=64,FI=16,ty=2**32-1,rd=new Uint32Array;function qI(s,e,t,i,r,n,o,a){const c=r.length,l=new Uint8Array(ua),h=ki(l),d=Ol(r)&&Ol(n),p=d?ki(r):rd,f=d?ki(n):rd;for(let g=0;g<c;o++){if(s(e,t,i,h,o,a),o>=ty)throw new Error("arx: counter overflow");const y=Math.min(ua,c-g);if(d&&y===ua){const v=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let b=0,w;b<FI;b++)w=v+b,f[w]=p[w]^h[b];g+=ua;continue}for(let v=0,b;v<y;v++)b=g+v,n[b]=r[b]^l[v];g+=y}}function BI(s,e){const{allowShortKeys:t,extendNonceFn:i,counterLength:r,counterRight:n,rounds:o}=OI({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof s!="function")throw new Error("core must be a function");return Rc(r),Rc(o),td(n),td(t),(a,c,l,h,d=0)=>{as(a),as(c),as(l);const p=l.length;if(h===void 0&&(h=new Uint8Array(p)),as(h),Rc(d),d<0||d>=ty)throw new Error("arx: counter overflow");if(h.length<p)throw new Error(`arx: output (${h.length}) is shorter than data (${p})`);const f=[];let g=a.length,y,v;if(g===32)f.push(y=xl(a)),v=zI;else if(g===16&&t)y=new Uint8Array(32),y.set(a),y.set(a,16),v=LI,f.push(y);else throw new Error(`arx: invalid 32-byte key, got length=${g}`);Ol(c)||f.push(c=xl(c));const b=ki(y);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(v,b,ki(c.subarray(0,16)),b),c=c.subarray(16)}const w=16-r;if(w!==c.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(w!==12){const _=new Uint8Array(12);_.set(c,n?0:12-c.length),c=_,f.push(c)}const N=ki(c);return qI(s,v,b,N,l,h,d,o),Nn(...f),h}}const _t=(s,e)=>s[e++]&255|(s[e++]&255)<<8;let HI=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=Ml(e),as(e,32);const t=_t(e,0),i=_t(e,2),r=_t(e,4),n=_t(e,6),o=_t(e,8),a=_t(e,10),c=_t(e,12),l=_t(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|i<<3)&8191,this.r[2]=(i>>>10|r<<6)&7939,this.r[3]=(r>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let h=0;h<8;h++)this.pad[h]=_t(e,16+2*h)}process(e,t,i=!1){const r=i?0:2048,{h:n,r:o}=this,a=o[0],c=o[1],l=o[2],h=o[3],d=o[4],p=o[5],f=o[6],g=o[7],y=o[8],v=o[9],b=_t(e,t+0),w=_t(e,t+2),N=_t(e,t+4),_=_t(e,t+6),C=_t(e,t+8),T=_t(e,t+10),P=_t(e,t+12),O=_t(e,t+14);let $=n[0]+(b&8191),q=n[1]+((b>>>13|w<<3)&8191),j=n[2]+((w>>>10|N<<6)&8191),G=n[3]+((N>>>7|_<<9)&8191),B=n[4]+((_>>>4|C<<12)&8191),W=n[5]+(C>>>1&8191),V=n[6]+((C>>>14|T<<2)&8191),H=n[7]+((T>>>11|P<<5)&8191),K=n[8]+((P>>>8|O<<8)&8191),Q=n[9]+(O>>>5|r),S=0,z=S+$*a+q*(5*v)+j*(5*y)+G*(5*g)+B*(5*f);S=z>>>13,z&=8191,z+=W*(5*p)+V*(5*d)+H*(5*h)+K*(5*l)+Q*(5*c),S+=z>>>13,z&=8191;let ee=S+$*c+q*a+j*(5*v)+G*(5*y)+B*(5*g);S=ee>>>13,ee&=8191,ee+=W*(5*f)+V*(5*p)+H*(5*d)+K*(5*h)+Q*(5*l),S+=ee>>>13,ee&=8191;let Z=S+$*l+q*c+j*a+G*(5*v)+B*(5*y);S=Z>>>13,Z&=8191,Z+=W*(5*g)+V*(5*f)+H*(5*p)+K*(5*d)+Q*(5*h),S+=Z>>>13,Z&=8191;let ve=S+$*h+q*l+j*c+G*a+B*(5*v);S=ve>>>13,ve&=8191,ve+=W*(5*y)+V*(5*g)+H*(5*f)+K*(5*p)+Q*(5*d),S+=ve>>>13,ve&=8191;let pe=S+$*d+q*h+j*l+G*c+B*a;S=pe>>>13,pe&=8191,pe+=W*(5*v)+V*(5*y)+H*(5*g)+K*(5*f)+Q*(5*p),S+=pe>>>13,pe&=8191;let te=S+$*p+q*d+j*h+G*l+B*c;S=te>>>13,te&=8191,te+=W*a+V*(5*v)+H*(5*y)+K*(5*g)+Q*(5*f),S+=te>>>13,te&=8191;let st=S+$*f+q*p+j*d+G*h+B*l;S=st>>>13,st&=8191,st+=W*c+V*a+H*(5*v)+K*(5*y)+Q*(5*g),S+=st>>>13,st&=8191;let Le=S+$*g+q*f+j*p+G*d+B*h;S=Le>>>13,Le&=8191,Le+=W*l+V*c+H*a+K*(5*v)+Q*(5*y),S+=Le>>>13,Le&=8191;let Ie=S+$*y+q*g+j*f+G*p+B*d;S=Ie>>>13,Ie&=8191,Ie+=W*h+V*l+H*c+K*a+Q*(5*v),S+=Ie>>>13,Ie&=8191;let ke=S+$*v+q*y+j*g+G*f+B*p;S=ke>>>13,ke&=8191,ke+=W*d+V*h+H*l+K*c+Q*a,S+=ke>>>13,ke&=8191,S=(S<<2)+S|0,S=S+z|0,z=S&8191,S=S>>>13,ee+=S,n[0]=z,n[1]=ee,n[2]=Z,n[3]=ve,n[4]=pe,n[5]=te,n[6]=st,n[7]=Le,n[8]=Ie,n[9]=ke}finalize(){const{h:e,pad:t}=this,i=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=r,r=e[a]>>>13,e[a]&=8191;e[0]+=r*5,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,i[0]=e[0]+5,r=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+r,r=i[a]>>>13,i[a]&=8191;i[9]-=8192;let n=(r^1)-1;for(let a=0;a<10;a++)i[a]&=n;n=~n;for(let a=0;a<10;a++)e[a]=e[a]&n|i[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+t[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+t[a]|0)+(o>>>16)|0,e[a]=o&65535;Nn(i)}update(e){ed(this);const{buffer:t,blockLen:i}=this;e=Ml(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(i-this.pos,r-n);if(o===i){for(;i<=r-n;n+=i)this.process(e,n);continue}t.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){Nn(this.h,this.r,this.buffer,this.pad)}digestInto(e){ed(this),PI(e,this),this.finished=!0;const{buffer:t,h:i}=this;let{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=i[o]>>>0,e[n++]=i[o]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}};function WI(s){const e=(i,r)=>s(r).update(Ml(i)).digest(),t=s(new Uint8Array(32));return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=i=>s(i),e}const VI=WI(s=>new HI(s));function KI(s,e,t,i,r,n=20){let o=s[0],a=s[1],c=s[2],l=s[3],h=e[0],d=e[1],p=e[2],f=e[3],g=e[4],y=e[5],v=e[6],b=e[7],w=r,N=t[0],_=t[1],C=t[2],T=o,P=a,O=c,$=l,q=h,j=d,G=p,B=f,W=g,V=y,H=v,K=b,Q=w,S=N,z=_,ee=C;for(let ve=0;ve<n;ve+=2)T=T+q|0,Q=Ee(Q^T,16),W=W+Q|0,q=Ee(q^W,12),T=T+q|0,Q=Ee(Q^T,8),W=W+Q|0,q=Ee(q^W,7),P=P+j|0,S=Ee(S^P,16),V=V+S|0,j=Ee(j^V,12),P=P+j|0,S=Ee(S^P,8),V=V+S|0,j=Ee(j^V,7),O=O+G|0,z=Ee(z^O,16),H=H+z|0,G=Ee(G^H,12),O=O+G|0,z=Ee(z^O,8),H=H+z|0,G=Ee(G^H,7),$=$+B|0,ee=Ee(ee^$,16),K=K+ee|0,B=Ee(B^K,12),$=$+B|0,ee=Ee(ee^$,8),K=K+ee|0,B=Ee(B^K,7),T=T+j|0,ee=Ee(ee^T,16),H=H+ee|0,j=Ee(j^H,12),T=T+j|0,ee=Ee(ee^T,8),H=H+ee|0,j=Ee(j^H,7),P=P+G|0,Q=Ee(Q^P,16),K=K+Q|0,G=Ee(G^K,12),P=P+G|0,Q=Ee(Q^P,8),K=K+Q|0,G=Ee(G^K,7),O=O+B|0,S=Ee(S^O,16),W=W+S|0,B=Ee(B^W,12),O=O+B|0,S=Ee(S^O,8),W=W+S|0,B=Ee(B^W,7),$=$+q|0,z=Ee(z^$,16),V=V+z|0,q=Ee(q^V,12),$=$+q|0,z=Ee(z^$,8),V=V+z|0,q=Ee(q^V,7);let Z=0;i[Z++]=o+T|0,i[Z++]=a+P|0,i[Z++]=c+O|0,i[Z++]=l+$|0,i[Z++]=h+q|0,i[Z++]=d+j|0,i[Z++]=p+G|0,i[Z++]=f+B|0,i[Z++]=g+W|0,i[Z++]=y+V|0,i[Z++]=v+H|0,i[Z++]=b+K|0,i[Z++]=w+Q|0,i[Z++]=N+S|0,i[Z++]=_+z|0,i[Z++]=C+ee|0}const GI=BI(KI,{counterRight:!1,counterLength:4,allowShortKeys:!1}),YI=new Uint8Array(16),nd=(s,e)=>{s.update(e);const t=e.length%16;t&&s.update(YI.subarray(t))},QI=new Uint8Array(32);function od(s,e,t,i,r){const n=s(e,t,QI),o=VI.create(n);r&&nd(o,r),nd(o,i);const a=new Uint8Array(16),c=$I(a);id(c,0,BigInt(r?r.length:0),!0),id(c,8,BigInt(i.length),!0),o.update(a);const l=o.digest();return Nn(n,a),l}const ZI=s=>(e,t,i)=>({encrypt(r,n){const o=r.length;n=sd(o+16,n,!1),n.set(r);const a=n.subarray(0,-16);s(e,t,a,a,1);const c=od(s,e,t,a,i);return n.set(c,o),Nn(c),n},decrypt(r,n){n=sd(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=od(s,e,t,o,i);if(!DI(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),s(e,t,n,n,1),Nn(c),n}}),sy=kI({blockSize:64,nonceLength:12,tagLength:16},ZI(GI));let iy=class extends Dh{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Oh(e);const i=En(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(i.length>r?e.create().update(i).digest():i);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=e.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),n.fill(0)}update(e){return In(this),this.iHash.update(e),this}digestInto(e){In(this),hc(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:i,finished:r,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=r,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const jh=(s,e,t)=>new iy(s,e).update(t).digest();jh.create=(s,e)=>new iy(s,e);function JI(s,e,t){return Oh(s),t===void 0&&(t=new Uint8Array(s.outputLen)),jh(s,En(t),En(e))}const Uc=new Uint8Array([0]),ad=new Uint8Array;function XI(s,e,t,i=32){if(Oh(s),Co(i),i>255*s.outputLen)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(i/s.outputLen);t===void 0&&(t=ad);const n=new Uint8Array(r*s.outputLen),o=jh.create(s,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<r;l++)Uc[0]=l+1,a.update(l===0?ad:c).update(t).update(Uc).digestInto(c),n.set(c,s.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Uc.fill(0),n.slice(0,i)}const e1=(s,e,t,i,r)=>XI(s,JI(s,e,t),i,r);function t1(s,e,t,i){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(t>>r&n),a=Number(t&n),c=i?4:0,l=i?0:4;s.setUint32(e+c,o,i),s.setUint32(e+l,a,i)}function s1(s,e,t){return s&e^~s&t}function i1(s,e,t){return s&e^s&t^e&t}let r1=class extends Dh{constructor(e,t,i,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=jc(this.buffer)}update(e){In(this);const{view:t,buffer:i,blockLen:r}=this;e=En(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(r-this.pos,n-o);if(a===r){const c=jc(e);for(;r<=n-o;o+=r)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){In(this),Hf(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:r,isLE:n}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(i,0),o=0);for(let d=o;d<r;d++)t[d]=0;t1(i,r-8,BigInt(this.length*8),n),this.process(i,0);const a=jc(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,h[d],n)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:r,finished:n,destroyed:o,pos:a}=this;return e.length=r,e.pos=a,e.finished=n,e.destroyed=o,r%t&&e.buffer.set(i),e}};const n1=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]),mi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),bi=new Uint32Array(64);let o1=class extends r1{constructor(){super(64,32,8,!1),this.A=mi[0]|0,this.B=mi[1]|0,this.C=mi[2]|0,this.D=mi[3]|0,this.E=mi[4]|0,this.F=mi[5]|0,this.G=mi[6]|0,this.H=mi[7]|0}get(){const{A:e,B:t,C:i,D:r,E:n,F:o,G:a,H:c}=this;return[e,t,i,r,n,o,a,c]}set(e,t,i,r,n,o,a,c){this.A=e|0,this.B=t|0,this.C=i|0,this.D=r|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,t){for(let d=0;d<16;d++,t+=4)bi[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){const p=bi[d-15],f=bi[d-2],g=zs(p,7)^zs(p,18)^p>>>3,y=zs(f,17)^zs(f,19)^f>>>10;bi[d]=y+bi[d-7]+g+bi[d-16]|0}let{A:i,B:r,C:n,D:o,E:a,F:c,G:l,H:h}=this;for(let d=0;d<64;d++){const p=zs(a,6)^zs(a,11)^zs(a,25),f=h+p+s1(a,c,l)+n1[d]+bi[d]|0,g=(zs(i,2)^zs(i,13)^zs(i,22))+i1(i,r,n)|0;h=l,l=c,c=a,a=o+f|0,o=n,n=r,r=i,i=f+g|0}i=i+this.A|0,r=r+this.B|0,n=n+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(i,r,n,o,a,c,l,h)}roundClean(){bi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const uc=Wf(()=>new o1);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ry=BigInt(0);function Rh(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function ny(s){if(!Rh(s))throw new Error("Uint8Array expected")}const a1=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function c1(s){ny(s);let e="";for(let t=0;t<s.length;t++)e+=a1[s[t]];return e}function l1(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);return s===""?ry:BigInt("0x"+s)}const ii={_0:48,_9:57,A:65,F:70,a:97,f:102};function cd(s){if(s>=ii._0&&s<=ii._9)return s-ii._0;if(s>=ii.A&&s<=ii.F)return s-(ii.A-10);if(s>=ii.a&&s<=ii.f)return s-(ii.a-10)}function oy(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);const e=s.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(t);for(let r=0,n=0;r<t;r++,n+=2){const o=cd(s.charCodeAt(n)),a=cd(s.charCodeAt(n+1));if(o===void 0||a===void 0){const c=s[n]+s[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}i[r]=o*16+a}return i}function ld(s){return ny(s),l1(c1(Uint8Array.from(s).reverse()))}function h1(s,e){return oy(s.toString(16).padStart(e*2,"0"))}function u1(s,e){return h1(s,e).reverse()}function hd(s,e,t){let i;if(typeof e=="string")try{i=oy(e)}catch(n){throw new Error(s+" must be hex string or Uint8Array, cause: "+n)}else if(Rh(e))i=Uint8Array.from(e);else throw new Error(s+" must be hex string or Uint8Array");const r=i.length;if(typeof t=="number"&&r!==t)throw new Error(s+" of length "+t+" expected, got "+r);return i}const Lc=s=>typeof s=="bigint"&&ry<=s;function d1(s,e,t){return Lc(s)&&Lc(e)&&Lc(t)&&e<=s&&s<t}function ud(s,e,t,i){if(!d1(e,t,i))throw new Error("expected valid "+s+": "+t+" <= n < "+i+", got "+e)}const p1={bigint:s=>typeof s=="bigint",function:s=>typeof s=="function",boolean:s=>typeof s=="boolean",string:s=>typeof s=="string",stringOrUint8Array:s=>typeof s=="string"||Rh(s),isSafeInteger:s=>Number.isSafeInteger(s),array:s=>Array.isArray(s),field:(s,e)=>e.Fp.isValid(s),hash:s=>typeof s=="function"&&Number.isSafeInteger(s.outputLen)};function g1(s,e,t={}){const i=(r,n,o)=>{const a=p1[n];if(typeof a!="function")throw new Error("invalid validator function");const c=s[r];if(!(o&&c===void 0)&&!a(c,s))throw new Error("param "+String(r)+" is invalid. Expected "+n+", got "+c)};for(const[r,n]of Object.entries(e))i(r,n,!1);for(const[r,n]of Object.entries(t))i(r,n,!0);return s}const dn=BigInt(0),da=BigInt(1);function ay(s,e){const t=s%e;return t>=dn?t:e+t}function f1(s,e,t){if(e<dn)throw new Error("invalid exponent, negatives unsupported");if(t<=dn)throw new Error("invalid modulus");if(t===da)return dn;let i=da;for(;e>dn;)e&da&&(i=i*s%t),s=s*s%t,e>>=da;return i}function Ds(s,e,t){let i=s;for(;e-- >dn;)i*=i,i%=t;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Cr=BigInt(0),zc=BigInt(1);function y1(s){return g1(s,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...s})}function w1(s){const e=y1(s),{P:t}=e,i=w=>ay(w,t),r=e.montgomeryBits,n=Math.ceil(r/8),o=e.nByteLength,a=e.adjustScalarBytes||(w=>w),c=e.powPminus2||(w=>f1(w,t-BigInt(2),t));function l(w,N,_){const C=i(w*(N-_));return N=i(N-C),_=i(_+C),[N,_]}const h=(e.a-BigInt(2))/BigInt(4);function d(w,N){ud("u",w,Cr,t),ud("scalar",N,Cr,t);const _=N,C=w;let T=zc,P=Cr,O=w,$=zc,q=Cr,j;for(let B=BigInt(r-1);B>=Cr;B--){const W=_>>B&zc;q^=W,j=l(q,T,O),T=j[0],O=j[1],j=l(q,P,$),P=j[0],$=j[1],q=W;const V=T+P,H=i(V*V),K=T-P,Q=i(K*K),S=H-Q,z=O+$,ee=O-$,Z=i(ee*V),ve=i(z*K),pe=Z+ve,te=Z-ve;O=i(pe*pe),$=i(C*i(te*te)),T=i(H*Q),P=i(S*(H+i(h*S)))}j=l(q,T,O),T=j[0],O=j[1],j=l(q,P,$),P=j[0],$=j[1];const G=c(P);return i(T*G)}function p(w){return u1(i(w),n)}function f(w){const N=hd("u coordinate",w,n);return o===32&&(N[31]&=127),ld(N)}function g(w){const N=hd("scalar",w),_=N.length;if(_!==n&&_!==o){let C=""+n+" or "+o;throw new Error("invalid scalar, expected "+C+" bytes, got "+_)}return ld(a(N))}function y(w,N){const _=f(N),C=g(w),T=d(_,C);if(T===Cr)throw new Error("invalid private or public key received");return p(T)}const v=p(e.Gu);function b(w){return y(w,v)}return{scalarMult:y,scalarMultBase:b,getSharedSecret:(w,N)=>y(w,N),getPublicKey:w=>b(w),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:v}}const Dl=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const m1=BigInt(1),dd=BigInt(2),b1=BigInt(3),v1=BigInt(5);BigInt(8);function I1(s){const e=BigInt(10),t=BigInt(20),i=BigInt(40),r=BigInt(80),n=Dl,o=s*s%n*s%n,a=Ds(o,dd,n)*o%n,c=Ds(a,m1,n)*s%n,l=Ds(c,v1,n)*c%n,h=Ds(l,e,n)*l%n,d=Ds(h,t,n)*h%n,p=Ds(d,i,n)*d%n,f=Ds(p,r,n)*p%n,g=Ds(f,r,n)*p%n,y=Ds(g,e,n)*l%n;return{pow_p_5_8:Ds(y,dd,n)*s%n,b2:o}}function E1(s){return s[0]&=248,s[31]&=127,s[31]|=64,s}const kl=w1({P:Dl,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:s=>{const e=Dl,{pow_p_5_8:t,b2:i}=I1(s);return ay(Ds(t,b1,e)*i,e)},adjustScalarBytes:E1,randomBytes:qo}),cy="base10",qt="base16",Mi="base64pad",Bn="base64url",Bo="utf8",ly=0,di=1,Ho=2,N1=0,pd=1,fo=12,Uh=32;function A1(){const s=kl.utils.randomPrivateKey(),e=kl.getPublicKey(s);return{privateKey:u.toString(s,qt),publicKey:u.toString(e,qt)}}function jl(){const s=qo(Uh);return u.toString(s,qt)}function _1(s,e){const t=kl.getSharedSecret(u.fromString(s,qt),u.fromString(e,qt)),i=e1(uc,t,void 0,void 0,Uh);return u.toString(i,qt)}function ka(s){const e=uc(u.fromString(s,qt));return u.toString(e,qt)}function hi(s){const e=uc(u.fromString(s,Bo));return u.toString(e,qt)}function hy(s){return u.fromString(`${s}`,cy)}function hr(s){return Number(u.toString(s,cy))}function C1(s){const e=hy(typeof s.type<"u"?s.type:ly);if(hr(e)===di&&typeof s.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof s.senderPublicKey<"u"?u.fromString(s.senderPublicKey,qt):void 0,i=typeof s.iv<"u"?u.fromString(s.iv,qt):qo(fo),r=u.fromString(s.symKey,qt),n=sy(r,i).encrypt(u.fromString(s.message,Bo));return uy({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:s.encoding})}function S1(s){const e=u.fromString(s.symKey,qt),{sealed:t,iv:i}=To(s),r=sy(e,i).decrypt(t);if(r===null)throw new Error("Failed to decrypt");return u.toString(r,Bo)}function T1(s,e){const t=hy(Ho),i=qo(fo),r=u.fromString(s,Bo);return uy({type:t,sealed:r,iv:i,encoding:e})}function P1(s,e){const{sealed:t}=To({encoded:s,encoding:e});return u.toString(t,Bo)}function uy(s){const{encoding:e=Mi}=s;if(hr(s.type)===Ho)return u.toString(u.concat([s.type,s.sealed]),e);if(hr(s.type)===di){if(typeof s.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return u.toString(u.concat([s.type,s.senderPublicKey,s.iv,s.sealed]),e)}return u.toString(u.concat([s.type,s.iv,s.sealed]),e)}function To(s){const{encoded:e,encoding:t=Mi}=s,i=u.fromString(e,t),r=i.slice(N1,pd),n=pd;if(hr(r)===di){const l=n+Uh,h=l+fo,d=i.slice(n,l),p=i.slice(l,h),f=i.slice(h);return{type:r,sealed:f,iv:p,senderPublicKey:d}}if(hr(r)===Ho){const l=i.slice(n),h=qo(fo);return{type:r,sealed:l,iv:h}}const o=n+fo,a=i.slice(n,o),c=i.slice(o);return{type:r,sealed:c,iv:a}}function $1(s,e){const t=To({encoded:s,encoding:e==null?void 0:e.encoding});return dy({type:hr(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?u.toString(t.senderPublicKey,qt):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function dy(s){const e=(s==null?void 0:s.type)||ly;if(e===di){if(typeof(s==null?void 0:s.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(s==null?void 0:s.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:s==null?void 0:s.senderPublicKey,receiverPublicKey:s==null?void 0:s.receiverPublicKey}}function gd(s){return s.type===di&&typeof s.senderPublicKey=="string"&&typeof s.receiverPublicKey=="string"}function fd(s){return s.type===Ho}function M1(s){return new Df.ec("p256").keyFromPublic({x:A.dist.Buffer.from(s.x,"base64").toString("hex"),y:A.dist.Buffer.from(s.y,"base64").toString("hex")},"hex")}function x1(s){let e=s.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function O1(s){return A.dist.Buffer.from(x1(s),"base64")}function D1(s,e){const[t,i,r]=s.split("."),n=O1(r);if(n.length!==64)throw new Error("Invalid signature length");const o=n.slice(0,32).toString("hex"),a=n.slice(32,64).toString("hex"),c=`${t}.${i}`,l=uc(c),h=M1(e),d=u.toString(l,qt);if(!h.verify(d,{r:o,s:a}))throw new Error("Invalid signature");return u.sn(s).payload}const k1="irn";function Ka(s){return(s==null?void 0:s.relay)||{protocol:k1}}function ao(s){const e=u.C[s];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${s}`);return e}function j1(s,e="-"){const t={},i="relay"+e;return Object.keys(s).forEach(r=>{if(r.startsWith(i)){const n=r.replace(i,""),o=s[r];t[n]=o}}),t}function yd(s){if(!s.includes("wc:")){const l=Bf(s);l!=null&&l.includes("wc:")&&(s=l)}s=s.includes("wc://")?s.replace("wc://",""):s,s=s.includes("wc:")?s.replace("wc:",""):s;const e=s.indexOf(":"),t=s.indexOf("?")!==-1?s.indexOf("?"):void 0,i=s.substring(0,e),r=s.substring(e+1,t).split("@"),n=typeof t<"u"?s.substring(t):"",o=new URLSearchParams(n),a={};o.forEach((l,h)=>{a[h]=l});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:R1(r[0]),version:parseInt(r[1],10),symKey:a.symKey,relay:j1(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function R1(s){return s.startsWith("//")?s.substring(2):s}function U1(s,e="-"){const t="relay",i={};return Object.keys(s).forEach(r=>{const n=r,o=t+e+n;s[n]&&(i[o]=s[n])}),i}function wd(s){const e=new URLSearchParams,t=U1(s.relay);Object.keys(t).sort().forEach(r=>{e.set(r,t[r])}),e.set("symKey",s.symKey),s.expiryTimestamp&&e.set("expiryTimestamp",s.expiryTimestamp.toString()),s.methods&&e.set("methods",s.methods.join(","));const i=e.toString();return`${s.protocol}:${s.topic}@${s.version}?${i}`}function pa(s,e,t){return`${s}?wc_ev=${t}&topic=${e}`}function Pn(s){const e=[];return s.forEach(t=>{const[i,r]=t.split(":");e.push(`${i}:${r}`)}),e}function L1(s){const e=[];return Object.values(s).forEach(t=>{e.push(...Pn(t.accounts))}),e}function z1(s,e){const t=[];return Object.values(s).forEach(i=>{Pn(i.accounts).includes(e)&&t.push(...i.methods)}),t}function F1(s,e){const t=[];return Object.values(s).forEach(i=>{Pn(i.accounts).includes(e)&&t.push(...i.events)}),t}function Lh(s){return s.includes(":")}function co(s){return Lh(s)?s.split(":")[0]:s}function q1(s){const e={};return s==null||s.forEach(t=>{var i;const[r,n]=t.split(":");e[r]||(e[r]={accounts:[],chains:[],events:[],methods:[]}),e[r].accounts.push(t),(i=e[r].chains)==null||i.push(`${r}:${n}`)}),e}function md(s,e){e=e.map(i=>i.replace("did:pkh:",""));const t=q1(e);for(const[i,r]of Object.entries(t))r.methods?r.methods=Oa(r.methods,s):r.methods=s,r.events=["chainChanged","accountsChanged"];return t}const B1={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},H1={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function U(s,e){const{message:t,code:i}=H1[s];return{message:e?`${t} ${e}`:t,code:i}}function Re(s,e){const{message:t,code:i}=B1[s];return{message:e?`${t} ${e}`:t,code:i}}function ur(s,e){return!!Array.isArray(s)}function Po(s){return Object.getPrototypeOf(s)===Object.prototype&&Object.keys(s).length}function Wt(s){return typeof s>"u"}function nt(s,e){return e&&Wt(s)?!0:typeof s=="string"&&!!s.trim().length}function zh(s,e){return e&&Wt(s)?!0:typeof s=="number"&&!isNaN(s)}function W1(s,e){const{requiredNamespaces:t}=e,i=Object.keys(s.namespaces),r=Object.keys(t);let n=!0;return nr(r,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:l}=s.namespaces[o],h=Pn(a),d=t[o];(!nr(jf(o,d),h)||!nr(d.methods,c)||!nr(d.events,l))&&(n=!1)}),n):!1}function Ga(s){return nt(s,!1)&&s.includes(":")?s.split(":").length===2:!1}function V1(s){if(nt(s,!1)&&s.includes(":")){const e=s.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&Ga(t)}}return!1}function K1(s){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(nt(s,!1)){if(e(s))return!0;const t=Bf(s);return e(t)}}catch{}return!1}function G1(s){var e;return(e=s==null?void 0:s.proposer)==null?void 0:e.publicKey}function Y1(s){return s==null?void 0:s.topic}function Q1(s,e){let t=null;return nt(s==null?void 0:s.publicKey,!1)||(t=U("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function bd(s){let e=!0;return ur(s)?s.length&&(e=s.every(t=>nt(t,!1))):e=!1,e}function Z1(s,e,t){let i=null;return ur(e)&&e.length?e.forEach(r=>{i||Ga(r)||(i=Re("UNSUPPORTED_CHAINS",`${t}, chain ${r} should be a string and conform to "namespace:chainId" format`))}):Ga(s)||(i=Re("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function J1(s,e,t){let i=null;return Object.entries(s).forEach(([r,n])=>{if(i)return;const o=Z1(r,jf(r,n),`${e} ${t}`);o&&(i=o)}),i}function X1(s,e){let t=null;return ur(s)?s.forEach(i=>{t||V1(i)||(t=Re("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Re("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function eE(s,e){let t=null;return Object.values(s).forEach(i=>{if(t)return;const r=X1(i==null?void 0:i.accounts,`${e} namespace`);r&&(t=r)}),t}function tE(s,e){let t=null;return bd(s==null?void 0:s.methods)?bd(s==null?void 0:s.events)||(t=Re("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Re("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function py(s,e){let t=null;return Object.values(s).forEach(i=>{if(t)return;const r=tE(i,`${e}, namespace`);r&&(t=r)}),t}function sE(s,e,t){let i=null;if(s&&Po(s)){const r=py(s,e);r&&(i=r);const n=J1(s,e,t);n&&(i=n)}else i=U("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Fc(s,e){let t=null;if(s&&Po(s)){const i=py(s,e);i&&(t=i);const r=eE(s,e);r&&(t=r)}else t=U("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function gy(s){return nt(s.protocol,!0)}function iE(s,e){let t=!1;return s?s&&ur(s)&&s.length&&s.forEach(i=>{t=gy(i)}):t=!0,t}function rE(s){return typeof s=="number"}function Jt(s){return typeof s<"u"&&typeof s!==null}function nE(s){return!(!s||typeof s!="object"||!s.code||!zh(s.code,!1)||!s.message||!nt(s.message,!1))}function oE(s){return!(Wt(s)||!nt(s.method,!1))}function aE(s){return!(Wt(s)||Wt(s.result)&&Wt(s.error)||!zh(s.id,!1)||!nt(s.jsonrpc,!1))}function cE(s){return!(Wt(s)||!nt(s.name,!1))}function vd(s,e){return!(!Ga(e)||!L1(s).includes(e))}function lE(s,e,t){return nt(t,!1)?z1(s,e).includes(t):!1}function hE(s,e,t){return nt(t,!1)?F1(s,e).includes(t):!1}function Id(s,e,t){let i=null;const r=uE(s),n=dE(e),o=Object.keys(r),a=Object.keys(n),c=Ed(Object.keys(s)),l=Ed(Object.keys(e)),h=c.filter(d=>!l.includes(d));return h.length&&(i=U("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.
@@ -9,7 +9,7 @@ ${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+A.dist.Buffer.from(nI(t)
9
9
  Approved: ${a.toString()}`)),Object.keys(e).forEach(d=>{if(!d.includes(":")||i)return;const p=Pn(e[d].accounts);p.includes(d)||(i=U("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${d}
10
10
  Required: ${d}
11
11
  Approved: ${p.toString()}`))}),o.forEach(d=>{i||(nr(r[d].methods,n[d].methods)?nr(r[d].events,n[d].events)||(i=U("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${d}`)):i=U("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${d}`))}),i}function uE(s){const e={};return Object.keys(s).forEach(t=>{var i;t.includes(":")?e[t]=s[t]:(i=s[t].chains)==null||i.forEach(r=>{e[r]={methods:s[t].methods,events:s[t].events}})}),e}function Ed(s){return[...new Set(s.map(e=>e.includes(":")?e.split(":")[0]:e))]}function dE(s){const e={};return Object.keys(s).forEach(t=>{if(t.includes(":"))e[t]=s[t];else{const i=Pn(s[t].accounts);i==null||i.forEach(r=>{e[r]={accounts:s[t].accounts.filter(n=>n.includes(`${r}:`)),methods:s[t].methods,events:s[t].events}})}}),e}function pE(s,e){return zh(s,!1)&&s<=e.max&&s>=e.min}function Nd(){const s=Fo();return new Promise(e=>{switch(s){case ls.browser:e(gE());break;case ls.reactNative:e(fE());break;case ls.node:e(yE());break;default:e(!0)}})}function gE(){return zo()&&(navigator==null?void 0:navigator.onLine)}async function fE(){if(zi()&&typeof A.dist.global<"u"&&A.dist.global!=null&&A.dist.global.NetInfo){const s=await(A.dist.global==null?void 0:A.dist.global.NetInfo.fetch());return s==null?void 0:s.isConnected}return!0}function yE(){return!0}function wE(s){switch(Fo()){case ls.browser:mE(s);break;case ls.reactNative:bE(s);break}}function mE(s){!zi()&&zo()&&(window.addEventListener("online",()=>s(!0)),window.addEventListener("offline",()=>s(!1)))}function bE(s){var e;zi()&&typeof A.dist.global<"u"&&A.dist.global!=null&&A.dist.global.NetInfo&&((e=A.dist.global)==null||e.NetInfo.addEventListener(t=>s(t==null?void 0:t.isConnected)))}const qc={};let Hn=class{static get(e){return qc[e]}static set(e,t){qc[e]=t}static delete(e){delete qc[e]}};var Ya={exports:{}};Ya.exports;(function(s,e){var t=200,i="__lodash_hash_undefined__",r=1,n=2,o=9007199254740991,a="[object Arguments]",c="[object Array]",l="[object AsyncFunction]",h="[object Boolean]",d="[object Date]",p="[object Error]",f="[object Function]",g="[object GeneratorFunction]",y="[object Map]",v="[object Number]",b="[object Null]",w="[object Object]",N="[object Promise]",_="[object Proxy]",C="[object RegExp]",T="[object Set]",P="[object String]",O="[object Symbol]",$="[object Undefined]",q="[object WeakMap]",j="[object ArrayBuffer]",G="[object DataView]",B="[object Float32Array]",W="[object Float64Array]",V="[object Int8Array]",H="[object Int16Array]",K="[object Int32Array]",Q="[object Uint8Array]",S="[object Uint8ClampedArray]",z="[object Uint16Array]",ee="[object Uint32Array]",Z=/[\\^$.*+?()[\]{}|]/g,ve=/^\[object .+?Constructor\]$/,pe=/^(?:0|[1-9]\d*)$/,te={};te[B]=te[W]=te[V]=te[H]=te[K]=te[Q]=te[S]=te[z]=te[ee]=!0,te[a]=te[c]=te[j]=te[h]=te[G]=te[d]=te[p]=te[f]=te[y]=te[v]=te[w]=te[C]=te[T]=te[P]=te[q]=!1;var st=typeof A.commonjsGlobal=="object"&&A.commonjsGlobal&&A.commonjsGlobal.Object===Object&&A.commonjsGlobal,Le=typeof self=="object"&&self&&self.Object===Object&&self,Ie=st||Le||Function("return this")(),ke=e&&!e.nodeType&&e,js=ke&&!0&&s&&!s.nodeType&&s,Rs=js&&js.exports===ke,Xs=Rs&&st.process,Er=function(){try{return Xs&&Xs.binding&&Xs.binding("util")}catch{}}(),Us=Er&&Er.isTypedArray;function Dn(m,E){for(var M=-1,Y=m==null?0:m.length,Ye=0,ae=[];++M<Y;){var it=m[M];E(it,M,m)&&(ae[Ye++]=it)}return ae}function Om(m,E){for(var M=-1,Y=E.length,Ye=m.length;++M<Y;)m[Ye+M]=E[M];return m}function Dm(m,E){for(var M=-1,Y=m==null?0:m.length;++M<Y;)if(E(m[M],M,m))return!0;return!1}function km(m,E){for(var M=-1,Y=Array(m);++M<m;)Y[M]=E(M);return Y}function jm(m){return function(E){return m(E)}}function Rm(m,E){return m.has(E)}function Um(m,E){return m==null?void 0:m[E]}function Lm(m){var E=-1,M=Array(m.size);return m.forEach(function(Y,Ye){M[++E]=[Ye,Y]}),M}function zm(m,E){return function(M){return m(E(M))}}function Fm(m){var E=-1,M=Array(m.size);return m.forEach(function(Y){M[++E]=Y}),M}var qm=Array.prototype,Bm=Function.prototype,ta=Object.prototype,_c=Ie["__core-js_shared__"],hu=Bm.toString,Ls=ta.hasOwnProperty,uu=function(){var m=/[^.]+$/.exec(_c&&_c.keys&&_c.keys.IE_PROTO||"");return m?"Symbol(src)_1."+m:""}(),du=ta.toString,Hm=RegExp("^"+hu.call(Ls).replace(Z,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),pu=Rs?Ie.Buffer:void 0,sa=Ie.Symbol,gu=Ie.Uint8Array,fu=ta.propertyIsEnumerable,Wm=qm.splice,qi=sa?sa.toStringTag:void 0,yu=Object.getOwnPropertySymbols,Vm=pu?pu.isBuffer:void 0,Km=zm(Object.keys,Object),Cc=Nr(Ie,"DataView"),kn=Nr(Ie,"Map"),Sc=Nr(Ie,"Promise"),Tc=Nr(Ie,"Set"),Pc=Nr(Ie,"WeakMap"),jn=Nr(Object,"create"),Gm=Wi(Cc),Ym=Wi(kn),Qm=Wi(Sc),Zm=Wi(Tc),Jm=Wi(Pc),wu=sa?sa.prototype:void 0,$c=wu?wu.valueOf:void 0;function Bi(m){var E=-1,M=m==null?0:m.length;for(this.clear();++E<M;){var Y=m[E];this.set(Y[0],Y[1])}}function Xm(){this.__data__=jn?jn(null):{},this.size=0}function eb(m){var E=this.has(m)&&delete this.__data__[m];return this.size-=E?1:0,E}function tb(m){var E=this.__data__;if(jn){var M=E[m];return M===i?void 0:M}return Ls.call(E,m)?E[m]:void 0}function sb(m){var E=this.__data__;return jn?E[m]!==void 0:Ls.call(E,m)}function ib(m,E){var M=this.__data__;return this.size+=this.has(m)?0:1,M[m]=jn&&E===void 0?i:E,this}Bi.prototype.clear=Xm,Bi.prototype.delete=eb,Bi.prototype.get=tb,Bi.prototype.has=sb,Bi.prototype.set=ib;function ei(m){var E=-1,M=m==null?0:m.length;for(this.clear();++E<M;){var Y=m[E];this.set(Y[0],Y[1])}}function rb(){this.__data__=[],this.size=0}function nb(m){var E=this.__data__,M=ra(E,m);if(M<0)return!1;var Y=E.length-1;return M==Y?E.pop():Wm.call(E,M,1),--this.size,!0}function ob(m){var E=this.__data__,M=ra(E,m);return M<0?void 0:E[M][1]}function ab(m){return ra(this.__data__,m)>-1}function cb(m,E){var M=this.__data__,Y=ra(M,m);return Y<0?(++this.size,M.push([m,E])):M[Y][1]=E,this}ei.prototype.clear=rb,ei.prototype.delete=nb,ei.prototype.get=ob,ei.prototype.has=ab,ei.prototype.set=cb;function Hi(m){var E=-1,M=m==null?0:m.length;for(this.clear();++E<M;){var Y=m[E];this.set(Y[0],Y[1])}}function lb(){this.size=0,this.__data__={hash:new Bi,map:new(kn||ei),string:new Bi}}function hb(m){var E=na(this,m).delete(m);return this.size-=E?1:0,E}function ub(m){return na(this,m).get(m)}function db(m){return na(this,m).has(m)}function pb(m,E){var M=na(this,m),Y=M.size;return M.set(m,E),this.size+=M.size==Y?0:1,this}Hi.prototype.clear=lb,Hi.prototype.delete=hb,Hi.prototype.get=ub,Hi.prototype.has=db,Hi.prototype.set=pb;function ia(m){var E=-1,M=m==null?0:m.length;for(this.__data__=new Hi;++E<M;)this.add(m[E])}function gb(m){return this.__data__.set(m,i),this}function fb(m){return this.__data__.has(m)}ia.prototype.add=ia.prototype.push=gb,ia.prototype.has=fb;function fi(m){var E=this.__data__=new ei(m);this.size=E.size}function yb(){this.__data__=new ei,this.size=0}function wb(m){var E=this.__data__,M=E.delete(m);return this.size=E.size,M}function mb(m){return this.__data__.get(m)}function bb(m){return this.__data__.has(m)}function vb(m,E){var M=this.__data__;if(M instanceof ei){var Y=M.__data__;if(!kn||Y.length<t-1)return Y.push([m,E]),this.size=++M.size,this;M=this.__data__=new Hi(Y)}return M.set(m,E),this.size=M.size,this}fi.prototype.clear=yb,fi.prototype.delete=wb,fi.prototype.get=mb,fi.prototype.has=bb,fi.prototype.set=vb;function Ib(m,E){var M=oa(m),Y=!M&&jb(m),Ye=!M&&!Y&&Mc(m),ae=!M&&!Y&&!Ye&&Cu(m),it=M||Y||Ye||ae,ft=it?km(m.length,String):[],Nt=ft.length;for(var Xe in m)Ls.call(m,Xe)&&!(it&&(Xe=="length"||Ye&&(Xe=="offset"||Xe=="parent")||ae&&(Xe=="buffer"||Xe=="byteLength"||Xe=="byteOffset")||Mb(Xe,Nt)))&&ft.push(Xe);return ft}function ra(m,E){for(var M=m.length;M--;)if(Eu(m[M][0],E))return M;return-1}function Eb(m,E,M){var Y=E(m);return oa(m)?Y:Om(Y,M(m))}function Rn(m){return m==null?m===void 0?$:b:qi&&qi in Object(m)?Pb(m):kb(m)}function mu(m){return Un(m)&&Rn(m)==a}function bu(m,E,M,Y,Ye){return m===E?!0:m==null||E==null||!Un(m)&&!Un(E)?m!==m&&E!==E:Nb(m,E,M,Y,bu,Ye)}function Nb(m,E,M,Y,Ye,ae){var it=oa(m),ft=oa(E),Nt=it?c:yi(m),Xe=ft?c:yi(E);Nt=Nt==a?w:Nt,Xe=Xe==a?w:Xe;var ts=Nt==w,Cs=Xe==w,Rt=Nt==Xe;if(Rt&&Mc(m)){if(!Mc(E))return!1;it=!0,ts=!1}if(Rt&&!ts)return ae||(ae=new fi),it||Cu(m)?vu(m,E,M,Y,Ye,ae):Sb(m,E,Nt,M,Y,Ye,ae);if(!(M&r)){var ps=ts&&Ls.call(m,"__wrapped__"),gs=Cs&&Ls.call(E,"__wrapped__");if(ps||gs){var wi=ps?m.value():m,ti=gs?E.value():E;return ae||(ae=new fi),Ye(wi,ti,M,Y,ae)}}return Rt?(ae||(ae=new fi),Tb(m,E,M,Y,Ye,ae)):!1}function Ab(m){if(!_u(m)||Ob(m))return!1;var E=Nu(m)?Hm:ve;return E.test(Wi(m))}function _b(m){return Un(m)&&Au(m.length)&&!!te[Rn(m)]}function Cb(m){if(!Db(m))return Km(m);var E=[];for(var M in Object(m))Ls.call(m,M)&&M!="constructor"&&E.push(M);return E}function vu(m,E,M,Y,Ye,ae){var it=M&r,ft=m.length,Nt=E.length;if(ft!=Nt&&!(it&&Nt>ft))return!1;var Xe=ae.get(m);if(Xe&&ae.get(E))return Xe==E;var ts=-1,Cs=!0,Rt=M&n?new ia:void 0;for(ae.set(m,E),ae.set(E,m);++ts<ft;){var ps=m[ts],gs=E[ts];if(Y)var wi=it?Y(gs,ps,ts,E,m,ae):Y(ps,gs,ts,m,E,ae);if(wi!==void 0){if(wi)continue;Cs=!1;break}if(Rt){if(!Dm(E,function(ti,Vi){if(!Rm(Rt,Vi)&&(ps===ti||Ye(ps,ti,M,Y,ae)))return Rt.push(Vi)})){Cs=!1;break}}else if(!(ps===gs||Ye(ps,gs,M,Y,ae))){Cs=!1;break}}return ae.delete(m),ae.delete(E),Cs}function Sb(m,E,M,Y,Ye,ae,it){switch(M){case G:if(m.byteLength!=E.byteLength||m.byteOffset!=E.byteOffset)return!1;m=m.buffer,E=E.buffer;case j:return!(m.byteLength!=E.byteLength||!ae(new gu(m),new gu(E)));case h:case d:case v:return Eu(+m,+E);case p:return m.name==E.name&&m.message==E.message;case C:case P:return m==E+"";case y:var ft=Lm;case T:var Nt=Y&r;if(ft||(ft=Fm),m.size!=E.size&&!Nt)return!1;var Xe=it.get(m);if(Xe)return Xe==E;Y|=n,it.set(m,E);var ts=vu(ft(m),ft(E),Y,Ye,ae,it);return it.delete(m),ts;case O:if($c)return $c.call(m)==$c.call(E)}return!1}function Tb(m,E,M,Y,Ye,ae){var it=M&r,ft=Iu(m),Nt=ft.length,Xe=Iu(E),ts=Xe.length;if(Nt!=ts&&!it)return!1;for(var Cs=Nt;Cs--;){var Rt=ft[Cs];if(!(it?Rt in E:Ls.call(E,Rt)))return!1}var ps=ae.get(m);if(ps&&ae.get(E))return ps==E;var gs=!0;ae.set(m,E),ae.set(E,m);for(var wi=it;++Cs<Nt;){Rt=ft[Cs];var ti=m[Rt],Vi=E[Rt];if(Y)var Su=it?Y(Vi,ti,Rt,E,m,ae):Y(ti,Vi,Rt,m,E,ae);if(!(Su===void 0?ti===Vi||Ye(ti,Vi,M,Y,ae):Su)){gs=!1;break}wi||(wi=Rt=="constructor")}if(gs&&!wi){var aa=m.constructor,ca=E.constructor;aa!=ca&&"constructor"in m&&"constructor"in E&&!(typeof aa=="function"&&aa instanceof aa&&typeof ca=="function"&&ca instanceof ca)&&(gs=!1)}return ae.delete(m),ae.delete(E),gs}function Iu(m){return Eb(m,Lb,$b)}function na(m,E){var M=m.__data__;return xb(E)?M[typeof E=="string"?"string":"hash"]:M.map}function Nr(m,E){var M=Um(m,E);return Ab(M)?M:void 0}function Pb(m){var E=Ls.call(m,qi),M=m[qi];try{m[qi]=void 0;var Y=!0}catch{}var Ye=du.call(m);return Y&&(E?m[qi]=M:delete m[qi]),Ye}var $b=yu?function(m){return m==null?[]:(m=Object(m),Dn(yu(m),function(E){return fu.call(m,E)}))}:zb,yi=Rn;(Cc&&yi(new Cc(new ArrayBuffer(1)))!=G||kn&&yi(new kn)!=y||Sc&&yi(Sc.resolve())!=N||Tc&&yi(new Tc)!=T||Pc&&yi(new Pc)!=q)&&(yi=function(m){var E=Rn(m),M=E==w?m.constructor:void 0,Y=M?Wi(M):"";if(Y)switch(Y){case Gm:return G;case Ym:return y;case Qm:return N;case Zm:return T;case Jm:return q}return E});function Mb(m,E){return E=E??o,!!E&&(typeof m=="number"||pe.test(m))&&m>-1&&m%1==0&&m<E}function xb(m){var E=typeof m;return E=="string"||E=="number"||E=="symbol"||E=="boolean"?m!=="__proto__":m===null}function Ob(m){return!!uu&&uu in m}function Db(m){var E=m&&m.constructor,M=typeof E=="function"&&E.prototype||ta;return m===M}function kb(m){return du.call(m)}function Wi(m){if(m!=null){try{return hu.call(m)}catch{}try{return m+""}catch{}}return""}function Eu(m,E){return m===E||m!==m&&E!==E}var jb=mu(function(){return arguments}())?mu:function(m){return Un(m)&&Ls.call(m,"callee")&&!fu.call(m,"callee")},oa=Array.isArray;function Rb(m){return m!=null&&Au(m.length)&&!Nu(m)}var Mc=Vm||Fb;function Ub(m,E){return bu(m,E)}function Nu(m){if(!_u(m))return!1;var E=Rn(m);return E==f||E==g||E==l||E==_}function Au(m){return typeof m=="number"&&m>-1&&m%1==0&&m<=o}function _u(m){var E=typeof m;return m!=null&&(E=="object"||E=="function")}function Un(m){return m!=null&&typeof m=="object"}var Cu=Us?jm(Us):_b;function Lb(m){return Rb(m)?Ib(m):Cb(m)}function zb(){return[]}function Fb(){return!1}s.exports=Ub})(Ya,Ya.exports);var vE=Ya.exports;const IE=A.getDefaultExportFromCjs(vE),fy="wc",yy=2,Rl="core",Zs=`${fy}@2:${Rl}:`,EE={logger:"error"},NE={database:":memory:"},AE="crypto",Ad="client_ed25519_seed",_E=u.cjs.ONE_DAY,CE="keychain",SE="0.3",TE="messages",PE="0.3",_d=u.cjs.SIX_HOURS,$E="publisher",wy="irn",ME="error",my="wss://relay.walletconnect.org",xE="relayer",It={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},OE="_subscription",fs={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},DE=.1,Ul="2.19.0",Ze={link_mode:"link_mode",relay:"relay"},kE="0.3",jE="WALLETCONNECT_CLIENT_ID",Cd="WALLETCONNECT_LINK_MODE_APPS",ns={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},RE="subscription",UE="0.3",LE=u.cjs.FIVE_SECONDS*1e3,zE="pairing",FE="0.3",Wn={wc_pairingDelete:{req:{ttl:u.cjs.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:u.cjs.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:u.cjs.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:u.cjs.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:u.cjs.ONE_DAY,prompt:!1,tag:0},res:{ttl:u.cjs.ONE_DAY,prompt:!1,tag:0}}},tr={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Ss={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},qE="history",BE="0.3",HE="expirer",bs={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},WE="0.3",VE="verify-api",KE="https://verify.walletconnect.com",by="https://verify.walletconnect.org",yo=by,GE=`${yo}/v3`,YE=[KE,by],QE="echo",ZE="https://echo.walletconnect.com",Gs={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},ci={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Ts={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Ki={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Gi={authenticated_session_approve_started:"authenticated_session_approve_started",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve"},Vn={no_internet_connection:"no_internet_connection",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},JE=.1,XE="event-client",eN=86400,tN="https://pulse.walletconnect.org/batch";function sN(s,e){if(s.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var r=0;r<s.length;r++){var n=s.charAt(r),o=n.charCodeAt(0);if(t[o]!==255)throw new TypeError(n+" is ambiguous");t[o]=r}var a=s.length,c=s.charAt(0),l=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function d(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var y=0,v=0,b=0,w=g.length;b!==w&&g[b]===0;)b++,y++;for(var N=(w-b)*h+1>>>0,_=new Uint8Array(N);b!==w;){for(var C=g[b],T=0,P=N-1;(C!==0||T<v)&&P!==-1;P--,T++)C+=256*_[P]>>>0,_[P]=C%a>>>0,C=C/a>>>0;if(C!==0)throw new Error("Non-zero carry");v=T,b++}for(var O=N-v;O!==N&&_[O]===0;)O++;for(var $=c.repeat(y);O<N;++O)$+=s.charAt(_[O]);return $}function p(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var y=0;if(g[y]!==" "){for(var v=0,b=0;g[y]===c;)v++,y++;for(var w=(g.length-y)*l+1>>>0,N=new Uint8Array(w);g[y];){var _=t[g.charCodeAt(y)];if(_===255)return;for(var C=0,T=w-1;(_!==0||C<b)&&T!==-1;T--,C++)_+=a*N[T]>>>0,N[T]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");b=C,y++}if(g[y]!==" "){for(var P=w-b;P!==w&&N[P]===0;)P++;for(var O=new Uint8Array(v+(w-P)),$=v;P!==w;)O[$++]=N[P++];return O}}}function f(g){var y=p(g);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:p,decode:f}}var iN=sN,rN=iN;const vy=s=>{if(s instanceof Uint8Array&&s.constructor.name==="Uint8Array")return s;if(s instanceof ArrayBuffer)return new Uint8Array(s);if(ArrayBuffer.isView(s))return new Uint8Array(s.buffer,s.byteOffset,s.byteLength);throw new Error("Unknown type, must be binary type")},nN=s=>new TextEncoder().encode(s),oN=s=>new TextDecoder().decode(s);let aN=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},cN=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Iy(this,e)}},lN=class{constructor(e){this.decoders=e}or(e){return Iy(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const Iy=(s,e)=>new lN({...s.decoders||{[s.prefix]:s},...e.decoders||{[e.prefix]:e}});let hN=class{constructor(e,t,i,r){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=r,this.encoder=new aN(e,t,i),this.decoder=new cN(e,t,r)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const dc=({name:s,prefix:e,encode:t,decode:i})=>new hN(s,e,t,i),Wo=({prefix:s,name:e,alphabet:t})=>{const{encode:i,decode:r}=rN(t,e);return dc({prefix:s,name:e,encode:i,decode:n=>vy(r(n))})},uN=(s,e,t,i)=>{const r={};for(let h=0;h<e.length;++h)r[e[h]]=h;let n=s.length;for(;s[n-1]==="=";)--n;const o=new Uint8Array(n*t/8|0);let a=0,c=0,l=0;for(let h=0;h<n;++h){const d=r[s[h]];if(d===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<t|d,a+=t,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},dN=(s,e,t)=>{const i=e[e.length-1]==="=",r=(1<<t)-1;let n="",o=0,a=0;for(let c=0;c<s.length;++c)for(a=a<<8|s[c],o+=8;o>t;)o-=t,n+=e[r&a>>o];if(o&&(n+=e[r&a<<t-o]),i)for(;n.length*t&7;)n+="=";return n},kt=({name:s,prefix:e,bitsPerChar:t,alphabet:i})=>dc({prefix:e,name:s,encode(r){return dN(r,i,t)},decode(r){return uN(r,i,t,s)}}),pN=dc({prefix:"\0",name:"identity",encode:s=>oN(s),decode:s=>nN(s)});var gN=Object.freeze({__proto__:null,identity:pN});const fN=kt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var yN=Object.freeze({__proto__:null,base2:fN});const wN=kt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var mN=Object.freeze({__proto__:null,base8:wN});const bN=Wo({prefix:"9",name:"base10",alphabet:"0123456789"});var vN=Object.freeze({__proto__:null,base10:bN});const IN=kt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),EN=kt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var NN=Object.freeze({__proto__:null,base16:IN,base16upper:EN});const AN=kt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_N=kt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),CN=kt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),SN=kt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),TN=kt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),PN=kt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),$N=kt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),MN=kt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xN=kt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ON=Object.freeze({__proto__:null,base32:AN,base32upper:_N,base32pad:CN,base32padupper:SN,base32hex:TN,base32hexupper:PN,base32hexpad:$N,base32hexpadupper:MN,base32z:xN});const DN=Wo({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),kN=Wo({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var jN=Object.freeze({__proto__:null,base36:DN,base36upper:kN});const RN=Wo({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),UN=Wo({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var LN=Object.freeze({__proto__:null,base58btc:RN,base58flickr:UN});const zN=kt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),FN=kt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qN=kt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),BN=kt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var HN=Object.freeze({__proto__:null,base64:zN,base64pad:FN,base64url:qN,base64urlpad:BN});const Ey=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),WN=Ey.reduce((s,e,t)=>(s[t]=e,s),[]),VN=Ey.reduce((s,e,t)=>(s[e.codePointAt(0)]=t,s),[]);function KN(s){return s.reduce((e,t)=>(e+=WN[t],e),"")}function GN(s){const e=[];for(const t of s){const i=VN[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const YN=dc({prefix:"🚀",name:"base256emoji",encode:KN,decode:GN});var QN=Object.freeze({__proto__:null,base256emoji:YN}),ZN=Ny,Sd=128,JN=-128,XN=Math.pow(2,31);function Ny(s,e,t){e=e||[],t=t||0;for(var i=t;s>=XN;)e[t++]=s&255|Sd,s/=128;for(;s&JN;)e[t++]=s&255|Sd,s>>>=7;return e[t]=s|0,Ny.bytes=t-i+1,e}var eA=Ll,tA=128,Td=127;function Ll(s,i){var t=0,i=i||0,r=0,n=i,o,a=s.length;do{if(n>=a)throw Ll.bytes=0,new RangeError("Could not decode varint");o=s[n++],t+=r<28?(o&Td)<<r:(o&Td)*Math.pow(2,r),r+=7}while(o>=tA);return Ll.bytes=n-i,t}var sA=Math.pow(2,7),iA=Math.pow(2,14),rA=Math.pow(2,21),nA=Math.pow(2,28),oA=Math.pow(2,35),aA=Math.pow(2,42),cA=Math.pow(2,49),lA=Math.pow(2,56),hA=Math.pow(2,63),uA=function(s){return s<sA?1:s<iA?2:s<rA?3:s<nA?4:s<oA?5:s<aA?6:s<cA?7:s<lA?8:s<hA?9:10},dA={encode:ZN,decode:eA,encodingLength:uA},Ay=dA;const Pd=(s,e,t=0)=>(Ay.encode(s,e,t),e),$d=s=>Ay.encodingLength(s),zl=(s,e)=>{const t=e.byteLength,i=$d(s),r=i+$d(t),n=new Uint8Array(r+t);return Pd(s,n,0),Pd(t,n,i),n.set(e,r),new pA(s,t,e,n)};let pA=class{constructor(e,t,i,r){this.code=e,this.size=t,this.digest=i,this.bytes=r}};const _y=({name:s,code:e,encode:t})=>new gA(s,e,t);let gA=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?zl(this.code,t):t.then(i=>zl(this.code,i))}else throw Error("Unknown type, must be binary type")}};const Cy=s=>async e=>new Uint8Array(await crypto.subtle.digest(s,e)),fA=_y({name:"sha2-256",code:18,encode:Cy("SHA-256")}),yA=_y({name:"sha2-512",code:19,encode:Cy("SHA-512")});var wA=Object.freeze({__proto__:null,sha256:fA,sha512:yA});const Sy=0,mA="identity",Ty=vy,bA=s=>zl(Sy,Ty(s)),vA={code:Sy,name:mA,encode:Ty,digest:bA};var IA=Object.freeze({__proto__:null,identity:vA});new TextEncoder,new TextDecoder;const Md={...gN,...yN,...mN,...vN,...NN,...ON,...jN,...LN,...HN,...QN};({...wA,...IA});function EA(s=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(s):new Uint8Array(s)}function Py(s,e,t,i){return{name:s,prefix:e,encoder:{name:s,prefix:e,encode:t},decoder:{decode:i}}}const xd=Py("utf8","u",s=>"u"+new TextDecoder("utf8").decode(s),s=>new TextEncoder().encode(s.substring(1))),Bc=Py("ascii","a",s=>{let e="a";for(let t=0;t<s.length;t++)e+=String.fromCharCode(s[t]);return e},s=>{s=s.substring(1);const e=EA(s.length);for(let t=0;t<s.length;t++)e[t]=s.charCodeAt(t);return e}),NA={utf8:xd,"utf-8":xd,hex:Md.base16,latin1:Bc,ascii:Bc,binary:Bc,...Md};function AA(s,e="utf8"){const t=NA[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(s,"utf8"):t.decoder.decode(`${t.prefix}${s}`)}var _A=Object.defineProperty,CA=(s,e,t)=>e in s?_A(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Fs=(s,e,t)=>CA(s,typeof e!="symbol"?e+"":e,t);let SA=class{constructor(e,t){this.core=e,this.logger=t,Fs(this,"keychain",new Map),Fs(this,"name",CE),Fs(this,"version",SE),Fs(this,"initialized",!1),Fs(this,"storagePrefix",Zs),Fs(this,"init",async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}}),Fs(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),Fs(this,"set",async(i,r)=>{this.isInitialized(),this.keychain.set(i,r),await this.persist()}),Fs(this,"get",i=>{this.isInitialized();const r=this.keychain.get(i);if(typeof r>"u"){const{message:n}=U("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(n)}return r}),Fs(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()}),this.core=e,this.logger=u.E(t,this.name)}get context(){return u.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Lf(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?zf(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}};var TA=Object.defineProperty,PA=(s,e,t)=>e in s?TA(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ct=(s,e,t)=>PA(s,typeof e!="symbol"?e+"":e,t);let $A=class{constructor(e,t,i){this.core=e,this.logger=t,Ct(this,"name",AE),Ct(this,"keychain"),Ct(this,"randomSessionIdentifier",jl()),Ct(this,"initialized",!1),Ct(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Ct(this,"hasKeys",r=>(this.isInitialized(),this.keychain.has(r))),Ct(this,"getClientId",async()=>{this.isInitialized();const r=await this.getClientSeed(),n=u.Po(r);return u.Qe(n.publicKey)}),Ct(this,"generateKeyPair",()=>{this.isInitialized();const r=A1();return this.setPrivateKey(r.publicKey,r.privateKey)}),Ct(this,"signJWT",async r=>{this.isInitialized();const n=await this.getClientSeed(),o=u.Po(n),a=this.randomSessionIdentifier,c=_E;return await u.Qo(a,r,c,o)}),Ct(this,"generateSharedKey",(r,n,o)=>{this.isInitialized();const a=this.getPrivateKey(r),c=_1(a,n);return this.setSymKey(c,o)}),Ct(this,"setSymKey",async(r,n)=>{this.isInitialized();const o=n||ka(r);return await this.keychain.set(o,r),o}),Ct(this,"deleteKeyPair",async r=>{this.isInitialized(),await this.keychain.del(r)}),Ct(this,"deleteSymKey",async r=>{this.isInitialized(),await this.keychain.del(r)}),Ct(this,"encode",async(r,n,o)=>{this.isInitialized();const a=dy(o),c=u.safeJsonStringify(n);if(fd(a))return T1(c,o==null?void 0:o.encoding);if(gd(a)){const p=a.senderPublicKey,f=a.receiverPublicKey;r=await this.generateSharedKey(p,f)}const l=this.getSymKey(r),{type:h,senderPublicKey:d}=a;return C1({type:h,symKey:l,message:c,senderPublicKey:d,encoding:o==null?void 0:o.encoding})}),Ct(this,"decode",async(r,n,o)=>{this.isInitialized();const a=$1(n,o);if(fd(a)){const c=P1(n,o==null?void 0:o.encoding);return u.safeJsonParse(c)}if(gd(a)){const c=a.receiverPublicKey,l=a.senderPublicKey;r=await this.generateSharedKey(c,l)}try{const c=this.getSymKey(r),l=S1({symKey:c,encoded:n,encoding:o==null?void 0:o.encoding});return u.safeJsonParse(l)}catch(c){this.logger.error(`Failed to decode message from topic: '${r}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),Ct(this,"getPayloadType",(r,n=Mi)=>{const o=To({encoded:r,encoding:n});return hr(o.type)}),Ct(this,"getPayloadSenderPublicKey",(r,n=Mi)=>{const o=To({encoded:r,encoding:n});return o.senderPublicKey?u.toString(o.senderPublicKey,qt):void 0}),this.core=e,this.logger=u.E(t,this.name),this.keychain=i||new SA(this.core,this.logger)}get context(){return u.y(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Ad)}catch{e=jl(),await this.keychain.set(Ad,e)}return AA(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}};var MA=Object.defineProperty,xA=(s,e,t)=>e in s?MA(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,qs=(s,e,t)=>xA(s,typeof e!="symbol"?e+"":e,t);let OA=class extends Iv{constructor(e,t){super(e,t),this.logger=e,this.core=t,qs(this,"messages",new Map),qs(this,"name",TE),qs(this,"version",PE),qs(this,"initialized",!1),qs(this,"storagePrefix",Zs),qs(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}}),qs(this,"set",async(i,r)=>{this.isInitialized();const n=hi(r);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[n]<"u"||(o[n]=r,this.messages.set(i,o),await this.persist()),n}),qs(this,"get",i=>{this.isInitialized();let r=this.messages.get(i);return typeof r>"u"&&(r={}),r}),qs(this,"has",(i,r)=>{this.isInitialized();const n=this.get(i),o=hi(r);return typeof n[o]<"u"}),qs(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()}),this.logger=u.E(e,this.name),this.core=t}get context(){return u.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Lf(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?zf(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}};var DA=Object.defineProperty,kA=Object.defineProperties,jA=Object.getOwnPropertyDescriptors,Od=Object.getOwnPropertySymbols,RA=Object.prototype.hasOwnProperty,UA=Object.prototype.propertyIsEnumerable,Fl=(s,e,t)=>e in s?DA(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ga=(s,e)=>{for(var t in e||(e={}))RA.call(e,t)&&Fl(s,t,e[t]);if(Od)for(var t of Od(e))UA.call(e,t)&&Fl(s,t,e[t]);return s},Hc=(s,e)=>kA(s,jA(e)),Ps=(s,e,t)=>Fl(s,typeof e!="symbol"?e+"":e,t);let LA=class extends Ev{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,Ps(this,"events",new oe.eventsExports.EventEmitter),Ps(this,"name",$E),Ps(this,"queue",new Map),Ps(this,"publishTimeout",u.cjs.toMiliseconds(u.cjs.ONE_MINUTE)),Ps(this,"initialPublishTimeout",u.cjs.toMiliseconds(u.cjs.ONE_SECOND*15)),Ps(this,"needsTransportRestart",!1),Ps(this,"publish",async(i,r,n)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:r,opts:n}});const a=(n==null?void 0:n.ttl)||_d,c=Ka(n),l=(n==null?void 0:n.prompt)||!1,h=(n==null?void 0:n.tag)||0,d=(n==null?void 0:n.id)||u.getBigIntRpcId().toString(),p={topic:i,message:r,opts:{ttl:a,relay:c,prompt:l,tag:h,id:d,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}},f=`Failed to publish payload, please try again. id:${d} tag:${h}`;try{const g=new Promise(async y=>{const v=({id:w})=>{p.opts.id===w&&(this.removeRequestFromQueue(w),this.relayer.events.removeListener(It.publish,v),y(p))};this.relayer.events.on(It.publish,v);const b=$i(new Promise((w,N)=>{this.rpcPublish({topic:i,message:r,ttl:a,prompt:l,tag:h,id:d,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}).then(w).catch(_=>{this.logger.warn(_,_==null?void 0:_.message),N(_)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${d} tag:${h}`);try{await b,this.events.removeListener(It.publish,v)}catch(w){this.queue.set(d,Hc(ga({},p),{attempt:1})),this.logger.warn(w,w==null?void 0:w.message)}});this.logger.trace({type:"method",method:"publish",params:{id:d,topic:i,message:r,opts:n}}),await $i(g,this.publishTimeout,f)}catch(g){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(g),(o=n==null?void 0:n.internal)!=null&&o.throwOnFailedPublish)throw g}finally{this.queue.delete(d)}}),Ps(this,"on",(i,r)=>{this.events.on(i,r)}),Ps(this,"once",(i,r)=>{this.events.once(i,r)}),Ps(this,"off",(i,r)=>{this.events.off(i,r)}),Ps(this,"removeListener",(i,r)=>{this.events.removeListener(i,r)}),this.relayer=e,this.logger=u.E(t,this.name),this.registerEventListeners()}get context(){return u.y(this.logger)}async rpcPublish(e){var t,i,r,n;const{topic:o,message:a,ttl:c=_d,prompt:l,tag:h,id:d,attestation:p,tvf:f}=e,g={method:ao(Ka().protocol).publish,params:ga({topic:o,message:a,ttl:c,prompt:l,tag:h,attestation:p},f),id:d};Wt((t=g.params)==null?void 0:t.prompt)&&((i=g.params)==null||delete i.prompt),Wt((r=g.params)==null?void 0:r.tag)&&((n=g.params)==null||delete n.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:g});const y=await this.relayer.request(g);return this.relayer.events.emit(It.publish,e),this.logger.debug("Successfully Published Payload"),y}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{const i=e.attempt+1;this.queue.set(t,Hc(ga({},e),{attempt:i}));const{topic:r,message:n,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish(Hc(ga({},e),{topic:r,message:n,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(u.r.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(It.connection_stalled);return}this.checkQueue()}),this.relayer.on(It.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}};var zA=Object.defineProperty,FA=(s,e,t)=>e in s?zA(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Sr=(s,e,t)=>FA(s,typeof e!="symbol"?e+"":e,t);let qA=class{constructor(){Sr(this,"map",new Map),Sr(this,"set",(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])}),Sr(this,"get",e=>this.map.get(e)||[]),Sr(this,"exists",(e,t)=>this.get(e).includes(t)),Sr(this,"delete",(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const r=i.filter(n=>n!==t);if(!r.length){this.map.delete(e);return}this.map.set(e,r)}),Sr(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}};var BA=Object.defineProperty,HA=Object.defineProperties,WA=Object.getOwnPropertyDescriptors,Dd=Object.getOwnPropertySymbols,VA=Object.prototype.hasOwnProperty,KA=Object.prototype.propertyIsEnumerable,ql=(s,e,t)=>e in s?BA(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Kn=(s,e)=>{for(var t in e||(e={}))VA.call(e,t)&&ql(s,t,e[t]);if(Dd)for(var t of Dd(e))KA.call(e,t)&&ql(s,t,e[t]);return s},Wc=(s,e)=>HA(s,WA(e)),je=(s,e,t)=>ql(s,typeof e!="symbol"?e+"":e,t);let GA=class extends _v{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,je(this,"subscriptions",new Map),je(this,"topicMap",new qA),je(this,"events",new oe.eventsExports.EventEmitter),je(this,"name",RE),je(this,"version",UE),je(this,"pending",new Map),je(this,"cached",[]),je(this,"initialized",!1),je(this,"pendingSubscriptionWatchLabel","pending_sub_watch_label"),je(this,"pollingInterval",20),je(this,"storagePrefix",Zs),je(this,"subscribeTimeout",u.cjs.toMiliseconds(u.cjs.ONE_MINUTE)),je(this,"initialSubscribeTimeout",u.cjs.toMiliseconds(u.cjs.ONE_SECOND*15)),je(this,"clientId"),je(this,"batchSubscribeTopicsLimit",500),je(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),je(this,"subscribe",async(i,r)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:r}});try{const n=Ka(r),o={topic:i,relay:n,transportType:r==null?void 0:r.transportType};this.pending.set(i,o);const a=await this.rpcSubscribe(i,n,r);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:r}})),a}catch(n){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(n),n}}),je(this,"unsubscribe",async(i,r)=>{this.isInitialized(),typeof(r==null?void 0:r.id)<"u"?await this.unsubscribeById(i,r.id,r):await this.unsubscribeByTopic(i,r)}),je(this,"isSubscribed",async i=>{if(this.topics.includes(i))return!0;const r=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((n,o)=>{const a=new u.cjs.Watch;a.start(r);const c=setInterval(()=>{(!this.pending.has(i)&&this.topics.includes(i)||this.cached.some(l=>l.topic===i))&&(clearInterval(c),a.stop(r),n(!0)),a.elapsed(r)>=LE&&(clearInterval(c),a.stop(r),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)}),je(this,"on",(i,r)=>{this.events.on(i,r)}),je(this,"once",(i,r)=>{this.events.once(i,r)}),je(this,"off",(i,r)=>{this.events.off(i,r)}),je(this,"removeListener",(i,r)=>{this.events.removeListener(i,r)}),je(this,"start",async()=>{await this.onConnect()}),je(this,"stop",async()=>{await this.onDisconnect()}),je(this,"restart",async()=>{await this.restore(),await this.onRestart()}),je(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(r=>{i.push(r)}),await this.batchSubscribe(i)}),je(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(u.r.pulse,async()=>{await this.checkPending()}),this.events.on(ns.created,async i=>{const r=ns.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:i}),await this.persist()}),this.events.on(ns.deleted,async i=>{const r=ns.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:i}),await this.persist()})}),this.relayer=e,this.logger=u.E(t,this.name),this.clientId=""}get context(){return u.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async r=>await this.unsubscribeById(e,r,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const r=Ka(i);await this.restartToComplete({topic:e,id:t,relay:r}),await this.rpcUnsubscribe(e,t,r);const n=Re("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(r){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(r),r}}async rpcSubscribe(e,t,i){var r;(!i||(i==null?void 0:i.transportType)===Ze.relay)&&await this.restartToComplete({topic:e,id:e,relay:t});const n={method:ao(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});const o=(r=i==null?void 0:i.internal)==null?void 0:r.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if((i==null?void 0:i.transportType)===Ze.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(h=>this.logger.warn(h))},u.cjs.toMiliseconds(u.cjs.ONE_SECOND)),a;const c=new Promise(async h=>{const d=p=>{p.topic===e&&(this.events.removeListener(ns.created,d),h(p.id))};this.events.on(ns.created,d);try{const p=await $i(new Promise((f,g)=>{this.relayer.request(n).catch(y=>{this.logger.warn(y,y==null?void 0:y.message),g(y)}).then(f)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(ns.created,d),h(p)}catch{}}),l=await $i(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!l&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return l?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(It.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:ao(t.protocol).batchSubscribe,params:{topics:e.map(r=>r.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await $i(new Promise(r=>{this.relayer.request(i).catch(n=>this.logger.warn(n)).then(r)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(It.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:ao(t.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let r;try{r=await await $i(new Promise((n,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a)}).then(n)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(It.connection_stalled)}return r}rpcUnsubscribe(e,t,i){const r={method:ao(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r}),this.relayer.request(r)}onSubscribe(e,t){this.setSubscription(e,Wc(Kn({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,Kn({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,Kn({},t)),this.topicMap.set(t.topic,e),this.events.emit(ns.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=U("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(ns.deleted,Wc(Kn({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(ns.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<t;i++){const r=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(r)}}this.events.emit(ns.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=U("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async t=>Wc(Kn({},t),{id:await this.getSubscriptionId(t.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await U0(u.cjs.toMiliseconds(u.cjs.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return hi(e+await this.getClientId())}};var YA=Object.defineProperty,kd=Object.getOwnPropertySymbols,QA=Object.prototype.hasOwnProperty,ZA=Object.prototype.propertyIsEnumerable,Bl=(s,e,t)=>e in s?YA(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,jd=(s,e)=>{for(var t in e||(e={}))QA.call(e,t)&&Bl(s,t,e[t]);if(kd)for(var t of kd(e))ZA.call(e,t)&&Bl(s,t,e[t]);return s},Ne=(s,e,t)=>Bl(s,typeof e!="symbol"?e+"":e,t);let JA=class extends Nv{constructor(e){super(e),Ne(this,"protocol","wc"),Ne(this,"version",2),Ne(this,"core"),Ne(this,"logger"),Ne(this,"events",new oe.eventsExports.EventEmitter),Ne(this,"provider"),Ne(this,"messages"),Ne(this,"subscriber"),Ne(this,"publisher"),Ne(this,"name",xE),Ne(this,"transportExplicitlyClosed",!1),Ne(this,"initialized",!1),Ne(this,"connectionAttemptInProgress",!1),Ne(this,"relayUrl"),Ne(this,"projectId"),Ne(this,"packageName"),Ne(this,"bundleId"),Ne(this,"hasExperiencedNetworkDisruption",!1),Ne(this,"pingTimeout"),Ne(this,"heartBeatTimeout",u.cjs.toMiliseconds(u.cjs.THIRTY_SECONDS+u.cjs.FIVE_SECONDS)),Ne(this,"reconnectTimeout"),Ne(this,"connectPromise"),Ne(this,"reconnectInProgress",!1),Ne(this,"requestsInFlight",[]),Ne(this,"connectTimeout",u.cjs.toMiliseconds(u.cjs.ONE_SECOND*15)),Ne(this,"request",async t=>{var i,r;this.logger.debug("Publishing Request Payload");const n=t.id||u.getBigIntRpcId().toString();await this.toEstablishConnection();try{this.logger.trace({id:n,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${n}:${((r=t.params)==null?void 0:r.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(t);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${n}`),o}}),Ne(this,"resetPingTimeout",()=>{if(Wa())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,r;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(r=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||r.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t,t==null?void 0:t.message)}}),Ne(this,"onPayloadHandler",t=>{this.onProviderPayload(t),this.resetPingTimeout()}),Ne(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(It.connect)}),Ne(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),Ne(this,"onProviderErrorHandler",t=>{this.logger.fatal(`Fatal socket error: ${t.message}`),this.events.emit(It.error,t),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),Ne(this,"registerProviderListeners",()=>{this.provider.on(fs.payload,this.onPayloadHandler),this.provider.on(fs.connect,this.onConnectHandler),this.provider.on(fs.disconnect,this.onDisconnectHandler),this.provider.on(fs.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?u.E(e.logger,this.name):u.Ot(u.k({level:e.logger||ME})),this.messages=new OA(this.logger,e.core),this.subscriber=new GA(this,this.logger),this.publisher=new LA(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||my,this.projectId=e.projectId,N0()?this.packageName=Fu():A0()&&(this.bundleId=Fu()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e==null?void 0:e.message)}}get context(){return u.y(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1||!1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:Ze.relay})}async subscribe(e,t){var i,r,n;this.isInitialized(),(!(t!=null&&t.transportType)||(t==null?void 0:t.transportType)==="relay")&&await this.toEstablishConnection();const o=typeof((i=t==null?void 0:t.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(r=t==null?void 0:t.internal)==null?void 0:r.throwOnFailedPublish;let a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",c;const l=h=>{h.topic===e&&(this.subscriber.off(ns.created,l),c())};return await Promise.all([new Promise(h=>{c=h,this.subscriber.on(ns.created,l)}),new Promise(async(h,d)=>{a=await this.subscriber.subscribe(e,jd({internal:{throwOnFailedPublish:o}},t)).catch(p=>{o&&d(p)})||a,h()})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await $i(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,i)=>{await this.connect(e).then(t).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Nd())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const t=e.sort((i,r)=>i.publishedAt-r.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const i of t)try{await this.onMessageEvent(i)}catch(r){this.logger.warn(r,"Error while processing batch message event: "+(r==null?void 0:r.message))}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const r=dt(u.cjs.FIVE_MINUTES),n={topic:i,expiry:r,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,n)}this.events.emit(It.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(i,r)=>{const n=()=>{r(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(fs.disconnect,n),await $i(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{r(o)}).finally(()=>{this.provider.off(fs.disconnect,n),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(fs.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(fs.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const r=i;this.logger.warn({},r.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(i=>setTimeout(i,u.cjs.toMiliseconds(t*1))),t++}}startPingTimeout(){var e,t,i,r,n;if(Wa())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((n=(r=(i=this.provider)==null?void 0:i.connection)==null?void 0:r.socket)==null||n.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o==null?void 0:o.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new u.o(new u.f(T0({sdkVersion:Ul,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.warn(`Ignoring message for non-subscribed topic ${t}`),!0;const r=this.messages.has(t,i);return r&&this.logger.warn(`Ignoring duplicate message: ${i}`),r}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),u.isJsonRpcRequest(e)){if(!e.method.endsWith(OE))return;const t=e.params,{topic:i,message:r,publishedAt:n,attestation:o}=t.data,a={topic:i,message:r,publishedAt:n,transportType:Ze.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(jd({type:"event",event:t.id},a)),this.events.emit(t.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else u.isJsonRpcResponse(e)&&this.events.emit(It.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(It.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=u.formatJsonRpcResult(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(fs.payload,this.onPayloadHandler),this.provider.off(fs.connect,this.onConnectHandler),this.provider.off(fs.disconnect,this.onDisconnectHandler),this.provider.off(fs.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Nd();wE(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(i=>this.logger.error(i,i==null?void 0:i.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(It.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e==null?void 0:e.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},u.cjs.toMiliseconds(DE)))))}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}};var XA=Object.defineProperty,Rd=Object.getOwnPropertySymbols,e_=Object.prototype.hasOwnProperty,t_=Object.prototype.propertyIsEnumerable,Hl=(s,e,t)=>e in s?XA(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ud=(s,e)=>{for(var t in e||(e={}))e_.call(e,t)&&Hl(s,t,e[t]);if(Rd)for(var t of Rd(e))t_.call(e,t)&&Hl(s,t,e[t]);return s},Kt=(s,e,t)=>Hl(s,typeof e!="symbol"?e+"":e,t);let wr=class extends Av{constructor(e,t,i,r=Zs,n=void 0){super(e,t,i,r),this.core=e,this.logger=t,this.name=i,Kt(this,"map",new Map),Kt(this,"version",kE),Kt(this,"cached",[]),Kt(this,"initialized",!1),Kt(this,"getKey"),Kt(this,"storagePrefix",Zs),Kt(this,"recentlyDeleted",[]),Kt(this,"recentlyDeletedLimit",200),Kt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Wt(o)?this.map.set(this.getKey(o),o):G1(o)?this.map.set(o.id,o):Y1(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),Kt(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())}),Kt(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),Kt(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>IE(a[c],o[c]))):this.values)),Kt(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=Ud(Ud({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),Kt(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())}),this.logger=u.E(t,this.name),this.storagePrefix=r,this.getKey=n}get context(){return u.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:r}=U("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(r),new Error(r)}const{message:i}=U("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=U("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}};var s_=Object.defineProperty,i_=(s,e,t)=>e in s?s_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,fe=(s,e,t)=>i_(s,typeof e!="symbol"?e+"":e,t);let r_=class{constructor(e,t){this.core=e,this.logger=t,fe(this,"name",zE),fe(this,"version",FE),fe(this,"events",new oe.Nt),fe(this,"pairings"),fe(this,"initialized",!1),fe(this,"storagePrefix",Zs),fe(this,"ignoredPayloadTypes",[di]),fe(this,"registeredMethods",[]),fe(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),fe(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]}),fe(this,"create",async i=>{this.isInitialized();const r=jl(),n=await this.core.crypto.setSymKey(r),o=dt(u.cjs.FIVE_MINUTES),a={protocol:wy},c={topic:n,expiry:o,relay:a,active:!1,methods:i==null?void 0:i.methods},l=wd({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:r,relay:a,expiryTimestamp:o,methods:i==null?void 0:i.methods});return this.events.emit(tr.create,c),this.core.expirer.set(n,o),await this.pairings.set(n,c),await this.core.relayer.subscribe(n,{transportType:i==null?void 0:i.transportType}),{topic:n,uri:l}}),fe(this,"pair",async i=>{this.isInitialized();const r=this.core.eventClient.createEvent({properties:{topic:i==null?void 0:i.uri,trace:[Gs.pairing_started]}});this.isValidPair(i,r);const{topic:n,symKey:o,relay:a,expiryTimestamp:c,methods:l}=yd(i.uri);r.props.properties.topic=n,r.addTrace(Gs.pairing_uri_validation_success),r.addTrace(Gs.pairing_uri_not_expired);let h;if(this.pairings.keys.includes(n)){if(h=this.pairings.get(n),r.addTrace(Gs.existing_pairing),h.active)throw r.setError(ci.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);r.addTrace(Gs.pairing_not_expired)}const d=c||dt(u.cjs.FIVE_MINUTES),p={topic:n,relay:a,expiry:d,active:!1,methods:l};this.core.expirer.set(n,d),await this.pairings.set(n,p),r.addTrace(Gs.store_new_pairing),i.activatePairing&&await this.activate({topic:n}),this.events.emit(tr.create,p),r.addTrace(Gs.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),r.addTrace(Gs.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{r.setError(ci.no_internet_connection)}try{await this.core.relayer.subscribe(n,{relay:a})}catch(f){throw r.setError(ci.subscribe_pairing_topic_failure),f}return r.addTrace(Gs.subscribe_pairing_topic_success),p}),fe(this,"activate",async({topic:i})=>{this.isInitialized();const r=dt(u.cjs.FIVE_MINUTES);this.core.expirer.set(i,r),await this.pairings.update(i,{active:!0,expiry:r})}),fe(this,"ping",async i=>{this.isInitialized(),await this.isValidPing(i),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:r}=i;if(this.pairings.keys.includes(r)){const n=await this.sendRequest(r,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Zi();this.events.once($e("pairing_ping",n),({error:l})=>{l?c(l):a()}),await o()}}),fe(this,"updateExpiry",async({topic:i,expiry:r})=>{this.isInitialized(),await this.pairings.update(i,{expiry:r})}),fe(this,"updateMetadata",async({topic:i,metadata:r})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:r})}),fe(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),fe(this,"disconnect",async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:r}=i;this.pairings.keys.includes(r)&&(await this.sendRequest(r,"wc_pairingDelete",Re("USER_DISCONNECTED")),await this.deletePairing(r))}),fe(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:r,relay:n,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(r);return wd({protocol:this.core.protocol,version:this.core.version,topic:r,symKey:c,relay:n,expiryTimestamp:o,methods:a})}),fe(this,"sendRequest",async(i,r,n)=>{const o=u.formatJsonRpcRequest(r,n),a=await this.core.crypto.encode(i,o),c=Wn[r].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id}),fe(this,"sendResult",async(i,r,n)=>{const o=u.formatJsonRpcResult(i,n),a=await this.core.crypto.encode(r,o),c=(await this.core.history.get(r,i)).request.method,l=Wn[c].res;await this.core.relayer.publish(r,a,l),await this.core.history.resolve(o)}),fe(this,"sendError",async(i,r,n)=>{const o=u.formatJsonRpcError(i,n),a=await this.core.crypto.encode(r,o),c=(await this.core.history.get(r,i)).request.method,l=Wn[c]?Wn[c].res:Wn.unregistered_method.res;await this.core.relayer.publish(r,a,l),await this.core.history.resolve(o)}),fe(this,"deletePairing",async(i,r)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Re("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),r?Promise.resolve():this.core.expirer.del(i)])}),fe(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(r=>Ci(r.expiry));await Promise.all(i.map(r=>this.deletePairing(r.topic)))}),fe(this,"onRelayEventRequest",i=>{const{topic:r,payload:n}=i;switch(n.method){case"wc_pairingPing":return this.onPairingPingRequest(r,n);case"wc_pairingDelete":return this.onPairingDeleteRequest(r,n);default:return this.onUnknownRpcMethodRequest(r,n)}}),fe(this,"onRelayEventResponse",async i=>{const{topic:r,payload:n}=i,o=(await this.core.history.get(r,n.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(r,n);default:return this.onUnknownRpcMethodResponse(o)}}),fe(this,"onPairingPingRequest",async(i,r)=>{const{id:n}=r;try{this.isValidPing({topic:i}),await this.sendResult(n,i,!0),this.events.emit(tr.ping,{id:n,topic:i})}catch(o){await this.sendError(n,i,o),this.logger.error(o)}}),fe(this,"onPairingPingResponse",(i,r)=>{const{id:n}=r;setTimeout(()=>{u.isJsonRpcResult(r)?this.events.emit($e("pairing_ping",n),{}):u.isJsonRpcError(r)&&this.events.emit($e("pairing_ping",n),{error:r.error})},500)}),fe(this,"onPairingDeleteRequest",async(i,r)=>{const{id:n}=r;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(tr.delete,{id:n,topic:i})}catch(o){await this.sendError(n,i,o),this.logger.error(o)}}),fe(this,"onUnknownRpcMethodRequest",async(i,r)=>{const{id:n,method:o}=r;try{if(this.registeredMethods.includes(o))return;const a=Re("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,i,a),this.logger.error(a)}catch(a){await this.sendError(n,i,a),this.logger.error(a)}}),fe(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(Re("WC_METHOD_UNSUPPORTED",i))}),fe(this,"isValidPair",(i,r)=>{var n;if(!Jt(i)){const{message:a}=U("MISSING_OR_INVALID",`pair() params: ${i}`);throw r.setError(ci.malformed_pairing_uri),new Error(a)}if(!K1(i.uri)){const{message:a}=U("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw r.setError(ci.malformed_pairing_uri),new Error(a)}const o=yd(i==null?void 0:i.uri);if(!((n=o==null?void 0:o.relay)!=null&&n.protocol)){const{message:a}=U("MISSING_OR_INVALID","pair() uri#relay-protocol");throw r.setError(ci.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=U("MISSING_OR_INVALID","pair() uri#symKey");throw r.setError(ci.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&u.cjs.toMiliseconds(o==null?void 0:o.expiryTimestamp)<Date.now()){r.setError(ci.pairing_expired);const{message:a}=U("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),fe(this,"isValidPing",async i=>{if(!Jt(i)){const{message:n}=U("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(n)}const{topic:r}=i;await this.isValidPairingTopic(r)}),fe(this,"isValidDisconnect",async i=>{if(!Jt(i)){const{message:n}=U("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(n)}const{topic:r}=i;await this.isValidPairingTopic(r)}),fe(this,"isValidPairingTopic",async i=>{if(!nt(i,!1)){const{message:r}=U("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(r)}if(!this.pairings.keys.includes(i)){const{message:r}=U("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(r)}if(Ci(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:r}=U("EXPIRED",`pairing topic: ${i}`);throw new Error(r)}}),this.core=e,this.logger=u.E(t,this.name),this.pairings=new wr(this.core,this.logger,this.name,this.storagePrefix)}get context(){return u.y(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(It.message,async e=>{const{topic:t,message:i,transportType:r}=e;if(!this.pairings.keys.includes(t)||r===Ze.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const n=await this.core.crypto.decode(t,i);try{u.isJsonRpcRequest(n)?(this.core.history.set(t,n),this.onRelayEventRequest({topic:t,payload:n})):u.isJsonRpcResponse(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:t,payload:n}),this.core.history.delete(t,n.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(bs.expired,async e=>{const{topic:t}=qf(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(tr.expire,{topic:t}))})}};var n_=Object.defineProperty,o_=(s,e,t)=>e in s?n_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,St=(s,e,t)=>o_(s,typeof e!="symbol"?e+"":e,t);let a_=class extends vv{constructor(e,t){super(e,t),this.core=e,this.logger=t,St(this,"records",new Map),St(this,"events",new oe.eventsExports.EventEmitter),St(this,"name",qE),St(this,"version",BE),St(this,"cached",[]),St(this,"initialized",!1),St(this,"storagePrefix",Zs),St(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),St(this,"set",(i,r,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:r,chainId:n}),this.records.has(r.id))return;const o={id:r.id,topic:i,request:{method:r.method,params:r.params||null},chainId:n,expiry:dt(u.cjs.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Ss.created,o)}),St(this,"resolve",async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const r=await this.getRecord(i.id);typeof r.response>"u"&&(r.response=u.isJsonRpcError(i)?{error:i.error}:{result:i.result},this.records.set(r.id,r),this.persist(),this.events.emit(Ss.updated,r))}),St(this,"get",async(i,r)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:r}),await this.getRecord(r))),St(this,"delete",(i,r)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:r}),this.values.forEach(n=>{if(n.topic===i){if(typeof r<"u"&&n.id!==r)return;this.records.delete(n.id),this.events.emit(Ss.deleted,n)}}),this.persist()}),St(this,"exists",async(i,r)=>(this.isInitialized(),this.records.has(r)?(await this.getRecord(r)).topic===i:!1)),St(this,"on",(i,r)=>{this.events.on(i,r)}),St(this,"once",(i,r)=>{this.events.once(i,r)}),St(this,"off",(i,r)=>{this.events.off(i,r)}),St(this,"removeListener",(i,r)=>{this.events.removeListener(i,r)}),this.logger=u.E(t,this.name)}get context(){return u.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:u.formatJsonRpcRequest(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:i}=U("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Ss.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=U("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Ss.created,e=>{const t=Ss.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Ss.updated,e=>{const t=Ss.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Ss.deleted,e=>{const t=Ss.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(u.r.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{u.cjs.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(Ss.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}};var c_=Object.defineProperty,l_=(s,e,t)=>e in s?c_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ut=(s,e,t)=>l_(s,typeof e!="symbol"?e+"":e,t);let h_=class extends Cv{constructor(e,t){super(e,t),this.core=e,this.logger=t,Ut(this,"expirations",new Map),Ut(this,"events",new oe.eventsExports.EventEmitter),Ut(this,"name",HE),Ut(this,"version",WE),Ut(this,"cached",[]),Ut(this,"initialized",!1),Ut(this,"storagePrefix",Zs),Ut(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Ut(this,"has",i=>{try{const r=this.formatTarget(i);return typeof this.getExpiration(r)<"u"}catch{return!1}}),Ut(this,"set",(i,r)=>{this.isInitialized();const n=this.formatTarget(i),o={target:n,expiry:r};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit(bs.created,{target:n,expiration:o})}),Ut(this,"get",i=>{this.isInitialized();const r=this.formatTarget(i);return this.getExpiration(r)}),Ut(this,"del",i=>{if(this.isInitialized(),this.has(i)){const r=this.formatTarget(i),n=this.getExpiration(r);this.expirations.delete(r),this.events.emit(bs.deleted,{target:r,expiration:n})}}),Ut(this,"on",(i,r)=>{this.events.on(i,r)}),Ut(this,"once",(i,r)=>{this.events.once(i,r)}),Ut(this,"off",(i,r)=>{this.events.off(i,r)}),Ut(this,"removeListener",(i,r)=>{this.events.removeListener(i,r)}),this.logger=u.E(t,this.name)}get context(){return u.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return P0(e);if(typeof e=="number")return $0(e);const{message:t}=U("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(bs.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=U("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:i}=U("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;u.cjs.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(bs.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(u.r.pulse,()=>this.checkExpirations()),this.events.on(bs.created,e=>{const t=bs.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(bs.expired,e=>{const t=bs.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(bs.deleted,e=>{const t=bs.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}};var u_=Object.defineProperty,d_=(s,e,t)=>e in s?u_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,at=(s,e,t)=>d_(s,typeof e!="symbol"?e+"":e,t);let p_=class extends Sv{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,at(this,"name",VE),at(this,"abortController"),at(this,"isDevEnv"),at(this,"verifyUrlV3",GE),at(this,"storagePrefix",Zs),at(this,"version",yy),at(this,"publicKey"),at(this,"fetchPromise"),at(this,"init",async()=>{var r;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&u.cjs.toMiliseconds((r=this.publicKey)==null?void 0:r.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),at(this,"register",async r=>{if(!zo()||this.isDevEnv)return;const n=window.location.origin,{id:o,decryptedId:a}=r,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{const l=u.getDocument_1(),h=this.startAbortTimer(u.cjs.ONE_SECOND*5),d=await new Promise((p,f)=>{const g=()=>{window.removeEventListener("message",v),l.body.removeChild(y),f("attestation aborted")};this.abortController.signal.addEventListener("abort",g);const y=l.createElement("iframe");y.src=c,y.style.display="none",y.addEventListener("error",g,{signal:this.abortController.signal});const v=b=>{if(b.data&&typeof b.data=="string")try{const w=JSON.parse(b.data);if(w.type==="verify_attestation"){if(u.sn(w.attestation).payload.id!==o)return;clearInterval(h),l.body.removeChild(y),this.abortController.signal.removeEventListener("abort",g),window.removeEventListener("message",v),p(w.attestation===null?"":w.attestation)}}catch(w){this.logger.warn(w)}};l.body.appendChild(y),window.addEventListener("message",v,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",d),d}catch(l){this.logger.warn(l)}return""}),at(this,"resolve",async r=>{if(this.isDevEnv)return"";const{attestationId:n,hash:o,encryptedId:a}=r;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(u.sn(n).payload.id!==a)return;const l=await this.isValidJwtAttestation(n);if(l){if(!l.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return l}}if(!o)return;const c=this.getVerifyUrl(r==null?void 0:r.verifyUrl);return this.fetchAttestation(o,c)}),at(this,"fetchAttestation",async(r,n)=>{this.logger.debug(`resolving attestation: ${r} from url: ${n}`);const o=this.startAbortTimer(u.cjs.ONE_SECOND*5),a=await fetch(`${n}/attestation/${r}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),at(this,"getVerifyUrl",r=>{let n=r||yo;return YE.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${yo}`),n=yo),n}),at(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const r=this.startAbortTimer(u.cjs.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(r),await n.json()}catch(r){this.logger.warn(r)}}),at(this,"persistPublicKey",async r=>{this.logger.debug("persisting public key to local storage",r),await this.store.setItem(this.storeKey,r),this.publicKey=r}),at(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),at(this,"isValidJwtAttestation",async r=>{const n=await this.getPublicKey();try{if(n)return this.validateAttestation(r,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(r,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),at(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),at(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o))});const r=await this.fetchPromise;return this.fetchPromise=void 0,r}),at(this,"validateAttestation",(r,n)=>{const o=D1(r,n.publicKey),a={hasExpired:u.cjs.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=u.E(t,this.name),this.abortController=new AbortController,this.isDevEnv=xh(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return u.y(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),u.cjs.toMiliseconds(e))}};var g_=Object.defineProperty,f_=(s,e,t)=>e in s?g_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ld=(s,e,t)=>f_(s,typeof e!="symbol"?e+"":e,t);let y_=class extends Tv{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,Ld(this,"context",QE),Ld(this,"registerDeviceToken",async i=>{const{clientId:r,token:n,notificationType:o,enableEncrypted:a=!1}=i,c=`${ZE}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:r,type:o,token:n,always_raw:a})})}),this.logger=u.E(t,this.context)}};var w_=Object.defineProperty,zd=Object.getOwnPropertySymbols,m_=Object.prototype.hasOwnProperty,b_=Object.prototype.propertyIsEnumerable,Wl=(s,e,t)=>e in s?w_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Gn=(s,e)=>{for(var t in e||(e={}))m_.call(e,t)&&Wl(s,t,e[t]);if(zd)for(var t of zd(e))b_.call(e,t)&&Wl(s,t,e[t]);return s},yt=(s,e,t)=>Wl(s,typeof e!="symbol"?e+"":e,t);let v_=class extends Pv{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,yt(this,"context",XE),yt(this,"storagePrefix",Zs),yt(this,"storageVersion",JE),yt(this,"events",new Map),yt(this,"shouldPersist",!1),yt(this,"init",async()=>{if(!xh())try{const r={eventId:Bu(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Uf(this.core.relayer.protocol,this.core.relayer.version,Ul)}}};await this.sendEvent([r])}catch(r){this.logger.warn(r)}}),yt(this,"createEvent",r=>{const{event:n="ERROR",type:o="",properties:{topic:a,trace:c}}=r,l=Bu(),h=this.core.projectId||"",d=Date.now(),p=Gn({eventId:l,timestamp:d,props:{event:n,type:o,properties:{topic:a,trace:c}},bundleId:h,domain:this.getAppDomain()},this.setMethods(l));return this.telemetryEnabled&&(this.events.set(l,p),this.shouldPersist=!0),p}),yt(this,"getEvent",r=>{const{eventId:n,topic:o}=r;if(n)return this.events.get(n);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return Gn(Gn({},a),this.setMethods(a.eventId))}),yt(this,"deleteEvent",r=>{const{eventId:n}=r;this.events.delete(n),this.shouldPersist=!0}),yt(this,"setEventListeners",()=>{this.core.heartbeat.on(u.r.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(r=>{u.cjs.fromMiliseconds(Date.now())-u.cjs.fromMiliseconds(r.timestamp)>eN&&(this.events.delete(r.eventId),this.shouldPersist=!0)})})}),yt(this,"setMethods",r=>({addTrace:n=>this.addTrace(r,n),setError:n=>this.setError(r,n)})),yt(this,"addTrace",(r,n)=>{const o=this.events.get(r);o&&(o.props.properties.trace.push(n),this.events.set(r,o),this.shouldPersist=!0)}),yt(this,"setError",(r,n)=>{const o=this.events.get(r);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(r,o),this.shouldPersist=!0)}),yt(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),yt(this,"restore",async()=>{try{const r=await this.core.storage.getItem(this.storageKey)||[];if(!r.length)return;r.forEach(n=>{this.events.set(n.eventId,Gn(Gn({},n),this.setMethods(n.eventId)))})}catch(r){this.logger.warn(r)}}),yt(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const r=[];for(const[n,o]of this.events)o.props.type&&r.push(o);if(r.length!==0)try{if((await this.sendEvent(r)).ok)for(const n of r)this.events.delete(n.eventId),this.shouldPersist=!0}catch(n){this.logger.warn(n)}}),yt(this,"sendEvent",async r=>{const n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${tN}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Ul}${n}`,{method:"POST",body:JSON.stringify(r)})}),yt(this,"getAppDomain",()=>Rf().url),this.logger=u.E(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}};var I_=Object.defineProperty,Fd=Object.getOwnPropertySymbols,E_=Object.prototype.hasOwnProperty,N_=Object.prototype.propertyIsEnumerable,Vl=(s,e,t)=>e in s?I_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,qd=(s,e)=>{for(var t in e||(e={}))E_.call(e,t)&&Vl(s,t,e[t]);if(Fd)for(var t of Fd(e))N_.call(e,t)&&Vl(s,t,e[t]);return s},He=(s,e,t)=>Vl(s,typeof e!="symbol"?e+"":e,t);let A_=class $y extends yv{constructor(e){var t;super(e),He(this,"protocol",fy),He(this,"version",yy),He(this,"name",Rl),He(this,"relayUrl"),He(this,"projectId"),He(this,"customStoragePrefix"),He(this,"events",new oe.eventsExports.EventEmitter),He(this,"logger"),He(this,"heartbeat"),He(this,"relayer"),He(this,"crypto"),He(this,"storage"),He(this,"history"),He(this,"expirer"),He(this,"pairing"),He(this,"verify"),He(this,"echoClient"),He(this,"linkModeSupportedApps"),He(this,"eventClient"),He(this,"initialized",!1),He(this,"logChunkController"),He(this,"on",(o,a)=>this.events.on(o,a)),He(this,"once",(o,a)=>this.events.once(o,a)),He(this,"off",(o,a)=>this.events.off(o,a)),He(this,"removeListener",(o,a)=>this.events.removeListener(o,a)),He(this,"dispatchEnvelope",({topic:o,message:a,sessionExists:c})=>{if(!o||!a)return;const l={topic:o,message:a,publishedAt:Date.now(),transportType:Ze.link_mode};this.relayer.onLinkMessageEvent(l,{sessionExists:c})}),this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||my,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=u.k({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:EE.logger,name:Rl}),{logger:r,chunkLoggerController:n}=u.A({opts:i,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=n,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=u.E(r,this.name),this.heartbeat=new u.i,this.crypto=new $A(this,this.logger,e==null?void 0:e.keychain),this.history=new a_(this,this.logger),this.expirer=new h_(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new u.h(qd(qd({},NE),e==null?void 0:e.storageOptions)),this.relayer=new JA({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new r_(this,this.logger),this.verify=new p_(this,this.logger,this.storage),this.echoClient=new y_(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new v_(this,this.logger,e==null?void 0:e.telemetryEnabled)}static async init(e){const t=new $y(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(jE,i),t}get context(){return u.y(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Cd,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(Cd)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}};const __=A_;var C_=Object.defineProperty,S_=(s,e,t)=>e in s?C_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Bd=(s,e,t)=>S_(s,typeof e!="symbol"?e+"":e,t);let T_=class{constructor(e){this.opts=e,Bd(this,"protocol","wc"),Bd(this,"version",2)}},P_=class{constructor(e){this.client=e}};const My="wc",xy=2,Oy="client",Fh=`${My}@${xy}:${Oy}:`,Vc={name:Oy,logger:"error"},Hd="WALLETCONNECT_DEEPLINK_CHOICE",$_="proposal",Wd="Proposal expired",M_="session",Tr=u.cjs.SEVEN_DAYS,x_="engine",wt={wc_sessionPropose:{req:{ttl:u.cjs.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:u.cjs.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:u.cjs.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:u.cjs.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:u.cjs.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:u.cjs.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:u.cjs.ONE_DAY,prompt:!1,tag:1104},res:{ttl:u.cjs.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:u.cjs.ONE_DAY,prompt:!1,tag:1106},res:{ttl:u.cjs.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:u.cjs.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:u.cjs.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:u.cjs.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:u.cjs.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:u.cjs.ONE_DAY,prompt:!1,tag:1112},res:{ttl:u.cjs.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:u.cjs.ONE_DAY,prompt:!1,tag:1114},res:{ttl:u.cjs.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:u.cjs.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:u.cjs.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:u.cjs.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:u.cjs.FIVE_MINUTES,prompt:!1,tag:1119}}},Kc={min:u.cjs.FIVE_MINUTES,max:u.cjs.SEVEN_DAYS},Bs={idle:"IDLE",active:"ACTIVE"},Vd={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},O_="request",D_=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],k_="wc",j_="auth",R_="authKeys",U_="pairingTopics",L_="requests",pc=`${k_}@${1.5}:${j_}:`,ja=`${pc}:PUB_KEY`;var z_=Object.defineProperty,F_=Object.defineProperties,q_=Object.getOwnPropertyDescriptors,Kd=Object.getOwnPropertySymbols,B_=Object.prototype.hasOwnProperty,H_=Object.prototype.propertyIsEnumerable,Kl=(s,e,t)=>e in s?z_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,et=(s,e)=>{for(var t in e||(e={}))B_.call(e,t)&&Kl(s,t,e[t]);if(Kd)for(var t of Kd(e))H_.call(e,t)&&Kl(s,t,e[t]);return s},Gt=(s,e)=>F_(s,q_(e)),D=(s,e,t)=>Kl(s,typeof e!="symbol"?e+"":e,t);let W_=class extends P_{constructor(e){super(e),D(this,"name",x_),D(this,"events",new oe.Nt),D(this,"initialized",!1),D(this,"requestQueue",{state:Bs.idle,queue:[]}),D(this,"sessionRequestQueue",{state:Bs.idle,queue:[]}),D(this,"requestQueueDelay",u.cjs.ONE_SECOND),D(this,"expectedPairingMethodMap",new Map),D(this,"recentlyDeletedMap",new Map),D(this,"recentlyDeletedLimit",200),D(this,"relayMessageCache",[]),D(this,"pendingSessions",new Map),D(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(wt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},u.cjs.toMiliseconds(this.requestQueueDelay)))}),D(this,"connect",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Gt(et({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:r,requiredNamespaces:n,optionalNamespaces:o,sessionProperties:a,relays:c}=i;let l=r,h,d=!1;try{if(l){const C=this.client.core.pairing.pairings.get(l);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),d=C.active}}catch(C){throw this.client.logger.error(`connect() -> pairing.get(${l}) failed`),C}if(!l||!d){const{topic:C,uri:T}=await this.client.core.pairing.create();l=C,h=T}if(!l){const{message:C}=U("NO_MATCHING_KEY",`connect() pairing topic: ${l}`);throw new Error(C)}const p=await this.client.core.crypto.generateKeyPair(),f=wt.wc_sessionPropose.req.ttl||u.cjs.FIVE_MINUTES,g=dt(f),y=Gt(et({requiredNamespaces:n,optionalNamespaces:o,relays:c??[{protocol:wy}],proposer:{publicKey:p,metadata:this.client.metadata},expiryTimestamp:g,pairingTopic:l},a&&{sessionProperties:a}),{id:u.payloadId()}),v=$e("session_connect",y.id),{reject:b,resolve:w,done:N}=Zi(f,Wd),_=({id:C})=>{C===y.id&&(this.client.events.off("proposal_expire",_),this.pendingSessions.delete(y.id),this.events.emit(v,{error:{message:Wd,code:0}}))};return this.client.events.on("proposal_expire",_),this.events.once(v,({error:C,session:T})=>{this.client.events.off("proposal_expire",_),C?b(C):T&&w(T)}),await this.sendRequest({topic:l,method:"wc_sessionPropose",params:y,throwOnFailedPublish:!0,clientRpcId:y.id}),await this.setProposal(y.id,y),{uri:h,approval:N}}),D(this,"pair",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}}),D(this,"approve",async t=>{var i,r,n;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=t==null?void 0:t.id)==null?void 0:i.toString(),trace:[Ts.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(O){throw o.setError(Ki.no_internet_connection),O}try{await this.isValidProposalId(t==null?void 0:t.id)}catch(O){throw this.client.logger.error(`approve() -> proposal.get(${t==null?void 0:t.id}) failed`),o.setError(Ki.proposal_not_found),O}try{await this.isValidApprove(t)}catch(O){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Ki.session_approve_namespace_validation_failure),O}const{id:a,relayProtocol:c,namespaces:l,sessionProperties:h,sessionConfig:d}=t,p=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:f,proposer:g,requiredNamespaces:y,optionalNamespaces:v}=p;let b=(r=this.client.core.eventClient)==null?void 0:r.getEvent({topic:f});b||(b=(n=this.client.core.eventClient)==null?void 0:n.createEvent({type:Ts.session_approve_started,properties:{topic:f,trace:[Ts.session_approve_started,Ts.session_namespaces_validation_success]}}));const w=await this.client.core.crypto.generateKeyPair(),N=g.publicKey,_=await this.client.core.crypto.generateSharedKey(w,N),C=et(et({relay:{protocol:c??"irn"},namespaces:l,controller:{publicKey:w,metadata:this.client.metadata},expiry:dt(Tr)},h&&{sessionProperties:h}),d&&{sessionConfig:d}),T=Ze.relay;b.addTrace(Ts.subscribing_session_topic);try{await this.client.core.relayer.subscribe(_,{transportType:T})}catch(O){throw b.setError(Ki.subscribe_session_topic_failure),O}b.addTrace(Ts.subscribe_session_topic_success);const P=Gt(et({},C),{topic:_,requiredNamespaces:y,optionalNamespaces:v,pairingTopic:f,acknowledged:!1,self:C.controller,peer:{publicKey:g.publicKey,metadata:g.metadata},controller:w,transportType:Ze.relay});await this.client.session.set(_,P),b.addTrace(Ts.store_session);try{b.addTrace(Ts.publishing_session_settle),await this.sendRequest({topic:_,method:"wc_sessionSettle",params:C,throwOnFailedPublish:!0}).catch(O=>{throw b==null||b.setError(Ki.session_settle_publish_failure),O}),b.addTrace(Ts.session_settle_publish_success),b.addTrace(Ts.publishing_session_approve),await this.sendResult({id:a,topic:f,result:{relay:{protocol:c??"irn"},responderPublicKey:w},throwOnFailedPublish:!0}).catch(O=>{throw b==null||b.setError(Ki.session_approve_publish_failure),O}),b.addTrace(Ts.session_approve_publish_success)}catch(O){throw this.client.logger.error(O),this.client.session.delete(_,Re("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(_),O}return this.client.core.eventClient.deleteEvent({eventId:b.eventId}),await this.client.core.pairing.updateMetadata({topic:f,metadata:g.metadata}),await this.client.proposal.delete(a,Re("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:f}),await this.setExpiry(_,dt(Tr)),{topic:_,acknowledged:()=>Promise.resolve(this.client.session.get(_))}}),D(this,"reject",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:r}=t;let n;try{n=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}n&&(await this.sendError({id:i,topic:n,error:r,rpcOpts:wt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Re("USER_DISCONNECTED")))}),D(this,"update",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(d){throw this.client.logger.error("update() -> isValidUpdate() failed"),d}const{topic:i,namespaces:r}=t,{done:n,resolve:o,reject:a}=Zi(),c=u.payloadId(),l=u.getBigIntRpcId().toString(),h=this.client.session.get(i).namespaces;return this.events.once($e("session_update",c),({error:d})=>{d?a(d):o()}),await this.client.session.update(i,{namespaces:r}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:r},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:l}).catch(d=>{this.client.logger.error(d),this.client.session.update(i,{namespaces:h}),a(d)}),{acknowledged:n}}),D(this,"extend",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:i}=t,r=u.payloadId(),{done:n,resolve:o,reject:a}=Zi();return this.events.once($e("session_extend",r),({error:c})=>{c?a(c):o()}),await this.setExpiry(i,dt(Tr)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:r,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:n}}),D(this,"request",async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(b){throw this.client.logger.error("request() -> isValidRequest() failed"),b}const{chainId:i,request:r,topic:n,expiry:o=wt.wc_sessionRequest.req.ttl}=t,a=this.client.session.get(n);(a==null?void 0:a.transportType)===Ze.relay&&await this.confirmOnlineStateOrThrow();const c=u.payloadId(),l=u.getBigIntRpcId().toString(),{done:h,resolve:d,reject:p}=Zi(o,"Request expired. Please try again.");this.events.once($e("session_request",c),({error:b,result:w})=>{b?p(b):d(w)});const f="wc_sessionRequest",g=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(g)return await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:n,method:f,params:{request:Gt(et({},r),{expiryTimestamp:dt(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:g}).catch(b=>p(b)),this.client.events.emit("session_request_sent",{topic:n,request:r,chainId:i,id:c}),await h();const y={request:Gt(et({},r),{expiryTimestamp:dt(o)}),chainId:i},v=this.shouldSetTVF(f,y);return await Promise.all([new Promise(async b=>{await this.sendRequest(et({clientRpcId:c,relayRpcId:l,topic:n,method:f,params:y,expiry:o,throwOnFailedPublish:!0},v&&{tvf:this.getTVFParams(c,y)})).catch(w=>p(w)),this.client.events.emit("session_request_sent",{topic:n,request:r,chainId:i,id:c}),b()}),new Promise(async b=>{var w;if(!((w=a.sessionConfig)!=null&&w.disableDeepLink)){const N=await D0(this.client.core.storage,Hd);await M0({id:c,topic:n,wcDeepLink:N})}b()}),h()]).then(b=>b[2])}),D(this,"respond",async t=>{this.isInitialized(),await this.isValidRespond(t);const{topic:i,response:r}=t,{id:n}=r,o=this.client.session.get(i);o.transportType===Ze.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);u.isJsonRpcResult(r)?await this.sendResult({id:n,topic:i,result:r.result,throwOnFailedPublish:!0,appLink:a}):u.isJsonRpcError(r)&&await this.sendError({id:n,topic:i,error:r.error,appLink:a}),this.cleanupAfterResponse(t)}),D(this,"ping",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(r){throw this.client.logger.error("ping() -> isValidPing() failed"),r}const{topic:i}=t;if(this.client.session.keys.includes(i)){const r=u.payloadId(),n=u.getBigIntRpcId().toString(),{done:o,resolve:a,reject:c}=Zi();this.events.once($e("session_ping",r),({error:l})=>{l?c(l):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:r,relayRpcId:n}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:i}))}),D(this,"emit",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:i,event:r,chainId:n}=t,o=u.getBigIntRpcId().toString(),a=u.payloadId();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:r,chainId:n},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),D(this,"disconnect",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Re("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:r}=U("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(r)}}),D(this,"find",t=>(this.isInitialized(),this.client.session.getAll().filter(i=>W1(i,t)))),D(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),D(this,"authenticate",async(t,i)=>{var r;this.isInitialized(),this.isValidAuthenticate(t);const n=i&&this.client.core.linkModeSupportedApps.includes(i)&&((r=this.client.metadata.redirect)==null?void 0:r.linkMode),o=n?Ze.link_mode:Ze.relay;o===Ze.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:l,domain:h,nonce:d,type:p,exp:f,nbf:g,methods:y=[],expiry:v}=t,b=[...t.resources||[]],{topic:w,uri:N}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:w,uri:N}});const _=await this.client.core.crypto.generateKeyPair(),C=ka(_);if(await Promise.all([this.client.auth.authKeys.set(ja,{responseTopic:C,publicKey:_}),this.client.auth.pairingTopics.set(C,{topic:C,pairingTopic:w})]),await this.client.core.relayer.subscribe(C,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${w}`),y.length>0){const{namespace:S}=wn(a[0]);let z=AI(S,"request",y);Da(b)&&(z=CI(z,b.pop())),b.push(z)}const T=v&&v>wt.wc_sessionAuthenticate.req.ttl?v:wt.wc_sessionAuthenticate.req.ttl,P={authPayload:{type:p??"caip122",chains:a,statement:c,aud:l,domain:h,version:"1",nonce:d,iat:new Date().toISOString(),exp:f,nbf:g,resources:b},requester:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:dt(T)},O={eip155:{chains:a,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},$={requiredNamespaces:{},optionalNamespaces:O,relays:[{protocol:"irn"}],pairingTopic:w,proposer:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:dt(wt.wc_sessionPropose.req.ttl),id:u.payloadId()},{done:q,resolve:j,reject:G}=Zi(T,"Request expired"),B=u.payloadId(),W=$e("session_connect",$.id),V=$e("session_request",B),H=async({error:S,session:z})=>{this.events.off(V,K),S?G(S):z&&j({session:z})},K=async S=>{var z,ee,Z;if(await this.deletePendingAuthRequest(B,{message:"fulfilled",code:0}),S.error){const ke=Re("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return S.error.code===ke.code?void 0:(this.events.off(W,H),G(S.error.message))}await this.deleteProposal($.id),this.events.off(W,H);const{cacaos:ve,responder:pe}=S.result,te=[],st=[];for(const ke of ve){await Zu({cacao:ke,projectId:this.client.core.projectId})||(this.client.logger.error(ke,"Signature verification failed"),G(Re("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:js}=ke,Rs=Da(js.resources),Xs=[$l(js.iss)],Er=Va(js.iss);if(Rs){const Us=Ju(Rs),Dn=Xu(Rs);te.push(...Us),Xs.push(...Dn)}for(const Us of Xs)st.push(`${Us}:${Er}`)}const Le=await this.client.core.crypto.generateSharedKey(_,pe.publicKey);let Ie;te.length>0&&(Ie={topic:Le,acknowledged:!0,self:{publicKey:_,metadata:this.client.metadata},peer:pe,controller:pe.publicKey,expiry:dt(Tr),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:w,namespaces:md([...new Set(te)],[...new Set(st)]),transportType:o},await this.client.core.relayer.subscribe(Le,{transportType:o}),await this.client.session.set(Le,Ie),w&&await this.client.core.pairing.updateMetadata({topic:w,metadata:pe.metadata}),Ie=this.client.session.get(Le)),(z=this.client.metadata.redirect)!=null&&z.linkMode&&(ee=pe.metadata.redirect)!=null&&ee.linkMode&&(Z=pe.metadata.redirect)!=null&&Z.universal&&i&&(this.client.core.addLinkModeSupportedApp(pe.metadata.redirect.universal),this.client.session.update(Le,{transportType:Ze.link_mode})),j({auths:ve,session:Ie})};this.events.once(W,H),this.events.once(V,K);let Q;try{if(n){const S=u.formatJsonRpcRequest("wc_sessionAuthenticate",P,B);this.client.core.history.set(w,S);const z=await this.client.core.crypto.encode("",S,{type:Ho,encoding:Bn});Q=pa(i,w,z)}else await Promise.all([this.sendRequest({topic:w,method:"wc_sessionAuthenticate",params:P,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:B}),this.sendRequest({topic:w,method:"wc_sessionPropose",params:$,expiry:wt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:$.id})])}catch(S){throw this.events.off(W,H),this.events.off(V,K),S}return await this.setProposal($.id,$),await this.setAuthRequest(B,{request:Gt(et({},P),{verifyContext:{}}),pairingTopic:w,transportType:o}),{uri:Q??N,response:q}}),D(this,"approveSessionAuthenticate",async t=>{const{id:i,auths:r}=t,n=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[Gi.authenticated_session_approve_started]}});try{this.isInitialized()}catch(v){throw n.setError(Vn.no_internet_connection),v}const o=this.getPendingAuthRequest(i);if(!o)throw n.setError(Vn.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||Ze.relay;a===Ze.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),h=ka(c),d={type:di,receiverPublicKey:c,senderPublicKey:l},p=[],f=[];for(const v of r){if(!await Zu({cacao:v,projectId:this.client.core.projectId})){n.setError(Vn.invalid_cacao);const C=Re("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:h,error:C,encodeOpts:d}),new Error(C.message)}n.addTrace(Gi.cacaos_verified);const{p:b}=v,w=Da(b.resources),N=[$l(b.iss)],_=Va(b.iss);if(w){const C=Ju(w),T=Xu(w);p.push(...C),N.push(...T)}for(const C of N)f.push(`${C}:${_}`)}const g=await this.client.core.crypto.generateSharedKey(l,c);n.addTrace(Gi.create_authenticated_session_topic);let y;if((p==null?void 0:p.length)>0){y={topic:g,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:dt(Tr),authentication:r,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:md([...new Set(p)],[...new Set(f)]),transportType:a},n.addTrace(Gi.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(g,{transportType:a})}catch(v){throw n.setError(Vn.subscribe_authenticated_session_topic_failure),v}n.addTrace(Gi.subscribe_authenticated_session_topic_success),await this.client.session.set(g,y),n.addTrace(Gi.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}n.addTrace(Gi.publishing_authenticated_session_approve);try{await this.sendResult({topic:h,id:i,result:{cacaos:r,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:d,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(v){throw n.setError(Vn.authenticated_session_approve_publish_failure),v}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:n.eventId}),{session:y}}),D(this,"rejectSessionAuthenticate",async t=>{this.isInitialized();const{id:i,reason:r}=t,n=this.getPendingAuthRequest(i);if(!n)throw new Error(`Could not find pending auth request with id ${i}`);n.transportType===Ze.relay&&await this.confirmOnlineStateOrThrow();const o=n.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=ka(o),l={type:di,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:c,error:r,encodeOpts:l,rpcOpts:wt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(n.requester.metadata,n.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Re("USER_DISCONNECTED"))}),D(this,"formatAuthMessage",t=>{this.isInitialized();const{request:i,iss:r}=t;return Zf(i,r)}),D(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)}),D(this,"cleanupDuplicatePairings",async t=>{if(t.pairingTopic)try{const i=this.client.core.pairing.pairings.get(t.pairingTopic),r=this.client.core.pairing.pairings.getAll().filter(n=>{var o,a;return((o=n.peerMetadata)==null?void 0:o.url)&&((a=n.peerMetadata)==null?void 0:a.url)===t.peer.metadata.url&&n.topic&&n.topic!==i.topic});if(r.length===0)return;this.client.logger.info(`Cleaning up ${r.length} duplicate pairing(s)`),await Promise.all(r.map(n=>this.client.core.pairing.disconnect({topic:n.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}}),D(this,"deleteSession",async t=>{var i;const{topic:r,expirerHasDeleted:n=!1,emitEvent:o=!0,id:a=0}=t,{self:c}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),await this.client.session.delete(r,Re("USER_DISCONNECTED")),this.addToRecentlyDeleted(r,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(r)&&await this.client.core.crypto.deleteSymKey(r),n||this.client.core.expirer.del(r),this.client.core.storage.removeItem(Hd).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===r&&this.deletePendingSessionRequest(l.id,Re("USER_DISCONNECTED"))}),r===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=Bs.idle),o&&this.client.events.emit("session_delete",{id:a,topic:r})}),D(this,"deleteProposal",async(t,i)=>{if(i)try{const r=this.client.proposal.get(t),n=this.client.core.eventClient.getEvent({topic:r.pairingTopic});n==null||n.setError(Ki.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,Re("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")}),D(this,"deletePendingSessionRequest",async(t,i,r=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),r?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(n=>n.id!==t),r&&(this.sessionRequestQueue.state=Bs.idle,this.client.events.emit("session_request_expire",{id:t}))}),D(this,"deletePendingAuthRequest",async(t,i,r=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),r?Promise.resolve():this.client.core.expirer.del(t)])}),D(this,"setExpiry",async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))}),D(this,"setProposal",async(t,i)=>{this.client.core.expirer.set(t,dt(wt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)}),D(this,"setAuthRequest",async(t,i)=>{const{request:r,pairingTopic:n,transportType:o=Ze.relay}=i;this.client.core.expirer.set(t,r.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:r.authPayload,requester:r.requester,expiryTimestamp:r.expiryTimestamp,id:t,pairingTopic:n,verifyContext:r.verifyContext,transportType:o})}),D(this,"setPendingSessionRequest",async t=>{const{id:i,topic:r,params:n,verifyContext:o}=t,a=n.request.expiryTimestamp||dt(wt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:r,params:n,verifyContext:o})}),D(this,"sendRequest",async t=>{const{topic:i,method:r,params:n,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:l,appLink:h,tvf:d}=t,p=u.formatJsonRpcRequest(r,n,c);let f;const g=!!h;try{const b=g?Bn:Mi;f=await this.client.core.crypto.encode(i,p,{encoding:b})}catch(b){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),b}let y;if(D_.includes(r)){const b=hi(JSON.stringify(p)),w=hi(f);y=await this.client.core.verify.register({id:w,decryptedId:b})}const v=wt[r].req;if(v.attestation=y,o&&(v.ttl=o),a&&(v.id=a),this.client.core.history.set(i,p),g){const b=pa(h,i,f);await A.dist.global.Linking.openURL(b,this.client.name)}else{const b=wt[r].req;o&&(b.ttl=o),a&&(b.id=a),b.tvf=Gt(et({},d),{correlationId:p.id}),l?(b.internal=Gt(et({},b.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,f,b)):this.client.core.relayer.publish(i,f,b).catch(w=>this.client.logger.error(w))}return p.id}),D(this,"sendResult",async t=>{const{id:i,topic:r,result:n,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=t,l=u.formatJsonRpcResult(i,n);let h;const d=c&&typeof(A.dist.global==null?void 0:A.dist.global.Linking)<"u";try{const g=d?Bn:Mi;h=await this.client.core.crypto.encode(r,l,Gt(et({},a||{}),{encoding:g}))}catch(g){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${r} failed`),g}let p,f;try{p=await this.client.core.history.get(r,i);const g=p.request;try{this.shouldSetTVF(g.method,g.params)&&(f=this.getTVFParams(i,g.params,n))}catch(y){this.client.logger.warn("sendResult() -> getTVFParams() failed",y)}}catch(g){throw this.client.logger.error(`sendResult() -> history.get(${r}, ${i}) failed`),g}if(d){const g=pa(c,r,h);await A.dist.global.Linking.openURL(g,this.client.name)}else{const g=p.request.method,y=wt[g].res;y.tvf=Gt(et({},f),{correlationId:i}),o?(y.internal=Gt(et({},y.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(r,h,y)):this.client.core.relayer.publish(r,h,y).catch(v=>this.client.logger.error(v))}await this.client.core.history.resolve(l)}),D(this,"sendError",async t=>{const{id:i,topic:r,error:n,encodeOpts:o,rpcOpts:a,appLink:c}=t,l=u.formatJsonRpcError(i,n);let h;const d=c&&typeof(A.dist.global==null?void 0:A.dist.global.Linking)<"u";try{const f=d?Bn:Mi;h=await this.client.core.crypto.encode(r,l,Gt(et({},o||{}),{encoding:f}))}catch(f){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${r} failed`),f}let p;try{p=await this.client.core.history.get(r,i)}catch(f){throw this.client.logger.error(`sendError() -> history.get(${r}, ${i}) failed`),f}if(d){const f=pa(c,r,h);await A.dist.global.Linking.openURL(f,this.client.name)}else{const f=p.request.method,g=a||wt[f].res;this.client.core.relayer.publish(r,h,g)}await this.client.core.history.resolve(l)}),D(this,"cleanup",async()=>{const t=[],i=[];this.client.session.getAll().forEach(r=>{let n=!1;Ci(r.expiry)&&(n=!0),this.client.core.crypto.keychain.has(r.topic)||(n=!0),n&&t.push(r.topic)}),this.client.proposal.getAll().forEach(r=>{Ci(r.expiryTimestamp)&&i.push(r.id)}),await Promise.all([...t.map(r=>this.deleteSession({topic:r})),...i.map(r=>this.deleteProposal(r))])}),D(this,"onRelayEventRequest",async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()}),D(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===Bs.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Bs.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=Bs.idle}),D(this,"processRequest",async t=>{const{topic:i,payload:r,attestation:n,transportType:o,encryptedId:a}=t,c=r.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:r,attestation:n,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,r);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,r);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,r);case"wc_sessionPing":return await this.onSessionPingRequest(i,r);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,r);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:r,attestation:n,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,r);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:r,attestation:n,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}}),D(this,"onRelayEventResponse",async t=>{const{topic:i,payload:r,transportType:n}=t,o=(await this.client.core.history.get(i,r.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,r,n);case"wc_sessionSettle":return this.onSessionSettleResponse(i,r);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,r);case"wc_sessionExtend":return this.onSessionExtendResponse(i,r);case"wc_sessionPing":return this.onSessionPingResponse(i,r);case"wc_sessionRequest":return this.onSessionRequestResponse(i,r);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,r);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),D(this,"onRelayEventUnknownPayload",t=>{const{topic:i}=t,{message:r}=U("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(r)}),D(this,"shouldIgnorePairingRequest",t=>{const{topic:i,requestMethod:r}=t,n=this.expectedPairingMethodMap.get(i);return!n||n.includes(r)?!1:!!(n.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),D(this,"onSessionProposeRequest",async t=>{const{topic:i,payload:r,attestation:n,encryptedId:o}=t,{params:a,id:c}=r;try{const l=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),l==null||l.setError(ci.proposal_listener_not_found)),this.isValidConnect(et({},r.params));const h=a.expiryTimestamp||dt(wt.wc_sessionPropose.req.ttl),d=et({id:c,pairingTopic:i,expiryTimestamp:h},a);await this.setProposal(c,d);const p=await this.getVerifyContext({attestationId:n,hash:hi(JSON.stringify(r)),encryptedId:o,metadata:d.proposer.metadata});l==null||l.addTrace(Gs.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:d,verifyContext:p})}catch(l){await this.sendError({id:c,topic:i,error:l,rpcOpts:wt.wc_sessionPropose.autoReject}),this.client.logger.error(l)}}),D(this,"onSessionProposeResponse",async(t,i,r)=>{const{id:n}=i;if(u.isJsonRpcResult(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const l=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const h=await this.client.core.crypto.generateSharedKey(c,l);this.pendingSessions.set(n,{sessionTopic:h,pairingTopic:t,proposalId:n,publicKey:c});const d=await this.client.core.relayer.subscribe(h,{transportType:r});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:d}),await this.client.core.pairing.activate({topic:t})}else if(u.isJsonRpcError(i)){await this.client.proposal.delete(n,Re("USER_DISCONNECTED"));const o=$e("session_connect",n);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:i.error})}}),D(this,"onSessionSettleRequest",async(t,i)=>{const{id:r,params:n}=i;try{this.isValidSessionSettleRequest(n);const{relay:o,controller:a,expiry:c,namespaces:l,sessionProperties:h,sessionConfig:d}=i.params,p=[...this.pendingSessions.values()].find(y=>y.sessionTopic===t);if(!p)return this.client.logger.error(`Pending session not found for topic ${t}`);const f=this.client.proposal.get(p.proposalId),g=Gt(et(et({topic:t,relay:o,expiry:c,namespaces:l,acknowledged:!0,pairingTopic:p.pairingTopic,requiredNamespaces:f.requiredNamespaces,optionalNamespaces:f.optionalNamespaces,controller:a.publicKey,self:{publicKey:p.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},h&&{sessionProperties:h}),d&&{sessionConfig:d}),{transportType:Ze.relay});await this.client.session.set(g.topic,g),await this.setExpiry(g.topic,g.expiry),await this.client.core.pairing.updateMetadata({topic:p.pairingTopic,metadata:g.peer.metadata}),this.client.events.emit("session_connect",{session:g}),this.events.emit($e("session_connect",p.proposalId),{session:g}),this.pendingSessions.delete(p.proposalId),this.deleteProposal(p.proposalId,!1),this.cleanupDuplicatePairings(g),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:r,topic:t,error:o}),this.client.logger.error(o)}}),D(this,"onSessionSettleResponse",async(t,i)=>{const{id:r}=i;u.isJsonRpcResult(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit($e("session_approve",r),{})):u.isJsonRpcError(i)&&(await this.client.session.delete(t,Re("USER_DISCONNECTED")),this.events.emit($e("session_approve",r),{error:i.error}))}),D(this,"onSessionUpdateRequest",async(t,i)=>{const{params:r,id:n}=i;try{const o=`${t}_session_update`,a=Hn.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.warn(`Discarding out of sync request - ${n}`),this.sendError({id:n,topic:t,error:Re("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(et({topic:t},r));try{Hn.set(o,n),await this.client.session.update(t,{namespaces:r.namespaces}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0})}catch(c){throw Hn.delete(o),c}this.client.events.emit("session_update",{id:n,topic:t,params:r})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}}),D(this,"isRequestOutOfSync",(t,i)=>i.toString().slice(0,-3)<t.toString().slice(0,-3)),D(this,"onSessionUpdateResponse",(t,i)=>{const{id:r}=i,n=$e("session_update",r);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);u.isJsonRpcResult(i)?this.events.emit($e("session_update",r),{}):u.isJsonRpcError(i)&&this.events.emit($e("session_update",r),{error:i.error})}),D(this,"onSessionExtendRequest",async(t,i)=>{const{id:r}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,dt(Tr)),await this.sendResult({id:r,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:r,topic:t})}catch(n){await this.sendError({id:r,topic:t,error:n}),this.client.logger.error(n)}}),D(this,"onSessionExtendResponse",(t,i)=>{const{id:r}=i,n=$e("session_extend",r);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);u.isJsonRpcResult(i)?this.events.emit($e("session_extend",r),{}):u.isJsonRpcError(i)&&this.events.emit($e("session_extend",r),{error:i.error})}),D(this,"onSessionPingRequest",async(t,i)=>{const{id:r}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:r,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:r,topic:t})}catch(n){await this.sendError({id:r,topic:t,error:n}),this.client.logger.error(n)}}),D(this,"onSessionPingResponse",(t,i)=>{const{id:r}=i,n=$e("session_ping",r);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);setTimeout(()=>{u.isJsonRpcResult(i)?this.events.emit($e("session_ping",r),{}):u.isJsonRpcError(i)&&this.events.emit($e("session_ping",r),{error:i.error})},500)}),D(this,"onSessionDeleteRequest",async(t,i)=>{const{id:r}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(n=>{this.client.core.relayer.once(It.publish,async()=>{n(await this.deleteSession({topic:t,id:r}))})}),this.sendResult({id:r,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:Re("USER_DISCONNECTED")})]).catch(n=>this.client.logger.error(n))}catch(n){this.client.logger.error(n)}}),D(this,"onSessionRequest",async t=>{var i,r,n;const{topic:o,payload:a,attestation:c,encryptedId:l,transportType:h}=t,{id:d,params:p}=a;try{await this.isValidRequest(et({topic:o},p));const f=this.client.session.get(o),g=await this.getVerifyContext({attestationId:c,hash:hi(JSON.stringify(u.formatJsonRpcRequest("wc_sessionRequest",p,d))),encryptedId:l,metadata:f.peer.metadata,transportType:h}),y={id:d,topic:o,params:p,verifyContext:g};await this.setPendingSessionRequest(y),h===Ze.link_mode&&(i=f.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((r=f.peer.metadata.redirect)==null?void 0:r.universal),(n=this.client.signConfig)!=null&&n.disableRequestQueue?this.emitSessionRequest(y):(this.addSessionRequestToSessionRequestQueue(y),this.processSessionRequestQueue())}catch(f){await this.sendError({id:d,topic:o,error:f}),this.client.logger.error(f)}}),D(this,"onSessionRequestResponse",(t,i)=>{const{id:r}=i,n=$e("session_request",r);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);u.isJsonRpcResult(i)?this.events.emit($e("session_request",r),{result:i.result}):u.isJsonRpcError(i)&&this.events.emit($e("session_request",r),{error:i.error})}),D(this,"onSessionEventRequest",async(t,i)=>{const{id:r,params:n}=i;try{const o=`${t}_session_event_${n.event.name}`,a=Hn.get(o);if(a&&this.isRequestOutOfSync(a,r)){this.client.logger.info(`Discarding out of sync request - ${r}`);return}this.isValidEmit(et({topic:t},n)),this.client.events.emit("session_event",{id:r,topic:t,params:n}),Hn.set(o,r)}catch(o){await this.sendError({id:r,topic:t,error:o}),this.client.logger.error(o)}}),D(this,"onSessionAuthenticateResponse",(t,i)=>{const{id:r}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),u.isJsonRpcResult(i)?this.events.emit($e("session_request",r),{result:i.result}):u.isJsonRpcError(i)&&this.events.emit($e("session_request",r),{error:i.error})}),D(this,"onSessionAuthenticateRequest",async t=>{var i;const{topic:r,payload:n,attestation:o,encryptedId:a,transportType:c}=t;try{const{requester:l,authPayload:h,expiryTimestamp:d}=n.params,p=await this.getVerifyContext({attestationId:o,hash:hi(JSON.stringify(n)),encryptedId:a,metadata:l.metadata,transportType:c}),f={requester:l,pairingTopic:r,id:n.id,authPayload:h,verifyContext:p,expiryTimestamp:d};await this.setAuthRequest(n.id,{request:f,pairingTopic:r,transportType:c}),c===Ze.link_mode&&(i=l.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:r,params:n.params,id:n.id,verifyContext:p})}catch(l){this.client.logger.error(l);const h=n.params.requester.publicKey,d=await this.client.core.crypto.generateKeyPair(),p=this.getAppLinkIfEnabled(n.params.requester.metadata,c),f={type:di,receiverPublicKey:h,senderPublicKey:d};await this.sendError({id:n.id,topic:r,error:l,encodeOpts:f,rpcOpts:wt.wc_sessionAuthenticate.autoReject,appLink:p})}}),D(this,"addSessionRequestToSessionRequestQueue",t=>{this.sessionRequestQueue.queue.push(t)}),D(this,"cleanupAfterResponse",t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Bs.idle,this.processSessionRequestQueue()},u.cjs.toMiliseconds(this.requestQueueDelay))}),D(this,"cleanupPendingSentRequestsForTopic",({topic:t,error:i})=>{const r=this.client.core.history.pending;r.length>0&&r.filter(n=>n.topic===t&&n.request.method==="wc_sessionRequest").forEach(n=>{const o=n.request.id,a=$e("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit($e("session_request",n.request.id),{error:i})})}),D(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===Bs.active){this.client.logger.info("session request queue is already active.");return}const t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Bs.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}}),D(this,"emitSessionRequest",t=>{this.client.events.emit("session_request",t)}),D(this,"onPairingCreated",t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const i=this.client.proposal.getAll().find(r=>r.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:u.formatJsonRpcRequest("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})}),D(this,"isValidConnect",async t=>{if(!Jt(t)){const{message:c}=U("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(c)}const{pairingTopic:i,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:o,relays:a}=t;if(Wt(i)||await this.isValidPairingTopic(i),!iE(a)){const{message:c}=U("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(c)}!Wt(r)&&Po(r)!==0&&this.validateNamespaces(r,"requiredNamespaces"),!Wt(n)&&Po(n)!==0&&this.validateNamespaces(n,"optionalNamespaces"),Wt(o)||this.validateSessionProps(o,"sessionProperties")}),D(this,"validateNamespaces",(t,i)=>{const r=sE(t,"connect()",i);if(r)throw new Error(r.message)}),D(this,"isValidApprove",async t=>{if(!Jt(t))throw new Error(U("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:i,namespaces:r,relayProtocol:n,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const a=this.client.proposal.get(i),c=Fc(r,"approve()");if(c)throw new Error(c.message);const l=Id(a.requiredNamespaces,r,"approve()");if(l)throw new Error(l.message);if(!nt(n,!0)){const{message:h}=U("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(h)}Wt(o)||this.validateSessionProps(o,"sessionProperties")}),D(this,"isValidReject",async t=>{if(!Jt(t)){const{message:n}=U("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(n)}const{id:i,reason:r}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!nE(r)){const{message:n}=U("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(r)}`);throw new Error(n)}}),D(this,"isValidSessionSettleRequest",t=>{if(!Jt(t)){const{message:l}=U("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(l)}const{relay:i,controller:r,namespaces:n,expiry:o}=t;if(!gy(i)){const{message:l}=U("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const a=Q1(r,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=Fc(n,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(Ci(o)){const{message:l}=U("EXPIRED","onSessionSettleRequest()");throw new Error(l)}}),D(this,"isValidUpdate",async t=>{if(!Jt(t)){const{message:c}=U("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(c)}const{topic:i,namespaces:r}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const n=this.client.session.get(i),o=Fc(r,"update()");if(o)throw new Error(o.message);const a=Id(n.requiredNamespaces,r,"update()");if(a)throw new Error(a.message)}),D(this,"isValidExtend",async t=>{if(!Jt(t)){const{message:r}=U("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(r)}const{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)}),D(this,"isValidRequest",async t=>{if(!Jt(t)){const{message:c}=U("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(c)}const{topic:i,request:r,chainId:n,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:a}=this.client.session.get(i);if(!vd(a,n)){const{message:c}=U("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(c)}if(!oE(r)){const{message:c}=U("MISSING_OR_INVALID",`request() ${JSON.stringify(r)}`);throw new Error(c)}if(!lE(a,n,r.method)){const{message:c}=U("MISSING_OR_INVALID",`request() method: ${r.method}`);throw new Error(c)}if(o&&!pE(o,Kc)){const{message:c}=U("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Kc.min} and ${Kc.max}`);throw new Error(c)}}),D(this,"isValidRespond",async t=>{var i;if(!Jt(t)){const{message:o}=U("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}const{topic:r,response:n}=t;try{await this.isValidSessionTopic(r)}catch(o){throw(i=t==null?void 0:t.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!aE(n)){const{message:o}=U("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(o)}}),D(this,"isValidPing",async t=>{if(!Jt(t)){const{message:r}=U("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(r)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)}),D(this,"isValidEmit",async t=>{if(!Jt(t)){const{message:a}=U("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(a)}const{topic:i,event:r,chainId:n}=t;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!vd(o,n)){const{message:a}=U("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(a)}if(!cE(r)){const{message:a}=U("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(a)}if(!hE(o,n,r.name)){const{message:a}=U("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(a)}}),D(this,"isValidDisconnect",async t=>{if(!Jt(t)){const{message:r}=U("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(r)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)}),D(this,"isValidAuthenticate",t=>{const{chains:i,uri:r,domain:n,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!nt(r,!1))throw new Error("uri is required parameter");if(!nt(n,!1))throw new Error("domain is required parameter");if(!nt(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>wn(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=wn(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),D(this,"getVerifyContext",async t=>{const{attestationId:i,hash:r,encryptedId:n,metadata:o,transportType:a}=t,c={verified:{verifyUrl:o.verifyUrl||yo,validation:"UNKNOWN",origin:o.url||""}};try{if(a===Ze.link_mode){const h=this.getAppLinkIfEnabled(o,a);return c.verified.validation=h&&new URL(h).origin===new URL(o.url).origin?"VALID":"INVALID",c}const l=await this.client.core.verify.resolve({attestationId:i,hash:r,encryptedId:n,verifyUrl:o.verifyUrl});l&&(c.verified.origin=l.origin,c.verified.isScam=l.isScam,c.verified.validation=l.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(l){this.client.logger.warn(l)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),D(this,"validateSessionProps",(t,i)=>{Object.values(t).forEach(r=>{if(!nt(r,!1)){const{message:n}=U("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(r)}`);throw new Error(n)}})}),D(this,"getPendingAuthRequest",t=>{const i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0}),D(this,"addToRecentlyDeleted",(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let r=0;const n=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(r++>=n)break;this.recentlyDeletedMap.delete(o)}}}),D(this,"checkRecentlyDeleted",t=>{const i=this.recentlyDeletedMap.get(t);if(i){const{message:r}=U("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(r)}}),D(this,"isLinkModeEnabled",(t,i)=>{var r,n,o,a,c,l,h,d,p;return!t||i!==Ze.link_mode?!1:((n=(r=this.client.metadata)==null?void 0:r.redirect)==null?void 0:n.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((l=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:l.universal)!==""&&((h=t==null?void 0:t.redirect)==null?void 0:h.universal)!==void 0&&((d=t==null?void 0:t.redirect)==null?void 0:d.universal)!==""&&((p=t==null?void 0:t.redirect)==null?void 0:p.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(A.dist.global==null?void 0:A.dist.global.Linking)<"u"}),D(this,"getAppLinkIfEnabled",(t,i)=>{var r;return this.isLinkModeEnabled(t,i)?(r=t==null?void 0:t.redirect)==null?void 0:r.universal:void 0}),D(this,"handleLinkModeMessage",({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const i=qu(t,"topic")||"",r=decodeURIComponent(qu(t,"wc_ev")||""),n=this.client.session.keys.includes(i);n&&this.client.session.update(i,{transportType:Ze.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:r,sessionExists:n})}),D(this,"registerLinkModeListeners",async()=>{var t;if(xh()||zi()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){const i=A.dist.global==null?void 0:A.dist.global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const r=await i.getInitialURL();r&&setTimeout(()=>{this.handleLinkModeMessage({url:r})},50)}}}),D(this,"shouldSetTVF",(t,i)=>{if(!i||t!=="wc_sessionRequest")return!1;const{request:r}=i;return Object.keys(Vd).includes(r.method)}),D(this,"getTVFParams",(t,i,r)=>{var n,o;try{const a=i.request.method,c=this.extractTxHashesFromResult(a,r);return Gt(et({correlationId:t,rpcMethods:[a],chainId:i.chainId},this.isValidContractData(i.request.params)&&{contractAddresses:[(o=(n=i.request.params)==null?void 0:n[0])==null?void 0:o.to]}),{txHashes:c})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),D(this,"isValidContractData",t=>{var i;if(!t)return!1;try{const r=(t==null?void 0:t.data)||((i=t==null?void 0:t[0])==null?void 0:i.data);if(!r.startsWith("0x"))return!1;const n=r.slice(2);return/^[0-9a-fA-F]*$/.test(n)?n.length%2===0:!1}catch{}return!1}),D(this,"extractTxHashesFromResult",(t,i)=>{try{const r=Vd[t];if(typeof i=="string")return[i];const n=i[r.key];if(ur(n))return n;if(typeof n=="string")return[n]}catch(r){this.client.logger.warn("Error extracting tx hashes from result",r)}return[]})}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(It.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:i,attestation:r,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(ja)?this.client.auth.authKeys.get(ja):{publicKey:void 0},a=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:n===Ze.link_mode?Bn:Mi});try{u.isJsonRpcRequest(a)?(this.client.core.history.set(t,a),this.onRelayEventRequest({topic:t,payload:a,attestation:r,transportType:n,encryptedId:hi(i)})):u.isJsonRpcResponse(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:t,payload:a,transportType:n}),this.client.core.history.delete(t,a.id)):this.onRelayEventUnknownPayload({topic:t,payload:a,transportType:n})}catch(c){this.client.logger.error(c)}}registerExpirerEvents(){this.client.core.expirer.on(bs.expired,async e=>{const{topic:t,id:i}=qf(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,U("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,U("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(tr.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(tr.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!nt(e,!1)){const{message:t}=U("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=U("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Ci(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=U("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!nt(e,!1)){const{message:t}=U("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=U("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Ci(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=U("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=U("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(nt(e,!1)){const{message:t}=U("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{const{message:t}=U("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!rE(e)){const{message:t}=U("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=U("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Ci(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=U("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}},V_=class extends wr{constructor(e,t){super(e,t,$_,Fh),this.core=e,this.logger=t}},K_=class extends wr{constructor(e,t){super(e,t,M_,Fh),this.core=e,this.logger=t}},G_=class extends wr{constructor(e,t){super(e,t,O_,Fh,i=>i.id),this.core=e,this.logger=t}},Y_=class extends wr{constructor(e,t){super(e,t,R_,pc,()=>ja),this.core=e,this.logger=t}},Q_=class extends wr{constructor(e,t){super(e,t,U_,pc),this.core=e,this.logger=t}},Z_=class extends wr{constructor(e,t){super(e,t,L_,pc,i=>i.id),this.core=e,this.logger=t}};var J_=Object.defineProperty,X_=(s,e,t)=>e in s?J_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Gc=(s,e,t)=>X_(s,typeof e!="symbol"?e+"":e,t);let eC=class{constructor(e,t){this.core=e,this.logger=t,Gc(this,"authKeys"),Gc(this,"pairingTopics"),Gc(this,"requests"),this.authKeys=new Y_(this.core,this.logger),this.pairingTopics=new Q_(this.core,this.logger),this.requests=new Z_(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}};var tC=Object.defineProperty,sC=(s,e,t)=>e in s?tC(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ye=(s,e,t)=>sC(s,typeof e!="symbol"?e+"":e,t);let iC=class Dy extends T_{constructor(e){super(e),ye(this,"protocol",My),ye(this,"version",xy),ye(this,"name",Vc.name),ye(this,"metadata"),ye(this,"core"),ye(this,"logger"),ye(this,"events",new oe.eventsExports.EventEmitter),ye(this,"engine"),ye(this,"session"),ye(this,"proposal"),ye(this,"pendingRequest"),ye(this,"auth"),ye(this,"signConfig"),ye(this,"on",(i,r)=>this.events.on(i,r)),ye(this,"once",(i,r)=>this.events.once(i,r)),ye(this,"off",(i,r)=>this.events.off(i,r)),ye(this,"removeListener",(i,r)=>this.events.removeListener(i,r)),ye(this,"removeAllListeners",i=>this.events.removeAllListeners(i)),ye(this,"connect",async i=>{try{return await this.engine.connect(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"pair",async i=>{try{return await this.engine.pair(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"approve",async i=>{try{return await this.engine.approve(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"reject",async i=>{try{return await this.engine.reject(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"update",async i=>{try{return await this.engine.update(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"extend",async i=>{try{return await this.engine.extend(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"request",async i=>{try{return await this.engine.request(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"respond",async i=>{try{return await this.engine.respond(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"ping",async i=>{try{return await this.engine.ping(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"emit",async i=>{try{return await this.engine.emit(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"disconnect",async i=>{try{return await this.engine.disconnect(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"find",i=>{try{return this.engine.find(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}}),ye(this,"authenticate",async(i,r)=>{try{return await this.engine.authenticate(i,r)}catch(n){throw this.logger.error(n.message),n}}),ye(this,"formatAuthMessage",i=>{try{return this.engine.formatAuthMessage(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"approveSessionAuthenticate",async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(r){throw this.logger.error(r.message),r}}),ye(this,"rejectSessionAuthenticate",async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(r){throw this.logger.error(r.message),r}}),this.name=(e==null?void 0:e.name)||Vc.name,this.metadata=(e==null?void 0:e.metadata)||Rf(),this.signConfig=e==null?void 0:e.signConfig;const t=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:u.Ot(u.k({level:(e==null?void 0:e.logger)||Vc.logger}));this.core=(e==null?void 0:e.core)||new __(e),this.logger=u.E(t,this.name),this.session=new K_(this.core,this.logger),this.proposal=new V_(this.core,this.logger),this.pendingRequest=new G_(this.core,this.logger),this.engine=new W_(this),this.auth=new eC(this.core,this.logger)}static async init(e){const t=new Dy(e);return await t.initialize(),t}get context(){return u.y(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},u.cjs.toMiliseconds(u.cjs.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};const Gd="error",rC="wss://relay.walletconnect.org",nC="wc",oC="universal_provider",Yd=`${nC}@2:${oC}:`,ky="https://rpc.walletconnect.org/v1/",rn="generic",aC=`${ky}bundler`,As={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var fa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof A.dist.global<"u"?A.dist.global:typeof self<"u"?self:{};function cC(){this.__data__=[],this.size=0}var lC=cC;function hC(s,e){return s===e||s!==s&&e!==e}var gc=hC,uC=gc;function dC(s,e){for(var t=s.length;t--;)if(uC(s[t][0],e))return t;return-1}var fc=dC,pC=fc,gC=Array.prototype,fC=gC.splice;function yC(s){var e=this.__data__,t=pC(e,s);if(t<0)return!1;var i=e.length-1;return t==i?e.pop():fC.call(e,t,1),--this.size,!0}var wC=yC,mC=fc;function bC(s){var e=this.__data__,t=mC(e,s);return t<0?void 0:e[t][1]}var vC=bC,IC=fc;function EC(s){return IC(this.__data__,s)>-1}var NC=EC,AC=fc;function _C(s,e){var t=this.__data__,i=AC(t,s);return i<0?(++this.size,t.push([s,e])):t[i][1]=e,this}var CC=_C,SC=lC,TC=wC,PC=vC,$C=NC,MC=CC;function nn(s){var e=-1,t=s==null?0:s.length;for(this.clear();++e<t;){var i=s[e];this.set(i[0],i[1])}}nn.prototype.clear=SC,nn.prototype.delete=TC,nn.prototype.get=PC,nn.prototype.has=$C,nn.prototype.set=MC;var yc=nn,xC=yc;function OC(){this.__data__=new xC,this.size=0}var DC=OC;function kC(s){var e=this.__data__,t=e.delete(s);return this.size=e.size,t}var jC=kC;function RC(s){return this.__data__.get(s)}var UC=RC;function LC(s){return this.__data__.has(s)}var zC=LC,FC=typeof fa=="object"&&fa&&fa.Object===Object&&fa,jy=FC,qC=jy,BC=typeof self=="object"&&self&&self.Object===Object&&self,HC=qC||BC||Function("return this")(),$n=HC,WC=$n,VC=WC.Symbol,Ry=VC,Qd=Ry,Uy=Object.prototype,KC=Uy.hasOwnProperty,GC=Uy.toString,Yn=Qd?Qd.toStringTag:void 0;function YC(s){var e=KC.call(s,Yn),t=s[Yn];try{s[Yn]=void 0;var i=!0}catch{}var r=GC.call(s);return i&&(e?s[Yn]=t:delete s[Yn]),r}var QC=YC,ZC=Object.prototype,JC=ZC.toString;function XC(s){return JC.call(s)}var eS=XC,Zd=Ry,tS=QC,sS=eS,iS="[object Null]",rS="[object Undefined]",Jd=Zd?Zd.toStringTag:void 0;function nS(s){return s==null?s===void 0?rS:iS:Jd&&Jd in Object(s)?tS(s):sS(s)}var wc=nS;function oS(s){var e=typeof s;return s!=null&&(e=="object"||e=="function")}var mr=oS,aS=wc,cS=mr,lS="[object AsyncFunction]",hS="[object Function]",uS="[object GeneratorFunction]",dS="[object Proxy]";function pS(s){if(!cS(s))return!1;var e=aS(s);return e==hS||e==uS||e==lS||e==dS}var qh=pS,gS=$n,fS=gS["__core-js_shared__"],yS=fS,Yc=yS,Xd=function(){var s=/[^.]+$/.exec(Yc&&Yc.keys&&Yc.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}();function wS(s){return!!Xd&&Xd in s}var mS=wS,bS=Function.prototype,vS=bS.toString;function IS(s){if(s!=null){try{return vS.call(s)}catch{}try{return s+""}catch{}}return""}var ES=IS,NS=qh,AS=mS,_S=mr,CS=ES,SS=/[\\^$.*+?()[\]{}|]/g,TS=/^\[object .+?Constructor\]$/,PS=Function.prototype,$S=Object.prototype,MS=PS.toString,xS=$S.hasOwnProperty,OS=RegExp("^"+MS.call(xS).replace(SS,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function DS(s){if(!_S(s)||AS(s))return!1;var e=NS(s)?OS:TS;return e.test(CS(s))}var kS=DS;function jS(s,e){return s==null?void 0:s[e]}var RS=jS,US=kS,LS=RS;function zS(s,e){var t=LS(s,e);return US(t)?t:void 0}var Bh=zS,FS=Bh,qS=$n,BS=FS(qS,"Map"),Ly=BS,HS=Bh,WS=HS(Object,"create"),mc=WS,ep=mc;function VS(){this.__data__=ep?ep(null):{},this.size=0}var KS=VS;function GS(s){var e=this.has(s)&&delete this.__data__[s];return this.size-=e?1:0,e}var YS=GS,QS=mc,ZS="__lodash_hash_undefined__",JS=Object.prototype,XS=JS.hasOwnProperty;function eT(s){var e=this.__data__;if(QS){var t=e[s];return t===ZS?void 0:t}return XS.call(e,s)?e[s]:void 0}var tT=eT,sT=mc,iT=Object.prototype,rT=iT.hasOwnProperty;function nT(s){var e=this.__data__;return sT?e[s]!==void 0:rT.call(e,s)}var oT=nT,aT=mc,cT="__lodash_hash_undefined__";function lT(s,e){var t=this.__data__;return this.size+=this.has(s)?0:1,t[s]=aT&&e===void 0?cT:e,this}var hT=lT,uT=KS,dT=YS,pT=tT,gT=oT,fT=hT;function on(s){var e=-1,t=s==null?0:s.length;for(this.clear();++e<t;){var i=s[e];this.set(i[0],i[1])}}on.prototype.clear=uT,on.prototype.delete=dT,on.prototype.get=pT,on.prototype.has=gT,on.prototype.set=fT;var yT=on,tp=yT,wT=yc,mT=Ly;function bT(){this.size=0,this.__data__={hash:new tp,map:new(mT||wT),string:new tp}}var vT=bT;function IT(s){var e=typeof s;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?s!=="__proto__":s===null}var ET=IT,NT=ET;function AT(s,e){var t=s.__data__;return NT(e)?t[typeof e=="string"?"string":"hash"]:t.map}var bc=AT,_T=bc;function CT(s){var e=_T(this,s).delete(s);return this.size-=e?1:0,e}var ST=CT,TT=bc;function PT(s){return TT(this,s).get(s)}var $T=PT,MT=bc;function xT(s){return MT(this,s).has(s)}var OT=xT,DT=bc;function kT(s,e){var t=DT(this,s),i=t.size;return t.set(s,e),this.size+=t.size==i?0:1,this}var jT=kT,RT=vT,UT=ST,LT=$T,zT=OT,FT=jT;function an(s){var e=-1,t=s==null?0:s.length;for(this.clear();++e<t;){var i=s[e];this.set(i[0],i[1])}}an.prototype.clear=RT,an.prototype.delete=UT,an.prototype.get=LT,an.prototype.has=zT,an.prototype.set=FT;var qT=an,BT=yc,HT=Ly,WT=qT,VT=200;function KT(s,e){var t=this.__data__;if(t instanceof BT){var i=t.__data__;if(!HT||i.length<VT-1)return i.push([s,e]),this.size=++t.size,this;t=this.__data__=new WT(i)}return t.set(s,e),this.size=t.size,this}var GT=KT,YT=yc,QT=DC,ZT=jC,JT=UC,XT=zC,eP=GT;function cn(s){var e=this.__data__=new YT(s);this.size=e.size}cn.prototype.clear=QT,cn.prototype.delete=ZT,cn.prototype.get=JT,cn.prototype.has=XT,cn.prototype.set=eP;var tP=cn,sP=Bh,iP=function(){try{var s=sP(Object,"defineProperty");return s({},"",{}),s}catch{}}(),zy=iP,sp=zy;function rP(s,e,t){e=="__proto__"&&sp?sp(s,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):s[e]=t}var Hh=rP,nP=Hh,oP=gc;function aP(s,e,t){(t!==void 0&&!oP(s[e],t)||t===void 0&&!(e in s))&&nP(s,e,t)}var Fy=aP;function cP(s){return function(e,t,i){for(var r=-1,n=Object(e),o=i(e),a=o.length;a--;){var c=o[s?a:++r];if(t(n[c],c,n)===!1)break}return e}}var lP=cP,hP=lP,uP=hP(),dP=uP,Gl={exports:{}};(function(s,e){var t=$n,i=e&&!e.nodeType&&e,r=i&&!0&&s&&!s.nodeType&&s,n=r&&r.exports===i,o=n?t.Buffer:void 0,a=o?o.allocUnsafe:void 0;function c(l,h){if(h)return l.slice();var d=l.length,p=a?a(d):new l.constructor(d);return l.copy(p),p}s.exports=c})(Gl,Gl.exports);var pP=$n,gP=pP.Uint8Array,fP=gP,ip=fP;function yP(s){var e=new s.constructor(s.byteLength);return new ip(e).set(new ip(s)),e}var wP=yP,mP=wP;function bP(s,e){var t=e?mP(s.buffer):s.buffer;return new s.constructor(t,s.byteOffset,s.length)}var vP=bP;function IP(s,e){var t=-1,i=s.length;for(e||(e=Array(i));++t<i;)e[t]=s[t];return e}var EP=IP,NP=mr,rp=Object.create,AP=function(){function s(){}return function(e){if(!NP(e))return{};if(rp)return rp(e);s.prototype=e;var t=new s;return s.prototype=void 0,t}}(),_P=AP;function CP(s,e){return function(t){return s(e(t))}}var SP=CP,TP=SP,PP=TP(Object.getPrototypeOf,Object),qy=PP,$P=Object.prototype;function MP(s){var e=s&&s.constructor,t=typeof e=="function"&&e.prototype||$P;return s===t}var By=MP,xP=_P,OP=qy,DP=By;function kP(s){return typeof s.constructor=="function"&&!DP(s)?xP(OP(s)):{}}var jP=kP;function RP(s){return s!=null&&typeof s=="object"}var Vo=RP,UP=wc,LP=Vo,zP="[object Arguments]";function FP(s){return LP(s)&&UP(s)==zP}var qP=FP,np=qP,BP=Vo,Hy=Object.prototype,HP=Hy.hasOwnProperty,WP=Hy.propertyIsEnumerable,VP=np(function(){return arguments}())?np:function(s){return BP(s)&&HP.call(s,"callee")&&!WP.call(s,"callee")},Wy=VP,KP=Array.isArray,Vy=KP,GP=9007199254740991;function YP(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=GP}var Ky=YP,QP=qh,ZP=Ky;function JP(s){return s!=null&&ZP(s.length)&&!QP(s)}var Wh=JP,XP=Wh,e$=Vo;function t$(s){return e$(s)&&XP(s)}var s$=t$,Qa={exports:{}};function i$(){return!1}var r$=i$;(function(s,e){var t=$n,i=r$,r=e&&!e.nodeType&&e,n=r&&!0&&s&&!s.nodeType&&s,o=n&&n.exports===r,a=o?t.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||i;s.exports=l})(Qa,Qa.exports);var n$=wc,o$=qy,a$=Vo,c$="[object Object]",l$=Function.prototype,h$=Object.prototype,Gy=l$.toString,u$=h$.hasOwnProperty,d$=Gy.call(Object);function p$(s){if(!a$(s)||n$(s)!=c$)return!1;var e=o$(s);if(e===null)return!0;var t=u$.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Gy.call(t)==d$}var g$=p$,f$=wc,y$=Ky,w$=Vo,m$="[object Arguments]",b$="[object Array]",v$="[object Boolean]",I$="[object Date]",E$="[object Error]",N$="[object Function]",A$="[object Map]",_$="[object Number]",C$="[object Object]",S$="[object RegExp]",T$="[object Set]",P$="[object String]",$$="[object WeakMap]",M$="[object ArrayBuffer]",x$="[object DataView]",O$="[object Float32Array]",D$="[object Float64Array]",k$="[object Int8Array]",j$="[object Int16Array]",R$="[object Int32Array]",U$="[object Uint8Array]",L$="[object Uint8ClampedArray]",z$="[object Uint16Array]",F$="[object Uint32Array]",Qe={};Qe[O$]=Qe[D$]=Qe[k$]=Qe[j$]=Qe[R$]=Qe[U$]=Qe[L$]=Qe[z$]=Qe[F$]=!0,Qe[m$]=Qe[b$]=Qe[M$]=Qe[v$]=Qe[x$]=Qe[I$]=Qe[E$]=Qe[N$]=Qe[A$]=Qe[_$]=Qe[C$]=Qe[S$]=Qe[T$]=Qe[P$]=Qe[$$]=!1;function q$(s){return w$(s)&&y$(s.length)&&!!Qe[f$(s)]}var B$=q$;function H$(s){return function(e){return s(e)}}var W$=H$,Yl={exports:{}};(function(s,e){var t=jy,i=e&&!e.nodeType&&e,r=i&&!0&&s&&!s.nodeType&&s,n=r&&r.exports===i,o=n&&t.process,a=function(){try{var c=r&&r.require&&r.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}}();s.exports=a})(Yl,Yl.exports);var V$=B$,K$=W$,op=Yl.exports,ap=op&&op.isTypedArray,G$=ap?K$(ap):V$,Yy=G$;function Y$(s,e){if(!(e==="constructor"&&typeof s[e]=="function")&&e!="__proto__")return s[e]}var Qy=Y$,Q$=Hh,Z$=gc,J$=Object.prototype,X$=J$.hasOwnProperty;function e2(s,e,t){var i=s[e];(!(X$.call(s,e)&&Z$(i,t))||t===void 0&&!(e in s))&&Q$(s,e,t)}var t2=e2,s2=t2,i2=Hh;function r2(s,e,t,i){var r=!t;t||(t={});for(var n=-1,o=e.length;++n<o;){var a=e[n],c=i?i(t[a],s[a],a,t,s):void 0;c===void 0&&(c=s[a]),r?i2(t,a,c):s2(t,a,c)}return t}var n2=r2;function o2(s,e){for(var t=-1,i=Array(s);++t<s;)i[t]=e(t);return i}var a2=o2,c2=9007199254740991,l2=/^(?:0|[1-9]\d*)$/;function h2(s,e){var t=typeof s;return e=e??c2,!!e&&(t=="number"||t!="symbol"&&l2.test(s))&&s>-1&&s%1==0&&s<e}var Zy=h2,u2=a2,d2=Wy,p2=Vy,g2=Qa.exports,f2=Zy,y2=Yy,w2=Object.prototype,m2=w2.hasOwnProperty;function b2(s,e){var t=p2(s),i=!t&&d2(s),r=!t&&!i&&g2(s),n=!t&&!i&&!r&&y2(s),o=t||i||r||n,a=o?u2(s.length,String):[],c=a.length;for(var l in s)(e||m2.call(s,l))&&!(o&&(l=="length"||r&&(l=="offset"||l=="parent")||n&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||f2(l,c)))&&a.push(l);return a}var v2=b2;function I2(s){var e=[];if(s!=null)for(var t in Object(s))e.push(t);return e}var E2=I2,N2=mr,A2=By,_2=E2,C2=Object.prototype,S2=C2.hasOwnProperty;function T2(s){if(!N2(s))return _2(s);var e=A2(s),t=[];for(var i in s)i=="constructor"&&(e||!S2.call(s,i))||t.push(i);return t}var P2=T2,$2=v2,M2=P2,x2=Wh;function O2(s){return x2(s)?$2(s,!0):M2(s)}var Jy=O2,D2=n2,k2=Jy;function j2(s){return D2(s,k2(s))}var R2=j2,cp=Fy,U2=Gl.exports,L2=vP,z2=EP,F2=jP,lp=Wy,hp=Vy,q2=s$,B2=Qa.exports,H2=qh,W2=mr,V2=g$,K2=Yy,up=Qy,G2=R2;function Y2(s,e,t,i,r,n,o){var a=up(s,t),c=up(e,t),l=o.get(c);if(l){cp(s,t,l);return}var h=n?n(a,c,t+"",s,e,o):void 0,d=h===void 0;if(d){var p=hp(c),f=!p&&B2(c),g=!p&&!f&&K2(c);h=c,p||f||g?hp(a)?h=a:q2(a)?h=z2(a):f?(d=!1,h=U2(c,!0)):g?(d=!1,h=L2(c,!0)):h=[]:V2(c)||lp(c)?(h=a,lp(a)?h=G2(a):(!W2(a)||H2(a))&&(h=F2(c))):d=!1}d&&(o.set(c,h),r(h,c,i,n,o),o.delete(c)),cp(s,t,h)}var Q2=Y2,Z2=tP,J2=Fy,X2=dP,eM=Q2,tM=mr,sM=Jy,iM=Qy;function Xy(s,e,t,i,r){s!==e&&X2(e,function(n,o){if(r||(r=new Z2),tM(n))eM(s,e,o,t,Xy,i,r);else{var a=i?i(iM(s,o),n,o+"",s,e,r):void 0;a===void 0&&(a=n),J2(s,o,a)}},sM)}var rM=Xy;function nM(s){return s}var ew=nM;function oM(s,e,t){switch(t.length){case 0:return s.call(e);case 1:return s.call(e,t[0]);case 2:return s.call(e,t[0],t[1]);case 3:return s.call(e,t[0],t[1],t[2])}return s.apply(e,t)}var aM=oM,cM=aM,dp=Math.max;function lM(s,e,t){return e=dp(e===void 0?s.length-1:e,0),function(){for(var i=arguments,r=-1,n=dp(i.length-e,0),o=Array(n);++r<n;)o[r]=i[e+r];r=-1;for(var a=Array(e+1);++r<e;)a[r]=i[r];return a[e]=t(o),cM(s,this,a)}}var hM=lM;function uM(s){return function(){return s}}var dM=uM,pM=dM,pp=zy,gM=ew,fM=pp?function(s,e){return pp(s,"toString",{configurable:!0,enumerable:!1,value:pM(e),writable:!0})}:gM,yM=fM,wM=800,mM=16,bM=Date.now;function vM(s){var e=0,t=0;return function(){var i=bM(),r=mM-(i-t);if(t=i,r>0){if(++e>=wM)return arguments[0]}else e=0;return s.apply(void 0,arguments)}}var IM=vM,EM=yM,NM=IM,AM=NM(EM),_M=AM,CM=ew,SM=hM,TM=_M;function PM(s,e){return TM(SM(s,e,CM),s+"")}var $M=PM,MM=gc,xM=Wh,OM=Zy,DM=mr;function kM(s,e,t){if(!DM(t))return!1;var i=typeof e;return(i=="number"?xM(t)&&OM(e,t.length):i=="string"&&e in t)?MM(t[e],s):!1}var jM=kM,RM=$M,UM=jM;function LM(s){return RM(function(e,t){var i=-1,r=t.length,n=r>1?t[r-1]:void 0,o=r>2?t[2]:void 0;for(n=s.length>3&&typeof n=="function"?(r--,n):void 0,o&&UM(t[0],t[1],o)&&(n=r<3?void 0:n,r=1),e=Object(e);++i<r;){var a=t[i];a&&s(e,a,i,n)}return e})}var zM=LM,FM=rM,qM=zM,BM=qM(function(s,e,t){FM(s,e,t)}),HM=BM,WM=Object.defineProperty,VM=Object.defineProperties,KM=Object.getOwnPropertyDescriptors,gp=Object.getOwnPropertySymbols,GM=Object.prototype.hasOwnProperty,YM=Object.prototype.propertyIsEnumerable,fp=(s,e,t)=>e in s?WM(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ya=(s,e)=>{for(var t in e||(e={}))GM.call(e,t)&&fp(s,t,e[t]);if(gp)for(var t of gp(e))YM.call(e,t)&&fp(s,t,e[t]);return s},QM=(s,e)=>VM(s,KM(e));function us(s,e,t){var i;const r=wn(s);return((i=e.rpcMap)==null?void 0:i[r.reference])||`${ky}?chainId=${r.namespace}:${r.reference}&projectId=${t}`}function br(s){return s.includes(":")?s.split(":")[1]:s}function tw(s){return s.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function ZM(s,e){const t=Object.keys(e.namespaces).filter(r=>r.includes(s));if(!t.length)return[];const i=[];return t.forEach(r=>{const n=e.namespaces[r].accounts;i.push(...n)}),i}function Qc(s={},e={}){const t=yp(s),i=yp(e);return HM(t,i)}function yp(s){var e,t,i,r;const n={};if(!Po(s))return n;for(const[o,a]of Object.entries(s)){const c=Lh(o)?[o]:a.chains,l=a.methods||[],h=a.events||[],d=a.rpcMap||{},p=co(o);n[p]=QM(ya(ya({},n[p]),a),{chains:Oa(c,(e=n[p])==null?void 0:e.chains),methods:Oa(l,(t=n[p])==null?void 0:t.methods),events:Oa(h,(i=n[p])==null?void 0:i.events),rpcMap:ya(ya({},d),(r=n[p])==null?void 0:r.rpcMap)})}return n}function JM(s){return s.includes(":")?s.split(":")[2]:s}function wp(s){const e={};for(const[t,i]of Object.entries(s)){const r=i.methods||[],n=i.events||[],o=i.accounts||[],a=Lh(t)?[t]:i.chains?i.chains:tw(i.accounts);e[t]={chains:a,methods:r,events:n,accounts:o}}return e}function Zc(s){return typeof s=="number"?s:s.includes("0x")?parseInt(s,16):(s=s.includes(":")?s.split(":")[1]:s,isNaN(Number(s))?s:Number(s))}const sw={},Se=s=>sw[s],Jc=(s,e)=>{sw[s]=e};var XM=Object.defineProperty,ex=(s,e,t)=>e in s?XM(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Pr=(s,e,t)=>ex(s,typeof e!="symbol"?e+"":e,t);class tx{constructor(e){Pr(this,"name","polkadot"),Pr(this,"client"),Pr(this,"httpProviders"),Pr(this,"events"),Pr(this,"namespace"),Pr(this,"chainId"),this.namespace=e.namespace,this.events=Se("events"),this.client=Se("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(As.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const r=br(t);e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||us(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new u.o(new u.f$1(i,Se("disableProviderPing")))}}var sx=Object.defineProperty,ix=Object.defineProperties,rx=Object.getOwnPropertyDescriptors,mp=Object.getOwnPropertySymbols,nx=Object.prototype.hasOwnProperty,ox=Object.prototype.propertyIsEnumerable,Ql=(s,e,t)=>e in s?sx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,bp=(s,e)=>{for(var t in e||(e={}))nx.call(e,t)&&Ql(s,t,e[t]);if(mp)for(var t of mp(e))ox.call(e,t)&&Ql(s,t,e[t]);return s},vp=(s,e)=>ix(s,rx(e)),$r=(s,e,t)=>Ql(s,typeof e!="symbol"?e+"":e,t);class ax{constructor(e){$r(this,"name","eip155"),$r(this,"client"),$r(this,"chainId"),$r(this,"namespace"),$r(this,"httpProviders"),$r(this,"events"),this.namespace=e.namespace,this.events=Se("events"),this.client=Se("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(As.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const i=t||us(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new u.o(new u.f$1(i,Se("disableProviderPing")))}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const r=parseInt(br(t));e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,i;let r=e.request.params?(t=e.request.params[0])==null?void 0:t.chainId:"0x0";r=r.startsWith("0x")?r:`0x${r}`;const n=parseInt(r,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:r}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${n}`);else throw new Error(`Failed to switch to chain 'eip155:${n}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,i,r;const n=(i=(t=e.request)==null?void 0:t.params)==null?void 0:i[0];if(!n)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((r=o==null?void 0:o.sessionProperties)==null?void 0:r.capabilities)||{};if(a!=null&&a[n])return a==null?void 0:a[n];const c=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:vp(bp({},o.sessionProperties||{}),{capabilities:vp(bp({},a||{}),{[n]:c})})})}catch(l){console.warn("Failed to update session with capabilities",l)}return c}async getCallStatus(e){var t,i;const r=this.client.session.get(e.topic),n=(t=r.sessionProperties)==null?void 0:t.bundler_name;if(n){const a=this.getBundlerUrl(e.chainId,n);try{return await this.getUserOperationReceipt(a,e)}catch(c){console.warn("Failed to fetch call status from bundler",c,a)}}const o=(i=r.sessionProperties)==null?void 0:i.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var i;const r=new URL(e),n=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u.formatJsonRpcRequest("eth_getUserOperationReceipt",[(i=t.request.params)==null?void 0:i[0]]))});if(!n.ok)throw new Error(`Failed to fetch user operation receipt - ${n.status}`);return await n.json()}getBundlerUrl(e,t){return`${aC}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}var cx=Object.defineProperty,lx=(s,e,t)=>e in s?cx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Mr=(s,e,t)=>lx(s,typeof e!="symbol"?e+"":e,t);class hx{constructor(e){Mr(this,"name","solana"),Mr(this,"client"),Mr(this,"httpProviders"),Mr(this,"events"),Mr(this,"namespace"),Mr(this,"chainId"),this.namespace=e.namespace,this.events=Se("events"),this.client=Se("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(As.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const r=br(t);e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||us(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new u.o(new u.f$1(i,Se("disableProviderPing")))}}var ux=Object.defineProperty,dx=(s,e,t)=>e in s?ux(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,xr=(s,e,t)=>dx(s,typeof e!="symbol"?e+"":e,t);class px{constructor(e){xr(this,"name","cosmos"),xr(this,"client"),xr(this,"httpProviders"),xr(this,"events"),xr(this,"namespace"),xr(this,"chainId"),this.namespace=e.namespace,this.events=Se("events"),this.client=Se("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(As.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const r=br(t);e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||us(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new u.o(new u.f$1(i,Se("disableProviderPing")))}}var gx=Object.defineProperty,fx=(s,e,t)=>e in s?gx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Or=(s,e,t)=>fx(s,typeof e!="symbol"?e+"":e,t);class yx{constructor(e){Or(this,"name","algorand"),Or(this,"client"),Or(this,"httpProviders"),Or(this,"events"),Or(this,"namespace"),Or(this,"chainId"),this.namespace=e.namespace,this.events=Se("events"),this.client=Se("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const i=t||us(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(As.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||us(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new u.o(new u.f$1(i,Se("disableProviderPing")))}}var wx=Object.defineProperty,mx=(s,e,t)=>e in s?wx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Dr=(s,e,t)=>mx(s,typeof e!="symbol"?e+"":e,t);class bx{constructor(e){Dr(this,"name","cip34"),Dr(this,"client"),Dr(this,"httpProviders"),Dr(this,"events"),Dr(this,"namespace"),Dr(this,"chainId"),this.namespace=e.namespace,this.events=Se("events"),this.client=Se("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(As.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const i=this.getCardanoRPCUrl(t),r=br(t);e[r]=this.createHttpProvider(r,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new u.o(new u.f$1(i,Se("disableProviderPing")))}}var vx=Object.defineProperty,Ix=(s,e,t)=>e in s?vx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,kr=(s,e,t)=>Ix(s,typeof e!="symbol"?e+"":e,t);class Ex{constructor(e){kr(this,"name","elrond"),kr(this,"client"),kr(this,"httpProviders"),kr(this,"events"),kr(this,"namespace"),kr(this,"chainId"),this.namespace=e.namespace,this.events=Se("events"),this.client=Se("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(As.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const r=br(t);e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||us(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new u.o(new u.f$1(i,Se("disableProviderPing")))}}var Nx=Object.defineProperty,Ax=(s,e,t)=>e in s?Nx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,jr=(s,e,t)=>Ax(s,typeof e!="symbol"?e+"":e,t);class _x{constructor(e){jr(this,"name","multiversx"),jr(this,"client"),jr(this,"httpProviders"),jr(this,"events"),jr(this,"namespace"),jr(this,"chainId"),this.namespace=e.namespace,this.events=Se("events"),this.client=Se("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(As.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const r=br(t);e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||us(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new u.o(new u.f$1(i,Se("disableProviderPing")))}}var Cx=Object.defineProperty,Sx=(s,e,t)=>e in s?Cx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Rr=(s,e,t)=>Sx(s,typeof e!="symbol"?e+"":e,t);class Tx{constructor(e){Rr(this,"name","near"),Rr(this,"client"),Rr(this,"httpProviders"),Rr(this,"events"),Rr(this,"namespace"),Rr(this,"chainId"),this.namespace=e.namespace,this.events=Se("events"),this.client=Se("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||us(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(As.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||us(e,this.namespace);return typeof i>"u"?void 0:new u.o(new u.f$1(i,Se("disableProviderPing")))}}var Px=Object.defineProperty,$x=(s,e,t)=>e in s?Px(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ur=(s,e,t)=>$x(s,typeof e!="symbol"?e+"":e,t);class Mx{constructor(e){Ur(this,"name","tezos"),Ur(this,"client"),Ur(this,"httpProviders"),Ur(this,"events"),Ur(this,"namespace"),Ur(this,"chainId"),this.namespace=e.namespace,this.events=Se("events"),this.client=Se("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||us(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(As.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{e[t]=this.createHttpProvider(t)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||us(e,this.namespace);return typeof i>"u"?void 0:new u.o(new u.f$1(i))}}var xx=Object.defineProperty,Ox=(s,e,t)=>e in s?xx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Lr=(s,e,t)=>Ox(s,typeof e!="symbol"?e+"":e,t);class Dx{constructor(e){Lr(this,"name",rn),Lr(this,"client"),Lr(this,"httpProviders"),Lr(this,"events"),Lr(this,"namespace"),Lr(this,"chainId"),this.namespace=e.namespace,this.events=Se("events"),this.client=Se("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(As.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){var e,t;const i={};return(t=(e=this.namespace)==null?void 0:e.accounts)==null||t.forEach(r=>{const n=wn(r);i[`${n.namespace}:${n.reference}`]=this.createHttpProvider(r)}),i}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||us(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new u.o(new u.f$1(i,Se("disableProviderPing")))}}var kx=Object.defineProperty,jx=Object.defineProperties,Rx=Object.getOwnPropertyDescriptors,Ip=Object.getOwnPropertySymbols,Ux=Object.prototype.hasOwnProperty,Lx=Object.prototype.propertyIsEnumerable,Zl=(s,e,t)=>e in s?kx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,wa=(s,e)=>{for(var t in e||(e={}))Ux.call(e,t)&&Zl(s,t,e[t]);if(Ip)for(var t of Ip(e))Lx.call(e,t)&&Zl(s,t,e[t]);return s},Xc=(s,e)=>jx(s,Rx(e)),$s=(s,e,t)=>Zl(s,typeof e!="symbol"?e+"":e,t);class Vh{constructor(e){$s(this,"client"),$s(this,"namespaces"),$s(this,"optionalNamespaces"),$s(this,"sessionProperties"),$s(this,"events",new oe.Nt),$s(this,"rpcProviders",{}),$s(this,"session"),$s(this,"providerOpts"),$s(this,"logger"),$s(this,"uri"),$s(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:u.Ot(u.k({level:(e==null?void 0:e.logger)||Gd})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const t=new Vh(e);return await t.initialize(),t}async request(e,t,i){const[r,n]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(r).request({request:wa({},e),chainId:`${r}:${n}`,topic:this.session.topic,expiry:i})}sendAsync(e,t,i,r){const n=new Date().getTime();this.request(e,i,r).then(o=>t(null,u.formatJsonRpcResult(n,o))).catch(o=>t(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:Re("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:r}=await this.client.authenticate(e,t);i&&(this.uri=i,this.events.emit("display_uri",i));const n=await r();if(this.session=n.session,this.session){const o=wp(this.session.namespaces);this.namespaces=Qc(this.namespaces,o),this.persist("namespaces",this.namespaces),this.onConnect()}return n}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){const{uri:t,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});t&&(this.uri=t,this.events.emit("display_uri",t));const r=await i();this.session=r;const n=wp(r.namespaces);return this.namespaces=Qc(this.namespaces,n),this.persist("namespaces",this.namespaces),this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[i,r]=this.validateChain(e),n=this.getProvider(i);n.name===rn?n.setDefaultChain(`${i}:${r}`,t):n.setDefaultChain(r,t)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(ur(t)){for(const i of t)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await iC.init({core:this.providerOpts.core,logger:this.providerOpts.logger||Gd,relayUrl:this.providerOpts.relayUrl||rC,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(t=>co(t)))];Jc("client",this.client),Jc("events",this.events),Jc("disableProviderPing",this.disableProviderPing),e.forEach(t=>{if(!this.session)return;const i=ZM(t,this.session),r=tw(i),n=Qc(this.namespaces,this.optionalNamespaces),o=Xc(wa({},n[t]),{accounts:i,chains:r});switch(t){case"eip155":this.rpcProviders[t]=new ax({namespace:o});break;case"algorand":this.rpcProviders[t]=new yx({namespace:o});break;case"solana":this.rpcProviders[t]=new hx({namespace:o});break;case"cosmos":this.rpcProviders[t]=new px({namespace:o});break;case"polkadot":this.rpcProviders[t]=new tx({namespace:o});break;case"cip34":this.rpcProviders[t]=new bx({namespace:o});break;case"elrond":this.rpcProviders[t]=new Ex({namespace:o});break;case"multiversx":this.rpcProviders[t]=new _x({namespace:o});break;case"near":this.rpcProviders[t]=new Tx({namespace:o});break;case"tezos":this.rpcProviders[t]=new Mx({namespace:o});break;default:this.rpcProviders[rn]?this.rpcProviders[rn].updateNamespace(o):this.rpcProviders[rn]=new Dx({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:t}=e,{event:i}=t;if(i.name==="accountsChanged"){const r=i.data;r&&ur(r)&&this.events.emit("accountsChanged",r.map(JM))}else if(i.name==="chainChanged"){const r=t.chainId,n=t.event.data,o=co(r),a=Zc(r)!==Zc(n)?`${o}:${Zc(n)}`:r;this.onChainChanged(a)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var i;const{namespaces:r}=t,n=(i=this.client)==null?void 0:i.session.get(e);this.session=Xc(wa({},n),{namespaces:r}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Xc(wa({},Re("USER_DISCONNECTED")),{data:e.topic}))}),this.on(As.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[rn]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace((t=this.session)==null?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:i,sessionProperties:r}=e;t&&Object.keys(t).length&&(this.namespaces=t),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=r,this.persist("namespaces",t),this.persist("optionalNamespaces",i)}validateChain(e){const[t,i]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,i];if(t&&!Object.keys(this.namespaces||{}).map(o=>co(o)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&i)return[t,i];const r=co(Object.keys(this.namespaces)[0]),n=this.rpcProviders[r].getDefaultChain();return[r,n]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[i,r]=this.validateChain(e);r&&(t||this.getProvider(i).setDefaultChain(r),this.namespaces[i]?this.namespaces[i].defaultChain=r:this.namespaces[`${i}:${r}`]?this.namespaces[`${i}:${r}`].defaultChain=r:this.namespaces[`${i}:${r}`]={defaultChain:r},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",r))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${Yd}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${Yd}/${e}`)}}const zx=Vh,iw={caipNetworkIdToNumber(s){return s?Number(s.split(":")[1]):void 0},parseEvmChainId(s){return typeof s=="string"?this.caipNetworkIdToNumber(s):s},getNetworksByNamespace(s,e){return(s==null?void 0:s.filter(t=>t.chainNamespace===e))||[]},getFirstNetworkByNamespace(s,e){return this.getNetworksByNamespace(s,e)[0]}},ma={bigNumber(s){return s?new k.Big(s):new k.Big(0)},multiply(s,e){if(s===void 0||e===void 0)return new k.Big(0);const t=new k.Big(s),i=new k.Big(e);return t.times(i)},formatNumberToLocalString(s,e=2){return s===void 0?"0.00":typeof s=="number"?s.toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e}):parseFloat(s).toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e})},parseLocalStringToNumber(s){return s===void 0?0:parseFloat(s.replace(/,/gu,""))}},Fx=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],qx=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],Bx=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],se={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network"},Hx={getERC20Abi:s=>se.USDT_CONTRACT_ADDRESSES.includes(s)?Bx:Fx,getSwapAbi:()=>qx},vi={validateCaipAddress(s){var e;if(((e=s.split(":"))==null?void 0:e.length)!==3)throw new Error("Invalid CAIP Address");return s},parseCaipAddress(s){const e=s.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${s}`);const[t,i,r]=e;if(!t||!i||!r)throw new Error(`Invalid CAIP-10 address: ${s}`);return{chainNamespace:t,chainId:i,address:r}},parseCaipNetworkId(s){const e=s.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${s}`);const[t,i]=e;if(!t||!i)throw new Error(`Invalid CAIP-2 network id: ${s}`);return{chainNamespace:t,chainId:i}}},de={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache"};function el(s){if(!s)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${s}:connected_connector_id`}const ce={setItem(s,e){lo()&&e!==void 0&&localStorage.setItem(s,e)},getItem(s){if(lo())return localStorage.getItem(s)||void 0},removeItem(s){lo()&&localStorage.removeItem(s)},clear(){lo()&&localStorage.clear()}};function lo(){return typeof window<"u"&&typeof localStorage<"u"}function xi(s,e){return e==="light"?{"--w3m-accent":(s==null?void 0:s["--w3m-accent"])||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":(s==null?void 0:s["--w3m-accent"])||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}const tl=(typeof A.dist.process<"u"&&typeof A.dist.process.env<"u"?A.dist.process.env.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",Vt={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:tl,SECURE_SITE_DASHBOARD:`${tl}/dashboard`,SECURE_SITE_FAVICON:`${tl}/images/favicon.png`,RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],WC_COINBASE_PAY_SDK_CHAINS:["ethereum","arbitrum","polygon","berachain","avalanche-c-chain","optimism","celo","base"],WC_COINBASE_PAY_SDK_FALLBACK_CHAIN:"ethereum",WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP:{Ethereum:"ethereum","Arbitrum One":"arbitrum",Polygon:"polygon",Berachain:"berachain",Avalanche:"avalanche-c-chain","OP Mainnet":"optimism",Celo:"celo",Base:"base"},WC_COINBASE_ONRAMP_APP_ID:"bf18c88d-495a-463b-b249-0b9d3656cf5e",SWAP_SUGGESTED_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP"],SWAP_POPULAR_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP","METAL","DAI","CHAMP","WOLF","SALE","BAL","BUSD","MUST","BTCpx","ROUTE","HEX","WELT","amDAI","VSQ","VISION","AURUM","pSP","SNX","VC","LINK","CHP","amUSDT","SPHERE","FOX","GIDDY","GFC","OMEN","OX_OLD","DE","WNT"],BALANCE_SUPPORTED_CHAINS:["eip155","solana"],SWAP_SUPPORTED_NETWORKS:["eip155:1","eip155:42161","eip155:10","eip155:324","eip155:8453","eip155:56","eip155:137","eip155:100","eip155:43114","eip155:250","eip155:8217","eip155:1313161554"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:["eip155","solana"],ACTIVITY_ENABLED_CHAIN_NAMESPACES:["eip155","solana"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in a new browser tab"},DEFAULT_FEATURES:{swaps:!0,onramp:!0,receive:!0,send:!0,email:!0,emailShowWallets:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],history:!0,analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0},DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"}},X={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired(s,e){return Date.now()-s>e},getActiveNetworkProps(){const s=X.getActiveNamespace(),e=X.getActiveCaipNetworkId(),t=e?e.split(":")[1]:void 0,i=t?isNaN(Number(t))?t:Number(t):void 0;return{namespace:s,caipNetworkId:e,chainId:i}},setWalletConnectDeepLink({name:s,href:e}){try{ce.setItem(de.DEEPLINK_CHOICE,JSON.stringify({href:e,name:s}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const s=ce.getItem(de.DEEPLINK_CHOICE);if(s)return JSON.parse(s)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{ce.removeItem(de.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(s){try{ce.setItem(de.ACTIVE_NAMESPACE,s)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(s){try{ce.setItem(de.ACTIVE_CAIP_NETWORK_ID,s),X.setActiveNamespace(s.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return ce.getItem(de.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{ce.removeItem(de.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(s){try{const e=el(s);ce.removeItem(e)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(s){try{const e=X.getRecentWallets();e.find(i=>i.id===s.id)||(e.unshift(s),e.length>2&&e.pop(),ce.setItem(de.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const s=ce.getItem(de.RECENT_WALLETS);return s?JSON.parse(s):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(s,e){try{const t=el(s);ce.setItem(t,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return ce.getItem(de.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(s){if(s)try{const e=el(s);return ce.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",s)}},setConnectedSocialProvider(s){try{ce.setItem(de.CONNECTED_SOCIAL,s)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return ce.getItem(de.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{ce.removeItem(de.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return ce.getItem(de.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var t;const s=ce.getItem(de.ACTIVE_CAIP_NETWORK_ID);return(t=s==null?void 0:s.split(":"))==null?void 0:t[1]},setConnectionStatus(s){try{ce.setItem(de.CONNECTION_STATUS,s)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return ce.getItem(de.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const s=ce.getItem(de.CONNECTED_NAMESPACES);return s!=null&&s.length?s.split(","):[]}catch{return[]}},setConnectedNamespaces(s){try{const e=Array.from(new Set(s));ce.setItem(de.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(s){try{const e=X.getConnectedNamespaces();e.includes(s)||(e.push(s),X.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(s){try{const e=X.getConnectedNamespaces(),t=e.indexOf(s);t>-1&&(e.splice(t,1),X.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return ce.getItem(de.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(s){try{ce.setItem(de.TELEGRAM_SOCIAL_PROVIDER,s)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{ce.removeItem(de.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let s={};try{const e=ce.getItem(de.PORTFOLIO_CACHE);s=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return s},removeAddressFromBalanceCache(s){try{const e=X.getBalanceCache();ce.setItem(de.PORTFOLIO_CACHE,JSON.stringify({...e,[s]:void 0}))}catch{console.info("Unable to remove address from balance cache",s)}},getBalanceCacheForCaipAddress(s){try{const t=X.getBalanceCache()[s];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.portfolio))return t.balance;X.removeAddressFromBalanceCache(s)}catch{console.info("Unable to get balance cache for address",s)}},updateBalanceCache(s){try{const e=X.getBalanceCache();e[s.caipAddress]=s,ce.setItem(de.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",s)}},getNativeBalanceCache(){let s={};try{const e=ce.getItem(de.NATIVE_BALANCE_CACHE);s=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return s},removeAddressFromNativeBalanceCache(s){try{const e=X.getBalanceCache();ce.setItem(de.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[s]:void 0}))}catch{console.info("Unable to remove address from balance cache",s)}},getNativeBalanceCacheForCaipAddress(s){try{const t=X.getNativeBalanceCache()[s];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.nativeBalance))return t;console.info("Discarding cache for address",s),X.removeAddressFromBalanceCache(s)}catch{console.info("Unable to get balance cache for address",s)}},updateNativeBalanceCache(s){try{const e=X.getNativeBalanceCache();e[s.caipAddress]=s,ce.setItem(de.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",s)}},getEnsCache(){let s={};try{const e=ce.getItem(de.ENS_CACHE);s=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return s},getEnsFromCacheForAddress(s){try{const t=X.getEnsCache()[s];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.ens))return t.ens;X.removeEnsFromCache(s)}catch{console.info("Unable to get ens name from cache",s)}},updateEnsCache(s){try{const e=X.getEnsCache();e[s.address]=s,ce.setItem(de.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",s)}},removeEnsFromCache(s){try{const e=X.getEnsCache();ce.setItem(de.ENS_CACHE,JSON.stringify({...e,[s]:void 0}))}catch{console.info("Unable to remove ens name from cache",s)}},getIdentityCache(){let s={};try{const e=ce.getItem(de.IDENTITY_CACHE);s=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return s},getIdentityFromCacheForAddress(s){try{const t=X.getIdentityCache()[s];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.identity))return t.identity;X.removeIdentityFromCache(s)}catch{console.info("Unable to get identity from cache",s)}},updateIdentityCache(s){try{const e=X.getIdentityCache();e[s.address]={identity:s.identity,timestamp:s.timestamp},ce.setItem(de.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",s)}},removeIdentityFromCache(s){try{const e=X.getIdentityCache();ce.setItem(de.IDENTITY_CACHE,JSON.stringify({...e,[s]:void 0}))}catch{console.info("Unable to remove identity from cache",s)}},clearAddressCache(){try{ce.removeItem(de.PORTFOLIO_CACHE),ce.removeItem(de.NATIVE_BALANCE_CACHE),ce.removeItem(de.ENS_CACHE),ce.removeItem(de.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}}},he={isMobile(){var s;return this.isClient()?!!((s=window==null?void 0:window.matchMedia("(pointer:coarse)"))!=null&&s.matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(s,e=""){return s==null?void 0:s.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const s=window==null?void 0:window.navigator.userAgent.toLowerCase();return he.isMobile()&&s.includes("android")},isIos(){if(!this.isMobile())return!1;const s=window==null?void 0:window.navigator.userAgent.toLowerCase();return s.includes("iphone")||s.includes("ipad")},isSafari(){return this.isClient()?(window==null?void 0:window.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(s){return s?s-Date.now()<=Vt.TEN_SEC_MS:!0},isAllowedRetry(s,e=Vt.ONE_SEC_MS){return Date.now()-s>=e},copyToClopboard(s){navigator.clipboard.writeText(s)},isIframe(){try{return(window==null?void 0:window.self)!==(window==null?void 0:window.top)}catch{return!1}},getPairingExpiry(){return Date.now()+Vt.FOUR_MINUTES_MS},getNetworkId(s){return s==null?void 0:s.split(":")[1]},getPlainAddress(s){return s==null?void 0:s.split(":")[2]},async wait(s){return new Promise(e=>{setTimeout(e,s)})},debounce(s,e=500){let t;return(...i)=>{function r(){s(...i)}t&&clearTimeout(t),t=setTimeout(r,e)}},isHttpUrl(s){return s.startsWith("http://")||s.startsWith("https://")},formatNativeUrl(s,e){if(he.isHttpUrl(s))return this.formatUniversalUrl(s,e);let t=s;t.includes("://")||(t=s.replaceAll("/","").replaceAll(":",""),t=`${t}://`),t.endsWith("/")||(t=`${t}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const i=encodeURIComponent(e);return{redirect:`${t}wc?uri=${i}`,href:t}},formatUniversalUrl(s,e){if(!he.isHttpUrl(s))return this.formatNativeUrl(s,e);let t=s;t.endsWith("/")||(t=`${t}/`);const i=encodeURIComponent(e);return{redirect:`${t}wc?uri=${i}`,href:t}},getOpenTargetForPlatform(s){return s==="popupWindow"?s:this.isTelegram()?X.getTelegramSocialProvider()?"_top":"_blank":s},openHref(s,e,t){window==null||window.open(s,this.getOpenTargetForPlatform(e),t||"noreferrer noopener")},returnOpenHref(s,e,t){return window==null?void 0:window.open(s,this.getOpenTargetForPlatform(e),t||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},async preloadImage(s){const e=new Promise((t,i)=>{const r=new Image;r.onload=t,r.onerror=i,r.crossOrigin="anonymous",r.src=s});return Promise.race([e,he.wait(2e3)])},formatBalance(s,e){let t="0.000";if(typeof s=="string"){const i=Number(s);if(i){const r=Math.floor(i*1e3)/1e3;r&&(t=r.toString())}}return`${t}${e?` ${e}`:""}`},formatBalance2(s,e){var i;let t;if(s==="0")t="0";else if(typeof s=="string"){const r=Number(s);r&&(t=(i=r.toString().match(/^-?\d+(?:\.\d{0,3})?/u))==null?void 0:i[0])}return{value:t??"0",rest:t==="0"?"000":"",symbol:e}},getApiUrl(){return se.W3M_API_URL},getBlockchainApiUrl(){return se.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return se.PULSE_API_URL},getUUID(){return crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})},parseError(s){var e,t;return typeof s=="string"?s:typeof((t=(e=s==null?void 0:s.issues)==null?void 0:e[0])==null?void 0:t.message)=="string"?s.issues[0].message:s instanceof Error?s.message:"Unknown error"},sortRequestedNetworks(s,e=[]){const t={};return e&&s&&(s.forEach((i,r)=>{t[i]=r}),e.sort((i,r)=>{const n=t[i.id],o=t[r.id];return n!==void 0&&o!==void 0?n-o:n!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(s){let e=0;for(const t of s)e+=t.value??0;return e},formatTokenBalance(s){const e=s.toFixed(2),[t,i]=e.split(".");return{dollars:t,pennies:i}},isAddress(s,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(s)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(s)||/^(?:0x)?[0-9A-F]{40}$/iu.test(s))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(s);default:return!1}},uniqueBy(s,e){const t=new Set;return s.filter(i=>{const r=i[e];return t.has(r)?!1:(t.add(r),!0)})},generateSdkVersion(s,e,t){const r=s.length===0?Vt.ADAPTER_TYPES.UNIVERSAL:s.map(n=>n.adapterType).join(",");return`${e}-${r}-${t}`},createAccount(s,e,t,i,r){return{namespace:s,address:e,type:t,publicKey:i,path:r}},isCaipAddress(s){if(typeof s!="string")return!1;const e=s.split(":"),t=e[0];return e.filter(Boolean).length===3&&t in se.CHAIN_NAME_MAP},isMac(){const s=window==null?void 0:window.navigator.userAgent.toLowerCase();return s.includes("macintosh")&&!s.includes("safari")},formatTelegramSocialLoginUrl(s){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,t="state=";if(new URL(s).host==="auth.magic.link"){const r="provider_authorization_url=",n=s.substring(s.indexOf(r)+r.length),o=this.injectIntoUrl(decodeURIComponent(n),t,e);return s.replace(n,encodeURIComponent(o))}return this.injectIntoUrl(s,t,e)},injectIntoUrl(s,e,t){const i=s.indexOf(e);if(i===-1)throw new Error(`${e} parameter not found in the URL: ${s}`);const r=s.indexOf("&",i),n=e.length,o=r!==-1?r:s.length,a=s.substring(0,i+n),c=s.substring(i+n,o),l=s.substring(r),h=c+t;return a+h+l}};async function Qn(...s){const e=await fetch(...s);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class vc{constructor({baseUrl:e,clientId:t}){this.baseUrl=e,this.clientId=t}async get({headers:e,signal:t,cache:i,...r}){const n=this.createUrl(r);return(await Qn(n,{method:"GET",headers:e,signal:t,cache:i})).json()}async getBlob({headers:e,signal:t,...i}){const r=this.createUrl(i);return(await Qn(r,{method:"GET",headers:e,signal:t})).blob()}async post({body:e,headers:t,signal:i,...r}){const n=this.createUrl(r);return(await Qn(n,{method:"POST",headers:t,body:e?JSON.stringify(e):void 0,signal:i})).json()}async put({body:e,headers:t,signal:i,...r}){const n=this.createUrl(r);return(await Qn(n,{method:"PUT",headers:t,body:e?JSON.stringify(e):void 0,signal:i})).json()}async delete({body:e,headers:t,signal:i,...r}){const n=this.createUrl(r);return(await Qn(n,{method:"DELETE",headers:t,body:e?JSON.stringify(e):void 0,signal:i})).json()}createUrl({path:e,params:t}){const i=new URL(e,this.baseUrl);return t&&Object.entries(t).forEach(([r,n])=>{n&&i.searchParams.append(r,n)}),this.clientId&&i.searchParams.append("clientId",this.clientId),i}}const Wx={handleSolanaDeeplinkRedirect(s){if(I.state.activeChain===se.CHAIN.SOLANA){const e=window.location.href,t=encodeURIComponent(e);if(s==="Phantom"&&!("phantom"in window)){const i=e.startsWith("https")?"https":"http",r=e.split("/")[2],n=encodeURIComponent(`${i}://${r}`);window.location.href=`https://phantom.app/ul/browse/${t}?ref=${n}`}s==="Coinbase Wallet"&&!("coinbaseSolana"in window)&&(window.location.href=`https://go.cb-w.com/dapp?cb_url=${t}`)}}},ss=k.proxy({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),Es={state:ss,subscribeNetworkImages(s){return k.subscribe(ss.networkImages,()=>s(ss.networkImages))},subscribeKey(s,e){return k.subscribeKey(ss,s,e)},subscribe(s){return k.subscribe(ss,()=>s(ss))},setWalletImage(s,e){ss.walletImages[s]=e},setNetworkImage(s,e){ss.networkImages[s]=e},setChainImage(s,e){ss.chainImages[s]=e},setConnectorImage(s,e){ss.connectorImages={...ss.connectorImages,[s]:e}},setTokenImage(s,e){ss.tokenImages[s]=e},setCurrencyImage(s,e){ss.currencyImages[s]=e}},Vx={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00"},sl=k.proxy({networkImagePromises:{}}),Kh={async fetchWalletImage(s){if(s)return await ue._fetchWalletImage(s),this.getWalletImageById(s)},async fetchNetworkImage(s){if(!s)return;const e=this.getNetworkImageById(s);return e||(sl.networkImagePromises[s]||(sl.networkImagePromises[s]=ue._fetchNetworkImage(s)),await sl.networkImagePromises[s],this.getNetworkImageById(s))},getWalletImageById(s){if(s)return Es.state.walletImages[s]},getWalletImage(s){if(s!=null&&s.image_url)return s==null?void 0:s.image_url;if(s!=null&&s.image_id)return Es.state.walletImages[s.image_id]},getNetworkImage(s){var e,t,i;if((e=s==null?void 0:s.assets)!=null&&e.imageUrl)return(t=s==null?void 0:s.assets)==null?void 0:t.imageUrl;if((i=s==null?void 0:s.assets)!=null&&i.imageId)return Es.state.networkImages[s.assets.imageId]},getNetworkImageById(s){if(s)return Es.state.networkImages[s]},getConnectorImage(s){if(s!=null&&s.imageUrl)return s.imageUrl;if(s!=null&&s.imageId)return Es.state.connectorImages[s.imageId]},getChainImage(s){return Es.state.networkImages[Vx[s]]}},Kx={getFeatureValue(s,e){const t=e==null?void 0:e[s];return t===void 0?Vt.DEFAULT_FEATURES[s]:t},filterSocialsByPlatform(s){if(!s||!s.length)return s;if(he.isTelegram()){if(he.isIos())return s.filter(e=>e!=="google");if(he.isMac())return s.filter(e=>e!=="x");if(he.isAndroid())return s.filter(e=>!["facebook","x"].includes(e))}return s}},re=k.proxy({features:Vt.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:Vt.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0}),R={state:re,subscribeKey(s,e){return k.subscribeKey(re,s,e)},setOptions(s){Object.assign(re,s)},setFeatures(s){if(!s)return;re.features||(re.features=Vt.DEFAULT_FEATURES);const e={...re.features,...s};re.features=e,re.features.socials&&(re.features.socials=Kx.filterSocialsByPlatform(re.features.socials))},setProjectId(s){re.projectId=s},setCustomRpcUrls(s){re.customRpcUrls=s},setAllWallets(s){re.allWallets=s},setIncludeWalletIds(s){re.includeWalletIds=s},setExcludeWalletIds(s){re.excludeWalletIds=s},setFeaturedWalletIds(s){re.featuredWalletIds=s},setTokens(s){re.tokens=s},setTermsConditionsUrl(s){re.termsConditionsUrl=s},setPrivacyPolicyUrl(s){re.privacyPolicyUrl=s},setCustomWallets(s){re.customWallets=s},setIsSiweEnabled(s){re.isSiweEnabled=s},setIsUniversalProvider(s){re.isUniversalProvider=s},setSdkVersion(s){re.sdkVersion=s},setMetadata(s){re.metadata=s},setDisableAppend(s){re.disableAppend=s},setEIP6963Enabled(s){re.enableEIP6963=s},setDebug(s){re.debug=s},setEnableWalletConnect(s){re.enableWalletConnect=s},setEnableWalletGuide(s){re.enableWalletGuide=s},setEnableAuthLogger(s){re.enableAuthLogger=s},setEnableWallets(s){re.enableWallets=s},setHasMultipleAddresses(s){re.hasMultipleAddresses=s},setSIWX(s){re.siwx=s},setConnectMethodsOrder(s){re.features={...re.features,connectMethodsOrder:s}},setWalletFeaturesOrder(s){re.features={...re.features,walletFeaturesOrder:s}},setSocialsOrder(s){re.features={...re.features,socials:s}},setCollapseWallets(s){re.features={...re.features,collapseWallets:s}},setEnableEmbedded(s){re.enableEmbedded=s},setAllowUnsupportedChain(s){re.allowUnsupportedChain=s},setManualWCControl(s){re.manualWCControl=s},setEnableNetworkSwitch(s){re.enableNetworkSwitch=s},setDefaultAccountTypes(s={}){Object.entries(s).forEach(([e,t])=>{t&&(re.defaultAccountTypes[e]=t)})},setUniversalProviderConfigOverride(s){re.universalProviderConfigOverride=s},getUniversalProviderConfigOverride(){return re.universalProviderConfigOverride},getSnapshot(){return k.snapshot(re)}},Ii=k.proxy({message:"",variant:"info",open:!1}),wo={state:Ii,subscribeKey(s,e){return k.subscribeKey(Ii,s,e)},open(s,e){const{debug:t}=R.state,{shortMessage:i,longMessage:r}=s;t&&(Ii.message=i,Ii.variant=e,Ii.open=!0),r&&console.error(typeof r=="function"?r():r)},close(){Ii.open=!1,Ii.message="",Ii.variant="info"}},Gx=he.getAnalyticsUrl(),Yx=new vc({baseUrl:Gx,clientId:null}),Qx=["MODAL_CREATED"],ri=k.proxy({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),Be={state:ri,subscribe(s){return k.subscribe(ri,()=>s(ri))},getSdkProperties(){const{projectId:s,sdkType:e,sdkVersion:t}=R.state;return{projectId:s,st:e,sv:t||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(s){try{const e=ie.state.address;if(Qx.includes(s.data.event)||typeof window>"u")return;await Yx.post({path:"/e",params:Be.getSdkProperties(),body:{eventId:he.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:s.timestamp,props:{...s.data,address:e}}}),ri.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===se.HTTP_STATUS_CODES.FORBIDDEN&&!ri.reportedErrors.FORBIDDEN&&(wo.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${lo()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),ri.reportedErrors.FORBIDDEN=!0)}},sendEvent(s){var e;ri.timestamp=Date.now(),ri.data=s,(e=R.state.features)!=null&&e.analytics&&Be._sendAnalyticsEvent(ri)}},Zx=he.getApiUrl(),Lt=new vc({baseUrl:Zx,clientId:null}),Jx="40",Ep="4",Xx=20,Oe=k.proxy({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),ue={state:Oe,subscribeKey(s,e){return k.subscribeKey(Oe,s,e)},_getSdkProperties(){const{projectId:s,sdkType:e,sdkVersion:t}=R.state;return{projectId:s,st:e||"appkit",sv:t||"html-wagmi-4.2.2"}},_filterOutExtensions(s){return R.state.isUniversalProvider?s.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):s},async _fetchWalletImage(s){const e=`${Lt.baseUrl}/getWalletImage/${s}`,t=await Lt.getBlob({path:e,params:ue._getSdkProperties()});Es.setWalletImage(s,URL.createObjectURL(t))},async _fetchNetworkImage(s){const e=`${Lt.baseUrl}/public/getAssetImage/${s}`,t=await Lt.getBlob({path:e,params:ue._getSdkProperties()});Es.setNetworkImage(s,URL.createObjectURL(t))},async _fetchConnectorImage(s){const e=`${Lt.baseUrl}/public/getAssetImage/${s}`,t=await Lt.getBlob({path:e,params:ue._getSdkProperties()});Es.setConnectorImage(s,URL.createObjectURL(t))},async _fetchCurrencyImage(s){const e=`${Lt.baseUrl}/public/getCurrencyImage/${s}`,t=await Lt.getBlob({path:e,params:ue._getSdkProperties()});Es.setCurrencyImage(s,URL.createObjectURL(t))},async _fetchTokenImage(s){const e=`${Lt.baseUrl}/public/getTokenImage/${s}`,t=await Lt.getBlob({path:e,params:ue._getSdkProperties()});Es.setTokenImage(s,URL.createObjectURL(t))},async fetchNetworkImages(){const s=I.getAllRequestedCaipNetworks(),e=s==null?void 0:s.map(({assets:t})=>t==null?void 0:t.imageId).filter(Boolean).filter(t=>!Kh.getNetworkImageById(t));e&&await Promise.allSettled(e.map(t=>ue._fetchNetworkImage(t)))},async fetchConnectorImages(){const{connectors:s}=le.state,e=s.map(({imageId:t})=>t).filter(Boolean);await Promise.allSettled(e.map(t=>ue._fetchConnectorImage(t)))},async fetchCurrencyImages(s=[]){await Promise.allSettled(s.map(e=>ue._fetchCurrencyImage(e)))},async fetchTokenImages(s=[]){await Promise.allSettled(s.map(e=>ue._fetchTokenImage(e)))},async fetchFeaturedWallets(){const{featuredWalletIds:s}=R.state;if(s!=null&&s.length){const{data:e}=await Lt.get({path:"/getWallets",params:{...ue._getSdkProperties(),page:"1",entries:s!=null&&s.length?String(s.length):Ep,include:s==null?void 0:s.join(",")}});e.sort((i,r)=>s.indexOf(i.id)-s.indexOf(r.id));const t=e.map(i=>i.image_id).filter(Boolean);await Promise.allSettled(t.map(i=>ue._fetchWalletImage(i))),Oe.featured=e,Oe.allFeatured=e}},async fetchRecommendedWallets(){try{Oe.isFetchingRecommendedWallets=!0;const{includeWalletIds:s,excludeWalletIds:e,featuredWalletIds:t}=R.state,i=[...e??[],...t??[]].filter(Boolean),r=I.getRequestedCaipNetworkIds().join(","),{data:n,count:o}=await Lt.get({path:"/getWallets",params:{...ue._getSdkProperties(),page:"1",chains:r,entries:Ep,include:s==null?void 0:s.join(","),exclude:i==null?void 0:i.join(",")}}),a=X.getRecentWallets(),c=n.map(h=>h.image_id).filter(Boolean),l=a.map(h=>h.image_id).filter(Boolean);await Promise.allSettled([...c,...l].map(h=>ue._fetchWalletImage(h))),Oe.recommended=n,Oe.allRecommended=n,Oe.count=o??0}catch{}finally{Oe.isFetchingRecommendedWallets=!1}},async fetchWallets({page:s}){const{includeWalletIds:e,excludeWalletIds:t,featuredWalletIds:i}=R.state,r=I.getRequestedCaipNetworkIds().join(","),n=[...Oe.recommended.map(({id:l})=>l),...t??[],...i??[]].filter(Boolean),{data:o,count:a}=await Lt.get({path:"/getWallets",params:{...ue._getSdkProperties(),page:String(s),entries:Jx,chains:r,include:e==null?void 0:e.join(","),exclude:n.join(",")}}),c=o.slice(0,Xx).map(l=>l.image_id).filter(Boolean);await Promise.allSettled(c.map(l=>ue._fetchWalletImage(l))),Oe.wallets=he.uniqueBy([...Oe.wallets,...ue._filterOutExtensions(o)],"id"),Oe.count=a>Oe.count?a:Oe.count,Oe.page=s},async initializeExcludedWallets({ids:s}){const e=I.getRequestedCaipNetworkIds().join(","),{data:t}=await Lt.get({path:"/getWallets",params:{...ue._getSdkProperties(),page:"1",entries:String(s.length),chains:e,include:s==null?void 0:s.join(",")}});t&&t.forEach(i=>{i!=null&&i.rdns&&Oe.excludedWallets.push({rdns:i.rdns,name:i.name})})},async searchWallet({search:s,badge:e}){const{includeWalletIds:t,excludeWalletIds:i}=R.state;Oe.search=[];const r=I.getRequestedCaipNetworkIds().join(","),{data:n}=await Lt.get({path:"/getWallets",params:{...ue._getSdkProperties(),page:"1",entries:"100",search:s==null?void 0:s.trim(),badge_type:e,chains:r,include:t==null?void 0:t.join(","),exclude:i==null?void 0:i.join(",")}});Be.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:e??"",search:s??""}});const o=n.map(a=>a.image_id).filter(Boolean);await Promise.allSettled([...o.map(a=>ue._fetchWalletImage(a)),he.wait(300)]),Oe.search=ue._filterOutExtensions(n)},initPromise(s,e){const t=Oe.promises[s];return t||(Oe.promises[s]=e())},prefetch({fetchConnectorImages:s=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:t=!0,fetchNetworkImages:i=!0}={}){const r=[s&&ue.initPromise("connectorImages",ue.fetchConnectorImages),e&&ue.initPromise("featuredWallets",ue.fetchFeaturedWallets),t&&ue.initPromise("recommendedWallets",ue.fetchRecommendedWallets),i&&ue.initPromise("networkImages",ue.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(r)},prefetchAnalyticsConfig(){var s;(s=R.state.features)!=null&&s.analytics&&ue.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:s}=await Lt.get({path:"/getAnalyticsConfig",params:ue._getSdkProperties()});R.setFeatures({analytics:s})}catch{R.setFeatures({analytics:!1})}},setFilterByNamespace(s){if(!s){Oe.featured=Oe.allFeatured,Oe.recommended=Oe.allRecommended;return}const e=I.getRequestedCaipNetworkIds().join(",");Oe.featured=Oe.allFeatured.filter(t=>{var i;return(i=t.chains)==null?void 0:i.some(r=>e.includes(r))}),Oe.recommended=Oe.allRecommended.filter(t=>{var i;return(i=t.chains)==null?void 0:i.some(r=>e.includes(r))})}},Pe=k.proxy({view:"Connect",history:["Connect"],transactionStack:[]}),xe={state:Pe,subscribeKey(s,e){return k.subscribeKey(Pe,s,e)},pushTransactionStack(s){Pe.transactionStack.push(s)},popTransactionStack(s){var t,i;const e=Pe.transactionStack.pop();if(e)if(s)this.goBack(),(t=e==null?void 0:e.onCancel)==null||t.call(e);else{if(e.goBack)this.goBack();else if(e.replace){const n=Pe.history.indexOf("ConnectingSiwe");n>0?this.goBackToIndex(n-1):(ot.close(),Pe.history=[])}else e.view&&this.reset(e.view);(i=e==null?void 0:e.onSuccess)==null||i.call(e)}},push(s,e){s!==Pe.view&&(Pe.view=s,Pe.history.push(s),Pe.data=e)},reset(s,e){Pe.view=s,Pe.history=[s],Pe.data=e},replace(s,e){Pe.history.at(-1)===s||(Pe.view=s,Pe.history[Pe.history.length-1]=s,Pe.data=e)},goBack(){var e;const s=!I.state.activeCaipAddress&&this.state.view==="ConnectingFarcaster";if(Pe.history.length>1&&!Pe.history.includes("UnsupportedChain")){Pe.history.pop();const[t]=Pe.history.slice(-1);t&&(Pe.view=t)}else ot.close();(e=Pe.data)!=null&&e.wallet&&(Pe.data.wallet=void 0),setTimeout(()=>{var t,i,r;if(s){ie.setFarcasterUrl(void 0,I.state.activeChain);const n=le.getAuthConnector();(t=n==null?void 0:n.provider)==null||t.reload();const o=k.snapshot(R.state);(r=(i=n==null?void 0:n.provider)==null?void 0:i.syncDappData)==null||r.call(i,{metadata:o.metadata,sdkVersion:o.sdkVersion,projectId:o.projectId,sdkType:o.sdkType})}},100)},goBackToIndex(s){if(Pe.history.length>1){Pe.history=Pe.history.slice(0,s+1);const[e]=Pe.history.slice(-1);e&&(Pe.view=e)}}},ni=k.proxy({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),Ft={state:ni,subscribe(s){return k.subscribe(ni,()=>s(ni))},setThemeMode(s){ni.themeMode=s;try{const e=le.getAuthConnector();if(e){const t=Ft.getSnapshot().themeVariables;e.provider.syncTheme({themeMode:s,themeVariables:t,w3mThemeVariables:xi(t,s)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(s){ni.themeVariables={...ni.themeVariables,...s};try{const e=le.getAuthConnector();if(e){const t=Ft.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:t,w3mThemeVariables:xi(ni.themeVariables,ni.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return k.snapshot(ni)}},rw={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0},De=k.proxy({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...rw}}),le={state:De,subscribe(s){return k.subscribe(De,()=>{s(De)})},subscribeKey(s,e){return k.subscribeKey(De,s,e)},initialize(s){s.forEach(e=>{const t=X.getConnectedConnectorId(e);t&&this.setConnectorId(t,e)})},setActiveConnector(s){s&&(De.activeConnector=k.ref(s))},setConnectors(s){s.filter(t=>!De.allConnectors.some(i=>i.id===t.id&&this.getConnectorName(i.name)===this.getConnectorName(t.name)&&i.chain===t.chain)).forEach(t=>{t.type!=="MULTI_CHAIN"&&De.allConnectors.push(k.ref(t))}),De.connectors=this.mergeMultiChainConnectors(De.allConnectors)},removeAdapter(s){De.allConnectors=De.allConnectors.filter(e=>e.chain!==s),De.connectors=this.mergeMultiChainConnectors(De.allConnectors)},mergeMultiChainConnectors(s){const e=this.generateConnectorMapByName(s),t=[];return e.forEach(i=>{const r=i[0],n=(r==null?void 0:r.id)===se.CONNECTOR_ID.AUTH;i.length>1&&r?t.push({name:r.name,imageUrl:r.imageUrl,imageId:r.imageId,connectors:[...i],type:n?"AUTH":"MULTI_CHAIN",chain:"eip155",id:(r==null?void 0:r.id)||""}):r&&t.push(r)}),t},generateConnectorMapByName(s){const e=new Map;return s.forEach(t=>{const{name:i}=t,r=this.getConnectorName(i);if(!r)return;const n=e.get(r)||[];n.find(a=>a.chain===t.chain)||n.push(t),e.set(r,n)}),e},getConnectorName(s){return s&&({"Trust Wallet":"Trust"}[s]||s)},getUniqueConnectorsByName(s){const e=[];return s.forEach(t=>{e.find(i=>i.chain===t.chain)||e.push(t)}),e},addConnector(s){var e,t,i;if(s.id===se.CONNECTOR_ID.AUTH){const r=s,n=k.snapshot(R.state),o=Ft.getSnapshot().themeMode,a=Ft.getSnapshot().themeVariables;(t=(e=r==null?void 0:r.provider)==null?void 0:e.syncDappData)==null||t.call(e,{metadata:n.metadata,sdkVersion:n.sdkVersion,projectId:n.projectId,sdkType:n.sdkType}),(i=r==null?void 0:r.provider)==null||i.syncTheme({themeMode:o,themeVariables:a,w3mThemeVariables:xi(a,o)}),this.setConnectors([s])}else this.setConnectors([s])},getAuthConnector(s){var i;const e=s||I.state.activeChain,t=De.connectors.find(r=>r.id===se.CONNECTOR_ID.AUTH);if(t)return(i=t==null?void 0:t.connectors)!=null&&i.length?t.connectors.find(n=>n.chain===e):t},getAnnouncedConnectorRdns(){return De.connectors.filter(s=>s.type==="ANNOUNCED").map(s=>{var e;return(e=s.info)==null?void 0:e.rdns})},getConnectorById(s){return De.allConnectors.find(e=>e.id===s)},getConnector(s,e){return De.allConnectors.filter(i=>i.chain===I.state.activeChain).find(i=>{var r;return i.explorerId===s||((r=i.info)==null?void 0:r.rdns)===e})},syncIfAuthConnector(s){var n,o;if(s.id!=="ID_AUTH")return;const e=s,t=k.snapshot(R.state),i=Ft.getSnapshot().themeMode,r=Ft.getSnapshot().themeVariables;(o=(n=e==null?void 0:e.provider)==null?void 0:n.syncDappData)==null||o.call(n,{metadata:t.metadata,sdkVersion:t.sdkVersion,sdkType:t.sdkType,projectId:t.projectId}),e.provider.syncTheme({themeMode:i,themeVariables:r,w3mThemeVariables:xi(r,i)})},getConnectorsByNamespace(s){const e=De.allConnectors.filter(t=>t.chain===s);return this.mergeMultiChainConnectors(e)},selectWalletConnector(s){const e=le.getConnector(s.id,s.rdns);I.state.activeChain===se.CHAIN.SOLANA&&Wx.handleSolanaDeeplinkRedirect((e==null?void 0:e.name)||s.name||""),e?xe.push("ConnectingExternal",{connector:e}):xe.push("ConnectingWalletConnect",{wallet:s})},getConnectors(s){return s?this.getConnectorsByNamespace(s):this.mergeMultiChainConnectors(De.allConnectors)},setFilterByNamespace(s){De.filterByNamespace=s,De.connectors=this.getConnectors(s),ue.setFilterByNamespace(s)},setConnectorId(s,e){s&&(De.activeConnectorIds={...De.activeConnectorIds,[e]:s},X.setConnectedConnectorId(e,s))},removeConnectorId(s){De.activeConnectorIds={...De.activeConnectorIds,[s]:void 0},X.deleteConnectedConnectorId(s)},getConnectorId(s){if(s)return De.activeConnectorIds[s]},isConnected(s){return s?!!De.activeConnectorIds[s]:Object.values(De.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){De.activeConnectorIds={...rw}}};function ba(s,e){return le.getConnectorId(s)===e}function eO(s){const e=Array.from(I.state.chains.keys());let t=[];return s?(t.push([s,I.state.chains.get(s)]),ba(s,se.CONNECTOR_ID.WALLET_CONNECT)?e.forEach(i=>{i!==s&&ba(i,se.CONNECTOR_ID.WALLET_CONNECT)&&t.push([i,I.state.chains.get(i)])}):ba(s,se.CONNECTOR_ID.AUTH)&&e.forEach(i=>{i!==s&&ba(i,se.CONNECTOR_ID.AUTH)&&t.push([i,I.state.chains.get(i)])})):t=Array.from(I.state.chains.entries()),t}var tO=Object.defineProperty,sO=(s,e,t)=>e in s?tO(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Np=(s,e,t)=>sO(s,typeof e!="symbol"?e+"":e,t);class iO extends u.IEvents{constructor(e){super(),this.opts=e,Np(this,"protocol","wc"),Np(this,"version",2)}}var rO=Object.defineProperty,nO=(s,e,t)=>e in s?rO(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,oO=(s,e,t)=>nO(s,e+"",t);let aO=class extends u.IEvents{constructor(e,t){super(),this.core=e,this.logger=t,oO(this,"records",new Map)}},cO=class{constructor(e,t){this.logger=e,this.core=t}};class lO extends u.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}}let hO=class extends u.IEvents{constructor(e){super()}},uO=class{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}},dO=class extends u.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}},pO=class extends u.IEvents{constructor(e,t){super(),this.core=e,this.logger=t}},gO=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},fO=class{constructor(e,t){this.projectId=e,this.logger=t}},yO=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var wO=Object.defineProperty,mO=(s,e,t)=>e in s?wO(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ap=(s,e,t)=>mO(s,typeof e!="symbol"?e+"":e,t);let bO=class{constructor(e){this.opts=e,Ap(this,"protocol","wc"),Ap(this,"version",2)}},vO=class{constructor(e){this.client=e}};const IO="https://secure.walletconnect.org/sdk";typeof A.dist.process<"u"&&typeof A.dist.process.env<"u"&&A.dist.process.env.NEXT_PUBLIC_SECURE_SITE_SDK_URL;typeof A.dist.process<"u"&&typeof A.dist.process.env<"u"&&A.dist.process.env.NEXT_PUBLIC_DEFAULT_LOG_LEVEL;typeof A.dist.process<"u"&&typeof A.dist.process.env<"u"&&A.dist.process.env.NEXT_PUBLIC_SECURE_SITE_SDK_VERSION;const Si={SAFE_RPC_METHODS:["eth_accounts","eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","eth_feeHistory","eth_gasPrice","eth_getAccount","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockReceipts","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_getProof","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","eth_maxPriorityFeePerGas","eth_newBlockFilter","eth_newFilter","eth_newPendingTransactionFilter","eth_sendRawTransaction","eth_syncing","eth_uninstallFilter","wallet_getCapabilities","wallet_getCallsStatus","eth_getUserOperationReceipt","eth_estimateUserOperationGas","eth_getUserOperationByHash","eth_supportedEntryPoints","wallet_getAssets"],NOT_SAFE_RPC_METHODS:["personal_sign","eth_signTypedData_v4","eth_sendTransaction","solana_signMessage","solana_signTransaction","solana_signAllTransactions","solana_signAndSendTransaction","wallet_sendCalls","wallet_grantPermissions","wallet_revokePermissions","eth_sendUserOperation"],GET_CHAIN_ID:"eth_chainId",RPC_METHOD_NOT_ALLOWED_MESSAGE:"Requested RPC call is not allowed",RPC_METHOD_NOT_ALLOWED_UI_MESSAGE:"Action not allowed",ACCOUNT_TYPES:{EOA:"eoa",SMART_ACCOUNT:"smartAccount"}},Ji=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),ut=k.proxy({...Ji}),vt={state:ut,subscribeKey(s,e){return k.subscribeKey(ut,s,e)},showLoading(s,e={}){this._showMessage({message:s,variant:"loading",...e})},showSuccess(s){this._showMessage({message:s,variant:"success"})},showSvg(s,e){this._showMessage({message:s,svg:e})},showError(s){const e=he.parseError(s);this._showMessage({message:e,variant:"error"})},hide(){ut.message=Ji.message,ut.variant=Ji.variant,ut.svg=Ji.svg,ut.open=Ji.open,ut.autoClose=Ji.autoClose},_showMessage({message:s,svg:e,variant:t="success",autoClose:i=Ji.autoClose}){ut.open?(ut.open=!1,setTimeout(()=>{ut.message=s,ut.variant=t,ut.svg=e,ut.open=!0,ut.autoClose=i},150)):(ut.message=s,ut.variant=t,ut.svg=e,ut.open=!0,ut.autoClose=i)}},mn={getSIWX(){return R.state.siwx},async initializeIfEnabled(){var n;const s=R.state.siwx,e=I.getActiveCaipAddress();if(!(s&&e))return;const[t,i,r]=e.split(":");if(I.checkIfSupportedNetwork(t))try{if((await s.getSessions(`${t}:${i}`,r)).length)return;await ot.open({view:"SIWXSignMessage"})}catch(o){console.error("SIWXUtil:initializeIfEnabled",o),Be.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await((n=qe._getClient())==null?void 0:n.disconnect().catch(console.error)),xe.reset("Connect"),vt.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const s=R.state.siwx,e=he.getPlainAddress(I.getActiveCaipAddress()),t=I.getActiveCaipNetwork(),i=qe._getClient();if(!s)throw new Error("SIWX is not enabled");if(!e)throw new Error("No ActiveCaipAddress found");if(!t)throw new Error("No ActiveCaipNetwork or client found");if(!i)throw new Error("No ConnectionController client found");try{const r=await s.createMessage({chainId:t.caipNetworkId,accountAddress:e}),n=r.toString();le.getConnectorId(t.chainNamespace)===se.CONNECTOR_ID.AUTH&&xe.pushTransactionStack({view:null,goBack:!1,replace:!0});const a=await i.signMessage(n);await s.addSession({data:r,message:n,signature:a}),ot.close(),Be.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(r){const n=this.getSIWXEventProperties();(!ot.state.open||xe.state.view==="ApproveTransaction")&&await ot.open({view:"SIWXSignMessage"}),n.isSmartAccount?vt.showError("This application might not support Smart Accounts"):vt.showError("Signature declined"),Be.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:n}),console.error("SWIXUtil:requestSignMessage",r)}},async cancelSignMessage(){var s;try{const e=this.getSIWX();((s=e==null?void 0:e.getRequired)==null?void 0:s.call(e))?await qe.disconnect():ot.close(),xe.reset("Connect"),Be.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(e){console.error("SIWXUtil:cancelSignMessage",e)}},async getSessions(){const s=R.state.siwx,e=he.getPlainAddress(I.getActiveCaipAddress()),t=I.getActiveCaipNetwork();return s&&e&&t?s.getSessions(t.caipNetworkId,e):[]},async isSIWXCloseDisabled(){var e;const s=this.getSIWX();if(s){const t=xe.state.view==="ApproveTransaction",i=xe.state.view==="SIWXSignMessage";if(t||i)return((e=s.getRequired)==null?void 0:e.call(s))&&(await this.getSessions()).length===0}return!1},async universalProviderAuthenticate({universalProvider:s,chains:e,methods:t}){var a,c,l;const i=mn.getSIWX(),r=new Set(e.map(h=>h.split(":")[0]));if(!i||r.size!==1||!r.has("eip155"))return!1;const n=await i.createMessage({chainId:((a=I.getActiveCaipNetwork())==null?void 0:a.caipNetworkId)||"",accountAddress:""}),o=await s.authenticate({nonce:n.nonce,domain:n.domain,uri:n.uri,exp:n.expirationTime,iat:n.issuedAt,nbf:n.notBefore,requestId:n.requestId,version:n.version,resources:n.resources,statement:n.statement,chainId:n.chainId,methods:t,chains:[n.chainId,...e.filter(h=>h!==n.chainId)]});if(vt.showLoading("Authenticating...",{autoClose:!1}),ie.setConnectedWalletInfo({...o.session.peer.metadata,name:o.session.peer.metadata.name,icon:(c=o.session.peer.metadata.icons)==null?void 0:c[0],type:"WALLET_CONNECT"},Array.from(r)[0]),(l=o==null?void 0:o.auths)!=null&&l.length){const h=o.auths.map(d=>{const p=s.client.formatAuthMessage({request:d.p,iss:d.p.iss});return{data:{...d.p,accountAddress:d.p.iss.split(":").slice(-1).join(""),chainId:d.p.iss.split(":").slice(2,4).join(":"),uri:d.p.aud,version:d.p.version||n.version,expirationTime:d.p.exp,issuedAt:d.p.iat,notBefore:d.p.nbf},message:p,signature:d.s.s,cacao:d}});try{await i.setSessions(h),Be.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:mn.getSIWXEventProperties()})}catch(d){throw console.error("SIWX:universalProviderAuth - failed to set sessions",d),Be.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:mn.getSIWXEventProperties()}),await s.disconnect().catch(console.error),d}finally{vt.hide()}}return!0},getSIWXEventProperties(){var s;return{network:((s=I.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)||"",isSmartAccount:ie.state.preferredAccountType===Si.ACCOUNT_TYPES.SMART_ACCOUNT}},async clearSessions(){const s=this.getSIWX();s&&await s.setSessions([])}},We=k.proxy({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),EO={state:We,subscribe(s){return k.subscribe(We,()=>s(We))},setLastNetworkInView(s){We.lastNetworkInView=s},async fetchTransactions(s,e){var t;if(!s)throw new Error("Transactions can't be fetched without an accountAddress");We.loading=!0;try{const i=await ne.fetchTransactions({account:s,cursor:We.next,onramp:e,cache:e==="coinbase"?"no-cache":void 0,chainId:(t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId}),r=this.filterSpamTransactions(i.data),n=this.filterByConnectedChain(r),o=[...We.transactions,...n];We.loading=!1,e==="coinbase"?We.coinbaseTransactions=this.groupTransactionsByYearAndMonth(We.coinbaseTransactions,i.data):(We.transactions=o,We.transactionsByYear=this.groupTransactionsByYearAndMonth(We.transactionsByYear,n)),We.empty=o.length===0,We.next=i.next?i.next:void 0}catch{Be.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:s,projectId:R.state.projectId,cursor:We.next,isSmartAccount:ie.state.preferredAccountType===Si.ACCOUNT_TYPES.SMART_ACCOUNT}}),vt.showError("Failed to fetch transactions"),We.loading=!1,We.empty=!0,We.next=void 0}},groupTransactionsByYearAndMonth(s={},e=[]){const t=s;return e.forEach(i=>{const r=new Date(i.metadata.minedAt).getFullYear(),n=new Date(i.metadata.minedAt).getMonth(),o=t[r]??{},c=(o[n]??[]).filter(l=>l.id!==i.id);t[r]={...o,[n]:[...c,i].sort((l,h)=>new Date(h.metadata.minedAt).getTime()-new Date(l.metadata.minedAt).getTime())}}),t},filterSpamTransactions(s){return s.filter(e=>!e.transfers.every(i=>{var r;return((r=i.nft_info)==null?void 0:r.flags.is_spam)===!0}))},filterByConnectedChain(s){var i;const e=(i=I.state.activeCaipNetwork)==null?void 0:i.caipNetworkId;return s.filter(r=>r.metadata.chain===e)},clearCursor(){We.next=void 0},resetTransactions(){We.transactions=[],We.transactionsByYear={},We.lastNetworkInView=void 0,We.loading=!1,We.empty=!1,We.next=void 0}},Ve=k.proxy({wcError:!1,buffering:!1,status:"disconnected"});let zr;const qe={state:Ve,subscribeKey(s,e){return k.subscribeKey(Ve,s,e)},_getClient(){return Ve._client},setClient(s){Ve._client=k.ref(s)},async connectWalletConnect(){var s,e,t,i;if(he.isTelegram()||he.isSafari()&&he.isIos()){if(zr){await zr,zr=void 0;return}if(!he.isPairingExpired(Ve==null?void 0:Ve.wcPairingExpiry)){const r=Ve.wcUri;Ve.wcUri=r;return}zr=(e=(s=this._getClient())==null?void 0:s.connectWalletConnect)==null?void 0:e.call(s).catch(()=>{}),this.state.status="connecting",await zr,zr=void 0,Ve.wcPairingExpiry=void 0,this.state.status="connected"}else await((i=(t=this._getClient())==null?void 0:t.connectWalletConnect)==null?void 0:i.call(t))},async connectExternal(s,e,t=!0){var i,r;await((r=(i=this._getClient())==null?void 0:i.connectExternal)==null?void 0:r.call(i,s)),t&&I.setActiveNamespace(e)},async reconnectExternal(s){var t,i;await((i=(t=this._getClient())==null?void 0:t.reconnectExternal)==null?void 0:i.call(t,s));const e=s.chain||I.state.activeChain;e&&le.setConnectorId(s.id,e)},async setPreferredAccountType(s){var t;ot.setLoading(!0,I.state.activeChain);const e=le.getAuthConnector();e&&(await(e==null?void 0:e.provider.setPreferredAccount(s)),await this.reconnectExternal(e),ot.setLoading(!1,I.state.activeChain),Be.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:s,network:((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)||""}}))},async signMessage(s){var e;return(e=this._getClient())==null?void 0:e.signMessage(s)},parseUnits(s,e){var t;return(t=this._getClient())==null?void 0:t.parseUnits(s,e)},formatUnits(s,e){var t;return(t=this._getClient())==null?void 0:t.formatUnits(s,e)},async sendTransaction(s){var e;return(e=this._getClient())==null?void 0:e.sendTransaction(s)},async getCapabilities(s){var e;return(e=this._getClient())==null?void 0:e.getCapabilities(s)},async grantPermissions(s){var e;return(e=this._getClient())==null?void 0:e.grantPermissions(s)},async walletGetAssets(s){var e;return((e=this._getClient())==null?void 0:e.walletGetAssets(s))??{}},async estimateGas(s){var e;return(e=this._getClient())==null?void 0:e.estimateGas(s)},async writeContract(s){var e;return(e=this._getClient())==null?void 0:e.writeContract(s)},async getEnsAddress(s){var e;return(e=this._getClient())==null?void 0:e.getEnsAddress(s)},async getEnsAvatar(s){var e;return(e=this._getClient())==null?void 0:e.getEnsAvatar(s)},checkInstalled(s){var e,t;return((t=(e=this._getClient())==null?void 0:e.checkInstalled)==null?void 0:t.call(e,s))||!1},resetWcConnection(){Ve.wcUri=void 0,Ve.wcPairingExpiry=void 0,Ve.wcLinking=void 0,Ve.recentWallet=void 0,Ve.status="disconnected",EO.resetTransactions(),X.deleteWalletConnectDeepLink()},resetUri(){Ve.wcUri=void 0,Ve.wcPairingExpiry=void 0},finalizeWcConnection(){var t,i;const{wcLinking:s,recentWallet:e}=qe.state;s&&X.setWalletConnectDeepLink(s),e&&X.setAppKitRecent(e),Be.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:s?"mobile":"qrcode",name:((i=(t=xe.state.data)==null?void 0:t.wallet)==null?void 0:i.name)||"Unknown"}})},setWcBasic(s){Ve.wcBasic=s},setUri(s){Ve.wcUri=s,Ve.wcPairingExpiry=he.getPairingExpiry()},setWcLinking(s){Ve.wcLinking=s},setWcError(s){Ve.wcError=s,Ve.buffering=!1},setRecentWallet(s){Ve.recentWallet=s},setBuffering(s){Ve.buffering=s},setStatus(s){Ve.status=s},async disconnect(s){try{ot.setLoading(!0,s),await mn.clearSessions(),await I.disconnect(s),ot.setLoading(!1,s),le.setFilterByNamespace(void 0)}catch{throw new Error("Failed to disconnect")}}},Zn=k.proxy({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),pi={state:Zn,subscribe(s){return k.subscribe(Zn,()=>s(Zn))},set(s){Object.assign(Zn,{...Zn,...s})}},il={createBalance(s,e){const t={name:s.metadata.name||"",symbol:s.metadata.symbol||"",decimals:s.metadata.decimals||0,value:s.metadata.value||0,price:s.metadata.price||0,iconUrl:s.metadata.iconUrl||""};return{name:t.name,symbol:t.symbol,chainId:e,address:s.address==="native"?void 0:this.convertAddressToCAIP10Address(s.address,e),value:t.value,price:t.price,quantity:{decimals:t.decimals.toString(),numeric:this.convertHexToBalance({hex:s.balance,decimals:t.decimals})},iconUrl:t.iconUrl}},convertHexToBalance({hex:s,decimals:e}){return yn.formatUnits(BigInt(s),e)},convertAddressToCAIP10Address(s,e){return`${e}:${s}`},createCAIP2ChainId(s,e){return`${e}:${parseInt(s,16)}`},getChainIdHexFromCAIP2ChainId(s){const e=s.split(":");if(e.length<2||!e[1])return"0x0";const t=e[1],i=parseInt(t,10);return isNaN(i)?"0x0":`0x${i.toString(16)}`},isWalletGetAssetsResponse(s){return typeof s!="object"||s===null?!1:Object.values(s).every(e=>Array.isArray(e)&&e.every(t=>this.isValidAsset(t)))},isValidAsset(s){return typeof s=="object"&&s!==null&&typeof s.address=="string"&&typeof s.balance=="string"&&(s.type==="ERC20"||s.type==="NATIVE")&&typeof s.metadata=="object"&&s.metadata!==null&&typeof s.metadata.name=="string"&&typeof s.metadata.symbol=="string"&&typeof s.metadata.decimals=="number"&&typeof s.metadata.price=="number"&&typeof s.metadata.iconUrl=="string"}},_p={async getMyTokensWithBalance(s){const e=ie.state.address,t=I.state.activeCaipNetwork;if(!e||!t)return[];if(t.chainNamespace==="eip155"){const r=await this.getEIP155Balances(e,t);if(r)return this.filterLowQualityTokens(r)}const i=await ne.getBalance(e,t.caipNetworkId,s);return this.filterLowQualityTokens(i.balances)},async getEIP155Balances(s,e){var t,i;try{const r=il.getChainIdHexFromCAIP2ChainId(e.caipNetworkId),n=await qe.getCapabilities(s);if(!((i=(t=n==null?void 0:n[r])==null?void 0:t.assetDiscovery)!=null&&i.supported))return null;const o=await qe.walletGetAssets({account:s,chainFilter:[r]});return il.isWalletGetAssetsResponse(o)?(o[r]||[]).map(c=>il.createBalance(c,e.caipNetworkId)):null}catch{return null}},filterLowQualityTokens(s){return s.filter(e=>e.quantity.decimals!=="0")},mapBalancesToSwapTokens(s){return(s==null?void 0:s.map(e=>({...e,address:e!=null&&e.address?e.address:I.getActiveNetworkTokenAddress(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1})))||[]}},be=k.proxy({tokenBalances:[],loading:!1}),Cp={state:be,subscribe(s){return k.subscribe(be,()=>s(be))},subscribeKey(s,e){return k.subscribeKey(be,s,e)},setToken(s){s&&(be.token=k.ref(s))},setTokenAmount(s){be.sendTokenAmount=s},setReceiverAddress(s){be.receiverAddress=s},setReceiverProfileImageUrl(s){be.receiverProfileImageUrl=s},setReceiverProfileName(s){be.receiverProfileName=s},setGasPrice(s){be.gasPrice=s},setGasPriceInUsd(s){be.gasPriceInUSD=s},setNetworkBalanceInUsd(s){be.networkBalanceInUSD=s},setLoading(s){be.loading=s},sendToken(){var s;switch((s=I.state.activeCaipNetwork)==null?void 0:s.chainNamespace){case"eip155":this.sendEvmToken();return;case"solana":this.sendSolanaToken();return;default:throw new Error("Unsupported chain")}},sendEvmToken(){var s,e,t,i,r;(s=this.state.token)!=null&&s.address&&this.state.sendTokenAmount&&this.state.receiverAddress?(Be.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:ie.state.preferredAccountType===Si.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token.address,amount:this.state.sendTokenAmount,network:((e=I.state.activeCaipNetwork)==null?void 0:e.caipNetworkId)||""}}),this.sendERC20Token({receiverAddress:this.state.receiverAddress,tokenAddress:this.state.token.address,sendTokenAmount:this.state.sendTokenAmount,decimals:this.state.token.quantity.decimals})):this.state.receiverAddress&&this.state.sendTokenAmount&&this.state.gasPrice&&((t=this.state.token)!=null&&t.quantity.decimals)&&(Be.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:ie.state.preferredAccountType===Si.ACCOUNT_TYPES.SMART_ACCOUNT,token:(i=this.state.token)==null?void 0:i.symbol,amount:this.state.sendTokenAmount,network:((r=I.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)||""}}),this.sendNativeToken({receiverAddress:this.state.receiverAddress,sendTokenAmount:this.state.sendTokenAmount,gasPrice:this.state.gasPrice,decimals:this.state.token.quantity.decimals}))},async fetchTokenBalance(s){var n,o;be.loading=!0;const e=(n=I.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,t=(o=I.state.activeCaipNetwork)==null?void 0:o.chainNamespace,i=I.state.activeCaipAddress,r=i?he.getPlainAddress(i):void 0;if(be.lastRetry&&!he.isAllowedRetry(be.lastRetry,30*Vt.ONE_SEC_MS))return be.loading=!1,[];try{if(r&&e&&t){const a=await _p.getMyTokensWithBalance();return be.tokenBalances=a,be.lastRetry=void 0,a}}catch(a){be.lastRetry=Date.now(),s==null||s(a),vt.showError("Token Balance Unavailable")}finally{be.loading=!1}return[]},fetchNetworkBalance(){if(be.tokenBalances.length===0)return;const s=_p.mapBalancesToSwapTokens(be.tokenBalances);if(!s)return;const e=s.find(t=>t.address===I.getActiveNetworkTokenAddress());e&&(be.networkBalanceInUSD=e?ma.multiply(e.quantity.numeric,e.price).toString():"0")},isInsufficientNetworkTokenForGas(s,e){const t=e||"0";return ma.bigNumber(s).eq(0)?!0:ma.bigNumber(ma.bigNumber(t)).gt(s)},hasInsufficientGasFunds(){let s=!0;return ie.state.preferredAccountType===Si.ACCOUNT_TYPES.SMART_ACCOUNT?s=!1:be.networkBalanceInUSD&&(s=this.isInsufficientNetworkTokenForGas(be.networkBalanceInUSD,be.gasPriceInUSD)),s},async sendNativeToken(s){var n,o,a,c;xe.pushTransactionStack({view:"Account",goBack:!1});const e=s.receiverAddress,t=ie.state.address,i=qe.parseUnits(s.sendTokenAmount.toString(),Number(s.decimals)),r="0x";try{await qe.sendTransaction({chainNamespace:"eip155",to:e,address:t,data:r,value:i??BigInt(0),gasPrice:s.gasPrice}),vt.showSuccess("Transaction started"),Be.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:ie.state.preferredAccountType===Si.ACCOUNT_TYPES.SMART_ACCOUNT,token:((n=this.state.token)==null?void 0:n.symbol)||"",amount:s.sendTokenAmount,network:((o=I.state.activeCaipNetwork)==null?void 0:o.caipNetworkId)||""}}),this.resetSend()}catch(l){console.error("SendController:sendERC20Token - failed to send native token",l);const h=l instanceof Error?l.message:"Unknown error";Be.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:h,isSmartAccount:ie.state.preferredAccountType===Si.ACCOUNT_TYPES.SMART_ACCOUNT,token:((a=this.state.token)==null?void 0:a.symbol)||"",amount:s.sendTokenAmount,network:((c=I.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||""}}),vt.showError("Something went wrong")}},async sendERC20Token(s){var t,i;xe.pushTransactionStack({view:"Account",goBack:!1});const e=qe.parseUnits(s.sendTokenAmount.toString(),Number(s.decimals));try{if(ie.state.address&&s.sendTokenAmount&&s.receiverAddress&&s.tokenAddress){const r=he.getPlainAddress(s.tokenAddress);await qe.writeContract({fromAddress:ie.state.address,tokenAddress:r,args:[s.receiverAddress,e??BigInt(0)],method:"transfer",abi:Hx.getERC20Abi(r),chainNamespace:"eip155"}),vt.showSuccess("Transaction started"),this.resetSend()}}catch(r){console.error("SendController:sendERC20Token - failed to send erc20 token",r);const n=r instanceof Error?r.message:"Unknown error";Be.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:n,isSmartAccount:ie.state.preferredAccountType===Si.ACCOUNT_TYPES.SMART_ACCOUNT,token:((t=this.state.token)==null?void 0:t.symbol)||"",amount:s.sendTokenAmount,network:((i=I.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)||""}}),vt.showError("Something went wrong")}},sendSolanaToken(){if(!this.state.sendTokenAmount||!this.state.receiverAddress){vt.showError("Please enter a valid amount and receiver address");return}xe.pushTransactionStack({view:"Account",goBack:!1}),qe.sendTransaction({chainNamespace:"solana",to:this.state.receiverAddress,value:this.state.sendTokenAmount}).then(()=>{this.resetSend(),ie.fetchTokenBalance()}).catch(s=>{vt.showError("Failed to send transaction. Please try again."),console.error("SendController:sendToken - failed to send solana transaction",s)})},resetSend(){be.token=void 0,be.sendTokenAmount=void 0,be.receiverAddress=void 0,be.receiverProfileImageUrl=void 0,be.receiverProfileName=void 0,be.loading=!1,be.tokenBalances=[]}},rl={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[],user:void 0},va={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},F=k.proxy({chains:k.proxyMap(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),I={state:F,subscribe(s){return k.subscribe(F,()=>{s(F)})},subscribeKey(s,e){return k.subscribeKey(F,s,e)},subscribeChainProp(s,e,t){let i;return k.subscribe(F.chains,()=>{var n;const r=t||F.activeChain;if(r){const o=(n=F.chains.get(r))==null?void 0:n[s];i!==o&&(i=o,e(o))}})},initialize(s,e,t){const{chainId:i,namespace:r}=X.getActiveNetworkProps(),n=e==null?void 0:e.find(l=>l.id.toString()===(i==null?void 0:i.toString())),a=s.find(l=>(l==null?void 0:l.namespace)===r)||(s==null?void 0:s[0]),c=new Set([...(e==null?void 0:e.map(l=>l.chainNamespace))??[]]);((s==null?void 0:s.length)===0||!a)&&(F.noAdapters=!0),F.noAdapters||(F.activeChain=a==null?void 0:a.namespace,F.activeCaipNetwork=n,this.setChainNetworkData(a==null?void 0:a.namespace,{caipNetwork:n}),F.activeChain&&pi.set({activeChain:a==null?void 0:a.namespace})),c.forEach(l=>{const h=e==null?void 0:e.filter(d=>d.chainNamespace===l);I.state.chains.set(l,{namespace:l,networkState:k.proxy({...va,caipNetwork:h==null?void 0:h[0]}),accountState:k.proxy(rl),caipNetworks:h??[],...t}),this.setRequestedCaipNetworks(h??[],l)})},removeAdapter(s){var e,t;if(F.activeChain===s){const i=Array.from(F.chains.entries()).find(([r])=>r!==s);if(i){const r=(t=(e=i[1])==null?void 0:e.caipNetworks)==null?void 0:t[0];r&&this.setActiveCaipNetwork(r)}}F.chains.delete(s)},addAdapter(s,{networkControllerClient:e,connectionControllerClient:t},i){F.chains.set(s.namespace,{namespace:s.namespace,networkState:{...va,caipNetwork:i[0]},accountState:rl,caipNetworks:i,connectionControllerClient:t,networkControllerClient:e}),this.setRequestedCaipNetworks((i==null?void 0:i.filter(r=>r.chainNamespace===s.namespace))??[],s.namespace)},addNetwork(s){var t;const e=F.chains.get(s.chainNamespace);if(e){const i=[...e.caipNetworks||[]];(t=e.caipNetworks)!=null&&t.find(r=>r.id===s.id)||i.push(s),F.chains.set(s.chainNamespace,{...e,caipNetworks:i}),this.setRequestedCaipNetworks(i,s.chainNamespace)}},removeNetwork(s,e){var i,r,n;const t=F.chains.get(s);if(t){const o=((i=F.activeCaipNetwork)==null?void 0:i.id)===e,a=[...((r=t.caipNetworks)==null?void 0:r.filter(c=>c.id!==e))||[]];o&&((n=t==null?void 0:t.caipNetworks)!=null&&n[0])&&this.setActiveCaipNetwork(t.caipNetworks[0]),F.chains.set(s,{...t,caipNetworks:a}),this.setRequestedCaipNetworks(a||[],s)}},setAdapterNetworkState(s,e){const t=F.chains.get(s);t&&(t.networkState={...t.networkState||va,...e},F.chains.set(s,t))},setChainAccountData(s,e,t=!0){if(!s)throw new Error("Chain is required to update chain account data");const i=F.chains.get(s);if(i){const r={...i.accountState||rl,...e};F.chains.set(s,{...i,accountState:r}),(F.chains.size===1||F.activeChain===s)&&(e.caipAddress&&(F.activeCaipAddress=e.caipAddress),ie.replaceState(r))}},setChainNetworkData(s,e){if(!s)return;const t=F.chains.get(s);if(t){const i={...t.networkState||va,...e};F.chains.set(s,{...t,networkState:i})}},setAccountProp(s,e,t,i=!0){this.setChainAccountData(t,{[s]:e},i),s==="status"&&e==="disconnected"&&t&&le.removeConnectorId(t)},setActiveNamespace(s){var i,r;F.activeChain=s;const e=s?F.chains.get(s):void 0,t=(i=e==null?void 0:e.networkState)==null?void 0:i.caipNetwork;t!=null&&t.id&&s&&(F.activeCaipAddress=(r=e==null?void 0:e.accountState)==null?void 0:r.caipAddress,F.activeCaipNetwork=t,this.setChainNetworkData(s,{caipNetwork:t}),X.setActiveCaipNetworkId(t==null?void 0:t.caipNetworkId),pi.set({activeChain:s,selectedNetworkId:t==null?void 0:t.caipNetworkId}))},setActiveCaipNetwork(s){var i,r,n;if(!s)return;F.activeChain!==s.chainNamespace&&this.setIsSwitchingNamespace(!0);const e=F.chains.get(s.chainNamespace);F.activeChain=s.chainNamespace,F.activeCaipNetwork=s,this.setChainNetworkData(s.chainNamespace,{caipNetwork:s}),(i=e==null?void 0:e.accountState)!=null&&i.address?F.activeCaipAddress=`${s.chainNamespace}:${s.id}:${(r=e==null?void 0:e.accountState)==null?void 0:r.address}`:F.activeCaipAddress=void 0,this.setAccountProp("caipAddress",F.activeCaipAddress,s.chainNamespace),e&&ie.replaceState(e.accountState),Cp.resetSend(),pi.set({activeChain:F.activeChain,selectedNetworkId:(n=F.activeCaipNetwork)==null?void 0:n.caipNetworkId}),X.setActiveCaipNetworkId(s.caipNetworkId),!this.checkIfSupportedNetwork(s.chainNamespace)&&R.state.enableNetworkSwitch&&!R.state.allowUnsupportedChain&&!qe.state.wcBasic&&this.showUnsupportedChainUI()},addCaipNetwork(s){var t;if(!s)return;const e=F.chains.get(s.chainNamespace);e&&((t=e==null?void 0:e.caipNetworks)==null||t.push(s))},async switchActiveNamespace(s){var r;if(!s)return;const e=s!==I.state.activeChain,t=(r=I.getNetworkData(s))==null?void 0:r.caipNetwork,i=I.getCaipNetworkByNamespace(s,t==null?void 0:t.id);e&&i&&await I.switchActiveNetwork(i)},async switchActiveNetwork(s){var r;const e=I.state.chains.get(I.state.activeChain);!((r=e==null?void 0:e.caipNetworks)!=null&&r.some(n=>{var o;return n.id===((o=F.activeCaipNetwork)==null?void 0:o.id)}))&&xe.goBack();const i=this.getNetworkControllerClient(s.chainNamespace);i&&(await i.switchCaipNetwork(s),Be.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:s.caipNetworkId}}))},getNetworkControllerClient(s){const e=s||F.activeChain,t=F.chains.get(e);if(!t)throw new Error("Chain adapter not found");if(!t.networkControllerClient)throw new Error("NetworkController client not set");return t.networkControllerClient},getConnectionControllerClient(s){const e=s||F.activeChain;if(!e)throw new Error("Chain is required to get connection controller client");const t=F.chains.get(e);if(!(t!=null&&t.connectionControllerClient))throw new Error("ConnectionController client not set");return t.connectionControllerClient},getAccountProp(s,e){var r;let t=F.activeChain;if(e&&(t=e),!t)return;const i=(r=F.chains.get(t))==null?void 0:r.accountState;if(i)return i[s]},getNetworkProp(s,e){var i;const t=(i=F.chains.get(e))==null?void 0:i.networkState;if(t)return t[s]},getRequestedCaipNetworks(s){const e=F.chains.get(s),{approvedCaipNetworkIds:t=[],requestedCaipNetworks:i=[]}=(e==null?void 0:e.networkState)||{};return he.sortRequestedNetworks(t,i)},getAllRequestedCaipNetworks(){const s=[];return F.chains.forEach(e=>{const t=this.getRequestedCaipNetworks(e.namespace);s.push(...t)}),s},setRequestedCaipNetworks(s,e){this.setAdapterNetworkState(e,{requestedCaipNetworks:s})},getAllApprovedCaipNetworkIds(){const s=[];return F.chains.forEach(e=>{const t=this.getApprovedCaipNetworkIds(e.namespace);s.push(...t)}),s},getActiveCaipNetwork(){return F.activeCaipNetwork},getActiveCaipAddress(){return F.activeCaipAddress},getApprovedCaipNetworkIds(s){var i;const e=F.chains.get(s);return((i=e==null?void 0:e.networkState)==null?void 0:i.approvedCaipNetworkIds)||[]},async setApprovedCaipNetworksData(s){const e=this.getNetworkControllerClient(),t=await(e==null?void 0:e.getApprovedCaipNetworksData());this.setAdapterNetworkState(s,{approvedCaipNetworkIds:t==null?void 0:t.approvedCaipNetworkIds,supportsAllNetworks:t==null?void 0:t.supportsAllNetworks})},checkIfSupportedNetwork(s,e){const t=e||F.activeCaipNetwork,i=this.getRequestedCaipNetworks(s);return i.length?i==null?void 0:i.some(r=>r.id===(t==null?void 0:t.id)):!0},checkIfSupportedChainId(s){if(!F.activeChain)return!0;const e=this.getRequestedCaipNetworks(F.activeChain);return e==null?void 0:e.some(t=>t.id===s)},setSmartAccountEnabledNetworks(s,e){this.setAdapterNetworkState(e,{smartAccountEnabledNetworks:s})},checkIfSmartAccountEnabled(){var i;const s=iw.caipNetworkIdToNumber((i=F.activeCaipNetwork)==null?void 0:i.caipNetworkId),e=F.activeChain;if(!e||!s)return!1;const t=this.getNetworkProp("smartAccountEnabledNetworks",e);return!!(t!=null&&t.includes(Number(s)))},getActiveNetworkTokenAddress(){var i,r;const s=((i=F.activeCaipNetwork)==null?void 0:i.chainNamespace)||"eip155",e=((r=F.activeCaipNetwork)==null?void 0:r.id)||1,t=Vt.NATIVE_TOKEN_ADDRESS[s];return`${s}:${e}:${t}`},showUnsupportedChainUI(){ot.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const s=F.activeCaipNetwork;return!!(s!=null&&s.chainNamespace&&Vt.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(s.chainNamespace))},resetNetwork(s){this.setAdapterNetworkState(s,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]})},resetAccount(s){const e=s;if(!e)throw new Error("Chain is required to set account prop");F.activeCaipAddress=void 0,this.setChainAccountData(e,{smartAccountDeployed:!1,currentTab:0,caipAddress:void 0,address:void 0,balance:void 0,balanceSymbol:void 0,profileName:void 0,profileImage:void 0,addressExplorerUrl:void 0,tokenBalance:[],connectedWalletInfo:void 0,preferredAccountType:void 0,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,allAccounts:[],user:void 0,status:"disconnected"}),le.removeConnectorId(e)},async disconnect(s){const e=eO(s);try{Cp.resetSend();const t=await Promise.allSettled(e.map(async([r,n])=>{var o;try{const{caipAddress:a}=this.getAccountData(r)||{};a&&((o=n.connectionControllerClient)!=null&&o.disconnect)&&await n.connectionControllerClient.disconnect(r),this.resetAccount(r),this.resetNetwork(r)}catch(a){throw new Error(`Failed to disconnect chain ${r}: ${a.message}`)}}));qe.resetWcConnection();const i=t.filter(r=>r.status==="rejected");if(i.length>0)throw new Error(i.map(r=>r.reason.message).join(", "));X.deleteConnectedSocialProvider(),s?le.removeConnectorId(s):le.resetConnectorIds(),Be.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:s||"all"}})}catch(t){console.error(t.message||"Failed to disconnect chains"),Be.sendEvent({type:"track",event:"DISCONNECT_ERROR",properties:{message:t.message||"Failed to disconnect chains"}})}},setIsSwitchingNamespace(s){F.isSwitchingNamespace=s},getFirstCaipNetworkSupportsAuthConnector(){var t,i;const s=[];let e;if(F.chains.forEach(r=>{se.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(n=>n===r.namespace)&&r.namespace&&s.push(r.namespace)}),s.length>0){const r=s[0];return e=r?(i=(t=F.chains.get(r))==null?void 0:t.caipNetworks)==null?void 0:i[0]:void 0,e}},getAccountData(s){var e;return s?(e=I.state.chains.get(s))==null?void 0:e.accountState:ie.state},getNetworkData(s){var t;const e=s||F.activeChain;if(e)return(t=I.state.chains.get(e))==null?void 0:t.networkState},getCaipNetworkByNamespace(s,e){var r,n,o;if(!s)return;const t=I.state.chains.get(s),i=(r=t==null?void 0:t.caipNetworks)==null?void 0:r.find(a=>a.id===e);return i||((n=t==null?void 0:t.networkState)==null?void 0:n.caipNetwork)||((o=t==null?void 0:t.caipNetworks)==null?void 0:o[0])},getRequestedCaipNetworkIds(){const s=le.state.filterByNamespace;return(s?[F.chains.get(s)]:Array.from(F.chains.values())).flatMap(t=>(t==null?void 0:t.caipNetworks)||[]).map(t=>t.caipNetworkId)}},NO={purchaseCurrencies:[{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"Ether",symbol:"ETH",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]}],paymentCurrencies:[{id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},{id:"EUR",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]}]},nw=he.getBlockchainApiUrl(),is=k.proxy({clientId:null,api:new vc({baseUrl:nw,clientId:null}),supportedChains:{http:[],ws:[]}}),ne={state:is,async get(s){const{st:e,sv:t}=ne.getSdkProperties(),i=R.state.projectId,r={...s.params||{},st:e,sv:t,projectId:i};return is.api.get({...s,params:r})},getSdkProperties(){const{sdkType:s,sdkVersion:e}=R.state;return{st:s||"unknown",sv:e||"unknown"}},async isNetworkSupported(s){if(!s)return!1;try{is.supportedChains.http.length||await ne.getSupportedNetworks()}catch{return!1}return is.supportedChains.http.includes(s)},async getSupportedNetworks(){const s=await ne.get({path:"v1/supported-chains"});return is.supportedChains=s,s},async fetchIdentity({address:s,caipNetworkId:e}){if(!await ne.isNetworkSupported(e))return{avatar:"",name:""};const i=X.getIdentityFromCacheForAddress(s);if(i)return i;const r=await ne.get({path:`/v1/identity/${s}`,params:{sender:I.state.activeCaipAddress?he.getPlainAddress(I.state.activeCaipAddress):void 0}});return X.updateIdentityCache({address:s,identity:r,timestamp:Date.now()}),r},async fetchTransactions({account:s,cursor:e,onramp:t,signal:i,cache:r,chainId:n}){var a;return await ne.isNetworkSupported((a=I.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?ne.get({path:`/v1/account/${s}/history`,params:{cursor:e,onramp:t,chainId:n},signal:i,cache:r}):{data:[],next:void 0}},async fetchSwapQuote({amount:s,userAddress:e,from:t,to:i,gasPrice:r}){var o;return await ne.isNetworkSupported((o=I.state.activeCaipNetwork)==null?void 0:o.caipNetworkId)?ne.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:s,userAddress:e,from:t,to:i,gasPrice:r}}):{quotes:[]}},async fetchSwapTokens({chainId:s}){var t;return await ne.isNetworkSupported((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)?ne.get({path:"/v1/convert/tokens",params:{chainId:s}}):{tokens:[]}},async fetchTokenPrice({addresses:s}){var t;return await ne.isNetworkSupported((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)?is.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:s,projectId:R.state.projectId},headers:{"Content-Type":"application/json"}}):{fungibles:[]}},async fetchSwapAllowance({tokenAddress:s,userAddress:e}){var i;return await ne.isNetworkSupported((i=I.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?ne.get({path:"/v1/convert/allowance",params:{tokenAddress:s,userAddress:e},headers:{"Content-Type":"application/json"}}):{allowance:"0"}},async fetchGasPrice({chainId:s}){var r;const{st:e,sv:t}=ne.getSdkProperties();if(!await ne.isNetworkSupported((r=I.state.activeCaipNetwork)==null?void 0:r.caipNetworkId))throw new Error("Network not supported for Gas Price");return ne.get({path:"/v1/convert/gas-price",headers:{"Content-Type":"application/json"},params:{chainId:s,st:e,sv:t}})},async generateSwapCalldata({amount:s,from:e,to:t,userAddress:i,disableEstimate:r}){var o;if(!await ne.isNetworkSupported((o=I.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return is.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:s,eip155:{slippage:Vt.CONVERT_SLIPPAGE_TOLERANCE},projectId:R.state.projectId,from:e,to:t,userAddress:i,disableEstimate:r}})},async generateApproveCalldata({from:s,to:e,userAddress:t}){var o;const{st:i,sv:r}=ne.getSdkProperties();if(!await ne.isNetworkSupported((o=I.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return ne.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:t,from:s,to:e,st:i,sv:r}})},async getBalance(s,e,t){var l;const{st:i,sv:r}=ne.getSdkProperties();if(!await ne.isNetworkSupported((l=I.state.activeCaipNetwork)==null?void 0:l.caipNetworkId))return vt.showError("Token Balance Unavailable"),{balances:[]};const o=`${e}:${s}`,a=X.getBalanceCacheForCaipAddress(o);if(a)return a;const c=await ne.get({path:`/v1/account/${s}/balance`,params:{currency:"usd",chainId:e,forceUpdate:t,st:i,sv:r}});return X.updateBalanceCache({caipAddress:o,balance:c,timestamp:Date.now()}),c},async lookupEnsName(s){var t;return await ne.isNetworkSupported((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)?ne.get({path:`/v1/profile/account/${s}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]}},async reverseLookupEnsName({address:s}){var t;return await ne.isNetworkSupported((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)?ne.get({path:`/v1/profile/reverse/${s}`,params:{sender:ie.state.address,apiVersion:"2"}}):[]},async getEnsNameSuggestions(s){var t;return await ne.isNetworkSupported((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)?ne.get({path:`/v1/profile/suggestions/${s}`,params:{zone:"reown.id"}}):{suggestions:[]}},async registerEnsName({coinType:s,address:e,message:t,signature:i}){var n;return await ne.isNetworkSupported((n=I.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)?is.api.post({path:"/v1/profile/account",body:{coin_type:s,address:e,message:t,signature:i},headers:{"Content-Type":"application/json"}}):{success:!1}},async generateOnRampURL({destinationWallets:s,partnerUserId:e,defaultNetwork:t,purchaseAmount:i,paymentAmount:r}){var a;return await ne.isNetworkSupported((a=I.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?(await is.api.post({path:"/v1/generators/onrampurl",params:{projectId:R.state.projectId},body:{destinationWallets:s,defaultNetwork:t,partnerUserId:e,defaultExperience:"buy",presetCryptoAmount:i,presetFiatAmount:r}})).url:""},async getOnrampOptions(){var e;if(!await ne.isNetworkSupported((e=I.state.activeCaipNetwork)==null?void 0:e.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await ne.get({path:"/v1/onramp/options"})}catch{return NO}},async getOnrampQuote({purchaseCurrency:s,paymentCurrency:e,amount:t,network:i}){var r;try{return await ne.isNetworkSupported((r=I.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)?await is.api.post({path:"/v1/onramp/quote",params:{projectId:R.state.projectId},body:{purchaseCurrency:s,paymentCurrency:e,amount:t,network:i}}):null}catch{return{coinbaseFee:{amount:t,currency:e.id},networkFee:{amount:t,currency:e.id},paymentSubtotal:{amount:t,currency:e.id},paymentTotal:{amount:t,currency:e.id},purchaseAmount:{amount:t,currency:e.id},quoteId:"mocked-quote-id"}}},async getSmartSessions(s){var t;return await ne.isNetworkSupported((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)?ne.get({path:`/v1/sessions/${s}`}):[]},async revokeSmartSession(s,e,t){var r;return await ne.isNetworkSupported((r=I.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)?is.api.post({path:`/v1/sessions/${s}/revoke`,params:{projectId:R.state.projectId},body:{pci:e,signature:t}}):{success:!1}},setClientId(s){is.clientId=s,is.api=new vc({baseUrl:nw,clientId:s})}},Hs=k.proxy({currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[]}),ie={state:Hs,replaceState(s){s&&Object.assign(Hs,k.ref(s))},subscribe(s){return I.subscribeChainProp("accountState",e=>{if(e)return s(e)})},subscribeKey(s,e,t){let i;return I.subscribeChainProp("accountState",r=>{if(r){const n=r[s];i!==n&&(i=n,e(n))}},t)},setStatus(s,e){I.setAccountProp("status",s,e)},getCaipAddress(s){return I.getAccountProp("caipAddress",s)},setCaipAddress(s,e){const t=s?he.getPlainAddress(s):void 0;e===I.state.activeChain&&(I.state.activeCaipAddress=s),I.setAccountProp("caipAddress",s,e),I.setAccountProp("address",t,e)},setBalance(s,e,t){I.setAccountProp("balance",s,t),I.setAccountProp("balanceSymbol",e,t)},setProfileName(s,e){I.setAccountProp("profileName",s,e)},setProfileImage(s,e){I.setAccountProp("profileImage",s,e)},setUser(s,e){I.setAccountProp("user",s,e)},setAddressExplorerUrl(s,e){I.setAccountProp("addressExplorerUrl",s,e)},setSmartAccountDeployed(s,e){I.setAccountProp("smartAccountDeployed",s,e)},setCurrentTab(s){I.setAccountProp("currentTab",s,I.state.activeChain)},setTokenBalance(s,e){s&&I.setAccountProp("tokenBalance",s,e)},setShouldUpdateToAddress(s,e){I.setAccountProp("shouldUpdateToAddress",s,e)},setAllAccounts(s,e){I.setAccountProp("allAccounts",s,e)},addAddressLabel(s,e,t){const i=I.getAccountProp("addressLabels",t)||new Map;i.set(s,e),I.setAccountProp("addressLabels",i,t)},removeAddressLabel(s,e){const t=I.getAccountProp("addressLabels",e)||new Map;t.delete(s),I.setAccountProp("addressLabels",t,e)},setConnectedWalletInfo(s,e){I.setAccountProp("connectedWalletInfo",s,e,!1)},setPreferredAccountType(s,e){I.setAccountProp("preferredAccountType",s,e)},setSocialProvider(s,e){s&&I.setAccountProp("socialProvider",s,e)},setSocialWindow(s,e){I.setAccountProp("socialWindow",s?k.ref(s):void 0,e)},setFarcasterUrl(s,e){I.setAccountProp("farcasterUrl",s,e)},async fetchTokenBalance(s){var n,o;Hs.balanceLoading=!0;const e=(n=I.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,t=(o=I.state.activeCaipNetwork)==null?void 0:o.chainNamespace,i=I.state.activeCaipAddress,r=i?he.getPlainAddress(i):void 0;if(Hs.lastRetry&&!he.isAllowedRetry(Hs.lastRetry,30*Vt.ONE_SEC_MS))return Hs.balanceLoading=!1,[];try{if(r&&e&&t){const c=(await ne.getBalance(r,e)).balances.filter(l=>l.quantity.decimals!=="0");return this.setTokenBalance(c,t),Hs.lastRetry=void 0,Hs.balanceLoading=!1,c}}catch(a){Hs.lastRetry=Date.now(),s==null||s(a),vt.showError("Token Balance Unavailable")}finally{Hs.balanceLoading=!1}return[]},resetAccount(s){I.resetAccount(s)}},Yt=k.proxy({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),ot={state:Yt,subscribe(s){return k.subscribe(Yt,()=>s(Yt))},subscribeKey(s,e){return k.subscribeKey(Yt,s,e)},async open(s){var r;const e=ie.state.status==="connected";qe.state.wcBasic?ue.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1}):await ue.prefetch({fetchConnectorImages:!e,fetchFeaturedWallets:!e,fetchRecommendedWallets:!e}),s!=null&&s.namespace?(await I.switchActiveNamespace(s.namespace),ot.setLoading(!0,s.namespace)):ot.setLoading(!0),le.setFilterByNamespace(s==null?void 0:s.namespace);const t=(r=I.getAccountData(s==null?void 0:s.namespace))==null?void 0:r.caipAddress;I.state.noAdapters&&!t?he.isMobile()?xe.reset("AllWallets"):xe.reset("ConnectingWalletConnectBasic"):s!=null&&s.view?xe.reset(s.view):t?xe.reset("Account"):xe.reset("Connect"),Yt.open=!0,pi.set({open:!0}),Be.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:!!t}})},close(){const s=R.state.enableEmbedded,e=!!I.state.activeCaipAddress;Yt.open&&Be.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:e}}),Yt.open=!1,ot.clearLoading(),s?e?xe.replace("Account"):xe.push("Connect"):pi.set({open:!1}),qe.resetUri()},setLoading(s,e){e&&Yt.loadingNamespaceMap.set(e,s),Yt.loading=s,pi.set({loading:s})},clearLoading(){Yt.loadingNamespaceMap.clear(),Yt.loading=!1},shake(){Yt.shake||(Yt.shake=!0,setTimeout(()=>{Yt.shake=!1},500))}},Sp=2147483648,AO={convertEVMChainIdToCoinType(s){if(s>=Sp)throw new Error("Invalid chainId");return(Sp|s)>>>0}},ys=k.proxy({suggestions:[],loading:!1}),ow={state:ys,subscribe(s){return k.subscribe(ys,()=>s(ys))},subscribeKey(s,e){return k.subscribeKey(ys,s,e)},async resolveName(s){var e,t;try{return await ne.lookupEnsName(s)}catch(i){const r=i;throw new Error(((t=(e=r==null?void 0:r.reasons)==null?void 0:e[0])==null?void 0:t.description)||"Error resolving name")}},async isNameRegistered(s){try{return await ne.lookupEnsName(s),!0}catch{return!1}},async getSuggestions(s){try{ys.loading=!0,ys.suggestions=[];const e=await ne.getEnsNameSuggestions(s);return ys.suggestions=e.suggestions.map(t=>({...t,name:t.name}))||[],ys.suggestions}catch(e){const t=this.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(t)}finally{ys.loading=!1}},async getNamesForAddress(s){try{if(!I.state.activeCaipNetwork)return[];const t=X.getEnsFromCacheForAddress(s);if(t)return t;const i=await ne.reverseLookupEnsName({address:s});return X.updateEnsCache({address:s,ens:i,timestamp:Date.now()}),i}catch(e){const t=this.parseEnsApiError(e,"Error fetching names for address");throw new Error(t)}},async registerName(s){const e=I.state.activeCaipNetwork;if(!e)throw new Error("Network not found");const t=ie.state.address,i=le.getAuthConnector();if(!t||!i)throw new Error("Address or auth connector not found");ys.loading=!0;try{const r=JSON.stringify({name:s,attributes:{},timestamp:Math.floor(Date.now()/1e3)});xe.pushTransactionStack({view:"RegisterAccountNameSuccess",goBack:!1,replace:!0,onCancel(){ys.loading=!1}});const n=await qe.signMessage(r),o=e.id;if(!o)throw new Error("Network not found");const a=AO.convertEVMChainIdToCoinType(Number(o));await ne.registerEnsName({coinType:a,address:t,signature:n,message:r}),ie.setProfileName(s,e.chainNamespace),xe.replace("RegisterAccountNameSuccess")}catch(r){const n=this.parseEnsApiError(r,`Error registering name ${s}`);throw xe.replace("RegisterAccountName"),new Error(n)}finally{ys.loading=!1}},validateName(s){return/^[a-zA-Z0-9-]{4,}$/u.test(s)},parseEnsApiError(s,e){var i,r;const t=s;return((r=(i=t==null?void 0:t.reasons)==null?void 0:i[0])==null?void 0:r.description)||e}};function $o(s,{strict:e=!0}={}){return!s||typeof s!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(s):s.startsWith("0x")}function Tp(s){return $o(s,{strict:!1})?Math.ceil((s.length-2)/2):s.length}const aw="2.23.2";let Jn={getDocsUrl:({docsBaseUrl:s,docsPath:e="",docsSlug:t})=>e?`${s??"https://viem.sh"}${e}${t?`#${t}`:""}`:void 0,version:`viem@${aw}`};class dr extends Error{constructor(e,t={}){var a;const i=(()=>{var c;return t.cause instanceof dr?t.cause.details:(c=t.cause)!=null&&c.message?t.cause.message:t.details})(),r=t.cause instanceof dr&&t.cause.docsPath||t.docsPath,n=(a=Jn.getDocsUrl)==null?void 0:a.call(Jn,{...t,docsPath:r}),o=[e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...i?[`Details: ${i}`]:[],...Jn.version?[`Version: ${Jn.version}`]:[]].join(`
12
- `);super(o,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=aw}walk(e){return cw(this,e)}}function cw(s,e){return e!=null&&e(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause!==void 0?cw(s.cause,e):e?null:s}class lw extends dr{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function Mn(s,{dir:e,size:t=32}={}){return typeof s=="string"?_O(s,{dir:e,size:t}):CO(s,{dir:e,size:t})}function _O(s,{dir:e,size:t=32}={}){if(t===null)return s;const i=s.replace("0x","");if(i.length>t*2)throw new lw({size:Math.ceil(i.length/2),targetSize:t,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](t*2,"0")}`}function CO(s,{dir:e,size:t=32}={}){if(t===null)return s;if(s.length>t)throw new lw({size:s.length,targetSize:t,type:"bytes"});const i=new Uint8Array(t);for(let r=0;r<t;r++){const n=e==="right";i[n?r:t-r-1]=s[n?r:s.length-r-1]}return i}class SO extends dr{constructor({max:e,min:t,signed:i,size:r,value:n}){super(`Number "${n}" is not in safe ${r?`${r*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class TO extends dr{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function xn(s,{size:e}){if(Tp(s)>e)throw new TO({givenSize:Tp(s),maxSize:e})}function Jl(s,e={}){const{signed:t}=e;e.size&&xn(s,{size:e.size});const i=BigInt(s);if(!t)return i;const r=(s.length-2)/2,n=(1n<<BigInt(r)*8n-1n)-1n;return i<=n?i:i-BigInt(`0x${"f".padStart(r*2,"f")}`)-1n}function PO(s,e={}){return Number(Jl(s,e))}const $O=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function Xl(s,e={}){return typeof s=="number"||typeof s=="bigint"?uw(s,e):typeof s=="string"?OO(s,e):typeof s=="boolean"?MO(s,e):hw(s,e)}function MO(s,e={}){const t=`0x${Number(s)}`;return typeof e.size=="number"?(xn(t,{size:e.size}),Mn(t,{size:e.size})):t}function hw(s,e={}){let t="";for(let r=0;r<s.length;r++)t+=$O[s[r]];const i=`0x${t}`;return typeof e.size=="number"?(xn(i,{size:e.size}),Mn(i,{dir:"right",size:e.size})):i}function uw(s,e={}){const{signed:t,size:i}=e,r=BigInt(s);let n;i?t?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof s=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&t?-n-1n:0;if(n&&r>n||r<o){const c=typeof s=="bigint"?"n":"";throw new SO({max:n?`${n}${c}`:void 0,min:`${o}${c}`,signed:t,size:i,value:`${s}${c}`})}const a=`0x${(t&&r<0?(1n<<BigInt(i*8))+BigInt(r):r).toString(16)}`;return i?Mn(a,{size:i}):a}const xO=new TextEncoder;function OO(s,e={}){const t=xO.encode(s);return hw(t,e)}const DO=new TextEncoder;function kO(s,e={}){return typeof s=="number"||typeof s=="bigint"?RO(s,e):typeof s=="boolean"?jO(s,e):$o(s)?dw(s,e):pw(s,e)}function jO(s,e={}){const t=new Uint8Array(1);return t[0]=Number(s),typeof e.size=="number"?(xn(t,{size:e.size}),Mn(t,{size:e.size})):t}const oi={zero:48,nine:57,A:65,F:70,a:97,f:102};function Pp(s){if(s>=oi.zero&&s<=oi.nine)return s-oi.zero;if(s>=oi.A&&s<=oi.F)return s-(oi.A-10);if(s>=oi.a&&s<=oi.f)return s-(oi.a-10)}function dw(s,e={}){let t=s;e.size&&(xn(t,{size:e.size}),t=Mn(t,{dir:"right",size:e.size}));let i=t.slice(2);i.length%2&&(i=`0${i}`);const r=i.length/2,n=new Uint8Array(r);for(let o=0,a=0;o<r;o++){const c=Pp(i.charCodeAt(a++)),l=Pp(i.charCodeAt(a++));if(c===void 0||l===void 0)throw new dr(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);n[o]=c*16+l}return n}function RO(s,e){const t=uw(s,e);return dw(t)}function pw(s,e={}){const t=DO.encode(s);return typeof e.size=="number"?(xn(t,{size:e.size}),Mn(t,{dir:"right",size:e.size})):t}function Za(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function UO(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Ko(s,...e){if(!UO(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function LO(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Za(s.outputLen),Za(s.blockLen)}function eh(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function gw(s,e){Ko(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Ia=BigInt(2**32-1),$p=BigInt(32);function zO(s,e=!1){return e?{h:Number(s&Ia),l:Number(s>>$p&Ia)}:{h:Number(s>>$p&Ia)|0,l:Number(s&Ia)|0}}function FO(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=zO(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const qO=(s,e,t)=>s<<t|e>>>32-t,BO=(s,e,t)=>e<<t|s>>>32-t,HO=(s,e,t)=>e<<t-32|s>>>64-t,WO=(s,e,t)=>s<<t-32|e>>>64-t,Fr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function VO(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function KO(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function GO(s,e){return s<<32-e|s>>>e}const Mp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function YO(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function xp(s){for(let e=0;e<s.length;e++)s[e]=YO(s[e])}function QO(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function Gh(s){return typeof s=="string"&&(s=QO(s)),Ko(s),s}function ZO(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Ko(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}class fw{clone(){return this._cloneInto()}}function yw(s){const e=i=>s().update(Gh(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function JO(s=32){if(Fr&&typeof Fr.getRandomValues=="function")return Fr.getRandomValues(new Uint8Array(s));if(Fr&&typeof Fr.randomBytes=="function")return Fr.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const ww=[],mw=[],bw=[],XO=BigInt(0),Xn=BigInt(1),eD=BigInt(2),tD=BigInt(7),sD=BigInt(256),iD=BigInt(113);for(let s=0,e=Xn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],ww.push(2*(5*i+t)),mw.push((s+1)*(s+2)/2%64);let r=XO;for(let n=0;n<7;n++)e=(e<<Xn^(e>>tD)*iD)%sD,e&eD&&(r^=Xn<<(Xn<<BigInt(n))-Xn);bw.push(r)}const[rD,nD]=FO(bw,!0),Op=(s,e,t)=>t>32?HO(s,e,t):qO(s,e,t),Dp=(s,e,t)=>t>32?WO(s,e,t):BO(s,e,t);function oD(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],d=Op(l,h,1)^t[a],p=Dp(l,h,1)^t[a+1];for(let f=0;f<50;f+=10)s[o+f]^=d,s[o+f+1]^=p}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=mw[o],c=Op(r,n,a),l=Dp(r,n,a),h=ww[o];r=s[h],n=s[h+1],s[h]=c,s[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=rD[i],s[1]^=nD[i]}t.fill(0)}class Yh extends fw{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Za(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=VO(this.state)}keccak(){Mp||xp(this.state32),oD(this.state32,this.rounds),Mp||xp(this.state32),this.posOut=0,this.pos=0}update(e){eh(this);const{blockLen:t,state:i}=this;e=Gh(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){eh(this,!1),Ko(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Za(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(gw(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new Yh(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}}const aD=(s,e,t)=>yw(()=>new Yh(e,s,t)),cD=aD(1,136,256/8);function vw(s,e){const t=e||"hex",i=cD($o(s,{strict:!1})?kO(s):s);return t==="bytes"?i:Xl(i)}class lD extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const nl=new lD(8192);function hD(s,e){if(nl.has(`${s}.${e}`))return nl.get(`${s}.${e}`);const t=s.substring(2).toLowerCase(),i=vw(pw(t),"bytes"),r=t.split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(i[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const n=`0x${r.join("")}`;return nl.set(`${s}.${e}`,n),n}function uD(s){const e=vw(`0x${s.substring(4)}`).substring(26);return hD(`0x${e}`)}async function dD({hash:s,signature:e}){const t=$o(s)?s:Xl(s),{secp256k1:i}=await Promise.resolve().then(()=>require("./secp256k1-CuaGNRQC.js"));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:l,s:h,v:d,yParity:p}=e,f=Number(p??d),g=kp(f);return new i.Signature(Jl(l),Jl(h)).addRecoveryBit(g)}const o=$o(e)?e:Xl(e),a=PO(`0x${o.slice(130)}`),c=kp(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(t.substring(2)).toHex(!1)}`}function kp(s){if(s===0||s===1)return s;if(s===27)return 0;if(s===28)return 1;throw new Error("Invalid yParityOrV value")}async function pD({hash:s,signature:e}){return uD(await dD({hash:s,signature:e}))}function gD(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let l=0;l<e.length;l++)e[l]=255;for(let l=0;l<s.length;l++){const h=s.charAt(l),d=h.charCodeAt(0);if(e[d]!==255)throw new TypeError(h+" is ambiguous");e[d]=l}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";let h=0,d=0,p=0;const f=l.length;for(;p!==f&&l[p]===0;)p++,h++;const g=(f-p)*n+1>>>0,y=new Uint8Array(g);for(;p!==f;){let w=l[p],N=0;for(let _=g-1;(w!==0||N<d)&&_!==-1;_--,N++)w+=256*y[_]>>>0,y[_]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");d=N,p++}let v=g-d;for(;v!==g&&y[v]===0;)v++;let b=i.repeat(h);for(;v<g;++v)b+=s.charAt(y[v]);return b}function a(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;let h=0,d=0,p=0;for(;l[h]===i;)d++,h++;const f=(l.length-h)*r+1>>>0,g=new Uint8Array(f);for(;h<l.length;){const w=l.charCodeAt(h);if(w>255)return;let N=e[w];if(N===255)return;let _=0;for(let C=f-1;(N!==0||_<p)&&C!==-1;C--,_++)N+=t*g[C]>>>0,g[C]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");p=_,h++}let y=f-p;for(;y!==f&&g[y]===0;)y++;const v=new Uint8Array(d+(f-y));let b=d;for(;y!==f;)v[b++]=g[y++];return v}function c(l){const h=a(l);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var fD="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Iw=gD(fD),yD=":";function bn(s){const[e,t]=s.split(yD);return{namespace:e,reference:t}}function Ew(s,e){return s.includes(":")?[s]:e.chains||[]}const wD="ReactNative",hs={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},mD="js";function Ja(){return typeof A.dist.process<"u"&&typeof A.dist.process.versions<"u"&&typeof A.dist.process.versions.node<"u"}function Fi(){return!u.getDocument_1()&&!!u.getNavigator_1()&&navigator.product===wD}function bD(){return Fi()&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Platform)<"u"&&(A.dist.global==null?void 0:A.dist.global.Platform.OS)==="android"}function vD(){return Fi()&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Platform)<"u"&&(A.dist.global==null?void 0:A.dist.global.Platform.OS)==="ios"}function Go(){return!Ja()&&!!u.getNavigator_1()&&!!u.getDocument_1()}function Yo(){return Fi()?hs.reactNative:Ja()?hs.node:Go()?hs.browser:hs.unknown}function jp(){var s;try{return Fi()&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Application)<"u"?(s=A.dist.global.Application)==null?void 0:s.applicationId:void 0}catch{return}}function ID(s,e){const t=new URLSearchParams(s);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const r=e[i];r!==void 0&&t.set(i,r)}return t.toString()}function Nw(){return u.getWindowMetadata_1()||{name:"",description:"",url:"",icons:[""]}}function ED(){if(Yo()===hs.reactNative&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Platform)<"u"){const{OS:t,Version:i}=A.dist.global.Platform;return[t,i].join("-")}const s=u.detect();if(s===null)return"unknown";const e=s.os?s.os.replace(" ","").toLowerCase():"unknown";return s.type==="browser"?[e,s.name,s.version].join("-"):[e,s.version].join("-")}function ND(){var s;const e=Yo();return e===hs.browser?[e,((s=u.getLocation_1())==null?void 0:s.host)||"unknown"].join(":"):e}function Aw(s,e,t){const i=ED(),r=ND();return[[s,e].join("-"),[mD,t].join("-"),i,r].join("/")}function AD({protocol:s,version:e,relayUrl:t,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=t.split("?"),h=Aw(s,e,i),d={auth:r,ua:h,projectId:n,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},p=ID(l[1]||"",d);return l[0]+"?"+p}function or(s,e){return s.filter(t=>e.includes(t)).length===s.length}function th(s){return Object.fromEntries(s.entries())}function sh(s){return new Map(Object.entries(s))}function Xi(s=u.cjs.FIVE_MINUTES,e){const t=u.cjs.toMiliseconds(s||u.cjs.FIVE_MINUTES);let i,r,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&r&&(clearTimeout(n),r(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},t),i=a,r=c})}}function Oi(s,e,t){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(t)),e);try{const o=await s;i(o)}catch(o){r(o)}clearTimeout(n)})}function _w(s,e){if(typeof e=="string"&&e.startsWith(`${s}:`))return e;if(s.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(s.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${s}`)}function _D(s){return _w("topic",s)}function CD(s){return _w("id",s)}function Cw(s){const[e,t]=s.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function pt(s,e){return u.cjs.fromMiliseconds(Date.now()+u.cjs.toMiliseconds(s))}function Ti(s){return Date.now()>=u.cjs.toMiliseconds(s)}function Me(s,e){return`${s}${e?`:${e}`:""}`}function Ra(s=[],e=[]){return[...new Set([...s,...e])]}async function SD({id:s,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const r=typeof t=="string"?JSON.parse(t):t,n=r==null?void 0:r.href;if(typeof n!="string")return;const o=TD(n,s,e),a=Yo();if(a===hs.browser){if(!((i=u.getDocument_1())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}PD(o)}else a===hs.reactNative&&typeof(A.dist.global==null?void 0:A.dist.global.Linking)<"u"&&await A.dist.global.Linking.openURL(o)}catch(r){console.error(r)}}function TD(s,e,t){const i=`requestId=${e}&sessionTopic=${t}`;s.endsWith("/")&&(s=s.slice(0,-1));let r=`${s}`;if(s.startsWith("https://t.me")){const n=s.includes("?")?"&startapp=":"?startapp=";r=`${r}${n}${OD(i,!0)}`}else r=`${r}/wc?${i}`;return r}function PD(s){let e="_self";xD()?e="_top":(MD()||s.startsWith("https://")||s.startsWith("http://"))&&(e="_blank"),window.open(s,e,"noreferrer noopener")}async function $D(s,e){let t="";try{if(Go()&&(t=localStorage.getItem(e),t))return t;t=await s.getItem(e)}catch(i){console.error(i)}return t}function Rp(s,e){if(!s.includes(e))return null;const t=s.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Up(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}function Qh(){return typeof A.dist.process<"u"&&A.dist.process.env.IS_VITEST==="true"}function MD(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function xD(){try{return window.self!==window.top}catch{return!1}}function OD(s,e=!1){const t=A.dist.Buffer.from(s).toString("base64");return e?t.replace(/[=]/g,""):t}function Sw(s){return A.dist.Buffer.from(s,"base64").toString("utf-8")}function DD(s){return new Promise(e=>setTimeout(e,s))}function Mo(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function kD(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Ic(s,...e){if(!kD(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function Zh(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Mo(s.outputLen),Mo(s.blockLen)}function An(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function Tw(s,e){Ic(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Ea=BigInt(2**32-1),Lp=BigInt(32);function jD(s,e=!1){return e?{h:Number(s&Ea),l:Number(s>>Lp&Ea)}:{h:Number(s>>Lp&Ea)|0,l:Number(s&Ea)|0}}function RD(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=jD(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const UD=(s,e,t)=>s<<t|e>>>32-t,LD=(s,e,t)=>e<<t|s>>>32-t,zD=(s,e,t)=>e<<t-32|s>>>64-t,FD=(s,e,t)=>s<<t-32|e>>>64-t,qr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function qD(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function ol(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Ws(s,e){return s<<32-e|s>>>e}const zp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function BD(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Fp(s){for(let e=0;e<s.length;e++)s[e]=BD(s[e])}function HD(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function _n(s){return typeof s=="string"&&(s=HD(s)),Ic(s),s}let Jh=class{clone(){return this._cloneInto()}};function Pw(s){const e=i=>s().update(_n(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function Qo(s=32){if(qr&&typeof qr.getRandomValues=="function")return qr.getRandomValues(new Uint8Array(s));if(qr&&typeof qr.randomBytes=="function")return qr.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const $w=[],Mw=[],xw=[],WD=BigInt(0),eo=BigInt(1),VD=BigInt(2),KD=BigInt(7),GD=BigInt(256),YD=BigInt(113);for(let s=0,e=eo,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],$w.push(2*(5*i+t)),Mw.push((s+1)*(s+2)/2%64);let r=WD;for(let n=0;n<7;n++)e=(e<<eo^(e>>KD)*YD)%GD,e&VD&&(r^=eo<<(eo<<BigInt(n))-eo);xw.push(r)}const[QD,ZD]=RD(xw,!0),qp=(s,e,t)=>t>32?zD(s,e,t):UD(s,e,t),Bp=(s,e,t)=>t>32?FD(s,e,t):LD(s,e,t);function JD(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],d=qp(l,h,1)^t[a],p=Bp(l,h,1)^t[a+1];for(let f=0;f<50;f+=10)s[o+f]^=d,s[o+f+1]^=p}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=Mw[o],c=qp(r,n,a),l=Bp(r,n,a),h=$w[o];r=s[h],n=s[h+1],s[h]=c,s[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=QD[i],s[1]^=ZD[i]}t.fill(0)}let XD=class Ow extends Jh{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Mo(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=qD(this.state)}keccak(){zp||Fp(this.state32),JD(this.state32,this.rounds),zp||Fp(this.state32),this.posOut=0,this.pos=0}update(e){An(this);const{blockLen:t,state:i}=this;e=_n(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){An(this,!1),Ic(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Mo(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Tw(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new Ow(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const ek=(s,e,t)=>Pw(()=>new XD(e,s,t)),tk=ek(1,136,256/8),sk="https://rpc.walletconnect.org/v1";function Dw(s){const e=`Ethereum Signed Message:
12
+ `);super(o,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=aw}walk(e){return cw(this,e)}}function cw(s,e){return e!=null&&e(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause!==void 0?cw(s.cause,e):e?null:s}class lw extends dr{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function Mn(s,{dir:e,size:t=32}={}){return typeof s=="string"?_O(s,{dir:e,size:t}):CO(s,{dir:e,size:t})}function _O(s,{dir:e,size:t=32}={}){if(t===null)return s;const i=s.replace("0x","");if(i.length>t*2)throw new lw({size:Math.ceil(i.length/2),targetSize:t,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](t*2,"0")}`}function CO(s,{dir:e,size:t=32}={}){if(t===null)return s;if(s.length>t)throw new lw({size:s.length,targetSize:t,type:"bytes"});const i=new Uint8Array(t);for(let r=0;r<t;r++){const n=e==="right";i[n?r:t-r-1]=s[n?r:s.length-r-1]}return i}class SO extends dr{constructor({max:e,min:t,signed:i,size:r,value:n}){super(`Number "${n}" is not in safe ${r?`${r*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class TO extends dr{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function xn(s,{size:e}){if(Tp(s)>e)throw new TO({givenSize:Tp(s),maxSize:e})}function Jl(s,e={}){const{signed:t}=e;e.size&&xn(s,{size:e.size});const i=BigInt(s);if(!t)return i;const r=(s.length-2)/2,n=(1n<<BigInt(r)*8n-1n)-1n;return i<=n?i:i-BigInt(`0x${"f".padStart(r*2,"f")}`)-1n}function PO(s,e={}){return Number(Jl(s,e))}const $O=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function Xl(s,e={}){return typeof s=="number"||typeof s=="bigint"?uw(s,e):typeof s=="string"?OO(s,e):typeof s=="boolean"?MO(s,e):hw(s,e)}function MO(s,e={}){const t=`0x${Number(s)}`;return typeof e.size=="number"?(xn(t,{size:e.size}),Mn(t,{size:e.size})):t}function hw(s,e={}){let t="";for(let r=0;r<s.length;r++)t+=$O[s[r]];const i=`0x${t}`;return typeof e.size=="number"?(xn(i,{size:e.size}),Mn(i,{dir:"right",size:e.size})):i}function uw(s,e={}){const{signed:t,size:i}=e,r=BigInt(s);let n;i?t?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof s=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&t?-n-1n:0;if(n&&r>n||r<o){const c=typeof s=="bigint"?"n":"";throw new SO({max:n?`${n}${c}`:void 0,min:`${o}${c}`,signed:t,size:i,value:`${s}${c}`})}const a=`0x${(t&&r<0?(1n<<BigInt(i*8))+BigInt(r):r).toString(16)}`;return i?Mn(a,{size:i}):a}const xO=new TextEncoder;function OO(s,e={}){const t=xO.encode(s);return hw(t,e)}const DO=new TextEncoder;function kO(s,e={}){return typeof s=="number"||typeof s=="bigint"?RO(s,e):typeof s=="boolean"?jO(s,e):$o(s)?dw(s,e):pw(s,e)}function jO(s,e={}){const t=new Uint8Array(1);return t[0]=Number(s),typeof e.size=="number"?(xn(t,{size:e.size}),Mn(t,{size:e.size})):t}const oi={zero:48,nine:57,A:65,F:70,a:97,f:102};function Pp(s){if(s>=oi.zero&&s<=oi.nine)return s-oi.zero;if(s>=oi.A&&s<=oi.F)return s-(oi.A-10);if(s>=oi.a&&s<=oi.f)return s-(oi.a-10)}function dw(s,e={}){let t=s;e.size&&(xn(t,{size:e.size}),t=Mn(t,{dir:"right",size:e.size}));let i=t.slice(2);i.length%2&&(i=`0${i}`);const r=i.length/2,n=new Uint8Array(r);for(let o=0,a=0;o<r;o++){const c=Pp(i.charCodeAt(a++)),l=Pp(i.charCodeAt(a++));if(c===void 0||l===void 0)throw new dr(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);n[o]=c*16+l}return n}function RO(s,e){const t=uw(s,e);return dw(t)}function pw(s,e={}){const t=DO.encode(s);return typeof e.size=="number"?(xn(t,{size:e.size}),Mn(t,{dir:"right",size:e.size})):t}function Za(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function UO(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Ko(s,...e){if(!UO(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function LO(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Za(s.outputLen),Za(s.blockLen)}function eh(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function gw(s,e){Ko(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Ia=BigInt(2**32-1),$p=BigInt(32);function zO(s,e=!1){return e?{h:Number(s&Ia),l:Number(s>>$p&Ia)}:{h:Number(s>>$p&Ia)|0,l:Number(s&Ia)|0}}function FO(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=zO(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const qO=(s,e,t)=>s<<t|e>>>32-t,BO=(s,e,t)=>e<<t|s>>>32-t,HO=(s,e,t)=>e<<t-32|s>>>64-t,WO=(s,e,t)=>s<<t-32|e>>>64-t,Fr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function VO(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function KO(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function GO(s,e){return s<<32-e|s>>>e}const Mp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function YO(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function xp(s){for(let e=0;e<s.length;e++)s[e]=YO(s[e])}function QO(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function Gh(s){return typeof s=="string"&&(s=QO(s)),Ko(s),s}function ZO(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Ko(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}class fw{clone(){return this._cloneInto()}}function yw(s){const e=i=>s().update(Gh(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function JO(s=32){if(Fr&&typeof Fr.getRandomValues=="function")return Fr.getRandomValues(new Uint8Array(s));if(Fr&&typeof Fr.randomBytes=="function")return Fr.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const ww=[],mw=[],bw=[],XO=BigInt(0),Xn=BigInt(1),eD=BigInt(2),tD=BigInt(7),sD=BigInt(256),iD=BigInt(113);for(let s=0,e=Xn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],ww.push(2*(5*i+t)),mw.push((s+1)*(s+2)/2%64);let r=XO;for(let n=0;n<7;n++)e=(e<<Xn^(e>>tD)*iD)%sD,e&eD&&(r^=Xn<<(Xn<<BigInt(n))-Xn);bw.push(r)}const[rD,nD]=FO(bw,!0),Op=(s,e,t)=>t>32?HO(s,e,t):qO(s,e,t),Dp=(s,e,t)=>t>32?WO(s,e,t):BO(s,e,t);function oD(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],d=Op(l,h,1)^t[a],p=Dp(l,h,1)^t[a+1];for(let f=0;f<50;f+=10)s[o+f]^=d,s[o+f+1]^=p}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=mw[o],c=Op(r,n,a),l=Dp(r,n,a),h=ww[o];r=s[h],n=s[h+1],s[h]=c,s[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=rD[i],s[1]^=nD[i]}t.fill(0)}class Yh extends fw{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Za(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=VO(this.state)}keccak(){Mp||xp(this.state32),oD(this.state32,this.rounds),Mp||xp(this.state32),this.posOut=0,this.pos=0}update(e){eh(this);const{blockLen:t,state:i}=this;e=Gh(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){eh(this,!1),Ko(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Za(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(gw(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new Yh(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}}const aD=(s,e,t)=>yw(()=>new Yh(e,s,t)),cD=aD(1,136,256/8);function vw(s,e){const t=e||"hex",i=cD($o(s,{strict:!1})?kO(s):s);return t==="bytes"?i:Xl(i)}class lD extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const nl=new lD(8192);function hD(s,e){if(nl.has(`${s}.${e}`))return nl.get(`${s}.${e}`);const t=s.substring(2).toLowerCase(),i=vw(pw(t),"bytes"),r=t.split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(i[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const n=`0x${r.join("")}`;return nl.set(`${s}.${e}`,n),n}function uD(s){const e=vw(`0x${s.substring(4)}`).substring(26);return hD(`0x${e}`)}async function dD({hash:s,signature:e}){const t=$o(s)?s:Xl(s),{secp256k1:i}=await Promise.resolve().then(()=>require("./secp256k1-Y38qxq0y.js"));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:l,s:h,v:d,yParity:p}=e,f=Number(p??d),g=kp(f);return new i.Signature(Jl(l),Jl(h)).addRecoveryBit(g)}const o=$o(e)?e:Xl(e),a=PO(`0x${o.slice(130)}`),c=kp(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(t.substring(2)).toHex(!1)}`}function kp(s){if(s===0||s===1)return s;if(s===27)return 0;if(s===28)return 1;throw new Error("Invalid yParityOrV value")}async function pD({hash:s,signature:e}){return uD(await dD({hash:s,signature:e}))}function gD(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let l=0;l<e.length;l++)e[l]=255;for(let l=0;l<s.length;l++){const h=s.charAt(l),d=h.charCodeAt(0);if(e[d]!==255)throw new TypeError(h+" is ambiguous");e[d]=l}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";let h=0,d=0,p=0;const f=l.length;for(;p!==f&&l[p]===0;)p++,h++;const g=(f-p)*n+1>>>0,y=new Uint8Array(g);for(;p!==f;){let w=l[p],N=0;for(let _=g-1;(w!==0||N<d)&&_!==-1;_--,N++)w+=256*y[_]>>>0,y[_]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");d=N,p++}let v=g-d;for(;v!==g&&y[v]===0;)v++;let b=i.repeat(h);for(;v<g;++v)b+=s.charAt(y[v]);return b}function a(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;let h=0,d=0,p=0;for(;l[h]===i;)d++,h++;const f=(l.length-h)*r+1>>>0,g=new Uint8Array(f);for(;h<l.length;){const w=l.charCodeAt(h);if(w>255)return;let N=e[w];if(N===255)return;let _=0;for(let C=f-1;(N!==0||_<p)&&C!==-1;C--,_++)N+=t*g[C]>>>0,g[C]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");p=_,h++}let y=f-p;for(;y!==f&&g[y]===0;)y++;const v=new Uint8Array(d+(f-y));let b=d;for(;y!==f;)v[b++]=g[y++];return v}function c(l){const h=a(l);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var fD="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Iw=gD(fD),yD=":";function bn(s){const[e,t]=s.split(yD);return{namespace:e,reference:t}}function Ew(s,e){return s.includes(":")?[s]:e.chains||[]}const wD="ReactNative",hs={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},mD="js";function Ja(){return typeof A.dist.process<"u"&&typeof A.dist.process.versions<"u"&&typeof A.dist.process.versions.node<"u"}function Fi(){return!u.getDocument_1()&&!!u.getNavigator_1()&&navigator.product===wD}function bD(){return Fi()&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Platform)<"u"&&(A.dist.global==null?void 0:A.dist.global.Platform.OS)==="android"}function vD(){return Fi()&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Platform)<"u"&&(A.dist.global==null?void 0:A.dist.global.Platform.OS)==="ios"}function Go(){return!Ja()&&!!u.getNavigator_1()&&!!u.getDocument_1()}function Yo(){return Fi()?hs.reactNative:Ja()?hs.node:Go()?hs.browser:hs.unknown}function jp(){var s;try{return Fi()&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Application)<"u"?(s=A.dist.global.Application)==null?void 0:s.applicationId:void 0}catch{return}}function ID(s,e){const t=new URLSearchParams(s);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const r=e[i];r!==void 0&&t.set(i,r)}return t.toString()}function Nw(){return u.getWindowMetadata_1()||{name:"",description:"",url:"",icons:[""]}}function ED(){if(Yo()===hs.reactNative&&typeof A.dist.global<"u"&&typeof(A.dist.global==null?void 0:A.dist.global.Platform)<"u"){const{OS:t,Version:i}=A.dist.global.Platform;return[t,i].join("-")}const s=u.detect();if(s===null)return"unknown";const e=s.os?s.os.replace(" ","").toLowerCase():"unknown";return s.type==="browser"?[e,s.name,s.version].join("-"):[e,s.version].join("-")}function ND(){var s;const e=Yo();return e===hs.browser?[e,((s=u.getLocation_1())==null?void 0:s.host)||"unknown"].join(":"):e}function Aw(s,e,t){const i=ED(),r=ND();return[[s,e].join("-"),[mD,t].join("-"),i,r].join("/")}function AD({protocol:s,version:e,relayUrl:t,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=t.split("?"),h=Aw(s,e,i),d={auth:r,ua:h,projectId:n,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},p=ID(l[1]||"",d);return l[0]+"?"+p}function or(s,e){return s.filter(t=>e.includes(t)).length===s.length}function th(s){return Object.fromEntries(s.entries())}function sh(s){return new Map(Object.entries(s))}function Xi(s=u.cjs.FIVE_MINUTES,e){const t=u.cjs.toMiliseconds(s||u.cjs.FIVE_MINUTES);let i,r,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&r&&(clearTimeout(n),r(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},t),i=a,r=c})}}function Oi(s,e,t){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(t)),e);try{const o=await s;i(o)}catch(o){r(o)}clearTimeout(n)})}function _w(s,e){if(typeof e=="string"&&e.startsWith(`${s}:`))return e;if(s.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(s.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${s}`)}function _D(s){return _w("topic",s)}function CD(s){return _w("id",s)}function Cw(s){const[e,t]=s.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function pt(s,e){return u.cjs.fromMiliseconds(Date.now()+u.cjs.toMiliseconds(s))}function Ti(s){return Date.now()>=u.cjs.toMiliseconds(s)}function Me(s,e){return`${s}${e?`:${e}`:""}`}function Ra(s=[],e=[]){return[...new Set([...s,...e])]}async function SD({id:s,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const r=typeof t=="string"?JSON.parse(t):t,n=r==null?void 0:r.href;if(typeof n!="string")return;const o=TD(n,s,e),a=Yo();if(a===hs.browser){if(!((i=u.getDocument_1())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}PD(o)}else a===hs.reactNative&&typeof(A.dist.global==null?void 0:A.dist.global.Linking)<"u"&&await A.dist.global.Linking.openURL(o)}catch(r){console.error(r)}}function TD(s,e,t){const i=`requestId=${e}&sessionTopic=${t}`;s.endsWith("/")&&(s=s.slice(0,-1));let r=`${s}`;if(s.startsWith("https://t.me")){const n=s.includes("?")?"&startapp=":"?startapp=";r=`${r}${n}${OD(i,!0)}`}else r=`${r}/wc?${i}`;return r}function PD(s){let e="_self";xD()?e="_top":(MD()||s.startsWith("https://")||s.startsWith("http://"))&&(e="_blank"),window.open(s,e,"noreferrer noopener")}async function $D(s,e){let t="";try{if(Go()&&(t=localStorage.getItem(e),t))return t;t=await s.getItem(e)}catch(i){console.error(i)}return t}function Rp(s,e){if(!s.includes(e))return null;const t=s.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Up(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}function Qh(){return typeof A.dist.process<"u"&&A.dist.process.env.IS_VITEST==="true"}function MD(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function xD(){try{return window.self!==window.top}catch{return!1}}function OD(s,e=!1){const t=A.dist.Buffer.from(s).toString("base64");return e?t.replace(/[=]/g,""):t}function Sw(s){return A.dist.Buffer.from(s,"base64").toString("utf-8")}function DD(s){return new Promise(e=>setTimeout(e,s))}function Mo(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function kD(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Ic(s,...e){if(!kD(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function Zh(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Mo(s.outputLen),Mo(s.blockLen)}function An(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function Tw(s,e){Ic(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Ea=BigInt(2**32-1),Lp=BigInt(32);function jD(s,e=!1){return e?{h:Number(s&Ea),l:Number(s>>Lp&Ea)}:{h:Number(s>>Lp&Ea)|0,l:Number(s&Ea)|0}}function RD(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=jD(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const UD=(s,e,t)=>s<<t|e>>>32-t,LD=(s,e,t)=>e<<t|s>>>32-t,zD=(s,e,t)=>e<<t-32|s>>>64-t,FD=(s,e,t)=>s<<t-32|e>>>64-t,qr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function qD(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function ol(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Ws(s,e){return s<<32-e|s>>>e}const zp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function BD(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Fp(s){for(let e=0;e<s.length;e++)s[e]=BD(s[e])}function HD(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function _n(s){return typeof s=="string"&&(s=HD(s)),Ic(s),s}let Jh=class{clone(){return this._cloneInto()}};function Pw(s){const e=i=>s().update(_n(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function Qo(s=32){if(qr&&typeof qr.getRandomValues=="function")return qr.getRandomValues(new Uint8Array(s));if(qr&&typeof qr.randomBytes=="function")return qr.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const $w=[],Mw=[],xw=[],WD=BigInt(0),eo=BigInt(1),VD=BigInt(2),KD=BigInt(7),GD=BigInt(256),YD=BigInt(113);for(let s=0,e=eo,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],$w.push(2*(5*i+t)),Mw.push((s+1)*(s+2)/2%64);let r=WD;for(let n=0;n<7;n++)e=(e<<eo^(e>>KD)*YD)%GD,e&VD&&(r^=eo<<(eo<<BigInt(n))-eo);xw.push(r)}const[QD,ZD]=RD(xw,!0),qp=(s,e,t)=>t>32?zD(s,e,t):UD(s,e,t),Bp=(s,e,t)=>t>32?FD(s,e,t):LD(s,e,t);function JD(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],d=qp(l,h,1)^t[a],p=Bp(l,h,1)^t[a+1];for(let f=0;f<50;f+=10)s[o+f]^=d,s[o+f+1]^=p}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=Mw[o],c=qp(r,n,a),l=Bp(r,n,a),h=$w[o];r=s[h],n=s[h+1],s[h]=c,s[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=QD[i],s[1]^=ZD[i]}t.fill(0)}let XD=class Ow extends Jh{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Mo(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=qD(this.state)}keccak(){zp||Fp(this.state32),JD(this.state32,this.rounds),zp||Fp(this.state32),this.posOut=0,this.pos=0}update(e){An(this);const{blockLen:t,state:i}=this;e=_n(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){An(this,!1),Ic(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Mo(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Tw(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new Ow(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const ek=(s,e,t)=>Pw(()=>new XD(e,s,t)),tk=ek(1,136,256/8),sk="https://rpc.walletconnect.org/v1";function Dw(s){const e=`Ethereum Signed Message:
13
13
  ${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+A.dist.Buffer.from(tk(t)).toString("hex")}async function ik(s,e,t,i,r,n){switch(t.t){case"eip191":return await rk(s,e,t.s);case"eip1271":return await nk(s,e,t.s,i,r,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}async function rk(s,e,t){return(await pD({hash:Dw(e),signature:t})).toLowerCase()===s.toLowerCase()}async function nk(s,e,t,i,r,n){const o=bn(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l="0000000000000000000000000000000000000000000000000000000000000041",h=t.substring(2),d=Dw(e).substring(2),p=a+d+c+l+h,f=await fetch(`${n||sk}/?chainId=${i}&projectId=${r}`,{method:"POST",body:JSON.stringify({id:ok(),jsonrpc:"2.0",method:"eth_call",params:[{to:s,data:p},"latest"]})}),{result:g}=await f.json();return g?g.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function ok(){return Date.now()+Math.floor(Math.random()*1e3)}function ak(s){const e=atob(s),t=new Uint8Array(e.length);for(let o=0;o<e.length;o++)t[o]=e.charCodeAt(o);const i=t[0];if(i===0)throw new Error("No signatures found");const r=1+i*64;if(t.length<r)throw new Error("Transaction data too short for claimed signature count");if(t.length<100)throw new Error("Transaction too short");const n=A.dist.Buffer.from(s,"base64").slice(1,65);return Iw.encode(n)}var ck=Object.defineProperty,lk=Object.defineProperties,hk=Object.getOwnPropertyDescriptors,Hp=Object.getOwnPropertySymbols,uk=Object.prototype.hasOwnProperty,dk=Object.prototype.propertyIsEnumerable,Wp=(s,e,t)=>e in s?ck(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,pk=(s,e)=>{for(var t in e||(e={}))uk.call(e,t)&&Wp(s,t,e[t]);if(Hp)for(var t of Hp(e))dk.call(e,t)&&Wp(s,t,e[t]);return s},gk=(s,e)=>lk(s,hk(e));const fk="did:pkh:",Xh=s=>s==null?void 0:s.split(":"),yk=s=>{const e=s&&Xh(s);if(e)return s.includes(fk)?e[3]:e[1]},ih=s=>{const e=s&&Xh(s);if(e)return e[2]+":"+e[3]},Xa=s=>{const e=s&&Xh(s);if(e)return e.pop()};async function Vp(s){const{cacao:e,projectId:t}=s,{s:i,p:r}=e,n=kw(r,r.iss),o=Xa(r.iss);return await ik(o,n,i,ih(r.iss),t)}const kw=(s,e)=>{const t=`${s.domain} wants you to sign in with your Ethereum account:`,i=Xa(e);if(!s.aud&&!s.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let r=s.statement||void 0;const n=`URI: ${s.aud||s.uri}`,o=`Version: ${s.version}`,a=`Chain ID: ${yk(e)}`,c=`Nonce: ${s.nonce}`,l=`Issued At: ${s.iat}`,h=s.exp?`Expiration Time: ${s.exp}`:void 0,d=s.nbf?`Not Before: ${s.nbf}`:void 0,p=s.requestId?`Request ID: ${s.requestId}`:void 0,f=s.resources?`Resources:${s.resources.map(y=>`
14
14
  - ${y}`).join("")}`:void 0,g=Ua(s.resources);if(g){const y=xo(g);r=_k(r,y)}return[t,i,"",r,"",n,o,a,c,l,h,d,p,f].filter(y=>y!=null).join(`
15
15
  `)};function wk(s){return A.dist.Buffer.from(JSON.stringify(s)).toString("base64")}function mk(s){return JSON.parse(A.dist.Buffer.from(s,"base64").toString("utf-8"))}function pr(s){if(!s)throw new Error("No recap provided, value is undefined");if(!s.att)throw new Error("No `att` property found");const e=Object.keys(s.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{const i=s.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(r=>{const n=i[r];if(!Array.isArray(n))throw new Error(`Ability limits ${r} must be an array of objects, found: ${n}`);if(!n.length)throw new Error(`Value of ${r} is empty array, must be an array with objects`);n.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${r}) must be an array of objects, found: ${o}`)})})})}function bk(s,e,t,i={}){return t==null||t.sort((r,n)=>r.localeCompare(n)),{att:{[s]:vk(e,t,i)}}}function vk(s,e,t={}){e=e==null?void 0:e.sort((r,n)=>r.localeCompare(n));const i=e.map(r=>({[`${s}/${r}`]:[t]}));return Object.assign({},...i)}function jw(s){return pr(s),`urn:recap:${wk(s).replace(/=/g,"")}`}function xo(s){const e=mk(s.replace("urn:recap:",""));return pr(e),e}function Ik(s,e,t){const i=bk(s,e,t);return jw(i)}function Ek(s){return s&&s.includes("urn:recap:")}function Nk(s,e){const t=xo(s),i=xo(e),r=Ak(t,i);return jw(r)}function Ak(s,e){pr(s),pr(e);const t=Object.keys(s.att).concat(Object.keys(e.att)).sort((r,n)=>r.localeCompare(n)),i={att:{}};return t.forEach(r=>{var n,o;Object.keys(((n=s.att)==null?void 0:n[r])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[r])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,l;i.att[r]=gk(pk({},i.att[r]),{[a]:((c=s.att[r])==null?void 0:c[a])||((l=e.att[r])==null?void 0:l[a])})})}),i}function _k(s="",e){pr(e);const t="I further authorize the stated URI to perform the following actions on my behalf: ";if(s.includes(t))return s;const i=[];let r=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(d=>({ability:d.split("/")[0],action:d.split("/")[1]}));c.sort((d,p)=>d.action.localeCompare(p.action));const l={};c.forEach(d=>{l[d.ability]||(l[d.ability]=[]),l[d.ability].push(d.action)});const h=Object.keys(l).map(d=>(r++,`(${r}) '${d}': '${l[d].join("', '")}' for '${a}'.`));i.push(h.join(", ").replace(".,","."))});const n=i.join(" "),o=`${t}${n}`;return`${s?s+" ":""}${o}`}function Kp(s){var e;const t=xo(s);pr(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(r=>r.split("/")[1]):[]}function Gp(s){const e=xo(s);pr(e);const t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(r=>{var n;(n=r==null?void 0:r[0])!=null&&n.chains&&t.push(r[0].chains)})}),[...new Set(t.flat())]}function Ua(s){if(!s)return;const e=s==null?void 0:s[s.length-1];return Ek(e)?e:void 0}function al(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function Rw(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function cs(s,...e){if(!Rw(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function Yp(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function Ck(s,e){cs(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function Qp(s){if(typeof s!="boolean")throw new Error(`boolean expected, not ${s}`)}const ji=s=>new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)),Sk=s=>new DataView(s.buffer,s.byteOffset,s.byteLength),Tk=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Tk)throw new Error("Non little-endian hardware is not supported");function Pk(s){if(typeof s!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(s))}function rh(s){if(typeof s=="string")s=Pk(s);else if(Rw(s))s=nh(s);else throw new Error("Uint8Array expected, got "+typeof s);return s}function $k(s,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(s,e)}function Mk(s,e){if(s.length!==e.length)return!1;let t=0;for(let i=0;i<s.length;i++)t|=s[i]^e[i];return t===0}const xk=(s,e)=>{function t(i,...r){if(cs(i),s.nonceLength!==void 0){const l=r[0];if(!l)throw new Error("nonce / iv required");s.varSizeNonce?cs(l):cs(l,s.nonceLength)}const n=s.tagLength;n&&r[1]!==void 0&&cs(r[1]);const o=e(i,...r),a=(l,h)=>{if(h!==void 0){if(l!==2)throw new Error("cipher output not supported");cs(h)}};let c=!1;return{encrypt(l,h){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,cs(l),a(o.encrypt.length,h),o.encrypt(l,h)},decrypt(l,h){if(cs(l),n&&l.length<n)throw new Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,h),o.decrypt(l,h)}}}return Object.assign(t,s),t};function Zp(s,e,t=!0){if(e===void 0)return new Uint8Array(s);if(e.length!==s)throw new Error("invalid output length, expected "+s+", got: "+e.length);if(t&&!Ok(e))throw new Error("invalid output, must be aligned");return e}function Jp(s,e,t,i){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(t>>r&n),a=Number(t&n);s.setUint32(e+4,o,i),s.setUint32(e+0,a,i)}function Ok(s){return s.byteOffset%4===0}function nh(s){return Uint8Array.from(s)}function Cn(...s){for(let e=0;e<s.length;e++)s[e].fill(0)}const Uw=s=>Uint8Array.from(s.split("").map(e=>e.charCodeAt(0))),Dk=Uw("expand 16-byte k"),kk=Uw("expand 32-byte k"),jk=ji(Dk),Rk=ji(kk);function Ae(s,e){return s<<e|s>>>32-e}function oh(s){return s.byteOffset%4===0}const Na=64,Uk=16,Lw=2**32-1,Xp=new Uint32Array;function Lk(s,e,t,i,r,n,o,a){const c=r.length,l=new Uint8Array(Na),h=ji(l),d=oh(r)&&oh(n),p=d?ji(r):Xp,f=d?ji(n):Xp;for(let g=0;g<c;o++){if(s(e,t,i,h,o,a),o>=Lw)throw new Error("arx: counter overflow");const y=Math.min(Na,c-g);if(d&&y===Na){const v=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let b=0,w;b<Uk;b++)w=v+b,f[w]=p[w]^h[b];g+=Na;continue}for(let v=0,b;v<y;v++)b=g+v,n[b]=r[b]^l[v];g+=y}}function zk(s,e){const{allowShortKeys:t,extendNonceFn:i,counterLength:r,counterRight:n,rounds:o}=$k({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof s!="function")throw new Error("core must be a function");return al(r),al(o),Qp(n),Qp(t),(a,c,l,h,d=0)=>{cs(a),cs(c),cs(l);const p=l.length;if(h===void 0&&(h=new Uint8Array(p)),cs(h),al(d),d<0||d>=Lw)throw new Error("arx: counter overflow");if(h.length<p)throw new Error(`arx: output (${h.length}) is shorter than data (${p})`);const f=[];let g=a.length,y,v;if(g===32)f.push(y=nh(a)),v=Rk;else if(g===16&&t)y=new Uint8Array(32),y.set(a),y.set(a,16),v=jk,f.push(y);else throw new Error(`arx: invalid 32-byte key, got length=${g}`);oh(c)||f.push(c=nh(c));const b=ji(y);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(v,b,ji(c.subarray(0,16)),b),c=c.subarray(16)}const w=16-r;if(w!==c.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(w!==12){const _=new Uint8Array(12);_.set(c,n?0:12-c.length),c=_,f.push(c)}const N=ji(c);return Lk(s,v,b,N,l,h,d,o),Cn(...f),h}}const Tt=(s,e)=>s[e++]&255|(s[e++]&255)<<8;let Fk=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=rh(e),cs(e,32);const t=Tt(e,0),i=Tt(e,2),r=Tt(e,4),n=Tt(e,6),o=Tt(e,8),a=Tt(e,10),c=Tt(e,12),l=Tt(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|i<<3)&8191,this.r[2]=(i>>>10|r<<6)&7939,this.r[3]=(r>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let h=0;h<8;h++)this.pad[h]=Tt(e,16+2*h)}process(e,t,i=!1){const r=i?0:2048,{h:n,r:o}=this,a=o[0],c=o[1],l=o[2],h=o[3],d=o[4],p=o[5],f=o[6],g=o[7],y=o[8],v=o[9],b=Tt(e,t+0),w=Tt(e,t+2),N=Tt(e,t+4),_=Tt(e,t+6),C=Tt(e,t+8),T=Tt(e,t+10),P=Tt(e,t+12),O=Tt(e,t+14);let $=n[0]+(b&8191),q=n[1]+((b>>>13|w<<3)&8191),j=n[2]+((w>>>10|N<<6)&8191),G=n[3]+((N>>>7|_<<9)&8191),B=n[4]+((_>>>4|C<<12)&8191),W=n[5]+(C>>>1&8191),V=n[6]+((C>>>14|T<<2)&8191),H=n[7]+((T>>>11|P<<5)&8191),K=n[8]+((P>>>8|O<<8)&8191),Q=n[9]+(O>>>5|r),S=0,z=S+$*a+q*(5*v)+j*(5*y)+G*(5*g)+B*(5*f);S=z>>>13,z&=8191,z+=W*(5*p)+V*(5*d)+H*(5*h)+K*(5*l)+Q*(5*c),S+=z>>>13,z&=8191;let ee=S+$*c+q*a+j*(5*v)+G*(5*y)+B*(5*g);S=ee>>>13,ee&=8191,ee+=W*(5*f)+V*(5*p)+H*(5*d)+K*(5*h)+Q*(5*l),S+=ee>>>13,ee&=8191;let Z=S+$*l+q*c+j*a+G*(5*v)+B*(5*y);S=Z>>>13,Z&=8191,Z+=W*(5*g)+V*(5*f)+H*(5*p)+K*(5*d)+Q*(5*h),S+=Z>>>13,Z&=8191;let ve=S+$*h+q*l+j*c+G*a+B*(5*v);S=ve>>>13,ve&=8191,ve+=W*(5*y)+V*(5*g)+H*(5*f)+K*(5*p)+Q*(5*d),S+=ve>>>13,ve&=8191;let pe=S+$*d+q*h+j*l+G*c+B*a;S=pe>>>13,pe&=8191,pe+=W*(5*v)+V*(5*y)+H*(5*g)+K*(5*f)+Q*(5*p),S+=pe>>>13,pe&=8191;let te=S+$*p+q*d+j*h+G*l+B*c;S=te>>>13,te&=8191,te+=W*a+V*(5*v)+H*(5*y)+K*(5*g)+Q*(5*f),S+=te>>>13,te&=8191;let st=S+$*f+q*p+j*d+G*h+B*l;S=st>>>13,st&=8191,st+=W*c+V*a+H*(5*v)+K*(5*y)+Q*(5*g),S+=st>>>13,st&=8191;let Le=S+$*g+q*f+j*p+G*d+B*h;S=Le>>>13,Le&=8191,Le+=W*l+V*c+H*a+K*(5*v)+Q*(5*y),S+=Le>>>13,Le&=8191;let Ie=S+$*y+q*g+j*f+G*p+B*d;S=Ie>>>13,Ie&=8191,Ie+=W*h+V*l+H*c+K*a+Q*(5*v),S+=Ie>>>13,Ie&=8191;let ke=S+$*v+q*y+j*g+G*f+B*p;S=ke>>>13,ke&=8191,ke+=W*d+V*h+H*l+K*c+Q*a,S+=ke>>>13,ke&=8191,S=(S<<2)+S|0,S=S+z|0,z=S&8191,S=S>>>13,ee+=S,n[0]=z,n[1]=ee,n[2]=Z,n[3]=ve,n[4]=pe,n[5]=te,n[6]=st,n[7]=Le,n[8]=Ie,n[9]=ke}finalize(){const{h:e,pad:t}=this,i=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=r,r=e[a]>>>13,e[a]&=8191;e[0]+=r*5,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,i[0]=e[0]+5,r=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+r,r=i[a]>>>13,i[a]&=8191;i[9]-=8192;let n=(r^1)-1;for(let a=0;a<10;a++)i[a]&=n;n=~n;for(let a=0;a<10;a++)e[a]=e[a]&n|i[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+t[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+t[a]|0)+(o>>>16)|0,e[a]=o&65535;Cn(i)}update(e){Yp(this);const{buffer:t,blockLen:i}=this;e=rh(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(i-this.pos,r-n);if(o===i){for(;i<=r-n;n+=i)this.process(e,n);continue}t.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){Cn(this.h,this.r,this.buffer,this.pad)}digestInto(e){Yp(this),Ck(e,this),this.finished=!0;const{buffer:t,h:i}=this;let{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=i[o]>>>0,e[n++]=i[o]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}};function qk(s){const e=(i,r)=>s(r).update(rh(i)).digest(),t=s(new Uint8Array(32));return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=i=>s(i),e}const Bk=qk(s=>new Fk(s));function Hk(s,e,t,i,r,n=20){let o=s[0],a=s[1],c=s[2],l=s[3],h=e[0],d=e[1],p=e[2],f=e[3],g=e[4],y=e[5],v=e[6],b=e[7],w=r,N=t[0],_=t[1],C=t[2],T=o,P=a,O=c,$=l,q=h,j=d,G=p,B=f,W=g,V=y,H=v,K=b,Q=w,S=N,z=_,ee=C;for(let ve=0;ve<n;ve+=2)T=T+q|0,Q=Ae(Q^T,16),W=W+Q|0,q=Ae(q^W,12),T=T+q|0,Q=Ae(Q^T,8),W=W+Q|0,q=Ae(q^W,7),P=P+j|0,S=Ae(S^P,16),V=V+S|0,j=Ae(j^V,12),P=P+j|0,S=Ae(S^P,8),V=V+S|0,j=Ae(j^V,7),O=O+G|0,z=Ae(z^O,16),H=H+z|0,G=Ae(G^H,12),O=O+G|0,z=Ae(z^O,8),H=H+z|0,G=Ae(G^H,7),$=$+B|0,ee=Ae(ee^$,16),K=K+ee|0,B=Ae(B^K,12),$=$+B|0,ee=Ae(ee^$,8),K=K+ee|0,B=Ae(B^K,7),T=T+j|0,ee=Ae(ee^T,16),H=H+ee|0,j=Ae(j^H,12),T=T+j|0,ee=Ae(ee^T,8),H=H+ee|0,j=Ae(j^H,7),P=P+G|0,Q=Ae(Q^P,16),K=K+Q|0,G=Ae(G^K,12),P=P+G|0,Q=Ae(Q^P,8),K=K+Q|0,G=Ae(G^K,7),O=O+B|0,S=Ae(S^O,16),W=W+S|0,B=Ae(B^W,12),O=O+B|0,S=Ae(S^O,8),W=W+S|0,B=Ae(B^W,7),$=$+q|0,z=Ae(z^$,16),V=V+z|0,q=Ae(q^V,12),$=$+q|0,z=Ae(z^$,8),V=V+z|0,q=Ae(q^V,7);let Z=0;i[Z++]=o+T|0,i[Z++]=a+P|0,i[Z++]=c+O|0,i[Z++]=l+$|0,i[Z++]=h+q|0,i[Z++]=d+j|0,i[Z++]=p+G|0,i[Z++]=f+B|0,i[Z++]=g+W|0,i[Z++]=y+V|0,i[Z++]=v+H|0,i[Z++]=b+K|0,i[Z++]=w+Q|0,i[Z++]=N+S|0,i[Z++]=_+z|0,i[Z++]=C+ee|0}const Wk=zk(Hk,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Vk=new Uint8Array(16),eg=(s,e)=>{s.update(e);const t=e.length%16;t&&s.update(Vk.subarray(t))},Kk=new Uint8Array(32);function tg(s,e,t,i,r){const n=s(e,t,Kk),o=Bk.create(n);r&&eg(o,r),eg(o,i);const a=new Uint8Array(16),c=Sk(a);Jp(c,0,BigInt(r?r.length:0),!0),Jp(c,8,BigInt(i.length),!0),o.update(a);const l=o.digest();return Cn(n,a),l}const Gk=s=>(e,t,i)=>({encrypt(r,n){const o=r.length;n=Zp(o+16,n,!1),n.set(r);const a=n.subarray(0,-16);s(e,t,a,a,1);const c=tg(s,e,t,a,i);return n.set(c,o),Cn(c),n},decrypt(r,n){n=Zp(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=tg(s,e,t,o,i);if(!Mk(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),s(e,t,n,n,1),Cn(c),n}}),zw=xk({blockSize:64,nonceLength:12,tagLength:16},Gk(Wk));let Fw=class extends Jh{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Zh(e);const i=_n(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(i.length>r?e.create().update(i).digest():i);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=e.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),n.fill(0)}update(e){return An(this),this.iHash.update(e),this}digestInto(e){An(this),Ic(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:i,finished:r,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=r,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const eu=(s,e,t)=>new Fw(s,e).update(t).digest();eu.create=(s,e)=>new Fw(s,e);function Yk(s,e,t){return Zh(s),t===void 0&&(t=new Uint8Array(s.outputLen)),eu(s,_n(t),_n(e))}const cl=new Uint8Array([0]),sg=new Uint8Array;function Qk(s,e,t,i=32){if(Zh(s),Mo(i),i>255*s.outputLen)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(i/s.outputLen);t===void 0&&(t=sg);const n=new Uint8Array(r*s.outputLen),o=eu.create(s,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<r;l++)cl[0]=l+1,a.update(l===0?sg:c).update(t).update(cl).digestInto(c),n.set(c,s.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),cl.fill(0),n.slice(0,i)}const Zk=(s,e,t,i,r)=>Qk(s,Yk(s,e,t),i,r);function Jk(s,e,t,i){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(t>>r&n),a=Number(t&n),c=i?4:0,l=i?0:4;s.setUint32(e+c,o,i),s.setUint32(e+l,a,i)}function Xk(s,e,t){return s&e^~s&t}function e3(s,e,t){return s&e^s&t^e&t}class t3 extends Jh{constructor(e,t,i,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ol(this.buffer)}update(e){An(this);const{view:t,buffer:i,blockLen:r}=this;e=_n(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(r-this.pos,n-o);if(a===r){const c=ol(e);for(;r<=n-o;o+=r)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){An(this),Tw(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:r,isLE:n}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(i,0),o=0);for(let d=o;d<r;d++)t[d]=0;Jk(i,r-8,BigInt(this.length*8),n),this.process(i,0);const a=ol(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,h[d],n)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:r,finished:n,destroyed:o,pos:a}=this;return e.length=r,e.pos=a,e.finished=n,e.destroyed=o,r%t&&e.buffer.set(i),e}}const s3=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]),Ei=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ni=new Uint32Array(64);let i3=class extends t3{constructor(){super(64,32,8,!1),this.A=Ei[0]|0,this.B=Ei[1]|0,this.C=Ei[2]|0,this.D=Ei[3]|0,this.E=Ei[4]|0,this.F=Ei[5]|0,this.G=Ei[6]|0,this.H=Ei[7]|0}get(){const{A:e,B:t,C:i,D:r,E:n,F:o,G:a,H:c}=this;return[e,t,i,r,n,o,a,c]}set(e,t,i,r,n,o,a,c){this.A=e|0,this.B=t|0,this.C=i|0,this.D=r|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,t){for(let d=0;d<16;d++,t+=4)Ni[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){const p=Ni[d-15],f=Ni[d-2],g=Ws(p,7)^Ws(p,18)^p>>>3,y=Ws(f,17)^Ws(f,19)^f>>>10;Ni[d]=y+Ni[d-7]+g+Ni[d-16]|0}let{A:i,B:r,C:n,D:o,E:a,F:c,G:l,H:h}=this;for(let d=0;d<64;d++){const p=Ws(a,6)^Ws(a,11)^Ws(a,25),f=h+p+Xk(a,c,l)+s3[d]+Ni[d]|0,g=(Ws(i,2)^Ws(i,13)^Ws(i,22))+e3(i,r,n)|0;h=l,l=c,c=a,a=o+f|0,o=n,n=r,r=i,i=f+g|0}i=i+this.A|0,r=r+this.B|0,n=n+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(i,r,n,o,a,c,l,h)}roundClean(){Ni.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Ec=Pw(()=>new i3);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const qw=BigInt(0);function tu(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Bw(s){if(!tu(s))throw new Error("Uint8Array expected")}const r3=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function n3(s){Bw(s);let e="";for(let t=0;t<s.length;t++)e+=r3[s[t]];return e}function o3(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);return s===""?qw:BigInt("0x"+s)}const ai={_0:48,_9:57,A:65,F:70,a:97,f:102};function ig(s){if(s>=ai._0&&s<=ai._9)return s-ai._0;if(s>=ai.A&&s<=ai.F)return s-(ai.A-10);if(s>=ai.a&&s<=ai.f)return s-(ai.a-10)}function Hw(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);const e=s.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(t);for(let r=0,n=0;r<t;r++,n+=2){const o=ig(s.charCodeAt(n)),a=ig(s.charCodeAt(n+1));if(o===void 0||a===void 0){const c=s[n]+s[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}i[r]=o*16+a}return i}function rg(s){return Bw(s),o3(n3(Uint8Array.from(s).reverse()))}function a3(s,e){return Hw(s.toString(16).padStart(e*2,"0"))}function c3(s,e){return a3(s,e).reverse()}function ng(s,e,t){let i;if(typeof e=="string")try{i=Hw(e)}catch(n){throw new Error(s+" must be hex string or Uint8Array, cause: "+n)}else if(tu(e))i=Uint8Array.from(e);else throw new Error(s+" must be hex string or Uint8Array");const r=i.length;if(typeof t=="number"&&r!==t)throw new Error(s+" of length "+t+" expected, got "+r);return i}const ll=s=>typeof s=="bigint"&&qw<=s;function l3(s,e,t){return ll(s)&&ll(e)&&ll(t)&&e<=s&&s<t}function og(s,e,t,i){if(!l3(e,t,i))throw new Error("expected valid "+s+": "+t+" <= n < "+i+", got "+e)}const h3={bigint:s=>typeof s=="bigint",function:s=>typeof s=="function",boolean:s=>typeof s=="boolean",string:s=>typeof s=="string",stringOrUint8Array:s=>typeof s=="string"||tu(s),isSafeInteger:s=>Number.isSafeInteger(s),array:s=>Array.isArray(s),field:(s,e)=>e.Fp.isValid(s),hash:s=>typeof s=="function"&&Number.isSafeInteger(s.outputLen)};function u3(s,e,t={}){const i=(r,n,o)=>{const a=h3[n];if(typeof a!="function")throw new Error("invalid validator function");const c=s[r];if(!(o&&c===void 0)&&!a(c,s))throw new Error("param "+String(r)+" is invalid. Expected "+n+", got "+c)};for(const[r,n]of Object.entries(e))i(r,n,!1);for(const[r,n]of Object.entries(t))i(r,n,!0);return s}const pn=BigInt(0),Aa=BigInt(1);function Ww(s,e){const t=s%e;return t>=pn?t:e+t}function d3(s,e,t){if(e<pn)throw new Error("invalid exponent, negatives unsupported");if(t<=pn)throw new Error("invalid modulus");if(t===Aa)return pn;let i=Aa;for(;e>pn;)e&Aa&&(i=i*s%t),s=s*s%t,e>>=Aa;return i}function ks(s,e,t){let i=s;for(;e-- >pn;)i*=i,i%=t;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Br=BigInt(0),hl=BigInt(1);function p3(s){return u3(s,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...s})}function g3(s){const e=p3(s),{P:t}=e,i=w=>Ww(w,t),r=e.montgomeryBits,n=Math.ceil(r/8),o=e.nByteLength,a=e.adjustScalarBytes||(w=>w),c=e.powPminus2||(w=>d3(w,t-BigInt(2),t));function l(w,N,_){const C=i(w*(N-_));return N=i(N-C),_=i(_+C),[N,_]}const h=(e.a-BigInt(2))/BigInt(4);function d(w,N){og("u",w,Br,t),og("scalar",N,Br,t);const _=N,C=w;let T=hl,P=Br,O=w,$=hl,q=Br,j;for(let B=BigInt(r-1);B>=Br;B--){const W=_>>B&hl;q^=W,j=l(q,T,O),T=j[0],O=j[1],j=l(q,P,$),P=j[0],$=j[1],q=W;const V=T+P,H=i(V*V),K=T-P,Q=i(K*K),S=H-Q,z=O+$,ee=O-$,Z=i(ee*V),ve=i(z*K),pe=Z+ve,te=Z-ve;O=i(pe*pe),$=i(C*i(te*te)),T=i(H*Q),P=i(S*(H+i(h*S)))}j=l(q,T,O),T=j[0],O=j[1],j=l(q,P,$),P=j[0],$=j[1];const G=c(P);return i(T*G)}function p(w){return c3(i(w),n)}function f(w){const N=ng("u coordinate",w,n);return o===32&&(N[31]&=127),rg(N)}function g(w){const N=ng("scalar",w),_=N.length;if(_!==n&&_!==o){let C=""+n+" or "+o;throw new Error("invalid scalar, expected "+C+" bytes, got "+_)}return rg(a(N))}function y(w,N){const _=f(N),C=g(w),T=d(_,C);if(T===Br)throw new Error("invalid private or public key received");return p(T)}const v=p(e.Gu);function b(w){return y(w,v)}return{scalarMult:y,scalarMultBase:b,getSharedSecret:(w,N)=>y(w,N),getPublicKey:w=>b(w),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:v}}const ah=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const f3=BigInt(1),ag=BigInt(2),y3=BigInt(3),w3=BigInt(5);BigInt(8);function m3(s){const e=BigInt(10),t=BigInt(20),i=BigInt(40),r=BigInt(80),n=ah,o=s*s%n*s%n,a=ks(o,ag,n)*o%n,c=ks(a,f3,n)*s%n,l=ks(c,w3,n)*c%n,h=ks(l,e,n)*l%n,d=ks(h,t,n)*h%n,p=ks(d,i,n)*d%n,f=ks(p,r,n)*p%n,g=ks(f,r,n)*p%n,y=ks(g,e,n)*l%n;return{pow_p_5_8:ks(y,ag,n)*s%n,b2:o}}function b3(s){return s[0]&=248,s[31]&=127,s[31]|=64,s}const ch=g3({P:ah,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:s=>{const e=ah,{pow_p_5_8:t,b2:i}=m3(s);return Ww(ks(t,y3,e)*i,e)},adjustScalarBytes:b3,randomBytes:Qo}),Vw="base10",Bt="base16",Di="base64pad",to="base64url",Zo="utf8",Kw=0,gi=1,Jo=2,v3=0,cg=1,mo=12,su=32;function I3(){const s=ch.utils.randomPrivateKey(),e=ch.getPublicKey(s);return{privateKey:u.toString(s,Bt),publicKey:u.toString(e,Bt)}}function lh(){const s=Qo(su);return u.toString(s,Bt)}function E3(s,e){const t=ch.getSharedSecret(u.fromString(s,Bt),u.fromString(e,Bt)),i=Zk(Ec,t,void 0,void 0,su);return u.toString(i,Bt)}function La(s){const e=Ec(u.fromString(s,Bt));return u.toString(e,Bt)}function Qs(s){const e=Ec(u.fromString(s,Zo));return u.toString(e,Bt)}function Gw(s){return u.fromString(`${s}`,Vw)}function gr(s){return Number(u.toString(s,Vw))}function N3(s){const e=Gw(typeof s.type<"u"?s.type:Kw);if(gr(e)===gi&&typeof s.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof s.senderPublicKey<"u"?u.fromString(s.senderPublicKey,Bt):void 0,i=typeof s.iv<"u"?u.fromString(s.iv,Bt):Qo(mo),r=u.fromString(s.symKey,Bt),n=zw(r,i).encrypt(u.fromString(s.message,Zo));return Yw({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:s.encoding})}function A3(s){const e=u.fromString(s.symKey,Bt),{sealed:t,iv:i}=Oo(s),r=zw(e,i).decrypt(t);if(r===null)throw new Error("Failed to decrypt");return u.toString(r,Zo)}function _3(s,e){const t=Gw(Jo),i=Qo(mo),r=u.fromString(s,Zo);return Yw({type:t,sealed:r,iv:i,encoding:e})}function C3(s,e){const{sealed:t}=Oo({encoded:s,encoding:e});return u.toString(t,Zo)}function Yw(s){const{encoding:e=Di}=s;if(gr(s.type)===Jo)return u.toString(u.concat([s.type,s.sealed]),e);if(gr(s.type)===gi){if(typeof s.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return u.toString(u.concat([s.type,s.senderPublicKey,s.iv,s.sealed]),e)}return u.toString(u.concat([s.type,s.iv,s.sealed]),e)}function Oo(s){const{encoded:e,encoding:t=Di}=s,i=u.fromString(e,t),r=i.slice(v3,cg),n=cg;if(gr(r)===gi){const l=n+su,h=l+mo,d=i.slice(n,l),p=i.slice(l,h),f=i.slice(h);return{type:r,sealed:f,iv:p,senderPublicKey:d}}if(gr(r)===Jo){const l=i.slice(n),h=Qo(mo);return{type:r,sealed:l,iv:h}}const o=n+mo,a=i.slice(n,o),c=i.slice(o);return{type:r,sealed:c,iv:a}}function S3(s,e){const t=Oo({encoded:s,encoding:e==null?void 0:e.encoding});return Qw({type:gr(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?u.toString(t.senderPublicKey,Bt):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function Qw(s){const e=(s==null?void 0:s.type)||Kw;if(e===gi){if(typeof(s==null?void 0:s.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(s==null?void 0:s.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:s==null?void 0:s.senderPublicKey,receiverPublicKey:s==null?void 0:s.receiverPublicKey}}function lg(s){return s.type===gi&&typeof s.senderPublicKey=="string"&&typeof s.receiverPublicKey=="string"}function hg(s){return s.type===Jo}function T3(s){return new Df.ec("p256").keyFromPublic({x:A.dist.Buffer.from(s.x,"base64").toString("hex"),y:A.dist.Buffer.from(s.y,"base64").toString("hex")},"hex")}function P3(s){let e=s.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function $3(s){return A.dist.Buffer.from(P3(s),"base64")}function M3(s,e){const[t,i,r]=s.split("."),n=$3(r);if(n.length!==64)throw new Error("Invalid signature length");const o=n.slice(0,32).toString("hex"),a=n.slice(32,64).toString("hex"),c=`${t}.${i}`,l=Ec(c),h=T3(e),d=u.toString(l,Bt);if(!h.verify(d,{r:o,s:a}))throw new Error("Invalid signature");return u.sn(s).payload}const x3="irn";function ec(s){return(s==null?void 0:s.relay)||{protocol:x3}}function ho(s){const e=u.C[s];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${s}`);return e}function O3(s,e="-"){const t={},i="relay"+e;return Object.keys(s).forEach(r=>{if(r.startsWith(i)){const n=r.replace(i,""),o=s[r];t[n]=o}}),t}function ug(s){if(!s.includes("wc:")){const l=Sw(s);l!=null&&l.includes("wc:")&&(s=l)}s=s.includes("wc://")?s.replace("wc://",""):s,s=s.includes("wc:")?s.replace("wc:",""):s;const e=s.indexOf(":"),t=s.indexOf("?")!==-1?s.indexOf("?"):void 0,i=s.substring(0,e),r=s.substring(e+1,t).split("@"),n=typeof t<"u"?s.substring(t):"",o=new URLSearchParams(n),a={};o.forEach((l,h)=>{a[h]=l});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:D3(r[0]),version:parseInt(r[1],10),symKey:a.symKey,relay:O3(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function D3(s){return s.startsWith("//")?s.substring(2):s}function k3(s,e="-"){const t="relay",i={};return Object.keys(s).forEach(r=>{const n=r,o=t+e+n;s[n]&&(i[o]=s[n])}),i}function dg(s){const e=new URLSearchParams,t=k3(s.relay);Object.keys(t).sort().forEach(r=>{e.set(r,t[r])}),e.set("symKey",s.symKey),s.expiryTimestamp&&e.set("expiryTimestamp",s.expiryTimestamp.toString()),s.methods&&e.set("methods",s.methods.join(","));const i=e.toString();return`${s.protocol}:${s.topic}@${s.version}?${i}`}function _a(s,e,t){return`${s}?wc_ev=${t}&topic=${e}`}function On(s){const e=[];return s.forEach(t=>{const[i,r]=t.split(":");e.push(`${i}:${r}`)}),e}function j3(s){const e=[];return Object.values(s).forEach(t=>{e.push(...On(t.accounts))}),e}function R3(s,e){const t=[];return Object.values(s).forEach(i=>{On(i.accounts).includes(e)&&t.push(...i.methods)}),t}function U3(s,e){const t=[];return Object.values(s).forEach(i=>{On(i.accounts).includes(e)&&t.push(...i.events)}),t}function iu(s){return s.includes(":")}function uo(s){return iu(s)?s.split(":")[0]:s}function L3(s){const e={};return s==null||s.forEach(t=>{var i;const[r,n]=t.split(":");e[r]||(e[r]={accounts:[],chains:[],events:[],methods:[]}),e[r].accounts.push(t),(i=e[r].chains)==null||i.push(`${r}:${n}`)}),e}function pg(s,e){e=e.map(i=>i.replace("did:pkh:",""));const t=L3(e);for(const[i,r]of Object.entries(t))r.methods?r.methods=Ra(r.methods,s):r.methods=s,r.events=["chainChanged","accountsChanged"];return t}const z3={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},F3={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function L(s,e){const{message:t,code:i}=F3[s];return{message:e?`${t} ${e}`:t,code:i}}function Ue(s,e){const{message:t,code:i}=z3[s];return{message:e?`${t} ${e}`:t,code:i}}function fr(s,e){return!!Array.isArray(s)}function Do(s){return Object.getPrototypeOf(s)===Object.prototype&&Object.keys(s).length}function Ot(s){return typeof s>"u"}function ht(s,e){return e&&Ot(s)?!0:typeof s=="string"&&!!s.trim().length}function ru(s,e){return e&&Ot(s)?!0:typeof s=="number"&&!isNaN(s)}function q3(s,e){const{requiredNamespaces:t}=e,i=Object.keys(s.namespaces),r=Object.keys(t);let n=!0;return or(r,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:l}=s.namespaces[o],h=On(a),d=t[o];(!or(Ew(o,d),h)||!or(d.methods,c)||!or(d.events,l))&&(n=!1)}),n):!1}function tc(s){return ht(s,!1)&&s.includes(":")?s.split(":").length===2:!1}function B3(s){if(ht(s,!1)&&s.includes(":")){const e=s.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&tc(t)}}return!1}function H3(s){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(ht(s,!1)){if(e(s))return!0;const t=Sw(s);return e(t)}}catch{}return!1}function W3(s){var e;return(e=s==null?void 0:s.proposer)==null?void 0:e.publicKey}function V3(s){return s==null?void 0:s.topic}function K3(s,e){let t=null;return ht(s==null?void 0:s.publicKey,!1)||(t=L("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function gg(s){let e=!0;return fr(s)?s.length&&(e=s.every(t=>ht(t,!1))):e=!1,e}function G3(s,e,t){let i=null;return fr(e)&&e.length?e.forEach(r=>{i||tc(r)||(i=Ue("UNSUPPORTED_CHAINS",`${t}, chain ${r} should be a string and conform to "namespace:chainId" format`))}):tc(s)||(i=Ue("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function Y3(s,e,t){let i=null;return Object.entries(s).forEach(([r,n])=>{if(i)return;const o=G3(r,Ew(r,n),`${e} ${t}`);o&&(i=o)}),i}function Q3(s,e){let t=null;return fr(s)?s.forEach(i=>{t||B3(i)||(t=Ue("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Ue("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function Z3(s,e){let t=null;return Object.values(s).forEach(i=>{if(t)return;const r=Q3(i==null?void 0:i.accounts,`${e} namespace`);r&&(t=r)}),t}function J3(s,e){let t=null;return gg(s==null?void 0:s.methods)?gg(s==null?void 0:s.events)||(t=Ue("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Ue("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Zw(s,e){let t=null;return Object.values(s).forEach(i=>{if(t)return;const r=J3(i,`${e}, namespace`);r&&(t=r)}),t}function X3(s,e,t){let i=null;if(s&&Do(s)){const r=Zw(s,e);r&&(i=r);const n=Y3(s,e,t);n&&(i=n)}else i=L("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function ul(s,e){let t=null;if(s&&Do(s)){const i=Zw(s,e);i&&(t=i);const r=Z3(s,e);r&&(t=r)}else t=L("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Jw(s){return ht(s.protocol,!0)}function ej(s,e){let t=!1;return s?s&&fr(s)&&s.length&&s.forEach(i=>{t=Jw(i)}):t=!0,t}function tj(s){return typeof s=="number"}function Xt(s){return typeof s<"u"&&typeof s!==null}function sj(s){return!(!s||typeof s!="object"||!s.code||!ru(s.code,!1)||!s.message||!ht(s.message,!1))}function ij(s){return!(Ot(s)||!ht(s.method,!1))}function rj(s){return!(Ot(s)||Ot(s.result)&&Ot(s.error)||!ru(s.id,!1)||!ht(s.jsonrpc,!1))}function nj(s){return!(Ot(s)||!ht(s.name,!1))}function fg(s,e){return!(!tc(e)||!j3(s).includes(e))}function oj(s,e,t){return ht(t,!1)?R3(s,e).includes(t):!1}function aj(s,e,t){return ht(t,!1)?U3(s,e).includes(t):!1}function yg(s,e,t){let i=null;const r=cj(s),n=lj(e),o=Object.keys(r),a=Object.keys(n),c=wg(Object.keys(s)),l=wg(Object.keys(e)),h=c.filter(d=>!l.includes(d));return h.length&&(i=L("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.
@@ -894,7 +894,7 @@ ${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+A.dist.Buffer.from(tk(t)
894
894
  .wui-color-fg-350 {
895
895
  background-color: var(--wui-color-fg-350);
896
896
  }
897
- `,Ma={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603};function ea(s){return{formatters:void 0,fees:void 0,serializers:void 0,...s}}const _h=ea({id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!1,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",deprecatedCaipNetworkId:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"}),Ch=ea({id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",deprecatedCaipNetworkId:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"}),cz=ea({id:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",network:"solana-testnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"});ea({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});ea({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0});const lz={solana:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"],eip155:["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_showCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"],bip122:["sendTransfer","signMessage","signPsbt","getAccountAddresses"]},Mm={getMethodsByChainNamespace(s){return lz[s]||[]},createDefaultNamespace(s){return{methods:this.getMethodsByChainNamespace(s),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(s,e){if(!e)return{...s};const t={...s},i=new Set;if(e.methods&&Object.keys(e.methods).forEach(r=>i.add(r)),e.chains&&Object.keys(e.chains).forEach(r=>i.add(r)),e.events&&Object.keys(e.events).forEach(r=>i.add(r)),e.rpcMap&&Object.keys(e.rpcMap).forEach(r=>{const[n]=r.split(":");n&&i.add(n)}),i.forEach(r=>{t[r]||(t[r]=this.createDefaultNamespace(r))}),e.methods&&Object.entries(e.methods).forEach(([r,n])=>{t[r]&&(t[r].methods=n)}),e.chains&&Object.entries(e.chains).forEach(([r,n])=>{t[r]&&(t[r].chains=n)}),e.events&&Object.entries(e.events).forEach(([r,n])=>{t[r]&&(t[r].events=n)}),e.rpcMap){const r=new Set;Object.entries(e.rpcMap).forEach(([n,o])=>{const[a,c]=n.split(":");!a||!c||!t[a]||(t[a].rpcMap||(t[a].rpcMap={}),r.has(a)||(t[a].rpcMap={},r.add(a)),t[a].rpcMap[c]=o)})}return t},createNamespaces(s,e){const t=s.reduce((i,r)=>{const{id:n,chainNamespace:o,rpcUrls:a}=r,c=a.default.http[0];i[o]||(i[o]=this.createDefaultNamespace(o));const l=`${o}:${n}`,h=i[o];switch(h.chains.push(l),l){case _h.caipNetworkId:h.chains.push(_h.deprecatedCaipNetworkId);break;case Ch.caipNetworkId:h.chains.push(Ch.deprecatedCaipNetworkId);break}return h!=null&&h.rpcMap&&c&&(h.rpcMap[n]=c),i},{});return this.applyNamespaceOverrides(t,e)},resolveReownName:async s=>{var i;const e=await ow.resolveName(s);return((i=(Object.values(e==null?void 0:e.addresses)||[])[0])==null?void 0:i.address)||!1},getChainsFromNamespaces(s={}){return Object.values(s).flatMap(e=>{const t=e.chains||[],i=e.accounts.map(r=>{const[n,o]=r.split(":");return`${n}:${o}`});return Array.from(new Set([...t,...i]))})},isSessionEventData(s){return typeof s=="object"&&s!==null&&"id"in s&&"topic"in s&&"params"in s&&typeof s.params=="object"&&s.params!==null&&"chainId"in s.params&&"event"in s.params&&typeof s.params.event=="object"&&s.params.event!==null}};class xm{constructor({provider:e,caipNetworks:t,namespace:i}){this.id=se.CONNECTOR_ID.WALLET_CONNECT,this.name=sc.ConnectorNamesMap[se.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=sc.ConnectorImageIds[se.CONNECTOR_ID.WALLET_CONNECT],this.caipNetworks=t,this.provider=e,this.chain=i}get chains(){return this.caipNetworks}async connectWalletConnect(){if(!await this.authenticate()){const t=R.state.universalProviderConfigOverride,i=Mm.createNamespaces(this.caipNetworks,t);await this.provider.connect({optionalNamespaces:i})}return{clientId:await this.provider.client.core.crypto.getClientId(),session:this.provider.session}}async disconnect(){await this.provider.disconnect()}async authenticate(){const e=this.chains.map(t=>t.caipNetworkId);return mn.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:hz})}}const hz=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"];class uz{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,e&&this.construct(e)}construct(e){this.caipNetworks=e.networks,this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get networks(){return this.caipNetworks||[]}setAuthProvider(e){this.addConnector({id:se.CONNECTOR_ID.AUTH,type:"AUTH",name:se.CONNECTOR_NAMES.AUTH,provider:e,imageId:sc.ConnectorImageIds[se.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const t=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter(i=>t.has(i.id)?!1:(t.add(i.id),!0)),this.emit("connectors",this.availableConnectors)}setStatus(e,t){ie.setStatus(e,t)}on(e,t){var i;this.eventListeners.has(e)||this.eventListeners.set(e,new Set),(i=this.eventListeners.get(e))==null||i.add(t)}off(e,t){const i=this.eventListeners.get(e);i&&i.delete(t)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,t){const i=this.eventListeners.get(e);i&&i.forEach(r=>r(t))}async connectWalletConnect(e){return{clientId:(await this.getWalletConnectConnector().connectWalletConnect()).clientId}}async switchNetwork(e){const{caipNetwork:t,providerType:i}=e;if(!e.provider)return;const r="provider"in e.provider?e.provider.provider:e.provider;if(i==="WALLET_CONNECT"){r.setDefaultChain(t.caipNetworkId);return}if(r&&i==="AUTH"){const n=r;await n.switchNetwork(t.caipNetworkId);const o=await n.getUser({chainId:t.caipNetworkId,preferredAccountType:R.state.defaultAccountTypes[t.chainNamespace]});this.emit("switchNetwork",o)}}getWalletConnectConnector(){const e=this.connectors.find(t=>t instanceof xm);if(!e)throw new Error("WalletConnectConnector not found");return e}}class dz extends uz{setUniversalProvider(e){this.addConnector(new xm({provider:e,caipNetworks:this.caipNetworks||[],namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){var r,n,o,a;const t=this.provider,i=((a=(o=(n=(r=t==null?void 0:t.session)==null?void 0:r.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const[,,l]=c.split(":");return l}).filter((c,l,h)=>h.indexOf(c)===l))||[];return Promise.resolve({accounts:i.map(c=>he.createAccount(e,c,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var n,o,a,c,l;if(!(e.caipNetwork&&Vt.BALANCE_SUPPORTED_CHAINS.includes((n=e.caipNetwork)==null?void 0:n.chainNamespace))||(o=e.caipNetwork)!=null&&o.testnet)return{balance:"0.00",symbol:((a=e.caipNetwork)==null?void 0:a.nativeCurrency.symbol)||""};if(ie.state.balanceLoading&&e.chainId===((c=I.state.activeCaipNetwork)==null?void 0:c.id))return{balance:ie.state.balance||"0.00",symbol:ie.state.balanceSymbol||""};const r=(await ie.fetchTokenBalance()).find(h=>{var d,p;return h.chainId===`${(d=e.caipNetwork)==null?void 0:d.chainNamespace}:${e.chainId}`&&h.symbol===((p=e.caipNetwork)==null?void 0:p.nativeCurrency.symbol)});return{balance:(r==null?void 0:r.quantity.numeric)||"0.00",symbol:(r==null?void 0:r.symbol)||((l=e.caipNetwork)==null?void 0:l.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:t,message:i,address:r}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=I.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===se.CHAIN.SOLANA?n=(await t.request({method:"solana_signMessage",params:{message:Iw.encode(new TextEncoder().encode(i)),pubkey:r}},(a=I.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await t.request({method:"personal_sign",params:[i,r]},(c=I.state.activeCaipNetwork)==null?void 0:c.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async getProfile(){return Promise.resolve({profileImage:"",profileName:""})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}async getEnsAddress(){return Promise.resolve({address:!1})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var r,n,o,a,c,l;const{caipNetwork:t}=e,i=this.getWalletConnectConnector();if(t.chainNamespace===se.CHAIN.EVM)try{await((r=i.provider)==null?void 0:r.request({method:"wallet_switchEthereumChain",params:[{chainId:yn.toHex(t.id)}]}))}catch(h){if(h.code===Ma.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||h.code===Ma.ERROR_INVALID_CHAIN_ID||h.code===Ma.ERROR_CODE_DEFAULT||((o=(n=h==null?void 0:h.data)==null?void 0:n.originalError)==null?void 0:o.code)===Ma.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=i.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:yn.toHex(t.id),rpcUrls:[(a=t==null?void 0:t.rpcUrls.chainDefault)==null?void 0:a.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[(c=t.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}i.provider.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(i=>i.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}class pz{constructor(e){var t;this.hasSwitchedToPreferredAccountTypeOnConnect=!1,this.chainNamespaces=[],this.reportedAlertErrors={},this.getCaipNetwork=i=>{var r,n;if(i){const o=(r=I.getNetworkData(i))==null?void 0:r.caipNetwork;return o||((n=I.getRequestedCaipNetworks(i).filter(a=>a.chainNamespace===i))==null?void 0:n[0])}return I.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const i=this.getCaipNetwork();if(i)return i.id},this.getCaipNetworks=i=>I.getRequestedCaipNetworks(i),this.getActiveChainNamespace=()=>I.state.activeChain,this.setRequestedCaipNetworks=(i,r)=>{I.setRequestedCaipNetworks(i,r)},this.getApprovedCaipNetworkIds=()=>I.getAllApprovedCaipNetworkIds(),this.getCaipAddress=i=>I.state.activeChain===i||!i?I.state.activeCaipAddress:I.getAccountProp("caipAddress",i),this.setClientId=i=>{ne.setClientId(i)},this.getProvider=i=>tt.getProvider(i),this.getProviderType=i=>tt.getProviderId(i),this.getPreferredAccountType=()=>ie.state.preferredAccountType,this.setCaipAddress=(i,r)=>{ie.setCaipAddress(i,r)},this.setBalance=(i,r,n)=>{ie.setBalance(i,r,n)},this.setProfileName=(i,r)=>{ie.setProfileName(i,r)},this.setProfileImage=(i,r)=>{ie.setProfileImage(i,r)},this.setUser=(i,r)=>{ie.setUser(i,r),R.state.enableEmbedded&&ot.close()},this.resetAccount=i=>{ie.resetAccount(i)},this.setCaipNetwork=i=>{I.setActiveCaipNetwork(i)},this.setCaipNetworkOfNamespace=(i,r)=>{I.setChainNetworkData(r,{caipNetwork:i})},this.setAllAccounts=(i,r)=>{ie.setAllAccounts(i,r),R.setHasMultipleAddresses((i==null?void 0:i.length)>1)},this.setStatus=(i,r)=>{ie.setStatus(i,r),le.isConnected()?X.setConnectionStatus("connected"):X.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=i=>I.getAccountProp("address",i),this.setConnectors=i=>{const r=[...le.getConnectors(),...i];le.setConnectors(r)},this.fetchIdentity=i=>ne.fetchIdentity(i),this.getReownName=i=>ow.getNamesForAddress(i),this.getConnectors=()=>le.getConnectors(),this.getConnectorImage=i=>Kh.getConnectorImage(i),this.setConnectedWalletInfo=(i,r)=>{const n=tt.getProviderId(r),o=i?{...i,type:n}:void 0;ie.setConnectedWalletInfo(o,r)},this.getIsConnectedState=()=>!!I.state.activeCaipAddress,this.addAddressLabel=(i,r,n)=>{ie.addAddressLabel(i,r,n)},this.removeAddressLabel=(i,r)=>{ie.removeAddressLabel(i,r)},this.getAddress=i=>I.state.activeChain===i||!i?ie.state.address:I.getAccountProp("address",i),this.setApprovedCaipNetworksData=i=>I.setApprovedCaipNetworksData(i),this.resetNetwork=i=>{I.resetNetwork(i)},this.addConnector=i=>{le.addConnector(i)},this.resetWcConnection=()=>{qe.resetWcConnection()},this.setAddressExplorerUrl=(i,r)=>{ie.setAddressExplorerUrl(i,r)},this.setSmartAccountDeployed=(i,r)=>{ie.setSmartAccountDeployed(i,r)},this.setSmartAccountEnabledNetworks=(i,r)=>{I.setSmartAccountEnabledNetworks(i,r)},this.setPreferredAccountType=(i,r)=>{ie.setPreferredAccountType(i,r)},this.setEIP6963Enabled=i=>{R.setEIP6963Enabled(i)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=[...new Set((t=this.caipNetworks)==null?void 0:t.map(i=>i.chainNamespace))],this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.initialize(e),this.sendInitializeEvent(e)}async initialize(e){this.initControllers(e),await this.initChainAdapters(),await this.injectModalUi(),await this.syncExistingConnection(),pi.set({initialized:!0})}sendInitializeEvent(e){var i;const{...t}=e;delete t.adapters,Be.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map(r=>r.id),siweConfig:{options:((i=e.siweConfig)==null?void 0:i.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&Ft.setThemeMode(e.themeMode),e.themeVariables&&Ft.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");I.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const t=this.getDefaultNetwork();t&&I.setActiveCaipNetwork(t)}initializeConnectionController(e){qe.setWcBasic(e.basic??!1)}initializeConnectorController(){le.initialize(this.chainNamespaces)}initializeOptionsController(e){var r;R.setDebug(e.debug!==!1),R.setEnableWalletConnect(e.enableWalletConnect!==!1),R.setEnableWalletGuide(e.enableWalletGuide!==!1),R.setEnableWallets(e.enableWallets!==!1),R.setEIP6963Enabled(e.enableEIP6963!==!1),R.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),R.setEnableAuthLogger(e.enableAuthLogger!==!1),R.setCustomRpcUrls(e.customRpcUrls),R.setSdkVersion(e.sdkVersion),R.setProjectId(e.projectId),R.setEnableEmbedded(e.enableEmbedded),R.setAllWallets(e.allWallets),R.setIncludeWalletIds(e.includeWalletIds),R.setExcludeWalletIds(e.excludeWalletIds),R.setFeaturedWalletIds(e.featuredWalletIds),R.setTokens(e.tokens),R.setTermsConditionsUrl(e.termsConditionsUrl),R.setPrivacyPolicyUrl(e.privacyPolicyUrl),R.setCustomWallets(e.customWallets),R.setFeatures(e.features),R.setAllowUnsupportedChain(e.allowUnsupportedChain),R.setDefaultAccountTypes(e.defaultAccountTypes),R.setUniversalProviderConfigOverride(e.universalProviderConfigOverride);const t=this.getDefaultMetaData();if(!e.metadata&&t&&(e.metadata=t),R.setMetadata(e.metadata),R.setDisableAppend(e.disableAppend),R.setEnableEmbedded(e.enableEmbedded),R.setSIWX(e.siwx),!e.projectId){wo.open($a.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((r=e.adapters)==null?void 0:r.find(n=>n.namespace===se.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");R.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,t,i,r;return typeof window<"u"&&typeof document<"u"?{name:((t=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:t.textContent)||"",description:((i=document.querySelector('meta[property="og:description"]'))==null?void 0:i.content)||"",url:window.location.origin,icons:[((r=document.querySelector('link[rel~="icon"]'))==null?void 0:r.href)||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const i=hn.getUnsupportedNetwork(`${t}:${e}`);I.setActiveCaipNetwork(i)}}getDefaultNetwork(){return hn.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return hn.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return hn.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(r=>{var n;return r.id===((n=e.defaultNetwork)==null?void 0:n.id)});return t?hn.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var n;const e=I.state.activeChain,t=this.getAdapter(e),i=(n=this.getCaipNetwork(e))==null?void 0:n.id;if(!t)throw new Error("Adapter not found");const r=await t.connectWalletConnect(i);this.close(),this.setClientId((r==null?void 0:r.clientId)||null),X.setConnectedNamespaces([...I.state.chains.keys()]),this.chainNamespaces.forEach(o=>{le.setConnectorId(Ai.CONNECTOR_TYPE_WALLET_CONNECT,o)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:t,type:i,provider:r,chain:n,caipNetwork:o})=>{var f,g,y,v,b,w,N;const a=I.state.activeChain,c=n||a,l=this.getAdapter(c);if(n&&n!==a&&!o){const _=(f=this.caipNetworks)==null?void 0:f.find(C=>C.chainNamespace===n);_&&this.setCaipNetwork(_)}if(!l)throw new Error("Adapter not found");const h=this.getCaipNetwork(c),d=await l.connect({id:e,info:t,type:i,provider:r,chainId:(o==null?void 0:o.id)||(h==null?void 0:h.id),rpcUrl:((v=(y=(g=o==null?void 0:o.rpcUrls)==null?void 0:g.default)==null?void 0:y.http)==null?void 0:v[0])||((N=(w=(b=h==null?void 0:h.rpcUrls)==null?void 0:b.default)==null?void 0:w.http)==null?void 0:N[0])});if(!d)return;X.addConnectedNamespace(c),this.syncProvider({...d,chainNamespace:c}),await this.syncAccount({...d,chainNamespace:c});const{accounts:p}=await l.getAccounts({namespace:c,id:e});this.setAllAccounts(p,c)},reconnectExternal:async({id:e,info:t,type:i,provider:r})=>{var a;const n=I.state.activeChain,o=this.getAdapter(n);o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:t,type:i,provider:r,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),X.addConnectedNamespace(n))},disconnect:async e=>{const t=e||I.state.activeChain,i=this.getAdapter(t),r=tt.getProvider(t),n=tt.getProviderId(t);await(i==null?void 0:i.disconnect({provider:r,providerType:n})),X.removeConnectedNamespace(t),tt.resetChain(t),this.setUser(void 0,t),this.setStatus("disconnected",t),this.hasSwitchedToPreferredAccountTypeOnConnect=!1},checkInstalled:e=>e?e.some(t=>{var i;return!!((i=window.ethereum)!=null&&i[String(t)])}):!!window.ethereum,signMessage:async e=>{const t=this.getAdapter(I.state.activeChain),i=await(t==null?void 0:t.signMessage({message:e,address:ie.state.address,provider:tt.getProvider(I.state.activeChain)}));return(i==null?void 0:i.signature)||""},sendTransaction:async e=>{if(e.chainNamespace===se.CHAIN.EVM){const t=this.getAdapter(I.state.activeChain),i=tt.getProvider(I.state.activeChain),r=await(t==null?void 0:t.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:i}));return(r==null?void 0:r.hash)||""}return""},estimateGas:async e=>{if(e.chainNamespace===se.CHAIN.EVM){const t=this.getAdapter(I.state.activeChain),i=tt.getProvider(I.state.activeChain),r=this.getCaipNetwork();if(!r)throw new Error("CaipNetwork is undefined");const n=await(t==null?void 0:t.estimateGas({...e,provider:i,caipNetwork:r}));return(n==null?void 0:n.gas)||0n}return 0n},getEnsAvatar:async()=>{var i;const e=this.getAdapter(I.state.activeChain),t=await(e==null?void 0:e.getProfile({address:ie.state.address,chainId:Number((i=this.getCaipNetwork())==null?void 0:i.id)}));return(t==null?void 0:t.profileImage)||!1},getEnsAddress:async e=>{const t=this.getAdapter(I.state.activeChain),i=this.getCaipNetwork();if(!i)return!1;const r=await(t==null?void 0:t.getEnsAddress({name:e,caipNetwork:i}));return(r==null?void 0:r.address)||!1},writeContract:async e=>{const t=this.getAdapter(I.state.activeChain),i=this.getCaipNetwork(),r=this.getCaipAddress(),n=tt.getProvider(I.state.activeChain);if(!i||!r)throw new Error("CaipNetwork or CaipAddress is undefined");const o=await(t==null?void 0:t.writeContract({...e,caipNetwork:i,provider:n,caipAddress:r}));return o==null?void 0:o.hash},parseUnits:(e,t)=>{const i=this.getAdapter(I.state.activeChain);return(i==null?void 0:i.parseUnits({value:e,decimals:t}))??0n},formatUnits:(e,t)=>{const i=this.getAdapter(I.state.activeChain);return(i==null?void 0:i.formatUnits({value:e,decimals:t}))??"0"},getCapabilities:async e=>{const t=this.getAdapter(I.state.activeChain);return await(t==null?void 0:t.getCapabilities(e))},grantPermissions:async e=>{const t=this.getAdapter(I.state.activeChain);return await(t==null?void 0:t.grantPermissions(e))},revokePermissions:async e=>{const t=this.getAdapter(I.state.activeChain);return t!=null&&t.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter(I.state.activeChain);return await(t==null?void 0:t.walletGetAssets(e))??{}}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},qe.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){var t,i,r,n,o;if(tt.getProviderId(I.state.activeChain)===Ai.CONNECTOR_TYPE_WALLET_CONNECT){const a=(i=(t=this.universalProvider)==null?void 0:t.session)==null?void 0:i.namespaces;return{supportsAllNetworks:((o=(n=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:n.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=tt.getProvider(t),n=tt.getProviderId(t);if(e.chainNamespace===I.state.activeChain){const o=this.getAdapter(t);await(o==null?void 0:o.switchNetwork({caipNetwork:e,provider:r,providerType:n}))}else if(this.setCaipNetwork(e),n===Ai.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const o=this.getAddressByChainNamespace(t);o&&this.syncAccount({address:o,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(t=>{const i=t.chains||[],r=t.accounts.map(n=>{const{chainId:o,chainNamespace:a}=vi.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...i,...r]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,i)=>{var n;const r=e==null?void 0:e.find(o=>o.namespace===i);return r?(t[i]=r,t[i].namespace=i,t[i].construct({namespace:i,projectId:(n=this.options)==null?void 0:n.projectId,networks:this.caipNetworks})):t[i]=new dz({namespace:i,networks:this.caipNetworks}),t},{})}async initChainAdapter(e){var t;this.onConnectors(e),this.listenAdapter(e),(t=this.chainAdapters)==null||t[e].syncConnectors(this.options,this),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){const t=this.getAdapter(e);t==null||t.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const i=X.getConnectionStatus();i==="connected"?this.setStatus("connecting",e):i==="disconnected"?(X.clearAddressCache(),this.setStatus(i,e)):this.setStatus(i,e),t.on("switchNetwork",({address:r,chainId:n})=>{var l;const o=(l=this.caipNetworks)==null?void 0:l.find(h=>h.id===n||h.caipNetworkId===n),a=I.state.activeChain===e,c=I.getAccountProp("address",e);if(o){const h=a&&r?r:c;h&&this.syncAccount({address:h,chainId:n,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),t.on("disconnect",this.disconnect.bind(this,e)),t.on("pendingTransactions",()=>{const r=ie.state.address,n=I.state.activeCaipNetwork;!r||!(n!=null&&n.id)||this.updateNativeBalance(r,n.id,n.chainNamespace)}),t.on("accountChanged",({address:r,chainId:n})=>{var a,c;const o=I.state.activeChain===e;o&&n?this.syncAccount({address:r,chainId:n,chainNamespace:e}):o&&((a=I.state.activeCaipNetwork)!=null&&a.id)?this.syncAccount({address:r,chainId:(c=I.state.activeCaipNetwork)==null?void 0:c.id,chainNamespace:e}):this.syncAccountInfo(r,n,e)})}async createUniversalProviderForAdapter(e){var t,i,r;await this.getUniversalProvider(),this.universalProvider&&((r=(i=(t=this.chainAdapters)==null?void 0:t[e])==null?void 0:i.setUniversalProvider)==null||r.call(i,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{const t=le.getConnectorId(e);switch(this.setStatus("connecting",e),t){case se.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case se.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}async syncAdapterConnection(e){var o,a,c;const t=this.getAdapter(e),i=le.getConnectorId(e),r=this.getCaipNetwork(e),n=le.getConnectors(e).find(l=>l.id===i);try{if(!t||!n)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(r!=null&&r.id))throw new Error("CaipNetwork not found");const l=await(t==null?void 0:t.syncConnection({namespace:e,id:n.id,chainId:r.id,rpcUrl:(c=(a=(o=r==null?void 0:r.rpcUrls)==null?void 0:o.default)==null?void 0:a.http)==null?void 0:c[0]}));if(l){const h=await(t==null?void 0:t.getAccounts({namespace:e,id:n.id}));h&&h.accounts.length>0?this.setAllAccounts(h.accounts,e):this.setAllAccounts([he.createAccount(e,l.address,"eoa")],e),this.syncProvider({...l,chainNamespace:e}),await this.syncAccount({...l,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch{this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async t=>{var a,c,l,h,d;const i=this.getAdapter(t),r=((h=(l=(c=(a=this.universalProvider)==null?void 0:a.session)==null?void 0:c.namespaces)==null?void 0:l[t])==null?void 0:h.accounts)||[],n=(d=I.state.activeCaipNetwork)==null?void 0:d.id,o=r.find(p=>{const{chainId:f}=vi.parseCaipAddress(p);return f===(n==null?void 0:n.toString())})||r[0];if(o){const p=vi.validateCaipAddress(o),{chainId:f,address:g}=vi.parseCaipAddress(p);if(tt.setProviderId(t,Ai.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&I.state.activeCaipNetwork&&(i==null?void 0:i.namespace)!==se.CHAIN.EVM){const y=i==null?void 0:i.getWalletConnectProvider({caipNetworks:this.caipNetworks,provider:this.universalProvider,activeCaipNetwork:I.state.activeCaipNetwork});tt.setProvider(t,y)}else tt.setProvider(t,this.universalProvider);le.setConnectorId(se.CONNECTOR_ID.WALLET_CONNECT,t),X.addConnectedNamespace(t),this.syncWalletConnectAccounts(t),await this.syncAccount({address:g,chainId:f,chainNamespace:t})}else this.setStatus("disconnected",t);await I.setApprovedCaipNetworksData(t)});await Promise.all(e)}syncWalletConnectAccounts(e){var i,r,n,o,a;const t=(a=(o=(n=(r=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:r.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const{address:l}=vi.parseCaipAddress(c);return l}).filter((c,l,h)=>h.indexOf(c)===l);t&&this.setAllAccounts(t.map(c=>he.createAccount(e,c,e==="bip122"?"payment":"eoa")),e)}syncProvider({type:e,provider:t,id:i,chainNamespace:r}){tt.setProviderId(r,e),tt.setProvider(r,t),le.setConnectorId(i,r)}async syncAccount(e){var d,p,f,g,y,v;const t=e.chainNamespace===I.state.activeChain,i=I.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:r,chainId:n,chainNamespace:o}=e,{chainId:a}=X.getActiveNetworkProps(),c=n||a,l=((d=I.state.activeCaipNetwork)==null?void 0:d.name)===se.UNSUPPORTED_NETWORK_NAME,h=I.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!h)&&c){let b=(p=this.caipNetworks)==null?void 0:p.find(_=>_.id.toString()===c.toString()),w=(f=this.caipNetworks)==null?void 0:f.find(_=>_.chainNamespace===o);if(!h&&!b&&!w){const _=this.getApprovedCaipNetworkIds()||[],C=_.find(P=>{var O;return((O=vi.parseCaipNetworkId(P))==null?void 0:O.chainId)===c.toString()}),T=_.find(P=>{var O;return((O=vi.parseCaipNetworkId(P))==null?void 0:O.chainNamespace)===o});b=(g=this.caipNetworks)==null?void 0:g.find(P=>P.caipNetworkId===C),w=(y=this.caipNetworks)==null?void 0:y.find(P=>P.caipNetworkId===T||"deprecatedCaipNetworkId"in P&&P.deprecatedCaipNetworkId===T)}const N=b||w;(N==null?void 0:N.chainNamespace)===I.state.activeChain?R.state.enableNetworkSwitch&&!R.state.allowUnsupportedChain&&((v=I.state.activeCaipNetwork)==null?void 0:v.name)===se.UNSUPPORTED_NETWORK_NAME?I.showUnsupportedChainUI():this.setCaipNetwork(N):t||i&&this.setCaipNetworkOfNamespace(i,o),this.syncConnectedWalletInfo(o),Tm.isLowerCaseMatch(r,ie.state.address)||this.syncAccountInfo(r,N==null?void 0:N.id,o),t?await this.syncBalance({address:r,chainId:N==null?void 0:N.id,chainNamespace:o}):await this.syncBalance({address:r,chainId:i==null?void 0:i.id,chainNamespace:o})}}async syncAccountInfo(e,t,i){const r=this.getCaipAddress(i),n=t||(r==null?void 0:r.split(":")[1]);if(!n)return;const o=`${i}:${n}:${e}`;this.setCaipAddress(o,i),await this.syncIdentity({address:e,chainId:n,chainNamespace:i})}async syncReownName(e,t){try{const i=await this.getReownName(e);if(i[0]){const r=i[0];this.setProfileName(r.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){var r;const t=le.getConnectorId(e),i=tt.getProviderId(e);if(i===Ai.CONNECTOR_TYPE_ANNOUNCED||i===Ai.CONNECTOR_TYPE_INJECTED){if(t){const n=this.getConnectors().find(o=>o.id===t);if(n){const{info:o,name:a,imageUrl:c}=n,l=c||this.getConnectorImage(n);this.setConnectedWalletInfo({name:a,icon:l,...o},e)}}}else if(i===Ai.CONNECTOR_TYPE_WALLET_CONNECT){const n=tt.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(r=n.session.peer.metadata.icons)==null?void 0:r[0]},e)}else if(t)if(t===se.CONNECTOR_ID.COINBASE){const n=this.getConnectors().find(o=>o.id===se.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(n)},e)}else this.setConnectedWalletInfo({name:t},e)}async syncBalance(e){!iw.getNetworksByNamespace(this.caipNetworks,e.chainNamespace).find(i=>{var r;return i.id.toString()===((r=e.chainId)==null?void 0:r.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async updateNativeBalance(e,t,i){const r=this.getAdapter(i);if(r){const n=await r.getBalance({address:e,chainId:t,caipNetwork:this.getCaipNetwork(i),tokens:this.options.tokens});this.setBalance(n.balance,n.symbol,i)}}async initializeUniversalAdapter(){var i,r,n,o,a,c,l,h,d,p;const e=ez.createLogger((f,...g)=>{f&&this.handleAlertError(f),console.error(...g)}),t={projectId:(i=this.options)==null?void 0:i.projectId,metadata:{name:(r=this.options)!=null&&r.metadata?(n=this.options)==null?void 0:n.metadata.name:"",description:(o=this.options)!=null&&o.metadata?(a=this.options)==null?void 0:a.metadata.description:"",url:(c=this.options)!=null&&c.metadata?(l=this.options)==null?void 0:l.metadata.url:"",icons:(h=this.options)!=null&&h.metadata?(d=this.options)==null?void 0:d.metadata.icons:[""]},logger:e};R.setManualWCControl(!!((p=this.options)!=null&&p.manualWCControl)),this.universalProvider=this.options.universalProvider??await cu.init(t),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",e=>{qe.setUri(e)}),this.universalProvider.on("connect",qe.finalizeWcConnection),this.universalProvider.on("disconnect",()=>{this.chainNamespaces.forEach(e=>{this.resetAccount(e)}),qe.resetWcConnection()}),this.universalProvider.on("chainChanged",e=>{var r;const t=(r=this.caipNetworks)==null?void 0:r.find(n=>n.id==e),i=this.getCaipNetwork();if(!t){this.setUnsupportedNetwork(e);return}(i==null?void 0:i.id)!==(t==null?void 0:t.id)&&this.setCaipNetwork(t)}),this.universalProvider.on("session_event",e=>{if(Mm.isSessionEventData(e)){const{name:t,data:i}=e.params.event;t==="accountsChanged"&&Array.isArray(i)&&he.isCaipAddress(i[0])&&this.syncAccount(vi.parseCaipAddress(i[0]))}}))}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&he.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Be.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}handleAlertError(e){const t=Object.entries($a.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[i,r]=t??[],{message:n,alertErrorKey:o}=r??{};if(i&&n&&!this.reportedAlertErrors[i]){const a=$a.ALERT_ERRORS[o];a&&(wo.open(a,"error"),this.reportedAlertErrors[i]=!0)}}getAdapter(e){var t;if(e)return(t=this.chainAdapters)==null?void 0:t[e]}createAdapter(e){var r;if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const i=e;i.namespace=t,i.construct({namespace:t,projectId:(r=this.options)==null?void 0:r.projectId,networks:this.caipNetworks}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=i)}async open(e){await this.injectModalUi(),e!=null&&e.uri&&qe.setUri(e.uri),await ot.open(e)}async close(){await this.injectModalUi(),ot.close()}setLoading(e,t){ot.setLoading(e,t)}async disconnect(e){await qe.disconnect(e)}getError(){return""}getChainId(){var e;return(e=I.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e){var i;const t=(i=this.caipNetworks)==null?void 0:i.find(r=>r.id===e.id);if(!t){wo.open($a.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await I.switchActiveNetwork(t)}getWalletProvider(){return I.state.activeChain?tt.state.providers[I.state.activeChain]:null}getWalletProviderType(){return tt.getProviderId(I.state.activeChain)}subscribeProviders(e){return tt.subscribeProviders(e)}getThemeMode(){return Ft.state.themeMode}getThemeVariables(){return Ft.state.themeVariables}setThemeMode(e){Ft.setThemeMode(e),$m(Ft.state.themeMode)}setTermsConditionsUrl(e){R.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){R.setPrivacyPolicyUrl(e)}setThemeVariables(e){Ft.setThemeVariables(e),rz(Ft.state.themeVariables)}subscribeTheme(e){return Ft.subscribe(e)}getWalletInfo(){return ie.state.connectedWalletInfo}getAccount(e){const t=le.getAuthConnector(e),i=I.getAccountData(e);if(i)return{allAccounts:i.allAccounts,caipAddress:i.caipAddress,address:he.getPlainAddress(i.caipAddress),isConnected:!!i.caipAddress,status:i.status,embeddedWalletInfo:t?{user:i.user,authProvider:i.socialProvider||"email",accountType:i.preferredAccountType,isSmartAccountDeployed:!!i.smartAccountDeployed}:void 0}}subscribeAccount(e,t){const i=()=>{const r=this.getAccount(t);r&&e(r)};t?I.subscribeChainProp("accountState",i,t):I.subscribe(i),le.subscribe(i)}subscribeNetwork(e){return I.subscribe(({activeCaipNetwork:t})=>{e({caipNetwork:t,chainId:t==null?void 0:t.id,caipNetworkId:t==null?void 0:t.caipNetworkId})})}subscribeWalletInfo(e){return ie.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){ie.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){I.subscribeKey("activeCaipNetwork",e)}getState(){return pi.state}subscribeState(e){return pi.subscribe(e)}showErrorMessage(e){vt.showError(e)}showSuccessMessage(e){vt.showSuccess(e)}getEvent(){return{...Be.state}}subscribeEvents(e){return Be.subscribe(e)}replace(e){xe.replace(e)}redirect(e){xe.push(e)}popTransactionStack(e){xe.popTransactionStack(e)}isOpen(){return ot.state.open}isTransactionStackEmpty(){return xe.state.transactionStack.length===0}isTransactionShouldReplaceView(){var e;return(e=xe.state.transactionStack[xe.state.transactionStack.length-1])==null?void 0:e.replace}static getInstance(){return this.instance}updateFeatures(e){R.setFeatures(e)}updateOptions(e){const i={...R.state||{},...e};R.setOptions(i)}setConnectMethodsOrder(e){R.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){R.setWalletFeaturesOrder(e)}setCollapseWallets(e){R.setCollapseWallets(e)}setSocialsOrder(e){R.setSocialsOrder(e)}getConnectMethodsOrder(){return rc.getConnectOrderMethod(R.state.features,le.getConnectors())}removeAdapter(e){var n;const t=this.getIsConnectedState(),i=this.getAdapter(e);if(!i||!this.chainAdapters||t)return;const r=(n=this.caipNetworks)==null?void 0:n.filter(o=>o.chainNamespace!==e);I.removeAdapter(e),le.removeAdapter(e),this.chainNamespaces=this.chainNamespaces.filter(o=>o!==e),this.caipNetworks=r,i.removeAllEventListeners(),Reflect.deleteProperty(this.chainAdapters,e)}addAdapter(e,t){const i=e.namespace;if(!this.connectionControllerClient||!this.networkControllerClient||!this.chainAdapters||!i)return;const r=this.extendCaipNetworks({...this.options,networks:t});this.caipNetworks=[...this.caipNetworks||[],...r],this.createAdapter(e),this.initChainAdapter(i),I.addAdapter(e,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient},r)}addNetwork(e,t){var r;if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const i=this.extendCaipNetwork(t,this.options);I.addNetwork(i),this.caipNetworks&&!((r=this.caipNetworks)!=null&&r.find(n=>n.id===i.id))&&this.caipNetworks.push(i)}removeNetwork(e,t){var n;if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);if(!((n=this.caipNetworks)==null?void 0:n.find(o=>o.id===t)))throw new Error(`Network with ID ${t} not found`);if(!this.caipNetworks)return;const r=this.caipNetworks.filter(o=>o.chainNamespace===e&&o.id!==t);if(!(r!=null&&r.length))throw new Error("Cannot remove last network for a namespace");I.removeNetwork(e,t),this.caipNetworks=[...r]}}let of=!1;class gz extends pz{async open(e){le.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&qe.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!of&&he.isClient()){if(await Promise.resolve().then(()=>require("./basic-YNjcoRfK.js")),await Promise.resolve().then(()=>require("./w3m-modal-BfRfCY9F.js")),!document.querySelector("w3m-modal")){const t=document.createElement("w3m-modal");!R.state.disableAppend&&!R.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",t)}of=!0}}}const fz="1.7.2";function yz(s){return new gz({...s,basic:!0,sdkVersion:`html-core-${fz}`})}function wz(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let l=0;l<e.length;l++)e[l]=255;for(let l=0;l<s.length;l++){const h=s.charAt(l),d=h.charCodeAt(0);if(e[d]!==255)throw new TypeError(h+" is ambiguous");e[d]=l}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";let h=0,d=0,p=0;const f=l.length;for(;p!==f&&l[p]===0;)p++,h++;const g=(f-p)*n+1>>>0,y=new Uint8Array(g);for(;p!==f;){let w=l[p],N=0;for(let _=g-1;(w!==0||N<d)&&_!==-1;_--,N++)w+=256*y[_]>>>0,y[_]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");d=N,p++}let v=g-d;for(;v!==g&&y[v]===0;)v++;let b=i.repeat(h);for(;v<g;++v)b+=s.charAt(y[v]);return b}function a(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;let h=0,d=0,p=0;for(;l[h]===i;)d++,h++;const f=(l.length-h)*r+1>>>0,g=new Uint8Array(f);for(;h<l.length;){const w=l.charCodeAt(h);if(w>255)return;let N=e[w];if(N===255)return;let _=0;for(let C=f-1;(N!==0||_<p)&&C!==-1;C--,_++)N+=t*g[C]>>>0,g[C]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");p=_,h++}let y=f-p;for(;y!==f&&g[y]===0;)y++;const v=new Uint8Array(d+(f-y));let b=d;for(;y!==f;)v[b++]=g[y++];return v}function c(l){const h=a(l);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var mz="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const _l=wz(mz);class fn extends Error{constructor(){super(),Object.setPrototypeOf(this,fn.prototype)}}class af extends Error{constructor(e){super(`WalletConnect Adapter - Method ${e} is not supported by the wallet`),this.name="WalletConnectFeatureNotSupportedError"}}function bz(s){let e=[s];return s===gt.Mainnet||s===gt.Deprecated_Mainnet?(e=[gt.Mainnet,gt.Deprecated_Mainnet],s===gt.Deprecated_Mainnet&&console.warn(nc.mainnet)):(s===gt.Deprecated_Devnet||s===gt.Devnet)&&(e=[gt.Devnet,gt.Deprecated_Devnet],console.warn(nc.devnet)),e}const nc={mainnet:`You are using a deprecated chain ID for Solana Mainnet, please use ${gt.Mainnet} instead.`,devnet:`You are using a deprecated chain ID for Solana Devnet, please use ${gt.Devnet} instead.`,wallet:"The connected wallet is using a deprecated chain ID for Solana. Please, contact them to upgrade. You can learn more at https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip10.md#chain-ids"};function cf(s,e){var i;const t=(i=s.namespaces.solana)==null?void 0:i.accounts.map(r=>`solana:${r.split(":")[1]}`);if(e===gt.Mainnet)return t!=null&&t.find(r=>r===gt.Mainnet)?gt.Mainnet:(console.warn(nc.wallet),gt.Deprecated_Mainnet);if(e===gt.Devnet)return t!=null&&t.find(r=>r===gt.Devnet)?gt.Devnet:(console.warn(nc.wallet),gt.Deprecated_Devnet);throw Error("WalletConnect Solana Adapter: Unable to get a default chain from the session.")}function vz(s){return{optionalNamespaces:{solana:{chains:bz(s),methods:[Is.signTransaction,Is.signMessage],events:[]}}}}class lu extends Error{constructor(){super("QR Code Modal was closed by user"),Object.setPrototypeOf(this,lu.prototype),this.name="QRCodeModalError"}}class Iz{constructor(e){At(this,"_UniversalProvider");At(this,"_session");At(this,"_modal");At(this,"_projectId");At(this,"_network");At(this,"_ConnectQueueResolver");if(this.initClient(e.options),this._network=e.network,!e.options.projectId)throw Error("WalletConnect Adapter: Project ID is undefined");this._projectId=e.options.projectId}async connect(){var r,n,o,a,c,l;if(this._UniversalProvider||await new Promise(h=>{this._ConnectQueueResolver=h}),!this._UniversalProvider)throw new Error("WalletConnect Adapter - Universal Provider was undefined while calling 'connect()'");if(this._UniversalProvider.session){this._session=this._UniversalProvider.session;const h=cf(this._session,this._network);return this._network=h,this._UniversalProvider.setDefaultChain(h),{publicKey:this.publicKey}}await this.initModal();const e=vz(this._network);(r=this._modal)==null||r.open();const t=new AbortController,i=t.signal;(n=this._modal)==null||n.subscribeState(h=>{h.open||t.abort(new lu)});try{const h=await Promise.race([(o=this._UniversalProvider)==null?void 0:o.connect(e),new Promise((p,f)=>{i.addEventListener("abort",()=>{f(i.reason)})})]);if((a=this._modal)==null||a.close(),this._session=h,!h)throw new cc;const d=cf(h,this._network);return this._network=d,(c=this._UniversalProvider)==null||c.setDefaultChain(d),{publicKey:this.publicKey}}catch(h){throw(l=this._modal)==null||l.close(),h}}async disconnect(){var e;if((e=this._UniversalProvider)!=null&&e.session){if(await this.initModal(),!this._modal)throw Error("WalletConnect Adapter -Modal is undefined: unable to disconnect");await this.client.disconnect(),this._session=void 0}else throw new fn}get client(){if(this._UniversalProvider)return this._UniversalProvider;throw new fn}get session(){if(!this._session)throw new fn;return this._session}get publicKey(){var e,t,i;if((e=this._UniversalProvider)!=null&&e.session&&this._session){const{address:r}=v0(((i=(t=this._session)==null?void 0:t.namespaces.solana)==null?void 0:i.accounts[0])??"");return new A.PublicKey(r)}throw new fn}async signTransaction(e){this.checkIfWalletSupportsMethod(Is.signTransaction);const t=ui(e),i=t?{}:e,{signature:r,transaction:n}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:Is.signTransaction,params:{...i,transaction:this.serialize(e)}}});return n?this.deserialize(n,t):(e.addSignature(this.publicKey,A.dist.Buffer.from(_l.decode(r))),e)}async signMessage(e){this.checkIfWalletSupportsMethod(Is.signMessage);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:Is.signMessage,params:{pubkey:this.publicKey.toString(),message:_l.encode(e)}}});return _l.decode(t)}async signAndSendTransaction(e){this.checkIfWalletSupportsMethod(Is.signAndSendTransaction);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:Is.signAndSendTransaction,params:{transaction:this.serialize(e)}}});return t}async signAllTransactions(e){try{this.checkIfWalletSupportsMethod(Is.signAllTransactions);const t=e.map(r=>this.serialize(r)),{transactions:i}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:Is.signAllTransactions,params:{transactions:t}}});return e.map((r,n)=>ui(r)?this.deserialize(i[n]??"",!0):this.deserialize(i[n]??""))}catch(t){if(t instanceof af){const i=e.map(n=>this.signTransaction(n));return await Promise.all(i)}throw t}}async initClient(e){const t=await zx.init(e);this._UniversalProvider=t,this._ConnectQueueResolver&&this._ConnectQueueResolver(!0)}async initModal(){if(!this._modal){if(!this._UniversalProvider)throw new Error("WalletConnect Adapter - cannot init modal when Universal Provider is undefined");this._modal=yz({projectId:this._projectId,universalProvider:this._UniversalProvider,networks:[_h,Ch,cz],manualWCControl:!0})}}serialize(e){return A.dist.Buffer.from(e.serialize({verifySignatures:!1})).toString("base64")}deserialize(e,t=!1){return t?A.VersionedTransaction.deserialize(A.dist.Buffer.from(e,"base64")):A.Transaction.from(A.dist.Buffer.from(e,"base64"))}checkIfWalletSupportsMethod(e){var t;if(!((t=this.session.namespaces.solana)!=null&&t.methods.includes(e)))throw new af(e)}}const Ez="WalletConnect";class Nz extends $h{constructor(t){super();At(this,"name",Ez);At(this,"url","https://walletconnect.org");At(this,"icon","data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4NSIgdmlld0JveD0iMCAwIDMwMCAxODUiIHdpZHRoPSIzMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTYxLjQzODU0MjkgMzYuMjU2MjYxMmM0OC45MTEyMjQxLTQ3Ljg4ODE2NjMgMTI4LjIxMTk4NzEtNDcuODg4MTY2MyAxNzcuMTIzMjA5MSAwbDUuODg2NTQ1IDUuNzYzNDE3NGMyLjQ0NTU2MSAyLjM5NDQwODEgMi40NDU1NjEgNi4yNzY1MTEyIDAgOC42NzA5MjA0bC0yMC4xMzY2OTUgMTkuNzE1NTAzYy0xLjIyMjc4MSAxLjE5NzIwNTEtMy4yMDUzIDEuMTk3MjA1MS00LjQyODA4MSAwbC04LjEwMDU4NC03LjkzMTE0NzljLTM0LjEyMTY5Mi0zMy40MDc5ODE3LTg5LjQ0Mzg4Ni0zMy40MDc5ODE3LTEyMy41NjU1Nzg4IDBsLTguNjc1MDU2MiA4LjQ5MzYwNTFjLTEuMjIyNzgxNiAxLjE5NzIwNDEtMy4yMDUzMDEgMS4xOTcyMDQxLTQuNDI4MDgwNiAwbC0yMC4xMzY2OTQ5LTE5LjcxNTUwMzFjLTIuNDQ1NTYxMi0yLjM5NDQwOTItMi40NDU1NjEyLTYuMjc2NTEyMiAwLTguNjcwOTIwNHptMjE4Ljc2Nzc5NjEgNDAuNzczNzQ0OSAxNy45MjE2OTcgMTcuNTQ2ODk3YzIuNDQ1NTQ5IDIuMzk0Mzk2OSAyLjQ0NTU2MyA2LjI3NjQ3NjkuMDAwMDMxIDguNjcwODg5OWwtODAuODEwMTcxIDc5LjEyMTEzNGMtMi40NDU1NDQgMi4zOTQ0MjYtNi40MTA1ODIgMi4zOTQ0NTMtOC44NTYxNi4wMDAwNjItLjAwMDAxLS4wMDAwMS0uMDAwMDIyLS4wMDAwMjItLjAwMDAzMi0uMDAwMDMybC01Ny4zNTQxNDMtNTYuMTU0NTcyYy0uNjExMzktLjU5ODYwMi0xLjYwMjY1LS41OTg2MDItMi4yMTQwNCAwLS4wMDAwMDQuMDAwMDA0LS4wMDAwMDcuMDAwMDA4LS4wMDAwMTEuMDAwMDExbC01Ny4zNTI5MjEyIDU2LjE1NDUzMWMtMi40NDU1MzY4IDIuMzk0NDMyLTYuNDEwNTc1NSAyLjM5NDQ3Mi04Ljg1NjE2MTIuMDAwMDg3LS4wMDAwMTQzLS4wMDAwMTQtLjAwMDAyOTYtLjAwMDAyOC0uMDAwMDQ0OS0uMDAwMDQ0bC04MC44MTI0MTk0My03OS4xMjIxODVjLTIuNDQ1NTYwMjEtMi4zOTQ0MDgtMi40NDU1NjAyMS02LjI3NjUxMTUgMC04LjY3MDkxOTdsMTcuOTIxNzI5NjMtMTcuNTQ2ODY3M2MyLjQ0NTU2MDItMi4zOTQ0MDgyIDYuNDEwNTk4OS0yLjM5NDQwODIgOC44NTYxNjAyIDBsNTcuMzU0OTc3NSA1Ni4xNTUzNTdjLjYxMTM5MDguNTk4NjAyIDEuNjAyNjQ5LjU5ODYwMiAyLjIxNDAzOTggMCAuMDAwMDA5Mi0uMDAwMDA5LjAwMDAxNzQtLjAwMDAxNy4wMDAwMjY1LS4wMDAwMjRsNTcuMzUyMTAzMS01Ni4xNTUzMzNjMi40NDU1MDUtMi4zOTQ0NjMzIDYuNDEwNTQ0LTIuMzk0NTUzMSA4Ljg1NjE2MS0uMDAwMi4wMDAwMzQuMDAwMDMzNi4wMDAwNjguMDAwMDY3My4wMDAxMDEuMDAwMTAxbDU3LjM1NDkwMiA1Ni4xNTU0MzJjLjYxMTM5LjU5ODYwMSAxLjYwMjY1LjU5ODYwMSAyLjIxNDA0IDBsNTcuMzUzOTc1LTU2LjE1NDMyNDljMi40NDU1NjEtMi4zOTQ0MDkyIDYuNDEwNTk5LTIuMzk0NDA5MiA4Ljg1NjE2IDB6IiBmaWxsPSIjM2I5OWZjIi8+PC9zdmc+");At(this,"supportedTransactionVersions",new Set(["legacy",0]));At(this,"_publicKey");At(this,"_connecting");At(this,"_wallet");At(this,"_config");At(this,"_readyState");At(this,"_onDisconnect");this._publicKey=null,this._connecting=!1,this._config=t,this._wallet=null,this._readyState=typeof window>"u"?ge.Unsupported:ge.Loadable,this._onDisconnect=this.disconnect.bind(this)}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Loadable)throw new Li;this._connecting=!0,this._wallet=new Iz({network:this._config.network===Ao.Mainnet?Ba.Mainnet:Ba.Devnet,options:this._config.options});const{publicKey:t}=await this._wallet.connect();this._publicKey=t,this.emit("connect",t),this._wallet.client.on("session_delete",this._onDisconnect)}catch(t){throw t.constructor.name==="QRCodeModalError"||t instanceof Error&&t.name==="QRCodeModalError"?new Kb:(this._connecting=!1,t)}finally{this._connecting=!1}}async disconnect(){const t=this._wallet;if(t){t.client.off("session_delete",this._onDisconnect),this._publicKey=null;try{t.client.session&&await t.disconnect()}catch(i){console.error("WalletConnectWalletAdapter: disconnect error",i),this.emit("error",new ko(i==null?void 0:i.message,i))}}this.emit("disconnect")}async signTransaction(t){try{const i=this._wallet;if(!i)throw new Ge;try{return await i.signTransaction(t)}catch(r){throw new rt(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}async signMessage(t){try{const i=this._wallet;if(!i)throw new Ge;try{return await i.signMessage(t)}catch(r){throw new jo(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}async signAndSendTransaction(t){try{const i=this._wallet;if(!i)throw new Ge;try{return await i.signAndSendTransaction(t)}catch(r){throw new rt(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}async signAllTransactions(t){try{const i=this._wallet;if(!i)throw new Ge;try{return await i.signAllTransactions(t)}catch(r){throw new rt(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}}const Az={icon:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8yMDM1XzExMDYpIj4KPHJlY3Qgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIGZpbGw9IiM1NEZGRjUiLz4KPGcgZmlsdGVyPSJ1cmwoI2ZpbHRlcjBfZl8yMDM1XzExMDYpIj4KPHBhdGggZD0iTTEzLjQ4MDYgMTk4LjYwNUMtMjkuMzI3NiAzMTkuMDQzIDE5OS42NjEgMjg1LjAyNyAzMTkuNTA3IDI1Mi45NjRDNDQyLjE2NSAyMTIuMjU5IDM1Ny4zODYgMzIuODI2OSAyNjkuNDE1IDI4Ljg1NThDMTgxLjQ0MyAyNC44ODQ3IDI4MC4zMjIgMTExLjgyNCAyMDUuNTk1IDEzNi42NTZDMTMwLjg2OCAxNjEuNDg3IDY2Ljk5MDcgNDguMDU4MyAxMy40ODA2IDE5OC42MDVaIiBmaWxsPSJ3aGl0ZSIvPgo8L2c+CjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIxX2ZfMjAzNV8xMTA2KSI+CjxwYXRoIGQ9Ik04NS41MTE4IC00NS44MjI1QzYzLjA1NjIgLTEwNy4xNzYgLTE2LjkxODkgLTIzLjk5NTMgLTU0LjA5OTUgMjUuMjY0M0MtODkuNTY1MiA3OC44NDc5IDMuMDA5MzcgMTI1LjE1MiAzOS4zMjA4IDEwMC4wMzdDNzUuNjMyMyA3NC45MjI3IDcuNzc0NDggNzAuMDM2MyAyOS4zNzA4IDM3LjM3ODVDNTAuOTY3MSA0LjcyMDc2IDExMy41ODEgMzAuODY5NSA4NS41MTE4IC00NS44MjI1WiIgZmlsbD0iIzAwRkZGMCIgZmlsbC1vcGFjaXR5PSIwLjY3Ii8+CjwvZz4KPGcgZmlsdGVyPSJ1cmwoI2ZpbHRlcjJfZl8yMDM1XzExMDYpIj4KPHBhdGggZD0iTTk2LjQ3OTYgMjI1LjQyNEM2NS44NTAyIDEyMi4zNjMgLTY2LjA4MTggMTc2LjYzNyAtMTI4LjIxOSAyMTYuNjU3Qy0xODcuOTkgMjY0LjA0MiAtNDYuMDcxMSA0MDAuMzQ4IDEyLjg3MjUgMzkzLjM3NkM3MS44MTYxIDM4Ni40MDMgLTM0LjQxMTggMzI3LjA2NSAxLjk4NzAyIDI5OC4xN0MzOC4zODU4IDI2OS4yNzYgMTM0Ljc2NiAzNTQuMjQ5IDk2LjQ3OTYgMjI1LjQyNFoiIGZpbGw9IiM5RDgxRkYiLz4KPC9nPgo8ZyBmaWx0ZXI9InVybCgjZmlsdGVyM19mXzIwMzVfMTEwNikiPgo8cGF0aCBkPSJNMjgyLjEyIC0xMDcuMzUzQzIxNi4wNDcgLTE4Ni4wMzEgMTIxLjQ2MyAtMTIwLjk3IDgyLjQyOTYgLTc4LjYwNDdDNDguMjczOSAtMzAuNjQ0NiAyMjQuMjc1IDU3LjIzMTIgMjczLjEyMSA0Mi4xNzE0QzMyMS45NjggMjcuMTExNSAyMDYuNTEyIC00LjA1MDM4IDIyNy4yOTcgLTMzLjI4NzlDMjQ4LjA4MiAtNjIuNTI1NSAzNjQuNzEyIC05LjAwNTY2IDI4Mi4xMiAtMTA3LjM1M1oiIGZpbGw9IiM0RDk0RkYiLz4KPC9nPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTkzLjE4OSAxNTIuODM2SDEzNi42NzRMODcuMjA4NiAxMDMuMDUxTDEzNy4zMSA1My4yNjYzTDE1MC45NTUgNDBIMTA1LjgxOUw0OC4zMzU5IDk3Ljc3NzNDNDUuNDM0OSAxMDAuNjg5IDQ1LjQ0OTggMTA1LjQwMiA0OC4zNjU2IDEwOC4yOTlMOTMuMTg5IDE1Mi44MzZaTTExOS4zMyAxMDMuMTY4SDExOC45OTVMMTE5LjMyNiAxMDMuMTY0TDExOS4zMyAxMDMuMTY4Wk0xMTkuMzMgMTAzLjE2OEwxNjguNzkxIDE1Mi45NDlMMTE4LjY5IDIwMi43MzRMMTA1LjA0NSAyMTZIMTUwLjE4TDIwNy42NjQgMTU4LjIyNkMyMTAuNTY1IDE1NS4zMTQgMjEwLjU1IDE1MC42MDIgMjA3LjYzNCAxNDcuNzA1TDE2Mi44MTEgMTAzLjE2OEgxMTkuMzNaIiBmaWxsPSJibGFjayIvPgo8L2c+CjxkZWZzPgo8ZmlsdGVyIGlkPSJmaWx0ZXIwX2ZfMjAzNV8xMTA2IiB4PSItOTAuMjQxMSIgeT0iLTY5LjczNjkiIHdpZHRoPSI1NjkuNTU4IiBoZWlnaHQ9IjQ1MS40MzEiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIj4KPGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz4KPGZlQmxlbmQgbW9kZT0ibm9ybWFsIiBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIHJlc3VsdD0ic2hhcGUiLz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iNDkuMjMwOCIgcmVzdWx0PSJlZmZlY3QxX2ZvcmVncm91bmRCbHVyXzIwMzVfMTEwNiIvPgo8L2ZpbHRlcj4KPGZpbHRlciBpZD0iZmlsdGVyMV9mXzIwMzVfMTEwNiIgeD0iLTE2MC41MTEiIHk9Ii0xNjUuOTg3IiB3aWR0aD0iMzUxLjU5NiIgaGVpZ2h0PSIzNzEuNTA3IiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiI+CjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iQmFja2dyb3VuZEltYWdlRml4IiByZXN1bHQ9InNoYXBlIi8+CjxmZUdhdXNzaWFuQmx1ciBzdGREZXZpYXRpb249IjQ5LjIzMDgiIHJlc3VsdD0iZWZmZWN0MV9mb3JlZ3JvdW5kQmx1cl8yMDM1XzExMDYiLz4KPC9maWx0ZXI+CjxmaWx0ZXIgaWQ9ImZpbHRlcjJfZl8yMDM1XzExMDYiIHg9Ii0yNDEuMDc4IiB5PSI2Ny42NDIiIHdpZHRoPSI0NDQuODUxIiBoZWlnaHQ9IjQyNC40NTIiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIj4KPGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz4KPGZlQmxlbmQgbW9kZT0ibm9ybWFsIiBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIHJlc3VsdD0ic2hhcGUiLz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iNDkuMjMwOCIgcmVzdWx0PSJlZmZlY3QxX2ZvcmVncm91bmRCbHVyXzIwMzVfMTEwNiIvPgo8L2ZpbHRlcj4KPGZpbHRlciBpZD0iZmlsdGVyM19mXzIwMzVfMTEwNiIgeD0iLTIwLjM5NjgiIHk9Ii0yNDIuNzU4IiB3aWR0aD0iNDMwLjE5MSIgaGVpZ2h0PSIzODUuMTA1IiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiI+CjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iQmFja2dyb3VuZEltYWdlRml4IiByZXN1bHQ9InNoYXBlIi8+CjxmZUdhdXNzaWFuQmx1ciBzdGREZXZpYXRpb249IjQ5LjIzMDgiIHJlc3VsdD0iZWZmZWN0MV9mb3JlZ3JvdW5kQmx1cl8yMDM1XzExMDYiLz4KPC9maWx0ZXI+CjxjbGlwUGF0aCBpZD0iY2xpcDBfMjAzNV8xMTA2Ij4KPHJlY3Qgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIGZpbGw9IndoaXRlIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg==",name:"Bitget Wallet"},_z=[Az],Cz=s=>_z.find(e=>e.name.toLocaleLowerCase().includes(s.name.toLocaleLowerCase()))||s,Sz=(s,e,t)=>e[s]||t[s],lf=(s,e)=>Sz(s,Cz(e),e);class _i extends oe.Wallet{constructor(e,t){super(),this.adapter=e,this.connection=t}getAdapter(){return this.adapter}getName(){return lf("name",this.adapter)}getUrl(){return this.adapter.url}async connect(){if(this.isConnected())return this.getAddresses();const e=await new Promise((t,i)=>{this.adapter.on("connect",()=>{this.adapter.off("connect"),this.adapter.off("error"),t(this.getAddresses())}),this.adapter.on("error",r=>{this.adapter.off("connect"),this.adapter.off("error"),i(r)}),this.adapter.connect().catch(i)});return this.emit("connect"),this.adapter.on("disconnect",()=>this.emit("disconnect")),e}getNetworkInfo(){return{}}isConnected(){return this.adapter.connected}async disconnect(){this.isConnected()&&(await new Promise((e,t)=>{this.adapter.on("disconnect",()=>{this.adapter.off("disconnect"),this.adapter.off("error"),e(void 0)}),this.adapter.on("error",i=>{this.adapter.off("disconnect"),this.adapter.off("error"),t(i)}),this.adapter.disconnect().catch(t)}),this.adapter.removeAllListeners(),this.emit("disconnect"))}getChainId(){return oe.CHAIN_ID_SOLANA}getAddress(){var e;return(e=this.adapter.publicKey)==null?void 0:e.toString()}getAddresses(){const e=this.getAddress();return e?[e]:[]}setMainAddress(){throw new Error("Not supported")}getBalance(){throw new Error("Not supported")}async signTransaction(e){if(!this.adapter.signTransaction||!this.adapter.signAllTransactions)throw new Error("Not supported");return Array.isArray(e)?this.adapter.signAllTransactions(e):this.adapter.signTransaction(e)}async sendTransaction(e){var n;const{transaction:t}=e,i=Array.isArray(t)?t:[t];if(i.length===0)throw new Error("Empty transactions array");const r=[];for(const o of i){const a=await this.adapter.sendTransaction(o,this.connection,{...e.options});r.push(a)}return await this.connection.confirmTransaction(r[0],(n=e.options)==null?void 0:n.commitment),{id:r[0],data:r.length===1?r[0]:r}}async signAndSendTransaction(e){return this.sendTransaction(e)}signMessage(e){if(!this.adapter.signMessage)throw new Error("Not supported");return this.adapter.signMessage(e)}getIcon(){return lf("icon",this.adapter)}getWalletState(){const e=this.adapter.readyState;if(!(e in oe.WalletState))throw new Error(`Unknown wallet state ${e}`);return oe.WalletState[e]}getFeatures(){const e=[oe.BaseFeatures.SendTransaction,oe.BaseFeatures.SignAndSendTransaction];return this.adapter.signTransaction&&this.adapter.signAllTransactions&&e.push(oe.BaseFeatures.SignTransaction),this.adapter.signMessage&&e.push(oe.BaseFeatures.SignMessage),e}supportsChain(e){return e===oe.CHAIN_ID_SOLANA}}function Tz(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let l=0;l<e.length;l++)e[l]=255;for(let l=0;l<s.length;l++){const h=s.charAt(l),d=h.charCodeAt(0);if(e[d]!==255)throw new TypeError(h+" is ambiguous");e[d]=l}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";let h=0,d=0,p=0;const f=l.length;for(;p!==f&&l[p]===0;)p++,h++;const g=(f-p)*n+1>>>0,y=new Uint8Array(g);for(;p!==f;){let w=l[p],N=0;for(let _=g-1;(w!==0||N<d)&&_!==-1;_--,N++)w+=256*y[_]>>>0,y[_]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");d=N,p++}let v=g-d;for(;v!==g&&y[v]===0;)v++;let b=i.repeat(h);for(;v<g;++v)b+=s.charAt(y[v]);return b}function a(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;let h=0,d=0,p=0;for(;l[h]===i;)d++,h++;const f=(l.length-h)*r+1>>>0,g=new Uint8Array(f);for(;h<l.length;){const w=l.charCodeAt(h);if(w>255)return;let N=e[w];if(N===255)return;let _=0;for(let C=f-1;(N!==0||_<p)&&C!==-1;C--,_++)N+=t*g[C]>>>0,g[C]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");p=_,h++}let y=f-p;for(;y!==f&&g[y]===0;)y++;const v=new Uint8Array(d+(f-y));let b=d;for(;y!==f;)v[b++]=g[y++];return v}function c(l){const h=a(l);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var Pz="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const $z=Tz(Pz);var J=function(s,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!i:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(s):i?i.value:e.get(s)},lt=function(s,e,t,i,r){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?r.call(s,t):r?r.value=t:e.set(s,t),t},xt,es,ar,cr,er,go,oc,Ce,ac,Sh,qa,Th,No,Ph,hf,uf,df,pf;class Mz extends yf{get name(){return J(this,Ce,"f").name}get url(){return"https://github.com/solana-labs/wallet-standard"}get icon(){return J(this,Ce,"f").icon}get readyState(){return J(this,ac,"f")}get publicKey(){return J(this,ar,"f")}get connecting(){return J(this,cr,"f")}get supportedTransactionVersions(){return J(this,oc,"f")}get wallet(){return J(this,Ce,"f")}get standard(){return!0}constructor({wallet:e}){super(),xt.add(this),es.set(this,void 0),ar.set(this,void 0),cr.set(this,void 0),er.set(this,void 0),go.set(this,void 0),oc.set(this,void 0),Ce.set(this,void 0),ac.set(this,typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.Installed),Ph.set(this,t=>{if("accounts"in t){const i=J(this,Ce,"f").accounts[0];J(this,es,"f")&&!J(this,er,"f")&&i!==J(this,es,"f")&&(i?J(this,xt,"m",qa).call(this,i):(this.emit("error",new ff),J(this,xt,"m",Th).call(this)))}"features"in t&&J(this,xt,"m",No).call(this)}),lt(this,Ce,e,"f"),lt(this,es,null,"f"),lt(this,ar,null,"f"),lt(this,cr,!1,"f"),lt(this,er,!1,"f"),lt(this,go,J(this,Ce,"f").features[mf].on("change",J(this,Ph,"f")),"f"),J(this,xt,"m",No).call(this)}destroy(){lt(this,es,null,"f"),lt(this,ar,null,"f"),lt(this,cr,!1,"f"),lt(this,er,!1,"f");const e=J(this,go,"f");e&&(lt(this,go,null,"f"),e())}async autoConnect(){return J(this,xt,"m",Sh).call(this,{silent:!0})}async connect(){return J(this,xt,"m",Sh).call(this)}async disconnect(){if($u in J(this,Ce,"f").features)try{lt(this,er,!0,"f"),await J(this,Ce,"f").features[$u].disconnect()}catch(e){this.emit("error",new ko(e==null?void 0:e.message,e))}finally{lt(this,er,!1,"f")}J(this,xt,"m",Th).call(this)}async sendTransaction(e,t,i={}){try{const r=J(this,es,"f");if(!r)throw new Ge;let n;if(Pi in J(this,Ce,"f").features)if(r.features.includes(Pi))n=Pi;else if(Mt in J(this,Ce,"f").features&&r.features.includes(Mt))n=Mt;else throw new Ns;else if(Mt in J(this,Ce,"f").features){if(!r.features.includes(Mt))throw new Ns;n=Mt}else throw new un;const o=pv(t.rpcEndpoint);if(!r.chains.includes(o))throw new rr;try{const{signers:a,...c}=i;let l;if(ui(e)?(a!=null&&a.length&&e.sign(a),l=e.serialize()):(e=await this.prepareTransaction(e,t,c),a!=null&&a.length&&e.partialSign(...a),l=new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))),n===Pi){const[h]=await J(this,Ce,"f").features[Pi].signAndSendTransaction({account:r,chain:o,transaction:l,options:{preflightCommitment:Dc(c.preflightCommitment||t.commitment),skipPreflight:c.skipPreflight,maxRetries:c.maxRetries,minContextSlot:c.minContextSlot}});return $z.encode(h.signature)}else{const[h]=await J(this,Ce,"f").features[Mt].signTransaction({account:r,chain:o,transaction:l,options:{preflightCommitment:Dc(c.preflightCommitment||t.commitment),minContextSlot:c.minContextSlot}});return await t.sendRawTransaction(h.signedTransaction,{...c,preflightCommitment:Dc(c.preflightCommitment||t.commitment)})}}catch(a){throw a instanceof Dt?a:new rr(a==null?void 0:a.message,a)}}catch(r){throw this.emit("error",r),r}}}es=new WeakMap,ar=new WeakMap,cr=new WeakMap,er=new WeakMap,go=new WeakMap,oc=new WeakMap,Ce=new WeakMap,ac=new WeakMap,Ph=new WeakMap,xt=new WeakSet,Sh=async function(e){try{if(this.connected||this.connecting)return;if(J(this,ac,"f")!==ge.Installed)throw new Li;if(lt(this,cr,!0,"f"),!J(this,Ce,"f").accounts.length)try{await J(this,Ce,"f").features[wf].connect(e)}catch(i){throw new cc(i==null?void 0:i.message,i)}const t=J(this,Ce,"f").accounts[0];if(!t)throw new Ns;J(this,xt,"m",qa).call(this,t)}catch(t){throw this.emit("error",t),t}finally{lt(this,cr,!1,"f")}},qa=function(e){let t;try{t=new A.PublicKey(e.address)}catch(i){throw new yr(i==null?void 0:i.message,i)}lt(this,es,e,"f"),lt(this,ar,t,"f"),J(this,xt,"m",No).call(this),this.emit("connect",t)},Th=function(){lt(this,es,null,"f"),lt(this,ar,null,"f"),J(this,xt,"m",No).call(this),this.emit("disconnect")},No=function(){var t,i;const e=Pi in J(this,Ce,"f").features?J(this,Ce,"f").features[Pi].supportedTransactionVersions:J(this,Ce,"f").features[Mt].supportedTransactionVersions;lt(this,oc,Hb.arraysEqual(e,["legacy"])?null:new Set(e),"f"),Mt in J(this,Ce,"f").features&&((t=J(this,es,"f"))!=null&&t.features.includes(Mt))?(this.signTransaction=J(this,xt,"m",hf),this.signAllTransactions=J(this,xt,"m",uf)):(delete this.signTransaction,delete this.signAllTransactions),Ln in J(this,Ce,"f").features&&((i=J(this,es,"f"))!=null&&i.features.includes(Ln))?this.signMessage=J(this,xt,"m",df):delete this.signMessage,xc in J(this,Ce,"f").features?this.signIn=J(this,xt,"m",pf):delete this.signIn},hf=async function(e){try{const t=J(this,es,"f");if(!t)throw new Ge;if(!(Mt in J(this,Ce,"f").features))throw new un;if(!t.features.includes(Mt))throw new Ns;try{const r=(await J(this,Ce,"f").features[Mt].signTransaction({account:t,transaction:ui(e)?e.serialize():new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))}))[0].signedTransaction;return ui(e)?A.VersionedTransaction.deserialize(r):A.Transaction.from(r)}catch(i){throw i instanceof Dt?i:new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}},uf=async function(e){try{const t=J(this,es,"f");if(!t)throw new Ge;if(!(Mt in J(this,Ce,"f").features))throw new un;if(!t.features.includes(Mt))throw new Ns;try{const i=await J(this,Ce,"f").features[Mt].signTransaction(...e.map(r=>({account:t,transaction:ui(r)?r.serialize():new Uint8Array(r.serialize({requireAllSignatures:!1,verifySignatures:!1}))})));return e.map((r,n)=>{const o=i[n].signedTransaction;return ui(r)?A.VersionedTransaction.deserialize(o):A.Transaction.from(o)})}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}},df=async function(e){try{const t=J(this,es,"f");if(!t)throw new Ge;if(!(Ln in J(this,Ce,"f").features))throw new un;if(!t.features.includes(Ln))throw new Ns;try{return(await J(this,Ce,"f").features[Ln].signMessage({account:t,message:e}))[0].signature}catch(i){throw new jo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}},pf=async function(e={}){try{if(!(xc in J(this,Ce,"f").features))throw new un;let t;try{[t]=await J(this,Ce,"f").features[xc].signIn(e)}catch(i){throw new Pu(i==null?void 0:i.message,i)}if(!t)throw new Pu;return J(this,xt,"m",qa).call(this,t.account),t}catch(t){throw this.emit("error",t),t}};function xz(s){return Wb.getWallets().get().filter(Gb).map(e=>new _i(new Mz({wallet:e}),s))}function Oz(s){return s.includes("rpcpool.com")?"triton":s.includes("helius-rpc.com")?"helius":s.includes("rpc.ankr.com")?"ankr":"unknown"}async function Dz(s,e,t,i){const r=i.transaction.transaction,n=o=>o.programId.toString()!=="ComputeBudget111111111111111111111111111111";if(xa.isVersionedTransaction(r)){const o=(await Promise.all(r.message.addressTableLookups.map(c=>s.getAddressLookupTable(c.accountKey)))).map(c=>c.value).filter(c=>c!==null),a=A.TransactionMessage.decompile(r.message,{addressLookupTableAccounts:o});a.recentBlockhash=e,r.message.recentBlockhash=e,a.instructions=a.instructions.filter(n),r.message=a.compileToV0Message(o),a.instructions.push(...await gf(s,r)),r.message=a.compileToV0Message(o),r.sign(i.transaction.signers??[])}else r.recentBlockhash=e,r.lastValidBlockHeight=t,r.instructions=r.instructions.filter(n),r.add(...await gf(s,r)),i.transaction.signers&&r.partialSign(...i.transaction.signers);return r}async function gf(s,e,t){var N,_;let i=2e5,r=0;const n=A.ComputeBudgetProgram.setComputeUnitLimit({units:3e5});let o;if(xa.isVersionedTransaction(e)){const C=(await Promise.all(e.message.addressTableLookups.map(P=>s.getAddressLookupTable(P.accountKey)))).map(P=>P.value).filter(P=>P!==null),T=A.TransactionMessage.decompile(e.message,{addressLookupTableAccounts:C});T.instructions=[n,...T.instructions],o=new A.VersionedTransaction(T.compileToV0Message(C)),o.signatures=[...e.signatures]}else{const C=new A.Transaction;C.recentBlockhash=e.recentBlockhash,C.feePayer=e.feePayer,C.instructions=[n,...e.instructions],C.signatures=[...e.signatures],o=C}e:for(;;){if(xa.isVersionedTransaction(o)&&!o.message.recentBlockhash){const{blockhash:T}=await s.getLatestBlockhash(t);o.message.recentBlockhash=T}const C=await(xa.isVersionedTransaction(o)?s.simulateTransaction(o,{commitment:t,replaceRecentBlockhash:!0}):s.simulateTransaction(o));if(C.value.err){if(kz(C.value)){if(r<5){r++,await oe.sleep(1e3);continue e}}else if(r<3){r++,await oe.sleep(1e3);continue e}throw new Error(`Simulation failed: ${JSON.stringify(C.value.err)}
897
+ `,Ma={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603};function ea(s){return{formatters:void 0,fees:void 0,serializers:void 0,...s}}const _h=ea({id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!1,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",deprecatedCaipNetworkId:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"}),Ch=ea({id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",deprecatedCaipNetworkId:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"}),cz=ea({id:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",network:"solana-testnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"});ea({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});ea({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0});const lz={solana:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"],eip155:["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_showCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"],bip122:["sendTransfer","signMessage","signPsbt","getAccountAddresses"]},Mm={getMethodsByChainNamespace(s){return lz[s]||[]},createDefaultNamespace(s){return{methods:this.getMethodsByChainNamespace(s),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(s,e){if(!e)return{...s};const t={...s},i=new Set;if(e.methods&&Object.keys(e.methods).forEach(r=>i.add(r)),e.chains&&Object.keys(e.chains).forEach(r=>i.add(r)),e.events&&Object.keys(e.events).forEach(r=>i.add(r)),e.rpcMap&&Object.keys(e.rpcMap).forEach(r=>{const[n]=r.split(":");n&&i.add(n)}),i.forEach(r=>{t[r]||(t[r]=this.createDefaultNamespace(r))}),e.methods&&Object.entries(e.methods).forEach(([r,n])=>{t[r]&&(t[r].methods=n)}),e.chains&&Object.entries(e.chains).forEach(([r,n])=>{t[r]&&(t[r].chains=n)}),e.events&&Object.entries(e.events).forEach(([r,n])=>{t[r]&&(t[r].events=n)}),e.rpcMap){const r=new Set;Object.entries(e.rpcMap).forEach(([n,o])=>{const[a,c]=n.split(":");!a||!c||!t[a]||(t[a].rpcMap||(t[a].rpcMap={}),r.has(a)||(t[a].rpcMap={},r.add(a)),t[a].rpcMap[c]=o)})}return t},createNamespaces(s,e){const t=s.reduce((i,r)=>{const{id:n,chainNamespace:o,rpcUrls:a}=r,c=a.default.http[0];i[o]||(i[o]=this.createDefaultNamespace(o));const l=`${o}:${n}`,h=i[o];switch(h.chains.push(l),l){case _h.caipNetworkId:h.chains.push(_h.deprecatedCaipNetworkId);break;case Ch.caipNetworkId:h.chains.push(Ch.deprecatedCaipNetworkId);break}return h!=null&&h.rpcMap&&c&&(h.rpcMap[n]=c),i},{});return this.applyNamespaceOverrides(t,e)},resolveReownName:async s=>{var i;const e=await ow.resolveName(s);return((i=(Object.values(e==null?void 0:e.addresses)||[])[0])==null?void 0:i.address)||!1},getChainsFromNamespaces(s={}){return Object.values(s).flatMap(e=>{const t=e.chains||[],i=e.accounts.map(r=>{const[n,o]=r.split(":");return`${n}:${o}`});return Array.from(new Set([...t,...i]))})},isSessionEventData(s){return typeof s=="object"&&s!==null&&"id"in s&&"topic"in s&&"params"in s&&typeof s.params=="object"&&s.params!==null&&"chainId"in s.params&&"event"in s.params&&typeof s.params.event=="object"&&s.params.event!==null}};class xm{constructor({provider:e,caipNetworks:t,namespace:i}){this.id=se.CONNECTOR_ID.WALLET_CONNECT,this.name=sc.ConnectorNamesMap[se.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=sc.ConnectorImageIds[se.CONNECTOR_ID.WALLET_CONNECT],this.caipNetworks=t,this.provider=e,this.chain=i}get chains(){return this.caipNetworks}async connectWalletConnect(){if(!await this.authenticate()){const t=R.state.universalProviderConfigOverride,i=Mm.createNamespaces(this.caipNetworks,t);await this.provider.connect({optionalNamespaces:i})}return{clientId:await this.provider.client.core.crypto.getClientId(),session:this.provider.session}}async disconnect(){await this.provider.disconnect()}async authenticate(){const e=this.chains.map(t=>t.caipNetworkId);return mn.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:hz})}}const hz=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"];class uz{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,e&&this.construct(e)}construct(e){this.caipNetworks=e.networks,this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get networks(){return this.caipNetworks||[]}setAuthProvider(e){this.addConnector({id:se.CONNECTOR_ID.AUTH,type:"AUTH",name:se.CONNECTOR_NAMES.AUTH,provider:e,imageId:sc.ConnectorImageIds[se.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const t=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter(i=>t.has(i.id)?!1:(t.add(i.id),!0)),this.emit("connectors",this.availableConnectors)}setStatus(e,t){ie.setStatus(e,t)}on(e,t){var i;this.eventListeners.has(e)||this.eventListeners.set(e,new Set),(i=this.eventListeners.get(e))==null||i.add(t)}off(e,t){const i=this.eventListeners.get(e);i&&i.delete(t)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,t){const i=this.eventListeners.get(e);i&&i.forEach(r=>r(t))}async connectWalletConnect(e){return{clientId:(await this.getWalletConnectConnector().connectWalletConnect()).clientId}}async switchNetwork(e){const{caipNetwork:t,providerType:i}=e;if(!e.provider)return;const r="provider"in e.provider?e.provider.provider:e.provider;if(i==="WALLET_CONNECT"){r.setDefaultChain(t.caipNetworkId);return}if(r&&i==="AUTH"){const n=r;await n.switchNetwork(t.caipNetworkId);const o=await n.getUser({chainId:t.caipNetworkId,preferredAccountType:R.state.defaultAccountTypes[t.chainNamespace]});this.emit("switchNetwork",o)}}getWalletConnectConnector(){const e=this.connectors.find(t=>t instanceof xm);if(!e)throw new Error("WalletConnectConnector not found");return e}}class dz extends uz{setUniversalProvider(e){this.addConnector(new xm({provider:e,caipNetworks:this.caipNetworks||[],namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){var r,n,o,a;const t=this.provider,i=((a=(o=(n=(r=t==null?void 0:t.session)==null?void 0:r.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const[,,l]=c.split(":");return l}).filter((c,l,h)=>h.indexOf(c)===l))||[];return Promise.resolve({accounts:i.map(c=>he.createAccount(e,c,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var n,o,a,c,l;if(!(e.caipNetwork&&Vt.BALANCE_SUPPORTED_CHAINS.includes((n=e.caipNetwork)==null?void 0:n.chainNamespace))||(o=e.caipNetwork)!=null&&o.testnet)return{balance:"0.00",symbol:((a=e.caipNetwork)==null?void 0:a.nativeCurrency.symbol)||""};if(ie.state.balanceLoading&&e.chainId===((c=I.state.activeCaipNetwork)==null?void 0:c.id))return{balance:ie.state.balance||"0.00",symbol:ie.state.balanceSymbol||""};const r=(await ie.fetchTokenBalance()).find(h=>{var d,p;return h.chainId===`${(d=e.caipNetwork)==null?void 0:d.chainNamespace}:${e.chainId}`&&h.symbol===((p=e.caipNetwork)==null?void 0:p.nativeCurrency.symbol)});return{balance:(r==null?void 0:r.quantity.numeric)||"0.00",symbol:(r==null?void 0:r.symbol)||((l=e.caipNetwork)==null?void 0:l.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:t,message:i,address:r}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=I.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===se.CHAIN.SOLANA?n=(await t.request({method:"solana_signMessage",params:{message:Iw.encode(new TextEncoder().encode(i)),pubkey:r}},(a=I.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await t.request({method:"personal_sign",params:[i,r]},(c=I.state.activeCaipNetwork)==null?void 0:c.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async getProfile(){return Promise.resolve({profileImage:"",profileName:""})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}async getEnsAddress(){return Promise.resolve({address:!1})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var r,n,o,a,c,l;const{caipNetwork:t}=e,i=this.getWalletConnectConnector();if(t.chainNamespace===se.CHAIN.EVM)try{await((r=i.provider)==null?void 0:r.request({method:"wallet_switchEthereumChain",params:[{chainId:yn.toHex(t.id)}]}))}catch(h){if(h.code===Ma.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||h.code===Ma.ERROR_INVALID_CHAIN_ID||h.code===Ma.ERROR_CODE_DEFAULT||((o=(n=h==null?void 0:h.data)==null?void 0:n.originalError)==null?void 0:o.code)===Ma.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=i.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:yn.toHex(t.id),rpcUrls:[(a=t==null?void 0:t.rpcUrls.chainDefault)==null?void 0:a.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[(c=t.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}i.provider.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(i=>i.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}class pz{constructor(e){var t;this.hasSwitchedToPreferredAccountTypeOnConnect=!1,this.chainNamespaces=[],this.reportedAlertErrors={},this.getCaipNetwork=i=>{var r,n;if(i){const o=(r=I.getNetworkData(i))==null?void 0:r.caipNetwork;return o||((n=I.getRequestedCaipNetworks(i).filter(a=>a.chainNamespace===i))==null?void 0:n[0])}return I.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const i=this.getCaipNetwork();if(i)return i.id},this.getCaipNetworks=i=>I.getRequestedCaipNetworks(i),this.getActiveChainNamespace=()=>I.state.activeChain,this.setRequestedCaipNetworks=(i,r)=>{I.setRequestedCaipNetworks(i,r)},this.getApprovedCaipNetworkIds=()=>I.getAllApprovedCaipNetworkIds(),this.getCaipAddress=i=>I.state.activeChain===i||!i?I.state.activeCaipAddress:I.getAccountProp("caipAddress",i),this.setClientId=i=>{ne.setClientId(i)},this.getProvider=i=>tt.getProvider(i),this.getProviderType=i=>tt.getProviderId(i),this.getPreferredAccountType=()=>ie.state.preferredAccountType,this.setCaipAddress=(i,r)=>{ie.setCaipAddress(i,r)},this.setBalance=(i,r,n)=>{ie.setBalance(i,r,n)},this.setProfileName=(i,r)=>{ie.setProfileName(i,r)},this.setProfileImage=(i,r)=>{ie.setProfileImage(i,r)},this.setUser=(i,r)=>{ie.setUser(i,r),R.state.enableEmbedded&&ot.close()},this.resetAccount=i=>{ie.resetAccount(i)},this.setCaipNetwork=i=>{I.setActiveCaipNetwork(i)},this.setCaipNetworkOfNamespace=(i,r)=>{I.setChainNetworkData(r,{caipNetwork:i})},this.setAllAccounts=(i,r)=>{ie.setAllAccounts(i,r),R.setHasMultipleAddresses((i==null?void 0:i.length)>1)},this.setStatus=(i,r)=>{ie.setStatus(i,r),le.isConnected()?X.setConnectionStatus("connected"):X.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=i=>I.getAccountProp("address",i),this.setConnectors=i=>{const r=[...le.getConnectors(),...i];le.setConnectors(r)},this.fetchIdentity=i=>ne.fetchIdentity(i),this.getReownName=i=>ow.getNamesForAddress(i),this.getConnectors=()=>le.getConnectors(),this.getConnectorImage=i=>Kh.getConnectorImage(i),this.setConnectedWalletInfo=(i,r)=>{const n=tt.getProviderId(r),o=i?{...i,type:n}:void 0;ie.setConnectedWalletInfo(o,r)},this.getIsConnectedState=()=>!!I.state.activeCaipAddress,this.addAddressLabel=(i,r,n)=>{ie.addAddressLabel(i,r,n)},this.removeAddressLabel=(i,r)=>{ie.removeAddressLabel(i,r)},this.getAddress=i=>I.state.activeChain===i||!i?ie.state.address:I.getAccountProp("address",i),this.setApprovedCaipNetworksData=i=>I.setApprovedCaipNetworksData(i),this.resetNetwork=i=>{I.resetNetwork(i)},this.addConnector=i=>{le.addConnector(i)},this.resetWcConnection=()=>{qe.resetWcConnection()},this.setAddressExplorerUrl=(i,r)=>{ie.setAddressExplorerUrl(i,r)},this.setSmartAccountDeployed=(i,r)=>{ie.setSmartAccountDeployed(i,r)},this.setSmartAccountEnabledNetworks=(i,r)=>{I.setSmartAccountEnabledNetworks(i,r)},this.setPreferredAccountType=(i,r)=>{ie.setPreferredAccountType(i,r)},this.setEIP6963Enabled=i=>{R.setEIP6963Enabled(i)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=[...new Set((t=this.caipNetworks)==null?void 0:t.map(i=>i.chainNamespace))],this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.initialize(e),this.sendInitializeEvent(e)}async initialize(e){this.initControllers(e),await this.initChainAdapters(),await this.injectModalUi(),await this.syncExistingConnection(),pi.set({initialized:!0})}sendInitializeEvent(e){var i;const{...t}=e;delete t.adapters,Be.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map(r=>r.id),siweConfig:{options:((i=e.siweConfig)==null?void 0:i.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&Ft.setThemeMode(e.themeMode),e.themeVariables&&Ft.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");I.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const t=this.getDefaultNetwork();t&&I.setActiveCaipNetwork(t)}initializeConnectionController(e){qe.setWcBasic(e.basic??!1)}initializeConnectorController(){le.initialize(this.chainNamespaces)}initializeOptionsController(e){var r;R.setDebug(e.debug!==!1),R.setEnableWalletConnect(e.enableWalletConnect!==!1),R.setEnableWalletGuide(e.enableWalletGuide!==!1),R.setEnableWallets(e.enableWallets!==!1),R.setEIP6963Enabled(e.enableEIP6963!==!1),R.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),R.setEnableAuthLogger(e.enableAuthLogger!==!1),R.setCustomRpcUrls(e.customRpcUrls),R.setSdkVersion(e.sdkVersion),R.setProjectId(e.projectId),R.setEnableEmbedded(e.enableEmbedded),R.setAllWallets(e.allWallets),R.setIncludeWalletIds(e.includeWalletIds),R.setExcludeWalletIds(e.excludeWalletIds),R.setFeaturedWalletIds(e.featuredWalletIds),R.setTokens(e.tokens),R.setTermsConditionsUrl(e.termsConditionsUrl),R.setPrivacyPolicyUrl(e.privacyPolicyUrl),R.setCustomWallets(e.customWallets),R.setFeatures(e.features),R.setAllowUnsupportedChain(e.allowUnsupportedChain),R.setDefaultAccountTypes(e.defaultAccountTypes),R.setUniversalProviderConfigOverride(e.universalProviderConfigOverride);const t=this.getDefaultMetaData();if(!e.metadata&&t&&(e.metadata=t),R.setMetadata(e.metadata),R.setDisableAppend(e.disableAppend),R.setEnableEmbedded(e.enableEmbedded),R.setSIWX(e.siwx),!e.projectId){wo.open($a.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((r=e.adapters)==null?void 0:r.find(n=>n.namespace===se.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");R.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,t,i,r;return typeof window<"u"&&typeof document<"u"?{name:((t=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:t.textContent)||"",description:((i=document.querySelector('meta[property="og:description"]'))==null?void 0:i.content)||"",url:window.location.origin,icons:[((r=document.querySelector('link[rel~="icon"]'))==null?void 0:r.href)||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const i=hn.getUnsupportedNetwork(`${t}:${e}`);I.setActiveCaipNetwork(i)}}getDefaultNetwork(){return hn.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return hn.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return hn.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(r=>{var n;return r.id===((n=e.defaultNetwork)==null?void 0:n.id)});return t?hn.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var n;const e=I.state.activeChain,t=this.getAdapter(e),i=(n=this.getCaipNetwork(e))==null?void 0:n.id;if(!t)throw new Error("Adapter not found");const r=await t.connectWalletConnect(i);this.close(),this.setClientId((r==null?void 0:r.clientId)||null),X.setConnectedNamespaces([...I.state.chains.keys()]),this.chainNamespaces.forEach(o=>{le.setConnectorId(Ai.CONNECTOR_TYPE_WALLET_CONNECT,o)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:t,type:i,provider:r,chain:n,caipNetwork:o})=>{var f,g,y,v,b,w,N;const a=I.state.activeChain,c=n||a,l=this.getAdapter(c);if(n&&n!==a&&!o){const _=(f=this.caipNetworks)==null?void 0:f.find(C=>C.chainNamespace===n);_&&this.setCaipNetwork(_)}if(!l)throw new Error("Adapter not found");const h=this.getCaipNetwork(c),d=await l.connect({id:e,info:t,type:i,provider:r,chainId:(o==null?void 0:o.id)||(h==null?void 0:h.id),rpcUrl:((v=(y=(g=o==null?void 0:o.rpcUrls)==null?void 0:g.default)==null?void 0:y.http)==null?void 0:v[0])||((N=(w=(b=h==null?void 0:h.rpcUrls)==null?void 0:b.default)==null?void 0:w.http)==null?void 0:N[0])});if(!d)return;X.addConnectedNamespace(c),this.syncProvider({...d,chainNamespace:c}),await this.syncAccount({...d,chainNamespace:c});const{accounts:p}=await l.getAccounts({namespace:c,id:e});this.setAllAccounts(p,c)},reconnectExternal:async({id:e,info:t,type:i,provider:r})=>{var a;const n=I.state.activeChain,o=this.getAdapter(n);o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:t,type:i,provider:r,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),X.addConnectedNamespace(n))},disconnect:async e=>{const t=e||I.state.activeChain,i=this.getAdapter(t),r=tt.getProvider(t),n=tt.getProviderId(t);await(i==null?void 0:i.disconnect({provider:r,providerType:n})),X.removeConnectedNamespace(t),tt.resetChain(t),this.setUser(void 0,t),this.setStatus("disconnected",t),this.hasSwitchedToPreferredAccountTypeOnConnect=!1},checkInstalled:e=>e?e.some(t=>{var i;return!!((i=window.ethereum)!=null&&i[String(t)])}):!!window.ethereum,signMessage:async e=>{const t=this.getAdapter(I.state.activeChain),i=await(t==null?void 0:t.signMessage({message:e,address:ie.state.address,provider:tt.getProvider(I.state.activeChain)}));return(i==null?void 0:i.signature)||""},sendTransaction:async e=>{if(e.chainNamespace===se.CHAIN.EVM){const t=this.getAdapter(I.state.activeChain),i=tt.getProvider(I.state.activeChain),r=await(t==null?void 0:t.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:i}));return(r==null?void 0:r.hash)||""}return""},estimateGas:async e=>{if(e.chainNamespace===se.CHAIN.EVM){const t=this.getAdapter(I.state.activeChain),i=tt.getProvider(I.state.activeChain),r=this.getCaipNetwork();if(!r)throw new Error("CaipNetwork is undefined");const n=await(t==null?void 0:t.estimateGas({...e,provider:i,caipNetwork:r}));return(n==null?void 0:n.gas)||0n}return 0n},getEnsAvatar:async()=>{var i;const e=this.getAdapter(I.state.activeChain),t=await(e==null?void 0:e.getProfile({address:ie.state.address,chainId:Number((i=this.getCaipNetwork())==null?void 0:i.id)}));return(t==null?void 0:t.profileImage)||!1},getEnsAddress:async e=>{const t=this.getAdapter(I.state.activeChain),i=this.getCaipNetwork();if(!i)return!1;const r=await(t==null?void 0:t.getEnsAddress({name:e,caipNetwork:i}));return(r==null?void 0:r.address)||!1},writeContract:async e=>{const t=this.getAdapter(I.state.activeChain),i=this.getCaipNetwork(),r=this.getCaipAddress(),n=tt.getProvider(I.state.activeChain);if(!i||!r)throw new Error("CaipNetwork or CaipAddress is undefined");const o=await(t==null?void 0:t.writeContract({...e,caipNetwork:i,provider:n,caipAddress:r}));return o==null?void 0:o.hash},parseUnits:(e,t)=>{const i=this.getAdapter(I.state.activeChain);return(i==null?void 0:i.parseUnits({value:e,decimals:t}))??0n},formatUnits:(e,t)=>{const i=this.getAdapter(I.state.activeChain);return(i==null?void 0:i.formatUnits({value:e,decimals:t}))??"0"},getCapabilities:async e=>{const t=this.getAdapter(I.state.activeChain);return await(t==null?void 0:t.getCapabilities(e))},grantPermissions:async e=>{const t=this.getAdapter(I.state.activeChain);return await(t==null?void 0:t.grantPermissions(e))},revokePermissions:async e=>{const t=this.getAdapter(I.state.activeChain);return t!=null&&t.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter(I.state.activeChain);return await(t==null?void 0:t.walletGetAssets(e))??{}}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},qe.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){var t,i,r,n,o;if(tt.getProviderId(I.state.activeChain)===Ai.CONNECTOR_TYPE_WALLET_CONNECT){const a=(i=(t=this.universalProvider)==null?void 0:t.session)==null?void 0:i.namespaces;return{supportsAllNetworks:((o=(n=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:n.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=tt.getProvider(t),n=tt.getProviderId(t);if(e.chainNamespace===I.state.activeChain){const o=this.getAdapter(t);await(o==null?void 0:o.switchNetwork({caipNetwork:e,provider:r,providerType:n}))}else if(this.setCaipNetwork(e),n===Ai.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const o=this.getAddressByChainNamespace(t);o&&this.syncAccount({address:o,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(t=>{const i=t.chains||[],r=t.accounts.map(n=>{const{chainId:o,chainNamespace:a}=vi.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...i,...r]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,i)=>{var n;const r=e==null?void 0:e.find(o=>o.namespace===i);return r?(t[i]=r,t[i].namespace=i,t[i].construct({namespace:i,projectId:(n=this.options)==null?void 0:n.projectId,networks:this.caipNetworks})):t[i]=new dz({namespace:i,networks:this.caipNetworks}),t},{})}async initChainAdapter(e){var t;this.onConnectors(e),this.listenAdapter(e),(t=this.chainAdapters)==null||t[e].syncConnectors(this.options,this),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){const t=this.getAdapter(e);t==null||t.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const i=X.getConnectionStatus();i==="connected"?this.setStatus("connecting",e):i==="disconnected"?(X.clearAddressCache(),this.setStatus(i,e)):this.setStatus(i,e),t.on("switchNetwork",({address:r,chainId:n})=>{var l;const o=(l=this.caipNetworks)==null?void 0:l.find(h=>h.id===n||h.caipNetworkId===n),a=I.state.activeChain===e,c=I.getAccountProp("address",e);if(o){const h=a&&r?r:c;h&&this.syncAccount({address:h,chainId:n,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),t.on("disconnect",this.disconnect.bind(this,e)),t.on("pendingTransactions",()=>{const r=ie.state.address,n=I.state.activeCaipNetwork;!r||!(n!=null&&n.id)||this.updateNativeBalance(r,n.id,n.chainNamespace)}),t.on("accountChanged",({address:r,chainId:n})=>{var a,c;const o=I.state.activeChain===e;o&&n?this.syncAccount({address:r,chainId:n,chainNamespace:e}):o&&((a=I.state.activeCaipNetwork)!=null&&a.id)?this.syncAccount({address:r,chainId:(c=I.state.activeCaipNetwork)==null?void 0:c.id,chainNamespace:e}):this.syncAccountInfo(r,n,e)})}async createUniversalProviderForAdapter(e){var t,i,r;await this.getUniversalProvider(),this.universalProvider&&((r=(i=(t=this.chainAdapters)==null?void 0:t[e])==null?void 0:i.setUniversalProvider)==null||r.call(i,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{const t=le.getConnectorId(e);switch(this.setStatus("connecting",e),t){case se.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case se.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}async syncAdapterConnection(e){var o,a,c;const t=this.getAdapter(e),i=le.getConnectorId(e),r=this.getCaipNetwork(e),n=le.getConnectors(e).find(l=>l.id===i);try{if(!t||!n)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(r!=null&&r.id))throw new Error("CaipNetwork not found");const l=await(t==null?void 0:t.syncConnection({namespace:e,id:n.id,chainId:r.id,rpcUrl:(c=(a=(o=r==null?void 0:r.rpcUrls)==null?void 0:o.default)==null?void 0:a.http)==null?void 0:c[0]}));if(l){const h=await(t==null?void 0:t.getAccounts({namespace:e,id:n.id}));h&&h.accounts.length>0?this.setAllAccounts(h.accounts,e):this.setAllAccounts([he.createAccount(e,l.address,"eoa")],e),this.syncProvider({...l,chainNamespace:e}),await this.syncAccount({...l,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch{this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async t=>{var a,c,l,h,d;const i=this.getAdapter(t),r=((h=(l=(c=(a=this.universalProvider)==null?void 0:a.session)==null?void 0:c.namespaces)==null?void 0:l[t])==null?void 0:h.accounts)||[],n=(d=I.state.activeCaipNetwork)==null?void 0:d.id,o=r.find(p=>{const{chainId:f}=vi.parseCaipAddress(p);return f===(n==null?void 0:n.toString())})||r[0];if(o){const p=vi.validateCaipAddress(o),{chainId:f,address:g}=vi.parseCaipAddress(p);if(tt.setProviderId(t,Ai.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&I.state.activeCaipNetwork&&(i==null?void 0:i.namespace)!==se.CHAIN.EVM){const y=i==null?void 0:i.getWalletConnectProvider({caipNetworks:this.caipNetworks,provider:this.universalProvider,activeCaipNetwork:I.state.activeCaipNetwork});tt.setProvider(t,y)}else tt.setProvider(t,this.universalProvider);le.setConnectorId(se.CONNECTOR_ID.WALLET_CONNECT,t),X.addConnectedNamespace(t),this.syncWalletConnectAccounts(t),await this.syncAccount({address:g,chainId:f,chainNamespace:t})}else this.setStatus("disconnected",t);await I.setApprovedCaipNetworksData(t)});await Promise.all(e)}syncWalletConnectAccounts(e){var i,r,n,o,a;const t=(a=(o=(n=(r=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:r.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const{address:l}=vi.parseCaipAddress(c);return l}).filter((c,l,h)=>h.indexOf(c)===l);t&&this.setAllAccounts(t.map(c=>he.createAccount(e,c,e==="bip122"?"payment":"eoa")),e)}syncProvider({type:e,provider:t,id:i,chainNamespace:r}){tt.setProviderId(r,e),tt.setProvider(r,t),le.setConnectorId(i,r)}async syncAccount(e){var d,p,f,g,y,v;const t=e.chainNamespace===I.state.activeChain,i=I.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:r,chainId:n,chainNamespace:o}=e,{chainId:a}=X.getActiveNetworkProps(),c=n||a,l=((d=I.state.activeCaipNetwork)==null?void 0:d.name)===se.UNSUPPORTED_NETWORK_NAME,h=I.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!h)&&c){let b=(p=this.caipNetworks)==null?void 0:p.find(_=>_.id.toString()===c.toString()),w=(f=this.caipNetworks)==null?void 0:f.find(_=>_.chainNamespace===o);if(!h&&!b&&!w){const _=this.getApprovedCaipNetworkIds()||[],C=_.find(P=>{var O;return((O=vi.parseCaipNetworkId(P))==null?void 0:O.chainId)===c.toString()}),T=_.find(P=>{var O;return((O=vi.parseCaipNetworkId(P))==null?void 0:O.chainNamespace)===o});b=(g=this.caipNetworks)==null?void 0:g.find(P=>P.caipNetworkId===C),w=(y=this.caipNetworks)==null?void 0:y.find(P=>P.caipNetworkId===T||"deprecatedCaipNetworkId"in P&&P.deprecatedCaipNetworkId===T)}const N=b||w;(N==null?void 0:N.chainNamespace)===I.state.activeChain?R.state.enableNetworkSwitch&&!R.state.allowUnsupportedChain&&((v=I.state.activeCaipNetwork)==null?void 0:v.name)===se.UNSUPPORTED_NETWORK_NAME?I.showUnsupportedChainUI():this.setCaipNetwork(N):t||i&&this.setCaipNetworkOfNamespace(i,o),this.syncConnectedWalletInfo(o),Tm.isLowerCaseMatch(r,ie.state.address)||this.syncAccountInfo(r,N==null?void 0:N.id,o),t?await this.syncBalance({address:r,chainId:N==null?void 0:N.id,chainNamespace:o}):await this.syncBalance({address:r,chainId:i==null?void 0:i.id,chainNamespace:o})}}async syncAccountInfo(e,t,i){const r=this.getCaipAddress(i),n=t||(r==null?void 0:r.split(":")[1]);if(!n)return;const o=`${i}:${n}:${e}`;this.setCaipAddress(o,i),await this.syncIdentity({address:e,chainId:n,chainNamespace:i})}async syncReownName(e,t){try{const i=await this.getReownName(e);if(i[0]){const r=i[0];this.setProfileName(r.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){var r;const t=le.getConnectorId(e),i=tt.getProviderId(e);if(i===Ai.CONNECTOR_TYPE_ANNOUNCED||i===Ai.CONNECTOR_TYPE_INJECTED){if(t){const n=this.getConnectors().find(o=>o.id===t);if(n){const{info:o,name:a,imageUrl:c}=n,l=c||this.getConnectorImage(n);this.setConnectedWalletInfo({name:a,icon:l,...o},e)}}}else if(i===Ai.CONNECTOR_TYPE_WALLET_CONNECT){const n=tt.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(r=n.session.peer.metadata.icons)==null?void 0:r[0]},e)}else if(t)if(t===se.CONNECTOR_ID.COINBASE){const n=this.getConnectors().find(o=>o.id===se.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(n)},e)}else this.setConnectedWalletInfo({name:t},e)}async syncBalance(e){!iw.getNetworksByNamespace(this.caipNetworks,e.chainNamespace).find(i=>{var r;return i.id.toString()===((r=e.chainId)==null?void 0:r.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async updateNativeBalance(e,t,i){const r=this.getAdapter(i);if(r){const n=await r.getBalance({address:e,chainId:t,caipNetwork:this.getCaipNetwork(i),tokens:this.options.tokens});this.setBalance(n.balance,n.symbol,i)}}async initializeUniversalAdapter(){var i,r,n,o,a,c,l,h,d,p;const e=ez.createLogger((f,...g)=>{f&&this.handleAlertError(f),console.error(...g)}),t={projectId:(i=this.options)==null?void 0:i.projectId,metadata:{name:(r=this.options)!=null&&r.metadata?(n=this.options)==null?void 0:n.metadata.name:"",description:(o=this.options)!=null&&o.metadata?(a=this.options)==null?void 0:a.metadata.description:"",url:(c=this.options)!=null&&c.metadata?(l=this.options)==null?void 0:l.metadata.url:"",icons:(h=this.options)!=null&&h.metadata?(d=this.options)==null?void 0:d.metadata.icons:[""]},logger:e};R.setManualWCControl(!!((p=this.options)!=null&&p.manualWCControl)),this.universalProvider=this.options.universalProvider??await cu.init(t),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",e=>{qe.setUri(e)}),this.universalProvider.on("connect",qe.finalizeWcConnection),this.universalProvider.on("disconnect",()=>{this.chainNamespaces.forEach(e=>{this.resetAccount(e)}),qe.resetWcConnection()}),this.universalProvider.on("chainChanged",e=>{var r;const t=(r=this.caipNetworks)==null?void 0:r.find(n=>n.id==e),i=this.getCaipNetwork();if(!t){this.setUnsupportedNetwork(e);return}(i==null?void 0:i.id)!==(t==null?void 0:t.id)&&this.setCaipNetwork(t)}),this.universalProvider.on("session_event",e=>{if(Mm.isSessionEventData(e)){const{name:t,data:i}=e.params.event;t==="accountsChanged"&&Array.isArray(i)&&he.isCaipAddress(i[0])&&this.syncAccount(vi.parseCaipAddress(i[0]))}}))}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&he.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Be.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}handleAlertError(e){const t=Object.entries($a.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[i,r]=t??[],{message:n,alertErrorKey:o}=r??{};if(i&&n&&!this.reportedAlertErrors[i]){const a=$a.ALERT_ERRORS[o];a&&(wo.open(a,"error"),this.reportedAlertErrors[i]=!0)}}getAdapter(e){var t;if(e)return(t=this.chainAdapters)==null?void 0:t[e]}createAdapter(e){var r;if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const i=e;i.namespace=t,i.construct({namespace:t,projectId:(r=this.options)==null?void 0:r.projectId,networks:this.caipNetworks}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=i)}async open(e){await this.injectModalUi(),e!=null&&e.uri&&qe.setUri(e.uri),await ot.open(e)}async close(){await this.injectModalUi(),ot.close()}setLoading(e,t){ot.setLoading(e,t)}async disconnect(e){await qe.disconnect(e)}getError(){return""}getChainId(){var e;return(e=I.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e){var i;const t=(i=this.caipNetworks)==null?void 0:i.find(r=>r.id===e.id);if(!t){wo.open($a.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await I.switchActiveNetwork(t)}getWalletProvider(){return I.state.activeChain?tt.state.providers[I.state.activeChain]:null}getWalletProviderType(){return tt.getProviderId(I.state.activeChain)}subscribeProviders(e){return tt.subscribeProviders(e)}getThemeMode(){return Ft.state.themeMode}getThemeVariables(){return Ft.state.themeVariables}setThemeMode(e){Ft.setThemeMode(e),$m(Ft.state.themeMode)}setTermsConditionsUrl(e){R.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){R.setPrivacyPolicyUrl(e)}setThemeVariables(e){Ft.setThemeVariables(e),rz(Ft.state.themeVariables)}subscribeTheme(e){return Ft.subscribe(e)}getWalletInfo(){return ie.state.connectedWalletInfo}getAccount(e){const t=le.getAuthConnector(e),i=I.getAccountData(e);if(i)return{allAccounts:i.allAccounts,caipAddress:i.caipAddress,address:he.getPlainAddress(i.caipAddress),isConnected:!!i.caipAddress,status:i.status,embeddedWalletInfo:t?{user:i.user,authProvider:i.socialProvider||"email",accountType:i.preferredAccountType,isSmartAccountDeployed:!!i.smartAccountDeployed}:void 0}}subscribeAccount(e,t){const i=()=>{const r=this.getAccount(t);r&&e(r)};t?I.subscribeChainProp("accountState",i,t):I.subscribe(i),le.subscribe(i)}subscribeNetwork(e){return I.subscribe(({activeCaipNetwork:t})=>{e({caipNetwork:t,chainId:t==null?void 0:t.id,caipNetworkId:t==null?void 0:t.caipNetworkId})})}subscribeWalletInfo(e){return ie.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){ie.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){I.subscribeKey("activeCaipNetwork",e)}getState(){return pi.state}subscribeState(e){return pi.subscribe(e)}showErrorMessage(e){vt.showError(e)}showSuccessMessage(e){vt.showSuccess(e)}getEvent(){return{...Be.state}}subscribeEvents(e){return Be.subscribe(e)}replace(e){xe.replace(e)}redirect(e){xe.push(e)}popTransactionStack(e){xe.popTransactionStack(e)}isOpen(){return ot.state.open}isTransactionStackEmpty(){return xe.state.transactionStack.length===0}isTransactionShouldReplaceView(){var e;return(e=xe.state.transactionStack[xe.state.transactionStack.length-1])==null?void 0:e.replace}static getInstance(){return this.instance}updateFeatures(e){R.setFeatures(e)}updateOptions(e){const i={...R.state||{},...e};R.setOptions(i)}setConnectMethodsOrder(e){R.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){R.setWalletFeaturesOrder(e)}setCollapseWallets(e){R.setCollapseWallets(e)}setSocialsOrder(e){R.setSocialsOrder(e)}getConnectMethodsOrder(){return rc.getConnectOrderMethod(R.state.features,le.getConnectors())}removeAdapter(e){var n;const t=this.getIsConnectedState(),i=this.getAdapter(e);if(!i||!this.chainAdapters||t)return;const r=(n=this.caipNetworks)==null?void 0:n.filter(o=>o.chainNamespace!==e);I.removeAdapter(e),le.removeAdapter(e),this.chainNamespaces=this.chainNamespaces.filter(o=>o!==e),this.caipNetworks=r,i.removeAllEventListeners(),Reflect.deleteProperty(this.chainAdapters,e)}addAdapter(e,t){const i=e.namespace;if(!this.connectionControllerClient||!this.networkControllerClient||!this.chainAdapters||!i)return;const r=this.extendCaipNetworks({...this.options,networks:t});this.caipNetworks=[...this.caipNetworks||[],...r],this.createAdapter(e),this.initChainAdapter(i),I.addAdapter(e,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient},r)}addNetwork(e,t){var r;if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const i=this.extendCaipNetwork(t,this.options);I.addNetwork(i),this.caipNetworks&&!((r=this.caipNetworks)!=null&&r.find(n=>n.id===i.id))&&this.caipNetworks.push(i)}removeNetwork(e,t){var n;if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);if(!((n=this.caipNetworks)==null?void 0:n.find(o=>o.id===t)))throw new Error(`Network with ID ${t} not found`);if(!this.caipNetworks)return;const r=this.caipNetworks.filter(o=>o.chainNamespace===e&&o.id!==t);if(!(r!=null&&r.length))throw new Error("Cannot remove last network for a namespace");I.removeNetwork(e,t),this.caipNetworks=[...r]}}let of=!1;class gz extends pz{async open(e){le.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&qe.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!of&&he.isClient()){if(await Promise.resolve().then(()=>require("./basic-BH3rU0o2.js")),await Promise.resolve().then(()=>require("./w3m-modal-253PNp3t.js")),!document.querySelector("w3m-modal")){const t=document.createElement("w3m-modal");!R.state.disableAppend&&!R.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",t)}of=!0}}}const fz="1.7.2";function yz(s){return new gz({...s,basic:!0,sdkVersion:`html-core-${fz}`})}function wz(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let l=0;l<e.length;l++)e[l]=255;for(let l=0;l<s.length;l++){const h=s.charAt(l),d=h.charCodeAt(0);if(e[d]!==255)throw new TypeError(h+" is ambiguous");e[d]=l}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";let h=0,d=0,p=0;const f=l.length;for(;p!==f&&l[p]===0;)p++,h++;const g=(f-p)*n+1>>>0,y=new Uint8Array(g);for(;p!==f;){let w=l[p],N=0;for(let _=g-1;(w!==0||N<d)&&_!==-1;_--,N++)w+=256*y[_]>>>0,y[_]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");d=N,p++}let v=g-d;for(;v!==g&&y[v]===0;)v++;let b=i.repeat(h);for(;v<g;++v)b+=s.charAt(y[v]);return b}function a(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;let h=0,d=0,p=0;for(;l[h]===i;)d++,h++;const f=(l.length-h)*r+1>>>0,g=new Uint8Array(f);for(;h<l.length;){const w=l.charCodeAt(h);if(w>255)return;let N=e[w];if(N===255)return;let _=0;for(let C=f-1;(N!==0||_<p)&&C!==-1;C--,_++)N+=t*g[C]>>>0,g[C]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");p=_,h++}let y=f-p;for(;y!==f&&g[y]===0;)y++;const v=new Uint8Array(d+(f-y));let b=d;for(;y!==f;)v[b++]=g[y++];return v}function c(l){const h=a(l);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var mz="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const _l=wz(mz);class fn extends Error{constructor(){super(),Object.setPrototypeOf(this,fn.prototype)}}class af extends Error{constructor(e){super(`WalletConnect Adapter - Method ${e} is not supported by the wallet`),this.name="WalletConnectFeatureNotSupportedError"}}function bz(s){let e=[s];return s===gt.Mainnet||s===gt.Deprecated_Mainnet?(e=[gt.Mainnet,gt.Deprecated_Mainnet],s===gt.Deprecated_Mainnet&&console.warn(nc.mainnet)):(s===gt.Deprecated_Devnet||s===gt.Devnet)&&(e=[gt.Devnet,gt.Deprecated_Devnet],console.warn(nc.devnet)),e}const nc={mainnet:`You are using a deprecated chain ID for Solana Mainnet, please use ${gt.Mainnet} instead.`,devnet:`You are using a deprecated chain ID for Solana Devnet, please use ${gt.Devnet} instead.`,wallet:"The connected wallet is using a deprecated chain ID for Solana. Please, contact them to upgrade. You can learn more at https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip10.md#chain-ids"};function cf(s,e){var i;const t=(i=s.namespaces.solana)==null?void 0:i.accounts.map(r=>`solana:${r.split(":")[1]}`);if(e===gt.Mainnet)return t!=null&&t.find(r=>r===gt.Mainnet)?gt.Mainnet:(console.warn(nc.wallet),gt.Deprecated_Mainnet);if(e===gt.Devnet)return t!=null&&t.find(r=>r===gt.Devnet)?gt.Devnet:(console.warn(nc.wallet),gt.Deprecated_Devnet);throw Error("WalletConnect Solana Adapter: Unable to get a default chain from the session.")}function vz(s){return{optionalNamespaces:{solana:{chains:bz(s),methods:[Is.signTransaction,Is.signMessage],events:[]}}}}class lu extends Error{constructor(){super("QR Code Modal was closed by user"),Object.setPrototypeOf(this,lu.prototype),this.name="QRCodeModalError"}}class Iz{constructor(e){At(this,"_UniversalProvider");At(this,"_session");At(this,"_modal");At(this,"_projectId");At(this,"_network");At(this,"_ConnectQueueResolver");if(this.initClient(e.options),this._network=e.network,!e.options.projectId)throw Error("WalletConnect Adapter: Project ID is undefined");this._projectId=e.options.projectId}async connect(){var r,n,o,a,c,l;if(this._UniversalProvider||await new Promise(h=>{this._ConnectQueueResolver=h}),!this._UniversalProvider)throw new Error("WalletConnect Adapter - Universal Provider was undefined while calling 'connect()'");if(this._UniversalProvider.session){this._session=this._UniversalProvider.session;const h=cf(this._session,this._network);return this._network=h,this._UniversalProvider.setDefaultChain(h),{publicKey:this.publicKey}}await this.initModal();const e=vz(this._network);(r=this._modal)==null||r.open();const t=new AbortController,i=t.signal;(n=this._modal)==null||n.subscribeState(h=>{h.open||t.abort(new lu)});try{const h=await Promise.race([(o=this._UniversalProvider)==null?void 0:o.connect(e),new Promise((p,f)=>{i.addEventListener("abort",()=>{f(i.reason)})})]);if((a=this._modal)==null||a.close(),this._session=h,!h)throw new cc;const d=cf(h,this._network);return this._network=d,(c=this._UniversalProvider)==null||c.setDefaultChain(d),{publicKey:this.publicKey}}catch(h){throw(l=this._modal)==null||l.close(),h}}async disconnect(){var e;if((e=this._UniversalProvider)!=null&&e.session){if(await this.initModal(),!this._modal)throw Error("WalletConnect Adapter -Modal is undefined: unable to disconnect");await this.client.disconnect(),this._session=void 0}else throw new fn}get client(){if(this._UniversalProvider)return this._UniversalProvider;throw new fn}get session(){if(!this._session)throw new fn;return this._session}get publicKey(){var e,t,i;if((e=this._UniversalProvider)!=null&&e.session&&this._session){const{address:r}=v0(((i=(t=this._session)==null?void 0:t.namespaces.solana)==null?void 0:i.accounts[0])??"");return new A.PublicKey(r)}throw new fn}async signTransaction(e){this.checkIfWalletSupportsMethod(Is.signTransaction);const t=ui(e),i=t?{}:e,{signature:r,transaction:n}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:Is.signTransaction,params:{...i,transaction:this.serialize(e)}}});return n?this.deserialize(n,t):(e.addSignature(this.publicKey,A.dist.Buffer.from(_l.decode(r))),e)}async signMessage(e){this.checkIfWalletSupportsMethod(Is.signMessage);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:Is.signMessage,params:{pubkey:this.publicKey.toString(),message:_l.encode(e)}}});return _l.decode(t)}async signAndSendTransaction(e){this.checkIfWalletSupportsMethod(Is.signAndSendTransaction);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:Is.signAndSendTransaction,params:{transaction:this.serialize(e)}}});return t}async signAllTransactions(e){try{this.checkIfWalletSupportsMethod(Is.signAllTransactions);const t=e.map(r=>this.serialize(r)),{transactions:i}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:Is.signAllTransactions,params:{transactions:t}}});return e.map((r,n)=>ui(r)?this.deserialize(i[n]??"",!0):this.deserialize(i[n]??""))}catch(t){if(t instanceof af){const i=e.map(n=>this.signTransaction(n));return await Promise.all(i)}throw t}}async initClient(e){const t=await zx.init(e);this._UniversalProvider=t,this._ConnectQueueResolver&&this._ConnectQueueResolver(!0)}async initModal(){if(!this._modal){if(!this._UniversalProvider)throw new Error("WalletConnect Adapter - cannot init modal when Universal Provider is undefined");this._modal=yz({projectId:this._projectId,universalProvider:this._UniversalProvider,networks:[_h,Ch,cz],manualWCControl:!0})}}serialize(e){return A.dist.Buffer.from(e.serialize({verifySignatures:!1})).toString("base64")}deserialize(e,t=!1){return t?A.VersionedTransaction.deserialize(A.dist.Buffer.from(e,"base64")):A.Transaction.from(A.dist.Buffer.from(e,"base64"))}checkIfWalletSupportsMethod(e){var t;if(!((t=this.session.namespaces.solana)!=null&&t.methods.includes(e)))throw new af(e)}}const Ez="WalletConnect";class Nz extends $h{constructor(t){super();At(this,"name",Ez);At(this,"url","https://walletconnect.org");At(this,"icon","data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4NSIgdmlld0JveD0iMCAwIDMwMCAxODUiIHdpZHRoPSIzMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTYxLjQzODU0MjkgMzYuMjU2MjYxMmM0OC45MTEyMjQxLTQ3Ljg4ODE2NjMgMTI4LjIxMTk4NzEtNDcuODg4MTY2MyAxNzcuMTIzMjA5MSAwbDUuODg2NTQ1IDUuNzYzNDE3NGMyLjQ0NTU2MSAyLjM5NDQwODEgMi40NDU1NjEgNi4yNzY1MTEyIDAgOC42NzA5MjA0bC0yMC4xMzY2OTUgMTkuNzE1NTAzYy0xLjIyMjc4MSAxLjE5NzIwNTEtMy4yMDUzIDEuMTk3MjA1MS00LjQyODA4MSAwbC04LjEwMDU4NC03LjkzMTE0NzljLTM0LjEyMTY5Mi0zMy40MDc5ODE3LTg5LjQ0Mzg4Ni0zMy40MDc5ODE3LTEyMy41NjU1Nzg4IDBsLTguNjc1MDU2MiA4LjQ5MzYwNTFjLTEuMjIyNzgxNiAxLjE5NzIwNDEtMy4yMDUzMDEgMS4xOTcyMDQxLTQuNDI4MDgwNiAwbC0yMC4xMzY2OTQ5LTE5LjcxNTUwMzFjLTIuNDQ1NTYxMi0yLjM5NDQwOTItMi40NDU1NjEyLTYuMjc2NTEyMiAwLTguNjcwOTIwNHptMjE4Ljc2Nzc5NjEgNDAuNzczNzQ0OSAxNy45MjE2OTcgMTcuNTQ2ODk3YzIuNDQ1NTQ5IDIuMzk0Mzk2OSAyLjQ0NTU2MyA2LjI3NjQ3NjkuMDAwMDMxIDguNjcwODg5OWwtODAuODEwMTcxIDc5LjEyMTEzNGMtMi40NDU1NDQgMi4zOTQ0MjYtNi40MTA1ODIgMi4zOTQ0NTMtOC44NTYxNi4wMDAwNjItLjAwMDAxLS4wMDAwMS0uMDAwMDIyLS4wMDAwMjItLjAwMDAzMi0uMDAwMDMybC01Ny4zNTQxNDMtNTYuMTU0NTcyYy0uNjExMzktLjU5ODYwMi0xLjYwMjY1LS41OTg2MDItMi4yMTQwNCAwLS4wMDAwMDQuMDAwMDA0LS4wMDAwMDcuMDAwMDA4LS4wMDAwMTEuMDAwMDExbC01Ny4zNTI5MjEyIDU2LjE1NDUzMWMtMi40NDU1MzY4IDIuMzk0NDMyLTYuNDEwNTc1NSAyLjM5NDQ3Mi04Ljg1NjE2MTIuMDAwMDg3LS4wMDAwMTQzLS4wMDAwMTQtLjAwMDAyOTYtLjAwMDAyOC0uMDAwMDQ0OS0uMDAwMDQ0bC04MC44MTI0MTk0My03OS4xMjIxODVjLTIuNDQ1NTYwMjEtMi4zOTQ0MDgtMi40NDU1NjAyMS02LjI3NjUxMTUgMC04LjY3MDkxOTdsMTcuOTIxNzI5NjMtMTcuNTQ2ODY3M2MyLjQ0NTU2MDItMi4zOTQ0MDgyIDYuNDEwNTk4OS0yLjM5NDQwODIgOC44NTYxNjAyIDBsNTcuMzU0OTc3NSA1Ni4xNTUzNTdjLjYxMTM5MDguNTk4NjAyIDEuNjAyNjQ5LjU5ODYwMiAyLjIxNDAzOTggMCAuMDAwMDA5Mi0uMDAwMDA5LjAwMDAxNzQtLjAwMDAxNy4wMDAwMjY1LS4wMDAwMjRsNTcuMzUyMTAzMS01Ni4xNTUzMzNjMi40NDU1MDUtMi4zOTQ0NjMzIDYuNDEwNTQ0LTIuMzk0NTUzMSA4Ljg1NjE2MS0uMDAwMi4wMDAwMzQuMDAwMDMzNi4wMDAwNjguMDAwMDY3My4wMDAxMDEuMDAwMTAxbDU3LjM1NDkwMiA1Ni4xNTU0MzJjLjYxMTM5LjU5ODYwMSAxLjYwMjY1LjU5ODYwMSAyLjIxNDA0IDBsNTcuMzUzOTc1LTU2LjE1NDMyNDljMi40NDU1NjEtMi4zOTQ0MDkyIDYuNDEwNTk5LTIuMzk0NDA5MiA4Ljg1NjE2IDB6IiBmaWxsPSIjM2I5OWZjIi8+PC9zdmc+");At(this,"supportedTransactionVersions",new Set(["legacy",0]));At(this,"_publicKey");At(this,"_connecting");At(this,"_wallet");At(this,"_config");At(this,"_readyState");At(this,"_onDisconnect");this._publicKey=null,this._connecting=!1,this._config=t,this._wallet=null,this._readyState=typeof window>"u"?ge.Unsupported:ge.Loadable,this._onDisconnect=this.disconnect.bind(this)}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ge.Loadable)throw new Li;this._connecting=!0,this._wallet=new Iz({network:this._config.network===Ao.Mainnet?Ba.Mainnet:Ba.Devnet,options:this._config.options});const{publicKey:t}=await this._wallet.connect();this._publicKey=t,this.emit("connect",t),this._wallet.client.on("session_delete",this._onDisconnect)}catch(t){throw t.constructor.name==="QRCodeModalError"||t instanceof Error&&t.name==="QRCodeModalError"?new Kb:(this._connecting=!1,t)}finally{this._connecting=!1}}async disconnect(){const t=this._wallet;if(t){t.client.off("session_delete",this._onDisconnect),this._publicKey=null;try{t.client.session&&await t.disconnect()}catch(i){console.error("WalletConnectWalletAdapter: disconnect error",i),this.emit("error",new ko(i==null?void 0:i.message,i))}}this.emit("disconnect")}async signTransaction(t){try{const i=this._wallet;if(!i)throw new Ge;try{return await i.signTransaction(t)}catch(r){throw new rt(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}async signMessage(t){try{const i=this._wallet;if(!i)throw new Ge;try{return await i.signMessage(t)}catch(r){throw new jo(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}async signAndSendTransaction(t){try{const i=this._wallet;if(!i)throw new Ge;try{return await i.signAndSendTransaction(t)}catch(r){throw new rt(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}async signAllTransactions(t){try{const i=this._wallet;if(!i)throw new Ge;try{return await i.signAllTransactions(t)}catch(r){throw new rt(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}}const Az={icon:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8yMDM1XzExMDYpIj4KPHJlY3Qgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIGZpbGw9IiM1NEZGRjUiLz4KPGcgZmlsdGVyPSJ1cmwoI2ZpbHRlcjBfZl8yMDM1XzExMDYpIj4KPHBhdGggZD0iTTEzLjQ4MDYgMTk4LjYwNUMtMjkuMzI3NiAzMTkuMDQzIDE5OS42NjEgMjg1LjAyNyAzMTkuNTA3IDI1Mi45NjRDNDQyLjE2NSAyMTIuMjU5IDM1Ny4zODYgMzIuODI2OSAyNjkuNDE1IDI4Ljg1NThDMTgxLjQ0MyAyNC44ODQ3IDI4MC4zMjIgMTExLjgyNCAyMDUuNTk1IDEzNi42NTZDMTMwLjg2OCAxNjEuNDg3IDY2Ljk5MDcgNDguMDU4MyAxMy40ODA2IDE5OC42MDVaIiBmaWxsPSJ3aGl0ZSIvPgo8L2c+CjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIxX2ZfMjAzNV8xMTA2KSI+CjxwYXRoIGQ9Ik04NS41MTE4IC00NS44MjI1QzYzLjA1NjIgLTEwNy4xNzYgLTE2LjkxODkgLTIzLjk5NTMgLTU0LjA5OTUgMjUuMjY0M0MtODkuNTY1MiA3OC44NDc5IDMuMDA5MzcgMTI1LjE1MiAzOS4zMjA4IDEwMC4wMzdDNzUuNjMyMyA3NC45MjI3IDcuNzc0NDggNzAuMDM2MyAyOS4zNzA4IDM3LjM3ODVDNTAuOTY3MSA0LjcyMDc2IDExMy41ODEgMzAuODY5NSA4NS41MTE4IC00NS44MjI1WiIgZmlsbD0iIzAwRkZGMCIgZmlsbC1vcGFjaXR5PSIwLjY3Ii8+CjwvZz4KPGcgZmlsdGVyPSJ1cmwoI2ZpbHRlcjJfZl8yMDM1XzExMDYpIj4KPHBhdGggZD0iTTk2LjQ3OTYgMjI1LjQyNEM2NS44NTAyIDEyMi4zNjMgLTY2LjA4MTggMTc2LjYzNyAtMTI4LjIxOSAyMTYuNjU3Qy0xODcuOTkgMjY0LjA0MiAtNDYuMDcxMSA0MDAuMzQ4IDEyLjg3MjUgMzkzLjM3NkM3MS44MTYxIDM4Ni40MDMgLTM0LjQxMTggMzI3LjA2NSAxLjk4NzAyIDI5OC4xN0MzOC4zODU4IDI2OS4yNzYgMTM0Ljc2NiAzNTQuMjQ5IDk2LjQ3OTYgMjI1LjQyNFoiIGZpbGw9IiM5RDgxRkYiLz4KPC9nPgo8ZyBmaWx0ZXI9InVybCgjZmlsdGVyM19mXzIwMzVfMTEwNikiPgo8cGF0aCBkPSJNMjgyLjEyIC0xMDcuMzUzQzIxNi4wNDcgLTE4Ni4wMzEgMTIxLjQ2MyAtMTIwLjk3IDgyLjQyOTYgLTc4LjYwNDdDNDguMjczOSAtMzAuNjQ0NiAyMjQuMjc1IDU3LjIzMTIgMjczLjEyMSA0Mi4xNzE0QzMyMS45NjggMjcuMTExNSAyMDYuNTEyIC00LjA1MDM4IDIyNy4yOTcgLTMzLjI4NzlDMjQ4LjA4MiAtNjIuNTI1NSAzNjQuNzEyIC05LjAwNTY2IDI4Mi4xMiAtMTA3LjM1M1oiIGZpbGw9IiM0RDk0RkYiLz4KPC9nPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTkzLjE4OSAxNTIuODM2SDEzNi42NzRMODcuMjA4NiAxMDMuMDUxTDEzNy4zMSA1My4yNjYzTDE1MC45NTUgNDBIMTA1LjgxOUw0OC4zMzU5IDk3Ljc3NzNDNDUuNDM0OSAxMDAuNjg5IDQ1LjQ0OTggMTA1LjQwMiA0OC4zNjU2IDEwOC4yOTlMOTMuMTg5IDE1Mi44MzZaTTExOS4zMyAxMDMuMTY4SDExOC45OTVMMTE5LjMyNiAxMDMuMTY0TDExOS4zMyAxMDMuMTY4Wk0xMTkuMzMgMTAzLjE2OEwxNjguNzkxIDE1Mi45NDlMMTE4LjY5IDIwMi43MzRMMTA1LjA0NSAyMTZIMTUwLjE4TDIwNy42NjQgMTU4LjIyNkMyMTAuNTY1IDE1NS4zMTQgMjEwLjU1IDE1MC42MDIgMjA3LjYzNCAxNDcuNzA1TDE2Mi44MTEgMTAzLjE2OEgxMTkuMzNaIiBmaWxsPSJibGFjayIvPgo8L2c+CjxkZWZzPgo8ZmlsdGVyIGlkPSJmaWx0ZXIwX2ZfMjAzNV8xMTA2IiB4PSItOTAuMjQxMSIgeT0iLTY5LjczNjkiIHdpZHRoPSI1NjkuNTU4IiBoZWlnaHQ9IjQ1MS40MzEiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIj4KPGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz4KPGZlQmxlbmQgbW9kZT0ibm9ybWFsIiBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIHJlc3VsdD0ic2hhcGUiLz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iNDkuMjMwOCIgcmVzdWx0PSJlZmZlY3QxX2ZvcmVncm91bmRCbHVyXzIwMzVfMTEwNiIvPgo8L2ZpbHRlcj4KPGZpbHRlciBpZD0iZmlsdGVyMV9mXzIwMzVfMTEwNiIgeD0iLTE2MC41MTEiIHk9Ii0xNjUuOTg3IiB3aWR0aD0iMzUxLjU5NiIgaGVpZ2h0PSIzNzEuNTA3IiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiI+CjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iQmFja2dyb3VuZEltYWdlRml4IiByZXN1bHQ9InNoYXBlIi8+CjxmZUdhdXNzaWFuQmx1ciBzdGREZXZpYXRpb249IjQ5LjIzMDgiIHJlc3VsdD0iZWZmZWN0MV9mb3JlZ3JvdW5kQmx1cl8yMDM1XzExMDYiLz4KPC9maWx0ZXI+CjxmaWx0ZXIgaWQ9ImZpbHRlcjJfZl8yMDM1XzExMDYiIHg9Ii0yNDEuMDc4IiB5PSI2Ny42NDIiIHdpZHRoPSI0NDQuODUxIiBoZWlnaHQ9IjQyNC40NTIiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIj4KPGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz4KPGZlQmxlbmQgbW9kZT0ibm9ybWFsIiBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIHJlc3VsdD0ic2hhcGUiLz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iNDkuMjMwOCIgcmVzdWx0PSJlZmZlY3QxX2ZvcmVncm91bmRCbHVyXzIwMzVfMTEwNiIvPgo8L2ZpbHRlcj4KPGZpbHRlciBpZD0iZmlsdGVyM19mXzIwMzVfMTEwNiIgeD0iLTIwLjM5NjgiIHk9Ii0yNDIuNzU4IiB3aWR0aD0iNDMwLjE5MSIgaGVpZ2h0PSIzODUuMTA1IiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiI+CjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iQmFja2dyb3VuZEltYWdlRml4IiByZXN1bHQ9InNoYXBlIi8+CjxmZUdhdXNzaWFuQmx1ciBzdGREZXZpYXRpb249IjQ5LjIzMDgiIHJlc3VsdD0iZWZmZWN0MV9mb3JlZ3JvdW5kQmx1cl8yMDM1XzExMDYiLz4KPC9maWx0ZXI+CjxjbGlwUGF0aCBpZD0iY2xpcDBfMjAzNV8xMTA2Ij4KPHJlY3Qgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIGZpbGw9IndoaXRlIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg==",name:"Bitget Wallet"},_z=[Az],Cz=s=>_z.find(e=>e.name.toLocaleLowerCase().includes(s.name.toLocaleLowerCase()))||s,Sz=(s,e,t)=>e[s]||t[s],lf=(s,e)=>Sz(s,Cz(e),e);class _i extends oe.Wallet{constructor(e,t){super(),this.adapter=e,this.connection=t}getAdapter(){return this.adapter}getName(){return lf("name",this.adapter)}getUrl(){return this.adapter.url}async connect(){if(this.isConnected())return this.getAddresses();const e=await new Promise((t,i)=>{this.adapter.on("connect",()=>{this.adapter.off("connect"),this.adapter.off("error"),t(this.getAddresses())}),this.adapter.on("error",r=>{this.adapter.off("connect"),this.adapter.off("error"),i(r)}),this.adapter.connect().catch(i)});return this.emit("connect"),this.adapter.on("disconnect",()=>this.emit("disconnect")),e}getNetworkInfo(){return{}}isConnected(){return this.adapter.connected}async disconnect(){this.isConnected()&&(await new Promise((e,t)=>{this.adapter.on("disconnect",()=>{this.adapter.off("disconnect"),this.adapter.off("error"),e(void 0)}),this.adapter.on("error",i=>{this.adapter.off("disconnect"),this.adapter.off("error"),t(i)}),this.adapter.disconnect().catch(t)}),this.adapter.removeAllListeners(),this.emit("disconnect"))}getChainId(){return oe.CHAIN_ID_SOLANA}getAddress(){var e;return(e=this.adapter.publicKey)==null?void 0:e.toString()}getAddresses(){const e=this.getAddress();return e?[e]:[]}setMainAddress(){throw new Error("Not supported")}getBalance(){throw new Error("Not supported")}async signTransaction(e){if(!this.adapter.signTransaction||!this.adapter.signAllTransactions)throw new Error("Not supported");return Array.isArray(e)?this.adapter.signAllTransactions(e):this.adapter.signTransaction(e)}async sendTransaction(e){var n;const{transaction:t}=e,i=Array.isArray(t)?t:[t];if(i.length===0)throw new Error("Empty transactions array");const r=[];for(const o of i){const a=await this.adapter.sendTransaction(o,this.connection,{...e.options});r.push(a)}return await this.connection.confirmTransaction(r[0],(n=e.options)==null?void 0:n.commitment),{id:r[0],data:r.length===1?r[0]:r}}async signAndSendTransaction(e){return this.sendTransaction(e)}signMessage(e){if(!this.adapter.signMessage)throw new Error("Not supported");return this.adapter.signMessage(e)}getIcon(){return lf("icon",this.adapter)}getWalletState(){const e=this.adapter.readyState;if(!(e in oe.WalletState))throw new Error(`Unknown wallet state ${e}`);return oe.WalletState[e]}getFeatures(){const e=[oe.BaseFeatures.SendTransaction,oe.BaseFeatures.SignAndSendTransaction];return this.adapter.signTransaction&&this.adapter.signAllTransactions&&e.push(oe.BaseFeatures.SignTransaction),this.adapter.signMessage&&e.push(oe.BaseFeatures.SignMessage),e}supportsChain(e){return e===oe.CHAIN_ID_SOLANA}}function Tz(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let l=0;l<e.length;l++)e[l]=255;for(let l=0;l<s.length;l++){const h=s.charAt(l),d=h.charCodeAt(0);if(e[d]!==255)throw new TypeError(h+" is ambiguous");e[d]=l}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";let h=0,d=0,p=0;const f=l.length;for(;p!==f&&l[p]===0;)p++,h++;const g=(f-p)*n+1>>>0,y=new Uint8Array(g);for(;p!==f;){let w=l[p],N=0;for(let _=g-1;(w!==0||N<d)&&_!==-1;_--,N++)w+=256*y[_]>>>0,y[_]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");d=N,p++}let v=g-d;for(;v!==g&&y[v]===0;)v++;let b=i.repeat(h);for(;v<g;++v)b+=s.charAt(y[v]);return b}function a(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;let h=0,d=0,p=0;for(;l[h]===i;)d++,h++;const f=(l.length-h)*r+1>>>0,g=new Uint8Array(f);for(;h<l.length;){const w=l.charCodeAt(h);if(w>255)return;let N=e[w];if(N===255)return;let _=0;for(let C=f-1;(N!==0||_<p)&&C!==-1;C--,_++)N+=t*g[C]>>>0,g[C]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");p=_,h++}let y=f-p;for(;y!==f&&g[y]===0;)y++;const v=new Uint8Array(d+(f-y));let b=d;for(;y!==f;)v[b++]=g[y++];return v}function c(l){const h=a(l);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var Pz="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const $z=Tz(Pz);var J=function(s,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!i:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(s):i?i.value:e.get(s)},lt=function(s,e,t,i,r){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?r.call(s,t):r?r.value=t:e.set(s,t),t},xt,es,ar,cr,er,go,oc,Ce,ac,Sh,qa,Th,No,Ph,hf,uf,df,pf;class Mz extends yf{get name(){return J(this,Ce,"f").name}get url(){return"https://github.com/solana-labs/wallet-standard"}get icon(){return J(this,Ce,"f").icon}get readyState(){return J(this,ac,"f")}get publicKey(){return J(this,ar,"f")}get connecting(){return J(this,cr,"f")}get supportedTransactionVersions(){return J(this,oc,"f")}get wallet(){return J(this,Ce,"f")}get standard(){return!0}constructor({wallet:e}){super(),xt.add(this),es.set(this,void 0),ar.set(this,void 0),cr.set(this,void 0),er.set(this,void 0),go.set(this,void 0),oc.set(this,void 0),Ce.set(this,void 0),ac.set(this,typeof window>"u"||typeof document>"u"?ge.Unsupported:ge.Installed),Ph.set(this,t=>{if("accounts"in t){const i=J(this,Ce,"f").accounts[0];J(this,es,"f")&&!J(this,er,"f")&&i!==J(this,es,"f")&&(i?J(this,xt,"m",qa).call(this,i):(this.emit("error",new ff),J(this,xt,"m",Th).call(this)))}"features"in t&&J(this,xt,"m",No).call(this)}),lt(this,Ce,e,"f"),lt(this,es,null,"f"),lt(this,ar,null,"f"),lt(this,cr,!1,"f"),lt(this,er,!1,"f"),lt(this,go,J(this,Ce,"f").features[mf].on("change",J(this,Ph,"f")),"f"),J(this,xt,"m",No).call(this)}destroy(){lt(this,es,null,"f"),lt(this,ar,null,"f"),lt(this,cr,!1,"f"),lt(this,er,!1,"f");const e=J(this,go,"f");e&&(lt(this,go,null,"f"),e())}async autoConnect(){return J(this,xt,"m",Sh).call(this,{silent:!0})}async connect(){return J(this,xt,"m",Sh).call(this)}async disconnect(){if($u in J(this,Ce,"f").features)try{lt(this,er,!0,"f"),await J(this,Ce,"f").features[$u].disconnect()}catch(e){this.emit("error",new ko(e==null?void 0:e.message,e))}finally{lt(this,er,!1,"f")}J(this,xt,"m",Th).call(this)}async sendTransaction(e,t,i={}){try{const r=J(this,es,"f");if(!r)throw new Ge;let n;if(Pi in J(this,Ce,"f").features)if(r.features.includes(Pi))n=Pi;else if(Mt in J(this,Ce,"f").features&&r.features.includes(Mt))n=Mt;else throw new Ns;else if(Mt in J(this,Ce,"f").features){if(!r.features.includes(Mt))throw new Ns;n=Mt}else throw new un;const o=pv(t.rpcEndpoint);if(!r.chains.includes(o))throw new rr;try{const{signers:a,...c}=i;let l;if(ui(e)?(a!=null&&a.length&&e.sign(a),l=e.serialize()):(e=await this.prepareTransaction(e,t,c),a!=null&&a.length&&e.partialSign(...a),l=new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))),n===Pi){const[h]=await J(this,Ce,"f").features[Pi].signAndSendTransaction({account:r,chain:o,transaction:l,options:{preflightCommitment:Dc(c.preflightCommitment||t.commitment),skipPreflight:c.skipPreflight,maxRetries:c.maxRetries,minContextSlot:c.minContextSlot}});return $z.encode(h.signature)}else{const[h]=await J(this,Ce,"f").features[Mt].signTransaction({account:r,chain:o,transaction:l,options:{preflightCommitment:Dc(c.preflightCommitment||t.commitment),minContextSlot:c.minContextSlot}});return await t.sendRawTransaction(h.signedTransaction,{...c,preflightCommitment:Dc(c.preflightCommitment||t.commitment)})}}catch(a){throw a instanceof Dt?a:new rr(a==null?void 0:a.message,a)}}catch(r){throw this.emit("error",r),r}}}es=new WeakMap,ar=new WeakMap,cr=new WeakMap,er=new WeakMap,go=new WeakMap,oc=new WeakMap,Ce=new WeakMap,ac=new WeakMap,Ph=new WeakMap,xt=new WeakSet,Sh=async function(e){try{if(this.connected||this.connecting)return;if(J(this,ac,"f")!==ge.Installed)throw new Li;if(lt(this,cr,!0,"f"),!J(this,Ce,"f").accounts.length)try{await J(this,Ce,"f").features[wf].connect(e)}catch(i){throw new cc(i==null?void 0:i.message,i)}const t=J(this,Ce,"f").accounts[0];if(!t)throw new Ns;J(this,xt,"m",qa).call(this,t)}catch(t){throw this.emit("error",t),t}finally{lt(this,cr,!1,"f")}},qa=function(e){let t;try{t=new A.PublicKey(e.address)}catch(i){throw new yr(i==null?void 0:i.message,i)}lt(this,es,e,"f"),lt(this,ar,t,"f"),J(this,xt,"m",No).call(this),this.emit("connect",t)},Th=function(){lt(this,es,null,"f"),lt(this,ar,null,"f"),J(this,xt,"m",No).call(this),this.emit("disconnect")},No=function(){var t,i;const e=Pi in J(this,Ce,"f").features?J(this,Ce,"f").features[Pi].supportedTransactionVersions:J(this,Ce,"f").features[Mt].supportedTransactionVersions;lt(this,oc,Hb.arraysEqual(e,["legacy"])?null:new Set(e),"f"),Mt in J(this,Ce,"f").features&&((t=J(this,es,"f"))!=null&&t.features.includes(Mt))?(this.signTransaction=J(this,xt,"m",hf),this.signAllTransactions=J(this,xt,"m",uf)):(delete this.signTransaction,delete this.signAllTransactions),Ln in J(this,Ce,"f").features&&((i=J(this,es,"f"))!=null&&i.features.includes(Ln))?this.signMessage=J(this,xt,"m",df):delete this.signMessage,xc in J(this,Ce,"f").features?this.signIn=J(this,xt,"m",pf):delete this.signIn},hf=async function(e){try{const t=J(this,es,"f");if(!t)throw new Ge;if(!(Mt in J(this,Ce,"f").features))throw new un;if(!t.features.includes(Mt))throw new Ns;try{const r=(await J(this,Ce,"f").features[Mt].signTransaction({account:t,transaction:ui(e)?e.serialize():new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))}))[0].signedTransaction;return ui(e)?A.VersionedTransaction.deserialize(r):A.Transaction.from(r)}catch(i){throw i instanceof Dt?i:new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}},uf=async function(e){try{const t=J(this,es,"f");if(!t)throw new Ge;if(!(Mt in J(this,Ce,"f").features))throw new un;if(!t.features.includes(Mt))throw new Ns;try{const i=await J(this,Ce,"f").features[Mt].signTransaction(...e.map(r=>({account:t,transaction:ui(r)?r.serialize():new Uint8Array(r.serialize({requireAllSignatures:!1,verifySignatures:!1}))})));return e.map((r,n)=>{const o=i[n].signedTransaction;return ui(r)?A.VersionedTransaction.deserialize(o):A.Transaction.from(o)})}catch(i){throw new rt(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}},df=async function(e){try{const t=J(this,es,"f");if(!t)throw new Ge;if(!(Ln in J(this,Ce,"f").features))throw new un;if(!t.features.includes(Ln))throw new Ns;try{return(await J(this,Ce,"f").features[Ln].signMessage({account:t,message:e}))[0].signature}catch(i){throw new jo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}},pf=async function(e={}){try{if(!(xc in J(this,Ce,"f").features))throw new un;let t;try{[t]=await J(this,Ce,"f").features[xc].signIn(e)}catch(i){throw new Pu(i==null?void 0:i.message,i)}if(!t)throw new Pu;return J(this,xt,"m",qa).call(this,t.account),t}catch(t){throw this.emit("error",t),t}};function xz(s){return Wb.getWallets().get().filter(Gb).map(e=>new _i(new Mz({wallet:e}),s))}function Oz(s){return s.includes("rpcpool.com")?"triton":s.includes("helius-rpc.com")?"helius":s.includes("rpc.ankr.com")?"ankr":"unknown"}async function Dz(s,e,t,i){const r=i.transaction.transaction,n=o=>o.programId.toString()!=="ComputeBudget111111111111111111111111111111";if(xa.isVersionedTransaction(r)){const o=(await Promise.all(r.message.addressTableLookups.map(c=>s.getAddressLookupTable(c.accountKey)))).map(c=>c.value).filter(c=>c!==null),a=A.TransactionMessage.decompile(r.message,{addressLookupTableAccounts:o});a.recentBlockhash=e,r.message.recentBlockhash=e,a.instructions=a.instructions.filter(n),r.message=a.compileToV0Message(o),a.instructions.push(...await gf(s,r)),r.message=a.compileToV0Message(o),r.sign(i.transaction.signers??[])}else r.recentBlockhash=e,r.lastValidBlockHeight=t,r.instructions=r.instructions.filter(n),r.add(...await gf(s,r)),i.transaction.signers&&r.partialSign(...i.transaction.signers);return r}async function gf(s,e,t){var N,_;let i=2e5,r=0;const n=A.ComputeBudgetProgram.setComputeUnitLimit({units:3e5});let o;if(xa.isVersionedTransaction(e)){const C=(await Promise.all(e.message.addressTableLookups.map(P=>s.getAddressLookupTable(P.accountKey)))).map(P=>P.value).filter(P=>P!==null),T=A.TransactionMessage.decompile(e.message,{addressLookupTableAccounts:C});T.instructions=[n,...T.instructions],o=new A.VersionedTransaction(T.compileToV0Message(C)),o.signatures=[...e.signatures]}else{const C=new A.Transaction;C.recentBlockhash=e.recentBlockhash,C.feePayer=e.feePayer,C.instructions=[n,...e.instructions],C.signatures=[...e.signatures],o=C}e:for(;;){if(xa.isVersionedTransaction(o)&&!o.message.recentBlockhash){const{blockhash:T}=await s.getLatestBlockhash(t);o.message.recentBlockhash=T}const C=await(xa.isVersionedTransaction(o)?s.simulateTransaction(o,{commitment:t,replaceRecentBlockhash:!0}):s.simulateTransaction(o));if(C.value.err){if(kz(C.value)){if(r<5){r++,await oe.sleep(1e3);continue e}}else if(r<3){r++,await oe.sleep(1e3);continue e}throw new Error(`Simulation failed: ${JSON.stringify(C.value.err)}
898
898
  Logs:
899
899
  ${(C.value.logs||[]).join(`
900
900
  `)}`)}else{C.value.unitsConsumed&&(i=C.value.unitsConsumed);break}}const a=Math.floor(i*1.2),c=[];c.push(A.ComputeBudgetProgram.setComputeUnitLimit({units:a}));const l=((_=(N=oe.config.transactionSettings)==null?void 0:N.Solana)==null?void 0:_.priorityFee)||{},{percentile:h=.9,percentileMultiple:d=1,min:p=1e5,max:f=1e8}=l,g=async C=>{if(C==="triton")try{return{fee:await Tu.determinePriorityFeeTritonOne(s,e,h,d,p,f),methodUsed:"triton"}}catch(T){console.warn("Failed to determine priority fee using Triton RPC:",T)}try{return{fee:await Tu.determinePriorityFee(s,e,h,d,p,f),methodUsed:"default"}}catch(T){return console.warn("Failed to determine priority fee using Triton RPC:",T),{fee:p,methodUsed:"minimum"}}},y=Oz(s.rpcEndpoint),{fee:v,methodUsed:b}=await g(y),w=v/1e6/A.LAMPORTS_PER_SOL*a;return console.table({"RPC Provider":y,"Method used":b,"Percentile used":h,"Multiple used":d,"Compute budget":a,"Priority fee":v,"Max fee in SOL":w}),c.push(A.ComputeBudgetProgram.setComputeUnitPrice({microLamports:v})),c}function kz(s){const e={};if(s.err==="BlockhashNotFound"&&(e.BlockhashNotFound="Blockhash not found during simulation. Trying again."),s.logs)for(const t of s.logs)t.includes("SlippageToleranceExceeded")&&(e.SlippageToleranceExceeded="Slippage failure during simulation. Trying again."),t.includes("RequireGteViolated")&&(e.RequireGteViolated="Swap instruction failure during simulation. Trying again.");return oe.isEmptyObject(e)?!1:(console.table(e),!0)}const jz=s=>s.getName().toLowerCase().replaceAll("wallet","").trim();function Rz(){const s=oe.config.isMainnet?"mainnet-beta":"devnet",e=new A.Connection(oe.config.rpcs.Solana||A.clusterApiUrl(s));return{...xz(e).reduce((t,i)=>(t[jz(i)]=i,t),{}),bitget:new _i(new Qb,e),clover:new _i(new Jb,e),coin98:new _i(new sv,e),solong:new _i(new lv,e),torus:new _i(new uv,e),nightly:new _i(new rv,e),...oe.config.ui.walletConnectProjectId?{walletConnect:new _i(new Nz({network:oe.config.isMainnet?Ao.Mainnet:Ao.Devnet,options:{projectId:oe.config.ui.walletConnectProjectId,customStoragePrefix:"wh-connect-solana-adapter"}}),e)}:{}}}async function Uz(s,e,t){if(!e)throw new Error("Wallet not found");if(!oe.config.rpcs.Solana)throw new Error("Solana RPC not found");const i=(t==null?void 0:t.commitment)??"finalized",r=new A.Connection(oe.config.rpcs.Solana),{blockhash:n,lastValidBlockHeight:o}=await r.getLatestBlockhash(i),a=await Dz(r,n,o,s);let c=null,l=null,h=1,d="";const f=(await e.signTransaction(a)).serialize(),g={skipPreflight:!0,maxRetries:0,preFlightCommitment:i};d=await r.sendRawTransaction(f,g),c=r.confirmTransaction({signature:d,blockhash:n,lastValidBlockHeight:o},i);try{for(;!l&&(l=await Promise.race([c,new Promise(v=>setTimeout(()=>{v(null)},5e3))]),!l);){console.log(`Tx not confirmed after ${5e3*h++}ms, resending`);try{await r.sendRawTransaction(f,g)}catch(v){console.error("Failed to resend transaction:",v)}}}catch(y){if(y instanceof Error&&y.name==="TransactionExpiredBlockheightExceededError")for(let w=0;w<5;++w){try{if(await r.getTransaction(d,{commitment:"confirmed",maxSupportedTransactionVersion:0}))return d}catch{}await oe.sleep(2e3)}throw y}if(l.value.err){let y=`Transaction failed: ${l.value.err}`;if(typeof l.value.err=="object")try{y=`Transaction failed: ${JSON.stringify(l.value.err,(v,b)=>typeof b=="bigint"?b.toString():b)}`}catch{y="Transaction failed: Unknown error"}throw new Error(`Transaction failed: ${y}`)}return d}const Lz=Object.freeze(Object.defineProperty({__proto__:null,fetchOptions:Rz,signAndSendTransaction:Uz},Symbol.toStringTag,{value:"Module"}));exports.AccountController=ie;exports.AlertController=wo;exports.ApiController=ue;exports.AssetController=Es;exports.AssetUtil=Kh;exports.ChainController=I;exports.ConnectionController=qe;exports.ConnectorController=le;exports.ConnectorUtil=Io;exports.ConstantsUtil=se;exports.ConstantsUtil$1=Vt;exports.ConstantsUtil$2=Pm;exports.CoreHelperUtil=he;exports.EventsController=Be;exports.Hash=Sf;exports.Hash$1=fw;exports.ModalController=ot;exports.OptionsController=R;exports.RouterController=xe;exports.SIWXUtil=mn;exports.SnackController=vt;exports.StorageUtil=X;exports.ThemeController=Ft;exports.WalletUtil=rc;exports.abytes=Lo;exports.abytes$1=Ko;exports.aexists=Pl;exports.aexists$1=eh;exports.ahash=Hv;exports.ahash$1=LO;exports.aoutput=Cf;exports.aoutput$1=gw;exports.colorStyles=az;exports.concatBytes=s0;exports.concatBytes$1=ZO;exports.createView=Jv;exports.createView$1=KO;exports.elementStyles=oz;exports.initializeTheming=iz;exports.randomBytes=i0;exports.randomBytes$1=JO;exports.resetStyles=nz;exports.rotr=Xv;exports.rotr$1=GO;exports.solana=Lz;exports.toBytes=Mh;exports.toBytes$1=Gh;exports.wrapConstructor=Tf;exports.wrapConstructor$1=yw;