@avail-project/widgets 0.0.1

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 (143) hide show
  1. package/README.md +34 -0
  2. package/dist/common/components/ErrorBoundary.d.ts +44 -0
  3. package/dist/common/components/ErrorBoundary.d.ts.map +1 -0
  4. package/dist/common/components/ErrorBoundary.js +65 -0
  5. package/dist/common/hooks/useDebouncedCallback.d.ts +13 -0
  6. package/dist/common/hooks/useDebouncedCallback.d.ts.map +1 -0
  7. package/dist/common/hooks/useDebouncedCallback.js +42 -0
  8. package/dist/common/hooks/useDebouncedValue.d.ts +5 -0
  9. package/dist/common/hooks/useDebouncedValue.d.ts.map +1 -0
  10. package/dist/common/hooks/useDebouncedValue.js +15 -0
  11. package/dist/common/hooks/useInterval.d.ts +11 -0
  12. package/dist/common/hooks/useInterval.d.ts.map +1 -0
  13. package/dist/common/hooks/useInterval.js +25 -0
  14. package/dist/common/hooks/useLatest.d.ts +12 -0
  15. package/dist/common/hooks/useLatest.d.ts.map +1 -0
  16. package/dist/common/hooks/useLatest.js +19 -0
  17. package/dist/common/hooks/useNexusError.d.ts +20 -0
  18. package/dist/common/hooks/useNexusError.d.ts.map +1 -0
  19. package/dist/common/hooks/useNexusError.js +120 -0
  20. package/dist/common/hooks/usePolling.d.ts +7 -0
  21. package/dist/common/hooks/usePolling.d.ts.map +1 -0
  22. package/dist/common/hooks/usePolling.js +29 -0
  23. package/dist/common/hooks/useStableCallback.d.ts +6 -0
  24. package/dist/common/hooks/useStableCallback.d.ts.map +1 -0
  25. package/dist/common/hooks/useStableCallback.js +13 -0
  26. package/dist/common/hooks/useStopwatch.d.ts +17 -0
  27. package/dist/common/hooks/useStopwatch.d.ts.map +1 -0
  28. package/dist/common/hooks/useStopwatch.js +44 -0
  29. package/dist/common/hooks/useTransactionExecution.d.ts +62 -0
  30. package/dist/common/hooks/useTransactionExecution.d.ts.map +1 -0
  31. package/dist/common/hooks/useTransactionExecution.js +273 -0
  32. package/dist/common/hooks/useTransactionFlow.d.ts +71 -0
  33. package/dist/common/hooks/useTransactionFlow.d.ts.map +1 -0
  34. package/dist/common/hooks/useTransactionFlow.js +435 -0
  35. package/dist/common/index.d.ts +17 -0
  36. package/dist/common/index.d.ts.map +1 -0
  37. package/dist/common/index.js +16 -0
  38. package/dist/common/tx/steps.d.ts +19 -0
  39. package/dist/common/tx/steps.d.ts.map +1 -0
  40. package/dist/common/tx/steps.js +89 -0
  41. package/dist/common/tx/types.d.ts +11 -0
  42. package/dist/common/tx/types.d.ts.map +1 -0
  43. package/dist/common/tx/types.js +19 -0
  44. package/dist/common/tx/useTransactionSteps.d.ts +21 -0
  45. package/dist/common/tx/useTransactionSteps.d.ts.map +1 -0
  46. package/dist/common/tx/useTransactionSteps.js +40 -0
  47. package/dist/common/types/transaction-flow.d.ts +48 -0
  48. package/dist/common/types/transaction-flow.d.ts.map +1 -0
  49. package/dist/common/types/transaction-flow.js +2 -0
  50. package/dist/common/utils/constant.d.ts +99 -0
  51. package/dist/common/utils/constant.d.ts.map +1 -0
  52. package/dist/common/utils/constant.js +370 -0
  53. package/dist/common/utils/token-pricing.d.ts +33 -0
  54. package/dist/common/utils/token-pricing.d.ts.map +1 -0
  55. package/dist/common/utils/token-pricing.js +255 -0
  56. package/dist/common/utils/transaction-flow.d.ts +35 -0
  57. package/dist/common/utils/transaction-flow.d.ts.map +1 -0
  58. package/dist/common/utils/transaction-flow.js +65 -0
  59. package/dist/index.d.ts +5 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +2 -0
  62. package/dist/lib/utils.d.ts +4 -0
  63. package/dist/lib/utils.d.ts.map +1 -0
  64. package/dist/lib/utils.js +8 -0
  65. package/dist/nexus/NexusProvider.d.ts +50 -0
  66. package/dist/nexus/NexusProvider.d.ts.map +1 -0
  67. package/dist/nexus/NexusProvider.js +572 -0
  68. package/dist/nexus-widget/components/address-identicon.d.ts +5 -0
  69. package/dist/nexus-widget/components/address-identicon.d.ts.map +1 -0
  70. package/dist/nexus-widget/components/address-identicon.js +39 -0
  71. package/dist/nexus-widget/components/amount-input-unified.d.ts +18 -0
  72. package/dist/nexus-widget/components/amount-input-unified.d.ts.map +1 -0
  73. package/dist/nexus-widget/components/amount-input-unified.js +88 -0
  74. package/dist/nexus-widget/components/deposit-idle-form.d.ts +29 -0
  75. package/dist/nexus-widget/components/deposit-idle-form.d.ts.map +1 -0
  76. package/dist/nexus-widget/components/deposit-idle-form.js +506 -0
  77. package/dist/nexus-widget/components/nexus-widget-progress-screen.d.ts +36 -0
  78. package/dist/nexus-widget/components/nexus-widget-progress-screen.d.ts.map +1 -0
  79. package/dist/nexus-widget/components/nexus-widget-progress-screen.js +737 -0
  80. package/dist/nexus-widget/components/pay-using-selector.d.ts +9 -0
  81. package/dist/nexus-widget/components/pay-using-selector.d.ts.map +1 -0
  82. package/dist/nexus-widget/components/pay-using-selector.js +37 -0
  83. package/dist/nexus-widget/components/pay-with-sources.d.ts +11 -0
  84. package/dist/nexus-widget/components/pay-with-sources.d.ts.map +1 -0
  85. package/dist/nexus-widget/components/pay-with-sources.js +266 -0
  86. package/dist/nexus-widget/components/receive-asset-selector.d.ts +28 -0
  87. package/dist/nexus-widget/components/receive-asset-selector.d.ts.map +1 -0
  88. package/dist/nexus-widget/components/receive-asset-selector.js +1178 -0
  89. package/dist/nexus-widget/components/recipient-input.d.ts +10 -0
  90. package/dist/nexus-widget/components/recipient-input.d.ts.map +1 -0
  91. package/dist/nexus-widget/components/recipient-input.js +44 -0
  92. package/dist/nexus-widget/components/send-idle-form.d.ts +29 -0
  93. package/dist/nexus-widget/components/send-idle-form.d.ts.map +1 -0
  94. package/dist/nexus-widget/components/send-idle-form.js +548 -0
  95. package/dist/nexus-widget/components/status-alerts.d.ts +7 -0
  96. package/dist/nexus-widget/components/status-alerts.d.ts.map +1 -0
  97. package/dist/nexus-widget/components/status-alerts.js +17 -0
  98. package/dist/nexus-widget/components/swap-asset-selector.d.ts +74 -0
  99. package/dist/nexus-widget/components/swap-asset-selector.d.ts.map +1 -0
  100. package/dist/nexus-widget/components/swap-asset-selector.js +1910 -0
  101. package/dist/nexus-widget/components/swap-idle-form.d.ts +29 -0
  102. package/dist/nexus-widget/components/swap-idle-form.d.ts.map +1 -0
  103. package/dist/nexus-widget/components/swap-idle-form.js +1289 -0
  104. package/dist/nexus-widget/components/swap-intent-preview.d.ts +95 -0
  105. package/dist/nexus-widget/components/swap-intent-preview.d.ts.map +1 -0
  106. package/dist/nexus-widget/components/swap-intent-preview.js +1050 -0
  107. package/dist/nexus-widget/nexus-widget.d.ts +4 -0
  108. package/dist/nexus-widget/nexus-widget.d.ts.map +1 -0
  109. package/dist/nexus-widget/nexus-widget.js +7819 -0
  110. package/dist/nexus-widget/sdk-types.d.ts +13 -0
  111. package/dist/nexus-widget/sdk-types.d.ts.map +1 -0
  112. package/dist/nexus-widget/sdk-types.js +1 -0
  113. package/dist/nexus-widget/theme.d.ts +156 -0
  114. package/dist/nexus-widget/theme.d.ts.map +1 -0
  115. package/dist/nexus-widget/theme.js +159 -0
  116. package/dist/nexus-widget/types.d.ts +141 -0
  117. package/dist/nexus-widget/types.d.ts.map +1 -0
  118. package/dist/nexus-widget/types.js +1 -0
  119. package/dist/nexus-widget/utils/citrea-tokens.d.ts +82 -0
  120. package/dist/nexus-widget/utils/citrea-tokens.d.ts.map +1 -0
  121. package/dist/nexus-widget/utils/citrea-tokens.js +136 -0
  122. package/dist/nexus-widget/utils/deposit-source-selection.d.ts +55 -0
  123. package/dist/nexus-widget/utils/deposit-source-selection.d.ts.map +1 -0
  124. package/dist/nexus-widget/utils/deposit-source-selection.js +219 -0
  125. package/dist/swaps/components/stacked-token-icons.d.ts +15 -0
  126. package/dist/swaps/components/stacked-token-icons.d.ts.map +1 -0
  127. package/dist/swaps/components/stacked-token-icons.js +38 -0
  128. package/dist/swaps/components/step-flow.d.ts +32 -0
  129. package/dist/swaps/components/step-flow.d.ts.map +1 -0
  130. package/dist/swaps/components/step-flow.js +54 -0
  131. package/dist/swaps/components/token-icon.d.ts +11 -0
  132. package/dist/swaps/components/token-icon.d.ts.map +1 -0
  133. package/dist/swaps/components/token-icon.js +16 -0
  134. package/dist/swaps/components/transaction-progress.d.ts +43 -0
  135. package/dist/swaps/components/transaction-progress.d.ts.map +1 -0
  136. package/dist/swaps/components/transaction-progress.js +94 -0
  137. package/dist/ui/button.d.ts +11 -0
  138. package/dist/ui/button.d.ts.map +1 -0
  139. package/dist/ui/button.js +34 -0
  140. package/dist/ui/dialog.d.ts +17 -0
  141. package/dist/ui/dialog.d.ts.map +1 -0
  142. package/dist/ui/dialog.js +47 -0
  143. package/package.json +60 -0
@@ -0,0 +1,1289 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // biome-ignore-all lint: NexusWidget registry component from shadcn registry.
3
+ import Decimal from "decimal.js";
4
+ import React, { useEffect, useRef, useState } from "react";
5
+ import { createPortal } from "react-dom";
6
+ import { formatSelectedTokenBalanceLabel, formatUsdBalanceLabel, } from "./swap-asset-selector";
7
+ const tabularNums = {
8
+ fontFeatureSettings: '"tnum"',
9
+ fontVariantNumeric: "tabular-nums",
10
+ };
11
+ const brand = "var(--foreground-brand)";
12
+ /** Chevron down icon used in asset selector pills */
13
+ const ChevronDownIcon = () => (_jsx("svg", { height: "10", style: { width: "12px", height: "12px", flexShrink: 0 }, viewBox: "0 0 10 10", width: "10", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M2 3.5L5 6.5L8 3.5", fill: "none", stroke: "#848483", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.3" }) }));
14
+ const ArrowUpDownIcon = () => (_jsx("svg", { height: "12", style: { flexShrink: 0 }, viewBox: "0 0 24 24", width: "12", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M7 15L7 3M7 3L11 7M7 3L3 7M17 9L17 21M17 21L13 17M17 21L21 17", fill: "none", stroke: "#848483", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2" }) }));
15
+ /** Reusable percentage quick-select buttons row with transition wrapper */
16
+ function PercentButtons({ visible, onSelect, maxLabel = "Max", }) {
17
+ const [hoveredPct, setHoveredPct] = useState(null);
18
+ return (_jsx("div", { style: {
19
+ alignItems: "center",
20
+ backgroundColor: "#F0F3F9",
21
+ borderRadius: "6px",
22
+ boxShadow: "#2A388B0F 0px 1px 2px inset",
23
+ boxSizing: "border-box",
24
+ display: "flex",
25
+ flexShrink: 0,
26
+ gap: "2px",
27
+ padding: "2px",
28
+ opacity: visible ? 1 : 0,
29
+ visibility: visible ? "visible" : "hidden",
30
+ pointerEvents: visible ? "auto" : "none",
31
+ transition: "opacity 0.18s ease-out, visibility 0.18s ease-out",
32
+ width: "97px",
33
+ }, children: [20, 50, 100].map((pct) => {
34
+ const label = pct === 100 ? maxLabel : `${pct}%`;
35
+ const isHovered = hoveredPct === pct;
36
+ return (_jsx("button", { onClick: (e) => {
37
+ e.stopPropagation();
38
+ onSelect(pct);
39
+ }, onMouseDown: (e) => {
40
+ e.preventDefault();
41
+ }, onMouseEnter: () => setHoveredPct(pct), onMouseLeave: () => setHoveredPct(null), style: {
42
+ alignItems: "center",
43
+ backgroundColor: isHovered ? "#FFFFFF" : "transparent",
44
+ borderRadius: "4px",
45
+ boxShadow: isHovered ? "#3C286414 0px 1px 2px" : "none",
46
+ boxSizing: "border-box",
47
+ color: isHovered ? "#1F1F1F" : "#8E8E89",
48
+ cursor: "pointer",
49
+ display: "flex",
50
+ fontFamily: '"Geist", system-ui, sans-serif',
51
+ fontSize: "10px",
52
+ fontWeight: 500,
53
+ height: "18px",
54
+ justifyContent: "center",
55
+ flex: "1 1 0%",
56
+ minWidth: 0,
57
+ paddingInline: "3px",
58
+ border: "none",
59
+ transition: "all 0.15s ease-out",
60
+ }, tabIndex: -1, type: "button", children: label }, pct));
61
+ }) }));
62
+ }
63
+ function UnifiedTokenLogoBadge({ token, size = 24, }) {
64
+ const [popover, setPopover] = useState(null);
65
+ const triggerRef = useRef(null);
66
+ const sources = token.sourceTokens ?? [];
67
+ const chainCount = new Set(sources
68
+ .map((source) => source.chainId ?? source.chainName)
69
+ .filter(Boolean)).size || sources.length;
70
+ const showPopover = () => {
71
+ const rect = triggerRef.current?.getBoundingClientRect();
72
+ if (!rect || typeof window === "undefined")
73
+ return;
74
+ const width = 250;
75
+ const maxHeight = 260;
76
+ const viewportPadding = 8;
77
+ const left = Math.min(Math.max(viewportPadding, rect.right - width), window.innerWidth - width - viewportPadding);
78
+ const belowTop = rect.bottom + 8;
79
+ const top = belowTop + maxHeight > window.innerHeight
80
+ ? Math.max(viewportPadding, rect.top - maxHeight - 8)
81
+ : belowTop;
82
+ setPopover({ left, top, width, maxHeight });
83
+ };
84
+ return (_jsxs("div", { onMouseEnter: showPopover, onMouseLeave: () => setPopover(null), ref: triggerRef, style: {
85
+ boxSizing: "border-box",
86
+ flexShrink: 0,
87
+ height: `${size}px`,
88
+ position: "relative",
89
+ width: `${size}px`,
90
+ }, children: [_jsx(LogoCircle, { alt: token.symbol, fontSize: Math.max(9, Math.floor(size / 2)), label: token.symbol, size: size, src: token.logo }), chainCount > 0 && (_jsx("div", { style: {
91
+ alignItems: "center",
92
+ backgroundColor: brand,
93
+ border: "1px solid #FFFFFE",
94
+ borderRadius: "999px",
95
+ bottom: -3,
96
+ boxSizing: "border-box",
97
+ color: "#FFFFFE",
98
+ display: "flex",
99
+ fontFamily: '"Geist", system-ui, sans-serif',
100
+ fontSize: "8px",
101
+ fontWeight: 700,
102
+ height: "12px",
103
+ justifyContent: "center",
104
+ lineHeight: "14px",
105
+ minWidth: "12px",
106
+ paddingInline: chainCount > 9 ? "3px" : 0,
107
+ position: "absolute",
108
+ right: -3,
109
+ }, children: chainCount })), popover &&
110
+ sources.length > 0 &&
111
+ typeof document !== "undefined" &&
112
+ createPortal(_jsxs("div", { style: {
113
+ backgroundColor: "#FFFFFE",
114
+ border: "1px solid #E8E8E7",
115
+ borderRadius: "10px",
116
+ boxShadow: "0 10px 28px rgba(22, 22, 21, 0.14)",
117
+ boxSizing: "border-box",
118
+ ...tabularNums,
119
+ left: popover.left,
120
+ maxHeight: popover.maxHeight,
121
+ overflowY: "auto",
122
+ padding: "12px",
123
+ pointerEvents: "none",
124
+ position: "fixed",
125
+ top: popover.top,
126
+ width: popover.width,
127
+ zIndex: 2147483647,
128
+ }, children: [_jsxs("div", { style: {
129
+ alignItems: "center",
130
+ display: "flex",
131
+ justifyContent: "space-between",
132
+ marginBottom: "8px",
133
+ }, children: [_jsxs("span", { style: {
134
+ color: "#848483",
135
+ fontFamily: '"Geist", system-ui, sans-serif',
136
+ fontSize: "11px",
137
+ fontWeight: 700,
138
+ letterSpacing: "0.08em",
139
+ lineHeight: "16px",
140
+ textTransform: "uppercase",
141
+ }, children: ["Unified \u00B7 ", chainCount, " ", chainCount === 1 ? "Chain" : "Chains"] }), _jsxs("span", { style: {
142
+ color: "#161615",
143
+ fontFamily: '"Geist", system-ui, sans-serif',
144
+ fontSize: "15px",
145
+ fontWeight: 700,
146
+ lineHeight: "16px",
147
+ }, children: ["\u2248 ", formatUsdBalanceLabel(token.balanceInFiat)] })] }), _jsx("div", { style: {
148
+ display: "flex",
149
+ flexDirection: "column",
150
+ gap: "8px",
151
+ }, children: sources.map((source) => (_jsxs("div", { style: {
152
+ alignItems: "center",
153
+ display: "flex",
154
+ gap: "8px",
155
+ justifyContent: "space-between",
156
+ }, children: [_jsxs("div", { style: {
157
+ alignItems: "center",
158
+ display: "flex",
159
+ gap: "8px",
160
+ minWidth: 0,
161
+ }, children: [_jsx(LogoCircle, { alt: source.chainName, fontSize: 7, label: source.chainName, size: 15, src: source.chainLogo }), _jsx("span", { style: {
162
+ color: "#161615",
163
+ fontFamily: '"Geist", system-ui, sans-serif',
164
+ fontSize: "15px",
165
+ fontWeight: 500,
166
+ lineHeight: "20px",
167
+ overflow: "hidden",
168
+ textOverflow: "ellipsis",
169
+ whiteSpace: "nowrap",
170
+ }, children: source.chainName || "Unknown chain" })] }), _jsx("span", { style: {
171
+ color: "#161615",
172
+ fontFamily: '"Geist", system-ui, sans-serif',
173
+ fontSize: "15px",
174
+ fontWeight: 600,
175
+ lineHeight: "20px",
176
+ }, children: formatAmountInputDisplay(source.balance || "0") })] }, `${source.chainId}-${source.contractAddress}`))) })] }), document.body)] }));
177
+ }
178
+ function PercentHoverButton({ label, onClick, tabIndex, }) {
179
+ const [hover, setHover] = useState(false);
180
+ const [active, setActive] = useState(false);
181
+ const handledPointerDownRef = useRef(false);
182
+ const pointerResetTimerRef = useRef(null);
183
+ useEffect(() => {
184
+ return () => {
185
+ if (pointerResetTimerRef.current) {
186
+ clearTimeout(pointerResetTimerRef.current);
187
+ }
188
+ };
189
+ }, []);
190
+ const isHighlighted = hover || active;
191
+ return (_jsx("button", { onClick: () => {
192
+ if (handledPointerDownRef.current) {
193
+ if (pointerResetTimerRef.current) {
194
+ clearTimeout(pointerResetTimerRef.current);
195
+ pointerResetTimerRef.current = null;
196
+ }
197
+ handledPointerDownRef.current = false;
198
+ return;
199
+ }
200
+ onClick();
201
+ }, onMouseDown: (event) => {
202
+ event.preventDefault();
203
+ setActive(true);
204
+ }, onMouseEnter: () => setHover(true), onMouseLeave: () => {
205
+ setHover(false);
206
+ setActive(false);
207
+ }, onMouseUp: () => setActive(false), onPointerDown: (event) => {
208
+ if (event.pointerType === "mouse")
209
+ return;
210
+ event.preventDefault();
211
+ if (pointerResetTimerRef.current) {
212
+ clearTimeout(pointerResetTimerRef.current);
213
+ }
214
+ handledPointerDownRef.current = true;
215
+ setActive(true);
216
+ onClick();
217
+ }, onPointerUp: () => {
218
+ setActive(false);
219
+ if (handledPointerDownRef.current) {
220
+ pointerResetTimerRef.current = setTimeout(() => {
221
+ handledPointerDownRef.current = false;
222
+ pointerResetTimerRef.current = null;
223
+ }, 350);
224
+ }
225
+ }, style: {
226
+ alignItems: "center",
227
+ backgroundColor: isHighlighted ? "#E8F0FF" : "#F4F4F3",
228
+ borderRadius: "6px",
229
+ boxSizing: "border-box",
230
+ display: "flex",
231
+ flex: "1 1 0%",
232
+ justifyContent: "center",
233
+ paddingBlock: "3px",
234
+ paddingInline: "6px",
235
+ border: "none",
236
+ cursor: "pointer",
237
+ transition: "background-color 0.2s ease-out",
238
+ }, tabIndex: tabIndex, children: _jsx("div", { style: {
239
+ boxSizing: "border-box",
240
+ color: isHighlighted ? brand : "#363635",
241
+ fontFamily: '"Geist", system-ui, sans-serif',
242
+ fontSize: "11px",
243
+ fontWeight: 500,
244
+ lineHeight: "16px",
245
+ transition: "color 0.2s ease-out",
246
+ ...(label === "MAX" ? { letterSpacing: "0.02em" } : {}),
247
+ }, children: label }) }));
248
+ }
249
+ function SkeletonBar({ width, height, borderRadius = "8px", }) {
250
+ return (_jsx("div", { "aria-hidden": "true", style: {
251
+ background: "linear-gradient(90deg, #F0F0EF 0%, #E6EEFF 48%, #F0F0EF 100%)",
252
+ backgroundSize: "200% 100%",
253
+ borderRadius,
254
+ height,
255
+ maxWidth: "100%",
256
+ width,
257
+ animation: "nexusSwapSkeletonShimmer 1.2s ease-in-out infinite",
258
+ } }));
259
+ }
260
+ function LogoCircle({ src, alt, label, size, fontSize, outline, style, }) {
261
+ const [failed, setFailed] = useState(!src);
262
+ useEffect(() => {
263
+ setFailed(!src);
264
+ }, [src]);
265
+ const fallbackLabel = (label || alt || "?").trim().slice(0, 1).toUpperCase();
266
+ if (!failed && src) {
267
+ return (_jsx("img", { alt: alt || label || "", onError: () => setFailed(true), src: src, style: {
268
+ backgroundColor: "#FFFFFE",
269
+ borderRadius: "999px",
270
+ height: `${size}px`,
271
+ objectFit: "cover",
272
+ outline,
273
+ width: `${size}px`,
274
+ ...style,
275
+ } }));
276
+ }
277
+ return (_jsx("div", { "aria-label": alt || label || "Token", role: "img", style: {
278
+ alignItems: "center",
279
+ backgroundColor: "#E8F0FF",
280
+ borderRadius: "999px",
281
+ color: brand,
282
+ display: "flex",
283
+ fontFamily: '"Geist", system-ui, sans-serif',
284
+ fontSize: `${fontSize}px`,
285
+ fontWeight: 700,
286
+ height: `${size}px`,
287
+ justifyContent: "center",
288
+ lineHeight: `${size}px`,
289
+ outline,
290
+ width: `${size}px`,
291
+ ...style,
292
+ }, children: fallbackLabel || "?" }));
293
+ }
294
+ const sameAddress = (a, b) => Boolean(a && b && a.toLowerCase() === b.toLowerCase());
295
+ const formatShortAddress = (address) => {
296
+ if (!address)
297
+ return "";
298
+ return address.length > 12
299
+ ? `${address.slice(0, 6)}…${address.slice(-4)}`
300
+ : address;
301
+ };
302
+ const formatTokenBalanceLabel = formatSelectedTokenBalanceLabel;
303
+ const parseDecimal = (value) => {
304
+ if (value === null || value === undefined || value === "")
305
+ return undefined;
306
+ if (Decimal.isDecimal(value))
307
+ return value;
308
+ const cleaned = String(value).replace(/[^0-9.-]/g, "");
309
+ if (!cleaned || cleaned === "-" || cleaned === "." || cleaned === "-.") {
310
+ return undefined;
311
+ }
312
+ try {
313
+ const parsed = new Decimal(cleaned);
314
+ return parsed.isFinite() ? parsed : undefined;
315
+ }
316
+ catch {
317
+ return undefined;
318
+ }
319
+ };
320
+ const formatUsdValue = (value) => value.gt(0) && value.lt(0.01) ? "<0.01" : value.toDecimalPlaces(2).toFixed(2);
321
+ const MAX_AMOUNT_DISPLAY_DECIMALS = 8;
322
+ const getTokenInputDecimals = (token) => {
323
+ const decimals = Number(token?.decimals);
324
+ return Number.isFinite(decimals) && decimals >= 0 ? Math.floor(decimals) : 18;
325
+ };
326
+ const formatAmountInputDisplay = (value) => {
327
+ if (!value)
328
+ return "";
329
+ try {
330
+ return new Decimal(value)
331
+ .toDecimalPlaces(MAX_AMOUNT_DISPLAY_DECIMALS, Decimal.ROUND_DOWN)
332
+ .toFixed();
333
+ }
334
+ catch {
335
+ return value;
336
+ }
337
+ };
338
+ export function SwapIdleForm({ amount, receiveQuoteAmount, receiveQuoteUsd, isReceiveAmountLoading = false, isReceiveUsdLoading = false, sourceRouteStatus, sourceRouteMessage, onAmountChange, fromTokens, toToken, totalBalance, usdValue, onOpenSourcePicker, onOpenDestPicker, onOpenRecipientPicker, recipientAddress, defaultRecipientAddress, swapType, onUpdateTokens, isAmountReadOnly = false, isDestinationPickerDisabled = false, hideDestinationTokenDropdownIcon = false, isSourcePickerDisabled = false, }) {
339
+ const [focusedPanel, setFocusedPanel] = useState(null);
340
+ const [focusedRow, setFocusedRow] = useState(null);
341
+ const [tooltip, setTooltip] = useState(null);
342
+ const [tooltipTriggerRect, setTooltipTriggerRect] = useState(null);
343
+ const sourceListRef = useRef(null);
344
+ const sourceRowRefs = useRef({});
345
+ const sourceInputRefs = useRef({});
346
+ const previousSourceCountRef = useRef(fromTokens.length);
347
+ const prevTokensRef = useRef(fromTokens);
348
+ const [autofocusIndex, setAutofocusIndex] = useState(null);
349
+ useEffect(() => {
350
+ const prev = prevTokensRef.current;
351
+ if (fromTokens.length > prev.length) {
352
+ setAutofocusIndex(fromTokens.length - 1);
353
+ }
354
+ else if (fromTokens.length === prev.length) {
355
+ for (let i = 0; i < fromTokens.length; i++) {
356
+ const p = prev[i];
357
+ const c = fromTokens[i];
358
+ if (p &&
359
+ c &&
360
+ (p.contractAddress !== c.contractAddress ||
361
+ p.chainId !== c.chainId) &&
362
+ !c.userAmount) {
363
+ setAutofocusIndex(i);
364
+ break;
365
+ }
366
+ }
367
+ }
368
+ prevTokensRef.current = fromTokens;
369
+ }, [fromTokens]);
370
+ useEffect(() => {
371
+ const previousSourceCount = previousSourceCountRef.current;
372
+ if (fromTokens.length > previousSourceCount && previousSourceCount > 0) {
373
+ const newIndex = fromTokens.length - 1;
374
+ requestAnimationFrame(() => {
375
+ const input = sourceInputRefs.current[newIndex];
376
+ if (input) {
377
+ input.focus();
378
+ input.select();
379
+ }
380
+ const container = sourceListRef.current;
381
+ const row = sourceRowRefs.current[newIndex];
382
+ if (!container ||
383
+ !row ||
384
+ container.scrollHeight <= container.clientHeight) {
385
+ return;
386
+ }
387
+ const containerRect = container.getBoundingClientRect();
388
+ const rowRect = row.getBoundingClientRect();
389
+ const nextTop = rowRect.top - containerRect.top + container.scrollTop - 8;
390
+ container.scrollTo({
391
+ behavior: "smooth",
392
+ top: Math.max(0, nextTop),
393
+ });
394
+ });
395
+ }
396
+ previousSourceCountRef.current = fromTokens.length;
397
+ }, [fromTokens.length]);
398
+ const sanitizeInput = (raw, maxDecimals = 18) => {
399
+ let next = raw.replaceAll(/[^0-9.]/g, "");
400
+ const parts = next.split(".");
401
+ if (parts.length > 2)
402
+ next = parts[0] + "." + parts.slice(1).join("");
403
+ const [integerPart, decimalPart] = next.split(".");
404
+ if (decimalPart !== undefined) {
405
+ next = `${integerPart}.${decimalPart.slice(0, Math.max(0, maxDecimals))}`;
406
+ }
407
+ if (next === ".")
408
+ next = "0.";
409
+ // Strip leading zeros
410
+ if (next.length > 1 && next.startsWith("0") && next[1] !== ".") {
411
+ next = next.replace(/^0+/, "");
412
+ if (next === "")
413
+ next = "0";
414
+ if (next.startsWith("."))
415
+ next = "0" + next;
416
+ }
417
+ return next;
418
+ };
419
+ const handleBlurAmount = (index) => {
420
+ if (!onUpdateTokens)
421
+ return;
422
+ const token = fromTokens[index];
423
+ if (!token || !token.userAmount)
424
+ return;
425
+ if (token.userAmount.includes(".")) {
426
+ const stripped = token.userAmount.replace(/0+$/, "").replace(/\.$/, "");
427
+ if (stripped !== token.userAmount) {
428
+ const next = [...fromTokens];
429
+ next[index] = { ...token, userAmount: stripped };
430
+ onUpdateTokens(next);
431
+ }
432
+ }
433
+ };
434
+ const handleSendInput = (e) => {
435
+ if (isAmountReadOnly)
436
+ return;
437
+ const token = fromTokens.length === 1 ? fromTokens[0] : undefined;
438
+ onAmountChange(sanitizeInput(e.target.value, getTokenInputDecimals(token)), "send");
439
+ };
440
+ const handleTokenAmountChange = (index, val) => {
441
+ if (isAmountReadOnly)
442
+ return;
443
+ if (!onUpdateTokens)
444
+ return;
445
+ const token = fromTokens[index];
446
+ if (!token)
447
+ return;
448
+ let sanitized = sanitizeInput(val, token.userAmountMode === "usd"
449
+ ? MAX_AMOUNT_DISPLAY_DECIMALS
450
+ : getTokenInputDecimals(token));
451
+ const next = [...fromTokens];
452
+ next[index] = { ...token, userAmount: sanitized };
453
+ onUpdateTokens(next);
454
+ // Also update total amount for backwards compatibility if needed
455
+ const total = next.reduce((sum, t) => sum + Number(t.userAmount || 0), 0);
456
+ onAmountChange(total > 0 ? String(total) : "", "send");
457
+ };
458
+ const handleToggleMode = (index) => {
459
+ if (isAmountReadOnly)
460
+ return;
461
+ if (!onUpdateTokens)
462
+ return;
463
+ const token = fromTokens[index];
464
+ if (!token)
465
+ return;
466
+ const tokenBalance = Number(String(token.balance).replace(/[^0-9.]/g, "")) || 0;
467
+ const fiatBalance = Number(String(token.balanceInFiat).replace(/[^0-9.]/g, "")) || 0;
468
+ const price = tokenBalance > 0 ? fiatBalance / tokenBalance : 0;
469
+ if (price === 0)
470
+ return;
471
+ const currentVal = Number(token.userAmount || 0);
472
+ const next = [...fromTokens];
473
+ if (token.userAmountMode === "usd") {
474
+ const newTokenVal = currentVal > 0 ? (currentVal / price).toString() : "";
475
+ next[index] = {
476
+ ...token,
477
+ userAmountMode: "token",
478
+ userAmount: newTokenVal ? newTokenVal.substring(0, 10) : "",
479
+ };
480
+ }
481
+ else {
482
+ const newUsdVal = currentVal > 0 ? (currentVal * price).toFixed(2) : "";
483
+ next[index] = { ...token, userAmountMode: "usd", userAmount: newUsdVal };
484
+ }
485
+ onUpdateTokens(next);
486
+ const total = getTokenAmountTotal(next);
487
+ onAmountChange(total > 0 ? String(total) : "", "send");
488
+ };
489
+ const getSourceUsdValue = React.useCallback((token) => {
490
+ if (!token || !token.userAmount)
491
+ return 0;
492
+ const quotedUsd = parseDecimal(token.userAmountUsd);
493
+ if (quotedUsd && quotedUsd.gte(0))
494
+ return quotedUsd.toNumber();
495
+ const tokenBalance = Number(String(token.balance).replace(/[^0-9.]/g, "")) || 0;
496
+ const fiatBalance = Number(String(token.balanceInFiat).replace(/[^0-9.]/g, "")) || 0;
497
+ const price = tokenBalance > 0 ? fiatBalance / tokenBalance : 0;
498
+ const amountNumber = Number(token.userAmount || 0);
499
+ if (!Number.isFinite(amountNumber))
500
+ return 0;
501
+ if (token.userAmountMode === "usd")
502
+ return amountNumber;
503
+ return amountNumber * price;
504
+ }, []);
505
+ const totalUsd = React.useMemo(() => {
506
+ return fromTokens.reduce((sum, token) => sum + getSourceUsdValue(token), 0);
507
+ }, [fromTokens, getSourceUsdValue]);
508
+ const hasSourceOverflow = fromTokens.length > 3;
509
+ const [isSourceListAtBottom, setIsSourceListAtBottom] = useState(false);
510
+ const updateSourceListScrollState = React.useCallback(() => {
511
+ const element = sourceListRef.current;
512
+ if (!element || !hasSourceOverflow) {
513
+ setIsSourceListAtBottom(false);
514
+ return;
515
+ }
516
+ const distanceFromBottom = element.scrollHeight - element.scrollTop - element.clientHeight;
517
+ setIsSourceListAtBottom(distanceFromBottom <= 2);
518
+ }, [hasSourceOverflow]);
519
+ useEffect(() => {
520
+ requestAnimationFrame(updateSourceListScrollState);
521
+ }, [fromTokens.length, updateSourceListScrollState]);
522
+ const sourceRowsToRender = fromTokens.length > 0
523
+ ? fromTokens.map((token, index) => ({ token, index, position: index }))
524
+ : [{ token: null, index: 0, position: 0 }];
525
+ const isExactIn = swapType === "exactIn";
526
+ const showSourceRouteSkeleton = !isExactIn && sourceRouteStatus === "loading";
527
+ const sourceRouteHelper = sourceRouteStatus === "insufficient" ? sourceRouteMessage : undefined;
528
+ const receiveBalanceLabel = formatTokenBalanceLabel(toToken);
529
+ const getReceiveUsdRate = () => {
530
+ const quoteTokenAmount = parseDecimal(receiveQuoteAmount);
531
+ const quoteUsdAmount = parseDecimal(receiveQuoteUsd);
532
+ if (quoteTokenAmount?.gt(0) && quoteUsdAmount?.gt(0)) {
533
+ return quoteUsdAmount.div(quoteTokenAmount);
534
+ }
535
+ const tokenBalance = parseDecimal(toToken?.balance);
536
+ const fiatBalance = parseDecimal(toToken?.balanceInFiat);
537
+ if (tokenBalance?.gt(0) && fiatBalance?.gt(0)) {
538
+ return fiatBalance.div(tokenBalance);
539
+ }
540
+ return undefined;
541
+ };
542
+ const receiveInputValue = isExactIn ? (receiveQuoteAmount ?? "") : amount;
543
+ const receiveDisplayValue = focusedPanel === "receive"
544
+ ? receiveInputValue
545
+ : formatAmountInputDisplay(receiveInputValue);
546
+ const receiveAmountTextColor = (!isExactIn && amount) || (isExactIn && receiveQuoteAmount)
547
+ ? "#161615"
548
+ : "#9E9E9C";
549
+ const receiveUsdRate = getReceiveUsdRate();
550
+ const receiveTokenAmount = parseDecimal(receiveInputValue);
551
+ const receiveUsdAmount = receiveQuoteUsd
552
+ ? parseDecimal(receiveQuoteUsd)
553
+ : receiveTokenAmount && receiveUsdRate
554
+ ? receiveTokenAmount.mul(receiveUsdRate)
555
+ : undefined;
556
+ const receiveAltValue = `≈ $${receiveUsdAmount ? formatUsdValue(receiveUsdAmount) : "0.00"}`;
557
+ const isDefaultRecipient = sameAddress(recipientAddress, defaultRecipientAddress);
558
+ const recipientColor = recipientAddress
559
+ ? isDefaultRecipient
560
+ ? brand
561
+ : "#B7791F"
562
+ : "#848483";
563
+ const getTokenAmountTotal = (tokens) => tokens.reduce((sum, item) => sum + Number(item.userAmount || 0), 0);
564
+ const handleSendPercentForToken = (index, pct, token) => {
565
+ if (isAmountReadOnly)
566
+ return;
567
+ if (!token.balance || !onUpdateTokens)
568
+ return;
569
+ let finalVal = "";
570
+ const isUsdMode = token.userAmountMode === "usd";
571
+ if (isUsdMode) {
572
+ const fiatBalStr = String(token.balanceInFiat || "0");
573
+ const fiatBalance = parseDecimal(fiatBalStr);
574
+ if (!fiatBalance)
575
+ return;
576
+ if (pct === 100) {
577
+ finalVal = fiatBalance
578
+ .toDecimalPlaces(MAX_AMOUNT_DISPLAY_DECIMALS, Decimal.ROUND_DOWN)
579
+ .toFixed();
580
+ }
581
+ else {
582
+ finalVal = fiatBalance
583
+ .mul(pct)
584
+ .div(100)
585
+ .toDecimalPlaces(MAX_AMOUNT_DISPLAY_DECIMALS, Decimal.ROUND_DOWN)
586
+ .toFixed();
587
+ }
588
+ }
589
+ else {
590
+ const balanceStr = String(token.balance || "0");
591
+ const tokenBalance = parseDecimal(balanceStr);
592
+ if (!tokenBalance)
593
+ return;
594
+ const tokenDecimals = getTokenInputDecimals(token);
595
+ if (pct === 100) {
596
+ finalVal = tokenBalance
597
+ .toDecimalPlaces(tokenDecimals, Decimal.ROUND_DOWN)
598
+ .toFixed();
599
+ }
600
+ else {
601
+ finalVal = tokenBalance
602
+ .mul(pct)
603
+ .div(100)
604
+ .toDecimalPlaces(tokenDecimals, Decimal.ROUND_DOWN)
605
+ .toFixed();
606
+ }
607
+ }
608
+ const next = [...fromTokens];
609
+ next[index] = {
610
+ ...next[index],
611
+ userAmount: finalVal,
612
+ userAmountMode: isUsdMode ? "usd" : "token",
613
+ };
614
+ onUpdateTokens(next);
615
+ const total = getTokenAmountTotal(next);
616
+ onAmountChange(total > 0 ? String(total) : "", "send");
617
+ };
618
+ const handleSendPercent = (pct) => {
619
+ if (isAmountReadOnly)
620
+ return;
621
+ if (!totalBalance)
622
+ return;
623
+ const bal = parseFloat(totalBalance.replace(/[^0-9.]/g, ""));
624
+ if (isNaN(bal))
625
+ return;
626
+ const val = bal * (pct / 100);
627
+ // If there's only one token, or no tokens, update the main amount
628
+ if (fromTokens.length <= 1) {
629
+ if (fromTokens.length === 1 && onUpdateTokens) {
630
+ handleSendPercentForToken(0, pct, fromTokens[0]);
631
+ return;
632
+ }
633
+ onAmountChange(val.toFixed(6).replace(/\.?0+$/, ""), "send");
634
+ }
635
+ };
636
+ return (_jsxs("div", { style: {
637
+ display: "flex",
638
+ flexDirection: "column",
639
+ gap: "9px",
640
+ width: "100%",
641
+ }, children: [(isReceiveAmountLoading || isReceiveUsdLoading || sourceRouteStatus) && (_jsx("style", { children: `@keyframes nexusSwapSkeletonShimmer {
642
+ 0% { background-position: 100% 0; opacity: 0.72; }
643
+ 50% { opacity: 1; }
644
+ 100% { background-position: -100% 0; opacity: 0.72; }
645
+ }` })), _jsxs("div", { className: "nexus-focus-container", style: {
646
+ alignItems: "center",
647
+ backgroundColor: "#FFFFFE",
648
+ borderColor: "#E8E8E7",
649
+ borderRadius: "9px",
650
+ borderStyle: "solid",
651
+ borderWidth: "1px",
652
+ boxShadow: "#1616150A 0px 1px 2px",
653
+ boxSizing: "border-box",
654
+ display: "flex",
655
+ flexDirection: "column",
656
+ fontVariantNumeric: "tabular-nums",
657
+ gap: "6px",
658
+ justifyContent: "center",
659
+ paddingBlock: "9px",
660
+ paddingInline: "9px",
661
+ width: "100%",
662
+ }, children: [_jsxs("div", { style: {
663
+ alignItems: "center",
664
+ alignSelf: "stretch",
665
+ boxSizing: "border-box",
666
+ display: "flex",
667
+ justifyContent: "space-between",
668
+ width: "100%",
669
+ }, children: [_jsx("div", { style: {
670
+ boxSizing: "border-box",
671
+ color: "#848483",
672
+ fontFamily: '"Geist", system-ui, sans-serif',
673
+ fontSize: "12px",
674
+ fontWeight: 500,
675
+ letterSpacing: "0.08em",
676
+ lineHeight: "18px",
677
+ textTransform: "uppercase",
678
+ }, children: "Send" }), _jsxs("button", { disabled: fromTokens.length === 0 || isSourcePickerDisabled, onClick: () => onOpenSourcePicker(), style: {
679
+ alignItems: "center",
680
+ background: "transparent",
681
+ border: "none",
682
+ borderRadius: "6px",
683
+ display: "flex",
684
+ gap: "4px",
685
+ padding: "2px 0",
686
+ color: fromTokens.length > 0 && !isSourcePickerDisabled
687
+ ? brand
688
+ : "#A8A8A6",
689
+ cursor: fromTokens.length > 0 && !isSourcePickerDisabled
690
+ ? "pointer"
691
+ : "not-allowed",
692
+ fontFamily: '"Geist", system-ui, sans-serif',
693
+ fontSize: "12px",
694
+ fontWeight: 500,
695
+ lineHeight: "18px",
696
+ opacity: fromTokens.length > 0 && !isSourcePickerDisabled ? 1 : 0.75,
697
+ }, type: "button", children: [_jsx("span", { "aria-hidden": "true", style: {
698
+ color: "currentColor",
699
+ fontSize: "14px",
700
+ lineHeight: "14px",
701
+ }, children: "+" }), "Add more assets"] })] }), _jsx("div", { onScroll: updateSourceListScrollState, ref: sourceListRef, style: {
702
+ alignSelf: "stretch",
703
+ boxSizing: "border-box",
704
+ display: "flex",
705
+ flexDirection: "column",
706
+ gap: "9px",
707
+ maxHeight: hasSourceOverflow ? "178px" : undefined,
708
+ overflowX: hasSourceOverflow ? "hidden" : undefined,
709
+ overflowY: hasSourceOverflow ? "auto" : undefined,
710
+ paddingRight: hasSourceOverflow ? "4px" : undefined,
711
+ overscrollBehavior: hasSourceOverflow ? "contain" : undefined,
712
+ transition: "max-height 0.28s ease, padding-right 0.2s ease, opacity 0.2s ease",
713
+ width: "100%",
714
+ }, children: sourceRowsToRender.map(({ token, index, position }) => {
715
+ const showTooltipBelow = position === 0;
716
+ return (_jsxs("div", { ref: (element) => {
717
+ sourceRowRefs.current[index] = element;
718
+ }, style: {
719
+ display: "flex",
720
+ flexDirection: "column",
721
+ gap: "5px",
722
+ opacity: 1,
723
+ position: "relative",
724
+ transform: "translateY(0)",
725
+ transition: "opacity 0.18s ease, transform 0.18s ease",
726
+ zIndex: tooltip === `asset-send-${index}` ? 1000 : 1,
727
+ }, children: [_jsxs("div", { style: {
728
+ alignItems: "center",
729
+ alignSelf: "stretch",
730
+ boxSizing: "border-box",
731
+ display: "flex",
732
+ gap: "7px",
733
+ justifyContent: "space-between",
734
+ width: "100%",
735
+ }, children: [_jsx("div", { style: {
736
+ display: "flex",
737
+ alignItems: "center",
738
+ flex: 1,
739
+ minWidth: 0,
740
+ }, children: showSourceRouteSkeleton ? (_jsx(SkeletonBar, { height: "24px", width: "46%" })) : (_jsxs(_Fragment, { children: [token?.userAmountMode === "usd" && (_jsx("span", { style: {
741
+ color: (token
742
+ ? Boolean(token.userAmount)
743
+ : Boolean(isExactIn && amount))
744
+ ? "#161615"
745
+ : "#9E9E9C",
746
+ fontFamily: '"Delight-Medium", "Delight", system-ui, sans-serif',
747
+ fontSize: "29px",
748
+ fontWeight: 500,
749
+ lineHeight: "34px",
750
+ marginRight: "4px",
751
+ }, children: "$" })), _jsx("input", { "aria-readonly": isAmountReadOnly, onBlur: () => {
752
+ if (token)
753
+ handleBlurAmount(index);
754
+ setFocusedRow(null);
755
+ }, onChange: (e) => {
756
+ if (token)
757
+ handleTokenAmountChange(index, e.target.value);
758
+ else
759
+ handleSendInput(e);
760
+ }, onFocus: () => setFocusedRow(index), placeholder: "0", ref: (element) => {
761
+ sourceInputRefs.current[index] = element;
762
+ }, style: {
763
+ boxSizing: "border-box",
764
+ color: (token
765
+ ? Boolean(token.userAmount)
766
+ : Boolean(isExactIn && amount))
767
+ ? "#161615"
768
+ : "#9E9E9C",
769
+ cursor: isAmountReadOnly ? "default" : "text",
770
+ fontFamily: '"Delight-Medium", "Delight", system-ui, sans-serif',
771
+ fontSize: "29px",
772
+ fontWeight: 500,
773
+ lineHeight: "34px",
774
+ background: "transparent",
775
+ border: "none",
776
+ outline: "none",
777
+ padding: 0,
778
+ width: "100%",
779
+ minWidth: 0,
780
+ }, readOnly: isAmountReadOnly, type: "text", value: token
781
+ ? focusedRow === index
782
+ ? token.userAmount || ""
783
+ : formatAmountInputDisplay(token.userAmount || "")
784
+ : isExactIn
785
+ ? focusedRow === index
786
+ ? amount
787
+ : formatAmountInputDisplay(amount)
788
+ : "" })] })) }), _jsxs("div", { style: {
789
+ display: "flex",
790
+ gap: "7px",
791
+ alignItems: "center",
792
+ }, children: [showSourceRouteSkeleton ? (_jsx("div", { style: {
793
+ alignItems: "center",
794
+ display: "flex",
795
+ flexShrink: 0,
796
+ height: "25px",
797
+ width: "90px",
798
+ }, children: _jsx(SkeletonBar, { borderRadius: "999px", height: "23px", width: "100%" }) })) : (_jsxs("button", { disabled: isSourcePickerDisabled, onClick: () => onOpenSourcePicker(index), style: {
799
+ alignItems: "center",
800
+ backgroundColor: "#FFFFFE",
801
+ borderColor: token ? "#E8E8E7" : "#C8C8C7",
802
+ borderRadius: "999px",
803
+ borderStyle: token ? "solid" : "dashed",
804
+ borderWidth: "1px",
805
+ boxShadow: token ? "#1616150A 0px 1px 2px" : "none",
806
+ boxSizing: "border-box",
807
+ display: "flex",
808
+ gap: "6px",
809
+ paddingBottom: "3px",
810
+ paddingLeft: token ? "3px" : "7px",
811
+ paddingRight: "8px",
812
+ paddingTop: "3px",
813
+ cursor: isSourcePickerDisabled
814
+ ? "not-allowed"
815
+ : "pointer",
816
+ flexShrink: 0,
817
+ opacity: isSourcePickerDisabled ? 0.72 : 1,
818
+ }, children: [token ? (token.isUnified ? (_jsx(UnifiedTokenLogoBadge, { size: 20, token: token })) : (_jsxs("div", { style: {
819
+ boxSizing: "border-box",
820
+ flexShrink: 0,
821
+ height: "20px",
822
+ position: "relative",
823
+ width: "20px",
824
+ }, children: [_jsx(LogoCircle, { alt: token.symbol, fontSize: 10, label: token.symbol, size: 20, src: token.logo }), token.chainLogo && (_jsx(LogoCircle, { alt: token.chainName, fontSize: 5, label: token.chainName, outline: "1px solid #FFFFFE", size: 10, src: token.chainLogo, style: {
825
+ bottom: -2,
826
+ position: "absolute",
827
+ right: -2,
828
+ } }))] }))) : (_jsx("div", { style: {
829
+ borderColor: "#C8C8C7",
830
+ borderRadius: "999px",
831
+ borderStyle: "dashed",
832
+ borderWidth: "1.5px",
833
+ boxSizing: "border-box",
834
+ flexShrink: 0,
835
+ height: "18px",
836
+ width: "18px",
837
+ } })), _jsx("div", { style: {
838
+ boxSizing: "border-box",
839
+ color: "#161615",
840
+ fontFamily: '"Geist", system-ui, sans-serif',
841
+ fontSize: token ? "12px" : "14px",
842
+ fontWeight: 500,
843
+ lineHeight: token ? "16px" : "20px",
844
+ }, children: token ? token.symbol : "Assets" }), _jsx(ChevronDownIcon, {})] })), token && fromTokens.length > 1 && (_jsx("button", { onClick: () => {
845
+ if (!onUpdateTokens)
846
+ return;
847
+ const next = [...fromTokens];
848
+ next.splice(index, 1);
849
+ onUpdateTokens(next);
850
+ const total = getTokenAmountTotal(next);
851
+ onAmountChange(total > 0 ? String(total) : "", "send");
852
+ }, style: {
853
+ width: "18px",
854
+ height: "18px",
855
+ borderRadius: "999px",
856
+ backgroundColor: "#F0F0EF",
857
+ border: "none",
858
+ display: "flex",
859
+ alignItems: "center",
860
+ justifyContent: "center",
861
+ cursor: "pointer",
862
+ flexShrink: 0,
863
+ }, children: _jsxs("svg", { fill: "none", height: "10", stroke: "#848483", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", viewBox: "0 0 24 24", width: "10", children: [_jsx("line", { x1: "18", x2: "6", y1: "6", y2: "18" }), _jsx("line", { x1: "6", x2: "18", y1: "6", y2: "18" })] }) }))] })] }), _jsxs("div", { style: {
864
+ alignItems: "center",
865
+ alignSelf: "stretch",
866
+ boxSizing: "border-box",
867
+ display: "flex",
868
+ justifyContent: "space-between",
869
+ width: "100%",
870
+ minHeight: "24px",
871
+ }, children: [_jsx("div", { style: {
872
+ display: "flex",
873
+ justifyContent: "flex-start",
874
+ alignItems: "center",
875
+ flex: 1,
876
+ }, children: showSourceRouteSkeleton ? (_jsx(SkeletonBar, { height: "16px", width: "84px" })) : ((() => {
877
+ if (!token)
878
+ return (_jsxs("div", { style: {
879
+ boxSizing: "border-box",
880
+ color: "#848483",
881
+ fontFamily: '"Geist", system-ui, sans-serif',
882
+ fontSize: "11px",
883
+ lineHeight: "16px",
884
+ whiteSpace: "nowrap",
885
+ }, children: ["\u2248 $", usdValue || "0.00"] }));
886
+ const tokenBalance = Number(String(token.balance).replace(/[^0-9.]/g, "")) || 0;
887
+ const fiatBalance = Number(String(token.balanceInFiat).replace(/[^0-9.]/g, "")) || 0;
888
+ const price = tokenBalance > 0 ? fiatBalance / tokenBalance : 0;
889
+ const isUsdMode = token.userAmountMode === "usd";
890
+ const userAmtNum = Number(token.userAmount || 0);
891
+ const quotedUsd = parseDecimal(token.userAmountUsd);
892
+ const approxValue = isUsdMode
893
+ ? price > 0
894
+ ? (userAmtNum / price).toFixed(6)
895
+ : "0.000000"
896
+ : quotedUsd
897
+ ? quotedUsd.toDecimalPlaces(2).toFixed()
898
+ : (userAmtNum * price).toFixed(2);
899
+ const approxPrefix = isUsdMode ? "≈" : "≈ $";
900
+ const approxSuffix = isUsdMode
901
+ ? ` ${token.symbol}`
902
+ : "";
903
+ return (_jsxs("div", { onClick: () => handleToggleMode(index), style: {
904
+ display: "flex",
905
+ alignItems: "center",
906
+ gap: "6px",
907
+ cursor: price > 0 && !isAmountReadOnly
908
+ ? "pointer"
909
+ : "default",
910
+ }, children: [_jsxs("div", { style: {
911
+ boxSizing: "border-box",
912
+ color: "#848483",
913
+ fontFamily: '"Geist", system-ui, sans-serif',
914
+ fontSize: "11px",
915
+ lineHeight: "16px",
916
+ whiteSpace: "nowrap",
917
+ }, children: [approxPrefix, approxValue, approxSuffix] }), price > 0 && _jsx(ArrowUpDownIcon, {})] }));
918
+ })()) }), _jsx("div", { style: {
919
+ alignItems: "center",
920
+ display: token && focusedRow === index && !isAmountReadOnly
921
+ ? "flex"
922
+ : "none",
923
+ justifyContent: "center",
924
+ pointerEvents: token && focusedRow === index && !isAmountReadOnly
925
+ ? "auto"
926
+ : "none",
927
+ }, children: token && !isAmountReadOnly && (_jsx(PercentButtons, { onSelect: (pct) => token
928
+ ? handleSendPercentForToken(index, pct, token)
929
+ : handleSendPercent(pct), visible: Boolean(token) && focusedRow === index })) }), _jsx("div", { style: {
930
+ display: "flex",
931
+ justifyContent: "flex-end",
932
+ alignItems: "center",
933
+ flex: 1,
934
+ }, children: showSourceRouteSkeleton ? (_jsx(SkeletonBar, { height: "16px", width: "124px" })) : token ? (_jsxs("div", { onMouseEnter: (e) => {
935
+ setTooltip(`asset-send-${index}`);
936
+ setTooltipTriggerRect(e.currentTarget.getBoundingClientRect());
937
+ }, onMouseLeave: () => {
938
+ setTooltip(null);
939
+ setTooltipTriggerRect(null);
940
+ }, style: {
941
+ alignItems: "center",
942
+ boxSizing: "border-box",
943
+ display: "flex",
944
+ gap: "4px",
945
+ position: "relative",
946
+ cursor: "default",
947
+ whiteSpace: "nowrap",
948
+ }, children: [_jsx("div", { style: {
949
+ boxSizing: "border-box",
950
+ color: "#848483",
951
+ fontFamily: '"Geist", system-ui, sans-serif',
952
+ fontSize: "11px",
953
+ fontVariantNumeric: "tabular-nums",
954
+ lineHeight: "16px",
955
+ whiteSpace: "nowrap",
956
+ }, children: "Balance \u00B7" }), _jsx("div", { style: {
957
+ boxSizing: "border-box",
958
+ color: "#848483",
959
+ fontFamily: '"Geist", system-ui, sans-serif',
960
+ fontSize: "11px",
961
+ fontVariantNumeric: "tabular-nums",
962
+ lineHeight: "16px",
963
+ whiteSpace: "nowrap",
964
+ }, children: formatTokenBalanceLabel(token) }), tooltip === `asset-send-${index}` &&
965
+ tooltipTriggerRect &&
966
+ createPortal(_jsxs("div", { style: {
967
+ position: "fixed",
968
+ right: window.innerWidth - tooltipTriggerRect.right,
969
+ ...(showTooltipBelow
970
+ ? { top: tooltipTriggerRect.bottom + 8 }
971
+ : {
972
+ bottom: window.innerHeight -
973
+ tooltipTriggerRect.top +
974
+ 8,
975
+ }),
976
+ width: "198px",
977
+ backgroundColor: "#fff",
978
+ border: "1px solid #E8E8E7",
979
+ borderRadius: "12px",
980
+ boxShadow: "0 4px 12px rgba(0,0,0,0.08)",
981
+ padding: "12px",
982
+ display: "flex",
983
+ flexDirection: "column",
984
+ zIndex: 2147483647,
985
+ pointerEvents: "none",
986
+ textAlign: "left",
987
+ }, children: [_jsx("div", { style: {
988
+ fontSize: "11px",
989
+ fontWeight: 600,
990
+ color: "#848483",
991
+ letterSpacing: "0.06em",
992
+ textTransform: "uppercase",
993
+ marginBottom: "4px",
994
+ fontFamily: '"Geist", system-ui, sans-serif',
995
+ }, children: "Asset Balance" }), _jsx("div", { style: {
996
+ fontSize: "14px",
997
+ color: "#161615",
998
+ lineHeight: "18px",
999
+ fontFamily: '"Geist", system-ui, sans-serif',
1000
+ }, children: "This is your current asset balance on this chain." })] }), document.body)] })) : null })] })] }, token
1001
+ ? `${token.contractAddress}-${token.chainId}-${index}`
1002
+ : "empty"));
1003
+ }) }), hasSourceOverflow && (_jsxs("button", { "aria-label": isSourceListAtBottom
1004
+ ? "Scroll source assets to top"
1005
+ : "Scroll source assets", onClick: () => {
1006
+ const element = sourceListRef.current;
1007
+ if (!element)
1008
+ return;
1009
+ element.scrollTo({
1010
+ behavior: "smooth",
1011
+ top: isSourceListAtBottom ? 0 : element.scrollTop + 80,
1012
+ });
1013
+ }, style: {
1014
+ alignItems: "center",
1015
+ alignSelf: "center",
1016
+ background: "transparent",
1017
+ border: "none",
1018
+ color: "#686866",
1019
+ cursor: "pointer",
1020
+ display: "flex",
1021
+ fontFamily: '"Geist", system-ui, sans-serif',
1022
+ fontSize: "13px",
1023
+ fontWeight: 500,
1024
+ gap: "4px",
1025
+ lineHeight: "18px",
1026
+ marginTop: "-2px",
1027
+ padding: 0,
1028
+ }, type: "button", children: ["Scroll to view more assets", _jsx("span", { "aria-hidden": "true", children: isSourceListAtBottom ? "↑" : "↓" })] })), sourceRouteHelper && (_jsx("div", { style: {
1029
+ alignSelf: "stretch",
1030
+ color: sourceRouteStatus === "insufficient" ? "#D32F2F" : brand,
1031
+ fontFamily: '"Geist", system-ui, sans-serif',
1032
+ fontSize: "13px",
1033
+ fontWeight: 500,
1034
+ lineHeight: "18px",
1035
+ marginTop: "-6px",
1036
+ }, children: sourceRouteHelper })), totalUsd > 0 && (_jsxs("div", { style: {
1037
+ display: "flex",
1038
+ gap: "7px",
1039
+ alignItems: "center",
1040
+ paddingTop: "6px",
1041
+ alignSelf: "flex-start",
1042
+ justifyContent: "flex-start",
1043
+ }, children: [_jsxs("span", { style: {
1044
+ fontSize: "15px",
1045
+ fontWeight: 600,
1046
+ color: "#161615",
1047
+ fontFamily: '"Geist", system-ui, sans-serif',
1048
+ }, children: ["\u2248 $", totalUsd.toFixed(2)] }), _jsx("span", { style: {
1049
+ fontSize: "12px",
1050
+ color: "#848483",
1051
+ fontWeight: 600,
1052
+ fontFamily: '"Geist", system-ui, sans-serif',
1053
+ letterSpacing: "0.05em",
1054
+ }, children: "TOTAL" })] }))] }), _jsxs("div", { style: {
1055
+ backgroundColor: "#FFFFFE",
1056
+ borderColor: "#E8E8E7",
1057
+ borderRadius: "9px",
1058
+ borderStyle: "solid",
1059
+ borderWidth: "1px",
1060
+ boxShadow: "#1616150A 0px 1px 2px",
1061
+ boxSizing: "border-box",
1062
+ display: "flex",
1063
+ flexDirection: "column",
1064
+ fontVariantNumeric: "tabular-nums",
1065
+ gap: "6px",
1066
+ paddingBlock: "9px",
1067
+ paddingInline: "9px",
1068
+ width: "100%",
1069
+ }, children: [_jsx("div", { style: {
1070
+ alignSelf: "stretch",
1071
+ boxSizing: "border-box",
1072
+ color: "#848483",
1073
+ fontFamily: '"Geist", system-ui, sans-serif',
1074
+ fontSize: "12px",
1075
+ fontWeight: 500,
1076
+ letterSpacing: "0.08em",
1077
+ lineHeight: "18px",
1078
+ textTransform: "uppercase",
1079
+ width: "100%",
1080
+ }, children: "Receive" }), _jsxs("div", { style: {
1081
+ alignSelf: "stretch",
1082
+ boxSizing: "border-box",
1083
+ display: "flex",
1084
+ flexDirection: "column",
1085
+ gap: "4px",
1086
+ width: "100%",
1087
+ }, children: [_jsxs("div", { style: {
1088
+ alignItems: "center",
1089
+ alignSelf: "stretch",
1090
+ boxSizing: "border-box",
1091
+ display: "flex",
1092
+ gap: "9px",
1093
+ justifyContent: "space-between",
1094
+ width: "100%",
1095
+ }, children: [isReceiveAmountLoading ? (_jsx("div", { style: {
1096
+ alignItems: "center",
1097
+ boxSizing: "border-box",
1098
+ display: "flex",
1099
+ minHeight: "31px",
1100
+ minWidth: 0,
1101
+ width: "100%",
1102
+ }, children: _jsx(SkeletonBar, { height: "27px", width: "68%" }) })) : (_jsx("input", { "aria-disabled": "true", disabled: true, placeholder: "0", style: {
1103
+ boxSizing: "border-box",
1104
+ color: receiveAmountTextColor,
1105
+ fontFamily: '"Delight-Medium", "Delight", system-ui, sans-serif',
1106
+ fontSize: "29px",
1107
+ fontWeight: 500,
1108
+ lineHeight: "34px",
1109
+ background: "transparent",
1110
+ border: "none",
1111
+ cursor: "default",
1112
+ outline: "none",
1113
+ opacity: 1,
1114
+ padding: 0,
1115
+ WebkitTextFillColor: receiveAmountTextColor,
1116
+ width: "100%",
1117
+ minWidth: 0,
1118
+ }, type: "text", value: receiveDisplayValue })), _jsxs("button", { disabled: isDestinationPickerDisabled, onClick: onOpenDestPicker, style: {
1119
+ alignItems: "center",
1120
+ backgroundColor: "#FFFFFE",
1121
+ borderColor: toToken ? "#E8E8E7" : "#C8C8C7",
1122
+ borderRadius: "999px",
1123
+ borderStyle: toToken ? "solid" : "dashed",
1124
+ borderWidth: "1px",
1125
+ boxShadow: toToken ? "#1616150A 0px 1px 2px" : "none",
1126
+ boxSizing: "border-box",
1127
+ display: "flex",
1128
+ gap: "6px",
1129
+ paddingBottom: "3px",
1130
+ paddingLeft: toToken ? "3px" : "7px",
1131
+ paddingRight: "8px",
1132
+ paddingTop: "3px",
1133
+ cursor: isDestinationPickerDisabled ? "default" : "pointer",
1134
+ flexShrink: 0,
1135
+ }, children: [toToken ? (_jsxs("div", { style: {
1136
+ boxSizing: "border-box",
1137
+ flexShrink: 0,
1138
+ height: "20px",
1139
+ position: "relative",
1140
+ width: "20px",
1141
+ }, children: [_jsx(LogoCircle, { alt: toToken.symbol, fontSize: 10, label: toToken.symbol, size: 20, src: toToken.logo }), toToken.chainLogo && (_jsx(LogoCircle, { alt: toToken.chainName, fontSize: 5, label: toToken.chainName, outline: "1px solid #FFFFFE", size: 10, src: toToken.chainLogo, style: {
1142
+ bottom: -2,
1143
+ position: "absolute",
1144
+ right: -2,
1145
+ } }))] })) : (_jsx("div", { style: {
1146
+ borderColor: "#C8C8C7",
1147
+ borderRadius: "999px",
1148
+ borderStyle: "dashed",
1149
+ borderWidth: "1.5px",
1150
+ boxSizing: "border-box",
1151
+ flexShrink: 0,
1152
+ height: "18px",
1153
+ width: "18px",
1154
+ } })), _jsx("div", { style: {
1155
+ boxSizing: "border-box",
1156
+ color: "#161615",
1157
+ fontFamily: '"Geist", system-ui, sans-serif',
1158
+ fontSize: toToken ? "12px" : "14px",
1159
+ fontWeight: 500,
1160
+ lineHeight: toToken ? "16px" : "20px",
1161
+ }, children: toToken ? toToken.symbol : "Assets" }), !hideDestinationTokenDropdownIcon && _jsx(ChevronDownIcon, {})] })] }), _jsxs("div", { style: {
1162
+ alignItems: "center",
1163
+ alignSelf: "stretch",
1164
+ boxSizing: "border-box",
1165
+ display: "flex",
1166
+ justifyContent: "space-between",
1167
+ width: "100%",
1168
+ minHeight: "22px",
1169
+ }, children: [isReceiveUsdLoading ? (_jsx(SkeletonBar, { borderRadius: "6px", height: "16px", width: "74px" })) : (_jsx("div", { style: {
1170
+ boxSizing: "border-box",
1171
+ color: "#848483",
1172
+ fontFamily: '"Geist", system-ui, sans-serif',
1173
+ fontSize: "11px",
1174
+ lineHeight: "16px",
1175
+ whiteSpace: "nowrap",
1176
+ }, children: receiveAltValue })), toToken && focusedPanel === "receive" && (_jsxs("div", { onMouseEnter: () => setTooltip("asset-receive"), onMouseLeave: () => setTooltip(null), style: {
1177
+ alignItems: "center",
1178
+ boxSizing: "border-box",
1179
+ display: "flex",
1180
+ gap: "5px",
1181
+ position: "relative",
1182
+ cursor: "default",
1183
+ }, children: [_jsx("div", { style: {
1184
+ boxSizing: "border-box",
1185
+ color: "#848483",
1186
+ fontFamily: '"Geist", system-ui, sans-serif',
1187
+ fontSize: "11px",
1188
+ fontVariantNumeric: "tabular-nums",
1189
+ lineHeight: "16px",
1190
+ whiteSpace: "nowrap",
1191
+ }, children: "Asset Balance \u00B7" }), _jsx("div", { style: {
1192
+ boxSizing: "border-box",
1193
+ color: "#848483",
1194
+ fontFamily: '"Geist", system-ui, sans-serif',
1195
+ fontSize: "11px",
1196
+ fontVariantNumeric: "tabular-nums",
1197
+ lineHeight: "16px",
1198
+ whiteSpace: "nowrap",
1199
+ }, children: receiveBalanceLabel }), tooltip === "asset-receive" && (_jsxs("div", { style: {
1200
+ position: "absolute",
1201
+ right: 0,
1202
+ bottom: "calc(100% + 8px)",
1203
+ width: "198px",
1204
+ backgroundColor: "#fff",
1205
+ border: "1px solid #E8E8E7",
1206
+ borderRadius: "12px",
1207
+ boxShadow: "0 4px 12px rgba(0,0,0,0.08)",
1208
+ padding: "12px",
1209
+ display: "flex",
1210
+ flexDirection: "column",
1211
+ zIndex: 10000,
1212
+ pointerEvents: "none",
1213
+ textAlign: "left",
1214
+ }, children: [_jsx("div", { style: {
1215
+ fontSize: "11px",
1216
+ fontWeight: 600,
1217
+ color: "#848483",
1218
+ letterSpacing: "0.06em",
1219
+ textTransform: "uppercase",
1220
+ marginBottom: "4px",
1221
+ fontFamily: '"Geist", system-ui, sans-serif',
1222
+ }, children: "Asset Balance" }), _jsx("div", { style: {
1223
+ fontSize: "14px",
1224
+ color: "#161615",
1225
+ lineHeight: "18px",
1226
+ fontFamily: '"Geist", system-ui, sans-serif',
1227
+ }, children: "This is your current asset balance on this chain." })] }))] }))] })] }), onOpenRecipientPicker && (_jsxs(_Fragment, { children: [_jsx("div", { style: {
1228
+ alignSelf: "stretch",
1229
+ backgroundColor: "#E8E8E7",
1230
+ boxSizing: "border-box",
1231
+ flexShrink: 0,
1232
+ height: "1px",
1233
+ marginTop: "4px",
1234
+ width: "100%",
1235
+ } }), _jsxs("div", { style: {
1236
+ alignSelf: "stretch",
1237
+ boxSizing: "border-box",
1238
+ display: "flex",
1239
+ flexDirection: "column",
1240
+ gap: "4px",
1241
+ paddingTop: "2px",
1242
+ width: "100%",
1243
+ }, children: [_jsx("div", { style: {
1244
+ boxSizing: "border-box",
1245
+ color: "#7C7C7A",
1246
+ fontFamily: '"Geist", system-ui, sans-serif',
1247
+ fontSize: "12px",
1248
+ fontWeight: 500,
1249
+ letterSpacing: "0.08em",
1250
+ lineHeight: "18px",
1251
+ textTransform: "uppercase",
1252
+ }, children: "Recipient" }), _jsxs("div", { style: {
1253
+ alignItems: "center",
1254
+ alignSelf: "stretch",
1255
+ boxSizing: "border-box",
1256
+ display: "flex",
1257
+ gap: "9px",
1258
+ justifyContent: "space-between",
1259
+ width: "100%",
1260
+ }, children: [_jsx("div", { style: {
1261
+ boxSizing: "border-box",
1262
+ color: recipientColor,
1263
+ fontFamily: '"Geist", system-ui, sans-serif',
1264
+ fontSize: "14px",
1265
+ fontVariantNumeric: "tabular-nums",
1266
+ fontWeight: 500,
1267
+ lineHeight: "16px",
1268
+ }, children: recipientAddress
1269
+ ? formatShortAddress(recipientAddress)
1270
+ : "Select recipient" }), _jsx("button", { onClick: onOpenRecipientPicker, style: {
1271
+ alignItems: "center",
1272
+ backgroundColor: "#F4F6FF",
1273
+ borderRadius: "4px",
1274
+ boxSizing: "border-box",
1275
+ display: "flex",
1276
+ gap: "4px",
1277
+ paddingBlock: "6px",
1278
+ paddingInline: "9px",
1279
+ border: "none",
1280
+ cursor: "pointer",
1281
+ }, children: _jsx("div", { style: {
1282
+ boxSizing: "border-box",
1283
+ color: brand,
1284
+ fontFamily: '"Geist", system-ui, sans-serif',
1285
+ fontSize: "13px",
1286
+ fontWeight: 500,
1287
+ lineHeight: "13px",
1288
+ }, children: "Edit" }) })] })] })] }))] })] }));
1289
+ }