@getpara/react-sdk 2.0.0-alpha.3 → 2.0.0-alpha.6

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 (183) hide show
  1. package/dist/cli/cli.mjs +1 -6
  2. package/dist/index.js +11 -6499
  3. package/dist/modal/ParaModal.js +262 -0
  4. package/dist/modal/components/Account/Account.js +139 -0
  5. package/dist/modal/components/AddFunds/AddFunds.d.ts +0 -2
  6. package/dist/modal/components/AddFunds/AddFunds.js +69 -0
  7. package/dist/modal/components/AddFunds/AddFundsAsset.d.ts +1 -0
  8. package/dist/modal/components/AddFunds/AddFundsAsset.js +125 -0
  9. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +78 -0
  10. package/dist/modal/components/AddFunds/AddFundsContext.d.ts +31 -0
  11. package/dist/modal/components/AddFunds/AddFundsContext.js +160 -0
  12. package/dist/modal/components/AddFunds/AddFundsDone.js +49 -0
  13. package/dist/modal/components/AddFunds/AddFundsProvider.d.ts +1 -0
  14. package/dist/modal/components/AddFunds/AddFundsProvider.js +109 -0
  15. package/dist/modal/components/AddFunds/AddFundsReceive.d.ts +1 -0
  16. package/dist/modal/components/AddFunds/AddFundsReceive.js +83 -0
  17. package/dist/modal/components/AddFunds/AddFundsSettings.d.ts +1 -0
  18. package/dist/modal/components/AddFunds/AddFundsSettings.js +237 -0
  19. package/dist/{MoonPayEmbed-Q2HP2BFI.js → modal/components/AddFunds/MoonPayEmbed.js} +1 -3
  20. package/dist/modal/components/AddFunds/common.d.ts +19 -0
  21. package/dist/modal/components/AddFunds/common.js +24 -0
  22. package/dist/modal/components/AddFunds/index.js +4 -0
  23. package/dist/modal/components/AuthInput/AuthInput.js +262 -0
  24. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +33 -0
  25. package/dist/modal/components/AuthInput/phoneMasks.js +253 -0
  26. package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +4 -3
  27. package/dist/modal/components/AuthMainStep/AuthMainStep.js +50 -0
  28. package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +4 -3
  29. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +157 -0
  30. package/dist/modal/components/AuthOptions/AuthOptions.d.ts +4 -3
  31. package/dist/modal/components/AuthOptions/AuthOptions.js +67 -0
  32. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +18 -0
  33. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +10 -0
  34. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +18 -0
  35. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +5 -1
  36. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +49 -0
  37. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +63 -0
  38. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +55 -0
  39. package/dist/modal/components/Body/AnimatedHeightWrapper.js +29 -0
  40. package/dist/modal/components/Body/Body.d.ts +4 -3
  41. package/dist/modal/components/Body/Body.js +327 -0
  42. package/dist/modal/components/ChainSwitch/ChainSwitch.js +95 -0
  43. package/dist/modal/components/ChainSwitch/config.js +17 -0
  44. package/dist/modal/components/Controls/Controls.js +77 -0
  45. package/dist/modal/components/Controls/Selects.js +189 -0
  46. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +144 -0
  47. package/dist/modal/components/ExternalWalletStep/config.js +17 -0
  48. package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +34 -0
  49. package/dist/modal/components/ExternalWallets/ExternalWallets.js +173 -0
  50. package/dist/modal/components/Footer/Footer.js +95 -0
  51. package/dist/modal/components/Header/Header.js +43 -0
  52. package/dist/modal/components/Header/hooks/useStepTitle.js +54 -0
  53. package/dist/modal/components/Hero/Hero.js +116 -0
  54. package/dist/modal/components/IFrameStep/IFrameStep.js +59 -0
  55. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +31 -0
  56. package/dist/modal/components/ModalContent/ModalContent.js +95 -0
  57. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +27 -0
  58. package/dist/modal/components/OAuth/OAuth.d.ts +2 -2
  59. package/dist/modal/components/OAuth/OAuth.js +79 -0
  60. package/dist/modal/components/OAuth/TelegramOAuthStep.js +90 -0
  61. package/dist/modal/components/OnRampComponents/AddingFunds.js +23 -0
  62. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +77 -0
  63. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +107 -0
  64. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +132 -0
  65. package/dist/modal/components/StripeComponents/StripeComponents.js +88 -0
  66. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +27 -0
  67. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +143 -0
  68. package/dist/modal/components/Waiting/Waiting.js +17 -0
  69. package/dist/modal/components/WalletCard/PartnerIcon.js +34 -0
  70. package/dist/modal/components/WalletCard/WalletCard.d.ts +3 -3
  71. package/dist/modal/components/WalletCard/WalletCard.js +128 -0
  72. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +73 -0
  73. package/dist/modal/components/common.d.ts +32 -13
  74. package/dist/modal/components/common.js +175 -0
  75. package/dist/modal/components/index.js +2 -0
  76. package/dist/modal/constants/constants.d.ts +9 -2
  77. package/dist/modal/constants/constants.js +138 -0
  78. package/dist/modal/constants/defaults.js +10 -0
  79. package/dist/modal/constants/oAuthLogos.d.ts +3 -3
  80. package/dist/modal/constants/oAuthLogos.js +24 -0
  81. package/dist/modal/hooks/useGoBack.js +43 -0
  82. package/dist/modal/index.d.ts +1 -2
  83. package/dist/modal/index.js +29 -0
  84. package/dist/modal/stores/index.js +2 -0
  85. package/dist/modal/stores/modal/actions.js +133 -0
  86. package/dist/modal/stores/modal/useModalStore.d.ts +12 -4
  87. package/dist/modal/stores/modal/useModalStore.js +68 -0
  88. package/dist/modal/types/commonTypes.d.ts +0 -47
  89. package/dist/modal/types/commonTypes.js +1 -0
  90. package/dist/modal/types/externalWallets.d.ts +2 -0
  91. package/dist/modal/types/externalWallets.js +32 -0
  92. package/dist/modal/types/modalProps.d.ts +10 -2
  93. package/dist/modal/types/modalProps.js +12 -0
  94. package/dist/modal/utils/authInputHelpers.d.ts +7 -0
  95. package/dist/modal/utils/authInputHelpers.js +38 -0
  96. package/dist/modal/utils/authLayoutHelpers.js +8 -0
  97. package/dist/modal/utils/countryCodes.js +45 -0
  98. package/dist/modal/utils/getMailtoLink.js +10 -0
  99. package/dist/modal/utils/getTileButtonFlex.js +20 -0
  100. package/dist/modal/utils/isPasskeySupported.js +15 -0
  101. package/dist/modal/utils/openPopup.js +60 -0
  102. package/dist/modal/utils/routeMobileExternalWallet.js +31 -0
  103. package/dist/modal/utils/steps.d.ts +6 -0
  104. package/dist/modal/utils/steps.js +247 -0
  105. package/dist/modal/utils/stringFormatters.d.ts +1 -0
  106. package/dist/modal/utils/stringFormatters.js +19 -0
  107. package/dist/modal/utils/validateOnRampConfig.js +32 -0
  108. package/dist/package.json +6 -0
  109. package/dist/provider/ParaProvider.js +83 -0
  110. package/dist/provider/actions/getAccount.d.ts +8 -1
  111. package/dist/provider/actions/getAccount.js +51 -0
  112. package/dist/provider/actions/getWallet.d.ts +2 -2
  113. package/dist/provider/actions/getWallet.js +14 -0
  114. package/dist/provider/actions/index.d.ts +2 -0
  115. package/dist/provider/actions/index.js +59 -0
  116. package/dist/provider/actions/utils.js +15 -0
  117. package/dist/provider/components/CosmosWalletWrapper.js +34 -0
  118. package/dist/provider/components/EvmWalletWrapper.js +34 -0
  119. package/dist/provider/components/ExternalWalletWrapper.js +139 -0
  120. package/dist/provider/components/SolanaWalletWrapper.js +36 -0
  121. package/dist/provider/external/getParaCosmosConnector.js +22 -0
  122. package/dist/provider/external/getParaEvmConnector.js +22 -0
  123. package/dist/provider/external/getParaSolanaConnector.js +22 -0
  124. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +18 -0
  125. package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +21 -0
  126. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +14 -0
  127. package/dist/provider/hooks/index.js +4 -0
  128. package/dist/provider/hooks/mutations/index.d.ts +1 -0
  129. package/dist/provider/hooks/mutations/index.js +61 -0
  130. package/dist/provider/hooks/mutations/utils.js +22 -0
  131. package/dist/provider/hooks/queries/index.d.ts +1 -0
  132. package/dist/provider/hooks/queries/index.js +10 -0
  133. package/dist/provider/hooks/queries/useAccount.js +21 -0
  134. package/dist/provider/hooks/queries/useWallet.js +22 -0
  135. package/dist/provider/hooks/queries/useWalletBalance.d.ts +6 -0
  136. package/dist/provider/hooks/queries/useWalletBalance.js +55 -0
  137. package/dist/provider/hooks/utils/index.js +10 -0
  138. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +74 -0
  139. package/dist/provider/hooks/utils/useClient.js +10 -0
  140. package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
  141. package/dist/provider/hooks/utils/useEventListeners.js +147 -0
  142. package/dist/provider/hooks/utils/useInternalClient.js +10 -0
  143. package/dist/provider/hooks/utils/useModal.js +17 -0
  144. package/dist/provider/hooks/utils/useWalletState.d.ts +3 -3
  145. package/dist/provider/hooks/utils/useWalletState.js +48 -0
  146. package/dist/provider/index.js +9 -0
  147. package/dist/provider/providers/AuthProvider.d.ts +10 -6
  148. package/dist/provider/providers/AuthProvider.js +498 -0
  149. package/dist/provider/providers/CosmosExternalWalletProvider.js +66 -0
  150. package/dist/provider/providers/EvmExternalWalletProvider.js +74 -0
  151. package/dist/provider/providers/ExternalWalletProvider.d.ts +5 -2
  152. package/dist/provider/providers/ExternalWalletProvider.js +428 -0
  153. package/dist/provider/providers/SolanaExternalWalletProvider.js +66 -0
  154. package/dist/provider/stores/getters.d.ts +1 -1
  155. package/dist/provider/stores/getters.js +13 -0
  156. package/dist/provider/stores/setters.js +7 -0
  157. package/dist/provider/stores/slices/client.js +9 -0
  158. package/dist/provider/stores/slices/config.js +9 -0
  159. package/dist/provider/stores/slices/externalWallets.js +40 -0
  160. package/dist/provider/stores/slices/index.js +5 -0
  161. package/dist/provider/stores/slices/modal.js +16 -0
  162. package/dist/provider/stores/slices/wallet.js +13 -0
  163. package/dist/provider/stores/types.d.ts +7 -4
  164. package/dist/provider/stores/types.js +1 -0
  165. package/dist/provider/stores/useStore.js +28 -0
  166. package/dist/provider/types/externalWalletProviders.d.ts +2 -2
  167. package/dist/provider/types/externalWalletProviders.js +1 -0
  168. package/dist/provider/types/provider.d.ts +9 -3
  169. package/dist/provider/types/provider.js +1 -0
  170. package/dist/provider/types/query.js +1 -0
  171. package/dist/provider/types/utils.js +1 -0
  172. package/dist/provider/utils/constants.d.ts +5 -0
  173. package/dist/provider/utils/constants.js +10 -0
  174. package/dist/provider/utils/paraConfigTypeGuards.js +13 -0
  175. package/dist/provider/utils/renameMutations.js +18 -0
  176. package/package.json +18 -16
  177. package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
  178. package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
  179. package/dist/chunk-MMUBH76A.js.br +0 -0
  180. package/dist/chunk-MMUBH76A.js.gz +0 -0
  181. package/dist/index.js.br +0 -0
  182. package/dist/index.js.gz +0 -0
  183. /package/dist/modal/{components/AuthInput → utils}/countryCodes.d.ts +0 -0
@@ -0,0 +1,327 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { styled } from "styled-components";
5
+ import { IFrameSteps, ModalStep } from "../../utils/steps.js";
6
+ import { CpslAlert, CpslIcon } from "@getpara/react-components";
7
+ import { VerificationCodeStep } from "../VerificationCodeStep/VerificationCodeStep.js";
8
+ import { useModalStore } from "../../stores/index.js";
9
+ import { BiometricLoginStep } from "../BiometricLoginStep/BiometricLoginStep.js";
10
+ import { Setup2FAStep } from "../Setup2FAStep/Setup2FAStep.js";
11
+ import { LoginDoneStep } from "../LoginDoneStep/LoginDoneStep.js";
12
+ import { EnabledFlow } from "@getpara/web-sdk";
13
+ import { AwaitingBiometricsStep } from "../AwaitingBiometricsStep/AwaitingBiometricsStep.js";
14
+ import { AwaitingWalletCreationStep } from "../AwaitingWalletCreationStep/AwaitingWalletCreationStep.js";
15
+ import { WalletCreationDoneStep } from "../WalletCreationDoneStep/WalletCreationDoneStep.js";
16
+ import { RecoverySecretStep } from "../RecoverySecretStep/RecoverySecretStep.js";
17
+ import { TwoFactorDoneStep } from "../TwoFactorDoneStep/TwoFactorDoneStep.js";
18
+ import { BiometricCreationStep } from "../BiometricCreationStep/BiometricCreationStep.js";
19
+ import { AwaitingOAuthStep } from "../AwaitingOAuthStep/AwaitingOAuthStep.js";
20
+ import { AddFundsAwaiting, AddFundsDone, AddFunds } from "../AddFunds/index.js";
21
+ import FarcasterOAuthStep from "../OAuth/FarcasterOAuthStep.js";
22
+ import { Header } from "../Header/Header.js";
23
+ import { AuthMainStep } from "../AuthMainStep/AuthMainStep.js";
24
+ import { BODY_MOTION_VARIANTS, BODY_TRANSITION, MOBILE_SIZE } from "../../constants/constants.js";
25
+ import { Account } from "../Account/Account.js";
26
+ import { AuthOptions } from "../AuthOptions/AuthOptions.js";
27
+ import { ExternalWallets } from "../ExternalWallets/ExternalWallets.js";
28
+ import { ExternalWalletStep } from "../ExternalWalletStep/ExternalWalletStep.js";
29
+ import { Hero } from "../Hero/Hero.js";
30
+ import { AnimatedHeightWrapper } from "./AnimatedHeightWrapper.js";
31
+ import { ChainSwitch } from "../ChainSwitch/ChainSwitch.js";
32
+ import { motion, AnimatePresence } from "framer-motion";
33
+ import { Controls } from "../Controls/Controls.js";
34
+ import { useEffect, useState } from "react";
35
+ import { TelegramOAuthStep } from "../OAuth/TelegramOAuthStep.js";
36
+ import { AwaitingPasswordStep } from "../AwaitingPasswordStep/AwaitingPasswordStep.js";
37
+ import { IFrameStep } from "../IFrameStep/IFrameStep.js";
38
+ import { useStore } from "../../../provider/stores/useStore.js";
39
+ import { ExternalWalletVerificationStep } from "../ExternalWalletVerificationStep/ExternalWalletVerificationStep.js";
40
+ import { NetworkSpeedBanner } from "@getpara/react-common";
41
+ const MIN_HEIGHT = {
42
+ [ModalStep.ADD_FUNDS_AWAITING]: "680px"
43
+ };
44
+ const PADDING_TOP = {
45
+ [ModalStep.TELEGRAM_OAUTH]: "36px"
46
+ };
47
+ const PADDING_BOTTOM = {
48
+ [ModalStep.TELEGRAM_OAUTH]: "16px"
49
+ };
50
+ const Body = ({
51
+ oAuthMethods,
52
+ twoFactorAuthEnabled,
53
+ disableEmailLogin,
54
+ disablePhoneLogin,
55
+ isGuestModeEnabled = false,
56
+ onClose
57
+ }) => {
58
+ const currentStep = useModalStore((state) => state.step);
59
+ const onRampConfig = useModalStore((state) => state.onRampConfig);
60
+ const stepDirection = useModalStore((state) => state.stepDirection);
61
+ const setStepDirection = useModalStore((state) => state.setStepDirection);
62
+ const accountAddFundTab = useModalStore((state) => state.accountAddFundTab);
63
+ const setAccountAddFundTab = useModalStore((state) => state.setAccountAddFundTab);
64
+ const embeddedModal = useStore((state) => {
65
+ var _a;
66
+ return (_a = state.modalConfig) == null ? void 0 : _a.embeddedModal;
67
+ });
68
+ const appName = useStore((state) => state.appName);
69
+ const [isTestModeAlert, setIsTestModeAlert] = useState(onRampConfig == null ? void 0 : onRampConfig.testMode);
70
+ const Content = () => {
71
+ switch (currentStep) {
72
+ case ModalStep.AUTH_MAIN: {
73
+ return /* @__PURE__ */ jsx(
74
+ AuthMainStep,
75
+ {
76
+ oAuthMethods,
77
+ disableEmailLogin,
78
+ disablePhoneLogin,
79
+ isGuestModeEnabled
80
+ }
81
+ );
82
+ }
83
+ case ModalStep.EX_WALLET_MORE: {
84
+ return /* @__PURE__ */ jsx(ExternalWallets, {});
85
+ }
86
+ case ModalStep.AWAITING_GUEST_WALLET_CREATION: {
87
+ return /* @__PURE__ */ jsx(AwaitingWalletCreationStep, { isGuestMode: true });
88
+ }
89
+ case ModalStep.AUTH_MORE:
90
+ case ModalStep.AUTH_GUEST_SIGNUP: {
91
+ return /* @__PURE__ */ jsx(
92
+ AuthOptions,
93
+ {
94
+ oAuthMethods,
95
+ disableEmailLogin,
96
+ disablePhoneLogin,
97
+ isGuestModeEnabled
98
+ }
99
+ );
100
+ }
101
+ case ModalStep.VERIFICATIONS: {
102
+ return /* @__PURE__ */ jsx(VerificationCodeStep, {});
103
+ }
104
+ case ModalStep.EXTERNAL_WALLET_VERIFICATION: {
105
+ return /* @__PURE__ */ jsx(ExternalWalletVerificationStep, {});
106
+ }
107
+ case ModalStep.BIOMETRIC_LOGIN: {
108
+ return /* @__PURE__ */ jsx(BiometricLoginStep, {});
109
+ }
110
+ case ModalStep.SETUP_2FA:
111
+ case ModalStep.VERIFY_2FA: {
112
+ return /* @__PURE__ */ jsx(Setup2FAStep, { onClose });
113
+ }
114
+ case ModalStep.LOGIN_DONE: {
115
+ return /* @__PURE__ */ jsx(LoginDoneStep, { onClose });
116
+ }
117
+ case ModalStep.AWAITING_BIOMETRIC_LOGIN:
118
+ case ModalStep.AWAITING_BIOMETRIC_CREATION: {
119
+ return /* @__PURE__ */ jsx(AwaitingBiometricsStep, {});
120
+ }
121
+ case ModalStep.AWAITING_PASSWORD_LOGIN:
122
+ case ModalStep.AWAITING_PASSWORD_CREATION: {
123
+ return /* @__PURE__ */ jsx(AwaitingPasswordStep, {});
124
+ }
125
+ case ModalStep.AWAITING_WALLET_CREATION: {
126
+ return /* @__PURE__ */ jsx(AwaitingWalletCreationStep, {});
127
+ }
128
+ case ModalStep.WALLET_CREATION_DONE: {
129
+ return /* @__PURE__ */ jsx(WalletCreationDoneStep, { twoFactorAuthEnabled, onClose });
130
+ }
131
+ case ModalStep.SECRET: {
132
+ return /* @__PURE__ */ jsx(RecoverySecretStep, {});
133
+ }
134
+ case ModalStep.TWO_FACTOR_DONE: {
135
+ return /* @__PURE__ */ jsx(TwoFactorDoneStep, { onClose });
136
+ }
137
+ case ModalStep.BIOMETRIC_CREATION: {
138
+ return /* @__PURE__ */ jsx(BiometricCreationStep, {});
139
+ }
140
+ case ModalStep.AWAITING_OAUTH: {
141
+ return /* @__PURE__ */ jsx(AwaitingOAuthStep, {});
142
+ }
143
+ case ModalStep.FARCASTER_OAUTH: {
144
+ return /* @__PURE__ */ jsx(FarcasterOAuthStep, {});
145
+ }
146
+ case ModalStep.TELEGRAM_OAUTH: {
147
+ return /* @__PURE__ */ jsx(TelegramOAuthStep, {});
148
+ }
149
+ case ModalStep.ADD_FUNDS_BUY:
150
+ case ModalStep.ADD_FUNDS_RECEIVE:
151
+ case ModalStep.ADD_FUNDS_WITHDRAW: {
152
+ return /* @__PURE__ */ jsx(AddFunds, { "data-testid": "add-funds" });
153
+ }
154
+ case ModalStep.ADD_FUNDS_AWAITING: {
155
+ return /* @__PURE__ */ jsx(AddFundsAwaiting, {});
156
+ }
157
+ case ModalStep.ADD_FUNDS_SUCCESS: {
158
+ return /* @__PURE__ */ jsx(AddFundsDone, { isSuccess: true, onClose });
159
+ }
160
+ case ModalStep.ADD_FUNDS_FAILURE: {
161
+ return /* @__PURE__ */ jsx(AddFundsDone, { onClose });
162
+ }
163
+ case ModalStep.ACCOUNT_MAIN: {
164
+ return /* @__PURE__ */ jsx(Account, { onClose });
165
+ }
166
+ case ModalStep.EX_WALLET_SELECTED: {
167
+ return /* @__PURE__ */ jsx(ExternalWalletStep, {});
168
+ }
169
+ case ModalStep.CHAIN_SWITCH: {
170
+ return /* @__PURE__ */ jsx(ChainSwitch, {});
171
+ }
172
+ default: {
173
+ if (IFrameSteps.includes(currentStep)) {
174
+ return null;
175
+ }
176
+ }
177
+ }
178
+ };
179
+ useEffect(() => {
180
+ if (!isTestModeAlert && (onRampConfig == null ? void 0 : onRampConfig.testMode)) {
181
+ setIsTestModeAlert(true);
182
+ }
183
+ }, [onRampConfig == null ? void 0 : onRampConfig.testMode]);
184
+ useEffect(() => {
185
+ switch (currentStep) {
186
+ case ModalStep.ADD_FUNDS_BUY:
187
+ setAccountAddFundTab(EnabledFlow.BUY);
188
+ break;
189
+ case ModalStep.ADD_FUNDS_RECEIVE:
190
+ setAccountAddFundTab(EnabledFlow.RECEIVE);
191
+ break;
192
+ case ModalStep.ADD_FUNDS_WITHDRAW:
193
+ setAccountAddFundTab(EnabledFlow.WITHDRAW);
194
+ break;
195
+ default:
196
+ break;
197
+ }
198
+ }, [currentStep]);
199
+ return /* @__PURE__ */ jsxs(Container, { slot: "body", "data-testid": "modal-content", children: [
200
+ !embeddedModal && /* @__PURE__ */ jsxs(Fragment, { children: [
201
+ /* @__PURE__ */ jsx(Controls, { onClose }),
202
+ /* @__PURE__ */ jsx(Header, {})
203
+ ] }),
204
+ /* @__PURE__ */ jsxs(AnimatedWrapper, { children: [
205
+ /* @__PURE__ */ jsx(
206
+ AnimatePresence,
207
+ {
208
+ mode: "popLayout",
209
+ initial: false,
210
+ onExitComplete: () => {
211
+ setStepDirection(1);
212
+ },
213
+ custom: stepDirection,
214
+ children: /* @__PURE__ */ jsxs(
215
+ BodyContainer,
216
+ {
217
+ custom: stepDirection,
218
+ variants: BODY_MOTION_VARIANTS,
219
+ initial: "enter",
220
+ animate: "center",
221
+ exit: "exit",
222
+ transition: BODY_TRANSITION,
223
+ children: [
224
+ /* @__PURE__ */ jsx(Hero, {}),
225
+ /* @__PURE__ */ jsxs(
226
+ InnerContainer,
227
+ {
228
+ $embeddedModal: !!embeddedModal,
229
+ $step: currentStep,
230
+ $isIFrameStep: IFrameSteps.includes(currentStep),
231
+ children: [
232
+ /* @__PURE__ */ jsx(NetworkSpeedBanner, { fontSize: "12px", iconSize: "16px" }),
233
+ Content(),
234
+ (onRampConfig == null ? void 0 : onRampConfig.testMode) && [
235
+ ModalStep.ADD_FUNDS_BUY,
236
+ ModalStep.ADD_FUNDS_WITHDRAW,
237
+ ModalStep.ADD_FUNDS_AWAITING,
238
+ ModalStep.ADD_FUNDS_FAILURE,
239
+ ModalStep.ADD_FUNDS_SUCCESS
240
+ ].includes(currentStep) && isTestModeAlert && accountAddFundTab !== EnabledFlow.RECEIVE && /* @__PURE__ */ jsx(TestModeAlert, { children: /* @__PURE__ */ jsxs("div", { style: { fontSize: "14px" }, children: [
241
+ "This Para Modal is configured to run on-ramp services in ",
242
+ /* @__PURE__ */ jsx("b", { children: "test mode" }),
243
+ " only, for development purposes. If you are a user of ",
244
+ appName,
245
+ ", please contact support.",
246
+ /* @__PURE__ */ jsx(CloseButton, { onClick: () => setIsTestModeAlert(false), children: /* @__PURE__ */ jsx(CloseX, { icon: "x" }) })
247
+ ] }) })
248
+ ]
249
+ }
250
+ )
251
+ ]
252
+ },
253
+ ["ADD_FUNDS_BUY", "ADD_FUNDS_RECEIVE", "ADD_FUNDS_WITHDRAW"].includes(currentStep) ? "ADD_FUNDS" : currentStep
254
+ )
255
+ }
256
+ ),
257
+ /* @__PURE__ */ jsx(IFrameStep, {})
258
+ ] })
259
+ ] });
260
+ };
261
+ const Container = styled.div`
262
+ position: relative;
263
+ `;
264
+ const AnimatedWrapper = styled(AnimatedHeightWrapper)`
265
+ margin-top: -16px;
266
+ `;
267
+ const BodyContainer = styled(motion.div)`
268
+ position: relative;
269
+ display: flex;
270
+ flex-direction: column;
271
+ gap: 24px;
272
+ will-change: auto !important;
273
+ `;
274
+ const InnerContainer = styled.div`
275
+ z-index: 1;
276
+ flex: 1;
277
+ display: flex;
278
+ flex-direction: column;
279
+ justify-content: flex-start;
280
+ gap: 24px;
281
+ padding: ${({ $embeddedModal, $step, $isIFrameStep }) => {
282
+ var _a, _b;
283
+ return $isIFrameStep ? "0px" : $embeddedModal ? "12px 0px 0px" : `${(_a = PADDING_TOP[$step]) != null ? _a : "72px"} 72px ${(_b = PADDING_BOTTOM[$step]) != null ? _b : "32px"}`;
284
+ }};
285
+ min-height: ${({ $step }) => {
286
+ var _a;
287
+ return (_a = MIN_HEIGHT[$step]) != null ? _a : "auto";
288
+ }};
289
+ height: ${({ $step }) => {
290
+ var _a;
291
+ return (_a = MIN_HEIGHT[$step]) != null ? _a : "auto";
292
+ }};
293
+
294
+ @media (max-width: ${MOBILE_SIZE}px) {
295
+ padding: ${({ $embeddedModal, $step, $isIFrameStep }) => {
296
+ var _a;
297
+ return $isIFrameStep ? "0px" : $embeddedModal ? "12px 0px 0px" : `${(_a = PADDING_TOP[$step]) != null ? _a : "72px"} 16px 0px`;
298
+ }};
299
+ }
300
+
301
+ cpsl-auth-modal.force-mobile-media & {
302
+ padding: 72px 16px 0px;
303
+ }
304
+ `;
305
+ const TestModeAlert = styled(CpslAlert)`
306
+ --container-padding-end: 40px;
307
+ position: absolute;
308
+ bottom: 16px;
309
+ left: 16px;
310
+ right: 16px;
311
+ z-index: 1000;
312
+ `;
313
+ const CloseButton = styled.button`
314
+ background-color: transparent;
315
+ border: none;
316
+ padding: 4px;
317
+ cursor: pointer;
318
+ position: absolute;
319
+ top: 0;
320
+ right: 0;
321
+ `;
322
+ const CloseX = styled(CpslIcon)`
323
+ --icon-color: var(--cpsl-color-foreground-0);
324
+ `;
325
+ export {
326
+ Body
327
+ };
@@ -0,0 +1,95 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
7
+ import { CenteredText, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
8
+ import { useEffect, useMemo } from "react";
9
+ import { useModalStore } from "../../stores/index.js";
10
+ import styled from "styled-components";
11
+ import { useCopyToClipboard } from "@getpara/react-common";
12
+ import { ModalStep } from "../../utils/steps.js";
13
+ import { routeMobileExternalWallet } from "../../utils/routeMobileExternalWallet.js";
14
+ import { NETWORK_NOT_SUPPORTED_ERROR } from "../../constants/constants.js";
15
+ import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
16
+ const ChainSwitch = () => {
17
+ const [isCopied, copy] = useCopyToClipboard();
18
+ const externalWalletError = useModalStore((state) => state.externalWalletError);
19
+ const setStep = useModalStore((state) => state.setStep);
20
+ const setStepDirection = useModalStore((state) => state.setStepDirection);
21
+ const { switchChain, wallet, qrUri, chainIdSwitchingTo, walletDisplayHelpers } = useExternalWallets();
22
+ useEffect(() => {
23
+ if ((wallet == null ? void 0 : wallet.type) === "COSMOS") {
24
+ routeMobileExternalWallet(qrUri);
25
+ }
26
+ }, [qrUri, wallet]);
27
+ useEffect(() => {
28
+ if (!wallet) {
29
+ setStepDirection(-1);
30
+ setStep(ModalStep.ACCOUNT_MAIN);
31
+ }
32
+ }, [wallet]);
33
+ const handleTryAgainClick = () => __async(void 0, null, function* () {
34
+ if (chainIdSwitchingTo) {
35
+ yield switchChain(chainIdSwitchingTo);
36
+ }
37
+ });
38
+ const handleCopy = () => {
39
+ if (qrUri) {
40
+ copy(qrUri);
41
+ }
42
+ };
43
+ const Content = useMemo(() => {
44
+ var _a;
45
+ if (!wallet) {
46
+ return null;
47
+ }
48
+ const { isCosmosMobileWallet } = walletDisplayHelpers;
49
+ if (isCosmosMobileWallet) {
50
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
51
+ /* @__PURE__ */ jsx(CpslText, { weight: "semiBold", children: "Scan with your mobile device to switch networks" }),
52
+ /* @__PURE__ */ jsx(QRContainer, { children: !qrUri ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: qrUri, imageSrc: wallet.iconUrl }) }),
53
+ /* @__PURE__ */ jsxs(CpslButton, { size: "small", variant: "ghost", onClick: handleCopy, children: [
54
+ /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: isCopied ? "check" : "copy" }),
55
+ isCopied ? "Copied" : "Copy Link"
56
+ ] })
57
+ ] }) });
58
+ }
59
+ return /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
60
+ !(externalWalletError == null ? void 0 : externalWalletError.length) ? /* @__PURE__ */ jsx(CenteredText, { color: "contrast", weight: "semiBold", children: `Confirm the request to change networks in your ${wallet.name} wallet.` }) : /* @__PURE__ */ jsxs(Fragment, { children: [
61
+ /* @__PURE__ */ jsxs(ErrorContainer, { children: [
62
+ /* @__PURE__ */ jsx(ErrorIcon, { icon: "alertCircle" }),
63
+ /* @__PURE__ */ jsx(CenteredText, { weight: "semiBold", color: "error", children: externalWalletError[0] })
64
+ ] }),
65
+ externalWalletError[1] && /* @__PURE__ */ jsx(CenteredText, { color: "secondary", weight: "medium", children: externalWalletError[1] })
66
+ ] }),
67
+ ((_a = externalWalletError == null ? void 0 : externalWalletError[0]) == null ? void 0 : _a.toLowerCase()) !== NETWORK_NOT_SUPPORTED_ERROR && /* @__PURE__ */ jsxs(CpslButton, { variant: "secondary", onClick: handleTryAgainClick, children: [
68
+ /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "refresh" }),
69
+ "Try Again"
70
+ ] })
71
+ ] });
72
+ }, [wallet, walletDisplayHelpers, externalWalletError, qrUri]);
73
+ if (!wallet) {
74
+ return null;
75
+ }
76
+ return /* @__PURE__ */ jsx(Container, { children: Content });
77
+ };
78
+ const Container = styled(StepContainer)`
79
+ flex: 1;
80
+ justify-content: space-between;
81
+ `;
82
+ const ErrorContainer = styled.div`
83
+ display: flex;
84
+ align-items: center;
85
+ justify-content: center;
86
+ gap: 4px;
87
+ `;
88
+ const ErrorIcon = styled(CpslIcon)`
89
+ --height: 16px;
90
+ --width: 16px;
91
+ --icon-color: var(--cpsl-color-text-error);
92
+ `;
93
+ export {
94
+ ChainSwitch
95
+ };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ var TabValue = /* @__PURE__ */ ((TabValue2) => {
4
+ TabValue2["extension"] = "extension";
5
+ TabValue2["mobile"] = "mobile";
6
+ TabValue2["web"] = "web";
7
+ return TabValue2;
8
+ })(TabValue || {});
9
+ const TABS = {
10
+ extension: { label: "Extension", value: "extension" /* extension */, icon: "puzzlePiece" },
11
+ mobile: { label: "Mobile", value: "mobile" /* mobile */, icon: "phone" },
12
+ web: { label: "Web", value: "web" /* web */, icon: "globe" }
13
+ };
14
+ export {
15
+ TABS,
16
+ TabValue
17
+ };
@@ -0,0 +1,77 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslIcon } from "@getpara/react-components";
5
+ import { styled } from "styled-components";
6
+ import { useModalStore } from "../../stores/index.js";
7
+ import { useGoBack } from "../../hooks/useGoBack.js";
8
+ import { AccountSelect, ChainSelect } from "./Selects.js";
9
+ import { ModalStep } from "../../utils/steps.js";
10
+ import { HeaderButton } from "@getpara/react-common";
11
+ import { useStore } from "../../../provider/stores/useStore.js";
12
+ const Controls = ({ onClose }) => {
13
+ const bareModal = useStore((state) => {
14
+ var _a;
15
+ return (_a = state.modalConfig) == null ? void 0 : _a.bareModal;
16
+ });
17
+ const hasPreviousStep = useModalStore((state) => state.hasPreviousStep());
18
+ const step = useModalStore((state) => state.step);
19
+ const isFullyLoggedIn = useModalStore((state) => state.isFullyLoggedIn);
20
+ const goBack = useGoBack();
21
+ const shouldShowSelects = [
22
+ ModalStep.ACCOUNT_MAIN,
23
+ ModalStep.CHAIN_SWITCH,
24
+ ModalStep.ADD_FUNDS_BUY,
25
+ ModalStep.ADD_FUNDS_RECEIVE,
26
+ ModalStep.ADD_FUNDS_WITHDRAW
27
+ ].includes(step);
28
+ const handleBackClick = () => {
29
+ goBack();
30
+ };
31
+ return /* @__PURE__ */ jsxs(Container, { children: [
32
+ /* @__PURE__ */ jsx(
33
+ BackButton,
34
+ {
35
+ variant: "ghost",
36
+ style: {
37
+ visibility: hasPreviousStep ? "visible" : "hidden"
38
+ },
39
+ onClick: handleBackClick,
40
+ children: /* @__PURE__ */ jsx(CpslIcon, { icon: "arrow" })
41
+ }
42
+ ),
43
+ /* @__PURE__ */ jsx(MiddleContainer, { children: shouldShowSelects && isFullyLoggedIn && /* @__PURE__ */ jsxs(Fragment, { children: [
44
+ /* @__PURE__ */ jsx(ChainSelect, {}),
45
+ /* @__PURE__ */ jsx(AccountSelect, {})
46
+ ] }) }),
47
+ /* @__PURE__ */ jsx(CloseButton, { bareModal, variant: "ghost", onClick: onClose, children: /* @__PURE__ */ jsx(CpslIcon, { icon: "close" }) })
48
+ ] });
49
+ };
50
+ const Container = styled.div`
51
+ position: absolute;
52
+ width: 100%;
53
+ top: 16px;
54
+
55
+ z-index: 3;
56
+ display: flex;
57
+ align-items: center;
58
+ justify-content: space-between;
59
+ gap: 8px;
60
+ `;
61
+ const MiddleContainer = styled.div`
62
+ flex: 1;
63
+ display: flex;
64
+ align-items: center;
65
+ justify-content: center;
66
+ gap: 4px;
67
+ `;
68
+ const CloseButton = styled(HeaderButton)`
69
+ transform: rotate(180deg);
70
+ visibility: ${({ bareModal }) => bareModal ? "hidden" : "visible"};
71
+ `;
72
+ const BackButton = styled(HeaderButton)`
73
+ transform: rotate(180deg);
74
+ `;
75
+ export {
76
+ Controls
77
+ };