@agg-market/ui 11.0.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +1 -0
  2. package/dist/{chunk-HMUMJUIL.mjs → chunk-3ST2TN6E.mjs} +613 -312
  3. package/dist/{chunk-IUJXJEDQ.mjs → chunk-B56YA2YQ.mjs} +872 -650
  4. package/dist/chunk-CHVTY3OB.mjs +3140 -0
  5. package/dist/{chunk-2KGE5AJQ.mjs → chunk-GQ4P3AHJ.mjs} +66 -131
  6. package/dist/{chunk-UONHGMFI.mjs → chunk-T4WFRR6D.mjs} +23 -45
  7. package/dist/events.js +1013 -924
  8. package/dist/events.mjs +2 -2
  9. package/dist/index.js +3653 -2943
  10. package/dist/index.mjs +14 -7
  11. package/dist/modals.js +2578 -2190
  12. package/dist/modals.mjs +2 -2
  13. package/dist/pages.js +2192 -1763
  14. package/dist/pages.mjs +4 -4
  15. package/dist/primitives.js +860 -628
  16. package/dist/primitives.mjs +9 -1
  17. package/dist/styles.css +2 -2
  18. package/dist/tailwind.css +2 -2
  19. package/dist/trading.js +823 -673
  20. package/dist/trading.mjs +2 -2
  21. package/dist/types/deposit/deposit-modal.constants.d.mts +0 -4
  22. package/dist/types/deposit/deposit-modal.constants.d.ts +0 -4
  23. package/dist/types/deposit/deposit-modal.types.d.mts +110 -14
  24. package/dist/types/deposit/deposit-modal.types.d.ts +110 -14
  25. package/dist/types/deposit/index.d.mts +1 -1
  26. package/dist/types/deposit/index.d.ts +1 -1
  27. package/dist/types/deposit/steps/card-deposit.d.mts +13 -3
  28. package/dist/types/deposit/steps/card-deposit.d.ts +13 -3
  29. package/dist/types/deposit/steps/card-provider.d.mts +10 -0
  30. package/dist/types/deposit/steps/card-provider.d.ts +10 -0
  31. package/dist/types/deposit/steps/card-purchase-success.d.mts +7 -0
  32. package/dist/types/deposit/steps/card-purchase-success.d.ts +7 -0
  33. package/dist/types/deposit/steps/crypto-transfer.d.mts +13 -3
  34. package/dist/types/deposit/steps/crypto-transfer.d.ts +13 -3
  35. package/dist/types/deposit/steps/deposit-method.d.mts +6 -4
  36. package/dist/types/deposit/steps/deposit-method.d.ts +6 -4
  37. package/dist/types/deposit/steps/wallet-form.d.mts +20 -0
  38. package/dist/types/deposit/steps/wallet-form.d.ts +20 -0
  39. package/dist/types/deposit/steps/wallet-processing.d.mts +6 -0
  40. package/dist/types/deposit/steps/wallet-processing.d.ts +6 -0
  41. package/dist/types/deposit/steps/wallet-success.d.mts +7 -0
  42. package/dist/types/deposit/steps/wallet-success.d.ts +7 -0
  43. package/dist/types/pages/home/index.d.mts +1 -1
  44. package/dist/types/pages/home/index.d.ts +1 -1
  45. package/dist/types/pages/user-profile/components/available-balance-card.d.mts +17 -0
  46. package/dist/types/pages/user-profile/components/available-balance-card.d.ts +17 -0
  47. package/dist/types/pages/user-profile/components/balance-display.d.mts +3 -5
  48. package/dist/types/pages/user-profile/components/balance-display.d.ts +3 -5
  49. package/dist/types/pages/user-profile/components/positions-activity.d.mts +11 -1
  50. package/dist/types/pages/user-profile/components/positions-activity.d.ts +11 -1
  51. package/dist/types/pages/user-profile/components/positions-value-card.d.mts +10 -0
  52. package/dist/types/pages/user-profile/components/positions-value-card.d.ts +10 -0
  53. package/dist/types/pages/user-profile/components/user-info-card.d.mts +3 -1
  54. package/dist/types/pages/user-profile/components/user-info-card.d.ts +3 -1
  55. package/dist/types/pages/user-profile/index.d.mts +2 -2
  56. package/dist/types/pages/user-profile/index.d.ts +2 -2
  57. package/dist/types/pages/user-profile/user-profile.constants.d.mts +1 -2
  58. package/dist/types/pages/user-profile/user-profile.constants.d.ts +1 -2
  59. package/dist/types/pages/user-profile/user-profile.types.d.mts +29 -16
  60. package/dist/types/pages/user-profile/user-profile.types.d.ts +29 -16
  61. package/dist/types/primitives/icon/index.d.mts +4 -1
  62. package/dist/types/primitives/icon/index.d.ts +4 -1
  63. package/dist/types/primitives/icon/registry.d.mts +12 -0
  64. package/dist/types/primitives/icon/registry.d.ts +12 -0
  65. package/dist/types/primitives/icon/svg/bnb.d.mts +5 -0
  66. package/dist/types/primitives/icon/svg/bnb.d.ts +5 -0
  67. package/dist/types/primitives/icon/svg/polygon.d.mts +5 -0
  68. package/dist/types/primitives/icon/svg/polygon.d.ts +5 -0
  69. package/dist/types/primitives/icon/svg/success-check.d.mts +5 -0
  70. package/dist/types/primitives/icon/svg/success-check.d.ts +5 -0
  71. package/dist/types/primitives/index.d.mts +1 -0
  72. package/dist/types/primitives/index.d.ts +1 -0
  73. package/dist/types/primitives/skeleton/skeleton.types.d.mts +2 -0
  74. package/dist/types/primitives/skeleton/skeleton.types.d.ts +2 -0
  75. package/dist/types/primitives/skeleton/views/user-profile-overview-skeleton-view.d.mts +5 -0
  76. package/dist/types/primitives/skeleton/views/user-profile-overview-skeleton-view.d.ts +5 -0
  77. package/dist/types/primitives/skeleton/views/user-profile-positions-activity-skeleton-view.d.mts +5 -0
  78. package/dist/types/primitives/skeleton/views/user-profile-positions-activity-skeleton-view.d.ts +5 -0
  79. package/dist/types/primitives/tooltip/index.d.mts +6 -0
  80. package/dist/types/primitives/tooltip/index.d.ts +6 -0
  81. package/dist/types/primitives/tooltip/tooltip.constants.d.mts +2 -0
  82. package/dist/types/primitives/tooltip/tooltip.constants.d.ts +2 -0
  83. package/dist/types/primitives/tooltip/tooltip.types.d.mts +27 -0
  84. package/dist/types/primitives/tooltip/tooltip.types.d.ts +27 -0
  85. package/dist/types/profile/tabs/about-tab.d.mts +1 -1
  86. package/dist/types/profile/tabs/about-tab.d.ts +1 -1
  87. package/dist/types/profile/tabs/accounts-wallets-tab.d.mts +1 -1
  88. package/dist/types/profile/tabs/accounts-wallets-tab.d.ts +1 -1
  89. package/dist/types/withdraw/index.d.mts +2 -2
  90. package/dist/types/withdraw/index.d.ts +2 -2
  91. package/dist/types/withdraw/steps/withdraw-amount.d.mts +14 -5
  92. package/dist/types/withdraw/steps/withdraw-amount.d.ts +14 -5
  93. package/dist/types/withdraw/steps/withdraw-method.d.mts +3 -4
  94. package/dist/types/withdraw/steps/withdraw-method.d.ts +3 -4
  95. package/dist/types/withdraw/steps/withdraw-provider.d.mts +10 -0
  96. package/dist/types/withdraw/steps/withdraw-provider.d.ts +10 -0
  97. package/dist/types/withdraw/steps/withdraw-success.d.mts +7 -0
  98. package/dist/types/withdraw/steps/withdraw-success.d.ts +7 -0
  99. package/dist/types/withdraw/withdraw-modal.constants.d.mts +0 -4
  100. package/dist/types/withdraw/withdraw-modal.constants.d.ts +0 -4
  101. package/dist/types/withdraw/withdraw-modal.types.d.mts +47 -23
  102. package/dist/types/withdraw/withdraw-modal.types.d.ts +47 -23
  103. package/package.json +3 -2
  104. package/dist/chunk-5FSWOXEG.mjs +0 -2857
  105. package/dist/types/deposit/steps/kalshi-deposit.d.mts +0 -5
  106. package/dist/types/deposit/steps/kalshi-deposit.d.ts +0 -5
  107. package/dist/types/withdraw/steps/kalshi-withdraw.d.mts +0 -5
  108. package/dist/types/withdraw/steps/kalshi-withdraw.d.ts +0 -5
  109. package/dist/types/withdraw/steps/venue-selection.d.mts +0 -6
  110. package/dist/types/withdraw/steps/venue-selection.d.ts +0 -6
@@ -0,0 +1,3140 @@
1
+ import {
2
+ Badge,
3
+ BestPricesIcon,
4
+ BoltIcon,
5
+ Button,
6
+ CheckCircleIcon,
7
+ ChevronLeftIcon,
8
+ ChevronRightIcon,
9
+ CloseIcon,
10
+ CopyIcon,
11
+ CreateAccountIcon,
12
+ CreditCardIcon,
13
+ DocumentIcon,
14
+ Icon,
15
+ InlineAlert,
16
+ LinkAccountsIcon,
17
+ LoadingIcon,
18
+ Modal,
19
+ PlaySquareIcon,
20
+ ProfileIcon,
21
+ RemoteImage,
22
+ Select,
23
+ StateMessage,
24
+ StayInControlIcon,
25
+ SuccessCheckIcon,
26
+ VenueLogo,
27
+ WalletIcon,
28
+ WarningIcon,
29
+ __async,
30
+ __spreadProps,
31
+ __spreadValues,
32
+ cn,
33
+ formatAmountDisplay,
34
+ formatCompactUsd,
35
+ venueLogoLabels
36
+ } from "./chunk-B56YA2YQ.mjs";
37
+
38
+ // src/deposit/index.tsx
39
+ import { useState as useState3 } from "react";
40
+
41
+ // src/deposit/steps/deposit-method.tsx
42
+ import { useLabels } from "@agg-market/hooks";
43
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
44
+ var DepositMethodCard = ({
45
+ icon,
46
+ title,
47
+ description,
48
+ value,
49
+ highlighted = false,
50
+ onContinue
51
+ }) => /* @__PURE__ */ jsxs(
52
+ "div",
53
+ {
54
+ className: cn(
55
+ "flex items-center gap-3 sm:gap-4",
56
+ "rounded-xl border border-agg-separator",
57
+ "p-3 sm:p-4",
58
+ "transition-colors cursor-pointer hover:bg-agg-secondary-hover",
59
+ highlighted ? "" : ""
60
+ ),
61
+ role: "button",
62
+ tabIndex: 0,
63
+ onClick: onContinue,
64
+ onKeyDown: (e) => {
65
+ if (e.key === "Enter" || e.key === " ") {
66
+ e.preventDefault();
67
+ onContinue();
68
+ }
69
+ },
70
+ children: [
71
+ /* @__PURE__ */ jsx("div", { className: "shrink-0 flex items-center justify-center h-10 w-10 rounded-lg bg-agg-secondary-hover", children: icon }),
72
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
73
+ /* @__PURE__ */ jsx("p", { className: "agg-type-body-strong text-agg-foreground", children: title }),
74
+ /* @__PURE__ */ jsx("p", { className: "agg-type-label text-agg-muted-foreground", children: description })
75
+ ] }),
76
+ value ? /* @__PURE__ */ jsx("p", { className: "agg-type-label text-agg-muted-foreground", children: value }) : null,
77
+ /* @__PURE__ */ jsx("div", { className: "shrink-0 text-agg-muted-foreground", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-5 w-5" }) })
78
+ ]
79
+ }
80
+ );
81
+ var DepositMethodStep = ({
82
+ balance,
83
+ walletLabel,
84
+ walletBalance,
85
+ highlightedMethod,
86
+ onSelectMethod
87
+ }) => {
88
+ const labels = useLabels();
89
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
90
+ /* @__PURE__ */ jsx(Modal.Header, { title: labels.deposit.title, hideBorder: true }),
91
+ /* @__PURE__ */ jsx(Modal.Body, { classNames: { root: "px-5 pt-0 pb-6 sm:px-8 sm:pt-0 sm:pb-8" }, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-5", children: [
92
+ /* @__PURE__ */ jsxs("p", { className: "agg-type-body text-agg-foreground", children: [
93
+ labels.deposit.balancePrefix,
94
+ " ",
95
+ formatCompactUsd(balance)
96
+ ] }),
97
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
98
+ /* @__PURE__ */ jsx(
99
+ DepositMethodCard,
100
+ {
101
+ icon: /* @__PURE__ */ jsx(WalletIcon, { className: "h-6 w-6 text-agg-muted-foreground" }),
102
+ title: labels.deposit.methods.walletTitle(walletLabel),
103
+ description: labels.deposit.methods.walletDescription,
104
+ value: formatCompactUsd(walletBalance),
105
+ highlighted: highlightedMethod === "wallet",
106
+ onContinue: () => onSelectMethod("wallet")
107
+ }
108
+ ),
109
+ /* @__PURE__ */ jsx(
110
+ DepositMethodCard,
111
+ {
112
+ icon: /* @__PURE__ */ jsx(BoltIcon, { className: "h-6 w-6 text-agg-muted-foreground" }),
113
+ title: labels.deposit.methods.cryptoTitle,
114
+ description: labels.deposit.methods.cryptoDescription,
115
+ highlighted: highlightedMethod === "crypto",
116
+ onContinue: () => onSelectMethod("crypto")
117
+ }
118
+ ),
119
+ /* @__PURE__ */ jsx(
120
+ DepositMethodCard,
121
+ {
122
+ icon: /* @__PURE__ */ jsx(CreditCardIcon, { className: "h-6 w-6 text-agg-muted-foreground" }),
123
+ title: labels.deposit.methods.cardTitle,
124
+ description: labels.deposit.methods.cardDescription,
125
+ highlighted: highlightedMethod === "card",
126
+ onContinue: () => onSelectMethod("card")
127
+ }
128
+ )
129
+ ] })
130
+ ] }) })
131
+ ] });
132
+ };
133
+
134
+ // src/deposit/steps/card-deposit.tsx
135
+ import { useLabels as useLabels2 } from "@agg-market/hooks";
136
+ import { useEffect, useState } from "react";
137
+ import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
138
+ var CardDepositStep = ({
139
+ amount,
140
+ currency,
141
+ destinationWallet,
142
+ tokenOptions,
143
+ networkOptions,
144
+ selectedToken,
145
+ selectedNetwork,
146
+ onBack,
147
+ onAmountChange,
148
+ onCurrencyChange,
149
+ onTokenChange,
150
+ onNetworkChange,
151
+ onContinue
152
+ }) => {
153
+ const labels = useLabels2();
154
+ const [localAmount, setLocalAmount] = useState(amount);
155
+ useEffect(() => {
156
+ setLocalAmount(amount);
157
+ }, [amount]);
158
+ const numericAmount = Number(localAmount) || 0;
159
+ const isValid = numericAmount > 0;
160
+ return /* @__PURE__ */ jsxs2(Fragment2, { children: [
161
+ /* @__PURE__ */ jsx2(
162
+ Modal.Header,
163
+ {
164
+ title: labels.deposit.cardFlow.title,
165
+ hideBorder: true,
166
+ leftElement: /* @__PURE__ */ jsx2(
167
+ "button",
168
+ {
169
+ type: "button",
170
+ className: "mr-2 flex items-center justify-center text-agg-foreground transition-colors hover:cursor-pointer hover:text-agg-foreground/80",
171
+ onClick: onBack,
172
+ "aria-label": "Go back",
173
+ children: /* @__PURE__ */ jsx2(ChevronLeftIcon, { className: "h-6 w-6" })
174
+ }
175
+ )
176
+ }
177
+ ),
178
+ /* @__PURE__ */ jsx2(Modal.Body, { classNames: { root: "px-5 pt-0 pb-6 sm:px-8 sm:pt-0 sm:pb-8" }, children: /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-5", children: [
179
+ /* @__PURE__ */ jsxs2("div", { className: "flex gap-3 items-end", children: [
180
+ /* @__PURE__ */ jsxs2("div", { className: "flex-1 flex flex-col gap-2", children: [
181
+ /* @__PURE__ */ jsx2("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.deposit.cardFlow.amountLabel }),
182
+ /* @__PURE__ */ jsxs2("div", { className: "flex h-10 items-center gap-2 rounded border border-agg-separator bg-agg-secondary px-3", children: [
183
+ /* @__PURE__ */ jsx2(
184
+ "input",
185
+ {
186
+ type: "text",
187
+ inputMode: "decimal",
188
+ "aria-label": labels.deposit.cardFlow.amountLabel,
189
+ className: cn(
190
+ "agg-type-body w-full bg-transparent outline-none",
191
+ isValid ? "text-agg-foreground" : "text-agg-muted-foreground"
192
+ ),
193
+ placeholder: "0.00",
194
+ value: localAmount,
195
+ onChange: (event) => {
196
+ const next = event.target.value;
197
+ setLocalAmount(next);
198
+ onAmountChange(next);
199
+ }
200
+ }
201
+ ),
202
+ /* @__PURE__ */ jsx2("span", { className: "agg-type-body text-agg-muted-foreground", children: "$" })
203
+ ] })
204
+ ] }),
205
+ /* @__PURE__ */ jsx2("div", { className: "w-[100px]", children: /* @__PURE__ */ jsx2(
206
+ Select,
207
+ {
208
+ items: [{ value: currency, label: currency }],
209
+ value: currency,
210
+ onChange: onCurrencyChange,
211
+ ariaLabel: labels.deposit.cardFlow.currencyLabel
212
+ }
213
+ ) })
214
+ ] }),
215
+ /* @__PURE__ */ jsxs2("div", { className: "flex gap-5", children: [
216
+ /* @__PURE__ */ jsxs2("div", { className: "flex-1 flex flex-col gap-2 min-w-0", children: [
217
+ /* @__PURE__ */ jsx2("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.deposit.cardFlow.tokenLabel }),
218
+ /* @__PURE__ */ jsx2(
219
+ Select,
220
+ {
221
+ items: tokenOptions,
222
+ value: selectedToken,
223
+ onChange: onTokenChange,
224
+ ariaLabel: labels.deposit.cardFlow.tokenLabel
225
+ }
226
+ )
227
+ ] }),
228
+ /* @__PURE__ */ jsxs2("div", { className: "flex-1 flex flex-col gap-2 min-w-0", children: [
229
+ /* @__PURE__ */ jsx2("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.deposit.cardFlow.networkLabel }),
230
+ /* @__PURE__ */ jsx2(
231
+ Select,
232
+ {
233
+ items: networkOptions,
234
+ value: selectedNetwork,
235
+ onChange: onNetworkChange,
236
+ ariaLabel: labels.deposit.cardFlow.networkLabel
237
+ }
238
+ )
239
+ ] })
240
+ ] }),
241
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-2", children: [
242
+ /* @__PURE__ */ jsx2("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.deposit.cardFlow.destinationWalletLabel }),
243
+ /* @__PURE__ */ jsx2("div", { className: "flex h-10 items-center rounded border border-agg-separator bg-agg-secondary px-3", children: /* @__PURE__ */ jsx2("p", { className: "agg-type-body truncate text-agg-foreground", children: destinationWallet }) })
244
+ ] }),
245
+ /* @__PURE__ */ jsx2(
246
+ Button,
247
+ {
248
+ variant: isValid ? "primary" : "secondary",
249
+ size: "large",
250
+ className: "w-full",
251
+ disabled: !isValid,
252
+ onClick: () => onContinue(numericAmount),
253
+ children: labels.deposit.cardFlow.getQuotes
254
+ }
255
+ )
256
+ ] }) })
257
+ ] });
258
+ };
259
+
260
+ // src/deposit/steps/crypto-transfer.tsx
261
+ import { useLabels as useLabels3 } from "@agg-market/hooks";
262
+ import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
263
+ var CryptoTransferStep = ({
264
+ tokenOptions,
265
+ networkOptions,
266
+ selectedToken,
267
+ selectedNetwork,
268
+ depositAddress,
269
+ minDeposit,
270
+ feeEstimate,
271
+ eta,
272
+ onBack,
273
+ onTokenChange,
274
+ onNetworkChange,
275
+ onCopyAddress,
276
+ onDone
277
+ }) => {
278
+ const labels = useLabels3();
279
+ return /* @__PURE__ */ jsxs3(Fragment3, { children: [
280
+ /* @__PURE__ */ jsx3(
281
+ Modal.Header,
282
+ {
283
+ title: labels.deposit.sendCrypto.title,
284
+ hideBorder: true,
285
+ leftElement: /* @__PURE__ */ jsx3(
286
+ "button",
287
+ {
288
+ type: "button",
289
+ className: "mr-2 flex items-center justify-center text-agg-foreground transition-colors hover:cursor-pointer hover:text-agg-foreground/80",
290
+ onClick: onBack,
291
+ "aria-label": "Go back",
292
+ children: /* @__PURE__ */ jsx3(ChevronLeftIcon, { className: "h-6 w-6" })
293
+ }
294
+ )
295
+ }
296
+ ),
297
+ /* @__PURE__ */ jsx3(Modal.Body, { classNames: { root: "px-5 pt-0 pb-6 sm:px-8 sm:pt-0 sm:pb-8" }, children: /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-7", children: [
298
+ /* @__PURE__ */ jsx3("div", { className: "flex flex-col gap-5", children: /* @__PURE__ */ jsxs3("div", { className: "flex gap-5", children: [
299
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-1 flex-col gap-2 min-w-0", children: [
300
+ /* @__PURE__ */ jsx3("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.deposit.sendCrypto.tokenLabel }),
301
+ /* @__PURE__ */ jsx3(
302
+ Select,
303
+ {
304
+ items: tokenOptions,
305
+ value: selectedToken,
306
+ onChange: onTokenChange,
307
+ ariaLabel: labels.deposit.sendCrypto.tokenLabel
308
+ }
309
+ )
310
+ ] }),
311
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-1 flex-col gap-2 min-w-0", children: [
312
+ /* @__PURE__ */ jsx3("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.deposit.sendCrypto.networkLabel }),
313
+ /* @__PURE__ */ jsx3(
314
+ Select,
315
+ {
316
+ items: networkOptions,
317
+ value: selectedNetwork,
318
+ onChange: onNetworkChange,
319
+ ariaLabel: labels.deposit.sendCrypto.networkLabel
320
+ }
321
+ )
322
+ ] })
323
+ ] }) }),
324
+ /* @__PURE__ */ jsx3("div", { className: "mx-auto flex h-[160px] w-[160px] items-center justify-center rounded-xl border border-agg-separator bg-agg-secondary-hover", children: /* @__PURE__ */ jsx3("p", { className: "agg-type-label text-agg-muted-foreground", children: labels.deposit.sendCrypto.qrPlaceholder }) }),
325
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-3", children: [
326
+ /* @__PURE__ */ jsx3("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.deposit.sendCrypto.depositAddressLabel }),
327
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2 rounded border border-agg-separator bg-agg-secondary h-10 px-3", children: [
328
+ /* @__PURE__ */ jsx3("p", { className: "agg-type-body flex-1 min-w-0 truncate text-agg-foreground", children: depositAddress }),
329
+ /* @__PURE__ */ jsxs3(
330
+ "button",
331
+ {
332
+ type: "button",
333
+ className: "shrink-0 inline-flex items-center gap-1 text-agg-primary hover:text-agg-primary/80 transition-colors",
334
+ onClick: onCopyAddress,
335
+ children: [
336
+ /* @__PURE__ */ jsx3(CopyIcon, { className: "h-4 w-4" }),
337
+ /* @__PURE__ */ jsx3("span", { className: "agg-type-label-strong", children: labels.deposit.sendCrypto.copy })
338
+ ]
339
+ }
340
+ )
341
+ ] }),
342
+ /* @__PURE__ */ jsx3("p", { className: "agg-type-label text-agg-foreground", children: `${labels.deposit.sendCrypto.minDepositPrefix} ${minDeposit} \xB7 ${labels.deposit.walletFlow.feePrefix} ${feeEstimate} \xB7 ${eta}` })
343
+ ] }),
344
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-start gap-3 rounded-lg bg-agg-secondary-hover p-3", children: [
345
+ /* @__PURE__ */ jsx3(WarningIcon, { className: "h-4 w-4 text-agg-muted-foreground mt-0.5" }),
346
+ /* @__PURE__ */ jsx3("p", { className: "text-agg-xs leading-agg-4 text-agg-foreground", children: labels.deposit.sendCrypto.warning })
347
+ ] }),
348
+ /* @__PURE__ */ jsx3(
349
+ Button,
350
+ {
351
+ variant: "secondary",
352
+ size: "large",
353
+ className: "w-[120px] self-center",
354
+ onClick: onDone,
355
+ children: labels.deposit.done
356
+ }
357
+ )
358
+ ] }) })
359
+ ] });
360
+ };
361
+
362
+ // src/deposit/steps/wallet-form.tsx
363
+ import { useLabels as useLabels4 } from "@agg-market/hooks";
364
+ import { Fragment as Fragment4, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
365
+ var WalletFormStep = ({
366
+ walletLabel,
367
+ walletBalance,
368
+ tokenOptions,
369
+ networkOptions,
370
+ selectedToken,
371
+ selectedNetwork,
372
+ amount,
373
+ estimatedReceive,
374
+ feeEstimate,
375
+ eta,
376
+ onBack,
377
+ onTokenChange,
378
+ onNetworkChange,
379
+ onAmountChange,
380
+ onMax,
381
+ onConfirm
382
+ }) => {
383
+ const labels = useLabels4();
384
+ const isConfirmEnabled = Number(amount) > 0;
385
+ return /* @__PURE__ */ jsxs4(Fragment4, { children: [
386
+ /* @__PURE__ */ jsx4(
387
+ Modal.Header,
388
+ {
389
+ title: labels.deposit.walletFlow.title,
390
+ hideBorder: true,
391
+ leftElement: /* @__PURE__ */ jsx4(
392
+ "button",
393
+ {
394
+ type: "button",
395
+ className: "mr-2 flex items-center justify-center text-agg-foreground transition-colors hover:cursor-pointer hover:text-agg-foreground/80",
396
+ onClick: onBack,
397
+ "aria-label": "Go back",
398
+ children: /* @__PURE__ */ jsx4(ChevronLeftIcon, { className: "h-6 w-6" })
399
+ }
400
+ )
401
+ }
402
+ ),
403
+ /* @__PURE__ */ jsx4(Modal.Body, { classNames: { root: "px-5 pt-0 pb-6 sm:px-8 sm:pt-0 sm:pb-8" }, children: /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-7", children: [
404
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between", children: [
405
+ /* @__PURE__ */ jsx4("p", { className: "agg-type-label text-agg-foreground", children: walletLabel }),
406
+ /* @__PURE__ */ jsxs4("p", { className: "agg-type-label text-agg-muted-foreground", children: [
407
+ labels.deposit.balanceLabel,
408
+ " ",
409
+ formatCompactUsd(walletBalance)
410
+ ] })
411
+ ] }),
412
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-5", children: [
413
+ /* @__PURE__ */ jsxs4("div", { className: "flex gap-5", children: [
414
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-1 flex-col gap-2 min-w-0", children: [
415
+ /* @__PURE__ */ jsx4("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.deposit.walletFlow.tokenLabel }),
416
+ /* @__PURE__ */ jsx4(
417
+ Select,
418
+ {
419
+ items: tokenOptions,
420
+ value: selectedToken,
421
+ onChange: onTokenChange,
422
+ ariaLabel: labels.deposit.walletFlow.tokenLabel
423
+ }
424
+ )
425
+ ] }),
426
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-1 flex-col gap-2 min-w-0", children: [
427
+ /* @__PURE__ */ jsx4("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.deposit.walletFlow.networkLabel }),
428
+ /* @__PURE__ */ jsx4(
429
+ Select,
430
+ {
431
+ items: networkOptions,
432
+ value: selectedNetwork,
433
+ onChange: onNetworkChange,
434
+ ariaLabel: labels.deposit.walletFlow.networkLabel
435
+ }
436
+ )
437
+ ] })
438
+ ] }),
439
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-2", children: [
440
+ /* @__PURE__ */ jsx4("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.deposit.walletFlow.amountLabel }),
441
+ /* @__PURE__ */ jsxs4(
442
+ "div",
443
+ {
444
+ className: cn(
445
+ "flex items-center gap-2",
446
+ "rounded border border-agg-separator bg-agg-secondary",
447
+ "h-10 px-3"
448
+ ),
449
+ children: [
450
+ /* @__PURE__ */ jsx4(
451
+ "input",
452
+ {
453
+ type: "text",
454
+ inputMode: "decimal",
455
+ "aria-label": labels.deposit.walletFlow.amountLabel,
456
+ className: "agg-type-body w-full bg-transparent outline-none text-agg-foreground",
457
+ placeholder: "0.00",
458
+ value: amount,
459
+ onChange: (event) => onAmountChange(event.target.value)
460
+ }
461
+ ),
462
+ /* @__PURE__ */ jsx4(
463
+ "button",
464
+ {
465
+ type: "button",
466
+ className: "shrink-0 text-agg-primary transition-colors hover:text-agg-primary/80",
467
+ onClick: onMax,
468
+ "aria-label": labels.deposit.walletFlow.max,
469
+ children: labels.deposit.walletFlow.max
470
+ }
471
+ )
472
+ ]
473
+ }
474
+ )
475
+ ] }),
476
+ estimatedReceive && feeEstimate && eta ? /* @__PURE__ */ jsx4("p", { className: "agg-type-label text-agg-foreground", children: `\u2248 ${estimatedReceive} \xB7 ${labels.deposit.walletFlow.feePrefix} ${feeEstimate} \xB7 ${eta}` }) : null
477
+ ] }),
478
+ /* @__PURE__ */ jsx4(
479
+ Button,
480
+ {
481
+ variant: isConfirmEnabled ? "primary" : "secondary",
482
+ size: "large",
483
+ className: "w-full",
484
+ disabled: !isConfirmEnabled,
485
+ onClick: onConfirm,
486
+ children: labels.deposit.walletFlow.confirm
487
+ }
488
+ )
489
+ ] }) })
490
+ ] });
491
+ };
492
+
493
+ // src/deposit/steps/card-provider.tsx
494
+ import { useLabels as useLabels5 } from "@agg-market/hooks";
495
+ import { Fragment as Fragment5, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
496
+ var CardProviderItem = ({ provider, onSelect }) => {
497
+ const labels = useLabels5();
498
+ const badgeText = provider.badge === "best" ? labels.deposit.cardFlow.providerBadges.best : provider.badge === "low-kyc" ? labels.deposit.cardFlow.providerBadges.lowKyc : void 0;
499
+ return /* @__PURE__ */ jsx5(
500
+ "button",
501
+ {
502
+ type: "button",
503
+ className: "w-full rounded-xl border border-agg-separator px-4 py-3 text-left bg-agg-secondary hover:bg-agg-secondary-hover transition-colors cursor-pointer",
504
+ onClick: () => onSelect(provider.id),
505
+ children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-4", children: [
506
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
507
+ /* @__PURE__ */ jsx5("p", { className: "text-agg-base leading-agg-6 font-agg-bold text-agg-foreground", children: provider.name }),
508
+ badgeText ? /* @__PURE__ */ jsx5(
509
+ "span",
510
+ {
511
+ className: `rounded border px-2 py-[2px] text-[10px] leading-[14px] font-agg-bold uppercase ${provider.badge === "best" ? "border-agg-primary/50 text-agg-primary bg-agg-secondary" : "border-agg-separator text-agg-foreground bg-agg-secondary"}`,
512
+ children: badgeText
513
+ }
514
+ ) : null
515
+ ] }),
516
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-4", children: [
517
+ /* @__PURE__ */ jsxs5("div", { className: "text-right", children: [
518
+ /* @__PURE__ */ jsx5("p", { className: "agg-type-body text-agg-foreground", children: provider.quote }),
519
+ /* @__PURE__ */ jsxs5("p", { className: "agg-type-label text-agg-muted-foreground", children: [
520
+ labels.deposit.cardFlow.feeLabel,
521
+ " ",
522
+ provider.fee
523
+ ] })
524
+ ] }),
525
+ /* @__PURE__ */ jsx5(ChevronRightIcon, { className: "h-5 w-5 text-agg-muted-foreground" })
526
+ ] })
527
+ ] })
528
+ }
529
+ );
530
+ };
531
+ var CardProviderStep = ({
532
+ token,
533
+ amount,
534
+ currency,
535
+ providers,
536
+ onBack,
537
+ onSelectProvider
538
+ }) => {
539
+ const labels = useLabels5();
540
+ return /* @__PURE__ */ jsxs5(Fragment5, { children: [
541
+ /* @__PURE__ */ jsx5(
542
+ Modal.Header,
543
+ {
544
+ title: labels.deposit.cardFlow.selectProviderTitle,
545
+ hideBorder: true,
546
+ leftElement: /* @__PURE__ */ jsx5(
547
+ "button",
548
+ {
549
+ type: "button",
550
+ className: "mr-2 flex items-center justify-center text-agg-foreground transition-colors hover:cursor-pointer hover:text-agg-foreground/80",
551
+ onClick: onBack,
552
+ "aria-label": labels.deposit.back,
553
+ children: /* @__PURE__ */ jsx5(ChevronLeftIcon, { className: "h-6 w-6" })
554
+ }
555
+ )
556
+ }
557
+ ),
558
+ /* @__PURE__ */ jsx5(Modal.Body, { classNames: { root: "px-5 pt-0 pb-6 sm:px-8 sm:pt-0 sm:pb-8" }, children: /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-4", children: [
559
+ /* @__PURE__ */ jsxs5("p", { className: "agg-type-body text-agg-foreground", children: [
560
+ /* @__PURE__ */ jsx5("span", { className: "font-agg-bold", children: token }),
561
+ " ",
562
+ amount,
563
+ " ",
564
+ currency
565
+ ] }),
566
+ /* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-4", children: providers.map((provider) => /* @__PURE__ */ jsx5(CardProviderItem, { provider, onSelect: onSelectProvider }, provider.id)) })
567
+ ] }) })
568
+ ] });
569
+ };
570
+
571
+ // src/deposit/steps/card-purchase-success.tsx
572
+ import { useLabels as useLabels6 } from "@agg-market/hooks";
573
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
574
+ var SummaryRow = ({ label, value }) => /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between border-b border-agg-separator py-2 last:border-b-0", children: [
575
+ /* @__PURE__ */ jsx6("p", { className: "text-[12px] leading-4 font-agg-bold uppercase text-agg-muted-foreground", children: label }),
576
+ /* @__PURE__ */ jsx6("p", { className: "agg-type-label text-agg-foreground", children: value })
577
+ ] });
578
+ var CardPurchaseSuccessStep = ({
579
+ summary,
580
+ onDone,
581
+ onClose
582
+ }) => {
583
+ const labels = useLabels6();
584
+ return /* @__PURE__ */ jsx6("div", { className: "relative", children: /* @__PURE__ */ jsxs6(Modal.Body, { classNames: { root: "px-5 py-8 sm:px-8 sm:py-10" }, children: [
585
+ /* @__PURE__ */ jsx6(
586
+ "button",
587
+ {
588
+ type: "button",
589
+ className: "absolute right-8 top-7 flex items-center justify-center text-agg-foreground transition-colors hover:text-agg-foreground/80",
590
+ onClick: onClose,
591
+ "aria-label": labels.common.close,
592
+ children: /* @__PURE__ */ jsx6(CloseIcon, { className: "h-6 w-6" })
593
+ }
594
+ ),
595
+ /* @__PURE__ */ jsxs6("div", { className: "flex flex-col items-center gap-8", children: [
596
+ /* @__PURE__ */ jsx6("div", { className: "flex h-[60px] w-[60px] items-center justify-center rounded-full border border-[#18C15C80] bg-[#18C15C26]", children: /* @__PURE__ */ jsx6(SuccessCheckIcon, { className: "h-6 w-6 text-[#18C15C]" }) }),
597
+ /* @__PURE__ */ jsxs6("div", { className: "flex flex-col items-center gap-3 text-center", children: [
598
+ /* @__PURE__ */ jsx6("h3", { className: "text-agg-2xl leading-agg-8 font-agg-bold text-agg-foreground", children: labels.deposit.cardFlow.successTitle }),
599
+ /* @__PURE__ */ jsx6("p", { className: "agg-type-body text-agg-foreground", children: labels.deposit.cardFlow.successDescription })
600
+ ] }),
601
+ /* @__PURE__ */ jsxs6("div", { className: "w-full rounded-lg border border-agg-separator bg-agg-secondary px-3 py-1", children: [
602
+ /* @__PURE__ */ jsx6(
603
+ SummaryRow,
604
+ {
605
+ label: labels.deposit.summary.amountReceived,
606
+ value: summary.amountReceived
607
+ }
608
+ ),
609
+ /* @__PURE__ */ jsx6(SummaryRow, { label: labels.deposit.summary.network, value: summary.network }),
610
+ /* @__PURE__ */ jsx6(SummaryRow, { label: labels.deposit.cardFlow.summary.provider, value: summary.provider }),
611
+ /* @__PURE__ */ jsx6(SummaryRow, { label: labels.deposit.cardFlow.summary.fees, value: summary.fees })
612
+ ] }),
613
+ /* @__PURE__ */ jsx6(Button, { variant: "secondary", size: "large", className: "w-[120px]", onClick: onDone, children: labels.deposit.done })
614
+ ] })
615
+ ] }) });
616
+ };
617
+
618
+ // src/deposit/steps/wallet-processing.tsx
619
+ import { useLabels as useLabels7 } from "@agg-market/hooks";
620
+ import { useEffect as useEffect2, useMemo, useRef, useState as useState2 } from "react";
621
+ import { Fragment as Fragment6, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
622
+ var WalletProcessingStep = ({
623
+ steps,
624
+ onClose
625
+ }) => {
626
+ const labels = useLabels7();
627
+ const [progress, setProgress] = useState2(
628
+ () => steps.map((s) => __spreadValues({}, s))
629
+ );
630
+ const timeoutsRef = useRef([]);
631
+ const activeIndex = useMemo(() => progress.findIndex((s) => s.status === "active"), [progress]);
632
+ useEffect2(() => {
633
+ if (activeIndex === -1) return;
634
+ const id = window.setTimeout(() => {
635
+ setProgress((prev) => {
636
+ const next = prev.map((s) => __spreadValues({}, s));
637
+ const i = next.findIndex((s) => s.status === "active");
638
+ if (i !== -1) {
639
+ next[i].status = "complete";
640
+ if (i + 1 < next.length) {
641
+ next[i + 1].status = "active";
642
+ }
643
+ }
644
+ return next;
645
+ });
646
+ }, 500);
647
+ timeoutsRef.current.push(id);
648
+ return () => {
649
+ window.clearTimeout(id);
650
+ };
651
+ }, [activeIndex]);
652
+ useEffect2(() => {
653
+ const allDone = progress.every((s) => s.status === "complete");
654
+ if (allDone) {
655
+ onClose();
656
+ }
657
+ }, [progress, onClose]);
658
+ useEffect2(() => {
659
+ return () => {
660
+ timeoutsRef.current.forEach((id) => window.clearTimeout(id));
661
+ timeoutsRef.current = [];
662
+ };
663
+ }, []);
664
+ return /* @__PURE__ */ jsxs7(Fragment6, { children: [
665
+ /* @__PURE__ */ jsx7(Modal.Header, { title: labels.deposit.processingTitle, hideBorder: true }),
666
+ /* @__PURE__ */ jsx7(Modal.Body, { classNames: { root: "px-5 pt-0 pb-6 sm:px-8 sm:pt-0 sm:pb-8" }, children: /* @__PURE__ */ jsx7("div", { className: "flex flex-col gap-5", children: progress.map((step) => {
667
+ const isComplete = step.status === "complete";
668
+ const isActive = step.status === "active";
669
+ return /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-3", children: [
670
+ isComplete ? /* @__PURE__ */ jsx7(CheckCircleIcon, { className: "h-4 w-4 text-agg-primary" }) : /* @__PURE__ */ jsx7(
671
+ "span",
672
+ {
673
+ className: [
674
+ "inline-block h-4 w-4 rounded-full border",
675
+ isActive ? "border-2 border-agg-primary border-r-transparent animate-spin" : "",
676
+ !isActive ? "border-agg-separator" : ""
677
+ ].join(" ")
678
+ }
679
+ ),
680
+ /* @__PURE__ */ jsx7(
681
+ "p",
682
+ {
683
+ className: isComplete || isActive ? "agg-type-body text-agg-foreground" : "agg-type-body text-agg-muted-foreground",
684
+ children: step.label
685
+ }
686
+ )
687
+ ] }, step.id);
688
+ }) }) })
689
+ ] });
690
+ };
691
+
692
+ // src/deposit/steps/wallet-success.tsx
693
+ import { useLabels as useLabels8 } from "@agg-market/hooks";
694
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
695
+ var SummaryRow2 = ({ label, value }) => /* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between border-b border-agg-separator py-2 last:border-b-0", children: [
696
+ /* @__PURE__ */ jsx8("p", { className: "text-[12px] leading-4 font-agg-bold uppercase text-agg-muted-foreground", children: label }),
697
+ /* @__PURE__ */ jsx8("p", { className: "agg-type-label text-agg-foreground", children: value })
698
+ ] });
699
+ var WalletSuccessStep = ({
700
+ summary,
701
+ onDone,
702
+ onClose
703
+ }) => {
704
+ const labels = useLabels8();
705
+ return /* @__PURE__ */ jsx8("div", { className: "relative", children: /* @__PURE__ */ jsxs8(Modal.Body, { classNames: { root: "px-5 py-8 sm:px-8 sm:py-10" }, children: [
706
+ /* @__PURE__ */ jsx8(
707
+ "button",
708
+ {
709
+ type: "button",
710
+ className: "absolute right-8 top-7 flex items-center justify-center text-agg-foreground transition-colors hover:text-agg-foreground/80",
711
+ onClick: onClose,
712
+ "aria-label": labels.common.close,
713
+ children: /* @__PURE__ */ jsx8(CloseIcon, { className: "h-6 w-6" })
714
+ }
715
+ ),
716
+ /* @__PURE__ */ jsxs8("div", { className: "flex flex-col items-center gap-8", children: [
717
+ /* @__PURE__ */ jsx8("div", { className: "flex h-[60px] w-[60px] items-center justify-center rounded-full border border-[#18C15C80] bg-[#18C15C26]", children: /* @__PURE__ */ jsx8(SuccessCheckIcon, { className: "h-6 w-6 text-[#18C15C]" }) }),
718
+ /* @__PURE__ */ jsxs8("div", { className: "flex flex-col items-center gap-3 text-center", children: [
719
+ /* @__PURE__ */ jsx8("h3", { className: "text-agg-2xl leading-agg-8 font-agg-bold text-agg-foreground", children: labels.deposit.successTitle }),
720
+ /* @__PURE__ */ jsx8("p", { className: "agg-type-body text-agg-foreground", children: labels.deposit.successDescription })
721
+ ] }),
722
+ /* @__PURE__ */ jsxs8("div", { className: "w-full rounded-lg border border-agg-separator bg-agg-secondary px-3 py-1", children: [
723
+ /* @__PURE__ */ jsx8(
724
+ SummaryRow2,
725
+ {
726
+ label: labels.deposit.summary.amountReceived,
727
+ value: summary.amountReceived
728
+ }
729
+ ),
730
+ /* @__PURE__ */ jsx8(SummaryRow2, { label: labels.deposit.summary.network, value: summary.network }),
731
+ /* @__PURE__ */ jsx8(SummaryRow2, { label: labels.deposit.summary.fromWallet, value: summary.fromWallet }),
732
+ /* @__PURE__ */ jsx8(SummaryRow2, { label: labels.deposit.summary.gasFee, value: summary.gasFee })
733
+ ] }),
734
+ /* @__PURE__ */ jsx8(Button, { variant: "secondary", size: "large", className: "w-[120px]", onClick: onDone, children: labels.deposit.done })
735
+ ] })
736
+ ] }) });
737
+ };
738
+
739
+ // src/deposit/index.tsx
740
+ import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
741
+ var DepositModal = ({
742
+ open,
743
+ onOpenChange,
744
+ onSelectDepositMethod,
745
+ onContinueCardDeposit,
746
+ onDoneCryptoTransfer,
747
+ walletFlow,
748
+ onWalletTokenChange,
749
+ onWalletNetworkChange,
750
+ onWalletAmountChange,
751
+ onWalletMax,
752
+ onConfirmWalletDeposit,
753
+ onDoneWalletDeposit,
754
+ sendCryptoFlow,
755
+ onSendCryptoTokenChange,
756
+ onSendCryptoNetworkChange,
757
+ onCopySendCryptoAddress,
758
+ onDoneSendCrypto,
759
+ cardFlow,
760
+ onCardAmountChange,
761
+ onCardCurrencyChange,
762
+ onCardTokenChange,
763
+ onCardNetworkChange,
764
+ onSelectCardProvider,
765
+ onDoneCardPurchase
766
+ }) => {
767
+ const [step, setStep] = useState3("method");
768
+ const [highlightedMethod, setHighlightedMethod] = useState3("wallet");
769
+ const handleBackToMethod = () => {
770
+ setStep("method");
771
+ };
772
+ const handleSelectMethod = (method) => {
773
+ setHighlightedMethod(method);
774
+ onSelectDepositMethod == null ? void 0 : onSelectDepositMethod(method);
775
+ if (method === "wallet") {
776
+ setStep("wallet-form");
777
+ return;
778
+ }
779
+ if (method === "card") {
780
+ setStep("card-deposit");
781
+ } else if (method === "crypto") {
782
+ setStep("crypto-transfer");
783
+ }
784
+ };
785
+ const handleContinueCardDeposit = (amount) => {
786
+ onContinueCardDeposit == null ? void 0 : onContinueCardDeposit(amount);
787
+ setStep("card-provider");
788
+ };
789
+ const handleDoneCryptoTransfer = () => {
790
+ onDoneCryptoTransfer == null ? void 0 : onDoneCryptoTransfer();
791
+ onDoneSendCrypto();
792
+ };
793
+ const handleOpenChange = (isOpen) => {
794
+ if (!isOpen) {
795
+ setStep("method");
796
+ setHighlightedMethod("wallet");
797
+ }
798
+ onOpenChange(isOpen);
799
+ };
800
+ return /* @__PURE__ */ jsx9(Modal, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxs9(Modal.Container, { maxWidth: "600px", "aria-label": "Deposit", children: [
801
+ step === "method" ? /* @__PURE__ */ jsx9(
802
+ DepositMethodStep,
803
+ {
804
+ balance: walletFlow.balance,
805
+ walletLabel: walletFlow.walletLabel,
806
+ walletBalance: walletFlow.walletBalance,
807
+ highlightedMethod,
808
+ onSelectMethod: handleSelectMethod
809
+ }
810
+ ) : null,
811
+ step === "wallet-form" ? /* @__PURE__ */ jsx9(
812
+ WalletFormStep,
813
+ {
814
+ walletLabel: walletFlow.walletLabel,
815
+ walletBalance: walletFlow.walletBalance,
816
+ tokenOptions: walletFlow.tokenOptions,
817
+ networkOptions: walletFlow.networkOptions,
818
+ selectedToken: walletFlow.selectedToken,
819
+ selectedNetwork: walletFlow.selectedNetwork,
820
+ amount: walletFlow.amount,
821
+ estimatedReceive: walletFlow.estimatedReceive,
822
+ feeEstimate: walletFlow.feeEstimate,
823
+ eta: walletFlow.eta,
824
+ onBack: handleBackToMethod,
825
+ onTokenChange: onWalletTokenChange,
826
+ onNetworkChange: onWalletNetworkChange,
827
+ onAmountChange: onWalletAmountChange,
828
+ onMax: onWalletMax,
829
+ onConfirm: () => {
830
+ onConfirmWalletDeposit();
831
+ setStep("wallet-processing");
832
+ }
833
+ }
834
+ ) : null,
835
+ step === "wallet-processing" ? /* @__PURE__ */ jsx9(
836
+ WalletProcessingStep,
837
+ {
838
+ steps: walletFlow.processingSteps,
839
+ onClose: () => setStep("wallet-success")
840
+ }
841
+ ) : null,
842
+ step === "wallet-success" ? /* @__PURE__ */ jsx9(
843
+ WalletSuccessStep,
844
+ {
845
+ summary: walletFlow.successSummary,
846
+ onDone: onDoneWalletDeposit,
847
+ onClose: () => onOpenChange(false)
848
+ }
849
+ ) : null,
850
+ step === "card-deposit" ? /* @__PURE__ */ jsx9(
851
+ CardDepositStep,
852
+ {
853
+ amount: cardFlow.amount,
854
+ currency: cardFlow.currency,
855
+ destinationWallet: cardFlow.destinationWallet,
856
+ tokenOptions: cardFlow.tokenOptions,
857
+ networkOptions: cardFlow.networkOptions,
858
+ selectedToken: cardFlow.selectedToken,
859
+ selectedNetwork: cardFlow.selectedNetwork,
860
+ onBack: handleBackToMethod,
861
+ onAmountChange: onCardAmountChange,
862
+ onCurrencyChange: onCardCurrencyChange,
863
+ onTokenChange: onCardTokenChange,
864
+ onNetworkChange: onCardNetworkChange,
865
+ onContinue: handleContinueCardDeposit
866
+ }
867
+ ) : null,
868
+ step === "card-provider" ? /* @__PURE__ */ jsx9(
869
+ CardProviderStep,
870
+ {
871
+ amount: cardFlow.amount,
872
+ currency: cardFlow.currency,
873
+ token: cardFlow.selectedToken,
874
+ providers: cardFlow.providers,
875
+ onBack: () => setStep("card-deposit"),
876
+ onSelectProvider: (providerId) => {
877
+ onSelectCardProvider(providerId);
878
+ setStep("card-success");
879
+ }
880
+ }
881
+ ) : null,
882
+ step === "card-success" ? /* @__PURE__ */ jsx9(
883
+ CardPurchaseSuccessStep,
884
+ {
885
+ summary: cardFlow.purchaseSummary,
886
+ onClose: () => onOpenChange(false),
887
+ onDone: onDoneCardPurchase
888
+ }
889
+ ) : null,
890
+ step === "crypto-transfer" ? /* @__PURE__ */ jsx9(
891
+ CryptoTransferStep,
892
+ {
893
+ tokenOptions: sendCryptoFlow.tokenOptions,
894
+ networkOptions: sendCryptoFlow.networkOptions,
895
+ selectedToken: sendCryptoFlow.selectedToken,
896
+ selectedNetwork: sendCryptoFlow.selectedNetwork,
897
+ depositAddress: sendCryptoFlow.depositAddress,
898
+ minDeposit: sendCryptoFlow.minDeposit,
899
+ feeEstimate: sendCryptoFlow.feeEstimate,
900
+ eta: sendCryptoFlow.eta,
901
+ onBack: handleBackToMethod,
902
+ onTokenChange: onSendCryptoTokenChange,
903
+ onNetworkChange: onSendCryptoNetworkChange,
904
+ onCopyAddress: onCopySendCryptoAddress,
905
+ onDone: handleDoneCryptoTransfer
906
+ }
907
+ ) : null
908
+ ] }) });
909
+ };
910
+ DepositModal.displayName = "DepositModal";
911
+
912
+ // src/onramp/index.tsx
913
+ import { useCallback as useCallback2, useState as useState4 } from "react";
914
+
915
+ // src/onramp/steps/quote-form.tsx
916
+ import { useCallback } from "react";
917
+
918
+ // src/onramp/onramp-modal.constants.ts
919
+ var FIAT_OPTIONS = [
920
+ { value: "USD", label: "USD" },
921
+ { value: "EUR", label: "EUR" },
922
+ { value: "GBP", label: "GBP" }
923
+ ];
924
+ var FIAT_SYMBOLS = {
925
+ USD: "$",
926
+ EUR: "\u20AC",
927
+ GBP: "\xA3"
928
+ };
929
+ var CRYPTO_OPTIONS = [
930
+ { value: "USDC", label: "USDC (Ethereum)" },
931
+ { value: "USDC_BASE", label: "USDC (Base)" },
932
+ { value: "USDC_SOLANA", label: "USDC (Solana)" },
933
+ { value: "USDC_POLYGON", label: "USDC (Polygon)" },
934
+ { value: "USDC_ARBITRUM", label: "USDC (Arbitrum)" }
935
+ ];
936
+
937
+ // src/onramp/steps/quote-form.tsx
938
+ import { Fragment as Fragment7, jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
939
+ var QuoteFormStep = ({
940
+ title,
941
+ values,
942
+ onAmountChange,
943
+ onFiatChange,
944
+ onCryptoChange,
945
+ onWalletAddressChange,
946
+ onSubmit
947
+ }) => {
948
+ var _a;
949
+ const numericAmount = Number(values.amount) || 0;
950
+ const isFormValid = numericAmount > 0 && values.walletAddress.length > 0;
951
+ const handleAmountChange = useCallback(
952
+ (e) => {
953
+ const v = e.target.value.replace(/[^0-9.]/g, "");
954
+ const parts = v.split(".");
955
+ onAmountChange(parts.length > 2 ? `${parts[0]}.${parts.slice(1).join("")}` : v);
956
+ },
957
+ [onAmountChange]
958
+ );
959
+ return /* @__PURE__ */ jsxs10(Fragment7, { children: [
960
+ /* @__PURE__ */ jsx10(Modal.Header, { title, hideBorder: true }),
961
+ /* @__PURE__ */ jsx10(Modal.Body, { classNames: { root: "px-5 pt-0 pb-6 sm:px-8 sm:pt-0 sm:pb-8" }, children: /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-6", children: [
962
+ /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-2", children: [
963
+ /* @__PURE__ */ jsx10("p", { className: "agg-type-label text-agg-muted-foreground", children: "You pay" }),
964
+ /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-3", children: [
965
+ /* @__PURE__ */ jsx10("div", { className: "shrink-0", children: /* @__PURE__ */ jsx10(
966
+ Select,
967
+ {
968
+ items: FIAT_OPTIONS,
969
+ value: values.fiatCurrency,
970
+ onChange: onFiatChange,
971
+ ariaLabel: "Fiat currency",
972
+ className: "w-auto"
973
+ }
974
+ ) }),
975
+ /* @__PURE__ */ jsx10("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ jsxs10("div", { className: "flex items-baseline", children: [
976
+ /* @__PURE__ */ jsx10("span", { className: "agg-type-display text-agg-foreground", children: (_a = FIAT_SYMBOLS[values.fiatCurrency]) != null ? _a : "$" }),
977
+ /* @__PURE__ */ jsx10(
978
+ "input",
979
+ {
980
+ type: "text",
981
+ inputMode: "decimal",
982
+ "aria-label": "Amount",
983
+ className: cn(
984
+ "agg-type-display w-full bg-transparent outline-none",
985
+ numericAmount > 0 ? "text-agg-foreground" : "text-agg-muted-foreground"
986
+ ),
987
+ placeholder: "0",
988
+ value: values.amount ? formatAmountDisplay(values.amount) : "",
989
+ onChange: handleAmountChange
990
+ }
991
+ )
992
+ ] }) })
993
+ ] })
994
+ ] }),
995
+ /* @__PURE__ */ jsx10("div", { className: "border-t border-agg-separator" }),
996
+ /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-2", children: [
997
+ /* @__PURE__ */ jsx10("p", { className: "agg-type-label text-agg-muted-foreground", children: "You receive" }),
998
+ /* @__PURE__ */ jsx10(
999
+ Select,
1000
+ {
1001
+ items: CRYPTO_OPTIONS,
1002
+ value: values.cryptoCurrency,
1003
+ onChange: onCryptoChange,
1004
+ ariaLabel: "Cryptocurrency"
1005
+ }
1006
+ )
1007
+ ] }),
1008
+ /* @__PURE__ */ jsx10("div", { className: "border-t border-agg-separator" }),
1009
+ /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-2", children: [
1010
+ /* @__PURE__ */ jsx10("p", { className: "agg-type-label text-agg-muted-foreground", children: "Destination wallet" }),
1011
+ /* @__PURE__ */ jsx10(
1012
+ "input",
1013
+ {
1014
+ type: "text",
1015
+ "aria-label": "Wallet address",
1016
+ className: cn(
1017
+ "w-full rounded-agg-md border border-agg-separator bg-agg-secondary",
1018
+ "px-4 py-2 font-agg-sans text-agg-sm leading-agg-5 text-agg-foreground outline-none",
1019
+ "placeholder:text-agg-muted-foreground",
1020
+ "transition-[border-color,box-shadow] duration-200 ease-in-out",
1021
+ "focus:border-agg-primary focus:ring-2 focus:ring-agg-primary/15"
1022
+ ),
1023
+ placeholder: "0x...",
1024
+ value: values.walletAddress,
1025
+ onChange: (e) => onWalletAddressChange(e.target.value)
1026
+ }
1027
+ )
1028
+ ] }),
1029
+ /* @__PURE__ */ jsx10(
1030
+ Button,
1031
+ {
1032
+ variant: "primary",
1033
+ size: "large",
1034
+ className: "w-full",
1035
+ disabled: !isFormValid,
1036
+ onClick: onSubmit,
1037
+ children: "Get Quotes"
1038
+ }
1039
+ )
1040
+ ] }) })
1041
+ ] });
1042
+ };
1043
+
1044
+ // src/onramp/steps/quote-card.tsx
1045
+ import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
1046
+ var QuoteCard = ({ quote, rank, onSelect }) => {
1047
+ var _a;
1048
+ const isBest = rank === 1;
1049
+ return /* @__PURE__ */ jsxs11(
1050
+ "div",
1051
+ {
1052
+ className: cn(
1053
+ "flex items-center gap-3 sm:gap-4",
1054
+ "rounded-xl border",
1055
+ "p-3 sm:p-4",
1056
+ "transition-colors cursor-pointer",
1057
+ isBest ? "border-agg-primary bg-agg-primary/5 hover:bg-agg-primary/10" : "border-agg-separator hover:bg-agg-secondary-hover"
1058
+ ),
1059
+ role: "button",
1060
+ tabIndex: 0,
1061
+ onClick: onSelect,
1062
+ onKeyDown: (e) => {
1063
+ if (e.key === "Enter" || e.key === " ") {
1064
+ e.preventDefault();
1065
+ onSelect();
1066
+ }
1067
+ },
1068
+ children: [
1069
+ /* @__PURE__ */ jsx11(
1070
+ "div",
1071
+ {
1072
+ className: cn(
1073
+ "shrink-0 flex items-center justify-center h-10 w-10 rounded-lg",
1074
+ isBest ? "bg-agg-primary/10" : "bg-agg-secondary-hover"
1075
+ ),
1076
+ children: /* @__PURE__ */ jsx11(
1077
+ "span",
1078
+ {
1079
+ className: cn(
1080
+ "text-agg-lg font-agg-bold",
1081
+ isBest ? "text-agg-primary" : "text-agg-muted-foreground"
1082
+ ),
1083
+ children: rank
1084
+ }
1085
+ )
1086
+ }
1087
+ ),
1088
+ /* @__PURE__ */ jsxs11("div", { className: "flex-1 min-w-0", children: [
1089
+ /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2", children: [
1090
+ /* @__PURE__ */ jsx11("p", { className: "agg-type-body-strong text-agg-foreground", children: quote.serviceProvider }),
1091
+ isBest ? /* @__PURE__ */ jsx11(
1092
+ Badge,
1093
+ {
1094
+ text: "Best",
1095
+ size: "small",
1096
+ classNames: { root: "bg-agg-primary! text-white! border-agg-primary!" }
1097
+ }
1098
+ ) : null,
1099
+ quote.lowKyc ? /* @__PURE__ */ jsx11(Badge, { text: "Low KYC", size: "small" }) : null
1100
+ ] }),
1101
+ /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2 mt-0.5", children: [
1102
+ /* @__PURE__ */ jsxs11("p", { className: "agg-type-label text-agg-muted-foreground", children: [
1103
+ quote.destinationAmount.toFixed(6),
1104
+ " ",
1105
+ quote.destinationCurrencyCode.split("_")[0]
1106
+ ] }),
1107
+ /* @__PURE__ */ jsx11("span", { className: "text-agg-muted-foreground", children: "\xB7" }),
1108
+ /* @__PURE__ */ jsxs11("p", { className: "agg-type-label text-agg-muted-foreground", children: [
1109
+ "Fee ",
1110
+ (_a = FIAT_SYMBOLS[quote.sourceCurrencyCode]) != null ? _a : "",
1111
+ quote.totalFee.toFixed(2)
1112
+ ] })
1113
+ ] })
1114
+ ] }),
1115
+ /* @__PURE__ */ jsx11("div", { className: "shrink-0", children: /* @__PURE__ */ jsx11(
1116
+ Button,
1117
+ {
1118
+ variant: "secondary",
1119
+ size: "small",
1120
+ suffix: /* @__PURE__ */ jsx11(ChevronRightIcon, {}),
1121
+ onClick: (e) => {
1122
+ e.stopPropagation();
1123
+ onSelect();
1124
+ },
1125
+ children: "Select"
1126
+ }
1127
+ ) })
1128
+ ]
1129
+ }
1130
+ );
1131
+ };
1132
+
1133
+ // src/onramp/steps/quote-selection.tsx
1134
+ import { Fragment as Fragment8, jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
1135
+ var BACK_BUTTON_CLASS = "mr-2 flex items-center justify-center text-agg-foreground transition-colors hover:cursor-pointer hover:text-agg-foreground/80";
1136
+ var BackButton = ({ onClick }) => /* @__PURE__ */ jsx12("button", { type: "button", className: BACK_BUTTON_CLASS, onClick, "aria-label": "Go back", children: /* @__PURE__ */ jsx12(ChevronLeftIcon, { className: "h-6 w-6" }) });
1137
+ var QuoteSelectionStep = ({
1138
+ quotes,
1139
+ isLoading,
1140
+ error,
1141
+ fiatCurrency,
1142
+ cryptoCurrency,
1143
+ amount,
1144
+ onBack,
1145
+ onSelectQuote,
1146
+ onRetry
1147
+ }) => {
1148
+ var _a;
1149
+ const subtitle = `${cryptoCurrency.split("_")[0]} \xB7 ${(_a = FIAT_SYMBOLS[fiatCurrency]) != null ? _a : ""}${amount.toLocaleString()} ${fiatCurrency}`;
1150
+ return /* @__PURE__ */ jsxs12(Fragment8, { children: [
1151
+ /* @__PURE__ */ jsx12(
1152
+ Modal.Header,
1153
+ {
1154
+ title: "Select Provider",
1155
+ subtitle,
1156
+ hideBorder: true,
1157
+ leftElement: /* @__PURE__ */ jsx12(BackButton, { onClick: onBack })
1158
+ }
1159
+ ),
1160
+ /* @__PURE__ */ jsxs12(Modal.Body, { classNames: { root: "px-5 pt-0 pb-6 sm:px-8 sm:pt-0 sm:pb-8" }, children: [
1161
+ isLoading ? /* @__PURE__ */ jsx12("div", { className: "flex min-h-[240px] items-center justify-center", children: /* @__PURE__ */ jsx12(LoadingIcon, { size: "large" }) }) : null,
1162
+ !isLoading && error ? /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-4", children: [
1163
+ /* @__PURE__ */ jsx12(InlineAlert, { tone: "error", message: error }),
1164
+ /* @__PURE__ */ jsx12(Button, { variant: "secondary", size: "medium", className: "w-full", onClick: onRetry, children: "Retry" })
1165
+ ] }) : null,
1166
+ !isLoading && !error && quotes.length === 0 ? /* @__PURE__ */ jsx12(
1167
+ StateMessage,
1168
+ {
1169
+ tone: "empty",
1170
+ title: "No quotes available",
1171
+ description: "No providers returned quotes for this pair. Try a different amount or cryptocurrency.",
1172
+ actionLabel: "Go back",
1173
+ onAction: onBack
1174
+ }
1175
+ ) : null,
1176
+ !isLoading && quotes.length > 0 ? /* @__PURE__ */ jsx12("div", { className: "flex flex-col gap-3", children: quotes.map((quote, i) => /* @__PURE__ */ jsx12(
1177
+ QuoteCard,
1178
+ {
1179
+ quote,
1180
+ rank: i + 1,
1181
+ onSelect: () => onSelectQuote(quote)
1182
+ },
1183
+ `${quote.serviceProvider}-${quote.paymentMethodType}`
1184
+ )) }) : null
1185
+ ] })
1186
+ ] });
1187
+ };
1188
+
1189
+ // src/onramp/steps/widget.tsx
1190
+ import { useRef as useRef2 } from "react";
1191
+ import { Fragment as Fragment9, jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
1192
+ var BACK_BUTTON_CLASS2 = "mr-2 flex items-center justify-center text-agg-foreground transition-colors hover:cursor-pointer hover:text-agg-foreground/80";
1193
+ var BackButton2 = ({ onClick }) => /* @__PURE__ */ jsx13("button", { type: "button", className: BACK_BUTTON_CLASS2, onClick, "aria-label": "Go back", children: /* @__PURE__ */ jsx13(ChevronLeftIcon, { className: "h-6 w-6" }) });
1194
+ var WidgetStep = ({ widgetUrl, isLoading, onBack }) => {
1195
+ const iframeRef = useRef2(null);
1196
+ return /* @__PURE__ */ jsxs13(Fragment9, { children: [
1197
+ /* @__PURE__ */ jsx13(
1198
+ Modal.Header,
1199
+ {
1200
+ title: "Complete Purchase",
1201
+ hideBorder: true,
1202
+ leftElement: /* @__PURE__ */ jsx13(BackButton2, { onClick: onBack })
1203
+ }
1204
+ ),
1205
+ /* @__PURE__ */ jsxs13(Modal.Body, { classNames: { root: "p-0! sm:p-0! overflow-hidden" }, children: [
1206
+ isLoading ? /* @__PURE__ */ jsx13("div", { className: "flex min-h-[400px] items-center justify-center", children: /* @__PURE__ */ jsx13(LoadingIcon, { size: "large" }) }) : null,
1207
+ widgetUrl ? /* @__PURE__ */ jsx13(
1208
+ "iframe",
1209
+ {
1210
+ ref: iframeRef,
1211
+ src: widgetUrl,
1212
+ title: "Meld payment widget",
1213
+ className: "h-[700px] w-full border-0 block",
1214
+ allow: "camera; microphone; payment; encrypted-media"
1215
+ }
1216
+ ) : null
1217
+ ] })
1218
+ ] });
1219
+ };
1220
+
1221
+ // src/onramp/index.tsx
1222
+ import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
1223
+ var OnrampModal = ({
1224
+ open,
1225
+ onOpenChange,
1226
+ transactionType,
1227
+ walletAddress: initialWalletAddress = "",
1228
+ defaultFiatCurrency = "USD",
1229
+ defaultCryptoCurrency = "USDC",
1230
+ onGetQuotes,
1231
+ onSelectQuote
1232
+ }) => {
1233
+ const [step, setStep] = useState4("form");
1234
+ const [formValues, setFormValues] = useState4({
1235
+ amount: "",
1236
+ fiatCurrency: defaultFiatCurrency,
1237
+ cryptoCurrency: defaultCryptoCurrency,
1238
+ walletAddress: initialWalletAddress
1239
+ });
1240
+ const [quotes, setQuotes] = useState4([]);
1241
+ const [isLoadingQuotes, setIsLoadingQuotes] = useState4(false);
1242
+ const [quoteError, setQuoteError] = useState4(null);
1243
+ const [widgetUrl, setWidgetUrl] = useState4(null);
1244
+ const [isCreatingSession, setIsCreatingSession] = useState4(false);
1245
+ const handleOpenChange = useCallback2(
1246
+ (isOpen) => {
1247
+ if (!isOpen) {
1248
+ setStep("form");
1249
+ setQuotes([]);
1250
+ setQuoteError(null);
1251
+ setWidgetUrl(null);
1252
+ }
1253
+ onOpenChange(isOpen);
1254
+ },
1255
+ [onOpenChange]
1256
+ );
1257
+ const handleGetQuotes = useCallback2(() => __async(null, null, function* () {
1258
+ const numericAmount2 = Number(formValues.amount);
1259
+ if (!numericAmount2 || numericAmount2 <= 0) return;
1260
+ setStep("quotes");
1261
+ setIsLoadingQuotes(true);
1262
+ setQuoteError(null);
1263
+ try {
1264
+ const result = yield onGetQuotes({
1265
+ transactionType,
1266
+ sourceAmount: numericAmount2,
1267
+ sourceCurrencyCode: formValues.fiatCurrency,
1268
+ destinationCurrencyCode: formValues.cryptoCurrency,
1269
+ countryCode: "US"
1270
+ });
1271
+ setQuotes(result);
1272
+ } catch (err) {
1273
+ setQuoteError(err instanceof Error ? err.message : "Failed to fetch quotes");
1274
+ } finally {
1275
+ setIsLoadingQuotes(false);
1276
+ }
1277
+ }), [formValues, transactionType, onGetQuotes]);
1278
+ const handleSelectQuote = useCallback2(
1279
+ (quote) => __async(null, null, function* () {
1280
+ setStep("widget");
1281
+ setIsCreatingSession(true);
1282
+ try {
1283
+ const session = yield onSelectQuote({
1284
+ transactionType,
1285
+ serviceProvider: quote.serviceProvider,
1286
+ sourceAmount: quote.sourceAmount,
1287
+ sourceCurrencyCode: quote.sourceCurrencyCode,
1288
+ destinationCurrencyCode: quote.destinationCurrencyCode,
1289
+ countryCode: quote.countryCode,
1290
+ walletAddress: formValues.walletAddress
1291
+ });
1292
+ setWidgetUrl(session.serviceProviderWidgetUrl);
1293
+ } catch (e) {
1294
+ setStep("quotes");
1295
+ } finally {
1296
+ setIsCreatingSession(false);
1297
+ }
1298
+ }),
1299
+ [transactionType, formValues.walletAddress, onSelectQuote]
1300
+ );
1301
+ const numericAmount = Number(formValues.amount) || 0;
1302
+ return /* @__PURE__ */ jsx14(Modal, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxs14(
1303
+ Modal.Container,
1304
+ {
1305
+ maxWidth: "520px",
1306
+ "aria-label": transactionType === "BUY" ? "Buy Crypto" : "Sell Crypto",
1307
+ children: [
1308
+ step === "form" ? /* @__PURE__ */ jsx14(
1309
+ QuoteFormStep,
1310
+ {
1311
+ title: transactionType === "BUY" ? "Buy Crypto" : "Sell Crypto",
1312
+ values: formValues,
1313
+ onAmountChange: (amount) => setFormValues((prev) => __spreadProps(__spreadValues({}, prev), { amount })),
1314
+ onFiatChange: (fiatCurrency) => setFormValues((prev) => __spreadProps(__spreadValues({}, prev), { fiatCurrency })),
1315
+ onCryptoChange: (cryptoCurrency) => setFormValues((prev) => __spreadProps(__spreadValues({}, prev), { cryptoCurrency })),
1316
+ onWalletAddressChange: (walletAddress) => setFormValues((prev) => __spreadProps(__spreadValues({}, prev), { walletAddress })),
1317
+ onSubmit: handleGetQuotes
1318
+ }
1319
+ ) : null,
1320
+ step === "quotes" ? /* @__PURE__ */ jsx14(
1321
+ QuoteSelectionStep,
1322
+ {
1323
+ quotes,
1324
+ isLoading: isLoadingQuotes,
1325
+ error: quoteError,
1326
+ fiatCurrency: formValues.fiatCurrency,
1327
+ cryptoCurrency: formValues.cryptoCurrency,
1328
+ amount: numericAmount,
1329
+ onBack: () => setStep("form"),
1330
+ onSelectQuote: handleSelectQuote,
1331
+ onRetry: handleGetQuotes
1332
+ }
1333
+ ) : null,
1334
+ step === "widget" ? /* @__PURE__ */ jsx14(
1335
+ WidgetStep,
1336
+ {
1337
+ widgetUrl,
1338
+ isLoading: isCreatingSession,
1339
+ onBack: () => {
1340
+ setWidgetUrl(null);
1341
+ setStep("quotes");
1342
+ }
1343
+ }
1344
+ ) : null
1345
+ ]
1346
+ }
1347
+ ) });
1348
+ };
1349
+ OnrampModal.displayName = "OnrampModal";
1350
+
1351
+ // src/withdraw/index.tsx
1352
+ import { useState as useState5 } from "react";
1353
+
1354
+ // src/withdraw/steps/withdraw-method.tsx
1355
+ import { useLabels as useLabels9 } from "@agg-market/hooks";
1356
+ import { Fragment as Fragment10, jsx as jsx15, jsxs as jsxs15 } from "react/jsx-runtime";
1357
+ var WithdrawMethodCard = ({
1358
+ icon,
1359
+ title,
1360
+ description,
1361
+ onContinue
1362
+ }) => /* @__PURE__ */ jsxs15(
1363
+ "div",
1364
+ {
1365
+ className: cn(
1366
+ "flex items-center gap-3 sm:gap-4 rounded-xl border border-agg-separator bg-agg-secondary p-3 sm:p-4",
1367
+ "hover:bg-agg-secondary-hover transition-colors cursor-pointer"
1368
+ ),
1369
+ role: "button",
1370
+ tabIndex: 0,
1371
+ onClick: onContinue,
1372
+ onKeyDown: (e) => {
1373
+ if (e.key === "Enter" || e.key === " ") {
1374
+ e.preventDefault();
1375
+ onContinue();
1376
+ }
1377
+ },
1378
+ children: [
1379
+ /* @__PURE__ */ jsx15("div", { className: "shrink-0 flex items-center justify-center h-10 w-10 rounded-lg bg-agg-secondary-hover", children: icon }),
1380
+ /* @__PURE__ */ jsxs15("div", { className: "flex-1 min-w-0", children: [
1381
+ /* @__PURE__ */ jsx15("p", { className: "agg-type-body-strong text-agg-foreground", children: title }),
1382
+ /* @__PURE__ */ jsx15("p", { className: "agg-type-label text-agg-muted-foreground", children: description })
1383
+ ] }),
1384
+ /* @__PURE__ */ jsx15("div", { className: "shrink-0 text-agg-muted-foreground", children: /* @__PURE__ */ jsx15(ChevronRightIcon, { className: "h-5 w-5" }) })
1385
+ ]
1386
+ }
1387
+ );
1388
+ var WithdrawMethodStep = ({
1389
+ balance,
1390
+ onSelectMethod
1391
+ }) => {
1392
+ const labels = useLabels9();
1393
+ return /* @__PURE__ */ jsxs15(Fragment10, { children: [
1394
+ /* @__PURE__ */ jsx15(Modal.Header, { title: labels.withdraw.title, hideBorder: true }),
1395
+ /* @__PURE__ */ jsx15(Modal.Body, { classNames: { root: "px-5 pt-0 pb-6 sm:px-8 sm:pt-0 sm:pb-8" }, children: /* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-5", children: [
1396
+ /* @__PURE__ */ jsxs15("p", { className: "agg-type-body text-agg-foreground", children: [
1397
+ labels.withdraw.balancePrefix,
1398
+ " ",
1399
+ formatCompactUsd(balance)
1400
+ ] }),
1401
+ /* @__PURE__ */ jsx15(
1402
+ WithdrawMethodCard,
1403
+ {
1404
+ icon: /* @__PURE__ */ jsx15(CreditCardIcon, { className: "h-6 w-6 text-agg-muted-foreground" }),
1405
+ title: labels.withdraw.methods.cardTitle,
1406
+ description: labels.withdraw.methods.cardDescription,
1407
+ onContinue: () => onSelectMethod("card")
1408
+ }
1409
+ )
1410
+ ] }) })
1411
+ ] });
1412
+ };
1413
+
1414
+ // src/withdraw/steps/withdraw-amount.tsx
1415
+ import { useLabels as useLabels10 } from "@agg-market/hooks";
1416
+ import { Fragment as Fragment11, jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
1417
+ var WithdrawAmountStep = ({
1418
+ amount,
1419
+ currency,
1420
+ destinationWallet,
1421
+ tokenOptions,
1422
+ networkOptions,
1423
+ selectedToken,
1424
+ selectedNetwork,
1425
+ onBack,
1426
+ onAmountChange,
1427
+ onCurrencyChange,
1428
+ onTokenChange,
1429
+ onNetworkChange,
1430
+ onContinue
1431
+ }) => {
1432
+ const labels = useLabels10();
1433
+ const isValid = Number(amount) > 0;
1434
+ return /* @__PURE__ */ jsxs16(Fragment11, { children: [
1435
+ /* @__PURE__ */ jsx16(
1436
+ Modal.Header,
1437
+ {
1438
+ title: labels.withdraw.cardFlow.title,
1439
+ hideBorder: true,
1440
+ leftElement: /* @__PURE__ */ jsx16(
1441
+ "button",
1442
+ {
1443
+ type: "button",
1444
+ className: "mr-2 flex items-center justify-center text-agg-foreground transition-colors hover:cursor-pointer hover:text-agg-foreground/80",
1445
+ onClick: onBack,
1446
+ "aria-label": "Go back",
1447
+ children: /* @__PURE__ */ jsx16(ChevronLeftIcon, { className: "h-6 w-6" })
1448
+ }
1449
+ )
1450
+ }
1451
+ ),
1452
+ /* @__PURE__ */ jsx16(Modal.Body, { classNames: { root: "px-5 pt-0 pb-6 sm:px-8 sm:pt-0 sm:pb-8" }, children: /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-5", children: [
1453
+ /* @__PURE__ */ jsxs16("div", { className: "flex gap-3 items-end", children: [
1454
+ /* @__PURE__ */ jsxs16("div", { className: "flex-1 flex flex-col gap-2", children: [
1455
+ /* @__PURE__ */ jsx16("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.withdraw.cardFlow.amountLabel }),
1456
+ /* @__PURE__ */ jsxs16("div", { className: "flex h-10 items-center gap-2 rounded border border-agg-separator bg-agg-secondary px-3", children: [
1457
+ /* @__PURE__ */ jsx16(
1458
+ "input",
1459
+ {
1460
+ type: "text",
1461
+ inputMode: "decimal",
1462
+ "aria-label": labels.withdraw.cardFlow.amountLabel,
1463
+ className: cn(
1464
+ "agg-type-body w-full bg-transparent outline-none",
1465
+ isValid ? "text-agg-foreground" : "text-agg-muted-foreground"
1466
+ ),
1467
+ placeholder: "0.00",
1468
+ value: amount,
1469
+ onChange: (event) => onAmountChange(event.target.value)
1470
+ }
1471
+ ),
1472
+ /* @__PURE__ */ jsx16("span", { className: "agg-type-body text-agg-muted-foreground", children: "$" })
1473
+ ] })
1474
+ ] }),
1475
+ /* @__PURE__ */ jsx16("div", { className: "w-[100px]", children: /* @__PURE__ */ jsx16(
1476
+ Select,
1477
+ {
1478
+ items: [{ value: currency, label: currency }],
1479
+ value: currency,
1480
+ onChange: onCurrencyChange,
1481
+ ariaLabel: labels.withdraw.cardFlow.currencyLabel
1482
+ }
1483
+ ) })
1484
+ ] }),
1485
+ /* @__PURE__ */ jsxs16("div", { className: "flex gap-5", children: [
1486
+ /* @__PURE__ */ jsxs16("div", { className: "flex-1 flex flex-col gap-2 min-w-0", children: [
1487
+ /* @__PURE__ */ jsx16("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.withdraw.cardFlow.tokenLabel }),
1488
+ /* @__PURE__ */ jsx16(
1489
+ Select,
1490
+ {
1491
+ items: tokenOptions,
1492
+ value: selectedToken,
1493
+ onChange: onTokenChange,
1494
+ ariaLabel: labels.withdraw.cardFlow.tokenLabel
1495
+ }
1496
+ )
1497
+ ] }),
1498
+ /* @__PURE__ */ jsxs16("div", { className: "flex-1 flex flex-col gap-2 min-w-0", children: [
1499
+ /* @__PURE__ */ jsx16("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.withdraw.cardFlow.networkLabel }),
1500
+ /* @__PURE__ */ jsx16(
1501
+ Select,
1502
+ {
1503
+ items: networkOptions,
1504
+ value: selectedNetwork,
1505
+ onChange: onNetworkChange,
1506
+ ariaLabel: labels.withdraw.cardFlow.networkLabel
1507
+ }
1508
+ )
1509
+ ] })
1510
+ ] }),
1511
+ /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-2", children: [
1512
+ /* @__PURE__ */ jsx16("p", { className: "agg-type-label-strong text-agg-foreground", children: labels.withdraw.cardFlow.destinationWalletLabel }),
1513
+ /* @__PURE__ */ jsx16("div", { className: "flex h-10 items-center rounded border border-agg-separator bg-agg-secondary px-3", children: /* @__PURE__ */ jsx16("p", { className: "agg-type-body truncate text-agg-foreground", children: destinationWallet }) })
1514
+ ] }),
1515
+ /* @__PURE__ */ jsx16(
1516
+ Button,
1517
+ {
1518
+ variant: isValid ? "primary" : "secondary",
1519
+ size: "large",
1520
+ className: "w-full",
1521
+ disabled: !isValid,
1522
+ onClick: onContinue,
1523
+ children: labels.withdraw.cardFlow.getQuotes
1524
+ }
1525
+ )
1526
+ ] }) })
1527
+ ] });
1528
+ };
1529
+
1530
+ // src/withdraw/steps/withdraw-provider.tsx
1531
+ import { useLabels as useLabels11 } from "@agg-market/hooks";
1532
+ import { Fragment as Fragment12, jsx as jsx17, jsxs as jsxs17 } from "react/jsx-runtime";
1533
+ var WithdrawProviderItem = ({ provider, onSelect }) => {
1534
+ const labels = useLabels11();
1535
+ const badgeText = provider.badge === "best" ? labels.withdraw.cardFlow.providerBadges.best : provider.badge === "low-kyc" ? labels.withdraw.cardFlow.providerBadges.lowKyc : void 0;
1536
+ return /* @__PURE__ */ jsx17(
1537
+ "button",
1538
+ {
1539
+ type: "button",
1540
+ className: "w-full rounded-xl border border-agg-separator px-4 py-3 text-left bg-agg-secondary hover:bg-agg-secondary-hover transition-colors cursor-pointer",
1541
+ onClick: () => onSelect(provider.id),
1542
+ children: /* @__PURE__ */ jsxs17("div", { className: "flex items-center justify-between gap-4", children: [
1543
+ /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-2", children: [
1544
+ /* @__PURE__ */ jsx17("p", { className: "text-agg-base leading-agg-6 font-agg-bold text-agg-foreground", children: provider.name }),
1545
+ badgeText ? /* @__PURE__ */ jsx17(
1546
+ "span",
1547
+ {
1548
+ className: `rounded border px-2 py-[2px] text-[10px] leading-[14px] font-agg-bold uppercase ${provider.badge === "best" ? "border-agg-primary/50 text-agg-primary bg-agg-secondary" : "border-agg-separator text-agg-foreground bg-agg-secondary"}`,
1549
+ children: badgeText
1550
+ }
1551
+ ) : null
1552
+ ] }),
1553
+ /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-4", children: [
1554
+ /* @__PURE__ */ jsxs17("div", { className: "text-right", children: [
1555
+ /* @__PURE__ */ jsx17("p", { className: "agg-type-body text-agg-foreground", children: provider.quote }),
1556
+ /* @__PURE__ */ jsxs17("p", { className: "agg-type-label text-agg-muted-foreground", children: [
1557
+ labels.withdraw.cardFlow.feeLabel,
1558
+ " ",
1559
+ provider.fee
1560
+ ] })
1561
+ ] }),
1562
+ /* @__PURE__ */ jsx17(ChevronRightIcon, { className: "h-5 w-5 text-agg-muted-foreground" })
1563
+ ] })
1564
+ ] })
1565
+ }
1566
+ );
1567
+ };
1568
+ var WithdrawProviderStep = ({
1569
+ token,
1570
+ amount,
1571
+ currency,
1572
+ providers,
1573
+ onBack,
1574
+ onSelectProvider
1575
+ }) => {
1576
+ const labels = useLabels11();
1577
+ return /* @__PURE__ */ jsxs17(Fragment12, { children: [
1578
+ /* @__PURE__ */ jsx17(
1579
+ Modal.Header,
1580
+ {
1581
+ title: labels.withdraw.cardFlow.selectProviderTitle,
1582
+ hideBorder: true,
1583
+ leftElement: /* @__PURE__ */ jsx17(
1584
+ "button",
1585
+ {
1586
+ type: "button",
1587
+ className: "mr-2 flex items-center justify-center text-agg-foreground transition-colors hover:cursor-pointer hover:text-agg-foreground/80",
1588
+ onClick: onBack,
1589
+ "aria-label": labels.withdraw.back,
1590
+ children: /* @__PURE__ */ jsx17(ChevronLeftIcon, { className: "h-6 w-6" })
1591
+ }
1592
+ )
1593
+ }
1594
+ ),
1595
+ /* @__PURE__ */ jsx17(Modal.Body, { classNames: { root: "px-5 pt-0 pb-6 sm:px-8 sm:pt-0 sm:pb-8" }, children: /* @__PURE__ */ jsxs17("div", { className: "flex flex-col gap-4", children: [
1596
+ /* @__PURE__ */ jsxs17("p", { className: "agg-type-body text-agg-foreground", children: [
1597
+ /* @__PURE__ */ jsx17("span", { className: "font-agg-bold", children: token }),
1598
+ " $",
1599
+ amount,
1600
+ " ",
1601
+ currency
1602
+ ] }),
1603
+ /* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-4", children: providers.map((provider) => /* @__PURE__ */ jsx17(
1604
+ WithdrawProviderItem,
1605
+ {
1606
+ provider,
1607
+ onSelect: onSelectProvider
1608
+ },
1609
+ provider.id
1610
+ )) })
1611
+ ] }) })
1612
+ ] });
1613
+ };
1614
+
1615
+ // src/withdraw/steps/withdraw-success.tsx
1616
+ import { useLabels as useLabels12 } from "@agg-market/hooks";
1617
+ import { jsx as jsx18, jsxs as jsxs18 } from "react/jsx-runtime";
1618
+ var SummaryRow3 = ({ label, value }) => /* @__PURE__ */ jsxs18("div", { className: "flex items-center justify-between border-b border-agg-separator py-2 last:border-b-0", children: [
1619
+ /* @__PURE__ */ jsx18("p", { className: "text-[12px] leading-4 font-agg-bold uppercase text-agg-muted-foreground", children: label }),
1620
+ /* @__PURE__ */ jsx18("p", { className: "agg-type-label text-agg-foreground", children: value })
1621
+ ] });
1622
+ var WithdrawSuccessStep = ({
1623
+ summary,
1624
+ onDone,
1625
+ onClose
1626
+ }) => {
1627
+ const labels = useLabels12();
1628
+ return /* @__PURE__ */ jsx18("div", { className: "relative", children: /* @__PURE__ */ jsxs18(Modal.Body, { classNames: { root: "px-5 py-8 sm:px-8 sm:py-10" }, children: [
1629
+ /* @__PURE__ */ jsx18(
1630
+ "button",
1631
+ {
1632
+ type: "button",
1633
+ className: "absolute right-8 top-7 flex items-center justify-center text-agg-foreground transition-colors hover:text-agg-foreground/80",
1634
+ onClick: onClose,
1635
+ "aria-label": labels.common.close,
1636
+ children: /* @__PURE__ */ jsx18(CloseIcon, { className: "h-6 w-6" })
1637
+ }
1638
+ ),
1639
+ /* @__PURE__ */ jsxs18("div", { className: "flex flex-col items-center gap-8", children: [
1640
+ /* @__PURE__ */ jsx18("div", { className: "flex h-[60px] w-[60px] items-center justify-center rounded-full border border-[#18C15C80] bg-[#18C15C26]", children: /* @__PURE__ */ jsx18(SuccessCheckIcon, { className: "h-6 w-6 text-[#18C15C]" }) }),
1641
+ /* @__PURE__ */ jsxs18("div", { className: "flex flex-col items-center gap-3 text-center", children: [
1642
+ /* @__PURE__ */ jsx18("h3", { className: "text-agg-2xl leading-agg-8 font-agg-bold text-agg-foreground", children: labels.withdraw.cardFlow.successTitle }),
1643
+ /* @__PURE__ */ jsx18("p", { className: "agg-type-body text-agg-foreground", children: labels.withdraw.cardFlow.successDescription })
1644
+ ] }),
1645
+ /* @__PURE__ */ jsxs18("div", { className: "w-full rounded-lg border border-agg-separator bg-agg-secondary px-3 py-1", children: [
1646
+ /* @__PURE__ */ jsx18(
1647
+ SummaryRow3,
1648
+ {
1649
+ label: labels.withdraw.summary.amountReceived,
1650
+ value: summary.amountReceived
1651
+ }
1652
+ ),
1653
+ /* @__PURE__ */ jsx18(SummaryRow3, { label: labels.withdraw.summary.network, value: summary.network }),
1654
+ /* @__PURE__ */ jsx18(
1655
+ SummaryRow3,
1656
+ {
1657
+ label: labels.withdraw.cardFlow.summary.provider,
1658
+ value: summary.provider
1659
+ }
1660
+ ),
1661
+ /* @__PURE__ */ jsx18(
1662
+ SummaryRow3,
1663
+ {
1664
+ label: labels.withdraw.cardFlow.summary.toWallet,
1665
+ value: summary.toWallet
1666
+ }
1667
+ ),
1668
+ /* @__PURE__ */ jsx18(SummaryRow3, { label: labels.withdraw.cardFlow.summary.fees, value: summary.fees })
1669
+ ] }),
1670
+ /* @__PURE__ */ jsx18(Button, { variant: "secondary", size: "large", className: "w-[120px]", onClick: onDone, children: labels.withdraw.done })
1671
+ ] })
1672
+ ] }) });
1673
+ };
1674
+
1675
+ // src/withdraw/index.tsx
1676
+ import { jsx as jsx19, jsxs as jsxs19 } from "react/jsx-runtime";
1677
+ var WithdrawModal = ({
1678
+ open,
1679
+ onOpenChange,
1680
+ withdrawFlow,
1681
+ onSelectWithdrawMethod,
1682
+ onWithdrawAmountChange,
1683
+ onWithdrawCurrencyChange,
1684
+ onWithdrawTokenChange,
1685
+ onWithdrawNetworkChange,
1686
+ onGetWithdrawQuotes,
1687
+ onSelectWithdrawProvider,
1688
+ onDoneWithdraw
1689
+ }) => {
1690
+ const [step, setStep] = useState5("method");
1691
+ const handleBackToMethod = () => {
1692
+ setStep("method");
1693
+ };
1694
+ const handleSelectMethod = (method) => {
1695
+ setStep("withdraw-amount");
1696
+ onSelectWithdrawMethod == null ? void 0 : onSelectWithdrawMethod(method);
1697
+ };
1698
+ const handleOpenChange = (isOpen) => {
1699
+ if (!isOpen) {
1700
+ setStep("method");
1701
+ }
1702
+ onOpenChange(isOpen);
1703
+ };
1704
+ return /* @__PURE__ */ jsx19(Modal, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxs19(Modal.Container, { maxWidth: "600px", "aria-label": "Withdraw", children: [
1705
+ step === "method" ? /* @__PURE__ */ jsx19(WithdrawMethodStep, { balance: withdrawFlow.balance, onSelectMethod: handleSelectMethod }) : null,
1706
+ step === "withdraw-amount" ? /* @__PURE__ */ jsx19(
1707
+ WithdrawAmountStep,
1708
+ {
1709
+ amount: withdrawFlow.amount,
1710
+ currency: withdrawFlow.currency,
1711
+ destinationWallet: withdrawFlow.destinationWallet,
1712
+ tokenOptions: withdrawFlow.tokenOptions,
1713
+ networkOptions: withdrawFlow.networkOptions,
1714
+ selectedToken: withdrawFlow.selectedToken,
1715
+ selectedNetwork: withdrawFlow.selectedNetwork,
1716
+ onBack: handleBackToMethod,
1717
+ onAmountChange: onWithdrawAmountChange,
1718
+ onCurrencyChange: onWithdrawCurrencyChange,
1719
+ onTokenChange: onWithdrawTokenChange,
1720
+ onNetworkChange: onWithdrawNetworkChange,
1721
+ onContinue: () => {
1722
+ onGetWithdrawQuotes == null ? void 0 : onGetWithdrawQuotes();
1723
+ setStep("provider");
1724
+ }
1725
+ }
1726
+ ) : null,
1727
+ step === "provider" ? /* @__PURE__ */ jsx19(
1728
+ WithdrawProviderStep,
1729
+ {
1730
+ token: withdrawFlow.selectedToken,
1731
+ amount: withdrawFlow.amount,
1732
+ currency: withdrawFlow.currency,
1733
+ providers: withdrawFlow.providers,
1734
+ onBack: () => setStep("withdraw-amount"),
1735
+ onSelectProvider: (providerId) => {
1736
+ onSelectWithdrawProvider(providerId);
1737
+ setStep("success");
1738
+ }
1739
+ }
1740
+ ) : null,
1741
+ step === "success" ? /* @__PURE__ */ jsx19(
1742
+ WithdrawSuccessStep,
1743
+ {
1744
+ summary: withdrawFlow.purchaseSummary,
1745
+ onDone: onDoneWithdraw,
1746
+ onClose: () => onOpenChange(false)
1747
+ }
1748
+ ) : null
1749
+ ] }) });
1750
+ };
1751
+ WithdrawModal.displayName = "WithdrawModal";
1752
+
1753
+ // src/onboarding/index.tsx
1754
+ import { useCallback as useCallback7, useEffect as useEffect3, useState as useState10 } from "react";
1755
+ import { useLabels as useLabels18 } from "@agg-market/hooks";
1756
+ import * as Dialog3 from "@radix-ui/react-dialog";
1757
+
1758
+ // src/onboarding/onboarding-modal.constants.ts
1759
+ var HOW_IT_WORKS_FEATURE_KEYS = [
1760
+ "createAccount",
1761
+ "linkAccounts",
1762
+ "bestPrices",
1763
+ "stayInControl"
1764
+ ];
1765
+ var ONBOARDING_STEPS = {
1766
+ HOW_IT_WORKS: 0,
1767
+ PROFILE_SETUP: 1,
1768
+ CONNECT_ACCOUNTS: 2
1769
+ };
1770
+ var ONCHAIN_VENUES = [
1771
+ "polymarket",
1772
+ "opinion",
1773
+ "probable"
1774
+ ];
1775
+
1776
+ // src/onboarding/steps/how-it-works.tsx
1777
+ import { useCallback as useCallback3, useRef as useRef3, useState as useState6 } from "react";
1778
+ import { useLabels as useLabels13 } from "@agg-market/hooks";
1779
+ import { jsx as jsx20, jsxs as jsxs20 } from "react/jsx-runtime";
1780
+ var defaultIcons = {
1781
+ createAccount: /* @__PURE__ */ jsx20(CreateAccountIcon, { className: "h-[28px] w-[28px] text-agg-muted-foreground" }),
1782
+ linkAccounts: /* @__PURE__ */ jsx20(LinkAccountsIcon, { className: "h-[28px] w-[28px] text-agg-muted-foreground" }),
1783
+ bestPrices: /* @__PURE__ */ jsx20(BestPricesIcon, { className: "h-[28px] w-[28px] text-agg-muted-foreground" }),
1784
+ stayInControl: /* @__PURE__ */ jsx20(StayInControlIcon, { className: "h-[28px] w-[28px] text-agg-muted-foreground" })
1785
+ };
1786
+ var HowItWorksStep = ({ onContinue, icons }) => {
1787
+ const labels = useLabels13();
1788
+ const scrollRef = useRef3(null);
1789
+ const [showTopGradient, setShowTopGradient] = useState6(false);
1790
+ const [showBottomGradient, setShowBottomGradient] = useState6(true);
1791
+ const handleScroll = useCallback3(() => {
1792
+ const el = scrollRef.current;
1793
+ if (!el) return;
1794
+ setShowTopGradient(el.scrollTop > 0);
1795
+ setShowBottomGradient(el.scrollTop + el.clientHeight < el.scrollHeight - 1);
1796
+ }, []);
1797
+ return /* @__PURE__ */ jsxs20("div", { className: "flex flex-col gap-6 h-[600px] sm:h-auto", children: [
1798
+ /* @__PURE__ */ jsx20("h2", { className: "text-center text-agg-2xl font-agg-bold text-agg-foreground", children: labels.onboarding.howItWorks.title }),
1799
+ /* @__PURE__ */ jsxs20("div", { className: "relative flex-1 min-h-0 sm:flex-initial", children: [
1800
+ /* @__PURE__ */ jsx20(
1801
+ "div",
1802
+ {
1803
+ ref: scrollRef,
1804
+ onScroll: handleScroll,
1805
+ className: "flex flex-col gap-4 overflow-y-auto sm:overflow-visible h-full",
1806
+ children: HOW_IT_WORKS_FEATURE_KEYS.map((featureKey) => {
1807
+ var _a;
1808
+ const icon = (_a = icons == null ? void 0 : icons[featureKey]) != null ? _a : defaultIcons[featureKey];
1809
+ const feature = labels.onboarding.howItWorks.features[featureKey];
1810
+ return /* @__PURE__ */ jsxs20(
1811
+ "div",
1812
+ {
1813
+ className: cn(
1814
+ "flex items-center gap-4 py-4 px-5 sm:px-4",
1815
+ "rounded-agg-md",
1816
+ "bg-agg-secondary-hover"
1817
+ ),
1818
+ children: [
1819
+ /* @__PURE__ */ jsxs20("div", { className: "flex flex-col flex-1 min-w-0 gap-[6px]", children: [
1820
+ /* @__PURE__ */ jsx20("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: feature.title }),
1821
+ /* @__PURE__ */ jsx20("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: feature.description })
1822
+ ] }),
1823
+ icon ? /* @__PURE__ */ jsx20("div", { className: "hidden shrink-0 items-center justify-center text-agg-muted-foreground sm:flex", children: icon }) : null
1824
+ ]
1825
+ },
1826
+ featureKey
1827
+ );
1828
+ })
1829
+ }
1830
+ ),
1831
+ /* @__PURE__ */ jsx20(
1832
+ "div",
1833
+ {
1834
+ className: cn(
1835
+ "pointer-events-none absolute inset-x-0 top-0 h-20",
1836
+ "bg-gradient-to-b from-agg-secondary to-transparent",
1837
+ "sm:hidden transition-opacity",
1838
+ showTopGradient ? "opacity-100" : "opacity-0"
1839
+ )
1840
+ }
1841
+ ),
1842
+ /* @__PURE__ */ jsx20(
1843
+ "div",
1844
+ {
1845
+ className: cn(
1846
+ "pointer-events-none absolute inset-x-0 bottom-0 h-20",
1847
+ "bg-gradient-to-t from-agg-secondary to-transparent",
1848
+ "sm:hidden transition-opacity",
1849
+ showBottomGradient ? "opacity-100" : "opacity-0"
1850
+ )
1851
+ }
1852
+ )
1853
+ ] }),
1854
+ /* @__PURE__ */ jsx20(Button, { variant: "primary", size: "large", className: "w-full", onClick: onContinue, children: labels.onboarding.howItWorks.continue })
1855
+ ] });
1856
+ };
1857
+ HowItWorksStep.displayName = "HowItWorksStep";
1858
+
1859
+ // src/onboarding/steps/profile-setup.tsx
1860
+ import { useCallback as useCallback4, useRef as useRef4, useState as useState7 } from "react";
1861
+ import { useLabels as useLabels14 } from "@agg-market/hooks";
1862
+ import { jsx as jsx21, jsxs as jsxs21 } from "react/jsx-runtime";
1863
+ var ProfileSetupStep = ({ onContinue }) => {
1864
+ const labels = useLabels14();
1865
+ const [username, setUsername] = useState7("");
1866
+ const [avatarFile, setAvatarFile] = useState7();
1867
+ const [avatarPreview, setAvatarPreview] = useState7();
1868
+ const fileInputRef = useRef4(null);
1869
+ const handleAvatarClick = useCallback4(() => {
1870
+ var _a;
1871
+ (_a = fileInputRef.current) == null ? void 0 : _a.click();
1872
+ }, []);
1873
+ const handleFileChange = useCallback4((e) => {
1874
+ var _a;
1875
+ const file = (_a = e.target.files) == null ? void 0 : _a[0];
1876
+ if (!file) return;
1877
+ setAvatarFile(file);
1878
+ const reader = new FileReader();
1879
+ reader.onload = (event) => {
1880
+ var _a2;
1881
+ setAvatarPreview((_a2 = event.target) == null ? void 0 : _a2.result);
1882
+ };
1883
+ reader.readAsDataURL(file);
1884
+ }, []);
1885
+ const handleContinue = useCallback4(() => {
1886
+ onContinue({
1887
+ username,
1888
+ avatarFile,
1889
+ avatarPreview
1890
+ });
1891
+ }, [username, avatarFile, avatarPreview, onContinue]);
1892
+ return /* @__PURE__ */ jsxs21("div", { className: "flex flex-col gap-7", children: [
1893
+ /* @__PURE__ */ jsx21("h2", { className: "text-center text-agg-2xl font-agg-bold text-agg-foreground", children: labels.onboarding.profileSetup.title }),
1894
+ /* @__PURE__ */ jsxs21("div", { className: "flex flex-col gap-5 items-center w-full", children: [
1895
+ /* @__PURE__ */ jsxs21("div", { className: "flex justify-center", children: [
1896
+ /* @__PURE__ */ jsxs21(
1897
+ "button",
1898
+ {
1899
+ type: "button",
1900
+ onClick: handleAvatarClick,
1901
+ className: cn(
1902
+ "group relative flex items-center justify-center",
1903
+ "h-[80px] w-[80px]",
1904
+ "rounded-agg-full",
1905
+ "bg-agg-secondary-hover",
1906
+ !avatarPreview && "hover:bg-agg-tertiary",
1907
+ "transition-colors cursor-pointer",
1908
+ "overflow-hidden"
1909
+ ),
1910
+ "aria-label": labels.onboarding.profileSetup.uploadProfilePictureAria,
1911
+ children: [
1912
+ !avatarPreview ? /* @__PURE__ */ jsx21(
1913
+ "svg",
1914
+ {
1915
+ "aria-hidden": true,
1916
+ viewBox: "0 0 80 80",
1917
+ className: "pointer-events-none absolute inset-0 h-full w-full text-agg-separator group-hover:text-agg-muted-foreground",
1918
+ children: /* @__PURE__ */ jsx21(
1919
+ "circle",
1920
+ {
1921
+ cx: "40",
1922
+ cy: "40",
1923
+ r: "39.5",
1924
+ fill: "none",
1925
+ stroke: "currentColor",
1926
+ strokeWidth: "1",
1927
+ strokeDasharray: "8 8"
1928
+ }
1929
+ )
1930
+ }
1931
+ ) : null,
1932
+ avatarPreview ? /* @__PURE__ */ jsx21(
1933
+ RemoteImage,
1934
+ {
1935
+ src: avatarPreview,
1936
+ alt: labels.onboarding.profileSetup.profilePreviewAlt,
1937
+ className: "h-full w-full object-cover"
1938
+ }
1939
+ ) : /* @__PURE__ */ jsx21(ProfileIcon, { className: "h-7 w-7 text-agg-muted-foreground" })
1940
+ ]
1941
+ }
1942
+ ),
1943
+ /* @__PURE__ */ jsx21(
1944
+ "input",
1945
+ {
1946
+ ref: fileInputRef,
1947
+ type: "file",
1948
+ accept: "image/*",
1949
+ onChange: handleFileChange,
1950
+ className: "hidden",
1951
+ "aria-hidden": "true"
1952
+ }
1953
+ )
1954
+ ] }),
1955
+ /* @__PURE__ */ jsxs21("div", { className: "flex flex-col gap-2 w-full", children: [
1956
+ /* @__PURE__ */ jsx21(
1957
+ "label",
1958
+ {
1959
+ htmlFor: "onboarding-username",
1960
+ className: "text-agg-sm font-agg-bold text-agg-foreground",
1961
+ children: labels.onboarding.profileSetup.usernameLabel
1962
+ }
1963
+ ),
1964
+ /* @__PURE__ */ jsx21(
1965
+ "input",
1966
+ {
1967
+ id: "onboarding-username",
1968
+ type: "text",
1969
+ value: username,
1970
+ onChange: (e) => setUsername(e.target.value),
1971
+ placeholder: labels.onboarding.profileSetup.usernamePlaceholder,
1972
+ className: cn(
1973
+ "w-full px-3 py-2.5",
1974
+ "rounded-[4px]",
1975
+ "border border-agg-separator",
1976
+ "bg-agg-secondary text-agg-foreground",
1977
+ "placeholder:text-agg-muted-foreground",
1978
+ "outline-none",
1979
+ "hover:bg-agg-secondary-hover",
1980
+ "focus:border-agg-primary focus:ring-1 focus:ring-agg-primary",
1981
+ "transition-colors",
1982
+ "text-agg-sm sm:text-agg-base"
1983
+ )
1984
+ }
1985
+ )
1986
+ ] })
1987
+ ] }),
1988
+ /* @__PURE__ */ jsx21(Button, { variant: "primary", size: "large", className: "w-full", onClick: handleContinue, children: labels.onboarding.profileSetup.continue })
1989
+ ] });
1990
+ };
1991
+ ProfileSetupStep.displayName = "ProfileSetupStep";
1992
+
1993
+ // src/onboarding/steps/connect-accounts.tsx
1994
+ import { useLabels as useLabels15 } from "@agg-market/hooks";
1995
+ import { jsx as jsx22, jsxs as jsxs22 } from "react/jsx-runtime";
1996
+ var OnchainVenueLogos = () => {
1997
+ return /* @__PURE__ */ jsx22("div", { className: "flex gap-1 sm:gap-0 sm:-space-x-5", children: ONCHAIN_VENUES.map((venue, index) => /* @__PURE__ */ jsx22("div", { style: { zIndex: ONCHAIN_VENUES.length - index }, children: /* @__PURE__ */ jsx22(VenueLogo, { venue, variant: "logo", size: "medium", className: "sm:h-8 sm:w-8" }) }, venue)) });
1998
+ };
1999
+ var VenueCard = ({
2000
+ logos,
2001
+ title,
2002
+ mobileTitle,
2003
+ description,
2004
+ mobileDescription,
2005
+ onConnect,
2006
+ connected = false
2007
+ }) => {
2008
+ const labels = useLabels15();
2009
+ const action = connected ? /* @__PURE__ */ jsx22(CheckCircleIcon, { className: "h-6 w-6 text-agg-success" }) : /* @__PURE__ */ jsx22(
2010
+ Button,
2011
+ {
2012
+ variant: "tertiary",
2013
+ size: "large",
2014
+ className: "!h-auto !px-0 !py-0 text-agg-primary hover:bg-transparent hover:text-agg-primary-hover",
2015
+ onClick: onConnect,
2016
+ children: labels.onboarding.connectAccounts.connect
2017
+ }
2018
+ );
2019
+ const mobileAction = connected ? /* @__PURE__ */ jsx22(CheckCircleIcon, { className: "h-6 w-6 text-agg-success" }) : /* @__PURE__ */ jsx22(
2020
+ Button,
2021
+ {
2022
+ variant: "tertiary",
2023
+ size: "medium",
2024
+ className: "!h-auto !px-0 !py-0 text-agg-primary hover:bg-transparent hover:text-agg-primary-hover",
2025
+ onClick: onConnect,
2026
+ suffix: /* @__PURE__ */ jsx22(ChevronRightIcon, { className: "h-4 w-4" }),
2027
+ children: labels.onboarding.connectAccounts.connectAccount
2028
+ }
2029
+ );
2030
+ return /* @__PURE__ */ jsxs22(
2031
+ "div",
2032
+ {
2033
+ className: cn(
2034
+ "rounded-agg-md p-5 transition-colors",
2035
+ connected ? "bg-agg-success/5" : "bg-agg-secondary-hover hover:bg-agg-tertiary"
2036
+ ),
2037
+ children: [
2038
+ /* @__PURE__ */ jsxs22("div", { className: "hidden sm:flex items-center justify-between", children: [
2039
+ /* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-5", children: [
2040
+ /* @__PURE__ */ jsx22("div", { className: "shrink-0", children: logos }),
2041
+ /* @__PURE__ */ jsxs22("div", { className: "flex flex-col gap-[2px]", children: [
2042
+ /* @__PURE__ */ jsx22("p", { className: "text-agg-base font-agg-bold text-agg-foreground", children: title }),
2043
+ /* @__PURE__ */ jsx22("p", { className: "text-agg-sm text-agg-foreground", children: description })
2044
+ ] })
2045
+ ] }),
2046
+ /* @__PURE__ */ jsx22("div", { className: "shrink-0", children: action })
2047
+ ] }),
2048
+ /* @__PURE__ */ jsxs22("div", { className: "flex flex-col gap-3 sm:hidden", children: [
2049
+ /* @__PURE__ */ jsxs22("div", { className: "flex flex-col gap-3", children: [
2050
+ /* @__PURE__ */ jsx22("div", { className: "shrink-0", children: logos }),
2051
+ /* @__PURE__ */ jsx22("p", { className: "text-agg-lg font-agg-bold text-agg-foreground", children: mobileTitle != null ? mobileTitle : title })
2052
+ ] }),
2053
+ /* @__PURE__ */ jsxs22("div", { className: "flex flex-col items-start gap-2", children: [
2054
+ /* @__PURE__ */ jsx22("p", { className: "text-agg-base text-agg-foreground", children: mobileDescription != null ? mobileDescription : description }),
2055
+ mobileAction
2056
+ ] })
2057
+ ] })
2058
+ ]
2059
+ }
2060
+ );
2061
+ };
2062
+ var ConnectAccountsStep = ({
2063
+ onConnectOnchain,
2064
+ onConnectKalshi,
2065
+ onContinue,
2066
+ connectedOnchain = false,
2067
+ connectedKalshi = false
2068
+ }) => {
2069
+ const labels = useLabels15();
2070
+ const canContinue = connectedOnchain || connectedKalshi;
2071
+ return /* @__PURE__ */ jsxs22("div", { className: "flex flex-col gap-6", children: [
2072
+ /* @__PURE__ */ jsx22("h2", { className: "text-center text-agg-2xl font-agg-bold text-agg-foreground", children: labels.onboarding.connectAccounts.title }),
2073
+ /* @__PURE__ */ jsxs22("div", { className: "flex flex-col gap-4", children: [
2074
+ /* @__PURE__ */ jsx22(
2075
+ VenueCard,
2076
+ {
2077
+ logos: /* @__PURE__ */ jsx22(OnchainVenueLogos, {}),
2078
+ title: labels.onboarding.connectAccounts.onchainTitle,
2079
+ mobileTitle: labels.onboarding.connectAccounts.onchainMobileTitle(
2080
+ ONCHAIN_VENUES.length - 1
2081
+ ),
2082
+ description: labels.onboarding.connectAccounts.onchainDescription,
2083
+ mobileDescription: labels.onboarding.connectAccounts.onchainMobileDescription,
2084
+ onConnect: onConnectOnchain,
2085
+ connected: connectedOnchain
2086
+ }
2087
+ ),
2088
+ /* @__PURE__ */ jsx22(
2089
+ VenueCard,
2090
+ {
2091
+ logos: /* @__PURE__ */ jsx22("div", { className: "sm:flex sm:w-14 sm:items-center sm:justify-center", children: /* @__PURE__ */ jsx22(
2092
+ VenueLogo,
2093
+ {
2094
+ venue: "kalshi",
2095
+ variant: "logo",
2096
+ size: "large",
2097
+ className: "h-6 w-6 sm:h-9 sm:w-9"
2098
+ }
2099
+ ) }),
2100
+ title: labels.onboarding.connectAccounts.kalshiTitle,
2101
+ mobileTitle: labels.onboarding.connectAccounts.kalshiMobileTitle,
2102
+ description: labels.onboarding.connectAccounts.kalshiDescription,
2103
+ mobileDescription: labels.onboarding.connectAccounts.kalshiMobileDescription,
2104
+ onConnect: onConnectKalshi,
2105
+ connected: connectedKalshi
2106
+ }
2107
+ )
2108
+ ] }),
2109
+ /* @__PURE__ */ jsx22(
2110
+ Button,
2111
+ {
2112
+ variant: "primary",
2113
+ size: "large",
2114
+ className: "w-full",
2115
+ onClick: onContinue,
2116
+ disabled: !canContinue,
2117
+ children: labels.onboarding.connectAccounts.continue
2118
+ }
2119
+ )
2120
+ ] });
2121
+ };
2122
+ ConnectAccountsStep.displayName = "ConnectAccountsStep";
2123
+
2124
+ // src/onboarding/steps/connect-kalshi-modal.tsx
2125
+ import { useCallback as useCallback5, useState as useState8 } from "react";
2126
+ import { useLabels as useLabels16 } from "@agg-market/hooks";
2127
+ import * as Dialog from "@radix-ui/react-dialog";
2128
+ import { jsx as jsx23, jsxs as jsxs23 } from "react/jsx-runtime";
2129
+ var ConnectKalshiModal = ({
2130
+ open,
2131
+ onOpenChange,
2132
+ onVerify
2133
+ }) => {
2134
+ const labels = useLabels16();
2135
+ const [apiKeyId, setApiKeyId] = useState8("");
2136
+ const [privateKey, setPrivateKey] = useState8("");
2137
+ const [verifying, setVerifying] = useState8(false);
2138
+ const [error, setError] = useState8();
2139
+ const canVerify = apiKeyId.trim().length > 0 && privateKey.trim().length > 0;
2140
+ const handleCancel = useCallback5(() => {
2141
+ onOpenChange(false);
2142
+ }, [onOpenChange]);
2143
+ const handleVerify = useCallback5(() => __async(null, null, function* () {
2144
+ if (!canVerify || verifying) return;
2145
+ setVerifying(true);
2146
+ setError(void 0);
2147
+ try {
2148
+ const credentials = {
2149
+ apiKeyId: apiKeyId.trim(),
2150
+ privateKey: privateKey.trim()
2151
+ };
2152
+ yield onVerify(credentials);
2153
+ setApiKeyId("");
2154
+ setPrivateKey("");
2155
+ onOpenChange(false);
2156
+ } catch (err) {
2157
+ setError(
2158
+ err instanceof Error ? err.message : labels.onboarding.connectKalshiModal.fallbackError
2159
+ );
2160
+ } finally {
2161
+ setVerifying(false);
2162
+ }
2163
+ }), [
2164
+ apiKeyId,
2165
+ canVerify,
2166
+ labels.onboarding.connectKalshiModal.fallbackError,
2167
+ onOpenChange,
2168
+ onVerify,
2169
+ privateKey,
2170
+ verifying
2171
+ ]);
2172
+ const handleOpenChange = useCallback5(
2173
+ (value) => {
2174
+ if (value) {
2175
+ setApiKeyId("");
2176
+ setPrivateKey("");
2177
+ setError(void 0);
2178
+ setVerifying(false);
2179
+ }
2180
+ onOpenChange(value);
2181
+ },
2182
+ [onOpenChange]
2183
+ );
2184
+ return /* @__PURE__ */ jsx23(Modal, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxs23(
2185
+ Modal.Container,
2186
+ {
2187
+ maxWidth: "600px",
2188
+ "aria-label": labels.onboarding.connectKalshiModal.ariaLabel,
2189
+ classNames: { container: "!rounded-agg-lg" },
2190
+ children: [
2191
+ /* @__PURE__ */ jsx23(Dialog.Title, { className: "sr-only", children: labels.onboarding.connectKalshiModal.title }),
2192
+ /* @__PURE__ */ jsx23(
2193
+ Modal.Header,
2194
+ {
2195
+ hideClose: false,
2196
+ hideBorder: true,
2197
+ classNames: {
2198
+ root: "!min-h-0",
2199
+ container: "!py-[18px] !px-8"
2200
+ }
2201
+ }
2202
+ ),
2203
+ /* @__PURE__ */ jsx23(Modal.Body, { classNames: { root: "!px-5 !pt-0 !pb-[60px] sm:!px-8" }, children: /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-8 items-center", children: [
2204
+ /* @__PURE__ */ jsx23(
2205
+ VenueLogo,
2206
+ {
2207
+ venue: "kalshi",
2208
+ variant: "logo",
2209
+ size: "large",
2210
+ className: "h-[60px] w-[60px]"
2211
+ }
2212
+ ),
2213
+ /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-4 items-center text-center", children: [
2214
+ /* @__PURE__ */ jsx23("h2", { className: "text-agg-2xl font-agg-bold text-agg-foreground", children: labels.onboarding.connectKalshiModal.title }),
2215
+ /* @__PURE__ */ jsx23("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: labels.onboarding.connectKalshiModal.description })
2216
+ ] }),
2217
+ /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-4 w-full", children: [
2218
+ /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-3 rounded-agg-lg bg-agg-secondary-hover p-4", children: [
2219
+ /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-1", children: [
2220
+ /* @__PURE__ */ jsx23("p", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: labels.onboarding.connectKalshiModal.stepOne.label }),
2221
+ /* @__PURE__ */ jsx23("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: labels.onboarding.connectKalshiModal.stepOne.title })
2222
+ ] }),
2223
+ /* @__PURE__ */ jsxs23("div", { className: "space-y-0 text-agg-sm leading-agg-5 text-agg-foreground", children: [
2224
+ /* @__PURE__ */ jsx23("p", { children: labels.onboarding.connectKalshiModal.stepOne.instructions.signIn }),
2225
+ /* @__PURE__ */ jsxs23("p", { children: [
2226
+ labels.onboarding.connectKalshiModal.stepOne.instructions.goToProfilePrefix,
2227
+ " ",
2228
+ /* @__PURE__ */ jsx23("span", { className: "font-agg-bold", children: labels.onboarding.connectKalshiModal.stepOne.instructions.profileText }),
2229
+ labels.onboarding.connectKalshiModal.stepOne.instructions.goToProfileSeparator,
2230
+ " ",
2231
+ /* @__PURE__ */ jsx23("span", { className: "text-agg-foreground underline", children: labels.onboarding.connectKalshiModal.stepOne.instructions.profileUrl })
2232
+ ] }),
2233
+ /* @__PURE__ */ jsxs23("p", { children: [
2234
+ labels.onboarding.connectKalshiModal.stepOne.instructions.clickCreateKeyPrefix,
2235
+ " ",
2236
+ /* @__PURE__ */ jsx23("span", { className: "font-agg-bold", children: labels.onboarding.connectKalshiModal.stepOne.instructions.createKeyText }),
2237
+ labels.onboarding.connectKalshiModal.stepOne.instructions.clickCreateKeySuffix
2238
+ ] }),
2239
+ /* @__PURE__ */ jsxs23("p", { children: [
2240
+ labels.onboarding.connectKalshiModal.stepOne.instructions.selectPermissionsPrefix,
2241
+ " ",
2242
+ /* @__PURE__ */ jsx23("span", { className: "font-agg-bold", children: labels.onboarding.connectKalshiModal.stepOne.instructions.readWriteText }),
2243
+ labels.onboarding.connectKalshiModal.stepOne.instructions.selectPermissionsSuffix
2244
+ ] }),
2245
+ /* @__PURE__ */ jsx23("p", { children: labels.onboarding.connectKalshiModal.stepOne.instructions.createKey })
2246
+ ] }),
2247
+ /* @__PURE__ */ jsxs23("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: [
2248
+ labels.onboarding.connectKalshiModal.stepOne.footerLineOne,
2249
+ /* @__PURE__ */ jsx23("br", {}),
2250
+ labels.onboarding.connectKalshiModal.stepOne.footerLineTwo
2251
+ ] })
2252
+ ] }),
2253
+ /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-3 rounded-agg-lg bg-agg-secondary-hover p-4", children: [
2254
+ /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-1", children: [
2255
+ /* @__PURE__ */ jsx23("p", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: labels.onboarding.connectKalshiModal.stepTwo.label }),
2256
+ /* @__PURE__ */ jsx23("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: labels.onboarding.connectKalshiModal.stepTwo.title })
2257
+ ] }),
2258
+ /* @__PURE__ */ jsx23("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: labels.onboarding.connectKalshiModal.stepTwo.description }),
2259
+ /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-2", children: [
2260
+ /* @__PURE__ */ jsx23(
2261
+ "label",
2262
+ {
2263
+ htmlFor: "kalshi-api-key-id",
2264
+ className: "text-agg-sm font-agg-bold text-agg-foreground",
2265
+ children: labels.onboarding.connectKalshiModal.stepTwo.apiKeyIdLabel
2266
+ }
2267
+ ),
2268
+ /* @__PURE__ */ jsx23(
2269
+ "input",
2270
+ {
2271
+ id: "kalshi-api-key-id",
2272
+ type: "text",
2273
+ value: apiKeyId,
2274
+ onChange: (e) => setApiKeyId(e.target.value),
2275
+ placeholder: labels.onboarding.connectKalshiModal.stepTwo.apiKeyIdPlaceholder,
2276
+ className: cn(
2277
+ "w-full px-3 py-2.5 h-10",
2278
+ "rounded border border-agg-separator",
2279
+ "bg-agg-secondary text-agg-base text-agg-foreground",
2280
+ "placeholder:text-agg-muted-foreground",
2281
+ "outline-none",
2282
+ "focus:border-agg-primary focus:ring-1 focus:ring-agg-primary",
2283
+ "transition-colors"
2284
+ )
2285
+ }
2286
+ )
2287
+ ] }),
2288
+ /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-2", children: [
2289
+ /* @__PURE__ */ jsx23(
2290
+ "label",
2291
+ {
2292
+ htmlFor: "kalshi-private-key",
2293
+ className: "text-agg-sm font-agg-bold text-agg-foreground",
2294
+ children: labels.onboarding.connectKalshiModal.stepTwo.privateKeyLabel
2295
+ }
2296
+ ),
2297
+ /* @__PURE__ */ jsx23(
2298
+ "textarea",
2299
+ {
2300
+ id: "kalshi-private-key",
2301
+ value: privateKey,
2302
+ onChange: (e) => setPrivateKey(e.target.value),
2303
+ placeholder: labels.onboarding.connectKalshiModal.stepTwo.privateKeyPlaceholder,
2304
+ rows: 3,
2305
+ className: cn(
2306
+ "w-full px-3 py-2.5",
2307
+ "rounded border border-agg-separator",
2308
+ "bg-agg-secondary text-agg-base text-agg-foreground",
2309
+ "placeholder:text-agg-muted-foreground",
2310
+ "outline-none resize-none",
2311
+ "focus:border-agg-primary focus:ring-1 focus:ring-agg-primary",
2312
+ "transition-colors"
2313
+ )
2314
+ }
2315
+ )
2316
+ ] })
2317
+ ] })
2318
+ ] }),
2319
+ /* @__PURE__ */ jsxs23("div", { className: "flex items-center justify-between w-full", children: [
2320
+ /* @__PURE__ */ jsx23("p", { className: "text-agg-base text-agg-foreground", children: labels.onboarding.connectKalshiModal.help.label }),
2321
+ /* @__PURE__ */ jsxs23("div", { className: "flex items-center gap-3", children: [
2322
+ /* @__PURE__ */ jsxs23(
2323
+ "a",
2324
+ {
2325
+ href: "#",
2326
+ className: "flex items-center gap-2 text-agg-base font-agg-bold text-agg-primary hover:text-agg-primary-hover",
2327
+ children: [
2328
+ /* @__PURE__ */ jsx23(DocumentIcon, { className: "h-4 w-4" }),
2329
+ labels.onboarding.connectKalshiModal.help.docsLinkLabel
2330
+ ]
2331
+ }
2332
+ ),
2333
+ /* @__PURE__ */ jsx23("span", { className: "h-3 w-px bg-agg-separator" }),
2334
+ /* @__PURE__ */ jsxs23(
2335
+ "a",
2336
+ {
2337
+ href: "#",
2338
+ className: "flex items-center gap-2 text-agg-base font-agg-bold text-agg-primary hover:text-agg-primary-hover",
2339
+ children: [
2340
+ /* @__PURE__ */ jsx23(PlaySquareIcon, { className: "h-4 w-4" }),
2341
+ labels.onboarding.connectKalshiModal.help.tutorialLinkLabel
2342
+ ]
2343
+ }
2344
+ )
2345
+ ] })
2346
+ ] }),
2347
+ /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-5 items-center", children: [
2348
+ error ? /* @__PURE__ */ jsxs23("div", { className: "flex items-center gap-2", children: [
2349
+ /* @__PURE__ */ jsx23(WarningIcon, { className: "h-3.5 w-3.5 shrink-0 text-agg-error" }),
2350
+ /* @__PURE__ */ jsx23("p", { className: "text-agg-sm leading-agg-5 text-agg-error", children: error })
2351
+ ] }) : null,
2352
+ /* @__PURE__ */ jsxs23("div", { className: "flex items-center gap-3 justify-center", children: [
2353
+ /* @__PURE__ */ jsx23(Button, { variant: "secondary", size: "large", onClick: handleCancel, children: labels.onboarding.connectKalshiModal.actions.cancel }),
2354
+ /* @__PURE__ */ jsx23(
2355
+ Button,
2356
+ {
2357
+ variant: "primary",
2358
+ size: "large",
2359
+ onClick: handleVerify,
2360
+ disabled: !canVerify,
2361
+ isLoading: verifying,
2362
+ children: labels.onboarding.connectKalshiModal.actions.verifyConnection
2363
+ }
2364
+ )
2365
+ ] })
2366
+ ] })
2367
+ ] }) })
2368
+ ]
2369
+ }
2370
+ ) });
2371
+ };
2372
+ ConnectKalshiModal.displayName = "ConnectKalshiModal";
2373
+
2374
+ // src/onboarding/steps/connect-onchain-modal.tsx
2375
+ import { useCallback as useCallback6, useState as useState9 } from "react";
2376
+ import { useLabels as useLabels17 } from "@agg-market/hooks";
2377
+ import * as Dialog2 from "@radix-ui/react-dialog";
2378
+ import { jsx as jsx24, jsxs as jsxs24 } from "react/jsx-runtime";
2379
+ var ConnectOnchainModal = ({
2380
+ open,
2381
+ onOpenChange,
2382
+ onConnect
2383
+ }) => {
2384
+ const labels = useLabels17();
2385
+ const [connecting, setConnecting] = useState9(false);
2386
+ const [error, setError] = useState9();
2387
+ const handleCancel = useCallback6(() => {
2388
+ onOpenChange(false);
2389
+ }, [onOpenChange]);
2390
+ const handleConnect = useCallback6(() => __async(null, null, function* () {
2391
+ if (connecting) return;
2392
+ setConnecting(true);
2393
+ setError(void 0);
2394
+ try {
2395
+ yield onConnect();
2396
+ onOpenChange(false);
2397
+ } catch (err) {
2398
+ setError(
2399
+ err instanceof Error ? err.message : labels.onboarding.connectOnchainModal.fallbackError
2400
+ );
2401
+ } finally {
2402
+ setConnecting(false);
2403
+ }
2404
+ }), [connecting, labels.onboarding.connectOnchainModal.fallbackError, onConnect, onOpenChange]);
2405
+ const handleOpenChange = useCallback6(
2406
+ (value) => {
2407
+ if (value) {
2408
+ setError(void 0);
2409
+ setConnecting(false);
2410
+ }
2411
+ onOpenChange(value);
2412
+ },
2413
+ [onOpenChange]
2414
+ );
2415
+ return /* @__PURE__ */ jsx24(Modal, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxs24(
2416
+ Modal.Container,
2417
+ {
2418
+ maxWidth: "600px",
2419
+ "aria-label": labels.onboarding.connectOnchainModal.ariaLabel,
2420
+ classNames: { container: "!rounded-agg-lg" },
2421
+ children: [
2422
+ /* @__PURE__ */ jsx24(Dialog2.Title, { className: "sr-only", children: labels.onboarding.connectOnchainModal.title }),
2423
+ /* @__PURE__ */ jsx24(
2424
+ Modal.Header,
2425
+ {
2426
+ hideClose: false,
2427
+ hideBorder: true,
2428
+ classNames: {
2429
+ root: "!min-h-0",
2430
+ container: "!py-[18px] !px-8"
2431
+ }
2432
+ }
2433
+ ),
2434
+ /* @__PURE__ */ jsx24(Modal.Body, { classNames: { root: "!px-5 !pt-0 !pb-[60px] sm:!px-8" }, children: /* @__PURE__ */ jsxs24("div", { className: "flex flex-col gap-8 items-center", children: [
2435
+ /* @__PURE__ */ jsxs24("div", { className: "flex flex-col gap-4 items-center text-center", children: [
2436
+ /* @__PURE__ */ jsx24("h2", { className: "text-agg-2xl font-agg-bold text-agg-foreground", children: labels.onboarding.connectOnchainModal.title }),
2437
+ /* @__PURE__ */ jsx24("p", { className: "text-agg-base text-center leading-agg-6 text-agg-foreground whitespace-pre-line", children: labels.onboarding.connectOnchainModal.description })
2438
+ ] }),
2439
+ /* @__PURE__ */ jsxs24("div", { className: "flex w-full flex-col items-center gap-4 rounded-agg-xl bg-agg-secondary-hover p-6", children: [
2440
+ /* @__PURE__ */ jsx24("p", { className: "text-agg-sm font-agg-bold uppercase leading-agg-5 text-agg-muted-foreground", children: labels.onboarding.connectOnchainModal.supportedVenuesLabel }),
2441
+ /* @__PURE__ */ jsx24("div", { className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-3", children: ONCHAIN_VENUES.map((venue, index) => /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-[6px]", children: [
2442
+ index > 0 && /* @__PURE__ */ jsx24("span", { className: "mr-2.5 h-3 w-px bg-agg-separator" }),
2443
+ /* @__PURE__ */ jsx24(VenueLogo, { venue, size: "medium" }),
2444
+ /* @__PURE__ */ jsx24("span", { className: "text-agg-base text-agg-foreground", children: labels.venues[venue] })
2445
+ ] }, venue)) })
2446
+ ] }),
2447
+ /* @__PURE__ */ jsxs24("div", { className: "flex flex-col gap-6 items-center", children: [
2448
+ /* @__PURE__ */ jsxs24("div", { className: "flex flex-col gap-3 items-center", children: [
2449
+ error ? /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-2", children: [
2450
+ /* @__PURE__ */ jsx24(WarningIcon, { className: "h-3.5 w-3.5 shrink-0 text-agg-error" }),
2451
+ /* @__PURE__ */ jsx24("p", { className: "text-agg-sm leading-agg-5 text-agg-error", children: error })
2452
+ ] }) : null,
2453
+ /* @__PURE__ */ jsx24(
2454
+ Button,
2455
+ {
2456
+ variant: "primary",
2457
+ size: "large",
2458
+ onClick: handleConnect,
2459
+ isLoading: connecting,
2460
+ children: labels.onboarding.connectOnchainModal.connect
2461
+ }
2462
+ )
2463
+ ] }),
2464
+ /* @__PURE__ */ jsx24(
2465
+ Button,
2466
+ {
2467
+ variant: "tertiary",
2468
+ size: "medium",
2469
+ className: "!h-auto !px-0 !py-0 text-agg-primary hover:bg-transparent hover:text-agg-primary-hover",
2470
+ onClick: handleCancel,
2471
+ children: labels.onboarding.connectOnchainModal.cancel
2472
+ }
2473
+ )
2474
+ ] })
2475
+ ] }) })
2476
+ ]
2477
+ }
2478
+ ) });
2479
+ };
2480
+ ConnectOnchainModal.displayName = "ConnectOnchainModal";
2481
+
2482
+ // src/onboarding/index.tsx
2483
+ import { Fragment as Fragment13, jsx as jsx25, jsxs as jsxs25 } from "react/jsx-runtime";
2484
+ var OnboardingModal = ({
2485
+ open,
2486
+ onOpenChange,
2487
+ onProfileSubmit,
2488
+ onConnectOnchain,
2489
+ onConnectKalshi,
2490
+ onComplete,
2491
+ howItWorksIcons,
2492
+ connectedOnchain = false,
2493
+ connectedKalshi = false
2494
+ }) => {
2495
+ var _a;
2496
+ const labels = useLabels18();
2497
+ const [step, setStep] = useState10(ONBOARDING_STEPS.HOW_IT_WORKS);
2498
+ const stepLabels = {
2499
+ [ONBOARDING_STEPS.HOW_IT_WORKS]: labels.onboarding.modal.stepHowItWorks,
2500
+ [ONBOARDING_STEPS.PROFILE_SETUP]: labels.onboarding.modal.stepProfileSetup,
2501
+ [ONBOARDING_STEPS.CONNECT_ACCOUNTS]: labels.onboarding.modal.stepConnectAccounts
2502
+ };
2503
+ const resolvedTitle = (_a = stepLabels[step]) != null ? _a : labels.onboarding.modal.title;
2504
+ const [kalshiModalOpen, setKalshiModalOpen] = useState10(false);
2505
+ const [kalshiConnected, setKalshiConnected] = useState10(false);
2506
+ const [onchainModalOpen, setOnchainModalOpen] = useState10(false);
2507
+ const [onchainConnected, setOnchainConnected] = useState10(false);
2508
+ useEffect3(() => {
2509
+ if (open) {
2510
+ setStep(ONBOARDING_STEPS.HOW_IT_WORKS);
2511
+ setKalshiConnected(false);
2512
+ setOnchainConnected(false);
2513
+ }
2514
+ }, [open]);
2515
+ const handleHowItWorksContinue = useCallback7(() => {
2516
+ setStep(ONBOARDING_STEPS.PROFILE_SETUP);
2517
+ }, []);
2518
+ const handleProfileContinue = useCallback7(
2519
+ (data) => {
2520
+ onProfileSubmit == null ? void 0 : onProfileSubmit(data);
2521
+ setStep(ONBOARDING_STEPS.CONNECT_ACCOUNTS);
2522
+ },
2523
+ [onProfileSubmit]
2524
+ );
2525
+ const handleConnectContinue = useCallback7(() => {
2526
+ onComplete == null ? void 0 : onComplete();
2527
+ }, [onComplete]);
2528
+ const handleOpenOnchainModal = useCallback7(() => {
2529
+ setOnchainModalOpen(true);
2530
+ }, []);
2531
+ const handleOnchainConnect = useCallback7(() => __async(null, null, function* () {
2532
+ yield onConnectOnchain == null ? void 0 : onConnectOnchain();
2533
+ setOnchainConnected(true);
2534
+ }), [onConnectOnchain]);
2535
+ const handleOpenKalshiModal = useCallback7(() => {
2536
+ setKalshiModalOpen(true);
2537
+ }, []);
2538
+ const handleKalshiVerify = useCallback7(
2539
+ (credentials) => __async(null, null, function* () {
2540
+ yield onConnectKalshi == null ? void 0 : onConnectKalshi(credentials);
2541
+ setKalshiConnected(true);
2542
+ }),
2543
+ [onConnectKalshi]
2544
+ );
2545
+ return /* @__PURE__ */ jsxs25(Fragment13, { children: [
2546
+ /* @__PURE__ */ jsx25(Modal, { open, onOpenChange, children: /* @__PURE__ */ jsxs25(
2547
+ Modal.Container,
2548
+ {
2549
+ maxWidth: "600px",
2550
+ "aria-label": resolvedTitle,
2551
+ classNames: { container: "!rounded-agg-lg" },
2552
+ children: [
2553
+ /* @__PURE__ */ jsx25(Dialog3.Title, { className: "sr-only", children: resolvedTitle }),
2554
+ /* @__PURE__ */ jsxs25(Modal.Body, { classNames: { root: "px-5 py-6 sm:px-10 sm:py-8" }, children: [
2555
+ step === ONBOARDING_STEPS.HOW_IT_WORKS && /* @__PURE__ */ jsx25(HowItWorksStep, { onContinue: handleHowItWorksContinue, icons: howItWorksIcons }),
2556
+ step === ONBOARDING_STEPS.PROFILE_SETUP && /* @__PURE__ */ jsx25(ProfileSetupStep, { onContinue: handleProfileContinue }),
2557
+ step === ONBOARDING_STEPS.CONNECT_ACCOUNTS && /* @__PURE__ */ jsx25(
2558
+ ConnectAccountsStep,
2559
+ {
2560
+ onConnectOnchain: handleOpenOnchainModal,
2561
+ onConnectKalshi: handleOpenKalshiModal,
2562
+ onContinue: handleConnectContinue,
2563
+ connectedOnchain: connectedOnchain || onchainConnected,
2564
+ connectedKalshi: connectedKalshi || kalshiConnected
2565
+ }
2566
+ )
2567
+ ] })
2568
+ ]
2569
+ }
2570
+ ) }),
2571
+ /* @__PURE__ */ jsx25(
2572
+ ConnectOnchainModal,
2573
+ {
2574
+ open: onchainModalOpen,
2575
+ onOpenChange: setOnchainModalOpen,
2576
+ onConnect: handleOnchainConnect
2577
+ }
2578
+ ),
2579
+ /* @__PURE__ */ jsx25(
2580
+ ConnectKalshiModal,
2581
+ {
2582
+ open: kalshiModalOpen,
2583
+ onOpenChange: setKalshiModalOpen,
2584
+ onVerify: handleKalshiVerify
2585
+ }
2586
+ )
2587
+ ] });
2588
+ };
2589
+ OnboardingModal.displayName = "OnboardingModal";
2590
+
2591
+ // src/profile/index.tsx
2592
+ import { useState as useState11, useEffect as useEffect4, useCallback as useCallback9, useMemo as useMemo2 } from "react";
2593
+ import { useAggClient, useAggAuthState } from "@agg-market/hooks";
2594
+
2595
+ // src/profile/profile-modal.constants.ts
2596
+ var PROFILE_TAB_KEYS = {
2597
+ ABOUT: "about",
2598
+ ACCOUNTS_WALLETS: "accounts-wallets"
2599
+ };
2600
+ var PROFILE_TAB_ITEMS = [
2601
+ { value: PROFILE_TAB_KEYS.ABOUT, label: "About", icon: "profile" },
2602
+ { value: PROFILE_TAB_KEYS.ACCOUNTS_WALLETS, label: "Accounts & wallets", icon: "wallet" }
2603
+ ];
2604
+
2605
+ // src/profile/tabs/about-tab.tsx
2606
+ import { useCallback as useCallback8, useRef as useRef5 } from "react";
2607
+ import { useLabels as useLabels19 } from "@agg-market/hooks";
2608
+ import { jsx as jsx26, jsxs as jsxs26 } from "react/jsx-runtime";
2609
+ var AboutTab = ({
2610
+ avatarPreview,
2611
+ onDeleteProfile: _onDeleteProfile,
2612
+ draftUsername,
2613
+ onDraftUsernameChange,
2614
+ onDraftAvatarChange,
2615
+ draftAvatarPreview
2616
+ }) => {
2617
+ const labels = useLabels19();
2618
+ const fileInputRef = useRef5(null);
2619
+ const handleAvatarClick = useCallback8(() => {
2620
+ var _a;
2621
+ (_a = fileInputRef.current) == null ? void 0 : _a.click();
2622
+ }, []);
2623
+ const handleFileChange = useCallback8(
2624
+ (e) => {
2625
+ var _a;
2626
+ const file = (_a = e.target.files) == null ? void 0 : _a[0];
2627
+ if (!file) return;
2628
+ const reader = new FileReader();
2629
+ reader.onload = (event) => {
2630
+ var _a2;
2631
+ onDraftAvatarChange(file, (_a2 = event.target) == null ? void 0 : _a2.result);
2632
+ };
2633
+ reader.readAsDataURL(file);
2634
+ },
2635
+ [onDraftAvatarChange]
2636
+ );
2637
+ const resolvedPreview = draftAvatarPreview != null ? draftAvatarPreview : avatarPreview;
2638
+ const hasAvatarPreview = Boolean(resolvedPreview);
2639
+ return /* @__PURE__ */ jsxs26("div", { className: "flex flex-col gap-8", children: [
2640
+ /* @__PURE__ */ jsxs26("div", { className: "flex justify-center", children: [
2641
+ /* @__PURE__ */ jsxs26(
2642
+ "button",
2643
+ {
2644
+ type: "button",
2645
+ onClick: handleAvatarClick,
2646
+ className: cn(
2647
+ "group relative flex items-center justify-center",
2648
+ "h-[80px] w-[80px]",
2649
+ "rounded-agg-full",
2650
+ "bg-agg-secondary",
2651
+ !hasAvatarPreview && "hover:bg-agg-secondary-hover",
2652
+ "transition-colors cursor-pointer",
2653
+ "overflow-hidden"
2654
+ ),
2655
+ "aria-label": labels.onboarding.profileSetup.uploadProfilePictureAria,
2656
+ children: [
2657
+ !hasAvatarPreview ? /* @__PURE__ */ jsx26(
2658
+ "svg",
2659
+ {
2660
+ "aria-hidden": true,
2661
+ viewBox: "0 0 80 80",
2662
+ className: "pointer-events-none absolute inset-0 h-full w-full text-agg-separator group-hover:text-agg-muted-foreground",
2663
+ children: /* @__PURE__ */ jsx26(
2664
+ "circle",
2665
+ {
2666
+ cx: "40",
2667
+ cy: "40",
2668
+ r: "39.5",
2669
+ fill: "none",
2670
+ stroke: "currentColor",
2671
+ strokeWidth: "1",
2672
+ strokeDasharray: "8 8"
2673
+ }
2674
+ )
2675
+ }
2676
+ ) : null,
2677
+ resolvedPreview ? /* @__PURE__ */ jsx26(
2678
+ RemoteImage,
2679
+ {
2680
+ src: resolvedPreview,
2681
+ alt: labels.onboarding.profileSetup.profilePreviewAlt,
2682
+ className: "h-full w-full object-cover"
2683
+ }
2684
+ ) : /* @__PURE__ */ jsx26(ProfileIcon, { className: "h-8 w-8 text-agg-muted-foreground" })
2685
+ ]
2686
+ }
2687
+ ),
2688
+ /* @__PURE__ */ jsx26(
2689
+ "input",
2690
+ {
2691
+ ref: fileInputRef,
2692
+ type: "file",
2693
+ accept: "image/*",
2694
+ onChange: handleFileChange,
2695
+ className: "hidden",
2696
+ "aria-hidden": "true"
2697
+ }
2698
+ )
2699
+ ] }),
2700
+ /* @__PURE__ */ jsxs26("div", { className: "flex flex-col gap-2", children: [
2701
+ /* @__PURE__ */ jsx26(
2702
+ "label",
2703
+ {
2704
+ htmlFor: "profile-username",
2705
+ className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground",
2706
+ children: "Username"
2707
+ }
2708
+ ),
2709
+ /* @__PURE__ */ jsx26(
2710
+ "input",
2711
+ {
2712
+ id: "profile-username",
2713
+ type: "text",
2714
+ placeholder: "e.g. CryptoJohn",
2715
+ value: draftUsername,
2716
+ onChange: (e) => onDraftUsernameChange(e.target.value),
2717
+ className: cn(
2718
+ "w-full px-4 py-3",
2719
+ "rounded-agg-xl",
2720
+ "border border-agg-separator",
2721
+ "bg-agg-secondary text-agg-foreground",
2722
+ "placeholder:text-agg-muted-foreground",
2723
+ "outline-none",
2724
+ "focus:border-agg-primary focus:ring-1 focus:ring-agg-primary",
2725
+ "transition-colors",
2726
+ "text-agg-sm sm:text-agg-base"
2727
+ )
2728
+ }
2729
+ )
2730
+ ] })
2731
+ ] });
2732
+ };
2733
+ AboutTab.displayName = "AboutTab";
2734
+
2735
+ // src/profile/tabs/accounts-wallets-tab.tsx
2736
+ import { jsx as jsx27, jsxs as jsxs27 } from "react/jsx-runtime";
2737
+ var SectionTitle = ({ children }) => /* @__PURE__ */ jsx27("h3", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children });
2738
+ var AccountRow = ({ children, className }) => /* @__PURE__ */ jsx27(
2739
+ "div",
2740
+ {
2741
+ className: cn(
2742
+ "flex items-center justify-between",
2743
+ "rounded-agg-lg border border-agg-separator bg-agg-secondary",
2744
+ "px-5 py-3",
2745
+ className
2746
+ ),
2747
+ children
2748
+ }
2749
+ );
2750
+ var ConnectTextButton = ({ onClick }) => /* @__PURE__ */ jsx27(
2751
+ "button",
2752
+ {
2753
+ type: "button",
2754
+ onClick,
2755
+ className: "shrink-0 cursor-pointer text-agg-sm font-agg-bold leading-agg-5 text-agg-primary whitespace-nowrap",
2756
+ children: "Connect"
2757
+ }
2758
+ );
2759
+ var DisconnectTextButton = ({ onClick }) => /* @__PURE__ */ jsx27(
2760
+ "button",
2761
+ {
2762
+ type: "button",
2763
+ onClick,
2764
+ className: "shrink-0 cursor-pointer text-agg-sm font-agg-bold leading-agg-5 text-agg-muted-foreground whitespace-nowrap",
2765
+ children: "Disconnect"
2766
+ }
2767
+ );
2768
+ var AccountsWalletsTab = ({
2769
+ exchanges,
2770
+ socialAccounts,
2771
+ email,
2772
+ onDisconnectExchange,
2773
+ onConnectTwitter,
2774
+ onDisconnectTwitter,
2775
+ onConnectDiscord: _onConnectDiscord,
2776
+ onDisconnectDiscord: _onDisconnectDiscord,
2777
+ onConnectTelegram: _onConnectTelegram,
2778
+ onDisconnectTelegram: _onDisconnectTelegram,
2779
+ onConnectEmail
2780
+ }) => {
2781
+ const twitter = socialAccounts == null ? void 0 : socialAccounts.twitter;
2782
+ return /* @__PURE__ */ jsxs27("div", { className: "flex flex-col gap-8", children: [
2783
+ /* @__PURE__ */ jsxs27("div", { className: "flex flex-col gap-3", children: [
2784
+ /* @__PURE__ */ jsx27(SectionTitle, { children: "Exchanges" }),
2785
+ exchanges.length === 0 ? /* @__PURE__ */ jsx27("p", { className: "text-agg-sm leading-agg-5 text-agg-muted-foreground", children: "No exchange accounts connected." }) : /* @__PURE__ */ jsx27("div", { className: "flex flex-col gap-2", children: exchanges.map((account) => {
2786
+ var _a;
2787
+ const displayName = (_a = venueLogoLabels[account.venue]) != null ? _a : account.venue;
2788
+ return /* @__PURE__ */ jsxs27(AccountRow, { children: [
2789
+ /* @__PURE__ */ jsxs27("div", { className: "flex items-center gap-3 min-w-0", children: [
2790
+ /* @__PURE__ */ jsx27(VenueLogo, { venue: account.venue, size: "small" }),
2791
+ /* @__PURE__ */ jsx27("span", { className: "text-agg-base font-agg-normal leading-6 text-agg-foreground whitespace-nowrap", children: displayName }),
2792
+ /* @__PURE__ */ jsxs27("div", { className: "flex items-center gap-2 min-w-0", children: [
2793
+ /* @__PURE__ */ jsx27("span", { className: "truncate text-agg-base font-agg-normal leading-6 text-agg-foreground", children: account.displayAddress }),
2794
+ account.verified ? /* @__PURE__ */ jsx27(
2795
+ Icon,
2796
+ {
2797
+ name: "check-badge",
2798
+ size: "small",
2799
+ color: "var(--agg-color-primary, #536dfe)"
2800
+ }
2801
+ ) : null
2802
+ ] })
2803
+ ] }),
2804
+ /* @__PURE__ */ jsx27(DisconnectTextButton, { onClick: () => onDisconnectExchange(account.venue) })
2805
+ ] }, account.venue);
2806
+ }) })
2807
+ ] }),
2808
+ /* @__PURE__ */ jsxs27("div", { className: "flex flex-col gap-3", children: [
2809
+ /* @__PURE__ */ jsx27(SectionTitle, { children: "Social Accounts" }),
2810
+ /* @__PURE__ */ jsx27("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ jsxs27(AccountRow, { children: [
2811
+ /* @__PURE__ */ jsxs27("div", { className: "flex items-center gap-3", children: [
2812
+ /* @__PURE__ */ jsx27("span", { className: "flex h-5 w-5 shrink-0 items-center justify-center text-agg-foreground", children: /* @__PURE__ */ jsx27(Icon, { name: "twitter", size: "small", color: "currentColor" }) }),
2813
+ /* @__PURE__ */ jsx27("span", { className: "text-agg-base font-agg-normal leading-6 text-agg-foreground whitespace-nowrap", children: "X (Twitter)" })
2814
+ ] }),
2815
+ (twitter == null ? void 0 : twitter.connected) ? /* @__PURE__ */ jsx27(DisconnectTextButton, { onClick: onDisconnectTwitter }) : /* @__PURE__ */ jsx27(ConnectTextButton, { onClick: onConnectTwitter })
2816
+ ] }) })
2817
+ ] }),
2818
+ /* @__PURE__ */ jsxs27("div", { className: "flex flex-col gap-3", children: [
2819
+ /* @__PURE__ */ jsx27(SectionTitle, { children: "Email Address" }),
2820
+ /* @__PURE__ */ jsxs27(
2821
+ "button",
2822
+ {
2823
+ type: "button",
2824
+ onClick: onConnectEmail,
2825
+ className: cn(
2826
+ "flex items-center justify-between",
2827
+ "rounded-agg-lg border border-agg-separator bg-agg-secondary",
2828
+ "px-5 py-3",
2829
+ "cursor-pointer hover:bg-agg-secondary-hover"
2830
+ ),
2831
+ children: [
2832
+ /* @__PURE__ */ jsxs27("div", { className: "flex items-center gap-3", children: [
2833
+ /* @__PURE__ */ jsx27("span", { className: "flex h-5 w-5 shrink-0 items-center justify-center text-agg-foreground", children: /* @__PURE__ */ jsx27(Icon, { name: "email", size: "small", color: "currentColor" }) }),
2834
+ /* @__PURE__ */ jsx27("span", { className: "text-agg-base font-agg-normal leading-6 text-agg-foreground whitespace-nowrap", children: email != null ? email : "Connect email" })
2835
+ ] }),
2836
+ /* @__PURE__ */ jsx27(Icon, { name: "chevron-right", size: "small", color: "currentColor" })
2837
+ ]
2838
+ }
2839
+ )
2840
+ ] })
2841
+ ] });
2842
+ };
2843
+ AccountsWalletsTab.displayName = "AccountsWalletsTab";
2844
+
2845
+ // src/profile/index.tsx
2846
+ import { jsx as jsx28, jsxs as jsxs28 } from "react/jsx-runtime";
2847
+ var ProfileModal = ({
2848
+ open,
2849
+ onOpenChange,
2850
+ username,
2851
+ avatarPreview,
2852
+ onSave,
2853
+ onDeleteProfile,
2854
+ exchanges,
2855
+ socialAccounts,
2856
+ email,
2857
+ onDisconnectExchange,
2858
+ onConnectTwitter,
2859
+ onDisconnectTwitter,
2860
+ onConnectDiscord,
2861
+ onDisconnectDiscord,
2862
+ onConnectTelegram,
2863
+ onDisconnectTelegram,
2864
+ onConnectEmail
2865
+ }) => {
2866
+ var _a, _b, _c, _d, _e, _f;
2867
+ const client = useAggClient();
2868
+ const { user, startAuth } = useAggAuthState();
2869
+ const [activeTab, setActiveTab] = useState11(PROFILE_TAB_KEYS.ABOUT);
2870
+ const [draftUsername, setDraftUsername] = useState11(username != null ? username : "");
2871
+ const [draftAvatarFile, setDraftAvatarFile] = useState11();
2872
+ const [draftAvatarPreview, setDraftAvatarPreview] = useState11();
2873
+ const [isSaving, setIsSaving] = useState11(false);
2874
+ useEffect4(() => {
2875
+ setDraftUsername(username != null ? username : "");
2876
+ }, [username]);
2877
+ const handleOpenChange = useCallback9(
2878
+ (isOpen) => {
2879
+ if (!isOpen) {
2880
+ setActiveTab(PROFILE_TAB_KEYS.ABOUT);
2881
+ setIsSaving(false);
2882
+ setDraftUsername(username != null ? username : "");
2883
+ setDraftAvatarFile(void 0);
2884
+ setDraftAvatarPreview(void 0);
2885
+ }
2886
+ onOpenChange(isOpen);
2887
+ },
2888
+ [
2889
+ onOpenChange,
2890
+ username,
2891
+ setActiveTab,
2892
+ setIsSaving,
2893
+ setDraftUsername,
2894
+ setDraftAvatarFile,
2895
+ setDraftAvatarPreview
2896
+ ]
2897
+ );
2898
+ const handleDraftAvatarChange = useCallback9(
2899
+ (file, preview) => {
2900
+ setDraftAvatarFile(file);
2901
+ setDraftAvatarPreview(preview);
2902
+ },
2903
+ []
2904
+ );
2905
+ const hasChanges = draftUsername !== (username != null ? username : "") || draftAvatarFile !== void 0;
2906
+ const handleSave = useCallback9(() => __async(null, null, function* () {
2907
+ setIsSaving(true);
2908
+ try {
2909
+ const normalizedUsername = draftUsername.trim();
2910
+ if (normalizedUsername !== (username != null ? username : "")) {
2911
+ yield client.updateUser({ username: normalizedUsername || void 0 });
2912
+ }
2913
+ if (draftAvatarFile) {
2914
+ const { uploadUrl } = yield client.createAvatarUploadUrl(draftAvatarFile.type);
2915
+ yield fetch(uploadUrl, {
2916
+ method: "PUT",
2917
+ headers: {
2918
+ "Content-Type": draftAvatarFile.type
2919
+ },
2920
+ body: draftAvatarFile
2921
+ });
2922
+ yield client.updateUser({ confirmAvatar: true });
2923
+ }
2924
+ yield client.getCurrentUser();
2925
+ onSave({
2926
+ username: normalizedUsername || void 0,
2927
+ avatarFile: draftAvatarFile,
2928
+ avatarPreview: draftAvatarPreview
2929
+ });
2930
+ onOpenChange(false);
2931
+ } finally {
2932
+ setIsSaving(false);
2933
+ }
2934
+ }), [client, draftAvatarFile, draftAvatarPreview, draftUsername, onOpenChange, onSave, username]);
2935
+ const handleCancel = useCallback9(() => {
2936
+ handleOpenChange(false);
2937
+ }, [handleOpenChange]);
2938
+ const isAccountConnected = (providers) => {
2939
+ var _a2, _b2, _c2;
2940
+ const normalizedProviders = providers.map((provider) => provider.toLowerCase());
2941
+ const fromAccounts = (_b2 = (_a2 = user == null ? void 0 : user.accounts) == null ? void 0 : _a2.some(
2942
+ (account) => normalizedProviders.includes(String(account.provider).toLowerCase())
2943
+ )) != null ? _b2 : false;
2944
+ const legacyIdentities = user == null ? void 0 : user.identities;
2945
+ const fromLegacy = (_c2 = legacyIdentities == null ? void 0 : legacyIdentities.some(
2946
+ (identity) => {
2947
+ var _a3;
2948
+ return normalizedProviders.includes(String((_a3 = identity.provider) != null ? _a3 : "").toLowerCase());
2949
+ }
2950
+ )) != null ? _c2 : false;
2951
+ return fromAccounts || fromLegacy;
2952
+ };
2953
+ const resolvedSocialAccounts = socialAccounts != null ? socialAccounts : {
2954
+ twitter: {
2955
+ connected: isAccountConnected(["twitter"])
2956
+ }
2957
+ };
2958
+ const resolvedEmail = (_f = (_e = email != null ? email : (_b = (_a = user == null ? void 0 : user.accounts) == null ? void 0 : _a.find(
2959
+ (account) => String(account.provider).toLowerCase() === "email"
2960
+ )) == null ? void 0 : _b.providerAccountId) != null ? _e : (_d = (_c = user == null ? void 0 : user.identities) == null ? void 0 : _c.find((identity) => {
2961
+ var _a2;
2962
+ return String((_a2 = identity.provider) != null ? _a2 : "").toLowerCase() === "email";
2963
+ })) == null ? void 0 : _d.providerAccountId) != null ? _f : null;
2964
+ const resolveRedirectUrl = () => {
2965
+ if (typeof window === "undefined") return "http://localhost";
2966
+ return `${window.location.origin}${window.location.pathname}${window.location.search}`;
2967
+ };
2968
+ const handleConnectTwitter = useCallback9(() => __async(null, null, function* () {
2969
+ const result = yield startAuth({
2970
+ provider: "twitter",
2971
+ redirectUrl: resolveRedirectUrl()
2972
+ });
2973
+ onConnectTwitter == null ? void 0 : onConnectTwitter();
2974
+ if (result.type === "redirect" && typeof window !== "undefined") {
2975
+ window.location.assign(result.url);
2976
+ }
2977
+ }), [onConnectTwitter, startAuth]);
2978
+ const handleDisconnectTwitter = useCallback9(() => __async(null, null, function* () {
2979
+ yield client.disconnectAccount("twitter");
2980
+ yield client.getCurrentUser();
2981
+ onDisconnectTwitter == null ? void 0 : onDisconnectTwitter();
2982
+ }), [client, onDisconnectTwitter]);
2983
+ const handleConnectEmail = useCallback9(() => __async(null, null, function* () {
2984
+ var _a2;
2985
+ const typedEmail = typeof window !== "undefined" ? (_a2 = window.prompt("Enter your email to receive a magic link")) == null ? void 0 : _a2.trim() : void 0;
2986
+ if (!typedEmail) return;
2987
+ yield startAuth({
2988
+ provider: "email",
2989
+ email: typedEmail,
2990
+ redirectUrl: resolveRedirectUrl()
2991
+ });
2992
+ onConnectEmail == null ? void 0 : onConnectEmail();
2993
+ }), [onConnectEmail, startAuth]);
2994
+ const providerActionMap = useMemo2(
2995
+ () => ({
2996
+ twitter: {
2997
+ connect: () => {
2998
+ void handleConnectTwitter();
2999
+ },
3000
+ disconnect: () => {
3001
+ void handleDisconnectTwitter();
3002
+ }
3003
+ },
3004
+ email: {
3005
+ connect: () => {
3006
+ void handleConnectEmail();
3007
+ }
3008
+ }
3009
+ }),
3010
+ [handleConnectEmail, handleConnectTwitter, handleDisconnectTwitter]
3011
+ );
3012
+ return /* @__PURE__ */ jsx28(Modal, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxs28(Modal.Container, { maxWidth: "800px", "aria-label": "Edit Profile", children: [
3013
+ /* @__PURE__ */ jsx28(Modal.Header, { title: "Edit Profile" }),
3014
+ /* @__PURE__ */ jsx28(Modal.Body, { children: /* @__PURE__ */ jsxs28("div", { className: "flex flex-col sm:flex-row sm:gap-10", children: [
3015
+ /* @__PURE__ */ jsxs28("div", { className: "shrink-0", children: [
3016
+ /* @__PURE__ */ jsx28("div", { className: "flex gap-2 sm:hidden mb-6", children: PROFILE_TAB_ITEMS.map((tab) => {
3017
+ const isActive = activeTab === tab.value;
3018
+ return /* @__PURE__ */ jsxs28(
3019
+ "button",
3020
+ {
3021
+ type: "button",
3022
+ onClick: () => setActiveTab(tab.value),
3023
+ className: cn(
3024
+ "flex items-center gap-3 px-4 py-3 rounded-agg-lg",
3025
+ "text-agg-sm leading-agg-5 font-agg-sans",
3026
+ "transition-colors cursor-pointer",
3027
+ "border-b-2",
3028
+ isActive ? "font-agg-normal text-agg-foreground bg-agg-secondary-hover border-agg-primary" : "font-agg-normal text-agg-foreground border-transparent"
3029
+ ),
3030
+ children: [
3031
+ /* @__PURE__ */ jsx28(Icon, { name: tab.icon, size: "small", color: "currentColor" }),
3032
+ /* @__PURE__ */ jsx28("span", { className: "whitespace-nowrap", children: tab.label })
3033
+ ]
3034
+ },
3035
+ tab.value
3036
+ );
3037
+ }) }),
3038
+ /* @__PURE__ */ jsx28(
3039
+ "nav",
3040
+ {
3041
+ className: cn(
3042
+ "hidden sm:flex sm:flex-col",
3043
+ "w-[240px]",
3044
+ "overflow-hidden rounded-agg-lg",
3045
+ "border border-agg-separator",
3046
+ "bg-agg-secondary",
3047
+ "py-3"
3048
+ ),
3049
+ role: "tablist",
3050
+ "aria-label": "Profile sections",
3051
+ children: PROFILE_TAB_ITEMS.map((tab) => {
3052
+ const isActive = activeTab === tab.value;
3053
+ return /* @__PURE__ */ jsxs28(
3054
+ "button",
3055
+ {
3056
+ type: "button",
3057
+ role: "tab",
3058
+ "aria-selected": isActive,
3059
+ onClick: () => setActiveTab(tab.value),
3060
+ className: cn(
3061
+ "relative flex items-center gap-3",
3062
+ "h-[49px] px-6 py-4",
3063
+ "text-agg-sm leading-agg-5 font-agg-sans",
3064
+ "transition-colors cursor-pointer",
3065
+ isActive ? "font-agg-normal text-agg-foreground bg-agg-secondary-hover" : "font-agg-normal text-agg-foreground"
3066
+ ),
3067
+ children: [
3068
+ isActive ? /* @__PURE__ */ jsx28("div", { className: "absolute left-0 top-0 bottom-0 w-1 bg-agg-primary" }) : null,
3069
+ /* @__PURE__ */ jsx28(Icon, { name: tab.icon, size: "small", color: "currentColor" }),
3070
+ /* @__PURE__ */ jsx28("span", { className: "shrink-0 whitespace-nowrap", children: tab.label })
3071
+ ]
3072
+ },
3073
+ tab.value
3074
+ );
3075
+ })
3076
+ }
3077
+ )
3078
+ ] }),
3079
+ /* @__PURE__ */ jsxs28("div", { className: "min-w-0 flex-1", children: [
3080
+ activeTab === PROFILE_TAB_KEYS.ABOUT ? /* @__PURE__ */ jsx28(
3081
+ AboutTab,
3082
+ {
3083
+ username,
3084
+ avatarPreview,
3085
+ onDeleteProfile,
3086
+ draftUsername,
3087
+ onDraftUsernameChange: setDraftUsername,
3088
+ draftAvatarFile,
3089
+ onDraftAvatarChange: handleDraftAvatarChange,
3090
+ draftAvatarPreview
3091
+ }
3092
+ ) : null,
3093
+ activeTab === PROFILE_TAB_KEYS.ACCOUNTS_WALLETS ? /* @__PURE__ */ jsx28(
3094
+ AccountsWalletsTab,
3095
+ {
3096
+ exchanges,
3097
+ socialAccounts: resolvedSocialAccounts,
3098
+ email: resolvedEmail,
3099
+ onDisconnectExchange,
3100
+ onConnectTwitter: providerActionMap.twitter.connect,
3101
+ onDisconnectTwitter: providerActionMap.twitter.disconnect,
3102
+ onConnectDiscord,
3103
+ onDisconnectDiscord,
3104
+ onConnectTelegram,
3105
+ onDisconnectTelegram,
3106
+ onConnectEmail: providerActionMap.email.connect
3107
+ }
3108
+ ) : null
3109
+ ] })
3110
+ ] }) }),
3111
+ /* @__PURE__ */ jsxs28(Modal.Footer, { children: [
3112
+ /* @__PURE__ */ jsx28(Button, { variant: "secondary", size: "large", onClick: handleCancel, className: "min-w-[120px]", children: "Cancel" }),
3113
+ /* @__PURE__ */ jsx28(
3114
+ Button,
3115
+ {
3116
+ variant: "primary",
3117
+ size: "large",
3118
+ disabled: !hasChanges,
3119
+ isLoading: isSaving,
3120
+ onClick: handleSave,
3121
+ children: "Save Changes"
3122
+ }
3123
+ )
3124
+ ] })
3125
+ ] }) });
3126
+ };
3127
+ ProfileModal.displayName = "ProfileModal";
3128
+
3129
+ export {
3130
+ DepositModal,
3131
+ OnrampModal,
3132
+ WithdrawModal,
3133
+ HowItWorksStep,
3134
+ ProfileSetupStep,
3135
+ ConnectAccountsStep,
3136
+ ConnectKalshiModal,
3137
+ ConnectOnchainModal,
3138
+ OnboardingModal,
3139
+ ProfileModal
3140
+ };