@funkit/connect 10.0.0 → 10.1.0-next.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 (77) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/clients/chunk-42XZD2Y3.js +1112 -0
  3. package/dist/clients/chunk-5UIZBNLC.js +1175 -0
  4. package/dist/clients/chunk-BO7AZVPG.js +1112 -0
  5. package/dist/clients/chunk-BUCJRBW7.js +1472 -0
  6. package/dist/clients/{chunk-2NBYHUIW.js → chunk-ETB2YYFT.js} +1 -1
  7. package/dist/clients/{chunk-ZAXSDMDU.js → chunk-HD4Y4NKC.js} +2 -2
  8. package/dist/clients/{chunk-E3USJY7A.js → chunk-JNZY3GAA.js} +1 -1
  9. package/dist/clients/chunk-ME4OAQIY.js +696 -0
  10. package/dist/clients/chunk-PEVDOGEA.js +109 -0
  11. package/dist/clients/chunk-QIWGVVAW.js +1113 -0
  12. package/dist/clients/chunk-VJZW3MA3.js +94 -0
  13. package/dist/clients/chunk-WEETVC7U.js +1113 -0
  14. package/dist/clients/chunk-Y2KXVS36.js +230 -0
  15. package/dist/clients/fanatics.css +1 -1
  16. package/dist/clients/fanatics.js +2 -2
  17. package/dist/clients/lighter.css +11 -11
  18. package/dist/clients/lighter.d.ts +12 -2
  19. package/dist/clients/lighter.js +21 -9
  20. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +11 -11
  21. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +3 -3
  22. package/dist/clients/polymarket/index.css +11 -11
  23. package/dist/clients/polymarket/index.js +3 -3
  24. package/dist/clients/polymarket/usePolymarketAccountBalances.d.ts +66 -0
  25. package/dist/hooks/useIsTokenWhitelisted.d.ts +30 -0
  26. package/dist/index.css +11 -11
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +78 -31
  29. package/dist/modals/CheckoutModal/buildRelayChains.d.ts +12 -0
  30. package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +32 -5
  31. package/dist/modals/WithdrawalModal/useWithdrawal.d.ts +3 -3
  32. package/dist/providers/FunkitCheckoutContext/types.d.ts +20 -2
  33. package/dist/providers/FunkitFlagsProvider.d.ts +26 -0
  34. package/dist/utils/flags/config.d.ts +333 -0
  35. package/dist/utils/flags/endpoint.d.ts +22 -0
  36. package/dist/utils/flags/hash.d.ts +13 -0
  37. package/dist/utils/flags/impl.d.ts +10 -0
  38. package/dist/utils/flags/types.d.ts +49 -0
  39. package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
  40. package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
  41. package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
  42. package/dist/wallets/walletConnectors/chunk-4NV5BYRP.js +95 -0
  43. package/dist/wallets/walletConnectors/chunk-AVDUNQUW.js +96 -0
  44. package/dist/wallets/walletConnectors/chunk-GUQM4QSL.js +66 -0
  45. package/dist/wallets/walletConnectors/chunk-IULPZP2Q.js +69 -0
  46. package/dist/wallets/walletConnectors/chunk-JPN6TWIT.js +92 -0
  47. package/dist/wallets/walletConnectors/chunk-KCRO2AGO.js +106 -0
  48. package/dist/wallets/walletConnectors/chunk-KI5Y2BBF.js +94 -0
  49. package/dist/wallets/walletConnectors/chunk-NR2OGDHQ.js +103 -0
  50. package/dist/wallets/walletConnectors/chunk-OEEGYENV.js +87 -0
  51. package/dist/wallets/walletConnectors/chunk-OX37G4YT.js +98 -0
  52. package/dist/wallets/walletConnectors/chunk-SWFF3TWJ.js +100 -0
  53. package/dist/wallets/walletConnectors/chunk-TKB2OY6G.js +99 -0
  54. package/dist/wallets/walletConnectors/chunk-W2LCLDPX.js +70 -0
  55. package/dist/wallets/walletConnectors/chunk-WAHGI5L7.js +96 -0
  56. package/dist/wallets/walletConnectors/chunk-WKNQMP4A.js +93 -0
  57. package/dist/wallets/walletConnectors/chunk-XCNHV3HS.js +110 -0
  58. package/dist/wallets/walletConnectors/chunk-YO2K4MBH.js +218 -0
  59. package/dist/wallets/walletConnectors/chunk-YQFGVZGR.js +92 -0
  60. package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
  61. package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
  62. package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
  63. package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
  64. package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
  65. package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
  66. package/dist/wallets/walletConnectors/index.js +61 -61
  67. package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
  68. package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
  69. package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
  70. package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
  71. package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
  72. package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
  73. package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
  74. package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
  75. package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
  76. package/package.json +1 -1
  77. /package/dist/clients/{chunk-LUHEVXPD.js → chunk-HMP3LHMW.js} +0 -0
@@ -0,0 +1,1113 @@
1
+ "use client";
2
+ import {
3
+ usePolymarketAccountBalances
4
+ } from "./chunk-ZEXZQOAO.js";
5
+ import {
6
+ POLYMARKET_PERPS_ROUTING_ID,
7
+ POLYMARKET_PREDICTIONS_ROUTING_ID
8
+ } from "./chunk-VJZW3MA3.js";
9
+ import {
10
+ FunInput,
11
+ FunSkeletonBlock,
12
+ TooltipAnchorRefContext
13
+ } from "./chunk-AIYBOVHV.js";
14
+ import {
15
+ Box,
16
+ Text,
17
+ themeVars
18
+ } from "./chunk-PEVDOGEA.js";
19
+ import {
20
+ useFunkitTranslation
21
+ } from "./chunk-STLOQEN7.js";
22
+ import {
23
+ POLYGON_USDCE,
24
+ PUSD_TOKEN
25
+ } from "./chunk-ME4OAQIY.js";
26
+ import {
27
+ logger
28
+ } from "./chunk-AHYOV7AV.js";
29
+
30
+ // src/clients/polymarket/PolymarketDepositAccountDropdown.tsx
31
+ import React12 from "react";
32
+ import { polygon } from "viem/chains";
33
+
34
+ // src/components/Dropdown/AccountSelectDropdown.tsx
35
+ import React11, { useEffect as useEffect4 } from "react";
36
+
37
+ // src/components/Dropdown/BaseDropdown.tsx
38
+ import { isMobile } from "@funkit/utils";
39
+ import * as DropdownMenu2 from "@radix-ui/react-dropdown-menu";
40
+ import React10, { useCallback as useCallback2, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
41
+
42
+ // src/hooks/useScrollDivider.ts
43
+ import { useCallback, useEffect, useState } from "react";
44
+ var useScrollDivider = () => {
45
+ const [refElement, setRefElement] = useState(null);
46
+ const ref = useCallback((node) => setRefElement(node), []);
47
+ const [isTop, setIsTop] = useState(true);
48
+ const [isAtBottom, setIsAtBottom] = useState(false);
49
+ const [isScrollable, setIsScrollable] = useState(false);
50
+ const [isScrolling, setIsScrolling] = useState(false);
51
+ useEffect(() => {
52
+ const content = refElement;
53
+ if (!content || !window.ResizeObserver) {
54
+ return;
55
+ }
56
+ const handleScrollPositionChange = () => {
57
+ const { scrollTop, scrollHeight, clientHeight } = content;
58
+ setIsTop(scrollTop === 0);
59
+ setIsAtBottom(scrollTop + clientHeight >= scrollHeight - 1);
60
+ setIsScrollable(scrollHeight > clientHeight + 2);
61
+ };
62
+ const handleContentChange = () => {
63
+ handleScrollPositionChange();
64
+ setTimeout(handleScrollPositionChange, 500);
65
+ };
66
+ const onScrollChange = () => {
67
+ handleScrollPositionChange();
68
+ setIsScrolling(true);
69
+ };
70
+ const onScrollEnd = () => setIsScrolling(false);
71
+ content.addEventListener("scrollend", onScrollEnd);
72
+ content.addEventListener("scroll", onScrollChange);
73
+ const resizeObserver = new window.ResizeObserver(handleContentChange);
74
+ resizeObserver.observe(content);
75
+ const mutationObserver = new MutationObserver(handleContentChange);
76
+ mutationObserver.observe(content, {
77
+ childList: true,
78
+ subtree: true,
79
+ attributes: true,
80
+ attributeFilter: ["style", "class"]
81
+ });
82
+ handleScrollPositionChange();
83
+ return () => {
84
+ content.removeEventListener("scroll", onScrollChange);
85
+ content.removeEventListener("scrollend", onScrollEnd);
86
+ resizeObserver.unobserve(content);
87
+ mutationObserver.disconnect();
88
+ };
89
+ }, [refElement]);
90
+ return {
91
+ ref,
92
+ hasTopDivider: !isTop,
93
+ hasBottomDivider: isScrollable,
94
+ isAtBottom,
95
+ isScrolling,
96
+ isScrollable
97
+ };
98
+ };
99
+
100
+ // src/providers/FunkitProvider.tsx
101
+ import { LogLevel, initializeRelayClient } from "@funkit/fun-relay";
102
+ import { QueryClientProvider } from "@tanstack/react-query";
103
+ import React8, {
104
+ createContext,
105
+ useContext,
106
+ useEffect as useEffect2,
107
+ useMemo,
108
+ useRef
109
+ } from "react";
110
+
111
+ // src/utils/tokenMath.ts
112
+ import { formatCurrencyAndStringify } from "@funkit/utils";
113
+ import * as dnum from "dnum";
114
+ import { formatUnits } from "viem";
115
+ function floorToDecimals(value, decimals) {
116
+ const d = dnum.from(value, decimals);
117
+ return dnum.toNumber(d, decimals);
118
+ }
119
+ function formatUsdFlooredToCent(balanceUsd) {
120
+ return formatCurrencyAndStringify(floorToDecimals(balanceUsd, 2));
121
+ }
122
+
123
+ // src/components/Icons/CheckIcon.tsx
124
+ import React from "react";
125
+ var CheckIcon = ({
126
+ size = 16,
127
+ className
128
+ }) => /* @__PURE__ */ React.createElement(
129
+ "svg",
130
+ {
131
+ width: size,
132
+ height: size,
133
+ viewBox: "0 0 16 16",
134
+ fill: "none",
135
+ xmlns: "http://www.w3.org/2000/svg",
136
+ className
137
+ },
138
+ /* @__PURE__ */ React.createElement(
139
+ "path",
140
+ {
141
+ d: "M12.4919 4.88281L6.25757 11.1172L3.50781 8",
142
+ stroke: "currentColor",
143
+ strokeWidth: "1.5",
144
+ strokeLinecap: "round",
145
+ strokeLinejoin: "round",
146
+ pathLength: "100"
147
+ }
148
+ )
149
+ );
150
+
151
+ // src/components/Dropdown/BaseDropdownItem.tsx
152
+ import { noop } from "@funkit/utils";
153
+ import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
154
+ import React2 from "react";
155
+ import clsx from "clsx";
156
+
157
+ // src/components/Dropdown/BaseDropdownItem.css.ts
158
+ var disabledDropdownItemStyles = "BaseDropdownItem_disabledDropdownItemStyles__18hhw3k3 BaseDropdownItem__18hhw3k2";
159
+ var enabledDropdownItemStyles = "BaseDropdownItem_enabledDropdownItemStyles__18hhw3k1 BaseDropdownItem__18hhw3k0";
160
+
161
+ // src/components/Dropdown/BaseDropdownItem.tsx
162
+ function BaseDropdownItem({
163
+ iconComponent,
164
+ label,
165
+ description,
166
+ id,
167
+ onClick = noop,
168
+ isSelected = false,
169
+ isDisabled = false,
170
+ borderRadius = "connectButton",
171
+ horizontalIconGap = "dropdownItemIconGap",
172
+ tagComponent,
173
+ horizontalPadding = "dropdownItemPaddingX",
174
+ verticalPadding = "dropdownItemPaddingY"
175
+ }) {
176
+ return /* @__PURE__ */ React2.createElement(
177
+ DropdownMenu.Item,
178
+ {
179
+ disabled: isDisabled,
180
+ onSelect: () => onClick(id),
181
+ asChild: true
182
+ },
183
+ /* @__PURE__ */ React2.createElement(
184
+ Box,
185
+ {
186
+ width: "full",
187
+ display: "flex",
188
+ alignItems: "center",
189
+ justifyContent: "space-between",
190
+ gap: "24",
191
+ paddingY: verticalPadding,
192
+ paddingX: horizontalPadding,
193
+ className: clsx(
194
+ isDisabled ? disabledDropdownItemStyles : enabledDropdownItemStyles
195
+ ),
196
+ boxShadow: isSelected ? "selectedDropdownItem" : void 0,
197
+ borderRadius
198
+ },
199
+ /* @__PURE__ */ React2.createElement(
200
+ Box,
201
+ {
202
+ display: "flex",
203
+ alignItems: "center",
204
+ justifyContent: "flex-start",
205
+ gap: horizontalIconGap
206
+ },
207
+ iconComponent && /* @__PURE__ */ React2.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "center" }, iconComponent),
208
+ /* @__PURE__ */ React2.createElement(Box, { display: "flex", flexDirection: "column", justifyContent: "center" }, /* @__PURE__ */ React2.createElement(
209
+ Text,
210
+ {
211
+ size: "dropdownItemFontSize",
212
+ weight: "medium",
213
+ color: isSelected ? "selectedDropdownItemText" : void 0
214
+ },
215
+ label
216
+ ), description != null && /* @__PURE__ */ React2.createElement(Text, { size: "12", color: "secondaryText" }, description))
217
+ ),
218
+ /* @__PURE__ */ React2.createElement(
219
+ Box,
220
+ {
221
+ display: "flex",
222
+ alignItems: "center",
223
+ justifyContent: "center",
224
+ gap: "16"
225
+ },
226
+ tagComponent,
227
+ /* @__PURE__ */ React2.createElement(
228
+ Box,
229
+ {
230
+ width: "16",
231
+ height: "16",
232
+ alignItems: "center",
233
+ justifyContent: "center",
234
+ color: isSelected ? "selectedDropdownItemText" : "transparent"
235
+ },
236
+ /* @__PURE__ */ React2.createElement(CheckIcon, null)
237
+ )
238
+ )
239
+ )
240
+ );
241
+ }
242
+ var BaseDropdownItem_default = BaseDropdownItem;
243
+
244
+ // src/components/Icons/CaretDownIcon.tsx
245
+ import clsx2 from "clsx";
246
+ import React3 from "react";
247
+
248
+ // src/components/Icons/CaretDownIcon.css.ts
249
+ var caretClosed = "CaretDownIcon_caretClosed__1gjdf1i3";
250
+ var caretOpened = "CaretDownIcon_caretOpened__1gjdf1i2";
251
+
252
+ // src/components/Icons/CaretDownIcon.tsx
253
+ var CaretDownIcon = () => {
254
+ return /* @__PURE__ */ React3.createElement(
255
+ "svg",
256
+ {
257
+ width: "8",
258
+ height: "5",
259
+ viewBox: "0 0 8 5",
260
+ fill: "none",
261
+ xmlns: "http://www.w3.org/2000/svg"
262
+ },
263
+ /* @__PURE__ */ React3.createElement(
264
+ "path",
265
+ {
266
+ d: "M3.45163 2.92973L0.879121 0.393174C0.654314 0.188182 0.317464 0.217886 0.126753 0.459527C-0.0639587 0.701168 -0.036324 1.06324 0.188483 1.26824L3.60944 4.64138C3.65478 4.68988 3.70789 4.72919 3.76623 4.7574C3.83874 4.79249 3.91764 4.80968 3.99714 4.80771C4.07647 4.80576 4.15489 4.78486 4.22578 4.74655C4.23264 4.74283 4.23943 4.73894 4.24614 4.7349C4.28505 4.71152 4.32107 4.68295 4.35332 4.64987L7.82907 1.18704C8.04528 0.97163 8.0581 0.608604 7.8577 0.376205C7.6573 0.143806 7.31956 0.130027 7.10335 0.345432L4.51922 2.91996C4.51922 2.94623 4 3.43025 4 3.43025L3.45163 2.92973Z",
267
+ fill: "currentColor"
268
+ }
269
+ )
270
+ );
271
+ };
272
+ var AnimatedCaretDownIcon = ({
273
+ expanded,
274
+ color = "primaryText",
275
+ compact = false
276
+ }) => {
277
+ const animationClassName = clsx2(
278
+ expanded !== void 0 && (expanded ? caretOpened : caretClosed)
279
+ );
280
+ if (compact) {
281
+ return /* @__PURE__ */ React3.createElement(
282
+ Box,
283
+ {
284
+ color,
285
+ width: "8",
286
+ height: "8",
287
+ display: "flex",
288
+ alignItems: "center",
289
+ justifyContent: "center",
290
+ className: animationClassName
291
+ },
292
+ /* @__PURE__ */ React3.createElement(CaretDownIcon, null)
293
+ );
294
+ }
295
+ return /* @__PURE__ */ React3.createElement(
296
+ Box,
297
+ {
298
+ color,
299
+ width: "16",
300
+ height: "16",
301
+ display: "flex",
302
+ alignItems: "center",
303
+ justifyContent: "center",
304
+ className: animationClassName
305
+ },
306
+ /* @__PURE__ */ React3.createElement(
307
+ Box,
308
+ {
309
+ width: "8",
310
+ height: "8",
311
+ display: "flex",
312
+ alignItems: "center",
313
+ justifyContent: "center"
314
+ },
315
+ /* @__PURE__ */ React3.createElement(CaretDownIcon, null)
316
+ )
317
+ );
318
+ };
319
+
320
+ // src/components/FunNoResults/FunNoResults.tsx
321
+ import React6 from "react";
322
+
323
+ // src/components/Icons/CoinsIcon.tsx
324
+ import React4 from "react";
325
+ var CoinsIcon = ({
326
+ size = 48,
327
+ bgColor = "#141C41",
328
+ iconColor = "#878A98"
329
+ }) => {
330
+ return /* @__PURE__ */ React4.createElement(
331
+ "svg",
332
+ {
333
+ width: size,
334
+ height: size,
335
+ viewBox: "0 0 48 49",
336
+ fill: "none",
337
+ xmlns: "http://www.w3.org/2000/svg"
338
+ },
339
+ /* @__PURE__ */ React4.createElement("g", { clipPath: "url(#clip0_30657_22302)" }, /* @__PURE__ */ React4.createElement(
340
+ "path",
341
+ {
342
+ d: "M24 1C36.9787 1 47.5 11.5213 47.5 24.5C47.5 37.4787 36.9787 48 24 48C11.0213 48 0.5 37.4787 0.5 24.5C0.5 11.5213 11.0213 1 24 1Z",
343
+ fill: bgColor,
344
+ stroke: bgColor
345
+ }
346
+ ), /* @__PURE__ */ React4.createElement("g", { clipPath: "url(#clip1_30657_22302)" }, /* @__PURE__ */ React4.createElement(
347
+ "path",
348
+ {
349
+ d: "M25 17C25 18.1046 22.5376 19 19.5 19C16.4624 19 14 18.1046 14 17M25 17C25 15.8954 22.5376 15 19.5 15C16.4624 15 14 15.8954 14 17M25 17V18.5M14 17V29C14 30.1046 16.4624 31 19.5 31M19.5 23C19.3315 23 19.1647 22.9972 19 22.9918C16.1967 22.9 14 22.0433 14 21M19.5 27C16.4624 27 14 26.1046 14 25M34 23.5C34 24.6046 31.5376 25.5 28.5 25.5C25.4624 25.5 23 24.6046 23 23.5M34 23.5C34 22.3954 31.5376 21.5 28.5 21.5C25.4624 21.5 23 22.3954 23 23.5M34 23.5V31C34 32.1046 31.5376 33 28.5 33C25.4624 33 23 32.1046 23 31V23.5M34 27.25C34 28.3546 31.5376 29.25 28.5 29.25C25.4624 29.25 23 28.3546 23 27.25",
350
+ stroke: iconColor,
351
+ strokeWidth: "1.5",
352
+ strokeLinecap: "round",
353
+ strokeLinejoin: "round"
354
+ }
355
+ ))),
356
+ /* @__PURE__ */ React4.createElement("defs", null, /* @__PURE__ */ React4.createElement("clipPath", { id: "clip0_30657_22302" }, /* @__PURE__ */ React4.createElement(
357
+ "rect",
358
+ {
359
+ width: "48",
360
+ height: "48",
361
+ fill: "white",
362
+ transform: "translate(0 0.5)"
363
+ }
364
+ )), /* @__PURE__ */ React4.createElement("clipPath", { id: "clip1_30657_22302" }, /* @__PURE__ */ React4.createElement(
365
+ "rect",
366
+ {
367
+ width: "24",
368
+ height: "24",
369
+ fill: "white",
370
+ transform: "translate(12 12)"
371
+ }
372
+ )))
373
+ );
374
+ };
375
+
376
+ // src/components/Icons/SearchSkeletonIcon.tsx
377
+ import React5 from "react";
378
+ var SearchSkeletonIcon = () => {
379
+ return /* @__PURE__ */ React5.createElement(
380
+ "svg",
381
+ {
382
+ width: "122",
383
+ height: "81",
384
+ viewBox: "0 0 122 81",
385
+ fill: "none",
386
+ xmlns: "http://www.w3.org/2000/svg"
387
+ },
388
+ /* @__PURE__ */ React5.createElement("g", { clipPath: "url(#clip0_7590_15835)" }, /* @__PURE__ */ React5.createElement(
389
+ "path",
390
+ {
391
+ fillRule: "evenodd",
392
+ clipRule: "evenodd",
393
+ d: "M99.5636 34.0159C92.9099 34.0159 87.5159 39.4099 87.5159 46.0636C87.5159 52.7174 92.9099 58.1114 99.5636 58.1114C106.217 58.1114 111.611 52.7174 111.611 46.0636C111.611 39.4099 106.217 34.0159 99.5636 34.0159ZM83.5 46.0636C83.5 37.1919 90.6919 30 99.5636 30C108.435 30 115.627 37.1919 115.627 46.0636C115.627 49.7758 114.368 53.1938 112.254 55.9139L120.912 64.5722C121.696 65.3564 121.696 66.6277 120.912 67.4119C120.128 68.196 118.856 68.196 118.072 67.4119L109.414 58.7536C106.694 60.8681 103.276 62.1273 99.5636 62.1273C90.6919 62.1273 83.5 54.9353 83.5 46.0636Z",
394
+ fill: "currentColor"
395
+ }
396
+ ), /* @__PURE__ */ React5.createElement(
397
+ "path",
398
+ {
399
+ d: "M117.5 8H4.5C2.29086 8 0.5 9.79086 0.5 12V20C0.5 22.2091 2.29086 24 4.5 24H117.5C119.709 24 121.5 22.2091 121.5 20V12C121.5 9.79086 119.709 8 117.5 8Z",
400
+ fill: "currentColor"
401
+ }
402
+ ), /* @__PURE__ */ React5.createElement(
403
+ "path",
404
+ {
405
+ d: "M71.5 30H4.5C2.29086 30 0.5 31.7909 0.5 34V42C0.5 44.2091 2.29086 46 4.5 46H71.5C73.7091 46 75.5 44.2091 75.5 42V34C75.5 31.7909 73.7091 30 71.5 30Z",
406
+ fill: "currentColor"
407
+ }
408
+ ), /* @__PURE__ */ React5.createElement(
409
+ "path",
410
+ {
411
+ d: "M71.5 52H4.5C2.29086 52 0.5 53.7909 0.5 56V64C0.5 66.2091 2.29086 68 4.5 68H71.5C73.7091 68 75.5 66.2091 75.5 64V56C75.5 53.7909 73.7091 52 71.5 52Z",
412
+ fill: "currentColor"
413
+ }
414
+ )),
415
+ /* @__PURE__ */ React5.createElement("defs", null, /* @__PURE__ */ React5.createElement("clipPath", { id: "clip0_7590_15835" }, /* @__PURE__ */ React5.createElement(
416
+ "rect",
417
+ {
418
+ width: "121",
419
+ height: "81",
420
+ fill: "white",
421
+ transform: "translate(0.5)"
422
+ }
423
+ )))
424
+ );
425
+ };
426
+
427
+ // src/components/FunNoResults/FunNoResults.tsx
428
+ var FunNoResults = ({
429
+ text,
430
+ title,
431
+ variant = "default",
432
+ actionButton
433
+ }) => {
434
+ return /* @__PURE__ */ React6.createElement(
435
+ Box,
436
+ {
437
+ display: "flex",
438
+ flexDirection: "column",
439
+ justifyContent: "center",
440
+ alignItems: "center",
441
+ gap: variant === "default" ? "12" : "16",
442
+ color: "secondaryText",
443
+ style: { flex: 1 }
444
+ },
445
+ variant === "default" && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(SearchSkeletonIcon, null), /* @__PURE__ */ React6.createElement(Text, { color: "secondaryText", size: "10" }, text)),
446
+ variant === "actionable" && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(
447
+ CoinsIcon,
448
+ {
449
+ bgColor: themeVars.colors.offBackground,
450
+ iconColor: themeVars.colors.actionColor
451
+ }
452
+ ), /* @__PURE__ */ React6.createElement(
453
+ Box,
454
+ {
455
+ display: "flex",
456
+ flexDirection: "column",
457
+ alignItems: "center",
458
+ gap: "12"
459
+ },
460
+ /* @__PURE__ */ React6.createElement(
461
+ Box,
462
+ {
463
+ display: "flex",
464
+ flexDirection: "column",
465
+ alignItems: "center",
466
+ textAlign: "center",
467
+ gap: "8"
468
+ },
469
+ title && /* @__PURE__ */ React6.createElement(Text, { size: "14", color: "primaryText" }, title),
470
+ /* @__PURE__ */ React6.createElement(Text, { color: "secondaryText", size: "12" }, text)
471
+ ),
472
+ actionButton && /* @__PURE__ */ React6.createElement(Box, null, actionButton)
473
+ ))
474
+ );
475
+ };
476
+
477
+ // src/components/Icons/SwitchIcon.tsx
478
+ import React7 from "react";
479
+ var SwitchIcon = () => {
480
+ return /* @__PURE__ */ React7.createElement(
481
+ "svg",
482
+ {
483
+ width: "15",
484
+ height: "14",
485
+ viewBox: "0 0 15 14",
486
+ fill: "none",
487
+ xmlns: "http://www.w3.org/2000/svg"
488
+ },
489
+ /* @__PURE__ */ React7.createElement(
490
+ "path",
491
+ {
492
+ fillRule: "evenodd",
493
+ clipRule: "evenodd",
494
+ d: "M0.96967 4.86358C0.676777 4.57069 0.676777 4.09582 0.96967 3.80292L3.63634 1.13626C3.92923 0.843363 4.4041 0.843363 4.697 1.13626L7.36366 3.80292C7.65656 4.09582 7.65656 4.57069 7.36366 4.86358C7.07077 5.15648 6.5959 5.15648 6.303 4.86358L4.91667 3.47725L4.91667 12.3333C4.91667 12.7475 4.58088 13.0833 4.16667 13.0833C3.75245 13.0833 3.41667 12.7475 3.41667 12.3333L3.41667 3.47725L2.03033 4.86358C1.73744 5.15648 1.26256 5.15648 0.96967 4.86358ZM7.63634 9.13626C7.92923 8.84336 8.4041 8.84336 8.697 9.13626L10.0833 10.5226V1.66659C10.0833 1.25237 10.4191 0.916586 10.8333 0.916586C11.2475 0.916586 11.5833 1.25237 11.5833 1.66659V10.5226L12.9697 9.13626C13.2626 8.84336 13.7374 8.84336 14.0303 9.13626C14.3232 9.42915 14.3232 9.90402 14.0303 10.1969L11.3637 12.8636C11.0708 13.1565 10.5959 13.1565 10.303 12.8636L7.63634 10.1969C7.34344 9.90402 7.34344 9.42915 7.63634 9.13626Z",
495
+ fill: "currentColor"
496
+ }
497
+ )
498
+ );
499
+ };
500
+
501
+ // src/providers/FunkitProvider.tsx
502
+ var ThemeIdContext = createContext(void 0);
503
+ var attr = "data-rk";
504
+ var createThemeRootProps = (id) => ({ [attr]: id || "" });
505
+ var useThemeRootProps = () => {
506
+ const id = useContext(ThemeIdContext);
507
+ return createThemeRootProps(id);
508
+ };
509
+
510
+ // src/components/Dropdown/BaseActiveDropdownItem.tsx
511
+ import React9 from "react";
512
+
513
+ // src/components/Dropdown/BaseActiveDropdownItem.css.ts
514
+ var baseStyles = "BaseActiveDropdownItem_baseStyles__1dewiqw0";
515
+
516
+ // src/components/Dropdown/BaseDropdown.css.ts
517
+ var BORDER_RADIUS = "dropdown";
518
+ var baseDropdownItemWrapperStyles = "BaseDropdown_baseDropdownItemWrapperStyles__1nns6ys3 sprinkles_borderRadius_dropdownItem__1rsrm2f17";
519
+ var scrollGradientWrapperStyles = "BaseDropdown_scrollGradientWrapperStyles__1nns6ys1";
520
+ var scrollableDropdownStyles = "BaseDropdown_scrollableDropdownStyles__1nns6ys0";
521
+
522
+ // src/components/Dropdown/BaseActiveDropdownItem.tsx
523
+ function BaseActiveDropdownItem({
524
+ iconComponent,
525
+ label,
526
+ isOpened,
527
+ onClick,
528
+ horizontalIconGap = "dropdownItemIconGap",
529
+ alwaysVisibleLabel,
530
+ tagComponent,
531
+ tagPosition = "start",
532
+ size = "regular",
533
+ color = "primaryText",
534
+ arrowColor = "secondaryText",
535
+ background,
536
+ labelStyle,
537
+ compactIcon = false
538
+ }) {
539
+ return /* @__PURE__ */ React9.createElement(
540
+ Box,
541
+ {
542
+ display: "flex",
543
+ alignItems: "center",
544
+ justifyContent: "space-between",
545
+ gap: "6",
546
+ cursor: "pointer",
547
+ onClick,
548
+ background: background ?? {
549
+ base: "dropdownActiveItemBackgroundBase",
550
+ hover: "dropdownActiveItemBackgroundHover"
551
+ },
552
+ borderColor: {
553
+ base: "dropdownActiveItemBorderBase",
554
+ hover: "dropdownActiveItemBorderHover"
555
+ },
556
+ borderWidth: size === "compact" ? "0" : "1",
557
+ borderRadius: BORDER_RADIUS,
558
+ borderStyle: "solid",
559
+ paddingY: size === "compact" ? "2" : size === "large" ? "10" : "dropdownActiveItemRegularSizePaddingY",
560
+ paddingX: size === "compact" ? "4" : size === "large" ? "8" : "dropdownPaddingX",
561
+ className: baseStyles
562
+ },
563
+ /* @__PURE__ */ React9.createElement(
564
+ Box,
565
+ {
566
+ display: "flex",
567
+ alignItems: "center",
568
+ justifyContent: "space-between",
569
+ gap: horizontalIconGap,
570
+ style: size === "compact" ? void 0 : { flex: "1 0 auto" }
571
+ },
572
+ alwaysVisibleLabel && /* @__PURE__ */ React9.createElement(Box, { style: { flex: 1 } }, /* @__PURE__ */ React9.createElement(Text, { color: "secondaryText", size: "12" }, alwaysVisibleLabel)),
573
+ /* @__PURE__ */ React9.createElement(
574
+ Box,
575
+ {
576
+ display: "flex",
577
+ alignItems: "center",
578
+ justifyContent: "space-between",
579
+ gap: horizontalIconGap,
580
+ background: {
581
+ base: "transparent",
582
+ hover: "alwaysVisibleLabelBackgroundHover"
583
+ },
584
+ ...alwaysVisibleLabel ? {} : { style: { flex: 1 } }
585
+ },
586
+ /* @__PURE__ */ React9.createElement(
587
+ Box,
588
+ {
589
+ display: "flex",
590
+ alignItems: "center",
591
+ justifyContent: "center",
592
+ gap: horizontalIconGap,
593
+ ...alwaysVisibleLabel ? { style: { flexDirection: "row-reverse" } } : {}
594
+ },
595
+ tagPosition === "start" && tagComponent,
596
+ /* @__PURE__ */ React9.createElement(Box, { display: "flex", alignItems: "center", gap: horizontalIconGap }, iconComponent && /* @__PURE__ */ React9.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "center" }, iconComponent), /* @__PURE__ */ React9.createElement(
597
+ Text,
598
+ {
599
+ color,
600
+ size: "dropdownItemFontSize",
601
+ weight: "medium",
602
+ style: labelStyle
603
+ },
604
+ label
605
+ ))
606
+ ),
607
+ /* @__PURE__ */ React9.createElement(Box, { display: "flex", alignItems: "center", gap: "5" }, tagPosition === "end" && tagComponent, /* @__PURE__ */ React9.createElement(
608
+ AnimatedCaretDownIcon,
609
+ {
610
+ expanded: isOpened,
611
+ color: arrowColor,
612
+ compact: compactIcon
613
+ }
614
+ ))
615
+ )
616
+ )
617
+ );
618
+ }
619
+ var BaseActiveDropdownItem_default = BaseActiveDropdownItem;
620
+
621
+ // src/components/Dropdown/BaseDropdown.utils.ts
622
+ var NO_SELECTION_VALUE = "";
623
+ var ADDITIONAL_GROUP_KEY = "__additional__";
624
+ function buildAllOptions(options, allowUnselect, unselectLabel) {
625
+ if (allowUnselect) {
626
+ return [
627
+ {
628
+ label: unselectLabel ?? "",
629
+ value: NO_SELECTION_VALUE
630
+ },
631
+ ...options
632
+ ];
633
+ }
634
+ return options;
635
+ }
636
+ function filterOptions(allOptions, searchInput) {
637
+ const search = searchInput?.trim().toLowerCase() ?? "";
638
+ return allOptions.filter(
639
+ (option) => option.label.toLowerCase().includes(search)
640
+ );
641
+ }
642
+ function organizeDropdownGroups(filteredOptions, groups, additionalGroup, additionalGroupLabel) {
643
+ const organizedGroups = [];
644
+ if (!groups) {
645
+ organizedGroups.push({
646
+ key: ADDITIONAL_GROUP_KEY,
647
+ label: void 0,
648
+ options: filteredOptions
649
+ });
650
+ return {
651
+ organizedGroups,
652
+ organizedOptions: filteredOptions
653
+ };
654
+ }
655
+ const unselectOption = filteredOptions.find(
656
+ (option) => option.value === NO_SELECTION_VALUE
657
+ );
658
+ if (unselectOption) {
659
+ organizedGroups.push({
660
+ key: NO_SELECTION_VALUE,
661
+ label: void 0,
662
+ options: [unselectOption]
663
+ });
664
+ }
665
+ const optionsByValue = new Map(
666
+ filteredOptions.filter((option) => option.value !== NO_SELECTION_VALUE).map((option) => [option.value, option])
667
+ );
668
+ const inflatedGroups = groups.map((group) => ({
669
+ ...group,
670
+ // Only take the options that actually exist
671
+ // Note that this preserves the ordering of `group.values`
672
+ options: group.values.map((value) => optionsByValue.get(value)).filter((option) => !!option)
673
+ })).filter((group) => group.options.length > 0);
674
+ const hasNonEmptyGroup = inflatedGroups.length > 0;
675
+ for (const group of inflatedGroups) {
676
+ organizedGroups.push({
677
+ key: group.key,
678
+ label: group.label,
679
+ options: group.options
680
+ });
681
+ if (additionalGroup === "others") {
682
+ for (const option of group.options) {
683
+ optionsByValue.delete(option.value);
684
+ }
685
+ }
686
+ }
687
+ if (optionsByValue.size > 0) {
688
+ organizedGroups.push({
689
+ key: ADDITIONAL_GROUP_KEY,
690
+ // Only show additional group label if there actually are other groups
691
+ label: hasNonEmptyGroup ? additionalGroupLabel : void 0,
692
+ options: [...optionsByValue.values()]
693
+ });
694
+ }
695
+ const organizedOptions = organizedGroups.flatMap((group) => group.options);
696
+ return { organizedGroups, organizedOptions };
697
+ }
698
+
699
+ // src/components/Dropdown/BaseDropdown.tsx
700
+ var HORIZONTAL_ICON_GAP = "4";
701
+ var activeDropdownItemSize = {
702
+ compact: "18",
703
+ regular: "36",
704
+ large: "40"
705
+ };
706
+ function BaseDropdown({
707
+ activeItemProps,
708
+ value,
709
+ options,
710
+ groups,
711
+ additionalGroup = "others",
712
+ additionalGroupLabel,
713
+ allowUnselect = false,
714
+ unselectLabel,
715
+ onOptionSelected,
716
+ onOpen,
717
+ renderDropdownOption,
718
+ searchableOptions = false,
719
+ searchPlaceholder,
720
+ placeholder,
721
+ resetSearchOnClose = true,
722
+ openToTopOnMobile = true,
723
+ alwaysOpenToTop = false,
724
+ openDropdownFullWidth = true,
725
+ isLoading = false,
726
+ preloadIconUrls,
727
+ horizontalIconGap = HORIZONTAL_ICON_GAP,
728
+ openDropdownBackgroundColor = "openDropdownBackgroundColor",
729
+ size = "regular",
730
+ label,
731
+ maxDropdownHeight,
732
+ dropdownWidth,
733
+ dropdownAlign = "end",
734
+ testId
735
+ }) {
736
+ const { t } = useFunkitTranslation();
737
+ const themeRootProps = useThemeRootProps();
738
+ const isMobileDevice = isMobile();
739
+ const [isOpened, setIsOpened] = useState2(false);
740
+ const [searchInput, setSearchInput] = useState2("");
741
+ const { ref: scrollRef, hasTopDivider, isAtBottom } = useScrollDivider();
742
+ const allOptions = useMemo2(
743
+ () => buildAllOptions(options, allowUnselect, unselectLabel),
744
+ [options, allowUnselect, unselectLabel]
745
+ );
746
+ const selectedOption = allOptions.find((option) => option.value === value);
747
+ const prevIsOpenedRef = useRef2(false);
748
+ const portalThemeRef = useRef2(null);
749
+ const handleSearch = (event) => {
750
+ setSearchInput(event.target.value);
751
+ };
752
+ const filteredOptions = useMemo2(
753
+ () => filterOptions(allOptions, searchInput),
754
+ [allOptions, searchInput]
755
+ );
756
+ const { organizedGroups, organizedOptions } = useMemo2(
757
+ () => organizeDropdownGroups(
758
+ filteredOptions,
759
+ groups,
760
+ additionalGroup,
761
+ additionalGroupLabel
762
+ ),
763
+ [additionalGroup, additionalGroupLabel, filteredOptions, groups]
764
+ );
765
+ const handleOpenChange = useCallback2(
766
+ (open) => {
767
+ setIsOpened(open);
768
+ if (open) {
769
+ onOpen?.();
770
+ } else {
771
+ resetSearchOnClose && setSearchInput("");
772
+ }
773
+ },
774
+ [onOpen, resetSearchOnClose]
775
+ );
776
+ useEffect3(() => {
777
+ if (isOpened && !prevIsOpenedRef.current) {
778
+ prevIsOpenedRef.current = true;
779
+ if (selectedOption) {
780
+ const selectedOptionIndex = organizedOptions.findIndex(
781
+ (option) => option.value === selectedOption.value
782
+ );
783
+ if (selectedOptionIndex !== -1) {
784
+ requestAnimationFrame(() => {
785
+ const selectedOptionElement = document.getElementById(
786
+ `${selectedOption.value}-dropdown-item`
787
+ );
788
+ selectedOptionElement?.scrollIntoView({
789
+ behavior: "instant",
790
+ block: "center"
791
+ });
792
+ });
793
+ }
794
+ }
795
+ } else if (!isOpened) {
796
+ prevIsOpenedRef.current = false;
797
+ }
798
+ }, [isOpened, selectedOption, organizedOptions]);
799
+ const dropdownSide = alwaysOpenToTop || openToTopOnMobile && isMobileDevice ? "top" : "bottom";
800
+ return /* @__PURE__ */ React10.createElement(Box, { display: "flex", flexDirection: "column", gap: "4", testId }, label && /* @__PURE__ */ React10.createElement(Text, { size: "12", color: "secondaryText" }, label), /* @__PURE__ */ React10.createElement(
801
+ DropdownMenu2.Root,
802
+ {
803
+ open: isOpened,
804
+ onOpenChange: handleOpenChange,
805
+ modal: false
806
+ },
807
+ /* @__PURE__ */ React10.createElement(
808
+ Box,
809
+ {
810
+ position: "relative",
811
+ display: size === "compact" ? "flex" : void 0
812
+ },
813
+ isLoading ? /* @__PURE__ */ React10.createElement(FunSkeletonBlock, { height: activeDropdownItemSize[size] }) : /* @__PURE__ */ React10.createElement(DropdownMenu2.Trigger, { asChild: true }, /* @__PURE__ */ React10.createElement("div", null, /* @__PURE__ */ React10.createElement(
814
+ BaseActiveDropdownItem_default,
815
+ {
816
+ color: !selectedOption && !activeItemProps?.label && !!placeholder ? "secondaryText" : "primaryText",
817
+ ...activeItemProps,
818
+ size,
819
+ horizontalIconGap,
820
+ isOpened,
821
+ label: activeItemProps?.label ?? selectedOption?.label ?? placeholder ?? ""
822
+ }
823
+ ))),
824
+ /* @__PURE__ */ React10.createElement(DropdownMenu2.Portal, null, /* @__PURE__ */ React10.createElement(
825
+ DropdownMenu2.Content,
826
+ {
827
+ ...themeRootProps,
828
+ ref: portalThemeRef,
829
+ side: dropdownSide,
830
+ sideOffset: dropdownSide === "top" ? 8 : 6,
831
+ align: dropdownAlign,
832
+ className: "funkit-dropdown-content",
833
+ style: {
834
+ zIndex: `calc(${themeVars.modalZIndex} + 1)`,
835
+ width: dropdownWidth ? `${dropdownWidth}px` : openDropdownFullWidth ? "var(--radix-dropdown-menu-trigger-width)" : void 0,
836
+ transformOrigin: "var(--radix-dropdown-menu-content-transform-origin)"
837
+ },
838
+ onCloseAutoFocus: (e) => e.preventDefault()
839
+ },
840
+ /* @__PURE__ */ React10.createElement(TooltipAnchorRefContext.Provider, { value: portalThemeRef }, /* @__PURE__ */ React10.createElement(
841
+ Box,
842
+ {
843
+ background: openDropdownBackgroundColor,
844
+ borderColor: "transparent",
845
+ borderWidth: "1",
846
+ borderRadius: "dropdownList",
847
+ borderStyle: "solid",
848
+ boxShadow: "dropdown",
849
+ className: maxDropdownHeight ? scrollGradientWrapperStyles : void 0,
850
+ "data-fade-top": maxDropdownHeight && hasTopDivider ? "true" : "false",
851
+ "data-fade-bottom": maxDropdownHeight && !isAtBottom ? "true" : "false"
852
+ },
853
+ /* @__PURE__ */ React10.createElement(
854
+ Box,
855
+ {
856
+ className: maxDropdownHeight ? scrollableDropdownStyles : void 0,
857
+ ref: maxDropdownHeight ? scrollRef : void 0,
858
+ style: { maxHeight: maxDropdownHeight }
859
+ },
860
+ /* @__PURE__ */ React10.createElement(Box, { display: "flex", flexDirection: "column" }, searchableOptions && /* @__PURE__ */ React10.createElement(Box, { paddingTop: "8", paddingX: "8" }, /* @__PURE__ */ React10.createElement(
861
+ FunInput,
862
+ {
863
+ placeholder: searchPlaceholder ?? t("common.searchTokens"),
864
+ value: searchInput,
865
+ onChange: handleSearch,
866
+ prefixIcon: "SearchIcon"
867
+ }
868
+ )), organizedOptions.length === 0 ? /* @__PURE__ */ React10.createElement(FunNoResults, { text: t("common.noResultsFound") }) : /* @__PURE__ */ React10.createElement(
869
+ Box,
870
+ {
871
+ as: "ul",
872
+ display: "flex",
873
+ flexDirection: "column",
874
+ paddingY: size === "compact" ? "dropdownCompactPaddingY" : "dropdownPaddingY"
875
+ },
876
+ organizedGroups.map(
877
+ ({
878
+ key: groupKey,
879
+ label: groupLabel,
880
+ options: optionsInGroup
881
+ }, groupIndex) => /* @__PURE__ */ React10.createElement(React10.Fragment, { key: groupKey }, groupIndex > 0 && /* @__PURE__ */ React10.createElement(
882
+ Box,
883
+ {
884
+ height: "1",
885
+ background: "lightStroke",
886
+ marginY: "dropdownGroupDividerMarginY"
887
+ }
888
+ ), groupLabel && /* @__PURE__ */ React10.createElement(
889
+ Box,
890
+ {
891
+ paddingX: size === "compact" ? "dropdownCompactPaddingX" : "dropdownPaddingX"
892
+ },
893
+ /* @__PURE__ */ React10.createElement(
894
+ Box,
895
+ {
896
+ paddingX: "dropdownItemPaddingX",
897
+ paddingY: "dropdownItemPaddingY"
898
+ },
899
+ /* @__PURE__ */ React10.createElement(
900
+ Text,
901
+ {
902
+ color: "dropdownGroupHeader",
903
+ font: "dropdownGroupHeader",
904
+ size: "dropdownGroupHeader",
905
+ weight: "dropdownGroupHeader"
906
+ },
907
+ groupLabel
908
+ )
909
+ )
910
+ ), optionsInGroup.map((singleOption) => {
911
+ const isSelected = singleOption.value === selectedOption?.value;
912
+ return /* @__PURE__ */ React10.createElement(
913
+ Box,
914
+ {
915
+ key: singleOption.value,
916
+ paddingX: size === "compact" ? "dropdownCompactPaddingX" : "dropdownPaddingX"
917
+ },
918
+ /* @__PURE__ */ React10.createElement(
919
+ Box,
920
+ {
921
+ id: `${singleOption.value}-dropdown-item`,
922
+ as: "li",
923
+ background: {
924
+ base: isSelected ? "selectedDropdownItemBackground" : "transparent",
925
+ hover: "offBackground"
926
+ },
927
+ className: baseDropdownItemWrapperStyles,
928
+ onClick: () => {
929
+ onOptionSelected?.(singleOption);
930
+ }
931
+ },
932
+ renderDropdownOption(
933
+ singleOption,
934
+ isSelected
935
+ )
936
+ )
937
+ );
938
+ }))
939
+ )
940
+ ))
941
+ )
942
+ ))
943
+ )),
944
+ preloadIconUrls && /* @__PURE__ */ React10.createElement(
945
+ Box,
946
+ {
947
+ display: "none",
948
+ "aria-hidden": true,
949
+ style: { position: "absolute", top: "-100%", left: "-100%" }
950
+ },
951
+ preloadIconUrls.map((url, index) => /* @__PURE__ */ React10.createElement("img", { key: `${url}-${index}`, src: url, alt: "" }))
952
+ )
953
+ )
954
+ ));
955
+ }
956
+ var BaseDropdown_default = BaseDropdown;
957
+
958
+ // src/components/Dropdown/AccountSelectDropdown.tsx
959
+ var ACCOUNTS_GROUP = "accounts";
960
+ var ACTION_GROUP = "action";
961
+ function AccountSelectDropdown({
962
+ accounts,
963
+ selectedValue,
964
+ onSelect,
965
+ action,
966
+ prefixLabel,
967
+ label,
968
+ size,
969
+ dropdownWidth,
970
+ testId
971
+ }) {
972
+ const actionIdCollidesWithAccount = !!action && accounts.some((account) => account.value === action.id);
973
+ const actionId = action?.id;
974
+ useEffect4(() => {
975
+ if (actionIdCollidesWithAccount) {
976
+ logger.warn("accountSelectDropdown:actionIdCollidesWithAccountValue", {
977
+ actionId
978
+ });
979
+ }
980
+ }, [actionIdCollidesWithAccount, actionId]);
981
+ const options = [
982
+ ...accounts.map((account) => ({
983
+ value: account.value,
984
+ label: account.label
985
+ })),
986
+ ...action ? [{ value: action.id, label: action.label }] : []
987
+ ];
988
+ const groups = action ? [
989
+ {
990
+ key: ACCOUNTS_GROUP,
991
+ label: "",
992
+ values: accounts.map((account) => account.value)
993
+ },
994
+ { key: ACTION_GROUP, label: "", values: [action.id] }
995
+ ] : void 0;
996
+ return /* @__PURE__ */ React11.createElement(
997
+ BaseDropdown_default,
998
+ {
999
+ testId,
1000
+ label,
1001
+ size,
1002
+ dropdownWidth,
1003
+ value: selectedValue,
1004
+ options,
1005
+ groups,
1006
+ activeItemProps: { alwaysVisibleLabel: prefixLabel },
1007
+ renderDropdownOption: (option, isSelected) => {
1008
+ if (action && option.value === action.id) {
1009
+ return /* @__PURE__ */ React11.createElement(
1010
+ BaseDropdownItem_default,
1011
+ {
1012
+ id: option.value,
1013
+ label: option.label,
1014
+ iconComponent: action.icon && // Render the icon in the theme's primary text colour
1015
+ // (the icon uses `currentColor`), matching the label.
1016
+ /* @__PURE__ */ React11.createElement(Box, { display: "flex", color: "primaryText" }, action.icon),
1017
+ horizontalIconGap: "8",
1018
+ onClick: action.onSelect
1019
+ }
1020
+ );
1021
+ }
1022
+ const account = accounts.find((item) => item.value === option.value);
1023
+ return /* @__PURE__ */ React11.createElement(
1024
+ BaseDropdownItem_default,
1025
+ {
1026
+ id: option.value,
1027
+ label: option.label,
1028
+ description: account?.description,
1029
+ isSelected,
1030
+ onClick: onSelect
1031
+ }
1032
+ );
1033
+ }
1034
+ }
1035
+ );
1036
+ }
1037
+
1038
+ // src/clients/polymarket/PolymarketDepositAccountDropdown.tsx
1039
+ var ACCOUNT_DROPDOWN_OPTIONS_WIDTH = 264;
1040
+ var BALANCE_PLACEHOLDER = "\u2014";
1041
+ function formatBalance(balanceUsd) {
1042
+ return balanceUsd === void 0 ? BALANCE_PLACEHOLDER : formatUsdFlooredToCent(balanceUsd);
1043
+ }
1044
+ function PolymarketDepositAccountDropdown({
1045
+ onStepChange,
1046
+ modalState,
1047
+ dynamicRoutingId,
1048
+ applyDynamicTargetAssetCandidate,
1049
+ predictions,
1050
+ perps
1051
+ }) {
1052
+ const { t } = useFunkitTranslation();
1053
+ const balances = usePolymarketAccountBalances({ predictions, perps });
1054
+ const selectedRoutingId = dynamicRoutingId === POLYMARKET_PERPS_ROUTING_ID ? POLYMARKET_PERPS_ROUTING_ID : POLYMARKET_PREDICTIONS_ROUTING_ID;
1055
+ const accountCandidate = (routingId, recipient) => ({
1056
+ tokenAddress: POLYGON_USDCE,
1057
+ tokenChainId: polygon.id.toString(),
1058
+ tokenSymbol: PUSD_TOKEN.symbol,
1059
+ iconSrc: PUSD_TOKEN.iconSrc,
1060
+ dynamicRoutingId: routingId,
1061
+ customRecipient: recipient
1062
+ });
1063
+ const handleSelectAccount = (routingId) => {
1064
+ const isPerps = routingId === POLYMARKET_PERPS_ROUTING_ID;
1065
+ applyDynamicTargetAssetCandidate?.(
1066
+ accountCandidate(
1067
+ isPerps ? POLYMARKET_PERPS_ROUTING_ID : POLYMARKET_PREDICTIONS_ROUTING_ID,
1068
+ isPerps ? perps.address : predictions.address
1069
+ )
1070
+ );
1071
+ };
1072
+ return /* @__PURE__ */ React12.createElement(
1073
+ AccountSelectDropdown,
1074
+ {
1075
+ prefixLabel: t("perpsTransfer.depositTo"),
1076
+ dropdownWidth: ACCOUNT_DROPDOWN_OPTIONS_WIDTH,
1077
+ accounts: [
1078
+ {
1079
+ value: POLYMARKET_PREDICTIONS_ROUTING_ID,
1080
+ label: t("perpsTransfer.predictions"),
1081
+ description: formatBalance(balances.predictions.balanceUsd)
1082
+ },
1083
+ {
1084
+ value: POLYMARKET_PERPS_ROUTING_ID,
1085
+ label: t("perpsTransfer.perps"),
1086
+ description: formatBalance(balances.perps.balanceUsd)
1087
+ }
1088
+ ],
1089
+ selectedValue: selectedRoutingId,
1090
+ onSelect: handleSelectAccount,
1091
+ action: {
1092
+ id: "transfer-between-accounts",
1093
+ label: t("perpsTransfer.transferBetweenAccounts"),
1094
+ icon: /* @__PURE__ */ React12.createElement(SwitchIcon, null),
1095
+ // Navigation is absent on the loading skeleton; the action only fires
1096
+ // on the interactive screen. The transfer step reads balances from the
1097
+ // same shared cache, so none need to be threaded through here.
1098
+ onSelect: () => {
1099
+ if (onStepChange && modalState) {
1100
+ onStepChange({
1101
+ ...modalState,
1102
+ step: "perps_transfer" /* PERPS_TRANSFER */
1103
+ });
1104
+ }
1105
+ }
1106
+ }
1107
+ }
1108
+ );
1109
+ }
1110
+
1111
+ export {
1112
+ PolymarketDepositAccountDropdown
1113
+ };