@funkit/connect 11.7.0 → 12.1.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 (141) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/{chunk-67BKQQNG.js → chunk-2RND3WWH.js} +1 -1
  3. package/dist/{chunk-L67HP4HQ.js → chunk-53FF4ZHH.js} +1 -1
  4. package/dist/{chunk-4YEAUICE.js → chunk-DH3DS4FX.js} +1 -0
  5. package/dist/clients/{chunk-SG4ZS447.js → chunk-27VBRE7W.js} +79 -15
  6. package/dist/clients/{chunk-OASVWVSV.js → chunk-A5JW3UI6.js} +1 -1
  7. package/dist/clients/chunk-DNVDK7JQ.js +335 -0
  8. package/dist/clients/{chunk-FGUMPXTO.js → chunk-DYV3LRSE.js} +1 -1
  9. package/dist/clients/{chunk-44USAVWK.js → chunk-ECGTOMZQ.js} +2 -2
  10. package/dist/clients/{chunk-IYCZWLAF.js → chunk-IAIRECDV.js} +8 -37
  11. package/dist/clients/{chunk-I4B5AKZC.js → chunk-R6UAC2TB.js} +1 -1
  12. package/dist/clients/chunk-RQALGV5U.js +335 -0
  13. package/dist/clients/{chunk-Y7WLUPTX.js → chunk-VE6QD5IM.js} +67 -16
  14. package/dist/clients/fanatics.css +4686 -4659
  15. package/dist/clients/fanatics.js +7 -9
  16. package/dist/clients/internal/nado/withdrawalCallback.js +3 -3
  17. package/dist/clients/internal/nado/withdrawalErrors.js +2 -2
  18. package/dist/clients/internal/nado/withdrawalForm.css +4704 -4677
  19. package/dist/clients/internal/nado/withdrawalForm.js +38 -13
  20. package/dist/clients/internal/nado/withdrawalStatus.js +3 -3
  21. package/dist/clients/lighter.css +4704 -4677
  22. package/dist/clients/lighter.js +50 -30
  23. package/dist/clients/mallard.js +4 -4
  24. package/dist/clients/nado.js +3 -3
  25. package/dist/clients/polymarket/createPolymarketDepositConfig.d.ts +28 -19
  26. package/dist/clients/polymarket/createPolymarketDepositConfig.js +5 -4
  27. package/dist/clients/polymarket/index.d.ts +0 -1
  28. package/dist/clients/polymarket/index.js +4 -17
  29. package/dist/clients/polymarket/polymarket.d.ts +12 -27
  30. package/dist/clients/polymarket/polymarket.js +1 -1
  31. package/dist/components/AsyncImage/useAsyncImage.d.ts +2 -0
  32. package/dist/components/Box/Box.d.ts +15 -15
  33. package/dist/components/Dialog/Dialog.d.ts +8 -1
  34. package/dist/components/FunTransactionSummary/PaymentFeesSummary.d.ts +4 -1
  35. package/dist/components/FunTransactionSummary/PaymentFeesSummary.track.d.ts +12 -0
  36. package/dist/components/ModalHeaderTabs/ModalHeaderTabs.d.ts +23 -0
  37. package/dist/consts/polymarket.d.ts +14 -0
  38. package/dist/css/sprinkles.css.d.ts +17 -15
  39. package/dist/domains/polymarketPerps.d.ts +14 -0
  40. package/dist/hooks/queries/useFops.d.ts +3 -1
  41. package/dist/hooks/queries/useWithdrawalQuote.d.ts +7 -0
  42. package/dist/hooks/statsig/index.d.ts +1 -0
  43. package/dist/hooks/statsig/useExperimentV2.d.ts +8 -0
  44. package/dist/hooks/track/CheckoutModalEvent.d.ts +1 -0
  45. package/dist/hooks/track/analytics/events.d.ts +67 -0
  46. package/dist/hooks/track/analytics/mappers.d.ts +4 -1
  47. package/dist/hooks/track/analytics/quote.d.ts +3 -1
  48. package/dist/hooks/track/analytics/useWithdrawalAnalytics.d.ts +27 -3
  49. package/dist/hooks/track/useTrack.d.ts +1 -1
  50. package/dist/hooks/track/user.d.ts +8 -0
  51. package/dist/hooks/useCheckoutTransferInit.d.ts +3 -1
  52. package/dist/hooks/useFittedText.d.ts +19 -0
  53. package/dist/hooks/usePolymarketAccountBalances.d.ts +13 -25
  54. package/dist/hooks/useUpdateActiveFunkitCheckout.d.ts +10 -0
  55. package/dist/index.css +4704 -4677
  56. package/dist/index.js +5078 -3730
  57. package/dist/modals/CheckoutModal/CheckoutModalPrefetchedHooks.d.ts +2 -1
  58. package/dist/modals/CheckoutModal/InputAmount/InputAmount.d.ts +1 -1
  59. package/dist/modals/CheckoutModal/InputAmount/state.d.ts +10 -0
  60. package/dist/modals/CheckoutModal/InputAmount/useAmountInput.d.ts +1 -0
  61. package/dist/modals/CheckoutModal/SourceChange/CryptoCashToggle.d.ts +6 -1
  62. package/dist/modals/PolymarketPerpsTransfer/DirectionSwapButton.d.ts +1 -11
  63. package/dist/modals/PolymarketPerpsTransfer/PerpsHeaderTabs.d.ts +29 -0
  64. package/dist/modals/PolymarketPerpsTransfer/PerpsTransferAmountInput.css.d.ts +9 -0
  65. package/dist/modals/PolymarketPerpsTransfer/PerpsTransferAmountInput.d.ts +15 -0
  66. package/dist/modals/PolymarketPerpsTransfer/PerpsTransferBody.d.ts +12 -0
  67. package/dist/modals/PolymarketPerpsTransfer/PolymarketPerpsPrefetch.d.ts +7 -0
  68. package/dist/modals/PolymarketPerpsTransfer/PolymarketPerpsTransferScreen.d.ts +16 -2
  69. package/dist/modals/PolymarketPerpsTransfer/TransferAccountsCard.d.ts +12 -0
  70. package/dist/modals/PolymarketPerpsTransfer/TransferActionButton.d.ts +8 -1
  71. package/dist/modals/PolymarketPerpsTransfer/TransferPercentOptions.d.ts +13 -0
  72. package/dist/modals/PolymarketPerpsTransfer/usePerpsHeaderTabsState.d.ts +28 -0
  73. package/dist/modals/PolymarketPerpsTransfer/usePerpsTransferForm.d.ts +31 -5
  74. package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +6 -0
  75. package/dist/modals/WithdrawalModal/RecipientAddress.d.ts +0 -5
  76. package/dist/modals/WithdrawalModal/useTrackWithdrawalEvents.d.ts +8 -1
  77. package/dist/modals/WithdrawalModal/useTrackWithdrawalQuoteEvents.d.ts +16 -0
  78. package/dist/modals/WithdrawalModal/useWithdrawalChainPreference.d.ts +17 -0
  79. package/dist/modals/WithdrawalModal/withdrawalHooks.d.ts +2 -1
  80. package/dist/providers/FunkitCheckoutContext/index.d.ts +13 -1
  81. package/dist/providers/FunkitCheckoutContext/types.d.ts +30 -3
  82. package/dist/providers/FunkitConfigContext.d.ts +1 -1
  83. package/dist/providers/FunkitStatsigProvider.d.ts +2 -7
  84. package/dist/providers/FunkitStatsigWhnProvider.d.ts +17 -0
  85. package/dist/providers/FunkitThemeProvider.d.ts +3 -0
  86. package/dist/providers/GeneralWalletProvider.d.ts +1 -0
  87. package/dist/shadow-css.js +1 -1
  88. package/dist/themes/baseTheme.js +1 -1
  89. package/dist/themes/darkTheme.js +2 -2
  90. package/dist/themes/lightTheme.js +2 -2
  91. package/dist/utils/statsig/client.d.ts +4 -0
  92. package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
  93. package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
  94. package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
  95. package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
  96. package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
  97. package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
  98. package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
  99. package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
  100. package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
  101. package/dist/wallets/walletConnectors/index.js +46 -46
  102. package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
  103. package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
  104. package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
  105. package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
  106. package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
  107. package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
  108. package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
  109. package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
  110. package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
  111. package/package.json +5 -5
  112. package/dist/clients/chunk-AXLGZ5XX.js +0 -1325
  113. package/dist/clients/chunk-DSZHYQPX.js +0 -31
  114. package/dist/clients/chunk-HZP4DXIZ.js +0 -231
  115. package/dist/clients/chunk-LUHEVXPD.js +0 -109
  116. package/dist/clients/chunk-NM2NAKI3.js +0 -1195
  117. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +0 -17545
  118. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.d.ts +0 -30
  119. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +0 -20
  120. package/dist/clients/polymarket/index.css +0 -17545
  121. package/dist/modals/PolymarketPerpsTransfer/PerpsTransferRows.d.ts +0 -10
  122. package/dist/modals/PolymarketPerpsTransfer/TransferAmountRow.css.d.ts +0 -13
  123. package/dist/modals/PolymarketPerpsTransfer/TransferAmountRow.d.ts +0 -27
  124. package/dist/wallets/walletConnectors/{chunk-W2LCLDPX.js → chunk-2VP2F6EK.js} +3 -3
  125. package/dist/wallets/walletConnectors/{chunk-IULPZP2Q.js → chunk-4T6ZSRJF.js} +3 -3
  126. package/dist/wallets/walletConnectors/{chunk-WAHGI5L7.js → chunk-6BW3HLBG.js} +3 -3
  127. package/dist/wallets/walletConnectors/{chunk-YO2K4MBH.js → chunk-CCQV2ZET.js} +3 -3
  128. package/dist/wallets/walletConnectors/{chunk-TKB2OY6G.js → chunk-CPI4TD43.js} +3 -3
  129. package/dist/wallets/walletConnectors/{chunk-OX37G4YT.js → chunk-F5XEEVG6.js} +3 -3
  130. package/dist/wallets/walletConnectors/{chunk-JPN6TWIT.js → chunk-HNRB7KJU.js} +3 -3
  131. package/dist/wallets/walletConnectors/{chunk-WKNQMP4A.js → chunk-HTHAK6XB.js} +3 -3
  132. package/dist/wallets/walletConnectors/{chunk-GUQM4QSL.js → chunk-MIQTHJ6X.js} +3 -3
  133. package/dist/wallets/walletConnectors/{chunk-4NV5BYRP.js → chunk-RB3HR4R2.js} +3 -3
  134. package/dist/wallets/walletConnectors/{chunk-SWFF3TWJ.js → chunk-RVOY537T.js} +3 -3
  135. package/dist/wallets/walletConnectors/{chunk-KI5Y2BBF.js → chunk-STVVP43G.js} +3 -3
  136. package/dist/wallets/walletConnectors/{chunk-OEEGYENV.js → chunk-UK7C2JXW.js} +3 -3
  137. package/dist/wallets/walletConnectors/{chunk-YQFGVZGR.js → chunk-VAPGUPHO.js} +3 -3
  138. package/dist/wallets/walletConnectors/{chunk-XCNHV3HS.js → chunk-VTM6EECM.js} +3 -3
  139. package/dist/wallets/walletConnectors/{chunk-NR2OGDHQ.js → chunk-X6CGV36L.js} +3 -3
  140. package/dist/wallets/walletConnectors/{chunk-AVDUNQUW.js → chunk-YEZM4CK4.js} +3 -3
  141. package/dist/wallets/walletConnectors/{chunk-KCRO2AGO.js → chunk-ZNX4EMPB.js} +3 -3
@@ -1,1195 +0,0 @@
1
- "use client";
2
- import {
3
- FunInput,
4
- FunSkeletonBlock,
5
- TooltipAnchorRefContext
6
- } from "./chunk-AXLGZ5XX.js";
7
- import {
8
- Box,
9
- Text,
10
- themeVars
11
- } from "./chunk-LUHEVXPD.js";
12
- import {
13
- useFunkitTranslation
14
- } from "./chunk-OASVWVSV.js";
15
- import {
16
- POLYMARKET_PERPS_ROUTING_ID,
17
- POLYMARKET_PREDICTIONS_ROUTING_ID
18
- } from "./chunk-Y7WLUPTX.js";
19
- import {
20
- POLYGON_USDCE,
21
- PUSD_TOKEN
22
- } from "./chunk-IYCZWLAF.js";
23
- import {
24
- logger
25
- } from "./chunk-AHYOV7AV.js";
26
-
27
- // src/clients/polymarket/PolymarketDepositAccountDropdown.tsx
28
- import React13 from "react";
29
- import { getAddress } from "viem";
30
- import { polygon } from "viem/chains";
31
-
32
- // src/components/Dropdown/AccountSelectDropdown.tsx
33
- import React12, { useEffect as useEffect4 } from "react";
34
-
35
- // src/components/Dropdown/BaseDropdown.tsx
36
- import { isMobile } from "@funkit/utils";
37
- import * as DropdownMenu2 from "@radix-ui/react-dropdown-menu";
38
- import React11, { useCallback as useCallback2, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
39
-
40
- // src/hooks/useScrollDivider.ts
41
- import { useCallback, useEffect, useState } from "react";
42
- var useScrollDivider = () => {
43
- const [refElement, setRefElement] = useState(null);
44
- const ref = useCallback((node) => setRefElement(node), []);
45
- const [isTop, setIsTop] = useState(true);
46
- const [isAtBottom, setIsAtBottom] = useState(false);
47
- const [isScrollable, setIsScrollable] = useState(false);
48
- const [isScrolling, setIsScrolling] = useState(false);
49
- useEffect(() => {
50
- const content = refElement;
51
- if (!content || !window.ResizeObserver) {
52
- return;
53
- }
54
- const handleScrollPositionChange = () => {
55
- const { scrollTop, scrollHeight, clientHeight } = content;
56
- setIsTop(scrollTop === 0);
57
- setIsAtBottom(scrollTop + clientHeight >= scrollHeight - 1);
58
- setIsScrollable(scrollHeight > clientHeight + 2);
59
- };
60
- const handleContentChange = () => {
61
- handleScrollPositionChange();
62
- setTimeout(handleScrollPositionChange, 500);
63
- };
64
- const onScrollChange = () => {
65
- handleScrollPositionChange();
66
- setIsScrolling(true);
67
- };
68
- const onScrollEnd = () => setIsScrolling(false);
69
- content.addEventListener("scrollend", onScrollEnd);
70
- content.addEventListener("scroll", onScrollChange);
71
- const resizeObserver = new window.ResizeObserver(handleContentChange);
72
- resizeObserver.observe(content);
73
- const mutationObserver = new MutationObserver(handleContentChange);
74
- mutationObserver.observe(content, {
75
- childList: true,
76
- subtree: true,
77
- attributes: true,
78
- attributeFilter: ["style", "class"]
79
- });
80
- handleScrollPositionChange();
81
- return () => {
82
- content.removeEventListener("scroll", onScrollChange);
83
- content.removeEventListener("scrollend", onScrollEnd);
84
- resizeObserver.unobserve(content);
85
- mutationObserver.disconnect();
86
- };
87
- }, [refElement]);
88
- return {
89
- ref,
90
- hasTopDivider: !isTop,
91
- hasBottomDivider: isScrollable,
92
- isAtBottom,
93
- isScrolling,
94
- isScrollable
95
- };
96
- };
97
-
98
- // src/providers/FunkitProvider.tsx
99
- import { LogLevel, initializeRelayClient } from "@funkit/fun-relay";
100
- import { QueryClientProvider } from "@tanstack/react-query";
101
- import React9, {
102
- createContext as createContext2,
103
- useContext as useContext2,
104
- useEffect as useEffect2,
105
- useMemo,
106
- useRef,
107
- useState as useState2
108
- } from "react";
109
-
110
- // src/providers/FunkitShadowHostProvider.tsx
111
- import React, { createContext, useContext } from "react";
112
- import { createPortal } from "react-dom";
113
- var ShadowContainerContext = createContext(null);
114
- function useShadowContainer() {
115
- const container = useContext(ShadowContainerContext);
116
- if (container) {
117
- return container;
118
- }
119
- return typeof document === "undefined" ? null : document.body;
120
- }
121
- function useRootNode() {
122
- const container = useContext(ShadowContainerContext);
123
- return container ? container.getRootNode() : document;
124
- }
125
-
126
- // src/utils/tokenMath.ts
127
- import { formatCurrencyAndStringify } from "@funkit/utils";
128
- import * as dnum from "dnum";
129
- import { formatUnits } from "viem";
130
- function floorToDecimals(value, decimals) {
131
- const d = dnum.from(value, decimals);
132
- return dnum.toNumber(d, decimals);
133
- }
134
- function formatUsdFlooredToCent(balanceUsd) {
135
- return formatCurrencyAndStringify(floorToDecimals(balanceUsd, 2));
136
- }
137
-
138
- // src/components/Icons/CheckIcon.tsx
139
- import React2 from "react";
140
- var CheckIcon = ({
141
- size = 16,
142
- className
143
- }) => /* @__PURE__ */ React2.createElement(
144
- "svg",
145
- {
146
- width: size,
147
- height: size,
148
- viewBox: "0 0 16 16",
149
- fill: "none",
150
- xmlns: "http://www.w3.org/2000/svg",
151
- className
152
- },
153
- /* @__PURE__ */ React2.createElement(
154
- "path",
155
- {
156
- d: "M12.4919 4.88281L6.25757 11.1172L3.50781 8",
157
- stroke: "currentColor",
158
- strokeWidth: "1.5",
159
- strokeLinecap: "round",
160
- strokeLinejoin: "round",
161
- pathLength: "100"
162
- }
163
- )
164
- );
165
-
166
- // src/components/Dropdown/BaseDropdownItem.tsx
167
- import { noop } from "@funkit/utils";
168
- import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
169
- import React3 from "react";
170
- import clsx from "clsx";
171
-
172
- // src/components/Dropdown/BaseDropdownItem.css.ts
173
- var disabledDropdownItemStyles = "_18hhw3k3 _18hhw3k2";
174
- var enabledDropdownItemStyles = "_18hhw3k1 _18hhw3k0";
175
-
176
- // src/components/Dropdown/BaseDropdownItem.tsx
177
- function BaseDropdownItem({
178
- iconComponent,
179
- label,
180
- description,
181
- id,
182
- onClick = noop,
183
- isSelected = false,
184
- isDisabled = false,
185
- borderRadius = "connectButton",
186
- horizontalIconGap = "dropdownItemIconGap",
187
- tagComponent,
188
- horizontalPadding = "dropdownItemPaddingX",
189
- verticalPadding = "dropdownItemPaddingY"
190
- }) {
191
- return /* @__PURE__ */ React3.createElement(
192
- DropdownMenu.Item,
193
- {
194
- disabled: isDisabled,
195
- onSelect: () => onClick(id),
196
- asChild: true
197
- },
198
- /* @__PURE__ */ React3.createElement(
199
- Box,
200
- {
201
- width: "full",
202
- display: "flex",
203
- alignItems: "center",
204
- justifyContent: "space-between",
205
- gap: "24",
206
- paddingY: verticalPadding,
207
- paddingX: horizontalPadding,
208
- className: clsx(
209
- isDisabled ? disabledDropdownItemStyles : enabledDropdownItemStyles
210
- ),
211
- boxShadow: isSelected ? "selectedDropdownItem" : void 0,
212
- borderRadius
213
- },
214
- /* @__PURE__ */ React3.createElement(
215
- Box,
216
- {
217
- display: "flex",
218
- alignItems: "center",
219
- justifyContent: "flex-start",
220
- gap: horizontalIconGap
221
- },
222
- iconComponent && /* @__PURE__ */ React3.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "center" }, iconComponent),
223
- /* @__PURE__ */ React3.createElement(Box, { display: "flex", flexDirection: "column", justifyContent: "center" }, /* @__PURE__ */ React3.createElement(
224
- Text,
225
- {
226
- size: "dropdownItemFontSize",
227
- weight: "medium",
228
- color: isSelected ? "selectedDropdownItemText" : void 0
229
- },
230
- label
231
- ), description != null && /* @__PURE__ */ React3.createElement(Text, { size: "12", color: "secondaryText" }, description))
232
- ),
233
- /* @__PURE__ */ React3.createElement(
234
- Box,
235
- {
236
- display: "flex",
237
- alignItems: "center",
238
- justifyContent: "center",
239
- gap: "16"
240
- },
241
- tagComponent,
242
- /* @__PURE__ */ React3.createElement(
243
- Box,
244
- {
245
- width: "16",
246
- height: "16",
247
- alignItems: "center",
248
- justifyContent: "center",
249
- color: isSelected ? "selectedDropdownItemText" : "transparent"
250
- },
251
- /* @__PURE__ */ React3.createElement(CheckIcon, null)
252
- )
253
- )
254
- )
255
- );
256
- }
257
- var BaseDropdownItem_default = BaseDropdownItem;
258
-
259
- // src/components/Dropdown/BaseDropdown.css.ts
260
- var BORDER_RADIUS = "dropdown";
261
- var baseDropdownItemWrapperStyles = "_1nns6ys6 _1rsrm2f17";
262
- var dropdownContentAnimationStyles = "_1nns6ys2";
263
- var scrollGradientWrapperStyles = "_1nns6ys4";
264
- var scrollableDropdownStyles = "_1nns6ys3";
265
-
266
- // src/components/Icons/CaretDownIcon.tsx
267
- import clsx2 from "clsx";
268
- import React4 from "react";
269
-
270
- // src/components/Icons/CaretDownIcon.css.ts
271
- var caretClosed = "_1gjdf1i3";
272
- var caretOpened = "_1gjdf1i2";
273
-
274
- // src/components/Icons/CaretDownIcon.tsx
275
- var CaretDownIcon = () => {
276
- return /* @__PURE__ */ React4.createElement(
277
- "svg",
278
- {
279
- width: "8",
280
- height: "5",
281
- viewBox: "0 0 8 5",
282
- fill: "none",
283
- xmlns: "http://www.w3.org/2000/svg"
284
- },
285
- /* @__PURE__ */ React4.createElement(
286
- "path",
287
- {
288
- 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",
289
- fill: "currentColor"
290
- }
291
- )
292
- );
293
- };
294
- var AnimatedCaretDownIcon = ({
295
- expanded,
296
- color = "primaryText",
297
- compact = false
298
- }) => {
299
- const animationClassName = clsx2(
300
- expanded !== void 0 && (expanded ? caretOpened : caretClosed)
301
- );
302
- if (compact) {
303
- return /* @__PURE__ */ React4.createElement(
304
- Box,
305
- {
306
- color,
307
- width: "8",
308
- height: "8",
309
- display: "flex",
310
- alignItems: "center",
311
- justifyContent: "center",
312
- className: animationClassName
313
- },
314
- /* @__PURE__ */ React4.createElement(CaretDownIcon, null)
315
- );
316
- }
317
- return /* @__PURE__ */ React4.createElement(
318
- Box,
319
- {
320
- color,
321
- width: "16",
322
- height: "16",
323
- display: "flex",
324
- alignItems: "center",
325
- justifyContent: "center",
326
- className: animationClassName
327
- },
328
- /* @__PURE__ */ React4.createElement(
329
- Box,
330
- {
331
- width: "8",
332
- height: "8",
333
- display: "flex",
334
- alignItems: "center",
335
- justifyContent: "center"
336
- },
337
- /* @__PURE__ */ React4.createElement(CaretDownIcon, null)
338
- )
339
- );
340
- };
341
-
342
- // src/hooks/usePolymarketAccountBalances.ts
343
- import {
344
- skipToken,
345
- useQuery,
346
- useQueryClient
347
- } from "@tanstack/react-query";
348
- import * as dnum2 from "dnum";
349
- var DEFAULT_BALANCE_REFETCH_MS = 1e3;
350
- var polymarketAccountBalanceQueryKey = (address) => ["polymarket", "accountBalanceUsd", address ?? null];
351
- var polymarketBalanceSettleUntilQueryKey = (address) => ["polymarket", "accountBalanceSettleUntil", address];
352
- async function fetchAccountBalance(queryClient, getBalanceUsd, queryKey) {
353
- const [, , address] = queryKey;
354
- if (address === null) {
355
- throw new Error("polymarket balance query ran without an address");
356
- }
357
- try {
358
- const serverUsd = await getBalanceUsd();
359
- const settleUntil = queryClient.getQueryData(
360
- polymarketBalanceSettleUntilQueryKey(address)
361
- );
362
- const displayedUsd = queryClient.getQueryData(
363
- polymarketAccountBalanceQueryKey(address)
364
- );
365
- if (settleUntil !== void 0 && Date.now() < settleUntil && displayedUsd !== void 0) {
366
- return displayedUsd;
367
- }
368
- return serverUsd;
369
- } catch (error) {
370
- logger.warn("polymarket:accountBalance:fetchFailed", {
371
- address,
372
- error: String(error)
373
- });
374
- throw error;
375
- }
376
- }
377
- function useAccountBalance(account, refetchIntervalMs) {
378
- const queryClient = useQueryClient();
379
- const getBalanceUsd = account?.getBalanceUsd;
380
- const address = account?.address;
381
- const query = useQuery({
382
- queryKey: polymarketAccountBalanceQueryKey(address),
383
- // `skipToken` disables the query when the account isn't configured (the
384
- // perps-transfer config is optional). It is *not* a fallback for a missing
385
- // balance — the getter is the single source of truth.
386
- queryFn: getBalanceUsd && address ? ({ queryKey }) => fetchAccountBalance(queryClient, getBalanceUsd, queryKey) : skipToken,
387
- refetchInterval: refetchIntervalMs,
388
- // The poll interval is the freshness contract: a reader mounting within it
389
- // (e.g. navigating between the deposit picker and the transfer step) reads
390
- // the cached balance as-is instead of kicking off an extra mount fetch —
391
- // that's what makes the navigation flash-free *and* fetch-free.
392
- staleTime: refetchIntervalMs
393
- });
394
- return { balanceUsd: query.data };
395
- }
396
- function usePolymarketAccountBalances(accounts, options) {
397
- const refetchIntervalMs = options?.refetchIntervalMs ?? DEFAULT_BALANCE_REFETCH_MS;
398
- return {
399
- predictions: useAccountBalance(accounts.predictions, refetchIntervalMs),
400
- perps: useAccountBalance(accounts.perps, refetchIntervalMs)
401
- };
402
- }
403
-
404
- // src/components/FunNoResults/FunNoResults.tsx
405
- import React7 from "react";
406
-
407
- // src/components/Icons/CoinsIcon.tsx
408
- import React5 from "react";
409
- var CoinsIcon = ({
410
- size = 48,
411
- bgColor = "#141C41",
412
- iconColor = "#878A98"
413
- }) => {
414
- return /* @__PURE__ */ React5.createElement(
415
- "svg",
416
- {
417
- width: size,
418
- height: size,
419
- viewBox: "0 0 48 49",
420
- fill: "none",
421
- xmlns: "http://www.w3.org/2000/svg"
422
- },
423
- /* @__PURE__ */ React5.createElement("g", { clipPath: "url(#clip0_30657_22302)" }, /* @__PURE__ */ React5.createElement(
424
- "path",
425
- {
426
- 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",
427
- fill: bgColor,
428
- stroke: bgColor
429
- }
430
- ), /* @__PURE__ */ React5.createElement("g", { clipPath: "url(#clip1_30657_22302)" }, /* @__PURE__ */ React5.createElement(
431
- "path",
432
- {
433
- 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",
434
- stroke: iconColor,
435
- strokeWidth: "1.5",
436
- strokeLinecap: "round",
437
- strokeLinejoin: "round"
438
- }
439
- ))),
440
- /* @__PURE__ */ React5.createElement("defs", null, /* @__PURE__ */ React5.createElement("clipPath", { id: "clip0_30657_22302" }, /* @__PURE__ */ React5.createElement(
441
- "rect",
442
- {
443
- width: "48",
444
- height: "48",
445
- fill: "white",
446
- transform: "translate(0 0.5)"
447
- }
448
- )), /* @__PURE__ */ React5.createElement("clipPath", { id: "clip1_30657_22302" }, /* @__PURE__ */ React5.createElement(
449
- "rect",
450
- {
451
- width: "24",
452
- height: "24",
453
- fill: "white",
454
- transform: "translate(12 12)"
455
- }
456
- )))
457
- );
458
- };
459
-
460
- // src/components/Icons/SearchSkeletonIcon.tsx
461
- import React6 from "react";
462
- var SearchSkeletonIcon = () => {
463
- return /* @__PURE__ */ React6.createElement(
464
- "svg",
465
- {
466
- width: "122",
467
- height: "81",
468
- viewBox: "0 0 122 81",
469
- fill: "none",
470
- xmlns: "http://www.w3.org/2000/svg"
471
- },
472
- /* @__PURE__ */ React6.createElement("g", { clipPath: "url(#clip0_7590_15835)" }, /* @__PURE__ */ React6.createElement(
473
- "path",
474
- {
475
- fillRule: "evenodd",
476
- clipRule: "evenodd",
477
- 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",
478
- fill: "currentColor"
479
- }
480
- ), /* @__PURE__ */ React6.createElement(
481
- "path",
482
- {
483
- 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",
484
- fill: "currentColor"
485
- }
486
- ), /* @__PURE__ */ React6.createElement(
487
- "path",
488
- {
489
- 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",
490
- fill: "currentColor"
491
- }
492
- ), /* @__PURE__ */ React6.createElement(
493
- "path",
494
- {
495
- 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",
496
- fill: "currentColor"
497
- }
498
- )),
499
- /* @__PURE__ */ React6.createElement("defs", null, /* @__PURE__ */ React6.createElement("clipPath", { id: "clip0_7590_15835" }, /* @__PURE__ */ React6.createElement(
500
- "rect",
501
- {
502
- width: "121",
503
- height: "81",
504
- fill: "white",
505
- transform: "translate(0.5)"
506
- }
507
- )))
508
- );
509
- };
510
-
511
- // src/components/FunNoResults/FunNoResults.tsx
512
- var FunNoResults = ({
513
- text,
514
- title,
515
- variant = "default",
516
- actionButton
517
- }) => {
518
- return /* @__PURE__ */ React7.createElement(
519
- Box,
520
- {
521
- display: "flex",
522
- flexDirection: "column",
523
- justifyContent: "center",
524
- alignItems: "center",
525
- gap: variant === "default" ? "12" : "16",
526
- color: "secondaryText",
527
- style: { flex: 1 }
528
- },
529
- variant === "default" && /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(SearchSkeletonIcon, null), /* @__PURE__ */ React7.createElement(Text, { color: "secondaryText", size: "10" }, text)),
530
- variant === "actionable" && /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(
531
- CoinsIcon,
532
- {
533
- bgColor: themeVars.colors.offBackground,
534
- iconColor: themeVars.colors.actionColor
535
- }
536
- ), /* @__PURE__ */ React7.createElement(
537
- Box,
538
- {
539
- display: "flex",
540
- flexDirection: "column",
541
- alignItems: "center",
542
- gap: "12"
543
- },
544
- /* @__PURE__ */ React7.createElement(
545
- Box,
546
- {
547
- display: "flex",
548
- flexDirection: "column",
549
- alignItems: "center",
550
- textAlign: "center",
551
- gap: "8"
552
- },
553
- title && /* @__PURE__ */ React7.createElement(Text, { size: "14", color: "primaryText" }, title),
554
- /* @__PURE__ */ React7.createElement(Text, { color: "secondaryText", size: "12" }, text)
555
- ),
556
- actionButton && /* @__PURE__ */ React7.createElement(Box, null, actionButton)
557
- ))
558
- );
559
- };
560
-
561
- // src/components/Icons/SwitchIcon.tsx
562
- import React8 from "react";
563
- var SwitchIcon = () => {
564
- return /* @__PURE__ */ React8.createElement(
565
- "svg",
566
- {
567
- width: "15",
568
- height: "14",
569
- viewBox: "0 0 15 14",
570
- fill: "none",
571
- xmlns: "http://www.w3.org/2000/svg"
572
- },
573
- /* @__PURE__ */ React8.createElement(
574
- "path",
575
- {
576
- fillRule: "evenodd",
577
- clipRule: "evenodd",
578
- 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",
579
- fill: "currentColor"
580
- }
581
- )
582
- );
583
- };
584
-
585
- // src/providers/FunkitProvider.tsx
586
- var attr = "data-rk";
587
- var createThemeRootProps = (id) => ({ [attr]: id || "" });
588
- var ThemeRootContext = createContext2({
589
- id: void 0,
590
- element: null
591
- });
592
- var useThemeRootProps = () => createThemeRootProps(useContext2(ThemeRootContext).id);
593
-
594
- // src/components/Dropdown/BaseActiveDropdownItem.tsx
595
- import React10 from "react";
596
-
597
- // src/components/Dropdown/BaseActiveDropdownItem.css.ts
598
- var baseStyles = "_1dewiqw0";
599
-
600
- // src/components/Dropdown/BaseActiveDropdownItem.tsx
601
- function BaseActiveDropdownItem({
602
- iconComponent,
603
- label,
604
- isOpened,
605
- onClick,
606
- horizontalIconGap = "dropdownItemIconGap",
607
- alwaysVisibleLabel,
608
- tagComponent,
609
- tagPosition = "start",
610
- size = "regular",
611
- color = "primaryText",
612
- arrowColor = "secondaryText",
613
- background,
614
- labelStyle,
615
- compactIcon = false
616
- }) {
617
- return /* @__PURE__ */ React10.createElement(
618
- Box,
619
- {
620
- display: "flex",
621
- alignItems: "center",
622
- justifyContent: "space-between",
623
- gap: "6",
624
- cursor: "pointer",
625
- onClick,
626
- background: background ?? {
627
- base: "dropdownActiveItemBackgroundBase",
628
- hover: "dropdownActiveItemBackgroundHover"
629
- },
630
- borderColor: {
631
- base: "dropdownActiveItemBorderBase",
632
- hover: "dropdownActiveItemBorderHover"
633
- },
634
- borderWidth: size === "compact" ? "0" : "1",
635
- borderRadius: BORDER_RADIUS,
636
- borderStyle: "solid",
637
- paddingY: size === "compact" ? "2" : size === "large" ? "10" : "dropdownActiveItemRegularSizePaddingY",
638
- paddingX: size === "compact" ? "4" : size === "large" ? "8" : "dropdownPaddingX",
639
- className: baseStyles
640
- },
641
- /* @__PURE__ */ React10.createElement(
642
- Box,
643
- {
644
- display: "flex",
645
- alignItems: "center",
646
- justifyContent: "space-between",
647
- gap: horizontalIconGap,
648
- style: size === "compact" ? void 0 : { flex: "1 0 auto" }
649
- },
650
- alwaysVisibleLabel && /* @__PURE__ */ React10.createElement(Box, { style: { flex: 1 } }, /* @__PURE__ */ React10.createElement(Text, { color: "secondaryText", size: "12" }, alwaysVisibleLabel)),
651
- /* @__PURE__ */ React10.createElement(
652
- Box,
653
- {
654
- display: "flex",
655
- alignItems: "center",
656
- justifyContent: "space-between",
657
- gap: horizontalIconGap,
658
- background: {
659
- base: "transparent",
660
- hover: "alwaysVisibleLabelBackgroundHover"
661
- },
662
- ...alwaysVisibleLabel ? {} : { style: { flex: 1 } }
663
- },
664
- /* @__PURE__ */ React10.createElement(
665
- Box,
666
- {
667
- display: "flex",
668
- alignItems: "center",
669
- justifyContent: "center",
670
- gap: horizontalIconGap,
671
- ...alwaysVisibleLabel ? { style: { flexDirection: "row-reverse" } } : {}
672
- },
673
- tagPosition === "start" && tagComponent,
674
- /* @__PURE__ */ React10.createElement(Box, { display: "flex", alignItems: "center", gap: horizontalIconGap }, iconComponent && /* @__PURE__ */ React10.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "center" }, iconComponent), /* @__PURE__ */ React10.createElement(
675
- Text,
676
- {
677
- color,
678
- size: "dropdownItemFontSize",
679
- weight: "medium",
680
- style: labelStyle
681
- },
682
- label
683
- ))
684
- ),
685
- /* @__PURE__ */ React10.createElement(Box, { display: "flex", alignItems: "center", gap: "5" }, tagPosition === "end" && tagComponent, /* @__PURE__ */ React10.createElement(
686
- AnimatedCaretDownIcon,
687
- {
688
- expanded: isOpened,
689
- color: arrowColor,
690
- compact: compactIcon
691
- }
692
- ))
693
- )
694
- )
695
- );
696
- }
697
- var BaseActiveDropdownItem_default = BaseActiveDropdownItem;
698
-
699
- // src/components/Dropdown/BaseDropdown.utils.ts
700
- var NO_SELECTION_VALUE = "";
701
- var ADDITIONAL_GROUP_KEY = "__additional__";
702
- function buildAllOptions(options, allowUnselect, unselectLabel) {
703
- if (allowUnselect) {
704
- return [
705
- {
706
- label: unselectLabel ?? "",
707
- value: NO_SELECTION_VALUE
708
- },
709
- ...options
710
- ];
711
- }
712
- return options;
713
- }
714
- function filterOptions(allOptions, searchInput) {
715
- const search = searchInput?.trim().toLowerCase() ?? "";
716
- return allOptions.filter(
717
- (option) => option.label.toLowerCase().includes(search)
718
- );
719
- }
720
- function organizeDropdownGroups(filteredOptions, groups, additionalGroup, additionalGroupLabel) {
721
- const organizedGroups = [];
722
- if (!groups) {
723
- organizedGroups.push({
724
- key: ADDITIONAL_GROUP_KEY,
725
- label: void 0,
726
- options: filteredOptions
727
- });
728
- return {
729
- organizedGroups,
730
- organizedOptions: filteredOptions
731
- };
732
- }
733
- const unselectOption = filteredOptions.find(
734
- (option) => option.value === NO_SELECTION_VALUE
735
- );
736
- if (unselectOption) {
737
- organizedGroups.push({
738
- key: NO_SELECTION_VALUE,
739
- label: void 0,
740
- options: [unselectOption]
741
- });
742
- }
743
- const optionsByValue = new Map(
744
- filteredOptions.filter((option) => option.value !== NO_SELECTION_VALUE).map((option) => [option.value, option])
745
- );
746
- const inflatedGroups = groups.map((group) => ({
747
- ...group,
748
- // Only take the options that actually exist
749
- // Note that this preserves the ordering of `group.values`
750
- options: group.values.map((value) => optionsByValue.get(value)).filter((option) => !!option)
751
- })).filter((group) => group.options.length > 0);
752
- const hasNonEmptyGroup = inflatedGroups.length > 0;
753
- for (const group of inflatedGroups) {
754
- organizedGroups.push({
755
- key: group.key,
756
- label: group.label,
757
- options: group.options
758
- });
759
- if (additionalGroup === "others") {
760
- for (const option of group.options) {
761
- optionsByValue.delete(option.value);
762
- }
763
- }
764
- }
765
- if (optionsByValue.size > 0) {
766
- organizedGroups.push({
767
- key: ADDITIONAL_GROUP_KEY,
768
- // Only show additional group label if there actually are other groups
769
- label: hasNonEmptyGroup ? additionalGroupLabel : void 0,
770
- options: [...optionsByValue.values()]
771
- });
772
- }
773
- const organizedOptions = organizedGroups.flatMap((group) => group.options);
774
- return { organizedGroups, organizedOptions };
775
- }
776
-
777
- // src/components/Dropdown/BaseDropdown.tsx
778
- var HORIZONTAL_ICON_GAP = "4";
779
- var activeDropdownItemSize = {
780
- compact: "18",
781
- regular: "36",
782
- large: "40"
783
- };
784
- function BaseDropdown({
785
- activeItemProps,
786
- value,
787
- options,
788
- groups,
789
- additionalGroup = "others",
790
- additionalGroupLabel,
791
- allowUnselect = false,
792
- unselectLabel,
793
- onOptionSelected,
794
- onOpen,
795
- renderDropdownOption,
796
- searchableOptions = false,
797
- searchPlaceholder,
798
- placeholder,
799
- resetSearchOnClose = true,
800
- openToTopOnMobile = true,
801
- alwaysOpenToTop = false,
802
- openDropdownFullWidth = true,
803
- isLoading = false,
804
- preloadIconUrls,
805
- horizontalIconGap = HORIZONTAL_ICON_GAP,
806
- openDropdownBackgroundColor = "openDropdownBackgroundColor",
807
- size = "regular",
808
- label,
809
- maxDropdownHeight,
810
- dropdownWidth,
811
- dropdownAlign = "end",
812
- testId
813
- }) {
814
- const { t } = useFunkitTranslation();
815
- const themeRootProps = useThemeRootProps();
816
- const shadowContainer = useShadowContainer();
817
- const rootNode = useRootNode();
818
- const isMobileDevice = isMobile();
819
- const [isOpened, setIsOpened] = useState3(false);
820
- const [searchInput, setSearchInput] = useState3("");
821
- const { ref: scrollRef, hasTopDivider, isAtBottom } = useScrollDivider();
822
- const allOptions = useMemo2(
823
- () => buildAllOptions(options, allowUnselect, unselectLabel),
824
- [options, allowUnselect, unselectLabel]
825
- );
826
- const selectedOption = allOptions.find((option) => option.value === value);
827
- const prevIsOpenedRef = useRef2(false);
828
- const portalThemeRef = useRef2(null);
829
- const handleSearch = (event) => {
830
- setSearchInput(event.target.value);
831
- };
832
- const filteredOptions = useMemo2(
833
- () => filterOptions(allOptions, searchInput),
834
- [allOptions, searchInput]
835
- );
836
- const { organizedGroups, organizedOptions } = useMemo2(
837
- () => organizeDropdownGroups(
838
- filteredOptions,
839
- groups,
840
- additionalGroup,
841
- additionalGroupLabel
842
- ),
843
- [additionalGroup, additionalGroupLabel, filteredOptions, groups]
844
- );
845
- const handleOpenChange = useCallback2(
846
- (open) => {
847
- setIsOpened(open);
848
- if (open) {
849
- onOpen?.();
850
- } else {
851
- resetSearchOnClose && setSearchInput("");
852
- }
853
- },
854
- [onOpen, resetSearchOnClose]
855
- );
856
- useEffect3(() => {
857
- if (isOpened && !prevIsOpenedRef.current) {
858
- prevIsOpenedRef.current = true;
859
- if (selectedOption) {
860
- const selectedOptionIndex = organizedOptions.findIndex(
861
- (option) => option.value === selectedOption.value
862
- );
863
- if (selectedOptionIndex !== -1) {
864
- requestAnimationFrame(() => {
865
- const selectedOptionElement = rootNode.getElementById(
866
- `${selectedOption.value}-dropdown-item`
867
- );
868
- selectedOptionElement?.scrollIntoView({
869
- behavior: "instant",
870
- block: "center"
871
- });
872
- });
873
- }
874
- }
875
- } else if (!isOpened) {
876
- prevIsOpenedRef.current = false;
877
- }
878
- }, [isOpened, selectedOption, organizedOptions, rootNode]);
879
- const dropdownSide = alwaysOpenToTop || openToTopOnMobile && isMobileDevice ? "top" : "bottom";
880
- return /* @__PURE__ */ React11.createElement(Box, { display: "flex", flexDirection: "column", gap: "4", testId }, label && /* @__PURE__ */ React11.createElement(Text, { size: "12", color: "secondaryText" }, label), /* @__PURE__ */ React11.createElement(
881
- DropdownMenu2.Root,
882
- {
883
- open: isOpened,
884
- onOpenChange: handleOpenChange,
885
- modal: false
886
- },
887
- /* @__PURE__ */ React11.createElement(
888
- Box,
889
- {
890
- position: "relative",
891
- display: size === "compact" ? "flex" : void 0
892
- },
893
- isLoading ? /* @__PURE__ */ React11.createElement(FunSkeletonBlock, { height: activeDropdownItemSize[size] }) : /* @__PURE__ */ React11.createElement(DropdownMenu2.Trigger, { asChild: true }, /* @__PURE__ */ React11.createElement("div", null, /* @__PURE__ */ React11.createElement(
894
- BaseActiveDropdownItem_default,
895
- {
896
- color: !selectedOption && !activeItemProps?.label && !!placeholder ? "secondaryText" : "primaryText",
897
- ...activeItemProps,
898
- size,
899
- horizontalIconGap,
900
- isOpened,
901
- label: activeItemProps?.label ?? selectedOption?.label ?? placeholder ?? ""
902
- }
903
- ))),
904
- /* @__PURE__ */ React11.createElement(DropdownMenu2.Portal, { container: shadowContainer ?? void 0 }, /* @__PURE__ */ React11.createElement(
905
- DropdownMenu2.Content,
906
- {
907
- ...themeRootProps,
908
- ref: portalThemeRef,
909
- side: dropdownSide,
910
- sideOffset: dropdownSide === "top" ? 8 : 6,
911
- align: dropdownAlign,
912
- className: dropdownContentAnimationStyles,
913
- style: {
914
- zIndex: `calc(${themeVars.modalZIndex} + 1)`,
915
- width: dropdownWidth ? `${dropdownWidth}px` : openDropdownFullWidth ? "var(--radix-dropdown-menu-trigger-width)" : void 0,
916
- transformOrigin: "var(--radix-dropdown-menu-content-transform-origin)"
917
- },
918
- onCloseAutoFocus: (e) => e.preventDefault()
919
- },
920
- /* @__PURE__ */ React11.createElement(TooltipAnchorRefContext.Provider, { value: portalThemeRef }, /* @__PURE__ */ React11.createElement(
921
- Box,
922
- {
923
- background: openDropdownBackgroundColor,
924
- borderColor: "transparent",
925
- borderWidth: "1",
926
- borderRadius: "dropdownList",
927
- borderStyle: "solid",
928
- boxShadow: "dropdown",
929
- className: maxDropdownHeight ? scrollGradientWrapperStyles : void 0,
930
- "data-fade-top": maxDropdownHeight && hasTopDivider ? "true" : "false",
931
- "data-fade-bottom": maxDropdownHeight && !isAtBottom ? "true" : "false"
932
- },
933
- /* @__PURE__ */ React11.createElement(
934
- Box,
935
- {
936
- className: maxDropdownHeight ? scrollableDropdownStyles : void 0,
937
- ref: maxDropdownHeight ? scrollRef : void 0,
938
- style: { maxHeight: maxDropdownHeight }
939
- },
940
- /* @__PURE__ */ React11.createElement(Box, { display: "flex", flexDirection: "column" }, searchableOptions && /* @__PURE__ */ React11.createElement(Box, { paddingTop: "8", paddingX: "8" }, /* @__PURE__ */ React11.createElement(
941
- FunInput,
942
- {
943
- placeholder: searchPlaceholder ?? t("common.searchTokens"),
944
- value: searchInput,
945
- onChange: handleSearch,
946
- prefixIcon: "SearchIcon"
947
- }
948
- )), organizedOptions.length === 0 ? /* @__PURE__ */ React11.createElement(FunNoResults, { text: t("common.noResultsFound") }) : /* @__PURE__ */ React11.createElement(
949
- Box,
950
- {
951
- as: "ul",
952
- display: "flex",
953
- flexDirection: "column",
954
- paddingY: size === "compact" ? "dropdownCompactPaddingY" : "dropdownPaddingY"
955
- },
956
- organizedGroups.map(
957
- ({
958
- key: groupKey,
959
- label: groupLabel,
960
- options: optionsInGroup
961
- }, groupIndex) => /* @__PURE__ */ React11.createElement(React11.Fragment, { key: groupKey }, groupIndex > 0 && /* @__PURE__ */ React11.createElement(
962
- Box,
963
- {
964
- height: "1",
965
- background: "lightStroke",
966
- marginY: "dropdownGroupDividerMarginY"
967
- }
968
- ), groupLabel && /* @__PURE__ */ React11.createElement(
969
- Box,
970
- {
971
- paddingX: size === "compact" ? "dropdownCompactPaddingX" : "dropdownPaddingX"
972
- },
973
- /* @__PURE__ */ React11.createElement(
974
- Box,
975
- {
976
- paddingX: "dropdownItemPaddingX",
977
- paddingY: "dropdownItemPaddingY"
978
- },
979
- /* @__PURE__ */ React11.createElement(
980
- Text,
981
- {
982
- color: "dropdownGroupHeader",
983
- font: "dropdownGroupHeader",
984
- size: "dropdownGroupHeader",
985
- weight: "dropdownGroupHeader"
986
- },
987
- groupLabel
988
- )
989
- )
990
- ), optionsInGroup.map((singleOption) => {
991
- const isSelected = singleOption.value === selectedOption?.value;
992
- return /* @__PURE__ */ React11.createElement(
993
- Box,
994
- {
995
- key: singleOption.value,
996
- paddingX: size === "compact" ? "dropdownCompactPaddingX" : "dropdownPaddingX"
997
- },
998
- /* @__PURE__ */ React11.createElement(
999
- Box,
1000
- {
1001
- id: `${singleOption.value}-dropdown-item`,
1002
- as: "li",
1003
- background: {
1004
- base: isSelected ? "selectedDropdownItemBackground" : "transparent",
1005
- hover: "offBackground"
1006
- },
1007
- className: baseDropdownItemWrapperStyles,
1008
- onClick: () => {
1009
- onOptionSelected?.(singleOption);
1010
- }
1011
- },
1012
- renderDropdownOption(
1013
- singleOption,
1014
- isSelected
1015
- )
1016
- )
1017
- );
1018
- }))
1019
- )
1020
- ))
1021
- )
1022
- ))
1023
- )),
1024
- preloadIconUrls && /* @__PURE__ */ React11.createElement(
1025
- Box,
1026
- {
1027
- display: "none",
1028
- "aria-hidden": true,
1029
- style: { position: "absolute", top: "-100%", left: "-100%" }
1030
- },
1031
- preloadIconUrls.map((url, index) => /* @__PURE__ */ React11.createElement("img", { key: `${url}-${index}`, src: url, alt: "" }))
1032
- )
1033
- )
1034
- ));
1035
- }
1036
- var BaseDropdown_default = BaseDropdown;
1037
-
1038
- // src/components/Dropdown/AccountSelectDropdown.tsx
1039
- var ACCOUNTS_GROUP = "accounts";
1040
- var ACTION_GROUP = "action";
1041
- function AccountSelectDropdown({
1042
- accounts,
1043
- selectedValue,
1044
- onSelect,
1045
- action,
1046
- prefixLabel,
1047
- label,
1048
- size,
1049
- dropdownWidth,
1050
- testId
1051
- }) {
1052
- const actionIdCollidesWithAccount = !!action && accounts.some((account) => account.value === action.id);
1053
- const actionId = action?.id;
1054
- useEffect4(() => {
1055
- if (actionIdCollidesWithAccount) {
1056
- logger.warn("accountSelectDropdown:actionIdCollidesWithAccountValue", {
1057
- actionId
1058
- });
1059
- }
1060
- }, [actionIdCollidesWithAccount, actionId]);
1061
- const options = [
1062
- ...accounts.map((account) => ({
1063
- value: account.value,
1064
- label: account.label
1065
- })),
1066
- ...action ? [{ value: action.id, label: action.label }] : []
1067
- ];
1068
- const groups = action ? [
1069
- {
1070
- key: ACCOUNTS_GROUP,
1071
- label: "",
1072
- values: accounts.map((account) => account.value)
1073
- },
1074
- { key: ACTION_GROUP, label: "", values: [action.id] }
1075
- ] : void 0;
1076
- return /* @__PURE__ */ React12.createElement(
1077
- BaseDropdown_default,
1078
- {
1079
- testId,
1080
- label,
1081
- size,
1082
- dropdownWidth,
1083
- value: selectedValue,
1084
- options,
1085
- groups,
1086
- activeItemProps: { alwaysVisibleLabel: prefixLabel },
1087
- renderDropdownOption: (option, isSelected) => {
1088
- if (action && option.value === action.id) {
1089
- return /* @__PURE__ */ React12.createElement(
1090
- BaseDropdownItem_default,
1091
- {
1092
- id: option.value,
1093
- label: option.label,
1094
- iconComponent: action.icon && // Render the icon in the theme's primary text colour
1095
- // (the icon uses `currentColor`), matching the label.
1096
- /* @__PURE__ */ React12.createElement(Box, { display: "flex", color: "primaryText" }, action.icon),
1097
- horizontalIconGap: "8",
1098
- onClick: action.onSelect
1099
- }
1100
- );
1101
- }
1102
- const account = accounts.find((item) => item.value === option.value);
1103
- return /* @__PURE__ */ React12.createElement(
1104
- BaseDropdownItem_default,
1105
- {
1106
- id: option.value,
1107
- label: option.label,
1108
- description: account?.description,
1109
- isSelected,
1110
- onClick: onSelect
1111
- }
1112
- );
1113
- }
1114
- }
1115
- );
1116
- }
1117
-
1118
- // src/clients/polymarket/PolymarketDepositAccountDropdown.tsx
1119
- var ACCOUNT_DROPDOWN_OPTIONS_WIDTH = 264;
1120
- var BALANCE_PLACEHOLDER = "\u2014";
1121
- function formatBalance(balanceUsd) {
1122
- return balanceUsd === void 0 ? BALANCE_PLACEHOLDER : formatUsdFlooredToCent(balanceUsd);
1123
- }
1124
- function PolymarketDepositAccountDropdown({
1125
- onStepChange,
1126
- modalState,
1127
- dynamicRoutingId,
1128
- applyDynamicTargetAssetCandidate,
1129
- predictions,
1130
- perps
1131
- }) {
1132
- const { t } = useFunkitTranslation();
1133
- const balances = usePolymarketAccountBalances({ predictions, perps });
1134
- const selectedRoutingId = dynamicRoutingId === POLYMARKET_PERPS_ROUTING_ID ? POLYMARKET_PERPS_ROUTING_ID : POLYMARKET_PREDICTIONS_ROUTING_ID;
1135
- const accountCandidate = (routingId, recipient) => ({
1136
- tokenAddress: POLYGON_USDCE,
1137
- tokenChainId: polygon.id.toString(),
1138
- tokenSymbol: PUSD_TOKEN.symbol,
1139
- iconSrc: PUSD_TOKEN.iconSrc,
1140
- dynamicRoutingId: routingId,
1141
- customRecipient: recipient
1142
- });
1143
- const handleSelectAccount = (routingId) => {
1144
- const isPerps = routingId === POLYMARKET_PERPS_ROUTING_ID;
1145
- applyDynamicTargetAssetCandidate?.(
1146
- accountCandidate(
1147
- isPerps ? POLYMARKET_PERPS_ROUTING_ID : POLYMARKET_PREDICTIONS_ROUTING_ID,
1148
- // Checksum so the recipient agrees with createPolymarketDepositConfig's
1149
- // initial customRecipient (integrator addresses aren't guaranteed EIP-55).
1150
- isPerps ? getAddress(perps.address) : getAddress(predictions.address)
1151
- )
1152
- );
1153
- };
1154
- return /* @__PURE__ */ React13.createElement(
1155
- AccountSelectDropdown,
1156
- {
1157
- prefixLabel: t("perpsTransfer.depositTo"),
1158
- dropdownWidth: ACCOUNT_DROPDOWN_OPTIONS_WIDTH,
1159
- accounts: [
1160
- {
1161
- value: POLYMARKET_PREDICTIONS_ROUTING_ID,
1162
- label: t("perpsTransfer.predictions"),
1163
- description: formatBalance(balances.predictions.balanceUsd)
1164
- },
1165
- {
1166
- value: POLYMARKET_PERPS_ROUTING_ID,
1167
- label: t("perpsTransfer.perps"),
1168
- description: formatBalance(balances.perps.balanceUsd)
1169
- }
1170
- ],
1171
- selectedValue: selectedRoutingId,
1172
- onSelect: handleSelectAccount,
1173
- action: {
1174
- id: "transfer-between-accounts",
1175
- label: t("perpsTransfer.transferBetweenAccounts"),
1176
- icon: /* @__PURE__ */ React13.createElement(SwitchIcon, null),
1177
- // Navigation is absent on the loading skeleton; the action only fires
1178
- // on the interactive screen. The transfer step reads balances from the
1179
- // same shared cache, so none need to be threaded through here.
1180
- onSelect: () => {
1181
- if (onStepChange && modalState) {
1182
- onStepChange({
1183
- ...modalState,
1184
- step: "perps_transfer" /* PERPS_TRANSFER */
1185
- });
1186
- }
1187
- }
1188
- }
1189
- }
1190
- );
1191
- }
1192
-
1193
- export {
1194
- PolymarketDepositAccountDropdown
1195
- };