@privy-io/react-auth 3.11.1-beta-20260122161812 → 3.12.0

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 (416) hide show
  1. package/dist/cjs/AccountNotFoundScreen-BBWWze9O.js +1 -0
  2. package/dist/cjs/{Address-BJFF-dMG.js → Address-6qDWL5TN.js} +4 -4
  3. package/dist/cjs/AffirmativeConsentScreen-CCwAwjH1.js +6 -0
  4. package/dist/cjs/AllowlistRejectionScreen-DEMYbzGA.js +1 -0
  5. package/dist/cjs/AuthenticateWithWalletScreen-dBvBC7MB.js +1 -0
  6. package/dist/cjs/AwaitingEvmToSolBridgingScreen-D9NwI47L.js +2 -0
  7. package/dist/cjs/AwaitingExternalEthereumTransferScreen-D_0NulpI.js +2 -0
  8. package/dist/cjs/AwaitingPasswordlessCodeScreen-B4HAKL4-.js +103 -0
  9. package/dist/cjs/AwaitingSolToEvmBridgingScreen-CnuLLTC0.js +2 -0
  10. package/dist/cjs/{BridgeNetworkSelectionView-BNv-V9G2.js → BridgeNetworkSelectionView-DKA06V8u.js} +11 -11
  11. package/dist/cjs/CaptchaScreen-N-ueJQF3.js +1 -0
  12. package/dist/cjs/CoinbaseOnrampStatusScreen-06yaO6r4.js +16 -0
  13. package/dist/cjs/ConnectEmailForm-DZrCSv9t.js +3 -0
  14. package/dist/cjs/ConnectLedgerScreen-C7vGQocf.js +9 -0
  15. package/dist/cjs/ConnectOnlyLandingScreen-_9y9kOsT.js +1 -0
  16. package/dist/cjs/ConnectOnlyStatusScreen-mZHx4a7S.js +1 -0
  17. package/dist/cjs/ConnectOrCreateScreen-Cp4uExOd.js +1 -0
  18. package/dist/cjs/{ConnectPhoneForm-C8JEoPHB.js → ConnectPhoneForm-BWSmRonl.js} +1 -1
  19. package/dist/cjs/{ConnectWalletView-bug4GgVZ.js → ConnectWalletView-Bh1DK9t5.js} +6 -6
  20. package/dist/cjs/ConnectionStatusScreen-B27DUsGt.js +7 -0
  21. package/dist/cjs/CrossAppAuthScreen-BbLFbCdU.js +1 -0
  22. package/dist/cjs/CustomLandingScreenView-DP1fJrBU.js +23 -0
  23. package/dist/cjs/DelegatedActionsConsentScreen-DzWruJOn.js +1 -0
  24. package/dist/cjs/DelegatedActionsRevokeScreen-D-TwUXyj.js +1 -0
  25. package/dist/cjs/EmbeddedWalletConnectingScreen-CYav4Mjb.js +1 -0
  26. package/dist/cjs/EmbeddedWalletCreatedScreen-m0t_c_AA.js +1 -0
  27. package/dist/cjs/EmbeddedWalletKeyExportScreen-_4GMdJuo.js +40 -0
  28. package/dist/cjs/EmbeddedWalletOnAccountCreateScreen-B5-JBZRJ.js +1 -0
  29. package/dist/cjs/EmbeddedWalletPasswordUpdateScreen-CITAy3i6.js +1 -0
  30. package/dist/cjs/EmbeddedWalletPasswordUpdateSplashScreen-DG5LKyjo.js +1 -0
  31. package/dist/cjs/{EnrollTotp-BpzRLjKc.js → EnrollTotp-leOB_B4o.js} +8 -8
  32. package/dist/cjs/ErrorScreen-xNDIVXx8.js +4 -0
  33. package/dist/cjs/{FarcasterConnectStatusScreen-DuOFuio7.js → FarcasterConnectStatusScreen-Bzmd4izn.js} +9 -9
  34. package/dist/cjs/FarcasterSignerStatusScreen-Cxoi54pp.js +29 -0
  35. package/dist/cjs/FundSolWalletWithExternalSolanaWallet-BCyBv_xe.js +2 -0
  36. package/dist/cjs/{FundWalletMethodHeader-Dn7FrcOp.js → FundWalletMethodHeader-YwNCXAU_.js} +1 -1
  37. package/dist/cjs/FundingEditAmountScreen-CDlb4Acx.js +1 -0
  38. package/dist/cjs/FundingMethodSelectionScreen-DlPxjsJq.js +1 -0
  39. package/dist/cjs/InAppBrowserLoginNotPossible-Bdx0vKyA.js +1 -0
  40. package/dist/cjs/InstallWalletScreen-Cshn01eK.js +1 -0
  41. package/dist/cjs/LandingScreen-0FdwpJ9w.js +1 -0
  42. package/dist/cjs/{LinkConflictScreen-8h7pmzsL.js → LinkConflictScreen-BCzS7Szr.js} +7 -7
  43. package/dist/cjs/LinkEmailScreen-B7rxdQso.js +1 -0
  44. package/dist/cjs/{LinkPasskeyScreen-cUu7WCqn.js → LinkPasskeyScreen-o4qdrAL3.js} +10 -10
  45. package/dist/cjs/LinkPhoneScreen-DweFqlM1.js +1 -0
  46. package/dist/cjs/LoginFailedScreen-mHcvCBEz.js +1 -0
  47. package/dist/cjs/ManualTransferScreen-CfYgtyLD.js +1 -0
  48. package/dist/cjs/MfaAuthEnrollmentFlowScreen-D631h0XW.js +1 -0
  49. package/dist/cjs/MfaAuthVerifyFlowScreen-BZ3IyqAd.js +1 -0
  50. package/dist/cjs/MfaEnrollmentFlowScreen-_tNeX5lT.js +1 -0
  51. package/dist/cjs/MfaVerifyFlowScreen-D_7nkuBq.js +1 -0
  52. package/dist/cjs/{ModalHeader-7knkCFjH.js → ModalHeader-C5O9gNUP.js} +1 -1
  53. package/dist/cjs/{MoonpayStatusScreen-BWA_sZnz.js → MoonpayStatusScreen-DoFbZ_0d.js} +3 -3
  54. package/dist/cjs/OAuthStatusScreen-BZY7BiP5.js +1 -0
  55. package/dist/cjs/PasskeySelectSignupOrLogin-C3k_ixTz.js +1 -0
  56. package/dist/cjs/PasskeyStatusScreen-BX-SOBDr.js +3 -0
  57. package/dist/cjs/PasswordRecoveryScreen-VZQDtt5v.js +20 -0
  58. package/dist/cjs/{QrCode-DPcePk5I.js → QrCode-CLd3Ytk7.js} +3 -3
  59. package/dist/cjs/RecoveryOAuthStatusScreen-DKYx6ECd.js +1 -0
  60. package/dist/cjs/RecoveryPasswordCreateScreen-DP0xOBMA.js +1 -0
  61. package/dist/cjs/RecoverySelectionScreen-Bw9_M6y0.js +7 -0
  62. package/dist/cjs/{Screen-uapp8UP4.js → Screen-BSwlHqPg.js} +4 -4
  63. package/dist/cjs/{ScreenLayout-BENEZm1m.js → ScreenLayout-BtVIYAso.js} +1 -1
  64. package/dist/cjs/SetAutomaticRecoveryScreen-SUOUjBk4.js +14 -0
  65. package/dist/cjs/{SetWalletPasswordForm-NMSn8MW-.js → SetWalletPasswordForm-Gkq-DskE.js} +3 -3
  66. package/dist/cjs/SignRequestScreen-BNcy6yU_.js +26 -0
  67. package/dist/cjs/{StandardSignAndSendTransactionScreen-C0Af9uPz.js → StandardSignAndSendTransactionScreen-z_EUNaeD.js} +3 -3
  68. package/dist/cjs/TelegramAuthScreen-DV8KYJMX.js +1 -0
  69. package/dist/cjs/{TransactionDetails-BCQvuSov.js → TransactionDetails-DYow9ihU.js} +4 -4
  70. package/dist/cjs/{TransactionErrorView-DhdW4Ka8.js → TransactionErrorView-yUMJqqF2.js} +4 -4
  71. package/dist/cjs/TransferFromWalletScreen-Duk7CEcq.js +31 -0
  72. package/dist/cjs/TransferOrBridgeLoadingScreen-DuBLyfE1.js +6 -0
  73. package/dist/cjs/UpdateEmailScreen-DRJv5CZs.js +1 -0
  74. package/dist/cjs/UpdatePhoneScreen-C3myqOv0.js +1 -0
  75. package/dist/cjs/UserLimitReachedScreen-l_e6Vhr0.js +1 -0
  76. package/dist/cjs/{WalletInfoCard-DLnujds6.js → WalletInfoCard-CHEynRZS.js} +4 -4
  77. package/dist/cjs/{WalletInterstitialScreen-CMMSgAk9.js → WalletInterstitialScreen-BgoDwKIp.js} +1 -1
  78. package/dist/cjs/WalletLink-CZLtiI7E.js +22 -0
  79. package/dist/cjs/WalletOverflowButton-FlgoA77a.js +1 -0
  80. package/dist/cjs/abstract-smart-wallets.js +1 -1
  81. package/dist/cjs/{context-P14IM76D.js → context-BeSQM-Ma.js} +1 -1
  82. package/dist/cjs/ethers-XrYC9HG-.js +1 -0
  83. package/dist/cjs/extended-chains.js +1 -1
  84. package/dist/cjs/farcaster.js +1 -1
  85. package/dist/cjs/frame-Oz7volks.js +1 -0
  86. package/dist/cjs/{get-is-unified-wallet-DL_nMXp5.js → get-is-unified-wallet-BwdzQwn_.js} +1 -1
  87. package/dist/cjs/getErc20Balance-CN3JMVjF.js +1 -0
  88. package/dist/cjs/getErc20TokenInfo-DxDd_HN6.js +1 -0
  89. package/dist/cjs/getPublicClient-BsmZyCGX.js +1 -0
  90. package/dist/cjs/index-0-2WrPDo.js +12 -0
  91. package/dist/cjs/index-CzmnSRoa.js +174 -0
  92. package/dist/cjs/{index-BypMyGGH.js → index-W2ZSukRW.js} +1 -1
  93. package/dist/cjs/index.js +1 -1
  94. package/dist/cjs/{internal-context-NWsAL807.js → internal-context-BJv4f_bO.js} +1 -1
  95. package/dist/cjs/internal.js +1 -1
  96. package/dist/cjs/prepareFundingModalData-DDf6xLze.js +1 -0
  97. package/dist/cjs/{reservoir-CQGyEBb7.js → reservoir-Bx0HQwbb.js} +1 -1
  98. package/dist/cjs/{shared-CoZLntA9.js → shared-BcueHfN-.js} +6 -6
  99. package/dist/cjs/shouldProceedtoEmbeddedWalletCreationFlow-j6p9PEm-.js +1 -0
  100. package/dist/cjs/smart-wallets-BBh3vgRq.js +1 -0
  101. package/dist/cjs/smart-wallets.js +1 -1
  102. package/dist/cjs/solana.js +1 -1
  103. package/dist/cjs/{styles-DtykMHfN.js → styles-Csarwypj.js} +1 -1
  104. package/dist/cjs/to-ui-error-C4aac_aM.js +4 -0
  105. package/dist/cjs/ui.js +37 -37
  106. package/dist/cjs/use-export-wallet-C9HWu0Dq.js +1 -0
  107. package/dist/cjs/{use-sign-with-user-signer-BcAsQTGF.js → use-sign-with-user-signer-Cu_6Bx7m.js} +1 -1
  108. package/dist/cjs/useActiveWallet-vlXeDPzp.js +185 -0
  109. package/dist/cjs/{useGetSolPrice-C986iVoO.js → useGetSolPrice-Ca32VAbF.js} +1 -1
  110. package/dist/cjs/{useGetTokenPrice-cA2TnAzD.js → useGetTokenPrice-DJpJnTij.js} +1 -1
  111. package/dist/cjs/{useI18n-D4jKEXmt.js → useI18n-CnsBjm9v.js} +1 -1
  112. package/dist/cjs/usePrivy-Bx2PKTrU.js +1 -0
  113. package/dist/cjs/{useSolanaRpcClient-hHdPoMRE.js → useSolanaRpcClient-CYMWkK7E.js} +1 -1
  114. package/dist/cjs/useWalletBalance-DI8AY31i.js +1 -0
  115. package/dist/cjs/useWallets-BwB7ALB8.js +1 -0
  116. package/dist/cjs/useWallets-DMyuB5aJ.js +1 -0
  117. package/dist/dts/{events-context-vKnpI7Js.d.mts → events-context-DeukTtar.d.mts} +1 -1
  118. package/dist/dts/{events-context-vKnpI7Js.d.ts → events-context-DeukTtar.d.ts} +1 -1
  119. package/dist/dts/extended-chains.d.mts +1 -1
  120. package/dist/dts/extended-chains.d.ts +1 -1
  121. package/dist/dts/farcaster.d.mts +1 -1
  122. package/dist/dts/farcaster.d.ts +1 -1
  123. package/dist/dts/index.d.mts +40 -4
  124. package/dist/dts/index.d.ts +40 -4
  125. package/dist/dts/internal.d.mts +1 -1
  126. package/dist/dts/internal.d.ts +1 -1
  127. package/dist/dts/smart-wallets.d.mts +1 -1
  128. package/dist/dts/smart-wallets.d.ts +1 -1
  129. package/dist/dts/solana.d.mts +3 -3
  130. package/dist/dts/solana.d.ts +3 -3
  131. package/dist/dts/{types-DAzgcrBH.d.mts → types-FifkyCQc.d.mts} +2 -1
  132. package/dist/dts/{types-DAzgcrBH.d.ts → types-FifkyCQc.d.ts} +2 -1
  133. package/dist/dts/ui.d.mts +1 -1
  134. package/dist/dts/ui.d.ts +1 -1
  135. package/dist/esm/AccountNotFoundScreen-C6S8_GyN.mjs +1 -0
  136. package/dist/esm/Address-QmAVCQtO.mjs +17 -0
  137. package/dist/esm/AffirmativeConsentScreen-QfJBfI_f.mjs +6 -0
  138. package/dist/esm/AllowlistRejectionScreen-CX57yv4U.mjs +1 -0
  139. package/dist/esm/AuthenticateWithWalletScreen-CZJ-aWhZ.mjs +1 -0
  140. package/dist/esm/AwaitingEvmToSolBridgingScreen-C1CMtT4Y.mjs +2 -0
  141. package/dist/esm/AwaitingExternalEthereumTransferScreen-DX91STcF.mjs +2 -0
  142. package/dist/esm/AwaitingPasswordlessCodeScreen-BuExr50N.mjs +103 -0
  143. package/dist/esm/AwaitingSolToEvmBridgingScreen-Bm1i_2qW.mjs +2 -0
  144. package/dist/esm/BridgeNetworkSelectionView-DQGcampg.mjs +69 -0
  145. package/dist/esm/CaptchaScreen-B-hFDb5f.mjs +1 -0
  146. package/dist/esm/CoinbaseOnrampStatusScreen-OHm2RUBv.mjs +16 -0
  147. package/dist/esm/ConnectEmailForm-Df5OtmDR.mjs +3 -0
  148. package/dist/esm/ConnectLedgerScreen-BHLYW-F3.mjs +9 -0
  149. package/dist/esm/ConnectOnlyLandingScreen-C6nzEwpN.mjs +1 -0
  150. package/dist/esm/ConnectOnlyStatusScreen-CremlXDY.mjs +1 -0
  151. package/dist/esm/ConnectOrCreateScreen-262UvCdD.mjs +1 -0
  152. package/dist/esm/{ConnectPhoneForm-C1eL0VZH.mjs → ConnectPhoneForm-BMtTIItD.mjs} +1 -1
  153. package/dist/esm/{ConnectWalletView-BtuPwm-c.mjs → ConnectWalletView-BMjEKo1_.mjs} +6 -6
  154. package/dist/esm/ConnectionStatusScreen-mk5beBL7.mjs +7 -0
  155. package/dist/esm/CrossAppAuthScreen-BXjEJQv6.mjs +1 -0
  156. package/dist/esm/CustomLandingScreenView-BlDfJaDr.mjs +23 -0
  157. package/dist/esm/DelegatedActionsConsentScreen-ANmQe-9G.mjs +1 -0
  158. package/dist/esm/DelegatedActionsRevokeScreen-D9X7mWmI.mjs +1 -0
  159. package/dist/esm/EmbeddedWalletConnectingScreen-2g-RrIvW.mjs +1 -0
  160. package/dist/esm/EmbeddedWalletCreatedScreen-BXTAv4_-.mjs +1 -0
  161. package/dist/esm/EmbeddedWalletKeyExportScreen-DYVHVHOj.mjs +40 -0
  162. package/dist/esm/EmbeddedWalletOnAccountCreateScreen-CYyMoMFF.mjs +1 -0
  163. package/dist/esm/EmbeddedWalletPasswordUpdateScreen-oT5ZcPQV.mjs +1 -0
  164. package/dist/esm/EmbeddedWalletPasswordUpdateSplashScreen-BQcHDyuV.mjs +1 -0
  165. package/dist/esm/{EnrollTotp-Bk2mWeF6.mjs → EnrollTotp-DVLg14UT.mjs} +8 -8
  166. package/dist/esm/ErrorScreen-CLfeO5pd.mjs +4 -0
  167. package/dist/esm/{FarcasterConnectStatusScreen-CHItJej_.mjs → FarcasterConnectStatusScreen-CUO9DKCJ.mjs} +7 -7
  168. package/dist/esm/FarcasterSignerStatusScreen-B135UOnV.mjs +28 -0
  169. package/dist/esm/FundSolWalletWithExternalSolanaWallet-DO3ttgom.mjs +1 -0
  170. package/dist/esm/{FundWalletMethodHeader-B3nAPYAR.mjs → FundWalletMethodHeader-PIxwFzzh.mjs} +1 -1
  171. package/dist/esm/FundingEditAmountScreen-BRQb2ffL.mjs +1 -0
  172. package/dist/esm/FundingMethodSelectionScreen-DTt1Z5RI.mjs +1 -0
  173. package/dist/esm/InAppBrowserLoginNotPossible-DH96QD2c.mjs +1 -0
  174. package/dist/esm/InstallWalletScreen-PnK6VfrP.mjs +1 -0
  175. package/dist/esm/LandingScreen-D_EvjOHf.mjs +1 -0
  176. package/dist/esm/{LinkConflictScreen-DmFrdpwb.mjs → LinkConflictScreen-B94e_-2N.mjs} +7 -7
  177. package/dist/esm/LinkEmailScreen-CT8gAQr3.mjs +1 -0
  178. package/dist/esm/LinkPasskeyScreen-DYfWSjKR.mjs +105 -0
  179. package/dist/esm/LinkPhoneScreen-ccrKA6tf.mjs +1 -0
  180. package/dist/esm/LoginFailedScreen-BwgxhbMf.mjs +1 -0
  181. package/dist/esm/ManualTransferScreen-DgCG2P3B.mjs +1 -0
  182. package/dist/esm/MfaAuthEnrollmentFlowScreen-CNVUTOnE.mjs +1 -0
  183. package/dist/esm/MfaAuthVerifyFlowScreen-2nvvFipu.mjs +1 -0
  184. package/dist/esm/MfaEnrollmentFlowScreen-DfnIqNNU.mjs +1 -0
  185. package/dist/esm/MfaVerifyFlowScreen-BwerwBz5.mjs +1 -0
  186. package/dist/esm/{ModalHeader-cnW8OaHH.mjs → ModalHeader-rCMpqA2a.mjs} +4 -4
  187. package/dist/esm/MoonpayStatusScreen-D5fRCEb3.mjs +16 -0
  188. package/dist/esm/OAuthStatusScreen-DtLgYw89.mjs +1 -0
  189. package/dist/esm/PasskeySelectSignupOrLogin-QoPhmagh.mjs +1 -0
  190. package/dist/esm/PasskeyStatusScreen-DzjU3ZVT.mjs +3 -0
  191. package/dist/esm/PasswordRecoveryScreen-LZYGRBkP.mjs +20 -0
  192. package/dist/esm/{QrCode-BVe4kf2z.mjs → QrCode-DjnQgnaZ.mjs} +3 -3
  193. package/dist/esm/RecoveryOAuthStatusScreen-DKfp8Udh.mjs +1 -0
  194. package/dist/esm/RecoveryPasswordCreateScreen-D4DI5Bom.mjs +1 -0
  195. package/dist/esm/RecoverySelectionScreen-B2V3518x.mjs +7 -0
  196. package/dist/esm/{Screen-DgjLPjok.mjs → Screen-CV2tt2Ap.mjs} +11 -11
  197. package/dist/esm/{ScreenLayout-x3-Xgy2E.mjs → ScreenLayout-DF3DCKOK.mjs} +1 -1
  198. package/dist/esm/SetAutomaticRecoveryScreen-C6cFVbSx.mjs +14 -0
  199. package/dist/esm/{SetWalletPasswordForm-Deqef3mc.mjs → SetWalletPasswordForm-ChA4tW4Y.mjs} +4 -4
  200. package/dist/esm/SignRequestScreen-BslfKJ1N.mjs +26 -0
  201. package/dist/esm/{StandardSignAndSendTransactionScreen-BGAjDFes.mjs → StandardSignAndSendTransactionScreen-D4OBsj5k.mjs} +3 -3
  202. package/dist/esm/TelegramAuthScreen-BJq5f_Rq.mjs +1 -0
  203. package/dist/esm/{TransactionDetails-8R96szrm.mjs → TransactionDetails-BP142O9n.mjs} +4 -4
  204. package/dist/esm/TransactionErrorView-BwwGMqSj.mjs +166 -0
  205. package/dist/esm/TransferFromWalletScreen-BHH0YcI4.mjs +31 -0
  206. package/dist/esm/TransferOrBridgeLoadingScreen-VLQTcf_6.mjs +6 -0
  207. package/dist/esm/UpdateEmailScreen-CMFBvYz5.mjs +1 -0
  208. package/dist/esm/UpdatePhoneScreen-DmhHcNq3.mjs +1 -0
  209. package/dist/esm/UserLimitReachedScreen-DNqgCf3B.mjs +1 -0
  210. package/dist/esm/{WalletInfoCard-CR6-S95l.mjs → WalletInfoCard-ChBHG5L5.mjs} +3 -3
  211. package/dist/esm/WalletInterstitialScreen-RS89fm6t.mjs +1 -0
  212. package/dist/esm/WalletLink-CN4enmsE.mjs +22 -0
  213. package/dist/esm/WalletOverflowButton-B-nEN4GW.mjs +1 -0
  214. package/dist/esm/abstract-smart-wallets.mjs +1 -1
  215. package/dist/esm/context-LVpDfP2H.mjs +1 -0
  216. package/dist/esm/ethers-BQ45eiVv.mjs +1 -0
  217. package/dist/esm/extended-chains.mjs +1 -1
  218. package/dist/esm/farcaster.mjs +1 -1
  219. package/dist/esm/{frame-cjQkGswH.mjs → frame-uzTmvtww.mjs} +1 -1
  220. package/dist/esm/get-is-unified-wallet-CNcx75Dp.mjs +1 -0
  221. package/dist/esm/getErc20Balance-DA4dGV9O.mjs +1 -0
  222. package/dist/esm/getErc20TokenInfo-CxatSwzi.mjs +1 -0
  223. package/dist/esm/getPublicClient-B4uPLKn-.mjs +1 -0
  224. package/dist/esm/{index-0TRQs0PD.mjs → index-2knYP69D.mjs} +3 -3
  225. package/dist/esm/index-DNz_w3-G.mjs +174 -0
  226. package/dist/esm/{index-Cp1MRWbr.mjs → index-DoasOxbi.mjs} +1 -1
  227. package/dist/esm/index.mjs +1 -1
  228. package/dist/esm/{internal-context-D4S2Sfvt.mjs → internal-context-Z-fyxadS.mjs} +1 -1
  229. package/dist/esm/internal.mjs +1 -1
  230. package/dist/esm/{paths-BzM95ysC.mjs → paths-3HW55qZg.mjs} +1 -1
  231. package/dist/esm/prepareFundingModalData-DjTxAoJ1.mjs +1 -0
  232. package/dist/esm/reservoir-0wfhnc0j.mjs +1 -0
  233. package/dist/esm/{shared-C0CllI3K.mjs → shared-DwO5pr5t.mjs} +1 -1
  234. package/dist/esm/shouldProceedtoEmbeddedWalletCreationFlow-Cv_C9s3_.mjs +1 -0
  235. package/dist/esm/smart-wallets-9LKzbfWj.mjs +1 -0
  236. package/dist/esm/smart-wallets.mjs +1 -1
  237. package/dist/esm/solana.mjs +1 -1
  238. package/dist/esm/{styles-Fji1ReGu.mjs → styles-BNn7MnP1.mjs} +1 -1
  239. package/dist/esm/to-ui-error-CCqAdorW.mjs +4 -0
  240. package/dist/esm/ui.mjs +37 -37
  241. package/dist/esm/use-export-wallet-DllHf-2F.mjs +1 -0
  242. package/dist/esm/{use-sign-with-user-signer--95w9BaG.mjs → use-sign-with-user-signer-Do5Oi_rb.mjs} +1 -1
  243. package/dist/esm/useActiveWallet-RZ4w-uGq.mjs +185 -0
  244. package/dist/esm/{useGetSolPrice-usp7QcwI.mjs → useGetSolPrice-DwwjjGbd.mjs} +1 -1
  245. package/dist/esm/{useGetTokenPrice-DgKSvh6T.mjs → useGetTokenPrice-DERdsrmf.mjs} +1 -1
  246. package/dist/esm/{useI18n-DleS41MU.mjs → useI18n-Dk9y58cU.mjs} +1 -1
  247. package/dist/esm/usePrivy-Dj52a5sp.mjs +1 -0
  248. package/dist/esm/useSolanaRpcClient-B7UDPdLi.mjs +1 -0
  249. package/dist/esm/useWalletBalance-CRXiZUj2.mjs +1 -0
  250. package/dist/esm/useWallets-DlGuNtGR.mjs +1 -0
  251. package/dist/esm/useWallets-cSQYA-Jk.mjs +1 -0
  252. package/package.json +6 -6
  253. package/dist/cjs/AccountNotFoundScreen-Clo67iWH.js +0 -1
  254. package/dist/cjs/AffirmativeConsentScreen-2FGovWDj.js +0 -6
  255. package/dist/cjs/AllowlistRejectionScreen-BLcPF2_b.js +0 -1
  256. package/dist/cjs/AuthenticateWithWalletScreen-ByOwd0gq.js +0 -1
  257. package/dist/cjs/AwaitingEvmToSolBridgingScreen-D_dh3tgw.js +0 -2
  258. package/dist/cjs/AwaitingExternalEthereumTransferScreen-CB4SnTRS.js +0 -2
  259. package/dist/cjs/AwaitingPasswordlessCodeScreen-D43lCvaw.js +0 -103
  260. package/dist/cjs/AwaitingSolToEvmBridgingScreen-ppOL2XCp.js +0 -2
  261. package/dist/cjs/CaptchaScreen-oTaZlLej.js +0 -1
  262. package/dist/cjs/CoinbaseOnrampStatusScreen-CO97CoDr.js +0 -16
  263. package/dist/cjs/ConnectEmailForm-DAA-nxD6.js +0 -3
  264. package/dist/cjs/ConnectLedgerScreen-3SrqHJBl.js +0 -9
  265. package/dist/cjs/ConnectOnlyLandingScreen-DkR-VnS2.js +0 -1
  266. package/dist/cjs/ConnectOnlyStatusScreen-Cafk-5gS.js +0 -1
  267. package/dist/cjs/ConnectOrCreateScreen-DttF-fCs.js +0 -1
  268. package/dist/cjs/ConnectionStatusScreen-BfU_d8ZK.js +0 -7
  269. package/dist/cjs/CrossAppAuthScreen-Bs_x-Isw.js +0 -1
  270. package/dist/cjs/CustomLandingScreenView-B93ZDqp2.js +0 -23
  271. package/dist/cjs/DelegatedActionsConsentScreen-Cx5lj2BJ.js +0 -1
  272. package/dist/cjs/DelegatedActionsRevokeScreen-BEucV6g6.js +0 -1
  273. package/dist/cjs/EmbeddedWalletConnectingScreen-BjZ_7QsX.js +0 -1
  274. package/dist/cjs/EmbeddedWalletCreatedScreen-CbmJzZZL.js +0 -1
  275. package/dist/cjs/EmbeddedWalletKeyExportScreen-CdMuowdD.js +0 -40
  276. package/dist/cjs/EmbeddedWalletOnAccountCreateScreen-C_EBP_oR.js +0 -1
  277. package/dist/cjs/EmbeddedWalletPasswordUpdateScreen-DQhHO_tI.js +0 -1
  278. package/dist/cjs/EmbeddedWalletPasswordUpdateSplashScreen-C1dTDHuI.js +0 -1
  279. package/dist/cjs/ErrorScreen-CPDISQKp.js +0 -4
  280. package/dist/cjs/FarcasterSignerStatusScreen-BYnokloK.js +0 -29
  281. package/dist/cjs/FundSolWalletWithExternalSolanaWallet-D-pMJTgQ.js +0 -2
  282. package/dist/cjs/FundingEditAmountScreen-CGYBcgzY.js +0 -1
  283. package/dist/cjs/FundingMethodSelectionScreen-32rXIiuR.js +0 -1
  284. package/dist/cjs/InAppBrowserLoginNotPossible-Wz6tWwN4.js +0 -1
  285. package/dist/cjs/InstallWalletScreen-C6na1HMV.js +0 -1
  286. package/dist/cjs/LandingScreen-GYoGjPT7.js +0 -1
  287. package/dist/cjs/LinkEmailScreen-Bz6DBn1S.js +0 -1
  288. package/dist/cjs/LinkPhoneScreen-BFB7atSV.js +0 -1
  289. package/dist/cjs/LoginFailedScreen-C3X4o4W8.js +0 -1
  290. package/dist/cjs/ManualTransferScreen-Bx5GRcIk.js +0 -1
  291. package/dist/cjs/MfaAuthEnrollmentFlowScreen-D8DE5e8S.js +0 -1
  292. package/dist/cjs/MfaAuthVerifyFlowScreen-BeJSdbHB.js +0 -1
  293. package/dist/cjs/MfaEnrollmentFlowScreen-0X-6htEq.js +0 -1
  294. package/dist/cjs/MfaVerifyFlowScreen-BgdY97r7.js +0 -1
  295. package/dist/cjs/OAuthStatusScreen-DZbrwgcX.js +0 -1
  296. package/dist/cjs/PasskeySelectSignupOrLogin-DWW-VE2d.js +0 -1
  297. package/dist/cjs/PasskeyStatusScreen-DiieGaFn.js +0 -3
  298. package/dist/cjs/PasswordRecoveryScreen-OhRzyQhB.js +0 -20
  299. package/dist/cjs/RecoveryOAuthStatusScreen-DPPwIU7C.js +0 -1
  300. package/dist/cjs/RecoveryPasswordCreateScreen-Bg-E6CB6.js +0 -1
  301. package/dist/cjs/RecoverySelectionScreen-CauE_byN.js +0 -7
  302. package/dist/cjs/SetAutomaticRecoveryScreen-59UByZZC.js +0 -14
  303. package/dist/cjs/SignRequestScreen-CYQvIjLY.js +0 -26
  304. package/dist/cjs/TelegramAuthScreen-DxghStcs.js +0 -1
  305. package/dist/cjs/TransferFromWalletScreen-DSMlo8kv.js +0 -31
  306. package/dist/cjs/TransferOrBridgeLoadingScreen-D9t_WQ5r.js +0 -6
  307. package/dist/cjs/UpdateEmailScreen-CrTIJ16u.js +0 -1
  308. package/dist/cjs/UpdatePhoneScreen-DQzmlkOL.js +0 -1
  309. package/dist/cjs/UserLimitReachedScreen-BQxNahAD.js +0 -1
  310. package/dist/cjs/WalletLink-Bg4We2eg.js +0 -22
  311. package/dist/cjs/WalletOverflowButton-aYewWDKS.js +0 -1
  312. package/dist/cjs/ethers-BlKEtatO.js +0 -1
  313. package/dist/cjs/frame-BmNfc9mp.js +0 -1
  314. package/dist/cjs/getErc20Balance-CP3UfGGz.js +0 -1
  315. package/dist/cjs/getErc20TokenInfo-CVfH_czS.js +0 -1
  316. package/dist/cjs/index-LczlN1Dt.js +0 -12
  317. package/dist/cjs/private-privy-provider-hH9v0z7o.js +0 -358
  318. package/dist/cjs/shouldProceedtoEmbeddedWalletCreationFlow-Cp0BucAr.js +0 -1
  319. package/dist/cjs/smart-wallets-DUl8PaqV.js +0 -1
  320. package/dist/cjs/state-DMsGOICm.js +0 -1
  321. package/dist/cjs/stripUrlOAuthParamsAndRemoveStateCode-2iUOCDfo.js +0 -1
  322. package/dist/cjs/to-ui-error-caFMQ6I1.js +0 -4
  323. package/dist/cjs/use-create-wallet-without-fallback-CrxEFfhb.js +0 -1
  324. package/dist/cjs/use-export-wallet-DeI8q3KQ.js +0 -1
  325. package/dist/cjs/useActiveWallet-BySNV0ev.js +0 -1
  326. package/dist/cjs/useLogout-zT9OSxoO.js +0 -1
  327. package/dist/cjs/useMfa-KC6CWm9H.js +0 -1
  328. package/dist/cjs/useMfaEnrollment-DA9sTwf_.js +0 -1
  329. package/dist/cjs/useWalletBalance-8waYUAmD.js +0 -1
  330. package/dist/cjs/useWallets-2ejSMVGq.js +0 -1
  331. package/dist/esm/AccountNotFoundScreen-Cn6aKFIC.mjs +0 -1
  332. package/dist/esm/Address-CDF4d_Ha.mjs +0 -17
  333. package/dist/esm/AffirmativeConsentScreen-DwMHTAWp.mjs +0 -6
  334. package/dist/esm/AllowlistRejectionScreen-CtVeBy5G.mjs +0 -1
  335. package/dist/esm/AuthenticateWithWalletScreen-CqqsqfqZ.mjs +0 -1
  336. package/dist/esm/AwaitingEvmToSolBridgingScreen-CLkDS6o-.mjs +0 -2
  337. package/dist/esm/AwaitingExternalEthereumTransferScreen-Is2FdGJS.mjs +0 -2
  338. package/dist/esm/AwaitingPasswordlessCodeScreen-CAwXjOBS.mjs +0 -103
  339. package/dist/esm/AwaitingSolToEvmBridgingScreen-BDhpWAv1.mjs +0 -2
  340. package/dist/esm/BridgeNetworkSelectionView-C5xaiL3n.mjs +0 -69
  341. package/dist/esm/CaptchaScreen-CZCosLCJ.mjs +0 -1
  342. package/dist/esm/CoinbaseOnrampStatusScreen-DxbYHDRy.mjs +0 -16
  343. package/dist/esm/ConnectEmailForm-c2xnQzqc.mjs +0 -3
  344. package/dist/esm/ConnectLedgerScreen-CmspFZG8.mjs +0 -9
  345. package/dist/esm/ConnectOnlyLandingScreen-JXhxU6Je.mjs +0 -1
  346. package/dist/esm/ConnectOnlyStatusScreen-CZO6dxUB.mjs +0 -1
  347. package/dist/esm/ConnectOrCreateScreen-DHwSpwLa.mjs +0 -1
  348. package/dist/esm/ConnectionStatusScreen-d8tOwFAz.mjs +0 -7
  349. package/dist/esm/CrossAppAuthScreen-CNvQYKBN.mjs +0 -1
  350. package/dist/esm/CustomLandingScreenView-82pnUZOi.mjs +0 -23
  351. package/dist/esm/DelegatedActionsConsentScreen-D2cB2Jqt.mjs +0 -1
  352. package/dist/esm/DelegatedActionsRevokeScreen-DIdnDrIo.mjs +0 -1
  353. package/dist/esm/EmbeddedWalletConnectingScreen-DNDkMjZg.mjs +0 -1
  354. package/dist/esm/EmbeddedWalletCreatedScreen-6rmCkBPR.mjs +0 -1
  355. package/dist/esm/EmbeddedWalletKeyExportScreen-CrrImf0B.mjs +0 -40
  356. package/dist/esm/EmbeddedWalletOnAccountCreateScreen-MTCypdEY.mjs +0 -1
  357. package/dist/esm/EmbeddedWalletPasswordUpdateScreen-o-ONaPrc.mjs +0 -1
  358. package/dist/esm/EmbeddedWalletPasswordUpdateSplashScreen-BpRZwJZg.mjs +0 -1
  359. package/dist/esm/ErrorScreen-C891Rurl.mjs +0 -4
  360. package/dist/esm/FarcasterSignerStatusScreen-P3NEju7D.mjs +0 -28
  361. package/dist/esm/FundSolWalletWithExternalSolanaWallet-CGZdr_3E.mjs +0 -1
  362. package/dist/esm/FundingEditAmountScreen-B0MYigL_.mjs +0 -1
  363. package/dist/esm/FundingMethodSelectionScreen-CNJYvozR.mjs +0 -1
  364. package/dist/esm/InAppBrowserLoginNotPossible-CVyW-cIh.mjs +0 -1
  365. package/dist/esm/InstallWalletScreen-Bfo00Txs.mjs +0 -1
  366. package/dist/esm/LandingScreen-tAGl1tss.mjs +0 -1
  367. package/dist/esm/LinkEmailScreen-C_G_4bbm.mjs +0 -1
  368. package/dist/esm/LinkPasskeyScreen-DhD51WvM.mjs +0 -105
  369. package/dist/esm/LinkPhoneScreen-Bi5gcAMm.mjs +0 -1
  370. package/dist/esm/LoginFailedScreen-DbAdNYji.mjs +0 -1
  371. package/dist/esm/ManualTransferScreen-CR2QvdVh.mjs +0 -1
  372. package/dist/esm/MfaAuthEnrollmentFlowScreen-BEotfobF.mjs +0 -1
  373. package/dist/esm/MfaAuthVerifyFlowScreen-Cygjr5sH.mjs +0 -1
  374. package/dist/esm/MfaEnrollmentFlowScreen-jupYBcsQ.mjs +0 -1
  375. package/dist/esm/MfaVerifyFlowScreen-B8ONcY5T.mjs +0 -1
  376. package/dist/esm/MoonpayStatusScreen-BjmXS-jc.mjs +0 -16
  377. package/dist/esm/OAuthStatusScreen-YcgvWTtC.mjs +0 -1
  378. package/dist/esm/PasskeySelectSignupOrLogin-Db4EFSYE.mjs +0 -1
  379. package/dist/esm/PasskeyStatusScreen-CR-3RNXX.mjs +0 -3
  380. package/dist/esm/PasswordRecoveryScreen-BnD1OdcX.mjs +0 -20
  381. package/dist/esm/RecoveryOAuthStatusScreen-DhLx5fOQ.mjs +0 -1
  382. package/dist/esm/RecoveryPasswordCreateScreen-BHOh-fE-.mjs +0 -1
  383. package/dist/esm/RecoverySelectionScreen-1seYQLsM.mjs +0 -7
  384. package/dist/esm/SetAutomaticRecoveryScreen-CZLgLNlt.mjs +0 -14
  385. package/dist/esm/SignRequestScreen-EwmYkZZk.mjs +0 -26
  386. package/dist/esm/TelegramAuthScreen-BMWr2M6a.mjs +0 -1
  387. package/dist/esm/TransactionErrorView-CcY_O062.mjs +0 -166
  388. package/dist/esm/TransferFromWalletScreen-BTsyTZMc.mjs +0 -31
  389. package/dist/esm/TransferOrBridgeLoadingScreen-DZ1diPi7.mjs +0 -6
  390. package/dist/esm/UpdateEmailScreen-DyXsKvGA.mjs +0 -1
  391. package/dist/esm/UpdatePhoneScreen-erzZ8qOI.mjs +0 -1
  392. package/dist/esm/UserLimitReachedScreen-CfiHSh4t.mjs +0 -1
  393. package/dist/esm/WalletInterstitialScreen-DCg6fl5S.mjs +0 -1
  394. package/dist/esm/WalletLink-CTp4jR2d.mjs +0 -22
  395. package/dist/esm/WalletOverflowButton-i2nGLvV0.mjs +0 -1
  396. package/dist/esm/context-i_OKSUqt.mjs +0 -1
  397. package/dist/esm/ethers-Cr0T35kS.mjs +0 -1
  398. package/dist/esm/get-is-unified-wallet-Bon2jknh.mjs +0 -1
  399. package/dist/esm/getErc20Balance-BDNkB-EL.mjs +0 -1
  400. package/dist/esm/getErc20TokenInfo-79BQbhYn.mjs +0 -1
  401. package/dist/esm/private-privy-provider-B2_rZ8aq.mjs +0 -358
  402. package/dist/esm/reservoir-DNdkSA7R.mjs +0 -1
  403. package/dist/esm/shouldProceedtoEmbeddedWalletCreationFlow-CDHNJbN9.mjs +0 -1
  404. package/dist/esm/smart-wallets-BNt96zAq.mjs +0 -1
  405. package/dist/esm/state-BG13el3v.mjs +0 -1
  406. package/dist/esm/stripUrlOAuthParamsAndRemoveStateCode-9jsyCRfN.mjs +0 -1
  407. package/dist/esm/to-ui-error-C46oK5ox.mjs +0 -4
  408. package/dist/esm/use-create-wallet-without-fallback-CY32SGw2.mjs +0 -1
  409. package/dist/esm/use-export-wallet-CWry8VMl.mjs +0 -1
  410. package/dist/esm/useActiveWallet-D-T43q8N.mjs +0 -1
  411. package/dist/esm/useLogout-CHtNPDaK.mjs +0 -1
  412. package/dist/esm/useMfa-D20h0FBp.mjs +0 -1
  413. package/dist/esm/useMfaEnrollment-BOyHpB2c.mjs +0 -1
  414. package/dist/esm/useSolanaRpcClient-O9yIYVIZ.mjs +0 -1
  415. package/dist/esm/useWalletBalance-CMO_I7jz.mjs +0 -1
  416. package/dist/esm/useWallets-B3ZcS4km.mjs +0 -1
@@ -1,358 +0,0 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("mipd"),r=require("react"),n=require("react-device-detect"),i=require("viem/utils"),a=require("@privy-io/js-sdk-core"),o=require("@privy-io/popup"),s=require("./internal-context-NWsAL807.js"),l=require("./paths-DizMb-lU.js"),c=require("@scure/base"),d=require("viem"),u=require("uuid"),h=require("jose"),p=require("./get-is-unified-wallet-DL_nMXp5.js"),y=require("eventemitter3"),w=require("zustand"),m=require("./context-P14IM76D.js"),v=require("@coinbase/wallet-sdk"),g=require("@walletconnect/ethereum-provider"),f=require("ofetch"),E=require("js-cookie"),C=require("styled-components"),A=require("./events-context-Di6--rDg.js"),P=require("@headlessui/react"),T=require("@privy-io/ethereum"),_=require("@privy-io/urls");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function k(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var S=/*#__PURE__*/b(r),I=/*#__PURE__*/k(n),x=/*#__PURE__*/k(h),W=/*#__PURE__*/b(y),U=/*#__PURE__*/b(E);class O{static parse(e){try{return new O(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return x.decodeJwt(e),e}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){return Date.now()>=1e3*(this.expiration-e)}constructor(e){this.value=e,this._decoded=x.decodeJwt(e)}}class R extends O{static parse(e){try{return new R(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}const N=w.create((()=>({listings:[],loading:!1}))),M=N.setState,D=e=>{let t;try{t=new URL(e).hostname}catch(e){return}return N.getState().listings.find((({homepage:e})=>{let r;try{r=new URL(e).hostname}catch(e){return!1}return t.includes(r)}))},L=(e=!0)=>{let t=m.useAppConfig(),n=N((e=>e.listings)),i=N((e=>e.loading)),a=!!n.length;return r.useEffect((()=>{e&&!a&&(M({listings:[],loading:!0}),(async e=>{let t=new URL("v3/wallets","https://explorer-api.walletconnect.com");t.searchParams.append("projectId",e);let r=await fetch(t);return r.ok?Object.values((await r.json()).listings).sort((({slug:e},{slug:t})=>"rainbow"===e&&"metamask"===t?1:"metamask"===e||"rainbow"===e?-1:1)):(console.debug(`Failed to fetch WalletConnect listings: ${await r.text().catch((()=>"No response."))}`),[])})(t.walletConnectCloudProjectId).then((e=>M({listings:e,loading:!1}))).catch((e=>{console.error(e),M({listings:[],loading:!1})})))}),[e,a,t.walletConnectCloudProjectId]),{listings:n,loading:i}};function F(e){return"cryptocom"===e?"cryptocom-defi":"binance"===e?"binance-defi":e.replace(/[-_]wallet$/,"")}function j(e){return["wallet_connect","backpack","binance","binanceus","bitget_wallet","bybit_wallet","cryptocom","haha_wallet","jupiter","metamask","okx_wallet","phantom","rabby_wallet","rainbow","ronin_wallet","safe","solflare","uniswap","zerion","kraken_wallet"].some((t=>e?.includes(t)))}const q=e=>e.isApexWallet?"Apex Wallet":e.isAvalanche?"Core Wallet":e.isBackpack?"Backpack":e.isBifrost?"Bifrost Wallet":e.isBitKeep?"BitKeep":e.isBitski?"Bitski":e.isBlockWallet?"BlockWallet":e.isBraveWallet?"Brave Wallet":e.isClover?"Clover":e.isCoin98?"Coin98 Wallet":e.isCoinbaseWallet?"Coinbase Wallet":e.isDawn?"Dawn Wallet":e.isDefiant?"Defiant":e.isDesig?"Desig Wallet":e.isEnkrypt?"Enkrypt":e.isExodus?"Exodus":e.isFordefi?"Fordefi":e.isFrame?"Frame":e.isFrontier?"Frontier Wallet":e.isGamestop?"GameStop Wallet":e.isHaqqWallet?"HAQQ Wallet":e.isHyperPay?"HyperPay Wallet":e.isImToken?"ImToken":e.isHaloWallet?"Halo Wallet":e.isKuCoinWallet?"KuCoin Wallet":e.isMathWallet?"MathWallet":e.isNovaWallet?"Nova Wallet":e.isOkxWallet||e.isOKExWallet?"OKX Wallet":e.isOneInchIOSWallet||e.isOneInchAndroidWallet?"1inch Wallet":e.isOneKey?"OneKey Wallet":e.isOpera?"Opera":e.isPhantom||"isPhantom"in e?"Phantom":e.isPortal?"Ripio Portal":e.isRabby?"Rabby Wallet":e.isRainbow?"Rainbow":e.isSafePal?"SafePal Wallet":e.isStatus?"Status":e.isSubWallet?"SubWallet":e.isTalisman?"Talisman":e.isTally||e.isTaho?"Taho":e.isTokenPocket?"TokenPocket":e.isTokenary?"Tokenary":e.isTrust||e.isTrustWallet?"Trust Wallet":e.isTTWallet?"TTWallet":e.isXDEFI?"XDEFI Wallet":e.isZeal?"Zeal":e.isZerion?"Zerion":e.isMetaMask?"MetaMask":void 0,z=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||"MetaMask"!==q(e))return!1;if(e.providers)for(let t of e.providers)if(!z(t))return!1;return!0},K=(e,t,r,n)=>{let i=Number(e),a=t.find((e=>e.id===i));if(!a)throw new s.PrivyConnectorError(`Unsupported chainId ${e}`,4901);return d.createPublicClient({transport:d.http(B(a,r,n.appId)),chain:a})},B=(e,t,r)=>{let n,i=e.id,a=Number(e.id);if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])n=e.rpcUrls.privyWalletOverride.http[0];else if(t.rpcUrls&&t.rpcUrls[a])n=t.rpcUrls[a];else if(e.rpcUrls.privy?.http[0]){let t=new URL(e.rpcUrls.privy.http[0]);t.searchParams.append("privyAppId",r),n=t.toString()}else n=e.rpcUrls.public?.http[0]?e.rpcUrls.public.http[0]:e.rpcUrls.default?.http[0];if(!n)throw new s.PrivyConnectorError(`No RPC url found for ${i}`);return n},H=(e,t=3,r=4,n="ethereum")=>{if(!e)return"";let i="ethereum"===n?2:0;return t+r+i+3>=e.length?e:`${e.slice(0,i+t)}...${e.slice(e.length-r,e.length)}`},V=e=>new Promise((t=>setTimeout(t,e)));function Y(e,{interval:t=100,timeout:r=5e3}={}){return new Promise(((n,i)=>{let a,o=0,s=()=>{o>=r?i("Max attempts reached without result"):(a=e(),o+=t,null==a?setTimeout(s,t):n(a))};s()}))}const $=(e,t={})=>{let r=t.delayMs||150,n=t.maxAttempts||270;return new Promise((async(i,a)=>{let o=!1,s=0;for(;!o&&s<n;){if(t.abortSignal?.aborted)return;e().then((e=>{o=!0,i(e)}),((...e)=>{o=!0,a(...e)})),s+=1,await V(r)}o||a(Error("Exceeded max attempts before resolving function"))}))},G=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),J=e=>"string"==typeof e?e:"0x"+e.toString(16);async function Z({store:e,walletList:t,externalWalletConfig:r,walletChainType:n,timeout:i=3e3}){let a=!1,o=window;return new Promise((s=>{function l(){if(a)return;a=!0,window.removeEventListener("ethereum#initialized",l);let i=e.getProviders();console.debug("Detected injected providers:",i.map((e=>e.info)));let o=[];for(let e of i)t.includes("coinbase_wallet")&&"com.coinbase.wallet"===e.info.rdns||"solana-only"===n&&"app.phantom"===e.info.rdns||o.push({type:e.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:e});if("solana-only"!==n)for(let e of function(){let e=window,t=e.ethereum;if(!t)return[];let r=[];if(t.providers?.length)for(let e of t.providers)e&&r.push(e);return r.push(e.ethereum),r}()){let t=q(e);if(!i.some((e=>e.info.name===t))){if(z(e,!0)&&!o.find((e=>"metamask"===e.type))){o.push({type:"metamask",legacyInjectedProvider:e});continue}if("Phantom"===t&&!o.find((e=>"phantom"===e.type))){o.push({type:"phantom",legacyInjectedProvider:e});continue}if("Coinbase Wallet"===t&&!o.find((e=>"coinbase_wallet"===e.type&&"smartWalletOnly"!==r.coinbaseWallet?.config?.preference?.options))){o.push({type:"coinbase_wallet",legacyInjectedProvider:e});continue}o.find((e=>"unknown_browser_extension"===e.type))||o.push({type:"unknown_browser_extension",legacyInjectedProvider:e})}}s(o)}o.ethereum?l():(window.addEventListener("ethereum#initialized",l,{once:!0}),setTimeout((()=>{l()}),i))}))}function Q(e){return`eip155:${String(Number(e))}`}const X=(e,t,r,n)=>{let i=Number(e),a=t.find((e=>e.id===i));if(!a)throw new s.PrivyConnectorError(`Unsupported chainId ${e}`,4901);return B(a,r,n)},ee=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},r=e.types.EIP712Domain??Object.entries(e.domain).map((([e,r])=>{if(null!=r&&"string"==typeof e&&e in t)return{name:e,type:t[e]}})).filter((e=>void 0!==e));return{...e,types:{...e.types,EIP712Domain:r}}};const te="data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PScwIDAgMTAyNCAxMDI0JyBmaWxsPSdub25lJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHN0eWxlPSdoZWlnaHQ6MjhweDt3aWR0aDoyOHB4Jz48cmVjdCB3aWR0aD0nMTAyNCcgaGVpZ2h0PScxMDI0JyBmaWxsPScjMDA1MkZGJyByeD0nMTAwJyByeT0nMTAwJz48L3JlY3Q+PHBhdGggZmlsbC1ydWxlPSdldmVub2RkJyBjbGlwLXJ1bGU9J2V2ZW5vZGQnIGQ9J00xNTIgNTEyQzE1MiA3MTAuODIzIDMxMy4xNzcgODcyIDUxMiA4NzJDNzEwLjgyMyA4NzIgODcyIDcxMC44MjMgODcyIDUxMkM4NzIgMzEzLjE3NyA3MTAuODIzIDE1MiA1MTIgMTUyQzMxMy4xNzcgMTUyIDE1MiAzMTMuMTc3IDE1MiA1MTJaTTQyMCAzOTZDNDA2Ljc0NSAzOTYgMzk2IDQwNi43NDUgMzk2IDQyMFY2MDRDMzk2IDYxNy4yNTUgNDA2Ljc0NSA2MjggNDIwIDYyOEg2MDRDNjE3LjI1NSA2MjggNjI4IDYxNy4yNTUgNjI4IDYwNFY0MjBDNjI4IDQwNi43NDUgNjE3LjI1NSAzOTYgNjA0IDM5Nkg0MjBaJyBmaWxsPSd3aGl0ZSc+PC9wYXRoPjwvc3ZnPg==",re="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAALZJREFUaEPtmjEOhDAMBNc/O14GvOzys3CAKK6eAlmaVGl2Zc+kTOU685vkc9/bnD2prZK5/TZY24z9P+g4F5hNh7/GdoG37WlAA5CATwgCxHENYISwQAMQII5rACOEBRqAAHFcAxghLNAABIjjGsAIYYEGIEAc1wBGCAs0AAHiuAYwQligAQgQxzWAEcICDUCAOK4BjBAWaAACxHENYISwQAMQII6fBjr+VHkW3+u+tfyxMpJaDgYzYxb/ALZVAAAAAElFTkSuQmCC";class ne extends s.PrivyConnectorError{constructor(){super("Wallet timeout"),this.type="wallet_error"}}const ie=e=>e instanceof s.PrivyConnectorError?e:e?.code?new oe(e):new s.PrivyConnectorError("Unknown connector error",e);class ae extends s.PrivyError{constructor(e,t,r){super(e),this.type="provider_error",this.code=t,this.data=r}}class oe extends ae{constructor(e){super(e.message,e.code,e.data);let t=Object.values(a.ProviderErrors).find((t=>t.eipCode===e.code));this.details=t||a.ProviderErrors.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=a.ProviderErrors.E32002_CONNECTION_ALREADY_PENDING:this.details=a.ProviderErrors.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=a.ProviderErrors.E32002_WALLET_LOCKED))}}const se={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_LIMIT_REACHED:{message:"Unable to link",detail:"You've reached the maximum number of linked wallets.",retryable:!1},...a.ProviderErrors};class le{get(e){let t=localStorage.getItem(e);return null===t?void 0:JSON.parse(t)}put(e,t){void 0!==t?localStorage.setItem(e,JSON.stringify(t)):this.del(e)}del(e){localStorage.removeItem(e)}getKeys(){return Object.entries(localStorage).map((([e])=>e))}}function ce(){try{let e="privy:__session_storage__test",t=new le;return t.put(e,"blobby"),t.del(e),!0}catch(e){return!1}}var de="undefined"!=typeof window&&window.localStorage?new le:new class{get(e){return this._cache[e]}put(e,t){void 0!==t?this._cache[e]=t:this.del(e)}del(e){delete this._cache[e]}getKeys(){return Object.keys(this._cache)}constructor(){this._cache={}}};function ue(e){return"ethereum"===e.type}function he(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){let n=e[r],i=t[r];if(n?.address!==i?.address||n&&i&&ue(n)&&ue(i)&&n?.chainId!==i?.chainId||n?.connectorType!==i?.connectorType||n?.connectedAt!==i?.connectedAt||n?.walletClientType!==i?.walletClientType||n?.isConnected!==i?.isConnected||n?.linked!==i?.linked)return!1}return!0}class pe extends W.default{constructor(e){super(),this.walletClientType=e,this.connected=!1,this.initialized=!1}}const ye=(e,t)=>e.rpcTimeouts&&e.rpcTimeouts[t]||m.DEFAULT_RPC_TIMEOUT;let we,me;function ve(e){return"ethereum"===e.chainType}class ge extends pe{buildConnectedWallet(e,t,r,n){let a=async()=>!!this.wallets.find((t=>i.getAddress(t.address)===i.getAddress(e)));return{type:"ethereum",address:i.getAddress(e),chainId:t,meta:r,imported:n,switchChain:async r=>{let n,o;if(!a)throw new s.PrivyConnectorError("Wallet is not currently connected.");let l=this.wallets.find((t=>i.getAddress(t.address)===i.getAddress(e)))?.chainId;if(!l)throw new s.PrivyConnectorError("Unable to determine current chainId.");if("number"==typeof r?(n=`0x${r.toString(16)}`,o=r):(n=r,o=Number(r)),l===Q(n))return;let c=this.chains.find((e=>e.id===o));if(!c)throw new s.PrivyConnectorError(`Unsupported chainId: ${r}`);let d=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:n}]})};try{return await d()}catch(e){if(((e,t)=>{switch(t){case"coinbase_wallet":case"base_account":return e.message.includes("addEthereumChain");case"rabby_wallet":return e.message.includes("Unrecognized chain ID");default:return 4902===e.code||e.message?.includes("4902")}})(e,this.walletClientType))return"rabby_wallet"===this.walletClientType&&await V(300),await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:n,chainName:c.name,nativeCurrency:c.nativeCurrency,rpcUrls:[c.rpcUrls.default?.http[0]??""],blockExplorerUrls:[c.blockExplorers?.default.url??""]}]}),d();if("rainbow"===this.walletClientType&&e.message?.includes("wallet_switchEthereumChain"))throw new s.PrivyConnectorError(`Rainbow does not support the chainId ${t}`);throw e}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:a,getEthereumProvider:async()=>{if(!await a())throw new s.PrivyConnectorError("Wallet is not currently connected.");return this.proxyProvider},sign:async e=>{if(!await a())throw new s.PrivyConnectorError("Wallet is not currently connected.");return await this.sign(e)},disconnect:()=>{this.disconnect()}}}async syncAccounts(e){let t,r=e;try{if(void 0===r){let e=await $((()=>this.proxyProvider.request({method:"eth_accounts"})),{maxAttempts:10,delayMs:500});console.debug(`eth_accounts for ${this.walletClientType}:`,e),Array.isArray(e)&&(r=e)}}catch(e){console.debug("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.",e)}if(!r||!Array.isArray(r)||r.length<=0||!r[0])return;let n=r[0];if(!d.isAddress(n))return void console.warn(`Invalid ethereum address reported by ${this.walletClientType}: ${n}`);let a=i.getAddress(n),o=[];if("privy"===this.walletClientType){let e=de.get(m.getPrivyWalletKey(a));this.chains.find((t=>t.id===Number(e)))||(de.del(m.getPrivyWalletKey(a)),e=null),t=e||`0x${this.defaultChain.id.toString(16)}`;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:t}]})}catch(e){console.warn(`Unable to switch embedded wallet to chain ID ${t} on initialization`)}}else try{let e=await $((()=>this.proxyProvider.request({method:"eth_chainId"})),{maxAttempts:10,delayMs:500});if(console.debug(`eth_chainId for ${this.walletClientType}:`,e),"string"==typeof e)t=e;else{if("number"!=typeof e)throw Error("Invalid chainId returned from provider");t=`0x${e.toString(16)}`}}catch(e){console.warn(`Failed to get chainId from provider, defaulting to ${m.DEFAULT_NETWORK}`,e),t=m.DEFAULT_NETWORK}let s=Q(t);if(!o.find((e=>i.getAddress(e.address)===a))){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};o.push(this.buildConnectedWallet(i.getAddress(n),s,e,"embedded_imported"===this.connectorType))}he(o,this.wallets)||(this.wallets=o,this.emit("walletsUpdated"))}async getConnectedWallet(){let e=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt)).find((t=>e.find((e=>i.getAddress(e)===i.getAddress(t.address)))))||null}async isConnected(){let e=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(e)&&e.length>0}async sign(e){return await this.connect({showPrompt:!1}),this.proxyProvider.request({method:"personal_sign",params:[i.toHex(e),this.wallets[0]?.address]})}subscribeListeners(){this.proxyProvider.on("accountsChanged",this.onAccountsChanged),this.proxyProvider.on("chainChanged",this.onChainChanged),this.proxyProvider.on("disconnect",this.onDisconnect),this.proxyProvider.on("connect",this.onConnect)}unsubscribeListeners(){this.proxyProvider.removeListener("accountsChanged",this.onAccountsChanged),this.proxyProvider.removeListener("chainChanged",this.onChainChanged),this.proxyProvider.removeListener("disconnect",this.onDisconnect),this.proxyProvider.removeListener("connect",this.onConnect)}constructor(e,t,r,n){super(e),this.chainType="ethereum",this.onAccountsChanged=e=>{0===e.length?this.onDisconnect():this.syncAccounts(e)},this.onChainChanged=e=>{this.wallets.forEach((t=>{t.chainId=Q(e),"privy"===this.walletClientType&&de.put(m.getPrivyWalletKey(t.address),e)})),this.emit("walletsUpdated")},this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")},this.onConnect=async()=>{"base_account"===this.connectorType&&this.connected||(this.connected=!0,"coinbase_wallet"===this.connectorType&&await V(500),this.syncAccounts())},this.wallets=[],this.walletClientType=e,this.chains=t,this.defaultChain=r,this.rpcConfig=n,this.rpcTimeoutDuration=ye(n,e),this.connected=!1,this.initialized=!1}}class fe{on(e,t){if(this.walletProvider)return this.walletProvider.on(e,t);this._subscriptions.push({eventName:e,listener:t})}async request(e){if(!this.walletProvider)throw new s.PrivyConnectorError(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),this.walletTimeout()]).catch((e=>{throw ie(e)}))}constructor(e,t){this.removeListener=(e,t)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(e,t)}catch(e){console.warn("Unable to remove wallet provider listener")}},this.walletTimeout=(e=new ne,t=this.rpcTimeoutDuration)=>new Promise(((r,n)=>setTimeout((()=>{n(e)}),t))),this.setWalletProvider=e=>{this.walletProvider&&this._subscriptions.forEach((e=>{this.removeListener(e.eventName,e.listener)})),this.walletProvider=e,this._subscriptions.forEach((e=>{this.walletProvider?.on(e.eventName,e.listener)}))},this.walletProvider=e,this.rpcTimeoutDuration=t||m.DEFAULT_RPC_TIMEOUT,this._subscriptions=[]}}class Ee extends ge{async initialize(){await this.importPromise,await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:re,id:"com.coinbase.wallet"}}async promptConnection(){try{await this.importPromise;let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new s.PrivyConnectorError("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw ie(e)}}constructor(e,t,r,n,i){super("base_account",e,t,r),this.connectorType="base_account",this.walletClientType="base_account",this.displayName="Base",this.setBaseAccountSdk=i,this.proxyProvider=new fe(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.baseAccountConfig={...n,appChainIds:[t.id].concat(e.map((e=>e.id)))},we?(this.proxyProvider.setWalletProvider(we.getProvider()),this.setBaseAccountSdk(we)):this.importPromise=import("@base-org/account").then((({createBaseAccountSDK:e})=>{we=e(this.baseAccountConfig),this.proxyProvider.setWalletProvider(we.getProvider()),this.setBaseAccountSdk(we)})).catch(console.error)}}let Ce=[1,11155111,137,10,8453,84532,42161,7777777,43114,56];class Ae extends ge{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:te,id:"com.coinbase.wallet"}}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new s.PrivyConnectorError("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw ie(e)}}updateConnectionPreference(e){this.coinbaseWalletConfig={...this.coinbaseWalletConfig,preference:{...this.coinbaseWalletConfig.preference,options:e}},this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",me=v.createCoinbaseWalletSDK({...this.coinbaseWalletConfig}),this.proxyProvider.setWalletProvider(me.getProvider())}constructor(e,t,r,n){if(super("coinbase_wallet",e,t,r),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new fe(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.coinbaseWalletConfig={...n,appChainIds:[t.id].concat(e.map((e=>e.id)))},this.walletClientType="smartWalletOnly"===this.coinbaseWalletConfig.preference?.options?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!me){let e="eoaOnly"!==this.coinbaseWalletConfig.preference?.options?(this.coinbaseWalletConfig.appChainIds??[]).filter((e=>!Ce.includes(e))):[];e.length>0&&!e.every((e=>a.DEFAULT_SUPPORTED_CHAIN_IDS.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${e.join(", ")}`),me=v.createCoinbaseWalletSDK(this.coinbaseWalletConfig)}this.proxyProvider.setWalletProvider(me.getProvider())}}class Pe extends ge{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the EthereumNullConnector")}disconnect(){throw Error("disconnect called for an uninstalled wallet via the EthereumNullConnector")}promptConnection(e){throw Error(`promptConnection called for an uninstalled wallet via the EthereumNullConnector for ${e}`)}constructor({id:e,name:t,icon:r,walletClientType:n,defaultChain:i}){super(n,[],i,{}),this.connectorType="null",this.proxyProvider=new fe(void 0,m.DEFAULT_RPC_TIMEOUT),this.id=e,this.name=t,this.icon=r}}const Te=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...t},...r,children:/*#__PURE__*/e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25"})}),_e=({...t})=>/*#__PURE__*/e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",...t,children:[/*#__PURE__*/e.jsx("rect",{width:"32",height:"32",rx:"6",fill:"#121314"}),/*#__PURE__*/e.jsx("g",{transform:"translate(4, 4)",children:/*#__PURE__*/e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 318.6 318.6",children:[/*#__PURE__*/e.jsx("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),/*#__PURE__*/e.jsx("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),/*#__PURE__*/e.jsx("path",{d:"m44.4 35.5 98.7 74.6-17.5-44.3zm193.9 171.3-26.5 40.6 56.7 15.6 16.3-55.3zm-204.4.9L50.1 263l56.7-15.6-26.5-40.6z",className:"s1 s2"}),/*#__PURE__*/e.jsx("path",{d:"m103.6 138.2-15.8 23.9 56.3 2.5-2-60.5zm111.3 0-39-34.8-1.3 61.2 56.2-2.5zM106.8 247.4l33.8-16.5-29.2-22.8zm71.1-16.5 33.9 16.5-4.7-39.3z",className:"s1 s2"}),/*#__PURE__*/e.jsx("path",{fill:"#d7c1b3",stroke:"#d7c1b3",className:"s1",d:"m211.8 247.4-33.9-16.5 2.7 22.1-.3 9.3zm-105 0 31.5 14.9-.2-9.3 2.5-22.1z"}),/*#__PURE__*/e.jsx("path",{fill:"#233447",stroke:"#233447",className:"s1",d:"m138.8 193.5-28.2-8.3 19.9-9.1zm40.9 0 8.3-17.4 20 9.1z"}),/*#__PURE__*/e.jsx("path",{fill:"#cd6116",stroke:"#cd6116",className:"s1",d:"m106.8 247.4 4.8-40.6-31.3.9zM207 206.8l4.8 40.6 26.5-39.7zm23.8-44.7-56.2 2.5 5.2 28.9 8.3-17.4 20 9.1zm-120.2 23.1 20-9.1 8.2 17.4 5.3-28.9-56.3-2.5z"}),/*#__PURE__*/e.jsx("path",{fill:"#e4751f",stroke:"#e4751f",className:"s1",d:"m87.8 162.1 23.6 46-.8-22.9zm120.3 23.1-1 22.9 23.7-46zm-64-20.6-5.3 28.9 6.6 34.1 1.5-44.9zm30.5 0-2.7 18 1.2 45 6.7-34.1z"}),/*#__PURE__*/e.jsx("path",{d:"m179.8 193.5-6.7 34.1 4.8 3.3 29.2-22.8 1-22.9zm-69.2-8.3.8 22.9 29.2 22.8 4.8-3.3-6.6-34.1z",className:"s3"}),/*#__PURE__*/e.jsx("path",{fill:"#c0ad9e",stroke:"#c0ad9e",className:"s1",d:"m180.3 262.3.3-9.3-2.5-2.2h-37.7l-2.3 2.2.2 9.3-31.5-14.9 11 9 22.3 15.5h38.3l22.4-15.5 11-9z"}),/*#__PURE__*/e.jsx("path",{fill:"#161616",stroke:"#161616",className:"s1",d:"m177.9 230.9-4.8-3.3h-27.7l-4.8 3.3-2.5 22.1 2.3-2.2h37.7l2.5 2.2z"}),/*#__PURE__*/e.jsx("path",{fill:"#763d16",stroke:"#763d16",className:"s1",d:"m278.3 114.2 8.5-40.8-12.7-37.9-96.2 71.4 37 31.3 52.3 15.3 11.6-13.5-5-3.6 8-7.3-6.2-4.8 8-6.1zM31.8 73.4l8.5 40.8-5.4 4 8 6.1-6.1 4.8 8 7.3-5 3.6 11.5 13.5 52.3-15.3 37-31.3-96.2-71.4z"}),/*#__PURE__*/e.jsx("path",{d:"m267.2 153.5-52.3-15.3 15.9 23.9-23.7 46 31.2-.4h46.5zm-163.6-15.3-52.3 15.3-17.4 54.2h46.4l31.1.4-23.6-46zm71 26.4 3.3-57.7 15.2-41.1h-67.5l15 41.1 3.5 57.7 1.2 18.2.1 44.8h27.7l.2-44.8z",className:"s3"})]})})]}),be=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M46.5267 69.9229C42.0054 76.8509 34.4292 85.6182 24.348 85.6182C19.5824 85.6182 15 83.6563 15 75.1342C15 53.4305 44.6326 19.8327 72.1268 19.8327C87.768 19.8327 94 30.6846 94 43.0079C94 58.8258 83.7355 76.9122 73.5321 76.9122C70.2939 76.9122 68.7053 75.1342 68.7053 72.314C68.7053 71.5783 68.8275 70.7812 69.0719 69.9229C65.5893 75.8699 58.8685 81.3878 52.5754 81.3878C47.993 81.3878 45.6713 78.5063 45.6713 74.4598C45.6713 72.9884 45.9768 71.4556 46.5267 69.9229ZM83.6761 42.5794C83.6761 46.1704 81.5575 47.9658 79.1875 47.9658C76.7816 47.9658 74.6989 46.1704 74.6989 42.5794C74.6989 38.9885 76.7816 37.1931 79.1875 37.1931C81.5575 37.1931 83.6761 38.9885 83.6761 42.5794ZM70.2103 42.5795C70.2103 46.1704 68.0916 47.9658 65.7216 47.9658C63.3157 47.9658 61.233 46.1704 61.233 42.5795C61.233 38.9885 63.3157 37.1931 65.7216 37.1931C68.0916 37.1931 70.2103 38.9885 70.2103 42.5795Z",fill:"#FFFDF8"})]});function ke(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var Se=0;class Ie extends ge{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:this.providerDetail.info.name,icon:this.providerDetail.info.icon,id:this.providerDetail.info.rdns}}disconnect(){console.warn(`Programmatic disconnect with ${this.providerDetail.info.name} is not yet supported.`)}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new s.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw ie(e)}}constructor(e,t,r,n,i){super(i||"unknown",e,t,r),this.connectorType="injected",this.proxyProvider=new fe(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=n;let a=n.provider;this.proxyProvider.setWalletProvider(a)}}var xe="__private_"+Se+++"__walletBranding";class We extends ge{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return ke(this,xe)[xe]??{name:"Browser Extension",icon:Te,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new s.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw ie(e)}}constructor(e,t,r,n,i){super(i??"unknown",e,t,r),Object.defineProperty(this,xe,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new fe(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(n),"metamask"===i?ke(this,xe)[xe]={name:"MetaMask",icon:_e,id:"io.metamask"}:"phantom"===i&&(ke(this,xe)[xe]={name:"Phantom",icon:be,id:"phantom"})}}class Ue extends Ie{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{n.isMobile||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new s.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw ie(e)}}}const Oe=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","crypto.com_wallet_extension","crypto.com_onchain","binance","bitget_wallet","coinbase_wallet","coinbase_smart_wallet","base_account","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitget_wallet","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","privy","unknown","phantom","solflare","glow","backpack","jupiter","mobile_wallet_adapter"],Re=Object.freeze({phantom:{client:"phantom",name:"Phantom",installLink:I.isFirefox?"https://addons.mozilla.org/en-US/firefox/addon/phantom-app/":"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en",chainTypes:["ethereum","solana"],get isInstalled(){if("phantom"in window){let e=window;if(e?.phantom?.ethereum?.isPhantom&&e?.phantom?.ethereum?.chainId||e?.phantom?.solana?.isPhantom)return!0}return!1},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=Me({client:this.client,isSolana:t,connectOnly:r});return`${e?"phantom://":"https://phantom.app/ul/"}browse/${n}?ref=${n}`}},solflare:{client:"solflare",name:"Solflare",installLink:I.isFirefox?"https://addons.mozilla.org/es/firefox/addon/solflare-wallet/":"https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic",chainTypes:["solana"],get isInstalled(){return"solflare"in window&&!!window?.solflare?.isSolflare},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=Me({client:this.client,isSolana:t,connectOnly:r});return`${e?"solflare://ul/v1/":"https://solflare.com/ul/v1/"}browse/${n}?ref=${n}`}},jupiter:{client:"jupiter",name:"Jupiter Wallet",installLink:"https://chromewebstore.google.com/detail/jupiter-wallet/iledlaeogohbilgbfhmbgkgmpplbfboh",chainTypes:["solana"],get isInstalled(){return"jupiter"in window&&!!window?.jupiter?.isJupiter},getMobileRedirect({isSolana:e,connectOnly:t}){let r=Me({client:this.client,isSolana:e,connectOnly:t});return`jupjupjup://jup.ag/browse/${r}?ref=${r}`}},backpack:{client:"backpack",name:"Backpack",installLink:"https://chromewebstore.google.com/detail/backpack/aflkmfhebedbjioipglgcbcmnbpgliof",chainTypes:["ethereum","solana"],get isInstalled(){return!(!("backpack"in window)||!window?.backpack?.ethereum?.isBackpack&&!window?.backpack?.solana?.isBackpack)},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:r}){let n=Me({client:this.client,isSolana:t,connectOnly:r});return`${e?"backpack://ul/v1/":"https://backpack.app/ul/v1/"}browse/${n}?ref=${n}`}},okx_wallet:{client:"okx_wallet",name:"OKX Wallet",installLink:"https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",chainTypes:["ethereum","solana"],get isInstalled(){return"okxwallet"in window&&!!window?.okxwallet?.isOkxWallet},getMobileRedirect({isSolana:e,connectOnly:t}){return`okx://wallet/dapp/url?dappUrl=${Me({client:this.client,isSolana:e,connectOnly:t})}`}}});function Ne({connectorType:e,walletClientType:t}){for(let r of Oe)if(e===r||t===r)return Re[r]}function Me({client:e,isSolana:t,connectOnly:r}){let n=new URL(window.location.href);return n.searchParams.set("privy_connector",t?"solana_adapter":"injected"),n.searchParams.set("privy_wallet_client",e),n.searchParams.set("privy_connect_only",String(r)),encodeURIComponent(n.href.replace(/\/$/g,""))}const De=()=>{let e=de.get(m.CONNECTIONS_HISTORY_KEY);return e&&Array.isArray(e)&&e.map((e=>(e=>e&&"string"==typeof e.address&&"string"==typeof e.connectorType&&"string"==typeof e.walletClientType&&"number"==typeof e.connectedAt)(e))).every(Boolean)?e:[]};let Le=["phantom","glow","solflare","backpack","okx_wallet","walletconnect","mobile_wallet_adapter","jupiter"];function Fe(e){return e.toLowerCase().split(" ").join("_")}class je extends pe{get isInstalled(){return!0}get wallet(){return this._wallet}buildConnectedWallet(){return this._wallet.accounts.map((e=>({type:"solana",provider:new a.ConnectedStandardSolanaWallet({wallet:this._wallet,account:e}),address:e.address,connectedAt:Date.now(),walletClientType:this._wallet.name,connectorType:this.connectorType,imported:!1,meta:{name:this._wallet.name,id:this._wallet.name,icon:this._wallet.icon},isConnected:async()=>this._wallet.accounts.length>0,disconnect:async()=>{await this.disconnect()}})))}async syncAccounts(){this.wallets=this.buildConnectedWallet(),this.emit("walletsUpdated")}get walletBranding(){return{id:qe(this.wallet)?"walletconnect_solana":this.wallet.name,name:this.wallet.name,icon:this.wallet.icon}}async initialize(){this.subscribeListeners(),await this.syncAccounts(),this.shouldAttemptAutoConnect()&&(await(this.wallet.features["standard:connect"]?.connect({silent:!0}).catch((()=>{}))),await this.isConnected()&&await this.syncAccounts()),this.initialized=!0,this.emit("initialized")}async connect(e){if(e.showPrompt)try{await this.promptConnection()}catch(e){if(0===this._wallet.accounts.length)throw new s.PrivyNoSolanaAccountsError;throw e}if(!await this.isConnected())throw new s.PrivyNoSolanaAccountsError;return await this.syncAccounts(),this.getConnectedWallet()}async getConnectedWallet(){return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt))[0]||null}async isConnected(){return this._wallet.accounts.length>0}subscribeListeners(){this._unsubscribeListeners=this.wallet.features["standard:events"]?.on("change",this.onChange)}unsubscribeListeners(){this._unsubscribeListeners?.()}shouldAttemptAutoConnect(){return!(!this.autoConnectEnabled||!Le.includes(this.walletClientType))&&("phantom"!==this.walletClientType&&"metamask"!==this.walletClientType.toLowerCase()||De().some((({walletClientType:e})=>"phantom"===e||"metamask"===e.toLowerCase())))}constructor(e,t){super(Fe(qe(e)?"walletconnect_solana":e.name)),this.chainType="solana",this.connectorType="solana_adapter",this.disconnect=async()=>{await(this.wallet.features["standard:disconnect"]?.disconnect().catch((e=>console.error("Error disconnecting",e)))),await this.syncAccounts()},this.promptConnection=async()=>{try{await(this.wallet.features["standard:connect"]?.connect())}catch(e){throw ie(e)}},this.onChange=()=>{this.syncAccounts()},this._wallet=e,this.autoConnectEnabled=t,this.wallets=[]}}function qe(e){return"isWalletConnectSolana"in e&&e.isWalletConnectSolana}class ze extends je{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the SolanaNullConnector")}constructor({id:e,name:t,icon:r}){super({name:t},!1),this.connectorType="null",this.proxyProvider=new fe(void 0,m.DEFAULT_RPC_TIMEOUT),this.disconnect=async()=>{throw Error("disconnect called for an uninstalled wallet via the SolanaNullConnector")},this.promptConnection=async()=>{throw Error("promptConnection called for an uninstalled wallet via the SolanaNullConnector")},this.id=e,this.name=t,this.icon=r}}function Ke(e){return{name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}function Be(e,t){let r=Ke(t);if(n.isMobile&&r.universalLink)return Ge(r.universalLink,e);if(r.deepLink)return $e(r.deepLink,e);if(r.universalLink)return Ge(r.universalLink,e);throw new s.PrivyClientError(`Unsupported wallet ${t.id}`)}function He(e,t){let r=Ke(t);if(r.universalLink)return Ge(r.universalLink,e)}let Ve="WALLETCONNECT_DEEPLINK_CHOICE";function Ye(e){return e.startsWith("http://")||e.startsWith("https://")}function $e(e,t){if(Ye(e))return Ge(e,t);let r=e;return r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),{redirect:`${r}wc?uri=${encodeURIComponent(t)}`,href:r}}function Ge(e,t){if(!Ye(e))return $e(e,t);let r=e;return r.endsWith("/")||(r=`${r}/`),{redirect:`${r}wc?uri=${encodeURIComponent(t)}`,href:r}}function Je(e,t){window.open(e,t,"noreferrer noopener")}const Ze="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAHdElNRQfoDAIVODUC+w+GAAAGsUlEQVRYw6WXbYwWVxXHf+fOLAtCXYS2QJdIaClipGCTknXXNqBQMVHbfmhItH4Aral+IAEaG03UxJgYKQJGTUxtDWjaxDSNtcZqIGDwpRuW1oYiVqpdpZSlpC3qysu+PHPP3w/3mXnmeXZbPzjJZO7cefn/z/mfe865xlscq3dGDIguGiHLaMQVLja4s87FShcLo5jtApdddnHexUmHIy475JmdUkPRAQMu7gzT4ljnxJpdk0QPmMFkyAKN2OfOFpc2uuh1J3MZDrjAvXmVEQUuoosRxw642FcEG7IoDxiFxNiu8NYE+vcUYIFYRKKs113bXWx2Z34CoQZsVHOiCZ7mopdzdsFhv8NexEgRDHMxUSNREbh1bwNZwBsFblmfu/a4a6AEENYO5i3AOoEWeEUCF4MOOxBDMQAOk99OJALA2u80sBCwWGBZWG/yRwMaCAbBIAsQTJT3gea1OWfNeaPzvjoHEI85rA8ObtB1v7cIdJkIHgkh9AXpocy0LJjIKvB2wPpZB0v3wkrw5jdNEjeYeMhFX3BAyfn2ke9NUrgB9LrrcZcGJFCld4fWNddXbvbWfWzGR6xJFZsBGh0cBh3bBIxIEGTQ3W0h4NuDaSAzyAxCmGq11Vzf5uaa1aG8p+WFtrEYQGwvjICJkAEqvC+YNmcmMlMNvEaCdrcbyUvQAWDTjVuESHObM6cPGWHmzDwLaEtmzG9Z3qF1zUpXmuuZBb1z4bqeNC6f0WE1NtUTwHzEloiy3BvFisy0sYoLlQtT6XW15md2Qf9SY+2Ngfdca/TMSm/9ewz+/Boc/It45h/i4kSTsKw90SQJsPTvjSZbkWemDW7qTRZ0JEYJWSKxZJ7xmf6M224MzMzbX1s8F1YugjtvMg6eErt/4/z1jUrz1rXUKxnZC2zIg2mdBTK1mFUOKC1fOt/48kdzVixIz86Nij+eEacvpJWyZJ5xy7th8VzjjpuMJfMCW58QL73ekXPVlhsyE+vyzFiplJyauEIyrGIquruMq7qTxk+dcB495rzyTzFepCUWLIFv/kBg081Gd55WUk1IDGFTS89K++TDYxddzKnWcbluHd450xgdh7EGrOo1rr868PMTzqWJRGZ2d8oB/xpL33Xnxl2rjeNn4blXRXduzJ4B5y+28kWscAwXl+yeR654FFZPHoUb710YuPeDOUdPO48di1xptKpeEeHqOcYXNwQKGd88EDk3mqxtxPSfGRlsXRtYt8z4ytPOH/7eqpg1Aso7fYKgK4NPrMpYvsC4/poMA34yVJIQC3sCD9yecdsNyaV5yPj6ryJnR1PAvSNP4J+/1cgDfLbfePaMGGtM7Qdyl12WmKOmXgKKAp54vmBRTxfLrjE+tSYjBPjRM5FrrzIeuD2jf2lLzw8vN4JlfPVp581LsO1DgXv7jSzAiXPw/d+JiYLpjsu26Yfjf5O0rF5WoxsNT9G/bX0XKxakmPjlSee6HlizJJXSX7/oRDc+vjKR+f2wODcKd78/gR8/C9uedF44myJxmhh4OY/ipMQyqaWxmjn95TfEroMFOzbkvG+RceeqViPx1Aln1yEnOow1AnffHCpJAJ5/Vex4UvzptZRdY/O/1dJIS/NkcNmR6MTYah6qzseA4TfFtw4UvHBW1bc/O+7sPhwZHYf/jMODh5yfPudVbXj2TAJ/8XxrOZagNamj4Ei2/GNfuyRxh8t6BG2l15up+MIVODEiFr8rcPS0+O6RBF6mrrEGHHtFzOo2Lo7Dl37hvPQ6mNV6R9JYKgnYWcE37K5HlE2OT/5A0udaPUBHH+BQOMzuNsYLuDyZflTW+fTcmJFDHhJhaZqewMuewXDxcDR9IYyPN6Jj+6K4MF2vV8qBtZJScqVRNi6lpGONVJis5mpKi1WbgwsY+zIsBpcR8mzIZfuTRVZrtdu9odrptR/Xx5XONXJqBmCN0P6YMUQq9WJiwt0Je102WHdbpxSqydMObBWYdwDWLVcqcIMYe3NPjg0Ht84od0Ajju1w2XCr9e6QoqM9V23ZtnmI6cfAMMb9AY0YEHdb6oobEh4y3H3Ize6LsmGvN5IdUnhttdQ9UVrfLk/ljWEZ9wXsqAdQk1EA+O22GcgdZTke/bAs3OPY4HSdcB20HhvVtTMu0jmI8ekAhz2IICj2hKpNqI60NcuIRUHEej1quzubXa2tmZhenrfZmv3YYQ9ipDAIgvHptmblccuDjdRcmjFpWbDi/9ycZjZkRbk5jYztai/AUwiUx+qdEQB/m+25i9lxyvbcjrg45Lmd0uT/3p7/Fw6ODf+WO019AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDI0LTEyLTAyVDIxOjU2OjQ4KzAwOjAwMVpslgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyNC0xMi0wMlQyMTo1Njo0OCswMDowMEAH1CoAAAAodEVYdGRhdGU6dGltZXN0YW1wADIwMjQtMTItMDJUMjE6NTY6NTMrMDA6MDDZv6GRAAAAAElFTkSuQmCC";function Qe(e){return"solana"===e.chainType}function Xe(e){return"solana"===e.type}class et extends ge{async initialize(){let e=await this.createProvider();this.provider=e,this.proxyProvider.setWalletProvider(e),this.subscribeListeners(),e.session&&(this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=D(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown"),this.connected=!0,await this.syncAccounts()),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return!!this.walletProvider?.connected}get walletBranding(){let e=this.walletProvider?.session?.peer.metadata.icons?.[0];return{name:G(this.walletProvider?.session?.peer.metadata.name||"")||"WalletConnect",icon:"string"==typeof e?e:Ze,id:this.walletProvider?.session?.peer.metadata.name.toLowerCase()||"wallet_connect_v2"}}async resetConnection(e){this.walletProvider&&this.walletProvider.connected&&(await this.walletProvider.disconnect(),this.walletProvider.signer.session=void 0,this.walletClientType=e,this.redirectUri=void 0,this.fallbackUniversalRedirectUri=void 0,function(){try{localStorage.removeItem(Ve)}catch{}}(),this.onDisconnect())}async promptConnection(){if(this.provider)return new Promise(((e,t)=>{(async()=>{let t="",r=await Promise.race([this.walletProvider?.enable(),this.proxyProvider.walletTimeout()]);if(r?.length&&(t=r[0]),!t||""===t)throw new s.PrivyConnectorError("Unable to retrieve address");this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=D(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown",this.proxyProvider.rpcTimeoutDuration=ye(this.rpcConfig,this.walletClientType)),this.connected=!0,await this.syncAccounts(r),e()})().catch((e=>{t(e?ie(e):new s.PrivyConnectorError("Unknown error during connection"))}))}))}disconnect(){this.walletProvider?.disconnect().then((()=>this.onDisconnect())).catch((()=>console.warn("Unable to disconnect WalletConnect provider")))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(e){this.proxyProvider.setWalletProvider(e)}async createProvider(){let e={};for(let t of this.chains){let r=X(t.id,this.chains,this.rpcConfig,this.privyAppId);r&&(e[t.id]=r)}let t=this.shouldEnforceDefaultChainOnConnect?[this.defaultChain.id]:[],r=this.chains.map((e=>e.id)),i=await g.EthereumProvider.init({projectId:this.walletConnectCloudProjectId,chains:t,optionalChains:r,optionalEvents:g.OPTIONAL_EVENTS,optionalMethods:g.OPTIONAL_METHODS,rpcMap:e,showQrModal:!1,metadata:{description:this.privyAppName,name:this.privyAppName,url:window.location.origin,icons:[]}});return i.on("display_uri",(e=>{if(i.signer.abortPairingAttempt(),function(){try{localStorage.removeItem(Ve)}catch{}}(),!this.showPrivyQrModal)throw new s.PrivyConnectorError("WalletConnect modal not available - Privy handles wallet connections through its own UI");if(n.isMobile&&this.walletEntry){let{redirect:t,href:r}=Be(e,this.walletEntry);Je(t,"_self"),function({href:e,name:t}){try{localStorage.setItem(Ve,JSON.stringify({href:e,name:t}))}catch{}}({href:r,name:this.walletEntry.metadata?.shortName||this.walletEntry.name});let n=He(e,this.walletEntry);return this.redirectUri=t,this.fallbackUniversalRedirectUri=n?.redirect,this.showPrivyQrModal({native:t,universal:t})}if(this.redirectUri=void 0,this.walletEntry){let t=He(e,this.walletEntry);this.fallbackUniversalRedirectUri=t?.redirect}this.showPrivyQrModal({native:e,universal:void 0})})),i.on("connect",(()=>{i.session?.peer.metadata.url&&(this.walletEntry=D(i.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown")})),i}async enableProvider(){return this.walletProvider?.connected?Promise.resolve(this.walletProvider.accounts):await(this.walletProvider?.enable())}setWalletEntry(e,t){this.walletEntry=e,this.showPrivyQrModal=t}constructor({walletConnectCloudProjectId:e,rpcConfig:t,chains:r,defaultChain:n,shouldEnforceDefaultChainOnConnect:i,privyAppId:a,privyAppName:o,walletClientType:s}){super(s||"unknown",r,n,t),this.connectorType="wallet_connect_v2",this.privyAppId=a,this.privyAppName=o,this.walletConnectCloudProjectId=e,this.rpcConfig=t,this.shouldEnforceDefaultChainOnConnect=i,this.proxyProvider=new fe(void 0,this.rpcTimeoutDuration),s&&(this.walletEntry=(e=>N.getState().listings.find((({slug:t})=>F(t)===F(e))))(s),this.walletClientType=s)}}class tt extends W.default{get wallets(){let e=new Set;return this.walletConnectors.flatMap((e=>e.wallets)).sort(((e,t)=>e.connectedAt&&t.connectedAt?t.connectedAt-e.connectedAt:0)).filter((t=>{let r=`${t.address}${t.walletClientType}${t.connectorType}${t.meta.id}`;return!e.has(r)&&(e.add(r),!0)}))}async initialize(e){if(this.initialized&&!e||(e&&this.removeAllConnectors(),this.externalWalletConfig.disableAllExternalWallets))return;let t=Z({store:this.store,walletList:this.walletList,externalWalletConfig:this.externalWalletConfig,walletChainType:this.walletChainType}).then((e=>{e.forEach((({type:e,eip6963InjectedProvider:t,legacyInjectedProvider:r})=>{this.createEthereumWalletConnector({connectorType:"injected",walletClientType:e,providers:{eip6963InjectedProvider:t,legacyInjectedProvider:r}})}))}));for(let e of(this.walletList.includes("coinbase_wallet")&&this.createEthereumWalletConnector({connectorType:"coinbase_wallet",walletClientType:"coinbase_wallet"}),this.walletList.includes("base_account")&&this.createEthereumWalletConnector({connectorType:"base_account",walletClientType:"base_account"}),Object.values(Re)))!e.isInstalled&&this.walletList.includes(e.client)&&(["ethereum-only","ethereum-and-solana"].includes(this.walletChainType)&&e.chainTypes.includes("ethereum")&&this.createEthereumWalletConnector({connectorType:"null",walletClientType:e.client,walletConfig:e}),["ethereum-and-solana","solana-only"].includes(this.walletChainType)&&e.chainTypes.includes("solana")&&this.addSolanaWalletConnector(new ze({id:e.client,name:e.name})));this.externalWalletConfig.walletConnect.enabled&&(this.walletList.includes("wallet_connect_qr")||j(this.walletList))&&"solana-only"!==this.walletChainType&&this.createEthereumWalletConnector({connectorType:"wallet_connect_v2",walletClientType:"unknown"});let r=this.walletList.includes("wallet_connect_qr_solana")||j(this.walletList)&&"ethereum-only"!==this.walletChainType,n=this.externalWalletConfig.solana.connectors?.get()||[],i=async e=>{if(!r)return;let t=e.find((e=>"walletconnect_solana"===e.walletBranding?.id));t&&t.wallet&&await t.wallet.initialize({walletConnectCloudProjectId:this.walletConnectCloudProjectId,privyAppName:this.privyAppName})};i(n),n.filter((e=>r||"walletconnect_solana"!==e.walletBranding?.id)).forEach(this.addSolanaWalletConnector),this.externalWalletConfig.solana.connectors?._setOnConnectorsUpdated?.((e=>{i(e),e?.filter((e=>r||"walletconnect_solana"!==e.walletBranding?.id)).forEach(this.addSolanaWalletConnector)})),await t,this.initialized=!0}findWalletConnector(e,t,r){return"wallet_connect_v2"===e?this.walletConnectors.filter(ve).find((t=>t.connectorType===e&&(!r||t.wallets.some((e=>e.address===r)))))??null:this.walletConnectors.filter(ve).find((n=>n.connectorType===e&&n.walletClientType===t&&(!r||n.wallets.some((e=>e.address===r)))))??null}findSolanaWalletConnector(e){return this.walletConnectors.filter(Qe).find((t=>"unknown"===t.walletClientType?t.walletBranding.id===e:t.walletClientType===e))??null}onInitialized(e){e.wallets.forEach((e=>{let t=this.storedConnections.find((t=>t.address===e.address&&t.connectorType===e.connectorType&&("solana"===e.type&&"unknown"===t.walletClientType&&"unknown"===e.walletClientType?e.meta.id===t.id:t.walletClientType===e.walletClientType)));t&&(e.connectedAt=t.connectedAt)})),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(e){e.initialized&&this.emit("walletsUpdated")}async createEthereumWalletConnector({connectorType:e,walletClientType:t,providers:r,walletConfig:n}){let i=this.findWalletConnector(e,t);if(i&&ve(i))return i instanceof et&&i.resetConnection(t),i;let a=(()=>"injected"!==e?"coinbase_wallet"===e?new Ae(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig.coinbaseWallet.config):"base_account"===e?new Ee(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig.baseAccount.config,this.setBaseAccountSdk):"null"!==e?new et({walletConnectCloudProjectId:this.walletConnectCloudProjectId,rpcConfig:this.rpcConfig,chains:this.chains,defaultChain:this.defaultChain,shouldEnforceDefaultChainOnConnect:this.shouldEnforceDefaultChainOnConnect,privyAppId:this.privyAppId,privyAppName:this.privyAppName,walletClientType:t}):n?new Pe({id:n.client,name:n.name,defaultChain:this.defaultChain,walletClientType:n.client}):null:"metamask"===t&&r?.eip6963InjectedProvider?new Ue(this.chains,this.defaultChain,this.rpcConfig,r?.eip6963InjectedProvider,"metamask"):"metamask"===t&&r?.legacyInjectedProvider?new We(this.chains,this.defaultChain,this.rpcConfig,r?.legacyInjectedProvider,"metamask"):"phantom"===t&&r?.legacyInjectedProvider?new We(this.chains,this.defaultChain,this.rpcConfig,r?.legacyInjectedProvider,"phantom"):r?.legacyInjectedProvider&&"unknown_browser_extension"===t?new We(this.chains,this.defaultChain,this.rpcConfig,r?.legacyInjectedProvider):r?.eip6963InjectedProvider?new Ie(this.chains,this.defaultChain,this.rpcConfig,r?.eip6963InjectedProvider,t):void 0)();return a&&this.addWalletConnector(a),a||null}addWalletConnector(e){this.walletConnectors.push(e),e.on("initialized",(()=>this.onInitialized(e))),e.on("walletsUpdated",(()=>this.onWalletsUpdated(e))),e.initialize().catch((e=>{console.debug("Failed to initialize connector",e)}))}setWalletList(e){this.walletList=e,this.initialized&&this.initialize(!0).catch(console.error)}removeAllConnectors(){for(let e of this.walletConnectors)e.removeAllListeners();this.walletConnectors=[]}constructor(e,t,r,n,i,a,o,s,l,c,d,u){super(),this.addSolanaWalletConnector=async e=>{let t=this.findSolanaWalletConnector(e.walletClientType);if(!t||"null"===t.connectorType){if("null"===t?.connectorType){let e=this.walletConnectors.indexOf(t);this.walletConnectors.splice(e,1)}this.addWalletConnector(e)}},this.privyAppId=e,this.walletConnectCloudProjectId=t,this.rpcConfig=r,this.chains=n,this.defaultChain=i,this.walletConnectors=[],this.initialized=!1,this.store=a,this.walletList=o,this.shouldEnforceDefaultChainOnConnect=s,this.externalWalletConfig=l,this.privyAppName=c,this.walletChainType=u||"ethereum-only",this.setBaseAccountSdk=d,this.storedConnections=De()}}const rt=w.create((()=>({identityToken:null})));let nt=[l.sessionsRefreshPath,l.sessionsLogoutPath,l.analyticsEventsPath];class it{async get(e,t){try{return await this.baseFetch(e,t)}catch(e){throw s.formatApiError(e)}}async post(e,t,r){try{return await this.baseFetch(e,{method:"POST",...t?{body:t}:{},...r})}catch(e){throw s.formatApiError(e)}}async delete(e,t){try{return await this.baseFetch(e,{method:"DELETE",...t})}catch(e){throw s.formatApiError(e)}}constructor({appId:e,appClientId:t,client:r,defaults:n}){this.appId=e,this.appClientId=t,this.clientAnalyticsId=r.clientAnalyticsId,this.sdkVersion=m.VERSION,this.client=r,this.defaults=n,this.fallbackApiUrl=r.fallbackApiUrl,this.baseFetch=f.ofetch.create({baseURL:this.defaults.baseURL,timeout:this.defaults.timeout,retry:3,retryDelay:500,retryStatusCodes:[408,409,425,500,502,503,504],credentials:"include",onRequest:async({request:e,options:t})=>{let r=new Headers(t.headers);r.set("privy-app-id",this.appId),this.appClientId&&r.set("privy-client-id",this.appClientId),r.set("privy-ca-id",this.clientAnalyticsId||""),r.set("privy-client",`react-auth:${this.sdkVersion}`);let n=nt.includes(e.toString());if(!r.has("authorization")){let e=await this.client.getAccessToken({disableAutoRefresh:n});null!==e&&r.set("authorization",`Bearer ${e}`)}t.headers=r,t.retryDelay&&"number"==typeof t.retryDelay&&(t.retryDelay=3*t.retryDelay)},onRequestError:({error:e})=>{if(e instanceof DOMException&&"AbortError"===e.name)throw new s.PrivyTimeoutError}})}}const at=e=>({rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification});class ot{async authenticate(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(l.customJwtAccountAuthenticatePath,{token:this.meta.token})}catch(e){throw s.formatApiError(e)}}async link(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(l.customJwtAccountLinkPath,{token:this.meta.token})}catch(e){throw s.formatApiError(e)}}constructor(e){this.meta={token:e}}}function st(e){return e?{"privy-ui":"t"}:void 0}class lt{async authenticate(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new s.PrivyClientError("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(l.passwordlessAuthenticatePath,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw s.formatApiError(e)}}async link(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new s.PrivyClientError("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(l.passwordlessLinkPath,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw s.formatApiError(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:r}){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new s.PrivyClientError("Email must be set when initialzing authentication.");let n=st(r);try{return await this.api.post(l.passwordlessInitPath,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...n}})}catch(e){throw s.formatApiError(e)}}constructor({email:e,captchaToken:t,disableSignup:r}){this.meta={email:e,captchaToken:t,disableSignup:r??!1}}}class ct extends lt{async link(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new s.PrivyClientError("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(l.updateEmailPath,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw s.formatApiError(e)}}constructor(e,t,r){super({email:t,captchaToken:r}),this.meta={email:t,captchaToken:r,oldAddress:e,disableSignup:!1}}}function dt(e){return crypto.getRandomValues(new Uint8Array(e))}class ut{getOrCreateGuestCredential(e){let t=m.getGuestCredentialStorageKey(e);if(ce()){if(de.get(t))return de.get(t);{let e=h.base64url.encode(dt(32));return de.put(t,e),e}}return h.base64url.encode(dt(32))}async authenticate(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(l.guestAccountAuthenticatePath,{guest_credential:this.meta.guestCredential})}catch(e){throw s.formatApiError(e)}}async link(){throw Error("Linking is not supported for the guest flow")}constructor(e){this.meta={guestCredential:this.getOrCreateGuestCredential(e)}}}function ht(){return"undefined"!=typeof window&&"chrome-extension:"===window.location.protocol&&"chrome"in window}function pt(){if(!ht())return;let e=window.chrome;return e?.runtime?.id}function yt(){if(!ht())return!1;let e=window.chrome;return"function"==typeof e?.identity?.launchWebAuthFlow}async function wt(e){return new Promise(((t,r)=>{yt()?window.chrome.identity.launchWebAuthFlow({url:e,interactive:!0},(async e=>{try{let r=function(){if(!ht())return;let e=window.chrome;return e?.runtime?.lastError?.message}();if(r||!e){let e=`WebAuthFlow failed: ${r||"Response URI missing"}`;throw Error(e)}let n=new URL(e),i=pt();if(!i)throw Error("Invalid extension context");if("chrome-extension:"===n.protocol){if(n.hostname!==i)throw Error("Invalid responseUri origin")}else{if("https:"!==n.protocol)throw Error("Invalid responseUri protocol");{let e=n.hostname.split(".");if(3!==e.length||"chromiumapp"!==e[1]||"org"!==e[2]||e[0]!==i)throw Error("Invalid responseUri origin")}}let a=n.searchParams.get("privy_oauth_state"),o=n.searchParams.get("privy_oauth_code");if(!a||!o)throw Error("Invalid responseUri - missing required parameters");t({privyOAuthState:a,privyOAuthCode:o})}catch(e){r(e)}})):r(Error("Chrome identity API not available"))}))}function mt(){return h.base64url.encode(dt(36))}function vt(){return mt()}async function gt(e,t="S256"){if("S256"!=t)return e;{let t=await async function(e){let t=(new TextEncoder).encode(e);return new Uint8Array(await crypto.subtle.digest("SHA-256",t))}(e);return h.base64url.encode(t)}}class ft{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new s.PrivyClientError("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new s.PrivyClientError("User denied confirmation during OAuth flow");let e=function(){let e=de.get(m.CODE_VERIFIER_KEY);if(!e)throw new s.PrivyClientError("Authentication error.");return e}();try{let t=await this.api.post(l.oAuthAuthenticatePath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return de.del(m.CODE_VERIFIER_KEY),de.del(m.HEADLESS_OAUTH_KEY),de.del(m.OAUTH_DISABLE_SIGNUP_KEY),t}catch(e){let t=s.formatApiError(e);if(t.privyErrorCode)throw new s.PrivyClientError(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new s.PrivyClientError("Invalid code during oauth flow.",void 0,s.PrivyErrorCode.OAUTH_USER_DENIED);throw new s.PrivyClientError("Invalid code during OAuth flow.",void 0,s.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new s.PrivyClientError("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new s.PrivyClientError("User denied confirmation during OAuth flow");let e=de.get(m.CODE_VERIFIER_KEY);if(!e)throw new s.PrivyClientError("Authentication error.");try{let t=await this.api.post(l.oAuthLinkPath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return de.del(m.CODE_VERIFIER_KEY),t}catch(e){throw s.formatApiError(e)}}async getAuthorizationUrl(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!this.meta.provider)throw new s.PrivyClientError("Provider must be set when initializing OAuth authentication.");let e=mt();de.put(m.CODE_VERIFIER_KEY,e);let t=vt();de.put(m.STATE_CODE_KEY,t);let r=await gt(e);this.meta.withPrivyUi||de.put(m.HEADLESS_OAUTH_KEY,!0),this.meta.disableSignup?de.put(m.OAUTH_DISABLE_SIGNUP_KEY,!0):de.del(m.OAUTH_DISABLE_SIGNUP_KEY);let n=st(this.meta.withPrivyUi),i=window.location.href,a=function(){let e=pt();if(e)return`https://${e}.chromiumapp.org`}();a&&(i=a);try{return await this.api.post(l.oAuthInitPath,{provider:this.meta.provider,redirect_to:this.meta.customOAuthRedirectUrl||i,token:this.meta.captchaToken,code_challenge:r,state_code:t},{headers:{...n}})}catch(e){throw s.formatApiError(e)}}constructor(e){this.meta=e}}function Et(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),r=e.get("privy_oauth_state"),n=e.get("privy_oauth_provider");if(!t||!r||!n)return{inProgress:!1};let i=!1;try{i=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:r,provider:n,withPrivyUi:!de.get(m.HEADLESS_OAUTH_KEY),popupFlow:null!==window.opener&&i,disableSignup:!!de.get(m.OAUTH_DISABLE_SIGNUP_KEY)}}class Ct{execute(e){return null===this.promise&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}constructor(e){this.promise=null,this.fn=e}}const At=({address:e,chainId:t,nonce:r})=>`${window.location.host} wants you to sign in with your Ethereum account:\n${e}\n\nBy signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: ${t}\nNonce: ${r}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`;class Pt{get meta(){return{connectorType:this.wallet?.connectorType,walletClientType:this.wallet?.walletClientType,chainId:this.wallet?.chainId,address:this.wallet?.address,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new s.PrivyClientError("SiweFlow has no client instance");try{if(this.preparedMessage&&this.signature)return await this.client.authenticateWithSiweInternal({message:this.preparedMessage,signature:this.signature,chainId:this.wallet?.chainId,walletClientType:this.walletClientType??this.wallet?.walletClientType,connectorType:this.connectorType??this.wallet?.connectorType,mode:this._meta.disableSignup?"no-signup":"login-or-sign-up"});if(!this.wallet)throw new s.PrivyClientError("SiweFlow has no wallet instance");let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw s.formatApiError(e)}}async link(){if(!this.client)throw new s.PrivyClientError("SiweFlow has no client instance");try{if(!this.wallet)throw new s.PrivyClientError("SiweFlow has no wallet instance");let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw s.formatApiError(e)}}async sign(){if(!this.client)throw new s.PrivyClientError("SiweFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new s.PrivyClientError("Could not prepare SIWE message");if(!this.wallet)throw new s.PrivyClientError("SiweFlow has no wallet instance");let e=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:e}}async _getNonceOnce(){if(!this.client)throw new s.PrivyClientError("SiweFlow has no client instance");if(!this.wallet)throw new s.PrivyClientError("UI SiweFlow has no wallet instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new s.PrivyClientError("SiweFlow has no client instance");if(!this.wallet)throw new s.PrivyClientError("SiweFlow has no wallet instance");let e=this.wallet.address,t=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=At({address:e,chainId:t,nonce:this.nonce}),this.preparedMessage}constructor(e,t,r,n=!1,i){this._meta={disableSignup:!1},this.getNonceOnce=new Ct(this._getNonceOnce.bind(this)),this.wallet=t,this.captchaToken=r,this.client=e,this._meta.disableSignup=n,this.preparedMessage=i?.message,this.signature=i?.signature,this.walletClientType=i?.walletClientType,this.connectorType=i?.connectorType}}class Tt{async authenticate(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new s.PrivyClientError("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(l.passwordlessSmsAuthenticatePath,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw s.formatApiError(e)}}async link(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new s.PrivyClientError("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(l.passwordlessSmsLinkPath,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw s.formatApiError(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:r}){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new s.PrivyClientError("phone nNumber must be set when initialzing authentication.");let n=st(r);try{return await this.api.post(l.passwordlessSmsInitPath,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...n}})}catch(e){throw s.formatApiError(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:r}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:r??!1}}}class _t extends Tt{async link(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new s.PrivyClientError("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(l.updatePhonePath,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw s.formatApiError(e)}}constructor(e,t,r){super({phoneNumber:t,captchaToken:r}),this.meta={phoneNumber:t,captchaToken:r,oldPhoneNumber:e,disableSignup:!1}}}function bt(){return!(n.isSafari&&window.location.origin.startsWith("http://localhost"))}var kt,St=((kt={}).PRIVY="privy_access_token",kt.CUSTOMER="customer_access_token",kt);class It{get token(){return this.privyAccessToken||this.customerAccessToken}getToken(e){return"privy_access_token"===e?this.privyAccessToken:this.customerAccessToken}get customerAccessToken(){return this._getToken(m.CUSTOMER_ACCESS_TOKEN_STORAGE_KEY)}get privyAccessToken(){return this._getToken(m.PRIVY_ACCESS_TOKEN_STORAGE_KEY)}_getToken(e){try{let t=de.get(e);return"string"==typeof t?O.throwIfNotWellFormedJwt(t):null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=de.get(m.REFRESH_TOKEN_STORAGE_KEY);return"string"==typeof e?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}getProviderAccessToken(e){try{let t=de.get(m.getProviderAccessTokenStorageKey(e));if("string"!=typeof t)return null;{let r=new O(t);return r.isExpired()?(de.del(m.getProviderAccessTokenStorageKey(e)),null):r.value}}catch(e){return console.error(e),null}}get mightHaveServerCookies(){try{let e=U.default.get(m.SESSION_COOKIE_KEY);return void 0!==e&&e.length>0}catch(e){console.error(e)}return!1}hasRefreshCredentials(e="privy_access_token"){let t="string"==typeof this.getToken(e),r="string"==typeof this.refreshToken&&this.refreshToken!==m.DEPRECATED_REFRESH_TOKEN;return this.mightHaveServerCookies||t&&r}hasActiveAccessToken(e){let t=O.parse(this.getToken(e));return null!==t&&!t.isExpired(30)}authenticate(e){return this.authenticateOnce.execute(e)}link(e){return this.linkOnce.execute(e)}refresh(){return this.refreshOnce.execute()}destroy(){return this.destroyOnce.execute()}storeProviderAccessToken(e,t){"string"==typeof t?de.put(m.getProviderAccessTokenStorageKey(e),t):de.del(m.getProviderAccessTokenStorageKey(e))}updateIdentityToken(e){"string"==typeof e?this.storeIdentityToken(e):this.clearIdentityToken()}async _authenticate(e){try{let t=await e.authenticate(),{user:r,is_new_user:n,oauth_tokens:i}=t;this.handleTokenResponse(t);let a=i?{provider:i.provider,accessToken:i.access_token,accessTokenExpiresInSeconds:i.access_token_expires_in_seconds,refreshToken:i.refresh_token,refreshTokenExpiresInSeconds:i.refresh_token_expires_in_seconds,scopes:i.scopes}:void 0;return this._trackAuthenticateEvents(e,n),{user:p.convertUserResponseToUser(r),isNewUser:n,oAuthTokens:a}}catch(e){throw console.warn("Error authenticating session"),s.formatPrivyError(e)}}_trackAuthenticateEvents(e,t){let r=function(e){return e instanceof lt?"email":e instanceof Tt?"sms":e instanceof Pt?"siwe":e instanceof ut?"guest":e instanceof ot?"custom_auth":e instanceof ft?e.meta.provider:null}(e);r&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:r,isNewUser:t}}),"siwe"===r&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:e.meta.connectorType,walletClientType:e.meta.walletClientType}})}async _link(e){try{let t=await e.link(),r=t.oauth_tokens,n=r?{provider:r.provider,accessToken:r.access_token,accessTokenExpiresInSeconds:r.access_token_expires_in_seconds,refreshToken:r.refresh_token,refreshTokenExpiresInSeconds:r.refresh_token_expires_in_seconds,scopes:r.scopes}:void 0;return{user:p.convertUserResponseToUser(t),oAuthTokens:n}}catch(e){throw console.warn("Error linking account"),s.formatPrivyError(e)}}async _refresh(){if(!this.api)throw new s.PrivyClientError("Session has no API instance");if(!this.client)throw new s.PrivyClientError("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let e=this.token,t=this.refreshToken;if(this.client.useServerCookies&&!this.mightHaveServerCookies&&this.token&&window.location.origin===this.client.apiUrl)return this.destroyLocalState(),null;try{let r;if(!(e&&t||this.mightHaveServerCookies))return null;{let n={};e&&(n.authorization=`Bearer ${e}`),r=await this.api.post(l.sessionsRefreshPath,t?{refresh_token:t}:{},{headers:n})}return this.handleTokenResponse(r),p.convertUserResponseToUser(r.user)}catch(e){if(e instanceof s.PrivyApiError&&e.privyErrorCode===s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN)return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw s.formatPrivyError(e)}}handleTokenResponse(e){e.session_update_action&&"set"!==e.session_update_action?"clear"===e.session_update_action?this.destroyLocalState():"ignore"===e.session_update_action&&(e.token&&(this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token)),e.identity_token&&this.storeIdentityToken(e.identity_token)):this._storeAllTokens(e)}_storeAllTokens(e){this.storeRefreshToken(e.refresh_token),this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token),e.identity_token&&this.storeIdentityToken(e.identity_token)}async _destroy(){try{await(this.api?.post(l.sessionsLogoutPath,{refresh_token:this.refreshToken}))}catch(e){console.warn("Error destroying session")}this.destroyLocalState()}destroyLocalState(){this.storeRefreshToken(null),this.storeCustomerAccessToken(null),this.storePrivyAccessToken(null),this.clearIdentityToken()}storeCustomerAccessToken(e){if("string"==typeof e){let t=de.get(m.CUSTOMER_ACCESS_TOKEN_STORAGE_KEY);if(de.put(m.CUSTOMER_ACCESS_TOKEN_STORAGE_KEY,e),!this.client?.useServerCookies){let t=O.parse(e)?.expiration;U.default.set(m.CUSTOMER_ACCESS_TOKEN_COOKIE_KEY,e,{sameSite:"Strict",secure:bt(),expires:t?new Date(1e3*t):void 0})}t!==e&&this.client?.onStoreCustomerAccessToken?.(e)}else de.del(m.CUSTOMER_ACCESS_TOKEN_STORAGE_KEY),U.default.remove(m.CUSTOMER_ACCESS_TOKEN_COOKIE_KEY),this.client?.onDeleteCustomerAccessToken?.()}storeRefreshToken(e){"string"==typeof e?(de.put(m.REFRESH_TOKEN_STORAGE_KEY,e),this.client?.useServerCookies||U.default.set(m.SESSION_COOKIE_KEY,"t",{sameSite:"Strict",secure:bt(),expires:30})):(de.del(m.REFRESH_TOKEN_STORAGE_KEY),U.default.remove(m.REFRESH_TOKEN_COOKIE_KEY),U.default.remove(m.SESSION_COOKIE_KEY))}storePrivyAccessToken(e){"string"==typeof e?de.put(m.PRIVY_ACCESS_TOKEN_STORAGE_KEY,e):de.del(m.PRIVY_ACCESS_TOKEN_STORAGE_KEY)}storeIdentityToken(e){if(rt.setState({identityToken:e}),this.client?.useServerCookies)return;de.put(m.IDENTITY_TOKEN_STORAGE_KEY,e);let t=O.parse(e)?.expiration;U.default.set(m.IDENTITY_TOKEN_COOKIE_KEY,e,{sameSite:"Strict",secure:bt(),expires:t?new Date(1e3*t):void 0})}clearIdentityToken(){de.del(m.IDENTITY_TOKEN_STORAGE_KEY),rt.setState({identityToken:null}),U.default.remove(m.IDENTITY_TOKEN_COOKIE_KEY)}constructor(){this.authenticateOnce=new Ct((async e=>this._authenticate(e))),this.linkOnce=new Ct((async e=>this._link(e))),this.refreshOnce=new Ct(this._refresh.bind(this)),this.destroyOnce=new Ct(this._destroy.bind(this))}}let xt,Wt;var Ut=0,Ot="__private_"+Ut+++"__getOrGenerateClientAnalyticsId";class Rt{getAppId(){return this.appId}initializeConnectorManager({walletConnectCloudProjectId:e,rpcConfig:t,chains:r,defaultChain:n,store:i,walletList:a,shouldEnforceDefaultChainOnConnect:o,externalWalletConfig:s,appName:l,walletChainType:c,setBaseAccountSdk:d}){this.connectors||(this.connectors=new tt(this.appId,e,t,r,n,i,a,o,s,l,d,c))}generateApi(){let e=new it({appId:this.appId,appClientId:this.appClientId,client:this,defaults:{baseURL:this.apiUrl,timeout:this.timeout}});return this.session.api=e,e}updateApiUrl(e){this.apiUrl=e||this.fallbackApiUrl,this.api=this.generateApi(),e&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new s.PrivyClientError("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new s.PrivyClientError("No auth flow in progress.");let{oAuthTokens:e}=await this.session.link(this.authFlow);return{user:await this.getAuthenticatedUser(),oAuthTokens:e}}storeProviderAccessToken(e,t){this.session.storeProviderAccessToken(e,t)}getProviderAccessToken(e){return this.session.getProviderAccessToken(e)}async logout(){await this.session.destroy(),this.authFlow=void 0}clearProviderAcccessTokens(e){e.linkedAccounts.filter((e=>"cross_app"===e.type)).forEach((e=>{this.storeProviderAccessToken(e.providerApp.id,null)}))}startAuthFlow(e){return e.api=this.api,this.authFlow=e,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(l.mfaPasswordlessSmsInitPath,{action:"verify"})}catch(e){throw s.formatApiError(e)}}async initMfaPasskeyVerification(){try{let e=await this.api.post(l.mfaPasskeyInitPath,{});return at(e.options)}catch(e){throw s.formatApiError(e)}}async getCrossAppProviderDetails(e){try{return this._cachedProviderAppDetails[e]||(this._cachedProviderAppDetails[e]=await this.api.get(`/api/v1/apps/${e}/cross-app/details`)),this._cachedProviderAppDetails[e]}catch(e){console.error("Error fetching cross app provider details",e)}}async acceptTerms(){try{let e=await this.api.post(l.acceptTermsPath,{});return p.convertUserResponseToUser(e)}catch(e){throw s.formatPrivyError(e)}}async unlinkEmail(e){try{let t=await this.api.post(l.unlinkEmailPath,{address:e});return await this.getAuthenticatedUser()??p.convertUserResponseToUser(t)}catch(e){throw s.formatPrivyError(e)}}async unlinkPhone(e){try{let t=await this.api.post(l.unlinkPhonePath,{phoneNumber:e});return await this.getAuthenticatedUser()??p.convertUserResponseToUser(t)}catch(e){throw s.formatPrivyError(e)}}async unlinkEthereumWallet(e){try{let t=await this.api.post(l.unlinkWalletPath,{address:e});return await this.getAuthenticatedUser()??p.convertUserResponseToUser(t)}catch(e){throw s.formatPrivyError(e)}}async unlinkSolanaWallet(e){try{let t=await this.api.post(l.siwsUnlinkWalletPath,{address:e});return await this.getAuthenticatedUser()??p.convertUserResponseToUser(t)}catch(e){throw s.formatPrivyError(e)}}async unlinkOAuth(e,t){try{let r=await this.api.post(l.unlinkOAuthPath,{provider:e,subject:t});return await this.getAuthenticatedUser()??p.convertUserResponseToUser(r)}catch(e){throw s.formatPrivyError(e)}}async unlinkFarcaster(e){try{let t=await this.api.post(l.unlinkFarcasterPath,{fid:e});return await this.getAuthenticatedUser()??p.convertUserResponseToUser(t)}catch(e){throw s.formatPrivyError(e)}}async unlinkTelegram(e){try{let t=await this.api.post(l.telegramAccountUnlinkPath,{telegram_user_id:e});return await this.getAuthenticatedUser()??p.convertUserResponseToUser(t)}catch(e){throw s.formatPrivyError(e)}}async revokeDelegatedWallet(){try{await this.api.post(l.delegatedActionsRevokePath,{})}catch(e){throw s.formatPrivyError(e)}}async createAnalyticsEvent({eventName:e,payload:t,timestamp:r,options:n}){if("undefined"!=typeof window)try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(l.analyticsEventsPath,{event_name:e,client_id:this.clientAnalyticsId,payload:{...t||{},clientTimestamp:r?r.toISOString():(new Date).toISOString()}},{retry:-1,keepalive:n?.keepAlive??!1})}catch(e){console.log("Unable to submit event. This is not an issue.")}}async signMoonpayOnRampUrl(e){try{return this.api.post(l.moonpayPluginOnRampPath,e)}catch(e){throw s.formatPrivyError(e)}}async initCoinbaseOnRamp(e){try{return this.api.post(l.coinbaseOnRampInitPath,e)}catch(e){throw s.formatPrivyError(e)}}async getCoinbaseOnRampStatus({partnerUserId:e}){try{return this.api.get(`${l.coinbaseOnRampStatusPath}?partnerUserId=${e}`)}catch(e){throw s.formatPrivyError(e)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()?this.session.refresh():null}async getAccessToken(e){return await this.getPrivyAccessToken(e)||await this.getCustomerAccessToken(e)}async getCustomerAccessToken(e){return await this._getToken(St.CUSTOMER,e)}async getPrivyAccessToken(e){return await this._getToken(St.PRIVY,e)}async _getToken(e,t){return this.session.getToken(e)?this.session.hasActiveAccessToken(e)?this.session.hasRefreshCredentials(e)?R.parse(this.session.getToken(e))?.appId!==this.appId?(await this.logout(),null):this.session.getToken(e):(this.session.destroyLocalState(),null):!t?.disableAutoRefresh&&this.session.hasRefreshCredentials(e)?(await this.session.refresh(),this.session.getToken(e)):null:null}async getUsdTokenPrice(e){try{return(await this.api.get(`/api/v1/token_price?chainId=${e.id}&tokenSymbol=${e.nativeCurrency.symbol}`)).usd}catch(t){return void console.error(`Unable to fetch token price for chain with id ${e.id}`)}}async getUsdPriceForSol(){try{return(await this.api.get("/api/v1/token_price?chainId=0&tokenSymbol=SOL")).usd}catch(e){return void console.error("Unable to fetch token price for SOL")}}async getSplTokenMetadata({mintAddress:e,cluster:t}){try{return await this.api.get(`/api/v1/spl_token_info?mint_address=${e}&cluster=${t}`)}catch(r){return void console.error(`Unable to fetch token metadata for ${t}:${e}`)}}async requestFarcasterSignerStatus(e){try{return await this.api.post("/api/v1/farcaster/signer/status",{ed25519_public_key:e})}catch(e){throw console.error("Unable to fetch Farcaster signer status"),e}}async generateSiweNonce({address:e,captchaToken:t}){try{return(await this.api.post(l.siweInitPath,{address:e,token:t})).nonce}catch(e){throw s.formatPrivyError(e)}}async authenticateWithSiweInternal({message:e,signature:t,chainId:r,walletClientType:n,connectorType:i,mode:a}){return await this.api.post(l.siweAuthenticatePath,{message:e,signature:t,chainId:r,walletClientType:n,connectorType:i,mode:a})}async linkWithSiweInternal({message:e,signature:t,chainId:r,walletClientType:n,connectorType:i}){return await this.api.post(l.siweLinkPath,{message:e,signature:t,chainId:r,walletClientType:n,connectorType:i})}async linkSmartWallet({message:e,signature:t,smartWalletType:r,smartWalletVersion:n}){try{let i=await this.api.post(l.smartWalletLinkPath,{message:e,signature:t,smart_wallet_type:r,smart_wallet_version:n});return p.convertUserResponseToUser(i)}catch(e){throw s.formatPrivyError(e)}}async linkWithSiwe({message:e,signature:t,chainId:r,walletClientType:n,connectorType:i}){try{let a=await this.linkWithSiweInternal({message:e,signature:t,chainId:r,walletClientType:n,connectorType:i});return p.convertUserResponseToUser(a)}catch(e){throw s.formatPrivyError(e)}}async generateSiwsNonce({address:e,captchaToken:t}){try{return(await this.api.post(l.siwsInitPath,{address:e,token:t})).nonce}catch(e){throw s.formatPrivyError(e)}}async authenticateWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,mode:i,messageType:a="plain"}){return await this.api.post(l.siwsAuthenticatePath,{message:e,signature:t,walletClientType:r,connectorType:n,mode:i,message_type:a})}async authenticateWithSiws({message:e,signature:t,walletClientType:r,connectorType:n,mode:i,messageType:a="plain"}){let o=await this.authenticateWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,mode:i,messageType:a});this.session.handleTokenResponse(o);let s=p.convertUserResponseToUser(o.user);if(!s)throw Error("Authentication failed - no user returned");return{user:s,isNewUser:o.is_new_user||!1}}async sendAccountTransferRequest({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:i,telegramWebAppData:a,farcasterEmbeddedAddress:o,oAuthUserInfo:c}){try{let s,d;switch(r){case"email":s=l.transferEmailPath,d={nonce:e,email:t};break;case"sms":s=l.transferPhonePath,d={nonce:e,phoneNumber:t};break;case"siwe":if(s=l.transferWalletPath,!n)throw Error("Wallet parameters must be defined");d={nonce:e,address:t,...n};break;case"farcaster":s=l.transferFarcasterPath,d={nonce:e,farcaster_id:t,farcaster_embedded_address:o};break;case"telegram":s=l.telegramAccountTransferPath,d={nonce:e,telegram_auth_result:i,telegram_web_app_data:a};break;case"siws":s=l.siwsTransferPath,d={nonce:e,address:t,...n};break;case"custom":case"guest":case"passkey":throw Error("Invalid transfer account type");default:s=l.transferOAuthPath,d={nonce:e,userInfo:c}}let u=await this.api.post(s,d);return await this.getAuthenticatedUser()??p.convertUserResponseToUser(u)}catch(e){throw s.formatPrivyError(e)}}async linkWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,messageType:i="plain"}){return await this.api.post(l.siwsLinkPath,{message:e,signature:t,walletClientType:r,connectorType:n,message_type:i})}async linkWithSiws({message:e,signature:t,walletClientType:r,connectorType:n,messageType:i="plain"}){try{let a=await this.linkWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,messageType:i});return p.convertUserResponseToUser(a)}catch(e){throw s.formatPrivyError(e)}}async updateUserAndIdToken(){try{let e=await this.api.get(l.usersMePath);return this.session.updateIdentityToken(e.identity_token),p.convertUserResponseToUser(e.user)}catch(e){throw s.formatPrivyError(e)}}async scanTransaction(e){try{return await this.api.post(l.transactionScanningPath,e)}catch(e){throw s.formatPrivyError(e)}}constructor({apiUrl:e=m.DEFAULT_PRIVY_API_URL,appId:t,appClientId:r,timeout:n=m.DEFAULT_API_TIMEOUT_MS}){Object.defineProperty(this,Ot,{value:Nt}),this._cachedProviderAppDetails={},this.apiUrl=e,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=e!==m.DEFAULT_PRIVY_API_URL&&e.startsWith("https://privy."),this.timeout=n,this.appId=t,this.appClientId=r,this.clientAnalyticsId=function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}(this,Ot)[Ot](),xt||(xt=new It),this.session=xt,this.api=this.generateApi(),this.session.client=this}}function Nt(){if("undefined"==typeof window)return null;try{let e=de.get(m.CLIENT_ANALYTICS_ID_KEY);if("string"==typeof e&&e.length>0)return e}catch(e){}let e=u.v4();try{return de.put(m.CLIENT_ANALYTICS_ID_KEY,e),e}catch(t){return e}}function Mt(){if(!Wt)throw new s.PrivyClientError("No global PrivyClient instance found. Please ensure you have initialized the PrivyProvider.");return Wt}let Dt=/*#__PURE__*/r.createContext({plugins:{current:{}}});const Lt=()=>{let{plugins:e}=r.useContext(Dt);return r.useCallback((t=>e.current[t]),[e])};class Ft{get meta(){return this._meta}async authenticate(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!this.meta.channelToken)throw new s.PrivyClientError("Auth flow must be initialized first");try{let e=await this.api.post(l.farcasterAuthenticatePath,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});if(!e)throw new s.PrivyClientError("No response from authentication");return e}catch(e){throw s.formatApiError(e)}}async link(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(l.farcasterLinkPath,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw s.formatApiError(e)}}async _startChannelOnce(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");let e=await this.api.post(l.farcasterInitPath,{token:this.captchaToken});n.isMobile&&!n.isIOS&&e.connect_uri&&Je(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!this.meta.channelToken)throw new s.PrivyClientError("Auth flow must be initialized first");let e=await this.api.get(l.farcasterStatusPath,{headers:{"farcaster-channel-token":this.meta.channelToken}});return"completed"===e.state&&(this.message=e.message,this.signature=e.signature,this.fid=e.fid,!0)}constructor(e,t=!1){this._meta={disableSignup:!1},this.captchaToken=e,this.startChannelOnce=new Ct(this._startChannelOnce.bind(this)),this.pollForReady=new Ct(this._pollForReady.bind(this)),this._meta.disableSignup=t}}class jt{async initRegisterFlow(e){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");this.authenticateForRegistration=!0,this.meta.initRegisterResponse=await this.initRegisterOnce.execute(e)}async initAuthenticationFlow(e){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async register(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new s.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initRegisterResponse||(this.meta.initRegisterResponse=await this.initRegisterOnce.execute());try{let t=this.meta.initRegisterResponse.options,r=await e.startRegistration({optionsJSON:this._transformInitLinkOptionsToCamelCase(t)});return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(l.passkeyRegisterPath,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new s.PrivyClientError("Passkey request timed out or rejected by user.",void 0,s.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw s.formatApiError(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new s.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());let t=this.meta.allowedCredentialsIds?.map((e=>({type:"public-key",id:e})))??this.meta.initAuthenticateResponse.options.allow_credentials;try{let r=await e.startAuthentication({optionsJSON:this._transformInitAuthenticateOptionsToCamelCase({...this.meta.initAuthenticateResponse.options,allow_credentials:t})});return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(l.passkeyAuthenticatePath,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new s.PrivyClientError("Passkey request timed out or rejected by user.",void 0,s.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw s.formatApiError(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new s.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let t=this.meta.initLinkResponse.options,r=await e.startRegistration({optionsJSON:this._transformInitLinkOptionsToCamelCase(t)});return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(l.passkeyLinkPath,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new s.PrivyClientError("Passkey request timed out or rejected by user.",void 0,s.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw s.formatApiError(e)}}async _initRegisterOnce(e){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");let t=st(e);return await this.api.post(l.passkeyInitRegisterPath,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");let t=st(e);return await this.api.post(l.passkeyInitAuthenticatePath,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");return await this.api.post(l.passkeyInitLinkPath,{})}_transformInitLinkOptionsToCamelCase(e){return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params.map((e=>({type:e.type,alg:e.alg}))),timeout:e.timeout,excludeCredentials:e.exclude_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports}))),authenticatorSelection:{authenticatorAttachment:e.authenticator_selection?.authenticator_attachment,requireResidentKey:e.authenticator_selection?.require_resident_key,residentKey:e.authenticator_selection?.resident_key,userVerification:e.authenticator_selection?.user_verification},attestation:e.attestation,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props?.rk,hmacCreateSecret:e.extensions?.hmac_create_secret},hints:this.meta.hints}}_transformRegistrationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}_transformInitAuthenticateOptionsToCamelCase(e){return{rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}}_transformAuthenticationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}constructor({captchaToken:e,setPasskeyAuthState:t,hints:r}){this.authenticateForRegistration=!1,this.initRegisterOnce=new Ct(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new Ct(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Ct(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t,hints:r}}}const qt=({address:e,nonce:t})=>`${window.location.host} wants you to sign in with your Solana account:\n${e}\n\n${`You are proving you own ${e}.`}\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: mainnet\nNonce: ${t}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`;class zt{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup,messageType:this._meta.messageType,address:this.wallet?.address}}set messageType(e){this._meta.messageType=e}async authenticate(){if(!this.client)throw new s.PrivyClientError("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up",messageType:this.meta.messageType})}catch(e){throw s.formatApiError(e)}}async link(){if(!this.client)throw new s.PrivyClientError("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,messageType:this.meta.messageType})}catch(e){throw s.formatApiError(e)}}async sign(){let e,t;if(!this.client)throw new s.PrivyClientError("SiwsFlow has no client instance");await this.buildMessage();let r="transaction"===this.meta.messageType;if(!this.preparedMessage)throw new s.PrivyClientError("Could not prepare SIWS message");if(!r&&!this.wallet.provider.signMessage||r&&!this.wallet.provider.signTransaction)throw new s.PrivyClientError("Wallet does not support the necessary signing methods");if(r&&this._plugin){let r=await this.wallet.provider.signTransaction({transaction:c.base64.decode(this.preparedMessage)});e=c.base64.encode(r.signedTransaction),t=this._plugin.getSignatureFromTransaction(r.signedTransaction,this.wallet.address)}else{e=this.preparedMessage;let r=await this.wallet.provider.signMessage({message:(new TextEncoder).encode(this.preparedMessage)});t=c.base64.encode(r.signature)}return{message:e,signature:t}}async _getNonceOnce(){if(!this.client)throw new s.PrivyClientError("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new s.PrivyClientError("SiwsFlow has no client instance");let e=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),"transaction"===this.meta.messageType&&this._plugin?this.preparedMessage=this._plugin.createSiwsMemoTransaction({address:e,nonce:this.nonce}):this.preparedMessage=qt({address:e,nonce:this.nonce}),this.preparedMessage}constructor(e,t,r,n=!1,i="plain",a){this._meta={disableSignup:!1,messageType:"plain"},this.getNonceOnce=new Ct(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=r,this.client=t,this._meta.disableSignup=n,this._meta.messageType=i,this._plugin=a}}const Kt=/*#__PURE__*/r.createContext({enabled:!1,siteKey:"",provider:void 0,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:s.notImplemented,setError:s.notImplemented,setExecuting:s.notImplemented,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:s.noop,reset:s.notImplemented,execute:s.notImplemented});class Bt extends s.PrivyError{constructor(e,t,r){super(e||"Captcha failed"),this.type="Captcha",t instanceof Error&&(this.cause=t),this.privyErrorCode=r}}const Ht=({children:t,appId:n,captchaSiteKey:i,enabledCaptchaProvider:a})=>{let o=r.useRef(null),l=r.useRef(null),[c,d]=r.useState(),[u,h]=r.useState(),[p,y]=r.useState(!1),w=r.useMemo((()=>a?p||c||u?!p||c||u?c&&!u?{status:"success",token:c}:u?{status:"error",error:u}:{status:"ready"}:{status:"loading"}:{status:"ready"}:{status:"disabled"}),[a,c,u,p]),m=r.useMemo((()=>a?"turnstile"===a?{remove:()=>{o.current?.remove(),y(!1),h(void 0),d(void 0)},reset:()=>{o.current?.reset(),y(!1),h(void 0),d(void 0)},execute:()=>{y(!0),o.current?.execute()},waitForResult:async()=>{try{return await Y((()=>o.current?.getResponse()),{interval:200,timeout:2e4})}catch(e){throw new Bt("Captcha failed",null,s.PrivyErrorCode.CAPTCHA_TIMEOUT)}}}:{remove:()=>{l.current?.removeCaptcha(),y(!1),h(void 0),d(void 0)},reset:()=>{l.current?.resetCaptcha(),y(!1),h(void 0),d(void 0)},execute:()=>{y(!0),l.current?.execute()},waitForResult:async()=>{try{return await Y((()=>{let e=l.current?.getResponse();if(e)return e}),{interval:200,timeout:2e4})}catch(e){throw new Bt("Captcha failed",null,s.PrivyErrorCode.CAPTCHA_TIMEOUT)}}}:null),[a]),v=r.useMemo((()=>{if(!a||!m)return{...w,enabled:!1,siteKey:"",appId:n,setToken:s.notImplemented,setError:s.notImplemented,setExecuting:s.notImplemented,waitForResult:()=>Promise.resolve(void 0),remove:s.noop,reset:s.notImplemented,execute:s.notImplemented,provider:void 0,ref:{current:null}};let e={...w,enabled:!0,appId:n,setToken:d,setError:h,setExecuting:y};return"turnstile"===a?{...e,provider:"turnstile",ref:o,siteKey:i.split("t:")[1]??"",...m}:{...e,provider:"hcaptcha",ref:l,siteKey:i.split("h:")[1]??"",...m}}),[w,a,m,n,i]);/*#__PURE__*/return e.jsx(Kt.Provider,{value:v,children:t})},Vt=()=>r.useContext(Kt);class Yt{async authenticate(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(l.telegramAccountAuthenticatePath,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw s.formatApiError(e)}}async link(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(l.telegramAccountLinkPath,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw s.formatApiError(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function $t(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function Gt(){let e=new URL(window.location.href);e.searchParams.delete("id"),e.searchParams.delete("hash"),e.searchParams.delete("auth_date"),e.searchParams.delete("first_name"),e.searchParams.delete("last_name"),e.searchParams.delete("username"),e.searchParams.delete("photo_url"),e.hash="",window.history.replaceState({},"",e)}async function Jt(){let e=Mt();return e?e.getAccessToken():Promise.resolve(de.get(m.PRIVY_ACCESS_TOKEN_STORAGE_KEY)||de.get(m.CUSTOMER_ACCESS_TOKEN_STORAGE_KEY)||null)}let Zt=/*#__PURE__*/r.lazy((()=>Promise.resolve().then((function(){return require("./TurnstileWrapper-qLN0G5m7.js")})))),Qt=/*#__PURE__*/r.lazy((()=>Promise.resolve().then((function(){return require("./HCaptchaWrapper-CxqJE5RH.js")}))));const Xt=t=>{let n=Vt();return r.useEffect((()=>n.remove),[n.remove]),n.enabled&&n.provider?/*#__PURE__*/e.jsx(r.Suspense,{fallback:null,children:/*#__PURE__*/e.jsxs("div",{className:"hidden h-0 w-0",children:["turnstile"===n.provider&&/*#__PURE__*/e.jsx(Zt,{...t,captchaContext:n}),"hcaptcha"===n.provider&&/*#__PURE__*/e.jsx(Qt,{...t,captchaContext:n})]})}):null};var er=/*#__PURE__*/Object.freeze({__proto__:null,AccountNotFoundScreen:()=>Promise.resolve().then((function(){return require("./AccountNotFoundScreen-Clo67iWH.js")})),AffirmativeConsentScreen:()=>Promise.resolve().then((function(){return require("./AffirmativeConsentScreen-2FGovWDj.js")})),AllowlistRejectionScreen:()=>Promise.resolve().then((function(){return require("./AllowlistRejectionScreen-BLcPF2_b.js")})),AuthenticateWithWalletScreen:()=>Promise.resolve().then((function(){return require("./AuthenticateWithWalletScreen-ByOwd0gq.js")})),AwaitingEvmToSolBridgingScreen:()=>Promise.resolve().then((function(){return require("./AwaitingEvmToSolBridgingScreen-D_dh3tgw.js")})),AwaitingExternalEthereumTransferScreen:()=>Promise.resolve().then((function(){return require("./AwaitingExternalEthereumTransferScreen-CB4SnTRS.js")})),AwaitingPasswordlessCodeScreen:()=>Promise.resolve().then((function(){return require("./AwaitingPasswordlessCodeScreen-D43lCvaw.js")})),AwaitingSolToEvmBridgingScreen:()=>Promise.resolve().then((function(){return require("./AwaitingSolToEvmBridgingScreen-ppOL2XCp.js")})),CaptchaScreen:()=>Promise.resolve().then((function(){return require("./CaptchaScreen-oTaZlLej.js")})),CoinbaseOnrampStatusScreen:()=>Promise.resolve().then((function(){return require("./CoinbaseOnrampStatusScreen-CO97CoDr.js")})),ConnectLedgerScreen:()=>Promise.resolve().then((function(){return require("./ConnectLedgerScreen-3SrqHJBl.js")})),ConnectOnlyLandingScreen:()=>Promise.resolve().then((function(){return require("./ConnectOnlyLandingScreen-DkR-VnS2.js")})),ConnectOnlyStatusScreen:()=>Promise.resolve().then((function(){return require("./ConnectOnlyStatusScreen-Cafk-5gS.js")})),ConnectOrCreateScreen:()=>Promise.resolve().then((function(){return require("./ConnectOrCreateScreen-DttF-fCs.js")})),ConnectionStatusScreen:()=>Promise.resolve().then((function(){return require("./ConnectionStatusScreen-BfU_d8ZK.js")})),CrossAppAuthScreen:()=>Promise.resolve().then((function(){return require("./CrossAppAuthScreen-Bs_x-Isw.js")})),DelegatedActionsConsentScreen:()=>Promise.resolve().then((function(){return require("./DelegatedActionsConsentScreen-Cx5lj2BJ.js")})),DelegatedActionsRevokeScreen:()=>Promise.resolve().then((function(){return require("./DelegatedActionsRevokeScreen-BEucV6g6.js")})),EmbeddedWalletConnectingScreen:()=>Promise.resolve().then((function(){return require("./EmbeddedWalletConnectingScreen-BjZ_7QsX.js")})),EmbeddedWalletCreatedScreen:()=>Promise.resolve().then((function(){return require("./EmbeddedWalletCreatedScreen-CbmJzZZL.js")})),EmbeddedWalletKeyExportScreen:()=>Promise.resolve().then((function(){return require("./EmbeddedWalletKeyExportScreen-CdMuowdD.js")})),EmbeddedWalletOnAccountCreateScreen:()=>Promise.resolve().then((function(){return require("./EmbeddedWalletOnAccountCreateScreen-C_EBP_oR.js")})),EmbeddedWalletPasswordCreateScreen:()=>Promise.resolve().then((function(){return require("./RecoveryPasswordCreateScreen-Bg-E6CB6.js")})),EmbeddedWalletPasswordUpdateScreen:()=>Promise.resolve().then((function(){return require("./EmbeddedWalletPasswordUpdateScreen-DQhHO_tI.js")})),EmbeddedWalletPasswordUpdateSplashScreen:()=>Promise.resolve().then((function(){return require("./EmbeddedWalletPasswordUpdateSplashScreen-C1dTDHuI.js")})),ErrorScreen:()=>Promise.resolve().then((function(){return require("./ErrorScreen-CPDISQKp.js")})),FarcasterConnectStatusScreen:()=>Promise.resolve().then((function(){return require("./FarcasterConnectStatusScreen-DuOFuio7.js")})),FarcasterSignerStatusScreen:()=>Promise.resolve().then((function(){return require("./FarcasterSignerStatusScreen-BYnokloK.js")})),FundSolWalletWithExternalSolanaWallet:()=>Promise.resolve().then((function(){return require("./FundSolWalletWithExternalSolanaWallet-D-pMJTgQ.js")})),FundingAmountEditScreen:()=>Promise.resolve().then((function(){return require("./FundingEditAmountScreen-CGYBcgzY.js")})),FundingMethodSelectionScreen:()=>Promise.resolve().then((function(){return require("./FundingMethodSelectionScreen-32rXIiuR.js")})),InAppBrowserLoginNotPossible:()=>Promise.resolve().then((function(){return require("./InAppBrowserLoginNotPossible-Wz6tWwN4.js")})),InstallWalletScreen:()=>Promise.resolve().then((function(){return require("./InstallWalletScreen-C6na1HMV.js")})),LandingScreen:()=>Promise.resolve().then((function(){return require("./LandingScreen-GYoGjPT7.js")})),LinkConflictScreen:()=>Promise.resolve().then((function(){return require("./LinkConflictScreen-8h7pmzsL.js")})),LinkEmailScreen:()=>Promise.resolve().then((function(){return require("./LinkEmailScreen-Bz6DBn1S.js")})),LinkPasskeyScreen:()=>Promise.resolve().then((function(){return require("./LinkPasskeyScreen-cUu7WCqn.js")})),LinkPhoneScreen:()=>Promise.resolve().then((function(){return require("./LinkPhoneScreen-BFB7atSV.js")})),LoginFailedScreen:()=>Promise.resolve().then((function(){return require("./LoginFailedScreen-C3X4o4W8.js")})),ManualTransferScreen:()=>Promise.resolve().then((function(){return require("./ManualTransferScreen-Bx5GRcIk.js")})),MfaAuthEnrollmentFlowScreen:()=>Promise.resolve().then((function(){return require("./MfaAuthEnrollmentFlowScreen-D8DE5e8S.js")})),MfaAuthVerifyFlowScreen:()=>Promise.resolve().then((function(){return require("./MfaAuthVerifyFlowScreen-BeJSdbHB.js")})),MfaEnrollmentFlowScreen:()=>Promise.resolve().then((function(){return require("./MfaEnrollmentFlowScreen-0X-6htEq.js")})),MoonpayStatusScreen:()=>Promise.resolve().then((function(){return require("./MoonpayStatusScreen-BWA_sZnz.js")})),OAuthStatusScreen:()=>Promise.resolve().then((function(){return require("./OAuthStatusScreen-DZbrwgcX.js")})),PasskeySelectSignupOrLogin:()=>Promise.resolve().then((function(){return require("./PasskeySelectSignupOrLogin-DWW-VE2d.js")})),PasskeyStatusScreen:()=>Promise.resolve().then((function(){return require("./PasskeyStatusScreen-DiieGaFn.js")})),PasswordRecoveryScreen:()=>Promise.resolve().then((function(){return require("./PasswordRecoveryScreen-OhRzyQhB.js")})),RecoveryOAuthScreen:()=>Promise.resolve().then((function(){return require("./RecoveryOAuthStatusScreen-DPPwIU7C.js")})),RecoverySelectionScreen:()=>Promise.resolve().then((function(){return require("./RecoverySelectionScreen-CauE_byN.js")})),SendTransactionScreen:()=>Promise.resolve().then((function(){return require("./index-LczlN1Dt.js")})),SetAutomaticRecoveryScreen:()=>Promise.resolve().then((function(){return require("./SetAutomaticRecoveryScreen-59UByZZC.js")})),SignRequestScreen:()=>Promise.resolve().then((function(){return require("./SignRequestScreen-CYQvIjLY.js")})),StandardSignAndSendTransactionScreen:()=>Promise.resolve().then((function(){return require("./StandardSignAndSendTransactionScreen-C0Af9uPz.js")})),TelegramAuthScreen:()=>Promise.resolve().then((function(){return require("./TelegramAuthScreen-DxghStcs.js")})),TransferFromWalletScreen:()=>Promise.resolve().then((function(){return require("./TransferFromWalletScreen-DSMlo8kv.js")})),UpdateEmailScreen:()=>Promise.resolve().then((function(){return require("./UpdateEmailScreen-CrTIJ16u.js")})),UpdatePhoneScreen:()=>Promise.resolve().then((function(){return require("./UpdatePhoneScreen-DQzmlkOL.js")})),UserLimitReachedScreen:()=>Promise.resolve().then((function(){return require("./UserLimitReachedScreen-BQxNahAD.js")})),WalletInterstitialScreen:()=>Promise.resolve().then((function(){return require("./WalletInterstitialScreen-CMMSgAk9.js")}))});const tr=e=>{let[t,n]=r.useState("auto");return r.useEffect((()=>{let t=new ResizeObserver((e=>{n(e[0]?.contentRect.height??"auto")}));return e.current&&t.observe(e.current),()=>{e.current&&t.unobserve(e.current)}}),[e.current]),t};function rr(e){A.usePrivyEventSubscription("configureMfa",e)}const nr=C.styled.div`
2
- text-align: left;
3
- flex-grow: 1;
4
- `,ir=C.styled.div`
5
- display: flex;
6
- flex-direction: column;
7
- justify-content: flex-end;
8
- flex-grow: 1;
9
- `,ar=C.styled.div`
10
- display: flex;
11
- flex-direction: column;
12
- gap: 8px;
13
-
14
- /* for Internet Explorer, Edge */
15
- -ms-overflow-style: none;
16
-
17
- /* for Firefox */
18
- scrollbar-width: none;
19
-
20
- /* for Chrome, Safari, and Opera */
21
- &::-webkit-scrollbar {
22
- display: none;
23
- }
24
- `,or=C.styled(ar)`
25
- ${e=>"light"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.06)) bottom;":"dark"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.06)) bottom;":void 0}
26
-
27
- background-repeat: no-repeat;
28
- background-size:
29
- 100% 32px,
30
- 100% 16px;
31
- background-attachment: local, scroll;
32
- max-height: 400px;
33
- overflow-y: auto;
34
- scrollbar-width: none;
35
- padding: 3px;
36
- `;let sr=C.css`
37
- && {
38
- width: 100%;
39
- font-size: 16px;
40
- line-height: 24px;
41
- min-height: 56px;
42
-
43
- /* Tablet and Up */
44
- @media (min-width: 440px) {
45
- font-size: 14px;
46
- }
47
-
48
- display: flex;
49
- gap: 12px;
50
- align-items: center;
51
- color: var(--privy-color-foreground);
52
-
53
- padding: 10px 12px;
54
- border: 1px solid var(--privy-color-foreground-4) !important;
55
- border-radius: var(--privy-border-radius-md);
56
- transition: background-color 200ms ease;
57
-
58
- cursor: pointer;
59
-
60
- &:hover {
61
- background-color: var(--privy-color-background-2);
62
- }
63
-
64
- &:disabled {
65
- cursor: pointer;
66
- background-color: var(--privy-color-background-2);
67
- }
68
- }
69
- `;const lr=C.styled.div`
70
- text-align: center;
71
- font-size: 14px;
72
- margin-bottom: 24px;
73
- `,cr=C.styled.button.attrs({className:"login-method-button"})`
74
- ${sr}
75
- `;C.styled.a`
76
- ${sr}
77
- `;const dr=C.styled.div`
78
- width: 32px;
79
- height: 32px;
80
- border-radius: ${e=>e.$fullSize?"0":"4px"};
81
- background: ${e=>e.$fullSize?"transparent":"var(--privy-color-background-2)"};
82
- display: flex;
83
- align-items: center;
84
- justify-content: center;
85
- flex-shrink: 0;
86
-
87
- svg {
88
- width: ${e=>e.$fullSize?"32px":"18px"};
89
- height: ${e=>e.$fullSize?"32px":"18px"};
90
- color: ${e=>e.$fullSize?"inherit":"var(--privy-color-icon-muted)"};
91
- }
92
- `,ur=C.styled.div`
93
- width: 100%;
94
- height: 100%;
95
- min-height: inherit;
96
- display: flex;
97
- flex-direction: column;
98
- ${e=>e.$if?"display: none;":""}
99
- `,hr=C.styled.div`
100
- width: 100%;
101
- height: 100%;
102
- padding: ${e=>e.$withPadding?"64px 0px":"0px"};
103
- `,pr=C.styled.div`
104
- display: flex;
105
- flex-direction: column;
106
- align-items: center;
107
- justify-content: center;
108
- margin-bottom: 32px;
109
- gap: 12px;
110
- & h3 {
111
- font-size: 18px;
112
- font-style: normal;
113
- font-weight: 600;
114
- line-height: 24px;
115
- }
116
- & p {
117
- max-width: 300px;
118
- font-size: 14px;
119
- font-style: normal;
120
- font-weight: 400;
121
- line-height: 20px;
122
- }
123
- `,yr=w.create((()=>({inProgressMfaFlow:void 0})));const wr=C.createGlobalStyle`
124
- :root {
125
- ${e=>mr(e.palette)}
126
- };
127
- `;const mr=e=>{let t=function(e){return{"--privy-color-background":e.background,"--privy-color-background-2":e.background2,"--privy-color-background-3":e.background3,"--privy-color-foreground":e.foreground,"--privy-color-foreground-2":e.foreground2,"--privy-color-foreground-3":e.foreground3,"--privy-color-foreground-4":e.foreground4,"--privy-color-foreground-accent":e.foregroundAccent,"--privy-color-accent":e.accent,"--privy-color-accent-light":e.accentLight,"--privy-color-accent-hover":e.accentHover,"--privy-color-accent-dark":e.accentDark,"--privy-color-accent-darkest":e.accentDarkest,"--privy-color-success":e.success,"--privy-color-success-dark":e.successDark,"--privy-color-success-light":e.successLight,"--privy-color-success-bg":e.successBg,"--privy-color-error":e.error,"--privy-color-error-light":e.errorLight,"--privy-color-error-bg":e.errorBg,"--privy-color-error-bg-hover":e.errorBgHover,"--privy-color-warn":e.warn,"--privy-color-warn-light":e.warnLight,"--privy-color-warn-bg":e.warnBg,"--privy-color-warning-dark":e.warningDark,"--privy-color-error-dark":e.errorDark,"--privy-color-info-bg":e.infoBg,"--privy-color-info-bg-hover":e.infoBgHover,"--privy-color-border-default":e.borderDefault,"--privy-color-border-hover":e.borderHover,"--privy-color-border-focus":e.borderFocus,"--privy-color-border-error":e.borderError,"--privy-color-border-success":e.borderSuccess,"--privy-color-border-warning":e.borderWarning,"--privy-color-border-info":e.borderInfo,"--privy-color-border-interactive":e.borderInteractive,"--privy-color-border-interactive-hover":e.borderInteractiveHover,"--privy-color-background-hover":e.backgroundHover,"--privy-color-background-clicked":e.backgroundClicked,"--privy-color-background-disabled":e.backgroundDisabled,"--privy-color-background-interactive":e.backgroundInteractive,"--privy-color-background-interactive-hover":e.backgroundInteractiveHover,"--privy-color-background-interactive-clicked":e.backgroundInteractiveClicked,"--privy-color-background-interactive-disabled":e.backgroundInteractiveDisabled,"--privy-color-foreground-hover":e.foregroundHover,"--privy-color-foreground-clicked":e.foregroundClicked,"--privy-color-foreground-disabled":e.foregroundDisabled,"--privy-color-foreground-interactive":e.foregroundInteractive,"--privy-color-foreground-interactive-hover":e.foregroundInteractiveHover,"--privy-link-navigation-color":e.linkNavigationColor,"--privy-link-navigation-decoration":e.linkNavigationDecoration,"--privy-accent-has-good-contrast":e.accentHasGoodContrast,"--privy-color-icon-default":e.iconDefault,"--privy-color-icon-muted":e.iconMuted,"--privy-color-icon-subtle":e.iconSubtle,"--privy-color-icon-inverse":e.iconInverse,"--privy-color-icon-success":e.iconSuccess,"--privy-color-icon-warning":e.iconWarning,"--privy-color-icon-error":e.iconError,"--privy-color-icon-interactive":e.iconInteractive,"--privy-color-icon-default-hover":e.iconDefaultHover,"--privy-color-icon-muted-hover":e.iconMutedHover,"--privy-color-icon-subtle-hover":e.iconSubtleHover,"--privy-color-icon-default-clicked":e.iconDefaultClicked,"--privy-color-icon-muted-clicked":e.iconMutedClicked,"--privy-color-icon-subtle-clicked":e.iconSubtleClicked,"--privy-color-icon-default-disabled":e.iconDefaultDisabled,"--privy-color-icon-muted-disabled":e.iconMutedDisabled,"--privy-color-icon-subtle-disabled":e.iconSubtleDisabled,"--privy-color-icon-error-hover":e.iconErrorHover,"--privy-color-icon-interactive-hover":e.iconInteractiveHover,"--privy-color-icon-error-clicked":e.iconErrorClicked,"--privy-color-icon-interactive-clicked":e.iconInteractiveClicked,"--privy-color-icon-muted-disabled-alt":e.iconMutedDisabledAlt,"--privy-color-icon-subtle-disabled-alt":e.iconSubtleDisabledAlt,"--privy-border-radius-xs":"6px","--privy-border-radius-sm":"8px","--privy-border-radius-md":"12px","--privy-border-radius-mdlg":"16px","--privy-border-radius-lg":"24px","--privy-border-radius-full":"9999px","--privy-height-modal-full":"620px","--privy-height-modal-compact":"480px"}}(e);return C.css`
128
- ${Object.entries(t).map((([e,t])=>`${e}: ${t};`)).join("\n")}
129
- `},vr=C.styled.div`
130
- // css normalize only the privy application to avoid conflicts
131
- // with consuming application
132
- ${"\n *,\n ::before,\n ::after {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n }\n\n line-height: 1.15;\n -webkit-text-size-adjust: 100%;\n -moz-tab-size: 4;\n tab-size: 4;\n font-feature-settings: normal;\n\n margin: 0;\n font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji';\n\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n\n abbr:where([title]) {\n text-decoration: underline dotted;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji';\n display: inline;\n }\n\n a {\n color: inherit;\n text-decoration: inherit;\n }\n\n b,\n strong {\n font-weight: bolder;\n }\n\n code,\n kbd,\n samp,\n pre {\n font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;\n font-size: 1em;\n }\n\n small {\n font-size: 80%;\n }\n\n sub,\n sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n\n sub {\n bottom: -0.25em;\n }\n\n sup {\n top: -0.5em;\n }\n\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n\n button,\n input,\n optgroup,\n select,\n textarea {\n font-family: inherit;\n font-size: 100%;\n font-weight: inherit;\n line-height: inherit;\n color: inherit;\n margin: 0;\n padding: 0;\n }\n\n button,\n select {\n text-transform: none;\n }\n\n button,\n [type='button'],\n [type='reset'],\n [type='submit'] {\n -webkit-appearance: button;\n background-color: transparent;\n background-image: none;\n }\n\n ::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n\n :-moz-focusring {\n outline: 1px dotted ButtonText;\n }\n\n :-moz-ui-invalid {\n box-shadow: none;\n }\n\n legend {\n padding: 0;\n }\n\n progress {\n vertical-align: baseline;\n }\n\n ::-webkit-inner-spin-button,\n ::-webkit-outer-spin-button {\n height: auto;\n }\n\n [type='search'] {\n -webkit-appearance: textfield;\n outline-offset: -2px;\n }\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n ::-webkit-file-upload-button {\n -webkit-appearance: button;\n font: inherit;\n }\n\n summary {\n display: list-item;\n }\n\n blockquote,\n dl,\n dd,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n hr,\n figure,\n p,\n pre {\n margin: 0;\n }\n\n fieldset {\n margin: 0;\n padding: 0;\n }\n\n legend {\n padding: 0;\n }\n\n ol,\n ul,\n menu {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n textarea {\n resize: vertical;\n }\n\n input::placeholder,\n textarea::placeholder {\n opacity: 1;\n color: #9ca3af;\n }\n\n button,\n [role='button'] {\n cursor: pointer;\n }\n\n :disabled {\n cursor: default;\n }\n\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block;\n }\n\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n\n [hidden] {\n display: none;\n }\n"}
133
-
134
- // Privy styles
135
- color: var(--privy-color-foreground-2);
136
-
137
- h3 {
138
- font-size: 16px;
139
- line-height: 24px;
140
- font-weight: 500;
141
- color: var(--privy-color-foreground-2);
142
- }
143
-
144
- h4 {
145
- font-size: 14px;
146
- line-height: 20px;
147
- font-weight: 500;
148
- color: var(--privy-color-foreground);
149
- }
150
-
151
- p {
152
- font-size: 13px;
153
- line-height: 20px;
154
- color: var(--privy-color-foreground-2);
155
- }
156
-
157
- button:focus,
158
- input:focus,
159
- optgroup:focus,
160
- select:focus,
161
- textarea:focus {
162
- outline: none;
163
- border-color: var(--privy-color-accent-light);
164
- box-shadow: 0 0 0 3px var(--privy-color-border-focus);
165
- }
166
-
167
- .mobile-only {
168
- @media (min-width: 441px) {
169
- display: none;
170
- }
171
- }
172
-
173
- /* Animations */
174
-
175
- @keyframes fadein {
176
- 0% {
177
- opacity: 0;
178
- }
179
- 100% {
180
- opacity: 1;
181
- }
182
- }
183
- `,gr=({children:t,open:r,onClick:n,...i})=>/*#__PURE__*/e.jsx(P.Transition,{show:r,as:S.default.Fragment,children:/*#__PURE__*/e.jsxs(P.Dialog,{onClose:n,...i,as:Er,children:[/*#__PURE__*/e.jsx(P.TransitionChild,{as:S.default.Fragment,enterFrom:"entering",leaveTo:"leaving",children:/*#__PURE__*/e.jsx(fr,{id:"privy-dialog-backdrop","aria-hidden":"true"})}),/*#__PURE__*/e.jsx(Cr,{children:/*#__PURE__*/e.jsx(P.TransitionChild,{as:S.default.Fragment,enterFrom:"entering",leaveTo:"leaving",children:/*#__PURE__*/e.jsx(P.DialogPanel,{as:Ar,children:t})})})]})});let fr=C.styled.div`
184
- position: fixed;
185
- inset: 0;
186
-
187
- transition: backdrop-filter 100ms ease;
188
- backdrop-filter: blur(3px);
189
- -webkit-backdrop-filter: blur(3px);
190
-
191
- &.entering,
192
- &.leaving {
193
- backdrop-filter: unset;
194
- -webkit-backdrop-filter: unset;
195
- }
196
- `,Er=C.styled.div`
197
- position: relative;
198
- z-index: 999999;
199
- `,Cr=C.styled.div`
200
- position: fixed;
201
- inset: 0;
202
- display: flex;
203
- align-items: center;
204
- justify-content: center;
205
- width: 100vw;
206
- min-height: 100vh;
207
- `;const Ar=C.styled.div`
208
- // reset some default dialog styles
209
- padding: 0;
210
- background: transparent;
211
- border: none;
212
- width: 100%;
213
- pointer-events: auto;
214
-
215
- outline: none;
216
- display: block;
217
-
218
- /*
219
- * Normally it is bad to mix media queries like this We are doing
220
- * this here specifically for animations to avoid weird jank.
221
- */
222
- /* Mobile animation is a bottom drawer */
223
- @media (max-width: 440px) {
224
- opacity: 1;
225
- transform: translate3d(0, 0, 0);
226
- transition: transform 200ms ease-in;
227
- position: fixed;
228
- bottom: 0;
229
-
230
- &.entering,
231
- &.leaving {
232
- opacity: 0;
233
- transform: translate3d(0, 100%, 0);
234
- transition:
235
- transform 150ms ease-in 0ms,
236
- opacity 0ms ease 150ms;
237
- }
238
- }
239
-
240
- /* Tablet/Desktop animation is a fade in */
241
- @media (min-width: 441px) {
242
- opacity: 1;
243
- transition: opacity 100ms ease-in;
244
-
245
- &.entering,
246
- &.leaving {
247
- opacity: 0;
248
- transition-delay: 5ms;
249
- }
250
-
251
- margin: auto;
252
- width: 360px;
253
- box-shadow: 0px 8px 36px rgba(55, 65, 81, 0.15);
254
- border-radius: var(--privy-border-radius-lg);
255
- }
256
- `;C.styled.div`
257
- display: flex;
258
- flex-direction: column;
259
- align-items: center;
260
- justify-content: center;
261
- height: 100%;
262
- `;let Pr=C.styled.span`
263
- && {
264
- position: absolute;
265
- top: 0;
266
- left: 0;
267
- z-index: 2;
268
- }
269
- `,Tr=C.styled.span`
270
- position: relative;
271
- width: 82px;
272
- height: 82px;
273
- display: inline-block;
274
- `;const _r=C.styled.span`
275
- && {
276
- width: 82px;
277
- height: 82px;
278
- border-width: 4px;
279
- border-style: solid;
280
- border-color: ${e=>e.color??"var(--privy-color-icon-subtle)"};
281
- border-bottom-color: transparent;
282
- border-radius: 50%;
283
- display: inline-block;
284
- box-sizing: border-box;
285
- animation: rotation 1.2s linear infinite;
286
- transition: border-color 800ms;
287
- }
288
-
289
- @keyframes rotation {
290
- 0% {
291
- transform: rotate(0deg);
292
- }
293
- 100% {
294
- transform: rotate(360deg);
295
- }
296
- }
297
-
298
- &&&.success {
299
- border-color: var(--privy-color-icon-success);
300
- border-bottom-color: var(--privy-color-icon-success);
301
- }
302
-
303
- &&&.fail {
304
- border-color: var(--privy-color-icon-error);
305
- border-bottom-color: var(--privy-color-icon-error);
306
- }
307
- `,br=C.styled(_r)`
308
- && {
309
- border-bottom-color: ${e=>e.color??"var(--privy-color-border-default)"};
310
- border-color: ${e=>e.color??"var(--privy-color-border-default)"};
311
- animation: none;
312
- opacity: 0.5;
313
- }
314
- `;let kr=C.styled(_r)`
315
- && {
316
- height: 1rem;
317
- width: 1rem;
318
- margin: 2px 0;
319
- border-width: 1.5px;
320
-
321
- /* Override default Loader to match button transitions */
322
- transition: border-color 200ms ease;
323
- }
324
- `;const Sr=()=>{let{ready:e}=p.usePrivyContext(),{currentScreen:t}=p.usePrivyModal(),[n,i]=r.useState(null),[a,o]=r.useState(!1),s=function(e){let[t,n]=r.useState(!1),i=r.useRef(null),a=r.useRef(null),o=r.useRef(null);return r.useEffect((()=>{if(i.current&&(clearTimeout(i.current),i.current=null),a.current&&(clearTimeout(a.current),a.current=null),e)o.current=Date.now(),i.current=setTimeout((()=>{n(!0)}),150);else if(null!==o.current){let e=Date.now()-o.current;if(e>=150){let t=Math.max(0,400-(e-150));a.current=setTimeout((()=>{n(!1),o.current=null}),t)}else i.current&&(clearTimeout(i.current),i.current=null),n(!1),o.current=null}return()=>{i.current&&clearTimeout(i.current),a.current&&clearTimeout(a.current)}}),[e]),t}(a);return r.useEffect((()=>{if(!t)return i(null),void o(!1);o(!0),er[t]().then((r=>{(!t||e||r.default.isShownBeforeReady)&&(i((()=>r.default.component)),o(!1))})).catch((()=>{i(null),o(!1)}))}),[t,e]),{component:n,isLoading:s}};let Ir=/*#__PURE__*/r.lazy((()=>Promise.resolve().then((function(){return require("./MfaVerifyFlowScreen-BgdY97r7.js")})))),xr=/*#__PURE__*/r.lazy((()=>(e=>er[e]().then((e=>({default:e.default.component}))))("MfaAuthVerifyFlowScreen"))),Wr=()=>/*#__PURE__*/e.jsx(Dr,{children:/*#__PURE__*/e.jsx(_r,{})}),Ur=()=>{let{currentScreen:t}=p.usePrivyModal(),n=yr((e=>e.inProgressMfaFlow)),i=()=>yr.setState({inProgressMfaFlow:void 0}),{component:a,isLoading:o}=Sr();return function(){let{isModalOpen:e}=p.usePrivyContext(),{headless:t}=m.useAppConfig(),{currentScreen:n}=p.usePrivyModal(),{status:i,execute:a,reset:o,enabled:s}=Vt(),[l,c]=r.useState(!1);r.useEffect((()=>{!e&&s&&o()}),[e,s,o]),r.useEffect((()=>{n?er[n]().then((e=>{c(!!e.default.isCaptchaRequired)})).catch((()=>{c(!1)})):c(!1)}),[n]),r.useEffect((()=>{e&&l&&!t&&"ready"===i&&s&&a()}),[e,l,t,i,s,a])}(),t||"txn"!==n?o?/*#__PURE__*/e.jsx(Wr,{}):a?
325
- /*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(ur,{$if:!!n,children:/*#__PURE__*/e.jsx(r.Suspense,{children:/*#__PURE__*/e.jsx(a,{})})}),/*#__PURE__*/e.jsxs(r.Suspense,{children:["txn"===n&&/*#__PURE__*/e.jsx(Ir,{onClose:i}),"auth"===n&&/*#__PURE__*/e.jsx(xr,{})]})]}):null:/*#__PURE__*/e.jsx(r.Suspense,{children:/*#__PURE__*/e.jsx(Ir,{onClose:i})})},Or=()=>{let t=r.useRef(null);/*#__PURE__*/return e.jsx(Mr,{style:{height:tr(t)},id:"privy-modal-content",children:/*#__PURE__*/e.jsx("div",{ref:t,children:/*#__PURE__*/e.jsx(Ur,{})})})};const Rr=({open:t})=>{let n=m.useAppConfig(),{gracefulClosePrivyModal:i}=(()=>{let{closePrivyModal:e}=s.usePrivyInternal(),{onUserCloseViaDialogOrKeybindRef:t}=p.usePrivyModal();return{gracefulClosePrivyModal:r.useCallback((()=>{if(!t?.current)return e({shouldCallAuthOnSuccess:!1});t.current()}),[e])}})(),a=yr((e=>e.inProgressMfaFlow));return rr({onMfaRequired:()=>{n.mfa.noPromptOnMfaRequired||yr.setState({inProgressMfaFlow:"txn"})}}),n.render.standalone?/*#__PURE__*/e.jsx(vr,{children:/*#__PURE__*/e.jsx(Nr,{id:"privy-modal-content",children:/*#__PURE__*/e.jsx(Ur,{})})}):/*#__PURE__*/e.jsx(gr,{open:!(!t&&!a),id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>i(),children:/*#__PURE__*/e.jsx(vr,{children:/*#__PURE__*/e.jsx(Or,{})})})};let Nr=C.styled.div`
326
- display: flex;
327
- flex-direction: column;
328
- text-align: center;
329
- font-size: 14px;
330
- line-height: 20px;
331
- width: 100%;
332
- background: var(--privy-color-background);
333
- padding: 0 16px;
334
- `,Mr=C.styled(Nr)`
335
- transition: height 150ms ease-out;
336
- overflow-x: hidden;
337
- overflow-y: auto;
338
- scrollbar-width: none;
339
-
340
- // Ensure the modal gets pinned to the top if it ever gets too tall
341
- max-height: calc(100svh - 32px);
342
-
343
- border-radius: var(--privy-border-radius-lg) var(--privy-border-radius-lg) 0 0;
344
- box-shadow: 0px 0px 36px rgba(55, 65, 81, 0.15);
345
-
346
- @media (min-width: 441px) {
347
- box-shadow: 0px 8px 36px rgba(55, 65, 81, 0.15);
348
- border-radius: var(--privy-border-radius-lg);
349
- }
350
- `,Dr=C.styled.div`
351
- display: flex;
352
- align-items: center;
353
- justify-content: center;
354
- min-height: 300px;
355
- padding: 2rem;
356
- `;function Lr(t){let n=r.useRef(null),i=r.useRef();return r.useEffect((()=>{i.current?.remove(),i.current=function({botUsername:e,scriptHost:t}){let r=document.createElement("script"),{origin:n}=new URL(t);return r.async=!0,r.src=`${n}/js/telegram-login.js`,r.setAttribute("data-telegram-login",e),r.setAttribute("data-request-access","write"),r.setAttribute("data-lang","en"),r}(t),n.current?.after(i.current)}),[t]),/*#__PURE__*/e.jsx("div",{ref:n,hidden:!0})}const Fr=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];class jr extends Error{constructor(e,t,r){super(e),this.code=t,this.data=r}}class qr extends W.default{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new jr(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await Jt()||!this.address)throw new jr("Disconnected",4900);let{hash:r}=await Ei(t,{address:this.address});return r}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new jr(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await Jt()||!this.address)throw new jr("Disconnected",4900);let{signature:r}=await fi(t,{address:this.address});return r}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new jr(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new jr(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=K(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",t)}async handlePersonalSign(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for personal_sign");let t=e.params[0],r=e.params[1],{signature:n}=await vi({message:t},{address:r});return n}async handleSignedTypedData(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_signTypedData_v4");let t=e.params[0],r="string"==typeof e.params[1]?JSON.parse(e.params[1]):e.params[1],{signature:n}=await gi(ee(r),{address:t});return n}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");delete e.params[0].gasPrice,delete e.params[0].maxFeePerGas,delete e.params[0].maxPriorityFeePerGas;let t={...e.params[0],chainId:J(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...T.toViemTransactionSerializable(t)})}async request(e){switch(console.debug("Embedded1193Provider.request() called with args",e),e.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return J(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_sendTransaction":return this.handleSendTransaction(e);case"eth_signTransaction":return this.handleSignTransaction(e);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"personal_sign":return this.handlePersonalSign(e);case"eth_signTypedData_v4":return this.handleSignedTypedData(e)}if(!(e=>Fr.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await Jt();if(await Ci({address:this.address}),!t||!this.address)throw new jr("Disconnected",4900);try{let r={method:e.method,params:e.params},n=this.walletAccount;return n&&p.getIsUnifiedWallet(n)?this.handleWalletApiRequest(r,n,t):(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:r})).response.data}catch(e){throw console.error(e),new jr("Disconnected",4900)}}}async handleWalletApiRequest(e,t,r){let n=this.privyClient;if(!n)throw new jr("Disconnected",4900);if("secp256k1_sign"===e.method){let i=await a.rpc(n,(async({message:e})=>this.walletProxy.signWithUserSigner({accessToken:r,message:e})),{chain_type:"ethereum",method:"secp256k1_sign",wallet_id:t.id,params:{hash:e.params[0]}});if("secp256k1_sign"!==i.method)throw new jr(`Invalid params for ${e.method}`,4200);return i.data.signature}throw new jr(`Method not supported: ${e.method}`,4200)}constructor({walletProxy:e,address:t,entropyId:r,entropyIdVerifier:n,rpcConfig:i,chains:a,appId:o,chainId:s=1,walletIndex:l,privyClient:c,walletAccount:d}){super(),this.walletProxy=e,this.address=t,this.entropyId=r,this.entropyIdVerifier=n,this.chainId=s,this.rpcConfig=i,this.chains=a,this.publicClient=K(s,this.chains,i,{appId:o}),this.rpcTimeoutDuration=ye(i,"privy"),this.appId=o,this.walletIndex=l,this.privyClient=c,this.walletAccount=d}}const zr=e=>{if("ethereum"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier"};if("solana"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"solana-address-verifier"};throw Error("Failed to get account entropy details")},Kr=(e,t)=>{if(t?.imported)return zr(t);let r=p.getPrivyPrimaryWallet(e);if(!r)throw Error("Failed to find primary wallet");return zr(r)},Br=({...t})=>/*#__PURE__*/e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.37126 11.0323C2.37126 12.696 3.90598 13.4421 5.40654 13.4468C8.91753 13.4468 12.8021 11.2897 12.7819 7.67984C12.7673 5.07728 10.3748 2.86167 7.54357 2.88296C4.8495 2.88296 2.21821 4.6411 2.21803 7.03628C2.21803 7.67951 2.58722 8.30178 3.55231 8.37184C2.74763 9.16826 2.37126 10.1225 2.37126 11.0323ZM7.55283 8.68012C8.11562 8.68012 8.57186 8.13217 8.57186 7.45624C8.57186 6.78032 8.11562 6.23237 7.55283 6.23237C6.99003 6.23237 6.53379 6.78032 6.53379 7.45624C6.53379 8.13217 6.99003 8.68012 7.55283 8.68012ZM10.4747 8.68012C11.0375 8.68012 11.4937 8.13217 11.4937 7.45625C11.4937 6.78032 11.0375 6.23237 10.4747 6.23237C9.91186 6.23237 9.45562 6.78032 9.45562 7.45625C9.45562 8.13217 9.91186 8.68012 10.4747 8.68012Z",fill:t.color||"var(--privy-color-foreground-3)"})}),Hr=e=>{A.usePrivyEventSubscription("fundWallet",e);let{fundWallet:t}=s.usePrivyInternal();return{fundWallet:({address:e,options:r})=>t(e,r)}};let Vr=[],Yr=[];const $r=/*#__PURE__*/r.createContext(null);function Gr(){let e=r.useContext($r),{wallets:t}=(()=>{let e=m.useAppConfig(),{user:t}=p.usePrivyContext(),{walletProxy:n,privy:a}=s.usePrivyInternal(),{fundWallet:o}=Hr(),[l,c]=r.useState(e.defaultChain.id),d=r.useMemo((()=>t?.linkedAccounts.filter((e=>"wallet"===e.type&&"ethereum"===e.chainType&&null!==e.walletIndex&&"privy"===e.walletClientType))??Vr),[t]);return{wallets:r.useMemo((()=>{if(!n)return Yr;let r=De();return d.map((d=>{let u=()=>{if(!t)throw new s.PrivyClientError("User not ready");let{entropyId:r,entropyIdVerifier:i}=Kr(t,d);return new qr({walletProxy:n,address:d.address,entropyId:r,entropyIdVerifier:i,rpcConfig:e.rpcConfig,chains:e.chains,appId:e.id,chainId:l,walletIndex:d.walletIndex,privyClient:a,walletAccount:d})},h=r.find((e=>e.address===d.address&&e.connectorType===d.connectorType&&e.walletClientType===d.walletClientType))?.connectedAt??d.firstVerifiedAt?.getTime()??Date.now();return{fund:async e=>{await o({address:d.address,options:e})},type:"ethereum",chainId:`eip155:${l}`,switchChain:async e=>{c(Number(e))},getEthereumProvider:async()=>u(),sign:async e=>{let t=u();return await t.request({method:"personal_sign",params:[i.toHex(e),d.address]})},address:d.address,connectedAt:h,walletClientType:"privy",connectorType:"embedded",imported:d.imported,meta:{name:"Privy Wallet",icon:Br,id:"io.privy.wallet"},isConnected:async()=>!0,disconnect:()=>{},linked:!0,loginOrLink:async()=>{throw new s.PrivyClientError("Cannot link or login with embedded wallet")},unlink:async()=>{throw new s.PrivyClientError("Cannot unlink with embedded wallet")},walletIndex:d.walletIndex}}))}),[d,l,n])}})();return null===e?(console.warn("`useWallets` was called outside the PrivyProvider component"),{wallets:[],ready:!1}):r.useMemo((()=>({wallets:[...t,...e.wallets].sort(((e,t)=>t.connectedAt-e.connectedAt)),ready:e.ready})),[e.wallets,e.ready,t])}const Jr=()=>{let{ready:e,wallets:t}=Gr();return r.useEffect((()=>{if(!e)return;let r=t.map((e=>({address:e.address,connectorType:e.connectorType,walletClientType:e.walletClientType,connectedAt:e.connectedAt,id:e.meta.id})));de.put(m.CONNECTIONS_HISTORY_KEY,r)}),[e,t]),null},Zr=["error","invalid_request_arguments","wallet_not_on_device","invalid_recovery_pin","insufficient_funds","missing_or_invalid_mfa","mfa_verification_max_attempts_reached","mfa_timeout","twilio_verification_failed"];class Qr extends Error{constructor(e,t){super(t),this.type=e}}function Xr(e){let t=e.type;return"string"==typeof t&&Zr.includes(t)}function en(e){return Xr(e)&&"wallet_not_on_device"===e.type}async function tn(e,t,r,n,i,a=!1){let o=a,s=async s=>{if(o&&t&&t.length>0){s===(a?0:1)?i("configureMfa","onMfaRequired",{mfaMethods:t}):n.current?.reject(new Qr("missing_or_invalid_mfa","MFA verification failed, retry."));let o=await new Promise(((e,t)=>{r.current={resolve:e,reject:t},setTimeout((()=>{let e=new Qr("mfa_timeout","Timed out waiting for MFA code");n.current?.reject(e),t(e)}),3e5)}));return await e(o)}return await e()},l=null;for(let e=0;e<4;e++)try{l=await s(e),n.current?.resolve(void 0);break}catch(e){if("missing_or_invalid_mfa"!==e.type)throw n.current?.resolve(void 0),e;o=!0}if(null===l){let e=new Qr("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw n.current?.reject(e),e}return l}var rn;let nn=(rn=0,()=>"id-"+rn++);function an(e){return void 0!==e.error}let on=new class{enqueue(e,t){this.callbacks[e]=t}dequeue(e,t){let r=this.callbacks[t];if(!r)throw Error(`cannot dequeue ${e} event: no event found for id ${t}`);switch(delete this.callbacks[t],e){case"privy:iframe:ready":case"privy:user-signer:sign":case"privy:wallets:add":case"privy:wallets:import":case"privy:wallets:set-recovery":case"privy:wallets:connect":case"privy:wallets:recover":case"privy:wallets:rpc":case"privy:wallet:create":case"privy:mfa:verify":case"privy:mfa:init-enrollment":case"privy:mfa:submit-enrollment":case"privy:mfa:unenroll":case"privy:mfa:clear":case"privy:auth:unlink-passkey":case"privy:farcaster:init-signer":case"privy:farcaster:sign":case"privy:solana-wallet:create":case"privy:delegated-actions:consent":return r;default:throw Error(`invalid wallet event type ${e}`)}}constructor(){this.callbacks={}}},sn=new Map,ln=(e,t)=>"bigint"==typeof t?t.toString():t;function cn(e,t,r,n){let i=r.contentWindow;if(!i)throw Error("iframe not initialized");let a=((e,t)=>`${e}${JSON.stringify(t,ln)}`)(e,t);if("privy:wallet:create"===e){let e=sn.get(a);if(e)return e}let o=new Promise(((r,a)=>{let o=nn();on.enqueue(o,{resolve:r,reject:a}),i.postMessage({id:o,event:e,data:t},n)})).finally((()=>{sn.delete(a)}));return sn.set(a,o),o}function dn(t){let n=m.useIsServerConfigLoaded(),i=r.useRef(null),a=r.useRef(t.mfaMethods),o=A.useEmitPrivyEvent(),[s,l]=r.useState(!1);return r.useEffect((()=>{a.current=t.mfaMethods}),[t.mfaMethods]),r.useEffect((()=>{if(!s)return;let e=i.current;if(!e)return;function r(e){var r;e&&e.origin===t.origin&&"string"==typeof(r=e.data).event&&/^privy:.+/.test(r.event)&&function(e){switch(e.event){case"privy:iframe:ready":let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data);case"privy:user-signer:sign":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:add":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:set-recovery":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:connect":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:recover":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:rpc":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallet:create":let r=on.dequeue(e.event,e.id);return an(e)?r.reject(new Qr(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallets:import":let n=on.dequeue(e.event,e.id);return an(e)?n.reject(new Qr(e.error.type,e.error.message)):n.resolve(e.data);case"privy:mfa:verify":let i=on.dequeue(e.event,e.id);return an(e)?i.reject(new Qr(e.error.type,e.error.message)):i.resolve(e.data);case"privy:mfa:init-enrollment":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:submit-enrollment":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:unenroll":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:clear":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:auth:unlink-passkey":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:solana-wallet:create":let a=on.dequeue(e.event,e.id);return an(e)?a.reject(new Qr(e.error.type,e.error.message)):a.resolve(e.data);case"privy:farcaster:init-signer":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:farcaster:sign":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:delegated-actions:consent":{let t=on.dequeue(e.event,e.id);return an(e)?t.reject(new Qr(e.error.type,e.error.message)):t.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}(e.data)}let n={signWithUserSigner:r=>tn((n=>cn("privy:user-signer:sign",{...r,...n},e,t.origin)),a.current,t.mfaPromise,t.mfaSubmitPromise,o),addWallet:r=>tn((n=>cn("privy:wallets:add",{...r,...n},e,t.origin)),a.current,t.mfaPromise,t.mfaSubmitPromise,o),setRecovery:r=>tn((n=>cn("privy:wallets:set-recovery",{...r,...n},e,t.origin)),a.current,t.mfaPromise,t.mfaSubmitPromise,o),connect:r=>tn((n=>cn("privy:wallets:connect",{...r,...n},e,t.origin)),a.current,t.mfaPromise,t.mfaSubmitPromise,o),recover:r=>tn((n=>cn("privy:wallets:recover",{...r,...n},e,t.origin)),a.current,t.mfaPromise,t.mfaSubmitPromise,o,!r.recoveryAccessToken&&!r.recoveryPassword&&!r.recoverySecretOverride),rpc:r=>tn((n=>cn("privy:wallets:rpc",{...r,...n},e,t.origin)),a.current,t.mfaPromise,t.mfaSubmitPromise,o),create:r=>cn("privy:wallet:create",r,e,t.origin),importWallet:r=>cn("privy:wallets:import",r,e,t.origin),createSolana:r=>tn((n=>cn("privy:solana-wallet:create",{...r,...n},e,t.origin)),a.current,t.mfaPromise,t.mfaSubmitPromise,o),createDelegatedAction:r=>cn("privy:delegated-actions:consent",r,e,t.origin),verifyMfa:r=>tn((n=>cn("privy:mfa:verify",{...r,...n},e,t.origin)),a.current,t.mfaPromise,t.mfaSubmitPromise,o,!0),initEnrollMfa:r=>tn((n=>cn("privy:mfa:init-enrollment",{...r,...n},e,t.origin)),a.current,t.mfaPromise,t.mfaSubmitPromise,o),submitEnrollMfa:r=>tn((n=>cn("privy:mfa:submit-enrollment",{...r,...n},e,t.origin)),a.current,t.mfaPromise,t.mfaSubmitPromise,o),unenrollMfa:r=>tn((n=>cn("privy:mfa:unenroll",{...r,...n},e,t.origin)),a.current,t.mfaPromise,t.mfaSubmitPromise,o),clearMfa:r=>cn("privy:mfa:clear",r,e,t.origin),unlinkPasskeyAccount:r=>tn((n=>cn("privy:auth:unlink-passkey",{...r,...n},e,t.origin)),a.current,t.mfaPromise,t.mfaSubmitPromise,o),initFarcasterSigner:r=>cn("privy:farcaster:init-signer",r,e,t.origin),signFarcasterMessage:r=>cn("privy:farcaster:sign",r,e,t.origin)};window.addEventListener("message",r);let l=new AbortController;return $((()=>cn("privy:iframe:ready",{},e,t.origin)),{abortSignal:l.signal}).then((()=>t.onLoad(n)),((...e)=>{console.warn("Privy iframe failed to load: ",...e),t.onLoadFailed()})),()=>{window.removeEventListener("message",r),l.abort()}}),[s]),n?
357
- /*#__PURE__*/e.jsx("iframe",{ref:i,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>l(!0),src:_.constructURL({origin:t.origin,path:`/apps/${t.appId}/embedded-wallets`,query:{caid:t.clientAnalyticsId,client_id:t.appClientId}})}):null}function un(e){return["ethereum","solana"].includes(e.chainType)}const hn=({address:e,user:t})=>{let r=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!r)throw new s.PrivyClientError("Address to delegate is not associated with current user.");if(!un(r))throw new s.PrivyClientError(`useDelegatedActions is not supported for ${r.chainType} wallets. Use the useSessionSigners hook to provision server side access on behalf of your users.`);return{address:r.address,chainType:r.chainType,walletIndex:r.walletIndex??0}},pn=({address:e,user:t})=>{let r=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!r)throw new s.PrivyClientError("Address to delegate is not associated with current user.");let n=r.imported?r:p.getPrivyPrimaryWallet(t);if(!n)throw new s.PrivyClientError("Unable to determine root address for delegated address.");if(!un(n))throw new s.PrivyClientError(`useDelegatedActions is not supported for ${n.chainType} wallets. Use the useSessionSigners hook to provision server side access on behalf of your users.`);return{address:n.address,chainType:n.chainType,imported:n.imported}},yn=e=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.delegated));function wn(e){let t=e.replace("eip155:","");if(t)return parseInt(t);throw Error("Chain ID not compatible with CAIP-2 format.")}const mn="popup-privy-oauth",vn="PRIVY_OAUTH_USE_BROADCAST_CHANNEL";class gn{async authenticate(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(l.oAuthAuthenticatePath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw s.formatApiError(e)}}async link(){if(!this.api)throw new s.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(l.oAuthLinkPath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(e){throw s.formatApiError(e)}}constructor(e){this.meta=e}}async function fn({api:e,requesterAppId:t,providerAppId:r}){let n=(await e.get(`/api/v1/apps/${t}/cross-app/connections`)).connections.find((e=>e.provider_app_id===r));if(!n)throw new s.PrivyClientError("Invalid connected app");return{name:n.provider_app_name,logoUrl:n.provider_app_icon_url||void 0,apiUrl:n.provider_app_custom_api_url,readOnly:n.read_only,customAuthAuthorizeUrl:n.provider_app_custom_auth_authorize_url,customAuthTransactUrl:n.provider_app_custom_auth_transact_url}}const En=async({user:e,address:t,client:r,request:n,requesterAppId:i,reconnect:a})=>{r.createAnalyticsEvent({eventName:"cross_app_request_started",payload:{address:t,method:n.method}});let l=e?.linkedAccounts.find((e=>"cross_app"===e.type&&(e.embeddedWallets.some((e=>e.address===t))||e.smartWallets.some((e=>e.address===t)))));if(!e||!l)throw r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Cannot request a signature with this wallet address",address:t}}),new s.PrivyClientError("Cannot request a signature with this wallet address");let c=r.getProviderAccessToken(l.providerApp.id),d=await fn({api:r.api,requesterAppId:i,providerAppId:l.providerApp.id});if(!c){if(d.readOnly)throw console.error("cannot transact against a read-only provider app"),new s.PrivyClientError("Cannot transact against a read-only provider app");await a({appId:l.providerApp.id,action:"link"})&&(c=r.getProviderAccessToken(l.providerApp.id))}if(!c)throw r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Transactions require a valid token",address:t}}),new s.PrivyClientError("Transactions require a valid token");let u=new URL(d.customAuthTransactUrl||`${d.apiUrl}/oauth/transact`);u.searchParams.set("token",c||""),u.searchParams.set("request",Cn(n));let h=o.trigger({location:u.href});if(!h)throw r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Missing token",address:t}}),new s.PrivyClientError("Failed to initialize signature request");return new Promise(((e,i)=>{let a=setTimeout((()=>{d(),i(new s.PrivyClientError("Request timeout")),r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Request timeout",address:t}})}),12e4),o=setInterval((()=>{h.closed&&(d(),i(new s.PrivyClientError("User rejected request")),r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"User rejected request",address:t}}))}),300),c=a=>{a.data&&("set"===a.data.token?.action&&void 0!==a.data.token?.value?r.storeProviderAccessToken(l.providerApp.id,a.data.token.value):"clear"===a.data.token?.action&&r.storeProviderAccessToken(l.providerApp.id,null),"PRIVY_CROSS_APP_ACTION_RESPONSE"===a.data.type&&a.data.result&&(d(),e(a.data.result),r.createAnalyticsEvent({eventName:"cross_app_request_success",payload:{address:t,method:n.method}})),"PRIVY_CROSS_APP_ACTION_ERROR"===a.data.type&&a.data.error&&(d(),i(a.data.error),r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:a.data.error,address:t}})))};window.addEventListener("message",c);let d=()=>{h.close(),clearInterval(o),clearTimeout(a),window.removeEventListener("message",c)}}))};let Cn=e=>JSON.stringify({content:{request:{request:An(e,d.toHex)}},timestamp:Date.now(),callbackUrl:window.origin});const An=(e,t)=>"bigint"==typeof e?t(e):Array.isArray(e)?e.map((e=>An(e,t))):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map((([e,r])=>[e,An(r,t)]))):e;function Pn({isCreatingWallet:e,skipSplashScreen:t}){return e?"EmbeddedWalletPasswordCreateScreen":t?"EmbeddedWalletPasswordUpdateScreen":"EmbeddedWalletPasswordUpdateSplashScreen"}function Tn({walletAction:e,availableRecoveryMethods:t,legacySetWalletPasswordFlow:r,isResettingPassword:n,showAutomaticRecovery:i}){return i?"SetAutomaticRecoveryScreen":r||1===t.length?Pn({isCreatingWallet:"create"===e,skipSplashScreen:n}):"RecoverySelectionScreen"}function _n(e){switch(e){case"user-passcode":return"PasswordRecoveryScreen";case"google-drive":case"icloud":return"RecoveryOAuthScreen";default:throw Error("Recovery method not supported")}}const bn=e=>e.filter((e=>"wallets"===e.method||("exchange"===e.method?"coinbase"===e.provider:"card"===e.method||"payment-request"===e.method?"coinbase"===e.provider||"moonpay"===e.provider:(e.method,!1)))),kn={[a.mainnet.id]:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",[a.sepolia.id]:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",[a.optimism.id]:"0x0b2c639c533813f4aa9d7837caf62653d097ff85",[a.optimismSepolia.id]:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",[a.polygon.id]:"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",[a.polygonAmoy.id]:"0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582",[a.base.id]:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",[a.baseSepolia.id]:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",[a.avalanche.id]:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",[a.avalancheFuji.id]:"0x5425890298aed601595a70ab815c96711a31bc65",[a.arbitrum.id]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",[a.arbitrumSepolia.id]:"0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"},Sn=({address:e,appConfig:t,fundWalletConfig:r,methodScreen:n,chainIdOverride:i,comingFromSendTransactionScreen:a=!1,onComplete:o,onError:l})=>{let c,d;if(!t.fundingConfig)throw Error("Wallet funding is not enabled");let u=bn(t.fundingConfig.options);if(u.length<1)throw Error("Wallet funding is not enabled");c=i||(r?.chain?r.chain.id:wn(t.fundingConfig.defaultRecommendedCurrency.chain));let h=t.chains.find((e=>e.id===c));if(!h)throw new s.PrivyClientError(`Funding chain ${c} is not in PrivyProvider chains list`);let p=r?.amount??t.fundingConfig.defaultRecommendedAmount,y=!1;function w(){if(!c)return;let e=kn[c];u.find((e=>"wallets"===e.method))&&!e&&console.warn("Attempting to fund with USDC on chain where USDC address is not known. Funding via external wallet will be disabled."),d=e,y=!0}r&&"asset"in r?"USDC"===r.asset?w():"string"!=typeof r.asset&&"erc20"in r.asset&&(y=((e,t)=>e===kn[t.id])(d=r.asset.erc20,h)):"USDC"===t.fundingConfig.defaultRecommendedCurrency.asset&&w();let m=r?.defaultFundingMethod;return{chainType:"ethereum",address:e,amount:p,chain:h,erc20Address:d,erc20ContractInfo:y?{symbol:"USDC",decimals:6}:void 0,isUSDC:y,methodScreen:n,supportedOptions:u,comingFromSendTransactionScreen:a,defaultFundingMethod:m,usingDefaultFundingMethod:!!m,preferredCardProvider:r?.card?.preferredProvider,crossChainBridgingEnabled:t.fundingConfig.crossChainBridgingEnabled??!1,solanaChain:"solana:mainnet",uiConfig:r&&"uiConfig"in r?r.uiConfig:void 0,externalSolanaFundingScreen:null,onComplete:o??(()=>{}),onError:l??(()=>{})}};function In(e,t){if(e.onComplete)switch(t){case"external":e.fundingResult?e.onComplete({...e.fundingResult,fundingMethod:t}):e.onComplete({status:"cancelled",address:e.address,fundingMethod:t,amount:e.amount});break;case null:e.onComplete({status:"cancelled",address:e.address,fundingMethod:void 0,amount:e.amount});break;default:e.onComplete({status:"completed",address:e.address,fundingMethod:t,amount:e.amount})}}const xn=new Map([["FundingMethodSelectionScreen",null],["TransferFromWalletScreen","external"],["FundingAmountEditScreen","external"],["ConnectOnlyLandingScreen","external"],["ConnectOnlyStatusScreen","external"],["AwaitingExternalEthereumTransferScreen","external"],["AwaitingEvmToSolBridgingScreen","external"],["AwaitingSolToEvmBridgingScreen","external"],["ManualTransferScreen","manual"],["MoonpayStatusScreen","moonpay"]]);function Wn(e){let t=e.toLowerCase();return!!window?.webkit?.messageHandlers?.ReactNativeWebView||!!window?.ReactNativeWebView||["fbav","fban","instagram","snapchat","linkedinapp"].some((e=>t.includes(e)))}async function Un({rpc:e,address:t}){return(await e.getBalance(t,{commitment:"confirmed"}).send()).value??0n}let On={apple_oauth:"apple",custom_auth:"custom",discord_oauth:"discord",email:"email",farcaster:"farcaster",github_oauth:"github",google_oauth:"google",instagram_oauth:"instagram",linkedin_oauth:"linkedin",passkey:"passkey",phone:"sms",spotify_oauth:"spotify",telegram:"telegram",tiktok_oauth:"tiktok",line_oauth:"line",twitch_oauth:"twitch",twitter_oauth:"twitter",wallet:"siwe",smart_wallet:"siwe",cross_app:"privy:"};const Rn=e=>{if(p.isCustomOAuthProvider(e))return{displayName:e.replace("custom:",""),loginMethod:"custom"};let t=On[e];return"wallet"===e||"phone"===e?{displayName:e,loginMethod:t}:{displayName:t,loginMethod:t}},Nn=(e,t)=>!p.getPrivyEthereumWallet(e)&&("all-users"===t||"users-without-wallets"===t&&!Mn(e).length);let Mn=e=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"ethereum"===e.chainType));const Dn=(e,t)=>!p.getPrivySolanaWallet(e)&&("all-users"===t||"users-without-wallets"===t&&!Ln(e).length);let Ln=e=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"solana"===e.chainType));async function Fn(e,t,r,n){let i=T.toViemTransactionSerializable(e),{chain:a,...o}=await(async()=>n?await n():await t.prepareTransactionRequest({...i,account:{address:r,type:"json-rpc"}}))();return{...o,type:T.STRING_TO_NUMBER_TXN_TYPE[o.type]}}const jn=()=>{let e=m.useAppConfig(),{user:t}=p.usePrivyContext(),{client:n,refreshSessionAndUser:i,walletProxy:a}=s.usePrivyInternal();return{migrate:r.useCallback((async()=>{if("legacy-embedded-wallets-only"===e.embeddedWallets.mode)return{success:!0,migrated:!1};if(!t)throw new s.PrivyClientError("User must be authenticated before migrating wallets",s.PrivyErrorCode.MUST_BE_AUTHENTICATED);if(!a)throw new s.PrivyClientError("Cannot connect to wallet proxy");let r=await n.getAccessToken();if(!r)throw new s.PrivyClientError("User must be authenticated before migrating wallets",s.PrivyErrorCode.MUST_BE_AUTHENTICATED);let o=t.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&un(e)&&!p.getIsUnifiedWallet(e)));if(0===o.length)return{success:!0,migrated:!1};let l=o.filter((e=>e.imported)),c=o.filter((e=>!e.imported));if(c.length>0){let e=c.find((e=>"ethereum"===e.chainType&&0===e.walletIndex))??c.find((e=>"solana"===e.chainType&&0===e.walletIndex))??null;if(!e)throw new s.PrivyClientError("Primary wallet not found");let{entropyId:t,entropyIdVerifier:n}=zr(e);try{await a.connect({accessToken:r,entropyId:t,entropyIdVerifier:n})}catch(i){if(!en(i)||"privy"!==e.recoveryMethod)throw i;await a.recover({accessToken:r,entropyId:t,entropyIdVerifier:n})}await a.createDelegatedAction({accessToken:r,rootWallet:{address:e.address,chainType:e.chainType,imported:!1},delegatedWallets:c.map((e=>({address:e.address,chainType:e.chainType,walletIndex:e.walletIndex??0})))})}for(let e of l){let{entropyId:t,entropyIdVerifier:n}=zr(e);try{await a.connect({accessToken:r,entropyId:t,entropyIdVerifier:n})}catch(l){if(!en(l)||"privy"!==e.recoveryMethod)throw l;await a.recover({accessToken:r,entropyId:t,entropyIdVerifier:n})}await a.createDelegatedAction({accessToken:r,rootWallet:{address:e.address,chainType:e.chainType,imported:!0},delegatedWallets:[{address:e.address,chainType:e.chainType,walletIndex:e.walletIndex??0}]})}return await i(),{success:!0,migrated:!0}}),[e.embeddedWallets.mode,t,a,n,i])}},qn=({disabled:e})=>{let{migrate:t}=jn(),{user:n}=p.usePrivyContext(),{walletProxy:i}=s.usePrivyInternal(),a=r.useRef(!1);return r.useEffect((()=>{!e&&!a.current&&n&&i&&(a.current=!0,t().catch((e=>{console.debug("Unable to migrate wallets: ",e)})).finally((()=>{a.current=!1})))}),[n,i,e,t]),null},zn=e=>({id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}),Kn=Symbol("solana-funding-plugin"),Bn=Symbol("solana-ledger-plugin");let Hn=/*#__PURE__*/r.createContext({});const Vn=({children:t})=>{let n=m.useAppConfig(),[i,a]=r.useState({});return A.usePrivyEventSubscription("login",{onComplete:({loginAccount:e})=>{e&&"passkey"!==e.type&&"cross_app"!==e.type&&("wallet"!==e.type||"privy"!==e.walletClientType)&&(de.put(Yn(n.id),e.type),"wallet"===e.type?(de.put($n(n.id),e.walletClientType),de.put(Gn(n.id),e.chainType),a({accountType:e.type,walletClientType:e.walletClientType,chainType:e.chainType})):(de.del($n(n.id)),de.del(Gn(n.id)),a({accountType:e.type})))}}),r.useEffect((()=>{if(!n.id)return;let e=de.get(Yn(n.id)),t=de.get($n(n.id)),r=de.get(Gn(n.id));e&&a("wallet"===e?{accountType:e,walletClientType:t,chainType:r}:{accountType:e})}),[n.id]),/*#__PURE__*/e.jsx(Hn.Provider,{value:i,children:t})};let Yn=e=>`privy:${e}:recent-login-method`,$n=e=>`privy:${e}:recent-login-wallet-client`,Gn=e=>`privy:${e}:recent-login-chain-type`;const Jn=w.create((()=>({ethereum:[]}))),Zn=()=>Jn.getState().ethereum,Qn=(e,{chainType:t,walletIndex:r}={})=>e?.linkedAccounts.filter((e=>!("wallet"!==e.type||"privy"!==e.walletClientType||void 0!==r&&e.walletIndex!==r||void 0!==t&&e.chainType!==t)))??[],Xn=e=>e.reduce(((e,t)=>!e||e.walletIndex<t.walletIndex?t:e),null),ei=async({user:e,accessToken:t,proxy:r,refreshSessionAndUser:n,privy:i,appConfig:o,recoverEmbeddedWallet:s,setUser:l,walletIndex:c,chainType:d,recoveryMethod:u,recoveryPassword:h,recoveryAccessToken:y})=>{if(0===c)if("user-controlled-server-wallets-only"===o.embeddedWallets.mode)await a.create(i,{request:{chain_type:d}});else if("ethereum"===d){let n=p.getPrivySolanaWallet(e);n&&await s({address:n.address}),await r.create({accessToken:t,solanaAddress:n?.address,recoveryMethod:u,recoveryPassword:h,recoveryAccessToken:y})}else{if("solana"!==d)throw Error("Invalid input to create wallet");{let n=p.getPrivyEthereumWallet(e);n&&await s({address:n.address}),await r.createSolana({accessToken:t,ethereumAddress:n?.address,recoveryMethod:u,recoveryPassword:h,recoveryAccessToken:y})}}else if("user-controlled-server-wallets-only"===o.embeddedWallets.mode)await a.create(i,{request:{chain_type:d}});else{let{entropyId:n,entropyIdVerifier:i}=Kr(e);await s(),await r.addWallet({accessToken:t,entropyId:n,entropyIdVerifier:i,chainType:d,hdWalletIndex:c})}let w=await n(),m=Qn(w,{chainType:d,walletIndex:c})[0];return l(w),{user:w,account:m}};let ti=async({accessToken:e,appConfig:t,privy:r,emitPrivyEvent:n,proxy:i,refreshSessionAndUser:a,recoverEmbeddedWallet:o,user:l,walletIndex:c,setModalData:d,openModal:u,chainType:h,setUser:y})=>{if(c<0)throw n("createWallet","onError",s.PrivyErrorCode.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${c}) is invalid.`);let w=p.getPrivyPrimaryWallet(l);if(c>0&&!w)throw n("createWallet","onError",s.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),Error("Must have an existing embedded wallet to create an additional wallet.");if(t.embeddedWallets.requireUserOwnedRecoveryOnCreate&&"user-controlled-server-wallets-only"===t.embeddedWallets.mode)throw n("createWallet","onError",s.PrivyErrorCode.EMBEDDED_WALLET_CREATE_ERROR),Error("User owned recovery not yet supported for this app.");if(!w&&t.embeddedWallets.requireUserOwnedRecoveryOnCreate)return await ri({emitPrivyEvent:n,setModalData:d,openModal:u,chainType:h});let m=Qn(l,{chainType:h,walletIndex:c})[0];if(m)return{user:l,account:m};if(0===c&&!i)return ri({emitPrivyEvent:n,setModalData:d,openModal:u,chainType:h});if(!i)throw n("createWallet","onError",s.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");return ei({appConfig:t,walletIndex:c,chainType:h,user:l,accessToken:e,proxy:i,refreshSessionAndUser:a,privy:r,recoverEmbeddedWallet:o,setUser:y})},ri=async({emitPrivyEvent:e,setModalData:t,openModal:r,chainType:n})=>new Promise(((i,a)=>{t({createWallet:{onSuccess:({user:t,account:r})=>{e("createWallet","onSuccess",{wallet:r}),i({user:t,account:r})},onFailure:t=>{e("createWallet","onError",s.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),a(t)},callAuthOnSuccessOnClose:!1,shouldCreateEth:"ethereum"===n,shouldCreateSol:"solana"===n}}),r("EmbeddedWalletOnAccountCreateScreen")}));const ni=()=>{let e=m.useAppConfig(),t=A.useEmitPrivyEvent(),{setModalData:r}=p.usePrivyModal(),{initializeWalletProxy:n,recoverEmbeddedWallet:i,setUser:a,openModal:o,refreshSessionAndUser:l,privy:c,client:d}=s.usePrivyInternal();return{create:async({chainType:u,options:h,latestUser:p})=>{let y=p;if(y||(y=await l()),!y)throw t("createWallet","onError",s.PrivyErrorCode.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return await(async({appConfig:e,getAccessToken:t,initializeWalletProxy:r,user:n,privy:i,emitPrivyEvent:a,recoverEmbeddedWallet:o,setModalData:l,openModal:c,setUser:d,options:u,timeoutDuration:h,refreshSessionAndUser:p,chainType:y})=>{let[w,m]=await Promise.all([r(h),t()]);if(!m||!n)throw a("createWallet","onError",s.PrivyErrorCode.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");if(!w&&e.customAuth?.enabled)throw a("createWallet","onError",s.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(u&&"walletIndex"in u&&"number"==typeof u.walletIndex){if("user-controlled-server-wallets-only"===e.embeddedWallets.mode)throw a("createWallet","onError",s.PrivyErrorCode.INVALID_DATA),Error("Invalid input, use `createAdditional` instead of `walletIndex` to create additional wallets.");return ti({accessToken:m,appConfig:e,privy:i,emitPrivyEvent:a,openModal:c,proxy:w,refreshSessionAndUser:p,recoverEmbeddedWallet:o,setModalData:l,user:n,walletIndex:u.walletIndex,chainType:y,setUser:d})}let v=u&&"createAdditional"in u&&u.createAdditional,g=Qn(n,{chainType:y});if(g[0]&&!v)throw a("createWallet","onError",s.PrivyErrorCode.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");return ti({accessToken:m,appConfig:e,privy:i,emitPrivyEvent:a,openModal:c,proxy:w,recoverEmbeddedWallet:o,setModalData:l,user:n,walletIndex:(Xn(g)?.walletIndex??-1)+1,chainType:y,refreshSessionAndUser:p,setUser:d})})({appConfig:e,privy:c,getAccessToken:()=>d.getAccessToken(),refreshSessionAndUser:l,initializeWalletProxy:n,user:y,emitPrivyEvent:t,recoverEmbeddedWallet:i,setModalData:r,openModal:o,setUser:a,options:h,timeoutDuration:m.WALLET_PROXY_TIMEOUT,chainType:u})}}};function ii(e){let{create:t}=ni();return A.usePrivyEventSubscription("createWallet",e),{createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let{account:r}=await t({chainType:"ethereum",options:e});return r}}}const ai=async({emitPrivyEvent:e,getAccessToken:t,initializeWalletProxy:r,refreshSessionAndUser:n,user:i,appConfig:a},{privateKey:o,chainType:l,additionalSigners:c})=>{if(!i)throw e("linkAccount","onError",s.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:"siwe"}),new s.PrivyClientError("User must be authenticated before linking an account.");let d="user-controlled-server-wallets-only"===a.embeddedWallets.mode?"tee":"on-device";if(c&&"on-device"===d)throw new s.PrivyClientError("Specifying additionalSigners is only supported for TEE execution and this app uses On-device execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");let[u,h]=await Promise.all([t(),r(15e3)]);if(!h||!u)throw e("linkAccount","onError",s.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:"siwe"}),new s.PrivyClientError("User must be authenticated before linking an account.");let{address:y}=await h.importWallet({privateKey:o,accessToken:u,chainType:l,mode:d,additionalSigners:c}),w=await n(),m="solana"===l?p.getImportedPrivySolanaWallets(w):p.getImportedPrivyEthereumWallets(w),v=m?.find((e=>e.address===y));if(!v)throw e("createWallet","onError",s.PrivyErrorCode.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to import wallet");return e("createWallet","onSuccess",{wallet:v}),v},oi=()=>{let{user:e}=p.usePrivyContext(),{client:t,refreshSessionAndUser:n,initializeWalletProxy:i}=s.usePrivyInternal(),a=A.useEmitPrivyEvent(),o=m.useAppConfig();return{importWallet:r.useCallback((({privateKey:r,additionalSigners:s})=>ai({getAccessToken:()=>t.getAccessToken(),user:e,initializeWalletProxy:i,refreshSessionAndUser:n,emitPrivyEvent:a,appConfig:o},{privateKey:r,chainType:"ethereum",additionalSigners:s})),[e,t,n,i,a,o])}},si=()=>{let{importWallet:e}=oi(),{createWallet:t}=ii();return{...r.useContext(p.PrivyContext),importWallet:e,createWallet:t}};function li({subscribe:e,getExternalJwt:t,enabled:n=!0,onAuthenticated:i,onUnauthenticated:a,onError:o}){let{client:l,onCustomAuthAuthenticated:c}=s.usePrivyInternal(),{logout:d,authenticated:u,ready:h}=si();if(!l)throw new s.PrivyClientError("`useSyncJwtBasedAuthState` must be used within a `PrivyProvider`");let[p,y]=r.useState({status:"initial"}),w=r.useRef(),m=r.useRef(!1),v=r.useRef(t);r.useEffect((()=>{v.current=t}),[t]);let g=r.useRef(i);r.useEffect((()=>{g.current=i}),[i]);let f=r.useRef(a);r.useEffect((()=>{f.current=a}),[a]);let E=r.useRef(o);return r.useEffect((()=>{E.current=o}),[o]),r.useEffect((()=>{if(!n||!h)return;let t=async()=>{if(!m.current){m.current=!0;try{y({status:"loading"});let e=await v.current();if(void 0!==w.current&&w.current===e)return void y({status:"done"});if(!e)return u&&(await d(),f.current?.()),w.current=e,void y({status:"done"});l.startAuthFlow(new ot(e));let{user:t,isNewUser:r=!1}=await l.authenticate();if(!t)throw new s.PrivyClientError("Failed to sync with custom auth provider");g.current?.({user:t,isNewUser:r}),c(t,r),w.current=e,y({status:"done"})}catch(e){if(console.warn(e),await d().catch((()=>{})),f.current?.(),e instanceof s.PrivyApiError&&e.privyErrorCode===s.PrivyErrorCode.LINKED_TO_ANOTHER_USER)return y({status:"initial"}),void setTimeout((()=>{t()}),0);E.current?.(e),y({status:"error",error:e})}finally{m.current=!1}}};return t(),e(t)}),[e,l,c,u,d,n,h]),n?{state:p}:{state:{status:"not-enabled"}}}let ci=w.create((()=>({jwtAuthFlowState:{status:"not-enabled"}})));function di({customAuth:e}){let{jwtAuthFlowState:t}=function({customAuth:e}){let t=A.useEmitPrivyEvent(),n=r.useRef(),i=r.useCallback((e=>(n.current=e,()=>{n.current=void 0})),[]),a=e?.getCustomAccessToken??(()=>Promise.resolve(void 0)),{state:o}=li({enabled:!0===e?.enabled,subscribe:i,getExternalJwt:a,onAuthenticated:({user:e,isNewUser:r})=>{t("login","onComplete",{user:e,isNewUser:r,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),t("customAuth","onAuthenticated",{user:e})},onUnauthenticated:()=>{t("customAuth","onUnauthenticated")},onError:e=>{t("login","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}});return r.useEffect((()=>{(async()=>{e&&!e.isLoading&&n.current?.()})()}),[e?.enabled,e?.getCustomAccessToken,e?.isLoading]),{jwtAuthFlowState:o}}({customAuth:e});return r.useEffect((()=>{ci.setState({jwtAuthFlowState:t})}),[t]),null}const ui=/*#__PURE__*/r.createContext(!1);let hi,pi,yi,wi,mi;const vi=(e,t)=>hi(e,t),gi=(e,t)=>pi(e,t),fi=(e,t)=>yi(e,t),Ei=(e,t)=>wi(e,t),Ci=e=>mi(e);exports.AlignBottom=ir,exports.BASE_ACCOUNT_DATA_URI=re,exports.Blobby=Br,exports.BrowserExtensionWallet=Te,exports.ButtonLoader=t=>/*#__PURE__*/e.jsx(kr,{color:t.color||"var(--privy-color-foreground-3)"}),exports.COINBASE_WALLET_DATA_URI=te,exports.Captcha=Xt,exports.CaptchaError=Bt,exports.CoinbaseWallet=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]}),exports.ConnectionLoader=({success:t,fail:r})=>/*#__PURE__*/e.jsxs(Tr,{children:[/*#__PURE__*/e.jsx(Pr,{children:/*#__PURE__*/e.jsx(br,{className:t?"success":r?"fail":""})}),/*#__PURE__*/e.jsx(Pr,{children:/*#__PURE__*/e.jsx(_r,{className:t?"success":r?"fail":""})})]}),exports.ConnectorErrors=se,exports.ConnectorManager=tt,exports.CustomJwtAccountFlow=ot,exports.EmptyWalletState=hr,exports.EthereumNullConnector=Pe,exports.EthereumWalletConnector=ge,exports.Grow=nr,exports.GuestFlow=ut,exports.Header=pr,exports.Hide=ur,exports.Loader=_r,exports.LoaderFaint=br,exports.LoginMethodButton=cr,exports.LoginMethodContainer=ar,exports.LoginMethodContainerWithScrollShadows=or,exports.LoginMethodIconWrapper=dr,exports.Metamask=_e,exports.Phantom=be,exports.PrivatePrivyProvider=c=>{let d=c.client,u=c.privy,h=Lt(),y=m.useAppConfig();L(j(y?.appearance.walletList??[]));let[w,v]=r.useState(!1),g=yr((e=>e.inProgressMfaFlow)),[f,E]=r.useState(!1),[C,P]=r.useState(null),T=Jn((e=>e.ethereum)),[_,b]=r.useState(void 0),[k,S]=r.useState(!1),[I,x]=r.useState(null),[W,U]=r.useState(!1),[O,R]=r.useState({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:s.notImplemented}),[N,M]=r.useState({status:"initial"}),[D,F]=r.useState({status:"initial"}),[q,z]=r.useState({status:"initial"}),[B,H]=r.useState({status:"initial"}),[Y,$]=r.useState({status:"initial"}),[G,J]=r.useState({status:"initial"}),[Z,X]=r.useState(null),te=m.useIsServerConfigLoaded(),[re,ne]=r.useState({}),[ie,ae]=r.useState(null),se=r.useRef(null),[le,pe]=r.useState(!1),[ye,we]=r.useState(!1),me=r.useRef(null),ve=r.useRef(null),ge=r.useRef(A.privyEventsDefault),[fe,Ee]=r.useState(!1),[Ce,Ae]=r.useState(!1),Pe=r.useCallback((e=>{Ae(e),!e&&I&&er[I]().then((e=>{e.default.isUnauthenticatedScreem&&x(null)}))}),[I]);d.onStoreCustomerAccessToken=e=>{e&&A.emitPrivyEvent(ge,"accessToken","onAccessTokenGranted",{accessToken:e})},d.onDeleteCustomerAccessToken=()=>{P(null),Pe(!1),A.emitPrivyEvent(ge,"accessToken","onAccessTokenRemoved")};let Te=r.useRef(null),_e=r.useRef(null),be=r.useRef(!1),ke=({showWalletUIs:e})=>be.current?be.current:void 0!==e?!e:!y.embeddedWallets.showWalletUIs,Se=e=>{x(e),setTimeout((()=>{v(!0)}),15)};r.useEffect((()=>{Z&&se.current?.(Z)}),[Z]);let Ie=r.useCallback(((e,t)=>{P(e),S(t),Pe(!0),we(!0)}),[]);r.useEffect((()=>{ye&&Z&&C&&(async()=>{let e=Nn(C,y.embeddedWallets.ethereum.createOnLogin),t=Dn(C,y.embeddedWallets.solana.createOnLogin),r=await Jt();if(r){if(e&&t){let e=await Z.create({accessToken:r});return await Z.createSolana({accessToken:r,ethereumAddress:e?.address}),void we(!1)}if(t)return await Z.createSolana({accessToken:r,ethereumAddress:p.getPrivyEthereumWallet(C)?.address}),await Ge.refreshSessionAndUser(),void we(!1);if(e)return await Z.create({accessToken:r}),void we(!1)}})().catch(console.error)}),[ye&&Z&&C]),r.useEffect((()=>{if(y.externalWallets.solana.connectors)return y.externalWallets.solana.connectors.onMount(),()=>y.externalWallets.solana.connectors?.onUnmount()}),[y.externalWallets.solana.connectors]),r.useEffect((()=>{!f&&te&&async function(){let e,r=xe(),n=We(),i=t.createStore();d.initializeConnectorManager({walletConnectCloudProjectId:y.walletConnectCloudProjectId,rpcConfig:y.rpcConfig,chains:y.chains,defaultChain:y.defaultChain,store:i,walletList:y.appearance.walletList,shouldEnforceDefaultChainOnConnect:y.shouldEnforceDefaultChainOnConnect,externalWalletConfig:y.externalWallets,appName:y.name??"Privy",walletChainType:y.appearance.walletChainType,setBaseAccountSdk:b}),d.connectors?.on("connectorInitialized",(()=>{e&&clearTimeout(e);let t=d.connectors.walletConnectors.length,r=d.connectors.walletConnectors.reduce(((e,t)=>e+(t.initialized?1:0)),0);r===t?Ee(!0):e=setTimeout((()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:r,expected:t}),Ee(!0)}),1500)})),d.connectors?.initialize().then((()=>{De()}));let a=await d.getAuthenticatedUser(),o=!!a;y.legal.requireUsersAcceptTerms&&a&&!a.hasAcceptedTerms?(await d.logout(),Ge.setReadyToTrue(!0),A.emitPrivyEvent(ge,"logout","onSuccess")):(y.customAuth?.enabled||(Pe(!!a),a&&A.emitPrivyEvent(ge,"login","onComplete",{user:a,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),P(a)),r?_e.current=o?"link":"login":n&&!o?(_e.current="login",ne({telegramAuthModalData:{seamlessAuth:!0}}),Se("TelegramAuthScreen")):Ge.setReadyToTrue(!!a))}()}),[d,ie,f,te]),r.useEffect((()=>{if(f){if(!C||!C.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType)))return void pe(!!Z);if([...T].some((e=>"privy"===e.walletClientType)))return void pe(!0);pe(!!Z)}}),[f,C,T,Z]),r.useEffect((()=>{d.connectors?.setWalletList(y.appearance.walletList)}),[y.appearance.walletList.join()]);let xe=()=>{let e=Et();return e.inProgress&&e.popupFlow?window.opener.location.origin!==window.location.origin?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."}):"error"===e.authorizationCode?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Something went wrong. Try again."}):void window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}):(e.inProgress&&e.provider.startsWith("privy:")&&!e.popupFlow&&(new BroadcastChannel(mn).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(d.startAuthFlow(new ft({...e,customOAuthRedirectUrl:y.customOAuthRedirectUrl})),Se("OAuthStatusScreen"),!0))},We=()=>{let e=function(){let e;return(e=function(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),r=e.get("hash"),n=Number(e.get("auth_date")||""),i=e.get("first_name");if(t&&i&&n&&r)return Object.fromEntries(e.entries())}())?(Gt(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=$t(e.replace("#tgWebAppData=","")),{user:r,auth_date:n,hash:i}=t;return r&&n&&i?t:void 0}())?(Gt(),{flowType:"web-app",authData:e}):void 0}();if(!e||!y.loginMethods.telegram||!y.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let t=new Yt;return d.startAuthFlow(t),"login-url"===e.flowType&&(t.meta.telegramWebAppData=void 0,t.meta.telegramAuthResult=e.authData),"web-app"===e.flowType&&(t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=e.authData),!0},Ue=async(e,t,r,n)=>{if("solana_adapter"!==e)Oe(await(d.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:t}))||null,t,r,n);else{let e=d.connectors?.findSolanaWalletConnector(t);if(!e)return;Oe(e,t,r,n)}};async function Oe(e,t,r,n){if(!e)return R({status:"disconnected",connectedWallet:null,connectError:new s.PrivyConnectorError("Unable to connect to wallet."),connector:null,connectRetry:s.notImplemented}),n?.(null,r);R({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:s.notImplemented}),e instanceof et&&t&&await e.resetConnection(t),R({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Oe(e,t,r,n)});try{let t=await e.connect({showPrompt:!0});if((!t||ue(t))&&y.shouldEnforceDefaultChainOnConnect&&!y.chains.find((e=>e.id===Number(t?.chainId.replace("eip155:",""))))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){R((t=>({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:s.notImplemented})));try{await(t?.switchChain(y.defaultChain.id)),t&&(t.chainId=Q(i.toHex(y.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${y.defaultChain.id}`)}}return R((e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:s.notImplemented}))),t&&A.emitPrivyEvent(ge,"connectWallet","onSuccess",{wallet:t}),n?.(t,r)}catch(e){return e instanceof s.PrivyError?(console.warn(e.cause?e.cause:e.message),A.emitPrivyEvent(ge,"connectWallet","onError",e.privyErrorCode||s.PrivyErrorCode.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),A.emitPrivyEvent(ge,"connectWallet","onError",s.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR)),R((t=>({...t,status:"disconnected",connectedWallet:null,connectError:e}))),n?.(null,r)}}let Re=async(e,t,r)=>{if(null===e||!ue(e))return;let n=new Pt(d,e,t,r);d.startAuthFlow(n)},Me=async(e,t,r,n="plain")=>{let i=h(Bn);if("transaction"===n&&!i)throw new s.PrivyClientError("useSolanaLedger plugin hook must be mounted");if(null===e||!Xe(e))return;let a=new zt(e,d,t,r,n,i);d.startAuthFlow(a)},De=async()=>{let e=new URLSearchParams(window.location.search),t=e.get("privy_connector"),r=e.get("privy_wallet_client"),n="true"===e.get("privy_connect_only");if(!t||!r)return;let i=Ne({connectorType:t,walletClientType:r});if(!i||!i.isInstalled)return Se("LoginFailedScreen");if(!d.connectors)throw new s.PrivyClientError("Connector not initialized");await Se(n?"ConnectOnlyStatusScreen":"ConnectionStatusScreen");let a=new URL(window.location.href);a.searchParams.delete("privy_connector"),a.searchParams.delete("privy_wallet_client"),a.searchParams.delete("privy_connect_only"),window.history.pushState({},"",a),Ue(t,r,void 0,n?void 0:"solana_adapter"===t?Me:Re)};r.useEffect((()=>{f&&Ce&&null===C&&d.getAuthenticatedUser().then(P)}),[f,Ce,C,d]);let Le=e=>{if(!Ce)throw A.emitPrivyEvent(ge,"linkAccount","onError",s.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:e}),new s.PrivyClientError("User must be authenticated before linking an account.")},Fe=e=>{if(!Ce||!C)return!1;if("privy"===e.walletClientType)return!0;for(let t of C.linkedAccounts)if("wallet"===t.type&&t.address===e.address&&"privy"!==t.walletClientType)return!0;return!1},je=()=>{Jn.setState((e=>{let t=d.connectors?.wallets.filter(ue).map((e=>({...e,linked:Fe(e),loginOrLink:async()=>{if(!await e.isConnected())throw new s.PrivyClientError("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new s.PrivyClientError("Cannot link or login with embedded wallet");(async e=>{let t;if(!d.connectors)throw new s.PrivyClientError("Connector not initialized");t="ethereum"===e.type?d.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:d.connectors.findSolanaWalletConnector(e.walletClientType)||null,R((r=>({...r,connector:t,status:"connected",connectedWallet:e,connectError:null,connectRetry:s.notImplemented}))),y.captcha.enabledProvider&&!Ce?(ne({captchaModalData:{callback:t=>ue(e)?Re(e,t):Me(e,t),userIntentRequired:!1,onSuccessNavigateTo:"ConnectionStatusScreen",onErrorNavigateTo:"ErrorScreen"}}),await Se("CaptchaScreen")):(ue(e)?await Re(e):await Me(e),await Se("ConnectionStatusScreen"))})(e)},fund:async t=>{await Ge.fundWallet(e.address,t)},unlink:async()=>{if(!Ce)throw new s.PrivyClientError("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new s.PrivyClientError("Cannot unlink an embedded wallet");P(await d.unlinkEthereumWallet(e.address))}})))||[];return he(e.ethereum,t)?{}:{ethereum:t}}))};r.useEffect((()=>{je()}),[C?.linkedAccounts,Ce,f]),r.useEffect((()=>{if(f){if(!d.connectors)throw new s.PrivyClientError("Connector not initialized");je(),d.connectors.on("walletsUpdated",je)}}),[f]),r.useEffect((()=>{[...y.loginMethodsAndOrder?.primary??[],...y.loginMethodsAndOrder?.overflow??[]].filter((e=>e.startsWith("privy:"))).forEach((e=>d.getCrossAppProviderDetails(e.replace("privy:",""))))}),[!!d]);let qe=({transaction:e,sponsor:t,uiOptions:r,fundWalletConfig:n,address:o,signOnly:l})=>new Promise((async(h,w)=>{let{requesterAppId:m}=r||{},v=l?"signTransaction":"sendTransaction",g=o?p.getPrivyWalletWithAddress(C,o):p.getPrivyEthereumWallet(C);if(!g&&o){let r=p.getConnectedWalletWithAddress(Zn(),o);if(r){if(t)throw new s.PrivyClientError("Cannot sponsor transactions for externally connected wallet.");try{let t=await r.getEthereumProvider(),n={...e,from:o,chainId:e.chainId||Number(r.chainId.replace("eip155:","")),value:void 0!==e.value?i.toHex(e.value):void 0},a=await t.request({method:"sendTransaction"===v?"eth_sendTransaction":"eth_signTransaction",params:[n]});return A.emitPrivyEvent(ge,v,"onSuccess",{hash:a}),void h({hash:a})}catch(e){return A.emitPrivyEvent(ge,v,"onError",s.PrivyErrorCode.TRANSACTION_FAILURE),void w(e??new oe("Unable to "+v+e))}}}if(!g)return A.emitPrivyEvent(ge,v,"onError",s.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void w(new s.PrivyClientError("No embedded or connected wallet found for address."));if(!Ce||!C)return A.emitPrivyEvent(ge,v,"onError",s.PrivyErrorCode.MUST_BE_AUTHENTICATED),void w(Error("User must be authenticated before signing with a Privy wallet"));let f=g.address,E=g.walletIndex??0,{entropyId:P,entropyIdVerifier:T}=Kr(C,g),_=Je.wallets.find((e=>"privy"===e.walletClientType&&i.getAddress(e.address)===i.getAddress(f)));if(!_)return A.emitPrivyEvent(ge,v,"onError",s.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void w(Error("Must have a Privy wallet before signing"));let b=await _.getEthereumProvider(),k=await b.request({method:"eth_chainId"}),S=e.chainId?Number(e.chainId):wn(k);(e=>{if(!y.chains.map((e=>e.id)).includes(e))throw new s.PrivyConnectorError(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,s.PrivyErrorCode.UNSUPPORTED_CHAIN_ID)})(S);let I={...e,from:e.from??f,chainId:S},x=await Jt();if(!x||!Z)return A.emitPrivyEvent(ge,v,"onError",s.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void w(Error("Must have valid access token and Privy wallet to send transaction"));let W=K(I.chainId,y.chains,y.rpcConfig,{appId:c.appId}),U=p.getIsUnifiedWallet(g),O=async({transactionRequest:e})=>{try{let r;if(!await Ge.recoverEmbeddedWallet({address:f}))throw A.emitPrivyEvent(ge,v,"onError",s.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),w(Error("Unable to connect to wallet")),Error("Unable to connect to wallet");if(t){let t=await(async({transactionRequest:e})=>{if(!U)throw new s.PrivyClientError("Sponsoring is only supported for wallets on the TEE stack");if(l)throw new s.PrivyClientError("Cannot sponsor a sign transaction request");let t=e=>null==e?void 0:i.toHex(e),r=await a.rpc(u,(async({message:e})=>await Z.signWithUserSigner({accessToken:x,requesterAppId:m,message:e})),{chain_type:"ethereum",method:"eth_sendTransaction",caip2:Q(i.toHex(e.chainId)),sponsor:!0,params:{transaction:{from:e.from,to:e.to,chain_id:t(e.chainId),data:i.isHex(e.data)?e.data?e.data:i.toHex(Uint8Array.from(e.data)):void 0,value:t(e.value)}},wallet_id:g.id});if(r.data&&"hash"in r.data)return r.data.hash;throw new oe("Unable to sign transaction")})({transactionRequest:e});return A.emitPrivyEvent(ge,"sendTransaction","onSuccess",{hash:t}),t}if(U){let t=e=>null==e?void 0:i.toHex(e),n=await a.rpc(u,(async({message:e})=>await Z.signWithUserSigner({accessToken:x,requesterAppId:m,message:e})),{chain_type:"ethereum",method:"eth_signTransaction",params:{transaction:{from:e.from,to:e.to,nonce:t(e.nonce),chain_id:t(e.chainId),data:i.isHex(e.data)?e.data?e.data:i.toHex(Uint8Array.from(e.data)):void 0,value:t(e.value),type:e.type,gas_limit:t(e.gasLimit??e.gas),gas_price:t(e.gasPrice??e.gas),max_fee_per_gas:t(e.maxFeePerGas),max_priority_fee_per_gas:t(e.maxPriorityFeePerGas)}},wallet_id:g.id});if(!n.data||!("signed_transaction"in n.data))throw new oe("Unable to sign transaction");r=n.data.signed_transaction}else r=await async function({accessToken:e,entropyId:t,entropyIdVerifier:r,transactingWalletIndex:n,walletProxy:i,transactionRequest:a,requesterAppId:o}){return(await i.rpc({entropyId:t,entropyIdVerifier:r,hdWalletIndex:n??0,chainType:"ethereum",accessToken:e,requesterAppId:o,request:{method:"eth_signTransaction",params:[a]}})).response.data}({accessToken:x,entropyId:P,entropyIdVerifier:T,transactingWalletIndex:E,walletProxy:Z,transactionRequest:e,requesterAppId:m});if(l)return A.emitPrivyEvent(ge,"signTransaction","onSuccess",{signature:r}),r;{let e=await W.sendRawTransaction({serializedTransaction:r});return A.emitPrivyEvent(ge,"sendTransaction","onSuccess",{hash:e}),e}}catch(e){throw A.emitPrivyEvent(ge,v,"onError",s.PrivyErrorCode.TRANSACTION_FAILURE),e}};if(ke({showWalletUIs:r?.showWalletUIs})){let e=l||t?I:await Fn(I,W,I.from);try{let t=await O({transactionRequest:e});l?A.emitPrivyEvent(ge,"signTransaction","onSuccess",{signature:t}):A.emitPrivyEvent(ge,"sendTransaction","onSuccess",{hash:t}),h({hash:t})}catch(e){A.emitPrivyEvent(ge,v,"onError",s.PrivyErrorCode.TRANSACTION_FAILURE),w(e)}}else{let e={connectingWalletAddress:f,recoveryMethod:g.recoveryMethod,entropyId:P,entropyIdVerifier:T,onCompleteNavigateTo:"SendTransactionScreen",isUnifiedWallet:U,onFailure:e=>{A.emitPrivyEvent(ge,v,"onError",s.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),w(e)}},i=(e=>!!e.fundingConfig&&bn(e.fundingConfig.options).length>=1)(y)?Sn({address:f,appConfig:y,fundWalletConfig:n,methodScreen:"FundingMethodSelectionScreen",chainIdOverride:I.chainId,comingFromSendTransactionScreen:!0}):void 0;ne({connectWallet:e,sendTransaction:{transactionRequest:I,transactingWalletIndex:E,transactingWalletAddress:f,entropyId:P,entropyIdVerifier:T,signOnly:l,scanTransaction:async()=>{let e=await Fn(I,W,I.from);return await d.scanTransaction({metadata:{domain:y.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:e.from,to:e.to,value:e.value?.toString(),gas:e.gas?.toString(),gasPrice:e.gasPrice?.toString(),nonce:e.nonce?.toString(),data:e.data}]}})},getIsSponsored:async()=>!!t,onConfirm:({transactionRequest:e})=>O({transactionRequest:e}),onSuccess:e=>{l?A.emitPrivyEvent(ge,"signTransaction","onSuccess",{signature:e.hash}):A.emitPrivyEvent(ge,"sendTransaction","onSuccess",{hash:e.hash}),h(e)},onFailure:e=>{A.emitPrivyEvent(ge,v,"onError",s.PrivyErrorCode.TRANSACTION_FAILURE),w(e)},uiOptions:r||{},fundWalletConfig:n,requesterAppId:m},funding:i}),Se("EmbeddedWalletConnectingScreen")}}));function ze(){return new Promise((async(e,t)=>{let r=await Jt();if(!r||!Z)throw Error("Must have valid access token to enroll in MFA");try{await Z.verifyMfa({accessToken:r}),e()}catch(e){t(e)}}))}let Ke=e=>e?.linkedAccounts.filter((e=>null!==e.latestVerifiedAt&&!("wallet"===e.type&&"privy"===e.walletClientType))).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0],Be=e=>{let t=C?.linkedAccounts.filter((t=>t.type===e)).length??0,{displayName:r,loginMethod:n}=Rn(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw A.emitPrivyEvent(ge,"linkAccount","onError",s.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:n}),new s.PrivyClientError(`User already has an account of type ${r} linked.`)};async function He({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){x(null);let r=t?"setWalletPassword":"setWalletRecovery";if(!Ce||!C)throw A.emitPrivyEvent(ge,r,"onError",s.PrivyErrorCode.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let n=p.getPrivyPrimaryWallet(C);if(!n||!Z)throw A.emitPrivyEvent(ge,r,"onError",s.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");let i=p.getIsUnifiedWallet(n);if(i)throw A.emitPrivyEvent(ge,r,"onError",s.PrivyErrorCode.UNSUPPORTED_WALLET_TYPE),new s.PrivyClientError("User owned wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");try{await ze()}catch(e){throw A.emitPrivyEvent(ge,r,"onError",s.PrivyErrorCode.MISSING_MFA_CREDENTIALS),e}return new Promise(((a,o)=>{let l="user-passcode"===n.recoveryMethod,c=Tn({walletAction:"update",availableRecoveryMethods:y.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:l,showAutomaticRecovery:e}),{entropyId:d,entropyIdVerifier:u}=Kr(C),h={recoveryMethod:n.recoveryMethod,connectingWalletAddress:n.address,onCompleteNavigateTo:c,shouldForceMFA:!1,entropyId:d,isUnifiedWallet:i,entropyIdVerifier:u,onFailure:e=>{A.emitPrivyEvent(ge,r,"onError",s.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),o(e)}};ne({setWalletPassword:{onSuccess:e=>{A.emitPrivyEvent(ge,r,"onSuccess",{method:"user-passcode",wallet:e}),a(e)},onFailure:e=>{A.emitPrivyEvent(ge,r,"onError",s.PrivyErrorCode.USER_EXITED_SET_PASSWORD_FLOW),o(e)},callAuthOnSuccessOnClose:!1},recoverWallet:{entropyId:d,entropyIdVerifier:u,onFailure:o},connectWallet:h,recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:l,shouldCreateEth:!1,shouldCreateSol:!1}}),Se("EmbeddedWalletConnectingScreen")}))}async function Ve({appId:e,action:t,disableSignup:r}){let n=await Jt();if("link"===t&&!n)throw A.emitPrivyEvent(ge,"linkAccount","onError",s.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new s.PrivyClientError("User must be authenticated before linking an account.");if("login"===t&&n)throw A.emitPrivyEvent(ge,"login","onError",s.PrivyErrorCode.UNKNOWN_AUTH_ERROR),new s.PrivyClientError("Attempted to log in, but user is already logged in. Use a `link` helper instead.");Te.current=`privy:${e}`,_e.current=t;let i=o.trigger();return d.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise((async(n,a)=>{let{name:o,logoUrl:s}=await fn({api:d.api,providerAppId:e,requesterAppId:y.id});ne({crossAppAuth:{appId:e,name:o,logoUrl:s,action:t,popup:i,disableSignup:r,onSuccess:n,onError:a}}),Se("CrossAppAuthScreen")}))}let Ye={ready:f,authenticated:Ce,user:C,walletConnectors:d.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),ne({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,walletChainType:e?.walletChainType,description:e?.description,hideHeader:e?.hideHeader}}),Se("ConnectOnlyLandingScreen")},linkWallet:e=>(e&&"target"in e&&e&&(e=void 0),Le("siwe"),Te.current="siwe",_e.current="link",ne({...re,externalConnectWallet:{...re.externalConnectWallet,walletList:e?.walletList,walletChainType:e?.walletChainType,description:e?.description||`Link a wallet to your ${y?.name} account`}}),Se("AuthenticateWithWalletScreen")),startCrossAppAuthFlow:Ve,linkEmail:()=>{Le("email"),Be("email"),Te.current="email",_e.current="link",Se("LinkEmailScreen")},linkPhone:()=>{Le("sms"),Be("phone"),Te.current="sms",_e.current="link",Se("LinkPhoneScreen")},linkGoogle:async()=>{Le("google"),Be("google_oauth"),_e.current="link",await Ge.initLoginWithOAuth("google")},linkTwitter:async()=>{Le("twitter"),Be("twitter_oauth"),_e.current="link",await Ge.initLoginWithOAuth("twitter")},linkTwitch:async()=>{Le("twitch"),Be("twitch_oauth"),_e.current="link",await Ge.initLoginWithOAuth("twitch")},linkDiscord:async()=>{Le("discord"),Be("discord_oauth"),_e.current="link",await Ge.initLoginWithOAuth("discord")},linkGithub:async()=>{Le("github"),Be("github_oauth"),_e.current="link",await Ge.initLoginWithOAuth("github")},linkSpotify:async()=>{Le("spotify"),Be("spotify_oauth"),_e.current="link",await Ge.initLoginWithOAuth("spotify")},linkInstagram:async()=>{Le("instagram"),Be("instagram_oauth"),_e.current="link",await Ge.initLoginWithOAuth("instagram")},linkTiktok:async()=>{Le("tiktok"),Be("tiktok_oauth"),_e.current="link",await Ge.initLoginWithOAuth("tiktok")},linkLine:async()=>{Le("line"),Be("line_oauth"),_e.current="link",await Ge.initLoginWithOAuth("line")},linkLinkedIn:async()=>{Le("linkedin"),Be("linkedin_oauth"),_e.current="link",await Ge.initLoginWithOAuth("linkedin")},linkApple:async()=>{Le("apple"),Be("apple_oauth"),_e.current="link",await Ge.initLoginWithOAuth("apple")},linkPasskey:async()=>{Le("passkey"),Be("passkey"),await Ge.initLinkWithPasskey(),Se("LinkPasskeyScreen")},linkTelegram:async e=>{if(Le("telegram"),Be("telegram"),_e.current="link",Te.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let t=new Yt;d.startAuthFlow(t),t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=$t(e.launchParams.initDataRaw),ne({telegramAuthModalData:{seamlessAuth:!0}}),Se("TelegramAuthScreen")}else A.emitPrivyEvent(ge,"linkAccount","onError",s.PrivyErrorCode.INVALID_DATA,{linkMethod:"telegram"});else await Ge.initLoginWithTelegram();Se("TelegramAuthScreen")},linkFarcaster:async()=>{Le("farcaster"),Be("farcaster"),await Ge.initLoginWithFarcaster(),_e.current="link",Te.current="farcaster",Se("FarcasterConnectStatusScreen")},updateEmail:()=>{if(Le("email"),!C?.email)throw new s.PrivyClientError("User does not have an email linked to their account.");_e.current="update",Te.current="email",Se("UpdateEmailScreen")},updatePhone:()=>{if(Le("sms"),!C?.phone)throw new s.PrivyClientError("User does not have a phone number linked to their account.");_e.current="update",Te.current="sms",Se("UpdatePhoneScreen")},login:async e=>{e&&"target"in e&&e&&(e=void 0);let t="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!f){let e=await new Promise((e=>{ae((t=>e.bind(t)))}));if(ae(null),e)return void console.warn(t)}!C||C.isGuest?(_e.current="login",ne({login:e}),Se("LandingScreen")):console.warn(t)},connectOrCreateWallet:async()=>{f||(await new Promise((e=>{ae((()=>e))})),ae(null)),Ce?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(_e.current="connect-or-create",Se("ConnectOrCreateScreen"))},logout:async()=>{if(_e.current=null,Te.current=null,C&&d.clearProviderAcccessTokens(C),x(null),await d.logout(),C&&Z)try{await Z.clearMfa({userId:C.id})}catch(e){}P(null),Pe(!1),F({status:"initial"}),z({status:"initial"}),M({status:"initial"}),H({status:"initial"}),$({status:"initial"}),J({status:"initial"}),A.emitPrivyEvent(ge,"logout","onSuccess"),v(!1),de.del(m.CLIENT_ANALYTICS_ID_KEY),de.del(m.getGuestCredentialStorageKey(y.id))},getAccessToken:r.useCallback((async()=>{let e=await d.getCustomerAccessToken();return e&&!Ce&&Pe(!0),e}),[d,Ce]),unlinkWallet:async e=>{let t;return P(t=e.startsWith("0x")?await d.unlinkEthereumWallet(e):await d.unlinkSolanaWallet(e)),t},unlinkEmail:async e=>{let t=await d.unlinkEmail(e);return P(t),t},unlinkPhone:async e=>{let t=await d.unlinkPhone(e);return P(t),t},unlinkGoogle:async e=>{let t=await d.unlinkOAuth("google",e);return P(t),t},unlinkTwitter:async e=>{let t=await d.unlinkOAuth("twitter",e);return P(t),t},unlinkTwitch:async e=>{let t=await d.unlinkOAuth("twitch",e);return P(t),t},unlinkDiscord:async e=>{let t=await d.unlinkOAuth("discord",e);return P(t),t},unlinkGithub:async e=>{let t=await d.unlinkOAuth("github",e);return P(t),t},unlinkSpotify:async e=>{let t=await d.unlinkOAuth("spotify",e);return P(t),t},unlinkInstagram:async e=>{let t=await d.unlinkOAuth("instagram",e);return P(t),t},unlinkTiktok:async e=>{let t=await d.unlinkOAuth("tiktok",e);return P(t),t},unlinkLine:async e=>{let t=await d.unlinkOAuth("line",e);return P(t),t},unlinkLinkedIn:async e=>{let t=await d.unlinkOAuth("linkedin",e);return P(t),t},unlinkApple:async e=>{let t=await d.unlinkOAuth("apple",e);return P(t),t},unlinkFarcaster:async e=>{let t=await d.unlinkFarcaster(e);return P(t),t},unlinkTelegram:async e=>{let t=await d.unlinkTelegram(e);return P(t),t},unlinkPasskey:async e=>{let t=await Jt();if(!t)throw Error("Must have valid access token to enroll in MFA");if(!Z)throw Error("Wallet proxy not initialized.");let r=y.passkeys.shouldUnenrollMfaOnUnlink;await Z.unlinkPasskeyAccount({credentialId:e,accessToken:t,removeAsMfa:r});let n=await d.getAuthenticatedUser();return P(n),n},unlinkCrossAppAccount:async({subject:e})=>{let t=C?.linkedAccounts.find((t=>"cross_app"===t.type&&t.subject===e))?.providerApp;if(!t)throw new s.PrivyClientError("Invalid subject");d.storeProviderAccessToken(t.id,null);let r=await d.unlinkOAuth(`privy:${t.id}`,e);return P(r),r},setWalletRecovery:async e=>He({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>He({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,t)=>new Promise((async(r,n)=>{let{requesterAppId:o}=t?.uiOptions||{},l=e.message,c=t?.address?p.getPrivyWalletWithAddress(C,t.address):p.getPrivyEthereumWallet(C);if(!c&&void 0!==t?.address){let e=p.getConnectedWalletWithAddress(Zn(),t.address);if(e)try{let t=await e.getEthereumProvider(),n=await t.request({method:"personal_sign",params:[l,e.address]});return A.emitPrivyEvent(ge,"signMessage","onSuccess",{signature:n}),void r({signature:n})}catch(e){return A.emitPrivyEvent(ge,"signMessage","onError",s.PrivyErrorCode.UNABLE_TO_SIGN),void n(e??new oe("Unable to sign message"))}}if(!c)throw new s.PrivyClientError("No embedded or connected wallet found for address.");if(!Ce||!C)return A.emitPrivyEvent(ge,"signMessage","onError",s.PrivyErrorCode.MUST_BE_AUTHENTICATED),void n(Error("User must be authenticated before signing with a Privy wallet"));let h=c.address,y=c.walletIndex??0,{entropyId:w,entropyIdVerifier:m}=Kr(C,c),v=p.getIsUnifiedWallet(c);if("string"!=typeof l||l.length<1)return A.emitPrivyEvent(ge,"signMessage","onError",s.PrivyErrorCode.INVALID_MESSAGE),void n(Error("Message must be a non-empty string"));let g=async()=>{let t;if(!Ce)throw Error("User must be authenticated before signing with a Privy wallet");let r=await Jt();if(!Z||!r||!await Ge.recoverEmbeddedWallet({address:h}))throw Error("Unable to connect to wallet");if(d.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:h,requesterAppId:o}}),v){let n=i.isHex(e.message,{strict:!0}),s=await a.rpc(u,(async({message:e})=>await Z.signWithUserSigner({accessToken:r,requesterAppId:o,message:e})),{chain_type:"ethereum",method:"personal_sign",params:n?{message:l.slice(2),encoding:"hex"}:{message:l,encoding:"utf-8"},wallet_id:c.id});if(!s.data||!("signature"in s.data))throw new oe("Unable to sign message");t=s.data.signature}else{let{response:e}=await Z.rpc({accessToken:r,entropyId:w,entropyIdVerifier:m,chainType:"ethereum",hdWalletIndex:y,requesterAppId:o,request:{method:"personal_sign",params:[l,h]}});t=e.data}return d.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:h,requesterAppId:o}}),t};if(ke({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await g();A.emitPrivyEvent(ge,"signMessage","onSuccess",{signature:e}),r({signature:e})}catch(e){A.emitPrivyEvent(ge,"signMessage","onError",s.PrivyErrorCode.UNABLE_TO_SIGN),n(e??new oe("Unable to sign message"))}else ne({signMessage:{method:"personal_sign",data:l,confirmAndSign:g,onSuccess:e=>{A.emitPrivyEvent(ge,"signMessage","onSuccess",{signature:e}),r({signature:e})},onFailure:e=>{A.emitPrivyEvent(ge,"signMessage","onError",s.PrivyErrorCode.UNABLE_TO_SIGN),n(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:c.recoveryMethod,connectingWalletAddress:h,entropyId:w,entropyIdVerifier:m,onCompleteNavigateTo:"SignRequestScreen",isUnifiedWallet:v,onFailure:e=>{A.emitPrivyEvent(ge,"signMessage","onError",s.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),n(e)}}}),Se("EmbeddedWalletConnectingScreen")})),signTypedData:(e,t)=>new Promise((async(r,n)=>{let{requesterAppId:i}=t?.uiOptions||{},o=t?.address?p.getPrivyWalletWithAddress(C,t.address):p.getPrivyEthereumWallet(C);if(!o&&t?.address){let i=p.getConnectedWalletWithAddress(Zn(),t.address);if(i)try{let t=await i.getEthereumProvider(),n=ee(e),a=await t.request({method:"eth_signTypedData_v4",params:[i.address,n]});return A.emitPrivyEvent(ge,"signTypedData","onSuccess",{signature:a}),void r({signature:a})}catch(e){return A.emitPrivyEvent(ge,"signTypedData","onError",s.PrivyErrorCode.UNABLE_TO_SIGN),void n(e??new oe("Unable to sign typed data "+e))}}if(!o)throw new s.PrivyClientError("No embedded or connected wallet found for address.");if(!Ce||!C)return A.emitPrivyEvent(ge,"signTypedData","onError",s.PrivyErrorCode.MUST_BE_AUTHENTICATED),void n(Error("User must be authenticated before signing with a Privy wallet"));let l=o.address,c=o.walletIndex??0,{entropyId:h,entropyIdVerifier:y}=Kr(C,o),w=p.getIsUnifiedWallet(o),m=ee(e),v=async()=>{let e;if(!Ce)throw Error("User must be authenticated before signing with a Privy wallet");let t=await Jt();if(!Z||!t||!await Ge.recoverEmbeddedWallet({address:l}))throw Error("Unable to connect to wallet");if(d.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:l,requesterAppId:i}}),w){let{domain:r,types:n,primaryType:s,message:l}=m,c=await a.rpc(u,(async({message:e})=>await Z.signWithUserSigner({accessToken:t,requesterAppId:i,message:e})),{chain_type:"ethereum",method:"eth_signTypedData_v4",params:{typed_data:{domain:r,types:n,primary_type:s,message:l}},wallet_id:o.id});if(!c.data||!("signature"in c.data))throw new oe("Unable to sign message");e=c.data.signature}else{let{response:r}=await Z.rpc({accessToken:t,entropyId:h,entropyIdVerifier:y,chainType:"ethereum",hdWalletIndex:c,requesterAppId:i,request:{method:"eth_signTypedData_v4",params:[l,m]}});e=r.data}return d.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:l,requesterAppId:i}}),e};if(ke({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await v();A.emitPrivyEvent(ge,"signTypedData","onSuccess",{signature:e}),r({signature:e})}catch(e){A.emitPrivyEvent(ge,"signTypedData","onError",s.PrivyErrorCode.UNABLE_TO_SIGN),n(e??new oe("Unable to sign message"))}else ne({signMessage:{method:"eth_signTypedData_v4",data:m,confirmAndSign:v,onSuccess:e=>{A.emitPrivyEvent(ge,"signTypedData","onSuccess",{signature:e}),r({signature:e})},onFailure:e=>{A.emitPrivyEvent(ge,"signTypedData","onError",s.PrivyErrorCode.UNABLE_TO_SIGN),n(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:h,isUnifiedWallet:w,entropyIdVerifier:y,onCompleteNavigateTo:"SignRequestScreen",onFailure:e=>{A.emitPrivyEvent(ge,"signMessage","onError",s.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),n(e)}}}),Se("EmbeddedWalletConnectingScreen")})),sendTransaction:async(e,t)=>await qe({transaction:e,sponsor:t?.sponsor,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await qe({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),exportWallet:e=>new Promise((async(t,r)=>{if(!Ce||!C)return void r(Error("User must be authenticated before exporting their Privy wallet"));e&&"target"in e&&e&&(e=void 0);let n=e?.address?p.getPrivyWalletWithAddress(C,e.address):p.getPrivyEthereumWallet(C);if(!n)return void r(new s.PrivyClientError("User must have an embedded wallet."));let a=n.address,{entropyId:o,entropyIdVerifier:l}=Kr(C,n),u=p.getIsUnifiedWallet(n);if(!a)return void r(Error("User does not have an HD Ethereum wallet. To export an imported wallet, pass the `address` of the wallet to `exportWallet`."));if(!i.isAddress(a))return void r(Error("Must provide a valid Ethereum address."));let h={recoveryMethod:n.recoveryMethod,connectingWalletAddress:n.address,isUnifiedWallet:u,entropyId:o,entropyIdVerifier:l,onCompleteNavigateTo:"EmbeddedWalletKeyExportScreen",onFailure:r,shouldForceMFA:!0};ne(re),await Jt()&&Z?Z?un(n)?(ne({keyExport:{appId:c.appId,appClientId:c.clientId,origin:d.apiUrl,address:n.address,entropyId:o,entropyIdVerifier:l,hdWalletIndex:n.walletIndex,chainType:n.chainType,walletId:n.id,isUnifiedWallet:u,imported:n.imported,onSuccess:t,onFailure:r},connectWallet:h}),Se("EmbeddedWalletConnectingScreen")):r(Error(`Export is not supported for ${n.chainType} wallets`)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),promptMfa:ze,async init(e){switch(e){case"sms":return void await d.initMfaSmsVerification();case"passkey":return await d.initMfaPasskeyVerification();case"totp":return;default:throw Error(`Unsupported MFA method: ${e}`)}},async submit(e,t){switch(e){case"totp":case"sms":if("string"!=typeof t)throw new s.PrivyClientError("Invalid MFA code");me.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise(((e,t)=>{ve.current={resolve:e,reject:t}}));break;case"passkey":if("string"==typeof t)throw new s.PrivyClientError("Invalid authenticator response");let r=await import("@simplewebauthn/browser"),n=zn(await r.startAuthentication({optionsJSON:t}));me.current?.resolve({mfaMethod:e,mfaCode:n,relyingParty:window.origin}),await new Promise(((e,t)=>{ve.current={resolve:e,reject:t}}));break;default:throw me.current?.reject(new s.PrivyClientError("Unsupported MFA method")),new s.PrivyClientError(`Unsupported MFA method: ${e}`)}},cancel(){me.current?.reject(new s.PrivyClientError("MFA canceled"))},async initEnrollmentWithSms(e){let t=await Jt();if(!t||!Z)throw Error("Must have valid access token to enroll in MFA");await Z.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise(((t,r)=>{if(!e)return Ge.closePrivyModal(),void t();y.mfa.noPromptOnMfaRequired&&console.warn("[Privy Warning] Triggering the 'showMfaEnrollmentModal' function when 'noPromptOnMfaRequired' is set to true is unexpected. If this is intentional, ensure that you are building custom UIs for MFA verification."),ne({mfaEnrollmentFlow:{mfaMethods:y.mfa.methods,shouldUnlinkOnUnenrollMfa:y.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:r}}),Se("MfaEnrollmentFlowScreen")})),async initEnrollmentWithTotp(){let e=await Jt();if(!e||!Z)throw Error("Must have valid access token to enroll in MFA");let t=await Z.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let t=await Jt();if(!t||!Z)throw Error("Must have valid access token to enroll in MFA");await Z.submitEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber,code:e.mfaCode}),P(await d.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let t=await Jt();if(!t||!Z)throw Error("Must have valid access token to enroll in MFA");await Z.submitEnrollMfa({method:"totp",accessToken:t,code:e.mfaCode}),P(await d.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},t={}){let r=await Jt();if(!r||!Z)throw Error("Must have valid access token to enroll in MFA");await Z.submitEnrollMfa({method:"passkey",accessToken:r,credentialIds:e,removeForLogin:t.removeForLogin}),P(await d.getAuthenticatedUser())},async unenroll(e,t={}){let r=await Jt();if(!r||!Z)throw Error("Must have valid access token to remove MFA");"passkey"===e?await Z.submitEnrollMfa({method:"passkey",accessToken:r,credentialIds:[],removeForLogin:t.removeForLogin}):await Z.unenrollMfa({method:e,accessToken:r}),P(await d.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await Jt(),t=C?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!Z||!t)throw Error("Must have an embedded wallet to use Farcaster signers");if(p.getIsUnifiedWallet(t))throw new s.PrivyClientError("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!C?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Ge.recoverEmbeddedWallet({address:t.address}))throw Error("Unable to connect to wallet");let r=await Z.initFarcasterSigner({address:t.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===r.status&&P(await d.getAuthenticatedUser()||C||null),ne({farcasterSigner:r}),Se("FarcasterSignerStatusScreen")},getFarcasterSignerPublicKey:async()=>{let e,t=await Jt(),r=C?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Z||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(p.getIsUnifiedWallet(r))throw new s.PrivyClientError("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!C?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Ge.recoverEmbeddedWallet({address:r.address}))throw Error("Unable to connect to wallet");if(!C.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=C.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))},signFarcasterMessage:async e=>{let t=await Jt(),r=C?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Z||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(p.getIsUnifiedWallet(r))throw new s.PrivyClientError("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!C?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Ge.recoverEmbeddedWallet({address:r.address}))throw Error("Unable to connect to wallet");if(!C.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let n=await import("@simplewebauthn/browser"),i=await Z.signFarcasterMessage({address:r.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:n.bufferToBase64URLString(e)},fid:BigInt(C.farcaster.fid),relyingParty:window.origin});return new Uint8Array(n.base64URLStringToBuffer(i.signature))},signMessageWithCrossAppWallet(e,{address:t,chainId:r}){let n=C?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return En({user:C,client:d,address:t,requesterAppId:y.id,request:{method:n?"privy_signSmartWalletMessage":"personal_sign",params:[e,t],chainId:r},reconnect:Ve})},signTypedDataWithCrossAppWallet(e,{address:t,chainId:r}){let n=C?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t)))),i=ee(e);return En({user:C,client:d,address:t,requesterAppId:y.id,request:{method:n?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[t,i],chainId:r},reconnect:Ve})},sendTransactionWithCrossAppWallet(e,{address:t}){let r=C?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return En({user:C,client:d,address:t,requesterAppId:y.id,request:{method:r?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:Ve})},signTransactionWithCrossAppWallet(e,{address:t}){let r=C?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return En({user:C,client:d,address:t,requesterAppId:y.id,request:{method:r?"privy_signSmartWalletTx":"eth_signTransaction",params:[e],chainId:e.chainId},reconnect:Ve})},isModalOpen:w||!!g,mfaMethods:y.mfa.methods};hi=Ye.signMessage,pi=Ye.signTypedData,wi=async(e,t)=>await qe({transaction:e,...t,signOnly:!1}),yi=async(e,t)=>({signature:(await qe({transaction:e,...t,signOnly:!0})).hash});let $e=async e=>{let t,r,n;U(!0),$({status:"loading"}),d.startAuthFlow(new ft({...e,customOAuthRedirectUrl:y.customOAuthRedirectUrl}));let i=de.get(m.STATE_CODE_KEY),a=e.stateCode;if(i!==a)throw d.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:i??"",returnedStateCode:a??""}}),U(!1),new s.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,s.PrivyErrorCode.OAUTH_UNEXPECTED);if(null!==await d.getAccessToken())try{({user:t,oAuthTokens:n}=await d.link()),Te.current=e.provider;let r=Ke(t);t&&r&&A.emitPrivyEvent(ge,"linkAccount","onSuccess",{user:t,linkMethod:Te.current,linkedAccount:r})}catch(t){throw U(!1),A.emitPrivyEvent(ge,"linkAccount","onError",t.privyErrorCode||s.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:t,isNewUser:r,oAuthTokens:n}=await d.authenticate()),Te.current=e.provider;let i=Ke(t);t&&i&&void 0!==r&&A.emitPrivyEvent(ge,"login","onComplete",{user:t,isNewUser:r,wasAlreadyAuthenticated:!1,loginMethod:Te.current,loginAccount:i})}catch(e){throw U(!1),$({status:"error",error:e}),A.emitPrivyEvent(ge,"login","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}return P(t),S(r||!1),Pe(!0),U(!1),$({status:"done"}),n&&t&&A.emitPrivyEvent(ge,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:n,user:t}),t??void 0},Ge={privy:u,setAuthenticated:Pe,setUser:P,setIsNewUser:S,isNewUserThisSession:k,pendingTransaction:null,walletConnectionStatus:O,setWalletConnectionStatus:R,connectors:d.connectors?.walletConnectors??[],rpcConfig:y.rpcConfig,chains:y.chains,appId:c.appId,showFiatPrices:"native-token"!==y.embeddedWallets.priceDisplay.primary,clientAnalyticsId:d.clientAnalyticsId,onCustomAuthAuthenticated:Ie,hideWalletUIs:be,isHeadlessSigning:r.useCallback(ke,[y.embeddedWallets.showWalletUIs]),emailOtpState:D,setEmailOtpState:F,smsOtpState:q,setSmsOtpState:z,oAuthState:Y,setOAuthState:$,telegramAuthState:G,setTelegramAuthState:J,siweState:B,setSiweState:H,isHeadlessOAuthLoading:W,baseAccountSdk:_,setBaseAccountSdk:b,nativeTokenSymbolForChainId:e=>y.chains.find((t=>t.id===Number(e)))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(Z)return Z;let t=new Promise((e=>{se.current=e})),r=new Promise((t=>setTimeout((()=>t(null)),e))),n=await Promise.race([t,r]);return se.current=null,n},getAuthFlow:()=>d.authFlow,getAuthMeta:()=>d.authFlow?.meta,client:d,closePrivyModal:async(e={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let t,r=f&&Ce&&C;if(r&&Te.current&&(t=Ke(C)),"login"===_e.current)e.shouldCallAuthOnSuccess&&r&&Te.current?A.emitPrivyEvent(ge,"login","onComplete",{user:C,isNewUser:k,wasAlreadyAuthenticated:!1,loginMethod:Te.current,loginAccount:t??null}):A.emitPrivyEvent(ge,"login","onError",s.PrivyErrorCode.USER_EXITED_AUTH_FLOW);else if("link"===_e.current&&t)e.isSuccess&&r&&Te.current?A.emitPrivyEvent(ge,"linkAccount","onSuccess",{user:C,linkMethod:Te.current,linkedAccount:t}):Te.current&&A.emitPrivyEvent(ge,"linkAccount","onError",s.PrivyErrorCode.USER_EXITED_LINK_FLOW,{linkMethod:Te.current});else if("update"===_e.current&&t)e.isSuccess&&r&&Te.current?A.emitPrivyEvent(ge,"update","onSuccess",{user:C,updateMethod:Te.current,updatedAccount:t}):Te.current&&A.emitPrivyEvent(ge,"update","onError",s.PrivyErrorCode.USER_EXITED_UPDATE_FLOW,{linkMethod:Te.current});else if("connect-or-create"===_e.current){let e=Zn();e[0]?A.emitPrivyEvent(ge,"connectOrCreateWallet","onSuccess",{wallet:e[0]}):A.emitPrivyEvent(ge,"connectOrCreateWallet","onError",s.PrivyErrorCode.USER_EXITED_AUTH_FLOW)}let n=I&&xn.has(I),i="ErrorScreen"===I&&re.errorModalData&&xn.has(re.errorModalData.previousScreen);if((n||i)&&re.funding){let e,t=xn.get(I)??null;if(i&&re.funding?.onError){let e=re.errorModalData?.error,t=e?.privyErrorCode||s.PrivyErrorCode.UNKNOWN_FUNDING_ERROR,r=new s.PrivyClientError(e?.message||"Funding failed",e,t);re.funding?.onError?.(r)}if("solana"===re.funding.chainType){let r=y.solanaRpcs[re.funding.chain];if(!r)return console.warn("Unable to load solana rpc, skipping balance"),A.emitPrivyEvent(ge,"fundSolanaWallet","onUserExited",{address:re.funding.address,fundingMethod:t,chain:re.funding.chain,balance:e}),v(!1),void In(re.funding,t);if(h(Kn))try{e=await Un({rpc:r.rpc,address:re.funding.address})}catch{console.error("Unable to pull wallet balance")}else console.warn("Unable to load solana plugin, skipping balance");A.emitPrivyEvent(ge,"fundSolanaWallet","onUserExited",{address:re.funding.address,fundingMethod:t,chain:re.funding.chain,balance:e})}else{let r=K(re.funding.chain.id,y.chains,y.rpcConfig,{appId:c.appId});try{e=await r.getBalance({address:re.funding.address})}catch{console.error("Unable to pull wallet balance")}A.emitPrivyEvent(ge,"fundWallet","onUserExited",{address:re.funding.address,chain:re.funding.chain,fundingMethod:t,balance:e}),In(re.funding,t)}}ne((e=>({...e,externalConnectWallet:{}}))),_e.current=null,Te.current=null,S(!1),v(!1),R({status:"disconnected",connectedWallet:null,connector:null,connectError:null,connectRetry:()=>{}}),setTimeout((()=>{d.authFlow=void 0}),200)},openPrivyModal:Se,connectWallet:Oe,initLoginWithWallet:async(e,t,r,n)=>{ue(e)?(Te.current="siwe",Re(e,t,r)):(Te.current="siws",Me(e,t,r,n))},loginWithWallet:async()=>{let e,t,r;if(!f)throw new s.PrivyNotReadyError;if(d.authFlow instanceof Pt?e="siwe":d.authFlow instanceof zt&&(e="siws"),!e)throw new s.PrivyClientError("Must initialize SIWE/SIWS flow first.");if(null!==await d.getAccessToken())try{({user:t}=await d.link()),Te.current=e}catch(t){throw A.emitPrivyEvent(ge,"linkAccount","onError",t.privyErrorCode||s.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:t,isNewUser:r}=await d.authenticate()),Te.current=e}catch(e){throw A.emitPrivyEvent(ge,"login","onError",e.privyErrorCode||s.PrivyErrorCode.GENERIC_CONNECT_WALLET_ERROR),e}P(t||C||null),S(r||!1),Pe(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:r})=>new Promise((async(n,i)=>{let a=await Jt();if(!Ce||!C||!a)throw new s.PrivyClientError("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new s.PrivyClientError("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let o=Ge.walletProxy??await Ge.initializeWalletProxy(15e3);if(!o)throw new s.PrivyClientError("Wallet proxy not initialized.");if((({address:e,user:t})=>!!yn(t).find((t=>t.address===e)))({address:e,user:C}))return n();let l=p.getPrivyWalletWithAddress(C,e);if(!l)throw new s.PrivyClientError("Address to delegate is not associated with current user.");if(p.getIsUnifiedWallet(l))throw new s.PrivyClientError("useDelegatedActions is only supported for on-device execution and this app uses TEE execution. Use the useSessionSigners hook to provision server side access on behalf of your users. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");let c=hn({address:e,user:C}),d=pn({address:e,user:C}),u=async()=>{await o.createDelegatedAction({accessToken:a,rootWallet:d,delegatedWallets:[c]}),await Ge.refreshSessionAndUser()};if(await Ge.recoverEmbeddedWallet({address:e}),r)ne({delegatedActions:{consent:{address:e,onDelegate:u,onSuccess:async()=>{n()},onError:async e=>{i(e)}}}}),Se("DelegatedActionsConsentScreen");else try{await u(),n()}catch(e){i(e)}})),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise((async(t,r)=>{if(!Ce||!C)throw new s.PrivyClientError("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");let n=yn(C);if(0===n.length)throw new s.PrivyClientError("User has no delegated wallets to revoke.");if(n.some(p.getIsUnifiedWallet))throw new s.PrivyClientError("useDelegatedActions is only supported for on-device execution and this app uses TEE execution. Use the useSessionSigners hook to provision server side access on behalf of your users. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");let i=async()=>{await d.revokeDelegatedWallet(),await Ge.refreshSessionAndUser()};if(e)ne({delegatedActions:{revoke:{onRevoke:i,onSuccess:async()=>{t()},onError:async e=>{r(e)}}}}),Se("DelegatedActionsRevokeScreen");else try{await i(),t()}catch(e){r(e)}})),initLoginWithFarcaster:async(e,t)=>{let r=new Ft(e,t);d.startAuthFlow(r);try{Te.current="farcaster",await r.initializeFarcasterConnect()}catch(e){throw"login"===_e.current?A.emitPrivyEvent(ge,"login","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===_e.current&&A.emitPrivyEvent(ge,"linkAccount","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,t;if(!f)throw new s.PrivyNotReadyError;if(!(d.authFlow instanceof Ft))throw new s.PrivyClientError("Must initialize Farcaster flow first.");if(null!==await d.getAccessToken())try{({user:e}=await d.link()),Te.current="farcaster"}catch(e){throw A.emitPrivyEvent(ge,"linkAccount","onError",e.privyErrorCode||s.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:t}=await d.authenticate()),Te.current="farcaster"}catch(e){throw A.emitPrivyEvent(ge,"login","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}P(e||null),S(t||!1),Pe(!0)},async crossAppAuthFlow({appId:e,popup:t,action:r,disableSignup:n}){let i=`privy:${e}`;Te.current=i;let{url:a,stateCode:o,codeVerifier:c}=await async function({api:e,appId:t}){let r=mt(),n=vt(),i=await gt(r);try{let{url:a}=await e.post(l.oAuthInitPath,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:i,state_code:n});return{url:a,stateCode:n,codeVerifier:r}}catch(e){throw s.formatApiError(e)}}({api:d.api,appId:e});if(!a)throw d.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:"Unable to open cross-app auth popup",appId:e}}),new s.PrivyClientError("No authorization URL returned for cross-app auth.");try{let l=await async function({url:e,popup:t}){return t.location=e,new Promise(((e,r)=>{let n,i=setTimeout((()=>{r(new s.PrivyClientError("Authorization request timed out after 2 minutes.")),a()}),12e4);function a(){t?.close(),window.removeEventListener("message",l)}let o=setInterval((()=>{t?.closed&&!n&&(a(),clearInterval(o),clearTimeout(i),r(new s.PrivyClientError("User rejected request")))}),300);function l(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(clearTimeout(i),e(t.data),a()),"PRIVY_OAUTH_ERROR"===t.data.type&&(clearTimeout(i),r(new s.PrivyClientError(t.data.error)),a()),t.data.type===vn&&((n=new BroadcastChannel(mn)).onmessage=l))}window.addEventListener("message",l)}))}({url:a,popup:t,provider:i}),u=l.stateCode,h=l.authorizationCode;if(u!==o)throw d.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:i,storedStateCode:o??"",returnedStateCode:u??""}}),new s.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,s.PrivyErrorCode.OAUTH_UNEXPECTED);let p=await async function({appId:e,stateCode:t,codeVerifier:r,authorizationCode:n,action:i,client:a,disableSignup:o}){if(!n||!t)throw new s.PrivyClientError("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===n)throw new s.PrivyClientError("User denied confirmation during cross-app auth flow");try{let s=new gn({authorizationCode:n,stateCode:t,codeVerifier:r,provider:`privy:${e}`,disableSignup:!!o});a.startAuthFlow(s);let l="link"===i?await a.link():await a.authenticate(),c=l.oAuthTokens?.accessToken;return console.debug(),c}catch(e){let t=s.formatApiError(e);if(t.privyErrorCode===s.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED)throw t;if(t.privyErrorCode)throw new s.PrivyClientError(t.message||"Invalid code during cross-app auth flow.",void 0,t.privyErrorCode);if("User denied confirmation during cross-app auth flow"===t.message)throw new s.PrivyClientError("Invalid code during cross-app auth flow.",void 0,s.PrivyErrorCode.OAUTH_USER_DENIED);throw new s.PrivyClientError("Invalid code during cross-app auth flow.",void 0,s.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:c,stateCode:u,authorizationCode:h,action:r,client:d,disableSignup:n});p&&d.storeProviderAccessToken(e,p);let y=await Ge.refreshSessionAndUser();if(!y)throw new s.PrivyClientError("Unable to update user");return d.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),y}catch(e){throw d.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:i}}),e}},async initLoginWithOAuth(e,t,r){if(Te.current=e,!ce())return void Se("InAppBrowserLoginNotPossible");if("google"===e&&!y.allowOAuthInEmbeddedBrowsers&&Wn(window.navigator.userAgent))return void Se("InAppBrowserLoginNotPossible");"twitter"===e&&window.opener&&window.opener.postMessage({type:vn},"*"),de.del(m.HEADLESS_OAUTH_KEY),de.del(m.OAUTH_DISABLE_SIGNUP_KEY);let i=new ft({provider:e,disableSignup:!!r,withPrivyUi:!0,customOAuthRedirectUrl:y.customOAuthRedirectUrl});t&&i.addCaptchaToken(t),d.startAuthFlow(i);let a=await d.authFlow.getAuthorizationUrl();if(a&&a.url)if("twitter"===e&&n.isAndroid&&(a.url=a.url.replace("x.com","twitter.com")),"chrome-extension:"===window.location.protocol&&yt())try{let{privyOAuthCode:e,privyOAuthState:t}=await wt(a.url);Se("OAuthStatusScreen"),i.meta.stateCode=t,i.meta.authorizationCode=e}catch(e){throw console.error("OAuth in chrome extension flow failed:",e),e}else window.location.assign(a.url)},async initLoginWithTelegram(e,t){if(!f)throw new s.PrivyNotReadyError;Te.current="telegram";let r=new Yt(e,t);d.startAuthFlow(r),J({status:"loading"}),r.meta.telegramWebAppData=void 0,r.meta.telegramAuthResult=await new Promise(((e,t)=>y.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:y.loginConfig.telegramAuthConfiguration.botId,request_access:!0},(r=>r?e(r):("link"===_e.current?A.emitPrivyEvent(ge,"linkAccount","onError",s.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}):"login"===_e.current?A.emitPrivyEvent(ge,"login","onError",s.PrivyErrorCode.INVALID_CREDENTIALS):"update"===_e.current&&A.emitPrivyEvent(ge,"login","onError",s.PrivyErrorCode.FAILED_TO_UPDATE_ACCOUNT),t(new s.PrivyClientError("Telegram auth failed or was canceled by the client"))))):t(new s.PrivyClientError("Telegram was not initialized")):t(new s.PrivyClientError("Telegram Auth configuration is not loaded"))))},async loginWithTelegram(e){let t,r;if(!(d.authFlow instanceof Yt))throw new s.PrivyClientError("Must initialize Telegram flow before calling loginWithTelegram");d.authFlow.meta.captchaToken||=e?.captchaToken;let n=await Jt(),i=e?.intent||_e.current;if("login"===i)try{let e=await d.authenticate();t=e.user,r=e.isNewUser,Te.current="telegram"}catch(e){throw A.emitPrivyEvent(ge,"login","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}else{if("link"!==i)throw new s.PrivyClientError("Unknown auth intent");try{t=(await d.link()).user,Te.current="telegram"}catch(e){throw A.emitPrivyEvent(ge,"linkAccount","onError",e.privyErrorCode||s.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}P(t),S(r||!1),Pe(!0),J({status:"done"});let a=t?.linkedAccounts.find((({type:e})=>"telegram"===e))||null;return{user:t,isNewUser:r||!1,wasAlreadyAuthenticated:!!n,loginAccount:a}},async loginWithOAuth(e){let t,r,n;if(!(d.authFlow instanceof ft))throw new s.PrivyClientError("Must initialize OAuth flow before calling loginWithOAuth");let i=de.get(m.STATE_CODE_KEY),a=d.authFlow.meta.stateCode;if(i!==a)throw d.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:i??"",returnedStateCode:a??""}}),new s.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,s.PrivyErrorCode.OAUTH_UNEXPECTED);if(null!==await d.getAccessToken())try{let r=await d.link();t=r.user,n=r.oAuthTokens,Te.current=e}catch(t){throw A.emitPrivyEvent(ge,"linkAccount","onError",t.privyErrorCode||s.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let i=await d.authenticate();t=i.user,r=i.isNewUser,n=i.oAuthTokens,Te.current=e}catch(t){throw"login"===_e.current?A.emitPrivyEvent(ge,"login","onError",t.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===_e.current&&A.emitPrivyEvent(ge,"linkAccount","onError",t.privyErrorCode||s.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return P(t),S(r||!1),Pe(!0),n&&t&&A.emitPrivyEvent(ge,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:n,user:t}),n},passkeyAuthState:N,setPasskeyAuthState:M,async initSignupWithPasskey({captchaToken:e,withPrivyUi:t}){let r=new jt({captchaToken:e,setPasskeyAuthState:M,hints:y.passkeys.registration?.hints});d.startAuthFlow(r),_e.current="login";try{Te.current="passkey",M({status:"generating-challenge"}),await r.initRegisterFlow(t),M({status:"awaiting-passkey"})}catch(e){throw M({status:"error",error:e}),A.emitPrivyEvent(ge,"login","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,t;if(!f)throw new s.PrivyNotReadyError;if(!(d.authFlow instanceof jt))throw new s.PrivyClientError("Must initialize Passkey flow first.");if("passkey"!==Te.current){let e=new s.PrivyClientError("Must init login with Passkey flow first.");throw M({status:"error",error:e}),e}let r=await Jt();try{Te.current="passkey",M({status:"awaiting-passkey"}),({user:e,isNewUser:t}=await d.authenticate())}catch(e){throw M({status:"error",error:e}),A.emitPrivyEvent(ge,"login","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}P(e),S(t||!1),Pe(!0),M({status:"done"});let n=e?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:e,isNewUser:t||!1,wasAlreadyAuthenticated:!!r,loginAccount:n}},async initLoginWithPasskey({captchaToken:e,withPrivyUi:t}){let r=new jt({captchaToken:e,setPasskeyAuthState:M,hints:void 0});d.startAuthFlow(r),_e.current="login";try{Te.current="passkey",M({status:"generating-challenge"}),await r.initAuthenticationFlow(t),M({status:"awaiting-passkey"})}catch(e){throw M({status:"error",error:e}),A.emitPrivyEvent(ge,"login","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let t,r;if(!f)throw new s.PrivyNotReadyError;if(!(d.authFlow instanceof jt))throw new s.PrivyClientError("Must initialize Passkey flow first.");if(e?.credentialIds&&(d.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==Te.current){let e=new s.PrivyClientError("Must init login with Passkey flow first.");throw M({status:"error",error:e}),e}let n=await Jt();try{Te.current="passkey",M({status:"awaiting-passkey"}),({user:t,isNewUser:r}=await d.authenticate())}catch(e){throw M({status:"error",error:e}),A.emitPrivyEvent(ge,"login","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}P(t),S(r||!1),Pe(!0),M({status:"done"});let i=t?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:t,isNewUser:r||!1,wasAlreadyAuthenticated:!!n,loginAccount:i}},async initLinkWithPasskey(e){let t=new jt({captchaToken:e,hints:y.passkeys.registration?.hints});d.startAuthFlow(t),_e.current="link",Te.current="passkey",M({status:"generating-challenge"});try{await t.initLinkFlow(),M({status:"awaiting-passkey"})}catch(e){throw A.emitPrivyEvent(ge,"linkAccount","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),M({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!f)throw new s.PrivyNotReadyError;if(!(d.authFlow instanceof jt))throw new s.PrivyClientError("Must initialize Passkey flow first.");if("passkey"!==Te.current)throw new s.PrivyClientError("Must init login with Passkey flow first.");try{Te.current="passkey",({user:e}=await d.link())}catch(e){throw A.emitPrivyEvent(ge,"linkAccount","onError",e.privyErrorCode||s.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return P(e||C||null),M({status:"done"}),e},async initLoginWithHeadlessOAuth(e,t,r){if(!ce())throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");if("google"===e&&!y.allowOAuthInEmbeddedBrowsers&&Wn(window.navigator.userAgent))throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");let n=new ft({provider:e,withPrivyUi:!1,disableSignup:r??!1,customOAuthRedirectUrl:y.customOAuthRedirectUrl});t&&n.addCaptchaToken(t),$({status:"loading"});let i=await d.startAuthFlow(n).getAuthorizationUrl();if(i?.url)if("chrome-extension:"===window.location.protocol&&yt())try{let{privyOAuthCode:e,privyOAuthState:t}=await wt(i.url);n.meta.stateCode=t,n.meta.authorizationCode=e,await $e(n.meta)}catch(e){throw $({status:"error",error:e}),e}else window.location.assign(i.url)},loginWithHeadlessOAuth:$e,initLoginWithEmail:async({email:e,captchaToken:t,disableSignup:r,withPrivyUi:n})=>{let i=new lt({email:e,captchaToken:t,disableSignup:r});d.startAuthFlow(i);try{Te.current="email",F({status:"sending-code"});let e=await i.sendCodeEmail({withPrivyUi:n});if(e?.ssoRedirectUrl)return window.location.href=e.ssoRedirectUrl,void await V(1e4);F({status:"awaiting-code-input"})}catch(e){throw F({status:"error",error:e}),"login"===_e.current?A.emitPrivyEvent(ge,"login","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===_e.current&&A.emitPrivyEvent(ge,"linkAccount","onError",e.privyErrorCode||s.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async({oldAddress:e,newAddress:t,captchaToken:r})=>{let n=new ct(e,t,r);d.startAuthFlow(n);try{await n.sendCodeEmail({withPrivyUi:!0})}catch(e){throw A.emitPrivyEvent(ge,"update","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:Te.current}),e}},initUpdatePhone:async(e,t,r)=>{let n=new _t(e,t,r);d.startAuthFlow(n);try{await n.sendSmsCode({withPrivyUi:!0})}catch(e){A.emitPrivyEvent(ge,"update","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:Te.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:t,disableSignup:r,withPrivyUi:n})=>{z({status:"sending-code"});let i=new Tt({phoneNumber:e,captchaToken:t,disableSignup:r});d.startAuthFlow(i);try{Te.current="sms",await i.sendSmsCode({withPrivyUi:n}),z({status:"awaiting-code-input"})}catch(e){throw z({status:"error",error:e}),"login"===_e.current?A.emitPrivyEvent(ge,"login","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===_e.current&&A.emitPrivyEvent(ge,"linkAccount","onError",e.privyErrorCode||s.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"sms"}),e}},resendEmailCode:async()=>{await(d.authFlow?.sendCodeEmail({withPrivyUi:!0}))},resendSmsCode:async()=>{await(d.authFlow?.sendSmsCode({withPrivyUi:!0}))},loginWithCode:async e=>{let t,r;function n(e){d.authFlow instanceof lt?F(e):d.authFlow instanceof Tt&&z(e)}if(n({status:"submitting-code"}),!f){let e=new s.PrivyNotReadyError;throw n({status:"error",error:e}),e}if(d.authFlow instanceof lt)d.authFlow.meta.emailCode=e.trim();else{if(!(d.authFlow instanceof Tt)){let e=new s.PrivyClientError("Must initialize a passwordless code flow first");throw n({status:"error",error:e}),e}d.authFlow.meta.smsCode=e.trim()}let i=await Jt();if("link"===_e.current)try{({user:t}=await d.link())}catch(e){throw n({status:"error",error:e}),A.emitPrivyEvent(ge,"linkAccount","onError",e.privyErrorCode||s.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:Te.current}),e}else if("update"===_e.current)try{({user:t}=await d.link())}catch(e){throw n({status:"error",error:e}),A.emitPrivyEvent(ge,"update","onError",e.privyErrorCode||s.PrivyErrorCode.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:Te.current}),e}else try{({user:t,isNewUser:r}=await d.authenticate())}catch(e){throw n({status:"error",error:e}),A.emitPrivyEvent(ge,"login","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}let a=t||C;P(a||null),S(r||!1),Pe(!0),n({status:"done"});let o=null;return d.authFlow instanceof lt?o=a?.linkedAccounts.find((({type:e})=>"email"===e))||null:d.authFlow instanceof Tt&&(o=a?.linkedAccounts.find((({type:e})=>"phone"===e))||null),{user:a,isNewUser:r||!1,wasAlreadyAuthenticated:!!i,linkedAccount:o}},generateSiweMessage:async({address:e,chainId:t,captchaToken:r})=>{_e.current=Ce?"link":"login",Te.current="siwe",H({status:"generating-message"});let n=await d.generateSiweNonce({address:e,captchaToken:r});return H({status:"awaiting-signature"}),At({address:e,chainId:t.replace("eip155:",""),nonce:n})},generateSiweMessageForSmartWallet:async({address:e,chainId:t})=>{let r=await d.generateSiweNonce({address:e});return At({address:e,chainId:t.replace("eip155:",""),nonce:r})},linkSmartWallet:async({message:e,signature:t,smartWalletType:r,smartWalletVersion:n})=>{let i;i=await d.linkSmartWallet({message:e,signature:t,smartWalletType:r,smartWalletVersion:n}),P((i=await Ge.refreshSessionAndUser()??i)||C||null)},loginWithSiwe:async({message:e,signature:t,captchaToken:r,disableSignup:n,walletClientType:i,connectorType:a})=>{let o,l=null;try{if(C)throw Error("User already authenticated");let s=new Pt(d,void 0,r,n,{message:e,signature:t,walletClientType:i,connectorType:a});d.startAuthFlow(s),Te.current="siwe",_e.current="login",H({status:"submitting-signature"});let c=await d.authenticate();if(({user:l,isNewUser:o}=c),!l)throw Error("Authentication failed - no user returned")}catch(e){throw A.emitPrivyEvent(ge,"login","onError",e.privyErrorCode||s.PrivyErrorCode.UNKNOWN_AUTH_ERROR),H({status:"error",error:e}),e}return P(l),S(o||!1),Pe(!0),H({status:"done"}),_e.current=null,Te.current=null,{user:l,isNewUser:o||!1}},linkWithSiwe:async({message:e,signature:t,chainId:r,walletClientType:n,connectorType:i})=>{let a;Le("siwe");let o=null;try{H({status:"submitting-signature"}),a=await d.linkWithSiwe({message:e,signature:t,chainId:r,walletClientType:n,connectorType:i}),a=await Ge.refreshSessionAndUser()??a,H({status:"done"}),(o=Ke(a)||null)&&A.emitPrivyEvent(ge,"linkAccount","onSuccess",{user:a,linkMethod:"siwe",linkedAccount:o})}catch(e){throw A.emitPrivyEvent(ge,"linkAccount","onError",e.privyErrorCode||s.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),_e.current=null,Te.current=null,H({status:"error",error:e}),e}let l=a||C;return P(l||null),_e.current=null,Te.current=null,{user:l,linkedAccount:o}},refreshSessionAndUser:async()=>{let e=await d.getAuthenticatedUser();return Pe(!!e),P(e),e},walletProxy:Z,createAnalyticsEvent:({eventName:e,payload:t,timestamp:r})=>d.createAnalyticsEvent({eventName:e,payload:t,timestamp:r}),acceptTerms:async()=>{let e=await d.acceptTerms();return P(e),e},getUsdTokenPrice:e=>d.getUsdTokenPrice(e),getUsdPriceForSol:()=>d.getUsdPriceForSol(),getSplTokenMetadata:e=>d.getSplTokenMetadata(e),recoverEmbeddedWallet:async e=>new Promise((async(t,r)=>{if(!C)return void t(!0);let n=e?.address?p.getPrivyWalletWithAddress(C,e.address):p.getPrivyPrimaryWallet(C)||p.getImportedPrivyEthereumWallets(C).at(0)||p.getImportedPrivySolanaWallets(C).at(0);if(!n||p.getIsUnifiedWallet(n))return void t(!0);let i=await Jt();if(!i||!Z||!n)return void r(Error("Must have valid access token and Privy wallet to recover wallet"));let{entropyId:a,entropyIdVerifier:o}=Kr(C,n);try{await Z.connect({accessToken:i,entropyId:a,entropyIdVerifier:o}),t(!0)}catch(e){if(en(e)&&"privy"===n.recoveryMethod){let e;d.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:n.address}});try{e=await Z.recover({entropyId:a,entropyIdVerifier:o,accessToken:i})}catch(e){return void r(e)}e.entropyId||r(Error("Unable to recover wallet")),d.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:n.address}}),t(!0)}else en(e)&&"privy"!==n.recoveryMethod&&"privy-v2"!==n.recoveryMethod?(ne({recoverWallet:{entropyId:a,entropyIdVerifier:o,onFailure:r,onSuccess:()=>t(!0)},recoveryOAuthStatus:{provider:n.recoveryMethod,action:"recover",shouldCreateEth:!1,shouldCreateSol:!1}}),Se(_n(n.recoveryMethod))):r(e)}})),setReadyToTrue:e=>{E(!0),ie?.(e)},updateWallets:()=>je(),fundWallet:async(e,t)=>{let r="FundingMethodSelectionScreen";return new Promise(((n,i)=>{ne({funding:{...Sn({address:e,appConfig:y,fundWalletConfig:t,methodScreen:r,onComplete:n,onError:i})}}),Se(r)}))},openModal:Se,requestFarcasterSignerStatus:async e=>{let t=await Jt(),r=C?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Z||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(!C?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let n=await d.requestFarcasterSignerStatus(e);return"approved"===n.status&&P(await d.getAuthenticatedUser()||C||null),n},connectCoinbaseSmartWallet:async()=>{y.externalWallets.coinbaseWallet.config.preference={...y.externalWallets.coinbaseWallet.config.preference,options:"smartWalletOnly"};let e=d.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||d.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),Oe(e);await Ue("coinbase_wallet","coinbase_smart_wallet")},connectBaseAccount:async()=>{let e=d.connectors?.findWalletConnector("base_account","base_account");if(e)return Oe(e);await Ue("base_account","base_account")},initiateAccountTransfer:async({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:i,telegramWebAppData:a,farcasterEmbeddedAddress:o,oAuthUserInfo:s})=>{let l=await d.sendAccountTransferRequest({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:i,telegramWebAppData:a,farcasterEmbeddedAddress:o,oAuthUserInfo:s});return P(l),l},inProgressAuthFlowRef:_e,inProgressLoginOrLinkMethodRef:Te};mi=Ge.recoverEmbeddedWallet,Ge.recoverEmbeddedWallet;let Je=r.useMemo((()=>({wallets:T,ready:le&&fe})),[T,le,fe]),Ze=d.authFlow instanceof Yt,{siteKey:Qe,enabledProvider:tt}=y.captcha,rt=!y.headless&&tt&&!Ce&&(f||Ze);/*#__PURE__*/return e.jsx(ui.Provider,{value:!0,children:/*#__PURE__*/e.jsx(p.PrivyContext.Provider,{value:Ye,children:/*#__PURE__*/e.jsx(A.PrivyEventsContext.Provider,{value:ge,children:/*#__PURE__*/e.jsx($r.Provider,{value:Je,children:/*#__PURE__*/e.jsx(Ht,{appId:y.id,captchaSiteKey:Qe,enabledCaptchaProvider:tt,children:/*#__PURE__*/e.jsxs(s.InternalPrivyContext.Provider,{value:Ge,children:[/*#__PURE__*/e.jsx(Vn,{children:/*#__PURE__*/e.jsxs(p.ModalProvider,{data:re,setModalData:ne,setInitialScreen:x,initialScreen:I,authenticated:Ce,open:w,children:[c.children,/*#__PURE__*/e.jsx(di,{customAuth:y.customAuth}),rt&&/*#__PURE__*/e.jsx(Xt,{delayedExecution:!1}),/*#__PURE__*/e.jsx(Jr,{}),/*#__PURE__*/e.jsx(qn,{disabled:y.embeddedWallets.disableAutomaticMigration}),/*#__PURE__*/e.jsx(wr,{palette:y.appearance.palette||{}}),!y.render.standalone&&/*#__PURE__*/e.jsx(Rr,{open:w})]})}),/*#__PURE__*/e.jsx(dn,{appId:c.appId,appClientId:c.clientId,clientAnalyticsId:d.clientAnalyticsId,origin:d.apiUrl,mfaMethods:C?.mfaMethods,mfaPromise:me,mfaSubmitPromise:ve,onLoad:X,onLoadFailed:()=>null}),y.loginConfig.telegramAuthConfiguration&&
358
- /*#__PURE__*/e.jsx(ur,{$if:!0,children:/*#__PURE__*/e.jsx(Lr,{scriptHost:c.apiUrl||m.DEFAULT_PRIVY_API_URL,botUsername:y.loginConfig.telegramAuthConfiguration.botName})})]})})})})})})},exports.PrivyClient=Rt,exports.PrivyIframeError=Qr,exports.PrivyModal=Rr,exports.PrivyPluginProvider=({children:t})=>{let n=r.useRef({});/*#__PURE__*/return e.jsx(Dt.Provider,{value:{plugins:n},children:t})},exports.PrivyProviderRpcError=oe,exports.ProviderRpcError=ae,exports.RunEffectOnce=Ct,exports.SOLANA_FUNDING_PLUGIN_ID=Kn,exports.SOLANA_LEDGER_PLUGIN_ID=Bn,exports.SiweFlow=Pt,exports.SiwsFlow=zt,exports.SolanaNullConnector=ze,exports.SolanaWalletConnector=je,exports.Subtitle=lr,exports.Token=O,exports.UpdateEmailFlow=ct,exports.WALLET_CONNECT_LOGO_DATA_URI=Ze,exports.WalletConnect=({style:t,...r})=>{let n=m.useAppConfig();/*#__PURE__*/return e.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"28",height:"28",rx:"3",fill:"dark"===n?.appearance.palette.colorScheme?"#3396ff":"#141414"}),/*#__PURE__*/e.jsx("g",{clipPath:"url(#clip0_1765_9946)",children:/*#__PURE__*/e.jsx("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),/*#__PURE__*/e.jsx("defs",{children:/*#__PURE__*/e.jsx("clipPath",{id:"clip0_1765_9946",children:/*#__PURE__*/e.jsx("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})},exports.WalletConnectV2WalletConnector=et,exports.WalletConnector=pe,exports.WalletTimeoutError=ne,exports.addFundingResultToModalData=function(e,t,r,n,i,a,o){return{...e,funding:e?.funding?{...e.funding,fundingResult:{status:t,address:e.funding.address,fundingMethod:void 0,transactionHash:r,amount:e.funding.amount,assetType:i?a?.symbol||"ETH":o.nativeCurrency.symbol||"ETH",metadata:{walletClientType:n}}}:void 0,solanaFundingData:e?.solanaFundingData,sendTransaction:e?.sendTransaction}},exports.buildTargetUrl=Be,exports.clamp=function(e,{min:t,max:r}){return Math.min(Math.max(e,t),r)},exports.convert1dTo2dArray=(e,t)=>{let r=e.slice(0),n=[];for(;r.length;)n.push(r.splice(0,t));return n},exports.createCodeVerifier=mt,exports.createStateCode=vt,exports.createWalletAtIndex=ei,exports.deriveCodeChallengeFromCodeVerifier=gt,exports.detectCompletingOAuthFlow=Et,exports.e=Wn,exports.embeddedWalletRecoveryScreen=_n,exports.embeddedWalletSetPasswordScreen=Pn,exports.ensureGlobalClientInitialized=function(e){Wt||(Wt=new Rt({appId:e.appId,appClientId:e.clientId,apiUrl:e.apiUrl}))},exports.errorIndicatesInvalidRecoveryPassword=function(e){return Xr(e)&&("invalid_recovery_pin"===e.type||"invalid_request_arguments"===e.type)},exports.errorIndicatesMaxMfaRetries=function(e){return!!Xr(e)&&"mfa_verification_max_attempts_reached"===e.type},exports.errorIndicatesMfaCanceled=function(e){return!!function(e){let t=e.type;return"string"==typeof t&&"client_error"===t}(e)&&"MFA canceled"===e.message},exports.errorIndicatesMfaRateLimit=function(e){return!(!Xr(e)||!e.message.includes("code 429"))},exports.errorIndicatesMfaTimeout=function(e){return!!Xr(e)&&"mfa_timeout"===e.type},exports.errorIndicatesMfaVerificationFailed=function(e){return!!Xr(e)&&"missing_or_invalid_mfa"===e.type},exports.errorIndicatesRecoveryIsNeeded=en,exports.extractChainIdFromCAIP2=wn,exports.fetchWalletBalance=Un,exports.formatSolanaWalletAddress=(e,t=3,r=4)=>H(e,t,r,"solana"),exports.formatWalletAddress=H,exports.getAccessToken=Jt,exports.getBlockExplorer=(e,t)=>{let r=Number(e),n=t.find((e=>e.id===r));if(!n)throw new s.PrivyConnectorError(`Unsupported chainId ${e}`,4901);return n.blockExplorers?.default.url},exports.getCaptchaToken=async function(e){if(e.enabled){if("error"===e.status)throw new Bt(e.error,null,s.PrivyErrorCode.CAPTCHA_FAILURE);return"success"===e.status?e.token:(e.execute(),await e.waitForResult())}},exports.getDelegatedWalletsData=hn,exports.getEntropyDetailsForUser=Kr,exports.getGlobalClient=Mt,exports.getIdentityToken=async function(){return await(Wt?.updateUserAndIdToken()),Wt?.useServerCookies?rt.getState().identityToken:Promise.resolve(de.get(m.IDENTITY_TOKEN_STORAGE_KEY)||null)},exports.getJsonRpcEndpointFromChain=B,exports.getPublicClient=K,exports.getRootWalletDataForDelegation=pn,exports.getTelegramAuthErrorMessage=function(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===s.PrivyErrorCode.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===s.PrivyErrorCode.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===s.PrivyErrorCode.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===s.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===s.PrivyErrorCode.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===s.PrivyErrorCode.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===s.PrivyErrorCode.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof Bt&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t},exports.getWalletConfigForConnector=Ne,exports.importWallet=ai,exports.isBaseConnectedEthereumWallet=ue,exports.isBaseConnectedSolanaWallet=Xe,exports.isCoinbaseWalletInstalled=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers)for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0;return!1},exports.isFirstClassChainWallet=un,exports.isSolanaWalletConnector=Qe,exports.mobileWalletsConfig=Re,exports.parseAdditionalSigners=e=>e?.map((e=>({signer_id:e.signerId,override_policy_ids:e.policyIds}))),exports.prepareSiwsMessageWithNonce=qt,exports.prepareSolanaFundingModalData=function({address:e,fundWalletConfig:t,appConfig:r,comingFromSendTransactionScreen:n,externalSolanaFundingScreen:i,methodScreen:a}){if(!r.fundingConfig)throw Error("Wallet funding is not enabled");let o=bn(r.fundingConfig.options);if(o.length<1)throw Error("Wallet funding is not enabled");if("USDC"===t?.asset&&"solana:testnet"===t?.chain)throw Error("USDC funding is not supported on the Solana testnet");let s=t?.amount??r.fundingConfig.defaultRecommendedAmount,l=t?.defaultFundingMethod;return{chainType:"solana",address:e,supportedOptions:o,amount:s,isUSDC:"USDC"===t?.asset,methodScreen:a,comingFromSendTransactionScreen:n,chain:t?.chain||"solana:mainnet",crossChainBridgingEnabled:r.fundingConfig.crossChainBridgingEnabled??!1,defaultFundingMethod:l,preferredCardProvider:t?.card?.preferredProvider,usingDefaultFundingMethod:!!l,uiConfig:t?.uiConfig,externalSolanaFundingScreen:i,onComplete:()=>{},onError:()=>{}}},exports.prepareTransactionRequest=Fn,exports.shouldCreateEmbeddedEthWallet=Nn,exports.shouldCreateEmbeddedSolWallet=Dn,exports.shouldFetchWcRegistryListings=j,exports.sleep=V,exports.splitAtIndex=(e,t)=>{let r=[],n=[];for(let[i,a]of e.entries())i<t?r.push(a):n.push(a);return[r,n]},exports.toDisplayFromAccountType=Rn,exports.toEmbeddedWalletSetRecoveryScreen=Tn,exports.toSolanaWalletClientType=Fe,exports.transformOptionsToCamelCase=at,exports.transformResponseToSnakeCase=zn,exports.u=de,exports.useCaptcha=Vt,exports.useCorePrivyStateStore=yr,exports.useCreateWallet=ii,exports.useCreateWalletInternal=ni,exports.useElementHeight=tr,exports.useExternalWalletListing=e=>{let{listings:t}=L();return t.find((({slug:t})=>F(t)===F(e)))},exports.useExternalWalletListings=L,exports.useFundWallet=Hr,exports.useIdentityToken=function(){let{identityToken:e}=rt();return{identityToken:e}},exports.useImportWallet=oi,exports.useJwtAuthFlowState=()=>ci((e=>e.jwtAuthFlowState)),exports.useMigrateWallets=jn,exports.usePlugins=Lt,exports.usePrivy=si,exports.useRecentlyUsedLogin=()=>r.useContext(Hn),exports.useRegisterMfaListener=rr,exports.useRegisterPlugin=(...e)=>{let{plugins:t}=r.useContext(Dt);r.useEffect((()=>{for(let r of e)t.current[r.id]=r;return()=>{for(let r of e)delete t.current[r.id]}}),[t])},exports.useRequireSinglePrivyContext=()=>{if(r.useContext(ui))throw new s.PrivyClientError("Multiple PrivyProvider instances found","Found multiple instances of PrivyProvider, ensure there is only one mounted in your application tree.")},exports.useSyncJwtBasedAuthState=li,exports.useWallets=Gr,exports.validateEmail=e=>!!String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);