@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
@@ -34,7 +34,7 @@ import {
34
34
  formatAmountDisplay,
35
35
  formatCompactUsd,
36
36
  venueLogoLabels
37
- } from "./chunk-XP7DREIX.mjs";
37
+ } from "./chunk-XUML4ZJQ.mjs";
38
38
 
39
39
  // src/deposit/index.tsx
40
40
  import { useState as useState3 } from "react";
@@ -606,8 +606,7 @@ var DepositModal = ({
606
606
  setStep("method");
607
607
  };
608
608
  const handleSelectMethod = (method) => {
609
- if (!selectedVenue)
610
- return;
609
+ if (!selectedVenue) return;
611
610
  if (method === "card") {
612
611
  setStep("card-deposit");
613
612
  } else {
@@ -1019,10 +1018,9 @@ var OnrampModal = ({
1019
1018
  },
1020
1019
  [onOpenChange]
1021
1020
  );
1022
- const handleGetQuotes = useCallback4(() => __async(void 0, null, function* () {
1021
+ const handleGetQuotes = useCallback4(() => __async(null, null, function* () {
1023
1022
  const numericAmount2 = Number(formValues.amount);
1024
- if (!numericAmount2 || numericAmount2 <= 0)
1025
- return;
1023
+ if (!numericAmount2 || numericAmount2 <= 0) return;
1026
1024
  setStep("quotes");
1027
1025
  setIsLoadingQuotes(true);
1028
1026
  setQuoteError(null);
@@ -1042,7 +1040,7 @@ var OnrampModal = ({
1042
1040
  }
1043
1041
  }), [formValues, transactionType, onGetQuotes]);
1044
1042
  const handleSelectQuote = useCallback4(
1045
- (quote) => __async(void 0, null, function* () {
1043
+ (quote) => __async(null, null, function* () {
1046
1044
  setStep("widget");
1047
1045
  setIsCreatingSession(true);
1048
1046
  try {
@@ -1143,8 +1141,7 @@ var VenueRow2 = ({ venue, onSelect }) => {
1143
1141
  onClick: (e) => {
1144
1142
  e.stopPropagation();
1145
1143
  e.preventDefault();
1146
- if (!isDisabled)
1147
- onSelect(venue.venue);
1144
+ if (!isDisabled) onSelect(venue.venue);
1148
1145
  },
1149
1146
  onKeyDown: (e) => {
1150
1147
  if (!isDisabled && (e.key === "Enter" || e.key === " ")) {
@@ -1509,15 +1506,13 @@ var WithdrawModal = ({
1509
1506
  setSelectedMethod(null);
1510
1507
  };
1511
1508
  const handleSelectMethod = (method) => {
1512
- if (!selectedVenue)
1513
- return;
1509
+ if (!selectedVenue) return;
1514
1510
  setSelectedMethod(method);
1515
1511
  setStep("withdraw-amount");
1516
1512
  onSelectWithdrawMethod == null ? void 0 : onSelectWithdrawMethod(selectedVenue.venue, method);
1517
1513
  };
1518
1514
  const handleContinueWithdraw = (amount) => {
1519
- if (!selectedVenue || !selectedMethod)
1520
- return;
1515
+ if (!selectedVenue || !selectedMethod) return;
1521
1516
  if (selectedMethod === "wallet") {
1522
1517
  onContinueWalletWithdraw == null ? void 0 : onContinueWalletWithdraw(selectedVenue.venue, amount);
1523
1518
  } else {
@@ -1600,8 +1595,7 @@ var HowItWorksStep = ({ onContinue, icons }) => {
1600
1595
  const [showBottomGradient, setShowBottomGradient] = useState7(true);
1601
1596
  const handleScroll = useCallback6(() => {
1602
1597
  const el = scrollRef.current;
1603
- if (!el)
1604
- return;
1598
+ if (!el) return;
1605
1599
  setShowTopGradient(el.scrollTop > 0);
1606
1600
  setShowBottomGradient(el.scrollTop + el.clientHeight < el.scrollHeight - 1);
1607
1601
  }, []);
@@ -1684,8 +1678,7 @@ var ProfileSetupStep = ({ onContinue }) => {
1684
1678
  const handleFileChange = useCallback7((e) => {
1685
1679
  var _a;
1686
1680
  const file = (_a = e.target.files) == null ? void 0 : _a[0];
1687
- if (!file)
1688
- return;
1681
+ if (!file) return;
1689
1682
  setAvatarFile(file);
1690
1683
  const reader = new FileReader();
1691
1684
  reader.onload = (event) => {
@@ -1705,30 +1698,51 @@ var ProfileSetupStep = ({ onContinue }) => {
1705
1698
  /* @__PURE__ */ jsx18("h2", { className: "text-center text-agg-2xl font-agg-bold text-agg-foreground", children: labels.onboarding.profileSetup.title }),
1706
1699
  /* @__PURE__ */ jsxs18("div", { className: "flex flex-col gap-5 items-center w-full", children: [
1707
1700
  /* @__PURE__ */ jsxs18("div", { className: "flex justify-center", children: [
1708
- /* @__PURE__ */ jsx18(
1701
+ /* @__PURE__ */ jsxs18(
1709
1702
  "button",
1710
1703
  {
1711
1704
  type: "button",
1712
1705
  onClick: handleAvatarClick,
1713
1706
  className: cn(
1714
- "relative flex items-center justify-center",
1707
+ "group relative flex items-center justify-center",
1715
1708
  "h-[80px] w-[80px]",
1716
1709
  "rounded-agg-full",
1717
- "border border-dashed border-agg-separator",
1718
1710
  "bg-agg-secondary-hover",
1719
- "hover:bg-agg-tertiary",
1711
+ !avatarPreview && "hover:bg-agg-tertiary",
1720
1712
  "transition-colors cursor-pointer",
1721
1713
  "overflow-hidden"
1722
1714
  ),
1723
1715
  "aria-label": labels.onboarding.profileSetup.uploadProfilePictureAria,
1724
- children: avatarPreview ? /* @__PURE__ */ jsx18(
1725
- RemoteImage,
1726
- {
1727
- src: avatarPreview,
1728
- alt: labels.onboarding.profileSetup.profilePreviewAlt,
1729
- className: "h-full w-full object-cover"
1730
- }
1731
- ) : /* @__PURE__ */ jsx18(ProfileIcon, { className: "h-7 w-7 text-agg-muted-foreground" })
1716
+ children: [
1717
+ !avatarPreview ? /* @__PURE__ */ jsx18(
1718
+ "svg",
1719
+ {
1720
+ "aria-hidden": true,
1721
+ viewBox: "0 0 80 80",
1722
+ className: "pointer-events-none absolute inset-0 h-full w-full text-agg-separator group-hover:text-agg-muted-foreground",
1723
+ children: /* @__PURE__ */ jsx18(
1724
+ "circle",
1725
+ {
1726
+ cx: "40",
1727
+ cy: "40",
1728
+ r: "39.5",
1729
+ fill: "none",
1730
+ stroke: "currentColor",
1731
+ strokeWidth: "1",
1732
+ strokeDasharray: "8 8"
1733
+ }
1734
+ )
1735
+ }
1736
+ ) : null,
1737
+ avatarPreview ? /* @__PURE__ */ jsx18(
1738
+ RemoteImage,
1739
+ {
1740
+ src: avatarPreview,
1741
+ alt: labels.onboarding.profileSetup.profilePreviewAlt,
1742
+ className: "h-full w-full object-cover"
1743
+ }
1744
+ ) : /* @__PURE__ */ jsx18(ProfileIcon, { className: "h-7 w-7 text-agg-muted-foreground" })
1745
+ ]
1732
1746
  }
1733
1747
  ),
1734
1748
  /* @__PURE__ */ jsx18(
@@ -1931,9 +1945,8 @@ var ConnectKalshiModal = ({
1931
1945
  const handleCancel = useCallback8(() => {
1932
1946
  onOpenChange(false);
1933
1947
  }, [onOpenChange]);
1934
- const handleVerify = useCallback8(() => __async(void 0, null, function* () {
1935
- if (!canVerify || verifying)
1936
- return;
1948
+ const handleVerify = useCallback8(() => __async(null, null, function* () {
1949
+ if (!canVerify || verifying) return;
1937
1950
  setVerifying(true);
1938
1951
  setError(void 0);
1939
1952
  try {
@@ -2179,9 +2192,8 @@ var ConnectOnchainModal = ({
2179
2192
  const handleCancel = useCallback9(() => {
2180
2193
  onOpenChange(false);
2181
2194
  }, [onOpenChange]);
2182
- const handleConnect = useCallback9(() => __async(void 0, null, function* () {
2183
- if (connecting)
2184
- return;
2195
+ const handleConnect = useCallback9(() => __async(null, null, function* () {
2196
+ if (connecting) return;
2185
2197
  setConnecting(true);
2186
2198
  setError(void 0);
2187
2199
  try {
@@ -2321,7 +2333,7 @@ var OnboardingModal = ({
2321
2333
  const handleOpenOnchainModal = useCallback10(() => {
2322
2334
  setOnchainModalOpen(true);
2323
2335
  }, []);
2324
- const handleOnchainConnect = useCallback10(() => __async(void 0, null, function* () {
2336
+ const handleOnchainConnect = useCallback10(() => __async(null, null, function* () {
2325
2337
  yield onConnectOnchain == null ? void 0 : onConnectOnchain();
2326
2338
  setOnchainConnected(true);
2327
2339
  }), [onConnectOnchain]);
@@ -2329,7 +2341,7 @@ var OnboardingModal = ({
2329
2341
  setKalshiModalOpen(true);
2330
2342
  }, []);
2331
2343
  const handleKalshiVerify = useCallback10(
2332
- (credentials) => __async(void 0, null, function* () {
2344
+ (credentials) => __async(null, null, function* () {
2333
2345
  yield onConnectKalshi == null ? void 0 : onConnectKalshi(credentials);
2334
2346
  setKalshiConnected(true);
2335
2347
  }),
@@ -2382,7 +2394,8 @@ var OnboardingModal = ({
2382
2394
  OnboardingModal.displayName = "OnboardingModal";
2383
2395
 
2384
2396
  // src/profile/index.tsx
2385
- import { useState as useState12, useEffect as useEffect2, useCallback as useCallback12 } from "react";
2397
+ import { useState as useState12, useEffect as useEffect2, useCallback as useCallback12, useMemo as useMemo2 } from "react";
2398
+ import { useAggClient, useAggAuthState } from "@agg-market/hooks";
2386
2399
 
2387
2400
  // src/profile/profile-modal.constants.ts
2388
2401
  var PROFILE_TAB_KEYS = {
@@ -2400,7 +2413,7 @@ import { useLabels as useLabels7 } from "@agg-market/hooks";
2400
2413
  import { jsx as jsx23, jsxs as jsxs23 } from "react/jsx-runtime";
2401
2414
  var AboutTab = ({
2402
2415
  avatarPreview,
2403
- onDeleteProfile,
2416
+ onDeleteProfile: _onDeleteProfile,
2404
2417
  draftUsername,
2405
2418
  onDraftUsernameChange,
2406
2419
  onDraftAvatarChange,
@@ -2416,8 +2429,7 @@ var AboutTab = ({
2416
2429
  (e) => {
2417
2430
  var _a;
2418
2431
  const file = (_a = e.target.files) == null ? void 0 : _a[0];
2419
- if (!file)
2420
- return;
2432
+ if (!file) return;
2421
2433
  const reader = new FileReader();
2422
2434
  reader.onload = (event) => {
2423
2435
  var _a2;
@@ -2428,32 +2440,54 @@ var AboutTab = ({
2428
2440
  [onDraftAvatarChange]
2429
2441
  );
2430
2442
  const resolvedPreview = draftAvatarPreview != null ? draftAvatarPreview : avatarPreview;
2443
+ const hasAvatarPreview = Boolean(resolvedPreview);
2431
2444
  return /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-8", children: [
2432
2445
  /* @__PURE__ */ jsxs23("div", { className: "flex justify-center", children: [
2433
- /* @__PURE__ */ jsx23(
2446
+ /* @__PURE__ */ jsxs23(
2434
2447
  "button",
2435
2448
  {
2436
2449
  type: "button",
2437
2450
  onClick: handleAvatarClick,
2438
2451
  className: cn(
2439
- "relative flex items-center justify-center",
2452
+ "group relative flex items-center justify-center",
2440
2453
  "h-[80px] w-[80px]",
2441
2454
  "rounded-agg-full",
2442
- "border-2 border-dashed border-agg-separator",
2443
2455
  "bg-agg-secondary",
2444
- "hover:border-agg-muted-foreground hover:bg-agg-secondary-hover",
2456
+ !hasAvatarPreview && "hover:bg-agg-secondary-hover",
2445
2457
  "transition-colors cursor-pointer",
2446
2458
  "overflow-hidden"
2447
2459
  ),
2448
2460
  "aria-label": labels.onboarding.profileSetup.uploadProfilePictureAria,
2449
- children: resolvedPreview ? /* @__PURE__ */ jsx23(
2450
- RemoteImage,
2451
- {
2452
- src: resolvedPreview,
2453
- alt: labels.onboarding.profileSetup.profilePreviewAlt,
2454
- className: "h-full w-full object-cover"
2455
- }
2456
- ) : /* @__PURE__ */ jsx23(ProfileIcon, { className: "h-8 w-8 text-agg-muted-foreground" })
2461
+ children: [
2462
+ !hasAvatarPreview ? /* @__PURE__ */ jsx23(
2463
+ "svg",
2464
+ {
2465
+ "aria-hidden": true,
2466
+ viewBox: "0 0 80 80",
2467
+ className: "pointer-events-none absolute inset-0 h-full w-full text-agg-separator group-hover:text-agg-muted-foreground",
2468
+ children: /* @__PURE__ */ jsx23(
2469
+ "circle",
2470
+ {
2471
+ cx: "40",
2472
+ cy: "40",
2473
+ r: "39.5",
2474
+ fill: "none",
2475
+ stroke: "currentColor",
2476
+ strokeWidth: "1",
2477
+ strokeDasharray: "8 8"
2478
+ }
2479
+ )
2480
+ }
2481
+ ) : null,
2482
+ resolvedPreview ? /* @__PURE__ */ jsx23(
2483
+ RemoteImage,
2484
+ {
2485
+ src: resolvedPreview,
2486
+ alt: labels.onboarding.profileSetup.profilePreviewAlt,
2487
+ className: "h-full w-full object-cover"
2488
+ }
2489
+ ) : /* @__PURE__ */ jsx23(ProfileIcon, { className: "h-8 w-8 text-agg-muted-foreground" })
2490
+ ]
2457
2491
  }
2458
2492
  ),
2459
2493
  /* @__PURE__ */ jsx23(
@@ -2498,28 +2532,6 @@ var AboutTab = ({
2498
2532
  )
2499
2533
  }
2500
2534
  )
2501
- ] }),
2502
- /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-4", children: [
2503
- /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-1", children: [
2504
- /* @__PURE__ */ jsx23("span", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: "Delete your profile" }),
2505
- /* @__PURE__ */ jsx23("span", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: "This will permanently delete your account and all of its data. You will not be able to reactivate this account." })
2506
- ] }),
2507
- /* @__PURE__ */ jsx23(
2508
- "button",
2509
- {
2510
- type: "button",
2511
- onClick: onDeleteProfile,
2512
- className: cn(
2513
- "self-start cursor-pointer",
2514
- "rounded-agg-full border border-[#e5455f]",
2515
- "h-8 px-4",
2516
- "text-agg-sm font-agg-bold leading-agg-5 text-[#e5455f]",
2517
- "bg-agg-secondary hover:bg-[#e5455f]/10",
2518
- "transition-colors"
2519
- ),
2520
- children: "Delete Profile"
2521
- }
2522
- )
2523
2535
  ] })
2524
2536
  ] });
2525
2537
  };
@@ -2565,15 +2577,13 @@ var AccountsWalletsTab = ({
2565
2577
  onDisconnectExchange,
2566
2578
  onConnectTwitter,
2567
2579
  onDisconnectTwitter,
2568
- onConnectDiscord,
2569
- onDisconnectDiscord,
2570
- onConnectTelegram,
2571
- onDisconnectTelegram,
2580
+ onConnectDiscord: _onConnectDiscord,
2581
+ onDisconnectDiscord: _onDisconnectDiscord,
2582
+ onConnectTelegram: _onConnectTelegram,
2583
+ onDisconnectTelegram: _onDisconnectTelegram,
2572
2584
  onConnectEmail
2573
2585
  }) => {
2574
2586
  const twitter = socialAccounts == null ? void 0 : socialAccounts.twitter;
2575
- const discord = socialAccounts == null ? void 0 : socialAccounts.discord;
2576
- const telegram = socialAccounts == null ? void 0 : socialAccounts.telegram;
2577
2587
  return /* @__PURE__ */ jsxs24("div", { className: "flex flex-col gap-8", children: [
2578
2588
  /* @__PURE__ */ jsxs24("div", { className: "flex flex-col gap-3", children: [
2579
2589
  /* @__PURE__ */ jsx24(SectionTitle, { children: "Exchanges" }),
@@ -2602,29 +2612,13 @@ var AccountsWalletsTab = ({
2602
2612
  ] }),
2603
2613
  /* @__PURE__ */ jsxs24("div", { className: "flex flex-col gap-3", children: [
2604
2614
  /* @__PURE__ */ jsx24(SectionTitle, { children: "Social Accounts" }),
2605
- /* @__PURE__ */ jsxs24("div", { className: "flex flex-col gap-2", children: [
2606
- /* @__PURE__ */ jsxs24(AccountRow, { children: [
2607
- /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-3", children: [
2608
- /* @__PURE__ */ jsx24("span", { className: "flex h-5 w-5 shrink-0 items-center justify-center text-agg-foreground", children: /* @__PURE__ */ jsx24(Icon, { name: "twitter", size: "small", color: "currentColor" }) }),
2609
- /* @__PURE__ */ jsx24("span", { className: "text-agg-base font-agg-normal leading-6 text-agg-foreground whitespace-nowrap", children: "X (Twitter)" })
2610
- ] }),
2611
- (twitter == null ? void 0 : twitter.connected) ? /* @__PURE__ */ jsx24(DisconnectTextButton, { onClick: onDisconnectTwitter }) : /* @__PURE__ */ jsx24(ConnectTextButton, { onClick: onConnectTwitter })
2615
+ /* @__PURE__ */ jsx24("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ jsxs24(AccountRow, { children: [
2616
+ /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-3", children: [
2617
+ /* @__PURE__ */ jsx24("span", { className: "flex h-5 w-5 shrink-0 items-center justify-center text-agg-foreground", children: /* @__PURE__ */ jsx24(Icon, { name: "twitter", size: "small", color: "currentColor" }) }),
2618
+ /* @__PURE__ */ jsx24("span", { className: "text-agg-base font-agg-normal leading-6 text-agg-foreground whitespace-nowrap", children: "X (Twitter)" })
2612
2619
  ] }),
2613
- /* @__PURE__ */ jsxs24(AccountRow, { children: [
2614
- /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-3", children: [
2615
- /* @__PURE__ */ jsx24("span", { className: "flex h-5 w-5 shrink-0 items-center justify-center text-[#5865F2]", children: /* @__PURE__ */ jsx24(Icon, { name: "discord", size: "small", color: "currentColor" }) }),
2616
- /* @__PURE__ */ jsx24("span", { className: "text-agg-base font-agg-normal leading-6 text-agg-foreground whitespace-nowrap", children: "Discord" })
2617
- ] }),
2618
- (discord == null ? void 0 : discord.connected) ? /* @__PURE__ */ jsx24(DisconnectTextButton, { onClick: onDisconnectDiscord }) : /* @__PURE__ */ jsx24(ConnectTextButton, { onClick: onConnectDiscord })
2619
- ] }),
2620
- /* @__PURE__ */ jsxs24(AccountRow, { children: [
2621
- /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-3", children: [
2622
- /* @__PURE__ */ jsx24("span", { className: "flex h-5 w-5 shrink-0 items-center justify-center text-[#26A5E4]", children: /* @__PURE__ */ jsx24(Icon, { name: "telegram", size: "small", color: "currentColor" }) }),
2623
- /* @__PURE__ */ jsx24("span", { className: "text-agg-base font-agg-normal leading-6 text-agg-foreground whitespace-nowrap", children: "Telegram" })
2624
- ] }),
2625
- (telegram == null ? void 0 : telegram.connected) ? /* @__PURE__ */ jsx24(DisconnectTextButton, { onClick: onDisconnectTelegram }) : /* @__PURE__ */ jsx24(ConnectTextButton, { onClick: onConnectTelegram })
2626
- ] })
2627
- ] })
2620
+ (twitter == null ? void 0 : twitter.connected) ? /* @__PURE__ */ jsx24(DisconnectTextButton, { onClick: onDisconnectTwitter }) : /* @__PURE__ */ jsx24(ConnectTextButton, { onClick: onConnectTwitter })
2621
+ ] }) })
2628
2622
  ] }),
2629
2623
  /* @__PURE__ */ jsxs24("div", { className: "flex flex-col gap-3", children: [
2630
2624
  /* @__PURE__ */ jsx24(SectionTitle, { children: "Email Address" }),
@@ -2674,6 +2668,9 @@ var ProfileModal = ({
2674
2668
  onDisconnectTelegram,
2675
2669
  onConnectEmail
2676
2670
  }) => {
2671
+ var _a, _b, _c, _d, _e, _f;
2672
+ const client = useAggClient();
2673
+ const { user, startAuth } = useAggAuthState();
2677
2674
  const [activeTab, setActiveTab] = useState12(PROFILE_TAB_KEYS.ABOUT);
2678
2675
  const [draftUsername, setDraftUsername] = useState12(username != null ? username : "");
2679
2676
  const [draftAvatarFile, setDraftAvatarFile] = useState12();
@@ -2711,21 +2708,112 @@ var ProfileModal = ({
2711
2708
  []
2712
2709
  );
2713
2710
  const hasChanges = draftUsername !== (username != null ? username : "") || draftAvatarFile !== void 0;
2714
- const handleSave = useCallback12(() => {
2711
+ const handleSave = useCallback12(() => __async(null, null, function* () {
2715
2712
  setIsSaving(true);
2716
- onSave({
2717
- username: draftUsername || void 0,
2718
- avatarFile: draftAvatarFile,
2719
- avatarPreview: draftAvatarPreview
2720
- });
2721
- setTimeout(() => {
2722
- setIsSaving(false);
2713
+ try {
2714
+ const normalizedUsername = draftUsername.trim();
2715
+ if (normalizedUsername !== (username != null ? username : "")) {
2716
+ yield client.updateUser({ username: normalizedUsername || void 0 });
2717
+ }
2718
+ if (draftAvatarFile) {
2719
+ const { uploadUrl } = yield client.createAvatarUploadUrl(draftAvatarFile.type);
2720
+ yield fetch(uploadUrl, {
2721
+ method: "PUT",
2722
+ headers: {
2723
+ "Content-Type": draftAvatarFile.type
2724
+ },
2725
+ body: draftAvatarFile
2726
+ });
2727
+ yield client.updateUser({ confirmAvatar: true });
2728
+ }
2729
+ yield client.getCurrentUser();
2730
+ onSave({
2731
+ username: normalizedUsername || void 0,
2732
+ avatarFile: draftAvatarFile,
2733
+ avatarPreview: draftAvatarPreview
2734
+ });
2723
2735
  onOpenChange(false);
2724
- }, 500);
2725
- }, [draftUsername, draftAvatarFile, draftAvatarPreview, onSave, onOpenChange]);
2736
+ } finally {
2737
+ setIsSaving(false);
2738
+ }
2739
+ }), [client, draftAvatarFile, draftAvatarPreview, draftUsername, onOpenChange, onSave, username]);
2726
2740
  const handleCancel = useCallback12(() => {
2727
2741
  handleOpenChange(false);
2728
2742
  }, [handleOpenChange]);
2743
+ const isAccountConnected = (providers) => {
2744
+ var _a2, _b2, _c2;
2745
+ const normalizedProviders = providers.map((provider) => provider.toLowerCase());
2746
+ const fromAccounts = (_b2 = (_a2 = user == null ? void 0 : user.accounts) == null ? void 0 : _a2.some(
2747
+ (account) => normalizedProviders.includes(String(account.provider).toLowerCase())
2748
+ )) != null ? _b2 : false;
2749
+ const legacyIdentities = user == null ? void 0 : user.identities;
2750
+ const fromLegacy = (_c2 = legacyIdentities == null ? void 0 : legacyIdentities.some(
2751
+ (identity) => {
2752
+ var _a3;
2753
+ return normalizedProviders.includes(String((_a3 = identity.provider) != null ? _a3 : "").toLowerCase());
2754
+ }
2755
+ )) != null ? _c2 : false;
2756
+ return fromAccounts || fromLegacy;
2757
+ };
2758
+ const resolvedSocialAccounts = socialAccounts != null ? socialAccounts : {
2759
+ twitter: {
2760
+ connected: isAccountConnected(["twitter"])
2761
+ }
2762
+ };
2763
+ const resolvedEmail = (_f = (_e = email != null ? email : (_b = (_a = user == null ? void 0 : user.accounts) == null ? void 0 : _a.find(
2764
+ (account) => String(account.provider).toLowerCase() === "email"
2765
+ )) == null ? void 0 : _b.providerAccountId) != null ? _e : (_d = (_c = user == null ? void 0 : user.identities) == null ? void 0 : _c.find((identity) => {
2766
+ var _a2;
2767
+ return String((_a2 = identity.provider) != null ? _a2 : "").toLowerCase() === "email";
2768
+ })) == null ? void 0 : _d.providerAccountId) != null ? _f : null;
2769
+ const resolveRedirectUrl = () => {
2770
+ if (typeof window === "undefined") return "http://localhost";
2771
+ return `${window.location.origin}${window.location.pathname}${window.location.search}`;
2772
+ };
2773
+ const handleConnectTwitter = useCallback12(() => __async(null, null, function* () {
2774
+ const result = yield startAuth({
2775
+ provider: "twitter",
2776
+ redirectUrl: resolveRedirectUrl()
2777
+ });
2778
+ onConnectTwitter == null ? void 0 : onConnectTwitter();
2779
+ if (result.type === "redirect" && typeof window !== "undefined") {
2780
+ window.location.assign(result.url);
2781
+ }
2782
+ }), [onConnectTwitter, startAuth]);
2783
+ const handleDisconnectTwitter = useCallback12(() => __async(null, null, function* () {
2784
+ yield client.disconnectAccount("twitter");
2785
+ yield client.getCurrentUser();
2786
+ onDisconnectTwitter == null ? void 0 : onDisconnectTwitter();
2787
+ }), [client, onDisconnectTwitter]);
2788
+ const handleConnectEmail = useCallback12(() => __async(null, null, function* () {
2789
+ var _a2;
2790
+ const typedEmail = typeof window !== "undefined" ? (_a2 = window.prompt("Enter your email to receive a magic link")) == null ? void 0 : _a2.trim() : void 0;
2791
+ if (!typedEmail) return;
2792
+ yield startAuth({
2793
+ provider: "email",
2794
+ email: typedEmail,
2795
+ redirectUrl: resolveRedirectUrl()
2796
+ });
2797
+ onConnectEmail == null ? void 0 : onConnectEmail();
2798
+ }), [onConnectEmail, startAuth]);
2799
+ const providerActionMap = useMemo2(
2800
+ () => ({
2801
+ twitter: {
2802
+ connect: () => {
2803
+ void handleConnectTwitter();
2804
+ },
2805
+ disconnect: () => {
2806
+ void handleDisconnectTwitter();
2807
+ }
2808
+ },
2809
+ email: {
2810
+ connect: () => {
2811
+ void handleConnectEmail();
2812
+ }
2813
+ }
2814
+ }),
2815
+ [handleConnectEmail, handleConnectTwitter, handleDisconnectTwitter]
2816
+ );
2729
2817
  return /* @__PURE__ */ jsx25(Modal, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxs25(Modal.Container, { maxWidth: "800px", "aria-label": "Edit Profile", children: [
2730
2818
  /* @__PURE__ */ jsx25(Modal.Header, { title: "Edit Profile" }),
2731
2819
  /* @__PURE__ */ jsx25(Modal.Body, { children: /* @__PURE__ */ jsxs25("div", { className: "flex flex-col sm:flex-row sm:gap-10", children: [
@@ -2811,16 +2899,16 @@ var ProfileModal = ({
2811
2899
  AccountsWalletsTab,
2812
2900
  {
2813
2901
  exchanges,
2814
- socialAccounts,
2815
- email,
2902
+ socialAccounts: resolvedSocialAccounts,
2903
+ email: resolvedEmail,
2816
2904
  onDisconnectExchange,
2817
- onConnectTwitter,
2818
- onDisconnectTwitter,
2905
+ onConnectTwitter: providerActionMap.twitter.connect,
2906
+ onDisconnectTwitter: providerActionMap.twitter.disconnect,
2819
2907
  onConnectDiscord,
2820
2908
  onDisconnectDiscord,
2821
2909
  onConnectTelegram,
2822
2910
  onDisconnectTelegram,
2823
- onConnectEmail
2911
+ onConnectEmail: providerActionMap.email.connect
2824
2912
  }
2825
2913
  ) : null
2826
2914
  ] })