@agg-market/ui 10.0.0 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +1 -0
  2. package/dist/chunk-AKR2ZSBQ.mjs +1645 -0
  3. package/dist/{chunk-55YYUTBK.mjs → chunk-TA74OXPL.mjs} +206 -118
  4. package/dist/{chunk-5G4T5R2H.mjs → chunk-VMJGQKKU.mjs} +29 -47
  5. package/dist/{chunk-GYOCLZGH.mjs → chunk-VOYSFL6U.mjs} +227 -401
  6. package/dist/{chunk-XP7DREIX.mjs → chunk-XUML4ZJQ.mjs} +1626 -791
  7. package/dist/events.js +1451 -1306
  8. package/dist/events.mjs +2 -2
  9. package/dist/index.js +4293 -3202
  10. package/dist/index.mjs +20 -8
  11. package/dist/modals.js +1045 -872
  12. package/dist/modals.mjs +2 -2
  13. package/dist/pages.js +3488 -2226
  14. package/dist/pages.mjs +4 -4
  15. package/dist/primitives.js +1593 -765
  16. package/dist/primitives.mjs +11 -1
  17. package/dist/styles.css +2 -2
  18. package/dist/tailwind.css +2 -2
  19. package/dist/trading.js +864 -676
  20. package/dist/trading.mjs +2 -2
  21. package/dist/types/events/list/event-list.types.d.mts +1 -1
  22. package/dist/types/events/list/event-list.types.d.ts +1 -1
  23. package/dist/types/events/market-details/index.d.mts +2 -2
  24. package/dist/types/events/market-details/index.d.ts +2 -2
  25. package/dist/types/events/market-details/market-details.types.d.mts +1 -5
  26. package/dist/types/events/market-details/market-details.types.d.ts +1 -5
  27. package/dist/types/pages/home/index.d.mts +1 -1
  28. package/dist/types/pages/home/index.d.ts +1 -1
  29. package/dist/types/pages/user-profile/components/available-balance-card.d.mts +17 -0
  30. package/dist/types/pages/user-profile/components/available-balance-card.d.ts +17 -0
  31. package/dist/types/pages/user-profile/components/balance-display.d.mts +3 -5
  32. package/dist/types/pages/user-profile/components/balance-display.d.ts +3 -5
  33. package/dist/types/pages/user-profile/components/positions-activity.d.mts +11 -1
  34. package/dist/types/pages/user-profile/components/positions-activity.d.ts +11 -1
  35. package/dist/types/pages/user-profile/components/positions-value-card.d.mts +10 -0
  36. package/dist/types/pages/user-profile/components/positions-value-card.d.ts +10 -0
  37. package/dist/types/pages/user-profile/components/user-info-card.d.mts +3 -1
  38. package/dist/types/pages/user-profile/components/user-info-card.d.ts +3 -1
  39. package/dist/types/pages/user-profile/index.d.mts +2 -2
  40. package/dist/types/pages/user-profile/index.d.ts +2 -2
  41. package/dist/types/pages/user-profile/user-profile.constants.d.mts +1 -2
  42. package/dist/types/pages/user-profile/user-profile.constants.d.ts +1 -2
  43. package/dist/types/pages/user-profile/user-profile.types.d.mts +29 -16
  44. package/dist/types/pages/user-profile/user-profile.types.d.ts +29 -16
  45. package/dist/types/primitives/agg-logo/index.d.mts +6 -0
  46. package/dist/types/primitives/agg-logo/index.d.ts +6 -0
  47. package/dist/types/primitives/header/agg-logo.d.mts +2 -0
  48. package/dist/types/primitives/header/agg-logo.d.ts +2 -0
  49. package/dist/types/primitives/header/header.constants.d.mts +3 -0
  50. package/dist/types/primitives/header/header.constants.d.ts +3 -0
  51. package/dist/types/primitives/header/header.types.d.mts +28 -0
  52. package/dist/types/primitives/header/header.types.d.ts +28 -0
  53. package/dist/types/primitives/header/index.d.mts +7 -0
  54. package/dist/types/primitives/header/index.d.ts +7 -0
  55. package/dist/types/primitives/icon/index.d.mts +3 -1
  56. package/dist/types/primitives/icon/index.d.ts +3 -1
  57. package/dist/types/primitives/icon/registry.d.mts +8 -0
  58. package/dist/types/primitives/icon/registry.d.ts +8 -0
  59. package/dist/types/primitives/icon/svg/bnb.d.mts +5 -0
  60. package/dist/types/primitives/icon/svg/bnb.d.ts +5 -0
  61. package/dist/types/primitives/icon/svg/polygon.d.mts +5 -0
  62. package/dist/types/primitives/icon/svg/polygon.d.ts +5 -0
  63. package/dist/types/primitives/index.d.mts +3 -0
  64. package/dist/types/primitives/index.d.ts +3 -0
  65. package/dist/types/primitives/search/index.d.mts +1 -1
  66. package/dist/types/primitives/search/index.d.ts +1 -1
  67. package/dist/types/primitives/search/search.types.d.mts +9 -59
  68. package/dist/types/primitives/search/search.types.d.ts +9 -59
  69. package/dist/types/primitives/search/search.utils.d.mts +4 -0
  70. package/dist/types/primitives/search/search.utils.d.ts +4 -0
  71. package/dist/types/primitives/skeleton/skeleton.types.d.mts +3 -0
  72. package/dist/types/primitives/skeleton/skeleton.types.d.ts +3 -0
  73. package/dist/types/primitives/skeleton/views/search-skeleton-view.d.mts +5 -0
  74. package/dist/types/primitives/skeleton/views/search-skeleton-view.d.ts +5 -0
  75. package/dist/types/primitives/skeleton/views/user-profile-overview-skeleton-view.d.mts +5 -0
  76. package/dist/types/primitives/skeleton/views/user-profile-overview-skeleton-view.d.ts +5 -0
  77. package/dist/types/primitives/skeleton/views/user-profile-positions-activity-skeleton-view.d.mts +5 -0
  78. package/dist/types/primitives/skeleton/views/user-profile-positions-activity-skeleton-view.d.ts +5 -0
  79. package/dist/types/primitives/tooltip/index.d.mts +6 -0
  80. package/dist/types/primitives/tooltip/index.d.ts +6 -0
  81. package/dist/types/primitives/tooltip/tooltip.constants.d.mts +2 -0
  82. package/dist/types/primitives/tooltip/tooltip.constants.d.ts +2 -0
  83. package/dist/types/primitives/tooltip/tooltip.types.d.mts +27 -0
  84. package/dist/types/primitives/tooltip/tooltip.types.d.ts +27 -0
  85. package/dist/types/profile/tabs/about-tab.d.mts +1 -1
  86. package/dist/types/profile/tabs/about-tab.d.ts +1 -1
  87. package/dist/types/profile/tabs/accounts-wallets-tab.d.mts +1 -1
  88. package/dist/types/profile/tabs/accounts-wallets-tab.d.ts +1 -1
  89. package/dist/types/trading/types.d.mts +2 -2
  90. package/dist/types/trading/types.d.ts +2 -2
  91. package/package.json +4 -3
  92. package/dist/chunk-RYQSVETG.mjs +0 -1246
@@ -0,0 +1,1645 @@
1
+ import {
2
+ EventList,
3
+ EventListItem,
4
+ EventListItemDetails,
5
+ MarketDetails,
6
+ MarketDetailsList,
7
+ getDefaultEventListTabs,
8
+ isErrorWithStatus,
9
+ resolveTabVenus
10
+ } from "./chunk-VOYSFL6U.mjs";
11
+ import {
12
+ PlaceOrder,
13
+ Settlement
14
+ } from "./chunk-VMJGQKKU.mjs";
15
+ import {
16
+ Button,
17
+ Card,
18
+ Header,
19
+ Icon,
20
+ Modal,
21
+ RemoteImage,
22
+ SearchEmptyIcon,
23
+ Skeleton,
24
+ StateMessage,
25
+ Tabs,
26
+ Tooltip,
27
+ Typography,
28
+ VenueLogo,
29
+ __spreadProps,
30
+ __spreadValues,
31
+ cn,
32
+ skeletonViews,
33
+ venueLogoLabels,
34
+ venueLogoUrlRegistry
35
+ } from "./chunk-XUML4ZJQ.mjs";
36
+
37
+ // src/pages/home/index.tsx
38
+ import { useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState2 } from "react";
39
+ import { useCategories, useLabels as useLabels2, useSdkUiConfig, useVenueEvents } from "@agg-market/hooks";
40
+
41
+ // src/pages/event-market/index.tsx
42
+ import { useMemo, useState } from "react";
43
+ import { useVenueEvent, useLabels } from "@agg-market/hooks";
44
+ import dayjs from "dayjs";
45
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
46
+ var resolveHeroMarketId = (event, heroMarketId) => {
47
+ var _a, _b;
48
+ if (!((_a = event == null ? void 0 : event.venueMarkets) == null ? void 0 : _a.length)) return void 0;
49
+ if (heroMarketId) {
50
+ const matchingHeroMarket = event.venueMarkets.find(
51
+ (market) => market.id === heroMarketId
52
+ );
53
+ if (matchingHeroMarket) return matchingHeroMarket.id;
54
+ }
55
+ return (_b = event.venueMarkets[0]) == null ? void 0 : _b.id;
56
+ };
57
+ var buildHeroEvent = (event, heroMarketId) => {
58
+ if (!heroMarketId) return void 0;
59
+ const heroMarket = event.venueMarkets.find((market) => market.id === heroMarketId);
60
+ if (!heroMarket) return void 0;
61
+ return __spreadProps(__spreadValues({}, event), {
62
+ venueMarkets: [heroMarket]
63
+ });
64
+ };
65
+ var EventMarketPageMobileTrade = ({
66
+ placeOrder,
67
+ classNames
68
+ }) => {
69
+ const [isOpen, setIsOpen] = useState(false);
70
+ const handleOpen = () => {
71
+ setIsOpen(true);
72
+ };
73
+ const handleOpenChange = (nextOpen) => {
74
+ setIsOpen(nextOpen);
75
+ };
76
+ const handleClose = () => {
77
+ setIsOpen(false);
78
+ };
79
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
80
+ /* @__PURE__ */ jsx(
81
+ "div",
82
+ {
83
+ className: cn(
84
+ "fixed inset-x-0 bottom-0 z-20 flex justify-end p-4 lg:hidden",
85
+ classNames == null ? void 0 : classNames.mobileTradeCta
86
+ ),
87
+ children: /* @__PURE__ */ jsx(
88
+ Button,
89
+ {
90
+ size: "large",
91
+ className: "min-w-[168px] shadow-agg-modal",
92
+ "aria-label": placeOrder.actionLabel,
93
+ "data-testid": "event-market-page-mobile-trade-cta",
94
+ onClick: (e) => {
95
+ e.stopPropagation();
96
+ e.preventDefault();
97
+ handleOpen();
98
+ },
99
+ children: placeOrder.actionLabel
100
+ }
101
+ )
102
+ }
103
+ ),
104
+ /* @__PURE__ */ jsx(Modal, { open: isOpen, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsx(
105
+ Modal.Container,
106
+ {
107
+ "aria-label": placeOrder.title,
108
+ maxWidth: "420px",
109
+ classNames: {
110
+ content: "items-end p-0 sm:items-center sm:p-4",
111
+ container: cn(
112
+ "w-full max-w-[420px] border-0 bg-transparent shadow-none",
113
+ classNames == null ? void 0 : classNames.mobileTradeModal
114
+ )
115
+ },
116
+ children: /* @__PURE__ */ jsx(
117
+ PlaceOrder,
118
+ __spreadProps(__spreadValues({}, placeOrder), {
119
+ isDismissible: true,
120
+ className: cn("w-full rounded-t-agg-2xl sm:rounded-agg-xl", classNames == null ? void 0 : classNames.mobileTrade),
121
+ onClose: handleClose
122
+ })
123
+ )
124
+ }
125
+ ) })
126
+ ] });
127
+ };
128
+ var EventMarketPageUnavailableState = ({
129
+ ariaLabel
130
+ }) => {
131
+ const labels = useLabels();
132
+ return /* @__PURE__ */ jsx(
133
+ Card,
134
+ {
135
+ className: "rounded-agg-xl border border-agg-separator bg-agg-secondary p-6 shadow-none hover:shadow-none",
136
+ role: "status",
137
+ "aria-label": ariaLabel != null ? ariaLabel : labels.eventMarketPage.unavailableAria,
138
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
139
+ /* @__PURE__ */ jsx(Typography, { variant: "body-large-strong", children: labels.eventMarketPage.unavailableTitle }),
140
+ /* @__PURE__ */ jsx(Typography, { variant: "label", className: "text-agg-muted-foreground", children: labels.eventMarketPage.unavailableDescription })
141
+ ] })
142
+ }
143
+ );
144
+ };
145
+ var EventMarketPageNotFoundState = ({
146
+ ariaLabel
147
+ }) => {
148
+ const labels = useLabels();
149
+ return /* @__PURE__ */ jsx(Card, { className: "overflow-hidden rounded-agg-xl border border-agg-separator bg-agg-secondary p-0 shadow-none hover:shadow-none", children: /* @__PURE__ */ jsx(
150
+ StateMessage,
151
+ {
152
+ ariaLabel: ariaLabel != null ? ariaLabel : labels.eventItemDetails.notFoundAria,
153
+ title: labels.eventItemDetails.notFoundTitle,
154
+ description: labels.eventItemDetails.notFoundDescription,
155
+ className: "min-h-[320px] md:min-h-[360px]"
156
+ }
157
+ ) });
158
+ };
159
+ var EventMarketPageLoadingState = ({
160
+ placeOrder,
161
+ settlement,
162
+ classNames
163
+ }) => {
164
+ const labels = useLabels();
165
+ const fallbackSettlement = settlement != null ? settlement : {
166
+ sectionLabel: labels.trading.settlementSection,
167
+ question: labels.eventMarketPage.loadingSettlementQuestion,
168
+ differencesTitle: labels.eventMarketPage.loadingSettlementDifferencesTitle,
169
+ differences: [labels.eventMarketPage.loadingSettlementPlaceholder],
170
+ venues: [
171
+ {
172
+ venue: "polymarket",
173
+ description: labels.eventMarketPage.loadingSettlementPlaceholder
174
+ }
175
+ ]
176
+ };
177
+ return /* @__PURE__ */ jsxs("section", { className: cn("w-full pb-24 lg:pb-0", classNames == null ? void 0 : classNames.root), children: [
178
+ /* @__PURE__ */ jsxs(
179
+ "div",
180
+ {
181
+ className: cn(
182
+ "mx-auto flex w-full max-w-[1200px] flex-col gap-6 px-3 py-3 md:px-6 md:py-6 lg:flex-row lg:items-start lg:gap-8",
183
+ classNames == null ? void 0 : classNames.content
184
+ ),
185
+ children: [
186
+ /* @__PURE__ */ jsxs("div", { className: cn("flex min-w-0 flex-1 flex-col gap-6", classNames == null ? void 0 : classNames.main), children: [
187
+ /* @__PURE__ */ jsx(
188
+ EventListItemDetails,
189
+ {
190
+ isLoading: true,
191
+ classNames: {
192
+ root: classNames == null ? void 0 : classNames.hero
193
+ }
194
+ }
195
+ ),
196
+ /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-3", classNames == null ? void 0 : classNames.markets), children: [
197
+ /* @__PURE__ */ jsx(MarketDetails, { isLoading: true, isOpened: true, classNames: { root: "w-full" } }),
198
+ /* @__PURE__ */ jsx(MarketDetails, { isLoading: true, isOpened: false, classNames: { root: "w-full" } }),
199
+ /* @__PURE__ */ jsx(MarketDetails, { isLoading: true, isOpened: false, classNames: { root: "w-full" } })
200
+ ] }),
201
+ /* @__PURE__ */ jsx("div", { className: "md:hidden", children: /* @__PURE__ */ jsx(Settlement, __spreadProps(__spreadValues({}, fallbackSettlement), { isLoading: true, className: classNames == null ? void 0 : classNames.settlement })) }),
202
+ /* @__PURE__ */ jsx("div", { className: "hidden md:block", children: /* @__PURE__ */ jsx(Settlement, __spreadProps(__spreadValues({}, fallbackSettlement), { isLoading: true, className: classNames == null ? void 0 : classNames.settlement })) })
203
+ ] }),
204
+ placeOrder ? /* @__PURE__ */ jsx(
205
+ "aside",
206
+ {
207
+ className: cn(
208
+ "hidden w-full shrink-0 lg:sticky lg:top-6 lg:block lg:w-[343px]",
209
+ classNames == null ? void 0 : classNames.sidebar
210
+ ),
211
+ children: /* @__PURE__ */ jsx(PlaceOrder, __spreadProps(__spreadValues({}, placeOrder), { isLoading: true, className: classNames == null ? void 0 : classNames.trade }))
212
+ }
213
+ ) : null
214
+ ]
215
+ }
216
+ ),
217
+ placeOrder ? /* @__PURE__ */ jsx(
218
+ "div",
219
+ {
220
+ className: cn(
221
+ "fixed inset-x-0 bottom-0 z-20 flex justify-end p-4 lg:hidden",
222
+ classNames == null ? void 0 : classNames.mobileTradeCta
223
+ ),
224
+ children: /* @__PURE__ */ jsx(
225
+ Button,
226
+ {
227
+ size: "large",
228
+ className: "min-w-[168px] shadow-agg-modal",
229
+ "aria-label": placeOrder.actionLabel,
230
+ disabled: true,
231
+ children: placeOrder.actionLabel
232
+ }
233
+ )
234
+ }
235
+ ) : null
236
+ ] });
237
+ };
238
+ var EventMarketPageContent = ({
239
+ event,
240
+ heroMarketId,
241
+ defaultExpandedMarketId,
242
+ expandedMarketId,
243
+ heroDefaultTimeRange,
244
+ placeOrder,
245
+ settlement,
246
+ classNames,
247
+ ariaLabel
248
+ }) => {
249
+ const resolvedHeroMarketId = useMemo(() => {
250
+ return resolveHeroMarketId(event, heroMarketId);
251
+ }, [event, heroMarketId]);
252
+ const heroEvent = useMemo(() => {
253
+ return buildHeroEvent(event, resolvedHeroMarketId);
254
+ }, [event, resolvedHeroMarketId]);
255
+ if (!heroEvent || !event.venueMarkets.length) {
256
+ return /* @__PURE__ */ jsx(EventMarketPageUnavailableState, { ariaLabel });
257
+ }
258
+ return /* @__PURE__ */ jsxs(
259
+ "section",
260
+ {
261
+ className: cn("w-full pb-24 lg:pb-0", classNames == null ? void 0 : classNames.root),
262
+ "aria-label": ariaLabel != null ? ariaLabel : event.title,
263
+ children: [
264
+ /* @__PURE__ */ jsxs(
265
+ "div",
266
+ {
267
+ className: cn(
268
+ "mx-auto flex w-full max-w-[1200px] flex-row gap-6 px-3 py-3 md:px-6 md:py-6 lg:flex-row lg:items-start lg:gap-8",
269
+ classNames == null ? void 0 : classNames.content
270
+ ),
271
+ children: [
272
+ /* @__PURE__ */ jsxs("div", { className: cn("flex min-w-0 flex-1 flex-col gap-6", classNames == null ? void 0 : classNames.main), children: [
273
+ /* @__PURE__ */ jsx(
274
+ EventListItemDetails,
275
+ {
276
+ event: heroEvent,
277
+ defaultTimeRange: heroDefaultTimeRange,
278
+ classNames: {
279
+ root: classNames == null ? void 0 : classNames.hero
280
+ }
281
+ }
282
+ ),
283
+ /* @__PURE__ */ jsx(MarketDetailsList, { eventId: event.id }),
284
+ settlement ? /* @__PURE__ */ jsx("div", { className: "md:hidden", children: /* @__PURE__ */ jsx(Settlement, __spreadProps(__spreadValues({}, settlement), { className: classNames == null ? void 0 : classNames.settlement })) }) : null,
285
+ settlement ? /* @__PURE__ */ jsx("div", { className: "hidden md:block", children: /* @__PURE__ */ jsx(Settlement, __spreadProps(__spreadValues({}, settlement), { className: classNames == null ? void 0 : classNames.settlement })) }) : null
286
+ ] }),
287
+ placeOrder ? /* @__PURE__ */ jsx(
288
+ "aside",
289
+ {
290
+ className: cn("hidden w-full lg:block lg:max-w-[360px]", classNames == null ? void 0 : classNames.sidebar),
291
+ "data-testid": "event-market-page-desktop-trade",
292
+ children: /* @__PURE__ */ jsx(PlaceOrder, __spreadProps(__spreadValues({}, placeOrder), { className: classNames == null ? void 0 : classNames.trade }))
293
+ }
294
+ ) : null
295
+ ]
296
+ }
297
+ ),
298
+ placeOrder ? /* @__PURE__ */ jsx(EventMarketPageMobileTrade, { placeOrder, classNames }) : null
299
+ ]
300
+ }
301
+ );
302
+ };
303
+ var EventMarketPage = (props) => {
304
+ var _a;
305
+ const hasEventProp = "event" in props && !!props.event;
306
+ const {
307
+ event: fetchedEvent,
308
+ error: eventError,
309
+ isLoading: isFetchingEvent
310
+ } = useVenueEvent({
311
+ eventId: hasEventProp ? "" : (_a = props.eventId) != null ? _a : "",
312
+ enabled: !props.isLoading && !hasEventProp && !!props.eventId
313
+ });
314
+ if (props.isLoading) {
315
+ return /* @__PURE__ */ jsx(EventMarketPageLoadingState, { placeOrder: props.placeOrder, settlement: props.settlement });
316
+ }
317
+ if ("event" in props && props.event) {
318
+ return /* @__PURE__ */ jsx(EventMarketPageContent, __spreadProps(__spreadValues({}, props), { event: props.event }));
319
+ }
320
+ if (isFetchingEvent) {
321
+ return /* @__PURE__ */ jsx(
322
+ EventMarketPageLoadingState,
323
+ {
324
+ placeOrder: props.placeOrder,
325
+ settlement: props.settlement,
326
+ classNames: props.classNames
327
+ }
328
+ );
329
+ }
330
+ if (!fetchedEvent) {
331
+ if (isErrorWithStatus(eventError, 404)) {
332
+ return /* @__PURE__ */ jsx(EventMarketPageNotFoundState, { ariaLabel: props.ariaLabel });
333
+ }
334
+ return /* @__PURE__ */ jsx(EventMarketPageUnavailableState, { ariaLabel: props.ariaLabel });
335
+ }
336
+ return /* @__PURE__ */ jsx(EventMarketPageContent, __spreadProps(__spreadValues({}, props), { event: fetchedEvent }));
337
+ };
338
+ EventMarketPage.displayName = "EventMarketPage";
339
+
340
+ // src/pages/home/home.constants.ts
341
+ var ALL_CATEGORIES_TAB_VALUE = "trending";
342
+ var DEFAULT_CATEGORIES_LIMIT = 100;
343
+ var DEFAULT_ALL_CATEGORY_TAB_LABEL = "Trending";
344
+ var getDefaultEventSectionItems = (labels) => {
345
+ return [
346
+ {
347
+ id: "top-markets",
348
+ title: labels.home.topMarkets,
349
+ maxItemsPerRow: 3,
350
+ limit: 9,
351
+ maxVisibleItems: 9
352
+ }
353
+ ];
354
+ };
355
+
356
+ // src/pages/home/home.utils.ts
357
+ var resolveCategoryTabs = (categories, allCategoryTabLabel) => {
358
+ const seenCategoryIds = /* @__PURE__ */ new Set();
359
+ const tabs = [
360
+ {
361
+ value: ALL_CATEGORIES_TAB_VALUE,
362
+ label: allCategoryTabLabel,
363
+ iconName: "arrow-trend-up"
364
+ }
365
+ ];
366
+ for (const category of categories) {
367
+ if (seenCategoryIds.has(category.id)) continue;
368
+ seenCategoryIds.add(category.id);
369
+ tabs.push({
370
+ value: category.id,
371
+ label: category.name.trim().toLowerCase(),
372
+ categoryIds: [category.id]
373
+ });
374
+ }
375
+ return tabs;
376
+ };
377
+ var resolveInitialTabValue = (tabs, defaultActiveTab) => {
378
+ var _a, _b;
379
+ if (defaultActiveTab) {
380
+ const hasDefaultTab = tabs.some((tab) => tab.value === defaultActiveTab);
381
+ if (hasDefaultTab) return defaultActiveTab;
382
+ }
383
+ return (_b = (_a = tabs[0]) == null ? void 0 : _a.value) != null ? _b : ALL_CATEGORIES_TAB_VALUE;
384
+ };
385
+
386
+ // src/pages/home/index.tsx
387
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
388
+ var MIN_SEARCH_LENGTH = 3;
389
+ var SEARCH_DEBOUNCE_MS = 300;
390
+ var SEARCH_RESULTS_LIMIT = 9;
391
+ var HomeSearchResults = ({
392
+ activeTabValue,
393
+ query,
394
+ resolvedTabs,
395
+ className
396
+ }) => {
397
+ const labels = useLabels2();
398
+ const { search: searchConfig } = useSdkUiConfig();
399
+ const [activeVenueTabValue, setActiveVenueTabValue] = useState2("matched");
400
+ const eventListTabs = useMemo2(() => {
401
+ return getDefaultEventListTabs(labels);
402
+ }, [labels]);
403
+ const activeVenueTab = useMemo2(() => {
404
+ return eventListTabs.find((tab) => tab.value === activeVenueTabValue);
405
+ }, [activeVenueTabValue, eventListTabs]);
406
+ const activeCategoryTab = useMemo2(() => {
407
+ return resolvedTabs.find((tab) => tab.value === activeTabValue);
408
+ }, [activeTabValue, resolvedTabs]);
409
+ const { events, isLoading, isError, fetchNextPage, hasNextPage, isFetchingNextPage } = useVenueEvents({
410
+ queryKeyScope: "home-search-results",
411
+ search: query,
412
+ categoryIds: activeTabValue === ALL_CATEGORIES_TAB_VALUE ? void 0 : activeCategoryTab == null ? void 0 : activeCategoryTab.categoryIds,
413
+ venues: resolveTabVenus(activeVenueTab),
414
+ limit: SEARCH_RESULTS_LIMIT
415
+ });
416
+ const loadMoreRef = useRef(null);
417
+ useEffect2(() => {
418
+ if (!hasNextPage) return;
419
+ const target = loadMoreRef.current;
420
+ if (!target) return;
421
+ const observer = new IntersectionObserver(
422
+ (entries) => {
423
+ const entry = entries[0];
424
+ if (!(entry == null ? void 0 : entry.isIntersecting)) return;
425
+ if (isLoading || isFetchingNextPage || !hasNextPage) return;
426
+ void fetchNextPage();
427
+ },
428
+ {
429
+ rootMargin: "320px 0px"
430
+ }
431
+ );
432
+ observer.observe(target);
433
+ return () => {
434
+ observer.disconnect();
435
+ };
436
+ }, [fetchNextPage, hasNextPage, isFetchingNextPage, isLoading]);
437
+ const resultsTitle = labels.search.resultsSummary(
438
+ hasNextPage ? `${events.length}+` : `${events.length}`,
439
+ query
440
+ );
441
+ const searchResultTabs = useMemo2(() => {
442
+ return eventListTabs.map((tab) => {
443
+ const isActive = tab.value === activeVenueTabValue;
444
+ return {
445
+ value: tab.value,
446
+ label: tab.label,
447
+ icon: tab.iconName ? /* @__PURE__ */ jsx2(
448
+ Icon,
449
+ {
450
+ name: tab.iconName,
451
+ size: "small",
452
+ color: isActive ? "var(--agg-color-primary)" : "var(--agg-color-foreground)"
453
+ }
454
+ ) : tab.venueLogo ? /* @__PURE__ */ jsx2(
455
+ VenueLogo,
456
+ {
457
+ venue: tab.venueLogo,
458
+ size: "small",
459
+ className: cn(isActive ? "text-agg-primary" : "text-agg-foreground")
460
+ }
461
+ ) : void 0,
462
+ disabled: tab.disabled
463
+ };
464
+ });
465
+ }, [activeVenueTabValue, eventListTabs]);
466
+ const loadingPlaceholderCount = isFetchingNextPage ? 3 : 0;
467
+ if (isLoading) {
468
+ return /* @__PURE__ */ jsx2(Skeleton, { view: "event-list", ariaLabel: labels.search.loadingResults, className });
469
+ }
470
+ return /* @__PURE__ */ jsxs2("section", { className: cn("flex w-full flex-col gap-5", className), children: [
471
+ /* @__PURE__ */ jsx2("header", { className: "flex flex-col gap-5", children: /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between", children: [
472
+ /* @__PURE__ */ jsx2(Typography, { as: "h2", variant: "title", className: "min-w-0", children: resultsTitle }),
473
+ /* @__PURE__ */ jsx2(
474
+ Tabs,
475
+ {
476
+ ariaLabel: labels.eventList.tabsAria(resultsTitle),
477
+ items: searchResultTabs,
478
+ value: activeVenueTabValue,
479
+ onChange: setActiveVenueTabValue
480
+ }
481
+ )
482
+ ] }) }),
483
+ /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-1 gap-5 md:grid-cols-3", children: [
484
+ events.map((event) => /* @__PURE__ */ jsx2(
485
+ EventListItem,
486
+ {
487
+ event,
488
+ classNames: {
489
+ root: "w-full min-w-0 max-w-none"
490
+ },
491
+ onClick: (selectedEvent) => {
492
+ if (!selectedEvent) return;
493
+ searchConfig.onSelect(selectedEvent);
494
+ }
495
+ },
496
+ event.id
497
+ )),
498
+ Array.from({ length: loadingPlaceholderCount }).map((_, index) => /* @__PURE__ */ jsx2(
499
+ EventListItem,
500
+ {
501
+ isLoading: true,
502
+ classNames: {
503
+ root: "w-full min-w-0 max-w-none"
504
+ }
505
+ },
506
+ `search-results-loading-${index}`
507
+ )),
508
+ !isError && events.length === 0 ? /* @__PURE__ */ jsx2(Card, { className: "col-span-full overflow-hidden shadow-none hover:shadow-none p-0! border-none! bg-transparent!", children: /* @__PURE__ */ jsx2(
509
+ StateMessage,
510
+ {
511
+ ariaLabel: labels.eventList.emptyAria,
512
+ title: labels.eventList.emptyTitle,
513
+ description: labels.eventList.emptyDescription
514
+ }
515
+ ) }) : null,
516
+ isError ? /* @__PURE__ */ jsx2(
517
+ Typography,
518
+ {
519
+ variant: "body",
520
+ className: "col-span-full flex h-32 w-full items-center justify-center",
521
+ children: labels.eventList.error
522
+ }
523
+ ) : null
524
+ ] }),
525
+ hasNextPage ? /* @__PURE__ */ jsx2("div", { ref: loadMoreRef, className: "h-px w-full", "aria-hidden": true }) : null
526
+ ] });
527
+ };
528
+ var HomePage = ({
529
+ tabs,
530
+ defaultActiveTab,
531
+ onTabChange: _onTabChange,
532
+ eventSectionItems,
533
+ classNames,
534
+ categoriesLimit = DEFAULT_CATEGORIES_LIMIT,
535
+ allCategoryTabLabel = DEFAULT_ALL_CATEGORY_TAB_LABEL
536
+ }) => {
537
+ const labels = useLabels2();
538
+ const {
539
+ search: {
540
+ value: searchValue,
541
+ result: selectedEvent,
542
+ isShowingAllResults,
543
+ onSelect: onSelectEvent
544
+ }
545
+ } = useSdkUiConfig();
546
+ const hasCustomTabs = !!tabs && tabs.length > 0;
547
+ const normalizedSearchValue = searchValue.trim();
548
+ const [debouncedSearchValue, setDebouncedSearchValue] = useState2(() => {
549
+ return normalizedSearchValue.length >= MIN_SEARCH_LENGTH ? normalizedSearchValue : "";
550
+ });
551
+ useEffect2(() => {
552
+ if (normalizedSearchValue.length < MIN_SEARCH_LENGTH) {
553
+ setDebouncedSearchValue("");
554
+ return;
555
+ }
556
+ const timeoutId = window.setTimeout(() => {
557
+ setDebouncedSearchValue(normalizedSearchValue);
558
+ }, SEARCH_DEBOUNCE_MS);
559
+ return () => {
560
+ window.clearTimeout(timeoutId);
561
+ };
562
+ }, [normalizedSearchValue]);
563
+ const resolvedAllCategoryTabLabel = allCategoryTabLabel === DEFAULT_ALL_CATEGORY_TAB_LABEL ? labels.home.trending : allCategoryTabLabel;
564
+ const { categories } = useCategories({
565
+ limit: categoriesLimit,
566
+ enabled: !hasCustomTabs
567
+ });
568
+ const categoryTabs = useMemo2(() => {
569
+ return resolveCategoryTabs(categories, resolvedAllCategoryTabLabel);
570
+ }, [categories, resolvedAllCategoryTabLabel]);
571
+ const resolvedTabs = useMemo2(() => {
572
+ if (hasCustomTabs && tabs) return tabs;
573
+ return categoryTabs;
574
+ }, [categoryTabs, hasCustomTabs, tabs]);
575
+ const resolvedEventSectionItems = eventSectionItems && eventSectionItems.length > 0 ? eventSectionItems : getDefaultEventSectionItems(labels);
576
+ const [activeTabValue, setActiveTabValue] = useState2(() => {
577
+ return resolveInitialTabValue(resolvedTabs, defaultActiveTab);
578
+ });
579
+ useEffect2(() => {
580
+ setActiveTabValue((currentValue) => {
581
+ const hasCurrentValue = resolvedTabs.some((tab) => tab.value === currentValue);
582
+ if (hasCurrentValue) return currentValue;
583
+ return resolveInitialTabValue(resolvedTabs, defaultActiveTab);
584
+ });
585
+ }, [defaultActiveTab, resolvedTabs]);
586
+ const tabsItems = useMemo2(() => {
587
+ return resolvedTabs.map((tab) => {
588
+ const isActive = tab.value === activeTabValue;
589
+ return {
590
+ value: tab.value,
591
+ label: tab.label,
592
+ icon: tab.iconName ? /* @__PURE__ */ jsx2(
593
+ Icon,
594
+ {
595
+ name: tab.iconName,
596
+ size: "medium",
597
+ color: isActive ? "var(--agg-color-primary)" : "var(--agg-color-foreground)"
598
+ }
599
+ ) : void 0,
600
+ disabled: tab.disabled
601
+ };
602
+ });
603
+ }, [activeTabValue, resolvedTabs]);
604
+ const activeTab = useMemo2(() => {
605
+ return resolvedTabs.find((tab) => tab.value === activeTabValue);
606
+ }, [activeTabValue, resolvedTabs]);
607
+ const resolvedSectionItems = useMemo2(() => {
608
+ var _a, _b, _c, _d;
609
+ if (activeTabValue === ALL_CATEGORIES_TAB_VALUE) {
610
+ return resolvedEventSectionItems;
611
+ }
612
+ const maxItemsPerRow = (_b = (_a = resolvedEventSectionItems[0]) == null ? void 0 : _a.maxItemsPerRow) != null ? _b : 3;
613
+ const firstSectionLimit = (_c = resolvedEventSectionItems[0]) == null ? void 0 : _c.limit;
614
+ const limit = firstSectionLimit && Number.isFinite(firstSectionLimit) ? Math.max(9, Math.floor(firstSectionLimit)) : 9;
615
+ return [
616
+ {
617
+ id: `${activeTabValue}-markets`,
618
+ title: (_d = activeTab == null ? void 0 : activeTab.label) != null ? _d : activeTabValue,
619
+ maxItemsPerRow,
620
+ limit,
621
+ maxVisibleItems: void 0,
622
+ search: activeTab == null ? void 0 : activeTab.search,
623
+ categoryIds: activeTab == null ? void 0 : activeTab.categoryIds
624
+ }
625
+ ];
626
+ }, [activeTab, activeTabValue, resolvedEventSectionItems]);
627
+ const handleTabChange = (value) => {
628
+ setActiveTabValue(value);
629
+ _onTabChange == null ? void 0 : _onTabChange(value);
630
+ };
631
+ return /* @__PURE__ */ jsxs2("section", { className: cn("flex w-full flex-col", classNames == null ? void 0 : classNames.root), children: [
632
+ /* @__PURE__ */ jsx2(Header, { searchProps: {} }),
633
+ !selectedEvent && !isShowingAllResults ? /* @__PURE__ */ jsx2(
634
+ "header",
635
+ {
636
+ className: cn(
637
+ "w-full bg-agg-secondary border-b border-agg-separator",
638
+ classNames == null ? void 0 : classNames.header
639
+ ),
640
+ children: /* @__PURE__ */ jsx2(
641
+ Tabs,
642
+ {
643
+ ariaLabel: labels.home.categoryTabsAria,
644
+ variant: "underline",
645
+ className: cn("w-full px-4 md:px-10", classNames == null ? void 0 : classNames.tabs),
646
+ items: tabsItems,
647
+ value: activeTabValue,
648
+ onChange: handleTabChange
649
+ }
650
+ )
651
+ }
652
+ ) : null,
653
+ /* @__PURE__ */ jsx2(
654
+ "main",
655
+ {
656
+ className: cn(
657
+ "flex w-full flex-col gap-4 md:gap-10 px-4 md:px-10 py-4 md:py-8",
658
+ classNames == null ? void 0 : classNames.sections
659
+ ),
660
+ children: selectedEvent ? /* @__PURE__ */ jsx2(EventMarketPage, { eventId: selectedEvent.id }) : isShowingAllResults && debouncedSearchValue ? /* @__PURE__ */ jsx2(
661
+ HomeSearchResults,
662
+ {
663
+ activeTabValue,
664
+ query: debouncedSearchValue,
665
+ resolvedTabs
666
+ }
667
+ ) : resolvedSectionItems.map((eventSectionItem) => {
668
+ var _a, _b;
669
+ return /* @__PURE__ */ jsx2(
670
+ EventList,
671
+ {
672
+ title: eventSectionItem.title,
673
+ maxItemsPerRow: eventSectionItem.maxItemsPerRow,
674
+ limit: eventSectionItem.limit,
675
+ maxVisibleItems: eventSectionItem.maxVisibleItems,
676
+ search: debouncedSearchValue || eventSectionItem.search || (activeTab == null ? void 0 : activeTab.search),
677
+ categoryIds: (_b = eventSectionItem.categoryIds) != null ? _b : activeTab == null ? void 0 : activeTab.categoryIds,
678
+ onClick: (event) => {
679
+ if (!event) return;
680
+ onSelectEvent(event);
681
+ }
682
+ },
683
+ (_a = eventSectionItem.id) != null ? _a : eventSectionItem.title
684
+ );
685
+ })
686
+ }
687
+ )
688
+ ] });
689
+ };
690
+ HomePage.displayName = "HomePage";
691
+
692
+ // src/pages/user-profile/index.tsx
693
+ import { useMemo as useMemo4 } from "react";
694
+ import {
695
+ getWalletAddressFromUserProfile,
696
+ useAggBalance,
697
+ useAggAuthState,
698
+ useExecutionOrders,
699
+ useExecutionPositions
700
+ } from "@agg-market/hooks";
701
+
702
+ // src/pages/user-profile/components/positions-value-card.tsx
703
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
704
+ var PositionsValueCard = ({
705
+ label = "Positions Value",
706
+ valueLabel,
707
+ className
708
+ }) => {
709
+ return /* @__PURE__ */ jsxs3(
710
+ "div",
711
+ {
712
+ className: cn(
713
+ "flex h-full flex-col gap-3 rounded-agg-md border border-agg-separator bg-agg-secondary p-5",
714
+ className
715
+ ),
716
+ children: [
717
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
718
+ /* @__PURE__ */ jsx3(
719
+ "svg",
720
+ {
721
+ xmlns: "http://www.w3.org/2000/svg",
722
+ width: "16",
723
+ height: "16",
724
+ viewBox: "0 0 16 16",
725
+ fill: "none",
726
+ children: /* @__PURE__ */ jsx3(
727
+ "path",
728
+ {
729
+ d: "M16 7.99957C16 8.36757 15.702 8.66623 15.3333 8.66623H13.6893C13.388 8.66623 13.1233 8.86957 13.0453 9.15957L11.9273 13.3209C11.8 13.7376 11.444 13.9996 11.0333 13.9996H11.022C10.6067 13.9949 10.252 13.7229 10.1393 13.3236L7.95667 4.50623L5.838 11.9989C5.71067 12.3969 5.378 12.6496 4.98467 12.6649C4.57667 12.6869 4.23867 12.4549 4.088 12.0902L3.02133 9.10757C2.926 8.84357 2.674 8.66557 2.39333 8.66557H0.666667C0.298 8.66557 0 8.3669 0 7.9989C0 7.6309 0.298 7.33223 0.666667 7.33223H2.394C3.23667 7.33223 3.99267 7.8649 4.27733 8.65823L4.90267 10.4089L7.092 2.66557C7.226 2.2489 7.57667 1.9809 7.99933 1.9989C8.41133 2.00623 8.76333 2.27757 8.876 2.67357L11.0487 11.4509L11.7567 8.81357C11.9907 7.94157 12.7847 7.33223 13.688 7.33223H15.332C15.7007 7.33223 15.9987 7.6309 15.9987 7.9989L16 7.99957Z",
730
+ fill: "#9D9FAF"
731
+ }
732
+ )
733
+ }
734
+ ),
735
+ /* @__PURE__ */ jsx3("span", { className: "font-agg-sans text-agg-base leading-6 font-agg-normal text-agg-muted-foreground", children: label })
736
+ ] }),
737
+ /* @__PURE__ */ jsx3("div", { className: "font-agg-sans text-agg-2xl leading-8 font-agg-bold text-agg-foreground", children: valueLabel }),
738
+ /* @__PURE__ */ jsx3("div", { className: "flex-1" })
739
+ ]
740
+ }
741
+ );
742
+ };
743
+ PositionsValueCard.displayName = "PositionsValueCard";
744
+
745
+ // src/pages/user-profile/components/available-balance-card.tsx
746
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
747
+ var chainIconName = (label) => {
748
+ const key = label.trim().toLowerCase();
749
+ if (key.includes("polygon")) return "polygon";
750
+ if (key.includes("solana")) return "solana";
751
+ if (key.includes("bnb")) return "bnb";
752
+ if (key.includes("base")) return "bnb";
753
+ if (key.includes("arbitrum")) return "bnb";
754
+ if (key.includes("ethereum") || key.includes("eth")) return "ethereum";
755
+ return void 0;
756
+ };
757
+ var AvailableBalanceCard = ({
758
+ label = "Available Balance",
759
+ valueLabel,
760
+ chains,
761
+ className
762
+ }) => {
763
+ return /* @__PURE__ */ jsxs4(
764
+ "div",
765
+ {
766
+ className: cn(
767
+ "flex h-full flex-col gap-3 rounded-agg-md border border-agg-separator bg-agg-secondary p-5",
768
+ className
769
+ ),
770
+ children: [
771
+ /* @__PURE__ */ jsx4("div", { className: "flex items-center justify-between gap-3", children: /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2", children: [
772
+ /* @__PURE__ */ jsx4(
773
+ "svg",
774
+ {
775
+ xmlns: "http://www.w3.org/2000/svg",
776
+ width: "16",
777
+ height: "16",
778
+ viewBox: "0 0 16 16",
779
+ fill: "none",
780
+ "aria-hidden": "true",
781
+ focusable: "false",
782
+ children: /* @__PURE__ */ jsx4(
783
+ "path",
784
+ {
785
+ d: "M14 4.00065H3.33333C2.76067 4.00065 2.21867 3.75265 1.84333 3.33465C2.21 2.92532 2.74267 2.66732 3.33333 2.66732H15.3333C15.702 2.66732 16 2.36865 16 2.00065C16 1.63265 15.702 1.33398 15.3333 1.33398H3.33333C1.49267 1.33398 0 2.82665 0 4.66732V11.334C0 13.1747 1.49267 14.6673 3.33333 14.6673H14C15.1047 14.6673 16 13.772 16 12.6673V6.00065C16 4.89598 15.1047 4.00065 14 4.00065ZM14.6667 12.6673C14.6667 13.0347 14.368 13.334 14 13.334H3.33333C2.23067 13.334 1.33333 12.4367 1.33333 11.334V4.66598C1.90267 5.09198 2.60267 5.33398 3.33333 5.33398H14C14.368 5.33398 14.6667 5.63332 14.6667 6.00065V12.6673ZM13.3333 9.33399C13.3333 9.70199 13.0347 10.0007 12.6667 10.0007C12.2987 10.0007 12 9.70199 12 9.33399C12 8.96599 12.2987 8.66732 12.6667 8.66732C13.0347 8.66732 13.3333 8.96599 13.3333 9.33399Z",
786
+ fill: "#9D9FAF"
787
+ }
788
+ )
789
+ }
790
+ ),
791
+ /* @__PURE__ */ jsx4("span", { className: "font-agg-sans text-agg-base leading-6 font-agg-normal text-agg-muted-foreground", children: label })
792
+ ] }) }),
793
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-3", children: [
794
+ /* @__PURE__ */ jsx4("div", { className: "font-agg-sans text-agg-2xl leading-8 font-agg-bold text-agg-foreground", children: valueLabel }),
795
+ /* @__PURE__ */ jsx4(
796
+ Tooltip,
797
+ {
798
+ "aria-label": "Balances by chain",
799
+ size: "small",
800
+ side: "top",
801
+ classNames: { content: "border-0" },
802
+ content: /* @__PURE__ */ jsxs4("div", { className: "flex min-w-[280px] max-w-[360px] flex-col gap-2 p-3 sm:p-4", children: [
803
+ /* @__PURE__ */ jsx4("div", { className: "font-agg-sans text-agg-sm leading-5 font-agg-bold text-agg-foreground", children: "Balance by network" }),
804
+ /* @__PURE__ */ jsx4("div", { role: "list", className: "divide-y divide-agg-separator/60", children: chains.map((row) => {
805
+ const icon = chainIconName(row.label);
806
+ return /* @__PURE__ */ jsxs4(
807
+ "div",
808
+ {
809
+ role: "listitem",
810
+ className: "grid grid-cols-[1fr_auto] items-center gap-x-4 py-2 first:pt-0 last:pb-0",
811
+ children: [
812
+ /* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 items-center gap-2", children: [
813
+ icon ? /* @__PURE__ */ jsx4(Icon, { name: icon, size: "small", className: "text-agg-foreground" }) : /* @__PURE__ */ jsx4("span", { className: "flex h-5 w-5 items-center justify-center rounded-agg-sm border border-agg-separator text-agg-xs text-agg-muted-foreground", children: row.label.slice(0, 2).toUpperCase() }),
814
+ /* @__PURE__ */ jsx4("span", { className: "truncate font-agg-sans text-agg-sm leading-5 font-agg-normal text-agg-foreground", children: row.label })
815
+ ] }),
816
+ /* @__PURE__ */ jsx4("span", { className: "shrink-0 whitespace-nowrap tabular-nums font-agg-sans text-agg-sm leading-5 font-agg-bold text-agg-foreground", children: row.balance.toLocaleString("en-US", {
817
+ style: "currency",
818
+ currency: "USD",
819
+ minimumFractionDigits: 2,
820
+ maximumFractionDigits: 2
821
+ }) })
822
+ ]
823
+ },
824
+ row.key
825
+ );
826
+ }) }),
827
+ /* @__PURE__ */ jsx4("div", { className: "mt-1 rounded-agg-md bg-agg-secondary-hover p-3 font-agg-sans text-agg-sm leading-5 font-agg-normal text-agg-foreground", children: "Funds are stored across networks. We handle routing automatically, but keeping funds on the right network enables faster trades and lower fees. When depositing, you can choose your preferred network." })
828
+ ] }),
829
+ children: /* @__PURE__ */ jsxs4(
830
+ "div",
831
+ {
832
+ "data-testid": "balances-by-network-trigger",
833
+ className: "flex min-h-[20px] min-w-[20px] items-center gap-1 rounded-[6px] bg-agg-secondary-hover p-1.5",
834
+ children: [
835
+ (chains.slice(0, 4).length > 0 ? chains.slice(0, 4) : [{ key: "placeholder", label: "", balance: 0, accountCount: 0 }]).map((row) => {
836
+ const icon = chainIconName(row.label);
837
+ return icon ? /* @__PURE__ */ jsx4(
838
+ "span",
839
+ {
840
+ className: "relative z-0 flex h-4 w-4 items-center justify-center rounded-[4px] bg-agg-secondary",
841
+ children: /* @__PURE__ */ jsx4(Icon, { name: icon, size: "small", className: "text-agg-foreground" })
842
+ },
843
+ `icon-${row.key}`
844
+ ) : /* @__PURE__ */ jsx4(
845
+ "span",
846
+ {
847
+ className: "relative z-0 flex h-4 w-4 items-center justify-center rounded-[4px] bg-agg-secondary text-[10px] leading-3 text-agg-muted-foreground",
848
+ children: row.label ? row.label.slice(0, 2).toUpperCase() : ""
849
+ },
850
+ `icon-${row.key}`
851
+ );
852
+ }),
853
+ chains.length > 4 ? /* @__PURE__ */ jsxs4("span", { className: "relative z-0 flex h-4 w-4 items-center justify-center rounded-[4px] bg-agg-secondary font-agg-sans text-[10px] leading-3 text-agg-muted-foreground", children: [
854
+ "+",
855
+ chains.length - 4
856
+ ] }) : null
857
+ ]
858
+ }
859
+ )
860
+ }
861
+ )
862
+ ] }),
863
+ /* @__PURE__ */ jsx4("div", { className: "flex-1" })
864
+ ]
865
+ }
866
+ );
867
+ };
868
+ AvailableBalanceCard.displayName = "AvailableBalanceCard";
869
+
870
+ // src/pages/user-profile/components/positions-activity.tsx
871
+ import { useMemo as useMemo3, useState as useState3 } from "react";
872
+
873
+ // src/pages/user-profile/user-profile.constants.ts
874
+ var USER_PROFILE_TAB_POSITIONS = "positions";
875
+ var USER_PROFILE_TAB_ACTIVITY = "activity";
876
+ var USER_PROFILE_POSITION_FILTERS = [
877
+ { value: "active", label: "Active" },
878
+ { value: "closed", label: "Closed" }
879
+ ];
880
+
881
+ // src/pages/user-profile/components/activity-row.tsx
882
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
883
+ var ActivityRow = ({ activity, onClick }) => {
884
+ const handleClick = () => {
885
+ onClick == null ? void 0 : onClick(activity);
886
+ };
887
+ return /* @__PURE__ */ jsxs5(
888
+ "button",
889
+ {
890
+ type: "button",
891
+ className: cn(
892
+ "flex w-full flex-col gap-3 rounded-agg-sm p-0 text-left sm:flex-row sm:items-center sm:gap-6",
893
+ "hover:bg-agg-secondary-hover focus-visible:outline-none focus-visible:bg-agg-secondary-hover",
894
+ "cursor-pointer"
895
+ ),
896
+ onClick: handleClick,
897
+ children: [
898
+ /* @__PURE__ */ jsx5("p", { className: "hidden w-[60px] shrink-0 font-agg-sans text-agg-base leading-agg-6 font-agg-normal text-agg-foreground sm:block", children: activity.type }),
899
+ /* @__PURE__ */ jsxs5("div", { className: "flex min-w-0 w-full flex-1 items-center gap-3 sm:gap-4", children: [
900
+ /* @__PURE__ */ jsx5(VenueLogo, { venue: activity.venue, size: "small", className: "shrink-0" }),
901
+ /* @__PURE__ */ jsxs5("div", { className: "flex min-w-0 flex-1 items-center gap-3 sm:gap-4", children: [
902
+ /* @__PURE__ */ jsx5(
903
+ RemoteImage,
904
+ {
905
+ src: activity.thumbnailSrc,
906
+ alt: "",
907
+ className: "h-[52px] w-[52px] shrink-0 rounded-agg-sm object-cover sm:h-[60px] sm:w-[60px]"
908
+ }
909
+ ),
910
+ /* @__PURE__ */ jsxs5("div", { className: "flex min-w-0 flex-1 flex-col justify-center gap-2", children: [
911
+ /* @__PURE__ */ jsx5("p", { className: "min-w-full overflow-hidden text-ellipsis whitespace-nowrap font-agg-sans text-agg-base leading-agg-6 font-agg-bold text-agg-foreground", children: activity.title }),
912
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3", children: [
913
+ /* @__PURE__ */ jsx5("span", { className: "inline-flex items-center justify-center gap-1.5 rounded-full bg-agg-secondary-hover px-3 py-1.5 sm:px-4", children: /* @__PURE__ */ jsx5("span", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground whitespace-nowrap", children: activity.outcomeLabel }) }),
914
+ /* @__PURE__ */ jsx5("span", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-black whitespace-nowrap", children: activity.sharesLabel })
915
+ ] })
916
+ ] })
917
+ ] })
918
+ ] }),
919
+ /* @__PURE__ */ jsxs5("div", { className: "flex w-full flex-row items-center justify-between gap-1 text-agg-base leading-agg-6 whitespace-nowrap sm:w-[120px] sm:shrink-0 sm:flex-col sm:items-end sm:justify-center", children: [
920
+ /* @__PURE__ */ jsx5("p", { className: "font-agg-sans font-agg-bold text-black", children: activity.amountLabel }),
921
+ /* @__PURE__ */ jsx5("p", { className: "font-agg-sans font-agg-normal text-agg-muted-foreground", children: activity.timeLabel })
922
+ ] })
923
+ ]
924
+ }
925
+ );
926
+ };
927
+ ActivityRow.displayName = "ActivityRow";
928
+
929
+ // src/pages/user-profile/components/empty-state.tsx
930
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
931
+ var EmptyState = ({ title, description, className }) => {
932
+ return /* @__PURE__ */ jsx6(
933
+ "div",
934
+ {
935
+ className: cn("flex flex-col items-center justify-center gap-8 p-10", className),
936
+ role: "status",
937
+ "aria-live": "polite",
938
+ children: /* @__PURE__ */ jsxs6("div", { className: "flex flex-col items-center gap-5", children: [
939
+ /* @__PURE__ */ jsx6(SearchEmptyIcon, { className: "h-10 w-10 text-agg-muted-foreground", "aria-hidden": true }),
940
+ /* @__PURE__ */ jsxs6("div", { className: "flex flex-col items-center gap-1 text-center text-agg-foreground", children: [
941
+ /* @__PURE__ */ jsx6("p", { className: "font-agg-sans text-agg-base leading-agg-6 font-agg-bold", children: title }),
942
+ description ? /* @__PURE__ */ jsx6("p", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal", children: description }) : null
943
+ ] })
944
+ ] })
945
+ }
946
+ );
947
+ };
948
+ EmptyState.displayName = "EmptyState";
949
+
950
+ // src/pages/user-profile/components/position-row.tsx
951
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
952
+ var PositionRow = ({ position, onClick }) => {
953
+ const handleClick = () => {
954
+ onClick == null ? void 0 : onClick(position);
955
+ };
956
+ return /* @__PURE__ */ jsxs7(
957
+ "button",
958
+ {
959
+ type: "button",
960
+ className: cn(
961
+ "flex w-full flex-col gap-3 rounded-agg-sm p-0 text-left sm:flex-row sm:items-center sm:gap-6",
962
+ "hover:bg-agg-secondary-hover focus-visible:outline-none focus-visible:bg-agg-secondary-hover",
963
+ "cursor-pointer"
964
+ ),
965
+ onClick: handleClick,
966
+ children: [
967
+ /* @__PURE__ */ jsxs7("div", { className: "flex min-w-0 w-full flex-1 items-center gap-3 sm:gap-4", children: [
968
+ /* @__PURE__ */ jsx7(VenueLogo, { venue: position.venue, size: "small", className: "shrink-0" }),
969
+ /* @__PURE__ */ jsxs7("div", { className: "flex min-w-0 flex-1 items-center gap-3 sm:gap-4", children: [
970
+ /* @__PURE__ */ jsx7(
971
+ RemoteImage,
972
+ {
973
+ src: position.thumbnailSrc,
974
+ alt: "",
975
+ className: "h-[52px] w-[52px] shrink-0 rounded-agg-sm object-cover sm:h-[60px] sm:w-[60px]"
976
+ }
977
+ ),
978
+ /* @__PURE__ */ jsxs7("div", { className: "flex min-w-0 flex-1 flex-col justify-center gap-2", children: [
979
+ /* @__PURE__ */ jsx7("p", { className: "min-w-full overflow-hidden text-ellipsis whitespace-nowrap font-agg-sans text-agg-base leading-agg-6 font-agg-bold text-agg-foreground", children: position.title }),
980
+ /* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3", children: [
981
+ /* @__PURE__ */ jsx7("span", { className: "inline-flex items-center justify-center gap-1.5 rounded-full bg-agg-secondary-hover px-3 py-1.5 sm:px-4", children: /* @__PURE__ */ jsx7("span", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground whitespace-nowrap", children: position.outcomeLabel }) }),
982
+ /* @__PURE__ */ jsx7("span", { className: "font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-black whitespace-nowrap", children: position.sharesLabel })
983
+ ] })
984
+ ] })
985
+ ] })
986
+ ] }),
987
+ /* @__PURE__ */ jsx7("p", { className: "hidden w-[120px] shrink-0 agg-type-title text-agg-foreground sm:block", children: position.averageLabel }),
988
+ /* @__PURE__ */ jsx7("p", { className: "hidden w-[120px] shrink-0 agg-type-title text-agg-foreground sm:block", children: position.currentLabel }),
989
+ /* @__PURE__ */ jsxs7("div", { className: "flex w-full items-center justify-between gap-3 sm:w-auto sm:justify-start sm:gap-6 sm:shrink-0", children: [
990
+ /* @__PURE__ */ jsxs7("div", { className: "flex flex-col justify-center gap-1 text-agg-base leading-agg-6 whitespace-nowrap sm:w-[140px] sm:items-end", children: [
991
+ /* @__PURE__ */ jsx7("p", { className: "font-agg-sans font-agg-bold text-black", children: position.valueLabel }),
992
+ /* @__PURE__ */ jsx7(
993
+ "p",
994
+ {
995
+ className: cn(
996
+ "font-agg-sans font-agg-normal",
997
+ position.isPnlPositive ? "text-agg-success" : "text-agg-error"
998
+ ),
999
+ children: position.pnlLabel
1000
+ }
1001
+ )
1002
+ ] }),
1003
+ /* @__PURE__ */ jsx7(Icon, { name: "chevron-right", size: "small", className: "shrink-0 text-agg-muted-foreground" })
1004
+ ] })
1005
+ ]
1006
+ }
1007
+ );
1008
+ };
1009
+ PositionRow.displayName = "PositionRow";
1010
+
1011
+ // src/pages/user-profile/components/positions-activity.tsx
1012
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1013
+ var tabItems = [
1014
+ { value: USER_PROFILE_TAB_POSITIONS, label: "Positions" },
1015
+ { value: USER_PROFILE_TAB_ACTIVITY, label: "Activity" }
1016
+ ];
1017
+ var PositionsActivity = ({
1018
+ activePositions = [],
1019
+ closedPositions = [],
1020
+ activities = [],
1021
+ onPositionClick,
1022
+ onActivityClick,
1023
+ isLoadingPositions = false,
1024
+ isLoadingActivities = false,
1025
+ positionsError = false,
1026
+ activitiesError = false,
1027
+ hasMorePositions = false,
1028
+ isLoadingMorePositions = false,
1029
+ onLoadMorePositions,
1030
+ hasMoreActivities = false,
1031
+ isLoadingMoreActivities = false,
1032
+ onLoadMoreActivities,
1033
+ className
1034
+ }) => {
1035
+ const [activeTab, setActiveTab] = useState3(USER_PROFILE_TAB_POSITIONS);
1036
+ const [positionFilter, setPositionFilter] = useState3("active");
1037
+ const [searchValue, setSearchValue] = useState3("");
1038
+ const isPositionsTab = activeTab === USER_PROFILE_TAB_POSITIONS;
1039
+ const filteredPositions = useMemo3(() => {
1040
+ const positions = positionFilter === "active" ? activePositions : closedPositions;
1041
+ if (!searchValue.trim()) return positions;
1042
+ const query = searchValue.toLowerCase();
1043
+ return positions.filter((p) => p.title.toLowerCase().includes(query));
1044
+ }, [activePositions, closedPositions, positionFilter, searchValue]);
1045
+ const filteredActivities = useMemo3(() => {
1046
+ if (!searchValue.trim()) return activities;
1047
+ const query = searchValue.toLowerCase();
1048
+ return activities.filter((a) => a.title.toLowerCase().includes(query));
1049
+ }, [activities, searchValue]);
1050
+ const handleSearchChange = (event) => {
1051
+ setSearchValue(event.target.value);
1052
+ };
1053
+ return /* @__PURE__ */ jsxs8(
1054
+ "div",
1055
+ {
1056
+ className: cn(
1057
+ "flex flex-col items-start overflow-clip rounded-agg-md border border-agg-separator bg-agg-secondary",
1058
+ className
1059
+ ),
1060
+ children: [
1061
+ /* @__PURE__ */ jsx8(
1062
+ Tabs,
1063
+ {
1064
+ items: tabItems,
1065
+ value: activeTab,
1066
+ onChange: setActiveTab,
1067
+ variant: "underline",
1068
+ className: "w-full [&>div]:w-full",
1069
+ classNames: {
1070
+ tabList: "h-11 sm:h-12"
1071
+ }
1072
+ }
1073
+ ),
1074
+ /* @__PURE__ */ jsxs8("div", { className: "flex w-full flex-col gap-4 p-4 sm:gap-6 sm:p-6", children: [
1075
+ /* @__PURE__ */ jsxs8("div", { className: "flex flex-col items-start gap-3 sm:flex-row sm:gap-5", children: [
1076
+ isPositionsTab ? /* @__PURE__ */ jsx8("div", { className: "flex h-11 w-full shrink-0 items-stretch overflow-clip rounded-agg-sm border border-agg-separator sm:h-10 sm:w-[270px]", children: USER_PROFILE_POSITION_FILTERS.map((filter, idx) => {
1077
+ const isActive = filter.value === positionFilter;
1078
+ return /* @__PURE__ */ jsxs8("div", { className: "flex flex-1 items-stretch", children: [
1079
+ idx > 0 ? /* @__PURE__ */ jsx8("div", { className: "w-px bg-agg-separator", "aria-hidden": true }) : null,
1080
+ /* @__PURE__ */ jsx8(
1081
+ "button",
1082
+ {
1083
+ type: "button",
1084
+ onClick: () => setPositionFilter(filter.value),
1085
+ className: cn(
1086
+ "flex flex-1 cursor-pointer items-center justify-center px-3 py-3 font-agg-sans text-agg-sm leading-agg-5 sm:px-4 sm:text-agg-base sm:leading-agg-6",
1087
+ isActive ? "bg-agg-secondary-hover font-agg-bold text-agg-primary" : "bg-agg-secondary font-agg-normal text-agg-foreground hover:bg-agg-secondary-hover"
1088
+ ),
1089
+ children: filter.label
1090
+ }
1091
+ )
1092
+ ] }, filter.value);
1093
+ }) }) : null,
1094
+ /* @__PURE__ */ jsx8("label", { className: "flex w-full min-w-0 flex-1", children: /* @__PURE__ */ jsxs8("div", { className: "flex h-11 w-full items-center gap-3 rounded-agg-sm border border-agg-separator bg-agg-secondary px-3 py-2.5 focus-within:border-2 focus-within:border-agg-primary sm:h-10", children: [
1095
+ /* @__PURE__ */ jsx8(Icon, { name: "search", size: "small", className: "shrink-0 text-agg-muted-foreground" }),
1096
+ /* @__PURE__ */ jsx8(
1097
+ "input",
1098
+ {
1099
+ value: searchValue,
1100
+ onChange: handleSearchChange,
1101
+ placeholder: "Search...",
1102
+ className: cn(
1103
+ "h-6 w-full min-w-0 border-0 bg-transparent p-0",
1104
+ "font-agg-sans text-agg-base leading-agg-6 font-agg-normal text-agg-foreground",
1105
+ "placeholder:text-agg-muted-foreground",
1106
+ "outline-none focus:outline-none"
1107
+ )
1108
+ }
1109
+ )
1110
+ ] }) })
1111
+ ] }),
1112
+ isPositionsTab && filteredPositions.length > 0 ? /* @__PURE__ */ jsxs8("div", { className: "hidden items-center gap-6 px-0 sm:flex", children: [
1113
+ /* @__PURE__ */ jsx8("p", { className: "min-w-0 flex-1 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground", children: "Market" }),
1114
+ /* @__PURE__ */ jsx8("p", { className: "w-[120px] shrink-0 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground", children: "Average" }),
1115
+ /* @__PURE__ */ jsx8("p", { className: "w-[120px] shrink-0 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground", children: "Current" }),
1116
+ /* @__PURE__ */ jsx8("p", { className: "w-[184px] shrink-0 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground text-right", children: "Value" })
1117
+ ] }) : null,
1118
+ !isPositionsTab && filteredActivities.length > 0 ? /* @__PURE__ */ jsxs8("div", { className: "hidden items-center gap-6 px-0 sm:flex", children: [
1119
+ /* @__PURE__ */ jsx8("p", { className: "w-[60px] shrink-0 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground", children: "Type" }),
1120
+ /* @__PURE__ */ jsx8("p", { className: "min-w-0 flex-1 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground", children: "Market" }),
1121
+ /* @__PURE__ */ jsx8("p", { className: "w-[120px] shrink-0 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-muted-foreground text-right", children: "Amount" })
1122
+ ] }) : null,
1123
+ isPositionsTab ? isLoadingPositions && filteredPositions.length === 0 ? /* @__PURE__ */ jsx8(
1124
+ Skeleton,
1125
+ {
1126
+ view: skeletonViews.userProfilePositionsActivity,
1127
+ ariaLabel: "Loading positions"
1128
+ }
1129
+ ) : positionsError && filteredPositions.length === 0 ? /* @__PURE__ */ jsx8(
1130
+ EmptyState,
1131
+ {
1132
+ title: "Unable to load positions",
1133
+ description: "Please try again in a moment."
1134
+ }
1135
+ ) : filteredPositions.length > 0 ? /* @__PURE__ */ jsx8("div", { className: "flex flex-col gap-3 sm:gap-4", children: filteredPositions.map((position) => /* @__PURE__ */ jsx8(PositionRow, { position, onClick: onPositionClick }, position.id)) }) : /* @__PURE__ */ jsx8(
1136
+ EmptyState,
1137
+ {
1138
+ title: "No positions yet",
1139
+ description: "Your open trades will appear here once you place an order."
1140
+ }
1141
+ ) : isLoadingActivities && filteredActivities.length === 0 ? /* @__PURE__ */ jsx8(
1142
+ Skeleton,
1143
+ {
1144
+ view: skeletonViews.userProfilePositionsActivity,
1145
+ ariaLabel: "Loading activity"
1146
+ }
1147
+ ) : activitiesError && filteredActivities.length === 0 ? /* @__PURE__ */ jsx8(EmptyState, { title: "Unable to load activity", description: "Please try again in a moment." }) : filteredActivities.length > 0 ? /* @__PURE__ */ jsx8("div", { className: "flex flex-col gap-3 sm:gap-4", children: filteredActivities.map((activity) => /* @__PURE__ */ jsx8(ActivityRow, { activity, onClick: onActivityClick }, activity.id)) }) : /* @__PURE__ */ jsx8(
1148
+ EmptyState,
1149
+ {
1150
+ title: "No activity yet",
1151
+ description: "Your trading activity will appear here."
1152
+ }
1153
+ ),
1154
+ isPositionsTab ? hasMorePositions ? /* @__PURE__ */ jsx8("div", { className: "flex w-full justify-center pt-1", children: /* @__PURE__ */ jsx8(
1155
+ Button,
1156
+ {
1157
+ variant: "secondary",
1158
+ size: "medium",
1159
+ isLoading: isLoadingMorePositions,
1160
+ onClick: onLoadMorePositions,
1161
+ children: "Load more"
1162
+ }
1163
+ ) }) : null : hasMoreActivities ? /* @__PURE__ */ jsx8("div", { className: "flex w-full justify-center pt-1", children: /* @__PURE__ */ jsx8(
1164
+ Button,
1165
+ {
1166
+ variant: "secondary",
1167
+ size: "medium",
1168
+ isLoading: isLoadingMoreActivities,
1169
+ onClick: onLoadMoreActivities,
1170
+ children: "Load more"
1171
+ }
1172
+ ) }) : null
1173
+ ] })
1174
+ ]
1175
+ }
1176
+ );
1177
+ };
1178
+ PositionsActivity.displayName = "PositionsActivity";
1179
+
1180
+ // src/pages/user-profile/components/default-avatar.tsx
1181
+ import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
1182
+ var DefaultAvatar = ({ className }) => {
1183
+ return /* @__PURE__ */ jsxs9(
1184
+ "svg",
1185
+ {
1186
+ xmlns: "http://www.w3.org/2000/svg",
1187
+ width: "120",
1188
+ height: "120",
1189
+ viewBox: "0 0 120 120",
1190
+ fill: "none",
1191
+ className: cn("shrink-0", className),
1192
+ "aria-hidden": true,
1193
+ children: [
1194
+ /* @__PURE__ */ jsxs9("g", { clipPath: "url(#clip0_default_avatar)", children: [
1195
+ /* @__PURE__ */ jsx9(
1196
+ "path",
1197
+ {
1198
+ d: "M60 120C93.1371 120 120 93.1371 120 60C120 26.8629 93.1371 0 60 0C26.8629 0 0 26.8629 0 60C0 93.1371 26.8629 120 60 120Z",
1199
+ fill: "white"
1200
+ }
1201
+ ),
1202
+ /* @__PURE__ */ jsx9(
1203
+ "path",
1204
+ {
1205
+ d: "M60 120C93.1371 120 120 93.1371 120 60C120 26.8629 93.1371 0 60 0C26.8629 0 0 26.8629 0 60C0 93.1371 26.8629 120 60 120Z",
1206
+ fill: "black",
1207
+ fillOpacity: "0.1"
1208
+ }
1209
+ ),
1210
+ /* @__PURE__ */ jsx9(
1211
+ "path",
1212
+ {
1213
+ d: "M73.7338 64.1259C80.4187 59.6756 84.8276 52.0804 84.8276 43.4487C84.8276 29.7376 73.7111 18.6211 60 18.6211C46.2890 18.6211 35.1724 29.7376 35.1724 43.4487C35.1724 52.0804 39.5814 59.6756 46.2662 64.1259C46.2662 64.1259 46.2683 64.1280 46.2704 64.1280C46.2683 64.1280 46.2683 64.1259 46.2683 64.1259C30.2669 68.9487 17.8076 81.9356 13.7959 98.2742L13.7980 98.2763C14.4518 99.0645 15.1304 99.8342 15.8235 100.589C15.9911 100.774 16.1669 100.949 16.3387 101.129C16.8724 101.696 17.4124 102.255 17.9669 102.801C18.1966 103.027 18.4304 103.244 18.6642 103.465C19.1773 103.954 19.6966 104.436 20.2262 104.905C20.4890 105.137 20.7559 105.367 21.0207 105.594C21.5400 106.039 22.0656 106.476 22.6014 106.902C22.8828 107.127 23.1662 107.349 23.4497 107.570C23.9918 107.988 24.5421 108.394 25.0987 108.791C25.3862 108.996 25.6697 109.205 25.9614 109.405C26.5490 109.811 27.1469 110.200 27.7490 110.585C28.0200 110.756 28.2849 110.934 28.5580 111.104C29.2531 111.532 29.9607 111.942 30.6745 112.343C30.8628 112.449 31.0469 112.562 31.2373 112.666C32.1600 113.171 33.0973 113.655 34.0490 114.112C34.0718 114.122 34.0966 114.133 34.1193 114.143C35.0276 114.578 35.9504 114.989 36.8835 115.378C37.1731 115.500 37.4690 115.608 37.7607 115.724C38.4352 115.993 39.1097 116.258 39.7966 116.502C40.1607 116.632 40.5290 116.750 40.8952 116.874C41.5200 117.085 42.1490 117.290 42.7821 117.478C43.1835 117.598 43.5869 117.710 43.9924 117.822C44.6049 117.991 45.2214 118.153 45.8442 118.304C46.2642 118.405 46.6862 118.502 47.1104 118.596C47.7331 118.732 48.3580 118.856 48.9869 118.972C49.4131 119.051 49.8373 119.131 50.2676 119.200C50.9173 119.305 51.5711 119.394 52.2269 119.479C52.6407 119.533 53.0524 119.593 53.4683 119.636C54.1924 119.715 54.9228 119.771 55.6531 119.822C56.0069 119.847 56.3566 119.885 56.7104 119.903C57.8007 119.965 58.8952 120 60 120C61.1049 120 62.1993 119.965 63.2897 119.907C63.6435 119.889 63.9952 119.851 64.3469 119.827C65.0793 119.775 65.8097 119.719 66.5318 119.640C66.9476 119.595 67.3593 119.537 67.7731 119.483C68.4290 119.398 69.0828 119.309 69.7324 119.204C70.1607 119.134 70.5869 119.055 71.0131 118.976C71.6421 118.860 72.2690 118.736 72.8897 118.600C73.3138 118.507 73.7359 118.409 74.1559 118.308C74.7766 118.157 75.3931 117.996 76.0076 117.826C76.4111 117.714 76.8166 117.602 77.2180 117.482C77.8531 117.292 78.4800 117.087 79.1049 116.878C79.4711 116.754 79.8414 116.636 80.2035 116.506C80.8883 116.260 81.5649 115.997 82.2393 115.728C82.5311 115.612 82.8269 115.502 83.1166 115.382C84.0456 114.994 84.9642 114.586 85.8683 114.151C85.8952 114.139 85.9242 114.127 85.9511 114.114C86.9028 113.657 87.8400 113.173 88.7628 112.668C88.9531 112.565 89.1373 112.451 89.3256 112.345C90.0393 111.944 90.7469 111.534 91.4421 111.106C91.7152 110.938 91.9821 110.760 92.2511 110.587C92.8531 110.202 93.4511 109.811 94.0387 109.407C94.3283 109.207 94.6138 109.000 94.9014 108.793C95.4580 108.394 96.0083 107.988 96.5504 107.572C96.8359 107.353 97.1173 107.129 97.3987 106.904C97.9324 106.478 98.4600 106.041 98.9793 105.596C99.2462 105.369 99.5131 105.139 99.7738 104.907C100.303 104.438 100.823 103.956 101.336 103.467C101.568 103.246 101.803 103.027 102.033 102.803C102.588 102.257 103.130 101.698 103.661 101.131C103.831 100.949 104.007 100.774 104.177 100.591C104.870 99.8363 105.548 99.0666 106.202 98.2783L106.204 98.2763C102.195 81.9356 89.7352 68.9487 73.7338 64.1259Z",
1214
+ fill: "black",
1215
+ fillOpacity: "0.1"
1216
+ }
1217
+ )
1218
+ ] }),
1219
+ /* @__PURE__ */ jsx9("defs", { children: /* @__PURE__ */ jsx9("clipPath", { id: "clip0_default_avatar", children: /* @__PURE__ */ jsx9("rect", { width: "120", height: "120", fill: "white" }) }) })
1220
+ ]
1221
+ }
1222
+ );
1223
+ };
1224
+ DefaultAvatar.displayName = "DefaultAvatar";
1225
+
1226
+ // src/pages/user-profile/components/user-info-card.tsx
1227
+ import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
1228
+ var UserInfoCard = ({
1229
+ user,
1230
+ onEditProfile,
1231
+ onDeposit,
1232
+ onWithdraw,
1233
+ className
1234
+ }) => {
1235
+ var _a, _b, _c;
1236
+ const evmExchanges = ((_a = user.connectedExchanges) != null ? _a : []).filter((ex) => ex.venue !== "kalshi");
1237
+ const totalExchangeCount = (_c = (_b = user.connectedExchanges) == null ? void 0 : _b.length) != null ? _c : 0;
1238
+ const hasEvmExchanges = evmExchanges.length > 0;
1239
+ return /* @__PURE__ */ jsxs10(
1240
+ "div",
1241
+ {
1242
+ className: cn(
1243
+ "flex h-full flex-col items-start gap-4 sm:gap-6 rounded-agg-md border border-agg-separator bg-agg-secondary p-5",
1244
+ className
1245
+ ),
1246
+ children: [
1247
+ /* @__PURE__ */ jsxs10("div", { className: "flex w-full flex-col items-start gap-4 sm:flex-row sm:gap-5", children: [
1248
+ /* @__PURE__ */ jsx10("div", { className: "shrink-0", children: user.avatarUrl ? /* @__PURE__ */ jsx10(
1249
+ RemoteImage,
1250
+ {
1251
+ src: user.avatarUrl,
1252
+ alt: user.username,
1253
+ className: "h-20 w-20 rounded-full object-cover sm:h-[120px] sm:w-[120px]"
1254
+ }
1255
+ ) : /* @__PURE__ */ jsx10(DefaultAvatar, { className: "h-20 w-20 sm:h-[120px] sm:w-[120px]" }) }),
1256
+ /* @__PURE__ */ jsxs10("div", { className: "flex min-w-0 w-full flex-1 flex-col gap-3 sm:gap-4", children: [
1257
+ /* @__PURE__ */ jsxs10("div", { className: "flex flex-wrap items-center justify-between gap-3 sm:gap-4", children: [
1258
+ /* @__PURE__ */ jsxs10("div", { className: "flex min-w-0 items-center gap-2", children: [
1259
+ /* @__PURE__ */ jsx10("h2", { className: "truncate text-[22px] leading-7 font-agg-bold text-agg-foreground sm:agg-type-heading", children: user.username }),
1260
+ user.socialLinks && user.socialLinks.length > 0 ? /* @__PURE__ */ jsx10("div", { className: "flex items-center gap-2", children: user.socialLinks.map((social) => {
1261
+ const iconName = social.platform === "twitter" ? "twitter" : social.platform === "discord" ? "discord" : "telegram";
1262
+ const iconNode = /* @__PURE__ */ jsx10("span", { className: "flex size-7 shrink-0 items-center justify-center rounded-full border border-agg-separator bg-agg-secondary sm:size-8", children: /* @__PURE__ */ jsx10(Icon, { name: iconName, size: "small", className: "text-agg-foreground" }) });
1263
+ if (!social.handle) {
1264
+ return /* @__PURE__ */ jsx10("span", { children: iconNode }, `${social.platform}-icon`);
1265
+ }
1266
+ return /* @__PURE__ */ jsx10(
1267
+ "a",
1268
+ {
1269
+ href: social.handle,
1270
+ target: "_blank",
1271
+ rel: "noreferrer noopener",
1272
+ "aria-label": `${social.platform} profile`,
1273
+ children: iconNode
1274
+ },
1275
+ `${social.platform}-${social.handle}`
1276
+ );
1277
+ }) }) : null
1278
+ ] }),
1279
+ onEditProfile ? /* @__PURE__ */ jsxs10(
1280
+ "button",
1281
+ {
1282
+ type: "button",
1283
+ onClick: onEditProfile,
1284
+ className: "hidden shrink-0 cursor-pointer items-center gap-2 bg-transparent text-agg-primary hover:opacity-80 sm:flex",
1285
+ children: [
1286
+ /* @__PURE__ */ jsx10(Icon, { name: "pencil", size: "small", className: "text-agg-primary" }),
1287
+ /* @__PURE__ */ jsx10("span", { className: "text-agg-base font-agg-bold leading-6", children: "Edit" })
1288
+ ]
1289
+ }
1290
+ ) : null
1291
+ ] }),
1292
+ totalExchangeCount > 0 || user.socialHandle ? /* @__PURE__ */ jsxs10("div", { className: "flex w-full flex-col gap-2.5 sm:gap-3", children: [
1293
+ hasEvmExchanges ? /* @__PURE__ */ jsxs10("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3", children: [
1294
+ /* @__PURE__ */ jsx10("div", { className: "flex items-center", children: evmExchanges.map((exchange, idx) => /* @__PURE__ */ jsx10(
1295
+ "div",
1296
+ {
1297
+ className: cn(
1298
+ "relative flex h-5 w-5 shrink-0 items-center justify-center overflow-hidden rounded-[4px]",
1299
+ idx > 0 && "-ml-2"
1300
+ ),
1301
+ style: { zIndex: evmExchanges.length - idx },
1302
+ children: /* @__PURE__ */ jsx10(
1303
+ RemoteImage,
1304
+ {
1305
+ src: venueLogoUrlRegistry[exchange.venue],
1306
+ alt: venueLogoLabels[exchange.venue],
1307
+ className: "h-5 w-5"
1308
+ }
1309
+ )
1310
+ },
1311
+ `${exchange.venue}-${idx}`
1312
+ )) }),
1313
+ user.displayAddress ? /* @__PURE__ */ jsx10("span", { className: "text-agg-sm font-agg-normal leading-5 text-agg-foreground sm:text-agg-base sm:leading-6", children: user.displayAddress }) : null,
1314
+ /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-1", children: [
1315
+ /* @__PURE__ */ jsxs10("span", { className: "text-agg-sm font-agg-normal leading-5 text-agg-muted-foreground", children: [
1316
+ totalExchangeCount,
1317
+ " exchange",
1318
+ totalExchangeCount !== 1 ? "s" : ""
1319
+ ] }),
1320
+ /* @__PURE__ */ jsx10(Icon, { name: "info", size: "small", className: "text-agg-muted-foreground" })
1321
+ ] })
1322
+ ] }) : null,
1323
+ user.socialHandle ? /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2 sm:gap-3", children: [
1324
+ user.socialHandleVenue ? /* @__PURE__ */ jsx10("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center overflow-hidden rounded-[4px]", children: /* @__PURE__ */ jsx10(
1325
+ RemoteImage,
1326
+ {
1327
+ src: venueLogoUrlRegistry[user.socialHandleVenue],
1328
+ alt: venueLogoLabels[user.socialHandleVenue],
1329
+ className: "h-5 w-5"
1330
+ }
1331
+ ) }) : null,
1332
+ /* @__PURE__ */ jsx10("span", { className: "text-agg-sm font-agg-normal leading-5 text-agg-foreground sm:text-agg-base sm:leading-6", children: user.socialHandle })
1333
+ ] }) : null
1334
+ ] }) : null
1335
+ ] })
1336
+ ] }),
1337
+ (onDeposit || onWithdraw) && /* @__PURE__ */ jsxs10("div", { className: "flex w-full items-center gap-5", children: [
1338
+ /* @__PURE__ */ jsxs10("div", { className: "flex min-w-0 flex-1 items-center gap-3", children: [
1339
+ onDeposit ? /* @__PURE__ */ jsx10(
1340
+ "button",
1341
+ {
1342
+ type: "button",
1343
+ onClick: onDeposit,
1344
+ className: "inline-flex h-9 min-w-0 flex-1 items-center justify-center rounded-agg-full bg-agg-primary px-4 font-agg-sans text-agg-base font-agg-bold text-white hover:opacity-90 sm:h-10 sm:px-6",
1345
+ children: "Deposit"
1346
+ }
1347
+ ) : null,
1348
+ onWithdraw ? /* @__PURE__ */ jsx10(
1349
+ "button",
1350
+ {
1351
+ type: "button",
1352
+ onClick: onWithdraw,
1353
+ className: "inline-flex h-9 min-w-0 flex-1 items-center justify-center rounded-agg-full border border-agg-separator bg-transparent px-4 font-agg-sans text-agg-base font-agg-bold text-agg-foreground hover:bg-agg-secondary-hover sm:h-10 sm:px-6",
1354
+ children: "Withdraw"
1355
+ }
1356
+ ) : null
1357
+ ] }),
1358
+ onEditProfile ? /* @__PURE__ */ jsxs10(
1359
+ "button",
1360
+ {
1361
+ type: "button",
1362
+ onClick: onEditProfile,
1363
+ className: "flex shrink-0 cursor-pointer items-center gap-1.5 bg-transparent text-agg-primary hover:opacity-80 sm:hidden",
1364
+ children: [
1365
+ /* @__PURE__ */ jsx10(Icon, { name: "pencil", size: "small", className: "h-3.5 w-3.5 text-agg-primary" }),
1366
+ /* @__PURE__ */ jsx10("span", { className: "text-agg-sm font-agg-bold leading-5", children: "Edit" })
1367
+ ]
1368
+ }
1369
+ ) : null
1370
+ ] })
1371
+ ]
1372
+ }
1373
+ );
1374
+ };
1375
+ UserInfoCard.displayName = "UserInfoCard";
1376
+
1377
+ // src/pages/user-profile/index.tsx
1378
+ import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
1379
+ var currencyFormatter = new Intl.NumberFormat("en-US", {
1380
+ style: "currency",
1381
+ currency: "USD",
1382
+ minimumFractionDigits: 2,
1383
+ maximumFractionDigits: 2
1384
+ });
1385
+ var formatUsd = (value) => currencyFormatter.format(Number.isFinite(value) ? value : 0);
1386
+ var shortenAddress = (address) => {
1387
+ if (!address) return void 0;
1388
+ if (address.length <= 12) return address;
1389
+ return `${address.slice(0, 6)}...${address.slice(-5)}`;
1390
+ };
1391
+ var fallbackThumbnailSrc = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60"><rect width="100%" height="100%" fill="%23f4f4f7"/></svg>';
1392
+ var toRelativeTimeLabel = (value) => {
1393
+ const timestamp = value instanceof Date ? value.getTime() : Date.parse(value);
1394
+ if (Number.isNaN(timestamp)) return "";
1395
+ const diffMs = Date.now() - timestamp;
1396
+ const minute = 60 * 1e3;
1397
+ const hour = 60 * minute;
1398
+ const day = 24 * hour;
1399
+ const week = 7 * day;
1400
+ if (diffMs < hour) {
1401
+ const minutes = Math.max(1, Math.floor(diffMs / minute));
1402
+ return `${minutes}m ago`;
1403
+ }
1404
+ if (diffMs < day) {
1405
+ const hours = Math.max(1, Math.floor(diffMs / hour));
1406
+ return `${hours}h ago`;
1407
+ }
1408
+ if (diffMs < week) {
1409
+ const days = Math.max(1, Math.floor(diffMs / day));
1410
+ return `${days}d ago`;
1411
+ }
1412
+ const weeks = Math.max(1, Math.floor(diffMs / week));
1413
+ return `${weeks}w ago`;
1414
+ };
1415
+ var toAmountLabel = (amountRaw, executionPrice, filledAmountRaw) => {
1416
+ const parsedExecutionPrice = executionPrice ? Number(executionPrice) : Number.NaN;
1417
+ const parsedFilledAmount = filledAmountRaw ? Number(filledAmountRaw) : Number.NaN;
1418
+ if (Number.isFinite(parsedExecutionPrice) && Number.isFinite(parsedFilledAmount)) {
1419
+ return formatUsd(parsedExecutionPrice * parsedFilledAmount);
1420
+ }
1421
+ const parsedAmount = Number(amountRaw);
1422
+ if (Number.isFinite(parsedAmount)) return formatUsd(parsedAmount);
1423
+ return "$0.00";
1424
+ };
1425
+ var UserProfilePage = ({
1426
+ user,
1427
+ venueBalances: _venueBalances,
1428
+ balance,
1429
+ activePositions,
1430
+ closedPositions,
1431
+ activities,
1432
+ onEditProfile,
1433
+ onDeposit,
1434
+ onWithdraw,
1435
+ onPositionClick,
1436
+ onActivityClick,
1437
+ isLoadingPositions,
1438
+ isLoadingActivities,
1439
+ positionsError,
1440
+ activitiesError,
1441
+ hasMorePositions,
1442
+ isLoadingMorePositions,
1443
+ onLoadMorePositions,
1444
+ hasMoreActivities,
1445
+ isLoadingMoreActivities,
1446
+ onLoadMoreActivities,
1447
+ classNames
1448
+ }) => {
1449
+ const { user: currentUser, isAuthenticated } = useAggAuthState();
1450
+ const balanceState = useAggBalance();
1451
+ const shouldUseHookData = !user;
1452
+ const connectedVenuesFromBalance = useMemo4(
1453
+ () => {
1454
+ var _a;
1455
+ return (_a = balanceState.connectedVenues) != null ? _a : [];
1456
+ },
1457
+ [balanceState]
1458
+ );
1459
+ const connectedVenues = useMemo4(() => {
1460
+ if (!shouldUseHookData) return [];
1461
+ return [...new Set(connectedVenuesFromBalance)].sort((a, b) => a.localeCompare(b));
1462
+ }, [connectedVenuesFromBalance, shouldUseHookData]);
1463
+ const positionsQuery = useExecutionPositions({
1464
+ enabled: shouldUseHookData && isAuthenticated,
1465
+ limit: 25
1466
+ });
1467
+ const ordersQuery = useExecutionOrders({
1468
+ enabled: shouldUseHookData && isAuthenticated,
1469
+ limit: 25
1470
+ });
1471
+ const resolvedUser = useMemo4(() => {
1472
+ var _a, _b, _c, _d;
1473
+ if (user) return user;
1474
+ const fallbackUsername = (currentUser == null ? void 0 : currentUser.id) ? `user_${currentUser.id.slice(0, 6)}` : "User";
1475
+ const twitterAccount = (_a = currentUser == null ? void 0 : currentUser.accounts) == null ? void 0 : _a.find(
1476
+ (account) => String(account.provider).toLowerCase() === "twitter"
1477
+ );
1478
+ const normalizedTwitterHandle = (_b = twitterAccount == null ? void 0 : twitterAccount.providerAccountId) == null ? void 0 : _b.replace(/^@/, "");
1479
+ return {
1480
+ username: (_c = currentUser == null ? void 0 : currentUser.username) != null ? _c : fallbackUsername,
1481
+ avatarUrl: (_d = currentUser == null ? void 0 : currentUser.avatarUrl) != null ? _d : null,
1482
+ socialLinks: normalizedTwitterHandle ? [
1483
+ {
1484
+ platform: "twitter",
1485
+ handle: `https://x.com/${normalizedTwitterHandle}`
1486
+ }
1487
+ ] : [],
1488
+ connectedExchanges: connectedVenues.map((venue) => ({ venue })),
1489
+ displayAddress: shortenAddress(getWalletAddressFromUserProfile(currentUser)),
1490
+ socialHandle: normalizedTwitterHandle != null ? normalizedTwitterHandle : void 0
1491
+ };
1492
+ }, [connectedVenues, currentUser, user]);
1493
+ const positionsValueLabel = useMemo4(() => {
1494
+ var _a;
1495
+ if (balance == null ? void 0 : balance.totalLabel) return balance.totalLabel;
1496
+ const managed = balanceState.managedBalances;
1497
+ const positions = (_a = managed == null ? void 0 : managed.positions) != null ? _a : [];
1498
+ const positionsValueTotal = positions.reduce((sum, p) => sum + (Number(p.balance) || 0), 0);
1499
+ return formatUsd(positionsValueTotal);
1500
+ }, [balance, balanceState]);
1501
+ const availableBalanceLabel = useMemo4(() => {
1502
+ var _a;
1503
+ return formatUsd((_a = balanceState.totalBalance) != null ? _a : 0);
1504
+ }, [balanceState.totalBalance]);
1505
+ const resolvedActivities = useMemo4(() => {
1506
+ if (activities) return activities;
1507
+ return ordersQuery.orders.map((order) => {
1508
+ var _a, _b, _c, _d, _e, _f;
1509
+ const parsedSide = order.side.toLowerCase() === "buy" || order.side.toLowerCase() === "sell" ? order.side.toLowerCase() : "buy";
1510
+ const type = parsedSide === "buy" ? "Buy" : "Sell";
1511
+ const venue = connectedVenues.includes(order.venue) ? order.venue : "polymarket";
1512
+ return {
1513
+ id: order.id,
1514
+ type,
1515
+ thumbnailSrc: (_b = (_a = order.venueMarket) == null ? void 0 : _a.image) != null ? _b : fallbackThumbnailSrc,
1516
+ title: ((_c = order.venueMarket) == null ? void 0 : _c.question) || "Market",
1517
+ venue,
1518
+ outcomeLabel: ((_d = order.venueMarketOutcome) == null ? void 0 : _d.title) || ((_e = order.venueMarketOutcome) == null ? void 0 : _e.label) || "Outcome",
1519
+ sharesLabel: `${(_f = order.filledAmountRaw) != null ? _f : order.amountRaw} shares`,
1520
+ amountLabel: toAmountLabel(order.amountRaw, order.executionPrice, order.filledAmountRaw),
1521
+ timeLabel: toRelativeTimeLabel(order.createdAt)
1522
+ };
1523
+ });
1524
+ }, [activities, connectedVenues, ordersQuery.orders]);
1525
+ const resolvedActivePositions = useMemo4(() => {
1526
+ if (activePositions) return activePositions;
1527
+ return positionsQuery.positions.flatMap(
1528
+ (group) => group.venueMarket.venueMarketOutcomes.map((outcome) => {
1529
+ var _a, _b, _c;
1530
+ const outcomeVenue = (_a = outcome.venueBreakdown[0]) == null ? void 0 : _a.venue;
1531
+ const venue = connectedVenues.includes(outcomeVenue != null ? outcomeVenue : "polymarket") ? outcomeVenue != null ? outcomeVenue : "polymarket" : "polymarket";
1532
+ const currentPriceCents = Math.round(outcome.currentPrice * 100);
1533
+ const averagePriceCents = Math.round(outcome.avgEntryPrice * 100);
1534
+ const pnlPrefix = outcome.unrealizedPnl >= 0 ? "+" : "";
1535
+ const pnlPercent = (outcome.unrealizedPnlPercent * 100).toFixed(2);
1536
+ return {
1537
+ id: `${group.targetMarketId}-${outcome.label}-${(_b = outcome.title) != null ? _b : ""}`,
1538
+ thumbnailSrc: (_c = group.venueMarket.image) != null ? _c : fallbackThumbnailSrc,
1539
+ title: group.venueMarket.question,
1540
+ venue,
1541
+ outcomeLabel: `${outcome.label} ${currentPriceCents}\xA2`,
1542
+ sharesLabel: `${outcome.totalSize.toFixed(2)} shares`,
1543
+ averageLabel: `${averagePriceCents}\xA2`,
1544
+ currentLabel: `${currentPriceCents}\xA2`,
1545
+ valueLabel: formatUsd(outcome.totalValue),
1546
+ pnlLabel: `${pnlPrefix}${formatUsd(outcome.unrealizedPnl)} (${pnlPrefix}${pnlPercent}%)`,
1547
+ isPnlPositive: outcome.unrealizedPnl >= 0
1548
+ };
1549
+ })
1550
+ );
1551
+ }, [activePositions, connectedVenues, positionsQuery.positions]);
1552
+ const resolvedClosedPositions = useMemo4(() => {
1553
+ return closedPositions != null ? closedPositions : [];
1554
+ }, [closedPositions]);
1555
+ return /* @__PURE__ */ jsx11("div", { className: "box-border w-full overflow-x-hidden p-5 sm:p-10", children: /* @__PURE__ */ jsxs11(
1556
+ "section",
1557
+ {
1558
+ className: cn(
1559
+ // Outer container spacing per updated Figma
1560
+ "flex w-full flex-col gap-6 sm:gap-8 overflow-clip rounded-agg-xl border border-agg-separator bg-agg-secondary p-5 sm:p-8",
1561
+ classNames == null ? void 0 : classNames.root
1562
+ ),
1563
+ children: [
1564
+ /* @__PURE__ */ jsxs11(
1565
+ "div",
1566
+ {
1567
+ className: cn(
1568
+ "grid grid-cols-1 gap-6 sm:grid-cols-[1fr_minmax(300px,420px)] sm:items-stretch sm:gap-8",
1569
+ classNames == null ? void 0 : classNames.topRow
1570
+ ),
1571
+ children: [
1572
+ /* @__PURE__ */ jsx11(
1573
+ "div",
1574
+ {
1575
+ className: cn(
1576
+ "flex min-w-0 flex-1 flex-col gap-4 sm:gap-6 h-full",
1577
+ classNames == null ? void 0 : classNames.leftColumn
1578
+ ),
1579
+ children: /* @__PURE__ */ jsx11(
1580
+ UserInfoCard,
1581
+ {
1582
+ user: resolvedUser,
1583
+ onEditProfile,
1584
+ onDeposit,
1585
+ onWithdraw,
1586
+ className: cn("h-full", classNames == null ? void 0 : classNames.userInfoCard)
1587
+ }
1588
+ )
1589
+ }
1590
+ ),
1591
+ /* @__PURE__ */ jsxs11("div", { className: cn("grid grid-cols-1 grid-rows-2 gap-4 h-full", classNames == null ? void 0 : classNames.rightColumn), children: [
1592
+ /* @__PURE__ */ jsx11(PositionsValueCard, { valueLabel: positionsValueLabel, className: "h-full" }),
1593
+ /* @__PURE__ */ jsx11(
1594
+ AvailableBalanceCard,
1595
+ {
1596
+ valueLabel: availableBalanceLabel,
1597
+ chains: balanceState.balanceBreakdown.map((b) => ({
1598
+ key: b.key,
1599
+ label: b.label,
1600
+ balance: b.balance,
1601
+ accountCount: b.accountCount
1602
+ })),
1603
+ className: "h-full"
1604
+ }
1605
+ )
1606
+ ] })
1607
+ ]
1608
+ }
1609
+ ),
1610
+ /* @__PURE__ */ jsx11(
1611
+ PositionsActivity,
1612
+ {
1613
+ activePositions: resolvedActivePositions,
1614
+ closedPositions: resolvedClosedPositions,
1615
+ activities: resolvedActivities,
1616
+ onPositionClick,
1617
+ onActivityClick,
1618
+ isLoadingPositions: isLoadingPositions != null ? isLoadingPositions : !!shouldUseHookData && positionsQuery.isLoading,
1619
+ isLoadingActivities: isLoadingActivities != null ? isLoadingActivities : !!shouldUseHookData && ordersQuery.isLoading,
1620
+ positionsError: positionsError != null ? positionsError : !!shouldUseHookData && !!positionsQuery.error,
1621
+ activitiesError: activitiesError != null ? activitiesError : !!shouldUseHookData && !!ordersQuery.error,
1622
+ hasMorePositions: hasMorePositions != null ? hasMorePositions : !!shouldUseHookData && !!positionsQuery.hasNextPage,
1623
+ isLoadingMorePositions: isLoadingMorePositions != null ? isLoadingMorePositions : !!shouldUseHookData && !!positionsQuery.isFetchingNextPage,
1624
+ onLoadMorePositions: onLoadMorePositions != null ? onLoadMorePositions : shouldUseHookData && positionsQuery.hasNextPage ? () => {
1625
+ void positionsQuery.fetchNextPage();
1626
+ } : void 0,
1627
+ hasMoreActivities: hasMoreActivities != null ? hasMoreActivities : !!shouldUseHookData && !!ordersQuery.hasNextPage,
1628
+ isLoadingMoreActivities: isLoadingMoreActivities != null ? isLoadingMoreActivities : !!shouldUseHookData && !!ordersQuery.isFetchingNextPage,
1629
+ onLoadMoreActivities: onLoadMoreActivities != null ? onLoadMoreActivities : shouldUseHookData && ordersQuery.hasNextPage ? () => {
1630
+ void ordersQuery.fetchNextPage();
1631
+ } : void 0,
1632
+ className: classNames == null ? void 0 : classNames.positionsActivity
1633
+ }
1634
+ )
1635
+ ]
1636
+ }
1637
+ ) });
1638
+ };
1639
+ UserProfilePage.displayName = "UserProfilePage";
1640
+
1641
+ export {
1642
+ EventMarketPage,
1643
+ HomePage,
1644
+ UserProfilePage
1645
+ };