@aori/mega-swap-widget 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +404 -0
  3. package/dist/AssetSelectionMenu-Y3EB32BT.cjs +13 -0
  4. package/dist/AssetSelectionMenu-Y3EB32BT.cjs.map +1 -0
  5. package/dist/AssetSelectionMenu-ZRG42UCZ.js +13 -0
  6. package/dist/AssetSelectionMenu-ZRG42UCZ.js.map +1 -0
  7. package/dist/ChainSelectionMenu-FBAPPFKI.cjs +11 -0
  8. package/dist/ChainSelectionMenu-FBAPPFKI.cjs.map +1 -0
  9. package/dist/ChainSelectionMenu-QO3H4TNR.js +11 -0
  10. package/dist/ChainSelectionMenu-QO3H4TNR.js.map +1 -0
  11. package/dist/SwapFormHorizontal-JDJUDFNX.js +573 -0
  12. package/dist/SwapFormHorizontal-JDJUDFNX.js.map +1 -0
  13. package/dist/SwapFormHorizontal-WG3Z3CFT.cjs +573 -0
  14. package/dist/SwapFormHorizontal-WG3Z3CFT.cjs.map +1 -0
  15. package/dist/SwapFormSplit-7CHTPLEQ.js +441 -0
  16. package/dist/SwapFormSplit-7CHTPLEQ.js.map +1 -0
  17. package/dist/SwapFormSplit-VDDIRQUQ.cjs +441 -0
  18. package/dist/SwapFormSplit-VDDIRQUQ.cjs.map +1 -0
  19. package/dist/WalletPlaceholderPanel-7YDQ4FT6.js +57 -0
  20. package/dist/WalletPlaceholderPanel-7YDQ4FT6.js.map +1 -0
  21. package/dist/WalletPlaceholderPanel-FZ6XIAMF.cjs +57 -0
  22. package/dist/WalletPlaceholderPanel-FZ6XIAMF.cjs.map +1 -0
  23. package/dist/WidgetWalletPanel-D7I5TAU3.js +789 -0
  24. package/dist/WidgetWalletPanel-D7I5TAU3.js.map +1 -0
  25. package/dist/WidgetWalletPanel-T7H6FGVN.cjs +789 -0
  26. package/dist/WidgetWalletPanel-T7H6FGVN.cjs.map +1 -0
  27. package/dist/chunk-3E6RNP2D.cjs +389 -0
  28. package/dist/chunk-3E6RNP2D.cjs.map +1 -0
  29. package/dist/chunk-5TH6MFQD.cjs +122 -0
  30. package/dist/chunk-5TH6MFQD.cjs.map +1 -0
  31. package/dist/chunk-5XSCUUOW.js +101 -0
  32. package/dist/chunk-5XSCUUOW.js.map +1 -0
  33. package/dist/chunk-6Q7MSCKS.js +2199 -0
  34. package/dist/chunk-6Q7MSCKS.js.map +1 -0
  35. package/dist/chunk-6XB5R4GF.cjs +368 -0
  36. package/dist/chunk-6XB5R4GF.cjs.map +1 -0
  37. package/dist/chunk-6YLNOZ7P.js +389 -0
  38. package/dist/chunk-6YLNOZ7P.js.map +1 -0
  39. package/dist/chunk-7AWG6OWF.js +27 -0
  40. package/dist/chunk-7AWG6OWF.js.map +1 -0
  41. package/dist/chunk-ARMW5POL.js +3082 -0
  42. package/dist/chunk-ARMW5POL.js.map +1 -0
  43. package/dist/chunk-B3ILUJ7G.cjs +101 -0
  44. package/dist/chunk-B3ILUJ7G.cjs.map +1 -0
  45. package/dist/chunk-GGM3MDFM.js +32 -0
  46. package/dist/chunk-GGM3MDFM.js.map +1 -0
  47. package/dist/chunk-GZUTUD5O.cjs +2199 -0
  48. package/dist/chunk-GZUTUD5O.cjs.map +1 -0
  49. package/dist/chunk-HXOGJSAI.cjs +3082 -0
  50. package/dist/chunk-HXOGJSAI.cjs.map +1 -0
  51. package/dist/chunk-LTA7IG3J.js +122 -0
  52. package/dist/chunk-LTA7IG3J.js.map +1 -0
  53. package/dist/chunk-NBJPKJBC.cjs +32 -0
  54. package/dist/chunk-NBJPKJBC.cjs.map +1 -0
  55. package/dist/chunk-PGYOJ5RB.cjs +27 -0
  56. package/dist/chunk-PGYOJ5RB.cjs.map +1 -0
  57. package/dist/chunk-QHW27RMH.js +199 -0
  58. package/dist/chunk-QHW27RMH.js.map +1 -0
  59. package/dist/chunk-TMC4SUEV.js +368 -0
  60. package/dist/chunk-TMC4SUEV.js.map +1 -0
  61. package/dist/chunk-XQINW7QP.cjs +199 -0
  62. package/dist/chunk-XQINW7QP.cjs.map +1 -0
  63. package/dist/index.cjs +1780 -0
  64. package/dist/index.cjs.map +1 -0
  65. package/dist/index.css +1424 -0
  66. package/dist/index.css.map +1 -0
  67. package/dist/index.d.cts +555 -0
  68. package/dist/index.d.ts +555 -0
  69. package/dist/index.js +1780 -0
  70. package/dist/index.js.map +1 -0
  71. package/package.json +82 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,1780 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;"use client";
2
+
3
+
4
+ var _chunkXQINW7QPcjs = require('./chunk-XQINW7QP.cjs');
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+ var _chunkHXOGJSAIcjs = require('./chunk-HXOGJSAI.cjs');
30
+ require('./chunk-5TH6MFQD.cjs');
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+ var _chunk6XB5R4GFcjs = require('./chunk-6XB5R4GF.cjs');
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+ var _chunkGZUTUD5Ocjs = require('./chunk-GZUTUD5O.cjs');
52
+
53
+
54
+ var _chunkPGYOJ5RBcjs = require('./chunk-PGYOJ5RB.cjs');
55
+ require('./chunk-NBJPKJBC.cjs');
56
+
57
+ // src/SwapWidget.tsx
58
+ var _react = require('react'); var _react2 = _interopRequireDefault(_react);
59
+
60
+ // src/components/SwapContainer.tsx
61
+
62
+ var _shallow = require('zustand/react/shallow');
63
+
64
+ // src/components/SwapForm.tsx
65
+
66
+
67
+ var _jsxruntime = require('react/jsx-runtime');
68
+ var SwapForm = ({ onSwapComplete, onSwapInitiated }) => {
69
+ const {
70
+ web3ConnectionType,
71
+ hasConnectHandler,
72
+ lockBase,
73
+ lockQuote,
74
+ disableInverting,
75
+ tokenDisplay,
76
+ tokenBadgeOrientation,
77
+ widgetType
78
+ } = _chunkGZUTUD5Ocjs.useWidgetConfig.call(void 0, );
79
+ const isOverlayToken = tokenDisplay === "pill" || tokenDisplay === "ghost";
80
+ const isCompactMode = widgetType === "compact";
81
+ const basePadding = isCompactMode ? "px-4 pt-3 pb-1" : "px-4 pt-4 pb-2";
82
+ const quotePadding = isCompactMode ? "px-4 pt-4 pb-1" : "px-4 pt-6 pb-2";
83
+ const {
84
+ baseToken,
85
+ quoteToken,
86
+ baseAmount,
87
+ quoteAmount,
88
+ isBaseGasToken,
89
+ isQuoteGasToken,
90
+ isWrappingPair,
91
+ isUnwrappingPair,
92
+ baseBalance,
93
+ quoteBalance,
94
+ setBaseAmount,
95
+ setQuoteAmount,
96
+ swapTokens,
97
+ clearForm
98
+ } = _chunk6XB5R4GFcjs.useSwapFormContext.call(void 0, );
99
+ const {
100
+ rfqQuote,
101
+ status: rfqStatus,
102
+ handleInputChange,
103
+ ensureForParams,
104
+ stop,
105
+ clear,
106
+ refresh
107
+ } = _chunkHXOGJSAIcjs.useRfq.call(void 0, );
108
+ const { address: userAddress } = _chunkPGYOJ5RBcjs.useWalletState.call(void 0, );
109
+ const { openConnectModal: openWalletModal } = _chunkHXOGJSAIcjs.useWalletModal.call(void 0, );
110
+ const { isRecipientInputOpen, txStatus } = _chunk6XB5R4GFcjs.useWidgetSwapUIStore.call(void 0,
111
+ _shallow.useShallow.call(void 0, (state) => ({
112
+ isRecipientInputOpen: state.isRecipientInputOpen,
113
+ txStatus: state.txStatus
114
+ }))
115
+ );
116
+ const [reviewState, setReviewState] = _react.useState.call(void 0, null);
117
+ const [trackedOrderHash, setTrackedOrderHash] = _react.useState.call(void 0, null);
118
+ const isHandlingStaleRestart = _react.useRef.call(void 0, false);
119
+ const isPlacingOrder = false;
120
+ const reviewActionProps = _react.useMemo.call(void 0, () => {
121
+ if (!baseToken || !quoteToken || typeof baseAmount !== "number" || !quoteAmount || !userAddress) return null;
122
+ if (parseFloat(baseBalance.formatted) < baseAmount) return null;
123
+ return { base: baseToken, quote: quoteToken, baseAmount, quoteAmount, userAddress };
124
+ }, [baseToken, quoteToken, baseAmount, quoteAmount, userAddress, baseBalance.formatted]);
125
+ const onOrderSubmitted = _react.useCallback.call(void 0, (orderHash) => {
126
+ setTrackedOrderHash(orderHash);
127
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().startTracking(orderHash);
128
+ }, []);
129
+ const onStaleQuoteRestart = _react.useCallback.call(void 0, () => {
130
+ isHandlingStaleRestart.current = true;
131
+ refresh();
132
+ }, [refresh]);
133
+ _react.useEffect.call(void 0, () => {
134
+ if (reviewState !== null) return;
135
+ if (!baseToken || !quoteToken) return;
136
+ if (!baseAmount || baseAmount <= 0) {
137
+ handleInputChange({ amount: null, inputToken: baseToken, outputToken: quoteToken, setOutputAmount: setQuoteAmount });
138
+ return;
139
+ }
140
+ if (isWrappingPair || isUnwrappingPair) {
141
+ setQuoteAmount(baseAmount);
142
+ return;
143
+ }
144
+ handleInputChange({
145
+ amount: baseAmount,
146
+ inputToken: baseToken,
147
+ outputToken: quoteToken,
148
+ setOutputAmount: setQuoteAmount
149
+ });
150
+ }, [
151
+ reviewState,
152
+ baseAmount,
153
+ baseToken,
154
+ quoteToken,
155
+ isWrappingPair,
156
+ isUnwrappingPair,
157
+ handleInputChange,
158
+ setQuoteAmount
159
+ ]);
160
+ const handleToggleBaseSelection = _react.useCallback.call(void 0, () => {
161
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().setView("baseSelection");
162
+ }, []);
163
+ const handleToggleQuoteSelection = _react.useCallback.call(void 0, () => {
164
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().setView("quoteSelection");
165
+ }, []);
166
+ const handleInvert = _react.useCallback.call(void 0, () => {
167
+ swapTokens();
168
+ setQuoteAmount(null);
169
+ }, [swapTokens, setQuoteAmount]);
170
+ const handleMax = _react.useCallback.call(void 0, () => {
171
+ if (!baseBalance.formatted || !baseToken || !quoteToken) return;
172
+ const balNum = parseFloat(baseBalance.formatted);
173
+ if (!balNum || balNum <= 0) return;
174
+ const adjusted = balNum * 0.9999999999;
175
+ if (isWrappingPair || isUnwrappingPair) {
176
+ setBaseAmount(adjusted);
177
+ setQuoteAmount(adjusted);
178
+ clear();
179
+ } else {
180
+ setBaseAmount(adjusted);
181
+ setQuoteAmount(null);
182
+ ensureForParams({
183
+ inputToken: baseToken,
184
+ outputToken: quoteToken,
185
+ inputAmount: adjusted.toString(),
186
+ setOutputAmount: (amount) => setQuoteAmount(amount)
187
+ });
188
+ }
189
+ }, [
190
+ baseBalance.formatted,
191
+ baseToken,
192
+ quoteToken,
193
+ isWrappingPair,
194
+ isUnwrappingPair,
195
+ setBaseAmount,
196
+ setQuoteAmount,
197
+ clear,
198
+ ensureForParams
199
+ ]);
200
+ const handleClear = _react.useCallback.call(void 0, () => {
201
+ clear();
202
+ clearForm();
203
+ }, [clear, clearForm]);
204
+ const baseBalanceNum = baseBalance.formatted ? parseFloat(baseBalance.formatted) : null;
205
+ const hasAmount = !!(baseAmount || quoteAmount);
206
+ const baseUsd = _optionalChain([baseToken, 'optionalAccess', _ => _.price]) && baseAmount ? `$${(baseToken.price * baseAmount).toFixed(2)}` : "$0.00";
207
+ const quoteUsd = _optionalChain([quoteToken, 'optionalAccess', _2 => _2.price]) && quoteAmount ? `$${(quoteToken.price * quoteAmount).toFixed(2)}` : "$0.00";
208
+ const isShowingTxStatus = reviewState === "trackingTx" && !!trackedOrderHash && !!baseToken && !!quoteToken && !!baseAmount && !!quoteAmount;
209
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col w-full", children: [
210
+ isShowingTxStatus && trackedOrderHash && baseToken && quoteToken && baseAmount && quoteAmount ? (
211
+ /* ── TX STATUS (replaces token sections during tracking) ── */
212
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-hidden", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
213
+ _chunkHXOGJSAIcjs.TxStatusDisplay_default,
214
+ {
215
+ orderHash: trackedOrderHash,
216
+ base: baseToken,
217
+ quote: quoteToken,
218
+ baseAmount,
219
+ quoteAmount,
220
+ status: txStatus
221
+ }
222
+ ) })
223
+ ) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
224
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
225
+ "div",
226
+ {
227
+ className: `relative ${basePadding}`,
228
+ style: { borderBottom: "1px solid var(--widget-border)" },
229
+ children: [
230
+ isOverlayToken ? isCompactMode ? (
231
+ // compact + pill/ghost: side-by-side row, badge on side
232
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
233
+ "div",
234
+ {
235
+ className: `flex items-center gap-2 mb-2 ${tokenBadgeOrientation === "right" ? "flex-row-reverse" : "flex-row"}`,
236
+ children: [
237
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
238
+ _chunkHXOGJSAIcjs.AssetSelection_default,
239
+ {
240
+ toggle: handleToggleBaseSelection,
241
+ side: "base",
242
+ asset: baseToken,
243
+ isPlacingOrder: isPlacingOrder || lockBase
244
+ }
245
+ ),
246
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
247
+ _chunkHXOGJSAIcjs.AssetAmountInput_default,
248
+ {
249
+ side: "base",
250
+ asset: _nullishCoalesce(baseToken, () => ( null)),
251
+ otherAsset: _nullishCoalesce(quoteToken, () => ( null)),
252
+ isPlacingOrder,
253
+ isWrappingPair,
254
+ isUnwrappingPair
255
+ }
256
+ ) })
257
+ ]
258
+ }
259
+ )
260
+ ) : (
261
+ // default + pill/ghost: badge stacked above input, aligned to chosen side
262
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
263
+ "div",
264
+ {
265
+ className: `flex flex-col ${tokenBadgeOrientation === "right" ? "items-end" : "items-start"}`,
266
+ children: [
267
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
268
+ _chunkHXOGJSAIcjs.AssetSelection_default,
269
+ {
270
+ toggle: handleToggleBaseSelection,
271
+ side: "base",
272
+ asset: baseToken,
273
+ isPlacingOrder: isPlacingOrder || lockBase
274
+ }
275
+ ),
276
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
277
+ _chunkHXOGJSAIcjs.AssetAmountInput_default,
278
+ {
279
+ side: "base",
280
+ asset: _nullishCoalesce(baseToken, () => ( null)),
281
+ otherAsset: _nullishCoalesce(quoteToken, () => ( null)),
282
+ isPlacingOrder,
283
+ isWrappingPair,
284
+ isUnwrappingPair
285
+ }
286
+ )
287
+ ]
288
+ }
289
+ )
290
+ ) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
291
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
292
+ _chunkHXOGJSAIcjs.AssetSelection_default,
293
+ {
294
+ toggle: handleToggleBaseSelection,
295
+ side: "base",
296
+ asset: baseToken,
297
+ isPlacingOrder: isPlacingOrder || lockBase
298
+ }
299
+ ),
300
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
301
+ _chunkHXOGJSAIcjs.AssetAmountInput_default,
302
+ {
303
+ side: "base",
304
+ asset: _nullishCoalesce(baseToken, () => ( null)),
305
+ otherAsset: _nullishCoalesce(quoteToken, () => ( null)),
306
+ isPlacingOrder,
307
+ isWrappingPair,
308
+ isUnwrappingPair
309
+ }
310
+ )
311
+ ] }),
312
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mb-1 flex w-full flex-row items-center justify-between", children: [
313
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
314
+ "p",
315
+ {
316
+ className: "mono text-sm",
317
+ style: { color: "var(--widget-muted-foreground)" },
318
+ children: baseUsd
319
+ }
320
+ ),
321
+ userAddress && baseBalanceNum !== null && baseBalanceNum > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
322
+ "button",
323
+ {
324
+ type: "button",
325
+ onClick: handleMax,
326
+ disabled: isPlacingOrder,
327
+ className: "absolute bottom-3 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",
328
+ style: { borderRadius: "var(--widget-radius)" },
329
+ children: "Max"
330
+ }
331
+ )
332
+ ] })
333
+ ]
334
+ }
335
+ ),
336
+ !disableInverting && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex justify-center -my-4 relative z-10", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
337
+ "button",
338
+ {
339
+ type: "button",
340
+ onClick: handleInvert,
341
+ "aria-label": "Swap input and output tokens",
342
+ className: "flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)",
343
+ style: { border: "1px solid var(--widget-border)" },
344
+ children: [
345
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-2xs", children: "\u2191" }),
346
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-2xs", children: "\u2193" })
347
+ ]
348
+ }
349
+ ) }),
350
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: `relative ${quotePadding}`, children: [
351
+ isOverlayToken ? isCompactMode ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
352
+ "div",
353
+ {
354
+ className: `flex items-center gap-2 ${tokenBadgeOrientation === "right" ? "flex-row-reverse" : "flex-row"}`,
355
+ children: [
356
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
357
+ _chunkHXOGJSAIcjs.AssetSelection_default,
358
+ {
359
+ toggle: handleToggleQuoteSelection,
360
+ side: "quote",
361
+ asset: quoteToken,
362
+ isPlacingOrder: isPlacingOrder || lockQuote
363
+ }
364
+ ),
365
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
366
+ _chunkHXOGJSAIcjs.AssetAmountInput_default,
367
+ {
368
+ side: "quote",
369
+ asset: _nullishCoalesce(quoteToken, () => ( null)),
370
+ otherAsset: _nullishCoalesce(baseToken, () => ( null)),
371
+ isPlacingOrder,
372
+ isWrappingPair,
373
+ isUnwrappingPair
374
+ }
375
+ ) })
376
+ ]
377
+ }
378
+ ) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
379
+ "div",
380
+ {
381
+ className: `flex flex-col ${tokenBadgeOrientation === "right" ? "items-end" : "items-start"}`,
382
+ children: [
383
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
384
+ _chunkHXOGJSAIcjs.AssetSelection_default,
385
+ {
386
+ toggle: handleToggleQuoteSelection,
387
+ side: "quote",
388
+ asset: quoteToken,
389
+ isPlacingOrder: isPlacingOrder || lockQuote
390
+ }
391
+ ),
392
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
393
+ _chunkHXOGJSAIcjs.AssetAmountInput_default,
394
+ {
395
+ side: "quote",
396
+ asset: _nullishCoalesce(quoteToken, () => ( null)),
397
+ otherAsset: _nullishCoalesce(baseToken, () => ( null)),
398
+ isPlacingOrder,
399
+ isWrappingPair,
400
+ isUnwrappingPair
401
+ }
402
+ )
403
+ ]
404
+ }
405
+ ) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
406
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
407
+ _chunkHXOGJSAIcjs.AssetSelection_default,
408
+ {
409
+ toggle: handleToggleQuoteSelection,
410
+ side: "quote",
411
+ asset: quoteToken,
412
+ isPlacingOrder: isPlacingOrder || lockQuote
413
+ }
414
+ ),
415
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
416
+ _chunkHXOGJSAIcjs.AssetAmountInput_default,
417
+ {
418
+ side: "quote",
419
+ asset: _nullishCoalesce(quoteToken, () => ( null)),
420
+ otherAsset: _nullishCoalesce(baseToken, () => ( null)),
421
+ isPlacingOrder,
422
+ isWrappingPair,
423
+ isUnwrappingPair
424
+ }
425
+ )
426
+ ] }),
427
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-row items-center justify-between", children: [
428
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
429
+ "p",
430
+ {
431
+ className: "mono text-sm",
432
+ style: { color: "var(--widget-muted-foreground)" },
433
+ children: quoteUsd
434
+ }
435
+ ),
436
+ hasAmount && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
437
+ "button",
438
+ {
439
+ type: "button",
440
+ onClick: handleClear,
441
+ disabled: isPlacingOrder,
442
+ className: "absolute bottom-2 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",
443
+ style: { borderRadius: "var(--widget-radius)" },
444
+ children: "Clear"
445
+ }
446
+ )
447
+ ] })
448
+ ] }),
449
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
450
+ "div",
451
+ {
452
+ className: "flex flex-row items-center w-full overflow-hidden",
453
+ style: {
454
+ borderTop: isRecipientInputOpen ? "1px solid var(--widget-border)" : "none",
455
+ maxHeight: isRecipientInputOpen ? "60px" : "0px",
456
+ opacity: isRecipientInputOpen ? 1 : 0,
457
+ transition: "max-height 0.3s ease, opacity 0.3s ease"
458
+ },
459
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHXOGJSAIcjs.RecipientForm_default, {})
460
+ }
461
+ ),
462
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
463
+ "div",
464
+ {
465
+ className: "px-4",
466
+ style: {
467
+ borderTop: "1px solid var(--widget-border)",
468
+ borderBottom: "1px solid var(--widget-border)"
469
+ },
470
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkXQINW7QPcjs.QuoteLoader_default, {})
471
+ }
472
+ )
473
+ ] }),
474
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: `relative ${isShowingTxStatus ? "px-0" : "px-4"} ${isCompactMode ? "py-2" : "py-4"}`, children: userAddress && baseToken && quoteToken && baseAmount && baseAmount > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
475
+ _chunkHXOGJSAIcjs.SwapButton,
476
+ {
477
+ base: baseToken,
478
+ baseAmount,
479
+ quote: quoteToken,
480
+ quoteAmount: _nullishCoalesce(quoteAmount, () => ( 0)),
481
+ userAddress,
482
+ isWrappingPair,
483
+ isUnwrappingPair,
484
+ isBaseGasToken,
485
+ isQuoteGasToken,
486
+ reviewActionProps,
487
+ reviewState,
488
+ setReviewState,
489
+ trackedOrderHash,
490
+ setTrackedOrderHash,
491
+ onSwapComplete,
492
+ onSwapInitiated,
493
+ onOrderSubmitted,
494
+ onStaleQuoteRestart,
495
+ txStatus
496
+ }
497
+ ) : !userAddress && hasConnectHandler ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
498
+ "button",
499
+ {
500
+ onClick: () => openWalletModal(),
501
+ className: `w-full ${isCompactMode ? "py-2" : "py-3"} text-sm font-medium cursor-pointer transition-opacity hover:opacity-80`,
502
+ style: {
503
+ backgroundColor: "var(--widget-primary)",
504
+ color: "var(--widget-primary-foreground)",
505
+ borderRadius: "var(--widget-radius)"
506
+ },
507
+ children: "Connect Wallet"
508
+ }
509
+ ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
510
+ "button",
511
+ {
512
+ disabled: true,
513
+ className: `w-full ${isCompactMode ? "py-2" : "py-3"} text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed`,
514
+ style: {
515
+ backgroundColor: "var(--widget-primary)",
516
+ color: "var(--widget-primary-foreground)",
517
+ borderRadius: "var(--widget-radius)"
518
+ },
519
+ children: !userAddress ? "Connect Wallet" : "Enter Amount"
520
+ }
521
+ ) })
522
+ ] });
523
+ };
524
+ var SwapForm_default = SwapForm;
525
+
526
+ // src/components/SwapFormSkeleton.tsx
527
+
528
+ var SwapFormSkeleton = () => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col w-full", children: [
529
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
530
+ "div",
531
+ {
532
+ className: "relative px-4 pt-4 pb-2",
533
+ style: { borderBottom: "1px solid var(--widget-border)" },
534
+ children: [
535
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
536
+ "div",
537
+ {
538
+ className: "h-12 w-full animate-pulse",
539
+ style: { backgroundColor: "var(--widget-secondary)", borderRadius: "0.25rem" }
540
+ }
541
+ ),
542
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
543
+ "div",
544
+ {
545
+ className: "mt-2 h-20 w-2/3 animate-pulse",
546
+ style: { backgroundColor: "var(--widget-secondary)", opacity: 0.5, borderRadius: "0.25rem" }
547
+ }
548
+ ),
549
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-1 mb-1 flex w-full items-center justify-between", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
550
+ "div",
551
+ {
552
+ className: "h-4 w-12 animate-pulse",
553
+ style: { backgroundColor: "var(--widget-secondary)", opacity: 0.4, borderRadius: "0.25rem" }
554
+ }
555
+ ) })
556
+ ]
557
+ }
558
+ ),
559
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex justify-center -my-4 relative z-10", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
560
+ "div",
561
+ {
562
+ className: "h-8 w-8",
563
+ style: {
564
+ border: "1px solid var(--widget-border)",
565
+ backgroundColor: "var(--widget-card)",
566
+ borderRadius: "9999px"
567
+ }
568
+ }
569
+ ) }),
570
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "relative px-4 pt-6 pb-2", children: [
571
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
572
+ "div",
573
+ {
574
+ className: "h-12 w-full animate-pulse",
575
+ style: { backgroundColor: "var(--widget-secondary)", borderRadius: "0.25rem" }
576
+ }
577
+ ),
578
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
579
+ "div",
580
+ {
581
+ className: "mt-2 h-20 w-2/3 animate-pulse",
582
+ style: { backgroundColor: "var(--widget-secondary)", opacity: 0.5, borderRadius: "0.25rem" }
583
+ }
584
+ ),
585
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-1 mb-1 flex w-full items-center justify-between", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
586
+ "div",
587
+ {
588
+ className: "h-4 w-12 animate-pulse",
589
+ style: { backgroundColor: "var(--widget-secondary)", opacity: 0.4, borderRadius: "0.25rem" }
590
+ }
591
+ ) })
592
+ ] }),
593
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
594
+ "div",
595
+ {
596
+ className: "px-4",
597
+ style: {
598
+ height: "28px",
599
+ borderTop: "1px solid var(--widget-border)",
600
+ borderBottom: "1px solid var(--widget-border)"
601
+ }
602
+ }
603
+ ),
604
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "relative px-4 py-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
605
+ "div",
606
+ {
607
+ className: "w-full animate-pulse",
608
+ style: {
609
+ height: "44px",
610
+ backgroundColor: "var(--widget-secondary)",
611
+ borderRadius: "var(--widget-radius)",
612
+ opacity: 0.6
613
+ }
614
+ }
615
+ ) })
616
+ ] });
617
+
618
+ // src/components/SwapHeader.tsx
619
+
620
+
621
+
622
+ var TextScrambleDisplay = ({
623
+ targetText,
624
+ isError
625
+ }) => {
626
+ const { displayText, suffix, characterColors } = _chunkGZUTUD5Ocjs.useTextScramble.call(void 0,
627
+ targetText,
628
+ isError
629
+ );
630
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
631
+ displayText.split("").map((char, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
632
+ "span",
633
+ {
634
+ style: characterColors[index] ? { color: "var(--widget-destructive)" } : void 0,
635
+ children: char
636
+ },
637
+ index
638
+ )),
639
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
640
+ "span",
641
+ {
642
+ style: {
643
+ color: isError ? "var(--widget-destructive)" : "var(--widget-muted-foreground)",
644
+ opacity: isError ? 0.5 : 1
645
+ },
646
+ children: suffix
647
+ }
648
+ )
649
+ ] });
650
+ };
651
+ var SwapHeader = ({
652
+ headerText,
653
+ onBackClick,
654
+ isSameChain,
655
+ isWrappingPair,
656
+ isUnwrappingPair,
657
+ hasLowLiquidity,
658
+ hasInsufficientLiquidity,
659
+ hasRoutingError,
660
+ hasSizeCapError
661
+ }) => {
662
+ const view = _chunk6XB5R4GFcjs.useWidgetSwapUIStore.call(void 0, (state) => state.view);
663
+ const {
664
+ isRecipientInputOpen,
665
+ hasAllowanceError,
666
+ hoveredChainName,
667
+ isTrackingTx,
668
+ txStatus,
669
+ walletTab
670
+ } = _chunk6XB5R4GFcjs.useWidgetSwapUIStore.call(void 0,
671
+ _shallow.useShallow.call(void 0, (state) => ({
672
+ isRecipientInputOpen: state.isRecipientInputOpen,
673
+ hasAllowanceError: state.hasAllowanceError,
674
+ hoveredChainName: state.hoveredChainName,
675
+ isTrackingTx: state.isTrackingTx,
676
+ txStatus: state.txStatus,
677
+ walletTab: state.walletTab
678
+ }))
679
+ );
680
+ const { web3ConnectionType, swapHeaderVariant, customWalletUI, walletButtonEnabled } = _chunkGZUTUD5Ocjs.useWidgetConfig.call(void 0, );
681
+ const { isConnected } = _chunkPGYOJ5RBcjs.useWalletState.call(void 0, );
682
+ const { openAccountModal } = _chunkHXOGJSAIcjs.useWalletModal.call(void 0, );
683
+ const [mounted, setMounted] = _react.useState.call(void 0, false);
684
+ _react.useEffect.call(void 0, () => setMounted(true), []);
685
+ const [isRecipientButtonHovered, setIsRecipientButtonHovered] = _react.useState.call(void 0, false);
686
+ const scrambleKey = `${view}-${isRecipientButtonHovered}-${isRecipientInputOpen}-${hoveredChainName || "none"}`;
687
+ const getHeaderText = () => {
688
+ if (isTrackingTx && txStatus) {
689
+ switch (txStatus) {
690
+ case "pending":
691
+ return "Trade Pending";
692
+ case "received":
693
+ return "Trade Received";
694
+ case "completed":
695
+ return "Trade Filled";
696
+ case "failed":
697
+ return "Trade Failed";
698
+ case "cancelled":
699
+ return "Trade Cancelled";
700
+ default:
701
+ return "Processing Trade";
702
+ }
703
+ }
704
+ if (hoveredChainName && (view === "baseSelection" || view === "quoteSelection" || view === "baseChainSelection" || view === "quoteChainSelection")) {
705
+ return hoveredChainName;
706
+ }
707
+ if (view === "swap" && isRecipientButtonHovered) {
708
+ return isRecipientInputOpen ? "Remove Custom Recipient" : "Add Custom Recipient";
709
+ }
710
+ switch (view) {
711
+ case "wallet":
712
+ return "Wallet";
713
+ case "baseSelection":
714
+ return "Select Source Token";
715
+ case "quoteSelection":
716
+ return "Select Destination Token";
717
+ case "baseChainSelection":
718
+ return "Select Source Chain";
719
+ case "quoteChainSelection":
720
+ return "Select Destination Chain";
721
+ default:
722
+ if (view === "swap") {
723
+ if (hasAllowanceError && !isWrappingPair && !isUnwrappingPair)
724
+ return "Allowance check failed";
725
+ if (hasSizeCapError && !isWrappingPair && !isUnwrappingPair)
726
+ return "Size limit exceeded";
727
+ if (hasInsufficientLiquidity && !isWrappingPair && !isUnwrappingPair)
728
+ return "Insufficient Liquidity";
729
+ if (hasRoutingError && !isWrappingPair && !isUnwrappingPair)
730
+ return "Route Not Found";
731
+ if (hasLowLiquidity && !isWrappingPair && !isUnwrappingPair)
732
+ return "High Price Impact";
733
+ }
734
+ if (isSameChain && !isWrappingPair && !isUnwrappingPair) return "Swap";
735
+ if (isWrappingPair) return "Wrap";
736
+ if (isUnwrappingPair) return "Unwrap";
737
+ return headerText;
738
+ }
739
+ };
740
+ const targetHeaderText = getHeaderText();
741
+ const isErrorMessage = !isTrackingTx && view === "swap" && !isRecipientButtonHovered && (hasAllowanceError && !isWrappingPair && !isUnwrappingPair || hasSizeCapError && !isWrappingPair && !isUnwrappingPair || hasInsufficientLiquidity && !isWrappingPair && !isUnwrappingPair || hasRoutingError && !isWrappingPair && !isUnwrappingPair || hasLowLiquidity && !isWrappingPair && !isUnwrappingPair);
742
+ const statusVarMap = {
743
+ pending: "var(--widget-status-pending)",
744
+ received: "var(--widget-status-received)",
745
+ completed: "var(--widget-status-completed)",
746
+ failed: "var(--widget-status-failed)",
747
+ cancelled: "var(--widget-status-failed)"
748
+ };
749
+ const getHeaderTextColor = () => {
750
+ if (!isTrackingTx || !txStatus) return null;
751
+ return _nullishCoalesce(statusVarMap[txStatus], () => ( null));
752
+ };
753
+ const renderRightComponent = () => {
754
+ if (isTrackingTx) return null;
755
+ if (view === "swap") {
756
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
757
+ walletButtonEnabled && mounted && web3ConnectionType === "custom" && isConnected && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
758
+ "button",
759
+ {
760
+ onClick: () => {
761
+ if (customWalletUI === "provider" && openAccountModal) {
762
+ openAccountModal();
763
+ } else {
764
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().setView("wallet");
765
+ }
766
+ },
767
+ "aria-label": "Open wallet",
768
+ className: "size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",
769
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
770
+ "svg",
771
+ {
772
+ className: "size-3.5",
773
+ viewBox: "0 0 24 24",
774
+ fill: "none",
775
+ xmlns: "http://www.w3.org/2000/svg",
776
+ children: [
777
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { x: "2", y: "5", width: "20", height: "15", rx: "2", stroke: "currentColor", strokeWidth: "1.5" }),
778
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M16 12C16 11.4477 16.4477 11 17 11H21V13H17C16.4477 13 16 12.5523 16 12Z", fill: "currentColor" }),
779
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M2 9H22", stroke: "currentColor", strokeWidth: "1.5" })
780
+ ]
781
+ }
782
+ )
783
+ }
784
+ ),
785
+ walletButtonEnabled && mounted && web3ConnectionType === "standalone" && isConnected && openAccountModal && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
786
+ "button",
787
+ {
788
+ onClick: () => openAccountModal(),
789
+ "aria-label": "Open account",
790
+ className: "size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",
791
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
792
+ "svg",
793
+ {
794
+ className: "size-3.5",
795
+ viewBox: "0 0 24 24",
796
+ fill: "none",
797
+ xmlns: "http://www.w3.org/2000/svg",
798
+ children: [
799
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { x: "2", y: "5", width: "20", height: "15", rx: "2", stroke: "currentColor", strokeWidth: "1.5" }),
800
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M16 12C16 11.4477 16.4477 11 17 11H21V13H17C16.4477 13 16 12.5523 16 12Z", fill: "currentColor" }),
801
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M2 9H22", stroke: "currentColor", strokeWidth: "1.5" })
802
+ ]
803
+ }
804
+ )
805
+ }
806
+ ),
807
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
808
+ "button",
809
+ {
810
+ onClick: () => _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().toggleRecipientInput(),
811
+ onMouseEnter: () => setIsRecipientButtonHovered(true),
812
+ onMouseLeave: () => setIsRecipientButtonHovered(false),
813
+ "aria-label": isRecipientInputOpen ? "Remove custom recipient" : "Add custom recipient",
814
+ className: `size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors hover:text-(--widget-foreground) hover:opacity-100 ${isRecipientInputOpen ? "text-(--widget-destructive) opacity-80" : "text-(--widget-muted-foreground) opacity-60"}`,
815
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
816
+ "svg",
817
+ {
818
+ className: "size-3.5",
819
+ viewBox: "0 0 24 24",
820
+ fill: "none",
821
+ xmlns: "http://www.w3.org/2000/svg",
822
+ children: [
823
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
824
+ "path",
825
+ {
826
+ d: "M2 7.75C1.58579 7.75 1.25 8.08579 1.25 8.5C1.25 8.91421 1.58579 9.25 2 9.25V7.75ZM2 8.5V9.25H13.5V8.5V7.75H2V8.5Z",
827
+ fill: "currentColor"
828
+ }
829
+ ),
830
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
831
+ "path",
832
+ {
833
+ d: "M6 16.5H8",
834
+ stroke: "currentColor",
835
+ strokeWidth: "1.5",
836
+ strokeMiterlimit: "10",
837
+ strokeLinecap: "butt",
838
+ strokeLinejoin: "miter"
839
+ }
840
+ ),
841
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
842
+ "path",
843
+ {
844
+ d: "M10.5 16.5H14.5",
845
+ stroke: "currentColor",
846
+ strokeWidth: "1.5",
847
+ strokeMiterlimit: "10",
848
+ strokeLinecap: "butt",
849
+ strokeLinejoin: "miter"
850
+ }
851
+ ),
852
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
853
+ "path",
854
+ {
855
+ d: "M22 12.03V16.11C22 20.5 22 20.5 17.56 20.5H6.44C2 20.5 2 20.5 2 16.11V7.89C2 3.5 2 3.5 6.44 3.5H13.5",
856
+ stroke: "currentColor",
857
+ strokeWidth: "1.5",
858
+ strokeLinejoin: "miter"
859
+ }
860
+ ),
861
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
862
+ "g",
863
+ {
864
+ style: {
865
+ transform: `rotate(${isRecipientInputOpen ? "45deg" : "0deg"})`,
866
+ transformOrigin: "18.75px 6.75px",
867
+ transition: "transform 150ms ease-out"
868
+ },
869
+ children: [
870
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
871
+ "path",
872
+ {
873
+ d: "M15 6.75H22.5",
874
+ stroke: "currentColor",
875
+ strokeWidth: "1.5"
876
+ }
877
+ ),
878
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
879
+ "path",
880
+ {
881
+ d: "M18.75 10.5V3",
882
+ stroke: "currentColor",
883
+ strokeWidth: "1.5"
884
+ }
885
+ )
886
+ ]
887
+ }
888
+ )
889
+ ]
890
+ }
891
+ )
892
+ }
893
+ )
894
+ ] });
895
+ }
896
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
897
+ "button",
898
+ {
899
+ onClick: () => onBackClick ? onBackClick() : _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().setView("swap"),
900
+ className: "flex cursor-pointer items-center justify-center whitespace-nowrap h-6 transition-colors text-(--widget-muted-foreground) opacity-70 hover:text-(--widget-foreground) hover:opacity-100",
901
+ children: [
902
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "pr-1", children: "\u2190" }),
903
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm", children: "Back" })
904
+ ]
905
+ }
906
+ );
907
+ };
908
+ const headerTextColor = getHeaderTextColor();
909
+ if (swapHeaderVariant === "none") return null;
910
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "w-full pt-3 px-2 mono text-base flex flex-row justify-between h-6 shrink-0", children: [
911
+ view === "wallet" ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1 mono uppercase -translate-y-0.5 text-xs", children: [
912
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
913
+ "button",
914
+ {
915
+ type: "button",
916
+ onClick: () => _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().setWalletTab("wallet"),
917
+ className: "cursor-pointer transition-colors",
918
+ style: {
919
+ color: walletTab === "wallet" ? "var(--widget-foreground)" : "var(--widget-muted-foreground)"
920
+ },
921
+ children: [
922
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { color: "var(--widget-muted-foreground)" }, children: ">> " }),
923
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Wallet" })
924
+ ]
925
+ }
926
+ ),
927
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { color: "var(--widget-foreground)", opacity: 0.4 }, children: ">>" }),
928
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
929
+ "button",
930
+ {
931
+ type: "button",
932
+ onClick: () => _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().setWalletTab("activity"),
933
+ className: "cursor-pointer transition-colors",
934
+ style: {
935
+ color: walletTab === "activity" ? "var(--widget-foreground)" : "var(--widget-muted-foreground)"
936
+ },
937
+ children: "Activity"
938
+ }
939
+ )
940
+ ] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mono uppercase -translate-y-0.5 text-xs flex items-center", children: [
941
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
942
+ "span",
943
+ {
944
+ className: "mr-1.5",
945
+ style: { color: "var(--widget-muted-foreground)", opacity: 0.4 },
946
+ children: ">> "
947
+ }
948
+ ),
949
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
950
+ "span",
951
+ {
952
+ className: "relative",
953
+ style: { color: headerTextColor || "var(--widget-foreground)" },
954
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
955
+ TextScrambleDisplay,
956
+ {
957
+ targetText: targetHeaderText,
958
+ isError: _nullishCoalesce(isErrorMessage, () => ( false))
959
+ }
960
+ )
961
+ },
962
+ scrambleKey
963
+ )
964
+ ] }),
965
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-row items-center", children: renderRightComponent() })
966
+ ] });
967
+ };
968
+ var SwapHeader_default = SwapHeader;
969
+
970
+ // src/components/SwapContainer.tsx
971
+
972
+ var AssetSelectionMenu = _react.lazy.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("./AssetSelectionMenu-Y3EB32BT.cjs"))));
973
+ var ChainSelectionMenu = _react.lazy.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("./ChainSelectionMenu-FBAPPFKI.cjs"))));
974
+ var SwapFormHorizontal = _react.lazy.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("./SwapFormHorizontal-WG3Z3CFT.cjs"))));
975
+ var SwapFormSplit = _react.lazy.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("./SwapFormSplit-VDDIRQUQ.cjs"))));
976
+ var WidgetWalletPanel = _react.lazy.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("./WidgetWalletPanel-T7H6FGVN.cjs"))).then((m) => ({ default: m.WidgetWalletPanel })));
977
+ var WalletPlaceholderPanel = _react.lazy.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("./WalletPlaceholderPanel-FZ6XIAMF.cjs"))).then((m) => ({ default: m.WalletPlaceholderPanel })));
978
+ var SwapContainerInner = ({
979
+ onSwapComplete,
980
+ cardStyles,
981
+ cardWidth
982
+ }) => {
983
+ const {
984
+ baseToken,
985
+ quoteToken,
986
+ baseAmount,
987
+ quoteAmount,
988
+ isWrappingPair,
989
+ isUnwrappingPair,
990
+ isRegistryLoading
991
+ } = _chunk6XB5R4GFcjs.useSwapFormContext.call(void 0, );
992
+ const { liquidityError, routingError, sizeCapError, stop, clear } = _chunkHXOGJSAIcjs.useRfq.call(void 0, );
993
+ const view = _chunk6XB5R4GFcjs.useWidgetSwapUIStore.call(void 0, (state) => state.view);
994
+ const {
995
+ isTransitioning,
996
+ isRecipientInputOpen,
997
+ recipient,
998
+ selectedChainFilterChainId
999
+ } = _chunk6XB5R4GFcjs.useWidgetSwapUIStore.call(void 0,
1000
+ _shallow.useShallow.call(void 0, (state) => ({
1001
+ isTransitioning: state.isTransitioning,
1002
+ isRecipientInputOpen: state.isRecipientInputOpen,
1003
+ recipient: state.recipient,
1004
+ selectedChainFilterChainId: _nullishCoalesce(_optionalChain([state, 'access', _3 => _3.selectedChainFilter, 'optionalAccess', _4 => _4.chainId]), () => ( null))
1005
+ }))
1006
+ );
1007
+ const enterTimeoutRef = _react.useRef.call(void 0, null);
1008
+ const exitTimeoutRef = _react.useRef.call(void 0, null);
1009
+ const [exitingOverlay, setExitingOverlay] = _react.useState.call(void 0, null);
1010
+ _chunkHXOGJSAIcjs.useBalanceEventSubscription.call(void 0, );
1011
+ _react.useEffect.call(void 0, () => {
1012
+ return () => {
1013
+ if (enterTimeoutRef.current) clearTimeout(enterTimeoutRef.current);
1014
+ if (exitTimeoutRef.current) clearTimeout(exitTimeoutRef.current);
1015
+ };
1016
+ }, []);
1017
+ _react.useEffect.call(void 0, () => {
1018
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().resetUI();
1019
+ }, []);
1020
+ _react.useEffect.call(void 0, () => {
1021
+ if (!isTransitioning) return;
1022
+ enterTimeoutRef.current = setTimeout(() => {
1023
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().setIsTransitioning(false);
1024
+ enterTimeoutRef.current = null;
1025
+ }, 20);
1026
+ return () => {
1027
+ if (enterTimeoutRef.current) {
1028
+ clearTimeout(enterTimeoutRef.current);
1029
+ enterTimeoutRef.current = null;
1030
+ }
1031
+ };
1032
+ }, [isTransitioning]);
1033
+ const transitionToView = _react.useCallback.call(void 0,
1034
+ (newView, type = "navigation") => {
1035
+ if (exitTimeoutRef.current) {
1036
+ clearTimeout(exitTimeoutRef.current);
1037
+ exitTimeoutRef.current = null;
1038
+ setExitingOverlay(null);
1039
+ }
1040
+ const currentView = _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().view;
1041
+ if (currentView !== "swap" && newView !== "swap") {
1042
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().setView(newView);
1043
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().setIsTransitioning(false);
1044
+ } else {
1045
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().transitionToView(newView, type);
1046
+ }
1047
+ },
1048
+ []
1049
+ );
1050
+ const handleBackToSwap = _react.useCallback.call(void 0, () => {
1051
+ if (enterTimeoutRef.current) {
1052
+ clearTimeout(enterTimeoutRef.current);
1053
+ enterTimeoutRef.current = null;
1054
+ }
1055
+ if (exitTimeoutRef.current) {
1056
+ clearTimeout(exitTimeoutRef.current);
1057
+ exitTimeoutRef.current = null;
1058
+ }
1059
+ const currentView = _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().view;
1060
+ setExitingOverlay(currentView);
1061
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().setChainFilter(null);
1062
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().setView("swap");
1063
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().setIsTransitioning(false);
1064
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().resetAssetSelection();
1065
+ exitTimeoutRef.current = setTimeout(() => {
1066
+ setExitingOverlay(null);
1067
+ exitTimeoutRef.current = null;
1068
+ }, 200);
1069
+ }, []);
1070
+ const handleChainFilterSelect = _react.useCallback.call(void 0,
1071
+ (chainId) => {
1072
+ const previousView = view;
1073
+ const side = previousView === "baseChainSelection" ? "base" : "quote";
1074
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().setChainFilter({ chainId, side });
1075
+ _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().pushRecentChain(chainId);
1076
+ transitionToView(
1077
+ side === "base" ? "baseSelection" : "quoteSelection",
1078
+ "chainSelection"
1079
+ );
1080
+ },
1081
+ [view, transitionToView]
1082
+ );
1083
+ const handleMoreChainsClick = _react.useCallback.call(void 0, () => {
1084
+ const currentView = _chunk6XB5R4GFcjs.useWidgetSwapUIStore.getState().view;
1085
+ if (currentView === "baseSelection") {
1086
+ transitionToView("baseChainSelection", "chainSelection");
1087
+ } else if (currentView === "quoteSelection") {
1088
+ transitionToView("quoteChainSelection", "chainSelection");
1089
+ }
1090
+ }, [transitionToView]);
1091
+ const handleSwapInitiated = _react.useCallback.call(void 0, () => {
1092
+ stop();
1093
+ clear();
1094
+ }, [stop, clear]);
1095
+ const isSameChain = baseToken && quoteToken ? baseToken.chainId === quoteToken.chainId : true;
1096
+ const getHeaderText = () => {
1097
+ switch (view) {
1098
+ case "wallet":
1099
+ return "Wallet";
1100
+ case "baseSelection":
1101
+ return "Select Input Token";
1102
+ case "quoteSelection":
1103
+ return "Select Output Token";
1104
+ case "baseChainSelection":
1105
+ case "quoteChainSelection":
1106
+ return "Select Chain";
1107
+ default:
1108
+ return "Swap";
1109
+ }
1110
+ };
1111
+ const { assetMenuVariant, widgetType, customWalletUI } = _chunkGZUTUD5Ocjs.useWidgetConfig.call(void 0, );
1112
+ const isTokenSelection = view === "baseSelection" || view === "quoteSelection";
1113
+ const isChainSelection = view === "baseChainSelection" || view === "quoteChainSelection";
1114
+ const isSideBySide = assetMenuVariant === "split" && (widgetType === "default" || widgetType === "compact");
1115
+ const isInlineMenu = assetMenuVariant === "split" && (widgetType === "horizontal" || widgetType === "split");
1116
+ const isPanelMode = assetMenuVariant === "default";
1117
+ const showSwapForm = view === "swap" || isTokenSelection || isChainSelection || view === "wallet";
1118
+ const isTokenSelectionExiting = exitingOverlay === "baseSelection" || exitingOverlay === "quoteSelection";
1119
+ const isChainSelectionExiting = exitingOverlay === "baseChainSelection" || exitingOverlay === "quoteChainSelection";
1120
+ const showTokenOverlay = isTokenSelection || isTokenSelectionExiting;
1121
+ const showChainOverlay = isChainSelection || isChainSelectionExiting;
1122
+ const isTokenOverlayActive = isTokenSelection && !isTransitioning;
1123
+ const isChainOverlayActive = isChainSelection && !isTransitioning;
1124
+ const effectiveTokenView = isTokenSelection ? view : exitingOverlay;
1125
+ const menuSide = effectiveTokenView === "baseSelection" ? "base" : "quote";
1126
+ const menuOtherAsset = effectiveTokenView === "baseSelection" ? quoteToken : baseToken;
1127
+ const effectiveChainView = isChainSelection ? view : exitingOverlay;
1128
+ const chainMenuSide = effectiveChainView === "baseChainSelection" ? "base" : "quote";
1129
+ const overlayStyle = (isActive) => ({
1130
+ backgroundColor: "var(--widget-background)",
1131
+ opacity: isActive ? 1 : 0,
1132
+ transform: isActive ? "translateY(0)" : "translateY(6px)",
1133
+ transition: "opacity 200ms ease-in-out, transform 200ms ease-in-out"
1134
+ });
1135
+ const hasActiveOverlay = isPanelMode && (isTokenSelection || isChainSelection || view === "wallet" || exitingOverlay != null);
1136
+ const formContent = isRegistryLoading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SwapFormSkeleton, {}) : widgetType === "horizontal" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: null, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1137
+ SwapFormHorizontal,
1138
+ {
1139
+ onSwapComplete,
1140
+ onSwapInitiated: handleSwapInitiated,
1141
+ onBackToSwap: isInlineMenu ? handleBackToSwap : void 0,
1142
+ onMoreChainsClick: isInlineMenu ? handleMoreChainsClick : void 0
1143
+ }
1144
+ ) }) : widgetType === "split" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: null, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1145
+ SwapFormSplit,
1146
+ {
1147
+ onSwapComplete,
1148
+ onSwapInitiated: handleSwapInitiated,
1149
+ onBackToSwap: isInlineMenu ? handleBackToSwap : void 0,
1150
+ onMoreChainsClick: isInlineMenu ? handleMoreChainsClick : void 0
1151
+ }
1152
+ ) }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SwapForm_default, { onSwapComplete, onSwapInitiated: handleSwapInitiated });
1153
+ const cs = _nullishCoalesce(cardStyles, () => ( {}));
1154
+ const leftCardRef = _react.useRef.call(void 0, null);
1155
+ const [leftCardHeight, setLeftCardHeight] = _react.useState.call(void 0, 420);
1156
+ _react.useEffect.call(void 0, () => {
1157
+ if (!isSideBySide) return;
1158
+ const el = leftCardRef.current;
1159
+ if (!el) return;
1160
+ const observer = new ResizeObserver((entries) => {
1161
+ for (const entry of entries) {
1162
+ setLeftCardHeight(entry.contentRect.height);
1163
+ }
1164
+ });
1165
+ observer.observe(el);
1166
+ return () => observer.disconnect();
1167
+ }, [isSideBySide]);
1168
+ if (isSideBySide) {
1169
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1170
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1171
+ "div",
1172
+ {
1173
+ ref: leftCardRef,
1174
+ className: "flex flex-col w-full overflow-hidden transition-colors duration-300",
1175
+ style: {
1176
+ flex: "1 1 0",
1177
+ minWidth: 0,
1178
+ ...cs
1179
+ },
1180
+ children: [
1181
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1182
+ SwapHeader_default,
1183
+ {
1184
+ headerText: "Swap",
1185
+ onBackClick: handleBackToSwap,
1186
+ isSameChain,
1187
+ isWrappingPair,
1188
+ isUnwrappingPair,
1189
+ hasLowLiquidity: liquidityError,
1190
+ hasInsufficientLiquidity: liquidityError,
1191
+ hasRoutingError: routingError,
1192
+ hasSizeCapError: sizeCapError
1193
+ }
1194
+ ),
1195
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-hidden", children: formContent })
1196
+ ]
1197
+ }
1198
+ ),
1199
+ (showTokenOverlay || showChainOverlay) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1200
+ "div",
1201
+ {
1202
+ className: "flex flex-col overflow-hidden shrink-0",
1203
+ style: {
1204
+ width: cardWidth,
1205
+ height: `${leftCardHeight}px`,
1206
+ ...cs,
1207
+ ...overlayStyle(
1208
+ (isTokenSelection || isChainSelection) && !isTransitioning
1209
+ )
1210
+ },
1211
+ children: isTokenSelection || isTokenSelectionExiting ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: null, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1212
+ AssetSelectionMenu,
1213
+ {
1214
+ toggle: handleBackToSwap,
1215
+ side: menuSide,
1216
+ otherAsset: menuOtherAsset,
1217
+ onMoreChainsClick: handleMoreChainsClick,
1218
+ selectedChainFilter: selectedChainFilterChainId
1219
+ }
1220
+ ) }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: null, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1221
+ ChainSelectionMenu,
1222
+ {
1223
+ toggle: handleBackToSwap,
1224
+ side: chainMenuSide,
1225
+ onChainSelect: handleChainFilterSelect
1226
+ }
1227
+ ) })
1228
+ }
1229
+ )
1230
+ ] });
1231
+ }
1232
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1233
+ "div",
1234
+ {
1235
+ className: "flex flex-col w-full",
1236
+ style: {
1237
+ overflow: "hidden",
1238
+ position: "relative"
1239
+ },
1240
+ children: [
1241
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1242
+ SwapHeader_default,
1243
+ {
1244
+ headerText: getHeaderText(),
1245
+ onBackClick: handleBackToSwap,
1246
+ isSameChain,
1247
+ isWrappingPair,
1248
+ isUnwrappingPair,
1249
+ hasLowLiquidity: liquidityError,
1250
+ hasInsufficientLiquidity: liquidityError,
1251
+ hasRoutingError: routingError,
1252
+ hasSizeCapError: sizeCapError
1253
+ }
1254
+ ),
1255
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "relative overflow-hidden", children: [
1256
+ showSwapForm && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1257
+ "div",
1258
+ {
1259
+ className: "overflow-hidden",
1260
+ style: hasActiveOverlay ? { pointerEvents: "none" } : void 0,
1261
+ children: formContent
1262
+ }
1263
+ ),
1264
+ (view === "wallet" || exitingOverlay === "wallet") && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1265
+ "div",
1266
+ {
1267
+ className: "absolute inset-0 overflow-hidden",
1268
+ style: overlayStyle(view === "wallet" && !isTransitioning),
1269
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: null, children: customWalletUI === "none" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WalletPlaceholderPanel, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WidgetWalletPanel, {}) })
1270
+ }
1271
+ ),
1272
+ isPanelMode && showTokenOverlay && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1273
+ "div",
1274
+ {
1275
+ className: "absolute inset-0 overflow-hidden",
1276
+ style: overlayStyle(isTokenOverlayActive),
1277
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: null, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1278
+ AssetSelectionMenu,
1279
+ {
1280
+ toggle: handleBackToSwap,
1281
+ side: menuSide,
1282
+ otherAsset: menuOtherAsset,
1283
+ onMoreChainsClick: handleMoreChainsClick,
1284
+ selectedChainFilter: selectedChainFilterChainId
1285
+ }
1286
+ ) })
1287
+ }
1288
+ ),
1289
+ isPanelMode && showChainOverlay && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1290
+ "div",
1291
+ {
1292
+ className: "absolute inset-0 overflow-hidden",
1293
+ style: overlayStyle(isChainOverlayActive),
1294
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: null, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1295
+ ChainSelectionMenu,
1296
+ {
1297
+ toggle: handleBackToSwap,
1298
+ side: chainMenuSide,
1299
+ onChainSelect: handleChainFilterSelect
1300
+ }
1301
+ ) })
1302
+ }
1303
+ )
1304
+ ] })
1305
+ ]
1306
+ }
1307
+ );
1308
+ };
1309
+ var SwapContainer = ({
1310
+ onSwapComplete,
1311
+ defaultBaseToken,
1312
+ defaultQuoteToken,
1313
+ onBaseTokenChange,
1314
+ onQuoteTokenChange,
1315
+ cardStyles,
1316
+ cardWidth
1317
+ }) => {
1318
+ const { address: userAddress } = _chunkPGYOJ5RBcjs.useWalletState.call(void 0, );
1319
+ const recipient = _chunk6XB5R4GFcjs.useWidgetSwapUIStore.call(void 0, (s) => s.recipient);
1320
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1321
+ _chunk6XB5R4GFcjs.SwapFormProvider,
1322
+ {
1323
+ defaultBaseToken,
1324
+ defaultQuoteToken,
1325
+ onBaseTokenChange,
1326
+ onQuoteTokenChange,
1327
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHXOGJSAIcjs.RfqProvider, { recipient, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1328
+ SwapContainerInner,
1329
+ {
1330
+ onSwapComplete,
1331
+ cardStyles,
1332
+ cardWidth
1333
+ }
1334
+ ) })
1335
+ }
1336
+ );
1337
+ };
1338
+
1339
+ // src/theme/ThemeContext.tsx
1340
+
1341
+
1342
+ // src/theme/types.ts
1343
+ var defaultLightTheme = {
1344
+ background: "#ffffff",
1345
+ foreground: "#0a0a0a",
1346
+ card: "#ffffff",
1347
+ "card-foreground": "#0a0a0a",
1348
+ popover: "#ffffff",
1349
+ "popover-foreground": "#0a0a0a",
1350
+ primary: "#171717",
1351
+ "primary-foreground": "#fafafa",
1352
+ secondary: "#f5f5f5",
1353
+ "secondary-foreground": "#171717",
1354
+ muted: "#f5f5f5",
1355
+ "muted-foreground": "#737373",
1356
+ accent: "#f5f5f5",
1357
+ "accent-foreground": "#171717",
1358
+ destructive: "#e7000b",
1359
+ "destructive-foreground": "#ffffff",
1360
+ border: "#e5e5e5",
1361
+ input: "#e5e5e5",
1362
+ ring: "#a1a1a1",
1363
+ radius: "0.625rem",
1364
+ "border-style": "dotted",
1365
+ "status-pending": "#a1a1aa",
1366
+ "status-received": "#f59e0b",
1367
+ "status-completed": "#10b981",
1368
+ "status-failed": "#ef4444"
1369
+ };
1370
+ var defaultDarkTheme = {
1371
+ background: "#0a0a0a",
1372
+ foreground: "#fafafa",
1373
+ card: "#171717",
1374
+ "card-foreground": "#fafafa",
1375
+ popover: "#262626",
1376
+ "popover-foreground": "#fafafa",
1377
+ primary: "#e5e5e5",
1378
+ "primary-foreground": "#171717",
1379
+ secondary: "#262626",
1380
+ "secondary-foreground": "#fafafa",
1381
+ muted: "#262626",
1382
+ "muted-foreground": "#a1a1a1",
1383
+ accent: "#404040",
1384
+ "accent-foreground": "#fafafa",
1385
+ destructive: "#ff6467",
1386
+ "destructive-foreground": "#fafafa",
1387
+ border: "#282828",
1388
+ input: "#343434",
1389
+ ring: "#737373",
1390
+ radius: "0.625rem",
1391
+ "border-style": "dotted",
1392
+ "status-pending": "#a1a1aa",
1393
+ "status-received": "#fbbf24",
1394
+ "status-completed": "#2dd4bf",
1395
+ "status-failed": "#fb7185"
1396
+ };
1397
+ function themeToCSS(theme) {
1398
+ const vars = {
1399
+ "--widget-background": theme.background,
1400
+ "--widget-foreground": theme.foreground,
1401
+ "--widget-card": theme.card,
1402
+ "--widget-card-foreground": theme["card-foreground"],
1403
+ "--widget-popover": theme.popover,
1404
+ "--widget-popover-foreground": theme["popover-foreground"],
1405
+ "--widget-primary": theme.primary,
1406
+ "--widget-primary-foreground": theme["primary-foreground"],
1407
+ "--widget-secondary": theme.secondary,
1408
+ "--widget-secondary-foreground": theme["secondary-foreground"],
1409
+ "--widget-muted": theme.muted,
1410
+ "--widget-muted-foreground": theme["muted-foreground"],
1411
+ "--widget-accent": theme.accent,
1412
+ "--widget-accent-foreground": theme["accent-foreground"],
1413
+ "--widget-destructive": theme.destructive,
1414
+ "--widget-destructive-foreground": theme["destructive-foreground"],
1415
+ "--widget-border": theme.border,
1416
+ "--widget-input": theme.input,
1417
+ "--widget-ring": theme.ring,
1418
+ "--widget-radius": theme.radius,
1419
+ "--widget-border-style": theme["border-style"] || "dotted"
1420
+ };
1421
+ vars["--widget-font-sans"] = theme["font-sans"] || "inherit";
1422
+ vars["--widget-font-mono"] = theme["font-mono"] || "inherit";
1423
+ vars["--widget-shadow-color"] = theme["shadow-color"] || "oklch(0 0 0)";
1424
+ vars["--widget-shadow-opacity"] = theme["shadow-opacity"] || "0.1";
1425
+ vars["--widget-shadow-blur"] = theme["shadow-blur"] || "3px";
1426
+ vars["--widget-shadow-spread"] = theme["shadow-spread"] || "0px";
1427
+ vars["--widget-shadow-offset-x"] = theme["shadow-offset-x"] || "0";
1428
+ vars["--widget-shadow-offset-y"] = theme["shadow-offset-y"] || "1px";
1429
+ vars["--widget-letter-spacing"] = theme["letter-spacing"] || "normal";
1430
+ vars["--widget-status-pending"] = theme["status-pending"] || "#a1a1aa";
1431
+ vars["--widget-status-received"] = theme["status-received"] || "#fbbf24";
1432
+ vars["--widget-status-completed"] = theme["status-completed"] || "#2dd4bf";
1433
+ vars["--widget-status-failed"] = theme["status-failed"] || "#fb7185";
1434
+ return vars;
1435
+ }
1436
+
1437
+ // src/theme/ThemeContext.tsx
1438
+
1439
+ var WidgetThemeContext = _react.createContext.call(void 0, defaultDarkTheme);
1440
+ function WidgetThemeProvider({ theme, children }) {
1441
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WidgetThemeContext.Provider, { value: theme, children });
1442
+ }
1443
+ function useWidgetTheme() {
1444
+ return _react.useContext.call(void 0, WidgetThemeContext);
1445
+ }
1446
+
1447
+ // src/SwapWidget.tsx
1448
+
1449
+ var EMPTY_CHAINS = [];
1450
+ var EMPTY_SUPPORTED_INPUT_TOKENS = [];
1451
+ var EMPTY_SUPPORTED_OUTPUT_TOKENS = [];
1452
+ var EMPTY_SUPPORTED_CHAINS = [];
1453
+ var WIDGET_CRITICAL_CSS = `
1454
+ .aori-widget .text-2xs { font-size: 0.75rem; }
1455
+ .aori-widget .text-3xs { font-size: 0.68rem; }
1456
+ .aori-widget ::-webkit-scrollbar { width: 0px; height: 0px; display: none; }
1457
+ .aori-widget * { scrollbar-width: none; }
1458
+ .aori-widget input:focus, .aori-widget input:focus-visible,
1459
+ .aori-widget button:focus, .aori-widget button:focus-visible,
1460
+ .aori-widget select:focus, .aori-widget select:focus-visible { outline: none; }
1461
+ `;
1462
+ var WidgetErrorBoundary = (_class = class extends _react2.default.Component {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
1463
+ __init() {this.state = { hasError: false }}
1464
+ static getDerivedStateFromError() {
1465
+ return { hasError: true };
1466
+ }
1467
+ render() {
1468
+ if (this.state.hasError) {
1469
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { style: { padding: "1.5rem", textAlign: "center", color: "var(--widget-foreground, #888)", fontFamily: "system-ui, sans-serif" }, children: [
1470
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { style: { margin: "0 0 0.75rem", fontSize: "0.875rem" }, children: "Something went wrong." }),
1471
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1472
+ "button",
1473
+ {
1474
+ type: "button",
1475
+ onClick: () => this.setState({ hasError: false }),
1476
+ style: {
1477
+ padding: "0.375rem 1rem",
1478
+ fontSize: "0.8125rem",
1479
+ cursor: "pointer",
1480
+ border: "1px solid currentColor",
1481
+ borderRadius: "0.25rem",
1482
+ background: "transparent",
1483
+ color: "inherit"
1484
+ },
1485
+ children: "Retry"
1486
+ }
1487
+ )
1488
+ ] });
1489
+ }
1490
+ return this.props.children;
1491
+ }
1492
+ }, _class);
1493
+ function resolveTheme(cfg) {
1494
+ const base = cfg.theme.mode === "light" ? defaultLightTheme : defaultDarkTheme;
1495
+ const override = cfg.theme.mode === "light" ? cfg.theme.light : cfg.theme.dark;
1496
+ return override ? { ...base, ...override } : base;
1497
+ }
1498
+ function SwapWidget({
1499
+ config,
1500
+ className,
1501
+ onSwapComplete,
1502
+ onBaseTokenChange,
1503
+ onQuoteTokenChange,
1504
+ onRequestConnect,
1505
+ onRequestAccount,
1506
+ customWalletUI = "builtin"
1507
+ }) {
1508
+ _chunkGZUTUD5Ocjs.setApiKey.call(void 0, config.apiKey);
1509
+ _chunkGZUTUD5Ocjs.setRpcOverrides.call(void 0, config.rpcOverrides);
1510
+ _chunkGZUTUD5Ocjs.setVtApiBaseUrl.call(void 0, config.vtApiBaseUrl);
1511
+ const theme = resolveTheme(config);
1512
+ const widgetType = _nullishCoalesce(_optionalChain([config, 'access', _5 => _5.appearance, 'optionalAccess', _6 => _6.widgetType]), () => ( "default"));
1513
+ const tokenDisplay = _nullishCoalesce(_optionalChain([config, 'access', _7 => _7.appearance, 'optionalAccess', _8 => _8.tokenDisplay]), () => ( "default"));
1514
+ const tokenBadgeOrientation = _nullishCoalesce(_optionalChain([config, 'access', _9 => _9.appearance, 'optionalAccess', _10 => _10.tokenBadgeOrientation]), () => ( "left"));
1515
+ const assetMenuVariant = _nullishCoalesce(_optionalChain([config, 'access', _11 => _11.appearance, 'optionalAccess', _12 => _12.assetMenuVariant]), () => ( "default"));
1516
+ const amountInputVariant = _nullishCoalesce(_optionalChain([config, 'access', _13 => _13.appearance, 'optionalAccess', _14 => _14.amountInputVariant]), () => ( "default"));
1517
+ const hideAmountInputSymbol = _nullishCoalesce(_optionalChain([config, 'access', _15 => _15.appearance, 'optionalAccess', _16 => _16.hideAmountInputSymbol]), () => ( false));
1518
+ const swapButtonVariant = _nullishCoalesce(_optionalChain([config, 'access', _17 => _17.appearance, 'optionalAccess', _18 => _18.swapButtonVariant]), () => ( "default"));
1519
+ const swapHeaderVariant = _nullishCoalesce(_optionalChain([config, 'access', _19 => _19.appearance, 'optionalAccess', _20 => _20.swapHeaderVariant]), () => ( "default"));
1520
+ const quoteLoaderVariant = _nullishCoalesce(_optionalChain([config, 'access', _21 => _21.appearance, 'optionalAccess', _22 => _22.quoteLoaderVariant]), () => ( "default"));
1521
+ const walletButtonEnabled = _nullishCoalesce(_optionalChain([config, 'access', _23 => _23.appearance, 'optionalAccess', _24 => _24.walletButtonEnabled]), () => ( true));
1522
+ const fillContainer = _nullishCoalesce(_optionalChain([config, 'access', _25 => _25.appearance, 'optionalAccess', _26 => _26.fillContainer]), () => ( false));
1523
+ const hideBorder = _nullishCoalesce(_optionalChain([config, 'access', _27 => _27.appearance, 'optionalAccess', _28 => _28.hideBorder]), () => ( false));
1524
+ const cssVars = themeToCSS(theme);
1525
+ const isSplitSideBySide = assetMenuVariant === "split" && (widgetType === "default" || widgetType === "compact");
1526
+ const isSelectionOpen = _chunk6XB5R4GFcjs.useWidgetSwapUIStore.call(void 0,
1527
+ (s) => s.view === "baseSelection" || s.view === "quoteSelection" || s.view === "baseChainSelection" || s.view === "quoteChainSelection"
1528
+ );
1529
+ const cardWidth = widgetType === "compact" ? "22rem" : "24rem";
1530
+ const expandedMaxWidth = widgetType === "compact" ? "46rem" : "49rem";
1531
+ const widgetDimensions = isSplitSideBySide ? {
1532
+ maxWidth: isSelectionOpen ? expandedMaxWidth : cardWidth,
1533
+ transition: "max-width 0.3s ease",
1534
+ height: "auto",
1535
+ overflow: "visible",
1536
+ display: "flex",
1537
+ gap: "1rem",
1538
+ alignItems: "stretch",
1539
+ backgroundColor: "transparent",
1540
+ border: "none",
1541
+ borderRadius: 0,
1542
+ boxShadow: "none",
1543
+ padding: 0
1544
+ } : {
1545
+ width: "100%",
1546
+ ...fillContainer ? {} : {
1547
+ maxWidth: widgetType === "split" ? "48rem" : widgetType === "horizontal" ? "48rem" : widgetType === "compact" ? "22rem" : "24rem"
1548
+ },
1549
+ height: "auto",
1550
+ overflow: "hidden"
1551
+ };
1552
+ const cardStyles = {
1553
+ boxSizing: "border-box",
1554
+ backgroundColor: "var(--widget-background)",
1555
+ color: "var(--widget-foreground)",
1556
+ borderRadius: "var(--widget-radius)",
1557
+ ...hideBorder ? { border: "none" } : {
1558
+ borderWidth: "1px",
1559
+ borderStyle: "var(--widget-border-style)",
1560
+ borderColor: "var(--widget-border)"
1561
+ },
1562
+ boxShadow: "var(--widget-shadow-offset-x) var(--widget-shadow-offset-y) var(--widget-shadow-blur) var(--widget-shadow-spread) color-mix(in srgb, var(--widget-shadow-color) calc(var(--widget-shadow-opacity) * 100%), transparent)",
1563
+ padding: "0.25rem 0.5rem",
1564
+ paddingTop: "0.25rem"
1565
+ };
1566
+ const enabledChains = _nullishCoalesce(_optionalChain([config, 'access', _29 => _29.tokens, 'optionalAccess', _30 => _30.enabledChains]), () => ( EMPTY_CHAINS));
1567
+ const supportedInputTokens = _nullishCoalesce(_optionalChain([config, 'access', _31 => _31.tokens, 'optionalAccess', _32 => _32.supportedInputTokens]), () => ( EMPTY_SUPPORTED_INPUT_TOKENS));
1568
+ const supportedOutputTokens = _nullishCoalesce(_optionalChain([config, 'access', _33 => _33.tokens, 'optionalAccess', _34 => _34.supportedOutputTokens]), () => ( EMPTY_SUPPORTED_OUTPUT_TOKENS));
1569
+ const supportedInputChains = _nullishCoalesce(_optionalChain([config, 'access', _35 => _35.tokens, 'optionalAccess', _36 => _36.supportedInputChains]), () => ( EMPTY_SUPPORTED_CHAINS));
1570
+ const supportedOutputChains = _nullishCoalesce(_optionalChain([config, 'access', _37 => _37.tokens, 'optionalAccess', _38 => _38.supportedOutputChains]), () => ( EMPTY_SUPPORTED_CHAINS));
1571
+ const inputSelectionSearch = _nullishCoalesce(_optionalChain([config, 'access', _39 => _39.tokens, 'optionalAccess', _40 => _40.inputSelectionSearch]), () => ( true));
1572
+ const outputSelectionSearch = _nullishCoalesce(_optionalChain([config, 'access', _41 => _41.tokens, 'optionalAccess', _42 => _42.outputSelectionSearch]), () => ( true));
1573
+ const showInputSelectionTokenBalances = _nullishCoalesce(_optionalChain([config, 'access', _43 => _43.tokens, 'optionalAccess', _44 => _44.showInputSelectionTokenBalances]), () => ( true));
1574
+ const showOutputSelectionTokenBalances = _nullishCoalesce(_optionalChain([config, 'access', _45 => _45.tokens, 'optionalAccess', _46 => _46.showOutputSelectionTokenBalances]), () => ( true));
1575
+ const lockBase = _nullishCoalesce(_optionalChain([config, 'access', _47 => _47.tokens, 'optionalAccess', _48 => _48.lockBase]), () => ( false));
1576
+ const lockQuote = _nullishCoalesce(_optionalChain([config, 'access', _49 => _49.tokens, 'optionalAccess', _50 => _50.lockQuote]), () => ( false));
1577
+ const disableInverting = _nullishCoalesce(_optionalChain([config, 'access', _51 => _51.tokens, 'optionalAccess', _52 => _52.disableInverting]), () => ( false));
1578
+ const defaultSlippage = _nullishCoalesce(_optionalChain([config, 'access', _53 => _53.settings, 'optionalAccess', _54 => _54.defaultSlippage]), () => ( 0.01));
1579
+ const hasConnectHandler = !!onRequestConnect;
1580
+ const widgetConfigValue = _react.useMemo.call(void 0,
1581
+ () => ({
1582
+ apiKey: config.apiKey,
1583
+ web3ConnectionType: "custom",
1584
+ enabledChains,
1585
+ supportedInputTokens,
1586
+ supportedOutputTokens,
1587
+ supportedInputChains,
1588
+ supportedOutputChains,
1589
+ inputSelectionSearch,
1590
+ outputSelectionSearch,
1591
+ showInputSelectionTokenBalances,
1592
+ showOutputSelectionTokenBalances,
1593
+ lockBase,
1594
+ lockQuote,
1595
+ disableInverting,
1596
+ defaultSlippage,
1597
+ widgetType,
1598
+ tokenDisplay,
1599
+ tokenBadgeOrientation,
1600
+ assetMenuVariant,
1601
+ amountInputVariant,
1602
+ hideAmountInputSymbol,
1603
+ swapButtonVariant,
1604
+ swapHeaderVariant,
1605
+ quoteLoaderVariant,
1606
+ walletButtonEnabled,
1607
+ hasConnectHandler,
1608
+ customWalletUI
1609
+ }),
1610
+ [
1611
+ config.apiKey,
1612
+ enabledChains,
1613
+ supportedInputTokens,
1614
+ supportedOutputTokens,
1615
+ supportedInputChains,
1616
+ supportedOutputChains,
1617
+ inputSelectionSearch,
1618
+ outputSelectionSearch,
1619
+ showInputSelectionTokenBalances,
1620
+ showOutputSelectionTokenBalances,
1621
+ lockBase,
1622
+ lockQuote,
1623
+ disableInverting,
1624
+ defaultSlippage,
1625
+ widgetType,
1626
+ tokenDisplay,
1627
+ tokenBadgeOrientation,
1628
+ assetMenuVariant,
1629
+ amountInputVariant,
1630
+ hideAmountInputSymbol,
1631
+ swapButtonVariant,
1632
+ swapHeaderVariant,
1633
+ quoteLoaderVariant,
1634
+ walletButtonEnabled,
1635
+ hasConnectHandler,
1636
+ customWalletUI
1637
+ ]
1638
+ );
1639
+ const walletModalValue = _react.useMemo.call(void 0,
1640
+ () => onRequestConnect ? { openConnectModal: onRequestConnect, openAccountModal: onRequestAccount } : null,
1641
+ [onRequestConnect, onRequestAccount]
1642
+ );
1643
+ const inner = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGZUTUD5Ocjs.AoriClientProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGZUTUD5Ocjs.WidgetConfigContext.Provider, { value: widgetConfigValue, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WidgetThemeProvider, { theme, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1644
+ "div",
1645
+ {
1646
+ className: `aori-widget${className ? ` ${className}` : ""}`,
1647
+ style: {
1648
+ ...cssVars,
1649
+ "--font-sans": "var(--widget-font-sans)",
1650
+ "--font-mono": "var(--widget-font-mono)",
1651
+ fontFamily: "var(--widget-font-sans)",
1652
+ letterSpacing: "var(--widget-letter-spacing)",
1653
+ width: "100%",
1654
+ ...widgetDimensions,
1655
+ position: "relative",
1656
+ ...isSplitSideBySide ? {} : cardStyles
1657
+ },
1658
+ children: [
1659
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { dangerouslySetInnerHTML: { __html: WIDGET_CRITICAL_CSS } }),
1660
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WidgetErrorBoundary, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1661
+ SwapContainer,
1662
+ {
1663
+ onSwapComplete,
1664
+ defaultBaseToken: _optionalChain([config, 'access', _55 => _55.tokens, 'optionalAccess', _56 => _56.defaultBase]),
1665
+ defaultQuoteToken: _optionalChain([config, 'access', _57 => _57.tokens, 'optionalAccess', _58 => _58.defaultQuote]),
1666
+ onBaseTokenChange,
1667
+ onQuoteTokenChange,
1668
+ cardStyles: isSplitSideBySide ? cardStyles : void 0,
1669
+ cardWidth: isSplitSideBySide ? cardWidth : void 0
1670
+ }
1671
+ ) })
1672
+ ]
1673
+ }
1674
+ ) }) }) });
1675
+ if (walletModalValue) {
1676
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHXOGJSAIcjs.WalletModalContext.Provider, { value: walletModalValue, children: inner });
1677
+ }
1678
+ return inner;
1679
+ }
1680
+
1681
+ // src/wallet/ConnectButton.tsx
1682
+
1683
+ function ConnectButton() {
1684
+ const { openConnectModal } = _chunkHXOGJSAIcjs.useWalletModal.call(void 0, );
1685
+ const { isConnected, address } = _chunkPGYOJ5RBcjs.useWalletState.call(void 0, );
1686
+ const label = isConnected && address ? `${address.slice(0, 6)}...${address.slice(-4)}` : "Connect";
1687
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1688
+ "button",
1689
+ {
1690
+ type: "button",
1691
+ onClick: () => openConnectModal(),
1692
+ className: "h-8 cursor-pointer px-3 text-xs font-bold uppercase tracking-wide transition-colors duration-150 border border-border rounded-sm bg-card text-foreground hover:bg-secondary hover:border-foreground/20",
1693
+ children: label
1694
+ }
1695
+ );
1696
+ }
1697
+
1698
+ // src/wallet/shared/transports.ts
1699
+ var _wagmi = require('wagmi');
1700
+ function buildTransports(rpcOverrides) {
1701
+ const chainEntries = Object.entries(_chunkGZUTUD5Ocjs.staticChainsConfig);
1702
+ return Object.fromEntries(
1703
+ chainEntries.map(([id, c]) => {
1704
+ const override = _optionalChain([rpcOverrides, 'optionalAccess', _59 => _59[Number(id)]]);
1705
+ const overrideUrls = override ? Array.isArray(override) ? override : [override] : [];
1706
+ const urls = overrideUrls.length > 0 ? [...overrideUrls, ...c.rpcUrls] : c.rpcUrls;
1707
+ return [
1708
+ id,
1709
+ urls.length > 1 ? _wagmi.fallback.call(void 0, urls.map((url) => _wagmi.http.call(void 0, url, { batch: { batchSize: 50, wait: 50 } }))) : _wagmi.http.call(void 0, urls[0], { batch: { batchSize: 50, wait: 50 } })
1710
+ ];
1711
+ })
1712
+ );
1713
+ }
1714
+ var wagmiChains = _chunkGZUTUD5Ocjs.getAllChainConfigs.call(void 0, ).map((c) => c.wagmiChain);
1715
+
1716
+ // src/hooks/useTokenHelpers.ts
1717
+
1718
+ var useTokensForChain = (chainId) => {
1719
+ const { tokenRegistry, isLoadingRegistry, error } = _chunkGZUTUD5Ocjs.useTokenData.call(void 0, );
1720
+ const tokens = _react.useMemo.call(void 0, () => {
1721
+ return tokenRegistry.filter((token) => token.chainId === chainId);
1722
+ }, [tokenRegistry, chainId]);
1723
+ return { tokens, isLoading: isLoadingRegistry, error };
1724
+ };
1725
+ var useIsTokenSupported = (address, chainId) => {
1726
+ const { tokenRegistry } = _chunkGZUTUD5Ocjs.useTokenData.call(void 0, );
1727
+ return _react.useMemo.call(void 0, () => {
1728
+ if (!address || !tokenRegistry.length) return false;
1729
+ return tokenRegistry.some(
1730
+ (token) => token.address.toLowerCase() === address.toLowerCase() && token.chainId === chainId
1731
+ );
1732
+ }, [tokenRegistry, address, chainId]);
1733
+ };
1734
+ var useTokenByAddress = (address, chainId) => {
1735
+ const { getToken } = _chunkGZUTUD5Ocjs.useTokenData.call(void 0, );
1736
+ return _react.useMemo.call(void 0, () => {
1737
+ if (!address || !chainId) return void 0;
1738
+ return getToken(chainId, address);
1739
+ }, [getToken, address, chainId]);
1740
+ };
1741
+ var SUPPORTED_CHAINS = _chunkGZUTUD5Ocjs.getChainKeyToIdMapping.call(void 0, );
1742
+
1743
+
1744
+
1745
+
1746
+
1747
+
1748
+
1749
+
1750
+
1751
+
1752
+
1753
+
1754
+
1755
+
1756
+
1757
+
1758
+
1759
+
1760
+
1761
+
1762
+
1763
+
1764
+
1765
+
1766
+
1767
+
1768
+
1769
+
1770
+
1771
+
1772
+
1773
+
1774
+
1775
+
1776
+
1777
+
1778
+
1779
+ exports.ChainSwitch = _chunkHXOGJSAIcjs.ChainSwitch; exports.ConnectButton = ConnectButton; exports.RfqProvider = _chunkHXOGJSAIcjs.RfqProvider; exports.SignSwap = _chunkHXOGJSAIcjs.SignSwap; exports.SwapFormProvider = _chunk6XB5R4GFcjs.SwapFormProvider; exports.SwapWidget = SwapWidget; exports.WidgetThemeProvider = WidgetThemeProvider; exports.buildTransports = buildTransports; exports.canSubmitOrder = _chunkHXOGJSAIcjs.canSubmitOrder; exports.cleanupOldSubmissions = _chunkHXOGJSAIcjs.cleanupOldSubmissions; exports.defaultDarkTheme = defaultDarkTheme; exports.defaultLightTheme = defaultLightTheme; exports.isQuoteFresh = _chunkHXOGJSAIcjs.isQuoteFresh; exports.markOrderAsSubmitted = _chunkHXOGJSAIcjs.markOrderAsSubmitted; exports.pollOrderStatus = _chunkHXOGJSAIcjs.pollOrderStatus; exports.themeToCSS = themeToCSS; exports.useBalanceEventListener = _chunkHXOGJSAIcjs.useBalanceEventListener; exports.useBalanceEventSubscription = _chunkHXOGJSAIcjs.useBalanceEventSubscription; exports.useEmitBalanceEvent = _chunkHXOGJSAIcjs.useEmitBalanceEvent; exports.useIsTokenSupported = useIsTokenSupported; exports.useOrderStatusPolling = _chunkHXOGJSAIcjs.useOrderStatusPolling; exports.useRfq = _chunkHXOGJSAIcjs.useRfq; exports.useSwapForm = _chunk6XB5R4GFcjs.useSwapForm; exports.useSwapFormContext = _chunk6XB5R4GFcjs.useSwapFormContext; exports.useTokenByAddress = useTokenByAddress; exports.useTokenSelection = _chunk6XB5R4GFcjs.useTokenSelection; exports.useTokenSelectionStore = _chunk6XB5R4GFcjs.useTokenSelectionStore; exports.useTokensForChain = useTokensForChain; exports.useTransactionRegistry = _chunkHXOGJSAIcjs.useTransactionRegistry; exports.useUnwrapToken = _chunkHXOGJSAIcjs.useUnwrapToken; exports.useWalletModal = _chunkHXOGJSAIcjs.useWalletModal; exports.useWalletState = _chunkPGYOJ5RBcjs.useWalletState; exports.useWidgetSwapUIStore = _chunk6XB5R4GFcjs.useWidgetSwapUIStore; exports.useWidgetTheme = useWidgetTheme; exports.useWrapToken = _chunkHXOGJSAIcjs.useWrapToken; exports.wagmiChains = wagmiChains;
1780
+ //# sourceMappingURL=index.cjs.map