@funkit/connect-rn 0.0.0-20260710210119

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 (131) hide show
  1. package/CHANGELOG.md +350 -0
  2. package/README.md +220 -0
  3. package/dist/index.d.ts +24 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +4158 -0
  6. package/dist/index.js.map +7 -0
  7. package/dist/src/flow/AddressCopiedToast.d.ts +18 -0
  8. package/dist/src/flow/AddressCopiedToast.d.ts.map +1 -0
  9. package/dist/src/flow/FlowSheet.d.ts +47 -0
  10. package/dist/src/flow/FlowSheet.d.ts.map +1 -0
  11. package/dist/src/flow/FunkitFlowProvider.d.ts +23 -0
  12. package/dist/src/flow/FunkitFlowProvider.d.ts.map +1 -0
  13. package/dist/src/flow/depositFlowConfig.d.ts +101 -0
  14. package/dist/src/flow/depositFlowConfig.d.ts.map +1 -0
  15. package/dist/src/flow/useKeyboardHeight.d.ts +21 -0
  16. package/dist/src/flow/useKeyboardHeight.d.ts.map +1 -0
  17. package/dist/src/geo/isCountryBlocked.d.ts +3 -0
  18. package/dist/src/geo/isCountryBlocked.d.ts.map +1 -0
  19. package/dist/src/geo/useCheckoutBlocked.d.ts +10 -0
  20. package/dist/src/geo/useCheckoutBlocked.d.ts.map +1 -0
  21. package/dist/src/geo/useUserIpInfo.d.ts +22 -0
  22. package/dist/src/geo/useUserIpInfo.d.ts.map +1 -0
  23. package/dist/src/icons/CopyAddressIcon.d.ts +9 -0
  24. package/dist/src/icons/CopyAddressIcon.d.ts.map +1 -0
  25. package/dist/src/icons/CryptoBitcoinIcon.d.ts +9 -0
  26. package/dist/src/icons/CryptoBitcoinIcon.d.ts.map +1 -0
  27. package/dist/src/icons/CryptoTransferQRIcon.d.ts +9 -0
  28. package/dist/src/icons/CryptoTransferQRIcon.d.ts.map +1 -0
  29. package/dist/src/icons/FigmaSystemIcons.d.ts +19 -0
  30. package/dist/src/icons/FigmaSystemIcons.d.ts.map +1 -0
  31. package/dist/src/icons/FunIcon.d.ts +18 -0
  32. package/dist/src/icons/FunIcon.d.ts.map +1 -0
  33. package/dist/src/icons/PaymentBrandIcons.d.ts +24 -0
  34. package/dist/src/icons/PaymentBrandIcons.d.ts.map +1 -0
  35. package/dist/src/icons/QrChainCluster.d.ts +22 -0
  36. package/dist/src/icons/QrChainCluster.d.ts.map +1 -0
  37. package/dist/src/icons/SourceTokenCluster.d.ts +31 -0
  38. package/dist/src/icons/SourceTokenCluster.d.ts.map +1 -0
  39. package/dist/src/icons/TokenChainIcon.d.ts +19 -0
  40. package/dist/src/icons/TokenChainIcon.d.ts.map +1 -0
  41. package/dist/src/icons/assetLogos.d.ts +12 -0
  42. package/dist/src/icons/assetLogos.d.ts.map +1 -0
  43. package/dist/src/icons/funIconUri.d.ts +16 -0
  44. package/dist/src/icons/funIconUri.d.ts.map +1 -0
  45. package/dist/src/identity/IdentityContext.d.ts +52 -0
  46. package/dist/src/identity/IdentityContext.d.ts.map +1 -0
  47. package/dist/src/logging/consoleLogTransport.d.ts +10 -0
  48. package/dist/src/logging/consoleLogTransport.d.ts.map +1 -0
  49. package/dist/src/logging/datadogHttpLogTransport.d.ts +46 -0
  50. package/dist/src/logging/datadogHttpLogTransport.d.ts.map +1 -0
  51. package/dist/src/logging/logger.d.ts +9 -0
  52. package/dist/src/logging/logger.d.ts.map +1 -0
  53. package/dist/src/providers/FunkitProvider.d.ts +65 -0
  54. package/dist/src/providers/FunkitProvider.d.ts.map +1 -0
  55. package/dist/src/providers/FunkitStatsigProvider.d.ts +13 -0
  56. package/dist/src/providers/FunkitStatsigProvider.d.ts.map +1 -0
  57. package/dist/src/providers/useFunkitCheckout.d.ts +14 -0
  58. package/dist/src/providers/useFunkitCheckout.d.ts.map +1 -0
  59. package/dist/src/screens/AddMoneyScreen.d.ts +86 -0
  60. package/dist/src/screens/AddMoneyScreen.d.ts.map +1 -0
  61. package/dist/src/screens/AvailableChainsScreen.d.ts +33 -0
  62. package/dist/src/screens/AvailableChainsScreen.d.ts.map +1 -0
  63. package/dist/src/screens/CheckoutBlockedScreen.d.ts +2 -0
  64. package/dist/src/screens/CheckoutBlockedScreen.d.ts.map +1 -0
  65. package/dist/src/screens/NetworkSelector.d.ts +31 -0
  66. package/dist/src/screens/NetworkSelector.d.ts.map +1 -0
  67. package/dist/src/screens/QrCodeScreen.d.ts +42 -0
  68. package/dist/src/screens/QrCodeScreen.d.ts.map +1 -0
  69. package/dist/src/screens/TransferCryptoScreen.d.ts +40 -0
  70. package/dist/src/screens/TransferCryptoScreen.d.ts.map +1 -0
  71. package/dist/src/statsig/StatsigClientRN.d.ts +6 -0
  72. package/dist/src/statsig/StatsigClientRN.d.ts.map +1 -0
  73. package/dist/src/statsig/StatsigProviderRN.d.ts +7 -0
  74. package/dist/src/statsig/StatsigProviderRN.d.ts.map +1 -0
  75. package/dist/src/statsig/appVisibilityShim.d.ts +2 -0
  76. package/dist/src/statsig/appVisibilityShim.d.ts.map +1 -0
  77. package/dist/src/statsig/preloadedAsyncStorage.d.ts +3 -0
  78. package/dist/src/statsig/preloadedAsyncStorage.d.ts.map +1 -0
  79. package/dist/src/statsig/rnSetup.d.ts +3 -0
  80. package/dist/src/statsig/rnSetup.d.ts.map +1 -0
  81. package/dist/src/statsig/statsigMetadata.d.ts +2 -0
  82. package/dist/src/statsig/statsigMetadata.d.ts.map +1 -0
  83. package/dist/src/statsig/useClientAsyncInitRN.d.ts +7 -0
  84. package/dist/src/statsig/useClientAsyncInitRN.d.ts.map +1 -0
  85. package/dist/src/statsig/useClientBootstrapInitRN.d.ts +4 -0
  86. package/dist/src/statsig/useClientBootstrapInitRN.d.ts.map +1 -0
  87. package/dist/src/swapped/SwappedScreen.d.ts +21 -0
  88. package/dist/src/swapped/SwappedScreen.d.ts.map +1 -0
  89. package/dist/src/swapped/SwappedWebView.d.ts +18 -0
  90. package/dist/src/swapped/SwappedWebView.d.ts.map +1 -0
  91. package/dist/src/swapped/buildSwappedTheme.d.ts +31 -0
  92. package/dist/src/swapped/buildSwappedTheme.d.ts.map +1 -0
  93. package/dist/src/swapped/webViewSwappedTransport.d.ts +74 -0
  94. package/dist/src/swapped/webViewSwappedTransport.d.ts.map +1 -0
  95. package/dist/src/theme/FunkitThemeProvider.d.ts +50 -0
  96. package/dist/src/theme/FunkitThemeProvider.d.ts.map +1 -0
  97. package/dist/src/theme/restyle.d.ts +5606 -0
  98. package/dist/src/theme/restyle.d.ts.map +1 -0
  99. package/dist/src/theme/toRestyleTheme.d.ts +490 -0
  100. package/dist/src/theme/toRestyleTheme.d.ts.map +1 -0
  101. package/dist/src/theme/tokens.d.ts +159 -0
  102. package/dist/src/theme/tokens.d.ts.map +1 -0
  103. package/dist/src/theme/useColorScheme.d.ts +25 -0
  104. package/dist/src/theme/useColorScheme.d.ts.map +1 -0
  105. package/dist/src/theme/useFunkitTheme.d.ts +29 -0
  106. package/dist/src/theme/useFunkitTheme.d.ts.map +1 -0
  107. package/dist/src/transfer/QrCode.d.ts +24 -0
  108. package/dist/src/transfer/QrCode.d.ts.map +1 -0
  109. package/dist/src/transfer/availableChains.d.ts +53 -0
  110. package/dist/src/transfer/availableChains.d.ts.map +1 -0
  111. package/dist/src/transfer/clipboard.d.ts +23 -0
  112. package/dist/src/transfer/clipboard.d.ts.map +1 -0
  113. package/dist/src/transfer/fops.d.ts +26 -0
  114. package/dist/src/transfer/fops.d.ts.map +1 -0
  115. package/dist/src/transfer/formatDepositAddress.d.ts +9 -0
  116. package/dist/src/transfer/formatDepositAddress.d.ts.map +1 -0
  117. package/dist/src/transfer/hooks/useFops.d.ts +47 -0
  118. package/dist/src/transfer/hooks/useFops.d.ts.map +1 -0
  119. package/dist/src/transfer/hooks/useSupportedTokens.d.ts +26 -0
  120. package/dist/src/transfer/hooks/useSupportedTokens.d.ts.map +1 -0
  121. package/dist/src/transfer/hooks/useTokenTransfer.d.ts +33 -0
  122. package/dist/src/transfer/hooks/useTokenTransfer.d.ts.map +1 -0
  123. package/dist/src/transfer/hooks/useTransferInit.d.ts +27 -0
  124. package/dist/src/transfer/hooks/useTransferInit.d.ts.map +1 -0
  125. package/dist/src/transfer/hooks/useUDAParams.d.ts +9 -0
  126. package/dist/src/transfer/hooks/useUDAParams.d.ts.map +1 -0
  127. package/dist/src/transfer/supportedTokens.d.ts +34 -0
  128. package/dist/src/transfer/supportedTokens.d.ts.map +1 -0
  129. package/dist/src/version.d.ts +2 -0
  130. package/dist/src/version.d.ts.map +1 -0
  131. package/package.json +109 -0
package/dist/index.js ADDED
@@ -0,0 +1,4158 @@
1
+ // src/theme/tokens.ts
2
+ var systemFontTokens = {
3
+ family: "System",
4
+ weights: {
5
+ base: { cssWeight: "400" },
6
+ medium: { cssWeight: "500" }
7
+ }
8
+ };
9
+ function fontFamilyForWeight(fonts, weight) {
10
+ const { familySuffix } = fonts.weights[weight];
11
+ return familySuffix ? `${fonts.family}-${familySuffix}` : fonts.family;
12
+ }
13
+ var lightTokens = {
14
+ colors: {
15
+ bgModal: "#FFFFFF",
16
+ bgSecondary: "#F9F9F9",
17
+ btnPrimary: "#0F0F0F",
18
+ btnPrimaryHover: "#1B1B1B",
19
+ btnPrimaryPressed: "#1B1B1B",
20
+ btnPrimaryFocused: "#0F0F0F",
21
+ btnPrimaryDisabled: "#0F0F0F",
22
+ btnSecondary: "#F9F9F9",
23
+ btnSecondaryHover: "#EFEFEF",
24
+ btnSecondaryPressed: "#DDDDDD",
25
+ btnSecondaryFocused: "#F9F9F9",
26
+ btnSecondaryDisabled: "#F9F9F9",
27
+ btnTertiary: "#FFFFFF",
28
+ btnTertiaryHover: "#F9F9F9",
29
+ btnTertiaryPressed: "#EFEFEF",
30
+ btnTertiaryFocused: "#FFFFFF",
31
+ btnTertiaryDisabled: "#FFFFFF",
32
+ btnIcon: "#FFFFFF",
33
+ btnIconHover: "#F9F9F9",
34
+ btnIconPressed: "#EFEFEF",
35
+ btnIconFocused: "#FFFFFF",
36
+ btnIconDisabled: "#FFFFFF",
37
+ btnDestructive: "#F34126",
38
+ btnDestructiveHover: "#DB3B22",
39
+ btnDestructivePressed: "#C2341E",
40
+ btnDestructiveFocused: "#F34126",
41
+ btnDestructiveDisabled: "#F34126",
42
+ pill: "#FFFFFF",
43
+ pillHover: "#F9F9F9",
44
+ pillPressed: "#EFEFEF",
45
+ pillFocused: "#FFFFFF",
46
+ pillDisabled: "#FFFFFF",
47
+ textPrimary: "#0F0F0F",
48
+ textSecondary: "#6C6C6C",
49
+ textSuccess: "#52A300",
50
+ textError: "#F34126",
51
+ textHyperlink: "#0F0F0F",
52
+ textWarning: "#F97316",
53
+ onBtnPrimary: "#FFFFFF",
54
+ onBtnPrimaryLoading: "#FFFFFF",
55
+ onBtnSecondary: "#0F0F0F",
56
+ onBtnSecondaryLoading: "#000000",
57
+ onBtnTertiary: "#0F0F0F",
58
+ onBtnIcon: "#6C6C6C",
59
+ onBtnDestructive: "#FFFFFF",
60
+ onBtnDestructiveLoading: "#FFFFFF",
61
+ borderModal: "#FFFFFF",
62
+ borderDefault: "#EFEFEF",
63
+ borderFocused: "#BEBEBE",
64
+ borderSelected: "#0F0F0F",
65
+ borderBtnPrimary: "#0F0F0F",
66
+ borderBtnSecondary: "#F9F9F9",
67
+ brandPrimary: "#0F0F0F"
68
+ },
69
+ radii: {
70
+ modal: 24,
71
+ element: 12,
72
+ elementInner: 8,
73
+ button: 12,
74
+ rounded: 999
75
+ },
76
+ borderWidths: {
77
+ modal: 1,
78
+ elementsDefault: 1,
79
+ elementsFocused: 2,
80
+ elementsSelected: 1,
81
+ button: 0
82
+ },
83
+ spacing: {
84
+ none: 0,
85
+ elementsHorizontal: 12,
86
+ modalHorizontal: 16
87
+ },
88
+ sizes: {
89
+ topBar: 56,
90
+ buttonHeight: 42,
91
+ buttonXs: 32,
92
+ buttonSm: 36,
93
+ buttonMd: 40,
94
+ buttonLg: 48,
95
+ iconXs: 16,
96
+ iconSm: 16,
97
+ iconMd: 20,
98
+ iconLg: 20
99
+ },
100
+ fonts: systemFontTokens,
101
+ fontSizes: {
102
+ bodyBase: 16,
103
+ bodyDetail: 14,
104
+ headerTitle: 13,
105
+ headerSubtitle: 15,
106
+ amountInput: 48,
107
+ amountSummary: 48
108
+ },
109
+ fontLineHeights: {
110
+ bodyBase: 22,
111
+ bodyDetail: 20
112
+ }
113
+ };
114
+ var darkTokens = {
115
+ colors: {
116
+ bgModal: "#0F0F0F",
117
+ bgSecondary: "#1B1B1B",
118
+ btnPrimary: "#F9F9F9",
119
+ btnPrimaryHover: "#EFEFEF",
120
+ btnPrimaryPressed: "#EFEFEF",
121
+ btnPrimaryFocused: "#F9F9F9",
122
+ btnPrimaryDisabled: "#F9F9F9",
123
+ btnSecondary: "#1B1B1B",
124
+ btnSecondaryHover: "#2D2D2D",
125
+ btnSecondaryPressed: "#464646",
126
+ btnSecondaryFocused: "#1B1B1B",
127
+ btnSecondaryDisabled: "#1B1B1B",
128
+ btnTertiary: "#0F0F0F",
129
+ btnTertiaryHover: "#2D2D2D",
130
+ btnTertiaryPressed: "#464646",
131
+ btnTertiaryFocused: "#0F0F0F",
132
+ btnTertiaryDisabled: "#0F0F0F",
133
+ btnIcon: "#0F0F0F",
134
+ btnIconHover: "#1B1B1B",
135
+ btnIconPressed: "#2D2D2D",
136
+ btnIconFocused: "#0F0F0F",
137
+ btnIconDisabled: "#0F0F0F",
138
+ btnDestructive: "#DB3B22",
139
+ btnDestructiveHover: "#F34126",
140
+ btnDestructivePressed: "#F88877",
141
+ btnDestructiveFocused: "#DB3B22",
142
+ btnDestructiveDisabled: "#DB3B22",
143
+ pill: "#0F0F0F",
144
+ pillHover: "#1B1B1B",
145
+ pillPressed: "#2D2D2D",
146
+ pillFocused: "#0F0F0F",
147
+ pillDisabled: "#0F0F0F",
148
+ textPrimary: "#FFFFFF",
149
+ textSecondary: "#929292",
150
+ textSuccess: "#52A300",
151
+ textError: "#F34126",
152
+ textHyperlink: "#4971F0",
153
+ textWarning: "#F97316",
154
+ onBtnPrimary: "#000000",
155
+ onBtnPrimaryLoading: "#000000",
156
+ onBtnSecondary: "#F9F9F9",
157
+ onBtnSecondaryLoading: "#FFFFFF",
158
+ onBtnTertiary: "#F9F9F9",
159
+ onBtnIcon: "#929292",
160
+ onBtnDestructive: "#FFFFFF",
161
+ onBtnDestructiveLoading: "#FFFFFF",
162
+ borderModal: "#1B1B1B",
163
+ borderDefault: "#2D2D2D",
164
+ borderFocused: "#464646",
165
+ borderSelected: "#F9F9F9",
166
+ borderBtnPrimary: "#F9F9F9",
167
+ borderBtnSecondary: "#1B1B1B",
168
+ brandPrimary: "#FFFFFF"
169
+ },
170
+ radii: {
171
+ modal: 24,
172
+ element: 12,
173
+ elementInner: 8,
174
+ button: 24,
175
+ rounded: 999
176
+ },
177
+ borderWidths: {
178
+ modal: 1,
179
+ elementsDefault: 1,
180
+ elementsFocused: 2,
181
+ elementsSelected: 1,
182
+ button: 0
183
+ },
184
+ spacing: {
185
+ none: 0,
186
+ elementsHorizontal: 12,
187
+ modalHorizontal: 16
188
+ },
189
+ sizes: {
190
+ topBar: 56,
191
+ buttonHeight: 42,
192
+ buttonXs: 32,
193
+ buttonSm: 36,
194
+ buttonMd: 40,
195
+ buttonLg: 48,
196
+ iconXs: 16,
197
+ iconSm: 16,
198
+ iconMd: 20,
199
+ iconLg: 20
200
+ },
201
+ fonts: systemFontTokens,
202
+ fontSizes: {
203
+ bodyBase: 16,
204
+ bodyDetail: 14,
205
+ headerTitle: 13,
206
+ headerSubtitle: 15,
207
+ amountInput: 32,
208
+ amountSummary: 40
209
+ },
210
+ fontLineHeights: {
211
+ bodyBase: 22,
212
+ bodyDetail: 20
213
+ }
214
+ };
215
+
216
+ // src/theme/toRestyleTheme.ts
217
+ import { createTheme } from "@shopify/restyle";
218
+ function toRestyleTheme(tokens) {
219
+ const bodyLineHeight = tokens.fontLineHeights?.bodyBase ?? 22;
220
+ const detailLineHeight = tokens.fontLineHeights?.bodyDetail ?? 20;
221
+ const base = {
222
+ fontFamily: fontFamilyForWeight(tokens.fonts, "base"),
223
+ fontWeight: tokens.fonts.weights.base.cssWeight
224
+ };
225
+ const medium = {
226
+ fontFamily: fontFamilyForWeight(tokens.fonts, "medium"),
227
+ fontWeight: tokens.fonts.weights.medium.cssWeight
228
+ };
229
+ return createTheme({
230
+ colors: {
231
+ ...tokens.colors,
232
+ transparent: "transparent"
233
+ },
234
+ spacing: tokens.spacing,
235
+ borderRadii: tokens.radii,
236
+ borderWidths: tokens.borderWidths,
237
+ sizes: tokens.sizes,
238
+ breakpoints: {
239
+ phone: 0,
240
+ tablet: 768
241
+ },
242
+ textVariants: {
243
+ defaults: {
244
+ ...base,
245
+ fontSize: tokens.fontSizes.bodyBase,
246
+ lineHeight: bodyLineHeight,
247
+ color: "textPrimary"
248
+ },
249
+ body: {
250
+ ...base,
251
+ fontSize: tokens.fontSizes.bodyBase,
252
+ lineHeight: bodyLineHeight,
253
+ color: "textPrimary"
254
+ },
255
+ bodyMedium: {
256
+ ...medium,
257
+ fontSize: tokens.fontSizes.bodyBase,
258
+ lineHeight: bodyLineHeight,
259
+ color: "textPrimary"
260
+ },
261
+ detail: {
262
+ ...base,
263
+ fontSize: tokens.fontSizes.bodyDetail,
264
+ lineHeight: detailLineHeight,
265
+ color: "textSecondary"
266
+ },
267
+ headerTitle: {
268
+ ...medium,
269
+ fontSize: tokens.fontSizes.headerTitle,
270
+ color: "textPrimary",
271
+ textAlign: "center"
272
+ },
273
+ headerSubtitle: {
274
+ ...medium,
275
+ fontSize: tokens.fontSizes.headerSubtitle,
276
+ color: "textSecondary",
277
+ textAlign: "center"
278
+ },
279
+ amountInput: {
280
+ ...medium,
281
+ fontSize: tokens.fontSizes.amountInput,
282
+ color: "textPrimary"
283
+ },
284
+ amountSummary: {
285
+ ...medium,
286
+ fontSize: tokens.fontSizes.amountSummary,
287
+ color: "textPrimary"
288
+ }
289
+ },
290
+ // Per-weight `{ fontFamily, fontWeight }` the `Text` `weight` prop applies on
291
+ // top of any variant. Weight selection must set BOTH for custom fonts (see
292
+ // `fontFamilyForWeight`), so this reuses the exact `base`/`medium` the
293
+ // variants use — letting a node override only its weight (e.g.
294
+ // `variant="detail" weight="medium"`) without a `*Medium` twin per variant.
295
+ textWeights: {
296
+ base,
297
+ medium
298
+ }
299
+ });
300
+ }
301
+ var defaultLightTheme = toRestyleTheme(lightTokens);
302
+ var defaultDarkTheme = toRestyleTheme(darkTokens);
303
+
304
+ // src/theme/useColorScheme.ts
305
+ import { useEffect, useState } from "react";
306
+ import { Appearance } from "react-native";
307
+ function resolveColorScheme(controlled, override, system) {
308
+ if (controlled) {
309
+ return controlled;
310
+ }
311
+ return override ?? system ?? "light";
312
+ }
313
+ function normalizeColorScheme(scheme) {
314
+ return scheme === "light" || scheme === "dark" ? scheme : void 0;
315
+ }
316
+ function useColorScheme() {
317
+ const [scheme, setScheme] = useState(
318
+ () => normalizeColorScheme(Appearance.getColorScheme())
319
+ );
320
+ useEffect(() => {
321
+ const subscription = Appearance.addChangeListener(({ colorScheme }) => {
322
+ setScheme(normalizeColorScheme(colorScheme));
323
+ });
324
+ return () => subscription.remove();
325
+ }, []);
326
+ return scheme;
327
+ }
328
+
329
+ // src/theme/useFunkitTheme.ts
330
+ import { useMemo } from "react";
331
+ var DEFAULT_THEME_SET = {
332
+ light: defaultLightTheme,
333
+ dark: defaultDarkTheme
334
+ };
335
+ function selectTheme(themeSet, scheme) {
336
+ const primary = scheme === "dark" ? themeSet.dark : themeSet.light;
337
+ const fallback = scheme === "dark" ? themeSet.light : themeSet.dark;
338
+ if (primary) {
339
+ return primary;
340
+ }
341
+ if (fallback) {
342
+ return fallback;
343
+ }
344
+ throw new Error(
345
+ "FunkitProvider: `themes` must include at least one of { light, dark }"
346
+ );
347
+ }
348
+ function useFunkitTheme(themeSet = DEFAULT_THEME_SET) {
349
+ const scheme = useColorScheme();
350
+ return useMemo(
351
+ () => selectTheme(themeSet, scheme),
352
+ [scheme, themeSet.light, themeSet.dark]
353
+ );
354
+ }
355
+
356
+ // src/theme/restyle.ts
357
+ import {
358
+ createBox,
359
+ createText,
360
+ useTheme as useRestyleTheme
361
+ } from "@shopify/restyle";
362
+ import {
363
+ createElement,
364
+ forwardRef
365
+ } from "react";
366
+ var Box = createBox();
367
+ var RestyleText = createText();
368
+ var Text = forwardRef(
369
+ function Text2({ weight, style, ...rest }, ref) {
370
+ const theme = useRestyleTheme();
371
+ const weightStyle = weight ? theme.textWeights?.[weight] : void 0;
372
+ return createElement(RestyleText, {
373
+ ref,
374
+ style: weightStyle ? [weightStyle, style] : style,
375
+ ...rest
376
+ });
377
+ }
378
+ );
379
+ var useTheme = () => useRestyleTheme();
380
+
381
+ // src/flow/AddressCopiedToast.tsx
382
+ import { StyleSheet, Text as Text3 } from "react-native";
383
+ import Animated, { Easing, FadeOutUp, Keyframe } from "react-native-reanimated";
384
+
385
+ // src/icons/FigmaSystemIcons.tsx
386
+ import { SvgXml } from "react-native-svg";
387
+ import { jsx } from "react/jsx-runtime";
388
+ function useIconColor(color) {
389
+ const theme = useTheme();
390
+ return color ?? theme.colors.textPrimary;
391
+ }
392
+ function renderIcon(svg, size, color) {
393
+ return /* @__PURE__ */ jsx(
394
+ SvgXml,
395
+ {
396
+ xml: svg.replace(/currentColor/g, color),
397
+ width: size,
398
+ height: size
399
+ }
400
+ );
401
+ }
402
+ var CLOSE_SVG = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.41291 3.08709C4.0468 2.72097 3.4532 2.72097 3.08709 3.08709C2.72097 3.4532 2.72097 4.0468 3.08709 4.41291L8.67417 10L3.08709 15.5871C2.72097 15.9532 2.72097 16.5468 3.08709 16.9129C3.4532 17.279 4.0468 17.279 4.41291 16.9129L10 11.3258L15.5871 16.9129C15.9532 17.279 16.5468 17.279 16.9129 16.9129C17.279 16.5468 17.279 15.9532 16.9129 15.5871L11.3258 10L16.9129 4.41291C17.279 4.0468 17.279 3.4532 16.9129 3.08709C16.5468 2.72097 15.9532 2.72097 15.5871 3.08709L10 8.67417L4.41291 3.08709Z" fill="currentColor"/></svg>';
403
+ var QR_SCAN_SVG = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.83333 9.99935H10V14.166M2.50833 9.99935H2.5M6.675 14.166H6.66667M10.0083 17.4993H10M17.5083 9.99935H17.5M2.5 14.166H3.75M12.9167 9.99935H14.5833M2.5 17.4993H6.66667M10 1.66602V6.66602M14.6667 17.4993H16.1667C16.6334 17.4993 16.8667 17.4993 17.045 17.4085C17.2018 17.3286 17.3293 17.2011 17.4092 17.0443C17.5 16.8661 17.5 16.6327 17.5 16.166V14.666C17.5 14.1993 17.5 13.966 17.4092 13.7877C17.3293 13.6309 17.2018 13.5034 17.045 13.4235C16.8667 13.3327 16.6334 13.3327 16.1667 13.3327H14.6667C14.2 13.3327 13.9666 13.3327 13.7883 13.4235C13.6315 13.5034 13.5041 13.6309 13.4242 13.7877C13.3333 13.966 13.3333 14.1993 13.3333 14.666V16.166C13.3333 16.6327 13.3333 16.8661 13.4242 17.0443C13.5041 17.2011 13.6315 17.3286 13.7883 17.4085C13.9666 17.4993 14.2 17.4993 14.6667 17.4993ZM14.6667 6.66602H16.1667C16.6334 6.66602 16.8667 6.66602 17.045 6.57519C17.2018 6.49529 17.3293 6.36781 17.4092 6.21101C17.5 6.03275 17.5 5.79939 17.5 5.33268V3.83268C17.5 3.36597 17.5 3.13262 17.4092 2.95436C17.3293 2.79756 17.2018 2.67007 17.045 2.59018C16.8667 2.49935 16.6334 2.49935 16.1667 2.49935H14.6667C14.2 2.49935 13.9666 2.49935 13.7883 2.59018C13.6315 2.67007 13.5041 2.79756 13.4242 2.95436C13.3333 3.13262 13.3333 3.36597 13.3333 3.83268V5.33268C13.3333 5.79939 13.3333 6.03275 13.4242 6.21101C13.5041 6.36781 13.6315 6.49529 13.7883 6.57519C13.9666 6.66602 14.2 6.66602 14.6667 6.66602ZM3.83333 6.66602H5.33333C5.80004 6.66602 6.0334 6.66602 6.21166 6.57519C6.36846 6.49529 6.49594 6.36781 6.57584 6.21101C6.66667 6.03275 6.66667 5.79939 6.66667 5.33268V3.83268C6.66667 3.36597 6.66667 3.13262 6.57584 2.95436C6.49594 2.79756 6.36846 2.67007 6.21166 2.59018C6.0334 2.49935 5.80004 2.49935 5.33333 2.49935H3.83333C3.36662 2.49935 3.13327 2.49935 2.95501 2.59018C2.79821 2.67007 2.67072 2.79756 2.59083 2.95436C2.5 3.13262 2.5 3.36597 2.5 3.83268V5.33268C2.5 5.79939 2.5 6.03275 2.59083 6.21101C2.67072 6.36781 2.79821 6.49529 2.95501 6.57519C3.13327 6.66602 3.36662 6.66602 3.83333 6.66602Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>';
404
+ var COPY_SVG = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.6 10.4V12.08C5.6 12.7521 5.6 13.0881 5.73079 13.3448C5.84584 13.5706 6.02942 13.7542 6.25521 13.8692C6.51191 14 6.84794 14 7.52 14H12.08C12.7521 14 13.0881 14 13.3448 13.8692C13.5706 13.7542 13.7542 13.5706 13.8692 13.3448C14 13.0881 14 12.7521 14 12.08V7.52C14 6.84794 14 6.51191 13.8692 6.25521C13.7542 6.02942 13.5706 5.84584 13.3448 5.73079C13.0881 5.6 12.7521 5.6 12.08 5.6H10.4M3.92 10.4H8.48C9.15206 10.4 9.48809 10.4 9.74479 10.2692C9.97058 10.1542 10.1542 9.97058 10.2692 9.74479C10.4 9.48809 10.4 9.15206 10.4 8.48V3.92C10.4 3.24794 10.4 2.91191 10.2692 2.65521C10.1542 2.42942 9.97058 2.24584 9.74479 2.13079C9.48809 2 9.15206 2 8.48 2H3.92C3.24794 2 2.91191 2 2.65521 2.13079C2.42942 2.24584 2.24584 2.42942 2.13079 2.65521C2 2.91191 2 3.24794 2 3.92V8.48C2 9.15206 2 9.48809 2.13079 9.74479C2.24584 9.97058 2.42942 10.1542 2.65521 10.2692C2.91191 10.4 3.24794 10.4 3.92 10.4Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>';
405
+ var SHARE_SVG = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14 8V10.8C14 11.9201 14 12.4802 13.782 12.908C13.5903 13.2843 13.2843 13.5903 12.908 13.782C12.4802 14 11.9201 14 10.8 14H5.2C4.07989 14 3.51984 14 3.09202 13.782C2.71569 13.5903 2.40973 13.2843 2.21799 12.908C2 12.4802 2 11.9201 2 10.8V8M5.33333 4.66667L8 2L10.6667 4.66667M8 2V10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>';
406
+ var CHEVRON_RIGHT_SVG = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.71967 12.5303C5.42678 12.2374 5.42678 11.7626 5.71967 11.4697L9.18934 8L5.71967 4.53033C5.42678 4.23744 5.42678 3.76256 5.71967 3.46967C6.01256 3.17678 6.48744 3.17678 6.78033 3.46967L10.7803 7.46967C11.0732 7.76256 11.0732 8.23744 10.7803 8.53033L6.78033 12.5303C6.48744 12.8232 6.01256 12.8232 5.71967 12.5303Z" fill="currentColor"/></svg>';
407
+ var CHEVRON_LEFT_SVG = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.8504 15.6629C13.2165 15.2968 13.2165 14.7032 12.8504 14.3371L8.51333 10L12.8504 5.66291C13.2165 5.2968 13.2165 4.7032 12.8504 4.33709C12.4843 3.97097 11.8907 3.97097 11.5246 4.33709L6.52459 9.33709C6.15847 9.7032 6.15847 10.2968 6.52459 10.6629L11.5246 15.6629C11.8907 16.029 12.4843 16.029 12.8504 15.6629Z" fill="currentColor"/></svg>';
408
+ var SUCCESS_CHECK_SVG = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.5 8.5L7 10L10.5 6.5M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z" stroke="#52A300" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>';
409
+ var CHEVRON_DOWN_SVG = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.46967 5.71967C3.76256 5.42678 4.23744 5.42678 4.53033 5.71967L8 9.18934L11.4697 5.71967C11.7626 5.42678 12.2374 5.42678 12.5303 5.71967C12.8232 6.01256 12.8232 6.48744 12.5303 6.78033L8.53033 10.7803C8.23744 11.0732 7.76256 11.0732 7.46967 10.7803L3.46967 6.78033C3.17678 6.48744 3.17678 6.01256 3.46967 5.71967Z" fill="currentColor"/></svg>';
410
+ var CHECK_SVG = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M13.8047 4.19526C14.0651 4.45561 14.0651 4.87772 13.8047 5.13807L6.80474 12.1381C6.54439 12.3984 6.12228 12.3984 5.86193 12.1381L2.5286 8.80474C2.26825 8.54439 2.26825 8.12228 2.5286 7.86193C2.78895 7.60158 3.21106 7.60158 3.4714 7.86193L6.33333 10.7239L12.8619 4.19526C13.1223 3.93491 13.5444 3.93491 13.8047 4.19526Z" fill="currentColor"/></svg>';
411
+ function FigmaCloseIcon({ size = 20, color }) {
412
+ return renderIcon(CLOSE_SVG, size, useIconColor(color));
413
+ }
414
+ function FigmaQrScanIcon({ size = 20, color }) {
415
+ return renderIcon(QR_SCAN_SVG, size, useIconColor(color));
416
+ }
417
+ function FigmaCopyIcon({ size = 16, color }) {
418
+ return renderIcon(COPY_SVG, size, useIconColor(color));
419
+ }
420
+ function FigmaShareIcon({ size = 16, color }) {
421
+ return renderIcon(SHARE_SVG, size, useIconColor(color));
422
+ }
423
+ function FigmaChevronRightIcon({ size = 16, color }) {
424
+ return renderIcon(CHEVRON_RIGHT_SVG, size, useIconColor(color));
425
+ }
426
+ function FigmaChevronLeftIcon({ size = 20, color }) {
427
+ return renderIcon(CHEVRON_LEFT_SVG, size, useIconColor(color));
428
+ }
429
+ function FigmaSuccessCheckIcon({ size = 16 }) {
430
+ return /* @__PURE__ */ jsx(SvgXml, { xml: SUCCESS_CHECK_SVG, width: size, height: size });
431
+ }
432
+ function FigmaChevronDownIcon({ size = 16, color }) {
433
+ return renderIcon(CHEVRON_DOWN_SVG, size, useIconColor(color));
434
+ }
435
+ function FigmaCheckIcon({ size = 16, color }) {
436
+ return renderIcon(CHECK_SVG, size, useIconColor(color));
437
+ }
438
+ var INFO_CIRCLE_SVG = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 9.16667V13.3333M10 6.66667H10.0083M17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>';
439
+ function FigmaInfoCircleIcon({ size = 20, color }) {
440
+ return renderIcon(INFO_CIRCLE_SVG, size, useIconColor(color));
441
+ }
442
+ var PLUS_SVG = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.20833 5V11.4167M5 8.20833H11.4167" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>';
443
+ function FigmaPlusIcon({ size = 16, color }) {
444
+ return renderIcon(PLUS_SVG, size, useIconColor(color));
445
+ }
446
+
447
+ // src/flow/AddressCopiedToast.tsx
448
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
449
+ var enterAnimation = new Keyframe({
450
+ 0: {
451
+ opacity: 0,
452
+ transform: [{ translateY: 8 }, { scale: 0.96 }]
453
+ },
454
+ 100: {
455
+ opacity: 1,
456
+ transform: [{ translateY: 0 }, { scale: 1 }],
457
+ easing: Easing.bezier(0.34, 1.36, 0.64, 1)
458
+ }
459
+ }).duration(450);
460
+ var exitAnimation = FadeOutUp.duration(350);
461
+ function AddressCopiedToast({
462
+ label: label2 = "Address copied"
463
+ }) {
464
+ return /* @__PURE__ */ jsxs(
465
+ Animated.View,
466
+ {
467
+ entering: enterAnimation,
468
+ exiting: exitAnimation,
469
+ style: styles.pill,
470
+ accessibilityRole: "alert",
471
+ accessibilityLabel: label2,
472
+ children: [
473
+ /* @__PURE__ */ jsx2(Text3, { style: styles.label, children: label2 }),
474
+ /* @__PURE__ */ jsx2(FigmaSuccessCheckIcon, { size: 16 })
475
+ ]
476
+ }
477
+ );
478
+ }
479
+ var pill = {
480
+ height: 42,
481
+ paddingHorizontal: 16,
482
+ borderRadius: 999,
483
+ backgroundColor: "#ffffff",
484
+ flexDirection: "row",
485
+ alignItems: "center",
486
+ gap: 6,
487
+ shadowColor: "#000000",
488
+ shadowOpacity: 0.08,
489
+ shadowOffset: { width: 0, height: 4 },
490
+ shadowRadius: 12
491
+ };
492
+ var label = {
493
+ color: "#111111",
494
+ fontSize: 16,
495
+ fontWeight: "500"
496
+ };
497
+ var styles = StyleSheet.create({ pill, label });
498
+
499
+ // src/theme/FunkitThemeProvider.tsx
500
+ import { ThemeProvider } from "@shopify/restyle";
501
+ import {
502
+ createContext,
503
+ useCallback,
504
+ useContext,
505
+ useMemo as useMemo2,
506
+ useState as useState2
507
+ } from "react";
508
+ import { jsx as jsx3 } from "react/jsx-runtime";
509
+ var DEFAULT_THEMES = {
510
+ light: defaultLightTheme,
511
+ dark: defaultDarkTheme
512
+ };
513
+ var FunkitColorSchemeContext = createContext(
514
+ null
515
+ );
516
+ function FunkitThemeProvider({
517
+ children,
518
+ themes = DEFAULT_THEMES,
519
+ colorScheme
520
+ }) {
521
+ const isControlled = colorScheme != null;
522
+ const systemScheme = useColorScheme();
523
+ const [override, setOverride] = useState2(void 0);
524
+ const activeScheme = resolveColorScheme(colorScheme, override, systemScheme);
525
+ const toggleColorScheme = useCallback(
526
+ (next) => {
527
+ if (colorScheme != null) {
528
+ return;
529
+ }
530
+ setOverride((prev) => {
531
+ if (next != null) {
532
+ return next;
533
+ }
534
+ const current = resolveColorScheme(void 0, prev, systemScheme);
535
+ return current === "dark" ? "light" : "dark";
536
+ });
537
+ },
538
+ [colorScheme, systemScheme]
539
+ );
540
+ const theme = selectTheme(themes, activeScheme);
541
+ const value = useMemo2(
542
+ () => ({ colorScheme: activeScheme, toggleColorScheme, isControlled }),
543
+ [activeScheme, toggleColorScheme, isControlled]
544
+ );
545
+ return /* @__PURE__ */ jsx3(FunkitColorSchemeContext.Provider, { value, children: /* @__PURE__ */ jsx3(ThemeProvider, { theme, children }) });
546
+ }
547
+ function useFunkitColorScheme() {
548
+ const value = useContext(FunkitColorSchemeContext);
549
+ if (value == null) {
550
+ throw new Error("useFunkitColorScheme must be used within <FunkitProvider>");
551
+ }
552
+ return value;
553
+ }
554
+
555
+ // src/providers/FunkitProvider.tsx
556
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
557
+ import { useEffect as useEffect12, useMemo as useMemo10, useRef as useRef7 } from "react";
558
+ import { SafeAreaProvider } from "react-native-safe-area-context";
559
+
560
+ // src/flow/FunkitFlowProvider.tsx
561
+ import { useDynamicConfig as useDynamicConfig6 } from "@funkit/connect-core";
562
+ import {
563
+ createContext as createContext3,
564
+ useCallback as useCallback5,
565
+ useContext as useContext3,
566
+ useEffect as useEffect11,
567
+ useMemo as useMemo8,
568
+ useRef as useRef6,
569
+ useState as useState9
570
+ } from "react";
571
+ import { Share, StyleSheet as StyleSheet3, View as View3 } from "react-native";
572
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
573
+
574
+ // src/geo/useCheckoutBlocked.ts
575
+ import { useEffect as useEffect2, useMemo as useMemo3 } from "react";
576
+ import { useDynamicConfig, useEffectEvent } from "@funkit/connect-core";
577
+
578
+ // src/logging/logger.ts
579
+ import { FunLogger } from "@funkit/connect-core";
580
+
581
+ // src/logging/datadogHttpLogTransport.ts
582
+ var DEFAULT_SERVICE = "connect-rn";
583
+ var DEFAULT_SITE = "datadoghq.com";
584
+ var DEFAULT_FLUSH_INTERVAL_MS = 5e3;
585
+ var DEFAULT_MAX_BATCH_SIZE = 50;
586
+ var DatadogHttpLogTransport = class {
587
+ constructor(options) {
588
+ this.consent = "granted";
589
+ this.queue = [];
590
+ this.flushTimer = null;
591
+ const site = options.site ?? DEFAULT_SITE;
592
+ this.service = options.service ?? DEFAULT_SERVICE;
593
+ this.env = options.env;
594
+ this.flushIntervalMs = options.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS;
595
+ this.maxBatchSize = options.maxBatchSize ?? DEFAULT_MAX_BATCH_SIZE;
596
+ this.intakeUrl = `https://browser-intake-${site}/api/v2/logs?dd-api-key=${encodeURIComponent(options.clientToken)}&ddsource=react-native&dd-evp-origin=react-native`;
597
+ }
598
+ setEnv(environment) {
599
+ this.env = environment;
600
+ }
601
+ setTrackingConsent(consent) {
602
+ this.consent = consent;
603
+ if (consent !== "granted") {
604
+ this.queue = [];
605
+ this.clearTimer();
606
+ }
607
+ }
608
+ log({ level, title, context, error }) {
609
+ if (this.consent !== "granted") {
610
+ return;
611
+ }
612
+ const entry = {
613
+ // Caller context first so the mandatory Datadog fields below always win —
614
+ // a future LogContext attribute named e.g. `message`/`status` can't
615
+ // silently corrupt the record.
616
+ ...context,
617
+ ddsource: "react-native",
618
+ service: this.service,
619
+ status: level,
620
+ message: title,
621
+ ...this.env ? { ddtags: `env:${this.env}` } : {},
622
+ ...error ? {
623
+ error: {
624
+ message: error.message,
625
+ stack: error.stack,
626
+ kind: error.name
627
+ }
628
+ } : {}
629
+ };
630
+ this.queue.push(entry);
631
+ if (this.queue.length >= this.maxBatchSize) {
632
+ this.flush();
633
+ } else {
634
+ this.scheduleFlush();
635
+ }
636
+ }
637
+ /** Send the buffered batch. Fire-and-forget; network errors are swallowed. */
638
+ flush() {
639
+ this.clearTimer();
640
+ if (this.queue.length === 0) {
641
+ return;
642
+ }
643
+ if (typeof fetch !== "function") {
644
+ this.queue = [];
645
+ return;
646
+ }
647
+ const batch = this.queue;
648
+ this.queue = [];
649
+ fetch(this.intakeUrl, {
650
+ method: "POST",
651
+ headers: { "Content-Type": "application/json" },
652
+ body: JSON.stringify(batch)
653
+ }).catch(() => {
654
+ });
655
+ }
656
+ scheduleFlush() {
657
+ if (this.flushTimer != null) {
658
+ return;
659
+ }
660
+ this.flushTimer = setTimeout(() => {
661
+ this.flushTimer = null;
662
+ this.flush();
663
+ }, this.flushIntervalMs);
664
+ }
665
+ clearTimer() {
666
+ if (this.flushTimer != null) {
667
+ clearTimeout(this.flushTimer);
668
+ this.flushTimer = null;
669
+ }
670
+ }
671
+ };
672
+
673
+ // src/logging/logger.ts
674
+ var DDOG_CLIENT_TOKEN = "pub4f86c6be8c792cb48dc156a8c17d9a47";
675
+ var logger = new FunLogger(
676
+ new DatadogHttpLogTransport({
677
+ clientToken: DDOG_CLIENT_TOKEN
678
+ // service defaults to 'connect-rn' (see DatadogHttpLogTransport).
679
+ })
680
+ );
681
+
682
+ // src/geo/isCountryBlocked.ts
683
+ var ALL_MATCH = "*";
684
+ function isCountryBlocked(blockedList, userIpInfo) {
685
+ if (!userIpInfo.alpha2) {
686
+ logger.log("isUserBlockedForCheckout_NoIpDetected");
687
+ return true;
688
+ }
689
+ const isBlocked = blockedList.includes(ALL_MATCH) || blockedList.includes(userIpInfo.alpha2);
690
+ logger.info("isUserBlockedForCheckoutResult", {
691
+ isBlocked,
692
+ blockedList,
693
+ alpha2: userIpInfo.alpha2
694
+ });
695
+ return isBlocked;
696
+ }
697
+
698
+ // src/geo/useUserIpInfo.ts
699
+ import { useQuery } from "@tanstack/react-query";
700
+ var MOONPAY_LIVE_API_KEY = "pk_live_IxayBRQuBC3RzpPZkbGPrwUsRWAaeO";
701
+ function errData(error) {
702
+ return { error: error instanceof Error ? error.message : String(error) };
703
+ }
704
+ async function getIpViaMoonpay() {
705
+ const res = await fetch(
706
+ `https://api.moonpay.com/v3/ip_address?apiKey=${MOONPAY_LIVE_API_KEY}`
707
+ );
708
+ if (!res.ok) {
709
+ throw new Error(res.statusText);
710
+ }
711
+ const data = await res.json();
712
+ return { alpha2: data.alpha2, state: data.state };
713
+ }
714
+ async function getIpViaIpApi() {
715
+ const res = await fetch("https://ipapi.co/json");
716
+ if (!res.ok) {
717
+ throw new Error(res.statusText);
718
+ }
719
+ const data = await res.json();
720
+ return { alpha2: data.country_code, state: data.region_code };
721
+ }
722
+ function useUserIpInfo() {
723
+ const { data: userIpInfo, isLoading: isLoadingGeoCheck } = useQuery({
724
+ queryKey: ["getUserIpInfo"],
725
+ queryFn: async () => {
726
+ try {
727
+ return await getIpViaMoonpay();
728
+ } catch (moonpayError) {
729
+ logger.warn(
730
+ "connect-rn:getUserIpViaMoonpay:error",
731
+ errData(moonpayError)
732
+ );
733
+ try {
734
+ return await getIpViaIpApi();
735
+ } catch (ipApiError) {
736
+ logger.warn("connect-rn:getUserIpViaIpApi:error", errData(ipApiError));
737
+ throw ipApiError;
738
+ }
739
+ }
740
+ },
741
+ // Location is stable within a session; don't refetch aggressively.
742
+ staleTime: Number.POSITIVE_INFINITY,
743
+ refetchOnMount: false,
744
+ refetchOnReconnect: true,
745
+ refetchOnWindowFocus: false
746
+ });
747
+ return { userIpInfo, isLoadingGeoCheck };
748
+ }
749
+
750
+ // src/geo/useCheckoutBlocked.ts
751
+ function useCheckoutBlocked(params) {
752
+ const { userIpInfo, isLoadingGeoCheck } = useUserIpInfo();
753
+ const blockedCountries = useDynamicConfig("blockedcountries");
754
+ const isGeoblocked = useMemo3(() => {
755
+ if (isLoadingGeoCheck) {
756
+ return false;
757
+ }
758
+ if (!userIpInfo) {
759
+ return true;
760
+ }
761
+ return isCountryBlocked(blockedCountries, userIpInfo);
762
+ }, [blockedCountries, isLoadingGeoCheck, userIpInfo]);
763
+ const onCheckoutBlockedEvent = useEffectEvent(() => {
764
+ params.onCheckoutBlocked?.();
765
+ });
766
+ useEffect2(() => {
767
+ if (isGeoblocked) {
768
+ onCheckoutBlockedEvent();
769
+ }
770
+ }, [isGeoblocked]);
771
+ return { isGeoblocked, isLoadingGeoCheck };
772
+ }
773
+
774
+ // src/icons/assetLogos.ts
775
+ var ASSET_LOGO_SRCS = {
776
+ $MFER: "https://sdk-cdn.fun.xyz/images/mfer.png",
777
+ AARBUSDCN: "https://sdk-cdn.fun.xyz/images/aarbusdcn.png",
778
+ AAVE: "https://sdk-cdn.fun.xyz/images/aave.svg",
779
+ AERO: "https://sdk-cdn.fun.xyz/images/aero.svg",
780
+ APE: "https://sdk-cdn.fun.xyz/images/ape.svg",
781
+ APOLWMATIC: "https://sdk-cdn.fun.xyz/images/apolwmatic.png",
782
+ ARB: "https://sdk-cdn.fun.xyz/images/arb.svg",
783
+ BEHYPE: "https://sdk-cdn.fun.xyz/images/behype.svg",
784
+ BENTO: "https://sdk-cdn.fun.xyz/images/bento.png",
785
+ BLERF: "https://sdk-cdn.fun.xyz/images/blerf.png",
786
+ BRETT: "https://sdk-cdn.fun.xyz/images/brett.svg",
787
+ BSHIB: "https://sdk-cdn.fun.xyz/images/bshib.png",
788
+ BTC: "https://sdk-cdn.fun.xyz/images/btc.svg",
789
+ CBBTC: "https://sdk-cdn.fun.xyz/images/cbbtc.svg",
790
+ CBETH: "https://sdk-cdn.fun.xyz/images/cbeth.png",
791
+ CRO: "https://sdk-cdn.fun.xyz/images/cro.svg",
792
+ CRV: "https://sdk-cdn.fun.xyz/images/crv.svg",
793
+ DAI: "https://sdk-cdn.fun.xyz/images/dai.svg",
794
+ DEGEN: "https://sdk-cdn.fun.xyz/images/degen.svg",
795
+ ETH: "https://sdk-cdn.fun.xyz/images/eth.svg",
796
+ GMX: "https://sdk-cdn.fun.xyz/images/gmx.svg",
797
+ GRT: "https://sdk-cdn.fun.xyz/images/grt.svg",
798
+ HYPE: "https://sdk-cdn.fun.xyz/images/hype.svg",
799
+ IMX: "https://sdk-cdn.fun.xyz/images/imx.svg",
800
+ INJ: "https://sdk-cdn.fun.xyz/images/inj.svg",
801
+ LDO: "https://sdk-cdn.fun.xyz/images/ldo.svg",
802
+ LINK: "https://sdk-cdn.fun.xyz/images/link.png",
803
+ LUCK: "https://sdk-cdn.fun.xyz/images/luck.png",
804
+ MATIC: "https://sdk-cdn.fun.xyz/images/matic.svg",
805
+ MFER: "https://sdk-cdn.fun.xyz/images/mfer.png",
806
+ MKR: "https://sdk-cdn.fun.xyz/images/mkr.svg",
807
+ MNT: "https://sdk-cdn.fun.xyz/images/mnt.svg",
808
+ OP: "https://sdk-cdn.fun.xyz/images/optimism.svg",
809
+ PENDLE: "https://sdk-cdn.fun.xyz/images/pendle.svg",
810
+ POL: "https://sdk-cdn.fun.xyz/images/matic.svg",
811
+ PYUSD: "https://sdk-cdn.fun.xyz/images/pyusd.svg",
812
+ QNT: "https://sdk-cdn.fun.xyz/images/qnt.svg",
813
+ RNDR: "https://sdk-cdn.fun.xyz/images/rndr.svg",
814
+ ROOST: "https://sdk-cdn.fun.xyz/images/roost.png",
815
+ SAND: "https://sdk-cdn.fun.xyz/images/sand.svg",
816
+ SHIB: "https://sdk-cdn.fun.xyz/images/shib.svg",
817
+ SNX: "https://sdk-cdn.fun.xyz/images/snx.svg",
818
+ SOL: "https://sdk-cdn.fun.xyz/images/sol.svg",
819
+ SUSDS: "https://sdk-cdn.fun.xyz/images/susds.svg",
820
+ TYBG: "https://sdk-cdn.fun.xyz/images/tybg.png",
821
+ UNI: "https://sdk-cdn.fun.xyz/images/uni.png",
822
+ USDC: "https://sdk-cdn.fun.xyz/images/usdc.svg",
823
+ "USDC.E": "https://sdk-cdn.fun.xyz/images/usdc.svg",
824
+ USDBC: "https://sdk-cdn.fun.xyz/images/usdc.svg",
825
+ USDE: "https://sdk-cdn.fun.xyz/images/usde.svg",
826
+ WUSDE: "https://sdk-cdn.fun.xyz/images/usde.svg",
827
+ EUSDE: "https://sdk-cdn.fun.xyz/images/eusde.svg",
828
+ USDT: "https://sdk-cdn.fun.xyz/images/usdt.svg",
829
+ "USD\u20AE0": "https://sdk-cdn.fun.xyz/images/usdt0.svg",
830
+ USDT0: "https://sdk-cdn.fun.xyz/images/usdt0.svg",
831
+ USDS: "https://sdk-cdn.fun.xyz/images/usds.svg",
832
+ USDH: "https://sdk-cdn.fun.xyz/images/usdh.svg",
833
+ VRTX: "https://sdk-cdn.fun.xyz/images/vrtx.svg",
834
+ WBTC: "https://sdk-cdn.fun.xyz/images/wbtc.svg",
835
+ WEETH: "https://sdk-cdn.fun.xyz/images/weeth.png",
836
+ WETH: "https://sdk-cdn.fun.xyz/images/weth.svg",
837
+ WHYPE: "https://sdk-cdn.fun.xyz/images/whype.png",
838
+ WSTETH: "https://sdk-cdn.fun.xyz/images/wsteth.png",
839
+ TRUMP: "https://sdk-cdn.fun.xyz/images/trump.png",
840
+ BNB: "https://sdk-cdn.fun.xyz/images/bsc.svg",
841
+ WBNB: "https://sdk-cdn.fun.xyz/images/bsc.svg",
842
+ BTCB: "https://sdk-cdn.fun.xyz/images/btc.svg",
843
+ UBTC: "https://sdk-cdn.fun.xyz/images/btc.svg",
844
+ BUSD: "https://sdk-cdn.fun.xyz/images/busd.svg",
845
+ XAUT: "https://sdk-cdn.fun.xyz/images/xaut.png",
846
+ ADA: "https://sdk-cdn.fun.xyz/images/ada.svg",
847
+ XRP: "https://sdk-cdn.fun.xyz/images/xrp.svg",
848
+ UDOGE: "https://sdk-cdn.fun.xyz/images/doge.svg",
849
+ DOGE: "https://sdk-cdn.fun.xyz/images/doge.svg",
850
+ LTC: "https://sdk-cdn.fun.xyz/images/ltc.svg",
851
+ HNT: "https://sdk-cdn.fun.xyz/images/hnt.svg",
852
+ COMP: "https://sdk-cdn.fun.xyz/images/comp.svg",
853
+ PEPE: "https://sdk-cdn.fun.xyz/images/pepe.svg",
854
+ LSTHYPE: "https://sdk-cdn.fun.xyz/images/lsthype.svg",
855
+ HBUSDT: "https://sdk-cdn.fun.xyz/images/hbusdt.svg",
856
+ WVLP: "https://sdk-cdn.fun.xyz/images/wvlp.svg",
857
+ LIQUIDHYPE: "https://sdk-cdn.fun.xyz/images/liquidhype.svg",
858
+ VHYPE: "https://sdk-cdn.fun.xyz/images/vhype.png",
859
+ HBHYPE: "https://sdk-cdn.fun.xyz/images/hbhype.svg",
860
+ MON: "https://sdk-cdn.fun.xyz/images/monad.svg",
861
+ WMON: "https://sdk-cdn.fun.xyz/images/wmon.svg",
862
+ AUSD: "https://sdk-cdn.fun.xyz/images/ausd.svg",
863
+ SUSHI: "https://sdk-cdn.fun.xyz/images/sushi.svg",
864
+ SKY: "https://sdk-cdn.fun.xyz/images/sky.svg",
865
+ LIT: "https://sdk-cdn.fun.xyz/images/lit.svg",
866
+ AZTEC: "https://sdk-cdn.fun.xyz/images/aztec.svg",
867
+ U: "https://sdk-cdn.fun.xyz/images/u.png",
868
+ PUSD: "https://sdk-cdn.fun.xyz/images/pusd.svg"
869
+ };
870
+ var FALLBACK_ASSET_LOGO = "https://sdk-cdn.fun.xyz/images/dollar_circle.png";
871
+
872
+ // src/icons/CryptoBitcoinIcon.tsx
873
+ import { SvgXml as SvgXml2 } from "react-native-svg";
874
+ import { jsx as jsx4 } from "react/jsx-runtime";
875
+ var CIRCLE_BITCOIN_SVG = `<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12.9168 11.8737C12.9168 12.449 12.4505 12.9154 11.8752 12.9154H8.75016V10.832H11.8752C12.4505 10.832 12.9168 11.2984 12.9168 11.8737Z" fill="currentColor"/><path d="M11.4585 7.08203H8.75016V9.16536H11.4585C12.0338 9.16536 12.5002 8.69899 12.5002 8.1237C12.5002 7.5484 12.0338 7.08203 11.4585 7.08203Z" fill="currentColor"/><path fill-rule="evenodd" clip-rule="evenodd" d="M10.0002 0.832031C4.93755 0.832031 0.833496 4.93609 0.833496 9.9987C0.833496 15.0613 4.93755 19.1654 10.0002 19.1654C15.0628 19.1654 19.1668 15.0613 19.1668 9.9987C19.1668 4.93609 15.0628 0.832031 10.0002 0.832031ZM8.3335 4.16536C8.79373 4.16536 9.16683 4.53846 9.16683 4.9987V5.41536H10.0002V4.9987C10.0002 4.53846 10.3733 4.16536 10.8335 4.16536C11.2937 4.16536 11.6668 4.53846 11.6668 4.9987V5.42326C13.0653 5.52964 14.1668 6.69803 14.1668 8.1237C14.1668 8.74941 13.9546 9.32557 13.5983 9.78413C14.2 10.2809 14.5835 11.0325 14.5835 11.8737C14.5835 13.3695 13.3709 14.582 11.8752 14.582H11.6668V14.9987C11.6668 15.4589 11.2937 15.832 10.8335 15.832C10.3733 15.832 10.0002 15.4589 10.0002 14.9987V14.582H9.16683V14.9987C9.16683 15.4589 8.79373 15.832 8.3335 15.832C7.87326 15.832 7.50016 15.4589 7.50016 14.9987V14.582H6.66683C6.20659 14.582 5.8335 14.2089 5.8335 13.7487C5.8335 13.2885 6.20659 12.9154 6.66683 12.9154H7.0835V7.08203H6.66683C6.20659 7.08203 5.8335 6.70894 5.8335 6.2487C5.8335 5.78846 6.20659 5.41536 6.66683 5.41536H7.50016V4.9987C7.50016 4.53846 7.87326 4.16536 8.3335 4.16536Z" fill="currentColor"/></svg>`;
876
+ function CryptoBitcoinIcon({ size = 28 }) {
877
+ const theme = useTheme();
878
+ return /* @__PURE__ */ jsx4(
879
+ SvgXml2,
880
+ {
881
+ xml: CIRCLE_BITCOIN_SVG,
882
+ width: size,
883
+ height: size,
884
+ color: theme.colors.textPrimary
885
+ }
886
+ );
887
+ }
888
+
889
+ // src/icons/FunIcon.tsx
890
+ import { useEffect as useEffect3, useState as useState3 } from "react";
891
+ import { Image } from "react-native";
892
+ import { SvgXml as SvgXml3 } from "react-native-svg";
893
+ import { jsx as jsx5 } from "react/jsx-runtime";
894
+ var svgCache = /* @__PURE__ */ new Map();
895
+ function ensureViewBox(svg) {
896
+ if (/\bviewBox\s*=/.test(svg)) {
897
+ return svg;
898
+ }
899
+ const width = svg.match(/\bwidth="([\d.]+)"/)?.[1];
900
+ const height = svg.match(/\bheight="([\d.]+)"/)?.[1];
901
+ if (!width || !height) {
902
+ return svg;
903
+ }
904
+ return svg.replace(/<svg\b/, `<svg viewBox="0 0 ${width} ${height}"`);
905
+ }
906
+ function FunIcon({ uri, size = 32, fallbackUri }) {
907
+ const [currentUri, setCurrentUri] = useState3(uri);
908
+ const isSvg = currentUri.endsWith(".svg");
909
+ const [xml, setXml] = useState3(
910
+ () => svgCache.get(currentUri) ?? null
911
+ );
912
+ const [rasterLoaded, setRasterLoaded] = useState3(false);
913
+ useEffect3(() => {
914
+ setCurrentUri(uri);
915
+ setRasterLoaded(false);
916
+ setXml(svgCache.get(uri) ?? null);
917
+ }, [uri]);
918
+ const onFailure = () => {
919
+ if (fallbackUri && currentUri !== fallbackUri) {
920
+ setCurrentUri(fallbackUri);
921
+ setRasterLoaded(false);
922
+ setXml(svgCache.get(fallbackUri) ?? null);
923
+ }
924
+ };
925
+ useEffect3(() => {
926
+ if (!isSvg) {
927
+ return;
928
+ }
929
+ const cached = svgCache.get(currentUri);
930
+ if (cached != null) {
931
+ setXml(cached);
932
+ return;
933
+ }
934
+ let active = true;
935
+ fetch(currentUri).then((res) => {
936
+ if (!res.ok) {
937
+ throw new Error(`icon fetch ${res.status}`);
938
+ }
939
+ return res.text();
940
+ }).then((text) => {
941
+ if (!text.includes("<svg")) {
942
+ throw new Error("icon response is not an SVG");
943
+ }
944
+ const normalized = ensureViewBox(text);
945
+ svgCache.set(currentUri, normalized);
946
+ if (active) {
947
+ setXml(normalized);
948
+ }
949
+ }).catch(() => {
950
+ if (active) {
951
+ onFailure();
952
+ }
953
+ });
954
+ return () => {
955
+ active = false;
956
+ };
957
+ }, [currentUri, isSvg]);
958
+ const ready = isSvg ? xml != null : rasterLoaded;
959
+ const clip = { overflow: "hidden" };
960
+ return /* @__PURE__ */ jsx5(
961
+ Box,
962
+ {
963
+ width: size,
964
+ height: size,
965
+ borderRadius: "rounded",
966
+ backgroundColor: ready ? void 0 : "bgSecondary",
967
+ style: clip,
968
+ children: isSvg ? xml != null ? /* @__PURE__ */ jsx5(SvgXml3, { xml, width: size, height: size }) : null : /* @__PURE__ */ jsx5(
969
+ Image,
970
+ {
971
+ source: { uri: currentUri },
972
+ style: { width: size, height: size },
973
+ onLoad: () => setRasterLoaded(true),
974
+ onError: onFailure
975
+ }
976
+ )
977
+ }
978
+ );
979
+ }
980
+
981
+ // src/icons/funIconUri.ts
982
+ var CDN_BASE = "https://sdk-cdn.fun.xyz/images";
983
+ var chainIconUri = (chainKey) => `${CDN_BASE}/${chainKey}.svg`;
984
+ var tokenLogoUri = (symbol) => ASSET_LOGO_SRCS[symbol.toUpperCase()] ?? `${CDN_BASE}/${symbol.toLowerCase()}.svg`;
985
+
986
+ // src/icons/QrChainCluster.tsx
987
+ import { jsx as jsx6 } from "react/jsx-runtime";
988
+ function toIconUri(icon) {
989
+ return icon.startsWith("http") ? icon : chainIconUri(icon);
990
+ }
991
+ var CARD_SIZE = 51;
992
+ var SINGLE_SIZE = 40;
993
+ var GRID_SIZE = 20;
994
+ var GRID_GAP = 3;
995
+ function QrChainCluster({ iconKeys, max = 4 }) {
996
+ const keys = iconKeys.slice(0, max);
997
+ const first = keys[0];
998
+ if (first == null) {
999
+ return null;
1000
+ }
1001
+ if (keys.length === 1) {
1002
+ return /* @__PURE__ */ jsx6(Box, { alignItems: "center", justifyContent: "center", style: card, children: /* @__PURE__ */ jsx6(Box, { style: ring(SINGLE_SIZE), children: /* @__PURE__ */ jsx6(
1003
+ FunIcon,
1004
+ {
1005
+ uri: toIconUri(first),
1006
+ size: SINGLE_SIZE,
1007
+ fallbackUri: FALLBACK_ASSET_LOGO
1008
+ }
1009
+ ) }) });
1010
+ }
1011
+ return /* @__PURE__ */ jsx6(Box, { alignItems: "center", justifyContent: "center", style: card, children: /* @__PURE__ */ jsx6(Box, { flexDirection: "row", flexWrap: "wrap", style: grid, children: keys.map((key) => /* @__PURE__ */ jsx6(Box, { style: ring(GRID_SIZE), children: /* @__PURE__ */ jsx6(
1012
+ FunIcon,
1013
+ {
1014
+ uri: toIconUri(key),
1015
+ size: GRID_SIZE,
1016
+ fallbackUri: FALLBACK_ASSET_LOGO
1017
+ }
1018
+ ) }, key)) }) });
1019
+ }
1020
+ var grid = {
1021
+ width: GRID_SIZE * 2 + GRID_GAP,
1022
+ gap: GRID_GAP
1023
+ };
1024
+ var card = {
1025
+ width: CARD_SIZE,
1026
+ height: CARD_SIZE,
1027
+ borderRadius: 16,
1028
+ backgroundColor: "#FFFFFF"
1029
+ };
1030
+ var ring = (iconSize) => ({
1031
+ width: iconSize,
1032
+ height: iconSize,
1033
+ borderRadius: 999,
1034
+ backgroundColor: "#FFFFFF",
1035
+ overflow: "hidden"
1036
+ });
1037
+
1038
+ // src/icons/SourceTokenCluster.tsx
1039
+ import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
1040
+ function toIconUri2(icon) {
1041
+ return icon.startsWith("http") ? icon : chainIconUri(icon);
1042
+ }
1043
+ function SourceTokenCluster({
1044
+ icons,
1045
+ maxVisible = 4,
1046
+ size = 16,
1047
+ gap = 2,
1048
+ overflowMode = "count"
1049
+ }) {
1050
+ const theme = useTheme();
1051
+ const visible = icons.slice(0, maxVisible);
1052
+ const overflow = icons.length - visible.length;
1053
+ return /* @__PURE__ */ jsxs2(Box, { flexDirection: "row", alignItems: "center", style: { gap }, children: [
1054
+ visible.map((icon) => /* @__PURE__ */ jsx7(Box, { backgroundColor: "bgSecondary", style: iconRing(size), children: /* @__PURE__ */ jsx7(
1055
+ FunIcon,
1056
+ {
1057
+ uri: toIconUri2(icon),
1058
+ size,
1059
+ fallbackUri: FALLBACK_ASSET_LOGO
1060
+ }
1061
+ ) }, icon)),
1062
+ overflow > 0 ? (
1063
+ // Both chips are a fixed `size`×`size` circle (Figma). The "+" glyph sits
1064
+ // on `bgSecondary` (Add money `crypto2`); the "+N" count on `pillPressed`
1065
+ // (Transfer `tap-target`).
1066
+ /* @__PURE__ */ jsx7(
1067
+ Box,
1068
+ {
1069
+ backgroundColor: overflowMode === "plus" ? "bgSecondary" : "pillPressed",
1070
+ alignItems: "center",
1071
+ justifyContent: "center",
1072
+ style: overflowCircle(size),
1073
+ children: overflowMode === "plus" ? (
1074
+ // The geometric "+" glyph centers cleanly; the text "+" did not.
1075
+ /* @__PURE__ */ jsx7(FigmaPlusIcon, { size, color: theme.colors.textSecondary })
1076
+ ) : /* @__PURE__ */ jsx7(
1077
+ Text,
1078
+ {
1079
+ variant: "bodyMedium",
1080
+ color: "textSecondary",
1081
+ style: overflowText(size),
1082
+ children: `+${overflow}`
1083
+ }
1084
+ )
1085
+ }
1086
+ )
1087
+ ) : null
1088
+ ] });
1089
+ }
1090
+ var iconRing = (size) => ({
1091
+ width: size,
1092
+ height: size,
1093
+ borderRadius: 999,
1094
+ borderWidth: 1,
1095
+ borderColor: "rgba(0,0,0,0.1)",
1096
+ overflow: "hidden",
1097
+ // Center the same-size FunIcon so the border-box hairline doesn't push it 1px
1098
+ // off and clip the bottom-right; it fills the circle with the border on edge.
1099
+ alignItems: "center",
1100
+ justifyContent: "center"
1101
+ });
1102
+ var overflowCircle = (size) => ({
1103
+ width: size,
1104
+ height: size,
1105
+ borderRadius: 999
1106
+ });
1107
+ var overflowText = (size) => ({
1108
+ fontSize: Math.round(size * 0.6),
1109
+ letterSpacing: -0.48
1110
+ });
1111
+
1112
+ // src/icons/TokenChainIcon.tsx
1113
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
1114
+ function TokenChainIcon({
1115
+ symbol,
1116
+ iconSrc,
1117
+ chainKey,
1118
+ size = 24
1119
+ }) {
1120
+ const badge = Math.round(size * 0.5);
1121
+ return /* @__PURE__ */ jsxs3(Box, { width: size, height: size, children: [
1122
+ /* @__PURE__ */ jsx8(
1123
+ FunIcon,
1124
+ {
1125
+ uri: iconSrc ?? tokenLogoUri(symbol),
1126
+ size,
1127
+ fallbackUri: FALLBACK_ASSET_LOGO
1128
+ }
1129
+ ),
1130
+ chainKey ? /* @__PURE__ */ jsx8(
1131
+ Box,
1132
+ {
1133
+ backgroundColor: "bgModal",
1134
+ borderRadius: "rounded",
1135
+ alignItems: "center",
1136
+ justifyContent: "center",
1137
+ style: badgeRing(badge),
1138
+ children: /* @__PURE__ */ jsx8(
1139
+ FunIcon,
1140
+ {
1141
+ uri: chainIconUri(chainKey),
1142
+ size: badge,
1143
+ fallbackUri: FALLBACK_ASSET_LOGO
1144
+ }
1145
+ )
1146
+ }
1147
+ ) : null
1148
+ ] });
1149
+ }
1150
+ var badgeRing = (badge) => ({
1151
+ position: "absolute",
1152
+ right: -1,
1153
+ bottom: -1,
1154
+ width: badge + 2,
1155
+ height: badge + 2
1156
+ });
1157
+
1158
+ // src/screens/AddMoneyScreen.tsx
1159
+ import { useEffect as useEffect4, useRef, useState as useState4 } from "react";
1160
+ import { Animated as Animated2, Pressable, ScrollView } from "react-native";
1161
+ import Reanimated, {
1162
+ Easing as Easing2,
1163
+ Keyframe as Keyframe2,
1164
+ useAnimatedStyle,
1165
+ useSharedValue,
1166
+ withTiming
1167
+ } from "react-native-reanimated";
1168
+ import { Fragment, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
1169
+ var DROPDOWN_OPEN_DURATION = 250;
1170
+ var DROPDOWN_CLOSE_DURATION = 150;
1171
+ var DROPDOWN_EASING = Easing2.bezier(0.22, 1, 0.36, 1);
1172
+ var DROPDOWN_PRE_SCALE = 0.97;
1173
+ var DROPDOWN_TRANSLATE_Y = -4;
1174
+ var AnimatedPressable = Reanimated.createAnimatedComponent(Pressable);
1175
+ var menuEnter = new Keyframe2({
1176
+ 0: {
1177
+ opacity: 0,
1178
+ transform: [
1179
+ { translateY: DROPDOWN_TRANSLATE_Y },
1180
+ { scale: DROPDOWN_PRE_SCALE }
1181
+ ]
1182
+ },
1183
+ 100: {
1184
+ opacity: 1,
1185
+ transform: [{ translateY: 0 }, { scale: 1 }],
1186
+ easing: DROPDOWN_EASING
1187
+ }
1188
+ }).duration(DROPDOWN_OPEN_DURATION);
1189
+ var menuExit = new Keyframe2({
1190
+ 0: {
1191
+ opacity: 1,
1192
+ transform: [{ translateY: 0 }, { scale: 1 }]
1193
+ },
1194
+ 100: {
1195
+ opacity: 0,
1196
+ transform: [
1197
+ { translateY: DROPDOWN_TRANSLATE_Y },
1198
+ { scale: DROPDOWN_PRE_SCALE }
1199
+ ],
1200
+ easing: DROPDOWN_EASING
1201
+ }
1202
+ }).duration(DROPDOWN_CLOSE_DURATION);
1203
+ var scrimEnter = new Keyframe2({
1204
+ 0: { opacity: 0 },
1205
+ 100: { opacity: 1, easing: DROPDOWN_EASING }
1206
+ }).duration(DROPDOWN_OPEN_DURATION);
1207
+ var scrimExit = new Keyframe2({
1208
+ 0: { opacity: 1 },
1209
+ 100: { opacity: 0, easing: DROPDOWN_EASING }
1210
+ }).duration(DROPDOWN_CLOSE_DURATION);
1211
+ var DEFAULT_ERROR_TITLE = "Something went wrong";
1212
+ var DEFAULT_ERROR_MESSAGE = "There was a problem loading data.\nCheck your internet and try again.";
1213
+ var DEFAULT_RETRY_LABEL = "Try again";
1214
+ function AddMoneyScreen({
1215
+ methods,
1216
+ onSelectMethod,
1217
+ title = "Add money",
1218
+ loading = false,
1219
+ skeletonCount,
1220
+ error = false,
1221
+ onRetry,
1222
+ errorTitle = DEFAULT_ERROR_TITLE,
1223
+ errorMessage = DEFAULT_ERROR_MESSAGE,
1224
+ retryLabel = DEFAULT_RETRY_LABEL,
1225
+ receiveTokens,
1226
+ selectedReceiveTokenId,
1227
+ onSelectReceiveToken,
1228
+ depositToLabel = "Deposit to",
1229
+ payWithLabel = "Pay with",
1230
+ initialDropdownOpen = false
1231
+ }) {
1232
+ const selected = receiveTokens?.find((t) => t.id === selectedReceiveTokenId);
1233
+ const showDropdown = receiveTokens && receiveTokens.length > 0 && selected;
1234
+ const [dropdownOpen, setDropdownOpen] = useState4(initialDropdownOpen);
1235
+ const scrimVisible = !error && showDropdown && dropdownOpen;
1236
+ return /* @__PURE__ */ jsxs4(
1237
+ Box,
1238
+ {
1239
+ backgroundColor: "bgModal",
1240
+ borderTopLeftRadius: "modal",
1241
+ borderTopRightRadius: "modal",
1242
+ children: [
1243
+ /* @__PURE__ */ jsxs4(Box, { alignItems: "center", style: topBar, children: [
1244
+ /* @__PURE__ */ jsx9(Box, { backgroundColor: "borderFocused", style: grabber }),
1245
+ /* @__PURE__ */ jsx9(Text, { variant: "bodyMedium", color: "textPrimary", children: title })
1246
+ ] }),
1247
+ error ? /* @__PURE__ */ jsx9(
1248
+ AddMoneyError,
1249
+ {
1250
+ title: errorTitle,
1251
+ message: errorMessage,
1252
+ retryLabel,
1253
+ onRetry
1254
+ }
1255
+ ) : loading ? /* @__PURE__ */ jsx9(
1256
+ AddMoneyLoading,
1257
+ {
1258
+ count: skeletonCount,
1259
+ showDropdown: Boolean(showDropdown),
1260
+ depositToLabel,
1261
+ payWithLabel
1262
+ }
1263
+ ) : /* @__PURE__ */ jsxs4(Fragment, { children: [
1264
+ showDropdown ? /* @__PURE__ */ jsxs4(Box, { style: depositSection, children: [
1265
+ /* @__PURE__ */ jsx9(Box, { style: sectionLabel, children: /* @__PURE__ */ jsx9(Text, { variant: "detail", weight: "medium", color: "textSecondary", children: depositToLabel }) }),
1266
+ /* @__PURE__ */ jsx9(
1267
+ ReceiveTokenDropdown,
1268
+ {
1269
+ tokens: receiveTokens,
1270
+ selected,
1271
+ open: dropdownOpen,
1272
+ onToggle: () => setDropdownOpen((o) => !o),
1273
+ onSelect: (id) => {
1274
+ onSelectReceiveToken?.(id);
1275
+ setDropdownOpen(false);
1276
+ }
1277
+ }
1278
+ )
1279
+ ] }) : null,
1280
+ showDropdown ? (
1281
+ // "Pay with" section: a labeled, bordered card wrapping the method
1282
+ // rows with hairline dividers between them (Figma node 11202:8282).
1283
+ /* @__PURE__ */ jsxs4(Box, { style: payWithSection, children: [
1284
+ /* @__PURE__ */ jsx9(Box, { style: sectionLabel, children: /* @__PURE__ */ jsx9(Text, { variant: "detail", weight: "medium", color: "textSecondary", children: payWithLabel }) }),
1285
+ /* @__PURE__ */ jsx9(
1286
+ Box,
1287
+ {
1288
+ backgroundColor: "bgModal",
1289
+ borderColor: "borderDefault",
1290
+ borderWidth: 1,
1291
+ borderRadius: "element",
1292
+ style: methodsCard,
1293
+ children: methods.map((method, i) => /* @__PURE__ */ jsxs4(Box, { children: [
1294
+ i > 0 ? /* @__PURE__ */ jsx9(MethodDivider, {}) : null,
1295
+ /* @__PURE__ */ jsx9(
1296
+ Pressable,
1297
+ {
1298
+ onPress: () => onSelectMethod(method.id),
1299
+ accessibilityRole: "button",
1300
+ accessibilityLabel: method.title,
1301
+ children: /* @__PURE__ */ jsx9(PaymentMethodRow, { method })
1302
+ }
1303
+ )
1304
+ ] }, method.id))
1305
+ }
1306
+ )
1307
+ ] })
1308
+ ) : (
1309
+ // Methods-only: bare rows with full-width hairline dividers, no
1310
+ // outer border (Figma node 11202:8632).
1311
+ /* @__PURE__ */ jsx9(
1312
+ ScrollView,
1313
+ {
1314
+ contentContainerStyle: listContent,
1315
+ showsVerticalScrollIndicator: false,
1316
+ children: methods.map((method, i) => /* @__PURE__ */ jsxs4(Box, { children: [
1317
+ i > 0 ? /* @__PURE__ */ jsx9(MethodDivider, {}) : null,
1318
+ /* @__PURE__ */ jsx9(
1319
+ Pressable,
1320
+ {
1321
+ onPress: () => onSelectMethod(method.id),
1322
+ accessibilityRole: "button",
1323
+ accessibilityLabel: method.title,
1324
+ children: /* @__PURE__ */ jsx9(PaymentMethodRow, { method })
1325
+ }
1326
+ )
1327
+ ] }, method.id))
1328
+ }
1329
+ )
1330
+ )
1331
+ ] }),
1332
+ scrimVisible ? /* @__PURE__ */ jsx9(
1333
+ AnimatedPressable,
1334
+ {
1335
+ entering: scrimEnter,
1336
+ exiting: scrimExit,
1337
+ style: scrim,
1338
+ onPress: () => setDropdownOpen(false),
1339
+ accessibilityRole: "button",
1340
+ accessibilityLabel: "Close"
1341
+ }
1342
+ ) : null
1343
+ ]
1344
+ }
1345
+ );
1346
+ }
1347
+ function AddMoneyError({
1348
+ title,
1349
+ message,
1350
+ retryLabel,
1351
+ onRetry
1352
+ }) {
1353
+ return /* @__PURE__ */ jsxs4(Box, { alignItems: "center", justifyContent: "center", style: errorContainer, children: [
1354
+ /* @__PURE__ */ jsxs4(Box, { alignItems: "center", style: errorText, children: [
1355
+ /* @__PURE__ */ jsx9(Text, { variant: "bodyMedium", color: "textPrimary", children: title }),
1356
+ /* @__PURE__ */ jsx9(Text, { variant: "detail", color: "textSecondary", style: errorMessageText, children: message })
1357
+ ] }),
1358
+ /* @__PURE__ */ jsx9(
1359
+ Pressable,
1360
+ {
1361
+ onPress: onRetry,
1362
+ accessibilityRole: "button",
1363
+ accessibilityLabel: retryLabel,
1364
+ children: /* @__PURE__ */ jsx9(
1365
+ Box,
1366
+ {
1367
+ backgroundColor: "btnPrimary",
1368
+ borderRadius: "rounded",
1369
+ alignItems: "center",
1370
+ justifyContent: "center",
1371
+ style: retryButton,
1372
+ children: /* @__PURE__ */ jsx9(Text, { variant: "bodyMedium", color: "onBtnPrimary", children: retryLabel })
1373
+ }
1374
+ )
1375
+ }
1376
+ )
1377
+ ] });
1378
+ }
1379
+ function PaymentMethodRow({ method }) {
1380
+ return /* @__PURE__ */ jsxs4(
1381
+ Box,
1382
+ {
1383
+ flexDirection: "row",
1384
+ alignItems: "center",
1385
+ gap: "elementsHorizontal",
1386
+ style: row,
1387
+ children: [
1388
+ /* @__PURE__ */ jsx9(
1389
+ Box,
1390
+ {
1391
+ width: 48,
1392
+ height: 48,
1393
+ borderRadius: "rounded",
1394
+ backgroundColor: "bgSecondary",
1395
+ alignItems: "center",
1396
+ justifyContent: "center",
1397
+ children: method.icon
1398
+ }
1399
+ ),
1400
+ /* @__PURE__ */ jsxs4(Box, { flex: 1, style: details, children: [
1401
+ /* @__PURE__ */ jsx9(Text, { variant: "bodyMedium", color: "textPrimary", children: method.title }),
1402
+ method.subtitle ? /* @__PURE__ */ jsx9(Text, { variant: "detail", color: "textSecondary", children: method.subtitle }) : null
1403
+ ] }),
1404
+ method.trailing
1405
+ ]
1406
+ }
1407
+ );
1408
+ }
1409
+ function MethodDivider() {
1410
+ return /* @__PURE__ */ jsx9(Box, { backgroundColor: "borderDefault", style: divider });
1411
+ }
1412
+ function ReceiveTokenDropdown({
1413
+ tokens,
1414
+ selected,
1415
+ open,
1416
+ onToggle,
1417
+ onSelect
1418
+ }) {
1419
+ const selectable = tokens.length > 1;
1420
+ return /* @__PURE__ */ jsxs4(Box, { style: dropdownAnchor, children: [
1421
+ /* @__PURE__ */ jsx9(
1422
+ Pressable,
1423
+ {
1424
+ onPress: selectable ? onToggle : void 0,
1425
+ accessibilityRole: "button",
1426
+ accessibilityLabel: selected.label,
1427
+ children: /* @__PURE__ */ jsxs4(
1428
+ Box,
1429
+ {
1430
+ flexDirection: "row",
1431
+ alignItems: "center",
1432
+ justifyContent: "space-between",
1433
+ backgroundColor: "bgModal",
1434
+ borderColor: "borderDefault",
1435
+ borderWidth: 1,
1436
+ borderRadius: "element",
1437
+ style: dropdownTrigger,
1438
+ children: [
1439
+ /* @__PURE__ */ jsxs4(Box, { flexDirection: "row", alignItems: "center", style: triggerLeft, children: [
1440
+ selected.icon ?? /* @__PURE__ */ jsx9(ReceiveTokenIconFallback, {}),
1441
+ /* @__PURE__ */ jsx9(
1442
+ Text,
1443
+ {
1444
+ variant: "bodyMedium",
1445
+ color: "textPrimary",
1446
+ numberOfLines: 1,
1447
+ style: triggerLabel,
1448
+ children: selected.label
1449
+ }
1450
+ )
1451
+ ] }),
1452
+ selectable ? /* @__PURE__ */ jsx9(AnimatedChevron, { open }) : null
1453
+ ]
1454
+ }
1455
+ )
1456
+ }
1457
+ ),
1458
+ open && selectable ? /* @__PURE__ */ jsx9(
1459
+ Reanimated.View,
1460
+ {
1461
+ entering: menuEnter,
1462
+ exiting: menuExit,
1463
+ style: dropdownMenuOverlay,
1464
+ children: /* @__PURE__ */ jsx9(
1465
+ Box,
1466
+ {
1467
+ backgroundColor: "bgModal",
1468
+ borderRadius: "element",
1469
+ style: dropdownMenu,
1470
+ children: tokens.map((token) => /* @__PURE__ */ jsx9(
1471
+ Pressable,
1472
+ {
1473
+ onPress: () => onSelect(token.id),
1474
+ accessibilityRole: "menuitem",
1475
+ accessibilityLabel: token.label,
1476
+ children: /* @__PURE__ */ jsxs4(
1477
+ Box,
1478
+ {
1479
+ flexDirection: "row",
1480
+ alignItems: "center",
1481
+ justifyContent: "space-between",
1482
+ style: dropdownItem,
1483
+ children: [
1484
+ /* @__PURE__ */ jsxs4(
1485
+ Box,
1486
+ {
1487
+ flexDirection: "row",
1488
+ alignItems: "center",
1489
+ style: triggerLeft,
1490
+ children: [
1491
+ token.icon ?? /* @__PURE__ */ jsx9(ReceiveTokenIconFallback, {}),
1492
+ /* @__PURE__ */ jsx9(Text, { variant: "bodyMedium", color: "textPrimary", children: token.label })
1493
+ ]
1494
+ }
1495
+ ),
1496
+ token.id === selected.id ? /* @__PURE__ */ jsx9(CheckIcon, {}) : null
1497
+ ]
1498
+ }
1499
+ )
1500
+ },
1501
+ token.id
1502
+ ))
1503
+ }
1504
+ )
1505
+ }
1506
+ ) : null
1507
+ ] });
1508
+ }
1509
+ function ReceiveTokenIconFallback() {
1510
+ return /* @__PURE__ */ jsx9(
1511
+ Box,
1512
+ {
1513
+ width: 24,
1514
+ height: 24,
1515
+ borderRadius: "rounded",
1516
+ backgroundColor: "pillPressed"
1517
+ }
1518
+ );
1519
+ }
1520
+ function ChevronDownIcon() {
1521
+ return /* @__PURE__ */ jsx9(FigmaChevronDownIcon, { size: 16 });
1522
+ }
1523
+ function AnimatedChevron({ open }) {
1524
+ const rotation = useSharedValue(open ? 1 : 0);
1525
+ useEffect4(() => {
1526
+ rotation.value = withTiming(open ? 1 : 0, {
1527
+ duration: open ? DROPDOWN_OPEN_DURATION : DROPDOWN_CLOSE_DURATION,
1528
+ easing: DROPDOWN_EASING
1529
+ });
1530
+ }, [open, rotation]);
1531
+ const style = useAnimatedStyle(() => ({
1532
+ transform: [{ rotate: `${rotation.value * 180}deg` }]
1533
+ }));
1534
+ return /* @__PURE__ */ jsx9(Reanimated.View, { style, children: /* @__PURE__ */ jsx9(FigmaChevronDownIcon, { size: 16 }) });
1535
+ }
1536
+ function CheckIcon() {
1537
+ return /* @__PURE__ */ jsx9(FigmaCheckIcon, { size: 16 });
1538
+ }
1539
+ function AddMoneyLoading({
1540
+ count,
1541
+ showDropdown,
1542
+ depositToLabel,
1543
+ payWithLabel
1544
+ }) {
1545
+ const opacity = usePulse();
1546
+ const rowCount = count ?? (showDropdown ? 5 : 6);
1547
+ return /* @__PURE__ */ jsxs4(Fragment, { children: [
1548
+ showDropdown ? /* @__PURE__ */ jsxs4(Box, { style: depositSection, children: [
1549
+ /* @__PURE__ */ jsx9(Box, { style: sectionLabel, children: /* @__PURE__ */ jsx9(Text, { variant: "detail", color: "textSecondary", children: depositToLabel }) }),
1550
+ /* @__PURE__ */ jsxs4(
1551
+ Box,
1552
+ {
1553
+ flexDirection: "row",
1554
+ alignItems: "center",
1555
+ justifyContent: "space-between",
1556
+ backgroundColor: "bgModal",
1557
+ borderColor: "borderDefault",
1558
+ borderWidth: 1,
1559
+ borderRadius: "element",
1560
+ style: dropdownTrigger,
1561
+ children: [
1562
+ /* @__PURE__ */ jsxs4(Animated2.View, { style: [loadingSelectorLeft, { opacity }], children: [
1563
+ /* @__PURE__ */ jsx9(
1564
+ Box,
1565
+ {
1566
+ width: 20,
1567
+ height: 20,
1568
+ borderRadius: "rounded",
1569
+ backgroundColor: "pillPressed"
1570
+ }
1571
+ ),
1572
+ /* @__PURE__ */ jsx9(Box, { backgroundColor: "pillPressed", style: skeletonTitleBar })
1573
+ ] }),
1574
+ /* @__PURE__ */ jsx9(ChevronDownIcon, {})
1575
+ ]
1576
+ }
1577
+ )
1578
+ ] }) : null,
1579
+ showDropdown ? /* @__PURE__ */ jsxs4(Box, { style: payWithSection, children: [
1580
+ /* @__PURE__ */ jsx9(Box, { style: sectionLabel, children: /* @__PURE__ */ jsx9(Text, { variant: "detail", color: "textSecondary", children: payWithLabel }) }),
1581
+ /* @__PURE__ */ jsx9(
1582
+ Box,
1583
+ {
1584
+ backgroundColor: "bgModal",
1585
+ borderColor: "borderDefault",
1586
+ borderWidth: 1,
1587
+ borderRadius: "element",
1588
+ style: methodsCard,
1589
+ children: /* @__PURE__ */ jsx9(
1590
+ Animated2.View,
1591
+ {
1592
+ style: { opacity },
1593
+ accessibilityLabel: "Loading payment methods",
1594
+ children: Array.from({ length: rowCount }, (_, i) => /* @__PURE__ */ jsx9(PaymentMethodRowSkeleton, {}, i))
1595
+ }
1596
+ )
1597
+ }
1598
+ )
1599
+ ] }) : /* @__PURE__ */ jsx9(Box, { style: skeletonListContent, children: /* @__PURE__ */ jsx9(
1600
+ Animated2.View,
1601
+ {
1602
+ style: { opacity },
1603
+ accessibilityLabel: "Loading payment methods",
1604
+ children: Array.from({ length: rowCount }, (_, i) => /* @__PURE__ */ jsx9(PaymentMethodRowSkeleton, {}, i))
1605
+ }
1606
+ ) })
1607
+ ] });
1608
+ }
1609
+ function PaymentMethodRowSkeleton() {
1610
+ return /* @__PURE__ */ jsxs4(
1611
+ Box,
1612
+ {
1613
+ flexDirection: "row",
1614
+ alignItems: "center",
1615
+ gap: "elementsHorizontal",
1616
+ style: skeletonRow,
1617
+ children: [
1618
+ /* @__PURE__ */ jsx9(
1619
+ Box,
1620
+ {
1621
+ width: 48,
1622
+ height: 48,
1623
+ borderRadius: "rounded",
1624
+ backgroundColor: "pillPressed"
1625
+ }
1626
+ ),
1627
+ /* @__PURE__ */ jsxs4(Box, { flex: 1, style: skeletonDetails, children: [
1628
+ /* @__PURE__ */ jsx9(Box, { backgroundColor: "pillPressed", style: skeletonTitleBar }),
1629
+ /* @__PURE__ */ jsx9(Box, { backgroundColor: "pillPressed", style: skeletonSubtitleBar })
1630
+ ] })
1631
+ ]
1632
+ }
1633
+ );
1634
+ }
1635
+ function usePulse() {
1636
+ const opacity = useRef(new Animated2.Value(1)).current;
1637
+ useEffect4(() => {
1638
+ const loop = Animated2.loop(
1639
+ Animated2.sequence([
1640
+ Animated2.timing(opacity, {
1641
+ toValue: 0.5,
1642
+ duration: 700,
1643
+ useNativeDriver: true
1644
+ }),
1645
+ Animated2.timing(opacity, {
1646
+ toValue: 1,
1647
+ duration: 700,
1648
+ useNativeDriver: true
1649
+ })
1650
+ ])
1651
+ );
1652
+ loop.start();
1653
+ return () => loop.stop();
1654
+ }, [opacity]);
1655
+ return opacity;
1656
+ }
1657
+ var topBar = { height: 64, paddingTop: 25, paddingBottom: 12 };
1658
+ var grabber = {
1659
+ position: "absolute",
1660
+ top: 8,
1661
+ width: 36,
1662
+ height: 5,
1663
+ borderRadius: 999
1664
+ };
1665
+ var listContent = {
1666
+ paddingHorizontal: 16,
1667
+ paddingBottom: 16
1668
+ };
1669
+ var row = { padding: 12 };
1670
+ var details = { gap: 2 };
1671
+ var depositSection = {
1672
+ paddingHorizontal: 16,
1673
+ zIndex: 2
1674
+ };
1675
+ var payWithSection = {
1676
+ paddingHorizontal: 16,
1677
+ paddingTop: 12,
1678
+ paddingBottom: 16
1679
+ };
1680
+ var sectionLabel = { paddingHorizontal: 12, paddingBottom: 6 };
1681
+ var methodsCard = { paddingVertical: 2, overflow: "hidden" };
1682
+ var divider = { height: 1 };
1683
+ var dropdownAnchor = { position: "relative" };
1684
+ var dropdownTrigger = { height: 48, paddingHorizontal: 12 };
1685
+ var triggerLeft = { gap: 6, flex: 1 };
1686
+ var triggerLabel = { flex: 1 };
1687
+ var dropdownMenuOverlay = {
1688
+ position: "absolute",
1689
+ top: "100%",
1690
+ left: 0,
1691
+ right: 0,
1692
+ marginTop: 4,
1693
+ zIndex: 30
1694
+ };
1695
+ var dropdownMenu = {
1696
+ shadowColor: "#000",
1697
+ shadowOpacity: 0.12,
1698
+ shadowOffset: { width: 0, height: 8 },
1699
+ shadowRadius: 16,
1700
+ elevation: 8
1701
+ };
1702
+ var dropdownItem = { height: 48, paddingHorizontal: 12 };
1703
+ var scrim = {
1704
+ position: "absolute",
1705
+ top: 0,
1706
+ left: 0,
1707
+ right: 0,
1708
+ bottom: 0,
1709
+ backgroundColor: "rgba(0,0,0,0.2)",
1710
+ zIndex: 1
1711
+ };
1712
+ var errorContainer = {
1713
+ height: 468,
1714
+ gap: 24,
1715
+ paddingHorizontal: 16
1716
+ };
1717
+ var errorText = { gap: 8 };
1718
+ var errorMessageText = { textAlign: "center" };
1719
+ var retryButton = { height: 48, paddingHorizontal: 20 };
1720
+ var skeletonListContent = {
1721
+ paddingHorizontal: 16,
1722
+ paddingBottom: 16
1723
+ };
1724
+ var skeletonRow = { padding: 12 };
1725
+ var loadingSelectorLeft = {
1726
+ flexDirection: "row",
1727
+ alignItems: "center",
1728
+ gap: 6,
1729
+ flex: 1
1730
+ };
1731
+ var skeletonDetails = { gap: 4 };
1732
+ var skeletonTitleBar = { width: 157, height: 16, borderRadius: 4 };
1733
+ var skeletonSubtitleBar = {
1734
+ width: 83,
1735
+ height: 14,
1736
+ borderRadius: 4
1737
+ };
1738
+
1739
+ // src/screens/AvailableChainsScreen.tsx
1740
+ import {
1741
+ Pressable as Pressable2,
1742
+ ScrollView as ScrollView2,
1743
+ useWindowDimensions
1744
+ } from "react-native";
1745
+ import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
1746
+ function AvailableChainsScreen({
1747
+ networkLabel,
1748
+ chains,
1749
+ title = `Available ${networkLabel}`,
1750
+ loading = false,
1751
+ skeletonCount = 8,
1752
+ onClose
1753
+ }) {
1754
+ const { height } = useWindowDimensions();
1755
+ return /* @__PURE__ */ jsxs5(
1756
+ Box,
1757
+ {
1758
+ backgroundColor: "bgModal",
1759
+ borderTopLeftRadius: "modal",
1760
+ borderTopRightRadius: "modal",
1761
+ style: sheet,
1762
+ children: [
1763
+ /* @__PURE__ */ jsxs5(Box, { flexDirection: "row", alignItems: "center", style: topBar2, children: [
1764
+ /* @__PURE__ */ jsx10(
1765
+ Pressable2,
1766
+ {
1767
+ onPress: onClose,
1768
+ hitSlop: 12,
1769
+ accessibilityRole: "button",
1770
+ accessibilityLabel: "Close",
1771
+ children: /* @__PURE__ */ jsx10(Box, { alignItems: "center", justifyContent: "center", style: iconButton, children: /* @__PURE__ */ jsx10(FigmaCloseIcon, {}) })
1772
+ }
1773
+ ),
1774
+ /* @__PURE__ */ jsx10(Box, { flex: 1, alignItems: "center", children: /* @__PURE__ */ jsx10(Text, { variant: "bodyMedium", color: "textPrimary", children: title }) }),
1775
+ /* @__PURE__ */ jsx10(Box, { style: topBarSpacer })
1776
+ ] }),
1777
+ /* @__PURE__ */ jsx10(
1778
+ ScrollView2,
1779
+ {
1780
+ style: [list, { maxHeight: height * 0.72 }],
1781
+ showsVerticalScrollIndicator: false,
1782
+ contentContainerStyle: content,
1783
+ children: loading ? Array.from({ length: skeletonCount }, (_, index) => /* @__PURE__ */ jsx10(AvailableChainSkeleton, {}, index)) : chains.map((chain) => /* @__PURE__ */ jsxs5(
1784
+ Box,
1785
+ {
1786
+ flexDirection: "row",
1787
+ alignItems: "center",
1788
+ style: row2,
1789
+ children: [
1790
+ /* @__PURE__ */ jsx10(Box, { style: iconRing2, children: /* @__PURE__ */ jsx10(
1791
+ FunIcon,
1792
+ {
1793
+ uri: chain.iconUri,
1794
+ size: 36,
1795
+ fallbackUri: FALLBACK_ASSET_LOGO
1796
+ }
1797
+ ) }),
1798
+ /* @__PURE__ */ jsx10(Box, { flex: 1, children: /* @__PURE__ */ jsx10(Text, { variant: "bodyMedium", color: "textPrimary", children: chain.name }) }),
1799
+ chain.minLabel ? /* @__PURE__ */ jsx10(Text, { variant: "detail", color: "textSecondary", children: chain.minLabel }) : null
1800
+ ]
1801
+ },
1802
+ chain.id
1803
+ ))
1804
+ }
1805
+ )
1806
+ ]
1807
+ }
1808
+ );
1809
+ }
1810
+ function AvailableChainSkeleton() {
1811
+ return /* @__PURE__ */ jsxs5(Box, { flexDirection: "row", alignItems: "center", style: row2, children: [
1812
+ /* @__PURE__ */ jsx10(Box, { backgroundColor: "pillPressed", style: skeletonIcon }),
1813
+ /* @__PURE__ */ jsx10(Box, { flex: 1, children: /* @__PURE__ */ jsx10(Box, { backgroundColor: "pillPressed", style: skeletonName }) }),
1814
+ /* @__PURE__ */ jsx10(Box, { backgroundColor: "pillPressed", style: skeletonMin })
1815
+ ] });
1816
+ }
1817
+ var sheet = { paddingBottom: 20 };
1818
+ var topBar2 = {
1819
+ paddingVertical: 16,
1820
+ paddingHorizontal: 24,
1821
+ gap: 4
1822
+ };
1823
+ var iconButton = { width: 32, height: 32 };
1824
+ var topBarSpacer = { width: 32, height: 32 };
1825
+ var list = { width: "100%" };
1826
+ var content = { paddingHorizontal: 20 };
1827
+ var row2 = { gap: 12, paddingVertical: 10 };
1828
+ var skeletonIcon = { width: 36, height: 36, borderRadius: 999 };
1829
+ var skeletonName = { width: 157, height: 16, borderRadius: 4 };
1830
+ var skeletonMin = { width: 46, height: 16, borderRadius: 4 };
1831
+ var iconRing2 = {
1832
+ width: 36,
1833
+ height: 36,
1834
+ borderRadius: 999,
1835
+ borderWidth: 1,
1836
+ borderColor: "rgba(0,0,0,0.1)",
1837
+ overflow: "hidden",
1838
+ alignItems: "center",
1839
+ justifyContent: "center"
1840
+ };
1841
+
1842
+ // src/screens/CheckoutBlockedScreen.tsx
1843
+ import { StyleSheet as StyleSheet2 } from "react-native";
1844
+ import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
1845
+ function CheckoutBlockedScreen() {
1846
+ return /* @__PURE__ */ jsxs6(
1847
+ Box,
1848
+ {
1849
+ backgroundColor: "bgModal",
1850
+ borderTopLeftRadius: "modal",
1851
+ borderTopRightRadius: "modal",
1852
+ children: [
1853
+ /* @__PURE__ */ jsx11(Box, { alignItems: "center", style: styles2.topBar, children: /* @__PURE__ */ jsx11(Box, { backgroundColor: "borderFocused", style: styles2.grabber }) }),
1854
+ /* @__PURE__ */ jsxs6(Box, { alignItems: "center", justifyContent: "center", style: styles2.content, children: [
1855
+ /* @__PURE__ */ jsx11(
1856
+ Box,
1857
+ {
1858
+ backgroundColor: "bgSecondary",
1859
+ borderRadius: "rounded",
1860
+ alignItems: "center",
1861
+ justifyContent: "center",
1862
+ style: styles2.iconCircle,
1863
+ children: /* @__PURE__ */ jsx11(FigmaInfoCircleIcon, { size: 24 })
1864
+ }
1865
+ ),
1866
+ /* @__PURE__ */ jsxs6(Box, { alignItems: "center", style: styles2.textGroup, children: [
1867
+ /* @__PURE__ */ jsx11(Text, { variant: "bodyMedium", color: "textPrimary", children: "Not available" }),
1868
+ /* @__PURE__ */ jsx11(
1869
+ Text,
1870
+ {
1871
+ variant: "detail",
1872
+ color: "textSecondary",
1873
+ style: styles2.descriptionText,
1874
+ children: "This service is not available in your region."
1875
+ }
1876
+ )
1877
+ ] })
1878
+ ] })
1879
+ ]
1880
+ }
1881
+ );
1882
+ }
1883
+ var styles2 = StyleSheet2.create({
1884
+ topBar: { paddingTop: 20, paddingBottom: 12 },
1885
+ grabber: {
1886
+ position: "absolute",
1887
+ top: 8,
1888
+ width: 36,
1889
+ height: 5,
1890
+ borderRadius: 999
1891
+ },
1892
+ content: {
1893
+ height: 468,
1894
+ gap: 16,
1895
+ paddingHorizontal: 16
1896
+ },
1897
+ iconCircle: { width: 48, height: 48 },
1898
+ textGroup: { gap: 8 },
1899
+ descriptionText: { textAlign: "center" }
1900
+ });
1901
+
1902
+ // src/screens/QrCodeScreen.tsx
1903
+ import { useEffect as useEffect5, useRef as useRef2, useState as useState5 } from "react";
1904
+ import {
1905
+ Pressable as Pressable3,
1906
+ useWindowDimensions as useWindowDimensions2
1907
+ } from "react-native";
1908
+
1909
+ // src/icons/CopyAddressIcon.tsx
1910
+ import { SvgXml as SvgXml4 } from "react-native-svg";
1911
+ import { jsx as jsx12 } from "react/jsx-runtime";
1912
+ var COPY_ADDRESS_SVG = `<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10.2 5.8V4.26C10.2 3.64394 10.2 3.33591 10.0801 3.10061C9.97465 2.89363 9.80637 2.72535 9.59939 2.61989C9.36409 2.5 9.05606 2.5 8.44 2.5H4.26C3.64394 2.5 3.33591 2.5 3.10061 2.61989C2.89363 2.72535 2.72535 2.89363 2.61989 3.10061C2.5 3.33591 2.5 3.64394 2.5 4.26V8.44C2.5 9.05606 2.5 9.36409 2.61989 9.59939C2.72535 9.80637 2.89363 9.97465 3.10061 10.0801C3.33591 10.2 3.64394 10.2 4.26 10.2H5.8M7.56 13.5H11.74C12.3561 13.5 12.6641 13.5 12.8994 13.3801C13.1064 13.2746 13.2746 13.1064 13.3801 12.8994C13.5 12.6641 13.5 12.3561 13.5 11.74V7.56C13.5 6.94394 13.5 6.63591 13.3801 6.40061C13.2746 6.19363 13.1064 6.02535 12.8994 5.91989C12.6641 5.8 12.3561 5.8 11.74 5.8H7.56C6.94394 5.8 6.63591 5.8 6.40061 5.91989C6.19363 6.02535 6.02535 6.19363 5.91989 6.40061C5.8 6.63591 5.8 6.94394 5.8 7.56V11.74C5.8 12.3561 5.8 12.6641 5.91989 12.8994C6.02535 13.1064 6.19363 13.2746 6.40061 13.3801C6.63591 13.5 6.94394 13.5 7.56 13.5Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
1913
+ function CopyAddressIcon({ size = 16 }) {
1914
+ const theme = useTheme();
1915
+ return /* @__PURE__ */ jsx12(
1916
+ SvgXml4,
1917
+ {
1918
+ xml: COPY_ADDRESS_SVG,
1919
+ width: size,
1920
+ height: size,
1921
+ color: theme.colors.onBtnSecondary
1922
+ }
1923
+ );
1924
+ }
1925
+
1926
+ // src/screens/QrCodeScreen.tsx
1927
+ import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
1928
+ function QrCodeScreen({
1929
+ qrCode,
1930
+ centerIcon,
1931
+ address,
1932
+ title = "QR Code",
1933
+ copyLabel = "Copy address",
1934
+ copiedLabel = "Copied!",
1935
+ copiedFeedbackMs = 1800,
1936
+ onClose,
1937
+ onCopyAddress
1938
+ }) {
1939
+ const { height } = useWindowDimensions2();
1940
+ const [copied, setCopied] = useState5(false);
1941
+ const copyTimer = useRef2(void 0);
1942
+ useEffect5(() => () => clearTimeout(copyTimer.current), []);
1943
+ const handleCopy = async () => {
1944
+ const ok = await onCopyAddress?.();
1945
+ if (ok === false) return;
1946
+ setCopied(true);
1947
+ clearTimeout(copyTimer.current);
1948
+ copyTimer.current = setTimeout(() => setCopied(false), copiedFeedbackMs);
1949
+ };
1950
+ return /* @__PURE__ */ jsxs7(
1951
+ Box,
1952
+ {
1953
+ backgroundColor: "bgModal",
1954
+ borderTopLeftRadius: "modal",
1955
+ borderTopRightRadius: "modal",
1956
+ style: sheet2,
1957
+ children: [
1958
+ /* @__PURE__ */ jsxs7(Box, { flexDirection: "row", alignItems: "center", style: topBar3, children: [
1959
+ /* @__PURE__ */ jsx13(
1960
+ Pressable3,
1961
+ {
1962
+ onPress: onClose,
1963
+ hitSlop: 12,
1964
+ accessibilityRole: "button",
1965
+ accessibilityLabel: "Close",
1966
+ children: /* @__PURE__ */ jsx13(Text, { color: "textPrimary", style: closeGlyph, children: "\u2715" })
1967
+ }
1968
+ ),
1969
+ /* @__PURE__ */ jsx13(Box, { flex: 1, alignItems: "center", children: /* @__PURE__ */ jsx13(Text, { variant: "bodyMedium", color: "textPrimary", children: title }) }),
1970
+ /* @__PURE__ */ jsx13(Box, { style: topBarSpacer2 })
1971
+ ] }),
1972
+ /* @__PURE__ */ jsxs7(
1973
+ Box,
1974
+ {
1975
+ alignItems: "center",
1976
+ justifyContent: "center",
1977
+ style: [content2, { minHeight: height * 0.5 }],
1978
+ children: [
1979
+ /* @__PURE__ */ jsxs7(
1980
+ Box,
1981
+ {
1982
+ backgroundColor: "bgModal",
1983
+ borderColor: "borderDefault",
1984
+ borderWidth: 1.5,
1985
+ alignItems: "center",
1986
+ justifyContent: "center",
1987
+ style: qrFrame,
1988
+ children: [
1989
+ qrCode,
1990
+ centerIcon ? /* @__PURE__ */ jsx13(
1991
+ Box,
1992
+ {
1993
+ alignItems: "center",
1994
+ justifyContent: "center",
1995
+ style: centerOverlay,
1996
+ children: centerIcon
1997
+ }
1998
+ ) : null
1999
+ ]
2000
+ }
2001
+ ),
2002
+ address ? /* @__PURE__ */ jsxs7(Box, { alignItems: "center", style: addressGroup, children: [
2003
+ /* @__PURE__ */ jsx13(Text, { variant: "body", color: "textSecondary", style: addressText, children: address }),
2004
+ onCopyAddress ? /* @__PURE__ */ jsx13(
2005
+ Pressable3,
2006
+ {
2007
+ onPress: handleCopy,
2008
+ accessibilityRole: "button",
2009
+ accessibilityLabel: copied ? "Address copied" : "Copy address",
2010
+ children: /* @__PURE__ */ jsxs7(
2011
+ Box,
2012
+ {
2013
+ flexDirection: "row",
2014
+ alignItems: "center",
2015
+ justifyContent: "center",
2016
+ backgroundColor: "btnSecondary",
2017
+ borderColor: "btnSecondary",
2018
+ borderWidth: 1,
2019
+ borderRadius: "element",
2020
+ style: copyButton,
2021
+ children: [
2022
+ /* @__PURE__ */ jsx13(CopyAddressIcon, {}),
2023
+ /* @__PURE__ */ jsx13(Text, { variant: "bodyMedium", color: "onBtnSecondary", children: copied ? copiedLabel : copyLabel })
2024
+ ]
2025
+ }
2026
+ )
2027
+ }
2028
+ ) : null
2029
+ ] }) : null
2030
+ ]
2031
+ }
2032
+ )
2033
+ ]
2034
+ }
2035
+ );
2036
+ }
2037
+ var sheet2 = { paddingBottom: 32 };
2038
+ var topBar3 = {
2039
+ paddingVertical: 16,
2040
+ paddingHorizontal: 24,
2041
+ gap: 4
2042
+ };
2043
+ var closeGlyph = {
2044
+ fontSize: 20,
2045
+ lineHeight: 24,
2046
+ width: 32,
2047
+ textAlign: "center"
2048
+ };
2049
+ var topBarSpacer2 = { width: 32, height: 32 };
2050
+ var content2 = {
2051
+ paddingHorizontal: 20,
2052
+ paddingVertical: 45,
2053
+ gap: 40
2054
+ };
2055
+ var qrFrame = {
2056
+ width: 275,
2057
+ height: 275,
2058
+ borderRadius: 20,
2059
+ padding: 18,
2060
+ // Figma shadow/md: a soft lift under the card.
2061
+ shadowColor: "#000",
2062
+ shadowOpacity: 0.1,
2063
+ shadowOffset: { width: 0, height: 4 },
2064
+ shadowRadius: 16,
2065
+ elevation: 3
2066
+ };
2067
+ var centerOverlay = {
2068
+ position: "absolute",
2069
+ top: 0,
2070
+ left: 0,
2071
+ right: 0,
2072
+ bottom: 0,
2073
+ pointerEvents: "none"
2074
+ };
2075
+ var addressGroup = { gap: 16 };
2076
+ var addressText = { textAlign: "center", maxWidth: 220 };
2077
+ var copyButton = {
2078
+ height: 48,
2079
+ paddingHorizontal: 20,
2080
+ gap: 8
2081
+ };
2082
+
2083
+ // src/screens/TransferCryptoScreen.tsx
2084
+ import { useEffect as useEffect7, useRef as useRef3, useState as useState7 } from "react";
2085
+ import { Pressable as Pressable5 } from "react-native";
2086
+
2087
+ // src/screens/NetworkSelector.tsx
2088
+ import { useEffect as useEffect6, useState as useState6 } from "react";
2089
+ import { Pressable as Pressable4 } from "react-native";
2090
+ import Animated3, {
2091
+ Easing as Easing3,
2092
+ FadeIn,
2093
+ FadeOut,
2094
+ LinearTransition
2095
+ } from "react-native-reanimated";
2096
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
2097
+ function toIconUri3(icon) {
2098
+ return icon.startsWith("http") ? icon : chainIconUri(icon);
2099
+ }
2100
+ function NetworkSelector({
2101
+ networks,
2102
+ selectedId,
2103
+ onSelect
2104
+ }) {
2105
+ const [animate, setAnimate] = useState6(false);
2106
+ useEffect6(() => setAnimate(true), []);
2107
+ return /* @__PURE__ */ jsx14(
2108
+ Box,
2109
+ {
2110
+ flexDirection: "row",
2111
+ alignItems: "center",
2112
+ backgroundColor: "bgSecondary",
2113
+ borderColor: "borderDefault",
2114
+ borderWidth: 1,
2115
+ borderRadius: "rounded",
2116
+ style: track,
2117
+ children: networks.map((network) => {
2118
+ const selected = network.id === selectedId;
2119
+ return /* @__PURE__ */ jsx14(
2120
+ AnimatedPressable2,
2121
+ {
2122
+ onPress: () => onSelect(network.id),
2123
+ accessibilityRole: "button",
2124
+ accessibilityState: { selected },
2125
+ accessibilityLabel: network.label,
2126
+ style: selected ? selectedPress : iconPress,
2127
+ layout: animate ? segmentLayout : void 0,
2128
+ children: selected ? /* @__PURE__ */ jsx14(
2129
+ Animated3.View,
2130
+ {
2131
+ entering: animate ? FadeIn.duration(SLIDE_MS) : void 0,
2132
+ exiting: FadeOut.duration(COLLAPSE_MS),
2133
+ style: selectedFill,
2134
+ children: /* @__PURE__ */ jsxs8(
2135
+ Box,
2136
+ {
2137
+ flexDirection: "row",
2138
+ alignItems: "center",
2139
+ justifyContent: "center",
2140
+ backgroundColor: "bgModal",
2141
+ borderColor: "borderDefault",
2142
+ borderWidth: 1,
2143
+ borderRadius: "rounded",
2144
+ style: selectedPill,
2145
+ children: [
2146
+ /* @__PURE__ */ jsx14(ChainGlyph, { iconKeys: network.iconKeys }),
2147
+ /* @__PURE__ */ jsx14(Text, { variant: "bodyMedium", color: "textPrimary", children: network.label })
2148
+ ]
2149
+ }
2150
+ )
2151
+ }
2152
+ ) : /* @__PURE__ */ jsx14(ChainGlyph, { iconKeys: network.iconKeys })
2153
+ },
2154
+ network.id
2155
+ );
2156
+ })
2157
+ }
2158
+ );
2159
+ }
2160
+ var AnimatedPressable2 = Animated3.createAnimatedComponent(Pressable4);
2161
+ var SLIDE_MS = 250;
2162
+ var COLLAPSE_MS = 150;
2163
+ var segmentLayout = LinearTransition.duration(SLIDE_MS).easing(
2164
+ Easing3.bezier(0.22, 1, 0.36, 1)
2165
+ );
2166
+ function ChainGlyph({ iconKeys }) {
2167
+ if (iconKeys.length <= 1) {
2168
+ return /* @__PURE__ */ jsx14(
2169
+ FunIcon,
2170
+ {
2171
+ uri: toIconUri3(iconKeys[0] ?? ""),
2172
+ size: 24,
2173
+ fallbackUri: FALLBACK_ASSET_LOGO
2174
+ }
2175
+ );
2176
+ }
2177
+ return /* @__PURE__ */ jsx14(Box, { width: 24, height: 24, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsx14(Box, { flexDirection: "row", flexWrap: "wrap", style: miniGrid, children: iconKeys.slice(0, 4).map((key) => /* @__PURE__ */ jsx14(
2178
+ FunIcon,
2179
+ {
2180
+ uri: toIconUri3(key),
2181
+ size: 11,
2182
+ fallbackUri: FALLBACK_ASSET_LOGO
2183
+ },
2184
+ key
2185
+ )) }) });
2186
+ }
2187
+ var track = { height: 54, padding: 2 };
2188
+ var selectedPress = { flex: 1, height: "100%" };
2189
+ var selectedFill = { flex: 1 };
2190
+ var selectedPill = {
2191
+ height: "100%",
2192
+ paddingHorizontal: 16,
2193
+ gap: 10
2194
+ };
2195
+ var iconPress = {
2196
+ width: 50,
2197
+ height: "100%",
2198
+ alignItems: "center",
2199
+ justifyContent: "center"
2200
+ };
2201
+ var miniGrid = { width: 23.5, gap: 1.5 };
2202
+
2203
+ // src/screens/TransferCryptoScreen.tsx
2204
+ import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
2205
+ function TransferCryptoScreen({
2206
+ depositAddress,
2207
+ networks,
2208
+ selectedNetworkId,
2209
+ onSelectNetwork,
2210
+ supportedTokenIcons,
2211
+ minimumDepositLabel,
2212
+ title = "Transfer Crypto",
2213
+ depositAddressLabel = "Your deposit address",
2214
+ copyLabel = "Copy",
2215
+ copiedLabel = "Copied!",
2216
+ shareLabel = "Share",
2217
+ copiedFeedbackMs = 1800,
2218
+ onBack,
2219
+ onShowQrCode,
2220
+ onShowChains,
2221
+ onCopyAddress,
2222
+ onShareAddress
2223
+ }) {
2224
+ const theme = useTheme();
2225
+ const [copied, setCopied] = useState7(false);
2226
+ const copyTimer = useRef3(void 0);
2227
+ useEffect7(() => () => clearTimeout(copyTimer.current), []);
2228
+ const handleCopy = () => {
2229
+ onCopyAddress?.();
2230
+ setCopied(true);
2231
+ clearTimeout(copyTimer.current);
2232
+ copyTimer.current = setTimeout(() => setCopied(false), copiedFeedbackMs);
2233
+ };
2234
+ const showPreview = supportedTokenIcons != null && supportedTokenIcons.length > 0;
2235
+ const selectedNetwork = networks.find(
2236
+ (network) => network.id === selectedNetworkId
2237
+ );
2238
+ return /* @__PURE__ */ jsxs9(
2239
+ Box,
2240
+ {
2241
+ backgroundColor: "bgModal",
2242
+ borderTopLeftRadius: "modal",
2243
+ borderTopRightRadius: "modal",
2244
+ children: [
2245
+ /* @__PURE__ */ jsxs9(Box, { flexDirection: "row", alignItems: "center", style: topBar4, children: [
2246
+ /* @__PURE__ */ jsx15(
2247
+ Pressable5,
2248
+ {
2249
+ onPress: onBack,
2250
+ hitSlop: 12,
2251
+ accessibilityRole: "button",
2252
+ accessibilityLabel: "Back",
2253
+ children: /* @__PURE__ */ jsx15(Box, { alignItems: "center", justifyContent: "center", style: iconButton2, children: /* @__PURE__ */ jsx15(FigmaChevronLeftIcon, {}) })
2254
+ }
2255
+ ),
2256
+ /* @__PURE__ */ jsx15(Box, { flex: 1, alignItems: "center", children: /* @__PURE__ */ jsx15(Text, { variant: "bodyMedium", color: "textPrimary", children: title }) }),
2257
+ /* @__PURE__ */ jsx15(
2258
+ Pressable5,
2259
+ {
2260
+ onPress: onShowQrCode,
2261
+ hitSlop: 12,
2262
+ accessibilityRole: "button",
2263
+ accessibilityLabel: "Show QR code",
2264
+ children: /* @__PURE__ */ jsx15(Box, { alignItems: "center", justifyContent: "center", style: iconButton2, children: /* @__PURE__ */ jsx15(FigmaQrScanIcon, {}) })
2265
+ }
2266
+ )
2267
+ ] }),
2268
+ /* @__PURE__ */ jsxs9(Box, { style: content3, children: [
2269
+ /* @__PURE__ */ jsx15(
2270
+ NetworkSelector,
2271
+ {
2272
+ networks,
2273
+ selectedId: selectedNetworkId,
2274
+ onSelect: onSelectNetwork
2275
+ }
2276
+ ),
2277
+ /* @__PURE__ */ jsxs9(
2278
+ Box,
2279
+ {
2280
+ alignItems: "center",
2281
+ justifyContent: "flex-end",
2282
+ style: addressRegion,
2283
+ children: [
2284
+ /* @__PURE__ */ jsx15(
2285
+ Box,
2286
+ {
2287
+ flex: 1,
2288
+ alignItems: "center",
2289
+ justifyContent: "center",
2290
+ backgroundColor: "bgModal",
2291
+ borderColor: "borderDefault",
2292
+ borderWidth: 1,
2293
+ borderRadius: "element",
2294
+ style: addressCard,
2295
+ children: /* @__PURE__ */ jsxs9(Box, { alignItems: "center", style: addressColumn, children: [
2296
+ /* @__PURE__ */ jsxs9(Box, { alignItems: "center", style: addressGroup2, children: [
2297
+ /* @__PURE__ */ jsx15(Text, { variant: "body", color: "textSecondary", children: depositAddressLabel }),
2298
+ /* @__PURE__ */ jsx15(
2299
+ Text,
2300
+ {
2301
+ variant: "bodyMedium",
2302
+ color: "textPrimary",
2303
+ style: addressText2,
2304
+ children: depositAddress
2305
+ }
2306
+ )
2307
+ ] }),
2308
+ showPreview ? /* @__PURE__ */ jsx15(
2309
+ Pressable5,
2310
+ {
2311
+ onPress: onShowChains,
2312
+ accessibilityRole: "button",
2313
+ accessibilityLabel: "Available chains",
2314
+ children: /* @__PURE__ */ jsxs9(
2315
+ Box,
2316
+ {
2317
+ flexDirection: "row",
2318
+ alignItems: "center",
2319
+ backgroundColor: "bgSecondary",
2320
+ style: previewPill,
2321
+ children: [
2322
+ /* @__PURE__ */ jsx15(
2323
+ SourceTokenCluster,
2324
+ {
2325
+ icons: supportedTokenIcons,
2326
+ size: 20,
2327
+ gap: 4
2328
+ }
2329
+ ),
2330
+ /* @__PURE__ */ jsx15(
2331
+ FigmaChevronRightIcon,
2332
+ {
2333
+ size: 16,
2334
+ color: theme.colors.textSecondary
2335
+ }
2336
+ )
2337
+ ]
2338
+ }
2339
+ )
2340
+ }
2341
+ ) : minimumDepositLabel ? /* @__PURE__ */ jsx15(
2342
+ MinimumDepositPill,
2343
+ {
2344
+ label: minimumDepositLabel,
2345
+ iconKey: selectedNetwork?.iconKeys[0]
2346
+ }
2347
+ ) : null
2348
+ ] })
2349
+ }
2350
+ ),
2351
+ /* @__PURE__ */ jsxs9(Box, { flexDirection: "row", style: buttonsRow, children: [
2352
+ /* @__PURE__ */ jsx15(
2353
+ PillButton,
2354
+ {
2355
+ label: copied ? copiedLabel : copyLabel,
2356
+ accessibilityLabel: copied ? "Address copied" : "Copy address",
2357
+ icon: /* @__PURE__ */ jsx15(FigmaCopyIcon, { color: theme.colors.onBtnPrimary }),
2358
+ onPress: handleCopy
2359
+ }
2360
+ ),
2361
+ /* @__PURE__ */ jsx15(
2362
+ PillButton,
2363
+ {
2364
+ label: shareLabel,
2365
+ accessibilityLabel: "Share address",
2366
+ icon: /* @__PURE__ */ jsx15(FigmaShareIcon, { color: theme.colors.onBtnPrimary }),
2367
+ onPress: onShareAddress
2368
+ }
2369
+ )
2370
+ ] })
2371
+ ]
2372
+ }
2373
+ )
2374
+ ] })
2375
+ ]
2376
+ }
2377
+ );
2378
+ }
2379
+ function MinimumDepositPill({
2380
+ label: label2,
2381
+ iconKey
2382
+ }) {
2383
+ return /* @__PURE__ */ jsx15(Box, { alignItems: "center", justifyContent: "flex-start", style: minimumPill, children: /* @__PURE__ */ jsxs9(Box, { flexDirection: "row", alignItems: "center", style: minimumPillRow, children: [
2384
+ iconKey ? /* @__PURE__ */ jsx15(
2385
+ FunIcon,
2386
+ {
2387
+ uri: iconKey.startsWith("http") ? iconKey : chainIconUri(iconKey),
2388
+ size: 16,
2389
+ fallbackUri: FALLBACK_ASSET_LOGO
2390
+ }
2391
+ ) : null,
2392
+ /* @__PURE__ */ jsx15(Text, { variant: "detail", color: "textSecondary", children: label2 })
2393
+ ] }) });
2394
+ }
2395
+ function PillButton({
2396
+ label: label2,
2397
+ accessibilityLabel,
2398
+ icon,
2399
+ onPress
2400
+ }) {
2401
+ return /* @__PURE__ */ jsx15(
2402
+ Pressable5,
2403
+ {
2404
+ onPress,
2405
+ accessibilityRole: "button",
2406
+ accessibilityLabel,
2407
+ style: pillButtonPress,
2408
+ children: /* @__PURE__ */ jsxs9(
2409
+ Box,
2410
+ {
2411
+ flexDirection: "row",
2412
+ alignItems: "center",
2413
+ justifyContent: "center",
2414
+ backgroundColor: "btnPrimary",
2415
+ borderRadius: "rounded",
2416
+ style: pillButton,
2417
+ children: [
2418
+ icon,
2419
+ /* @__PURE__ */ jsx15(Text, { variant: "bodyMedium", color: "onBtnPrimary", children: label2 })
2420
+ ]
2421
+ }
2422
+ )
2423
+ }
2424
+ );
2425
+ }
2426
+ var topBar4 = {
2427
+ paddingTop: 16,
2428
+ paddingBottom: 16,
2429
+ paddingHorizontal: 24,
2430
+ gap: 4
2431
+ };
2432
+ var iconButton2 = { width: 32, height: 32 };
2433
+ var content3 = {
2434
+ paddingHorizontal: 20,
2435
+ // pb-16 in Figma + the iOS home-indicator space below the buttons, so the
2436
+ // sheet bottom sits flush with the 874px frame bottom.
2437
+ paddingBottom: 34,
2438
+ paddingTop: 8,
2439
+ gap: 16
2440
+ };
2441
+ var addressRegion = { height: 320, gap: 16, width: "100%" };
2442
+ var addressCard = {
2443
+ width: "100%",
2444
+ paddingVertical: 64,
2445
+ paddingHorizontal: 20,
2446
+ // Subtle card shadow (Figma shadow/lg at 2% — a faint lift). The card MUST
2447
+ // keep an opaque `backgroundColor`: on Android `elevation` draws its shadow
2448
+ // from the view outline, and without a solid background it can't clip to the
2449
+ // rounded corners — it bleeds as a gray rectangular border around the card.
2450
+ shadowColor: "#000",
2451
+ shadowOpacity: 0.02,
2452
+ shadowOffset: { width: 0, height: 8 },
2453
+ shadowRadius: 32,
2454
+ elevation: 1
2455
+ };
2456
+ var addressColumn = { gap: 6 };
2457
+ var addressGroup2 = { gap: 6 };
2458
+ var addressText2 = { fontSize: 24, lineHeight: 34 };
2459
+ var previewPill = {
2460
+ gap: 4,
2461
+ paddingHorizontal: 8,
2462
+ paddingVertical: 8,
2463
+ borderRadius: 999
2464
+ };
2465
+ var minimumPill = { height: 36, paddingTop: 2 };
2466
+ var minimumPillRow = { gap: 4, height: 20 };
2467
+ var buttonsRow = { gap: 10, width: "100%" };
2468
+ var pillButtonPress = { flex: 1 };
2469
+ var pillButton = { height: 56, paddingHorizontal: 24, gap: 8 };
2470
+
2471
+ // src/swapped/SwappedScreen.tsx
2472
+ import { useCallback as useCallback3 } from "react";
2473
+
2474
+ // src/swapped/SwappedWebView.tsx
2475
+ import { useTheme as useTheme2 } from "@shopify/restyle";
2476
+ import { useCallback as useCallback2, useEffect as useEffect8, useMemo as useMemo4, useRef as useRef4 } from "react";
2477
+ import { ActivityIndicator, View } from "react-native";
2478
+ import { WebView } from "react-native-webview";
2479
+
2480
+ // src/swapped/buildSwappedTheme.ts
2481
+ var px = (value) => `${value}px`;
2482
+ var toRawHex = (color) => color.replace(/^#/, "");
2483
+ function buildSwappedThemeQueryParamsRN(theme) {
2484
+ const { colors, borderRadii } = theme;
2485
+ return {
2486
+ iframeBackground: toRawHex(colors.bgModal),
2487
+ widgetBackground: toRawHex(colors.bgModal),
2488
+ textColor: toRawHex(colors.textPrimary),
2489
+ spinnerColor: toRawHex(colors.textPrimary),
2490
+ modalRadii: px(borderRadii.modal),
2491
+ skeletonColor: toRawHex(colors.borderDefault),
2492
+ skeletonSecondaryColor: toRawHex(colors.bgSecondary)
2493
+ };
2494
+ }
2495
+ function buildSwappedThemeRN(theme, isDarkMode) {
2496
+ const { colors, borderRadii, sizes, spacing, textVariants } = theme;
2497
+ return {
2498
+ colors: {
2499
+ // ── Core text ─────────────────────────────────────────────────────
2500
+ primaryText: colors.textPrimary,
2501
+ secondaryText: colors.textSecondary,
2502
+ tertiaryText: colors.textSecondary,
2503
+ // ── Surfaces ──────────────────────────────────────────────────────
2504
+ modalBackground: colors.bgModal,
2505
+ offBackground: colors.bgSecondary,
2506
+ hoverState: colors.bgSecondary,
2507
+ lightStroke: colors.borderDefault,
2508
+ mediumStroke: colors.borderFocused,
2509
+ heavyStroke: colors.borderFocused,
2510
+ modalBorder: colors.borderModal,
2511
+ modalHeaderDivider: colors.borderDefault,
2512
+ modalFooterDivider: colors.borderDefault,
2513
+ // ── Accent / brand ────────────────────────────────────────────────
2514
+ actionColor: colors.brandPrimary,
2515
+ accentColor: colors.brandPrimary,
2516
+ accentColorForeground: colors.onBtnPrimary,
2517
+ // ── Status ────────────────────────────────────────────────────────
2518
+ error: colors.textError,
2519
+ success: colors.textSuccess,
2520
+ // ── Spinner ───────────────────────────────────────────────────────
2521
+ spinnerIndicator: colors.textPrimary,
2522
+ spinnerBackground: colors.borderFocused,
2523
+ // ── Primary button ────────────────────────────────────────────────
2524
+ // web spreads both `buttonBackground*` (ThemeVars) and `buttonPrimary*`
2525
+ // (widget aliases); the widget reads whichever is present.
2526
+ buttonBackground: colors.btnPrimary,
2527
+ buttonBackgroundHover: colors.btnPrimaryHover,
2528
+ buttonBackgroundPressed: colors.btnPrimaryPressed,
2529
+ buttonBackgroundDisabled: colors.btnPrimaryDisabled,
2530
+ buttonPrimary: colors.btnPrimary,
2531
+ buttonPrimaryHover: colors.btnPrimaryHover,
2532
+ buttonDisabled: colors.btnPrimaryDisabled,
2533
+ buttonTextPrimary: colors.onBtnPrimary,
2534
+ buttonTextHover: colors.onBtnPrimary,
2535
+ buttonTextDisabled: colors.onBtnPrimary,
2536
+ buttonTextSecondary: colors.onBtnSecondary,
2537
+ buttonTextSecondaryDisabled: colors.onBtnSecondary,
2538
+ buttonFocusedOutline: "none",
2539
+ buttonBorderGradient: "none",
2540
+ buttonHoverBorderGradient: "none",
2541
+ buttonDisabledBorderGradient: "none",
2542
+ // ── Tertiary button ───────────────────────────────────────────────
2543
+ buttonBackgroundTertiary: colors.btnTertiary,
2544
+ buttonBackgroundHoverTertiary: colors.btnTertiaryHover,
2545
+ buttonBackgroundDisabledTertiary: colors.btnTertiaryDisabled,
2546
+ buttonTextTertiary: colors.onBtnTertiary,
2547
+ buttonTextDisabledTertiary: colors.onBtnTertiary,
2548
+ buttonBorderTertiary: "transparent",
2549
+ buttonBorderFocusedTertiary: colors.borderFocused,
2550
+ // ── Icon button / top bar ─────────────────────────────────────────
2551
+ headerButtonBackground: colors.btnIcon,
2552
+ buttonIconBackgroundHover: colors.btnIconHover,
2553
+ buttonIconBackgroundPressed: colors.btnIconPressed,
2554
+ buttonIconStroke: colors.onBtnIcon,
2555
+ modalTopbarIcon: colors.onBtnIcon,
2556
+ modalTopbarIconBackground: colors.btnIcon,
2557
+ modalTopbarIconBackgroundHover: colors.btnIconHover,
2558
+ modalTopbarIconBackgroundPressed: colors.btnIconPressed,
2559
+ // ── Input ─────────────────────────────────────────────────────────
2560
+ inputBackground: colors.bgModal,
2561
+ inputBackgroundHover: colors.bgSecondary,
2562
+ inputBorderBase: colors.borderDefault,
2563
+ inputBorderHover: colors.borderFocused,
2564
+ inputLabel: colors.textPrimary,
2565
+ inputBorder: colors.borderDefault,
2566
+ inputBorderFocused: colors.textSecondary,
2567
+ inputBorderActive: colors.textSecondary,
2568
+ inputPlaceholder: colors.textSecondary,
2569
+ // ── Selection ─────────────────────────────────────────────────────
2570
+ selectedOptionBorder: colors.borderSelected,
2571
+ focusedOptionBorder: colors.borderFocused,
2572
+ // ── Widget aliases (mirrors web buildSwappedTheme) ────────────────
2573
+ boxBackground: colors.bgSecondary,
2574
+ secondaryButtonBg: colors.btnTertiary,
2575
+ secondaryButtonText: colors.onBtnTertiary,
2576
+ secondaryButtonHover: colors.btnTertiaryHover,
2577
+ secondaryButtonTextHover: colors.onBtnTertiary
2578
+ },
2579
+ radii: {
2580
+ modal: px(borderRadii.modal),
2581
+ actionButton: px(borderRadii.button),
2582
+ summaryBox: px(borderRadii.element),
2583
+ box: px(borderRadii.element),
2584
+ otpInput: px(borderRadii.button),
2585
+ calculatorInput: px(borderRadii.button),
2586
+ amountPill: px(borderRadii.button)
2587
+ },
2588
+ paymentMethodLightLogos: !isDarkMode,
2589
+ headerHeight: px(sizes.topBar),
2590
+ headerFontWeight: String(textVariants.headerTitle.fontWeight ?? "500"),
2591
+ // web: topbarIconColor ← modalTopbarIcon (the icon on the top-bar buttons)
2592
+ topbarIconColor: colors.onBtnIcon,
2593
+ topbarTextFontSize: px(textVariants.headerTitle.fontSize ?? 13),
2594
+ headerIconWrapperSize: px(sizes.buttonXs),
2595
+ headerIconSize: px(sizes.iconMd),
2596
+ buttonFontWeight: String(textVariants.bodyMedium.fontWeight ?? "500"),
2597
+ modalBottomBarButtonHeight: px(sizes.buttonHeight),
2598
+ iframeBackground: colors.bgModal,
2599
+ // Same fixed paddings web sends (web: modalBaseHorizontalPadding + 6px).
2600
+ topbarPaddingX: px(spacing.modalHorizontal + 6),
2601
+ topbarPaddingY: "12px",
2602
+ boxPaddingY: "16px",
2603
+ boxPaddingX: "16px",
2604
+ paddingPrimary: "20px",
2605
+ paddingSecondary: "12px",
2606
+ paddingTertiary: "20px"
2607
+ };
2608
+ }
2609
+
2610
+ // src/swapped/webViewSwappedTransport.ts
2611
+ import {
2612
+ getSwappedOrigin
2613
+ } from "@funkit/connect-core";
2614
+ var FUNKIT_ENVELOPE_KEY = "__funkitSwapped";
2615
+ var SWAPPED_WEBVIEW_INJECTED_JS = `(function () {
2616
+ if (window.${FUNKIT_ENVELOPE_KEY}Bridge) { return; }
2617
+ window.${FUNKIT_ENVELOPE_KEY}Bridge = true;
2618
+ // The REAL postMessage, captured before the override below.
2619
+ var postToPage = window.postMessage.bind(window);
2620
+ function forwardToNative(message) {
2621
+ try {
2622
+ var data = typeof message === 'string' ? message : JSON.stringify(message);
2623
+ window.ReactNativeWebView && window.ReactNativeWebView.postMessage(data);
2624
+ } catch (e) {}
2625
+ }
2626
+ function bridged(message) {
2627
+ // funkit envelope (host \u2192 embed): unwrap + deliver to the page's listeners.
2628
+ if (message && message.${FUNKIT_ENVELOPE_KEY}) {
2629
+ try { postToPage(message.payload, '*'); } catch (e) {}
2630
+ return;
2631
+ }
2632
+ // Anything else is the embed talking to its host \u2192 forward to native.
2633
+ forwardToNative(message);
2634
+ }
2635
+ // The embed posts to window.parent (and sometimes window) \u2014 both are this
2636
+ // window at the top level, so both assignments install the same bridge.
2637
+ try { if (window.parent) { window.parent.postMessage = bridged; } } catch (e) {}
2638
+ try { window.postMessage = bridged; } catch (e) {}
2639
+ // No parent frame \u2192 the widget posts lifecycle messages to window.opener.
2640
+ try { if (!window.opener) { window.opener = { postMessage: forwardToNative }; } } catch (e) {}
2641
+ true;
2642
+ })();
2643
+ true;`;
2644
+ function buildSwappedSendScript(msg) {
2645
+ const envelope = JSON.stringify({ [FUNKIT_ENVELOPE_KEY]: true, payload: msg });
2646
+ return `(function () {
2647
+ try { window.postMessage(${envelope}, '*'); } catch (e) {}
2648
+ })();
2649
+ true;`;
2650
+ }
2651
+ function handleWebViewMessage(rawData, url) {
2652
+ if (url != null && getSwappedOrigin(url) == null) {
2653
+ return null;
2654
+ }
2655
+ let parsed;
2656
+ if (typeof rawData === "string") {
2657
+ try {
2658
+ parsed = JSON.parse(rawData);
2659
+ } catch {
2660
+ return null;
2661
+ }
2662
+ } else {
2663
+ parsed = rawData;
2664
+ }
2665
+ const data = parsed;
2666
+ if (!data || typeof data.type !== "string") {
2667
+ return null;
2668
+ }
2669
+ return data;
2670
+ }
2671
+ function createWebViewSwappedTransport({
2672
+ getWebView
2673
+ }) {
2674
+ const handlers = /* @__PURE__ */ new Set();
2675
+ const transport = {
2676
+ send(msg) {
2677
+ const webView = getWebView();
2678
+ if (!webView) {
2679
+ return false;
2680
+ }
2681
+ webView.injectJavaScript(buildSwappedSendScript(msg));
2682
+ return true;
2683
+ },
2684
+ onMessage(handler) {
2685
+ handlers.add(handler);
2686
+ return () => {
2687
+ handlers.delete(handler);
2688
+ };
2689
+ }
2690
+ };
2691
+ function dispatch(rawData, url) {
2692
+ const msg = handleWebViewMessage(rawData, url);
2693
+ if (msg) {
2694
+ for (const handler of handlers) {
2695
+ handler(msg);
2696
+ }
2697
+ }
2698
+ }
2699
+ return { transport, dispatch };
2700
+ }
2701
+
2702
+ // src/swapped/SwappedWebView.tsx
2703
+ import { jsx as jsx16 } from "react/jsx-runtime";
2704
+ function SwappedWebView({ url, onMessage, style }) {
2705
+ const webViewRef = useRef4(null);
2706
+ const { transport, dispatch } = useMemo4(
2707
+ () => createWebViewSwappedTransport({
2708
+ getWebView: () => webViewRef.current
2709
+ }),
2710
+ []
2711
+ );
2712
+ const theme = useTheme2();
2713
+ const { colorScheme } = useFunkitColorScheme();
2714
+ const swappedTheme = useMemo4(
2715
+ () => buildSwappedThemeRN(theme, colorScheme === "dark"),
2716
+ [theme, colorScheme]
2717
+ );
2718
+ const swappedThemeRef = useRef4(swappedTheme);
2719
+ swappedThemeRef.current = swappedTheme;
2720
+ const colorSchemeRef = useRef4(colorScheme);
2721
+ colorSchemeRef.current = colorScheme;
2722
+ const handlerRef = useRef4(onMessage);
2723
+ handlerRef.current = onMessage;
2724
+ useEffect8(
2725
+ () => transport.onMessage((msg) => {
2726
+ if (msg.type === "SWAPPED_READY") {
2727
+ transport.send({
2728
+ type: "SWAPPED_THEME",
2729
+ data: swappedThemeRef.current
2730
+ });
2731
+ logger.info("connect-rn:swapped:theme_sent", {
2732
+ colorScheme: colorSchemeRef.current
2733
+ });
2734
+ }
2735
+ handlerRef.current(msg);
2736
+ }),
2737
+ [transport]
2738
+ );
2739
+ const handleMessage = (event) => {
2740
+ dispatch(event.nativeEvent.data, event.nativeEvent.url);
2741
+ };
2742
+ const renderLoading = useCallback2(
2743
+ () => /* @__PURE__ */ jsx16(View, { style: [loadingOverlay, { backgroundColor: theme.colors.bgModal }], children: /* @__PURE__ */ jsx16(ActivityIndicator, { color: theme.colors.textSecondary }) }),
2744
+ [theme.colors.bgModal, theme.colors.textSecondary]
2745
+ );
2746
+ const handleError = (event) => {
2747
+ logger.warn("connect-rn:swapped:webview:error", {
2748
+ code: String(event.nativeEvent.code),
2749
+ description: event.nativeEvent.description,
2750
+ url: event.nativeEvent.url
2751
+ });
2752
+ };
2753
+ const handleHttpError = (event) => {
2754
+ logger.warn("connect-rn:swapped:webview:httpError", {
2755
+ status: String(event.nativeEvent.statusCode),
2756
+ url: event.nativeEvent.url
2757
+ });
2758
+ };
2759
+ return /* @__PURE__ */ jsx16(
2760
+ WebView,
2761
+ {
2762
+ ref: webViewRef,
2763
+ source: { uri: url },
2764
+ onMessage: handleMessage,
2765
+ onError: handleError,
2766
+ onHttpError: handleHttpError,
2767
+ scrollEnabled: false,
2768
+ injectedJavaScriptBeforeContentLoaded: SWAPPED_WEBVIEW_INJECTED_JS,
2769
+ startInLoadingState: true,
2770
+ renderLoading,
2771
+ javaScriptEnabled: true,
2772
+ domStorageEnabled: true,
2773
+ sharedCookiesEnabled: true,
2774
+ thirdPartyCookiesEnabled: true,
2775
+ allowsInlineMediaPlayback: true,
2776
+ keyboardDisplayRequiresUserAction: false,
2777
+ hideKeyboardAccessoryView: true,
2778
+ automaticallyAdjustContentInsets: false,
2779
+ contentInsetAdjustmentBehavior: "never",
2780
+ setSupportMultipleWindows: false,
2781
+ originWhitelist: ["https://*"],
2782
+ style: [{ backgroundColor: theme.colors.bgModal }, style]
2783
+ }
2784
+ );
2785
+ }
2786
+ var loadingOverlay = {
2787
+ position: "absolute",
2788
+ top: 0,
2789
+ left: 0,
2790
+ right: 0,
2791
+ bottom: 0,
2792
+ alignItems: "center",
2793
+ justifyContent: "center"
2794
+ };
2795
+
2796
+ // src/swapped/SwappedScreen.tsx
2797
+ import { jsx as jsx17 } from "react/jsx-runtime";
2798
+ function SwappedScreen({
2799
+ url,
2800
+ onClose,
2801
+ onBack,
2802
+ onSuccess
2803
+ }) {
2804
+ const handleMessage = useCallback3(
2805
+ (msg) => {
2806
+ switch (msg.type) {
2807
+ case "SWAPPED_GO_BACK":
2808
+ case "SWAPPED_NEW_DEPOSIT":
2809
+ onBack();
2810
+ break;
2811
+ case "SWAPPED_CLOSE":
2812
+ onClose();
2813
+ break;
2814
+ case "SWAPPED_TRANSACTION_SUCCESSFUL":
2815
+ logger.info("connect-rn:swapped:transaction_successful");
2816
+ onSuccess?.();
2817
+ break;
2818
+ case "SWAPPED_ERROR":
2819
+ logger.warn("connect-rn:swapped:error", {
2820
+ data: JSON.stringify(msg.data ?? {})
2821
+ });
2822
+ break;
2823
+ default:
2824
+ break;
2825
+ }
2826
+ },
2827
+ [onBack, onClose, onSuccess]
2828
+ );
2829
+ return /* @__PURE__ */ jsx17(
2830
+ Box,
2831
+ {
2832
+ backgroundColor: "bgModal",
2833
+ borderTopLeftRadius: "modal",
2834
+ borderTopRightRadius: "modal",
2835
+ style: sheet3,
2836
+ children: /* @__PURE__ */ jsx17(SwappedWebView, { url, onMessage: handleMessage, style: fill })
2837
+ }
2838
+ );
2839
+ }
2840
+ var SHEET_HEIGHT = 550;
2841
+ var sheet3 = { height: SHEET_HEIGHT, overflow: "hidden" };
2842
+ var fill = { flex: 1 };
2843
+
2844
+ // src/transfer/availableChains.ts
2845
+ import {
2846
+ bitcoinChain,
2847
+ chainMetadataById,
2848
+ solanaChain,
2849
+ tronChain
2850
+ } from "@funkit/chains";
2851
+ import {
2852
+ getMinTransferValueForChain
2853
+ } from "@funkit/connect-core";
2854
+ var NON_EVM_CHAIN_IDS = /* @__PURE__ */ new Set([
2855
+ solanaChain.id,
2856
+ tronChain.id,
2857
+ bitcoinChain.id
2858
+ ]);
2859
+ var EVM_NETWORK_ID = "evm";
2860
+ var EVM_NETWORK_LABEL = "EVM Chains";
2861
+ function isNonEvmChainId(chainId) {
2862
+ return NON_EVM_CHAIN_IDS.has(chainId);
2863
+ }
2864
+ function belongsToNetwork(chainId, networkChainId) {
2865
+ if (networkChainId == null) return true;
2866
+ if (NON_EVM_CHAIN_IDS.has(networkChainId)) return chainId === networkChainId;
2867
+ return !NON_EVM_CHAIN_IDS.has(chainId);
2868
+ }
2869
+ function buildAvailableChains({
2870
+ chainFilters,
2871
+ networkChainId,
2872
+ minTransferLimits,
2873
+ target
2874
+ }) {
2875
+ const minDepositAddOn = target?.getMinDepositUSD?.({
2876
+ tokenChainId: target.targetChain,
2877
+ tokenAddress: target.targetAsset,
2878
+ dynamicRoutingId: target.dynamicRoutingId
2879
+ }) ?? 0;
2880
+ return chainFilters.filter((f) => f.id !== "all").map((f) => ({ chainId: Number(f.id), name: f.label })).filter(({ chainId }) => belongsToNetwork(chainId, networkChainId)).map(({ chainId, name }) => {
2881
+ const meta = chainMetadataById[chainId];
2882
+ const min = Math.ceil(
2883
+ getMinTransferValueForChain(chainId, minTransferLimits) + minDepositAddOn
2884
+ );
2885
+ return {
2886
+ id: String(chainId),
2887
+ name: name || meta?.name || `Chain ${chainId}`,
2888
+ iconUri: meta?.iconUrl ?? FALLBACK_ASSET_LOGO,
2889
+ minLabel: `Min $${min}`
2890
+ };
2891
+ });
2892
+ }
2893
+ function buildDepositNetworks(chainFilters) {
2894
+ const chains = chainFilters.filter((f) => f.id !== "all").map((f) => ({ chainId: Number(f.id), label: f.label }));
2895
+ const iconUrl = (chainId) => chainMetadataById[chainId]?.iconUrl ?? FALLBACK_ASSET_LOGO;
2896
+ const evmChains = chains.filter((c) => !isNonEvmChainId(c.chainId));
2897
+ const networks = [];
2898
+ if (evmChains.length > 0) {
2899
+ networks.push({
2900
+ id: EVM_NETWORK_ID,
2901
+ label: EVM_NETWORK_LABEL,
2902
+ iconKeys: evmChains.map((c) => iconUrl(c.chainId)),
2903
+ // Any EVM chain selects the shared EVM deposit address.
2904
+ chainId: evmChains[0].chainId
2905
+ });
2906
+ }
2907
+ for (const c of chains) {
2908
+ if (!isNonEvmChainId(c.chainId)) continue;
2909
+ const meta = chainMetadataById[c.chainId];
2910
+ networks.push({
2911
+ id: String(c.chainId),
2912
+ label: c.label || meta?.name || `Chain ${c.chainId}`,
2913
+ iconKeys: [iconUrl(c.chainId)],
2914
+ chainId: c.chainId
2915
+ });
2916
+ }
2917
+ return networks;
2918
+ }
2919
+
2920
+ // src/transfer/clipboard.ts
2921
+ async function copyToClipboard(value) {
2922
+ try {
2923
+ const { default: Clipboard } = await import("@react-native-clipboard/clipboard");
2924
+ Clipboard.setString(value);
2925
+ return true;
2926
+ } catch (error) {
2927
+ logger.warn(
2928
+ "connect-rn: clipboard write failed; address not copied. Inject FunkitProvider `copyToClipboard` to use your own clipboard module (e.g. expo-clipboard in Expo Go).",
2929
+ { error: error instanceof Error ? error.message : String(error) }
2930
+ );
2931
+ return false;
2932
+ }
2933
+ }
2934
+
2935
+ // src/transfer/fops.ts
2936
+ import {
2937
+ FormOfPaymentType
2938
+ } from "@funkit/api-base";
2939
+ import { getFopsLimit } from "@funkit/connect-core";
2940
+ var BANK_TRANSFER_TIME = "1-2 days";
2941
+ function toFopRows(fops, exchangeRates) {
2942
+ return fops.map((fop) => {
2943
+ const limit = `${getFopsLimit(fop, exchangeRates)} limit`;
2944
+ const subtitle = fop.fopType === FormOfPaymentType.BANK_TRANSFER ? `${limit} \xB7 ${BANK_TRANSFER_TIME}` : limit;
2945
+ return {
2946
+ id: `${fop.fopType}:${fop.name}`,
2947
+ name: fop.name,
2948
+ iconUri: fop.iconImageUrl,
2949
+ subtitle,
2950
+ disabled: !fop.embeddedFlowUrl
2951
+ };
2952
+ });
2953
+ }
2954
+
2955
+ // src/transfer/formatDepositAddress.ts
2956
+ function formatDepositAddress(address, leading = 6, trailing = 6) {
2957
+ if (!address) {
2958
+ return "";
2959
+ }
2960
+ if (address.length <= leading + trailing) {
2961
+ return address;
2962
+ }
2963
+ return `${address.slice(0, leading)}\u2026${address.slice(-trailing)}`;
2964
+ }
2965
+
2966
+ // src/transfer/hooks/useFops.ts
2967
+ import {
2968
+ getFops
2969
+ } from "@funkit/api-base";
2970
+ import {
2971
+ FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS,
2972
+ solanaChain as solanaChain2
2973
+ } from "@funkit/chains";
2974
+ import {
2975
+ DEFAULT_FIAT_CURRENCY,
2976
+ FOPS_STALE_TIME,
2977
+ getDepositAddressForChain,
2978
+ sortFops,
2979
+ useDynamicConfig as useDynamicConfig3,
2980
+ useSwappedDefaultCurrencyQuery
2981
+ } from "@funkit/connect-core";
2982
+ import { useTheme as useTheme3 } from "@shopify/restyle";
2983
+ import { useQuery as useQuery3 } from "@tanstack/react-query";
2984
+ import { useMemo as useMemo6 } from "react";
2985
+
2986
+ // src/identity/IdentityContext.tsx
2987
+ import { createContext as createContext2, useContext as useContext2 } from "react";
2988
+ import { jsx as jsx18 } from "react/jsx-runtime";
2989
+ function generateSyntheticUserId(apiKey, externalUserId) {
2990
+ return `${apiKey}|${externalUserId}`;
2991
+ }
2992
+ function resolveFunkitIdentity(config, walletAddress) {
2993
+ const address = walletAddress || "0x";
2994
+ const userId = config.externalUserId ? generateSyntheticUserId(config.apiKey, config.externalUserId) : address;
2995
+ return {
2996
+ apiKey: config.apiKey,
2997
+ userId,
2998
+ walletAddress: address,
2999
+ loginType: config.loginType
3000
+ };
3001
+ }
3002
+ var FunkitIdentityContext = createContext2(null);
3003
+ function FunkitIdentityProvider({
3004
+ identity,
3005
+ children
3006
+ }) {
3007
+ return /* @__PURE__ */ jsx18(FunkitIdentityContext.Provider, { value: identity, children });
3008
+ }
3009
+ function useFunkitIdentity() {
3010
+ const identity = useContext2(FunkitIdentityContext);
3011
+ if (identity == null) {
3012
+ throw new Error(
3013
+ "useFunkitIdentity must be used within a <FunkitIdentityProvider> (mounted by <FunkitProvider>)"
3014
+ );
3015
+ }
3016
+ return identity;
3017
+ }
3018
+
3019
+ // src/transfer/hooks/useTransferInit.ts
3020
+ import {
3021
+ initializeCheckoutTokenTransferAddress
3022
+ } from "@funkit/api-base";
3023
+ import {
3024
+ getCheckoutTokenTransferParams
3025
+ } from "@funkit/connect-core";
3026
+ import { useQuery as useQuery2 } from "@tanstack/react-query";
3027
+
3028
+ // src/transfer/hooks/useUDAParams.ts
3029
+ import { useDynamicConfig as useDynamicConfig2 } from "@funkit/connect-core";
3030
+ import { useMemo as useMemo5 } from "react";
3031
+ function useUDAParams(dynamicRoutingId) {
3032
+ const udaParams = useDynamicConfig2("uda_params");
3033
+ return useMemo5(
3034
+ () => udaParams.find((param) => param.dynamicRoutingId === dynamicRoutingId)?.params,
3035
+ [udaParams, dynamicRoutingId]
3036
+ );
3037
+ }
3038
+
3039
+ // src/transfer/hooks/useTransferInit.ts
3040
+ var TRANSFER_CLIENT_METADATA = {};
3041
+ function useTransferInit({
3042
+ checkoutConfig,
3043
+ recipientAddr,
3044
+ dynamicRoutingId,
3045
+ enabled = true
3046
+ }) {
3047
+ const { apiKey, userId, walletAddress } = useFunkitIdentity();
3048
+ const udaParams = useUDAParams(dynamicRoutingId);
3049
+ const resolvedRecipient = recipientAddr || walletAddress || "0x";
3050
+ const params = getCheckoutTokenTransferParams({
3051
+ checkoutConfig,
3052
+ userId,
3053
+ apiKey,
3054
+ recipientAddr: resolvedRecipient,
3055
+ udaParams
3056
+ });
3057
+ const { data, isLoading, isFetching } = useQuery2({
3058
+ queryKey: ["initializeCheckoutTokenTransferAddress", params],
3059
+ queryFn: ({ queryKey: [, queryParams] }) => queryParams ? initializeCheckoutTokenTransferAddress({
3060
+ ...queryParams,
3061
+ logger,
3062
+ clientMetadata: TRANSFER_CLIENT_METADATA
3063
+ }) : void 0,
3064
+ enabled: enabled && !!params,
3065
+ refetchOnWindowFocus: false,
3066
+ refetchOnMount: false
3067
+ });
3068
+ return {
3069
+ transferInit: isFetching ? void 0 : data,
3070
+ recipientAddr: resolvedRecipient,
3071
+ isLoading,
3072
+ isFetching
3073
+ };
3074
+ }
3075
+
3076
+ // src/transfer/hooks/useFops.ts
3077
+ var DEFAULT_COUNTRY_CODE = "US";
3078
+ function useFops({
3079
+ checkoutConfig,
3080
+ dynamicRoutingId,
3081
+ enabled = true
3082
+ }) {
3083
+ const { apiKey, userId } = useFunkitIdentity();
3084
+ const isSwappedEnabled = !!useDynamicConfig3("enableswappeddeposit");
3085
+ const fopPriority = useDynamicConfig3("foppriority");
3086
+ const { userIpInfo } = useUserIpInfo();
3087
+ const countryCode = userIpInfo?.alpha2 || DEFAULT_COUNTRY_CODE;
3088
+ const {
3089
+ data: swappedCurrencyCode = DEFAULT_FIAT_CURRENCY,
3090
+ isLoading: isSwappedCurrencyCodeLoading
3091
+ } = useSwappedDefaultCurrencyQuery({
3092
+ apiKey,
3093
+ countryCode: userIpInfo?.alpha2,
3094
+ logger
3095
+ });
3096
+ const theme = useTheme3();
3097
+ const themeConfig = useMemo6(
3098
+ () => buildSwappedThemeQueryParamsRN(theme),
3099
+ [theme]
3100
+ );
3101
+ const {
3102
+ transferInit,
3103
+ isLoading: isTransferInitLoading,
3104
+ isFetching: isTransferInitFetching
3105
+ } = useTransferInit({
3106
+ checkoutConfig,
3107
+ dynamicRoutingId,
3108
+ enabled: enabled && isSwappedEnabled
3109
+ });
3110
+ const targetAsset = checkoutConfig?.targetAsset;
3111
+ const targetChain = checkoutConfig?.targetChain;
3112
+ const recipientAddress = targetChain ? getDepositAddressForChain(Number(targetChain), transferInit) : void 0;
3113
+ const isEnabled = enabled && isSwappedEnabled && !!apiKey && !!targetAsset && !!targetChain && !!recipientAddress && !!transferInit && !isSwappedCurrencyCodeLoading;
3114
+ const query = useQuery3({
3115
+ queryKey: [
3116
+ "fops",
3117
+ userId,
3118
+ recipientAddress,
3119
+ targetAsset,
3120
+ targetChain,
3121
+ apiKey,
3122
+ countryCode,
3123
+ swappedCurrencyCode,
3124
+ fopPriority,
3125
+ themeConfig
3126
+ ],
3127
+ queryFn: async () => {
3128
+ if (!recipientAddress || !targetChain || !targetAsset) {
3129
+ return { genericFormsOfPayments: [], savedFormsOfPayments: [] };
3130
+ }
3131
+ const destinationToken = { chainId: targetChain, address: targetAsset };
3132
+ const recipientTargets = [
3133
+ { recipientAddress, destinationToken },
3134
+ ...transferInit?.solanaAddr ? [
3135
+ {
3136
+ recipientAddress: transferInit.solanaAddr,
3137
+ destinationToken: {
3138
+ chainId: solanaChain2.id.toString(),
3139
+ address: FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS
3140
+ }
3141
+ }
3142
+ ] : []
3143
+ ];
3144
+ const response = await getFops({
3145
+ apiKey,
3146
+ logger,
3147
+ params: {
3148
+ recipientAddress,
3149
+ userId,
3150
+ destinationToken,
3151
+ fiatCurrencyCode: swappedCurrencyCode,
3152
+ countryCode,
3153
+ recipientTargets,
3154
+ thirdPartyPaymentConfigs: { swapped: { themeConfig } }
3155
+ }
3156
+ });
3157
+ return {
3158
+ genericFormsOfPayments: sortFops(
3159
+ response.genericFormsOfPayments,
3160
+ fopPriority
3161
+ ),
3162
+ savedFormsOfPayments: sortFops(
3163
+ response.savedFormsOfPayments,
3164
+ fopPriority
3165
+ )
3166
+ };
3167
+ },
3168
+ enabled: isEnabled,
3169
+ staleTime: FOPS_STALE_TIME,
3170
+ refetchOnWindowFocus: false
3171
+ });
3172
+ return {
3173
+ savedFops: query.data?.savedFormsOfPayments ?? [],
3174
+ genericFops: query.data?.genericFormsOfPayments ?? [],
3175
+ isLoading: query.isLoading || isTransferInitLoading,
3176
+ isFetching: isTransferInitFetching,
3177
+ isError: query.isError,
3178
+ refetch: () => void query.refetch(),
3179
+ isSwappedEnabled
3180
+ };
3181
+ }
3182
+
3183
+ // src/transfer/hooks/useSupportedTokens.ts
3184
+ import { getSupportedAssets } from "@funkit/api-base";
3185
+ import {
3186
+ isTransferChainEnabled,
3187
+ resolveTokenTransferConfig,
3188
+ useDynamicConfig as useDynamicConfig4
3189
+ } from "@funkit/connect-core";
3190
+ import { useQuery as useQuery4 } from "@tanstack/react-query";
3191
+ import { useMemo as useMemo7 } from "react";
3192
+
3193
+ // src/transfer/supportedTokens.ts
3194
+ function buildSupportedTokenList(resolved) {
3195
+ const priorityIndex = new Map(
3196
+ resolved.priorityTokenSymbols.map((symbol, i) => [symbol, i])
3197
+ );
3198
+ const tokens = [];
3199
+ const chainFilters = [{ id: "all", label: "All" }];
3200
+ for (const chainId of resolved.chainIdSortOrder) {
3201
+ const assets = Object.values(resolved.supportedAssets[chainId] ?? {});
3202
+ if (assets.length === 0) {
3203
+ continue;
3204
+ }
3205
+ chainFilters.push({ id: String(chainId), label: assets[0].chainName });
3206
+ for (const asset of assets) {
3207
+ tokens.push({
3208
+ id: `${asset.chainId}:${asset.address}`,
3209
+ symbol: asset.symbol,
3210
+ chainLabel: asset.chainName,
3211
+ chainId: Number(asset.chainId),
3212
+ address: asset.address
3213
+ });
3214
+ }
3215
+ }
3216
+ const rank = (symbol) => priorityIndex.get(symbol) ?? Number.POSITIVE_INFINITY;
3217
+ tokens.sort((a, b) => rank(a.symbol) - rank(b.symbol));
3218
+ return { tokens, chainFilters };
3219
+ }
3220
+
3221
+ // src/transfer/hooks/useSupportedTokens.ts
3222
+ function useSupportedTokens({
3223
+ enabled = true,
3224
+ transferInit
3225
+ } = {}) {
3226
+ const { apiKey } = useFunkitIdentity();
3227
+ const tokenTransferConfig = useDynamicConfig4("tokentransferconfig");
3228
+ const disabledChainAssets = useDynamicConfig4(
3229
+ "disabletokentransferchainsandassets"
3230
+ );
3231
+ const { data, isLoading } = useQuery4({
3232
+ queryKey: ["getSupportedAssets", apiKey],
3233
+ queryFn: ({ queryKey: [, key] }) => getSupportedAssets({ apiKey: key, logger }),
3234
+ enabled: enabled && !!apiKey,
3235
+ staleTime: 5 * 6e4,
3236
+ refetchOnWindowFocus: false
3237
+ });
3238
+ const { tokens, chainFilters } = useMemo7(() => {
3239
+ if (!data) {
3240
+ return { tokens: [], chainFilters: [{ id: "all", label: "All" }] };
3241
+ }
3242
+ const resolved = resolveTokenTransferConfig({
3243
+ chainConfigs: tokenTransferConfig.chains ?? [],
3244
+ priorityTokens: tokenTransferConfig.priorityTokens ?? [],
3245
+ disabledChainAssets,
3246
+ supportedAssets: data,
3247
+ logger
3248
+ });
3249
+ const built = buildSupportedTokenList(resolved);
3250
+ const isEnabled = (chainId) => chainId == null || isTransferChainEnabled(chainId, transferInit);
3251
+ return {
3252
+ tokens: built.tokens.filter((t) => isEnabled(t.chainId)),
3253
+ chainFilters: built.chainFilters.filter(
3254
+ (c) => c.id === "all" || isEnabled(Number(c.id))
3255
+ )
3256
+ };
3257
+ }, [data, tokenTransferConfig, disabledChainAssets, transferInit]);
3258
+ return { tokens, chainFilters, isLoading };
3259
+ }
3260
+
3261
+ // src/transfer/hooks/useTokenTransfer.ts
3262
+ import { bitcoinChain as bitcoinChain2, solanaChain as solanaChain3, tronChain as tronChain2 } from "@funkit/chains";
3263
+ import {
3264
+ getDepositAddressForChain as getDepositAddressForChain2,
3265
+ getMinTransferValueForChain as getMinTransferValueForChain2,
3266
+ getTransferTokenQrCodeUri,
3267
+ useDynamicConfig as useDynamicConfig5
3268
+ } from "@funkit/connect-core";
3269
+ var DEFAULT_MAX_SLIPPAGE_PERCENT = 0.25;
3270
+ function resolveBlockchain(chainId) {
3271
+ if (chainId === solanaChain3.id) {
3272
+ return "solana";
3273
+ }
3274
+ if (chainId === bitcoinChain2.id) {
3275
+ return "bitcoin";
3276
+ }
3277
+ if (chainId === tronChain2.id) {
3278
+ return "tron";
3279
+ }
3280
+ return "ethereum";
3281
+ }
3282
+ function useTokenTransfer({
3283
+ checkoutConfig,
3284
+ selectedChainId,
3285
+ dynamicRoutingId,
3286
+ enabled
3287
+ }) {
3288
+ const { transferInit, recipientAddr, isLoading } = useTransferInit({
3289
+ checkoutConfig,
3290
+ dynamicRoutingId,
3291
+ enabled
3292
+ });
3293
+ const minTransferLimits = useDynamicConfig5("mintokentransfervalue");
3294
+ const minTransferUsd = selectedChainId !== void 0 ? Math.ceil(
3295
+ getMinTransferValueForChain2(selectedChainId, minTransferLimits)
3296
+ ) : 0;
3297
+ const depositAddress = selectedChainId !== void 0 ? getDepositAddressForChain2(selectedChainId, transferInit) : void 0;
3298
+ const blockchain = resolveBlockchain(selectedChainId);
3299
+ const qrCodeUri = depositAddress ? getTransferTokenQrCodeUri({ depositAddress, type: blockchain }) : void 0;
3300
+ return {
3301
+ depositAddress,
3302
+ transferInit,
3303
+ recipientAddr,
3304
+ minTransferUsd,
3305
+ maxSlippagePercent: DEFAULT_MAX_SLIPPAGE_PERCENT,
3306
+ qrCodeUri,
3307
+ blockchain,
3308
+ isLoading
3309
+ };
3310
+ }
3311
+
3312
+ // src/transfer/QrCode.tsx
3313
+ import QRCode from "react-native-qrcode-svg";
3314
+ import { jsx as jsx19 } from "react/jsx-runtime";
3315
+ function QrCode({ value, size = 220, ecl = "H" }) {
3316
+ return /* @__PURE__ */ jsx19(
3317
+ QRCode,
3318
+ {
3319
+ value,
3320
+ size,
3321
+ ecl,
3322
+ color: "#101010",
3323
+ backgroundColor: "#FFFFFF"
3324
+ }
3325
+ );
3326
+ }
3327
+
3328
+ // src/flow/depositFlowConfig.ts
3329
+ function getDefaultDynamicTargetAsset(candidates, dynamicRoutingId) {
3330
+ if (!candidates?.length) return void 0;
3331
+ if (candidates.length === 1) return candidates[0];
3332
+ const routingId = dynamicRoutingId ?? "";
3333
+ return candidates.find((c) => c.dynamicRoutingId === routingId) ?? candidates.find((c) => c.isDefault) ?? candidates[0];
3334
+ }
3335
+
3336
+ // src/flow/FlowSheet.tsx
3337
+ import {
3338
+ useCallback as useCallback4,
3339
+ useEffect as useEffect10,
3340
+ useRef as useRef5
3341
+ } from "react";
3342
+ import { View as View2 } from "react-native";
3343
+ import {
3344
+ BottomSheetBackdrop,
3345
+ BottomSheetModal,
3346
+ BottomSheetModalProvider,
3347
+ BottomSheetView,
3348
+ useBottomSheetTimingConfigs
3349
+ } from "@gorhom/bottom-sheet";
3350
+ import { Easing as Easing4 } from "react-native-reanimated";
3351
+
3352
+ // src/flow/useKeyboardHeight.ts
3353
+ import { useEffect as useEffect9, useState as useState8 } from "react";
3354
+ import { Keyboard, Platform } from "react-native";
3355
+ function useKeyboardHeight(enabled) {
3356
+ const [height, setHeight] = useState8(0);
3357
+ useEffect9(() => {
3358
+ if (!enabled) {
3359
+ setHeight(0);
3360
+ return;
3361
+ }
3362
+ const showEvent = Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow";
3363
+ const hideEvent = Platform.OS === "ios" ? "keyboardWillHide" : "keyboardDidHide";
3364
+ const show = Keyboard.addListener(
3365
+ showEvent,
3366
+ (e) => setHeight(e.endCoordinates.height)
3367
+ );
3368
+ const hide = Keyboard.addListener(hideEvent, () => setHeight(0));
3369
+ return () => {
3370
+ show.remove();
3371
+ hide.remove();
3372
+ };
3373
+ }, [enabled]);
3374
+ return height;
3375
+ }
3376
+
3377
+ // src/flow/FlowSheet.tsx
3378
+ import { jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
3379
+ function FlowSheet({
3380
+ isOpen,
3381
+ session,
3382
+ onClose,
3383
+ content: content4,
3384
+ children,
3385
+ keyboardAvoidEnabled = false
3386
+ }) {
3387
+ const ref = useRef5(null);
3388
+ const setRef = useCallback4((instance) => {
3389
+ ref.current = instance;
3390
+ }, []);
3391
+ const keyboardHeight = useKeyboardHeight(keyboardAvoidEnabled);
3392
+ const hasPresented = useRef5(false);
3393
+ const sheetSelfDismissed = useRef5(false);
3394
+ useEffect10(() => {
3395
+ if (isOpen) {
3396
+ sheetSelfDismissed.current = false;
3397
+ ref.current?.present();
3398
+ hasPresented.current = true;
3399
+ return;
3400
+ }
3401
+ if (!hasPresented.current) return;
3402
+ hasPresented.current = false;
3403
+ if (sheetSelfDismissed.current) {
3404
+ sheetSelfDismissed.current = false;
3405
+ return;
3406
+ }
3407
+ ref.current?.dismiss();
3408
+ }, [isOpen, session]);
3409
+ const handleDismiss = useCallback4(() => {
3410
+ sheetSelfDismissed.current = true;
3411
+ onClose();
3412
+ }, [onClose]);
3413
+ const animationConfigs = useBottomSheetTimingConfigs({
3414
+ duration: 300,
3415
+ easing: Easing4.bezier(0.22, 1, 0.36, 1)
3416
+ });
3417
+ const renderBackdrop = useCallback4(
3418
+ (props) => /* @__PURE__ */ jsx20(
3419
+ BottomSheetBackdrop,
3420
+ {
3421
+ ...props,
3422
+ appearsOnIndex: 0,
3423
+ disappearsOnIndex: -1,
3424
+ pressBehavior: "close"
3425
+ }
3426
+ ),
3427
+ []
3428
+ );
3429
+ return /* @__PURE__ */ jsxs10(BottomSheetModalProvider, { children: [
3430
+ children,
3431
+ /* @__PURE__ */ jsx20(
3432
+ BottomSheetModal,
3433
+ {
3434
+ ref: setRef,
3435
+ enableDynamicSizing: true,
3436
+ keyboardBehavior: "extend",
3437
+ enableOverDrag: keyboardHeight === 0,
3438
+ animationConfigs,
3439
+ onDismiss: handleDismiss,
3440
+ backdropComponent: renderBackdrop,
3441
+ handleComponent: null,
3442
+ backgroundComponent: FlowSheetBackground,
3443
+ children: /* @__PURE__ */ jsxs10(BottomSheetView, { children: [
3444
+ content4,
3445
+ keyboardHeight > 0 ? /* @__PURE__ */ jsx20(View2, { style: { height: keyboardHeight } }) : null
3446
+ ] })
3447
+ }
3448
+ )
3449
+ ] });
3450
+ }
3451
+ function FlowSheetBackground({
3452
+ pointerEvents,
3453
+ style
3454
+ }) {
3455
+ const theme = useTheme();
3456
+ const surface = {
3457
+ backgroundColor: theme.colors.bgModal,
3458
+ borderTopLeftRadius: theme.borderRadii.modal,
3459
+ borderTopRightRadius: theme.borderRadii.modal
3460
+ };
3461
+ const extension = {
3462
+ ...bottomExtension,
3463
+ backgroundColor: theme.colors.bgModal
3464
+ };
3465
+ return /* @__PURE__ */ jsx20(View2, { pointerEvents, style: [style, surface], children: /* @__PURE__ */ jsx20(View2, { style: extension }) });
3466
+ }
3467
+ var bottomExtension = {
3468
+ position: "absolute",
3469
+ top: "100%",
3470
+ left: 0,
3471
+ right: 0,
3472
+ height: 1e3
3473
+ };
3474
+
3475
+ // src/flow/FunkitFlowProvider.tsx
3476
+ import { jsx as jsx21, jsxs as jsxs11 } from "react/jsx-runtime";
3477
+ var CLOSED = {
3478
+ isOpen: false,
3479
+ stack: [],
3480
+ config: null,
3481
+ callbacks: {},
3482
+ session: 0
3483
+ };
3484
+ var FunkitFlowContext = createContext3(null);
3485
+ function FunkitFlowProvider({
3486
+ children,
3487
+ copyToClipboard: copyToClipboard2 = copyToClipboard
3488
+ }) {
3489
+ const insets = useSafeAreaInsets();
3490
+ const [state, setState] = useState9(CLOSED);
3491
+ const beginDeposit = useCallback5(
3492
+ (config, callbacks = {}) => {
3493
+ callbacks.onOpen?.();
3494
+ setState((prev) => ({
3495
+ isOpen: true,
3496
+ stack: ["addMoney"],
3497
+ config,
3498
+ callbacks,
3499
+ session: prev.session + 1
3500
+ }));
3501
+ },
3502
+ []
3503
+ );
3504
+ const clearToast = useCallback5(() => {
3505
+ if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
3506
+ if (unmountTimerRef.current) clearTimeout(unmountTimerRef.current);
3507
+ setCopiedToastShown(false);
3508
+ setToastMounted(false);
3509
+ }, []);
3510
+ const closeFlow = useCallback5(() => {
3511
+ setState((prev) => {
3512
+ if (!prev.isOpen) return prev;
3513
+ prev.callbacks.onClose?.();
3514
+ return CLOSED;
3515
+ });
3516
+ clearToast();
3517
+ }, [clearToast]);
3518
+ const navigate = useCallback5((screen) => {
3519
+ setState((prev) => ({ ...prev, stack: [...prev.stack, screen] }));
3520
+ }, []);
3521
+ const back = useCallback5(() => {
3522
+ setState((prev) => {
3523
+ if (!prev.isOpen) return prev;
3524
+ if (prev.stack.length <= 1) {
3525
+ prev.callbacks.onClose?.();
3526
+ return CLOSED;
3527
+ }
3528
+ return { ...prev, stack: prev.stack.slice(0, -1) };
3529
+ });
3530
+ }, []);
3531
+ const value = useMemo8(
3532
+ () => ({ beginDeposit, closeFlow }),
3533
+ [beginDeposit, closeFlow]
3534
+ );
3535
+ const current = state.stack[state.stack.length - 1];
3536
+ const nav = useMemo8(
3537
+ () => ({ navigate, back, closeFlow }),
3538
+ [navigate, back, closeFlow]
3539
+ );
3540
+ const [toastMounted, setToastMounted] = useState9(false);
3541
+ const [copiedToastShown, setCopiedToastShown] = useState9(false);
3542
+ const hideTimerRef = useRef6(
3543
+ void 0
3544
+ );
3545
+ const unmountTimerRef = useRef6(
3546
+ void 0
3547
+ );
3548
+ const showCopiedToast = useCallback5(() => {
3549
+ if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
3550
+ if (unmountTimerRef.current) clearTimeout(unmountTimerRef.current);
3551
+ setToastMounted(true);
3552
+ setCopiedToastShown(true);
3553
+ hideTimerRef.current = setTimeout(() => {
3554
+ setCopiedToastShown(false);
3555
+ unmountTimerRef.current = setTimeout(
3556
+ () => setToastMounted(false),
3557
+ TOAST_EXIT_MS
3558
+ );
3559
+ }, TOAST_VISIBLE_MS);
3560
+ }, []);
3561
+ useEffect11(() => () => clearToast(), [clearToast]);
3562
+ return /* @__PURE__ */ jsx21(FunkitFlowContext.Provider, { value, children: /* @__PURE__ */ jsxs11(View3, { style: rootContainer, children: [
3563
+ /* @__PURE__ */ jsx21(
3564
+ FlowSheet,
3565
+ {
3566
+ isOpen: state.isOpen,
3567
+ session: state.session,
3568
+ onClose: closeFlow,
3569
+ keyboardAvoidEnabled: current === "swapped",
3570
+ content: (
3571
+ // Mounted only while open so the transfer query runs only then.
3572
+ state.isOpen && state.config ? /* @__PURE__ */ jsx21(
3573
+ FlowContent,
3574
+ {
3575
+ config: state.config,
3576
+ current,
3577
+ nav,
3578
+ copyToClipboard: copyToClipboard2,
3579
+ onCopySuccess: showCopiedToast,
3580
+ callbacks: state.callbacks
3581
+ }
3582
+ ) : null
3583
+ ),
3584
+ children
3585
+ }
3586
+ ),
3587
+ toastMounted ? /* @__PURE__ */ jsx21(
3588
+ View3,
3589
+ {
3590
+ style: [
3591
+ toastOverlay,
3592
+ { paddingTop: insets.top + TOAST_INSET_OFFSET }
3593
+ ],
3594
+ pointerEvents: "none",
3595
+ children: copiedToastShown ? /* @__PURE__ */ jsx21(AddressCopiedToast, {}) : null
3596
+ }
3597
+ ) : null
3598
+ ] }) });
3599
+ }
3600
+ var DEFAULT_EVM_CHAIN_ID = 1;
3601
+ var CRYPTO_METHOD_ID = "crypto";
3602
+ function resolveSelectedChainId(selectedNetworkId, initialChainId, evmRepresentativeChainId) {
3603
+ if (selectedNetworkId == null) return initialChainId;
3604
+ if (selectedNetworkId === EVM_NETWORK_ID) return evmRepresentativeChainId;
3605
+ const id = Number(selectedNetworkId);
3606
+ return Number.isFinite(id) ? id : initialChainId;
3607
+ }
3608
+ function FlowContent({
3609
+ config,
3610
+ current,
3611
+ nav,
3612
+ copyToClipboard: copyToClipboard2,
3613
+ onCopySuccess,
3614
+ callbacks
3615
+ }) {
3616
+ const { isGeoblocked, isLoadingGeoCheck } = useCheckoutBlocked({
3617
+ onCheckoutBlocked: callbacks.onCheckoutBlocked
3618
+ });
3619
+ const [selectedNetworkId, setSelectedNetworkId] = useState9();
3620
+ const [selectedCandidate, setSelectedCandidate] = useState9(
3621
+ () => getDefaultDynamicTargetAsset(
3622
+ config.dynamicTargetAssetCandidates,
3623
+ config.dynamicRoutingId
3624
+ )
3625
+ );
3626
+ const activeCheckoutConfig = selectedCandidate ? {
3627
+ ...config.checkoutConfig,
3628
+ targetChain: selectedCandidate.tokenChainId,
3629
+ targetAsset: selectedCandidate.tokenAddress
3630
+ } : config.checkoutConfig;
3631
+ const activeDynamicRoutingId = selectedCandidate?.dynamicRoutingId ?? config.dynamicRoutingId;
3632
+ const parsedSourceChain = config.sourceChain ? Number(config.sourceChain) : void 0;
3633
+ const initialChainId = parsedSourceChain != null && Number.isFinite(parsedSourceChain) ? parsedSourceChain : void 0;
3634
+ const evmRepresentativeChainId = initialChainId != null && !isNonEvmChainId(initialChainId) ? initialChainId : DEFAULT_EVM_CHAIN_ID;
3635
+ const selectedChainId = resolveSelectedChainId(
3636
+ selectedNetworkId,
3637
+ initialChainId,
3638
+ evmRepresentativeChainId
3639
+ );
3640
+ const {
3641
+ depositAddress: generatedAddress,
3642
+ qrCodeUri,
3643
+ transferInit,
3644
+ isLoading: isAddressLoading
3645
+ } = useTokenTransfer({
3646
+ checkoutConfig: activeCheckoutConfig,
3647
+ selectedChainId,
3648
+ dynamicRoutingId: activeDynamicRoutingId,
3649
+ enabled: true
3650
+ });
3651
+ const fetched = useSupportedTokens({ transferInit });
3652
+ const tokenChainFilters = config.tokenChainFilters ?? fetched.chainFilters;
3653
+ const depositNetworks = useMemo8(
3654
+ () => buildDepositNetworks(tokenChainFilters),
3655
+ [tokenChainFilters]
3656
+ );
3657
+ const initialNetwork = initialChainId == null ? void 0 : depositNetworks.find(
3658
+ (n) => n.chainId != null && belongsToNetwork(initialChainId, n.chainId)
3659
+ );
3660
+ const selectedChain = depositNetworks.find((n) => n.id === selectedNetworkId) ?? initialNetwork ?? depositNetworks[0];
3661
+ const minTransferLimits = useDynamicConfig6("mintokentransfervalue");
3662
+ const {
3663
+ savedFops,
3664
+ genericFops,
3665
+ isSwappedEnabled,
3666
+ isLoading: isFopsLoading,
3667
+ isError: isFopsError,
3668
+ refetch: refetchFops
3669
+ } = useFops({
3670
+ checkoutConfig: activeCheckoutConfig,
3671
+ dynamicRoutingId: activeDynamicRoutingId
3672
+ });
3673
+ const [selectedSwappedUrl, setSelectedSwappedUrl] = useState9();
3674
+ const availableChains = buildAvailableChains({
3675
+ chainFilters: tokenChainFilters,
3676
+ networkChainId: selectedChainId,
3677
+ minTransferLimits,
3678
+ target: {
3679
+ targetChain: activeCheckoutConfig?.targetChain,
3680
+ targetAsset: activeCheckoutConfig?.targetAsset,
3681
+ dynamicRoutingId: activeDynamicRoutingId,
3682
+ getMinDepositUSD: config.checkoutConfig?.getMinDepositUSD
3683
+ }
3684
+ });
3685
+ const singleChain = availableChains.length === 1 ? availableChains[0] : void 0;
3686
+ const rawAddress = generatedAddress ?? config.depositAddress;
3687
+ const displayAddress = rawAddress ? formatDepositAddress(rawAddress) : "Generating\u2026";
3688
+ const copyAddressAndToast = useCallback5(
3689
+ async (value) => {
3690
+ const ok = await copyToClipboard2(value) !== false;
3691
+ if (ok) onCopySuccess();
3692
+ return ok;
3693
+ },
3694
+ [copyToClipboard2, onCopySuccess]
3695
+ );
3696
+ const screen = (() => {
3697
+ switch (current) {
3698
+ case "addMoney": {
3699
+ const cryptoSourceIcons = [
3700
+ ...new Set(depositNetworks.flatMap((n) => n.iconKeys ?? []))
3701
+ ];
3702
+ const cryptoMethod = [
3703
+ {
3704
+ id: CRYPTO_METHOD_ID,
3705
+ title: "Crypto",
3706
+ subtitle: "No limit",
3707
+ icon: /* @__PURE__ */ jsx21(CryptoBitcoinIcon, {}),
3708
+ trailing: cryptoSourceIcons.length ? /* @__PURE__ */ jsx21(
3709
+ SourceTokenCluster,
3710
+ {
3711
+ icons: cryptoSourceIcons,
3712
+ overflowMode: "plus"
3713
+ }
3714
+ ) : void 0
3715
+ }
3716
+ ];
3717
+ const toCashRows = (fops) => toFopRows(fops).map((row3) => ({
3718
+ id: row3.id,
3719
+ title: row3.name,
3720
+ subtitle: row3.subtitle,
3721
+ icon: /* @__PURE__ */ jsx21(FunIcon, { uri: row3.iconUri, fallbackUri: FALLBACK_ASSET_LOGO })
3722
+ }));
3723
+ const methods = isSwappedEnabled ? [
3724
+ ...toCashRows(savedFops),
3725
+ ...cryptoMethod,
3726
+ ...toCashRows(genericFops)
3727
+ ] : cryptoMethod;
3728
+ const candidates = config.dynamicTargetAssetCandidates;
3729
+ const receiveTokens = candidates?.map(
3730
+ (c, i) => ({
3731
+ id: String(i),
3732
+ label: c.badgeText ? `${c.tokenSymbol} (${c.badgeText})` : c.tokenSymbol,
3733
+ icon: /* @__PURE__ */ jsx21(TokenChainIcon, { symbol: c.tokenSymbol, iconSrc: c.iconSrc })
3734
+ })
3735
+ );
3736
+ const selectedReceiveTokenId = selectedCandidate && candidates ? String(candidates.indexOf(selectedCandidate)) : void 0;
3737
+ return /* @__PURE__ */ jsx21(
3738
+ AddMoneyScreen,
3739
+ {
3740
+ methods,
3741
+ receiveTokens,
3742
+ selectedReceiveTokenId,
3743
+ onSelectReceiveToken: (id) => {
3744
+ const picked = candidates?.[Number(id)];
3745
+ if (picked) {
3746
+ setSelectedCandidate(picked);
3747
+ }
3748
+ },
3749
+ loading: isLoadingGeoCheck || isAddressLoading || isSwappedEnabled && isFopsLoading,
3750
+ error: isSwappedEnabled && isFopsError,
3751
+ onRetry: refetchFops,
3752
+ onSelectMethod: (id) => {
3753
+ if (id === CRYPTO_METHOD_ID) {
3754
+ nav.navigate("transfer");
3755
+ return;
3756
+ }
3757
+ if (id.includes(":")) {
3758
+ const fop = [...savedFops, ...genericFops].find(
3759
+ (f) => `${f.fopType}:${f.name}` === id
3760
+ );
3761
+ if (fop?.embeddedFlowUrl) {
3762
+ setSelectedSwappedUrl(fop.embeddedFlowUrl);
3763
+ nav.navigate("swapped");
3764
+ }
3765
+ return;
3766
+ }
3767
+ }
3768
+ }
3769
+ );
3770
+ }
3771
+ case "transfer": {
3772
+ const networks = depositNetworks.map((chain) => ({
3773
+ id: chain.id,
3774
+ label: chain.label,
3775
+ iconKeys: chain.iconKeys ?? []
3776
+ }));
3777
+ return /* @__PURE__ */ jsx21(
3778
+ TransferCryptoScreen,
3779
+ {
3780
+ depositAddress: displayAddress,
3781
+ networks,
3782
+ selectedNetworkId: selectedChain?.id ?? networks[0]?.id ?? "",
3783
+ onSelectNetwork: setSelectedNetworkId,
3784
+ supportedTokenIcons: singleChain ? void 0 : availableChains.length ? availableChains.map((c) => c.iconUri) : selectedChain?.iconKeys ?? [],
3785
+ minimumDepositLabel: singleChain?.minLabel,
3786
+ onBack: nav.back,
3787
+ onShowChains: availableChains.length > 1 ? () => nav.navigate("availableChains") : void 0,
3788
+ onShowQrCode: () => nav.navigate("qrCode"),
3789
+ onCopyAddress: rawAddress ? () => void copyAddressAndToast(rawAddress) : void 0,
3790
+ onShareAddress: rawAddress ? () => void Share.share({ message: rawAddress }) : void 0
3791
+ }
3792
+ );
3793
+ }
3794
+ case "availableChains":
3795
+ return /* @__PURE__ */ jsx21(
3796
+ AvailableChainsScreen,
3797
+ {
3798
+ networkLabel: selectedChain?.label ?? "",
3799
+ chains: availableChains,
3800
+ onClose: nav.back
3801
+ }
3802
+ );
3803
+ case "qrCode":
3804
+ return /* @__PURE__ */ jsx21(
3805
+ QrCodeScreen,
3806
+ {
3807
+ qrCode: config.qrCode ?? (qrCodeUri ? /* @__PURE__ */ jsx21(QrCode, { value: qrCodeUri, size: 235 }) : null),
3808
+ centerIcon: /* @__PURE__ */ jsx21(QrChainCluster, { iconKeys: selectedChain?.iconKeys ?? [] }),
3809
+ address: rawAddress,
3810
+ onCopyAddress: rawAddress ? () => copyAddressAndToast(rawAddress) : void 0,
3811
+ onClose: nav.back
3812
+ }
3813
+ );
3814
+ case "swapped":
3815
+ return selectedSwappedUrl ? /* @__PURE__ */ jsx21(
3816
+ SwappedScreen,
3817
+ {
3818
+ url: selectedSwappedUrl,
3819
+ onBack: nav.back,
3820
+ onClose: nav.closeFlow
3821
+ }
3822
+ ) : null;
3823
+ default:
3824
+ return null;
3825
+ }
3826
+ })();
3827
+ if (isGeoblocked) {
3828
+ return /* @__PURE__ */ jsx21(CheckoutBlockedScreen, {});
3829
+ }
3830
+ return screen;
3831
+ }
3832
+ var TOAST_VISIBLE_MS = 1800;
3833
+ var TOAST_EXIT_MS = 350;
3834
+ var TOAST_INSET_OFFSET = 20;
3835
+ var rootContainer = { flex: 1 };
3836
+ var toastOverlay = {
3837
+ ...StyleSheet3.absoluteFill,
3838
+ zIndex: 1,
3839
+ alignItems: "center"
3840
+ };
3841
+ function useFunkitFlow() {
3842
+ const value = useContext3(FunkitFlowContext);
3843
+ if (value == null) {
3844
+ throw new Error("useFunkitFlow must be used within <FunkitProvider>");
3845
+ }
3846
+ return value;
3847
+ }
3848
+
3849
+ // src/version.ts
3850
+ var CONNECT_RN_VERSION = true ? "0.0.0-20260710210119" : "0.0.0-dev";
3851
+
3852
+ // src/providers/FunkitStatsigProvider.tsx
3853
+ import {
3854
+ LogEventCompressionMode,
3855
+ LogLevel,
3856
+ StatsigProvider
3857
+ } from "@statsig/react-bindings";
3858
+ import { useMemo as useMemo9 } from "react";
3859
+
3860
+ // src/statsig/useClientAsyncInitRN.ts
3861
+ import {
3862
+ useStatsigInternalClientFactoryAsync
3863
+ } from "@statsig/react-bindings";
3864
+
3865
+ // src/statsig/StatsigClientRN.ts
3866
+ import {
3867
+ StatsigClient
3868
+ } from "@statsig/react-bindings";
3869
+
3870
+ // src/statsig/rnSetup.ts
3871
+ import {
3872
+ SDKType,
3873
+ StatsigMetadataProvider
3874
+ } from "@statsig/react-bindings";
3875
+
3876
+ // src/statsig/appVisibilityShim.ts
3877
+ import { _notifyVisibilityChanged } from "@statsig/react-bindings";
3878
+ import { AppState } from "react-native";
3879
+ var isApplied = false;
3880
+ function applyAppStateVisibilityShim() {
3881
+ if (isApplied) {
3882
+ return;
3883
+ }
3884
+ isApplied = true;
3885
+ AppState.addEventListener(
3886
+ "change",
3887
+ (nextAppState) => _notifyVisibilityChanged(
3888
+ nextAppState === "active" ? "foreground" : "background"
3889
+ )
3890
+ );
3891
+ }
3892
+
3893
+ // src/statsig/preloadedAsyncStorage.ts
3894
+ import AsyncStorage from "@react-native-async-storage/async-storage";
3895
+ import { Log } from "@statsig/react-bindings";
3896
+ var NOT_READY_ERROR = "Attempting to alter AsyncStorage before it is ready. Values will not be persisted.";
3897
+ function createPreloadedAsyncStorage() {
3898
+ const inMemoryStore = {};
3899
+ let isResolved = false;
3900
+ let readyPromise = null;
3901
+ const enforceIsResolved = () => {
3902
+ if (!isResolved) {
3903
+ Log.error(NOT_READY_ERROR);
3904
+ }
3905
+ return isResolved;
3906
+ };
3907
+ const provider = {
3908
+ getProviderName: () => "AsyncStorage",
3909
+ isReady: () => isResolved,
3910
+ isReadyResolver: () => {
3911
+ if (!readyPromise) {
3912
+ readyPromise = prefetchFromAsyncStorage(inMemoryStore).finally(() => {
3913
+ isResolved = true;
3914
+ });
3915
+ }
3916
+ return readyPromise;
3917
+ },
3918
+ getItem: (key) => {
3919
+ if (!enforceIsResolved()) {
3920
+ return null;
3921
+ }
3922
+ return inMemoryStore[key] ?? null;
3923
+ },
3924
+ setItem: (key, value) => {
3925
+ inMemoryStore[key] = value;
3926
+ if (!enforceIsResolved()) {
3927
+ return;
3928
+ }
3929
+ AsyncStorage.setItem(key, value).catch(Log.error);
3930
+ },
3931
+ removeItem: (key) => {
3932
+ delete inMemoryStore[key];
3933
+ if (!enforceIsResolved()) {
3934
+ return;
3935
+ }
3936
+ AsyncStorage.removeItem(key).catch(Log.error);
3937
+ },
3938
+ getAllKeys: () => {
3939
+ if (!enforceIsResolved()) {
3940
+ return [];
3941
+ }
3942
+ return Object.keys(inMemoryStore);
3943
+ }
3944
+ };
3945
+ return provider;
3946
+ }
3947
+ async function prefetchFromAsyncStorage(inMemoryStore) {
3948
+ const keys = await AsyncStorage.getAllKeys();
3949
+ await Promise.all(
3950
+ keys.map(async (key) => {
3951
+ if (!key.startsWith("statsig.")) {
3952
+ return;
3953
+ }
3954
+ const cache = await AsyncStorage.getItem(key);
3955
+ if (!cache) {
3956
+ return;
3957
+ }
3958
+ inMemoryStore[key] = cache;
3959
+ })
3960
+ );
3961
+ }
3962
+
3963
+ // src/statsig/rnSetup.ts
3964
+ function setupStatsigForReactNative(statsigMetadataAdditions, options) {
3965
+ applyAppStateVisibilityShim();
3966
+ SDKType._setBindingType("rn");
3967
+ if (statsigMetadataAdditions) {
3968
+ StatsigMetadataProvider.add(statsigMetadataAdditions);
3969
+ }
3970
+ if (options.storageProvider == null) {
3971
+ options.storageProvider = createPreloadedAsyncStorage();
3972
+ }
3973
+ applyNetworkFix(options);
3974
+ }
3975
+ function applyNetworkFix(options) {
3976
+ if (options.networkConfig?.networkOverrideFunc != null) {
3977
+ return;
3978
+ }
3979
+ const networkOverrideFunc = (url, args) => {
3980
+ if (args.body != null && args.method === "POST") {
3981
+ args.headers = {
3982
+ "Content-Type": "application/json",
3983
+ ...args.headers
3984
+ };
3985
+ }
3986
+ return fetch(url, args);
3987
+ };
3988
+ options.networkConfig = {
3989
+ networkOverrideFunc,
3990
+ ...options.networkConfig
3991
+ };
3992
+ }
3993
+
3994
+ // src/statsig/statsigMetadata.ts
3995
+ import { NativeModules, Platform as Platform2 } from "react-native";
3996
+ function resolveLocale() {
3997
+ if (Platform2.OS === "android") {
3998
+ const i18nManager = NativeModules.I18nManager;
3999
+ return i18nManager?.localeIdentifier ?? void 0;
4000
+ }
4001
+ if (Platform2.OS === "ios") {
4002
+ const settings = NativeModules.SettingsManager?.settings;
4003
+ return settings?.AppLocale ?? settings?.AppleLanguages?.[0] ?? void 0;
4004
+ }
4005
+ return void 0;
4006
+ }
4007
+ function getStatsigMetadataAdditions() {
4008
+ return {
4009
+ // Device-info-derived fields are dropped (no react-native-device-info).
4010
+ appVersion: void 0,
4011
+ systemVersion: void 0,
4012
+ deviceModelName: void 0,
4013
+ deviceModel: void 0,
4014
+ // Available without any native module:
4015
+ systemName: Platform2.OS,
4016
+ locale: resolveLocale()
4017
+ };
4018
+ }
4019
+
4020
+ // src/statsig/StatsigClientRN.ts
4021
+ var StatsigClientRN = class extends StatsigClient {
4022
+ constructor(sdkKey, user, options = null) {
4023
+ const opts = options ?? {};
4024
+ setupStatsigForReactNative(getStatsigMetadataAdditions(), opts);
4025
+ super(sdkKey, user, opts);
4026
+ this.__isRnClient = true;
4027
+ }
4028
+ };
4029
+
4030
+ // src/statsig/useClientAsyncInitRN.ts
4031
+ function useClientAsyncInitRN(sdkKey, initialUser, statsigOptions = null) {
4032
+ return useStatsigInternalClientFactoryAsync(
4033
+ (args) => new StatsigClientRN(args.sdkKey, args.initialUser, args.statsigOptions),
4034
+ {
4035
+ sdkKey,
4036
+ initialUser,
4037
+ statsigOptions
4038
+ }
4039
+ );
4040
+ }
4041
+
4042
+ // src/providers/FunkitStatsigProvider.tsx
4043
+ import { jsx as jsx22 } from "react/jsx-runtime";
4044
+ var STATSIG_API = "https://data-api.fun.xyz/v1";
4045
+ var STATSIG_CLIENT_KEY = "client-UmFd8WIJljA7cLmZuDqs3X25M8sKd5WIQP4BSC2bRbM";
4046
+ function FunkitStatsigProvider({
4047
+ children,
4048
+ apiKey,
4049
+ userId,
4050
+ isDevelopment = false
4051
+ }) {
4052
+ const user = useMemo9(
4053
+ () => ({ userID: userId, customIDs: { apiKey } }),
4054
+ [userId, apiKey]
4055
+ );
4056
+ const { client } = useClientAsyncInitRN(STATSIG_CLIENT_KEY, user, {
4057
+ networkConfig: {
4058
+ api: STATSIG_API,
4059
+ // default timeout (10s) is too large; statsig usually responds <200ms
4060
+ networkTimeoutMs: 5e3
4061
+ },
4062
+ // Our proxy supports compression; force it on to save bandwidth.
4063
+ logEventCompressionMode: LogEventCompressionMode.Forced,
4064
+ // Silence harmless warnings from hooks running before async init (we have
4065
+ // bootstrap fallbacks).
4066
+ logLevel: isDevelopment ? void 0 : LogLevel.Error,
4067
+ environment: {
4068
+ tier: isDevelopment ? "development" : "production"
4069
+ }
4070
+ });
4071
+ return /* @__PURE__ */ jsx22(StatsigProvider, { client, children });
4072
+ }
4073
+
4074
+ // src/providers/FunkitProvider.tsx
4075
+ import { jsx as jsx23 } from "react/jsx-runtime";
4076
+ var ANONYMOUS_CONFIG = { apiKey: "" };
4077
+ function createFallbackQueryClient() {
4078
+ return new QueryClient({
4079
+ defaultOptions: {
4080
+ queries: {
4081
+ staleTime: 6e4
4082
+ }
4083
+ }
4084
+ });
4085
+ }
4086
+ function FunkitProvider({
4087
+ children,
4088
+ config,
4089
+ walletAddress,
4090
+ queryClient,
4091
+ themes,
4092
+ colorScheme,
4093
+ debug = false,
4094
+ copyToClipboard: copyToClipboard2
4095
+ }) {
4096
+ const fallbackClient = useRef7(void 0);
4097
+ fallbackClient.current ??= createFallbackQueryClient();
4098
+ const client = queryClient ?? fallbackClient.current;
4099
+ const identity = useMemo10(
4100
+ () => resolveFunkitIdentity(config ?? ANONYMOUS_CONFIG, walletAddress),
4101
+ [config, walletAddress]
4102
+ );
4103
+ useEffect12(() => {
4104
+ if (!config?.apiKey) {
4105
+ return;
4106
+ }
4107
+ logger.configure(config.apiKey, debug, CONNECT_RN_VERSION);
4108
+ }, [config?.apiKey, debug]);
4109
+ useEffect12(() => {
4110
+ logger.setUserInfo(
4111
+ identity.userId,
4112
+ identity.walletAddress,
4113
+ "",
4114
+ identity.loginType ?? "",
4115
+ ""
4116
+ );
4117
+ }, [identity]);
4118
+ return /* @__PURE__ */ jsx23(SafeAreaProvider, { children: /* @__PURE__ */ jsx23(
4119
+ FunkitStatsigProvider,
4120
+ {
4121
+ apiKey: identity.apiKey,
4122
+ userId: identity.userId,
4123
+ isDevelopment: debug,
4124
+ children: /* @__PURE__ */ jsx23(QueryClientProvider, { client, children: /* @__PURE__ */ jsx23(FunkitIdentityProvider, { identity, children: /* @__PURE__ */ jsx23(FunkitThemeProvider, { themes, colorScheme, children: /* @__PURE__ */ jsx23(FunkitFlowProvider, { copyToClipboard: copyToClipboard2, children }) }) }) })
4125
+ }
4126
+ ) });
4127
+ }
4128
+
4129
+ // src/providers/useFunkitCheckout.ts
4130
+ import { useCallback as useCallback6 } from "react";
4131
+ function useFunkitCheckout(callbacks = {}) {
4132
+ const { beginDeposit: begin } = useFunkitFlow();
4133
+ const beginDeposit = useCallback6(
4134
+ (config) => begin(config, callbacks),
4135
+ [begin, callbacks]
4136
+ );
4137
+ return { beginDeposit };
4138
+ }
4139
+ export {
4140
+ AddressCopiedToast,
4141
+ Box,
4142
+ FunkitProvider,
4143
+ FunkitThemeProvider,
4144
+ Text,
4145
+ darkTokens,
4146
+ defaultDarkTheme,
4147
+ defaultLightTheme,
4148
+ fontFamilyForWeight,
4149
+ lightTokens,
4150
+ normalizeColorScheme,
4151
+ resolveColorScheme,
4152
+ toRestyleTheme,
4153
+ useColorScheme,
4154
+ useFunkitCheckout,
4155
+ useFunkitColorScheme,
4156
+ useFunkitTheme
4157
+ };
4158
+ //# sourceMappingURL=index.js.map