@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
@@ -0,0 +1,32 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+
28
+
29
+
30
+
31
+ exports.__commonJS = __commonJS; exports.__toESM = __toESM;
32
+ //# sourceMappingURL=chunk-NBJPKJBC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BAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;AAC1H,EAAE;AACF,EAAE,OAAO,EAAE;AACX,CAAC;AACD,IAAI,QAAQ,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,GAAG,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW;AAChH;AACA;AACA;AACA;AACA,EAAE,WAAW,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,EAAE,MAAM;AACjH,EAAE;AACF,CAAC,CAAC;AACF;AACA;AACE;AACA;AACF,2DAAC","file":"/Users/flooreyes/mega-swap-widget/dist/chunk-NBJPKJBC.cjs"}
@@ -0,0 +1,27 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+ // src/wallet/useWalletState.ts
4
+ var _react = require('react');
5
+ var _wagmi = require('wagmi');
6
+ function useClientMounted() {
7
+ const [mounted, setMounted] = _react.useState.call(void 0, false);
8
+ _react.useEffect.call(void 0, () => {
9
+ setMounted(true);
10
+ }, []);
11
+ return mounted;
12
+ }
13
+ function useWalletState() {
14
+ const mounted = useClientMounted();
15
+ const { address, isConnected, isConnecting, isReconnecting } = _wagmi.useAccount.call(void 0, );
16
+ return {
17
+ mounted,
18
+ address,
19
+ isConnected,
20
+ isLoading: isConnecting || isReconnecting
21
+ };
22
+ }
23
+
24
+
25
+
26
+ exports.useWalletState = useWalletState;
27
+ //# sourceMappingURL=chunk-PGYOJ5RB.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/flooreyes/mega-swap-widget/dist/chunk-PGYOJ5RB.cjs","../src/wallet/useWalletState.ts"],"names":[],"mappings":"AAAA,qFAAY;AACZ;AACA;ACAA,8BAAoC;AACpC,8BAA2B;AAE3B,SAAS,gBAAA,CAAA,EAAmB;AAC1B,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,EAAA,EAAI,6BAAA,KAAc,CAAA;AAC5C,EAAA,8BAAA,CAAU,EAAA,GAAM;AAAE,IAAA,UAAA,CAAW,IAAI,CAAA;AAAA,EAAG,CAAA,EAAG,CAAC,CAAC,CAAA;AACzC,EAAA,OAAO,OAAA;AACT;AAEO,SAAS,cAAA,CAAA,EAAiB;AAC/B,EAAA,MAAM,QAAA,EAAU,gBAAA,CAAiB,CAAA;AACjC,EAAA,MAAM,EAAE,OAAA,EAAS,WAAA,EAAa,YAAA,EAAc,eAAe,EAAA,EAAI,+BAAA,CAAW;AAE1E,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA,EAAW,aAAA,GAAgB;AAAA,EAC7B,CAAA;AACF;ADCA;AACA;AACE;AACF,wCAAC","file":"/Users/flooreyes/mega-swap-widget/dist/chunk-PGYOJ5RB.cjs","sourcesContent":[null,"'use client';\n\nimport { useEffect, useState } from 'react';\nimport { useAccount } from 'wagmi';\n\nfunction useClientMounted() {\n const [mounted, setMounted] = useState(false);\n useEffect(() => { setMounted(true); }, []);\n return mounted;\n}\n\nexport function useWalletState() {\n const mounted = useClientMounted();\n const { address, isConnected, isConnecting, isReconnecting } = useAccount();\n\n return {\n mounted,\n address,\n isConnected,\n isLoading: isConnecting || isReconnecting,\n };\n}\n"]}
@@ -0,0 +1,199 @@
1
+ "use client";
2
+ import {
3
+ useRfq
4
+ } from "./chunk-ARMW5POL.js";
5
+ import {
6
+ useSwapFormContext
7
+ } from "./chunk-TMC4SUEV.js";
8
+ import {
9
+ ThreeDots,
10
+ TokenImage_default,
11
+ useWidgetConfig
12
+ } from "./chunk-6Q7MSCKS.js";
13
+
14
+ // src/components/QuoteLoader.tsx
15
+ import React, { useEffect, useState } from "react";
16
+ import { jsx, jsxs } from "react/jsx-runtime";
17
+ function formatRate(rate) {
18
+ if (rate === 0) return "0";
19
+ const abs = Math.abs(rate);
20
+ if (abs >= 1e4) return rate.toFixed(0);
21
+ if (abs >= 1e3) return rate.toFixed(1);
22
+ if (abs >= 100) return rate.toFixed(2);
23
+ if (abs >= 1) return rate.toFixed(4);
24
+ if (abs >= 0.01) return rate.toFixed(6);
25
+ return rate.toExponential(3);
26
+ }
27
+ var QuoteLoader = React.memo(() => {
28
+ const [isOpen, setIsOpen] = useState(false);
29
+ const { liquidityError, routingError } = useRfq();
30
+ const {
31
+ baseAmount,
32
+ baseToken: base,
33
+ quoteAmount,
34
+ quoteToken: quote
35
+ } = useSwapFormContext();
36
+ const { quoteLoaderVariant, widgetType } = useWidgetConfig();
37
+ const isCompact = widgetType === "compact";
38
+ const exchangeRate = baseAmount && quoteAmount && parseFloat(quoteAmount.toString()) ? parseFloat(baseAmount.toString()) / parseFloat(quoteAmount.toString()) : 0;
39
+ const hasQuoteError = liquidityError || routingError;
40
+ const hasValidQuote = base && quote && baseAmount && parseFloat(baseAmount.toString()) && quoteAmount;
41
+ useEffect(() => {
42
+ if (quoteLoaderVariant === "expanded" && hasValidQuote) {
43
+ setIsOpen(true);
44
+ }
45
+ }, [quoteLoaderVariant, hasValidQuote]);
46
+ if (quoteLoaderVariant === "none") return null;
47
+ if (quoteLoaderVariant === "default") {
48
+ return /* @__PURE__ */ jsx("div", { className: `relative box-border flex flex-row pt-1 h-8 w-full items-center${isCompact ? " justify-start overflow-x-auto" : " justify-center"}`, children: /* @__PURE__ */ jsx(
49
+ "div",
50
+ {
51
+ className: `flex h-full items-center${isCompact ? " min-w-max" : " w-full overflow-hidden"}`,
52
+ style: { color: "var(--widget-foreground)" },
53
+ children: base && quote ? baseAmount && parseFloat(baseAmount.toString()) ? quoteAmount ? /* @__PURE__ */ jsxs("div", { className: "translate-y-px font-mono flex flex-row items-center gap-2 whitespace-nowrap", children: [
54
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center gap-1", children: [
55
+ /* @__PURE__ */ jsx(TokenImage_default, { asset: quote, size: "3xs", noChain: true, className: "mb-0.5" }),
56
+ /* @__PURE__ */ jsxs("span", { className: "text-xs uppercase", children: [
57
+ "1 ",
58
+ quote?.symbol
59
+ ] })
60
+ ] }),
61
+ /* @__PURE__ */ jsx("span", { className: "text-xs", style: { color: "var(--widget-muted-foreground)" }, children: "=" }),
62
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center gap-1", children: [
63
+ /* @__PURE__ */ jsx(TokenImage_default, { asset: base, size: "3xs", noChain: true, className: "mb-0.5" }),
64
+ /* @__PURE__ */ jsxs("span", { className: "text-xs uppercase", children: [
65
+ formatRate(exchangeRate),
66
+ " ",
67
+ base?.symbol
68
+ ] })
69
+ ] }),
70
+ /* @__PURE__ */ jsx("span", { className: "text-xs", style: { color: "var(--widget-muted-foreground)" }, children: base?.price ? `\u2248 $${(base.price * exchangeRate).toFixed(2)}` : "" })
71
+ ] }) : hasQuoteError ? /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-row pb-1 items-center justify-between", children: [
72
+ /* @__PURE__ */ jsx("p", { className: "text-xs", style: { color: "var(--widget-destructive)" }, children: "Quote not found" }),
73
+ /* @__PURE__ */ jsx(ThreeDots, { className: "h-8 w-8", style: { color: "var(--widget-destructive)" } })
74
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-row pb-1 items-center justify-between", children: [
75
+ /* @__PURE__ */ jsx("p", { className: "text-xs", style: { color: "var(--widget-accent)" }, children: "Searching For Quote" }),
76
+ /* @__PURE__ */ jsx(ThreeDots, { className: "h-8 w-8", style: { color: "var(--widget-accent)" } })
77
+ ] }) : /* @__PURE__ */ jsx("div", { className: "text-xs pb-1", style: { color: "var(--widget-foreground)", opacity: 0.4 }, children: "Enter Amount" }) : /* @__PURE__ */ jsx("div", { className: "text-xs pb-1", style: { color: "var(--widget-foreground)", opacity: 0.4 }, children: "Enter Amount" })
78
+ }
79
+ ) });
80
+ }
81
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col w-full", children: [
82
+ /* @__PURE__ */ jsx(
83
+ "div",
84
+ {
85
+ className: `relative box-border flex flex-row pt-1 h-8 w-full items-center cursor-pointer${isCompact ? " overflow-x-auto" : ""}`,
86
+ role: "button",
87
+ tabIndex: 0,
88
+ onClick: () => hasValidQuote && setIsOpen((v) => !v),
89
+ onKeyDown: (e) => {
90
+ if (e.key === "Enter" || e.key === " ") {
91
+ e.preventDefault();
92
+ hasValidQuote && setIsOpen((v) => !v);
93
+ }
94
+ },
95
+ children: /* @__PURE__ */ jsx(
96
+ "div",
97
+ {
98
+ className: `flex h-full items-center${isCompact ? " min-w-max overflow-x-auto" : " w-full overflow-hidden"}`,
99
+ style: { color: "var(--widget-foreground)" },
100
+ children: base && quote ? baseAmount && parseFloat(baseAmount.toString()) ? quoteAmount ? /* @__PURE__ */ jsxs("div", { className: "translate-y-px font-mono flex w-full flex-row items-center justify-between", children: [
101
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center gap-2 whitespace-nowrap", children: [
102
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center gap-1", children: [
103
+ /* @__PURE__ */ jsx(TokenImage_default, { asset: quote, size: "3xs", noChain: true, className: "mb-0.5" }),
104
+ /* @__PURE__ */ jsxs("span", { className: "text-xs uppercase", children: [
105
+ "1 ",
106
+ quote?.symbol
107
+ ] })
108
+ ] }),
109
+ /* @__PURE__ */ jsx("span", { className: "text-xs", style: { color: "var(--widget-muted-foreground)" }, children: "=" }),
110
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center gap-1", children: [
111
+ /* @__PURE__ */ jsx(TokenImage_default, { asset: base, size: "3xs", noChain: true, className: "mb-0.5" }),
112
+ /* @__PURE__ */ jsxs("span", { className: "text-xs uppercase", children: [
113
+ formatRate(exchangeRate),
114
+ " ",
115
+ base?.symbol
116
+ ] })
117
+ ] }),
118
+ /* @__PURE__ */ jsx("span", { className: "text-xs", style: { color: "var(--widget-muted-foreground)" }, children: base?.price ? `\u2248 $${(base.price * exchangeRate).toFixed(2)}` : "" })
119
+ ] }),
120
+ /* @__PURE__ */ jsx(
121
+ "span",
122
+ {
123
+ className: "text-xs ml-2 transition-transform duration-200 shrink-0",
124
+ style: {
125
+ color: "var(--widget-muted-foreground)",
126
+ transform: isOpen ? "rotate(180deg)" : "rotate(0deg)",
127
+ display: "inline-block"
128
+ },
129
+ children: "\u25BE"
130
+ }
131
+ )
132
+ ] }) : hasQuoteError ? /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-row pb-1 items-center justify-between", children: [
133
+ /* @__PURE__ */ jsx("p", { className: "text-xs", style: { color: "var(--widget-destructive)" }, children: "Quote not found" }),
134
+ /* @__PURE__ */ jsx(ThreeDots, { className: "h-8 w-8", style: { color: "var(--widget-destructive)" } })
135
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-row pb-1 items-center justify-between", children: [
136
+ /* @__PURE__ */ jsx("p", { className: "text-xs", style: { color: "var(--widget-accent)" }, children: "Searching For Quote" }),
137
+ /* @__PURE__ */ jsx(ThreeDots, { className: "h-8 w-8", style: { color: "var(--widget-accent)" } })
138
+ ] }) : /* @__PURE__ */ jsx("div", { className: "text-xs pb-1", style: { color: "var(--widget-foreground)", opacity: 0.4 }, children: "Enter Amount" }) : /* @__PURE__ */ jsx("div", { className: "text-xs pb-1", style: { color: "var(--widget-foreground)", opacity: 0.4 }, children: "Enter Amount" })
139
+ }
140
+ )
141
+ }
142
+ ),
143
+ /* @__PURE__ */ jsx(
144
+ "div",
145
+ {
146
+ className: "overflow-hidden transition-all duration-200",
147
+ style: {
148
+ maxHeight: isOpen && hasValidQuote ? "80px" : "0px",
149
+ opacity: isOpen && hasValidQuote ? 1 : 0
150
+ },
151
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5 pb-1 font-mono", children: [
152
+ /* @__PURE__ */ jsxs(
153
+ "div",
154
+ {
155
+ className: "flex justify-between text-2xs",
156
+ style: { color: "var(--widget-muted-foreground)" },
157
+ children: [
158
+ /* @__PURE__ */ jsx("span", { children: "USD Value" }),
159
+ /* @__PURE__ */ jsxs("span", { children: [
160
+ "$",
161
+ base?.price && quoteAmount ? (base.price * exchangeRate * parseFloat(quoteAmount.toString())).toFixed(2) : "\u2014"
162
+ ] })
163
+ ]
164
+ }
165
+ ),
166
+ /* @__PURE__ */ jsxs(
167
+ "div",
168
+ {
169
+ className: "flex justify-between text-2xs",
170
+ style: { color: "var(--widget-muted-foreground)" },
171
+ children: [
172
+ /* @__PURE__ */ jsx("span", { children: "Rate" }),
173
+ /* @__PURE__ */ jsx("span", { className: "uppercase", children: exchangeRate > 0 ? `${formatRate(exchangeRate)} ${base?.symbol ?? ""}` : "\u2014" })
174
+ ]
175
+ }
176
+ ),
177
+ /* @__PURE__ */ jsxs(
178
+ "div",
179
+ {
180
+ className: "flex justify-between text-2xs",
181
+ style: { color: "var(--widget-muted-foreground)" },
182
+ children: [
183
+ /* @__PURE__ */ jsx("span", { children: "Order Type" }),
184
+ /* @__PURE__ */ jsx("span", { children: "RFQ (Exact Fill)" })
185
+ ]
186
+ }
187
+ )
188
+ ] })
189
+ }
190
+ )
191
+ ] });
192
+ });
193
+ QuoteLoader.displayName = "QuoteLoader";
194
+ var QuoteLoader_default = QuoteLoader;
195
+
196
+ export {
197
+ QuoteLoader_default
198
+ };
199
+ //# sourceMappingURL=chunk-QHW27RMH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/QuoteLoader.tsx"],"sourcesContent":["'use client';\n\nimport { ThreeDots, TokenImage } from '../internal';\nimport React, { useEffect, useState } from 'react';\nimport { useWidgetConfig } from '../context/WidgetConfigContext';\nimport { useRfq } from '../providers/RfqProvider';\nimport { useSwapFormContext } from '../providers/SwapFormProvider';\n\nfunction formatRate(rate: number): string {\n if (rate === 0) return '0';\n const abs = Math.abs(rate);\n if (abs >= 10000) return rate.toFixed(0);\n if (abs >= 1000) return rate.toFixed(1);\n if (abs >= 100) return rate.toFixed(2);\n if (abs >= 1) return rate.toFixed(4);\n if (abs >= 0.01) return rate.toFixed(6);\n return rate.toExponential(3);\n}\n\nconst QuoteLoader = React.memo(() => {\n const [isOpen, setIsOpen] = useState(false);\n const { liquidityError, routingError } = useRfq();\n const {\n baseAmount,\n baseToken: base,\n quoteAmount,\n quoteToken: quote,\n } = useSwapFormContext();\n const { quoteLoaderVariant, widgetType } = useWidgetConfig();\n const isCompact = widgetType === 'compact';\n\n // Derive inline so it resets to 0 the moment quoteAmount is cleared —\n // prevents a one-frame flash of the stale rate after clear() or cancel().\n const exchangeRate =\n baseAmount && quoteAmount && parseFloat(quoteAmount.toString())\n ? parseFloat(baseAmount.toString()) / parseFloat(quoteAmount.toString())\n : 0;\n\n const hasQuoteError = liquidityError || routingError;\n const hasValidQuote =\n base &&\n quote &&\n baseAmount &&\n parseFloat(baseAmount.toString()) &&\n quoteAmount;\n\n // Auto-open expanded panel when a valid quote arrives\n useEffect(() => {\n if (quoteLoaderVariant === 'expanded' && hasValidQuote) {\n setIsOpen(true);\n }\n }, [quoteLoaderVariant, hasValidQuote]);\n\n // ── none variant ──────────────────────────────────────────────────────────\n if (quoteLoaderVariant === 'none') return null;\n\n // ── default (rate) variant ────────────────────────────────────────────────\n if (quoteLoaderVariant === 'default') {\n return (\n <div className={`relative box-border flex flex-row pt-1 h-8 w-full items-center${isCompact ? ' justify-start overflow-x-auto' : ' justify-center'}`}>\n <div\n className={`flex h-full items-center${isCompact ? ' min-w-max' : ' w-full overflow-hidden'}`}\n style={{ color: 'var(--widget-foreground)' }}\n >\n {base && quote ? (\n baseAmount && parseFloat(baseAmount.toString()) ? (\n quoteAmount ? (\n <div className=\"translate-y-px font-mono flex flex-row items-center gap-2 whitespace-nowrap\">\n <div className=\"flex flex-row items-center gap-1\">\n <TokenImage asset={quote} size=\"3xs\" noChain className=\"mb-0.5\" />\n <span className=\"text-xs uppercase\">1 {quote?.symbol}</span>\n </div>\n <span className=\"text-xs\" style={{ color: 'var(--widget-muted-foreground)' }}>=</span>\n <div className=\"flex flex-row items-center gap-1\">\n <TokenImage asset={base} size=\"3xs\" noChain className=\"mb-0.5\" />\n <span className=\"text-xs uppercase\">{formatRate(exchangeRate)} {base?.symbol}</span>\n </div>\n <span className=\"text-xs\" style={{ color: 'var(--widget-muted-foreground)' }}>\n {base?.price ? `≈ $${(base.price * exchangeRate).toFixed(2)}` : ''}\n </span>\n </div>\n ) : hasQuoteError ? (\n <div className=\"flex h-full w-full flex-row pb-1 items-center justify-between\">\n <p className=\"text-xs\" style={{ color: 'var(--widget-destructive)' }}>\n Quote not found\n </p>\n <ThreeDots className=\"h-8 w-8\" style={{ color: 'var(--widget-destructive)' }} />\n </div>\n ) : (\n <div className=\"flex h-full w-full flex-row pb-1 items-center justify-between\">\n <p className=\"text-xs\" style={{ color: 'var(--widget-accent)' }}>\n Searching For Quote\n </p>\n <ThreeDots className=\"h-8 w-8\" style={{ color: 'var(--widget-accent)' }} />\n </div>\n )\n ) : (\n <div className=\"text-xs pb-1\" style={{ color: 'var(--widget-foreground)', opacity: 0.4 }}>\n Enter Amount\n </div>\n )\n ) : (\n <div className=\"text-xs pb-1\" style={{ color: 'var(--widget-foreground)', opacity: 0.4 }}>\n Enter Amount\n </div>\n )}\n </div>\n </div>\n );\n }\n\n // ── expanded variant ──────────────────────────────────────────────────────\n return (\n <div className=\"flex flex-col w-full\">\n {/* Rate row — same as default, but clickable to expand */}\n <div\n className={`relative box-border flex flex-row pt-1 h-8 w-full items-center cursor-pointer${isCompact ? ' overflow-x-auto' : ''}`}\n role=\"button\"\n tabIndex={0}\n onClick={() => hasValidQuote && setIsOpen((v) => !v)}\n onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); hasValidQuote && setIsOpen((v) => !v); } }}\n >\n <div\n className={`flex h-full items-center${isCompact ? ' min-w-max overflow-x-auto' : ' w-full overflow-hidden'}`}\n style={{ color: 'var(--widget-foreground)' }}\n >\n {base && quote ? (\n baseAmount && parseFloat(baseAmount.toString()) ? (\n quoteAmount ? (\n <div className=\"translate-y-px font-mono flex w-full flex-row items-center justify-between\">\n <div className=\"flex flex-row items-center gap-2 whitespace-nowrap\">\n <div className=\"flex flex-row items-center gap-1\">\n <TokenImage asset={quote} size=\"3xs\" noChain className=\"mb-0.5\" />\n <span className=\"text-xs uppercase\">1 {quote?.symbol}</span>\n </div>\n <span className=\"text-xs\" style={{ color: 'var(--widget-muted-foreground)' }}>=</span>\n <div className=\"flex flex-row items-center gap-1\">\n <TokenImage asset={base} size=\"3xs\" noChain className=\"mb-0.5\" />\n <span className=\"text-xs uppercase\">{formatRate(exchangeRate)} {base?.symbol}</span>\n </div>\n <span className=\"text-xs\" style={{ color: 'var(--widget-muted-foreground)' }}>\n {base?.price ? `≈ $${(base.price * exchangeRate).toFixed(2)}` : ''}\n </span>\n </div>\n <span\n className=\"text-xs ml-2 transition-transform duration-200 shrink-0\"\n style={{\n color: 'var(--widget-muted-foreground)',\n transform: isOpen ? 'rotate(180deg)' : 'rotate(0deg)',\n display: 'inline-block',\n }}\n >\n ▾\n </span>\n </div>\n ) : hasQuoteError ? (\n <div className=\"flex h-full w-full flex-row pb-1 items-center justify-between\">\n <p className=\"text-xs\" style={{ color: 'var(--widget-destructive)' }}>\n Quote not found\n </p>\n <ThreeDots className=\"h-8 w-8\" style={{ color: 'var(--widget-destructive)' }} />\n </div>\n ) : (\n <div className=\"flex h-full w-full flex-row pb-1 items-center justify-between\">\n <p className=\"text-xs\" style={{ color: 'var(--widget-accent)' }}>\n Searching For Quote\n </p>\n <ThreeDots className=\"h-8 w-8\" style={{ color: 'var(--widget-accent)' }} />\n </div>\n )\n ) : (\n <div className=\"text-xs pb-1\" style={{ color: 'var(--widget-foreground)', opacity: 0.4 }}>\n Enter Amount\n </div>\n )\n ) : (\n <div className=\"text-xs pb-1\" style={{ color: 'var(--widget-foreground)', opacity: 0.4 }}>\n Enter Amount\n </div>\n )}\n </div>\n </div>\n\n {/* Expanded detail rows */}\n <div\n className=\"overflow-hidden transition-all duration-200\"\n style={{\n maxHeight: isOpen && hasValidQuote ? '80px' : '0px',\n opacity: isOpen && hasValidQuote ? 1 : 0,\n }}\n >\n <div className=\"flex flex-col gap-0.5 pb-1 font-mono\">\n <div\n className=\"flex justify-between text-2xs\"\n style={{ color: 'var(--widget-muted-foreground)' }}\n >\n <span>USD Value</span>\n <span>\n $\n {base?.price && quoteAmount\n ? (\n base.price *\n exchangeRate *\n parseFloat(quoteAmount.toString())\n ).toFixed(2)\n : '—'}\n </span>\n </div>\n <div\n className=\"flex justify-between text-2xs\"\n style={{ color: 'var(--widget-muted-foreground)' }}\n >\n <span>Rate</span>\n <span className=\"uppercase\">\n {exchangeRate > 0\n ? `${formatRate(exchangeRate)} ${base?.symbol ?? ''}`\n : '—'}\n </span>\n </div>\n <div\n className=\"flex justify-between text-2xs\"\n style={{ color: 'var(--widget-muted-foreground)' }}\n >\n <span>Order Type</span>\n <span>RFQ (Exact Fill)</span>\n </div>\n </div>\n </div>\n </div>\n );\n});\n\nQuoteLoader.displayName = 'QuoteLoader';\nexport default QuoteLoader;\n"],"mappings":";;;;;;;;;;;;;;AAGA,OAAO,SAAS,WAAW,gBAAgB;AAkEvB,cACA,YADA;AA7DpB,SAAS,WAAW,MAAsB;AACxC,MAAI,SAAS,EAAG,QAAO;AACvB,QAAM,MAAM,KAAK,IAAI,IAAI;AACzB,MAAI,OAAO,IAAO,QAAO,KAAK,QAAQ,CAAC;AACvC,MAAI,OAAO,IAAM,QAAO,KAAK,QAAQ,CAAC;AACtC,MAAI,OAAO,IAAK,QAAO,KAAK,QAAQ,CAAC;AACrC,MAAI,OAAO,EAAG,QAAO,KAAK,QAAQ,CAAC;AACnC,MAAI,OAAO,KAAM,QAAO,KAAK,QAAQ,CAAC;AACtC,SAAO,KAAK,cAAc,CAAC;AAC7B;AAEA,IA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