@dcl/blog-site 0.3.1-24533807769.commit-2e68981 → 0.3.1-24574465167.commit-1f456d2

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 (219) hide show
  1. package/assets/AuthorPage-Df6gn9_m.js +1 -0
  2. package/assets/BlogPage-B4pxSza8.js +1 -0
  3. package/assets/CategoryPage-CxeJ3QiI.js +1 -0
  4. package/assets/Media-BiHT3qBR.js +1 -0
  5. package/assets/PageLayout-Ciu0k-U_.js +1 -0
  6. package/assets/PostCard-Dd4F35zx.js +1 -0
  7. package/assets/PostPage-QHfmu2Vt.js +1 -0
  8. package/assets/PostPage.styled-D5lERqJA.js +2 -0
  9. package/assets/PreviewPage-J15Hru2y.js +1 -0
  10. package/assets/{QueryClientProvider-Dv18L3Bf.js → QueryClientProvider-OhEAiC0P.js} +1 -1
  11. package/assets/SEO-DW5vf2xx.js +5 -0
  12. package/assets/SearchPage-Aj2MbbZU.js +1 -0
  13. package/assets/SignInRedirect-qy6q_tZq.js +1 -0
  14. package/assets/{WalletStateProvider-Bb79ArZ-.js → WalletStateProvider-CdpYlS08.js} +1 -1
  15. package/assets/{Web3Inner-CgxSXeS_.js → Web3Inner-BJ-KSM84.js} +1 -1
  16. package/assets/{Web3SyncProvider-D6_GzSKM.js → Web3SyncProvider-CVoNw-Ck.js} +2 -2
  17. package/assets/X-DOiZv48t.js +15 -0
  18. package/assets/__federation_expose_App-8sv1g15i.js +1 -0
  19. package/assets/{__federation_fn_import-BxyPyKYw.js → __federation_fn_import-DNtjaGC4.js} +1 -1
  20. package/assets/__federation_shared_@dcl/core-web3/lazy-DkP-jRSY.js +2 -0
  21. package/assets/__federation_shared_@dcl/{core-web3-CKa_YLUg.js → core-web3-B8eHhcKW.js} +2 -2
  22. package/assets/__federation_shared_@dcl/{hooks-BUl9fwJ6.js → hooks-6RDCWtS0.js} +5 -5
  23. package/assets/__federation_shared_@dcl/schemas-Bx07hTGg.js +1 -0
  24. package/assets/__federation_shared_@emotion/react-TNrN6Qto.js +1 -0
  25. package/assets/__federation_shared_@emotion/{styled-DWCD7TRI.js → styled-CGJjdZ7M.js} +1 -1
  26. package/assets/{__federation_shared_decentraland-ui2-DhNprCzs.js → __federation_shared_decentraland-ui2-Bc45XQnG.js} +28 -31
  27. package/assets/__federation_shared_react-D4NpQaXx.js +1 -0
  28. package/assets/__federation_shared_react-dom-BnMp-IwM.js +1 -0
  29. package/assets/{__federation_shared_react-redux-BbbSoEti.js → __federation_shared_react-redux-C0CNQCVL.js} +1 -1
  30. package/assets/{__federation_shared_react-router-dom-CghPW3T5.js → __federation_shared_react-router-dom-DwnKrWTP.js} +1 -1
  31. package/assets/{__federation_shared_viem-BSisS619.js → __federation_shared_viem-BnQWYaJC.js} +1 -1
  32. package/assets/{__federation_shared_wagmi-BNNJMvLV.js → __federation_shared_wagmi-gkTMllsk.js} +1 -1
  33. package/assets/{add-CdrtIhqC.js → add-CrlFk3Q3.js} +1 -1
  34. package/assets/{all-wallets-Cmla8eMe.js → all-wallets-Cn4vlXAg.js} +1 -1
  35. package/assets/{app-store-ma7uMa9T.js → app-store-Be5qHevD.js} +1 -1
  36. package/assets/{apple-bELCHYbt.js → apple-BLF9iOOU.js} +1 -1
  37. package/assets/{arrow-bottom-DloKu1fV.js → arrow-bottom-DkIzNCmM.js} +1 -1
  38. package/assets/{arrow-bottom-circle-DzXI01oZ.js → arrow-bottom-circle-DTIccLhb.js} +1 -1
  39. package/assets/{arrow-left-B55lkgKK.js → arrow-left-Dn2O6Yc9.js} +1 -1
  40. package/assets/{arrow-right-Bw7eQ4QH.js → arrow-right-BhwoZxOJ.js} +1 -1
  41. package/assets/{arrow-top-Dn6leB_M.js → arrow-top-CKR018aC.js} +1 -1
  42. package/assets/authRedirect-CDwN-vsd.js +1 -0
  43. package/assets/{auto-track-CkHj-ik-.js → auto-track-D5pJjTP0.js} +1 -1
  44. package/assets/{bank-DH1VVekh.js → bank-C7cxDWGw.js} +1 -1
  45. package/assets/{basic-CpaLk7Rk.js → basic-C9P9esct.js} +1 -1
  46. package/assets/{biconomy-C-Aa3WOy.js → biconomy-C3StBANE.js} +1 -1
  47. package/assets/{browser-Cy2ntZlE.js → browser-DJ7_iUnZ.js} +1 -1
  48. package/assets/{card-DeDlu8qm.js → card-JDGi0NHR.js} +1 -1
  49. package/assets/{ccip-O3XMTSRc.js → ccip-CIy6Np-r.js} +1 -1
  50. package/assets/{checkmark-DNVFeB3s.js → checkmark-CPuFFcJX.js} +1 -1
  51. package/assets/{checkmark-bold-DEcOisss.js → checkmark-bold-mWhrN4oP.js} +1 -1
  52. package/assets/{chevron-bottom-xDV_oQI6.js → chevron-bottom-BiS2oxh-.js} +1 -1
  53. package/assets/{chevron-left-BYtOhhqm.js → chevron-left-mgiwYveY.js} +1 -1
  54. package/assets/{chevron-right-CfsnvkD5.js → chevron-right-BBbwfFkV.js} +1 -1
  55. package/assets/{chevron-top-CONIZzEr.js → chevron-top-vRyln5TS.js} +1 -1
  56. package/assets/{chrome-store-D9VGMy-w.js → chrome-store-BMwl9GFC.js} +1 -1
  57. package/assets/{clock-DRArrlZN.js → clock-Cyo1NCoz.js} +1 -1
  58. package/assets/{close-BnL2HnLj.js → close-DpLs-6ut.js} +1 -1
  59. package/assets/{coinPlaceholder-DspCsB1d.js → coinPlaceholder-CMWbyfzw.js} +1 -1
  60. package/assets/{compass-CL9Ubv1C.js → compass-BZlWuYsQ.js} +1 -1
  61. package/assets/config-DzzapLE-.js +1 -0
  62. package/assets/contentful-5JGMFnCq.js +4 -0
  63. package/assets/{controller-BVrxdctz.js → controller-zrh0AA5v.js} +2 -2
  64. package/assets/{copy-DzcJW_6z.js → copy-C8XbJm81.js} +1 -1
  65. package/assets/{core-CNeX_97j.js → core-CmzgCi5e.js} +3 -3
  66. package/assets/{createBundlerClient-BPAMiN0_.js → createBundlerClient-CvVX10zF.js} +1 -1
  67. package/assets/{createClient-B3NJif4G.js → createClient-DuiD_-hg.js} +1 -1
  68. package/assets/{cursor-VEXLPp4L.js → cursor-DgKI5UfF.js} +1 -1
  69. package/assets/{cursor-transparent-eNYb23WQ.js → cursor-transparent-DYc-PvMS.js} +1 -1
  70. package/assets/{decimals-QcoDvy79.js → decimals-BprNBSsW.js} +1 -1
  71. package/assets/{decimals-Bcje5XLK.js → decimals-DC_X5ByZ.js} +1 -1
  72. package/assets/defaultTheme-0boCqa4G.js +1 -0
  73. package/assets/{desktop-B8dtxVkT.js → desktop-BXu5vjTJ.js} +1 -1
  74. package/assets/{detectExtension-CCed483c.js → detectExtension-B_qG6Uj3.js} +1 -1
  75. package/assets/{disconnect-5l_BrY-g.js → disconnect-BIjCZBSY.js} +1 -1
  76. package/assets/{discord-vPm7sSnB.js → discord-BHe20Bgu.js} +1 -1
  77. package/assets/emotion-element-f0de968e.browser.esm-DUNwabDo.js +8 -0
  78. package/assets/{emotion-use-insertion-effect-with-fallbacks.browser.esm-BLv21GTb.js → emotion-use-insertion-effect-with-fallbacks.browser.esm-B88ZkZJW.js} +1 -1
  79. package/assets/{encode-D4fq-GtO.js → encode-w1S6O2Jy.js} +2 -2
  80. package/assets/{engine-C-meN4xY.js → engine-CjoYEL_B.js} +1 -1
  81. package/assets/{estimate-gas-DFiVp-Bb.js → estimate-gas-Clq1zGmM.js} +3 -3
  82. package/assets/{estimate-l1-fee-lAfdaqWJ.js → estimate-l1-fee-D_wtZw7B.js} +1 -1
  83. package/assets/{eth_getStorageAt-DFwf_hwV.js → eth_getStorageAt-BPq1D0T-.js} +1 -1
  84. package/assets/{etherscan-Ck2P6D17.js → etherscan-CG5vA-W6.js} +1 -1
  85. package/assets/events-DqOg3rR3.js +1 -0
  86. package/assets/{exclamation-triangle-DfbN77Lf.js → exclamation-triangle-GyJq4nAX.js} +1 -1
  87. package/assets/{extension-CtEMnFwe.js → extension-muflT2fN.js} +1 -1
  88. package/assets/{external-link-B0IDyBri.js → external-link-DH3pNf93.js} +1 -1
  89. package/assets/{extractIPFS-DIosWHkP.js → extractIPFS-CN8RjoYW.js} +1 -1
  90. package/assets/{facebook-C0UeZpYw.js → facebook-Dvt8S6HP.js} +1 -1
  91. package/assets/{farcaster-CYOZFCGP.js → farcaster-CExK9GF3.js} +1 -1
  92. package/assets/{fee-data-BpKOAsFJ.js → fee-data-ITl-GLgb.js} +1 -1
  93. package/assets/{fetchTokenMetadata-DqYbYFuX.js → fetchTokenMetadata-C8Ab2EFW.js} +2 -2
  94. package/assets/{filters-NBQeHIU7.js → filters-BjkvScGN.js} +1 -1
  95. package/assets/{get-ecosystem-wallet-info-CDZa8BmK.js → get-ecosystem-wallet-info-BMnnm-zL.js} +1 -1
  96. package/assets/{getBalance-Bw5byYn3.js → getBalance-D97jBzkx.js} +1 -1
  97. package/assets/{getInstalledModules-By8IApsm.js → getInstalledModules-bM9ZiQVT.js} +1 -1
  98. package/assets/{getNFT-YU4EH9Wq.js → getNFT-DXArYl_b.js} +2 -2
  99. package/assets/{getNFT-DEyn-Dm_.js → getNFT-o2zOBSOX.js} +1 -1
  100. package/assets/{github-C4rc0OEq.js → github-DIcpmiTD.js} +1 -1
  101. package/assets/{google-kXTnc_BR.js → google-Ckbmg2Ga.js} +1 -1
  102. package/assets/{help-circle-Bwzt3B2p.js → help-circle-s_lVA58g.js} +1 -1
  103. package/assets/{id-zOIHpH1K.js → id-DeQgQo7H.js} +1 -1
  104. package/assets/{image-B1eT9feQ.js → image-DbZ9UUJ_.js} +1 -1
  105. package/assets/{in-app-wallet-calls-C61H1buU.js → in-app-wallet-calls-DzF9AO72.js} +1 -1
  106. package/assets/index-B584AmqK.js +1 -0
  107. package/assets/{index-Dy0yjznp__bundled.js → index-B584AmqK__bundled.js} +1 -1
  108. package/assets/index-BHSHxmEC.js +1 -0
  109. package/assets/{index-BqjaI3ay.js → index-BtR4l8xs.js} +1 -1
  110. package/assets/{index-AMqzEpe3.js → index-BxRTPul1.js} +1 -1
  111. package/assets/{index-DD6DIvwj.js → index-C0Hq4IJY.js} +1 -1
  112. package/assets/index-C1_ZJ2Fz.js +2 -0
  113. package/assets/{index-CQa-TpsF.js → index-C2PA63OZ.js} +2 -2
  114. package/assets/{index-CUrF8sCH.js → index-C7wwE81D.js} +3 -3
  115. package/assets/index-C9JLZTTc.js +1 -0
  116. package/assets/{index-C3DFzjjm.js → index-CA0YZX5c.js} +1 -1
  117. package/assets/index-CDytriL0.js +3 -0
  118. package/assets/{index-BozJS3za.js → index-CFfzHT-l.js} +4 -4
  119. package/assets/{index-B5C7HYRN.js → index-Cl9Sxyic.js} +1 -1
  120. package/assets/index-CsRwhq7r.js +1 -0
  121. package/assets/{index-DFwD9Y6T.js → index-CyHd0GjE.js} +1 -1
  122. package/assets/index-DmRwGcGJ.js +2 -0
  123. package/assets/index-DyjOKhts.js +2 -0
  124. package/assets/index-_YWtfAHj.js +1 -0
  125. package/assets/{index-BjzJcZq6__bundled.js → index-_YWtfAHj__bundled.js} +1 -1
  126. package/assets/{index-C1_xRJU5.js → index-eLC4bAt3.js} +1 -1
  127. package/assets/{index-BOPorWEt.js → index-yCW6eWvL.js} +1 -1
  128. package/assets/index.es-BRoT1QUU.js +2 -0
  129. package/assets/{index.es-D3pP9hN4.js → index.es-Bjzmmtjk.js} +1 -1
  130. package/assets/{index.es-CX6b-_J8.js → index.es-DDZKss3Y.js} +1 -1
  131. package/assets/{index.es-Co6Vfgvo.js → index.es-t7HDtKGz.js} +3 -3
  132. package/assets/index.modern-zayAXp-r.js +5 -0
  133. package/assets/index.umd-ddl_WOWs.js +1 -0
  134. package/assets/{info-fCoUT5OA.js → info-B83FYyYF.js} +1 -1
  135. package/assets/{info-circle-BSc3Qu0H.js → info-circle-BIW8YsHS.js} +1 -1
  136. package/assets/{jsx-runtime-DncYoG30.js → jsx-runtime-BWEVYhay.js} +1 -1
  137. package/assets/{jsx-runtime-DncYoG30__bundled.js → jsx-runtime-BWEVYhay__bundled.js} +1 -1
  138. package/assets/{lightbulb-CtEeQpR-.js → lightbulb-D3FjAVfy.js} +1 -1
  139. package/assets/{mail-CyEGKrO1.js → mail-B-gu_WkI.js} +1 -1
  140. package/assets/{mobile-va3MMBf-.js → mobile-COjPZ1X2.js} +1 -1
  141. package/assets/{more-CNKLmFKq.js → more-Ra8fJn--.js} +1 -1
  142. package/assets/{network-placeholder-COaPFv9Z.js → network-placeholder-DWM9do2v.js} +1 -1
  143. package/assets/{nftPlaceholder-CwqKeCBT.js → nftPlaceholder-BkuiJ1Fi.js} +1 -1
  144. package/assets/{off-BXJei5ZC.js → off-KeVYYonx.js} +1 -1
  145. package/assets/{openzeppelin-5tViGSfu.js → openzeppelin-65KMFHrE.js} +1 -1
  146. package/assets/{ownerOf-B0jDYVPj.js → ownerOf-B5EfXA60.js} +1 -1
  147. package/assets/{parseNft-C9UVkjKp.js → parseNft-CtU7M4OG.js} +2 -2
  148. package/assets/{play-store-DPqFtu_u.js → play-store-Dvga_7y6.js} +1 -1
  149. package/assets/{plus-BRStu8oq.js → plus-1d7HZSRm.js} +1 -1
  150. package/assets/{preload-helper-DtiUdDj_.js → preload-helper-5SOR_wM4.js} +1 -1
  151. package/assets/{qr-code-zVq-PsFR.js → qr-code-DHi3Cbzt.js} +1 -1
  152. package/assets/{qr-overlay-CzG9L326.js → qr-overlay-wjVP52h3.js} +1 -1
  153. package/assets/{recycle-horizontal-BUcJt7KV.js → recycle-horizontal-f80ctvB9.js} +1 -1
  154. package/assets/{refresh-DoJwoFWZ.js → refresh-DCOqM3zJ.js} +1 -1
  155. package/assets/remoteEntry.js +1 -1
  156. package/assets/{reown-logo-VGJ4-w32.js → reown-logo-Bh1MMtyx.js} +1 -1
  157. package/assets/{resolveImplementation-CDZMD3pd.js → resolveImplementation-eBjFZj8j.js} +1 -1
  158. package/assets/rich-text-react-renderer.es5-DX5s0zF9.js +2 -0
  159. package/assets/{search-qfys2xfh.js → search-CZQy06by.js} +1 -1
  160. package/assets/{send-BNIku3tf.js → send-D-TwjhV1.js} +1 -1
  161. package/assets/{send-batch-transaction-DJsVdrRi.js → send-batch-transaction-Ugc9XCfc.js} +1 -1
  162. package/assets/{send-eip712-transaction-zZlwlA8h.js → send-eip712-transaction-CsbokYJ3.js} +2 -2
  163. package/assets/{send-gasless-transaction-0zsgzkl7.js → send-gasless-transaction-XWm5OsJP.js} +2 -2
  164. package/assets/{serializeAuthorizationList-B224vId9.js → serializeAuthorizationList-sXgqtd3N.js} +1 -1
  165. package/assets/{session-proposal-DQKIaN0P.js → session-proposal-BZkE3xXx.js} +1 -1
  166. package/assets/{session-request-DO6jaRLL.js → session-request-BS122IY1.js} +2 -2
  167. package/assets/{signing-D7Amo-_J.js → signing-DLkAwP5Y.js} +3 -3
  168. package/assets/{slice-D08eqHRd.js → slice-D5Jq-FmM.js} +1 -1
  169. package/assets/{slice-DH_M4Fq9.js → slice-DpowZ_6S.js} +1 -1
  170. package/assets/{swapHorizontal-D4EMXwCW.js → swapHorizontal-DH1W1UoG.js} +1 -1
  171. package/assets/{swapHorizontalBold-DPzDpA5S.js → swapHorizontalBold-D8QA6zjc.js} +1 -1
  172. package/assets/{swapHorizontalMedium-BO1_vkWp.js → swapHorizontalMedium-D6iiMSB9.js} +1 -1
  173. package/assets/{swapHorizontalRoundedBold-D5f2zm5T.js → swapHorizontalRoundedBold-CG0CSrfy.js} +1 -1
  174. package/assets/{swapVertical-Cl2TRZgu.js → swapVertical-BVkEaika.js} +1 -1
  175. package/assets/{telegram-COuwS3-1.js → telegram-BRL2ke_g.js} +1 -1
  176. package/assets/{thirdweb-ChZTN2O0.js → thirdweb-B-Xe4N-j.js} +3 -3
  177. package/assets/{three-dots-DaJ9Yk_z.js → three-dots-Ce3AHErA.js} +1 -1
  178. package/assets/{totalSupply-CeZQpDgj.js → totalSupply-BycaSCJm.js} +1 -1
  179. package/assets/{twitch-ChHlcjtL.js → twitch-BOhm2e6I.js} +1 -1
  180. package/assets/{twitterIcon-BHaGUsBd.js → twitterIcon-Bi32kZ_p.js} +1 -1
  181. package/assets/{uid-BE5dre25.js → uid-Cob2hcqP.js} +3 -3
  182. package/assets/useInfiniteBlogPosts-CA3uk6ie.js +1 -0
  183. package/assets/{verify-BJHlq4Cl.js → verify-XBYDp8cg.js} +1 -1
  184. package/assets/{verify-filled-CUQ_cX7L.js → verify-filled-DIs-cByX.js} +1 -1
  185. package/assets/{w3m-modal-BQt7iWW0.js → w3m-modal-CkzQCU-p.js} +1 -1
  186. package/assets/{wait-for-tx-receipt-mEy_aAXI.js → wait-for-tx-receipt-BmfZs18K.js} +1 -1
  187. package/assets/{wallet-Bqa5aoUK.js → wallet-DhGCzxG1.js} +1 -1
  188. package/assets/{wallet-placeholder-ZqWJAmHm.js → wallet-placeholder-CbhoKZ6M.js} +1 -1
  189. package/assets/{walletconnect-DgD3JeRt.js → walletconnect-Bo6cSb7c.js} +1 -1
  190. package/assets/{wallets-DBEqpf9_.js → wallets-DpmOypgu.js} +5 -5
  191. package/assets/{warning-circle-C-GR2K3_.js → warning-circle-DXO4TTWk.js} +1 -1
  192. package/assets/{web-connector-DbEpPXWA.js → web-connector-D9njQB_l.js} +3 -3
  193. package/assets/{webSocket-D9rKCHPk.js → webSocket-i6CHiIgb.js} +1 -1
  194. package/assets/{x-dxs8B49F.js → x-5st4UAZO.js} +1 -1
  195. package/index.html +29 -16
  196. package/package.json +3 -3
  197. package/assets/SignInRedirect-CXE_9i3I.js +0 -9
  198. package/assets/X-Bfq5REIM.js +0 -15
  199. package/assets/___vite-browser-external_commonjs-proxy-BqV5D26a.js +0 -1
  200. package/assets/__federation_expose_App-c8Vsr-t8.js +0 -1
  201. package/assets/__federation_shared_@dcl/core-web3/lazy-CB9aN5En.js +0 -2
  202. package/assets/__federation_shared_@dcl/schemas-DMXTEmDf.js +0 -1
  203. package/assets/__federation_shared_@emotion/react-Dqhl2Mup.js +0 -1
  204. package/assets/__federation_shared_react-B3tlNTLg.js +0 -1
  205. package/assets/__federation_shared_react-dom-CCS4dT_K.js +0 -1
  206. package/assets/_commonjsHelpers-C4iS2aBk.js +0 -1
  207. package/assets/emotion-react.browser.esm-C-lDaXQ7.js +0 -8
  208. package/assets/events-B5inrCVE.js +0 -1
  209. package/assets/index-BjA_RJ3F.js +0 -2
  210. package/assets/index-BjzJcZq6.js +0 -1
  211. package/assets/index-C1IoT2if.js +0 -3
  212. package/assets/index-CgX6dKUG.js +0 -2
  213. package/assets/index-DU4RVPgw.js +0 -1
  214. package/assets/index-Dy0yjznp.js +0 -1
  215. package/assets/index-IYkCvEK_.js +0 -1
  216. package/assets/index-Tsk25L8E.js +0 -1
  217. package/assets/index.es-D5YKsq2-.js +0 -2
  218. package/assets/index.umd-DK712HHb.js +0 -1
  219. package/assets/rich-text-react-renderer.es5-D_tE7AHo.js +0 -2
@@ -1,4 +1,4 @@
1
- import{w as l}from"./core-CNeX_97j.js";const e=l`<svg fill="none" viewBox="0 0 20 20">
1
+ import{w as l}from"./core-CmzgCi5e.js";const e=l`<svg fill="none" viewBox="0 0 20 20">
2
2
  <path
3
3
  fill="currentColor"
4
4
  d="M11 6.67a1 1 0 1 0-2 0v2.66a1 1 0 0 0 2 0V6.67ZM10 14.5a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Z"
@@ -1,9 +1,9 @@
1
- const __vite__fileDeps=["assets/eth_getTransactionCount-DWnnw2mX.js","assets/hex-B0Rx0hII.js","assets/in-app-wallet-calls-C61H1buU.js","assets/wait-for-tx-receipt-mEy_aAXI.js","assets/__federation_fn_import-BxyPyKYw.js","assets/rpc-ti0b0r_u.js","assets/utils-CozXUO91.js","assets/withCache-DYumIHzL.js","assets/json-BHzNJmTy.js","assets/sleep-mAKpSMLY.js","assets/send-batch-transaction-DJsVdrRi.js","assets/signing-D7Amo-_J.js","assets/preload-helper-DtiUdDj_.js","assets/fee-data-BpKOAsFJ.js","assets/op-gas-fee-reducer-CfxMcvXl.js","assets/estimate-gas-DFiVp-Bb.js","assets/encode-D4fq-GtO.js","assets/wallets-DBEqpf9_.js","assets/store-DOLZnwHk.js","assets/publicKeyToAddress-CxEKPAKT.js","assets/utils-C7urdXtO.js","assets/events-B5inrCVE.js","assets/_commonjsHelpers-C4iS2aBk.js","assets/index.es-D3pP9hN4.js","assets/index-nibyPLVP.js","assets/ethereum-dN7ENYl_.js","assets/passkeys-CTJ4NPfL.js","assets/uint8-array-DZKEMhA1.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
2
- import{_ as f}from"./preload-helper-DtiUdDj_.js";import{b as w,a as p,g as E}from"./withCache-DYumIHzL.js";import{S as G,r as V,p as _,T as D,U as F,W as q,X as Q,Z as H,_ as J,$ as Y}from"./wallets-DBEqpf9_.js";import{stringify as u}from"./json-BHzNJmTy.js";import{getCachedChain as I}from"./utils-CozXUO91.js";import{importShared as Z}from"./__federation_fn_import-BxyPyKYw.js";import{g as b,t as U,b as X}from"./estimate-gas-DFiVp-Bb.js";import{c as N}from"./signing-D7Amo-_J.js";import{getRpcClient as A}from"./rpc-ti0b0r_u.js";import{t as P,b as K}from"./hex-B0Rx0hII.js";import{s as k}from"./sleep-mAKpSMLY.js";const T=new Map,ee={getItem:async t=>T.get(t)??null,removeItem:async t=>{T.delete(t)},setItem:async(t,e)=>{T.set(t,e)}};async function S({authToken:t,client:e,ecosystem:i}){const s=await p(e,i)(`${w("inAppWallet")}/api/2024-05-05/accounts`,{headers:{Authorization:`Bearer embedded-wallet-token:${t}`,"Content-Type":"application/json"},method:"GET"});if(!s.ok){const c=await s.text().catch(()=>"Unknown error");throw new Error(`Failed to get user info: ${c}`)}return await s.json()}const te=w("inAppWallet"),ie=`${te}/`,B=`${ie}api/2023-10-20`,ae=`${B}/embedded-wallet/validate-custom-jwt`,ne=`${B}/embedded-wallet/validate-custom-auth-endpoint`,R=(t,e)=>e instanceof Error?`${t}: ${e.message}`:`${t}: ${u(e)}`;async function se(t){const i=await p(t.client,t.ecosystem)(ne,{body:u({developerClientId:t.client.clientId,payload:t.payload}),headers:{"Content-Type":"application/json"},method:"POST"});if(!i.ok){const a=await i.json();throw new Error(`Custom auth endpoint authentication error: ${a.message}`)}try{const{verifiedToken:a}=await i.json();return{storedToken:a}}catch(a){throw new Error(R("Malformed response from post auth_endpoint authentication",a))}}const M=t=>{if(!G.includes(t))throw new Error(`Unknown auth option ${t}`);switch(t){case"wallet":return"siwe";default:return t}},v=({authOption:t,client:e,ecosystem:i,mode:a="popup",redirectUrl:s,authFlow:c})=>{if(a==="popup"&&s)throw new Error("Redirect URL is not supported for popup mode");if(a==="window"&&!s)throw new Error("Redirect URL is required for window mode");const r=M(t);let n=`${w("inAppWallet")}/api/2024-05-05/login/${r}?clientId=${e.clientId}`;if(i?.partnerId?n=`${n}&ecosystemId=${i.id}&ecosystemPartnerId=${i.partnerId}`:i&&(n=`${n}&ecosystemId=${i.id}`),a!=="popup"){const l=new URL(s||window.location.href);l.searchParams.set("walletId",i?.id||"inApp"),l.searchParams.set("authProvider",t),c&&l.searchParams.set("authFlow",c),n=`${n}&redirectUrl=${encodeURIComponent(l.toString())}`}return n},W=({authOption:t,client:e,ecosystem:i})=>{const a=M(t);let s=`${w("inAppWallet")}/api/2024-05-05/login/${a}/callback?clientId=${e.clientId}`;return i?.partnerId?s=`${s}&ecosystemId=${i.id}&ecosystemPartnerId=${i.partnerId}`:i&&(s=`${s}&ecosystemId=${i.id}`),s};async function re(t){const e=p(t.client,t.ecosystem),i=v({authOption:"backend",client:t.client,ecosystem:t.ecosystem}),a=await e(`${i}`,{body:u({walletSecret:t.walletSecret}),headers:{"Content-Type":"application/json"},method:"POST"});if(!a.ok){const s=await a.text();throw new Error(`Failed to generate backend account: ${s}`)}return await a.json()}async function oe(t){let e=await t.storage.getGuestSessionId();e||(e=V(32),t.storage.saveGuestSessionId(e));const i=p(t.client,t.ecosystem),a=W({authOption:"guest",client:t.client,ecosystem:t.ecosystem}),s=await i(`${a}`,{body:u({sessionId:e}),headers:{"Content-Type":"application/json"},method:"POST"});if(!s.ok){const c=await s.text();throw new Error(`Failed to generate guest account: ${s.status} ${s.statusText} ${c}`)}return await s.json()}async function ce(t){const i=await p(t.client,t.ecosystem)(ae,{body:u({developerClientId:t.client.clientId,jwt:t.jwt}),headers:{"Content-Type":"application/json"},method:"POST"});if(!i.ok){const a=await i.json();throw new Error(`JWT authentication error: ${a.message}`)}try{const{verifiedToken:a}=await i.json();return{storedToken:a}}catch(a){throw new Error(R("Malformed response from post jwt authentication",a))}}function z(){return`${w("inAppWallet")}/api/2024-05-05/login/passkey/callback`}function x(t,e){return`${w("inAppWallet")}/api/2024-05-05/login/passkey?type=${t}${e?`&username=${e}`:""}`}async function le(t){if(!t.passkeyClient.isAvailable())throw new Error("Passkeys are not available on this device");const e=p(t.client,t.ecosystem),i=t.username??ue(t.ecosystem),s=await(await e(x("sign-up",i))).json();if(!s.challenge)throw new Error("No challenge received");const c=s.challenge,r=await t.passkeyClient.register({challenge:c,name:i,rp:t.rp}),n={};t.ecosystem?.partnerId&&(n["x-ecosystem-partner-id"]=t.ecosystem.partnerId),t.ecosystem?.id&&(n["x-ecosystem-id"]=t.ecosystem.id);const o=await(await e(z(),{body:u({authenticatorData:r.authenticatorData,clientData:r.clientData,credential:{algorithm:r.credential.algorithm,publicKey:r.credential.publicKey},credentialId:r.credentialId,origin:r.origin,rpId:t.rp.id,serverVerificationId:s.serverVerificationId,type:"sign-up",username:i}),headers:{"Content-Type":"application/json",...n},method:"POST"})).json();if(!o||!o.storedToken)throw new Error(`Error verifying passkey: ${o.message??"unknown error"}`);return await t.storage?.savePasskeyCredentialId(r.credentialId),o}async function de(t){if(!t.passkeyClient.isAvailable())throw new Error("Passkeys are not available on this device");const e=p(t.client,t.ecosystem),[i,a]=await Promise.all([e(x("sign-in")).then(o=>o.json()),t.storage?.getPasskeyCredentialId()]);if(!i.challenge)throw new Error("No challenge received");const s=i.challenge,c=await t.passkeyClient.authenticate({challenge:s,credentialId:a??void 0,rp:t.rp}),r={};t.ecosystem?.partnerId&&(r["x-ecosystem-partner-id"]=t.ecosystem.partnerId),t.ecosystem?.id&&(r["x-ecosystem-id"]=t.ecosystem.id);const l=await(await e(z(),{body:u({authenticatorData:c.authenticatorData,clientData:c.clientData,credentialId:c.credentialId,origin:c.origin,rpId:t.rp.id,serverVerificationId:i.serverVerificationId,signature:c.signature,type:"sign-in"}),headers:{"Content-Type":"application/json",...r},method:"POST"})).json();if(!l||!l.storedToken)throw new Error(`Error verifying passkey: ${l.message??"unknown error"}`);return await t.storage?.savePasskeyCredentialId(c.credentialId),l}function ue(t){return`${t?.id??"wallet"}-${new Date().toISOString()}`}function he(t){let a=[`${t.domain} wants you to sign in with your Ethereum account:`,t.address].join(`
1
+ const __vite__fileDeps=["assets/eth_getTransactionCount-DWnnw2mX.js","assets/hex-B0Rx0hII.js","assets/in-app-wallet-calls-DzF9AO72.js","assets/wait-for-tx-receipt-BmfZs18K.js","assets/__federation_fn_import-DNtjaGC4.js","assets/rpc-ti0b0r_u.js","assets/utils-CozXUO91.js","assets/withCache-DYumIHzL.js","assets/json-BHzNJmTy.js","assets/sleep-mAKpSMLY.js","assets/send-batch-transaction-Ugc9XCfc.js","assets/signing-DLkAwP5Y.js","assets/preload-helper-5SOR_wM4.js","assets/fee-data-ITl-GLgb.js","assets/op-gas-fee-reducer-CfxMcvXl.js","assets/estimate-gas-Clq1zGmM.js","assets/encode-w1S6O2Jy.js","assets/wallets-DpmOypgu.js","assets/store-DOLZnwHk.js","assets/publicKeyToAddress-CxEKPAKT.js","assets/utils-C7urdXtO.js","assets/events-DqOg3rR3.js","assets/contentful-5JGMFnCq.js","assets/index.es-Bjzmmtjk.js","assets/index-nibyPLVP.js","assets/ethereum-dN7ENYl_.js","assets/passkeys-CTJ4NPfL.js","assets/uint8-array-DZKEMhA1.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
2
+ import{_ as f}from"./preload-helper-5SOR_wM4.js";import{b as w,a as p,g as E}from"./withCache-DYumIHzL.js";import{S as G,r as V,p as _,T as D,U as F,W as q,X as Q,Z as H,_ as J,$ as Y}from"./wallets-DpmOypgu.js";import{stringify as u}from"./json-BHzNJmTy.js";import{getCachedChain as I}from"./utils-CozXUO91.js";import{importShared as Z}from"./__federation_fn_import-DNtjaGC4.js";import{g as b,t as U,b as X}from"./estimate-gas-Clq1zGmM.js";import{c as N}from"./signing-DLkAwP5Y.js";import{getRpcClient as A}from"./rpc-ti0b0r_u.js";import{t as P,b as K}from"./hex-B0Rx0hII.js";import{s as k}from"./sleep-mAKpSMLY.js";const T=new Map,ee={getItem:async t=>T.get(t)??null,removeItem:async t=>{T.delete(t)},setItem:async(t,e)=>{T.set(t,e)}};async function S({authToken:t,client:e,ecosystem:i}){const s=await p(e,i)(`${w("inAppWallet")}/api/2024-05-05/accounts`,{headers:{Authorization:`Bearer embedded-wallet-token:${t}`,"Content-Type":"application/json"},method:"GET"});if(!s.ok){const c=await s.text().catch(()=>"Unknown error");throw new Error(`Failed to get user info: ${c}`)}return await s.json()}const te=w("inAppWallet"),ie=`${te}/`,B=`${ie}api/2023-10-20`,ae=`${B}/embedded-wallet/validate-custom-jwt`,ne=`${B}/embedded-wallet/validate-custom-auth-endpoint`,R=(t,e)=>e instanceof Error?`${t}: ${e.message}`:`${t}: ${u(e)}`;async function se(t){const i=await p(t.client,t.ecosystem)(ne,{body:u({developerClientId:t.client.clientId,payload:t.payload}),headers:{"Content-Type":"application/json"},method:"POST"});if(!i.ok){const a=await i.json();throw new Error(`Custom auth endpoint authentication error: ${a.message}`)}try{const{verifiedToken:a}=await i.json();return{storedToken:a}}catch(a){throw new Error(R("Malformed response from post auth_endpoint authentication",a))}}const M=t=>{if(!G.includes(t))throw new Error(`Unknown auth option ${t}`);switch(t){case"wallet":return"siwe";default:return t}},v=({authOption:t,client:e,ecosystem:i,mode:a="popup",redirectUrl:s,authFlow:c})=>{if(a==="popup"&&s)throw new Error("Redirect URL is not supported for popup mode");if(a==="window"&&!s)throw new Error("Redirect URL is required for window mode");const r=M(t);let n=`${w("inAppWallet")}/api/2024-05-05/login/${r}?clientId=${e.clientId}`;if(i?.partnerId?n=`${n}&ecosystemId=${i.id}&ecosystemPartnerId=${i.partnerId}`:i&&(n=`${n}&ecosystemId=${i.id}`),a!=="popup"){const l=new URL(s||window.location.href);l.searchParams.set("walletId",i?.id||"inApp"),l.searchParams.set("authProvider",t),c&&l.searchParams.set("authFlow",c),n=`${n}&redirectUrl=${encodeURIComponent(l.toString())}`}return n},W=({authOption:t,client:e,ecosystem:i})=>{const a=M(t);let s=`${w("inAppWallet")}/api/2024-05-05/login/${a}/callback?clientId=${e.clientId}`;return i?.partnerId?s=`${s}&ecosystemId=${i.id}&ecosystemPartnerId=${i.partnerId}`:i&&(s=`${s}&ecosystemId=${i.id}`),s};async function re(t){const e=p(t.client,t.ecosystem),i=v({authOption:"backend",client:t.client,ecosystem:t.ecosystem}),a=await e(`${i}`,{body:u({walletSecret:t.walletSecret}),headers:{"Content-Type":"application/json"},method:"POST"});if(!a.ok){const s=await a.text();throw new Error(`Failed to generate backend account: ${s}`)}return await a.json()}async function oe(t){let e=await t.storage.getGuestSessionId();e||(e=V(32),t.storage.saveGuestSessionId(e));const i=p(t.client,t.ecosystem),a=W({authOption:"guest",client:t.client,ecosystem:t.ecosystem}),s=await i(`${a}`,{body:u({sessionId:e}),headers:{"Content-Type":"application/json"},method:"POST"});if(!s.ok){const c=await s.text();throw new Error(`Failed to generate guest account: ${s.status} ${s.statusText} ${c}`)}return await s.json()}async function ce(t){const i=await p(t.client,t.ecosystem)(ae,{body:u({developerClientId:t.client.clientId,jwt:t.jwt}),headers:{"Content-Type":"application/json"},method:"POST"});if(!i.ok){const a=await i.json();throw new Error(`JWT authentication error: ${a.message}`)}try{const{verifiedToken:a}=await i.json();return{storedToken:a}}catch(a){throw new Error(R("Malformed response from post jwt authentication",a))}}function z(){return`${w("inAppWallet")}/api/2024-05-05/login/passkey/callback`}function x(t,e){return`${w("inAppWallet")}/api/2024-05-05/login/passkey?type=${t}${e?`&username=${e}`:""}`}async function le(t){if(!t.passkeyClient.isAvailable())throw new Error("Passkeys are not available on this device");const e=p(t.client,t.ecosystem),i=t.username??ue(t.ecosystem),s=await(await e(x("sign-up",i))).json();if(!s.challenge)throw new Error("No challenge received");const c=s.challenge,r=await t.passkeyClient.register({challenge:c,name:i,rp:t.rp}),n={};t.ecosystem?.partnerId&&(n["x-ecosystem-partner-id"]=t.ecosystem.partnerId),t.ecosystem?.id&&(n["x-ecosystem-id"]=t.ecosystem.id);const o=await(await e(z(),{body:u({authenticatorData:r.authenticatorData,clientData:r.clientData,credential:{algorithm:r.credential.algorithm,publicKey:r.credential.publicKey},credentialId:r.credentialId,origin:r.origin,rpId:t.rp.id,serverVerificationId:s.serverVerificationId,type:"sign-up",username:i}),headers:{"Content-Type":"application/json",...n},method:"POST"})).json();if(!o||!o.storedToken)throw new Error(`Error verifying passkey: ${o.message??"unknown error"}`);return await t.storage?.savePasskeyCredentialId(r.credentialId),o}async function de(t){if(!t.passkeyClient.isAvailable())throw new Error("Passkeys are not available on this device");const e=p(t.client,t.ecosystem),[i,a]=await Promise.all([e(x("sign-in")).then(o=>o.json()),t.storage?.getPasskeyCredentialId()]);if(!i.challenge)throw new Error("No challenge received");const s=i.challenge,c=await t.passkeyClient.authenticate({challenge:s,credentialId:a??void 0,rp:t.rp}),r={};t.ecosystem?.partnerId&&(r["x-ecosystem-partner-id"]=t.ecosystem.partnerId),t.ecosystem?.id&&(r["x-ecosystem-id"]=t.ecosystem.id);const l=await(await e(z(),{body:u({authenticatorData:c.authenticatorData,clientData:c.clientData,credentialId:c.credentialId,origin:c.origin,rpId:t.rp.id,serverVerificationId:i.serverVerificationId,signature:c.signature,type:"sign-in"}),headers:{"Content-Type":"application/json",...r},method:"POST"})).json();if(!l||!l.storedToken)throw new Error(`Error verifying passkey: ${l.message??"unknown error"}`);return await t.storage?.savePasskeyCredentialId(c.credentialId),l}function ue(t){return`${t?.id??"wallet"}-${new Date().toISOString()}`}function he(t){let a=[`${t.domain} wants you to sign in with your Ethereum account:`,t.address].join(`
3
3
  `);a=[a,t.statement].join(`
4
4
 
5
5
  `),t.statement&&(a+=`
6
6
  `);const s=[];if(t.uri){const d=`URI: ${t.uri}`;s.push(d)}const c=`Version: ${t.version}`;if(s.push(c),t.chain_id){const d=`Chain ID: ${t.chain_id}`||"1";s.push(d)}const r=`Nonce: ${t.nonce}`;s.push(r);const n=`Issued At: ${t.issued_at}`;s.push(n);const l=`Expiration Time: ${t.expiration_time}`;if(s.push(l),t.invalid_before){const d=`Not Before: ${t.invalid_before}`;s.push(d)}t.resources&&s.push(["Resources:",...t.resources.map(d=>`- ${d}`)].join(`
7
7
  `));const o=s.join(`
8
8
  `);return[a,o].join(`
9
- `)}async function we(t){const{payload:e,account:i}=t,a=await i.signMessage({message:he(e)});return{payload:e,signature:a}}const pe=["xyz.abs"];async function me(t){const{wallet:e,client:i,ecosystem:a,chain:s}=t,c=pe.includes(e.id)?s||I(1):I(1),r=e.getAccount()||await e.connect({chain:c,client:i}),n=p(i,a),l=await(async()=>{const h=v({authOption:"wallet",client:t.client,ecosystem:t.ecosystem}),m=await n(`${h}&address=${r.address}&chainId=${c.id}`);if(!m.ok)throw new Error("Failed to generate SIWE login payload");return await m.json()})(),{signature:o}=await we({account:r,payload:l});return await(async()=>{const h=W({authOption:"wallet",client:t.client,ecosystem:t.ecosystem}),m=await n(`${h}&signature=${o}&payload=${encodeURIComponent(l)}`,{body:u({payload:l,signature:o}),headers:{"Content-Type":"application/json"},method:"POST"});if(!m.ok)throw new Error("Failed to verify SIWE signature");return await m.json()})()}async function ge({client:t,payload:e,storage:i}){const a=await i.getAuthCookie(),s=i.ecosystem,c=p(t,s);if(!a)throw new Error("No auth token found when signing message");const r={address:e.address,chainId:e.chainId,nonce:Number(e.nonce)},n=await c(`${w("inAppWallet")}/api/v1/enclave-wallet/sign-authorization`,{body:u(r),headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json","x-thirdweb-client-id":t.clientId},method:"POST"});if(!n.ok)throw new Error(`Failed to sign message - ${n.status} ${n.statusText}`);return await n.json()}async function ye({client:t,payload:{message:e,isRaw:i,originalMessage:a,chainId:s},storage:c}){const r=await c.getAuthCookie(),n=c.ecosystem,l=p(t,n);if(!r)throw new Error("No auth token found when signing message");const o=await l(`${w("inAppWallet")}/api/v1/enclave-wallet/sign-message`,{body:u({messagePayload:{chainId:s,isRaw:i,message:e,originalMessage:a}}),headers:{Authorization:`Bearer embedded-wallet-token:${r}`,"Content-Type":"application/json","x-thirdweb-client-id":t.clientId},method:"POST"});if(!o.ok)throw new Error(`Failed to sign message - ${o.status} ${o.statusText}`);return await o.json()}async function fe({client:t,payload:e,storage:i}){const a=await i.getAuthCookie(),s=i.ecosystem,c=p(t,s);if(!a)throw new Error("No auth token found when signing transaction");const r=await c(`${w("inAppWallet")}/api/v1/enclave-wallet/sign-transaction`,{body:u({transactionPayload:e}),headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json","x-thirdweb-client-id":t.clientId},method:"POST"});if(!r.ok)throw new Error(`Failed to sign transaction - ${r.status} ${r.statusText}`);return(await r.json()).signature}async function be({client:t,payload:e,storage:i}){const a=await i.getAuthCookie(),s=i.ecosystem,c=p(t,s);if(!a)throw new Error("No auth token found when signing typed data");const r=await c(`${w("inAppWallet")}/api/v1/enclave-wallet/sign-typed-data`,{body:u({...e}),headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json","x-thirdweb-client-id":t.clientId},method:"POST"});if(!r.ok)throw new Error(`Failed to sign typed data - ${r.status} ${r.statusText}`);return await r.json()}const{bytesToHex:Ie}=await Z("viem");class ve{constructor({client:e,ecosystem:i,address:a,storage:s}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"address",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=i,this.address=a,this.localStorage=s}async postWalletSetUp(e){await this.localStorage.saveAuthCookie(e.storedToken.cookieString)}async getUserWalletStatus(){const e=await this.localStorage.getAuthCookie();if(!e)return{status:"Logged Out"};const i=await S({authToken:e,client:this.client,ecosystem:this.ecosystem});if(!i)return{status:"Logged Out"};const a=i.wallets[0],s={email:i.linkedAccounts.find(c=>c.details.email!==void 0)?.details.email,phoneNumber:i.linkedAccounts.find(c=>c.details.phone!==void 0)?.details.phone,recoveryShareManagement:"ENCLAVE",userWalletId:i.id||""};return a?{account:await this.getAccount(),authDetails:s,status:"Logged In, Wallet Initialized",walletAddress:a.address}:{authDetails:s,status:"Logged In, Wallet Uninitialized"}}async getAccount(){const e=this.client,i=this.localStorage,a=this.address,s=this.ecosystem,c=async n=>{const l=A({chain:I(n.chainId),client:e}),o={chainId:P(n.chainId),data:n.data,gas:g(n.gas),nonce:g(n.nonce)||P(await f(async()=>{const{eth_getTransactionCount:d}=await import("./eth_getTransactionCount-DWnnw2mX.js");return{eth_getTransactionCount:d}},__vite__mapDeps([0,1])).then(({eth_getTransactionCount:d})=>d(l,{address:b(this.address),blockTag:"pending"}))),to:n.to?b(n.to):void 0,value:g(n.value)};return n.authorizationList&&n.authorizationList.length>0?(o.type=4,o.authorizationList=n.authorizationList,o.maxFeePerGas=g(n.maxFeePerGas),o.maxPriorityFeePerGas=g(n.maxPriorityFeePerGas)):g(n.maxFeePerGas)?(o.maxFeePerGas=g(n.maxFeePerGas),o.maxPriorityFeePerGas=g(n.maxPriorityFeePerGas),o.type=2):(o.gasPrice=g(n.gasPrice),o.type=0),fe({client:e,payload:o,storage:i})},r={address:b(a),async sendTransaction(n){const l=A({chain:I(n.chainId),client:e}),o=await c(n),d=await N(l,o);return U({chainId:n.chainId,client:e,contractAddress:n.to??void 0,ecosystem:s,gasPrice:n.gasPrice,transactionHash:d,walletAddress:a,walletType:"inApp"}),{transactionHash:d}},async signAuthorization(n){const l=await ge({client:e,payload:n,storage:i});return{address:b(l.address),chainId:Number.parseInt(l.chainId),nonce:BigInt(l.nonce),r:BigInt(l.r),s:BigInt(l.s),yParity:Number.parseInt(l.yParity)}},async signMessage({message:n,originalMessage:l,chainId:o}){const d=typeof n=="string"?{chainId:o,isRaw:!1,message:n,originalMessage:l}:{chainId:o,isRaw:!0,message:typeof n.raw=="string"?n.raw:Ie(n.raw),originalMessage:l},{signature:h}=await ye({client:e,payload:d,storage:i});return h},async signTransaction(n){if(!n.chainId)throw new Error("chainId required in tx to sign");return c({chainId:n.chainId,...n})},async signTypedData(n){const l=_(n),{signature:o}=await be({client:e,payload:l,storage:i});return o},sendCalls:async n=>{const{inAppWalletSendCalls:l}=await f(async()=>{const{inAppWalletSendCalls:y}=await import("./in-app-wallet-calls-C61H1buU.js");return{inAppWalletSendCalls:y}},__vite__mapDeps([2,3,4,5,6,7,8,9,1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25])),o=n.calls[0];if(!o)throw new Error("No calls to send");const d=o.client,h=o.chain||n.chain,m=await l({account:r,calls:n.calls,chain:h});return{chain:h,client:d,id:m}},getCallsStatus:async n=>{const{inAppWalletGetCallsStatus:l}=await f(async()=>{const{inAppWalletGetCallsStatus:o}=await import("./in-app-wallet-calls-C61H1buU.js");return{inAppWalletGetCallsStatus:o}},__vite__mapDeps([2,3,4,5,6,7,8,9,1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]));return l(n)},getCallsStatusRaw:async n=>{const{inAppWalletGetCallsStatusRaw:l}=await f(async()=>{const{inAppWalletGetCallsStatusRaw:o}=await import("./in-app-wallet-calls-C61H1buU.js");return{inAppWalletGetCallsStatusRaw:o}},__vite__mapDeps([2,3,4,5,6,7,8,9,1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]));return l(n)},getCapabilities:async n=>({[n.chainId??1]:{atomic:{status:"unsupported"},paymasterService:{supported:!1}}})};return r}}function g(t){return t===void 0||X(t)?t:P(t)}const ke={backgroundColor:"transparent",border:"none",colorScheme:"light",display:"none",height:"100%",pointerEvents:"all",position:"fixed",right:"0px",top:"0px",width:"100%",zIndex:"2147483646"},L=new Map;class Te{constructor({link:e,baseUrl:i,iframeId:a,container:s,onIframeInitialize:c,localStorage:r,clientId:n,ecosystem:l}){if(Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"POLLING_INTERVAL_SECONDS",{enumerable:!0,configurable:!0,writable:!0,value:1.4}),Object.defineProperty(this,"iframeBaseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.localStorage=r,this.clientId=n,this.ecosystem=l,this.iframeBaseUrl=i,typeof document>"u")return;s=s??document.body;let o=document.getElementById(a);const d=new URL(e);if(!o||o.src!==d.href){o=document.createElement("iframe");const h={...ke};Object.assign(o.style,h),o.setAttribute("id",a),o.setAttribute("fetchpriority","high"),s.appendChild(o),o.src=d.href;const m=y=>{if(y.data.eventType==="ewsIframeLoaded"){if(window.removeEventListener("message",m),!o){console.warn("thirdweb iFrame not found");return}this.onIframeLoadHandler(o,c)()}};window.addEventListener("message",m)}this.iframe=o}async onIframeLoadedInitVariables(){return{authCookie:await this.localStorage.getAuthCookie(),clientId:this.clientId,deviceShareStored:await this.localStorage.getDeviceShare(),ecosystemId:this.ecosystem?.id,partnerId:this.ecosystem?.partnerId,walletUserId:await this.localStorage.getWalletUserId()}}onIframeLoadHandler(e,i){return async()=>{const a=new MessageChannel,s=new Promise((c,r)=>{a.port1.onmessage=n=>{const{data:l}=n;a.port1.close(),l.success||r(new Error(l.error)),L.set(e.src,!0),i&&i(),c(!0)}});e?.contentWindow?.postMessage({data:await this.onIframeLoadedInitVariables(),eventType:"initIframe"},this.iframeBaseUrl,[a.port2]),await s}}async call({procedureName:e,params:i,showIframe:a=!1}){if(!this.iframe)throw new Error("Iframe not found. You are likely calling this from the backend where the DOM is not available.");for(;!L.get(this.iframe.src);)await k(this.POLLING_INTERVAL_SECONDS*1e3);a&&(this.iframe.style.display="block",await k(.005*1e3));const s=new MessageChannel,c=new Promise((r,n)=>{s.port1.onmessage=async l=>{const{data:o}=l;s.port1.close(),a&&(await k(.1*1e3),this.iframe&&(this.iframe.style.display="none")),o.success?r(o.data):n(new Error(o.error))}});return this.iframe.contentWindow?.postMessage({data:{...i,...await this.onIframeLoadedInitVariables()},eventType:e},this.iframeBaseUrl,[s.port2]),c}destroy(){this.iframe&&L.delete(this.iframe.src)}}class Le extends Te{constructor({clientId:e,baseUrl:i,ecosystem:a}){super({baseUrl:i,clientId:e,container:typeof document>"u"?void 0:document.body,ecosystem:a,iframeId:Pe+(a?.id||""),link:Ae({baseUrl:i,clientId:e,ecosystem:a,path:q}).href,localStorage:new D({clientId:e,ecosystem:a,storage:F})}),this.clientId=e,this.ecosystem=a}}function Ae({clientId:t,baseUrl:e,path:i,ecosystem:a,queryParams:s}){const c=new URL(`${i}`,e);if(s)for(const r of Object.keys(s))c.searchParams.set(r,s[r]?.toString()||"");return c.searchParams.set("clientId",t),a?.partnerId!==void 0&&c.searchParams.set("partnerId",a.partnerId),a?.id!==void 0&&c.searchParams.set("ecosystemId",a.id),c}const Pe="thirdweb-in-app-wallet-iframe";async function Se({client:t,ecosystem:e,authToken:i}){const s=await p(t,e)(`${w("inAppWallet")}/api/v1/enclave-wallet/generate`,{headers:{Authorization:`Bearer embedded-wallet-token:${i}`,"Content-Type":"application/json","x-thirdweb-client-id":t.clientId},method:"POST"});if(!s.ok)throw new Error(`Failed to generate wallet - ${s.status} ${s.statusText}`);const{wallet:c}=await s.json();return c}class We{constructor({baseUrl:e,querier:i,preLogin:a,postLogin:s,client:c,ecosystem:r}){Object.defineProperty(this,"LoginQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"preLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"postLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.baseUrl=e,this.LoginQuerier=i,this.preLogin=a,this.postLogin=s,this.client=c,this.ecosystem=r}async sendEmailLoginOtp({email:e}){return await this.LoginQuerier.call({params:{email:e},procedureName:"sendThirdwebEmailLoginOtp"})}async sendSmsLoginOtp({phoneNumber:e}){return await this.LoginQuerier.call({params:{phoneNumber:e},procedureName:"sendThirdwebSmsLoginOtp"})}}class Ee extends We{async authenticateWithModal(){return this.LoginQuerier.call({params:void 0,procedureName:"loginWithThirdwebModal",showIframe:!0})}async loginWithModal(){await this.preLogin();const e=await this.authenticateWithModal();return this.postLogin(e)}async authenticateWithIframe({email:e}){return this.LoginQuerier.call({params:{email:e},procedureName:"loginWithThirdwebModal",showIframe:!0})}async loginWithIframe({email:e}){await this.preLogin();const i=await this.authenticateWithIframe({email:e});return this.postLogin(i)}async authenticateWithCustomJwt({encryptionKey:e,jwt:i}){if(!e||e.length===0)throw new Error("Encryption key is required for custom jwt auth");return this.LoginQuerier.call({params:{encryptionKey:e,jwt:i},procedureName:"loginWithCustomJwt"})}async loginWithCustomJwt({encryptionKey:e,jwt:i}){if(!e||e.length===0)throw new Error("Encryption key is required for custom jwt auth");await this.preLogin();const a=await this.authenticateWithCustomJwt({encryptionKey:e,jwt:i});return this.postLogin(a)}async authenticateWithCustomAuthEndpoint({encryptionKey:e,payload:i}){return this.LoginQuerier.call({params:{encryptionKey:e,payload:i},procedureName:"loginWithCustomAuthEndpoint"})}async loginWithCustomAuthEndpoint({encryptionKey:e,payload:i}){if(!e||e.length===0)throw new Error("Encryption key is required for custom auth");await this.preLogin();const a=await this.authenticateWithCustomAuthEndpoint({encryptionKey:e,payload:i});return this.postLogin(a)}async authenticateWithEmailOtp({email:e,otp:i,recoveryCode:a}){return this.LoginQuerier.call({params:{email:e,otp:i,recoveryCode:a},procedureName:"verifyThirdwebEmailLoginOtp"})}async loginWithEmailOtp({email:e,otp:i,recoveryCode:a}){const s=await this.authenticateWithEmailOtp({email:e,otp:i,recoveryCode:a});return this.postLogin(s)}async authenticateWithSmsOtp({phoneNumber:e,otp:i,recoveryCode:a}){return this.LoginQuerier.call({params:{otp:i,phoneNumber:e,recoveryCode:a},procedureName:"verifyThirdwebSmsLoginOtp"})}async loginWithSmsOtp({phoneNumber:e,otp:i,recoveryCode:a}){const s=await this.authenticateWithSmsOtp({otp:i,phoneNumber:e,recoveryCode:a});return this.postLogin(s)}}class Oe{constructor({client:e,querier:i,onAuthSuccess:a,ecosystem:s,baseUrl:c,localStorage:r}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"AuthQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onAuthSuccess",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BaseLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=s,this.AuthQuerier=i,this.localStorage=r,this.onAuthSuccess=a,this.BaseLogin=new Ee({baseUrl:c,client:e,ecosystem:s,postLogin:async n=>this.postLogin(n),preLogin:async()=>{await this.preLogin()},querier:i})}async preLogin(){await this.logout()}async postLogin({storedToken:e,walletDetails:i}){return e.shouldStoreCookieString&&await this.localStorage.saveAuthCookie(e.cookieString),await this.onAuthSuccess({storedToken:e,walletDetails:i})}async loginWithAuthToken(e,i){e.storedToken.authProvider!=="Backend"&&await this.preLogin();const a=await S({authToken:e.storedToken.cookieString,client:this.client,ecosystem:this.ecosystem});if(!a)throw new Error("Cannot login, no user found for auth token");if(a.wallets.length>0&&a.wallets[0]?.type==="enclave")return this.postLogin({storedToken:e.storedToken,walletDetails:{walletAddress:a.wallets[0].address}});if(a.wallets.length===0){const c=await Se({authToken:e.storedToken.cookieString,client:this.client,ecosystem:this.ecosystem});return this.postLogin({storedToken:e.storedToken,walletDetails:{walletAddress:c.address}})}const s=await this.AuthQuerier.call({params:{recoveryCode:i,storedToken:e.storedToken},procedureName:"loginWithStoredTokenDetails"});return this.postLogin(s)}async loginWithModal(){return this.BaseLogin.loginWithModal()}async authenticateWithModal(){return this.BaseLogin.authenticateWithModal()}async loginWithIframe(e){return this.BaseLogin.loginWithIframe(e)}async authenticateWithIframe(e){return this.BaseLogin.authenticateWithIframe(e)}async loginWithCustomJwt(e){return this.BaseLogin.loginWithCustomJwt(e)}async authenticateWithCustomJwt(e){return this.BaseLogin.authenticateWithCustomJwt(e)}async loginWithCustomAuthEndpoint(e){return this.BaseLogin.loginWithCustomAuthEndpoint(e)}async authenticateWithCustomAuthEndpoint(e){return this.BaseLogin.authenticateWithCustomAuthEndpoint(e)}async sendEmailLoginOtp({email:e}){return this.BaseLogin.sendEmailLoginOtp({email:e})}async sendSmsLoginOtp({phoneNumber:e}){return this.BaseLogin.sendSmsLoginOtp({phoneNumber:e})}async loginWithEmailOtp(e){return await this.preLogin(),this.BaseLogin.loginWithEmailOtp(e)}async authenticateWithEmailOtp(e){return this.BaseLogin.authenticateWithEmailOtp(e)}async loginWithSmsOtp(e){return await this.preLogin(),this.BaseLogin.loginWithSmsOtp(e)}async authenticateWithSmsOtp(e){return this.BaseLogin.authenticateWithSmsOtp(e)}async logout(){const e=await this.localStorage.removeAuthCookie(),i=await this.localStorage.removeWalletUserId();return{success:e||i}}}const Ce="width=350, height=500",O=({isWindowOpenedByFn:t,win:e,closeOpenedWindow:i})=>{t?e?.close():e&&i?i(e):e&&e.close()};async function C(t){const e=v({...t,mode:t.mode||"redirect",authFlow:t.authFlow});t.mode==="redirect"?window.location.href=e:window.open(e),await new Promise(i=>setTimeout(i,5e3))}const $e=async t=>{let e=t.openedWindow,i=!1;if(e||(e=window.open(v({...t,mode:"popup"}),`Login to ${t.authOption}`,Ce),i=!0),!e)throw new Error("Something went wrong opening pop-up");return await new Promise((s,c)=>{const r=window.setInterval(async()=>{e.closed&&(clearInterval(r),window.removeEventListener("message",n),c(new Error("User closed login window")))},1e3),n=async l=>{if(l.origin===w("inAppWallet")){if(typeof l.data!="object"){c(new Error("Invalid event data"));return}switch(l.data.eventType){case"oauthSuccessResult":{window.removeEventListener("message",n),clearInterval(r),O({closeOpenedWindow:t.closeOpenedWindow,isWindowOpenedByFn:i,win:e}),l.data.authResult&&s(l.data.authResult);break}case"oauthFailureResult":{window.removeEventListener("message",n),clearInterval(r),O({closeOpenedWindow:t.closeOpenedWindow,isWindowOpenedByFn:i,win:e}),c(new Error(l.data.errorString));break}}}};window.addEventListener("message",n)})},je=async t=>{const{client:e,ecosystem:i}=t,a=v({authOption:t.strategy,client:e,ecosystem:i}),s={"Content-Type":"application/json","x-client-id":e.clientId};i?.id&&(s["x-ecosystem-id"]=i.id),i?.partnerId&&(s["x-ecosystem-partner-id"]=i.partnerId);const c=(()=>{switch(t.strategy){case"email":return{email:t.email};case"phone":return{phone:t.phoneNumber}}})(),r=await fetch(a,{body:u(c),headers:s,method:"POST"});if(!r.ok){const n=await r.text();let l;try{const o=JSON.parse(n);o&&typeof o.message=="string"&&(l=o.message)}catch{}throw new Error(l||"Failed to send verification code")}return await r.json()},$=async t=>{const{client:e,ecosystem:i}=t,a=W({authOption:t.strategy,client:t.client,ecosystem:t.ecosystem}),s={"Content-Type":"application/json","x-client-id":e.clientId};i?.id&&(s["x-ecosystem-id"]=i.id),i?.partnerId&&(s["x-ecosystem-partner-id"]=i.partnerId);const c=(()=>{switch(t.strategy){case"email":return{code:t.verificationCode,email:t.email};case"phone":return{code:t.verificationCode,phone:t.phoneNumber}}})(),r=await fetch(a,{body:u(c),headers:s,method:"POST"});if(!r.ok)throw new Error("Failed to verify verification code");return await r.json()};class j{constructor({client:e,ecosystem:i,querier:a,localStorage:s}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"walletManagerQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=i,this.walletManagerQuerier=a,this.localStorage=s}async postWalletSetUp(e){e.deviceShareStored&&await this.localStorage.saveDeviceShare(e.deviceShareStored,e.storedToken.authDetails.userWalletId)}async getUserWalletStatus(){const e=await this.walletManagerQuerier.call({params:void 0,procedureName:"getUserStatus"});return e.status==="Logged In, Wallet Initialized"?{status:"Logged In, Wallet Initialized",...e.user,account:await this.getAccount()}:e.status==="Logged In, New Device"?{status:"Logged In, New Device",...e.user}:e.status==="Logged In, Wallet Uninitialized"?{status:"Logged In, Wallet Uninitialized",...e.user}:{status:e.status}}async getAccount(){const e=this.walletManagerQuerier,i=this.client,a=this.ecosystem?.partnerId,{address:s}=await e.call({params:void 0,procedureName:"getAddress"}),c=async r=>{const n={chainId:r.chainId,data:r.data,gasLimit:r.gas,nonce:r.nonce,to:r.to??void 0,value:r.value};r.maxFeePerGas?(n.accessList=r.accessList,n.maxFeePerGas=r.maxFeePerGas,n.maxPriorityFeePerGas=r.maxPriorityFeePerGas,n.type=2):(n.gasPrice=r.gasPrice,n.type=0);const l=E().rpc,{signedTransaction:o}=await e.call({params:{chainId:r.chainId,partnerId:a,rpcEndpoint:`https://${r.chainId}.${l}`,transaction:n},procedureName:"signTransaction"});return o};return{address:b(s),async sendTransaction(r){const n=A({chain:I(r.chainId),client:i}),l=await c(r),o=await N(n,l);return U({chainId:r.chainId,client:i,contractAddress:r.to??void 0,gasPrice:r.gasPrice,transactionHash:o,walletAddress:s,walletType:"inApp"}),{transactionHash:o}},async signMessage({message:r}){const n=typeof r=="string"?r:r.raw instanceof Uint8Array?r.raw:K(r.raw),{signedMessage:l}=await e.call({params:{chainId:1,message:n,partnerId:a},procedureName:"signMessage"});return l},async signTransaction(r){if(!r.chainId)throw new Error("chainId required in tx to sign");return c({...r,chainId:r.chainId})},async signTypedData(r){const n=_(r);n.types?.EIP712Domain&&(n.types.EIP712Domain=void 0);const l=n.domain,o=l?.chainId,h={...l?.verifyingContract?{verifyingContract:l?.verifyingContract}:{},name:l?.name,version:l?.version};o&&(h.chainId=o);const m=E().rpc,{signedTypedData:y}=await e.call({params:{chainId:Number.parseInt(BigInt(o||1).toString()),domain:h,message:n.message,partnerId:a,rpcEndpoint:`https://${o}.${m}`,types:n.types},procedureName:"signTypedDataV4"});return y}}}}class Qe{isClientIdLegacyPaper(e){return e.indexOf("-")>0&&e.length===36}constructor({client:e,onAuthSuccess:i,ecosystem:a,passkeyDomain:s,storage:c}){if(Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"querier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"wallet",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"passkeyDomain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.isClientIdLegacyPaper(e.clientId))throw new Error("You are using a legacy clientId. Please use the clientId found on the thirdweb dashboard settings page");const r=w("inAppWallet");this.client=e,this.ecosystem=a,this.passkeyDomain=s,this.storage=new D({clientId:e.clientId,ecosystem:a,storage:c??De()}),this.querier=new Le({baseUrl:r,clientId:e.clientId,ecosystem:a}),this.auth=new Oe({baseUrl:r,client:e,ecosystem:a,localStorage:this.storage,onAuthSuccess:async n=>{if(i?.(n),n.storedToken.authDetails.walletType==="sharded"&&(await this.querier.call({params:{storedToken:n.storedToken},procedureName:"migrateFromShardToEnclave"})||console.warn("Failed to migrate from sharded to enclave wallet, continuing with sharded wallet")),this.wallet=await this.initializeWallet(n.storedToken.cookieString),!this.wallet)throw new Error("Failed to initialize wallet");const l="deviceShareStored"in n.walletDetails?n.walletDetails.deviceShareStored:void 0;return await this.wallet.postWalletSetUp({deviceShareStored:l,storedToken:n.storedToken}),this.wallet instanceof j&&await this.querier.call({params:{authCookie:n.storedToken.cookieString,clientId:this.client.clientId,deviceShareStored:"deviceShareStored"in n.walletDetails?n.walletDetails.deviceShareStored:null,ecosystemId:a?.id,partnerId:a?.partnerId,walletUserId:n.storedToken.authDetails.userWalletId},procedureName:"initIframe"}),{user:{account:await this.wallet.getAccount(),authDetails:n.storedToken.authDetails,status:"Logged In, Wallet Initialized",walletAddress:n.walletDetails.walletAddress}}},querier:this.querier})}async initializeWallet(e){const i=await this.storage.getAuthCookie();if(!e&&i===null)throw new Error("No auth token provided and no stored auth token found to initialize the wallet");const a=await S({authToken:e||i,client:this.client,ecosystem:this.ecosystem});if(!a)throw new Error("Cannot initialize wallet, no user logged in");if(a.wallets.length===0)throw new Error("Cannot initialize wallet, this user does not have a wallet generated yet");return a.wallets[0]?.type==="enclave"?new ve({address:a.wallets[0].address,client:this.client,ecosystem:this.ecosystem,storage:this.storage}):new j({client:this.client,ecosystem:this.ecosystem,localStorage:this.storage,querier:this.querier})}async getUser(){if(!this.wallet){const e=await this.storage.getAuthCookie();if(!e)return{status:"Logged Out"};this.wallet=await this.initializeWallet(e)}if(!this.wallet)throw new Error("Wallet not initialized");return await this.wallet.getUserWalletStatus()}getAccount(){if(!this.wallet)throw new Error("Wallet not initialized");return this.wallet.getAccount()}async preAuthenticate(e){return je({...e,client:this.client,ecosystem:this.ecosystem})}async authenticateWithRedirect(e,i,a){return C({authOption:e,client:this.client,ecosystem:this.ecosystem,mode:i,redirectUrl:a})}async loginWithAuthToken(e,i){return this.auth.loginWithAuthToken(e,i)}async authenticate(e){const i=e.strategy;switch(i){case"email":return $({...e,client:this.client,ecosystem:this.ecosystem});case"phone":return $({...e,client:this.client,ecosystem:this.ecosystem});case"auth_endpoint":return se({client:this.client,ecosystem:this.ecosystem,payload:e.payload});case"jwt":return ce({client:this.client,ecosystem:this.ecosystem,jwt:e.jwt});case"passkey":return this.passkeyAuth(e);case"iframe_email_verification":return this.auth.authenticateWithIframe({email:e.email});case"iframe":return this.auth.authenticateWithModal();case"apple":case"facebook":case"google":case"telegram":case"github":case"twitch":case"farcaster":case"line":case"x":case"tiktok":case"epic":case"steam":case"coinbase":case"discord":return $e({authOption:i,client:this.client,closeOpenedWindow:e.closeOpenedWindow,ecosystem:this.ecosystem,openedWindow:e.openedWindow});case"guest":return oe({client:this.client,ecosystem:this.ecosystem,storage:this.storage});case"backend":return re({client:this.client,ecosystem:this.ecosystem,walletSecret:e.walletSecret});case"wallet":return me({client:this.client,ecosystem:this.ecosystem,wallet:e.wallet,chain:e.chain})}}async connect(e){const i=e.strategy;switch(i){case"auth_endpoint":case"jwt":{const a=await this.authenticate(e);return await this.loginWithAuthToken(a,e.encryptionKey)}case"iframe_email_verification":return this.auth.loginWithIframe({email:e.email});case"iframe":return this.auth.loginWithModal();case"passkey":{const a=await this.passkeyAuth(e);return this.loginWithAuthToken(a)}case"backend":case"phone":case"email":case"wallet":case"apple":case"facebook":case"google":case"farcaster":case"telegram":case"github":case"line":case"x":case"tiktok":case"epic":case"guest":case"coinbase":case"twitch":case"steam":case"discord":{const a=await this.authenticate(e);return await this.auth.loginWithAuthToken(a)}default:_e(i)}}async logout(){return await this.auth.logout()}async passkeyAuth(e){const{PasskeyWebClient:i}=await f(async()=>{const{PasskeyWebClient:n}=await import("./passkeys-CTJ4NPfL.js");return{PasskeyWebClient:n}},__vite__mapDeps([26,27])),{passkeyName:a,storeLastUsedPasskey:s=!0}=e,c=new i,r=this.storage;return e.type==="sign-up"?le({client:this.client,ecosystem:this.ecosystem,passkeyClient:c,rp:{id:this.passkeyDomain??window.location.hostname,name:this.passkeyDomain??window.document.title},storage:s?r:void 0,username:a}):de({client:this.client,ecosystem:this.ecosystem,passkeyClient:c,rp:{id:this.passkeyDomain??window.location.hostname,name:this.passkeyDomain??window.document.title},storage:s?r:void 0})}async linkProfileWithRedirect(e,i,a){return C({authOption:e,client:this.client,ecosystem:this.ecosystem,mode:i,redirectUrl:a,authFlow:"link"})}async linkProfile(e){if("strategy"in e&&Q.includes(e.strategy)&&"mode"in e&&e.mode!=="popup"&&e.mode!==void 0)return await this.linkProfileWithRedirect(e.strategy,e.mode,"redirectUrl"in e?e.redirectUrl:void 0),[];const{storedToken:i}=await this.authenticate(e);return await H({client:e.client,ecosystem:e.ecosystem||this.ecosystem,storage:this.storage,tokenToLink:i.cookieString})}async unlinkProfile(e,i){return await J({allowAccountDeletion:i,client:this.client,ecosystem:this.ecosystem,profileToUnlink:e,storage:this.storage})}async getProfiles(){return Y({client:this.client,ecosystem:this.ecosystem,storage:this.storage})}}function _e(t,e){throw new Error(`Invalid param: ${t}`)}function De(){return typeof window<"u"&&window.localStorage?F:ee}export{Qe as InAppWebConnector};
9
+ `)}async function we(t){const{payload:e,account:i}=t,a=await i.signMessage({message:he(e)});return{payload:e,signature:a}}const pe=["xyz.abs"];async function me(t){const{wallet:e,client:i,ecosystem:a,chain:s}=t,c=pe.includes(e.id)?s||I(1):I(1),r=e.getAccount()||await e.connect({chain:c,client:i}),n=p(i,a),l=await(async()=>{const h=v({authOption:"wallet",client:t.client,ecosystem:t.ecosystem}),m=await n(`${h}&address=${r.address}&chainId=${c.id}`);if(!m.ok)throw new Error("Failed to generate SIWE login payload");return await m.json()})(),{signature:o}=await we({account:r,payload:l});return await(async()=>{const h=W({authOption:"wallet",client:t.client,ecosystem:t.ecosystem}),m=await n(`${h}&signature=${o}&payload=${encodeURIComponent(l)}`,{body:u({payload:l,signature:o}),headers:{"Content-Type":"application/json"},method:"POST"});if(!m.ok)throw new Error("Failed to verify SIWE signature");return await m.json()})()}async function ge({client:t,payload:e,storage:i}){const a=await i.getAuthCookie(),s=i.ecosystem,c=p(t,s);if(!a)throw new Error("No auth token found when signing message");const r={address:e.address,chainId:e.chainId,nonce:Number(e.nonce)},n=await c(`${w("inAppWallet")}/api/v1/enclave-wallet/sign-authorization`,{body:u(r),headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json","x-thirdweb-client-id":t.clientId},method:"POST"});if(!n.ok)throw new Error(`Failed to sign message - ${n.status} ${n.statusText}`);return await n.json()}async function ye({client:t,payload:{message:e,isRaw:i,originalMessage:a,chainId:s},storage:c}){const r=await c.getAuthCookie(),n=c.ecosystem,l=p(t,n);if(!r)throw new Error("No auth token found when signing message");const o=await l(`${w("inAppWallet")}/api/v1/enclave-wallet/sign-message`,{body:u({messagePayload:{chainId:s,isRaw:i,message:e,originalMessage:a}}),headers:{Authorization:`Bearer embedded-wallet-token:${r}`,"Content-Type":"application/json","x-thirdweb-client-id":t.clientId},method:"POST"});if(!o.ok)throw new Error(`Failed to sign message - ${o.status} ${o.statusText}`);return await o.json()}async function fe({client:t,payload:e,storage:i}){const a=await i.getAuthCookie(),s=i.ecosystem,c=p(t,s);if(!a)throw new Error("No auth token found when signing transaction");const r=await c(`${w("inAppWallet")}/api/v1/enclave-wallet/sign-transaction`,{body:u({transactionPayload:e}),headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json","x-thirdweb-client-id":t.clientId},method:"POST"});if(!r.ok)throw new Error(`Failed to sign transaction - ${r.status} ${r.statusText}`);return(await r.json()).signature}async function be({client:t,payload:e,storage:i}){const a=await i.getAuthCookie(),s=i.ecosystem,c=p(t,s);if(!a)throw new Error("No auth token found when signing typed data");const r=await c(`${w("inAppWallet")}/api/v1/enclave-wallet/sign-typed-data`,{body:u({...e}),headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json","x-thirdweb-client-id":t.clientId},method:"POST"});if(!r.ok)throw new Error(`Failed to sign typed data - ${r.status} ${r.statusText}`);return await r.json()}const{bytesToHex:Ie}=await Z("viem");class ve{constructor({client:e,ecosystem:i,address:a,storage:s}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"address",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=i,this.address=a,this.localStorage=s}async postWalletSetUp(e){await this.localStorage.saveAuthCookie(e.storedToken.cookieString)}async getUserWalletStatus(){const e=await this.localStorage.getAuthCookie();if(!e)return{status:"Logged Out"};const i=await S({authToken:e,client:this.client,ecosystem:this.ecosystem});if(!i)return{status:"Logged Out"};const a=i.wallets[0],s={email:i.linkedAccounts.find(c=>c.details.email!==void 0)?.details.email,phoneNumber:i.linkedAccounts.find(c=>c.details.phone!==void 0)?.details.phone,recoveryShareManagement:"ENCLAVE",userWalletId:i.id||""};return a?{account:await this.getAccount(),authDetails:s,status:"Logged In, Wallet Initialized",walletAddress:a.address}:{authDetails:s,status:"Logged In, Wallet Uninitialized"}}async getAccount(){const e=this.client,i=this.localStorage,a=this.address,s=this.ecosystem,c=async n=>{const l=A({chain:I(n.chainId),client:e}),o={chainId:P(n.chainId),data:n.data,gas:g(n.gas),nonce:g(n.nonce)||P(await f(async()=>{const{eth_getTransactionCount:d}=await import("./eth_getTransactionCount-DWnnw2mX.js");return{eth_getTransactionCount:d}},__vite__mapDeps([0,1])).then(({eth_getTransactionCount:d})=>d(l,{address:b(this.address),blockTag:"pending"}))),to:n.to?b(n.to):void 0,value:g(n.value)};return n.authorizationList&&n.authorizationList.length>0?(o.type=4,o.authorizationList=n.authorizationList,o.maxFeePerGas=g(n.maxFeePerGas),o.maxPriorityFeePerGas=g(n.maxPriorityFeePerGas)):g(n.maxFeePerGas)?(o.maxFeePerGas=g(n.maxFeePerGas),o.maxPriorityFeePerGas=g(n.maxPriorityFeePerGas),o.type=2):(o.gasPrice=g(n.gasPrice),o.type=0),fe({client:e,payload:o,storage:i})},r={address:b(a),async sendTransaction(n){const l=A({chain:I(n.chainId),client:e}),o=await c(n),d=await N(l,o);return U({chainId:n.chainId,client:e,contractAddress:n.to??void 0,ecosystem:s,gasPrice:n.gasPrice,transactionHash:d,walletAddress:a,walletType:"inApp"}),{transactionHash:d}},async signAuthorization(n){const l=await ge({client:e,payload:n,storage:i});return{address:b(l.address),chainId:Number.parseInt(l.chainId),nonce:BigInt(l.nonce),r:BigInt(l.r),s:BigInt(l.s),yParity:Number.parseInt(l.yParity)}},async signMessage({message:n,originalMessage:l,chainId:o}){const d=typeof n=="string"?{chainId:o,isRaw:!1,message:n,originalMessage:l}:{chainId:o,isRaw:!0,message:typeof n.raw=="string"?n.raw:Ie(n.raw),originalMessage:l},{signature:h}=await ye({client:e,payload:d,storage:i});return h},async signTransaction(n){if(!n.chainId)throw new Error("chainId required in tx to sign");return c({chainId:n.chainId,...n})},async signTypedData(n){const l=_(n),{signature:o}=await be({client:e,payload:l,storage:i});return o},sendCalls:async n=>{const{inAppWalletSendCalls:l}=await f(async()=>{const{inAppWalletSendCalls:y}=await import("./in-app-wallet-calls-DzF9AO72.js");return{inAppWalletSendCalls:y}},__vite__mapDeps([2,3,4,5,6,7,8,9,1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25])),o=n.calls[0];if(!o)throw new Error("No calls to send");const d=o.client,h=o.chain||n.chain,m=await l({account:r,calls:n.calls,chain:h});return{chain:h,client:d,id:m}},getCallsStatus:async n=>{const{inAppWalletGetCallsStatus:l}=await f(async()=>{const{inAppWalletGetCallsStatus:o}=await import("./in-app-wallet-calls-DzF9AO72.js");return{inAppWalletGetCallsStatus:o}},__vite__mapDeps([2,3,4,5,6,7,8,9,1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]));return l(n)},getCallsStatusRaw:async n=>{const{inAppWalletGetCallsStatusRaw:l}=await f(async()=>{const{inAppWalletGetCallsStatusRaw:o}=await import("./in-app-wallet-calls-DzF9AO72.js");return{inAppWalletGetCallsStatusRaw:o}},__vite__mapDeps([2,3,4,5,6,7,8,9,1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]));return l(n)},getCapabilities:async n=>({[n.chainId??1]:{atomic:{status:"unsupported"},paymasterService:{supported:!1}}})};return r}}function g(t){return t===void 0||X(t)?t:P(t)}const ke={backgroundColor:"transparent",border:"none",colorScheme:"light",display:"none",height:"100%",pointerEvents:"all",position:"fixed",right:"0px",top:"0px",width:"100%",zIndex:"2147483646"},L=new Map;class Te{constructor({link:e,baseUrl:i,iframeId:a,container:s,onIframeInitialize:c,localStorage:r,clientId:n,ecosystem:l}){if(Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"POLLING_INTERVAL_SECONDS",{enumerable:!0,configurable:!0,writable:!0,value:1.4}),Object.defineProperty(this,"iframeBaseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.localStorage=r,this.clientId=n,this.ecosystem=l,this.iframeBaseUrl=i,typeof document>"u")return;s=s??document.body;let o=document.getElementById(a);const d=new URL(e);if(!o||o.src!==d.href){o=document.createElement("iframe");const h={...ke};Object.assign(o.style,h),o.setAttribute("id",a),o.setAttribute("fetchpriority","high"),s.appendChild(o),o.src=d.href;const m=y=>{if(y.data.eventType==="ewsIframeLoaded"){if(window.removeEventListener("message",m),!o){console.warn("thirdweb iFrame not found");return}this.onIframeLoadHandler(o,c)()}};window.addEventListener("message",m)}this.iframe=o}async onIframeLoadedInitVariables(){return{authCookie:await this.localStorage.getAuthCookie(),clientId:this.clientId,deviceShareStored:await this.localStorage.getDeviceShare(),ecosystemId:this.ecosystem?.id,partnerId:this.ecosystem?.partnerId,walletUserId:await this.localStorage.getWalletUserId()}}onIframeLoadHandler(e,i){return async()=>{const a=new MessageChannel,s=new Promise((c,r)=>{a.port1.onmessage=n=>{const{data:l}=n;a.port1.close(),l.success||r(new Error(l.error)),L.set(e.src,!0),i&&i(),c(!0)}});e?.contentWindow?.postMessage({data:await this.onIframeLoadedInitVariables(),eventType:"initIframe"},this.iframeBaseUrl,[a.port2]),await s}}async call({procedureName:e,params:i,showIframe:a=!1}){if(!this.iframe)throw new Error("Iframe not found. You are likely calling this from the backend where the DOM is not available.");for(;!L.get(this.iframe.src);)await k(this.POLLING_INTERVAL_SECONDS*1e3);a&&(this.iframe.style.display="block",await k(.005*1e3));const s=new MessageChannel,c=new Promise((r,n)=>{s.port1.onmessage=async l=>{const{data:o}=l;s.port1.close(),a&&(await k(.1*1e3),this.iframe&&(this.iframe.style.display="none")),o.success?r(o.data):n(new Error(o.error))}});return this.iframe.contentWindow?.postMessage({data:{...i,...await this.onIframeLoadedInitVariables()},eventType:e},this.iframeBaseUrl,[s.port2]),c}destroy(){this.iframe&&L.delete(this.iframe.src)}}class Le extends Te{constructor({clientId:e,baseUrl:i,ecosystem:a}){super({baseUrl:i,clientId:e,container:typeof document>"u"?void 0:document.body,ecosystem:a,iframeId:Pe+(a?.id||""),link:Ae({baseUrl:i,clientId:e,ecosystem:a,path:q}).href,localStorage:new D({clientId:e,ecosystem:a,storage:F})}),this.clientId=e,this.ecosystem=a}}function Ae({clientId:t,baseUrl:e,path:i,ecosystem:a,queryParams:s}){const c=new URL(`${i}`,e);if(s)for(const r of Object.keys(s))c.searchParams.set(r,s[r]?.toString()||"");return c.searchParams.set("clientId",t),a?.partnerId!==void 0&&c.searchParams.set("partnerId",a.partnerId),a?.id!==void 0&&c.searchParams.set("ecosystemId",a.id),c}const Pe="thirdweb-in-app-wallet-iframe";async function Se({client:t,ecosystem:e,authToken:i}){const s=await p(t,e)(`${w("inAppWallet")}/api/v1/enclave-wallet/generate`,{headers:{Authorization:`Bearer embedded-wallet-token:${i}`,"Content-Type":"application/json","x-thirdweb-client-id":t.clientId},method:"POST"});if(!s.ok)throw new Error(`Failed to generate wallet - ${s.status} ${s.statusText}`);const{wallet:c}=await s.json();return c}class We{constructor({baseUrl:e,querier:i,preLogin:a,postLogin:s,client:c,ecosystem:r}){Object.defineProperty(this,"LoginQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"preLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"postLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.baseUrl=e,this.LoginQuerier=i,this.preLogin=a,this.postLogin=s,this.client=c,this.ecosystem=r}async sendEmailLoginOtp({email:e}){return await this.LoginQuerier.call({params:{email:e},procedureName:"sendThirdwebEmailLoginOtp"})}async sendSmsLoginOtp({phoneNumber:e}){return await this.LoginQuerier.call({params:{phoneNumber:e},procedureName:"sendThirdwebSmsLoginOtp"})}}class Ee extends We{async authenticateWithModal(){return this.LoginQuerier.call({params:void 0,procedureName:"loginWithThirdwebModal",showIframe:!0})}async loginWithModal(){await this.preLogin();const e=await this.authenticateWithModal();return this.postLogin(e)}async authenticateWithIframe({email:e}){return this.LoginQuerier.call({params:{email:e},procedureName:"loginWithThirdwebModal",showIframe:!0})}async loginWithIframe({email:e}){await this.preLogin();const i=await this.authenticateWithIframe({email:e});return this.postLogin(i)}async authenticateWithCustomJwt({encryptionKey:e,jwt:i}){if(!e||e.length===0)throw new Error("Encryption key is required for custom jwt auth");return this.LoginQuerier.call({params:{encryptionKey:e,jwt:i},procedureName:"loginWithCustomJwt"})}async loginWithCustomJwt({encryptionKey:e,jwt:i}){if(!e||e.length===0)throw new Error("Encryption key is required for custom jwt auth");await this.preLogin();const a=await this.authenticateWithCustomJwt({encryptionKey:e,jwt:i});return this.postLogin(a)}async authenticateWithCustomAuthEndpoint({encryptionKey:e,payload:i}){return this.LoginQuerier.call({params:{encryptionKey:e,payload:i},procedureName:"loginWithCustomAuthEndpoint"})}async loginWithCustomAuthEndpoint({encryptionKey:e,payload:i}){if(!e||e.length===0)throw new Error("Encryption key is required for custom auth");await this.preLogin();const a=await this.authenticateWithCustomAuthEndpoint({encryptionKey:e,payload:i});return this.postLogin(a)}async authenticateWithEmailOtp({email:e,otp:i,recoveryCode:a}){return this.LoginQuerier.call({params:{email:e,otp:i,recoveryCode:a},procedureName:"verifyThirdwebEmailLoginOtp"})}async loginWithEmailOtp({email:e,otp:i,recoveryCode:a}){const s=await this.authenticateWithEmailOtp({email:e,otp:i,recoveryCode:a});return this.postLogin(s)}async authenticateWithSmsOtp({phoneNumber:e,otp:i,recoveryCode:a}){return this.LoginQuerier.call({params:{otp:i,phoneNumber:e,recoveryCode:a},procedureName:"verifyThirdwebSmsLoginOtp"})}async loginWithSmsOtp({phoneNumber:e,otp:i,recoveryCode:a}){const s=await this.authenticateWithSmsOtp({otp:i,phoneNumber:e,recoveryCode:a});return this.postLogin(s)}}class Oe{constructor({client:e,querier:i,onAuthSuccess:a,ecosystem:s,baseUrl:c,localStorage:r}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"AuthQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onAuthSuccess",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BaseLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=s,this.AuthQuerier=i,this.localStorage=r,this.onAuthSuccess=a,this.BaseLogin=new Ee({baseUrl:c,client:e,ecosystem:s,postLogin:async n=>this.postLogin(n),preLogin:async()=>{await this.preLogin()},querier:i})}async preLogin(){await this.logout()}async postLogin({storedToken:e,walletDetails:i}){return e.shouldStoreCookieString&&await this.localStorage.saveAuthCookie(e.cookieString),await this.onAuthSuccess({storedToken:e,walletDetails:i})}async loginWithAuthToken(e,i){e.storedToken.authProvider!=="Backend"&&await this.preLogin();const a=await S({authToken:e.storedToken.cookieString,client:this.client,ecosystem:this.ecosystem});if(!a)throw new Error("Cannot login, no user found for auth token");if(a.wallets.length>0&&a.wallets[0]?.type==="enclave")return this.postLogin({storedToken:e.storedToken,walletDetails:{walletAddress:a.wallets[0].address}});if(a.wallets.length===0){const c=await Se({authToken:e.storedToken.cookieString,client:this.client,ecosystem:this.ecosystem});return this.postLogin({storedToken:e.storedToken,walletDetails:{walletAddress:c.address}})}const s=await this.AuthQuerier.call({params:{recoveryCode:i,storedToken:e.storedToken},procedureName:"loginWithStoredTokenDetails"});return this.postLogin(s)}async loginWithModal(){return this.BaseLogin.loginWithModal()}async authenticateWithModal(){return this.BaseLogin.authenticateWithModal()}async loginWithIframe(e){return this.BaseLogin.loginWithIframe(e)}async authenticateWithIframe(e){return this.BaseLogin.authenticateWithIframe(e)}async loginWithCustomJwt(e){return this.BaseLogin.loginWithCustomJwt(e)}async authenticateWithCustomJwt(e){return this.BaseLogin.authenticateWithCustomJwt(e)}async loginWithCustomAuthEndpoint(e){return this.BaseLogin.loginWithCustomAuthEndpoint(e)}async authenticateWithCustomAuthEndpoint(e){return this.BaseLogin.authenticateWithCustomAuthEndpoint(e)}async sendEmailLoginOtp({email:e}){return this.BaseLogin.sendEmailLoginOtp({email:e})}async sendSmsLoginOtp({phoneNumber:e}){return this.BaseLogin.sendSmsLoginOtp({phoneNumber:e})}async loginWithEmailOtp(e){return await this.preLogin(),this.BaseLogin.loginWithEmailOtp(e)}async authenticateWithEmailOtp(e){return this.BaseLogin.authenticateWithEmailOtp(e)}async loginWithSmsOtp(e){return await this.preLogin(),this.BaseLogin.loginWithSmsOtp(e)}async authenticateWithSmsOtp(e){return this.BaseLogin.authenticateWithSmsOtp(e)}async logout(){const e=await this.localStorage.removeAuthCookie(),i=await this.localStorage.removeWalletUserId();return{success:e||i}}}const Ce="width=350, height=500",O=({isWindowOpenedByFn:t,win:e,closeOpenedWindow:i})=>{t?e?.close():e&&i?i(e):e&&e.close()};async function C(t){const e=v({...t,mode:t.mode||"redirect",authFlow:t.authFlow});t.mode==="redirect"?window.location.href=e:window.open(e),await new Promise(i=>setTimeout(i,5e3))}const $e=async t=>{let e=t.openedWindow,i=!1;if(e||(e=window.open(v({...t,mode:"popup"}),`Login to ${t.authOption}`,Ce),i=!0),!e)throw new Error("Something went wrong opening pop-up");return await new Promise((s,c)=>{const r=window.setInterval(async()=>{e.closed&&(clearInterval(r),window.removeEventListener("message",n),c(new Error("User closed login window")))},1e3),n=async l=>{if(l.origin===w("inAppWallet")){if(typeof l.data!="object"){c(new Error("Invalid event data"));return}switch(l.data.eventType){case"oauthSuccessResult":{window.removeEventListener("message",n),clearInterval(r),O({closeOpenedWindow:t.closeOpenedWindow,isWindowOpenedByFn:i,win:e}),l.data.authResult&&s(l.data.authResult);break}case"oauthFailureResult":{window.removeEventListener("message",n),clearInterval(r),O({closeOpenedWindow:t.closeOpenedWindow,isWindowOpenedByFn:i,win:e}),c(new Error(l.data.errorString));break}}}};window.addEventListener("message",n)})},je=async t=>{const{client:e,ecosystem:i}=t,a=v({authOption:t.strategy,client:e,ecosystem:i}),s={"Content-Type":"application/json","x-client-id":e.clientId};i?.id&&(s["x-ecosystem-id"]=i.id),i?.partnerId&&(s["x-ecosystem-partner-id"]=i.partnerId);const c=(()=>{switch(t.strategy){case"email":return{email:t.email};case"phone":return{phone:t.phoneNumber}}})(),r=await fetch(a,{body:u(c),headers:s,method:"POST"});if(!r.ok){const n=await r.text();let l;try{const o=JSON.parse(n);o&&typeof o.message=="string"&&(l=o.message)}catch{}throw new Error(l||"Failed to send verification code")}return await r.json()},$=async t=>{const{client:e,ecosystem:i}=t,a=W({authOption:t.strategy,client:t.client,ecosystem:t.ecosystem}),s={"Content-Type":"application/json","x-client-id":e.clientId};i?.id&&(s["x-ecosystem-id"]=i.id),i?.partnerId&&(s["x-ecosystem-partner-id"]=i.partnerId);const c=(()=>{switch(t.strategy){case"email":return{code:t.verificationCode,email:t.email};case"phone":return{code:t.verificationCode,phone:t.phoneNumber}}})(),r=await fetch(a,{body:u(c),headers:s,method:"POST"});if(!r.ok)throw new Error("Failed to verify verification code");return await r.json()};class j{constructor({client:e,ecosystem:i,querier:a,localStorage:s}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"walletManagerQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=i,this.walletManagerQuerier=a,this.localStorage=s}async postWalletSetUp(e){e.deviceShareStored&&await this.localStorage.saveDeviceShare(e.deviceShareStored,e.storedToken.authDetails.userWalletId)}async getUserWalletStatus(){const e=await this.walletManagerQuerier.call({params:void 0,procedureName:"getUserStatus"});return e.status==="Logged In, Wallet Initialized"?{status:"Logged In, Wallet Initialized",...e.user,account:await this.getAccount()}:e.status==="Logged In, New Device"?{status:"Logged In, New Device",...e.user}:e.status==="Logged In, Wallet Uninitialized"?{status:"Logged In, Wallet Uninitialized",...e.user}:{status:e.status}}async getAccount(){const e=this.walletManagerQuerier,i=this.client,a=this.ecosystem?.partnerId,{address:s}=await e.call({params:void 0,procedureName:"getAddress"}),c=async r=>{const n={chainId:r.chainId,data:r.data,gasLimit:r.gas,nonce:r.nonce,to:r.to??void 0,value:r.value};r.maxFeePerGas?(n.accessList=r.accessList,n.maxFeePerGas=r.maxFeePerGas,n.maxPriorityFeePerGas=r.maxPriorityFeePerGas,n.type=2):(n.gasPrice=r.gasPrice,n.type=0);const l=E().rpc,{signedTransaction:o}=await e.call({params:{chainId:r.chainId,partnerId:a,rpcEndpoint:`https://${r.chainId}.${l}`,transaction:n},procedureName:"signTransaction"});return o};return{address:b(s),async sendTransaction(r){const n=A({chain:I(r.chainId),client:i}),l=await c(r),o=await N(n,l);return U({chainId:r.chainId,client:i,contractAddress:r.to??void 0,gasPrice:r.gasPrice,transactionHash:o,walletAddress:s,walletType:"inApp"}),{transactionHash:o}},async signMessage({message:r}){const n=typeof r=="string"?r:r.raw instanceof Uint8Array?r.raw:K(r.raw),{signedMessage:l}=await e.call({params:{chainId:1,message:n,partnerId:a},procedureName:"signMessage"});return l},async signTransaction(r){if(!r.chainId)throw new Error("chainId required in tx to sign");return c({...r,chainId:r.chainId})},async signTypedData(r){const n=_(r);n.types?.EIP712Domain&&(n.types.EIP712Domain=void 0);const l=n.domain,o=l?.chainId,h={...l?.verifyingContract?{verifyingContract:l?.verifyingContract}:{},name:l?.name,version:l?.version};o&&(h.chainId=o);const m=E().rpc,{signedTypedData:y}=await e.call({params:{chainId:Number.parseInt(BigInt(o||1).toString()),domain:h,message:n.message,partnerId:a,rpcEndpoint:`https://${o}.${m}`,types:n.types},procedureName:"signTypedDataV4"});return y}}}}class Qe{isClientIdLegacyPaper(e){return e.indexOf("-")>0&&e.length===36}constructor({client:e,onAuthSuccess:i,ecosystem:a,passkeyDomain:s,storage:c}){if(Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"querier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"wallet",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"passkeyDomain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.isClientIdLegacyPaper(e.clientId))throw new Error("You are using a legacy clientId. Please use the clientId found on the thirdweb dashboard settings page");const r=w("inAppWallet");this.client=e,this.ecosystem=a,this.passkeyDomain=s,this.storage=new D({clientId:e.clientId,ecosystem:a,storage:c??De()}),this.querier=new Le({baseUrl:r,clientId:e.clientId,ecosystem:a}),this.auth=new Oe({baseUrl:r,client:e,ecosystem:a,localStorage:this.storage,onAuthSuccess:async n=>{if(i?.(n),n.storedToken.authDetails.walletType==="sharded"&&(await this.querier.call({params:{storedToken:n.storedToken},procedureName:"migrateFromShardToEnclave"})||console.warn("Failed to migrate from sharded to enclave wallet, continuing with sharded wallet")),this.wallet=await this.initializeWallet(n.storedToken.cookieString),!this.wallet)throw new Error("Failed to initialize wallet");const l="deviceShareStored"in n.walletDetails?n.walletDetails.deviceShareStored:void 0;return await this.wallet.postWalletSetUp({deviceShareStored:l,storedToken:n.storedToken}),this.wallet instanceof j&&await this.querier.call({params:{authCookie:n.storedToken.cookieString,clientId:this.client.clientId,deviceShareStored:"deviceShareStored"in n.walletDetails?n.walletDetails.deviceShareStored:null,ecosystemId:a?.id,partnerId:a?.partnerId,walletUserId:n.storedToken.authDetails.userWalletId},procedureName:"initIframe"}),{user:{account:await this.wallet.getAccount(),authDetails:n.storedToken.authDetails,status:"Logged In, Wallet Initialized",walletAddress:n.walletDetails.walletAddress}}},querier:this.querier})}async initializeWallet(e){const i=await this.storage.getAuthCookie();if(!e&&i===null)throw new Error("No auth token provided and no stored auth token found to initialize the wallet");const a=await S({authToken:e||i,client:this.client,ecosystem:this.ecosystem});if(!a)throw new Error("Cannot initialize wallet, no user logged in");if(a.wallets.length===0)throw new Error("Cannot initialize wallet, this user does not have a wallet generated yet");return a.wallets[0]?.type==="enclave"?new ve({address:a.wallets[0].address,client:this.client,ecosystem:this.ecosystem,storage:this.storage}):new j({client:this.client,ecosystem:this.ecosystem,localStorage:this.storage,querier:this.querier})}async getUser(){if(!this.wallet){const e=await this.storage.getAuthCookie();if(!e)return{status:"Logged Out"};this.wallet=await this.initializeWallet(e)}if(!this.wallet)throw new Error("Wallet not initialized");return await this.wallet.getUserWalletStatus()}getAccount(){if(!this.wallet)throw new Error("Wallet not initialized");return this.wallet.getAccount()}async preAuthenticate(e){return je({...e,client:this.client,ecosystem:this.ecosystem})}async authenticateWithRedirect(e,i,a){return C({authOption:e,client:this.client,ecosystem:this.ecosystem,mode:i,redirectUrl:a})}async loginWithAuthToken(e,i){return this.auth.loginWithAuthToken(e,i)}async authenticate(e){const i=e.strategy;switch(i){case"email":return $({...e,client:this.client,ecosystem:this.ecosystem});case"phone":return $({...e,client:this.client,ecosystem:this.ecosystem});case"auth_endpoint":return se({client:this.client,ecosystem:this.ecosystem,payload:e.payload});case"jwt":return ce({client:this.client,ecosystem:this.ecosystem,jwt:e.jwt});case"passkey":return this.passkeyAuth(e);case"iframe_email_verification":return this.auth.authenticateWithIframe({email:e.email});case"iframe":return this.auth.authenticateWithModal();case"apple":case"facebook":case"google":case"telegram":case"github":case"twitch":case"farcaster":case"line":case"x":case"tiktok":case"epic":case"steam":case"coinbase":case"discord":return $e({authOption:i,client:this.client,closeOpenedWindow:e.closeOpenedWindow,ecosystem:this.ecosystem,openedWindow:e.openedWindow});case"guest":return oe({client:this.client,ecosystem:this.ecosystem,storage:this.storage});case"backend":return re({client:this.client,ecosystem:this.ecosystem,walletSecret:e.walletSecret});case"wallet":return me({client:this.client,ecosystem:this.ecosystem,wallet:e.wallet,chain:e.chain})}}async connect(e){const i=e.strategy;switch(i){case"auth_endpoint":case"jwt":{const a=await this.authenticate(e);return await this.loginWithAuthToken(a,e.encryptionKey)}case"iframe_email_verification":return this.auth.loginWithIframe({email:e.email});case"iframe":return this.auth.loginWithModal();case"passkey":{const a=await this.passkeyAuth(e);return this.loginWithAuthToken(a)}case"backend":case"phone":case"email":case"wallet":case"apple":case"facebook":case"google":case"farcaster":case"telegram":case"github":case"line":case"x":case"tiktok":case"epic":case"guest":case"coinbase":case"twitch":case"steam":case"discord":{const a=await this.authenticate(e);return await this.auth.loginWithAuthToken(a)}default:_e(i)}}async logout(){return await this.auth.logout()}async passkeyAuth(e){const{PasskeyWebClient:i}=await f(async()=>{const{PasskeyWebClient:n}=await import("./passkeys-CTJ4NPfL.js");return{PasskeyWebClient:n}},__vite__mapDeps([26,27])),{passkeyName:a,storeLastUsedPasskey:s=!0}=e,c=new i,r=this.storage;return e.type==="sign-up"?le({client:this.client,ecosystem:this.ecosystem,passkeyClient:c,rp:{id:this.passkeyDomain??window.location.hostname,name:this.passkeyDomain??window.document.title},storage:s?r:void 0,username:a}):de({client:this.client,ecosystem:this.ecosystem,passkeyClient:c,rp:{id:this.passkeyDomain??window.location.hostname,name:this.passkeyDomain??window.document.title},storage:s?r:void 0})}async linkProfileWithRedirect(e,i,a){return C({authOption:e,client:this.client,ecosystem:this.ecosystem,mode:i,redirectUrl:a,authFlow:"link"})}async linkProfile(e){if("strategy"in e&&Q.includes(e.strategy)&&"mode"in e&&e.mode!=="popup"&&e.mode!==void 0)return await this.linkProfileWithRedirect(e.strategy,e.mode,"redirectUrl"in e?e.redirectUrl:void 0),[];const{storedToken:i}=await this.authenticate(e);return await H({client:e.client,ecosystem:e.ecosystem||this.ecosystem,storage:this.storage,tokenToLink:i.cookieString})}async unlinkProfile(e,i){return await J({allowAccountDeletion:i,client:this.client,ecosystem:this.ecosystem,profileToUnlink:e,storage:this.storage})}async getProfiles(){return Y({client:this.client,ecosystem:this.ecosystem,storage:this.storage})}}function _e(t,e){throw new Error(`Invalid param: ${t}`)}function De(){return typeof window<"u"&&window.localStorage?F:ee}export{Qe as InAppWebConnector};
@@ -1,3 +1,3 @@
1
- import{ae as An,af as In,ag as Ws,ah as Zs,ai as Ys,aj as Sn,B as tt,$ as Nn,l as Pn,ak as Ir,al as te,am as Gs,an as Ze,ao as ee,ap as Rn,aq as Js,e as Ye,t as Sr,ar as kn,as as Ks,at as Xs,au as Pe,av as Qs,i as Nr,w as _t,aw as Ge,U as At,ax as Tt,b as Pr,ay as to,az as It,aA as z,aB as et,aC as Rr,aD as eo,aE as Je,aF as Ut,a2 as gt,aG as Tn,G as ne,aH as kr,O as $,W as ct,aI as re,D as no,aJ as Cn,aK as ro,aL as _n,aM as Ke,r as M,k as Tr,aN as so,aO as oo,aP as Cr,aQ as io,aR as ao,aS as Re,j as _r,a as Xe,a5 as Yt,aT as $r,aU as Or,L as qr,aV as Ht,aW as Gt,s as Q,aX as ke,H as Ct,aY as co,aZ as de,a_ as $n,a$ as On,b0 as qn,b1 as zn,b2 as Un,b3 as Ln,b4 as jn,b5 as Mn,b6 as Fn,b7 as Hn,b8 as Dn,b9 as Vn,ba as Wn,bb as Te,bc as Zn,bd as Yn,be as Gn,bf as Ce,bg as _e,bh as Jn,bi as Kn,bj as Xn,bk as Qn,bl as $e,bm as zr,bn as Jt,bo as tr,bp as uo,bq as K,br as Y,bs as fo,bt as H,bu as ut,bv as Qe,bw as $t,bx as Ur,by as lo,bz as Lr,bA as ho,bB as po,bC as yo,bD as mo,bE as go,bF as er,bG as wo,bH as bo,bI as vo,bJ as Eo,bK as xo,bL as nr,bM as jr,ac as Bo,bN as Mr,a6 as Fr,bO as Kt,bP as Hr,bQ as Dr,bR as Ao,bS as Io,N as St,c as Vr,a1 as Oe,K as So,bT as No,V as Po,bU as Wr,bV as rr,bW as Zr,bX as Ro,bY as ko,bZ as To,a0 as Co,S as _o,a7 as yt,a8 as se,b_ as $o,b$ as Oo,c0 as kt,c1 as qo,c2 as Yr,c3 as zo,ad as Uo,c4 as Gr,M as oe,c5 as Lo,P as jo,c6 as Mo,c7 as Fo,c8 as Ho,c9 as Do,ca as Vo,cb as le,cc as Wo,cd as Zo,ce as Yo,cf as Go,Q as Jo,cg as Jr}from"./uid-BE5dre25.js";import{_ as Ko}from"./preload-helper-DtiUdDj_.js";function sr(t){const e=[];if(typeof t=="string"){const n=An(t),r=n.length;for(let s=0;s<r;s++)e.push(In(n[s],{modifiers:Sn}))}else{const n=Ws(t),r=t.length;for(let s=0;s<r;s++){const o=t[s];if(Zs(o))continue;const a=An(o),c=a.length;for(let i=0;i<c;i++)e.push(In(a[i],{modifiers:Sn,structs:n}))}}if(e.length===0)throw new Ys({params:t});return e}function tn(t){if(!(t instanceof tt))return!1;const e=t.walk(n=>n instanceof Nn);return e instanceof Nn?e.data?.errorName==="HttpError"||e.data?.errorName==="ResolverError"||e.data?.errorName==="ResolverNotContract"||e.data?.errorName==="ResolverNotFound"||e.data?.errorName==="ReverseAddressMismatch"||e.data?.errorName==="UnsupportedResolverProfile":!1}function Xo(t){const{abi:e,data:n}=t,r=Pn(n,0,4),s=e.find(o=>o.type==="function"&&r===Ir(te(o)));if(!s)throw new Gs(r,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:s.name,args:"inputs"in s&&s.inputs&&s.inputs.length>0?Ze(s.inputs,Pn(n,4)):void 0}}const he="/docs/contract/encodeErrorResult";function or(t){const{abi:e,errorName:n,args:r}=t;let s=e[0];if(n){const i=ee({abi:e,args:r,name:n});if(!i)throw new Rn(n,{docsPath:he});s=i}if(s.type!=="error")throw new Rn(void 0,{docsPath:he});const o=te(s),a=Ir(o);let c="0x";if(r&&r.length>0){if(!s.inputs)throw new Js(s.name,{docsPath:he});c=Ye(s.inputs,r)}return Sr([a,c])}const pe="/docs/contract/encodeFunctionResult";function Qo(t){const{abi:e,functionName:n,result:r}=t;let s=e[0];if(n){const a=ee({abi:e,name:n});if(!a)throw new kn(n,{docsPath:pe});s=a}if(s.type!=="function")throw new kn(void 0,{docsPath:pe});if(!s.outputs)throw new Ks(s.name,{docsPath:pe});const o=(()=>{if(s.outputs.length===0)return[];if(s.outputs.length===1)return[r];if(Array.isArray(r))return r;throw new Xs(r)})();return Ye(s.outputs,o)}const ie="x-batch-gateway:true";async function ti(t){const{data:e,ccipRequest:n}=t,{args:[r]}=Xo({abi:Pe,data:e}),s=[],o=[];return await Promise.all(r.map(async(a,c)=>{try{o[c]=a.urls.includes(ie)?await ti({data:a.data,ccipRequest:n}):await n(a),s[c]=!1}catch(i){s[c]=!0,o[c]=ei(i)}})),Qo({abi:Pe,functionName:"query",result:[s,o]})}function ei(t){return t.name==="HttpRequestError"&&t.status?or({abi:Pe,errorName:"HttpError",args:[t.status,t.shortMessage]}):or({abi:[Qs],errorName:"Error",args:["shortMessage"in t?t.shortMessage:t.message]})}function Kr(t){if(t.length!==66||t.indexOf("[")!==0||t.indexOf("]")!==65)return null;const e=`0x${t.slice(1,65)}`;return Nr(e)?e:null}function qe(t){let e=new Uint8Array(32).fill(0);if(!t)return _t(e);const n=t.split(".");for(let r=n.length-1;r>=0;r-=1){const s=Kr(n[r]),o=s?Ge(s):At(Tt(n[r]),"bytes");e=At(Pr([e,o]),"bytes")}return _t(e)}function ni(t){return`[${t.slice(2)}]`}function ri(t){const e=new Uint8Array(32).fill(0);return t?Kr(t)||At(Tt(t)):_t(e)}function en(t){const e=t.replace(/^\.|\.$/gm,"");if(e.length===0)return new Uint8Array(1);const n=new Uint8Array(Tt(e).byteLength+2);let r=0;const s=e.split(".");for(let o=0;o<s.length;o++){let a=Tt(s[o]);a.byteLength>255&&(a=Tt(ni(ri(s[o])))),n[r]=a.length,n.set(a,r+1),r+=a.length+1}return n.byteLength!==r+1?n.slice(0,r+1):n}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const nn=BigInt(0),ze=BigInt(1);function Lt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function rn(t){if(!Lt(t))throw new Error("Uint8Array expected")}function Ot(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function Dt(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Xr(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?nn:BigInt("0x"+t)}const Qr=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",si=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function qt(t){if(rn(t),Qr)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=si[t[n]];return e}const rt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ir(t){if(t>=rt._0&&t<=rt._9)return t-rt._0;if(t>=rt.A&&t<=rt.F)return t-(rt.A-10);if(t>=rt.a&&t<=rt.f)return t-(rt.a-10)}function Xt(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Qr)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let s=0,o=0;s<n;s++,o+=2){const a=ir(t.charCodeAt(o)),c=ir(t.charCodeAt(o+1));if(a===void 0||c===void 0){const i=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+i+'" at index '+o)}r[s]=a*16+c}return r}function pt(t){return Xr(qt(t))}function ts(t){return rn(t),Xr(qt(Uint8Array.from(t).reverse()))}function jt(t,e){return Xt(t.toString(16).padStart(e*2,"0"))}function es(t,e){return jt(t,e).reverse()}function J(t,e,n){let r;if(typeof e=="string")try{r=Xt(e)}catch(o){throw new Error(t+" must be hex string or Uint8Array, cause: "+o)}else if(Lt(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(t+" of length "+n+" expected, got "+s);return r}function Qt(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];rn(s),e+=s.length}const n=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const o=t[r];n.set(o,s),s+=o.length}return n}const ye=t=>typeof t=="bigint"&&nn<=t;function sn(t,e,n){return ye(t)&&ye(e)&&ye(n)&&e<=t&&t<n}function xt(t,e,n,r){if(!sn(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function oi(t){let e;for(e=0;t>nn;t>>=ze,e+=1);return e}const ae=t=>(ze<<BigInt(t))-ze,me=t=>new Uint8Array(t),ar=t=>Uint8Array.from(t);function ii(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=me(t),s=me(t),o=0;const a=()=>{r.fill(1),s.fill(0),o=0},c=(...d)=>n(s,r,...d),i=(d=me(0))=>{s=c(ar([0]),d),r=c(),d.length!==0&&(s=c(ar([1]),d),r=c())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const l=[];for(;d<e;){r=c();const y=r.slice();l.push(y),d+=r.length}return Qt(...l)};return(d,l)=>{a(),i(d);let y;for(;!(y=l(u()));)i();return a(),y}}const ai={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Lt(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function ce(t,e,n={}){const r=(s,o,a)=>{const c=ai[o];if(typeof c!="function")throw new Error("invalid validator function");const i=t[s];if(!(a&&i===void 0)&&!c(i,t))throw new Error("param "+String(s)+" is invalid. Expected "+o+", got "+i)};for(const[s,o]of Object.entries(e))r(s,o,!1);for(const[s,o]of Object.entries(n))r(s,o,!0);return t}function cr(t){const e=new WeakMap;return(n,...r)=>{const s=e.get(n);if(s!==void 0)return s;const o=t(n,...r);return e.set(n,o),o}}function Mt(t,e){if(Et(t)>e)throw new Bi({givenSize:Et(t),maxSize:e})}const st={zero:48,nine:57,A:65,F:70,a:97,f:102};function ur(t){if(t>=st.zero&&t<=st.nine)return t-st.zero;if(t>=st.A&&t<=st.F)return t-(st.A-10);if(t>=st.a&&t<=st.f)return t-(st.a-10)}function ci(t,e={}){const{dir:n,size:r=32}=e;if(r===0)return t;if(t.length>r)throw new Ai({size:t.length,targetSize:r,type:"Bytes"});const s=new Uint8Array(r);for(let o=0;o<r;o++){const a=n==="right";s[a?o:r-o-1]=t[a?o:t.length-o-1]}return s}function ns(t,e={}){const{dir:n="left"}=e;let r=t,s=0;for(let o=0;o<r.length-1&&r[n==="left"?o:r.length-o-1].toString()==="0";o++)s++;return r=n==="left"?r.slice(s):r.slice(0,r.length-s),r}const ui=new TextDecoder,fi=new TextEncoder;function di(t){if(!(t instanceof Uint8Array)){if(!t)throw new Vt(t);if(typeof t!="object")throw new Vt(t);if(!("BYTES_PER_ELEMENT"in t))throw new Vt(t);if(t.BYTES_PER_ELEMENT!==1||t.constructor.name!=="Uint8Array")throw new Vt(t)}}function li(t){return t instanceof Uint8Array?t:typeof t=="string"?on(t):hi(t)}function hi(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function on(t,e={}){const{size:n}=e;let r=t;n&&(to(t,n),r=It(t,n));let s=r.slice(2);s.length%2&&(s=`0${s}`);const o=s.length/2,a=new Uint8Array(o);for(let c=0,i=0;c<o;c++){const u=ur(s.charCodeAt(i++)),f=ur(s.charCodeAt(i++));if(u===void 0||f===void 0)throw new z(`Invalid byte sequence ("${s[i-2]}${s[i-1]}" in "${s}").`);a[c]=u<<4|f}return a}function pi(t,e={}){const{size:n}=e,r=fi.encode(t);return typeof n=="number"?(Mt(r,n),yi(r,n)):r}function yi(t,e){return ci(t,{dir:"right",size:e})}function Et(t){return t.length}function mi(t,e,n,r={}){const{strict:s}=r;return t.slice(e,n)}function gi(t,e={}){const{size:n}=e;typeof n<"u"&&Mt(t,n);const r=et(t,e);return eo(r,e)}function wi(t,e={}){const{size:n}=e;let r=t;if(typeof n<"u"&&(Mt(r,n),r=rs(r)),r.length>1||r[0]>1)throw new xi(r);return!!r[0]}function at(t,e={}){const{size:n}=e;typeof n<"u"&&Mt(t,n);const r=et(t,e);return Rr(r,e)}function bi(t,e={}){const{size:n}=e;let r=t;return typeof n<"u"&&(Mt(r,n),r=vi(r)),ui.decode(r)}function rs(t){return ns(t,{dir:"left"})}function vi(t){return ns(t,{dir:"right"})}function Ei(t){try{return di(t),!0}catch{return!1}}class xi extends z{constructor(e){super(`Bytes value \`${e}\` is not a valid boolean.`,{metaMessages:["The bytes array must contain a single byte of either a `0` or `1` value."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesBooleanError"})}}class Vt extends z{constructor(e){super(`Value \`${typeof e=="object"?Je(e):e}\` of type \`${typeof e}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class Bi extends z{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Ai extends z{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}async function eu(t,e){const{blockNumber:n,blockTag:r,coinType:s,name:o,gatewayUrls:a,strict:c}=e,{chain:i}=t,u=(()=>{if(e.universalResolverAddress)return e.universalResolverAddress;if(!i)throw new Error("client chain not configured. universalResolverAddress is required.");return Ut({blockNumber:n,chain:i,contract:"ensUniversalResolver"})})(),f=i?.ensTlds;if(f&&!f.some(l=>o.endsWith(l)))return null;const d=s!=null?[qe(o),BigInt(s)]:[qe(o)];try{const l=gt({abi:Tn,functionName:"addr",args:d}),y={address:u,abi:kr,functionName:"resolveWithGateways",args:[ne(en(o)),l,a??[ie]],blockNumber:n,blockTag:r},h=await $(t,ct,"readContract")(y);if(h[0]==="0x")return null;const w=re({abi:Tn,args:d,functionName:"addr",data:h[0]});return w==="0x"||no(w)==="0x00"?null:w}catch(l){if(c)throw l;if(tn(l))return null;throw l}}class Ii extends tt{constructor({data:e}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(e)}`],name:"EnsAvatarInvalidMetadataError"})}}class Rt extends tt{constructor({reason:e}){super(`ENS NFT avatar URI is invalid. ${e}`,{name:"EnsAvatarInvalidNftUriError"})}}class an extends tt{constructor({uri:e}){super(`Unable to resolve ENS avatar URI "${e}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class Si extends tt{constructor({namespace:e}){super(`ENS NFT avatar namespace "${e}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}class nu extends tt{constructor({chainId:e}){super(`Invalid ENSIP-11 chainId: ${e}. Must be between 0 and 0x7fffffff, or 1.`,{name:"EnsInvalidChainIdError"})}}const Ni=/(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,Pi=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/,Ri=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,ki=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function Ti(t){try{const e=await fetch(t,{method:"HEAD"});return e.status===200?e.headers.get("content-type")?.startsWith("image/"):!1}catch(e){return typeof e=="object"&&typeof e.response<"u"||!Object.hasOwn(globalThis,"Image")?!1:new Promise(n=>{const r=new Image;r.onload=()=>{n(!0)},r.onerror=()=>{n(!1)},r.src=t})}}function fr(t,e){return t?t.endsWith("/")?t.slice(0,-1):t:e}function ss({uri:t,gatewayUrls:e}){const n=Ri.test(t);if(n)return{uri:t,isOnChain:!0,isEncoded:n};const r=fr(e?.ipfs,"https://ipfs.io"),s=fr(e?.arweave,"https://arweave.net"),o=t.match(Ni),{protocol:a,subpath:c,target:i,subtarget:u=""}=o?.groups||{},f=a==="ipns:/"||c==="ipns/",d=a==="ipfs:/"||c==="ipfs/"||Pi.test(t);if(t.startsWith("http")&&!f&&!d){let y=t;return e?.arweave&&(y=t.replace(/https:\/\/arweave.net/g,e?.arweave)),{uri:y,isOnChain:!1,isEncoded:!1}}if((f||d)&&i)return{uri:`${r}/${f?"ipns":"ipfs"}/${i}${u}`,isOnChain:!1,isEncoded:!1};if(a==="ar:/"&&i)return{uri:`${s}/${i}${u||""}`,isOnChain:!1,isEncoded:!1};let l=t.replace(ki,"");if(l.startsWith("<svg")&&(l=`data:image/svg+xml;base64,${btoa(l)}`),l.startsWith("data:")||l.startsWith("{"))return{uri:l,isOnChain:!0,isEncoded:!1};throw new an({uri:t})}function os(t){if(typeof t!="object"||!("image"in t)&&!("image_url"in t)&&!("image_data"in t))throw new Ii({data:t});return t.image||t.image_url||t.image_data}async function Ci({gatewayUrls:t,uri:e}){try{const n=await fetch(e).then(s=>s.json());return await cn({gatewayUrls:t,uri:os(n)})}catch{throw new an({uri:e})}}async function cn({gatewayUrls:t,uri:e}){const{uri:n,isOnChain:r}=ss({uri:e,gatewayUrls:t});if(r||await Ti(n))return n;throw new an({uri:e})}function _i(t){let e=t;e.startsWith("did:nft:")&&(e=e.replace("did:nft:","").replace(/_/g,"/"));const[n,r,s]=e.split("/"),[o,a]=n.split(":"),[c,i]=r.split(":");if(!o||o.toLowerCase()!=="eip155")throw new Rt({reason:"Only EIP-155 supported"});if(!a)throw new Rt({reason:"Chain ID not found"});if(!i)throw new Rt({reason:"Contract address not found"});if(!s)throw new Rt({reason:"Token ID not found"});if(!c)throw new Rt({reason:"ERC namespace not found"});return{chainID:Number.parseInt(a,10),namespace:c.toLowerCase(),contractAddress:i,tokenID:s}}async function $i(t,{nft:e}){if(e.namespace==="erc721")return ct(t,{address:e.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(e.tokenID)]});if(e.namespace==="erc1155")return ct(t,{address:e.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(e.tokenID)]});throw new Si({namespace:e.namespace})}async function Oi(t,{gatewayUrls:e,record:n}){return/eip155:/i.test(n)?qi(t,{gatewayUrls:e,record:n}):cn({uri:n,gatewayUrls:e})}async function qi(t,{gatewayUrls:e,record:n}){const r=_i(n),s=await $i(t,{nft:r}),{uri:o,isOnChain:a,isEncoded:c}=ss({uri:s,gatewayUrls:e});if(a&&(o.includes("data:application/json;base64,")||o.startsWith("{"))){const u=c?atob(o.replace("data:application/json;base64,","")):o,f=JSON.parse(u);return cn({uri:os(f),gatewayUrls:e})}let i=r.tokenID;return r.namespace==="erc1155"&&(i=i.replace("0x","").padStart(64,"0")),Ci({gatewayUrls:e,uri:o.replace(/(?:0x)?{id}/,i)})}async function zi(t,e){const{blockNumber:n,blockTag:r,key:s,name:o,gatewayUrls:a,strict:c}=e,{chain:i}=t,u=(()=>{if(e.universalResolverAddress)return e.universalResolverAddress;if(!i)throw new Error("client chain not configured. universalResolverAddress is required.");return Ut({blockNumber:n,chain:i,contract:"ensUniversalResolver"})})(),f=i?.ensTlds;if(f&&!f.some(d=>o.endsWith(d)))return null;try{const d={address:u,abi:kr,args:[ne(en(o)),gt({abi:Cn,functionName:"text",args:[qe(o),s]}),a??[ie]],functionName:"resolveWithGateways",blockNumber:n,blockTag:r},y=await $(t,ct,"readContract")(d);if(y[0]==="0x")return null;const m=re({abi:Cn,functionName:"text",data:y[0]});return m===""?null:m}catch(d){if(c)throw d;if(tn(d))return null;throw d}}async function ru(t,{blockNumber:e,blockTag:n,assetGatewayUrls:r,name:s,gatewayUrls:o,strict:a,universalResolverAddress:c}){const i=await $(t,zi,"getEnsText")({blockNumber:e,blockTag:n,key:"avatar",name:s,universalResolverAddress:c,gatewayUrls:o,strict:a});if(!i)return null;try{return await Oi(t,{record:i,gatewayUrls:r})}catch{return null}}async function su(t,e){const{address:n,blockNumber:r,blockTag:s,coinType:o=60n,gatewayUrls:a,strict:c}=e,{chain:i}=t,u=(()=>{if(e.universalResolverAddress)return e.universalResolverAddress;if(!i)throw new Error("client chain not configured. universalResolverAddress is required.");return Ut({blockNumber:r,chain:i,contract:"ensUniversalResolver"})})();try{const f={address:u,abi:ro,args:[n,o,a??[ie]],functionName:"reverseWithGateways",blockNumber:r,blockTag:s},d=$(t,ct,"readContract"),[l]=await d(f);return l||null}catch(f){if(c)throw f;if(tn(f))return null;throw f}}async function ou(t,e){const{blockNumber:n,blockTag:r,name:s}=e,{chain:o}=t,a=(()=>{if(e.universalResolverAddress)return e.universalResolverAddress;if(!o)throw new Error("client chain not configured. universalResolverAddress is required.");return Ut({blockNumber:n,chain:o,contract:"ensUniversalResolver"})})(),c=o?.ensTlds;if(c&&!c.some(u=>s.endsWith(u)))throw new Error(`${s} is not a valid ENS TLD (${c?.join(", ")}) for chain "${o.name}" (id: ${o.id}).`);const[i]=await $(t,ct,"readContract")({address:a,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"},{type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[ne(en(s))],blockNumber:n,blockTag:r});return i}function is(t,{method:e}){const n={};return t.transport.type==="fallback"&&t.transport.onResponse?.(({method:r,response:s,status:o,transport:a})=>{o==="success"&&e===r&&(n[s]=a.request)}),r=>n[r]||t.request}class Ui extends tt{constructor(e){super(`Filter type "${e}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}const dr="/docs/contract/encodeEventTopics";function un(t){const{abi:e,eventName:n,args:r}=t;let s=e[0];if(n){const i=ee({abi:e,name:n});if(!i)throw new _n(n,{docsPath:dr});s=i}if(s.type!=="event")throw new _n(void 0,{docsPath:dr});const o=te(s),a=Ke(o);let c=[];if(r&&"inputs"in s){const i=s.inputs?.filter(f=>"indexed"in f&&f.indexed),u=Array.isArray(r)?r:Object.values(r).length>0?i?.map(f=>r[f.name])??[]:[];u.length>0&&(c=i?.map((f,d)=>Array.isArray(u[d])?u[d].map((l,y)=>lr({param:f,value:u[d][y]})):typeof u[d]<"u"&&u[d]!==null?lr({param:f,value:u[d]}):null)??[])}return[a,...c]}function lr({param:t,value:e}){if(t.type==="string"||t.type==="bytes")return At(Ge(e));if(t.type==="tuple"||t.type.match(/^(.*)\[(\d+)?\]$/))throw new Ui(t.type);return Ye([t],[e])}async function Li(t,e){const{address:n,abi:r,args:s,eventName:o,fromBlock:a,strict:c,toBlock:i}=e,u=is(t,{method:"eth_newFilter"}),f=o?un({abi:r,args:s,eventName:o}):void 0,d=await t.request({method:"eth_newFilter",params:[{address:n,fromBlock:typeof a=="bigint"?M(a):a,toBlock:typeof i=="bigint"?M(i):i,topics:f}]});return{abi:r,args:s,eventName:o,id:d,request:u(d),strict:!!c,type:"event"}}async function ji(t){const e=is(t,{method:"eth_newPendingTransactionFilter"}),n=await t.request({method:"eth_newPendingTransactionFilter"});return{id:n,request:e(n),type:"transaction"}}async function iu(t,{address:e,blockNumber:n,blockTag:r=t.experimental_blockTag??"latest"}){const s=typeof n=="bigint"?M(n):void 0,o=await t.request({method:"eth_getBalance",params:[e,s||r]});return BigInt(o)}const Mi=new Map,Fi=new Map;function Hi(t){const e=(s,o)=>({clear:()=>o.delete(s),get:()=>o.get(s),set:a=>o.set(s,a)}),n=e(t,Mi),r=e(t,Fi);return{clear:()=>{n.clear(),r.clear()},promise:n,response:r}}async function Di(t,{cacheKey:e,cacheTime:n=Number.POSITIVE_INFINITY}){const r=Hi(e),s=r.response.get();if(s&&n>0&&Date.now()-s.created.getTime()<n)return s.data;let o=r.promise.get();o||(o=t(),r.promise.set(o));try{const a=await o;return r.response.set({created:new Date,data:a}),a}finally{r.promise.clear()}}const Vi=t=>`blockNumber.${t}`;async function fn(t,{cacheTime:e=t.cacheTime}={}){const n=await Di(()=>t.request({method:"eth_blockNumber"}),{cacheKey:Vi(t.uid),cacheTime:e});return BigInt(n)}async function au(t,{blockHash:e,blockNumber:n,blockTag:r="latest"}={}){const s=n!==void 0?M(n):void 0;let o;return e?o=await t.request({method:"eth_getBlockTransactionCountByHash",params:[e]},{dedupe:!0}):o=await t.request({method:"eth_getBlockTransactionCountByNumber",params:[s||r]},{dedupe:!!s}),Tr(o)}const hr="/docs/contract/decodeEventLog";function Ue(t){const{abi:e,data:n,strict:r,topics:s}=t,o=r??!0,[a,...c]=s;if(!a)throw new so({docsPath:hr});const i=e.find(h=>h.type==="event"&&a===Ke(te(h)));if(!(i&&"name"in i)||i.type!=="event")throw new oo(a,{docsPath:hr});const{name:u,inputs:f}=i,d=f?.some(h=>!("name"in h&&h.name)),l=d?[]:{},y=f.map((h,w)=>[h,w]).filter(([h])=>"indexed"in h&&h.indexed);for(let h=0;h<y.length;h++){const[w,I]=y[h],P=c[h];if(!P)throw new Cr({abiItem:i,param:w});l[d?I:w.name||I]=Wi({param:w,value:P})}const m=f.filter(h=>!("indexed"in h&&h.indexed));if(m.length>0){if(n&&n!=="0x")try{const h=Ze(m,n);if(h)if(d)for(let w=0;w<f.length;w++)l[w]=l[w]??h.shift();else for(let w=0;w<m.length;w++)l[m[w].name]=h[w]}catch(h){if(o)throw h instanceof io||h instanceof ao?new Re({abiItem:i,data:n,params:m,size:_r(n)}):h}else if(o)throw new Re({abiItem:i,data:"0x",params:m,size:0})}return{eventName:u,args:Object.values(l).length>0?l:void 0}}function Wi({param:t,value:e}){return t.type==="string"||t.type==="bytes"||t.type==="tuple"||t.type.match(/^(.*)\[(\d+)?\]$/)?e:(Ze([t],e)||[])[0]}function as(t){const{abi:e,args:n,logs:r,strict:s=!0}=t,o=(()=>{if(t.eventName)return Array.isArray(t.eventName)?t.eventName:[t.eventName]})();return r.map(a=>{const c=e.filter(f=>f.type==="event"&&a.topics[0]===Ke(f));if(c.length===0)return null;let i,u;for(const f of c)try{i=Ue({...a,abi:[f],strict:!0}),u=f;break}catch{}if(!i&&!s){u=c[0];try{i=Ue({...a,abi:[u],strict:!1})}catch{const f=u.inputs?.some(d=>!("name"in d&&d.name));return{...a,args:f?[]:{},eventName:u.name}}}return!i||!u||o&&!o.includes(i.eventName)||!Zi({args:i.args,inputs:u.inputs,matchArgs:n})?null:{...i,...a}}).filter(Boolean)}function Zi(t){const{args:e,inputs:n,matchArgs:r}=t;if(!r)return!0;if(!e)return!1;function s(o,a,c){try{return o.type==="address"?Xe(a,c):o.type==="string"||o.type==="bytes"?At(Ge(a))===c:a===c}catch{return!1}}return Array.isArray(e)&&Array.isArray(r)?r.every((o,a)=>{if(o==null)return!0;const c=n[a];return c?(Array.isArray(o)?o:[o]).some(u=>s(c,u,e[a])):!1}):typeof e=="object"&&!Array.isArray(e)&&typeof r=="object"&&!Array.isArray(r)?Object.entries(r).every(([o,a])=>{if(a==null)return!0;const c=n.find(u=>u.name===o);return c?(Array.isArray(a)?a:[a]).some(u=>s(c,u,e[o])):!1}):!1}async function Yi(t,{address:e,blockHash:n,fromBlock:r,toBlock:s,event:o,events:a,args:c,strict:i}={}){const u=i??!1,f=a??(o?[o]:void 0);let d=[];f&&(d=[f.flatMap(h=>un({abi:[h],eventName:h.name,args:a?void 0:c}))],o&&(d=d[0]));let l;n?l=await t.request({method:"eth_getLogs",params:[{address:e,topics:d,blockHash:n}]}):l=await t.request({method:"eth_getLogs",params:[{address:e,topics:d,fromBlock:typeof r=="bigint"?M(r):r,toBlock:typeof s=="bigint"?M(s):s}]});const y=l.map(m=>Yt(m));return f?as({abi:f,args:c,logs:y,strict:u}):y}async function Gi(t,e){const{abi:n,address:r,args:s,blockHash:o,eventName:a,fromBlock:c,toBlock:i,strict:u}=e,f=a?ee({abi:n,name:a}):void 0,d=f?void 0:n.filter(l=>l.type==="event");return $(t,Yi,"getLogs")({address:r,args:s,blockHash:o,event:f,events:d,fromBlock:c,toBlock:i,strict:u})}function Ji(t){return{baseFeePerGas:t.baseFeePerGas.map(e=>BigInt(e)),gasUsedRatio:t.gasUsedRatio,oldestBlock:BigInt(t.oldestBlock),reward:t.reward?.map(e=>e.map(n=>BigInt(n)))}}async function cu(t,{blockCount:e,blockNumber:n,blockTag:r="latest",rewardPercentiles:s}){const o=typeof n=="bigint"?M(n):void 0,a=await t.request({method:"eth_feeHistory",params:[M(e),o||r,s]},{dedupe:!!o});return Ji(a)}async function cs(t,{filter:e}){const n="strict"in e&&e.strict,r=await e.request({method:"eth_getFilterChanges",params:[e.id]});if(typeof r[0]=="string")return r;const s=r.map(o=>Yt(o));return!("abi"in e)||!e.abi?s:as({abi:e.abi,logs:s,strict:n})}async function Ki({address:t,authorization:e,signature:n}){return Xe(Or(t),await $r({authorization:e,signature:n}))}const Wt=new qr(8192);function Xi(t,{enabled:e=!0,id:n}){if(!e||!n)return t();if(Wt.get(n))return Wt.get(n);const r=t().finally(()=>Wt.delete(n));return Wt.set(n,r),r}function Qi(t,e={}){return async(n,r={})=>{const{dedupe:s=!1,methods:o,retryDelay:a=150,retryCount:c=3,uid:i}={...e,...r},{method:u}=n;if(o?.exclude?.includes(u))throw new Ht(new Error("method not supported"),{method:u});if(o?.include&&!o.include.includes(u))throw new Ht(new Error("method not supported"),{method:u});const f=s?Gt(`${i}.${Q(n)}`):void 0;return Xi(()=>ke(async()=>{try{return await t(n)}catch(d){const l=d;switch(l.code){case Qn.code:throw new Qn(l);case Xn.code:throw new Xn(l);case Kn.code:throw new Kn(l,{method:n.method});case Jn.code:throw new Jn(l);case _e.code:throw new _e(l);case Ce.code:throw new Ce(l);case Gn.code:throw new Gn(l);case Yn.code:throw new Yn(l);case Zn.code:throw new Zn(l);case Ht.code:throw new Ht(l,{method:n.method});case Te.code:throw new Te(l);case Wn.code:throw new Wn(l);case de.code:throw new de(l);case Vn.code:throw new Vn(l);case Dn.code:throw new Dn(l);case Hn.code:throw new Hn(l);case Fn.code:throw new Fn(l);case Mn.code:throw new Mn(l);case jn.code:throw new jn(l);case Ln.code:throw new Ln(l);case Un.code:throw new Un(l);case zn.code:throw new zn(l);case qn.code:throw new qn(l);case On.code:throw new On(l);case $n.code:throw new $n(l);case 5e3:throw new de(l);default:throw d instanceof tt?d:new co(l)}}},{delay:({count:d,error:l})=>{if(l&&l instanceof Ct){const y=l?.headers?.get("Retry-After");if(y?.match(/\d/))return Number.parseInt(y,10)*1e3}return~~(1<<d)*a},retryCount:c,shouldRetry:({error:d})=>ta(d)}),{enabled:s,id:f})}}function ta(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===Te.code||t.code===_e.code:t instanceof Ct&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function us(t,{errorInstance:e=new Error("timed out"),timeout:n,signal:r}){return new Promise((s,o)=>{(async()=>{let a;try{const c=new AbortController;n>0&&(a=setTimeout(()=>{r?c.abort():o(e)},n)),s(await t({signal:c?.signal||null}))}catch(c){c?.name==="AbortError"&&o(e),o(c)}finally{clearTimeout(a)}})()})}function ea(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const Le=ea();function fs(t,e={}){const{url:n,headers:r}=na(t);return{async request(s){const{body:o,fetchFn:a=e.fetchFn??fetch,onRequest:c=e.onRequest,onResponse:i=e.onResponse,timeout:u=e.timeout??1e4}=s,f={...e.fetchOptions??{},...s.fetchOptions??{}},{headers:d,method:l,signal:y}=f;try{const m=await us(async({signal:w})=>{const I={...f,body:Array.isArray(o)?Q(o.map(g=>({jsonrpc:"2.0",id:g.id??Le.take(),...g}))):Q({jsonrpc:"2.0",id:o.id??Le.take(),...o}),headers:{...r,"Content-Type":"application/json",...d},method:l||"POST",signal:y||(u>0?w:null)},P=new Request(n,I),b=await c?.(P,I)??{...I,url:n};return await a(b.url??n,b)},{errorInstance:new $e({body:o,url:n}),timeout:u,signal:!0});i&&await i(m);let h;if(m.headers.get("Content-Type")?.startsWith("application/json"))h=await m.json();else{h=await m.text();try{h=JSON.parse(h||"{}")}catch(w){if(m.ok)throw w;h={error:h}}}if(!m.ok)throw new Ct({body:o,details:Q(h.error)||m.statusText,headers:m.headers,status:m.status,url:n});return h}catch(m){throw m instanceof Ct||m instanceof $e?m:new Ct({body:o,cause:m,url:n})}}}}function na(t){try{const e=new URL(t),n=(()=>{if(e.username){const r=`${decodeURIComponent(e.username)}:${decodeURIComponent(e.password)}`;return e.username="",e.password="",{url:e.toString(),headers:{Authorization:`Basic ${btoa(r)}`}}}})();return{url:e.toString(),...n}}catch{return{url:t}}}const ge=new Map;async function ra(t){const{getSocket:e,keepAlive:n=!0,key:r="socket",reconnect:s=!0,url:o}=t,{interval:a=3e4}=typeof n=="object"?n:{},{attempts:c=5,delay:i=2e3}=typeof s=="object"?s:{},u=JSON.stringify({keepAlive:n,key:r,url:o,reconnect:s});let f=ge.get(u);if(f)return f;let d=0;const{schedule:l}=zr({id:u,fn:async()=>{const h=new Map,w=new Map;let I,P,b,p=!1;function g(){if(s&&d<c){if(p)return;p=!0,d++,P?.close(),setTimeout(async()=>{await B().catch(console.error),p=!1},i)}else h.clear(),w.clear()}async function B(){const v=await e({onClose(){for(const x of h.values())x.onError?.(new Jt({url:o}));for(const x of w.values())x.onError?.(new Jt({url:o}));g()},onError(x){I=x;for(const R of h.values())R.onError?.(I);for(const R of w.values())R.onError?.(I);g()},onOpen(){I=void 0,d=0},onResponse(x){const R=x.method==="eth_subscription",k=R?x.params.subscription:x.id,S=R?w:h,N=S.get(k);N&&N.onResponse(x),R||S.delete(k)}});if(P=v,n&&(b&&clearInterval(b),b=setInterval(()=>P.ping?.(),a)),s&&w.size>0){const x=w.entries();for(const[R,{onResponse:k,body:S,onError:N}]of x)S&&(w.delete(R),f?.request({body:S,onResponse:k,onError:N}))}return v}return await B(),I=void 0,f={close(){b&&clearInterval(b),P.close(),ge.delete(u)},get socket(){return P},request({body:v,onError:x,onResponse:R}){I&&x&&x(I);const k=v.id??Le.take(),S=N=>{typeof N.id=="number"&&k!==N.id||(v.method==="eth_subscribe"&&typeof N.result=="string"&&w.set(N.result,{onResponse:S,onError:x,body:v}),R(N))};v.method==="eth_unsubscribe"&&w.delete(v.params?.[0]),h.set(k,{onResponse:S,onError:x});try{P.request({body:{jsonrpc:"2.0",id:k,...v}})}catch(N){x?.(N)}},requestAsync({body:v,timeout:x=1e4}){return us(()=>new Promise((R,k)=>this.request({body:v,onError:k,onResponse:R})),{errorInstance:new $e({body:v,url:o}),timeout:x})},requests:h,subscriptions:w,url:o},ge.set(u,f),[f]}}),[y,[m]]=await l();return m}async function Zt(t,e={}){const{keepAlive:n,reconnect:r}=e;return ra({async getSocket({onClose:s,onError:o,onOpen:a,onResponse:c}){const i=await Ko(()=>import("./native-CJ5et6AR.js"),[]).then(y=>y.WebSocket),u=new i(t);function f(){u.removeEventListener("close",f),u.removeEventListener("message",d),u.removeEventListener("error",o),u.removeEventListener("open",a),s()}function d({data:y}){if(!(typeof y=="string"&&y.trim().length===0))try{const m=JSON.parse(y);c(m)}catch(m){o(m)}}u.addEventListener("close",f),u.addEventListener("message",d),u.addEventListener("error",o),u.addEventListener("open",a),u.readyState===i.CONNECTING&&await new Promise((y,m)=>{u&&(u.onopen=y,u.onerror=m)});const{close:l}=u;return Object.assign(u,{close(){l.bind(u)(),f()},ping(){try{if(u.readyState===u.CLOSED||u.readyState===u.CLOSING)throw new tr({url:u.url,cause:new Jt({url:u.url})});const y={jsonrpc:"2.0",id:null,method:"net_version",params:[]};u.send(JSON.stringify(y))}catch(y){o(y)}},request({body:y}){if(u.readyState===u.CLOSED||u.readyState===u.CLOSING)throw new tr({body:y,url:u.url,cause:new Jt({url:u.url})});return u.send(JSON.stringify(y))}})},keepAlive:n,reconnect:r,url:t})}function sa(t,{body:e,onError:n,onResponse:r}){return t.request({body:e,onError:n,onResponse:r}),t}async function oa(t,{body:e,timeout:n=1e4}){return t.requestAsync({body:e,timeout:n})}async function ia(t){const e=await Zt(t);return Object.assign(e.socket,{requests:e.requests,subscriptions:e.subscriptions})}const uu={http(t,e){return fs(t).request(e)},webSocket:sa,webSocketAsync:oa},aa=`Ethereum Signed Message:
1
+ import{ae as An,af as In,ag as Ws,ah as Zs,ai as Ys,aj as Sn,B as tt,$ as Nn,l as Pn,ak as Ir,al as te,am as Gs,an as Ze,ao as ee,ap as Rn,aq as Js,e as Ye,t as Sr,ar as kn,as as Ks,at as Xs,au as Pe,av as Qs,i as Nr,w as _t,aw as Ge,U as At,ax as Tt,b as Pr,ay as to,az as It,aA as z,aB as et,aC as Rr,aD as eo,aE as Je,aF as Ut,a2 as gt,aG as Tn,G as ne,aH as kr,O as $,W as ct,aI as re,D as no,aJ as Cn,aK as ro,aL as _n,aM as Ke,r as M,k as Tr,aN as so,aO as oo,aP as Cr,aQ as io,aR as ao,aS as Re,j as _r,a as Xe,a5 as Yt,aT as $r,aU as Or,L as qr,aV as Ht,aW as Gt,s as Q,aX as ke,H as Ct,aY as co,aZ as de,a_ as $n,a$ as On,b0 as qn,b1 as zn,b2 as Un,b3 as Ln,b4 as jn,b5 as Mn,b6 as Fn,b7 as Hn,b8 as Dn,b9 as Vn,ba as Wn,bb as Te,bc as Zn,bd as Yn,be as Gn,bf as Ce,bg as _e,bh as Jn,bi as Kn,bj as Xn,bk as Qn,bl as $e,bm as zr,bn as Jt,bo as tr,bp as uo,bq as K,br as Y,bs as fo,bt as H,bu as ut,bv as Qe,bw as $t,bx as Ur,by as lo,bz as Lr,bA as ho,bB as po,bC as yo,bD as mo,bE as go,bF as er,bG as wo,bH as bo,bI as vo,bJ as Eo,bK as xo,bL as nr,bM as jr,ac as Bo,bN as Mr,a6 as Fr,bO as Kt,bP as Hr,bQ as Dr,bR as Ao,bS as Io,N as St,c as Vr,a1 as Oe,K as So,bT as No,V as Po,bU as Wr,bV as rr,bW as Zr,bX as Ro,bY as ko,bZ as To,a0 as Co,S as _o,a7 as yt,a8 as se,b_ as $o,b$ as Oo,c0 as kt,c1 as qo,c2 as Yr,c3 as zo,ad as Uo,c4 as Gr,M as oe,c5 as Lo,P as jo,c6 as Mo,c7 as Fo,c8 as Ho,c9 as Do,ca as Vo,cb as le,cc as Wo,cd as Zo,ce as Yo,cf as Go,Q as Jo,cg as Jr}from"./uid-Cob2hcqP.js";import{_ as Ko}from"./preload-helper-5SOR_wM4.js";function sr(t){const e=[];if(typeof t=="string"){const n=An(t),r=n.length;for(let s=0;s<r;s++)e.push(In(n[s],{modifiers:Sn}))}else{const n=Ws(t),r=t.length;for(let s=0;s<r;s++){const o=t[s];if(Zs(o))continue;const a=An(o),c=a.length;for(let i=0;i<c;i++)e.push(In(a[i],{modifiers:Sn,structs:n}))}}if(e.length===0)throw new Ys({params:t});return e}function tn(t){if(!(t instanceof tt))return!1;const e=t.walk(n=>n instanceof Nn);return e instanceof Nn?e.data?.errorName==="HttpError"||e.data?.errorName==="ResolverError"||e.data?.errorName==="ResolverNotContract"||e.data?.errorName==="ResolverNotFound"||e.data?.errorName==="ReverseAddressMismatch"||e.data?.errorName==="UnsupportedResolverProfile":!1}function Xo(t){const{abi:e,data:n}=t,r=Pn(n,0,4),s=e.find(o=>o.type==="function"&&r===Ir(te(o)));if(!s)throw new Gs(r,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:s.name,args:"inputs"in s&&s.inputs&&s.inputs.length>0?Ze(s.inputs,Pn(n,4)):void 0}}const he="/docs/contract/encodeErrorResult";function or(t){const{abi:e,errorName:n,args:r}=t;let s=e[0];if(n){const i=ee({abi:e,args:r,name:n});if(!i)throw new Rn(n,{docsPath:he});s=i}if(s.type!=="error")throw new Rn(void 0,{docsPath:he});const o=te(s),a=Ir(o);let c="0x";if(r&&r.length>0){if(!s.inputs)throw new Js(s.name,{docsPath:he});c=Ye(s.inputs,r)}return Sr([a,c])}const pe="/docs/contract/encodeFunctionResult";function Qo(t){const{abi:e,functionName:n,result:r}=t;let s=e[0];if(n){const a=ee({abi:e,name:n});if(!a)throw new kn(n,{docsPath:pe});s=a}if(s.type!=="function")throw new kn(void 0,{docsPath:pe});if(!s.outputs)throw new Ks(s.name,{docsPath:pe});const o=(()=>{if(s.outputs.length===0)return[];if(s.outputs.length===1)return[r];if(Array.isArray(r))return r;throw new Xs(r)})();return Ye(s.outputs,o)}const ie="x-batch-gateway:true";async function ti(t){const{data:e,ccipRequest:n}=t,{args:[r]}=Xo({abi:Pe,data:e}),s=[],o=[];return await Promise.all(r.map(async(a,c)=>{try{o[c]=a.urls.includes(ie)?await ti({data:a.data,ccipRequest:n}):await n(a),s[c]=!1}catch(i){s[c]=!0,o[c]=ei(i)}})),Qo({abi:Pe,functionName:"query",result:[s,o]})}function ei(t){return t.name==="HttpRequestError"&&t.status?or({abi:Pe,errorName:"HttpError",args:[t.status,t.shortMessage]}):or({abi:[Qs],errorName:"Error",args:["shortMessage"in t?t.shortMessage:t.message]})}function Kr(t){if(t.length!==66||t.indexOf("[")!==0||t.indexOf("]")!==65)return null;const e=`0x${t.slice(1,65)}`;return Nr(e)?e:null}function qe(t){let e=new Uint8Array(32).fill(0);if(!t)return _t(e);const n=t.split(".");for(let r=n.length-1;r>=0;r-=1){const s=Kr(n[r]),o=s?Ge(s):At(Tt(n[r]),"bytes");e=At(Pr([e,o]),"bytes")}return _t(e)}function ni(t){return`[${t.slice(2)}]`}function ri(t){const e=new Uint8Array(32).fill(0);return t?Kr(t)||At(Tt(t)):_t(e)}function en(t){const e=t.replace(/^\.|\.$/gm,"");if(e.length===0)return new Uint8Array(1);const n=new Uint8Array(Tt(e).byteLength+2);let r=0;const s=e.split(".");for(let o=0;o<s.length;o++){let a=Tt(s[o]);a.byteLength>255&&(a=Tt(ni(ri(s[o])))),n[r]=a.length,n.set(a,r+1),r+=a.length+1}return n.byteLength!==r+1?n.slice(0,r+1):n}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const nn=BigInt(0),ze=BigInt(1);function Lt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function rn(t){if(!Lt(t))throw new Error("Uint8Array expected")}function Ot(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function Dt(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Xr(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?nn:BigInt("0x"+t)}const Qr=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",si=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function qt(t){if(rn(t),Qr)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=si[t[n]];return e}const rt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ir(t){if(t>=rt._0&&t<=rt._9)return t-rt._0;if(t>=rt.A&&t<=rt.F)return t-(rt.A-10);if(t>=rt.a&&t<=rt.f)return t-(rt.a-10)}function Xt(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Qr)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let s=0,o=0;s<n;s++,o+=2){const a=ir(t.charCodeAt(o)),c=ir(t.charCodeAt(o+1));if(a===void 0||c===void 0){const i=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+i+'" at index '+o)}r[s]=a*16+c}return r}function pt(t){return Xr(qt(t))}function ts(t){return rn(t),Xr(qt(Uint8Array.from(t).reverse()))}function jt(t,e){return Xt(t.toString(16).padStart(e*2,"0"))}function es(t,e){return jt(t,e).reverse()}function J(t,e,n){let r;if(typeof e=="string")try{r=Xt(e)}catch(o){throw new Error(t+" must be hex string or Uint8Array, cause: "+o)}else if(Lt(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(t+" of length "+n+" expected, got "+s);return r}function Qt(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];rn(s),e+=s.length}const n=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const o=t[r];n.set(o,s),s+=o.length}return n}const ye=t=>typeof t=="bigint"&&nn<=t;function sn(t,e,n){return ye(t)&&ye(e)&&ye(n)&&e<=t&&t<n}function xt(t,e,n,r){if(!sn(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function oi(t){let e;for(e=0;t>nn;t>>=ze,e+=1);return e}const ae=t=>(ze<<BigInt(t))-ze,me=t=>new Uint8Array(t),ar=t=>Uint8Array.from(t);function ii(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=me(t),s=me(t),o=0;const a=()=>{r.fill(1),s.fill(0),o=0},c=(...d)=>n(s,r,...d),i=(d=me(0))=>{s=c(ar([0]),d),r=c(),d.length!==0&&(s=c(ar([1]),d),r=c())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const l=[];for(;d<e;){r=c();const y=r.slice();l.push(y),d+=r.length}return Qt(...l)};return(d,l)=>{a(),i(d);let y;for(;!(y=l(u()));)i();return a(),y}}const ai={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Lt(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function ce(t,e,n={}){const r=(s,o,a)=>{const c=ai[o];if(typeof c!="function")throw new Error("invalid validator function");const i=t[s];if(!(a&&i===void 0)&&!c(i,t))throw new Error("param "+String(s)+" is invalid. Expected "+o+", got "+i)};for(const[s,o]of Object.entries(e))r(s,o,!1);for(const[s,o]of Object.entries(n))r(s,o,!0);return t}function cr(t){const e=new WeakMap;return(n,...r)=>{const s=e.get(n);if(s!==void 0)return s;const o=t(n,...r);return e.set(n,o),o}}function Mt(t,e){if(Et(t)>e)throw new Bi({givenSize:Et(t),maxSize:e})}const st={zero:48,nine:57,A:65,F:70,a:97,f:102};function ur(t){if(t>=st.zero&&t<=st.nine)return t-st.zero;if(t>=st.A&&t<=st.F)return t-(st.A-10);if(t>=st.a&&t<=st.f)return t-(st.a-10)}function ci(t,e={}){const{dir:n,size:r=32}=e;if(r===0)return t;if(t.length>r)throw new Ai({size:t.length,targetSize:r,type:"Bytes"});const s=new Uint8Array(r);for(let o=0;o<r;o++){const a=n==="right";s[a?o:r-o-1]=t[a?o:t.length-o-1]}return s}function ns(t,e={}){const{dir:n="left"}=e;let r=t,s=0;for(let o=0;o<r.length-1&&r[n==="left"?o:r.length-o-1].toString()==="0";o++)s++;return r=n==="left"?r.slice(s):r.slice(0,r.length-s),r}const ui=new TextDecoder,fi=new TextEncoder;function di(t){if(!(t instanceof Uint8Array)){if(!t)throw new Vt(t);if(typeof t!="object")throw new Vt(t);if(!("BYTES_PER_ELEMENT"in t))throw new Vt(t);if(t.BYTES_PER_ELEMENT!==1||t.constructor.name!=="Uint8Array")throw new Vt(t)}}function li(t){return t instanceof Uint8Array?t:typeof t=="string"?on(t):hi(t)}function hi(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function on(t,e={}){const{size:n}=e;let r=t;n&&(to(t,n),r=It(t,n));let s=r.slice(2);s.length%2&&(s=`0${s}`);const o=s.length/2,a=new Uint8Array(o);for(let c=0,i=0;c<o;c++){const u=ur(s.charCodeAt(i++)),f=ur(s.charCodeAt(i++));if(u===void 0||f===void 0)throw new z(`Invalid byte sequence ("${s[i-2]}${s[i-1]}" in "${s}").`);a[c]=u<<4|f}return a}function pi(t,e={}){const{size:n}=e,r=fi.encode(t);return typeof n=="number"?(Mt(r,n),yi(r,n)):r}function yi(t,e){return ci(t,{dir:"right",size:e})}function Et(t){return t.length}function mi(t,e,n,r={}){const{strict:s}=r;return t.slice(e,n)}function gi(t,e={}){const{size:n}=e;typeof n<"u"&&Mt(t,n);const r=et(t,e);return eo(r,e)}function wi(t,e={}){const{size:n}=e;let r=t;if(typeof n<"u"&&(Mt(r,n),r=rs(r)),r.length>1||r[0]>1)throw new xi(r);return!!r[0]}function at(t,e={}){const{size:n}=e;typeof n<"u"&&Mt(t,n);const r=et(t,e);return Rr(r,e)}function bi(t,e={}){const{size:n}=e;let r=t;return typeof n<"u"&&(Mt(r,n),r=vi(r)),ui.decode(r)}function rs(t){return ns(t,{dir:"left"})}function vi(t){return ns(t,{dir:"right"})}function Ei(t){try{return di(t),!0}catch{return!1}}class xi extends z{constructor(e){super(`Bytes value \`${e}\` is not a valid boolean.`,{metaMessages:["The bytes array must contain a single byte of either a `0` or `1` value."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesBooleanError"})}}class Vt extends z{constructor(e){super(`Value \`${typeof e=="object"?Je(e):e}\` of type \`${typeof e}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class Bi extends z{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Ai extends z{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}async function eu(t,e){const{blockNumber:n,blockTag:r,coinType:s,name:o,gatewayUrls:a,strict:c}=e,{chain:i}=t,u=(()=>{if(e.universalResolverAddress)return e.universalResolverAddress;if(!i)throw new Error("client chain not configured. universalResolverAddress is required.");return Ut({blockNumber:n,chain:i,contract:"ensUniversalResolver"})})(),f=i?.ensTlds;if(f&&!f.some(l=>o.endsWith(l)))return null;const d=s!=null?[qe(o),BigInt(s)]:[qe(o)];try{const l=gt({abi:Tn,functionName:"addr",args:d}),y={address:u,abi:kr,functionName:"resolveWithGateways",args:[ne(en(o)),l,a??[ie]],blockNumber:n,blockTag:r},h=await $(t,ct,"readContract")(y);if(h[0]==="0x")return null;const w=re({abi:Tn,args:d,functionName:"addr",data:h[0]});return w==="0x"||no(w)==="0x00"?null:w}catch(l){if(c)throw l;if(tn(l))return null;throw l}}class Ii extends tt{constructor({data:e}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(e)}`],name:"EnsAvatarInvalidMetadataError"})}}class Rt extends tt{constructor({reason:e}){super(`ENS NFT avatar URI is invalid. ${e}`,{name:"EnsAvatarInvalidNftUriError"})}}class an extends tt{constructor({uri:e}){super(`Unable to resolve ENS avatar URI "${e}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class Si extends tt{constructor({namespace:e}){super(`ENS NFT avatar namespace "${e}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}class nu extends tt{constructor({chainId:e}){super(`Invalid ENSIP-11 chainId: ${e}. Must be between 0 and 0x7fffffff, or 1.`,{name:"EnsInvalidChainIdError"})}}const Ni=/(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,Pi=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/,Ri=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,ki=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function Ti(t){try{const e=await fetch(t,{method:"HEAD"});return e.status===200?e.headers.get("content-type")?.startsWith("image/"):!1}catch(e){return typeof e=="object"&&typeof e.response<"u"||!Object.hasOwn(globalThis,"Image")?!1:new Promise(n=>{const r=new Image;r.onload=()=>{n(!0)},r.onerror=()=>{n(!1)},r.src=t})}}function fr(t,e){return t?t.endsWith("/")?t.slice(0,-1):t:e}function ss({uri:t,gatewayUrls:e}){const n=Ri.test(t);if(n)return{uri:t,isOnChain:!0,isEncoded:n};const r=fr(e?.ipfs,"https://ipfs.io"),s=fr(e?.arweave,"https://arweave.net"),o=t.match(Ni),{protocol:a,subpath:c,target:i,subtarget:u=""}=o?.groups||{},f=a==="ipns:/"||c==="ipns/",d=a==="ipfs:/"||c==="ipfs/"||Pi.test(t);if(t.startsWith("http")&&!f&&!d){let y=t;return e?.arweave&&(y=t.replace(/https:\/\/arweave.net/g,e?.arweave)),{uri:y,isOnChain:!1,isEncoded:!1}}if((f||d)&&i)return{uri:`${r}/${f?"ipns":"ipfs"}/${i}${u}`,isOnChain:!1,isEncoded:!1};if(a==="ar:/"&&i)return{uri:`${s}/${i}${u||""}`,isOnChain:!1,isEncoded:!1};let l=t.replace(ki,"");if(l.startsWith("<svg")&&(l=`data:image/svg+xml;base64,${btoa(l)}`),l.startsWith("data:")||l.startsWith("{"))return{uri:l,isOnChain:!0,isEncoded:!1};throw new an({uri:t})}function os(t){if(typeof t!="object"||!("image"in t)&&!("image_url"in t)&&!("image_data"in t))throw new Ii({data:t});return t.image||t.image_url||t.image_data}async function Ci({gatewayUrls:t,uri:e}){try{const n=await fetch(e).then(s=>s.json());return await cn({gatewayUrls:t,uri:os(n)})}catch{throw new an({uri:e})}}async function cn({gatewayUrls:t,uri:e}){const{uri:n,isOnChain:r}=ss({uri:e,gatewayUrls:t});if(r||await Ti(n))return n;throw new an({uri:e})}function _i(t){let e=t;e.startsWith("did:nft:")&&(e=e.replace("did:nft:","").replace(/_/g,"/"));const[n,r,s]=e.split("/"),[o,a]=n.split(":"),[c,i]=r.split(":");if(!o||o.toLowerCase()!=="eip155")throw new Rt({reason:"Only EIP-155 supported"});if(!a)throw new Rt({reason:"Chain ID not found"});if(!i)throw new Rt({reason:"Contract address not found"});if(!s)throw new Rt({reason:"Token ID not found"});if(!c)throw new Rt({reason:"ERC namespace not found"});return{chainID:Number.parseInt(a,10),namespace:c.toLowerCase(),contractAddress:i,tokenID:s}}async function $i(t,{nft:e}){if(e.namespace==="erc721")return ct(t,{address:e.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(e.tokenID)]});if(e.namespace==="erc1155")return ct(t,{address:e.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(e.tokenID)]});throw new Si({namespace:e.namespace})}async function Oi(t,{gatewayUrls:e,record:n}){return/eip155:/i.test(n)?qi(t,{gatewayUrls:e,record:n}):cn({uri:n,gatewayUrls:e})}async function qi(t,{gatewayUrls:e,record:n}){const r=_i(n),s=await $i(t,{nft:r}),{uri:o,isOnChain:a,isEncoded:c}=ss({uri:s,gatewayUrls:e});if(a&&(o.includes("data:application/json;base64,")||o.startsWith("{"))){const u=c?atob(o.replace("data:application/json;base64,","")):o,f=JSON.parse(u);return cn({uri:os(f),gatewayUrls:e})}let i=r.tokenID;return r.namespace==="erc1155"&&(i=i.replace("0x","").padStart(64,"0")),Ci({gatewayUrls:e,uri:o.replace(/(?:0x)?{id}/,i)})}async function zi(t,e){const{blockNumber:n,blockTag:r,key:s,name:o,gatewayUrls:a,strict:c}=e,{chain:i}=t,u=(()=>{if(e.universalResolverAddress)return e.universalResolverAddress;if(!i)throw new Error("client chain not configured. universalResolverAddress is required.");return Ut({blockNumber:n,chain:i,contract:"ensUniversalResolver"})})(),f=i?.ensTlds;if(f&&!f.some(d=>o.endsWith(d)))return null;try{const d={address:u,abi:kr,args:[ne(en(o)),gt({abi:Cn,functionName:"text",args:[qe(o),s]}),a??[ie]],functionName:"resolveWithGateways",blockNumber:n,blockTag:r},y=await $(t,ct,"readContract")(d);if(y[0]==="0x")return null;const m=re({abi:Cn,functionName:"text",data:y[0]});return m===""?null:m}catch(d){if(c)throw d;if(tn(d))return null;throw d}}async function ru(t,{blockNumber:e,blockTag:n,assetGatewayUrls:r,name:s,gatewayUrls:o,strict:a,universalResolverAddress:c}){const i=await $(t,zi,"getEnsText")({blockNumber:e,blockTag:n,key:"avatar",name:s,universalResolverAddress:c,gatewayUrls:o,strict:a});if(!i)return null;try{return await Oi(t,{record:i,gatewayUrls:r})}catch{return null}}async function su(t,e){const{address:n,blockNumber:r,blockTag:s,coinType:o=60n,gatewayUrls:a,strict:c}=e,{chain:i}=t,u=(()=>{if(e.universalResolverAddress)return e.universalResolverAddress;if(!i)throw new Error("client chain not configured. universalResolverAddress is required.");return Ut({blockNumber:r,chain:i,contract:"ensUniversalResolver"})})();try{const f={address:u,abi:ro,args:[n,o,a??[ie]],functionName:"reverseWithGateways",blockNumber:r,blockTag:s},d=$(t,ct,"readContract"),[l]=await d(f);return l||null}catch(f){if(c)throw f;if(tn(f))return null;throw f}}async function ou(t,e){const{blockNumber:n,blockTag:r,name:s}=e,{chain:o}=t,a=(()=>{if(e.universalResolverAddress)return e.universalResolverAddress;if(!o)throw new Error("client chain not configured. universalResolverAddress is required.");return Ut({blockNumber:n,chain:o,contract:"ensUniversalResolver"})})(),c=o?.ensTlds;if(c&&!c.some(u=>s.endsWith(u)))throw new Error(`${s} is not a valid ENS TLD (${c?.join(", ")}) for chain "${o.name}" (id: ${o.id}).`);const[i]=await $(t,ct,"readContract")({address:a,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"},{type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[ne(en(s))],blockNumber:n,blockTag:r});return i}function is(t,{method:e}){const n={};return t.transport.type==="fallback"&&t.transport.onResponse?.(({method:r,response:s,status:o,transport:a})=>{o==="success"&&e===r&&(n[s]=a.request)}),r=>n[r]||t.request}class Ui extends tt{constructor(e){super(`Filter type "${e}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}const dr="/docs/contract/encodeEventTopics";function un(t){const{abi:e,eventName:n,args:r}=t;let s=e[0];if(n){const i=ee({abi:e,name:n});if(!i)throw new _n(n,{docsPath:dr});s=i}if(s.type!=="event")throw new _n(void 0,{docsPath:dr});const o=te(s),a=Ke(o);let c=[];if(r&&"inputs"in s){const i=s.inputs?.filter(f=>"indexed"in f&&f.indexed),u=Array.isArray(r)?r:Object.values(r).length>0?i?.map(f=>r[f.name])??[]:[];u.length>0&&(c=i?.map((f,d)=>Array.isArray(u[d])?u[d].map((l,y)=>lr({param:f,value:u[d][y]})):typeof u[d]<"u"&&u[d]!==null?lr({param:f,value:u[d]}):null)??[])}return[a,...c]}function lr({param:t,value:e}){if(t.type==="string"||t.type==="bytes")return At(Ge(e));if(t.type==="tuple"||t.type.match(/^(.*)\[(\d+)?\]$/))throw new Ui(t.type);return Ye([t],[e])}async function Li(t,e){const{address:n,abi:r,args:s,eventName:o,fromBlock:a,strict:c,toBlock:i}=e,u=is(t,{method:"eth_newFilter"}),f=o?un({abi:r,args:s,eventName:o}):void 0,d=await t.request({method:"eth_newFilter",params:[{address:n,fromBlock:typeof a=="bigint"?M(a):a,toBlock:typeof i=="bigint"?M(i):i,topics:f}]});return{abi:r,args:s,eventName:o,id:d,request:u(d),strict:!!c,type:"event"}}async function ji(t){const e=is(t,{method:"eth_newPendingTransactionFilter"}),n=await t.request({method:"eth_newPendingTransactionFilter"});return{id:n,request:e(n),type:"transaction"}}async function iu(t,{address:e,blockNumber:n,blockTag:r=t.experimental_blockTag??"latest"}){const s=typeof n=="bigint"?M(n):void 0,o=await t.request({method:"eth_getBalance",params:[e,s||r]});return BigInt(o)}const Mi=new Map,Fi=new Map;function Hi(t){const e=(s,o)=>({clear:()=>o.delete(s),get:()=>o.get(s),set:a=>o.set(s,a)}),n=e(t,Mi),r=e(t,Fi);return{clear:()=>{n.clear(),r.clear()},promise:n,response:r}}async function Di(t,{cacheKey:e,cacheTime:n=Number.POSITIVE_INFINITY}){const r=Hi(e),s=r.response.get();if(s&&n>0&&Date.now()-s.created.getTime()<n)return s.data;let o=r.promise.get();o||(o=t(),r.promise.set(o));try{const a=await o;return r.response.set({created:new Date,data:a}),a}finally{r.promise.clear()}}const Vi=t=>`blockNumber.${t}`;async function fn(t,{cacheTime:e=t.cacheTime}={}){const n=await Di(()=>t.request({method:"eth_blockNumber"}),{cacheKey:Vi(t.uid),cacheTime:e});return BigInt(n)}async function au(t,{blockHash:e,blockNumber:n,blockTag:r="latest"}={}){const s=n!==void 0?M(n):void 0;let o;return e?o=await t.request({method:"eth_getBlockTransactionCountByHash",params:[e]},{dedupe:!0}):o=await t.request({method:"eth_getBlockTransactionCountByNumber",params:[s||r]},{dedupe:!!s}),Tr(o)}const hr="/docs/contract/decodeEventLog";function Ue(t){const{abi:e,data:n,strict:r,topics:s}=t,o=r??!0,[a,...c]=s;if(!a)throw new so({docsPath:hr});const i=e.find(h=>h.type==="event"&&a===Ke(te(h)));if(!(i&&"name"in i)||i.type!=="event")throw new oo(a,{docsPath:hr});const{name:u,inputs:f}=i,d=f?.some(h=>!("name"in h&&h.name)),l=d?[]:{},y=f.map((h,w)=>[h,w]).filter(([h])=>"indexed"in h&&h.indexed);for(let h=0;h<y.length;h++){const[w,I]=y[h],P=c[h];if(!P)throw new Cr({abiItem:i,param:w});l[d?I:w.name||I]=Wi({param:w,value:P})}const m=f.filter(h=>!("indexed"in h&&h.indexed));if(m.length>0){if(n&&n!=="0x")try{const h=Ze(m,n);if(h)if(d)for(let w=0;w<f.length;w++)l[w]=l[w]??h.shift();else for(let w=0;w<m.length;w++)l[m[w].name]=h[w]}catch(h){if(o)throw h instanceof io||h instanceof ao?new Re({abiItem:i,data:n,params:m,size:_r(n)}):h}else if(o)throw new Re({abiItem:i,data:"0x",params:m,size:0})}return{eventName:u,args:Object.values(l).length>0?l:void 0}}function Wi({param:t,value:e}){return t.type==="string"||t.type==="bytes"||t.type==="tuple"||t.type.match(/^(.*)\[(\d+)?\]$/)?e:(Ze([t],e)||[])[0]}function as(t){const{abi:e,args:n,logs:r,strict:s=!0}=t,o=(()=>{if(t.eventName)return Array.isArray(t.eventName)?t.eventName:[t.eventName]})();return r.map(a=>{const c=e.filter(f=>f.type==="event"&&a.topics[0]===Ke(f));if(c.length===0)return null;let i,u;for(const f of c)try{i=Ue({...a,abi:[f],strict:!0}),u=f;break}catch{}if(!i&&!s){u=c[0];try{i=Ue({...a,abi:[u],strict:!1})}catch{const f=u.inputs?.some(d=>!("name"in d&&d.name));return{...a,args:f?[]:{},eventName:u.name}}}return!i||!u||o&&!o.includes(i.eventName)||!Zi({args:i.args,inputs:u.inputs,matchArgs:n})?null:{...i,...a}}).filter(Boolean)}function Zi(t){const{args:e,inputs:n,matchArgs:r}=t;if(!r)return!0;if(!e)return!1;function s(o,a,c){try{return o.type==="address"?Xe(a,c):o.type==="string"||o.type==="bytes"?At(Ge(a))===c:a===c}catch{return!1}}return Array.isArray(e)&&Array.isArray(r)?r.every((o,a)=>{if(o==null)return!0;const c=n[a];return c?(Array.isArray(o)?o:[o]).some(u=>s(c,u,e[a])):!1}):typeof e=="object"&&!Array.isArray(e)&&typeof r=="object"&&!Array.isArray(r)?Object.entries(r).every(([o,a])=>{if(a==null)return!0;const c=n.find(u=>u.name===o);return c?(Array.isArray(a)?a:[a]).some(u=>s(c,u,e[o])):!1}):!1}async function Yi(t,{address:e,blockHash:n,fromBlock:r,toBlock:s,event:o,events:a,args:c,strict:i}={}){const u=i??!1,f=a??(o?[o]:void 0);let d=[];f&&(d=[f.flatMap(h=>un({abi:[h],eventName:h.name,args:a?void 0:c}))],o&&(d=d[0]));let l;n?l=await t.request({method:"eth_getLogs",params:[{address:e,topics:d,blockHash:n}]}):l=await t.request({method:"eth_getLogs",params:[{address:e,topics:d,fromBlock:typeof r=="bigint"?M(r):r,toBlock:typeof s=="bigint"?M(s):s}]});const y=l.map(m=>Yt(m));return f?as({abi:f,args:c,logs:y,strict:u}):y}async function Gi(t,e){const{abi:n,address:r,args:s,blockHash:o,eventName:a,fromBlock:c,toBlock:i,strict:u}=e,f=a?ee({abi:n,name:a}):void 0,d=f?void 0:n.filter(l=>l.type==="event");return $(t,Yi,"getLogs")({address:r,args:s,blockHash:o,event:f,events:d,fromBlock:c,toBlock:i,strict:u})}function Ji(t){return{baseFeePerGas:t.baseFeePerGas.map(e=>BigInt(e)),gasUsedRatio:t.gasUsedRatio,oldestBlock:BigInt(t.oldestBlock),reward:t.reward?.map(e=>e.map(n=>BigInt(n)))}}async function cu(t,{blockCount:e,blockNumber:n,blockTag:r="latest",rewardPercentiles:s}){const o=typeof n=="bigint"?M(n):void 0,a=await t.request({method:"eth_feeHistory",params:[M(e),o||r,s]},{dedupe:!!o});return Ji(a)}async function cs(t,{filter:e}){const n="strict"in e&&e.strict,r=await e.request({method:"eth_getFilterChanges",params:[e.id]});if(typeof r[0]=="string")return r;const s=r.map(o=>Yt(o));return!("abi"in e)||!e.abi?s:as({abi:e.abi,logs:s,strict:n})}async function Ki({address:t,authorization:e,signature:n}){return Xe(Or(t),await $r({authorization:e,signature:n}))}const Wt=new qr(8192);function Xi(t,{enabled:e=!0,id:n}){if(!e||!n)return t();if(Wt.get(n))return Wt.get(n);const r=t().finally(()=>Wt.delete(n));return Wt.set(n,r),r}function Qi(t,e={}){return async(n,r={})=>{const{dedupe:s=!1,methods:o,retryDelay:a=150,retryCount:c=3,uid:i}={...e,...r},{method:u}=n;if(o?.exclude?.includes(u))throw new Ht(new Error("method not supported"),{method:u});if(o?.include&&!o.include.includes(u))throw new Ht(new Error("method not supported"),{method:u});const f=s?Gt(`${i}.${Q(n)}`):void 0;return Xi(()=>ke(async()=>{try{return await t(n)}catch(d){const l=d;switch(l.code){case Qn.code:throw new Qn(l);case Xn.code:throw new Xn(l);case Kn.code:throw new Kn(l,{method:n.method});case Jn.code:throw new Jn(l);case _e.code:throw new _e(l);case Ce.code:throw new Ce(l);case Gn.code:throw new Gn(l);case Yn.code:throw new Yn(l);case Zn.code:throw new Zn(l);case Ht.code:throw new Ht(l,{method:n.method});case Te.code:throw new Te(l);case Wn.code:throw new Wn(l);case de.code:throw new de(l);case Vn.code:throw new Vn(l);case Dn.code:throw new Dn(l);case Hn.code:throw new Hn(l);case Fn.code:throw new Fn(l);case Mn.code:throw new Mn(l);case jn.code:throw new jn(l);case Ln.code:throw new Ln(l);case Un.code:throw new Un(l);case zn.code:throw new zn(l);case qn.code:throw new qn(l);case On.code:throw new On(l);case $n.code:throw new $n(l);case 5e3:throw new de(l);default:throw d instanceof tt?d:new co(l)}}},{delay:({count:d,error:l})=>{if(l&&l instanceof Ct){const y=l?.headers?.get("Retry-After");if(y?.match(/\d/))return Number.parseInt(y,10)*1e3}return~~(1<<d)*a},retryCount:c,shouldRetry:({error:d})=>ta(d)}),{enabled:s,id:f})}}function ta(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===Te.code||t.code===_e.code:t instanceof Ct&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function us(t,{errorInstance:e=new Error("timed out"),timeout:n,signal:r}){return new Promise((s,o)=>{(async()=>{let a;try{const c=new AbortController;n>0&&(a=setTimeout(()=>{r?c.abort():o(e)},n)),s(await t({signal:c?.signal||null}))}catch(c){c?.name==="AbortError"&&o(e),o(c)}finally{clearTimeout(a)}})()})}function ea(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const Le=ea();function fs(t,e={}){const{url:n,headers:r}=na(t);return{async request(s){const{body:o,fetchFn:a=e.fetchFn??fetch,onRequest:c=e.onRequest,onResponse:i=e.onResponse,timeout:u=e.timeout??1e4}=s,f={...e.fetchOptions??{},...s.fetchOptions??{}},{headers:d,method:l,signal:y}=f;try{const m=await us(async({signal:w})=>{const I={...f,body:Array.isArray(o)?Q(o.map(g=>({jsonrpc:"2.0",id:g.id??Le.take(),...g}))):Q({jsonrpc:"2.0",id:o.id??Le.take(),...o}),headers:{...r,"Content-Type":"application/json",...d},method:l||"POST",signal:y||(u>0?w:null)},P=new Request(n,I),b=await c?.(P,I)??{...I,url:n};return await a(b.url??n,b)},{errorInstance:new $e({body:o,url:n}),timeout:u,signal:!0});i&&await i(m);let h;if(m.headers.get("Content-Type")?.startsWith("application/json"))h=await m.json();else{h=await m.text();try{h=JSON.parse(h||"{}")}catch(w){if(m.ok)throw w;h={error:h}}}if(!m.ok)throw new Ct({body:o,details:Q(h.error)||m.statusText,headers:m.headers,status:m.status,url:n});return h}catch(m){throw m instanceof Ct||m instanceof $e?m:new Ct({body:o,cause:m,url:n})}}}}function na(t){try{const e=new URL(t),n=(()=>{if(e.username){const r=`${decodeURIComponent(e.username)}:${decodeURIComponent(e.password)}`;return e.username="",e.password="",{url:e.toString(),headers:{Authorization:`Basic ${btoa(r)}`}}}})();return{url:e.toString(),...n}}catch{return{url:t}}}const ge=new Map;async function ra(t){const{getSocket:e,keepAlive:n=!0,key:r="socket",reconnect:s=!0,url:o}=t,{interval:a=3e4}=typeof n=="object"?n:{},{attempts:c=5,delay:i=2e3}=typeof s=="object"?s:{},u=JSON.stringify({keepAlive:n,key:r,url:o,reconnect:s});let f=ge.get(u);if(f)return f;let d=0;const{schedule:l}=zr({id:u,fn:async()=>{const h=new Map,w=new Map;let I,P,b,p=!1;function g(){if(s&&d<c){if(p)return;p=!0,d++,P?.close(),setTimeout(async()=>{await B().catch(console.error),p=!1},i)}else h.clear(),w.clear()}async function B(){const v=await e({onClose(){for(const x of h.values())x.onError?.(new Jt({url:o}));for(const x of w.values())x.onError?.(new Jt({url:o}));g()},onError(x){I=x;for(const R of h.values())R.onError?.(I);for(const R of w.values())R.onError?.(I);g()},onOpen(){I=void 0,d=0},onResponse(x){const R=x.method==="eth_subscription",k=R?x.params.subscription:x.id,S=R?w:h,N=S.get(k);N&&N.onResponse(x),R||S.delete(k)}});if(P=v,n&&(b&&clearInterval(b),b=setInterval(()=>P.ping?.(),a)),s&&w.size>0){const x=w.entries();for(const[R,{onResponse:k,body:S,onError:N}]of x)S&&(w.delete(R),f?.request({body:S,onResponse:k,onError:N}))}return v}return await B(),I=void 0,f={close(){b&&clearInterval(b),P.close(),ge.delete(u)},get socket(){return P},request({body:v,onError:x,onResponse:R}){I&&x&&x(I);const k=v.id??Le.take(),S=N=>{typeof N.id=="number"&&k!==N.id||(v.method==="eth_subscribe"&&typeof N.result=="string"&&w.set(N.result,{onResponse:S,onError:x,body:v}),R(N))};v.method==="eth_unsubscribe"&&w.delete(v.params?.[0]),h.set(k,{onResponse:S,onError:x});try{P.request({body:{jsonrpc:"2.0",id:k,...v}})}catch(N){x?.(N)}},requestAsync({body:v,timeout:x=1e4}){return us(()=>new Promise((R,k)=>this.request({body:v,onError:k,onResponse:R})),{errorInstance:new $e({body:v,url:o}),timeout:x})},requests:h,subscriptions:w,url:o},ge.set(u,f),[f]}}),[y,[m]]=await l();return m}async function Zt(t,e={}){const{keepAlive:n,reconnect:r}=e;return ra({async getSocket({onClose:s,onError:o,onOpen:a,onResponse:c}){const i=await Ko(()=>import("./native-CJ5et6AR.js"),[]).then(y=>y.WebSocket),u=new i(t);function f(){u.removeEventListener("close",f),u.removeEventListener("message",d),u.removeEventListener("error",o),u.removeEventListener("open",a),s()}function d({data:y}){if(!(typeof y=="string"&&y.trim().length===0))try{const m=JSON.parse(y);c(m)}catch(m){o(m)}}u.addEventListener("close",f),u.addEventListener("message",d),u.addEventListener("error",o),u.addEventListener("open",a),u.readyState===i.CONNECTING&&await new Promise((y,m)=>{u&&(u.onopen=y,u.onerror=m)});const{close:l}=u;return Object.assign(u,{close(){l.bind(u)(),f()},ping(){try{if(u.readyState===u.CLOSED||u.readyState===u.CLOSING)throw new tr({url:u.url,cause:new Jt({url:u.url})});const y={jsonrpc:"2.0",id:null,method:"net_version",params:[]};u.send(JSON.stringify(y))}catch(y){o(y)}},request({body:y}){if(u.readyState===u.CLOSED||u.readyState===u.CLOSING)throw new tr({body:y,url:u.url,cause:new Jt({url:u.url})});return u.send(JSON.stringify(y))}})},keepAlive:n,reconnect:r,url:t})}function sa(t,{body:e,onError:n,onResponse:r}){return t.request({body:e,onError:n,onResponse:r}),t}async function oa(t,{body:e,timeout:n=1e4}){return t.requestAsync({body:e,timeout:n})}async function ia(t){const e=await Zt(t);return Object.assign(e.socket,{requests:e.requests,subscriptions:e.subscriptions})}const uu={http(t,e){return fs(t).request(e)},webSocket:sa,webSocketAsync:oa},aa=`Ethereum Signed Message:
2
2
  `;function ca(t){const e=typeof t=="string"?Gt(t):typeof t.raw=="string"?t.raw:_t(t.raw),n=Gt(`${aa}${_r(e)}`);return Pr([n,e])}function ua(t,e){return At(ca(t),e)}class fa extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const da={checksum:new fa(8192)},we=da.checksum;function dn(t,e={}){const{as:n=typeof t=="string"?"Hex":"Bytes"}=e,r=uo(li(t));return n==="Bytes"?r:et(r)}function ds(t,e={}){const{compressed:n}=e,{prefix:r,x:s,y:o}=t;if(n===!1||typeof s=="bigint"&&typeof o=="bigint"){if(r!==4)throw new pr({prefix:r,cause:new ga});return}if(n===!0||typeof s=="bigint"&&typeof o>"u"){if(r!==3&&r!==2)throw new pr({prefix:r,cause:new ma});return}throw new ya({publicKey:t})}function la(t){const e=(()=>{if(fo(t))return ls(t);if(Ei(t))return ha(t);const{prefix:n,x:r,y:s}=t;return typeof r=="bigint"&&typeof s=="bigint"?{prefix:n??4,x:r,y:s}:{prefix:n,x:r}})();return ds(e),e}function ha(t){return ls(et(t))}function ls(t){if(t.length!==132&&t.length!==130&&t.length!==68)throw new wa({publicKey:t});if(t.length===130){const r=BigInt(H(t,0,32)),s=BigInt(H(t,32,64));return{prefix:4,x:r,y:s}}if(t.length===132){const r=Number(H(t,0,1)),s=BigInt(H(t,1,33)),o=BigInt(H(t,33,65));return{prefix:r,x:s,y:o}}const e=Number(H(t,0,1)),n=BigInt(H(t,1,33));return{prefix:e,x:n}}function pa(t,e={}){ds(t);const{prefix:n,x:r,y:s}=t,{includePrefix:o=!0}=e;return K(o?Y(n,{size:1}):"0x",Y(r,{size:32}),typeof s=="bigint"?Y(s,{size:32}):"0x")}class ya extends z{constructor({publicKey:e}){super(`Value \`${Je(e)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class pr extends z{constructor({prefix:e,cause:n}){super(`Prefix "${e}" is invalid.`,{cause:n}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class ma extends z{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class ga extends z{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}let wa=class extends z{constructor({publicKey:e}){super(`Value \`${e}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${ut(Qe(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}};const ba=/^0x[a-fA-F0-9]{40}$/;function Ft(t,e={}){const{strict:n=!0}=e;if(!ba.test(t))throw new yr({address:t,cause:new xa});if(n){if(t.toLowerCase()===t)return;if(ln(t)!==t)throw new yr({address:t,cause:new Ba})}}function ln(t){if(we.has(t))return we.get(t);Ft(t,{strict:!1});const e=t.substring(2).toLowerCase(),n=dn(pi(e),{as:"Bytes"}),r=e.split("");for(let o=0;o<40;o+=2)n[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(n[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const s=`0x${r.join("")}`;return we.set(t,s),s}function va(t,e={}){const{checksum:n=!1}=e;return Ft(t),n?ln(t):t}function Ea(t,e={}){const n=dn(`0x${pa(t).slice(4)}`).substring(26);return va(`0x${n}`,e)}function du(t,e={}){const{strict:n=!0}=e??{};try{return Ft(t,{strict:n}),!0}catch{return!1}}class yr extends z{constructor({address:e,cause:n}){super(`Address "${e}" is invalid.`,{cause:n}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class xa extends z{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class Ba extends z{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const Aa=/^(.*)\[([0-9]*)\]$/,Ia=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,hs=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,mr=2n**256n-1n;function Bt(t,e,n){const{checksumAddress:r,staticPosition:s}=n,o=yn(e.type);if(o){const[a,c]=o;return Na(t,{...e,type:c},{checksumAddress:r,length:a,staticPosition:s})}if(e.type==="tuple")return Ta(t,e,{checksumAddress:r,staticPosition:s});if(e.type==="address")return Sa(t,{checksum:r});if(e.type==="bool")return Pa(t);if(e.type.startsWith("bytes"))return Ra(t,e,{staticPosition:s});if(e.type.startsWith("uint")||e.type.startsWith("int"))return ka(t,e);if(e.type==="string")return Ca(t,{staticPosition:s});throw new mn(e.type)}const gr=32,je=32;function Sa(t,e={}){const{checksum:n=!1}=e,r=t.readBytes(32);return[(o=>n?ln(o):o)(et(mi(r,-20))),32]}function Na(t,e,n){const{checksumAddress:r,length:s,staticPosition:o}=n;if(!s){const i=at(t.readBytes(je)),u=o+i,f=u+gr;t.setPosition(u);const d=at(t.readBytes(gr)),l=zt(e);let y=0;const m=[];for(let h=0;h<d;++h){t.setPosition(f+(l?h*32:y));const[w,I]=Bt(t,e,{checksumAddress:r,staticPosition:f});y+=I,m.push(w)}return t.setPosition(o+32),[m,32]}if(zt(e)){const i=at(t.readBytes(je)),u=o+i,f=[];for(let d=0;d<s;++d){t.setPosition(u+d*32);const[l]=Bt(t,e,{checksumAddress:r,staticPosition:u});f.push(l)}return t.setPosition(o+32),[f,32]}let a=0;const c=[];for(let i=0;i<s;++i){const[u,f]=Bt(t,e,{checksumAddress:r,staticPosition:o+a});a+=f,c.push(u)}return[c,a]}function Pa(t){return[wi(t.readBytes(32),{size:32}),32]}function Ra(t,e,{staticPosition:n}){const[r,s]=e.type.split("bytes");if(!s){const a=at(t.readBytes(32));t.setPosition(n+a);const c=at(t.readBytes(32));if(c===0)return t.setPosition(n+32),["0x",32];const i=t.readBytes(c);return t.setPosition(n+32),[et(i),32]}return[et(t.readBytes(Number.parseInt(s,10),32)),32]}function ka(t,e){const n=e.type.startsWith("int"),r=Number.parseInt(e.type.split("int")[1]||"256",10),s=t.readBytes(32);return[r>48?gi(s,{signed:n}):at(s,{signed:n}),32]}function Ta(t,e,n){const{checksumAddress:r,staticPosition:s}=n,o=e.components.length===0||e.components.some(({name:i})=>!i),a=o?[]:{};let c=0;if(zt(e)){const i=at(t.readBytes(je)),u=s+i;for(let f=0;f<e.components.length;++f){const d=e.components[f];t.setPosition(u+c);const[l,y]=Bt(t,d,{checksumAddress:r,staticPosition:u});c+=y,a[o?f:d?.name]=l}return t.setPosition(s+32),[a,32]}for(let i=0;i<e.components.length;++i){const u=e.components[i],[f,d]=Bt(t,u,{checksumAddress:r,staticPosition:s});a[o?i:u?.name]=f,c+=d}return[a,c]}function Ca(t,{staticPosition:e}){const n=at(t.readBytes(32)),r=e+n;t.setPosition(r);const s=at(t.readBytes(32));if(s===0)return t.setPosition(e+32),["",32];const o=t.readBytes(s,32),a=bi(rs(o));return t.setPosition(e+32),[a,32]}function _a({checksumAddress:t,parameters:e,values:n}){const r=[];for(let s=0;s<e.length;s++)r.push(hn({checksumAddress:t,parameter:e[s],value:n[s]}));return r}function hn({checksumAddress:t=!1,parameter:e,value:n}){const r=e,s=yn(r.type);if(s){const[o,a]=s;return Oa(n,{checksumAddress:t,length:o,parameter:{...r,type:a}})}if(r.type==="tuple")return ja(n,{checksumAddress:t,parameter:r});if(r.type==="address")return $a(n,{checksum:t});if(r.type==="bool")return za(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const o=r.type.startsWith("int"),[,,a="256"]=hs.exec(r.type)??[];return Ua(n,{signed:o,size:Number(a)})}if(r.type.startsWith("bytes"))return qa(n,{type:r.type});if(r.type==="string")return La(n);throw new mn(r.type)}function pn(t){let e=0;for(let o=0;o<t.length;o++){const{dynamic:a,encoded:c}=t[o];a?e+=32:e+=ut(c)}const n=[],r=[];let s=0;for(let o=0;o<t.length;o++){const{dynamic:a,encoded:c}=t[o];a?(n.push(Y(e+s,{size:32})),r.push(c),s+=ut(c)):n.push(c)}return K(...n,...r)}function $a(t,e){const{checksum:n=!1}=e;return Ft(t,{strict:n}),{dynamic:!1,encoded:$t(t.toLowerCase())}}function Oa(t,e){const{checksumAddress:n,length:r,parameter:s}=e,o=r===null;if(!Array.isArray(t))throw new Ya(t);if(!o&&t.length!==r)throw new Za({expectedLength:r,givenLength:t.length,type:`${s.type}[${r}]`});let a=!1;const c=[];for(let i=0;i<t.length;i++){const u=hn({checksumAddress:n,parameter:s,value:t[i]});u.dynamic&&(a=!0),c.push(u)}if(o||a){const i=pn(c);if(o){const u=Y(c.length,{size:32});return{dynamic:!0,encoded:c.length>0?K(u,i):u}}if(a)return{dynamic:!0,encoded:i}}return{dynamic:!1,encoded:K(...c.map(({encoded:i})=>i))}}function qa(t,{type:e}){const[,n]=e.split("bytes"),r=ut(t);if(!n){let s=t;return r%32!==0&&(s=It(s,Math.ceil((t.length-2)/2/32)*32)),{dynamic:!0,encoded:K($t(Y(r,{size:32})),s)}}if(r!==Number.parseInt(n,10))throw new gs({expectedSize:Number.parseInt(n,10),value:t});return{dynamic:!1,encoded:It(t)}}function za(t){if(typeof t!="boolean")throw new z(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:$t(Ur(t))}}function Ua(t,{signed:e,size:n}){if(typeof n=="number"){const r=2n**(BigInt(n)-(e?1n:0n))-1n,s=e?-r-1n:0n;if(t>r||t<s)throw new lo({max:r.toString(),min:s.toString(),signed:e,size:n/8,value:t.toString()})}return{dynamic:!1,encoded:Y(t,{size:32,signed:e})}}function La(t){const e=Lr(t),n=Math.ceil(ut(e)/32),r=[];for(let s=0;s<n;s++)r.push(It(H(e,s*32,(s+1)*32)));return{dynamic:!0,encoded:K(It(Y(ut(e),{size:32})),...r)}}function ja(t,e){const{checksumAddress:n,parameter:r}=e;let s=!1;const o=[];for(let a=0;a<r.components.length;a++){const c=r.components[a],i=Array.isArray(t)?a:c.name,u=hn({checksumAddress:n,parameter:c,value:t[i]});o.push(u),u.dynamic&&(s=!0)}return{dynamic:s,encoded:s?pn(o):K(...o.map(({encoded:a})=>a))}}function yn(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}function zt(t){const{type:e}=t;if(e==="string"||e==="bytes"||e.endsWith("[]"))return!0;if(e==="tuple")return t.components?.some(zt);const n=yn(t.type);return!!(n&&zt({...t,type:n[1]}))}const Ma={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Ha({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new Fa({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new wr({offset:t});const e=this.position-t;this.assertPosition(e),this.position=e},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new wr({offset:t});const e=this.position+t;this.assertPosition(e),this.position=e},inspectByte(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectBytes(t,e){const n=e??this.position;return this.assertPosition(n+t-1),this.bytes.subarray(n,n+t)},inspectUint8(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectUint16(t){const e=t??this.position;return this.assertPosition(e+1),this.dataView.getUint16(e)},inspectUint24(t){const e=t??this.position;return this.assertPosition(e+2),(this.dataView.getUint16(e)<<8)+this.dataView.getUint8(e+2)},inspectUint32(t){const e=t??this.position;return this.assertPosition(e+3),this.dataView.getUint32(e)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,t&255),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,e){this.assertReadLimit(),this._touch();const n=this.inspectBytes(t);return this.position+=e??t,n},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const e=this.position;return this.assertPosition(t),this.position=t,()=>this.position=e},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function ps(t,{recursiveReadLimit:e=8192}={}){const n=Object.create(Ma);return n.bytes=t,n.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=e,n}class wr extends z{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class Fa extends z{constructor({length:e,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.PositionOutOfBoundsError"})}}class Ha extends z{constructor({count:e,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.RecursiveReadLimitExceededError"})}}function Da(t,e,n={}){const{as:r="Array",checksumAddress:s=!1}=n,o=typeof e=="string"?on(e):e,a=ps(o);if(Et(o)===0&&t.length>0)throw new Wa;if(Et(o)&&Et(o)<32)throw new Va({data:typeof e=="string"?e:et(e),parameters:t,size:Et(o)});let c=0;const i=r==="Array"?[]:{};for(let u=0;u<t.length;++u){const f=t[u];a.setPosition(c);const[d,l]=Bt(a,f,{checksumAddress:s,staticPosition:0});c+=l,r==="Array"?i.push(d):i[f.name??u]=d}return i}function ys(t,e,n){const{checksumAddress:r=!1}={};if(t.length!==e.length)throw new ws({expectedLength:t.length,givenLength:e.length});const s=_a({checksumAddress:r,parameters:t,values:e}),o=pn(s);return o.length===0?"0x":o}function Me(t,e){if(t.length!==e.length)throw new ws({expectedLength:t.length,givenLength:e.length});const n=[];for(let r=0;r<t.length;r++){const s=t[r],o=e[r];n.push(Me.encode(s,o))}return K(...n)}(function(t){function e(n,r,s=!1){if(n==="address"){const i=r;return Ft(i),$t(i.toLowerCase(),s?32:0)}if(n==="string")return Lr(r);if(n==="bytes")return r;if(n==="bool")return $t(Ur(r),s?32:1);const o=n.match(hs);if(o){const[i,u,f="256"]=o,d=Number.parseInt(f,10)/8;return Y(r,{size:s?32:d,signed:u==="int"})}const a=n.match(Ia);if(a){const[i,u]=a;if(Number.parseInt(u,10)!==(r.length-2)/2)throw new gs({expectedSize:Number.parseInt(u,10),value:r});return It(r,s?32:0)}const c=n.match(Aa);if(c&&Array.isArray(r)){const[i,u]=c,f=[];for(let d=0;d<r.length;d++)f.push(e(u,r[d],!0));return f.length===0?"0x":K(...f)}throw new mn(n)}t.encode=e})(Me||(Me={}));function ms(t){return Array.isArray(t)&&typeof t[0]=="string"||typeof t=="string"?sr(t):t}class Va extends z{constructor({data:e,parameters:n,size:r}){super(`Data size of ${r} bytes is too small for given parameters.`,{metaMessages:[`Params: (${ho(n)})`,`Data: ${e} (${r} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class Wa extends z{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class Za extends z{constructor({expectedLength:e,givenLength:n,type:r}){super(`Array length mismatch for type \`${r}\`. Expected: \`${e}\`. Given: \`${n}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class gs extends z{constructor({expectedSize:e,value:n}){super(`Size of bytes "${n}" (bytes${ut(n)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class ws extends z{constructor({expectedLength:e,givenLength:n}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${n}`].join(`
3
3
  `)),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class Ya extends z{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class mn extends z{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}function Ga(t,e){const{as:n}=e,r=bs(t),s=ps(new Uint8Array(r.length));return r.encode(s),n==="Hex"?et(s.bytes):s.bytes}function Ja(t,e={}){const{as:n="Hex"}=e;return Ga(t,{as:n})}function bs(t){return Array.isArray(t)?Ka(t.map(e=>bs(e))):Xa(t)}function Ka(t){const e=t.reduce((s,o)=>s+o.length,0),n=vs(e);return{length:e<=55?1+e:1+n+e,encode(s){e<=55?s.pushByte(192+e):(s.pushByte(247+n),n===1?s.pushUint8(e):n===2?s.pushUint16(e):n===3?s.pushUint24(e):s.pushUint32(e));for(const{encode:o}of t)o(s)}}}function Xa(t){const e=typeof t=="string"?on(t):t,n=vs(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+n+e.length,encode(s){e.length===1&&e[0]<128?s.pushBytes(e):e.length<=55?(s.pushByte(128+e.length),s.pushBytes(e)):(s.pushByte(183+n),n===1?s.pushUint8(e.length):n===2?s.pushUint16(e.length):n===3?s.pushUint24(e.length):s.pushUint32(e.length),s.pushBytes(e))}}}function vs(t){if(t<=255)return 1;if(t<=65535)return 2;if(t<=16777215)return 3;if(t<=4294967295)return 4;throw new z("Length is too large.")}class Es extends po{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,yo(e);const r=mo(n);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 s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?e.create().update(r).digest():r);for(let a=0;a<o.length;a++)o[a]^=54;this.iHash.update(o),this.oHash=e.create();for(let a=0;a<o.length;a++)o[a]^=106;this.oHash.update(o),go(o)}update(e){return er(this),this.iHash.update(e),this}digestInto(e){er(this),wo(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:n,iHash:r,finished:s,destroyed:o,blockLen:a,outputLen:c}=this;return e=e,e.finished=s,e.destroyed=o,e.blockLen=a,e.outputLen=c,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const xs=(t,e,n)=>new Es(t,e).update(n).digest();xs.create=(t,e)=>new Es(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Z=BigInt(0),D=BigInt(1),ht=BigInt(2),Qa=BigInt(3),Bs=BigInt(4),As=BigInt(5),Is=BigInt(8);function W(t,e){const n=t%e;return n>=Z?n:e+n}function G(t,e,n){let r=t;for(;e-- >Z;)r*=r,r%=n;return r}function Fe(t,e){if(t===Z)throw new Error("invert: expected non-zero number");if(e<=Z)throw new Error("invert: expected positive modulus, got "+e);let n=W(t,e),r=e,s=Z,o=D;for(;n!==Z;){const c=r/n,i=r%n,u=s-o*c;r=n,n=i,s=o,o=u}if(r!==D)throw new Error("invert: does not exist");return W(s,e)}function Ss(t,e){const n=(t.ORDER+D)/Bs,r=t.pow(e,n);if(!t.eql(t.sqr(r),e))throw new Error("Cannot find square root");return r}function tc(t,e){const n=(t.ORDER-As)/Is,r=t.mul(e,ht),s=t.pow(r,n),o=t.mul(e,s),a=t.mul(t.mul(o,ht),s),c=t.mul(o,t.sub(a,t.ONE));if(!t.eql(t.sqr(c),e))throw new Error("Cannot find square root");return c}function ec(t){if(t<BigInt(3))throw new Error("sqrt is not defined for small field");let e=t-D,n=0;for(;e%ht===Z;)e/=ht,n++;let r=ht;const s=gn(t);for(;br(s,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Ss;let o=s.pow(r,e);const a=(e+D)/ht;return function(i,u){if(i.is0(u))return u;if(br(i,u)!==1)throw new Error("Cannot find square root");let f=n,d=i.mul(i.ONE,o),l=i.pow(u,e),y=i.pow(u,a);for(;!i.eql(l,i.ONE);){if(i.is0(l))return i.ZERO;let m=1,h=i.sqr(l);for(;!i.eql(h,i.ONE);)if(m++,h=i.sqr(h),m===f)throw new Error("Cannot find square root");const w=D<<BigInt(f-m-1),I=i.pow(d,w);f=m,d=i.sqr(I),l=i.mul(l,d),y=i.mul(y,I)}return y}}function nc(t){return t%Bs===Qa?Ss:t%Is===As?tc:ec(t)}const rc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function sc(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=rc.reduce((r,s)=>(r[s]="function",r),e);return ce(t,n)}function oc(t,e,n){if(n<Z)throw new Error("invalid exponent, negatives unsupported");if(n===Z)return t.ONE;if(n===D)return e;let r=t.ONE,s=e;for(;n>Z;)n&D&&(r=t.mul(r,s)),s=t.sqr(s),n>>=D;return r}function Ns(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),s=e.reduce((a,c,i)=>t.is0(c)?a:(r[i]=a,t.mul(a,c)),t.ONE),o=t.inv(s);return e.reduceRight((a,c,i)=>t.is0(c)?a:(r[i]=t.mul(a,r[i]),t.mul(a,c)),o),r}function br(t,e){const n=(t.ORDER-D)/ht,r=t.pow(e,n),s=t.eql(r,t.ONE),o=t.eql(r,t.ZERO),a=t.eql(r,t.neg(t.ONE));if(!s&&!o&&!a)throw new Error("invalid Legendre symbol result");return s?1:o?0:-1}function Ps(t,e){e!==void 0&&bo(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function gn(t,e,n=!1,r={}){if(t<=Z)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:o}=Ps(t,e);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a;const c=Object.freeze({ORDER:t,isLE:n,BITS:s,BYTES:o,MASK:ae(s),ZERO:Z,ONE:D,create:i=>W(i,t),isValid:i=>{if(typeof i!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof i);return Z<=i&&i<t},is0:i=>i===Z,isOdd:i=>(i&D)===D,neg:i=>W(-i,t),eql:(i,u)=>i===u,sqr:i=>W(i*i,t),add:(i,u)=>W(i+u,t),sub:(i,u)=>W(i-u,t),mul:(i,u)=>W(i*u,t),pow:(i,u)=>oc(c,i,u),div:(i,u)=>W(i*Fe(u,t),t),sqrN:i=>i*i,addN:(i,u)=>i+u,subN:(i,u)=>i-u,mulN:(i,u)=>i*u,inv:i=>Fe(i,t),sqrt:r.sqrt||(i=>(a||(a=nc(t)),a(c,i))),toBytes:i=>n?es(i,o):jt(i,o),fromBytes:i=>{if(i.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+i.length);return n?ts(i):pt(i)},invertBatch:i=>Ns(c,i),cmov:(i,u,f)=>f?u:i});return Object.freeze(c)}function Rs(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function ks(t){const e=Rs(t);return e+Math.ceil(e/2)}function ic(t,e,n=!1){const r=t.length,s=Rs(e),o=ks(e);if(r<16||r<o||r>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const a=n?ts(t):pt(t),c=W(a,e-D)+D;return n?es(c,s):jt(c,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const vr=BigInt(0),He=BigInt(1);function be(t,e){const n=e.negate();return t?n:e}function Ts(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function ve(t,e){Ts(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),s=2**t,o=ae(t),a=BigInt(t);return{windows:n,windowSize:r,mask:o,maxNumber:s,shiftBy:a}}function Er(t,e,n){const{windowSize:r,mask:s,maxNumber:o,shiftBy:a}=n;let c=Number(t&s),i=t>>a;c>r&&(c-=o,i+=He);const u=e*r,f=u+Math.abs(c)-1,d=c===0,l=c<0,y=e%2!==0;return{nextN:i,offset:f,isZero:d,isNeg:l,isNegF:y,offsetF:u}}function ac(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function cc(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)})}const Ee=new WeakMap,Cs=new WeakMap;function xe(t){return Cs.get(t)||1}function uc(t,e){return{constTimeNegate:be,hasPrecomputes(n){return xe(n)!==1},unsafeLadder(n,r,s=t.ZERO){let o=n;for(;r>vr;)r&He&&(s=s.add(o)),o=o.double(),r>>=He;return s},precomputeWindow(n,r){const{windows:s,windowSize:o}=ve(r,e),a=[];let c=n,i=c;for(let u=0;u<s;u++){i=c,a.push(i);for(let f=1;f<o;f++)i=i.add(c),a.push(i);c=i.double()}return a},wNAF(n,r,s){let o=t.ZERO,a=t.BASE;const c=ve(n,e);for(let i=0;i<c.windows;i++){const{nextN:u,offset:f,isZero:d,isNeg:l,isNegF:y,offsetF:m}=Er(s,i,c);s=u,d?a=a.add(be(y,r[m])):o=o.add(be(l,r[f]))}return{p:o,f:a}},wNAFUnsafe(n,r,s,o=t.ZERO){const a=ve(n,e);for(let c=0;c<a.windows&&s!==vr;c++){const{nextN:i,offset:u,isZero:f,isNeg:d}=Er(s,c,a);if(s=i,!f){const l=r[u];o=o.add(d?l.negate():l)}}return o},getPrecomputes(n,r,s){let o=Ee.get(r);return o||(o=this.precomputeWindow(r,n),n!==1&&Ee.set(r,s(o))),o},wNAFCached(n,r,s){const o=xe(n);return this.wNAF(o,this.getPrecomputes(o,n,s),r)},wNAFCachedUnsafe(n,r,s,o){const a=xe(n);return a===1?this.unsafeLadder(n,r,o):this.wNAFUnsafe(a,this.getPrecomputes(a,n,s),r,o)},setWindowSize(n,r){Ts(r,e),Cs.set(n,r),Ee.delete(n)}}}function fc(t,e,n,r){ac(n,t),cc(r,e);const s=n.length,o=r.length;if(s!==o)throw new Error("arrays of points and scalars must have equal length");const a=t.ZERO,c=oi(BigInt(s));let i=1;c>12?i=c-3:c>4?i=c-2:c>0&&(i=2);const u=ae(i),f=new Array(Number(u)+1).fill(a),d=Math.floor((e.BITS-1)/i)*i;let l=a;for(let y=d;y>=0;y-=i){f.fill(a);for(let h=0;h<o;h++){const w=r[h],I=Number(w>>BigInt(y)&u);f[I]=f[I].add(n[h])}let m=a;for(let h=f.length-1,w=a;h>0;h--)w=w.add(f[h]),m=m.add(w);if(l=l.add(m),y!==0)for(let h=0;h<i;h++)l=l.double()}return l}function _s(t){return sc(t.Fp),ce(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ps(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function xr(t){t.lowS!==void 0&&Ot("lowS",t.lowS),t.prehash!==void 0&&Ot("prehash",t.prehash)}function dc(t){const e=_s(t);ce(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:n,Fp:r,a:s}=e;if(n){if(!r.eql(s,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class lc extends Error{constructor(e=""){super(e)}}const ot={Err:lc,_tlv:{encode:(t,e)=>{const{Err:n}=ot;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length&1)throw new n("tlv.encode: unpadded data");const r=e.length/2,s=Dt(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const o=r>127?Dt(s.length/2|128):"";return Dt(t)+o+s+e},decode(t,e){const{Err:n}=ot;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const s=e[r++],o=!!(s&128);let a=0;if(!o)a=s;else{const i=s&127;if(!i)throw new n("tlv.decode(long): indefinite length not supported");if(i>4)throw new n("tlv.decode(long): byte length is too big");const u=e.subarray(r,r+i);if(u.length!==i)throw new n("tlv.decode: length bytes not complete");if(u[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const f of u)a=a<<8|f;if(r+=i,a<128)throw new n("tlv.decode(long): not minimal encoding")}const c=e.subarray(r,r+a);if(c.length!==a)throw new n("tlv.decode: wrong value length");return{v:c,l:e.subarray(r+a)}}},_int:{encode(t){const{Err:e}=ot;if(t<it)throw new e("integer: negative integers are not allowed");let n=Dt(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:e}=ot;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return pt(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=ot,s=J("signature",t),{v:o,l:a}=r.decode(48,s);if(a.length)throw new e("invalid signature: left bytes after parsing");const{v:c,l:i}=r.decode(2,o),{v:u,l:f}=r.decode(2,i);if(f.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(c),s:n.decode(u)}},hexFromSig(t){const{_tlv:e,_int:n}=ot,r=e.encode(2,n.encode(t.r)),s=e.encode(2,n.encode(t.s)),o=r+s;return e.encode(48,o)}};function Be(t,e){return qt(jt(t,e))}const it=BigInt(0),j=BigInt(1);BigInt(2);const Ae=BigInt(3),hc=BigInt(4);function pc(t){const e=dc(t),{Fp:n}=e,r=gn(e.n,e.nBitLength),s=e.toBytes||((b,p,g)=>{const B=p.toAffine();return Qt(Uint8Array.from([4]),n.toBytes(B.x),n.toBytes(B.y))}),o=e.fromBytes||(b=>{const p=b.subarray(1),g=n.fromBytes(p.subarray(0,n.BYTES)),B=n.fromBytes(p.subarray(n.BYTES,2*n.BYTES));return{x:g,y:B}});function a(b){const{a:p,b:g}=e,B=n.sqr(b),v=n.mul(B,b);return n.add(n.add(v,n.mul(b,p)),g)}function c(b,p){const g=n.sqr(p),B=a(b);return n.eql(g,B)}if(!c(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const i=n.mul(n.pow(e.a,Ae),hc),u=n.mul(n.sqr(e.b),BigInt(27));if(n.is0(n.add(i,u)))throw new Error("bad curve params: a or b");function f(b){return sn(b,j,e.n)}function d(b){const{allowedPrivateKeyLengths:p,nByteLength:g,wrapPrivateKey:B,n:v}=e;if(p&&typeof b!="bigint"){if(Lt(b)&&(b=qt(b)),typeof b!="string"||!p.includes(b.length))throw new Error("invalid private key");b=b.padStart(g*2,"0")}let x;try{x=typeof b=="bigint"?b:pt(J("private key",b,g))}catch{throw new Error("invalid private key, expected hex or "+g+" bytes, got "+typeof b)}return B&&(x=W(x,v)),xt("private key",x,j,v),x}function l(b){if(!(b instanceof h))throw new Error("ProjectivePoint expected")}const y=cr((b,p)=>{const{px:g,py:B,pz:v}=b;if(n.eql(v,n.ONE))return{x:g,y:B};const x=b.is0();p==null&&(p=x?n.ONE:n.inv(v));const R=n.mul(g,p),k=n.mul(B,p),S=n.mul(v,p);if(x)return{x:n.ZERO,y:n.ZERO};if(!n.eql(S,n.ONE))throw new Error("invZ was invalid");return{x:R,y:k}}),m=cr(b=>{if(b.is0()){if(e.allowInfinityPoint&&!n.is0(b.py))return;throw new Error("bad point: ZERO")}const{x:p,y:g}=b.toAffine();if(!n.isValid(p)||!n.isValid(g))throw new Error("bad point: x or y not FE");if(!c(p,g))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(p,g,B){if(p==null||!n.isValid(p))throw new Error("x required");if(g==null||!n.isValid(g)||n.is0(g))throw new Error("y required");if(B==null||!n.isValid(B))throw new Error("z required");this.px=p,this.py=g,this.pz=B,Object.freeze(this)}static fromAffine(p){const{x:g,y:B}=p||{};if(!p||!n.isValid(g)||!n.isValid(B))throw new Error("invalid affine point");if(p instanceof h)throw new Error("projective point not allowed");const v=x=>n.eql(x,n.ZERO);return v(g)&&v(B)?h.ZERO:new h(g,B,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(p){const g=Ns(n,p.map(B=>B.pz));return p.map((B,v)=>B.toAffine(g[v])).map(h.fromAffine)}static fromHex(p){const g=h.fromAffine(o(J("pointHex",p)));return g.assertValidity(),g}static fromPrivateKey(p){return h.BASE.multiply(d(p))}static msm(p,g){return fc(h,r,p,g)}_setWindowSize(p){P.setWindowSize(this,p)}assertValidity(){m(this)}hasEvenY(){const{y:p}=this.toAffine();if(n.isOdd)return!n.isOdd(p);throw new Error("Field doesn't support isOdd")}equals(p){l(p);const{px:g,py:B,pz:v}=this,{px:x,py:R,pz:k}=p,S=n.eql(n.mul(g,k),n.mul(x,v)),N=n.eql(n.mul(B,k),n.mul(R,v));return S&&N}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:p,b:g}=e,B=n.mul(g,Ae),{px:v,py:x,pz:R}=this;let k=n.ZERO,S=n.ZERO,N=n.ZERO,T=n.mul(v,v),U=n.mul(x,x),A=n.mul(R,R),E=n.mul(v,x);return E=n.add(E,E),N=n.mul(v,R),N=n.add(N,N),k=n.mul(p,N),S=n.mul(B,A),S=n.add(k,S),k=n.sub(U,S),S=n.add(U,S),S=n.mul(k,S),k=n.mul(E,k),N=n.mul(B,N),A=n.mul(p,A),E=n.sub(T,A),E=n.mul(p,E),E=n.add(E,N),N=n.add(T,T),T=n.add(N,T),T=n.add(T,A),T=n.mul(T,E),S=n.add(S,T),A=n.mul(x,R),A=n.add(A,A),T=n.mul(A,E),k=n.sub(k,T),N=n.mul(A,U),N=n.add(N,N),N=n.add(N,N),new h(k,S,N)}add(p){l(p);const{px:g,py:B,pz:v}=this,{px:x,py:R,pz:k}=p;let S=n.ZERO,N=n.ZERO,T=n.ZERO;const U=e.a,A=n.mul(e.b,Ae);let E=n.mul(g,x),C=n.mul(B,R),q=n.mul(v,k),_=n.add(g,B),O=n.add(x,R);_=n.mul(_,O),O=n.add(E,C),_=n.sub(_,O),O=n.add(g,v);let L=n.add(x,k);return O=n.mul(O,L),L=n.add(E,q),O=n.sub(O,L),L=n.add(B,v),S=n.add(R,k),L=n.mul(L,S),S=n.add(C,q),L=n.sub(L,S),T=n.mul(U,O),S=n.mul(A,q),T=n.add(S,T),S=n.sub(C,T),T=n.add(C,T),N=n.mul(S,T),C=n.add(E,E),C=n.add(C,E),q=n.mul(U,q),O=n.mul(A,O),C=n.add(C,q),q=n.sub(E,q),q=n.mul(U,q),O=n.add(O,q),E=n.mul(C,O),N=n.add(N,E),E=n.mul(L,O),S=n.mul(_,S),S=n.sub(S,E),E=n.mul(_,C),T=n.mul(L,T),T=n.add(T,E),new h(S,N,T)}subtract(p){return this.add(p.negate())}is0(){return this.equals(h.ZERO)}wNAF(p){return P.wNAFCached(this,p,h.normalizeZ)}multiplyUnsafe(p){const{endo:g,n:B}=e;xt("scalar",p,it,B);const v=h.ZERO;if(p===it)return v;if(this.is0()||p===j)return this;if(!g||P.hasPrecomputes(this))return P.wNAFCachedUnsafe(this,p,h.normalizeZ);let{k1neg:x,k1:R,k2neg:k,k2:S}=g.splitScalar(p),N=v,T=v,U=this;for(;R>it||S>it;)R&j&&(N=N.add(U)),S&j&&(T=T.add(U)),U=U.double(),R>>=j,S>>=j;return x&&(N=N.negate()),k&&(T=T.negate()),T=new h(n.mul(T.px,g.beta),T.py,T.pz),N.add(T)}multiply(p){const{endo:g,n:B}=e;xt("scalar",p,j,B);let v,x;if(g){const{k1neg:R,k1:k,k2neg:S,k2:N}=g.splitScalar(p);let{p:T,f:U}=this.wNAF(k),{p:A,f:E}=this.wNAF(N);T=P.constTimeNegate(R,T),A=P.constTimeNegate(S,A),A=new h(n.mul(A.px,g.beta),A.py,A.pz),v=T.add(A),x=U.add(E)}else{const{p:R,f:k}=this.wNAF(p);v=R,x=k}return h.normalizeZ([v,x])[0]}multiplyAndAddUnsafe(p,g,B){const v=h.BASE,x=(k,S)=>S===it||S===j||!k.equals(v)?k.multiplyUnsafe(S):k.multiply(S),R=x(this,g).add(x(p,B));return R.is0()?void 0:R}toAffine(p){return y(this,p)}isTorsionFree(){const{h:p,isTorsionFree:g}=e;if(p===j)return!0;if(g)return g(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:p,clearCofactor:g}=e;return p===j?this:g?g(h,this):this.multiplyUnsafe(e.h)}toRawBytes(p=!0){return Ot("isCompressed",p),this.assertValidity(),s(h,this,p)}toHex(p=!0){return Ot("isCompressed",p),qt(this.toRawBytes(p))}}h.BASE=new h(e.Gx,e.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const{endo:w,nBitLength:I}=e,P=uc(h,w?Math.ceil(I/2):I);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:d,weierstrassEquation:a,isWithinCurveOrder:f}}function yc(t){const e=_s(t);return ce(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function mc(t){const e=yc(t),{Fp:n,n:r,nByteLength:s,nBitLength:o}=e,a=n.BYTES+1,c=2*n.BYTES+1;function i(A){return W(A,r)}function u(A){return Fe(A,r)}const{ProjectivePoint:f,normPrivateKeyToScalar:d,weierstrassEquation:l,isWithinCurveOrder:y}=pc({...e,toBytes(A,E,C){const q=E.toAffine(),_=n.toBytes(q.x),O=Qt;return Ot("isCompressed",C),C?O(Uint8Array.from([E.hasEvenY()?2:3]),_):O(Uint8Array.from([4]),_,n.toBytes(q.y))},fromBytes(A){const E=A.length,C=A[0],q=A.subarray(1);if(E===a&&(C===2||C===3)){const _=pt(q);if(!sn(_,j,n.ORDER))throw new Error("Point is not on curve");const O=l(_);let L;try{L=n.sqrt(O)}catch(X){const V=X instanceof Error?": "+X.message:"";throw new Error("Point is not on curve"+V)}const F=(L&j)===j;return(C&1)===1!==F&&(L=n.neg(L)),{x:_,y:L}}else if(E===c&&C===4){const _=n.fromBytes(q.subarray(0,n.BYTES)),O=n.fromBytes(q.subarray(n.BYTES,2*n.BYTES));return{x:_,y:O}}else{const _=a,O=c;throw new Error("invalid Point, expected length of "+_+", or uncompressed "+O+", got "+E)}}});function m(A){const E=r>>j;return A>E}function h(A){return m(A)?i(-A):A}const w=(A,E,C)=>pt(A.slice(E,C));class I{constructor(E,C,q){xt("r",E,j,r),xt("s",C,j,r),this.r=E,this.s=C,q!=null&&(this.recovery=q),Object.freeze(this)}static fromCompact(E){const C=s;return E=J("compactSignature",E,C*2),new I(w(E,0,C),w(E,C,2*C))}static fromDER(E){const{r:C,s:q}=ot.toSig(J("DER",E));return new I(C,q)}assertValidity(){}addRecoveryBit(E){return new I(this.r,this.s,E)}recoverPublicKey(E){const{r:C,s:q,recovery:_}=this,O=v(J("msgHash",E));if(_==null||![0,1,2,3].includes(_))throw new Error("recovery id invalid");const L=_===2||_===3?C+e.n:C;if(L>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const F=_&1?"03":"02",nt=f.fromHex(F+Be(L,n.BYTES)),X=u(L),V=i(-O*X),wt=i(q*X),ft=f.BASE.multiplyAndAddUnsafe(nt,V,wt);if(!ft)throw new Error("point at infinify");return ft.assertValidity(),ft}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new I(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Xt(this.toDERHex())}toDERHex(){return ot.hexFromSig(this)}toCompactRawBytes(){return Xt(this.toCompactHex())}toCompactHex(){const E=s;return Be(this.r,E)+Be(this.s,E)}}const P={isValidPrivateKey(A){try{return d(A),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const A=ks(e.n);return ic(e.randomBytes(A),e.n)},precompute(A=8,E=f.BASE){return E._setWindowSize(A),E.multiply(BigInt(3)),E}};function b(A,E=!0){return f.fromPrivateKey(A).toRawBytes(E)}function p(A){if(typeof A=="bigint")return!1;if(A instanceof f)return!0;const C=J("key",A).length,q=n.BYTES,_=q+1,O=2*q+1;if(!(e.allowedPrivateKeyLengths||s===_))return C===_||C===O}function g(A,E,C=!0){if(p(A)===!0)throw new Error("first arg must be private key");if(p(E)===!1)throw new Error("second arg must be public key");return f.fromHex(E).multiply(d(A)).toRawBytes(C)}const B=e.bits2int||function(A){if(A.length>8192)throw new Error("input is too large");const E=pt(A),C=A.length*8-o;return C>0?E>>BigInt(C):E},v=e.bits2int_modN||function(A){return i(B(A))},x=ae(o);function R(A){return xt("num < 2^"+o,A,it,x),jt(A,s)}function k(A,E,C=S){if(["recovered","canonical"].some(dt=>dt in C))throw new Error("sign() legacy options not supported");const{hash:q,randomBytes:_}=e;let{lowS:O,prehash:L,extraEntropy:F}=C;O==null&&(O=!0),A=J("msgHash",A),xr(C),L&&(A=J("prehashed msgHash",q(A)));const nt=v(A),X=d(E),V=[R(X),R(nt)];if(F!=null&&F!==!1){const dt=F===!0?_(n.BYTES):F;V.push(J("extraEntropy",dt))}const wt=Qt(...V),ft=nt;function ue(dt){const bt=B(dt);if(!y(bt))return;const fe=u(bt),Nt=f.BASE.multiply(bt).toAffine(),lt=i(Nt.x);if(lt===it)return;const Pt=i(fe*i(ft+lt*X));if(Pt===it)return;let vt=(Nt.x===lt?0:2)|Number(Nt.y&j),Bn=Pt;return O&&m(Pt)&&(Bn=h(Pt),vt^=1),new I(lt,Bn,vt)}return{seed:wt,k2sig:ue}}const S={lowS:e.lowS,prehash:!1},N={lowS:e.lowS,prehash:!1};function T(A,E,C=S){const{seed:q,k2sig:_}=k(A,E,C),O=e;return ii(O.hash.outputLen,O.nByteLength,O.hmac)(q,_)}f.BASE._setWindowSize(8);function U(A,E,C,q=N){const _=A;E=J("msgHash",E),C=J("publicKey",C);const{lowS:O,prehash:L,format:F}=q;if(xr(q),"strict"in q)throw new Error("options.strict was renamed to lowS");if(F!==void 0&&F!=="compact"&&F!=="der")throw new Error("format must be compact or der");const nt=typeof _=="string"||Lt(_),X=!nt&&!F&&typeof _=="object"&&_!==null&&typeof _.r=="bigint"&&typeof _.s=="bigint";if(!nt&&!X)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let V,wt;try{if(X&&(V=new I(_.r,_.s)),nt){try{F!=="compact"&&(V=I.fromDER(_))}catch(vt){if(!(vt instanceof ot.Err))throw vt}!V&&F!=="der"&&(V=I.fromCompact(_))}wt=f.fromHex(C)}catch{return!1}if(!V||O&&V.hasHighS())return!1;L&&(E=e.hash(E));const{r:ft,s:ue}=V,dt=v(E),bt=u(ue),fe=i(dt*bt),Nt=i(ft*bt),lt=f.BASE.multiplyAndAddUnsafe(wt,fe,Nt)?.toAffine();return lt?i(lt.x)===ft:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:g,sign:T,verify:U,ProjectivePoint:f,Signature:I,utils:P}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gc(t){return{hash:t,hmac:(e,...n)=>xs(t,e,Eo(...n)),randomBytes:vo}}function wc(t,e){const n=r=>mc({...t,...gc(r)});return{...n(e),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $s=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Br=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),bc=BigInt(0),vc=BigInt(1),De=BigInt(2),Ar=(t,e)=>(t+e/De)/e;function Ec(t){const e=$s,n=BigInt(3),r=BigInt(6),s=BigInt(11),o=BigInt(22),a=BigInt(23),c=BigInt(44),i=BigInt(88),u=t*t*t%e,f=u*u*t%e,d=G(f,n,e)*f%e,l=G(d,n,e)*f%e,y=G(l,De,e)*u%e,m=G(y,s,e)*y%e,h=G(m,o,e)*m%e,w=G(h,c,e)*h%e,I=G(w,i,e)*w%e,P=G(I,c,e)*h%e,b=G(P,n,e)*f%e,p=G(b,a,e)*m%e,g=G(p,r,e)*u%e,B=G(g,De,e);if(!Ve.eql(Ve.sqr(B),t))throw new Error("Cannot find square root");return B}const Ve=gn($s,void 0,void 0,{sqrt:Ec}),wn=wc({a:bc,b:BigInt(7),Fp:Ve,n:Br,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Br,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-vc*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,a=BigInt("0x100000000000000000000000000000000"),c=Ar(o*t,e),i=Ar(-r*t,e);let u=W(t-c*n-i*s,e),f=W(-c*r-i*o,e);const d=u>a,l=f>a;if(d&&(u=e-u),l&&(f=e-f),u>a||f>a)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:d,k1:u,k2neg:l,k2:f}}}},xo),lu=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:wn},Symbol.toStringTag,{value:"Module"}));function Os(t,e={}){const{recovered:n}=e;if(typeof t.r>"u")throw new Ie({signature:t});if(typeof t.s>"u")throw new Ie({signature:t});if(n&&typeof t.yParity>"u")throw new Ie({signature:t});if(t.r<0n||t.r>mr)throw new Nc({value:t.r});if(t.s<0n||t.s>mr)throw new Pc({value:t.s});if(typeof t.yParity=="number"&&t.yParity!==0&&t.yParity!==1)throw new vn({value:t.yParity})}function xc(t){return qs(et(t))}function qs(t){if(t.length!==130&&t.length!==132)throw new Sc({signature:t});const e=BigInt(H(t,0,32)),n=BigInt(H(t,32,64)),r=(()=>{const s=+`0x${t.slice(130)}`;if(!Number.isNaN(s))try{return bn(s)}catch{throw new vn({value:s})}})();return typeof r>"u"?{r:e,s:n}:{r:e,s:n,yParity:r}}function zs(t){if(!(typeof t.r>"u")&&!(typeof t.s>"u"))return Us(t)}function Us(t){const e=typeof t=="string"?qs(t):t instanceof Uint8Array?xc(t):typeof t.r=="string"?Ac(t):t.v?Bc(t):{r:t.r,s:t.s,...typeof t.yParity<"u"?{yParity:t.yParity}:{}};return Os(e),e}function Bc(t){return{r:t.r,s:t.s,yParity:bn(t.v)}}function Ac(t){const e=(()=>{const n=t.v?Number(t.v):void 0;let r=t.yParity?Number(t.yParity):void 0;if(typeof n=="number"&&typeof r!="number"&&(r=bn(n)),typeof r!="number")throw new vn({value:t.yParity});return r})();return{r:BigInt(t.r),s:BigInt(t.s),yParity:e}}function Ic(t){const{r:e,s:n,yParity:r}=t;return[r?"0x01":"0x",e===0n?"0x":nr(Y(e)),n===0n?"0x":nr(Y(n))]}function bn(t){if(t===0||t===27)return 0;if(t===1||t===28)return 1;if(t>=35)return t%2===0?1:0;throw new Rc({value:t})}class Sc extends z{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${ut(Qe(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class Ie extends z{constructor({signature:e}){super(`Signature \`${Je(e)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class Nc extends z{constructor({value:e}){super(`Value \`${e}\` is an invalid r value. r must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidRError"})}}class Pc extends z{constructor({value:e}){super(`Value \`${e}\` is an invalid s value. s must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSError"})}}class vn extends z{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class Rc extends z{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}function kc(t,e={}){return typeof t.chainId=="string"?Tc(t):{...t,...e.signature}}function Tc(t){const{address:e,chainId:n,nonce:r}=t,s=zs(t);return{address:e,chainId:Number(n),nonce:BigInt(r),...s}}function Cc(t){return _c(t,{presign:!0})}function _c(t,e={}){const{presign:n}=e;return dn(K("0x05",Ja($c(n?{address:t.address,chainId:t.chainId,nonce:t.nonce}:t))))}function $c(t){const{address:e,chainId:n,nonce:r}=t,s=zs(t);return[n?Y(n):"0x",e,r?Y(r):"0x",...s?Ic(s):[]]}function Oc(t){return Ea(qc(t))}function qc(t){const{payload:e,signature:n}=t,{r,s,yParity:o}=n,c=new wn.Signature(BigInt(r),BigInt(s)).addRecoveryBit(o).recoverPublicKey(Qe(e).substring(2));return la(c)}const Ls="0x8010801080108010801080108010801080108010801080108010801080108010",js=ms("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function En(t){if(typeof t=="string"){if(H(t,-32)!==Ls)throw new Lc(t)}else Os(t.authorization)}function zc(t){En(t);const e=Rr(H(t,-64,-32)),n=H(t,-e-64,-64),r=H(t,0,-e-64),[s,o,a]=Da(js,n);return{authorization:kc({address:s.delegation,chainId:Number(s.chainId),nonce:s.nonce,yParity:s.yParity,r:s.r,s:s.s}),signature:r,...a&&a!=="0x"?{data:a,to:o}:{}}}function hu(t){const{data:e,signature:n}=t;En(t);const r=Oc({payload:Cc(t.authorization),signature:Us(t.authorization)}),s=ys(js,[{...t.authorization,delegation:t.authorization.address,chainId:BigInt(t.authorization.chainId)},t.to??r,e??"0x"]),o=Y(ut(s),{size:32});return K(n,s,o,Ls)}function Uc(t){try{return En(t),!0}catch{return!1}}let Lc=class extends z{constructor(e){super(`Value \`${e}\` is an invalid ERC-8010 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc8010.InvalidWrappedSignatureError"})}};function jc(t){return t.map(e=>({...e,value:BigInt(e.value)}))}function Mc(t){return{...t,balance:t.balance?BigInt(t.balance):void 0,nonce:t.nonce?Tr(t.nonce):void 0,storageProof:t.storageProof?jc(t.storageProof):void 0}}async function yu(t,{address:e,blockNumber:n,blockTag:r,storageKeys:s}){const o=r??"latest",a=n!==void 0?M(n):void 0,c=await t.request({method:"eth_getProof",params:[e,s,a||o]});return Mc(c)}async function mu(t,{address:e,blockNumber:n,blockTag:r="latest",slot:s}){const o=n!==void 0?M(n):void 0;return await t.request({method:"eth_getStorageAt",params:[e,s,o||r]})}async function Ms(t,{blockHash:e,blockNumber:n,blockTag:r,hash:s,index:o,sender:a,nonce:c}){const i=r||"latest",u=n!==void 0?M(n):void 0;let f=null;if(s?f=await t.request({method:"eth_getTransactionByHash",params:[s]},{dedupe:!0}):e?f=await t.request({method:"eth_getTransactionByBlockHashAndIndex",params:[e,M(o)]},{dedupe:!0}):typeof o=="number"?f=await t.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[u||i,M(o)]},{dedupe:!!u}):a&&typeof c=="number"&&(f=await t.request({method:"eth_getTransactionBySenderAndNonce",params:[a,M(c)]},{dedupe:!0})),!f)throw new jr({blockHash:e,blockNumber:n,blockTag:i,hash:s,index:o});return(t.chain?.formatters?.transaction?.format||Bo)(f,"getTransaction")}async function gu(t,{hash:e,transactionReceipt:n}){const[r,s]=await Promise.all([$(t,fn,"getBlockNumber")({}),e?$(t,Ms,"getTransaction")({hash:e}):void 0]),o=n?.blockNumber||s?.blockNumber;return o?r-o+1n:0n}async function Se(t,{hash:e}){const n=await t.request({method:"eth_getTransactionReceipt",params:[e]},{dedupe:!0});if(!n)throw new Mr({hash:e});return(t.chain?.formatters?.transactionReceipt?.format||Fr)(n,"getTransactionReceipt")}async function wu(t,e){const{account:n,authorizationList:r,allowFailure:s=!0,blockNumber:o,blockOverrides:a,blockTag:c,stateOverride:i}=e,u=e.contracts,{batchSize:f=e.batchSize??1024,deployless:d=e.deployless??!1}=typeof t.batch?.multicall=="object"?t.batch.multicall:{},l=(()=>{if(e.multicallAddress)return e.multicallAddress;if(d)return null;if(t.chain)return Ut({blockNumber:o,chain:t.chain,contract:"multicall3"});throw new Error("client chain not configured. multicallAddress is required.")})(),y=[[]];let m=0,h=0;for(let P=0;P<u.length;P++){const{abi:b,address:p,args:g,functionName:B}=u[P];try{const v=gt({abi:b,args:g,functionName:B});h+=(v.length-2)/2,f>0&&h>f&&y[m].length>0&&(m++,h=(v.length-2)/2,y[m]=[]),y[m]=[...y[m],{allowFailure:!0,callData:v,target:p}]}catch(v){const x=Kt(v,{abi:b,address:p,args:g,docsPath:"/docs/contract/multicall",functionName:B,sender:n});if(!s)throw x;y[m]=[...y[m],{allowFailure:!0,callData:"0x",target:p}]}}const w=await Promise.allSettled(y.map(P=>$(t,ct,"readContract")({...l===null?{code:Dr}:{address:l},abi:Hr,account:n,args:[P],authorizationList:r,blockNumber:o,blockOverrides:a,blockTag:c,functionName:"aggregate3",stateOverride:i}))),I=[];for(let P=0;P<w.length;P++){const b=w[P];if(b.status==="rejected"){if(!s)throw b.reason;for(let g=0;g<y[P].length;g++)I.push({status:"failure",error:b.reason,result:void 0});continue}const p=b.value;for(let g=0;g<p.length;g++){const{returnData:B,success:v}=p[g],{callData:x}=y[P][g],{abi:R,address:k,functionName:S,args:N}=u[I.length];try{if(x==="0x")throw new Ao;if(!v)throw new Io({data:B});const T=re({abi:R,args:N,data:B,functionName:S});I.push(s?{result:T,status:"success"}:T)}catch(T){const U=Kt(T,{abi:R,address:k,args:N,docsPath:"/docs/contract/multicall",functionName:S});if(!s)throw U;I.push({error:U,result:void 0,status:"failure"})}}}if(I.length!==u.length)throw new tt("multicall results mismatch");return I}async function bu(t,e){const{abi:n,address:r,args:s,dataSuffix:o,functionName:a,...c}=e,i=c.account?St(c.account):t.account,u=gt({abi:n,args:s,functionName:a});try{const{data:f}=await $(t,Vr,"call")({batch:!1,data:`${u}${o?o.replace("0x",""):""}`,to:r,...c,account:i}),d=re({abi:n,args:s,functionName:a,data:f||"0x"}),l=n.filter(y=>"name"in y&&y.name===e.functionName);return{result:d,request:{abi:l,address:r,args:s,dataSuffix:o,functionName:a,...c,account:i}}}catch(f){throw Kt(f,{abi:n,address:r,args:s,docsPath:"/docs/contract/simulateContract",functionName:a,sender:i?.address})}}async function Fs(t,{filter:e}){return e.request({method:"eth_uninstallFilter",params:[e.id]})}const Hs="0x6492649264926492649264926492649264926492649264926492649264926492";function Fc(t){if(H(t,-32)!==Hs)throw new Vc(t)}function Hc(t){const{data:e,signature:n,to:r}=t;return K(ys(ms("address, bytes, bytes"),[r,e,n]),Hs)}function Dc(t){try{return Fc(t),!0}catch{return!1}}class Vc extends z{constructor(e){super(`Value \`${e}\` is an invalid ERC-6492 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc6492.InvalidWrappedSignatureError"})}}function Wc({r:t,s:e,to:n="hex",v:r,yParity:s}){const o=(()=>{if(s===0||s===1)return s;if(r&&(r===27n||r===28n||r>=35n))return r%2n===0n?1:0;throw new Error("Invalid `v` or `yParity` value")})(),a=`0x${new wn.Signature(Oe(t),Oe(e)).toCompactHex()}${o===0?"1b":"1c"}`;return n==="hex"?a:So(a)}async function Ds(t,e){const{address:n,chain:r=t.chain,hash:s,erc6492VerifierAddress:o=e.universalSignatureVerifierAddress??r?.contracts?.erc6492Verifier?.address,multicallAddress:a=e.multicallAddress??r?.contracts?.multicall3?.address}=e;if(r?.verifyHash)return await r.verifyHash(t,e);const c=(()=>{const i=e.signature;return Nr(i)?i:typeof i=="object"&&"r"in i&&"s"in i?Wc(i):_t(i)})();try{return Uc(c)?await Zc(t,{...e,multicallAddress:a,signature:c}):await Yc(t,{...e,verifierAddress:o,signature:c})}catch(i){try{if(Xe(Or(n),await No({hash:s,signature:c})))return!0}catch{}if(i instanceof mt)return!1;throw i}}async function Zc(t,e){const{address:n,blockNumber:r,blockTag:s,hash:o,multicallAddress:a}=e,{authorization:c,data:i,signature:u,to:f}=zc(e.signature);if(await Po(t,{address:n,blockNumber:r,blockTag:s})===Sr(["0xef0100",c.address]))return await Gc(t,{address:n,blockNumber:r,blockTag:s,hash:o,signature:u});const l={address:c.address,chainId:Number(c.chainId),nonce:Number(c.nonce),r:M(c.r,{size:32}),s:M(c.s,{size:32}),yParity:c.yParity};if(!await Ki({address:n,authorization:l}))throw new mt;const m=await $(t,ct,"readContract")({...a?{address:a}:{code:Dr},authorizationList:[l],abi:Hr,blockNumber:r,blockTag:"pending",functionName:"aggregate3",args:[[...i?[{allowFailure:!0,target:f??n,callData:i}]:[],{allowFailure:!0,target:n,callData:gt({abi:Wr,functionName:"isValidSignature",args:[o,u]})}]]});if(m[m.length-1]?.returnData?.startsWith("0x1626ba7e"))return!0;throw new mt}async function Yc(t,e){const{address:n,factory:r,factoryData:s,hash:o,signature:a,verifierAddress:c,...i}=e,u=await(async()=>!r&&!s||Dc(a)?a:Hc({data:s,signature:a,to:r}))(),f=c?{to:c,data:gt({abi:rr,functionName:"isValidSig",args:[n,o,u]}),...i}:{data:Zr({abi:rr,args:[n,o,u],bytecode:Ro}),...i},{data:d}=await $(t,Vr,"call")(f).catch(l=>{throw l instanceof ko?new mt:l});if(To(d??"0x0"))return!0;throw new mt}async function Gc(t,e){const{address:n,blockNumber:r,blockTag:s,hash:o,signature:a}=e;if((await $(t,ct,"readContract")({address:n,abi:Wr,args:[o,a],blockNumber:r,blockTag:s,functionName:"isValidSignature"}).catch(i=>{throw i instanceof Co?new mt:i})).startsWith("0x1626ba7e"))return!0;throw new mt}class mt extends Error{}async function vu(t,{address:e,message:n,factory:r,factoryData:s,signature:o,...a}){const c=ua(n);return $(t,Ds,"verifyHash")({address:e,factory:r,factoryData:s,hash:c,signature:o,...a})}async function Eu(t,e){const{address:n,factory:r,factoryData:s,signature:o,message:a,primaryType:c,types:i,domain:u,...f}=e,d=_o({message:a,primaryType:c,types:i,domain:u});return $(t,Ds,"verifyHash")({address:n,factory:r,factoryData:s,hash:d,signature:o,...f})}function Jc(t,{emitOnBegin:e=!1,emitMissed:n=!1,onBlockNumber:r,onError:s,poll:o,pollingInterval:a=t.pollingInterval}){const c=typeof o<"u"?o:!(t.transport.type==="webSocket"||t.transport.type==="ipc"||t.transport.type==="fallback"&&(t.transport.transports[0].config.type==="webSocket"||t.transport.transports[0].config.type==="ipc"));let i;return c?(()=>{const d=Q(["watchBlockNumber",t.uid,e,n,a]);return yt(d,{onBlockNumber:r,onError:s},l=>se(async()=>{try{const y=await $(t,fn,"getBlockNumber")({cacheTime:0});if(i!==void 0){if(y===i)return;if(y-i>1&&n)for(let m=i+1n;m<y;m++)l.onBlockNumber(m,i),i=m}(i===void 0||y>i)&&(l.onBlockNumber(y,i),i=y)}catch(y){l.onError?.(y)}},{emitOnBegin:e,interval:a}))})():(()=>{const d=Q(["watchBlockNumber",t.uid,e,n]);return yt(d,{onBlockNumber:r,onError:s},l=>{let y=!0,m=()=>y=!1;return(async()=>{try{const h=(()=>{if(t.transport.type==="fallback"){const I=t.transport.transports.find(P=>P.config.type==="webSocket"||P.config.type==="ipc");return I?I.value:t.transport}return t.transport})(),{unsubscribe:w}=await h.subscribe({params:["newHeads"],onData(I){if(!y)return;const P=Oe(I.result?.number);l.onBlockNumber(P,i),i=P},onError(I){l.onError?.(I)}});m=w,y||m()}catch(h){s?.(h)}})(),()=>m()})})()}async function Kc(t,e){const{checkReplacement:n=!0,confirmations:r=1,hash:s,onReplaced:o,retryCount:a=6,retryDelay:c=({count:g})=>~~(1<<g)*200,timeout:i=18e4}=e,u=Q(["waitForTransactionReceipt",t.uid,s]),f=e.pollingInterval?e.pollingInterval:t.chain?.experimental_preconfirmationTime?t.chain.experimental_preconfirmationTime:t.pollingInterval;let d,l,y,m=!1,h,w;const{promise:I,resolve:P,reject:b}=$o(),p=i?setTimeout(()=>{w?.(),h?.(),b(new Oo({hash:s}))},i):void 0;return h=yt(u,{onReplaced:o,resolve:P,reject:b},async g=>{if(y=await $(t,Se,"getTransactionReceipt")({hash:s}).catch(()=>{}),y&&r<=1){clearTimeout(p),g.resolve(y),h?.();return}w=$(t,Jc,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:f,async onBlockNumber(B){const v=R=>{clearTimeout(p),w?.(),R(),h?.()};let x=B;if(!m)try{if(y){if(r>1&&(!y.blockNumber||x-y.blockNumber+1n<r))return;v(()=>g.resolve(y));return}if(n&&!d&&(m=!0,await ke(async()=>{d=await $(t,Ms,"getTransaction")({hash:s}),d.blockNumber&&(x=d.blockNumber)},{delay:c,retryCount:a}),m=!1),y=await $(t,Se,"getTransactionReceipt")({hash:s}),r>1&&(!y.blockNumber||x-y.blockNumber+1n<r))return;v(()=>g.resolve(y))}catch(R){if(R instanceof jr||R instanceof Mr){if(!d){m=!1;return}try{l=d,m=!0;const k=await ke(()=>$(t,kt,"getBlock")({blockNumber:x,includeTransactions:!0}),{delay:c,retryCount:a,shouldRetry:({error:T})=>T instanceof qo});m=!1;const S=k.transactions.find(({from:T,nonce:U})=>T===l.from&&U===l.nonce);if(!S||(y=await $(t,Se,"getTransactionReceipt")({hash:S.hash}),r>1&&(!y.blockNumber||x-y.blockNumber+1n<r)))return;let N="replaced";S.to===l.to&&S.value===l.value&&S.input===l.input?N="repriced":S.from===S.to&&S.value===0n&&(N="cancelled"),v(()=>{g.onReplaced?.({reason:N,replacedTransaction:l,transaction:S,transactionReceipt:y}),g.resolve(y)})}catch(k){v(()=>g.reject(k))}}else v(()=>g.reject(R))}}})}),I}function xu(t,{blockTag:e=t.experimental_blockTag??"latest",emitMissed:n=!1,emitOnBegin:r=!1,onBlock:s,onError:o,includeTransactions:a,poll:c,pollingInterval:i=t.pollingInterval}){const u=typeof c<"u"?c:!(t.transport.type==="webSocket"||t.transport.type==="ipc"||t.transport.type==="fallback"&&(t.transport.transports[0].config.type==="webSocket"||t.transport.transports[0].config.type==="ipc")),f=a??!1;let d;return u?(()=>{const m=Q(["watchBlocks",t.uid,e,n,r,f,i]);return yt(m,{onBlock:s,onError:o},h=>se(async()=>{try{const w=await $(t,kt,"getBlock")({blockTag:e,includeTransactions:f});if(w.number!==null&&d?.number!=null){if(w.number===d.number)return;if(w.number-d.number>1&&n)for(let I=d?.number+1n;I<w.number;I++){const P=await $(t,kt,"getBlock")({blockNumber:I,includeTransactions:f});h.onBlock(P,d),d=P}}(d?.number==null||e==="pending"&&w?.number==null||w.number!==null&&w.number>d.number)&&(h.onBlock(w,d),d=w)}catch(w){h.onError?.(w)}},{emitOnBegin:r,interval:i}))})():(()=>{let m=!0,h=!0,w=()=>m=!1;return(async()=>{try{r&&$(t,kt,"getBlock")({blockTag:e,includeTransactions:f}).then(b=>{m&&h&&(s(b,void 0),h=!1)}).catch(o);const I=(()=>{if(t.transport.type==="fallback"){const b=t.transport.transports.find(p=>p.config.type==="webSocket"||p.config.type==="ipc");return b?b.value:t.transport}return t.transport})(),{unsubscribe:P}=await I.subscribe({params:["newHeads"],async onData(b){if(!m)return;const p=await $(t,kt,"getBlock")({blockNumber:b.result?.number,includeTransactions:f}).catch(()=>{});m&&(s(p,d),h=!1,d=p)},onError(b){o?.(b)}});w=P,m||w()}catch(I){o?.(I)}})(),()=>w()})()}function Bu(t,e){const{abi:n,address:r,args:s,batch:o=!0,eventName:a,fromBlock:c,onError:i,onLogs:u,poll:f,pollingInterval:d=t.pollingInterval,strict:l}=e;return(typeof f<"u"?f:typeof c=="bigint"?!0:!(t.transport.type==="webSocket"||t.transport.type==="ipc"||t.transport.type==="fallback"&&(t.transport.transports[0].config.type==="webSocket"||t.transport.transports[0].config.type==="ipc")))?(()=>{const w=l??!1,I=Q(["watchContractEvent",r,s,o,t.uid,a,d,w,c]);return yt(I,{onLogs:u,onError:i},P=>{let b;c!==void 0&&(b=c-1n);let p,g=!1;const B=se(async()=>{if(!g){try{p=await $(t,Li,"createContractEventFilter")({abi:n,address:r,args:s,eventName:a,strict:w,fromBlock:c})}catch{}g=!0;return}try{let v;if(p)v=await $(t,cs,"getFilterChanges")({filter:p});else{const x=await $(t,fn,"getBlockNumber")({});b&&b<x?v=await $(t,Gi,"getContractEvents")({abi:n,address:r,args:s,eventName:a,fromBlock:b+1n,toBlock:x,strict:w}):v=[],b=x}if(v.length===0)return;if(o)P.onLogs(v);else for(const x of v)P.onLogs([x])}catch(v){p&&v instanceof Ce&&(g=!1),P.onError?.(v)}},{emitOnBegin:!0,interval:d});return async()=>{p&&await $(t,Fs,"uninstallFilter")({filter:p}),B()}})})():(()=>{const w=l??!1,I=Q(["watchContractEvent",r,s,o,t.uid,a,d,w]);let P=!0,b=()=>P=!1;return yt(I,{onLogs:u,onError:i},p=>((async()=>{try{const g=(()=>{if(t.transport.type==="fallback"){const x=t.transport.transports.find(R=>R.config.type==="webSocket"||R.config.type==="ipc");return x?x.value:t.transport}return t.transport})(),B=a?un({abi:n,eventName:a,args:s}):[],{unsubscribe:v}=await g.subscribe({params:["logs",{address:r,topics:B}],onData(x){if(!P)return;const R=x.result;try{const{eventName:k,args:S}=Ue({abi:n,data:R.data,topics:R.topics,strict:l}),N=Yt(R,{args:S,eventName:k});p.onLogs([N])}catch(k){let S,N;if(k instanceof Re||k instanceof Cr){if(l)return;S=k.abiItem.name,N=k.abiItem.inputs?.some(U=>!("name"in U&&U.name))}const T=Yt(R,{args:N?[]:{},eventName:S});p.onLogs([T])}},onError(x){p.onError?.(x)}});b=v,P||b()}catch(g){i?.(g)}})(),()=>b()))})()}function Au(t,{batch:e=!0,onError:n,onTransactions:r,poll:s,pollingInterval:o=t.pollingInterval}){return(typeof s<"u"?s:t.transport.type!=="webSocket"&&t.transport.type!=="ipc")?(()=>{const u=Q(["watchPendingTransactions",t.uid,e,o]);return yt(u,{onTransactions:r,onError:n},f=>{let d;const l=se(async()=>{try{if(!d)try{d=await $(t,ji,"createPendingTransactionFilter")({});return}catch(m){throw l(),m}const y=await $(t,cs,"getFilterChanges")({filter:d});if(y.length===0)return;if(e)f.onTransactions(y);else for(const m of y)f.onTransactions([m])}catch(y){f.onError?.(y)}},{emitOnBegin:!0,interval:o});return async()=>{d&&await $(t,Fs,"uninstallFilter")({filter:d}),l()}})})():(()=>{let u=!0,f=()=>u=!1;return(async()=>{try{const{unsubscribe:d}=await t.transport.subscribe({params:["newPendingTransactions"],onData(l){if(!u)return;const y=l.result;r([y])},onError(l){n?.(l)}});f=d,u||f()}catch(d){n?.(d)}})(),()=>f()})()}function Iu(t,e){const{abi:n,args:r,bytecode:s,...o}=e,a=Zr({abi:n,args:r,bytecode:s});return Yr(t,{...o,...o.authorizationList?{to:null}:{},data:a})}async function Su(t,e={}){const{account:n=t.account,chainId:r}=e,s=n?St(n):void 0,o=r?[s?.address,[M(r)]]:[s?.address],a=await t.request({method:"wallet_getCapabilities",params:o}),c={};for(const[i,u]of Object.entries(a)){c[Number(i)]={};for(let[f,d]of Object.entries(u))f==="addSubAccount"&&(f="unstable_addSubAccount"),c[Number(i)][f]=d}return typeof r=="number"?c[r]:c}async function Nu(t,e){const{chain:n=t.chain}=e,r=e.timeout??Math.max((n?.blockTime??0)*3,5e3),s=await zo(t,e);return await Uo(t,{...e,id:s.id,timeout:r})}async function Xc(t,{serializedTransaction:e,throwOnReceiptRevert:n,timeout:r}){const s=await t.request({method:"eth_sendRawTransactionSync",params:r?[e,M(r)]:[e]},{retryCount:0}),a=(t.chain?.formatters?.transactionReceipt?.format||Fr)(s);if(a.status==="reverted"&&n)throw new Gr({receipt:a});return a}const Ne=new qr(128);async function Pu(t,e){const{account:n=t.account,chain:r=t.chain,accessList:s,authorizationList:o,blobs:a,data:c,gas:i,gasPrice:u,maxFeePerBlobGas:f,maxFeePerGas:d,maxPriorityFeePerGas:l,nonce:y,pollingInterval:m,throwOnReceiptRevert:h,type:w,value:I,...P}=e,b=e.timeout??Math.max((r?.blockTime??0)*3,5e3);if(typeof n>"u")throw new oe({docsPath:"/docs/actions/wallet/sendTransactionSync"});const p=n?St(n):null;try{Lo(e);const g=await(async()=>{if(e.to)return e.to;if(e.to!==null&&o&&o.length>0)return await $r({authorization:o[0]}).catch(()=>{throw new tt("`to` is required. Could not infer from `authorizationList`.")})})();if(p?.type==="json-rpc"||p===null){let B;r!==null&&(B=await $(t,jo,"getChainId")({}),Mo({currentChainId:B,chain:r}));const v=t.chain?.formatters?.transactionRequest?.format,R=(v||Fo)({...Ho(P,{format:v}),accessList:s,account:p,authorizationList:o,blobs:a,chainId:B,data:c,gas:i,gasPrice:u,maxFeePerBlobGas:f,maxFeePerGas:d,maxPriorityFeePerGas:l,nonce:y,to:g,type:w,value:I},"sendTransaction"),k=Ne.get(t.uid),S=k?"wallet_sendTransaction":"eth_sendTransaction",N=await(async()=>{try{return await t.request({method:S,params:[R]},{retryCount:0})}catch(U){if(k===!1)throw U;const A=U;if(A.name==="InvalidInputRpcError"||A.name==="InvalidParamsRpcError"||A.name==="MethodNotFoundRpcError"||A.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[R]},{retryCount:0}).then(E=>(Ne.set(t.uid,!0),E)).catch(E=>{const C=E;throw C.name==="MethodNotFoundRpcError"||C.name==="MethodNotSupportedRpcError"?(Ne.set(t.uid,!1),A):C});throw A}})(),T=await $(t,Kc,"waitForTransactionReceipt")({checkReplacement:!1,hash:N,pollingInterval:m,timeout:b});if(h&&T.status==="reverted")throw new Gr({receipt:T});return T}if(p?.type==="local"){const B=await $(t,Do,"prepareTransactionRequest")({account:p,accessList:s,authorizationList:o,blobs:a,chain:r,data:c,gas:i,gasPrice:u,maxFeePerBlobGas:f,maxFeePerGas:d,maxPriorityFeePerGas:l,nonce:y,nonceManager:p.nonceManager,parameters:[...Vo,"sidecars"],type:w,value:I,...P,to:g}),v=r?.serializers?.transaction,x=await p.signTransaction(B,{serializer:v});return await $(t,Xc,"sendRawTransactionSync")({serializedTransaction:x,throwOnReceiptRevert:h,timeout:e.timeout})}throw p?.type==="smart"?new le({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new le({docsPath:"/docs/actions/wallet/sendTransactionSync",type:p?.type})}catch(g){throw g instanceof le?g:Wo(g,{...e,account:p,chain:e.chain||void 0})}}async function Ru(t,e){const{id:n}=e;await t.request({method:"wallet_showCallsStatus",params:[n]})}async function ku(t,{account:e=t.account,message:n}){if(!e)throw new oe({docsPath:"/docs/actions/wallet/signMessage"});const r=St(e);if(r.signMessage)return r.signMessage({message:n});const s=typeof n=="string"?Gt(n):n.raw instanceof Uint8Array?ne(n.raw):n.raw;return t.request({method:"personal_sign",params:[s,r.address]},{retryCount:0})}async function Tu(t,e){const{account:n=t.account,domain:r,message:s,primaryType:o}=e;if(!n)throw new oe({docsPath:"/docs/actions/wallet/signTypedData"});const a=St(n),c={EIP712Domain:Zo({domain:r}),...e.types};if(Yo({domain:r,message:s,primaryType:o,types:c}),a.signTypedData)return a.signTypedData({domain:r,message:s,primaryType:o,types:c});const i=Go({domain:r,message:s,primaryType:o,types:c});return t.request({method:"eth_signTypedData_v4",params:[a.address,i]},{retryCount:0})}async function Cu(t,e){return await t.request({method:"wallet_watchAsset",params:e},{retryCount:0})}async function We(t,e){return We.internal(t,Yr,"sendTransaction",e)}(function(t){async function e(n,r,s,o){const{abi:a,account:c=n.account,address:i,args:u,dataSuffix:f,functionName:d,...l}=o;if(typeof c>"u")throw new oe({docsPath:"/docs/contract/writeContract"});const y=c?St(c):null,m=gt({abi:a,args:u,functionName:d});try{return await $(n,r,s)({data:`${m}${f?f.replace("0x",""):""}`,to:i,account:y,...l})}catch(h){throw Kt(h,{abi:a,address:i,args:u,docsPath:"/docs/contract/writeContract",functionName:d,sender:y?.address})}}t.internal=e})(We||(We={}));function xn({key:t,methods:e,name:n,request:r,retryCount:s=3,retryDelay:o=150,timeout:a,type:c},i){const u=Jo();return{config:{key:t,methods:e,name:n,request:r,retryCount:s,retryDelay:o,timeout:a,type:c},request:Qi(r,{methods:e,retryCount:s,retryDelay:o,uid:u}),value:i}}function _u(t,e={}){const{key:n="custom",methods:r,name:s="Custom Provider",retryDelay:o}=e;return({retryCount:a})=>xn({key:n,methods:r,name:s,request:t.request.bind(t),retryCount:e.retryCount??a,retryDelay:o,type:"custom"})}class Vs extends tt{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function $u(t,e={}){const{batch:n,fetchFn:r,fetchOptions:s,key:o="http",methods:a,name:c="HTTP JSON-RPC",onFetchRequest:i,onFetchResponse:u,retryDelay:f,raw:d}=e;return({chain:l,retryCount:y,timeout:m})=>{const{batchSize:h=1e3,wait:w=0}=typeof n=="object"?n:{},I=e.retryCount??y,P=m??e.timeout??1e4,b=t||l?.rpcUrls.default.http[0];if(!b)throw new Vs;const p=fs(b,{fetchFn:r,fetchOptions:s,onRequest:i,onResponse:u,timeout:P});return xn({key:o,methods:a,name:c,async request({method:g,params:B}){const v={method:g,params:B},{schedule:x}=zr({id:b,wait:w,shouldSplitBatch(N){return N.length>h},fn:N=>p.request({body:N}),sort:(N,T)=>N.id-T.id}),R=async N=>n?x(N):[await p.request({body:N})],[{error:k,result:S}]=await R(v);if(d)return{error:k,result:S};if(k)throw new Jr({body:v,error:k,url:b});return S},retryCount:I,retryDelay:f,timeout:P,type:"http"},{fetchOptions:s,url:b})}}function Ou(t,e={}){const{keepAlive:n,key:r="webSocket",methods:s,name:o="WebSocket JSON-RPC",reconnect:a,retryDelay:c}=e;return({chain:i,retryCount:u,timeout:f})=>{const d=e.retryCount??u,l=f??e.timeout??1e4,y=t||i?.rpcUrls.default.webSocket?.[0],m={keepAlive:n,reconnect:a};if(!y)throw new Vs;return xn({key:r,methods:s,name:o,async request({method:h,params:w}){const I={method:h,params:w},P=await Zt(y,m),{error:b,result:p}=await P.requestAsync({body:I,timeout:l});if(b)throw new Jr({body:I,error:b,url:y});return p},retryCount:d,retryDelay:c,timeout:l,type:"webSocket"},{getSocket(){return ia(y)},getRpcClient(){return Zt(y,m)},async subscribe({params:h,onData:w,onError:I}){const P=await Zt(y,m),{result:b}=await new Promise((p,g)=>P.request({body:{method:"eth_subscribe",params:h},onError(B){g(B),I?.(B)},onResponse(B){if(B.error){g(B.error),I?.(B.error);return}if(typeof B.id=="number"){p(B);return}B.method==="eth_subscription"&&w(B.params)}}));return{subscriptionId:b,async unsubscribe(){return new Promise(p=>P.request({body:{method:"eth_unsubscribe",params:[b]},onResponse:p}))}}}})}}export{xn as $,xu as A,Kc as B,Eu as C,vu as D,Xc as E,wu as F,Se as G,gu as H,Ms as I,mu as J,yu as K,cu as L,zi as M,ou as N,su as O,ru as P,eu as Q,au as R,iu as S,ji as T,Cu as U,Tu as V,ku as W,Ru as X,Nu as Y,Su as Z,Iu as _,ti as a,nu as a0,wn as a1,Rt as a2,Si as a3,an as a4,Ui as a5,Vs as a6,_u as a7,Xo as a8,or as a9,Qo as aa,$u as ab,ri as ac,qe as ad,sr as ae,aa as af,Wc as ag,ca as ah,Ou as ai,Di as aj,us as ak,uu as al,lu as am,du as b,is as c,ys as d,un as e,Ue as f,cs as g,ua as h,fn as i,Yi as j,dn as k,ie as l,Fs as m,We as n,bu as o,as as p,Li as q,Gi as r,Pu as s,Bu as t,zc as u,Uc as v,hu as w,Ds as x,Au as y,Jc as z};
@@ -1,4 +1,4 @@
1
- import{w as l}from"./core-CNeX_97j.js";const h=l`<svg fill="none" viewBox="0 0 41 40">
1
+ import{w as l}from"./core-CmzgCi5e.js";const h=l`<svg fill="none" viewBox="0 0 41 40">
2
2
  <g clip-path="url(#a)">
3
3
  <path fill="#000" d="M.8 0h40v40H.8z" />
4
4
  <path