aegis-swap-widget 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -1
- package/README.md +22 -22
- package/dist/aegis-swap-widget.js +1810 -1633
- package/dist/components/icons.d.ts +4 -0
- package/dist/format.d.ts +2 -0
- package/dist/hooks/useResolvedTheme.d.ts +6 -0
- package/dist/hooks/useSubmitSwap.d.ts +3 -1
- package/dist/styles.css +1 -1
- package/dist/swap/executeSwapTransaction.d.ts +3 -1
- package/dist/transactionProgress.d.ts +13 -0
- package/dist/widget/AmountField.d.ts +4 -1
- package/dist/widget/ExecutionDetails.d.ts +5 -2
- package/dist/widget/useSwapController.d.ts +8 -0
- package/dist/widget/viewState.d.ts +10 -0
- package/package.json +4 -1
|
@@ -1,67 +1,19 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { a3 as
|
|
5
|
-
import { A as
|
|
6
|
-
import { createPortal as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return s === "." ? "0." : s;
|
|
10
|
-
}
|
|
11
|
-
function cn(t) {
|
|
12
|
-
const e = Be(t);
|
|
13
|
-
if (!e) return "";
|
|
14
|
-
const n = Number(e);
|
|
15
|
-
return Number.isFinite(n) && n > 20 ? "20" : e;
|
|
16
|
-
}
|
|
17
|
-
function fi(t, e) {
|
|
18
|
-
const n = t.trim();
|
|
19
|
-
if (!n || n === ".") return null;
|
|
20
|
-
try {
|
|
21
|
-
return Fa(n, e);
|
|
22
|
-
} catch {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function un(t) {
|
|
27
|
-
const e = t.trim();
|
|
28
|
-
if (!e) return null;
|
|
29
|
-
const n = Number(e);
|
|
30
|
-
return !Number.isFinite(n) || n < 0 || n > 20 ? null : Math.round(n * 100);
|
|
31
|
-
}
|
|
32
|
-
function Dn(t, e, n = "half-up") {
|
|
33
|
-
if (t === 0n || e <= 0) return t;
|
|
34
|
-
const a = t < 0n ? -1n : 1n, i = t < 0n ? -t : t, s = i.toString().length - e;
|
|
35
|
-
if (s <= 0) return t;
|
|
36
|
-
const l = 10n ** BigInt(s);
|
|
37
|
-
return (n === "floor" ? i / l * l : (i + l / 2n) / l * l) * a;
|
|
38
|
-
}
|
|
39
|
-
function Nt(t) {
|
|
40
|
-
return t.includes(".") ? t.replace(/\.?0+$/, "") : t;
|
|
41
|
-
}
|
|
42
|
-
function Ee(t, e, n = 4) {
|
|
43
|
-
return t == null ? "--" : Nt(Tt(Dn(t, n), e));
|
|
44
|
-
}
|
|
45
|
-
function hi(t, e, n = 4) {
|
|
46
|
-
return t == null ? "--" : Nt(
|
|
47
|
-
Tt(Dn(t, n, "floor"), e)
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
function dn(t, e) {
|
|
51
|
-
return t == null ? "" : Ee(t, e);
|
|
52
|
-
}
|
|
53
|
-
function mi(t, e) {
|
|
54
|
-
return t == null ? "" : Nt(Tt(t, e));
|
|
55
|
-
}
|
|
56
|
-
const gi = {
|
|
1
|
+
import { jsxs as p, jsx as i, Fragment as gn } from "react/jsx-runtime";
|
|
2
|
+
import { memo as ut, useState as P, useSyncExternalStore as ot, useRef as W, useEffect as U, useLayoutEffect as Za, useCallback as O, useMemo as J, useId as $e } from "react";
|
|
3
|
+
import { Box as Ja, Flame as ei, Gauge as ti, Coins as ni } from "lucide-react";
|
|
4
|
+
import { a3 as ai, T as Ve, a9 as ii, R as $n, w as ri, W as si, s as oi, D as li, S as Wn, Z as ci, v as ui, u as di, O as qe, a7 as pi, a0 as Hn, H as Vn, a1 as fi, G as Ne, $ as Nt, J as qn, r as hi, _ as Gn, aa as xe, a5 as gi, a4 as mn, ab as It, I as mi, L as St, a6 as wi, Y as bi, a2 as yi, N as vi, b as wn, z as _i, a as Ii, B as Si, k as Ai, f as bn, F as Ei, X as xi, n as yn, a8 as Ni } from "./polling-BI4pZg8Z.js";
|
|
5
|
+
import { A as Bs, c as ks, d as Ls, e as Fs, g as Us, h as $s, i as Ws, j as Hs, l as Vs, m as qs, o as Gs, M as zs, p as Ks, q as js, P as Xs, U as Ys, t as Qs, x as Zs, y as Js, C as eo, E as to, K as no, Q as ao, V as io } from "./polling-BI4pZg8Z.js";
|
|
6
|
+
import { createPortal as Pi } from "react-dom";
|
|
7
|
+
import { parseUnits as Ti, formatUnits as Ot, formatEther as Ci, formatGwei as Mi, createWalletClient as Ri, custom as Di, WaitForTransactionReceiptTimeoutError as vn, erc20Abi as zn } from "viem";
|
|
8
|
+
const Oi = {
|
|
57
9
|
USDC: { primary: "#d7ecff", secondary: "#2775ca", text: "#06111f" },
|
|
58
10
|
WATER: { primary: "#87dcff", secondary: "#0f5d96", text: "#051621" },
|
|
59
11
|
WOOD: { primary: "#c79a62", secondary: "#45633d", text: "#171008" },
|
|
60
12
|
GRASS: { primary: "#76e28a", secondary: "#244f32", text: "#061508" },
|
|
61
13
|
STONE: { primary: "#d7d1c3", secondary: "#5a6366", text: "#111416" }
|
|
62
14
|
};
|
|
63
|
-
function
|
|
64
|
-
const e =
|
|
15
|
+
function Bi(t) {
|
|
16
|
+
const e = Oi[t] ?? {
|
|
65
17
|
primary: "#eef3f0",
|
|
66
18
|
secondary: "#75827c",
|
|
67
19
|
text: "#111815"
|
|
@@ -72,38 +24,38 @@ function wi(t) {
|
|
|
72
24
|
"--aegis-token-text": e.text
|
|
73
25
|
};
|
|
74
26
|
}
|
|
75
|
-
const
|
|
27
|
+
const Pt = ut(function({
|
|
76
28
|
token: e,
|
|
77
29
|
metadataByAddress: n,
|
|
78
30
|
className: a
|
|
79
31
|
}) {
|
|
80
|
-
const
|
|
81
|
-
return /* @__PURE__ */
|
|
32
|
+
const r = ai(e, n), [s, o] = P(null), l = r && s !== r ? r : null;
|
|
33
|
+
return /* @__PURE__ */ i("span", { className: a, style: Bi(e.symbol), "aria-hidden": "true", children: l ? /* @__PURE__ */ i(
|
|
82
34
|
"img",
|
|
83
35
|
{
|
|
84
36
|
src: l,
|
|
85
37
|
alt: "",
|
|
86
38
|
loading: "lazy",
|
|
87
39
|
decoding: "async",
|
|
88
|
-
onError: () =>
|
|
40
|
+
onError: () => o(l)
|
|
89
41
|
}
|
|
90
42
|
) : e.symbol.slice(0, 1) });
|
|
91
|
-
}),
|
|
43
|
+
}), Kn = ut(function({
|
|
92
44
|
market: e,
|
|
93
45
|
metadataByAddress: n,
|
|
94
46
|
className: a
|
|
95
47
|
}) {
|
|
96
|
-
return /* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */
|
|
98
|
-
|
|
48
|
+
return /* @__PURE__ */ p("span", { className: a, "aria-hidden": "true", children: [
|
|
49
|
+
/* @__PURE__ */ i(
|
|
50
|
+
Pt,
|
|
99
51
|
{
|
|
100
52
|
token: e.counterToken,
|
|
101
53
|
metadataByAddress: n,
|
|
102
54
|
className: "aegis-swap-widget__pair-icon"
|
|
103
55
|
}
|
|
104
56
|
),
|
|
105
|
-
/* @__PURE__ */
|
|
106
|
-
|
|
57
|
+
/* @__PURE__ */ i(
|
|
58
|
+
Pt,
|
|
107
59
|
{
|
|
108
60
|
token: e.token,
|
|
109
61
|
metadataByAddress: n,
|
|
@@ -112,9 +64,9 @@ const St = nt(function({
|
|
|
112
64
|
)
|
|
113
65
|
] });
|
|
114
66
|
});
|
|
115
|
-
function
|
|
116
|
-
return /* @__PURE__ */
|
|
117
|
-
/* @__PURE__ */
|
|
67
|
+
function ki() {
|
|
68
|
+
return /* @__PURE__ */ p("svg", { viewBox: "0 0 150 151", "aria-hidden": "true", focusable: "false", children: [
|
|
69
|
+
/* @__PURE__ */ i(
|
|
118
70
|
"path",
|
|
119
71
|
{
|
|
120
72
|
d: "M64.7727 0.691736C28.1896 5.67985 0 37.048 0 75.0003C0 112.952 28.1896 144.321 64.7727 149.309C68.264 148.833 71.6788 148.116 75 147.177C106.48 138.274 129.545 109.141 129.545 74.8109C129.545 51.4969 113.281 31.9817 91.4795 26.993C87.8685 26.1667 84.1035 26.1664 80.4924 26.9925C78.6184 27.4212 76.7854 27.9573 75 28.5939C93.9861 35.3633 107.576 53.5001 107.576 74.8109C107.576 96.1216 93.9861 114.258 75 121.028C73.2146 121.664 71.3816 122.2 69.5076 122.629C65.8965 123.455 62.1318 123.454 58.5199 122.632C36.7188 117.667 20.4545 98.314 20.4545 75.0003C20.4545 40.67 43.5204 11.727 75 2.82341C78.3212 1.88407 81.736 1.16777 85.2273 0.691735C81.8833 0.235781 78.4691 0.000244141 75 0.000244141C71.5309 0.000244141 68.1167 0.235782 64.7727 0.691736Z",
|
|
@@ -122,7 +74,7 @@ function yi() {
|
|
|
122
74
|
opacity: "0.92"
|
|
123
75
|
}
|
|
124
76
|
),
|
|
125
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ i(
|
|
126
78
|
"path",
|
|
127
79
|
{
|
|
128
80
|
d: "M85.2273 149.374C121.81 144.386 150 113.018 150 75.0659C150 37.1137 121.81 5.74551 85.2273 0.757401C81.736 1.23343 78.3212 1.94972 75 2.88907C43.5204 11.7926 20.4545 40.925 20.4545 75.2553C20.4545 98.5693 36.7191 118.084 58.5205 123.073C62.1315 123.899 65.8965 123.9 69.5076 123.074C71.3816 122.645 73.2146 122.109 75 121.472C56.0139 114.703 42.4242 96.5661 42.4242 75.2553C42.4242 53.9445 56.0139 35.8078 75 29.0383C76.7854 28.4017 78.6184 27.8657 80.4924 27.437C84.1035 26.6108 87.8682 26.612 91.4801 27.4345C113.281 32.3988 129.545 51.7522 129.545 75.0659C129.545 109.396 106.48 138.339 75 147.243C71.6788 148.182 68.264 148.898 64.7727 149.374C68.1167 149.83 71.5309 150.066 75 150.066C78.4691 150.066 81.8833 149.83 85.2273 149.374Z",
|
|
@@ -132,8 +84,8 @@ function yi() {
|
|
|
132
84
|
)
|
|
133
85
|
] });
|
|
134
86
|
}
|
|
135
|
-
function
|
|
136
|
-
return /* @__PURE__ */
|
|
87
|
+
function Li({ className: t }) {
|
|
88
|
+
return /* @__PURE__ */ p(
|
|
137
89
|
"svg",
|
|
138
90
|
{
|
|
139
91
|
className: t,
|
|
@@ -142,17 +94,17 @@ function bi({ className: t }) {
|
|
|
142
94
|
focusable: "false",
|
|
143
95
|
fill: "currentColor",
|
|
144
96
|
children: [
|
|
145
|
-
/* @__PURE__ */
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */
|
|
148
|
-
/* @__PURE__ */
|
|
149
|
-
/* @__PURE__ */
|
|
97
|
+
/* @__PURE__ */ i("path", { d: "m959.8 730.9-539.8 245.4 539.8 319.1 539.9-319.1z", opacity: "0.6" }),
|
|
98
|
+
/* @__PURE__ */ i("path", { d: "m420.2 976.3 539.8 319.1v-564.5-650.3z", opacity: "0.45" }),
|
|
99
|
+
/* @__PURE__ */ i("path", { d: "m960 80.6v650.3 564.5l539.8-319.1z", opacity: "0.8" }),
|
|
100
|
+
/* @__PURE__ */ i("path", { d: "m420 1078.7 539.8 760.7v-441.8z", opacity: "0.45" }),
|
|
101
|
+
/* @__PURE__ */ i("path", { d: "m959.8 1397.6v441.8l540.2-760.7z", opacity: "0.8" })
|
|
150
102
|
]
|
|
151
103
|
}
|
|
152
104
|
);
|
|
153
105
|
}
|
|
154
|
-
function
|
|
155
|
-
return /* @__PURE__ */
|
|
106
|
+
function Fi({ className: t }) {
|
|
107
|
+
return /* @__PURE__ */ p(
|
|
156
108
|
"svg",
|
|
157
109
|
{
|
|
158
110
|
className: t,
|
|
@@ -160,8 +112,8 @@ function _i({ className: t }) {
|
|
|
160
112
|
"aria-hidden": "true",
|
|
161
113
|
focusable: "false",
|
|
162
114
|
children: [
|
|
163
|
-
/* @__PURE__ */
|
|
164
|
-
/* @__PURE__ */
|
|
115
|
+
/* @__PURE__ */ i("circle", { cx: "16", cy: "16", r: "16", fill: "#0052ff" }),
|
|
116
|
+
/* @__PURE__ */ i(
|
|
165
117
|
"path",
|
|
166
118
|
{
|
|
167
119
|
d: "M16.16 26.4c5.52 0 10.08-4.48 10.08-10S21.68 6.4 16.16 6.4c-5.04 0-9.2 3.68-9.92 8.48h13.32v2.56H6.24c.72 4.8 4.88 8.96 9.92 8.96Z",
|
|
@@ -172,71 +124,83 @@ function _i({ className: t }) {
|
|
|
172
124
|
}
|
|
173
125
|
);
|
|
174
126
|
}
|
|
175
|
-
function
|
|
176
|
-
return /* @__PURE__ */
|
|
177
|
-
/* @__PURE__ */
|
|
178
|
-
/* @__PURE__ */
|
|
179
|
-
/* @__PURE__ */
|
|
180
|
-
/* @__PURE__ */
|
|
127
|
+
function Ui() {
|
|
128
|
+
return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
|
|
129
|
+
/* @__PURE__ */ i("path", { d: "m3 16 4 4 4-4" }),
|
|
130
|
+
/* @__PURE__ */ i("path", { d: "M7 20V4" }),
|
|
131
|
+
/* @__PURE__ */ i("path", { d: "m21 8-4-4-4 4" }),
|
|
132
|
+
/* @__PURE__ */ i("path", { d: "M17 4v16" })
|
|
181
133
|
] });
|
|
182
134
|
}
|
|
183
|
-
function
|
|
184
|
-
return /* @__PURE__ */
|
|
185
|
-
/* @__PURE__ */
|
|
186
|
-
/* @__PURE__ */
|
|
187
|
-
/* @__PURE__ */
|
|
135
|
+
function Tt() {
|
|
136
|
+
return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
|
|
137
|
+
/* @__PURE__ */ i("path", { d: "M14 5h5v5" }),
|
|
138
|
+
/* @__PURE__ */ i("path", { d: "m13 11 6-6" }),
|
|
139
|
+
/* @__PURE__ */ i("path", { d: "M19 14v4.5A1.5 1.5 0 0 1 17.5 20h-12A1.5 1.5 0 0 1 4 18.5v-12A1.5 1.5 0 0 1 5.5 5H10" })
|
|
188
140
|
] });
|
|
189
141
|
}
|
|
190
|
-
function
|
|
191
|
-
return /* @__PURE__ */
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
/* @__PURE__ */
|
|
142
|
+
function $i() {
|
|
143
|
+
return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
|
|
144
|
+
/* @__PURE__ */ i("rect", { x: "8", y: "8", width: "12", height: "12", rx: "2" }),
|
|
145
|
+
/* @__PURE__ */ i("path", { d: "M4 14V6a2 2 0 0 1 2-2h8" })
|
|
194
146
|
] });
|
|
195
147
|
}
|
|
196
|
-
function
|
|
197
|
-
return /* @__PURE__ */
|
|
148
|
+
function lt() {
|
|
149
|
+
return /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ i("path", { d: "M20 6 9 17l-5-5" }) });
|
|
198
150
|
}
|
|
199
|
-
function
|
|
200
|
-
return /* @__PURE__ */
|
|
151
|
+
function jn() {
|
|
152
|
+
return /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ i("path", { d: "m6 9 6 6 6-6" }) });
|
|
201
153
|
}
|
|
202
|
-
function
|
|
203
|
-
return /* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
-
/* @__PURE__ */
|
|
206
|
-
/* @__PURE__ */
|
|
207
|
-
/* @__PURE__ */
|
|
208
|
-
/* @__PURE__ */
|
|
209
|
-
/* @__PURE__ */
|
|
154
|
+
function Wi() {
|
|
155
|
+
return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
|
|
156
|
+
/* @__PURE__ */ i("path", { d: "M5 7h5" }),
|
|
157
|
+
/* @__PURE__ */ i("path", { d: "M14 7h5" }),
|
|
158
|
+
/* @__PURE__ */ i("path", { d: "M5 17h9" }),
|
|
159
|
+
/* @__PURE__ */ i("path", { d: "M18 17h1" }),
|
|
160
|
+
/* @__PURE__ */ i("circle", { cx: "12", cy: "7", r: "2" }),
|
|
161
|
+
/* @__PURE__ */ i("circle", { cx: "16", cy: "17", r: "2" })
|
|
210
162
|
] });
|
|
211
163
|
}
|
|
212
|
-
function
|
|
213
|
-
return /* @__PURE__ */
|
|
164
|
+
function Hi() {
|
|
165
|
+
return /* @__PURE__ */ i(ni, { "aria-hidden": "true", focusable: "false" });
|
|
166
|
+
}
|
|
167
|
+
function Vi() {
|
|
168
|
+
return /* @__PURE__ */ i(ti, { "aria-hidden": "true", focusable: "false" });
|
|
169
|
+
}
|
|
170
|
+
function qi() {
|
|
171
|
+
return /* @__PURE__ */ i(ei, { "aria-hidden": "true", focusable: "false" });
|
|
172
|
+
}
|
|
173
|
+
function Gi() {
|
|
174
|
+
return /* @__PURE__ */ i(Ja, { "aria-hidden": "true", focusable: "false" });
|
|
175
|
+
}
|
|
176
|
+
function zi() {
|
|
177
|
+
return /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ i("circle", { cx: "12", cy: "12", r: "9" }) });
|
|
214
178
|
}
|
|
215
|
-
function
|
|
216
|
-
return /* @__PURE__ */
|
|
217
|
-
/* @__PURE__ */
|
|
218
|
-
/* @__PURE__ */
|
|
219
|
-
/* @__PURE__ */
|
|
179
|
+
function Ki() {
|
|
180
|
+
return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
|
|
181
|
+
/* @__PURE__ */ i("circle", { cx: "12", cy: "12", r: "9" }),
|
|
182
|
+
/* @__PURE__ */ i("path", { d: "M12 8v4" }),
|
|
183
|
+
/* @__PURE__ */ i("path", { d: "M12 16h.01" })
|
|
220
184
|
] });
|
|
221
185
|
}
|
|
222
|
-
function
|
|
223
|
-
return /* @__PURE__ */
|
|
224
|
-
/* @__PURE__ */
|
|
225
|
-
/* @__PURE__ */
|
|
226
|
-
/* @__PURE__ */
|
|
186
|
+
function Xn() {
|
|
187
|
+
return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
|
|
188
|
+
/* @__PURE__ */ i("circle", { cx: "12", cy: "12", r: "9" }),
|
|
189
|
+
/* @__PURE__ */ i("path", { d: "M12 11v5" }),
|
|
190
|
+
/* @__PURE__ */ i("path", { d: "M12 8h.01" })
|
|
227
191
|
] });
|
|
228
192
|
}
|
|
229
|
-
function
|
|
230
|
-
return /* @__PURE__ */
|
|
231
|
-
/* @__PURE__ */
|
|
232
|
-
/* @__PURE__ */
|
|
193
|
+
function ji() {
|
|
194
|
+
return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
|
|
195
|
+
/* @__PURE__ */ i("path", { d: "M18 6 6 18" }),
|
|
196
|
+
/* @__PURE__ */ i("path", { d: "m6 6 12 12" })
|
|
233
197
|
] });
|
|
234
198
|
}
|
|
235
|
-
const
|
|
236
|
-
function
|
|
199
|
+
const _n = "#06120c", In = "#f4f8f5";
|
|
200
|
+
function Pe(t) {
|
|
237
201
|
return Math.min(255, Math.max(0, Math.round(t)));
|
|
238
202
|
}
|
|
239
|
-
function
|
|
203
|
+
function Sn(t) {
|
|
240
204
|
const e = t.replace(/^#/, "");
|
|
241
205
|
if (!/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/.test(e)) return null;
|
|
242
206
|
const n = e.length === 3 ? e.split("").map((a) => a + a).join("") : e;
|
|
@@ -246,30 +210,30 @@ function hn(t) {
|
|
|
246
210
|
b: Number.parseInt(n.slice(4, 6), 16)
|
|
247
211
|
};
|
|
248
212
|
}
|
|
249
|
-
function
|
|
213
|
+
function Xi(t) {
|
|
250
214
|
return t.endsWith("%") ? Number.parseFloat(t) * 255 / 100 : Number.parseFloat(t);
|
|
251
215
|
}
|
|
252
|
-
function
|
|
216
|
+
function An(t) {
|
|
253
217
|
const e = t.match(/^rgba?\(\s*([\d.]+%?)\s*[,\s]\s*([\d.]+%?)\s*[,\s]\s*([\d.]+%?)/i);
|
|
254
218
|
if (!e) return null;
|
|
255
|
-
const [n, a,
|
|
256
|
-
return [n, a,
|
|
219
|
+
const [n, a, r] = [e[1], e[2], e[3]].map(Xi);
|
|
220
|
+
return [n, a, r].some((s) => Number.isNaN(s)) ? null : { r: Pe(n), g: Pe(a), b: Pe(r) };
|
|
257
221
|
}
|
|
258
|
-
function
|
|
259
|
-
const a = e / 100,
|
|
222
|
+
function Yi(t, e, n) {
|
|
223
|
+
const a = e / 100, r = n / 100, s = (1 - Math.abs(2 * r - 1)) * a, o = (t % 360 + 360) % 360 / 60, l = s * (1 - Math.abs(o % 2 - 1)), u = r - s / 2, [c, f, m] = o < 1 ? [s, l, 0] : o < 2 ? [l, s, 0] : o < 3 ? [0, s, l] : o < 4 ? [0, l, s] : o < 5 ? [l, 0, s] : [s, 0, l];
|
|
260
224
|
return {
|
|
261
|
-
r:
|
|
262
|
-
g:
|
|
263
|
-
b:
|
|
225
|
+
r: Pe((c + u) * 255),
|
|
226
|
+
g: Pe((f + u) * 255),
|
|
227
|
+
b: Pe((m + u) * 255)
|
|
264
228
|
};
|
|
265
229
|
}
|
|
266
|
-
function
|
|
230
|
+
function Qi(t) {
|
|
267
231
|
const e = t.match(/^hsla?\(\s*([\d.]+)(?:deg)?\s*[,\s]\s*([\d.]+)%\s*[,\s]\s*([\d.]+)%/i);
|
|
268
232
|
if (!e) return null;
|
|
269
|
-
const [n, a,
|
|
270
|
-
return [n, a,
|
|
233
|
+
const [n, a, r] = [e[1], e[2], e[3]].map(Number.parseFloat);
|
|
234
|
+
return [n, a, r].some((s) => Number.isNaN(s)) ? null : Yi(n, a, r);
|
|
271
235
|
}
|
|
272
|
-
function
|
|
236
|
+
function Zi(t) {
|
|
273
237
|
if (typeof document > "u") return null;
|
|
274
238
|
const e = document.createElement("canvas").getContext("2d");
|
|
275
239
|
if (!e) return null;
|
|
@@ -279,89 +243,102 @@ function Mi(t) {
|
|
|
279
243
|
const a = e.fillStyle;
|
|
280
244
|
return n === a ? n : null;
|
|
281
245
|
}
|
|
282
|
-
function
|
|
283
|
-
const e = t.trim(), n =
|
|
246
|
+
function Ji(t) {
|
|
247
|
+
const e = t.trim(), n = Sn(e) ?? An(e) ?? Qi(e);
|
|
284
248
|
if (n) return n;
|
|
285
|
-
const a =
|
|
286
|
-
return a ?
|
|
249
|
+
const a = Zi(e);
|
|
250
|
+
return a ? Sn(a) ?? An(a) : null;
|
|
287
251
|
}
|
|
288
|
-
function
|
|
252
|
+
function At(t) {
|
|
289
253
|
const e = t / 255;
|
|
290
254
|
return e <= 0.03928 ? e / 12.92 : ((e + 0.055) / 1.055) ** 2.4;
|
|
291
255
|
}
|
|
292
|
-
function
|
|
293
|
-
const e =
|
|
294
|
-
return e ? 0.2126 *
|
|
256
|
+
function Et(t) {
|
|
257
|
+
const e = Ji(t);
|
|
258
|
+
return e ? 0.2126 * At(e.r) + 0.7152 * At(e.g) + 0.0722 * At(e.b) : null;
|
|
295
259
|
}
|
|
296
|
-
function
|
|
260
|
+
function En(t, e) {
|
|
297
261
|
return (Math.max(t, e) + 0.05) / (Math.min(t, e) + 0.05);
|
|
298
262
|
}
|
|
299
|
-
function
|
|
300
|
-
const e =
|
|
263
|
+
function Yn(t) {
|
|
264
|
+
const e = Et(t);
|
|
301
265
|
if (e === null) return null;
|
|
302
|
-
const n =
|
|
303
|
-
return
|
|
304
|
-
}
|
|
305
|
-
const
|
|
306
|
-
function
|
|
307
|
-
return typeof window > "u" || !window.matchMedia ? "dark" : window.matchMedia(
|
|
308
|
-
}
|
|
309
|
-
function
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
266
|
+
const n = Et(_n) ?? 0, a = Et(In) ?? 1;
|
|
267
|
+
return En(e, n) >= En(e, a) ? _n : In;
|
|
268
|
+
}
|
|
269
|
+
const Qn = "(prefers-color-scheme: light)";
|
|
270
|
+
function er() {
|
|
271
|
+
return typeof window > "u" || !window.matchMedia ? "dark" : window.matchMedia(Qn).matches ? "light" : "dark";
|
|
272
|
+
}
|
|
273
|
+
function tr() {
|
|
274
|
+
return "dark";
|
|
275
|
+
}
|
|
276
|
+
function nr(t) {
|
|
277
|
+
if (typeof window > "u" || !window.matchMedia) return () => {
|
|
278
|
+
};
|
|
279
|
+
const e = window.matchMedia(Qn);
|
|
280
|
+
return e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
281
|
+
}
|
|
282
|
+
function ar() {
|
|
283
|
+
return () => {
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function Zn(t) {
|
|
287
|
+
const e = t === "auto", n = ot(
|
|
288
|
+
e ? nr : ar,
|
|
289
|
+
er,
|
|
290
|
+
tr
|
|
291
|
+
);
|
|
292
|
+
return t === "light" ? "light" : t === "dark" ? "dark" : e ? n : "dark";
|
|
293
|
+
}
|
|
294
|
+
function ir(t, e, n, a) {
|
|
295
|
+
const r = /* @__PURE__ */ new Map();
|
|
296
|
+
let s = 0, o = 0;
|
|
320
297
|
return t.forEach((l, u) => {
|
|
321
|
-
|
|
298
|
+
r.set(l.id, {
|
|
322
299
|
index: u,
|
|
323
300
|
zIndex: t.length - u,
|
|
324
|
-
offset:
|
|
301
|
+
offset: s,
|
|
325
302
|
front: u === 0,
|
|
326
|
-
hidden:
|
|
327
|
-
}), l.dismissed || (
|
|
328
|
-
}),
|
|
303
|
+
hidden: o >= a
|
|
304
|
+
}), l.dismissed || (s += (e[l.id] ?? 0) + n, o += 1);
|
|
305
|
+
}), r;
|
|
329
306
|
}
|
|
330
|
-
function
|
|
307
|
+
function rr(t) {
|
|
331
308
|
const e = t.style.height, n = t.style.transition;
|
|
332
309
|
t.style.transition = "none", t.style.height = "auto";
|
|
333
310
|
const a = t.getBoundingClientRect().height;
|
|
334
311
|
return t.style.height = e, t.getBoundingClientRect(), t.style.transition = n, a;
|
|
335
312
|
}
|
|
336
|
-
const
|
|
337
|
-
let
|
|
338
|
-
const
|
|
339
|
-
let
|
|
340
|
-
function
|
|
341
|
-
|
|
342
|
-
for (const e of
|
|
313
|
+
const dt = Object.freeze([]), sr = 32;
|
|
314
|
+
let ie = dt;
|
|
315
|
+
const Ct = /* @__PURE__ */ new Set();
|
|
316
|
+
let Fe = 0, xn = 0;
|
|
317
|
+
function Ge(t) {
|
|
318
|
+
ie = t.length === 0 ? dt : t;
|
|
319
|
+
for (const e of Ct) e();
|
|
343
320
|
}
|
|
344
|
-
function
|
|
345
|
-
return
|
|
321
|
+
function or() {
|
|
322
|
+
return ie;
|
|
346
323
|
}
|
|
347
|
-
function
|
|
348
|
-
return
|
|
349
|
-
|
|
324
|
+
function lr(t) {
|
|
325
|
+
return Ct.add(t), () => {
|
|
326
|
+
Ct.delete(t);
|
|
350
327
|
};
|
|
351
328
|
}
|
|
352
|
-
function
|
|
353
|
-
return
|
|
329
|
+
function cr() {
|
|
330
|
+
return xn += 1, `aegis-toast-${xn}`;
|
|
354
331
|
}
|
|
355
|
-
function
|
|
332
|
+
function ur(t, e) {
|
|
356
333
|
return !t || !e ? t === e : t.label === e.label && t.href === e.href && t.onClick === e.onClick;
|
|
357
334
|
}
|
|
358
|
-
function
|
|
359
|
-
const e = t.id ??
|
|
335
|
+
function We(t) {
|
|
336
|
+
const e = t.id ?? cr(), n = ie.find((o) => o.id === e), a = t.dismissible ?? !0;
|
|
360
337
|
if (n) {
|
|
361
|
-
if (n.type === t.type && n.title === t.title && n.description === t.description &&
|
|
338
|
+
if (n.type === t.type && n.title === t.title && n.description === t.description && ur(n.action, t.action) && n.duration === t.duration && n.dismissible === a && !n.dismissed)
|
|
362
339
|
return e;
|
|
363
|
-
|
|
364
|
-
const
|
|
340
|
+
Fe += 1;
|
|
341
|
+
const o = {
|
|
365
342
|
id: e,
|
|
366
343
|
type: t.type,
|
|
367
344
|
title: t.title,
|
|
@@ -370,13 +347,13 @@ function Le(t) {
|
|
|
370
347
|
duration: t.duration,
|
|
371
348
|
dismissible: a,
|
|
372
349
|
createdAt: n.createdAt,
|
|
373
|
-
updatedAt:
|
|
350
|
+
updatedAt: Fe,
|
|
374
351
|
dismissed: !1
|
|
375
352
|
};
|
|
376
|
-
return
|
|
353
|
+
return Ge(ie.map((l) => l.id === e ? o : l)), e;
|
|
377
354
|
}
|
|
378
|
-
|
|
379
|
-
const
|
|
355
|
+
Fe += 1;
|
|
356
|
+
const r = {
|
|
380
357
|
id: e,
|
|
381
358
|
type: t.type,
|
|
382
359
|
title: t.title,
|
|
@@ -384,227 +361,227 @@ function Le(t) {
|
|
|
384
361
|
action: t.action,
|
|
385
362
|
duration: t.duration,
|
|
386
363
|
dismissible: a,
|
|
387
|
-
createdAt:
|
|
388
|
-
updatedAt:
|
|
364
|
+
createdAt: Fe,
|
|
365
|
+
updatedAt: Fe,
|
|
389
366
|
dismissed: !1
|
|
390
|
-
},
|
|
391
|
-
return
|
|
367
|
+
}, s = ie.length >= sr ? ie.slice(1) : ie;
|
|
368
|
+
return Ge([...s, r]), e;
|
|
392
369
|
}
|
|
393
|
-
function
|
|
394
|
-
if (
|
|
395
|
-
const
|
|
396
|
-
|
|
370
|
+
function ve(t) {
|
|
371
|
+
if (ct.size === 0) {
|
|
372
|
+
const r = t === void 0 ? dt : ie.filter((s) => s.id !== t);
|
|
373
|
+
r.length !== ie.length && Ge(r);
|
|
397
374
|
return;
|
|
398
375
|
}
|
|
399
376
|
let n = !1;
|
|
400
|
-
const a =
|
|
401
|
-
n &&
|
|
402
|
-
}
|
|
403
|
-
function
|
|
404
|
-
const e =
|
|
405
|
-
e.length !==
|
|
406
|
-
}
|
|
407
|
-
const
|
|
408
|
-
let
|
|
409
|
-
const
|
|
410
|
-
function
|
|
411
|
-
for (const t of
|
|
412
|
-
}
|
|
413
|
-
function
|
|
414
|
-
return
|
|
415
|
-
|
|
377
|
+
const a = ie.map((r) => r.dismissed || t !== void 0 && r.id !== t ? r : (n = !0, { ...r, dismissed: !0 }));
|
|
378
|
+
n && Ge(a);
|
|
379
|
+
}
|
|
380
|
+
function dr(t) {
|
|
381
|
+
const e = ie.filter((n) => n.id !== t);
|
|
382
|
+
e.length !== ie.length && Ge(e);
|
|
383
|
+
}
|
|
384
|
+
const ct = /* @__PURE__ */ new Map(), Mt = /* @__PURE__ */ new WeakMap();
|
|
385
|
+
let pr = 0;
|
|
386
|
+
const Rt = /* @__PURE__ */ new Set();
|
|
387
|
+
function Nn() {
|
|
388
|
+
for (const t of Rt) t();
|
|
389
|
+
}
|
|
390
|
+
function fr(t, e) {
|
|
391
|
+
return Mt.has(t) || Mt.set(t, pr++), ct.set(t, e), Nn(), () => {
|
|
392
|
+
ct.delete(t), Nn();
|
|
416
393
|
};
|
|
417
394
|
}
|
|
418
|
-
function
|
|
419
|
-
return
|
|
420
|
-
|
|
395
|
+
function hr(t) {
|
|
396
|
+
return Rt.add(t), () => {
|
|
397
|
+
Rt.delete(t);
|
|
421
398
|
};
|
|
422
399
|
}
|
|
423
|
-
function
|
|
400
|
+
function gr(t) {
|
|
424
401
|
let e = null, n = null, a = 1 / 0;
|
|
425
|
-
for (const [
|
|
426
|
-
const
|
|
427
|
-
(e === null ||
|
|
402
|
+
for (const [r, s] of ct) {
|
|
403
|
+
const o = Mt.get(r) ?? 1 / 0;
|
|
404
|
+
(e === null || s === "host" && n !== "host" || s === n && o < a) && (e = r, n = s, a = o);
|
|
428
405
|
}
|
|
429
406
|
return e === t;
|
|
430
407
|
}
|
|
431
|
-
const
|
|
432
|
-
function
|
|
408
|
+
const mr = 45, wr = 0.11;
|
|
409
|
+
function br(t) {
|
|
433
410
|
return t === "bottom" ? 1 : -1;
|
|
434
411
|
}
|
|
435
|
-
function
|
|
412
|
+
function yr(t, e) {
|
|
436
413
|
const n = Math.abs(t);
|
|
437
|
-
return n >=
|
|
414
|
+
return n >= mr ? !0 : e > 0 && n / e > wr;
|
|
438
415
|
}
|
|
439
|
-
function
|
|
416
|
+
function vr(t, e) {
|
|
440
417
|
return t * e >= 0 ? t : t / (1.5 + Math.abs(t) / 20);
|
|
441
418
|
}
|
|
442
|
-
function
|
|
419
|
+
function _r(t, e, n) {
|
|
443
420
|
const a = n === "touch" ? 10 : 2;
|
|
444
421
|
return Math.max(Math.abs(t), Math.abs(e)) < a ? "pending" : Math.abs(e) >= Math.abs(t) ? "swipe" : "abort";
|
|
445
422
|
}
|
|
446
|
-
function
|
|
447
|
-
const a = n.now ?? (() => Date.now()),
|
|
448
|
-
let
|
|
423
|
+
function Ir(t, e, n = {}) {
|
|
424
|
+
const a = n.now ?? (() => Date.now()), r = n.set ?? ((f, m) => setTimeout(f, m)), s = n.clear ?? ((f) => clearTimeout(f));
|
|
425
|
+
let o = e, l = 0, u = null, c = !1;
|
|
449
426
|
return {
|
|
450
427
|
start() {
|
|
451
|
-
c || u !== null || (l = a(), u =
|
|
428
|
+
c || u !== null || (l = a(), u = r(
|
|
452
429
|
() => {
|
|
453
430
|
u = null, c = !0, t();
|
|
454
431
|
},
|
|
455
|
-
Math.max(0,
|
|
432
|
+
Math.max(0, o)
|
|
456
433
|
));
|
|
457
434
|
},
|
|
458
435
|
pause() {
|
|
459
|
-
c || u === null || (
|
|
436
|
+
c || u === null || (s(u), u = null, o -= a() - l);
|
|
460
437
|
},
|
|
461
438
|
cancel() {
|
|
462
|
-
u !== null &&
|
|
439
|
+
u !== null && s(u), u = null, c = !0;
|
|
463
440
|
}
|
|
464
441
|
};
|
|
465
442
|
}
|
|
466
|
-
function
|
|
443
|
+
function Sr({
|
|
467
444
|
durationMs: t,
|
|
468
445
|
epoch: e,
|
|
469
446
|
paused: n,
|
|
470
447
|
onExpire: a
|
|
471
448
|
}) {
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
const
|
|
475
|
-
|
|
449
|
+
const r = W(a);
|
|
450
|
+
r.current = a;
|
|
451
|
+
const s = W(null);
|
|
452
|
+
U(() => {
|
|
476
453
|
if (t === null || !Number.isFinite(t)) return;
|
|
477
|
-
const
|
|
478
|
-
return
|
|
479
|
-
|
|
454
|
+
const o = Ir(() => r.current(), t);
|
|
455
|
+
return s.current = o, () => {
|
|
456
|
+
s.current = null, o.cancel();
|
|
480
457
|
};
|
|
481
|
-
}, [t, e]),
|
|
482
|
-
const
|
|
483
|
-
|
|
458
|
+
}, [t, e]), U(() => {
|
|
459
|
+
const o = s.current;
|
|
460
|
+
o && (n ? o.pause() : o.start());
|
|
484
461
|
}, [t, e, n]);
|
|
485
462
|
}
|
|
486
|
-
const
|
|
487
|
-
loading:
|
|
488
|
-
success:
|
|
489
|
-
error:
|
|
490
|
-
info:
|
|
463
|
+
const Ar = 260, Jn = 8e3, Er = {
|
|
464
|
+
loading: zi,
|
|
465
|
+
success: lt,
|
|
466
|
+
error: Ki,
|
|
467
|
+
info: Xn
|
|
491
468
|
};
|
|
492
|
-
function
|
|
493
|
-
return t.duration !== void 0 ? Number.isFinite(t.duration) ? t.duration : null : t.type === "loading" ? null : t.type === "error" ?
|
|
469
|
+
function xr(t, e) {
|
|
470
|
+
return t.duration !== void 0 ? Number.isFinite(t.duration) ? t.duration : null : t.type === "loading" ? null : t.type === "error" ? Jn : e;
|
|
494
471
|
}
|
|
495
|
-
const
|
|
472
|
+
const Nr = ut(function({
|
|
496
473
|
toast: e,
|
|
497
474
|
index: n,
|
|
498
475
|
zIndex: a,
|
|
499
|
-
offset:
|
|
500
|
-
front:
|
|
501
|
-
hidden:
|
|
476
|
+
offset: r,
|
|
477
|
+
front: s,
|
|
478
|
+
hidden: o,
|
|
502
479
|
regionPaused: l,
|
|
503
480
|
yPosition: u,
|
|
504
481
|
defaultDurationMs: c,
|
|
505
|
-
closeButton:
|
|
506
|
-
height:
|
|
507
|
-
registerHeight:
|
|
508
|
-
unregisterHeight:
|
|
509
|
-
swipeStateRef:
|
|
482
|
+
closeButton: f,
|
|
483
|
+
height: m,
|
|
484
|
+
registerHeight: I,
|
|
485
|
+
unregisterHeight: E,
|
|
486
|
+
swipeStateRef: v
|
|
510
487
|
}) {
|
|
511
|
-
var
|
|
512
|
-
const w =
|
|
513
|
-
|
|
488
|
+
var K;
|
|
489
|
+
const w = W(null), b = W(null), [x, R] = P(!1), [D, B] = P(!1), [S, h] = P(!1);
|
|
490
|
+
U(() => {
|
|
514
491
|
let d = 0;
|
|
515
|
-
const
|
|
516
|
-
d = requestAnimationFrame(() =>
|
|
492
|
+
const _ = requestAnimationFrame(() => {
|
|
493
|
+
d = requestAnimationFrame(() => R(!0));
|
|
517
494
|
});
|
|
518
495
|
return () => {
|
|
519
|
-
cancelAnimationFrame(
|
|
496
|
+
cancelAnimationFrame(_), cancelAnimationFrame(d);
|
|
520
497
|
};
|
|
521
|
-
}, []),
|
|
498
|
+
}, []), Za(() => {
|
|
522
499
|
if (e.dismissed) return;
|
|
523
500
|
const d = w.current;
|
|
524
|
-
d &&
|
|
501
|
+
d && I(e.id, rr(d));
|
|
525
502
|
}, [
|
|
526
|
-
|
|
527
|
-
(
|
|
503
|
+
I,
|
|
504
|
+
(K = e.action) == null ? void 0 : K.label,
|
|
528
505
|
e.description,
|
|
529
506
|
e.dismissed,
|
|
530
507
|
e.id,
|
|
531
508
|
e.title
|
|
532
509
|
]);
|
|
533
|
-
const
|
|
534
|
-
e.dismissed || (
|
|
535
|
-
const
|
|
536
|
-
|
|
510
|
+
const A = W(r);
|
|
511
|
+
e.dismissed || (A.current = r);
|
|
512
|
+
const y = e.dismissed ? A.current : r;
|
|
513
|
+
U(() => {
|
|
537
514
|
if (!e.dismissed) {
|
|
538
|
-
|
|
515
|
+
h(!1);
|
|
539
516
|
return;
|
|
540
517
|
}
|
|
541
|
-
|
|
542
|
-
const d = window.setTimeout(() =>
|
|
518
|
+
E(e.id);
|
|
519
|
+
const d = window.setTimeout(() => dr(e.id), Ar);
|
|
543
520
|
return () => window.clearTimeout(d);
|
|
544
|
-
}, [e.dismissed, e.id,
|
|
545
|
-
durationMs:
|
|
521
|
+
}, [e.dismissed, e.id, E]), U(() => () => E(e.id), [e.id, E]), Sr({
|
|
522
|
+
durationMs: xr(e, c),
|
|
546
523
|
epoch: e.updatedAt,
|
|
547
|
-
paused: l ||
|
|
548
|
-
onExpire: () =>
|
|
524
|
+
paused: l || D || o || e.dismissed,
|
|
525
|
+
onExpire: () => ve(e.id)
|
|
549
526
|
});
|
|
550
|
-
const
|
|
551
|
-
const
|
|
552
|
-
if (!
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
!
|
|
556
|
-
},
|
|
557
|
-
!e.dismissible || e.dismissed || d.target.closest("button, a") || (
|
|
527
|
+
const M = (d, _) => {
|
|
528
|
+
const q = b.current;
|
|
529
|
+
if (!q || d.pointerId !== q.pointerId || (b.current = null, q.intent !== "swipe")) return;
|
|
530
|
+
B(!1), v.current = !1;
|
|
531
|
+
const k = w.current, ne = k && Number.parseFloat(k.style.getPropertyValue("--swipe-y")) || 0;
|
|
532
|
+
!_ && yr(ne, Date.now() - q.startedAt) ? (h(!0), ve(e.id)) : k == null || k.style.setProperty("--swipe-y", "0px");
|
|
533
|
+
}, V = (d) => {
|
|
534
|
+
!e.dismissible || e.dismissed || d.target.closest("button, a") || (b.current = {
|
|
558
535
|
pointerId: d.pointerId,
|
|
559
536
|
startX: d.clientX,
|
|
560
537
|
startY: d.clientY,
|
|
561
538
|
startedAt: Date.now(),
|
|
562
539
|
intent: "pending"
|
|
563
540
|
}, d.currentTarget.setPointerCapture(d.pointerId));
|
|
564
|
-
},
|
|
565
|
-
var
|
|
566
|
-
const
|
|
567
|
-
if (!
|
|
568
|
-
const
|
|
569
|
-
if (
|
|
570
|
-
const
|
|
571
|
-
(
|
|
572
|
-
},
|
|
541
|
+
}, z = (d) => {
|
|
542
|
+
var re;
|
|
543
|
+
const _ = b.current;
|
|
544
|
+
if (!_ || d.pointerId !== _.pointerId) return;
|
|
545
|
+
const q = d.clientX - _.startX, k = d.clientY - _.startY;
|
|
546
|
+
if (_.intent === "pending" && (_.intent = _r(q, k, d.pointerType || "mouse"), _.intent === "swipe" && (B(!0), v.current = !0)), _.intent !== "swipe") return;
|
|
547
|
+
const ne = vr(k, br(u));
|
|
548
|
+
(re = w.current) == null || re.style.setProperty("--swipe-y", `${ne}px`);
|
|
549
|
+
}, N = Er[e.type], te = {
|
|
573
550
|
"--index": n,
|
|
574
551
|
"--z": a,
|
|
575
|
-
"--offset": `${
|
|
576
|
-
...
|
|
552
|
+
"--offset": `${y}px`,
|
|
553
|
+
...m !== void 0 ? { "--initial-height": `${m}px` } : {}
|
|
577
554
|
};
|
|
578
|
-
return /* @__PURE__ */
|
|
555
|
+
return /* @__PURE__ */ p(
|
|
579
556
|
"li",
|
|
580
557
|
{
|
|
581
558
|
ref: w,
|
|
582
559
|
className: "aegis-swap-toast",
|
|
583
560
|
"data-type": e.type,
|
|
584
|
-
"data-mounted":
|
|
585
|
-
"data-front":
|
|
586
|
-
"data-removing": e.dismissed && !
|
|
587
|
-
"data-swipe-out":
|
|
588
|
-
"data-swiping":
|
|
589
|
-
"data-hidden":
|
|
561
|
+
"data-mounted": x ? "" : void 0,
|
|
562
|
+
"data-front": s ? "" : void 0,
|
|
563
|
+
"data-removing": e.dismissed && !S ? "" : void 0,
|
|
564
|
+
"data-swipe-out": S ? "" : void 0,
|
|
565
|
+
"data-swiping": D ? "" : void 0,
|
|
566
|
+
"data-hidden": o ? "" : void 0,
|
|
590
567
|
"data-dismissible": e.dismissible ? "" : void 0,
|
|
591
568
|
role: e.type === "error" ? "alert" : "status",
|
|
592
569
|
"aria-live": e.type === "error" ? "assertive" : "polite",
|
|
593
570
|
"aria-atomic": "true",
|
|
594
|
-
"aria-hidden":
|
|
595
|
-
style:
|
|
596
|
-
onPointerDown:
|
|
597
|
-
onPointerMove:
|
|
598
|
-
onPointerUp: (d) =>
|
|
599
|
-
onPointerCancel: (d) =>
|
|
571
|
+
"aria-hidden": o ? !0 : void 0,
|
|
572
|
+
style: te,
|
|
573
|
+
onPointerDown: V,
|
|
574
|
+
onPointerMove: z,
|
|
575
|
+
onPointerUp: (d) => M(d, !1),
|
|
576
|
+
onPointerCancel: (d) => M(d, !0),
|
|
600
577
|
onKeyDown: (d) => {
|
|
601
|
-
d.key === "Escape" && e.dismissible && !e.dismissed && (d.stopPropagation(),
|
|
578
|
+
d.key === "Escape" && e.dismissible && !e.dismissed && (d.stopPropagation(), ve(e.id));
|
|
602
579
|
},
|
|
603
580
|
children: [
|
|
604
|
-
/* @__PURE__ */
|
|
605
|
-
/* @__PURE__ */
|
|
606
|
-
/* @__PURE__ */
|
|
607
|
-
e.description ? /* @__PURE__ */
|
|
581
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-toast__icon", "aria-hidden": "true", children: /* @__PURE__ */ i(N, {}) }, e.type),
|
|
582
|
+
/* @__PURE__ */ p("div", { className: "aegis-swap-toast__content", children: [
|
|
583
|
+
/* @__PURE__ */ i("p", { className: "aegis-swap-toast__title", children: e.title }, `t:${e.title}`),
|
|
584
|
+
e.description ? /* @__PURE__ */ i(
|
|
608
585
|
"p",
|
|
609
586
|
{
|
|
610
587
|
className: "aegis-swap-toast__description",
|
|
@@ -613,144 +590,144 @@ const ar = nt(function({
|
|
|
613
590
|
`d:${e.description}`
|
|
614
591
|
) : null
|
|
615
592
|
] }),
|
|
616
|
-
e.action ? e.action.href ? /* @__PURE__ */
|
|
593
|
+
e.action ? e.action.href ? /* @__PURE__ */ i(
|
|
617
594
|
"a",
|
|
618
595
|
{
|
|
619
596
|
className: "aegis-swap-toast__action",
|
|
620
597
|
href: e.action.href,
|
|
621
598
|
target: "_blank",
|
|
622
599
|
rel: "noopener noreferrer",
|
|
623
|
-
onClick: () =>
|
|
600
|
+
onClick: () => ve(e.id),
|
|
624
601
|
children: e.action.label
|
|
625
602
|
}
|
|
626
|
-
) : /* @__PURE__ */
|
|
603
|
+
) : /* @__PURE__ */ i(
|
|
627
604
|
"button",
|
|
628
605
|
{
|
|
629
606
|
type: "button",
|
|
630
607
|
className: "aegis-swap-toast__action",
|
|
631
608
|
onClick: () => {
|
|
632
|
-
var d,
|
|
633
|
-
(
|
|
609
|
+
var d, _;
|
|
610
|
+
(_ = (d = e.action) == null ? void 0 : d.onClick) == null || _.call(d), ve(e.id);
|
|
634
611
|
},
|
|
635
612
|
children: e.action.label
|
|
636
613
|
}
|
|
637
614
|
) : null,
|
|
638
|
-
|
|
615
|
+
f && e.dismissible ? /* @__PURE__ */ i(
|
|
639
616
|
"button",
|
|
640
617
|
{
|
|
641
618
|
type: "button",
|
|
642
619
|
className: "aegis-swap-toast__close",
|
|
643
620
|
"aria-label": "Dismiss notification",
|
|
644
|
-
onClick: () =>
|
|
645
|
-
children: /* @__PURE__ */
|
|
621
|
+
onClick: () => ve(e.id),
|
|
622
|
+
children: /* @__PURE__ */ i(ji, {})
|
|
646
623
|
}
|
|
647
624
|
) : null
|
|
648
625
|
]
|
|
649
626
|
}
|
|
650
627
|
);
|
|
651
628
|
});
|
|
652
|
-
function
|
|
629
|
+
function Pr(t) {
|
|
653
630
|
return document.addEventListener("visibilitychange", t), () => document.removeEventListener("visibilitychange", t);
|
|
654
631
|
}
|
|
655
|
-
const
|
|
656
|
-
function
|
|
657
|
-
return
|
|
632
|
+
const Tr = () => !0;
|
|
633
|
+
function Cr() {
|
|
634
|
+
return ot(Pr, Ve, Tr);
|
|
658
635
|
}
|
|
659
|
-
const
|
|
660
|
-
function
|
|
636
|
+
const Mr = 12, Rr = 5e3, Dr = 3, Or = () => dt, Br = () => !1;
|
|
637
|
+
function ea({
|
|
661
638
|
kind: t,
|
|
662
639
|
position: e = "bottom-right",
|
|
663
640
|
theme: n,
|
|
664
641
|
accentColor: a,
|
|
665
|
-
accentTextColor:
|
|
666
|
-
duration:
|
|
667
|
-
visibleToasts:
|
|
642
|
+
accentTextColor: r,
|
|
643
|
+
duration: s = Rr,
|
|
644
|
+
visibleToasts: o = Dr,
|
|
668
645
|
closeButton: l = !1,
|
|
669
646
|
expand: u = !1,
|
|
670
647
|
offset: c,
|
|
671
|
-
className:
|
|
672
|
-
style:
|
|
648
|
+
className: f,
|
|
649
|
+
style: m
|
|
673
650
|
}) {
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
() =>
|
|
679
|
-
|
|
680
|
-
), [w,
|
|
681
|
-
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
}, []),
|
|
685
|
-
|
|
686
|
-
if (!(
|
|
687
|
-
const
|
|
688
|
-
return delete
|
|
651
|
+
const I = ot(lr, or, Or), E = W({}).current;
|
|
652
|
+
U(() => fr(E, t), [t, E]);
|
|
653
|
+
const v = ot(
|
|
654
|
+
hr,
|
|
655
|
+
() => gr(E),
|
|
656
|
+
Br
|
|
657
|
+
), [w, b] = P(!1);
|
|
658
|
+
U(() => b(!0), []);
|
|
659
|
+
const x = Zn(n), R = Cr(), [D, B] = P(!1), [S, h] = P(!1), [A, y] = P({}), M = W(!1), V = O((L, g) => {
|
|
660
|
+
y((T) => T[L] === g ? T : { ...T, [L]: g });
|
|
661
|
+
}, []), z = O((L) => {
|
|
662
|
+
y((g) => {
|
|
663
|
+
if (!(L in g)) return g;
|
|
664
|
+
const T = { ...g };
|
|
665
|
+
return delete T[L], T;
|
|
689
666
|
});
|
|
690
|
-
}, []),
|
|
691
|
-
() =>
|
|
692
|
-
[
|
|
693
|
-
),
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
}, [
|
|
697
|
-
const [
|
|
698
|
-
const
|
|
667
|
+
}, []), N = J(() => [...I].reverse(), [I]), te = J(
|
|
668
|
+
() => ir(N, A, Mr, o),
|
|
669
|
+
[A, N, o]
|
|
670
|
+
), K = N.find((L) => !L.dismissed) ?? N[0], d = K ? A[K.id] ?? 0 : 0;
|
|
671
|
+
U(() => {
|
|
672
|
+
N.length > 0 || (B(!1), h(!1));
|
|
673
|
+
}, [N.length]);
|
|
674
|
+
const [_, q] = e.split("-"), k = u || D || S, ne = D || S || !R, re = J(() => {
|
|
675
|
+
const L = { ...m };
|
|
699
676
|
if (a) {
|
|
700
|
-
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
} else
|
|
677
|
+
L["--aegis-swap-accent"] = a;
|
|
678
|
+
const g = r ?? Yn(a);
|
|
679
|
+
g && (L["--aegis-swap-accent-text"] = g);
|
|
680
|
+
} else r && (L["--aegis-swap-accent-text"] = r);
|
|
704
681
|
if (c !== void 0) {
|
|
705
|
-
const
|
|
706
|
-
|
|
682
|
+
const g = typeof c == "number" ? `${c}px` : c;
|
|
683
|
+
L["--aegis-swap-toast-offset-x"] = g, L["--aegis-swap-toast-offset-y"] = g;
|
|
707
684
|
}
|
|
708
|
-
return
|
|
709
|
-
}, [a,
|
|
710
|
-
return !w || !
|
|
711
|
-
/* @__PURE__ */
|
|
685
|
+
return L["--aegis-swap-toast-front-height"] = `${d}px`, L;
|
|
686
|
+
}, [a, r, d, c, m]);
|
|
687
|
+
return !w || !v || N.length === 0 ? null : Pi(
|
|
688
|
+
/* @__PURE__ */ i(
|
|
712
689
|
"ol",
|
|
713
690
|
{
|
|
714
691
|
className: [
|
|
715
692
|
"aegis-swap-toaster",
|
|
716
|
-
|
|
717
|
-
|
|
693
|
+
x === "light" ? "aegis-swap-toaster--light" : "",
|
|
694
|
+
f ?? ""
|
|
718
695
|
].join(" ").trim(),
|
|
719
|
-
"data-y-position":
|
|
720
|
-
"data-x-position":
|
|
721
|
-
"data-expanded":
|
|
696
|
+
"data-y-position": _,
|
|
697
|
+
"data-x-position": q,
|
|
698
|
+
"data-expanded": k ? "" : void 0,
|
|
722
699
|
"aria-label": "Notifications",
|
|
723
|
-
style:
|
|
724
|
-
onMouseEnter: () =>
|
|
725
|
-
onMouseMove: () =>
|
|
700
|
+
style: re,
|
|
701
|
+
onMouseEnter: () => B(!0),
|
|
702
|
+
onMouseMove: () => B(!0),
|
|
726
703
|
onMouseLeave: () => {
|
|
727
|
-
|
|
704
|
+
M.current || B(!1);
|
|
728
705
|
},
|
|
729
|
-
onFocus: () =>
|
|
730
|
-
onBlur: (
|
|
731
|
-
|
|
706
|
+
onFocus: () => h(!0),
|
|
707
|
+
onBlur: (L) => {
|
|
708
|
+
L.currentTarget.contains(L.relatedTarget) || h(!1);
|
|
732
709
|
},
|
|
733
|
-
children:
|
|
734
|
-
const
|
|
735
|
-
return
|
|
736
|
-
|
|
710
|
+
children: N.map((L) => {
|
|
711
|
+
const g = te.get(L.id);
|
|
712
|
+
return g ? /* @__PURE__ */ i(
|
|
713
|
+
Nr,
|
|
737
714
|
{
|
|
738
|
-
toast:
|
|
739
|
-
index:
|
|
740
|
-
zIndex:
|
|
741
|
-
offset:
|
|
742
|
-
front:
|
|
743
|
-
hidden:
|
|
744
|
-
regionPaused:
|
|
745
|
-
yPosition:
|
|
746
|
-
defaultDurationMs:
|
|
715
|
+
toast: L,
|
|
716
|
+
index: g.index,
|
|
717
|
+
zIndex: g.zIndex,
|
|
718
|
+
offset: g.offset,
|
|
719
|
+
front: g.front,
|
|
720
|
+
hidden: g.hidden,
|
|
721
|
+
regionPaused: ne,
|
|
722
|
+
yPosition: _,
|
|
723
|
+
defaultDurationMs: s,
|
|
747
724
|
closeButton: l,
|
|
748
|
-
height:
|
|
749
|
-
registerHeight:
|
|
750
|
-
unregisterHeight:
|
|
751
|
-
swipeStateRef:
|
|
725
|
+
height: A[L.id],
|
|
726
|
+
registerHeight: V,
|
|
727
|
+
unregisterHeight: z,
|
|
728
|
+
swipeStateRef: M
|
|
752
729
|
},
|
|
753
|
-
|
|
730
|
+
L.id
|
|
754
731
|
) : null;
|
|
755
732
|
})
|
|
756
733
|
}
|
|
@@ -758,137 +735,192 @@ function qn({
|
|
|
758
735
|
document.body
|
|
759
736
|
);
|
|
760
737
|
}
|
|
761
|
-
function
|
|
762
|
-
return /* @__PURE__ */
|
|
738
|
+
function Ms(t) {
|
|
739
|
+
return /* @__PURE__ */ i(ea, { kind: "host", ...t });
|
|
740
|
+
}
|
|
741
|
+
function kr(t) {
|
|
742
|
+
return /* @__PURE__ */ i(ea, { kind: "internal", ...t });
|
|
743
|
+
}
|
|
744
|
+
function He(t) {
|
|
745
|
+
const a = ((t.match(/,/g) ?? []).length === 1 && !t.includes(".") ? t.replace(",", ".") : t).replace(/[^\d.]/g, ""), [r = "", ...s] = a.split("."), o = s.length > 0 ? `${r}.${s.join("")}` : r;
|
|
746
|
+
return o === "." ? "0." : o;
|
|
747
|
+
}
|
|
748
|
+
function Pn(t) {
|
|
749
|
+
const e = He(t);
|
|
750
|
+
if (!e) return "";
|
|
751
|
+
const n = Number(e);
|
|
752
|
+
return Number.isFinite(n) && n > 20 ? "20" : e;
|
|
753
|
+
}
|
|
754
|
+
function Lr(t, e) {
|
|
755
|
+
const n = t.trim();
|
|
756
|
+
if (!n || n === ".") return null;
|
|
757
|
+
try {
|
|
758
|
+
return Ti(n, e);
|
|
759
|
+
} catch {
|
|
760
|
+
return null;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
function Tn(t) {
|
|
764
|
+
const e = t.trim();
|
|
765
|
+
if (!e) return null;
|
|
766
|
+
const n = Number(e);
|
|
767
|
+
return !Number.isFinite(n) || n < 0 || n > 20 ? null : Math.round(n * 100);
|
|
768
|
+
}
|
|
769
|
+
function pt(t, e, n = "half-up") {
|
|
770
|
+
if (t === 0n || e <= 0) return t;
|
|
771
|
+
const a = t < 0n ? -1n : 1n, r = t < 0n ? -t : t, o = r.toString().length - e;
|
|
772
|
+
if (o <= 0) return t;
|
|
773
|
+
const l = 10n ** BigInt(o);
|
|
774
|
+
return (n === "floor" ? r / l * l : (r + l / 2n) / l * l) * a;
|
|
775
|
+
}
|
|
776
|
+
function ze(t) {
|
|
777
|
+
return t.includes(".") ? t.replace(/\.?0+$/, "") : t;
|
|
778
|
+
}
|
|
779
|
+
function _e(t, e, n = 4) {
|
|
780
|
+
return t == null ? "--" : ze(Ot(pt(t, n), e));
|
|
781
|
+
}
|
|
782
|
+
function Fr(t, e, n = 4) {
|
|
783
|
+
return t == null ? "--" : ze(
|
|
784
|
+
Ot(pt(t, n, "floor"), e)
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
function Cn(t, e) {
|
|
788
|
+
return t == null ? "" : _e(t, e);
|
|
763
789
|
}
|
|
764
|
-
function
|
|
765
|
-
return
|
|
790
|
+
function Ur(t, e) {
|
|
791
|
+
return t == null ? "" : ze(Ot(t, e));
|
|
766
792
|
}
|
|
767
|
-
function
|
|
768
|
-
return
|
|
793
|
+
function $r(t, e = 4) {
|
|
794
|
+
return t == null ? "--" : ze(Ci(pt(t, e)));
|
|
769
795
|
}
|
|
770
|
-
function
|
|
796
|
+
function Wr(t, e = 4) {
|
|
797
|
+
return t == null ? "--" : ze(Mi(pt(t, e)));
|
|
798
|
+
}
|
|
799
|
+
function Ue(t) {
|
|
800
|
+
return (e, n) => We({ ...n, type: t, title: e });
|
|
801
|
+
}
|
|
802
|
+
function xt(t, e) {
|
|
771
803
|
const n = typeof t == "function" ? t(e) : t;
|
|
772
804
|
return typeof n == "string" ? { title: n } : n;
|
|
773
805
|
}
|
|
774
|
-
const
|
|
775
|
-
info:
|
|
776
|
-
success:
|
|
777
|
-
error:
|
|
778
|
-
loading:
|
|
806
|
+
const ye = Object.assign(Ue("info"), {
|
|
807
|
+
info: Ue("info"),
|
|
808
|
+
success: Ue("success"),
|
|
809
|
+
error: Ue("error"),
|
|
810
|
+
loading: Ue("loading"),
|
|
779
811
|
dismiss(t) {
|
|
780
|
-
|
|
812
|
+
ve(t);
|
|
781
813
|
},
|
|
782
814
|
promise(t, e) {
|
|
783
|
-
const n = typeof e.loading == "string" ? { title: e.loading } : e.loading, a =
|
|
784
|
-
let
|
|
815
|
+
const n = typeof e.loading == "string" ? { title: e.loading } : e.loading, a = We({ ...n, id: e.id, type: "loading" });
|
|
816
|
+
let r;
|
|
785
817
|
try {
|
|
786
|
-
|
|
787
|
-
} catch (
|
|
788
|
-
throw
|
|
818
|
+
r = typeof t == "function" ? t() : t;
|
|
819
|
+
} catch (s) {
|
|
820
|
+
throw We({ ...xt(e.error, s), id: a, type: "error" }), s;
|
|
789
821
|
}
|
|
790
|
-
return
|
|
791
|
-
(
|
|
792
|
-
|
|
822
|
+
return r.then(
|
|
823
|
+
(s) => {
|
|
824
|
+
We({ ...xt(e.success, s), id: a, type: "success" });
|
|
793
825
|
},
|
|
794
|
-
(
|
|
795
|
-
|
|
826
|
+
(s) => {
|
|
827
|
+
We({ ...xt(e.error, s), id: a, type: "error" });
|
|
796
828
|
}
|
|
797
829
|
), a;
|
|
798
830
|
}
|
|
799
|
-
}),
|
|
800
|
-
function
|
|
831
|
+
}), Hr = 4e3;
|
|
832
|
+
function Vr({
|
|
801
833
|
enabled: t,
|
|
802
834
|
status: e,
|
|
803
835
|
progress: n,
|
|
804
836
|
txHash: a,
|
|
805
|
-
explorerUrl:
|
|
806
|
-
successDescription:
|
|
837
|
+
explorerUrl: r,
|
|
838
|
+
successDescription: s
|
|
807
839
|
}) {
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
const c =
|
|
840
|
+
const o = W({ currentId: null, terminal: !1, lastId: null }), l = (n == null ? void 0 : n.state) ?? null, u = (n == null ? void 0 : n.label) ?? null;
|
|
841
|
+
U(() => {
|
|
842
|
+
const c = o.current;
|
|
811
843
|
if (!t) {
|
|
812
|
-
c.currentId && !c.terminal &&
|
|
844
|
+
c.currentId && !c.terminal && ye.dismiss(c.currentId), c.currentId = null, c.terminal = !1;
|
|
813
845
|
return;
|
|
814
846
|
}
|
|
815
|
-
const
|
|
847
|
+
const f = a && r ? { label: "View transaction", href: r } : void 0;
|
|
816
848
|
if (l === "error" && u) {
|
|
817
|
-
c.currentId =
|
|
849
|
+
c.currentId = ye.error(u, {
|
|
818
850
|
id: c.currentId ?? void 0,
|
|
819
|
-
action:
|
|
820
|
-
duration: u ===
|
|
851
|
+
action: f,
|
|
852
|
+
duration: u === ii ? Hr : Jn
|
|
821
853
|
}), c.terminal = !0, c.lastId = c.currentId;
|
|
822
854
|
return;
|
|
823
855
|
}
|
|
824
856
|
if (e === "success") {
|
|
825
|
-
c.currentId =
|
|
857
|
+
c.currentId = ye.success("Swap confirmed", {
|
|
826
858
|
id: c.currentId ?? void 0,
|
|
827
|
-
description:
|
|
828
|
-
action:
|
|
859
|
+
description: s ?? void 0,
|
|
860
|
+
action: f
|
|
829
861
|
}), c.terminal = !0, c.lastId = c.currentId;
|
|
830
862
|
return;
|
|
831
863
|
}
|
|
832
|
-
if ((l === "pending" || l === "mining") &&
|
|
833
|
-
(!c.currentId || c.terminal) && (c.lastId &&
|
|
864
|
+
if ((l === "pending" || l === "mining") && $n(e) && u) {
|
|
865
|
+
(!c.currentId || c.terminal) && (c.lastId && ye.dismiss(c.lastId), c.currentId = null, c.terminal = !1), c.currentId = ye.loading(u, {
|
|
834
866
|
id: c.currentId ?? void 0
|
|
835
867
|
}), c.lastId = c.currentId;
|
|
836
868
|
return;
|
|
837
869
|
}
|
|
838
|
-
c.currentId && !c.terminal && (
|
|
839
|
-
}, [t,
|
|
870
|
+
c.currentId && !c.terminal && (ye.dismiss(c.currentId), c.currentId = null);
|
|
871
|
+
}, [t, r, u, l, e, s, a]), U(
|
|
840
872
|
() => () => {
|
|
841
|
-
const c =
|
|
842
|
-
c.currentId && !c.terminal &&
|
|
873
|
+
const c = o.current;
|
|
874
|
+
c.currentId && !c.terminal && ye.dismiss(c.currentId);
|
|
843
875
|
},
|
|
844
876
|
[]
|
|
845
877
|
);
|
|
846
878
|
}
|
|
847
|
-
function
|
|
848
|
-
const
|
|
849
|
-
|
|
850
|
-
const
|
|
851
|
-
|
|
879
|
+
function ta(t, e, { initial: n, label: a, equals: r = Object.is }) {
|
|
880
|
+
const s = W(t);
|
|
881
|
+
s.current = t;
|
|
882
|
+
const o = W(n);
|
|
883
|
+
U(() => {
|
|
852
884
|
var l;
|
|
853
|
-
if (!
|
|
854
|
-
|
|
885
|
+
if (!r(o.current, e)) {
|
|
886
|
+
o.current = e;
|
|
855
887
|
try {
|
|
856
|
-
(l =
|
|
888
|
+
(l = s.current) == null || l.call(s, e);
|
|
857
889
|
} catch (u) {
|
|
858
890
|
console.warn(`[AegisSwapWidget] ${a} callback failed`, u);
|
|
859
891
|
}
|
|
860
892
|
}
|
|
861
893
|
});
|
|
862
894
|
}
|
|
863
|
-
function
|
|
864
|
-
|
|
895
|
+
function qr(t, e) {
|
|
896
|
+
ta(t ? (a) => {
|
|
865
897
|
a !== void 0 && t(a);
|
|
866
898
|
} : void 0, e, { initial: e, label: "onPoolChange" });
|
|
867
899
|
}
|
|
868
|
-
function
|
|
869
|
-
return
|
|
900
|
+
function na(t, e) {
|
|
901
|
+
return Dt(t, e, /* @__PURE__ */ new WeakSet());
|
|
870
902
|
}
|
|
871
|
-
function
|
|
903
|
+
function Dt(t, e, n) {
|
|
872
904
|
if (t === e) return !0;
|
|
873
905
|
if (typeof t != typeof e || typeof t != "object" || t === null || e === null || n.has(t)) return !1;
|
|
874
906
|
n.add(t);
|
|
875
907
|
try {
|
|
876
908
|
if (Array.isArray(t))
|
|
877
|
-
return !Array.isArray(e) || t.length !== e.length ? !1 : t.every((
|
|
909
|
+
return !Array.isArray(e) || t.length !== e.length ? !1 : t.every((o, l) => Dt(o, e[l], n));
|
|
878
910
|
if (Array.isArray(e)) return !1;
|
|
879
|
-
const a = t,
|
|
880
|
-
return
|
|
881
|
-
(
|
|
911
|
+
const a = t, r = e, s = Object.keys(a);
|
|
912
|
+
return s.length !== Object.keys(r).length ? !1 : s.every(
|
|
913
|
+
(o) => Object.prototype.hasOwnProperty.call(r, o) && Dt(a[o], r[o], n)
|
|
882
914
|
);
|
|
883
915
|
} finally {
|
|
884
916
|
n.delete(t);
|
|
885
917
|
}
|
|
886
918
|
}
|
|
887
|
-
function
|
|
888
|
-
const e =
|
|
889
|
-
return
|
|
919
|
+
function Ee(t) {
|
|
920
|
+
const e = W(t);
|
|
921
|
+
return na(e.current, t) || (e.current = t), e.current;
|
|
890
922
|
}
|
|
891
|
-
const
|
|
923
|
+
const Gr = {
|
|
892
924
|
status: "idle",
|
|
893
925
|
progress: null,
|
|
894
926
|
label: null,
|
|
@@ -898,768 +930,776 @@ const gr = {
|
|
|
898
930
|
txHash: null,
|
|
899
931
|
error: null
|
|
900
932
|
};
|
|
901
|
-
function
|
|
902
|
-
|
|
903
|
-
initial:
|
|
933
|
+
function zr(t, e) {
|
|
934
|
+
ta(t, e, {
|
|
935
|
+
initial: Gr,
|
|
904
936
|
label: "onStatusChange",
|
|
905
|
-
equals:
|
|
937
|
+
equals: na
|
|
906
938
|
});
|
|
907
939
|
}
|
|
908
|
-
async function
|
|
940
|
+
async function Kr({
|
|
909
941
|
wallet: t,
|
|
910
942
|
publicClient: e,
|
|
911
943
|
activeChain: n,
|
|
912
944
|
permit2: a,
|
|
913
|
-
router:
|
|
914
|
-
token:
|
|
915
|
-
amount:
|
|
945
|
+
router: r,
|
|
946
|
+
token: s,
|
|
947
|
+
amount: o,
|
|
916
948
|
approvalMode: l,
|
|
917
949
|
allowanceRead: u,
|
|
918
950
|
setStatus: c
|
|
919
951
|
}) {
|
|
920
952
|
try {
|
|
921
|
-
return await
|
|
953
|
+
return await ri({
|
|
922
954
|
provider: t.provider,
|
|
923
955
|
publicClient: e,
|
|
924
956
|
account: t.account,
|
|
925
957
|
chainId: n.chainId,
|
|
926
958
|
chain: n.chain,
|
|
927
959
|
permit2: a,
|
|
928
|
-
router:
|
|
929
|
-
token:
|
|
930
|
-
amount:
|
|
960
|
+
router: r,
|
|
961
|
+
token: s,
|
|
962
|
+
amount: o,
|
|
931
963
|
sizing: l,
|
|
932
964
|
allowanceRead: u
|
|
933
965
|
});
|
|
934
|
-
} catch (
|
|
935
|
-
if (
|
|
936
|
-
return c("approving"), await
|
|
966
|
+
} catch (f) {
|
|
967
|
+
if (si(f)) throw f;
|
|
968
|
+
return c("approving"), await oi({
|
|
937
969
|
provider: t.provider,
|
|
938
970
|
publicClient: e,
|
|
939
971
|
account: t.account,
|
|
940
972
|
chain: n.chain,
|
|
941
|
-
token:
|
|
973
|
+
token: s,
|
|
942
974
|
permit2: a,
|
|
943
|
-
router:
|
|
975
|
+
router: r,
|
|
944
976
|
// undefined -> MAX_UINT160, mirroring the 'max' permit sizing above.
|
|
945
|
-
amount: l === "max" ? void 0 :
|
|
946
|
-
expiration: Math.floor(Date.now() / 1e3) +
|
|
977
|
+
amount: l === "max" ? void 0 : o,
|
|
978
|
+
expiration: Math.floor(Date.now() / 1e3) + li
|
|
947
979
|
}), null;
|
|
948
980
|
}
|
|
949
981
|
}
|
|
950
|
-
async function
|
|
982
|
+
async function jr({
|
|
951
983
|
wallet: t,
|
|
952
984
|
publicClient: e,
|
|
953
985
|
activeChain: n,
|
|
954
986
|
market: a,
|
|
955
|
-
inputToken:
|
|
956
|
-
outputToken:
|
|
957
|
-
swapQuote:
|
|
987
|
+
inputToken: r,
|
|
988
|
+
outputToken: s,
|
|
989
|
+
swapQuote: o,
|
|
958
990
|
permit: l,
|
|
959
991
|
setStatus: u,
|
|
960
992
|
setTxHash: c,
|
|
961
|
-
onSubmitted:
|
|
993
|
+
onSubmitted: f
|
|
962
994
|
}) {
|
|
963
|
-
const
|
|
964
|
-
poolKey:
|
|
965
|
-
zeroForOne:
|
|
966
|
-
amountOut:
|
|
967
|
-
amountInMaximum:
|
|
995
|
+
const m = BigInt(Math.floor(Date.now() / 1e3) + Wn), I = ci(o), E = o.mode === "exactOut" ? ui({
|
|
996
|
+
poolKey: o.poolKey,
|
|
997
|
+
zeroForOne: o.zeroForOne,
|
|
998
|
+
amountOut: o.grossAmountOut,
|
|
999
|
+
amountInMaximum: o.amountInMaximum,
|
|
968
1000
|
recipient: t.account,
|
|
969
|
-
deadline:
|
|
1001
|
+
deadline: m,
|
|
970
1002
|
permit: l,
|
|
971
|
-
fee:
|
|
972
|
-
}) :
|
|
973
|
-
poolKey:
|
|
974
|
-
zeroForOne:
|
|
975
|
-
amountIn:
|
|
976
|
-
amountOutMinimum:
|
|
1003
|
+
fee: I
|
|
1004
|
+
}) : di({
|
|
1005
|
+
poolKey: o.poolKey,
|
|
1006
|
+
zeroForOne: o.zeroForOne,
|
|
1007
|
+
amountIn: o.amountIn,
|
|
1008
|
+
amountOutMinimum: o.amountOutMinimum,
|
|
977
1009
|
recipient: t.account,
|
|
978
|
-
deadline:
|
|
1010
|
+
deadline: m,
|
|
979
1011
|
permit: l,
|
|
980
|
-
fee:
|
|
1012
|
+
fee: I
|
|
981
1013
|
});
|
|
982
1014
|
u("submitting");
|
|
983
|
-
const
|
|
1015
|
+
const v = Ri({
|
|
984
1016
|
account: t.account,
|
|
985
1017
|
chain: n.chain,
|
|
986
|
-
transport:
|
|
1018
|
+
transport: Di(t.provider)
|
|
987
1019
|
}), w = await e.estimateGas({
|
|
988
1020
|
account: t.account,
|
|
989
1021
|
to: a.router,
|
|
990
|
-
data:
|
|
991
|
-
value:
|
|
992
|
-
}),
|
|
1022
|
+
data: E.calldata,
|
|
1023
|
+
value: E.value
|
|
1024
|
+
}), b = await v.sendTransaction({
|
|
993
1025
|
to: a.router,
|
|
994
|
-
data:
|
|
995
|
-
value:
|
|
1026
|
+
data: E.calldata,
|
|
1027
|
+
value: E.value,
|
|
996
1028
|
gas: w * 12n / 10n
|
|
997
|
-
}),
|
|
998
|
-
mode:
|
|
999
|
-
inputSymbol:
|
|
1000
|
-
outputSymbol:
|
|
1001
|
-
amountIn:
|
|
1002
|
-
amountOut:
|
|
1003
|
-
feeAmount:
|
|
1004
|
-
feeBps:
|
|
1029
|
+
}), x = {
|
|
1030
|
+
mode: o.mode,
|
|
1031
|
+
inputSymbol: r.symbol,
|
|
1032
|
+
outputSymbol: s.symbol,
|
|
1033
|
+
amountIn: o.amountIn,
|
|
1034
|
+
amountOut: o.amountOut,
|
|
1035
|
+
feeAmount: o.feeAmount,
|
|
1036
|
+
feeBps: o.feeBps
|
|
1005
1037
|
};
|
|
1006
|
-
c(
|
|
1038
|
+
c(b);
|
|
1007
1039
|
try {
|
|
1008
|
-
|
|
1009
|
-
} catch (
|
|
1010
|
-
console.warn("[AegisSwapWidget] onSubmitted callback failed",
|
|
1040
|
+
f == null || f(b, x);
|
|
1041
|
+
} catch (A) {
|
|
1042
|
+
console.warn("[AegisSwapWidget] onSubmitted callback failed", A);
|
|
1011
1043
|
}
|
|
1012
|
-
let
|
|
1013
|
-
const
|
|
1014
|
-
hash:
|
|
1015
|
-
onReplaced: (
|
|
1016
|
-
|
|
1044
|
+
let R = null;
|
|
1045
|
+
const D = await e.waitForTransactionReceipt({
|
|
1046
|
+
hash: b,
|
|
1047
|
+
onReplaced: (A) => {
|
|
1048
|
+
R = A.reason, c(A.transaction.hash);
|
|
1017
1049
|
}
|
|
1018
1050
|
});
|
|
1019
|
-
if (
|
|
1020
|
-
if (
|
|
1021
|
-
|
|
1051
|
+
if (R === "cancelled") throw new Error("Swap was cancelled in the wallet.");
|
|
1052
|
+
if (D.status === "reverted") throw new Error("Swap reverted on-chain.");
|
|
1053
|
+
const B = D.gasUsed ?? 0n, S = D.effectiveGasPrice ?? 0n, h = {
|
|
1054
|
+
transactionHash: D.transactionHash,
|
|
1055
|
+
blockNumber: D.blockNumber ?? 0n,
|
|
1056
|
+
gasUsed: B,
|
|
1057
|
+
effectiveGasPrice: S,
|
|
1058
|
+
feeWei: B * S
|
|
1059
|
+
};
|
|
1060
|
+
return { receipt: D, summary: h, swapDetails: x };
|
|
1022
1061
|
}
|
|
1023
|
-
async function
|
|
1024
|
-
return await
|
|
1025
|
-
() =>
|
|
1062
|
+
async function Xr(t, e) {
|
|
1063
|
+
return await Gn(
|
|
1064
|
+
() => qe(t),
|
|
1026
1065
|
(a) => a === e,
|
|
1027
1066
|
12,
|
|
1028
1067
|
250
|
|
1029
1068
|
) === e;
|
|
1030
1069
|
}
|
|
1031
|
-
function
|
|
1032
|
-
return
|
|
1070
|
+
function Yr(t, e) {
|
|
1071
|
+
return Gn(t, (n) => n >= e, 5, 300);
|
|
1033
1072
|
}
|
|
1034
|
-
function
|
|
1073
|
+
function Qr({
|
|
1035
1074
|
publicClient: t,
|
|
1036
1075
|
activeChain: e,
|
|
1037
1076
|
market: n,
|
|
1038
1077
|
inputToken: a,
|
|
1039
|
-
outputToken:
|
|
1040
|
-
quoteMode:
|
|
1041
|
-
activeAmount:
|
|
1078
|
+
outputToken: r,
|
|
1079
|
+
quoteMode: s,
|
|
1080
|
+
activeAmount: o,
|
|
1042
1081
|
slippageBps: l,
|
|
1043
1082
|
feeConfig: u,
|
|
1044
1083
|
quote: c,
|
|
1045
|
-
setQuote:
|
|
1046
|
-
owner:
|
|
1047
|
-
getActiveProvider:
|
|
1048
|
-
connectWallet:
|
|
1049
|
-
setWalletChainId:
|
|
1084
|
+
setQuote: f,
|
|
1085
|
+
owner: m,
|
|
1086
|
+
getActiveProvider: I,
|
|
1087
|
+
connectWallet: E,
|
|
1088
|
+
setWalletChainId: v,
|
|
1050
1089
|
readAllowance: w,
|
|
1051
|
-
commitAllowance:
|
|
1052
|
-
approvalMode:
|
|
1053
|
-
refreshBalances:
|
|
1054
|
-
refreshAllowances:
|
|
1055
|
-
onSubmitted:
|
|
1056
|
-
onSuccess:
|
|
1057
|
-
onError:
|
|
1090
|
+
commitAllowance: b,
|
|
1091
|
+
approvalMode: x,
|
|
1092
|
+
refreshBalances: R,
|
|
1093
|
+
refreshAllowances: D,
|
|
1094
|
+
onSubmitted: B,
|
|
1095
|
+
onSuccess: S,
|
|
1096
|
+
onError: h
|
|
1058
1097
|
}) {
|
|
1059
|
-
const [
|
|
1098
|
+
const [A, y] = P("idle"), [M, V] = P(null), [z, N] = P(null), [te, K] = P({
|
|
1060
1099
|
required: !1,
|
|
1061
1100
|
done: !1
|
|
1062
|
-
}), d =
|
|
1063
|
-
|
|
1064
|
-
}, []),
|
|
1065
|
-
let
|
|
1066
|
-
if (!
|
|
1067
|
-
const
|
|
1068
|
-
|
|
1101
|
+
}), [d, _] = P(null), q = O(() => {
|
|
1102
|
+
y("idle"), V(null), N(null), K({ required: !1, done: !1 }), _(null);
|
|
1103
|
+
}, []), k = O(async () => {
|
|
1104
|
+
let g = await I(), T = m;
|
|
1105
|
+
if (!g || !T) {
|
|
1106
|
+
const $ = await E();
|
|
1107
|
+
g = ($ == null ? void 0 : $.provider) ?? g, T = T ?? ($ == null ? void 0 : $.account) ?? null;
|
|
1069
1108
|
}
|
|
1070
|
-
if (!
|
|
1071
|
-
return
|
|
1072
|
-
if (!
|
|
1073
|
-
return
|
|
1074
|
-
const
|
|
1075
|
-
if (
|
|
1076
|
-
await
|
|
1077
|
-
const
|
|
1078
|
-
if (
|
|
1079
|
-
return
|
|
1109
|
+
if (!g)
|
|
1110
|
+
return N("No wallet provider found."), null;
|
|
1111
|
+
if (!T)
|
|
1112
|
+
return N("Wallet connection was not completed."), null;
|
|
1113
|
+
const H = await qe(g);
|
|
1114
|
+
if (v(H), H !== e.chainId) {
|
|
1115
|
+
await pi(g, e);
|
|
1116
|
+
const $ = await Xr(g, e.chainId);
|
|
1117
|
+
if (v($ ? e.chainId : await qe(g)), !$)
|
|
1118
|
+
return N("Network switch did not complete. Switch to the correct network and try again."), null;
|
|
1080
1119
|
}
|
|
1081
|
-
return { provider:
|
|
1082
|
-
}, [e,
|
|
1083
|
-
async (
|
|
1084
|
-
if (!n || l === null || !
|
|
1085
|
-
|
|
1120
|
+
return { provider: g, account: T };
|
|
1121
|
+
}, [e, E, I, m, v]), ne = O(
|
|
1122
|
+
async (g, T) => {
|
|
1123
|
+
if (!n || l === null || !o || o <= 0n) {
|
|
1124
|
+
N("Enter a valid amount and slippage, then try again."), y("idle");
|
|
1086
1125
|
return;
|
|
1087
1126
|
}
|
|
1088
|
-
const
|
|
1127
|
+
const H = T !== void 0 ? Promise.resolve(T) : w(g.account, n).catch(() => null), $ = Hn({
|
|
1089
1128
|
publicClient: t,
|
|
1090
1129
|
permit2: n.permit2,
|
|
1091
|
-
account:
|
|
1130
|
+
account: g.account,
|
|
1092
1131
|
token: a.address,
|
|
1093
1132
|
router: n.router
|
|
1094
1133
|
});
|
|
1095
|
-
|
|
1134
|
+
$.catch(() => {
|
|
1096
1135
|
});
|
|
1097
|
-
let
|
|
1136
|
+
let Y;
|
|
1098
1137
|
try {
|
|
1099
|
-
const
|
|
1138
|
+
const F = await Vn({
|
|
1100
1139
|
publicClient: t,
|
|
1101
|
-
account:
|
|
1140
|
+
account: g.account,
|
|
1102
1141
|
market: n,
|
|
1103
1142
|
tokenIn: a,
|
|
1104
|
-
tokenOut:
|
|
1105
|
-
mode:
|
|
1106
|
-
amount:
|
|
1143
|
+
tokenOut: r,
|
|
1144
|
+
mode: s,
|
|
1145
|
+
amount: o,
|
|
1107
1146
|
slippageBps: l,
|
|
1108
1147
|
fee: u
|
|
1109
|
-
}),
|
|
1110
|
-
if (
|
|
1111
|
-
|
|
1148
|
+
}), Ce = fi(c, F);
|
|
1149
|
+
if (Ce.priceMovedBeyondTolerance) {
|
|
1150
|
+
f(F), N(
|
|
1112
1151
|
"Price moved beyond your slippage tolerance. Review the updated quote and try again."
|
|
1113
|
-
),
|
|
1152
|
+
), y("idle");
|
|
1114
1153
|
return;
|
|
1115
1154
|
}
|
|
1116
|
-
|
|
1117
|
-
} catch (
|
|
1118
|
-
|
|
1155
|
+
Y = Ce.quote;
|
|
1156
|
+
} catch (F) {
|
|
1157
|
+
N(Ne(F, "Quote unavailable. Try again.")), y("idle");
|
|
1119
1158
|
return;
|
|
1120
1159
|
}
|
|
1121
|
-
|
|
1122
|
-
const
|
|
1123
|
-
if (
|
|
1124
|
-
|
|
1160
|
+
f(Y);
|
|
1161
|
+
const pe = Nt(Y);
|
|
1162
|
+
if (pe <= 0n) {
|
|
1163
|
+
N("Quote returned an empty amount. Try again."), y("idle");
|
|
1125
1164
|
return;
|
|
1126
1165
|
}
|
|
1127
|
-
const
|
|
1128
|
-
if (
|
|
1129
|
-
|
|
1166
|
+
const ue = await H ?? await w(g.account, n);
|
|
1167
|
+
if (b(g.account, n, ue), ue < pe) {
|
|
1168
|
+
K({ required: !0, done: !1 }), N(`Approve ${a.symbol} before swapping.`), y("idle");
|
|
1130
1169
|
return;
|
|
1131
1170
|
}
|
|
1132
|
-
|
|
1133
|
-
const
|
|
1134
|
-
wallet:
|
|
1171
|
+
y("signing");
|
|
1172
|
+
const Ke = await Kr({
|
|
1173
|
+
wallet: g,
|
|
1135
1174
|
publicClient: t,
|
|
1136
1175
|
activeChain: e,
|
|
1137
1176
|
permit2: n.permit2,
|
|
1138
1177
|
router: n.router,
|
|
1139
1178
|
token: a.address,
|
|
1140
|
-
amount:
|
|
1141
|
-
approvalMode:
|
|
1142
|
-
allowanceRead:
|
|
1143
|
-
setStatus:
|
|
1144
|
-
}), { receipt:
|
|
1145
|
-
wallet:
|
|
1179
|
+
amount: pe,
|
|
1180
|
+
approvalMode: x,
|
|
1181
|
+
allowanceRead: $,
|
|
1182
|
+
setStatus: y
|
|
1183
|
+
}), { receipt: je, summary: ft, swapDetails: Te } = await jr({
|
|
1184
|
+
wallet: g,
|
|
1146
1185
|
publicClient: t,
|
|
1147
1186
|
activeChain: e,
|
|
1148
1187
|
market: n,
|
|
1149
1188
|
inputToken: a,
|
|
1150
|
-
outputToken:
|
|
1151
|
-
swapQuote:
|
|
1152
|
-
permit:
|
|
1153
|
-
setStatus:
|
|
1154
|
-
setTxHash:
|
|
1155
|
-
onSubmitted:
|
|
1189
|
+
outputToken: r,
|
|
1190
|
+
swapQuote: Y,
|
|
1191
|
+
permit: Ke,
|
|
1192
|
+
setStatus: y,
|
|
1193
|
+
setTxHash: V,
|
|
1194
|
+
onSubmitted: B
|
|
1156
1195
|
});
|
|
1157
|
-
|
|
1196
|
+
_(ft), y("success");
|
|
1158
1197
|
try {
|
|
1159
|
-
|
|
1160
|
-
hash:
|
|
1161
|
-
explorerUrl:
|
|
1162
|
-
swap:
|
|
1198
|
+
S == null || S({
|
|
1199
|
+
hash: je.transactionHash,
|
|
1200
|
+
explorerUrl: qn(je.transactionHash, e),
|
|
1201
|
+
swap: Te
|
|
1163
1202
|
}), await Promise.all([
|
|
1164
|
-
|
|
1165
|
-
|
|
1203
|
+
R(g.account),
|
|
1204
|
+
D(g.account, n)
|
|
1166
1205
|
]);
|
|
1167
|
-
} catch (
|
|
1168
|
-
console.warn("[AegisSwapWidget] Post-success refresh failed",
|
|
1206
|
+
} catch (F) {
|
|
1207
|
+
console.warn("[AegisSwapWidget] Post-success refresh failed", F);
|
|
1169
1208
|
}
|
|
1170
1209
|
},
|
|
1171
1210
|
[
|
|
1172
|
-
|
|
1211
|
+
o,
|
|
1173
1212
|
e,
|
|
1174
|
-
|
|
1175
|
-
|
|
1213
|
+
x,
|
|
1214
|
+
b,
|
|
1176
1215
|
u,
|
|
1177
1216
|
a,
|
|
1178
1217
|
n,
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1218
|
+
B,
|
|
1219
|
+
S,
|
|
1220
|
+
r,
|
|
1182
1221
|
t,
|
|
1183
1222
|
c,
|
|
1184
|
-
|
|
1223
|
+
s,
|
|
1185
1224
|
w,
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1225
|
+
D,
|
|
1226
|
+
R,
|
|
1227
|
+
f,
|
|
1189
1228
|
l
|
|
1190
1229
|
]
|
|
1191
|
-
),
|
|
1192
|
-
|
|
1230
|
+
), re = O(async () => {
|
|
1231
|
+
N(null), V(null), _(null);
|
|
1193
1232
|
try {
|
|
1194
|
-
const
|
|
1195
|
-
if (!
|
|
1196
|
-
await
|
|
1197
|
-
} catch (
|
|
1198
|
-
if (
|
|
1199
|
-
|
|
1233
|
+
const g = await k();
|
|
1234
|
+
if (!g) return;
|
|
1235
|
+
await ne(g);
|
|
1236
|
+
} catch (g) {
|
|
1237
|
+
if (g instanceof vn) {
|
|
1238
|
+
N("Transaction is still pending. Check its status via the transaction link."), y("idle");
|
|
1200
1239
|
return;
|
|
1201
1240
|
}
|
|
1202
|
-
const
|
|
1203
|
-
|
|
1241
|
+
const T = Ne(g, "Swap failed."), H = g instanceof Error ? g : new Error(T);
|
|
1242
|
+
N(T), y("idle"), h == null || h(H);
|
|
1204
1243
|
}
|
|
1205
|
-
}, [
|
|
1206
|
-
|
|
1207
|
-
let
|
|
1244
|
+
}, [k, h, ne]), L = O(async () => {
|
|
1245
|
+
N(null), V(null), _(null), K({ required: !0, done: !1 });
|
|
1246
|
+
let g = !1;
|
|
1208
1247
|
try {
|
|
1209
|
-
const
|
|
1210
|
-
if (!
|
|
1211
|
-
if (!n || !c ||
|
|
1212
|
-
|
|
1248
|
+
const T = await k();
|
|
1249
|
+
if (!T) return;
|
|
1250
|
+
if (!n || !c || o === null || o <= 0n) {
|
|
1251
|
+
N("Enter a valid amount before approving.");
|
|
1213
1252
|
return;
|
|
1214
1253
|
}
|
|
1215
|
-
const
|
|
1216
|
-
if (
|
|
1217
|
-
|
|
1254
|
+
const H = Nt(c);
|
|
1255
|
+
if (H <= 0n) {
|
|
1256
|
+
N("Enter a valid amount before approving.");
|
|
1218
1257
|
return;
|
|
1219
1258
|
}
|
|
1220
|
-
let
|
|
1221
|
-
if (
|
|
1222
|
-
provider:
|
|
1259
|
+
let $ = await w(T.account, n);
|
|
1260
|
+
if (b(T.account, n, $), $ < H && (y("approving"), await hi({
|
|
1261
|
+
provider: T.provider,
|
|
1223
1262
|
publicClient: t,
|
|
1224
|
-
account:
|
|
1263
|
+
account: T.account,
|
|
1225
1264
|
chain: e.chain,
|
|
1226
1265
|
token: a.address,
|
|
1227
1266
|
permit2: n.permit2,
|
|
1228
|
-
amount:
|
|
1229
|
-
}),
|
|
1230
|
-
() => w(
|
|
1231
|
-
|
|
1232
|
-
),
|
|
1233
|
-
|
|
1267
|
+
amount: x === "exact" ? H : void 0
|
|
1268
|
+
}), $ = await Yr(
|
|
1269
|
+
() => w(T.account, n),
|
|
1270
|
+
H
|
|
1271
|
+
), b(T.account, n, $), $ < H)) {
|
|
1272
|
+
N("Approval confirmed, but allowance is still below this quote. Try again."), y("idle");
|
|
1234
1273
|
return;
|
|
1235
1274
|
}
|
|
1236
|
-
|
|
1237
|
-
} catch (
|
|
1238
|
-
if (
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
),
|
|
1275
|
+
K({ required: !0, done: !0 }), g = !0, await ne(T, $);
|
|
1276
|
+
} catch (T) {
|
|
1277
|
+
if (T instanceof vn) {
|
|
1278
|
+
N(
|
|
1279
|
+
g ? "Transaction is still pending. Check its status via the transaction link." : "Approval is still pending. Wait for it to confirm, then try again."
|
|
1280
|
+
), y("idle");
|
|
1242
1281
|
return;
|
|
1243
1282
|
}
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1283
|
+
const H = Ne(T, g ? "Swap failed." : "Approval failed."), $ = T instanceof Error ? T : new Error(H);
|
|
1284
|
+
N(H), y("idle"), h == null || h($);
|
|
1246
1285
|
}
|
|
1247
1286
|
}, [
|
|
1248
|
-
|
|
1287
|
+
o,
|
|
1249
1288
|
e.chain,
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1289
|
+
x,
|
|
1290
|
+
b,
|
|
1291
|
+
k,
|
|
1253
1292
|
a.address,
|
|
1254
1293
|
n,
|
|
1255
|
-
|
|
1256
|
-
|
|
1294
|
+
h,
|
|
1295
|
+
ne,
|
|
1257
1296
|
t,
|
|
1258
1297
|
c,
|
|
1259
1298
|
w
|
|
1260
1299
|
]);
|
|
1261
1300
|
return {
|
|
1262
|
-
submit:
|
|
1263
|
-
approveInputToken:
|
|
1264
|
-
reset:
|
|
1265
|
-
status:
|
|
1266
|
-
busy:
|
|
1267
|
-
txHash:
|
|
1268
|
-
actionError:
|
|
1269
|
-
approvalProgress:
|
|
1301
|
+
submit: re,
|
|
1302
|
+
approveInputToken: L,
|
|
1303
|
+
reset: q,
|
|
1304
|
+
status: A,
|
|
1305
|
+
busy: $n(A),
|
|
1306
|
+
txHash: M,
|
|
1307
|
+
actionError: z,
|
|
1308
|
+
approvalProgress: te,
|
|
1309
|
+
receiptSummary: d
|
|
1270
1310
|
};
|
|
1271
1311
|
}
|
|
1272
|
-
const
|
|
1273
|
-
function
|
|
1312
|
+
const Zr = 250, Jr = 5e3;
|
|
1313
|
+
function es({
|
|
1274
1314
|
owner: t,
|
|
1275
1315
|
market: e,
|
|
1276
1316
|
inputToken: n,
|
|
1277
1317
|
outputToken: a,
|
|
1278
|
-
quoteMode:
|
|
1279
|
-
activeAmount:
|
|
1280
|
-
slippageBps:
|
|
1318
|
+
quoteMode: r,
|
|
1319
|
+
activeAmount: s,
|
|
1320
|
+
slippageBps: o,
|
|
1281
1321
|
feeConfig: l
|
|
1282
1322
|
}) {
|
|
1283
1323
|
return [
|
|
1284
|
-
|
|
1324
|
+
xe(t),
|
|
1285
1325
|
(e == null ? void 0 : e.chainId) ?? "",
|
|
1286
1326
|
(e == null ? void 0 : e.poolId.toLowerCase()) ?? "",
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
(
|
|
1291
|
-
|
|
1327
|
+
xe(n.address),
|
|
1328
|
+
xe(a.address),
|
|
1329
|
+
r,
|
|
1330
|
+
(s == null ? void 0 : s.toString()) ?? "",
|
|
1331
|
+
o ?? "",
|
|
1292
1332
|
(l == null ? void 0 : l.bps) ?? "",
|
|
1293
|
-
|
|
1333
|
+
xe(l == null ? void 0 : l.recipient)
|
|
1294
1334
|
].join("|");
|
|
1295
1335
|
}
|
|
1296
|
-
function
|
|
1336
|
+
function ts({
|
|
1297
1337
|
publicClient: t,
|
|
1298
1338
|
owner: e,
|
|
1299
1339
|
market: n,
|
|
1300
1340
|
inputToken: a,
|
|
1301
|
-
outputToken:
|
|
1302
|
-
quoteMode:
|
|
1303
|
-
activeAmount:
|
|
1341
|
+
outputToken: r,
|
|
1342
|
+
quoteMode: s,
|
|
1343
|
+
activeAmount: o,
|
|
1304
1344
|
slippageBps: l,
|
|
1305
1345
|
feeConfig: u,
|
|
1306
1346
|
onQuote: c,
|
|
1307
|
-
pausedRef:
|
|
1347
|
+
pausedRef: f
|
|
1308
1348
|
}) {
|
|
1309
|
-
const [
|
|
1310
|
-
() =>
|
|
1349
|
+
const [m, I] = P(null), [E, v] = P(!1), [w, b] = P(null), x = J(
|
|
1350
|
+
() => es({
|
|
1311
1351
|
owner: e,
|
|
1312
1352
|
market: n,
|
|
1313
1353
|
inputToken: a,
|
|
1314
|
-
outputToken:
|
|
1315
|
-
quoteMode:
|
|
1316
|
-
activeAmount:
|
|
1354
|
+
outputToken: r,
|
|
1355
|
+
quoteMode: s,
|
|
1356
|
+
activeAmount: o,
|
|
1317
1357
|
slippageBps: l,
|
|
1318
1358
|
feeConfig: u
|
|
1319
1359
|
}),
|
|
1320
|
-
[
|
|
1321
|
-
),
|
|
1322
|
-
(
|
|
1323
|
-
|
|
1360
|
+
[o, u, a, n, r, e, s, l]
|
|
1361
|
+
), R = (m == null ? void 0 : m.key) === x ? m.quote : null, D = O(
|
|
1362
|
+
(h) => {
|
|
1363
|
+
I(h ? { key: x, quote: h } : null);
|
|
1324
1364
|
},
|
|
1325
|
-
[
|
|
1326
|
-
),
|
|
1327
|
-
|
|
1328
|
-
const
|
|
1329
|
-
|
|
1365
|
+
[x]
|
|
1366
|
+
), B = W(c);
|
|
1367
|
+
B.current = c;
|
|
1368
|
+
const S = O(() => {
|
|
1369
|
+
I(null), b(null);
|
|
1330
1370
|
}, []);
|
|
1331
|
-
return
|
|
1332
|
-
const
|
|
1333
|
-
let
|
|
1334
|
-
|
|
1335
|
-
const
|
|
1336
|
-
if (!
|
|
1337
|
-
return
|
|
1338
|
-
const
|
|
1339
|
-
async function
|
|
1340
|
-
var
|
|
1341
|
-
if (!(
|
|
1342
|
-
|
|
1371
|
+
return U(() => {
|
|
1372
|
+
const h = new AbortController();
|
|
1373
|
+
let A = !1, y = !1, M;
|
|
1374
|
+
I(null), b(null);
|
|
1375
|
+
const V = e, z = n, N = o, te = l;
|
|
1376
|
+
if (!V || !z || !N || N <= 0n || te === null)
|
|
1377
|
+
return v(!1), () => h.abort();
|
|
1378
|
+
const K = V, d = z, _ = N, q = te;
|
|
1379
|
+
async function k(L) {
|
|
1380
|
+
var g;
|
|
1381
|
+
if (!(y || h.signal.aborted)) {
|
|
1382
|
+
y = !0, L && v(!0);
|
|
1343
1383
|
try {
|
|
1344
|
-
const
|
|
1384
|
+
const T = await Vn({
|
|
1345
1385
|
publicClient: t,
|
|
1346
|
-
account:
|
|
1386
|
+
account: K,
|
|
1347
1387
|
market: d,
|
|
1348
1388
|
tokenIn: a,
|
|
1349
|
-
tokenOut:
|
|
1350
|
-
mode:
|
|
1351
|
-
amount:
|
|
1352
|
-
slippageBps:
|
|
1389
|
+
tokenOut: r,
|
|
1390
|
+
mode: s,
|
|
1391
|
+
amount: _,
|
|
1392
|
+
slippageBps: q,
|
|
1353
1393
|
fee: u,
|
|
1354
|
-
signal:
|
|
1394
|
+
signal: h.signal
|
|
1355
1395
|
});
|
|
1356
|
-
if (
|
|
1357
|
-
|
|
1358
|
-
(
|
|
1359
|
-
),
|
|
1360
|
-
} catch (
|
|
1361
|
-
if (
|
|
1362
|
-
|
|
1396
|
+
if (A || h.signal.aborted) return;
|
|
1397
|
+
I(
|
|
1398
|
+
(H) => H && H.key === x && gi(H.quote, T) ? H : { key: x, quote: T }
|
|
1399
|
+
), b(null), (g = B.current) == null || g.call(B, T);
|
|
1400
|
+
} catch (T) {
|
|
1401
|
+
if (A || h.signal.aborted) return;
|
|
1402
|
+
b(Ne(T, "Quote unavailable."));
|
|
1363
1403
|
} finally {
|
|
1364
|
-
|
|
1404
|
+
y = !1, !A && !h.signal.aborted && v(!1);
|
|
1365
1405
|
}
|
|
1366
1406
|
}
|
|
1367
1407
|
}
|
|
1368
|
-
const
|
|
1369
|
-
|
|
1370
|
-
!(
|
|
1371
|
-
},
|
|
1372
|
-
},
|
|
1373
|
-
!(
|
|
1408
|
+
const ne = window.setTimeout(() => {
|
|
1409
|
+
k(!0), M = window.setInterval(() => {
|
|
1410
|
+
!(f != null && f.current) && Ve() && k(!1);
|
|
1411
|
+
}, Jr);
|
|
1412
|
+
}, Zr), re = () => {
|
|
1413
|
+
!(f != null && f.current) && Ve() && k(!1);
|
|
1374
1414
|
};
|
|
1375
|
-
return document.addEventListener("visibilitychange",
|
|
1376
|
-
|
|
1415
|
+
return document.addEventListener("visibilitychange", re), () => {
|
|
1416
|
+
A = !0, window.clearTimeout(ne), M !== void 0 && window.clearInterval(M), document.removeEventListener("visibilitychange", re), h.abort();
|
|
1377
1417
|
};
|
|
1378
1418
|
}, [
|
|
1379
|
-
|
|
1419
|
+
o,
|
|
1380
1420
|
u,
|
|
1381
1421
|
a,
|
|
1382
1422
|
n,
|
|
1383
|
-
|
|
1423
|
+
r,
|
|
1384
1424
|
e,
|
|
1385
1425
|
t,
|
|
1386
|
-
|
|
1387
|
-
|
|
1426
|
+
s,
|
|
1427
|
+
x,
|
|
1388
1428
|
l
|
|
1389
|
-
]), { quote:
|
|
1429
|
+
]), { quote: R, quoteLoading: E, quoteError: w, setQuote: D, clearQuote: S };
|
|
1390
1430
|
}
|
|
1391
|
-
function
|
|
1392
|
-
return !t || !e || !
|
|
1431
|
+
function Mn(t, e, n, a) {
|
|
1432
|
+
return !t || !e || !It(t.owner, e) || !It(t.token, n) || !It(t.spender, a) ? null : t;
|
|
1393
1433
|
}
|
|
1394
|
-
function
|
|
1434
|
+
function Rn(t, e) {
|
|
1395
1435
|
if (!t || e === void 0 || e <= 0n) return !1;
|
|
1396
1436
|
const n = Math.floor(Date.now() / 1e3);
|
|
1397
|
-
return t.amount >= e && t.expiration > n +
|
|
1437
|
+
return t.amount >= e && t.expiration > n + Wn;
|
|
1398
1438
|
}
|
|
1399
|
-
function
|
|
1439
|
+
function ns({
|
|
1400
1440
|
publicClient: t,
|
|
1401
1441
|
owner: e,
|
|
1402
1442
|
market: n,
|
|
1403
1443
|
inputToken: a,
|
|
1404
|
-
spendAmount:
|
|
1444
|
+
spendAmount: r
|
|
1405
1445
|
}) {
|
|
1406
|
-
var
|
|
1407
|
-
const [
|
|
1408
|
-
async (d,
|
|
1446
|
+
var K;
|
|
1447
|
+
const [s, o] = P(null), [l, u] = P(null), [c, f] = P(!1), [m, I] = P(!1), [E, v] = P(null), [w, b] = P(null), x = O(
|
|
1448
|
+
async (d, _) => t.readContract({
|
|
1409
1449
|
address: a.address,
|
|
1410
|
-
abi:
|
|
1450
|
+
abi: zn,
|
|
1411
1451
|
functionName: "allowance",
|
|
1412
|
-
args: [d,
|
|
1452
|
+
args: [d, _.permit2]
|
|
1413
1453
|
}),
|
|
1414
1454
|
[a.address, t]
|
|
1415
|
-
),
|
|
1416
|
-
(d,
|
|
1417
|
-
|
|
1455
|
+
), R = O(
|
|
1456
|
+
(d, _, q) => {
|
|
1457
|
+
o({
|
|
1418
1458
|
owner: d,
|
|
1419
1459
|
token: a.address,
|
|
1420
|
-
spender:
|
|
1421
|
-
amount:
|
|
1422
|
-
}),
|
|
1460
|
+
spender: _.permit2,
|
|
1461
|
+
amount: q
|
|
1462
|
+
}), v(null);
|
|
1423
1463
|
},
|
|
1424
1464
|
[a.address]
|
|
1425
|
-
),
|
|
1426
|
-
async (d,
|
|
1427
|
-
const [
|
|
1465
|
+
), D = O(
|
|
1466
|
+
async (d, _) => {
|
|
1467
|
+
const [q, k] = await Hn({
|
|
1428
1468
|
publicClient: t,
|
|
1429
|
-
permit2:
|
|
1469
|
+
permit2: _.permit2,
|
|
1430
1470
|
account: d,
|
|
1431
1471
|
token: a.address,
|
|
1432
|
-
router:
|
|
1472
|
+
router: _.router
|
|
1433
1473
|
});
|
|
1434
1474
|
return {
|
|
1435
1475
|
owner: d,
|
|
1436
1476
|
token: a.address,
|
|
1437
|
-
spender:
|
|
1438
|
-
amount:
|
|
1439
|
-
expiration: Number(
|
|
1477
|
+
spender: _.router,
|
|
1478
|
+
amount: q,
|
|
1479
|
+
expiration: Number(k)
|
|
1440
1480
|
};
|
|
1441
1481
|
},
|
|
1442
1482
|
[a.address, t]
|
|
1443
|
-
),
|
|
1444
|
-
async (d,
|
|
1445
|
-
const [
|
|
1446
|
-
|
|
1447
|
-
|
|
1483
|
+
), B = O(
|
|
1484
|
+
async (d, _) => {
|
|
1485
|
+
const [q, k] = await Promise.allSettled([
|
|
1486
|
+
x(d, _),
|
|
1487
|
+
D(d, _)
|
|
1448
1488
|
]);
|
|
1449
|
-
d !== e ||
|
|
1489
|
+
d !== e || _.id !== (n == null ? void 0 : n.id) || (q.status === "fulfilled" && R(d, _, q.value), k.status === "fulfilled" && (u(k.value), b(null)));
|
|
1450
1490
|
},
|
|
1451
|
-
[
|
|
1452
|
-
),
|
|
1453
|
-
|
|
1491
|
+
[R, x, D, e, n]
|
|
1492
|
+
), S = r !== void 0 && r > 0n ? r : null, h = S !== null;
|
|
1493
|
+
U(() => {
|
|
1454
1494
|
let d = !1;
|
|
1455
|
-
return
|
|
1495
|
+
return v(null), !e || !n || !h ? (o(null), f(!1), () => {
|
|
1456
1496
|
d = !0;
|
|
1457
|
-
}) : (
|
|
1458
|
-
d ||
|
|
1459
|
-
}).catch((
|
|
1460
|
-
d || (
|
|
1497
|
+
}) : (f(!0), mn(() => x(e, n), 3, 300, () => d).then((_) => {
|
|
1498
|
+
d || R(e, n, _);
|
|
1499
|
+
}).catch((_) => {
|
|
1500
|
+
d || (o(null), v(Ne(_, "Approval check unavailable.")));
|
|
1461
1501
|
}).finally(() => {
|
|
1462
|
-
d ||
|
|
1502
|
+
d || f(!1);
|
|
1463
1503
|
}), () => {
|
|
1464
1504
|
d = !0;
|
|
1465
1505
|
});
|
|
1466
|
-
}, [
|
|
1506
|
+
}, [R, h, n, e, x]), U(() => {
|
|
1467
1507
|
let d = !1;
|
|
1468
|
-
return
|
|
1508
|
+
return b(null), !e || !n || !h ? (u(null), I(!1), () => {
|
|
1469
1509
|
d = !0;
|
|
1470
|
-
}) : (
|
|
1471
|
-
d || u(
|
|
1472
|
-
}).catch((
|
|
1473
|
-
d || (u(null),
|
|
1474
|
-
|
|
1510
|
+
}) : (I(!0), mn(() => D(e, n), 3, 300, () => d).then((_) => {
|
|
1511
|
+
d || u(_);
|
|
1512
|
+
}).catch((_) => {
|
|
1513
|
+
d || (u(null), b(
|
|
1514
|
+
Ne(_, "Authorization check unavailable.")
|
|
1475
1515
|
));
|
|
1476
1516
|
}).finally(() => {
|
|
1477
|
-
d ||
|
|
1517
|
+
d || I(!1);
|
|
1478
1518
|
}), () => {
|
|
1479
1519
|
d = !0;
|
|
1480
1520
|
});
|
|
1481
|
-
}, [
|
|
1482
|
-
const
|
|
1521
|
+
}, [h, n, e, D]);
|
|
1522
|
+
const A = n ? ((K = Mn(s, e, a.address, n.permit2)) == null ? void 0 : K.amount) ?? null : null, y = n ? Mn(l, e, a.address, n.router) : null, M = !!(e && n && h && !E && (c || A === null)), V = !!(e && n && S !== null && A !== null && A < S), z = !!(e && n && h && !V && !w && (m || y === null)), N = !!(e && n && h && !V && (w || y !== null && !Rn(y, r))), te = !!(e && n && h && !Rn(y, r));
|
|
1483
1523
|
return {
|
|
1484
|
-
allowanceAmount:
|
|
1485
|
-
allowanceError:
|
|
1486
|
-
approvalCheckPending:
|
|
1487
|
-
approvalRequired:
|
|
1488
|
-
authorizationCheckPending:
|
|
1489
|
-
authorizationRequired:
|
|
1490
|
-
authorizationPromptExpected:
|
|
1491
|
-
readAllowance:
|
|
1492
|
-
commitAllowance:
|
|
1493
|
-
refreshAllowances:
|
|
1524
|
+
allowanceAmount: A,
|
|
1525
|
+
allowanceError: E,
|
|
1526
|
+
approvalCheckPending: M,
|
|
1527
|
+
approvalRequired: V,
|
|
1528
|
+
authorizationCheckPending: z,
|
|
1529
|
+
authorizationRequired: N,
|
|
1530
|
+
authorizationPromptExpected: te,
|
|
1531
|
+
readAllowance: x,
|
|
1532
|
+
commitAllowance: R,
|
|
1533
|
+
refreshAllowances: B
|
|
1494
1534
|
};
|
|
1495
1535
|
}
|
|
1496
|
-
const
|
|
1497
|
-
function
|
|
1498
|
-
return [t ?? "",
|
|
1536
|
+
const as = 5e3, is = { input: null, output: null };
|
|
1537
|
+
function st(t, e, n) {
|
|
1538
|
+
return [t ?? "", xe(e), xe(n.address)].join("|");
|
|
1499
1539
|
}
|
|
1500
|
-
function
|
|
1501
|
-
return t[e] === n && t[a] ===
|
|
1540
|
+
function rs(t, e, n, a, r) {
|
|
1541
|
+
return t[e] === n && t[a] === r ? t : { ...t, [e]: n, [a]: r };
|
|
1502
1542
|
}
|
|
1503
|
-
function
|
|
1543
|
+
function Dn(t, e, n) {
|
|
1504
1544
|
return t.readContract({
|
|
1505
1545
|
address: e.address,
|
|
1506
|
-
abi:
|
|
1546
|
+
abi: zn,
|
|
1507
1547
|
functionName: "balanceOf",
|
|
1508
1548
|
args: [n]
|
|
1509
1549
|
});
|
|
1510
1550
|
}
|
|
1511
|
-
function
|
|
1551
|
+
function ss({
|
|
1512
1552
|
publicClient: t,
|
|
1513
1553
|
owner: e,
|
|
1514
1554
|
inputToken: n,
|
|
1515
1555
|
outputToken: a
|
|
1516
1556
|
}) {
|
|
1517
|
-
var
|
|
1518
|
-
const [
|
|
1557
|
+
var m;
|
|
1558
|
+
const [r, s] = P({}), o = W(0), l = (m = t.chain) == null ? void 0 : m.id, u = J(
|
|
1519
1559
|
() => e ? {
|
|
1520
|
-
input:
|
|
1521
|
-
output:
|
|
1522
|
-
} :
|
|
1523
|
-
[
|
|
1524
|
-
), c =
|
|
1525
|
-
async (
|
|
1526
|
-
const
|
|
1560
|
+
input: r[st(l, e, n)] ?? null,
|
|
1561
|
+
output: r[st(l, e, a)] ?? null
|
|
1562
|
+
} : is,
|
|
1563
|
+
[r, l, n, a, e]
|
|
1564
|
+
), c = O(
|
|
1565
|
+
async (I, E) => {
|
|
1566
|
+
const v = ++o.current, w = st(l, I, n), b = st(l, I, a);
|
|
1527
1567
|
try {
|
|
1528
|
-
const [
|
|
1529
|
-
|
|
1530
|
-
|
|
1568
|
+
const [x, R] = await Promise.all([
|
|
1569
|
+
Dn(t, n, I),
|
|
1570
|
+
Dn(t, a, I)
|
|
1531
1571
|
]);
|
|
1532
|
-
|
|
1572
|
+
v === o.current && !(E != null && E()) && s((D) => rs(D, w, x, b, R));
|
|
1533
1573
|
} catch {
|
|
1534
1574
|
}
|
|
1535
1575
|
},
|
|
1536
1576
|
[l, n, a, t]
|
|
1537
|
-
),
|
|
1538
|
-
(
|
|
1577
|
+
), f = O(
|
|
1578
|
+
(I) => c(I),
|
|
1539
1579
|
[c]
|
|
1540
1580
|
);
|
|
1541
|
-
return
|
|
1542
|
-
let
|
|
1581
|
+
return U(() => {
|
|
1582
|
+
let I = !1;
|
|
1543
1583
|
if (!e)
|
|
1544
|
-
return
|
|
1545
|
-
|
|
1584
|
+
return o.current += 1, s({}), () => {
|
|
1585
|
+
I = !0;
|
|
1546
1586
|
};
|
|
1547
|
-
const
|
|
1548
|
-
let
|
|
1587
|
+
const E = e;
|
|
1588
|
+
let v = !1;
|
|
1549
1589
|
async function w() {
|
|
1550
|
-
if (!
|
|
1551
|
-
|
|
1590
|
+
if (!v) {
|
|
1591
|
+
v = !0;
|
|
1552
1592
|
try {
|
|
1553
|
-
await c(
|
|
1593
|
+
await c(E, () => I);
|
|
1554
1594
|
} finally {
|
|
1555
|
-
|
|
1595
|
+
v = !1;
|
|
1556
1596
|
}
|
|
1557
1597
|
}
|
|
1558
1598
|
}
|
|
1559
1599
|
w();
|
|
1560
|
-
const
|
|
1561
|
-
|
|
1562
|
-
},
|
|
1563
|
-
|
|
1600
|
+
const b = window.setInterval(() => {
|
|
1601
|
+
Ve() && w();
|
|
1602
|
+
}, as), x = () => {
|
|
1603
|
+
Ve() && w();
|
|
1564
1604
|
};
|
|
1565
|
-
return document.addEventListener("visibilitychange",
|
|
1566
|
-
|
|
1605
|
+
return document.addEventListener("visibilitychange", x), () => {
|
|
1606
|
+
I = !0, window.clearInterval(b), document.removeEventListener("visibilitychange", x);
|
|
1567
1607
|
};
|
|
1568
|
-
}, [c, e]), { balances: u, refreshBalances:
|
|
1608
|
+
}, [c, e]), { balances: u, refreshBalances: f };
|
|
1569
1609
|
}
|
|
1570
|
-
function
|
|
1610
|
+
function os({
|
|
1571
1611
|
endpoint: t,
|
|
1572
1612
|
chainId: e,
|
|
1573
1613
|
addresses: n
|
|
1574
1614
|
}) {
|
|
1575
|
-
const [a,
|
|
1576
|
-
return
|
|
1615
|
+
const [a, r] = P({});
|
|
1616
|
+
return U(() => {
|
|
1577
1617
|
if (!t || !n.length) return;
|
|
1578
|
-
const
|
|
1579
|
-
return
|
|
1618
|
+
const s = new AbortController();
|
|
1619
|
+
return mi({
|
|
1580
1620
|
endpoint: t,
|
|
1581
1621
|
chainId: e,
|
|
1582
1622
|
addresses: n,
|
|
1583
|
-
signal:
|
|
1584
|
-
}).then((
|
|
1585
|
-
|
|
1623
|
+
signal: s.signal
|
|
1624
|
+
}).then((o) => {
|
|
1625
|
+
s.signal.aborted || o.size === 0 || r((l) => {
|
|
1586
1626
|
let u = !1;
|
|
1587
1627
|
const c = { ...l };
|
|
1588
|
-
return
|
|
1589
|
-
var
|
|
1590
|
-
((
|
|
1628
|
+
return o.forEach((f, m) => {
|
|
1629
|
+
var I;
|
|
1630
|
+
((I = c[m]) == null ? void 0 : I.iconURL) !== f.iconURL && (c[m] = f, u = !0);
|
|
1591
1631
|
}), u ? c : l;
|
|
1592
1632
|
});
|
|
1593
|
-
}).catch((
|
|
1594
|
-
|
|
1595
|
-
}), () =>
|
|
1633
|
+
}).catch((o) => {
|
|
1634
|
+
s.signal.aborted || console.warn("[AegisSwapWidget] Token metadata icons unavailable", o);
|
|
1635
|
+
}), () => s.abort();
|
|
1596
1636
|
}, [n, e, t]), a;
|
|
1597
1637
|
}
|
|
1598
|
-
function
|
|
1638
|
+
function ls({
|
|
1599
1639
|
provider: t,
|
|
1600
1640
|
controlledAccount: e,
|
|
1601
1641
|
getProvider: n,
|
|
1602
1642
|
onConnectWallet: a
|
|
1603
1643
|
}) {
|
|
1604
|
-
const [
|
|
1644
|
+
const [r, s] = P(null), [o, l] = P(null), [u, c] = P(null), f = O(async () => {
|
|
1605
1645
|
if (t) return t;
|
|
1606
1646
|
if (n) {
|
|
1607
|
-
const
|
|
1608
|
-
if (
|
|
1647
|
+
const v = await n();
|
|
1648
|
+
if (v) return v;
|
|
1609
1649
|
}
|
|
1610
|
-
return
|
|
1611
|
-
}, [n, t]),
|
|
1612
|
-
|
|
1613
|
-
let
|
|
1614
|
-
return
|
|
1615
|
-
|
|
1650
|
+
return St();
|
|
1651
|
+
}, [n, t]), m = t ?? u ?? St(), I = e ?? r;
|
|
1652
|
+
U(() => {
|
|
1653
|
+
let v = !1;
|
|
1654
|
+
return f().then((w) => {
|
|
1655
|
+
v || c(w);
|
|
1616
1656
|
}).catch((w) => {
|
|
1617
|
-
|
|
1657
|
+
v || (console.warn("[AegisSwapWidget] Provider resolver unavailable", w), c(St()));
|
|
1618
1658
|
}), () => {
|
|
1619
|
-
|
|
1659
|
+
v = !0;
|
|
1620
1660
|
};
|
|
1621
|
-
}, [
|
|
1622
|
-
if (!
|
|
1623
|
-
let
|
|
1661
|
+
}, [f]), U(() => {
|
|
1662
|
+
if (!m) return;
|
|
1663
|
+
let v = !1;
|
|
1624
1664
|
const w = async () => {
|
|
1625
1665
|
try {
|
|
1626
|
-
const [
|
|
1627
|
-
e ? Promise.resolve(e) :
|
|
1628
|
-
|
|
1666
|
+
const [x, R] = await Promise.all([
|
|
1667
|
+
e ? Promise.resolve(e) : vi(m),
|
|
1668
|
+
qe(m)
|
|
1629
1669
|
]);
|
|
1630
|
-
if (
|
|
1631
|
-
|
|
1670
|
+
if (v) return;
|
|
1671
|
+
s(x), l(R);
|
|
1632
1672
|
} catch {
|
|
1633
|
-
|
|
1673
|
+
v || (e || s(null), l(null));
|
|
1634
1674
|
}
|
|
1635
1675
|
};
|
|
1636
1676
|
w();
|
|
1637
|
-
const
|
|
1677
|
+
const b = wi(m, {
|
|
1638
1678
|
onAccountsChanged: w,
|
|
1639
1679
|
onChainChanged: w
|
|
1640
1680
|
});
|
|
1641
1681
|
return () => {
|
|
1642
|
-
|
|
1682
|
+
v = !0, b();
|
|
1643
1683
|
};
|
|
1644
|
-
}, [e,
|
|
1645
|
-
const
|
|
1646
|
-
const
|
|
1684
|
+
}, [e, m]);
|
|
1685
|
+
const E = O(async () => {
|
|
1686
|
+
const v = bi(
|
|
1647
1687
|
a ? await a() : void 0
|
|
1648
|
-
), w =
|
|
1688
|
+
), w = v.provider ?? await f();
|
|
1649
1689
|
if (!w) return null;
|
|
1650
1690
|
c(w);
|
|
1651
|
-
const
|
|
1652
|
-
return
|
|
1653
|
-
}, [
|
|
1654
|
-
return { owner:
|
|
1691
|
+
const b = v.account ?? await yi(w), x = await qe(w);
|
|
1692
|
+
return s(b), l(x), { provider: w, account: b };
|
|
1693
|
+
}, [f, a]);
|
|
1694
|
+
return { owner: I, walletChainId: o, setWalletChainId: l, getActiveProvider: f, connectWallet: E };
|
|
1655
1695
|
}
|
|
1656
|
-
function
|
|
1696
|
+
function cs(t) {
|
|
1657
1697
|
return t === "sell" ? "sell" : "buy";
|
|
1658
1698
|
}
|
|
1659
|
-
function
|
|
1699
|
+
function us(t) {
|
|
1660
1700
|
return `${t.slice(0, 6)}...${t.slice(-4)}`;
|
|
1661
1701
|
}
|
|
1662
|
-
function
|
|
1702
|
+
function aa(t, e, n) {
|
|
1663
1703
|
switch (t) {
|
|
1664
1704
|
case "ArrowRight":
|
|
1665
1705
|
case "ArrowDown":
|
|
@@ -1675,590 +1715,630 @@ function Vn(t, e, n) {
|
|
|
1675
1715
|
return null;
|
|
1676
1716
|
}
|
|
1677
1717
|
}
|
|
1678
|
-
function
|
|
1718
|
+
function ds({
|
|
1679
1719
|
busy: t,
|
|
1680
1720
|
status: e,
|
|
1681
1721
|
hasMarket: n,
|
|
1682
1722
|
hasAvailablePools: a,
|
|
1683
|
-
ownerConnected:
|
|
1684
|
-
wrongChain:
|
|
1685
|
-
activeChainName:
|
|
1723
|
+
ownerConnected: r,
|
|
1724
|
+
wrongChain: s,
|
|
1725
|
+
activeChainName: o,
|
|
1686
1726
|
activeInput: l,
|
|
1687
1727
|
amountInvalid: u,
|
|
1688
1728
|
slippageValid: c,
|
|
1689
|
-
insufficientBalance:
|
|
1690
|
-
hasQuote:
|
|
1691
|
-
quoteLoading:
|
|
1692
|
-
quoteUnavailable:
|
|
1693
|
-
allowanceError:
|
|
1729
|
+
insufficientBalance: f,
|
|
1730
|
+
hasQuote: m,
|
|
1731
|
+
quoteLoading: I,
|
|
1732
|
+
quoteUnavailable: E,
|
|
1733
|
+
allowanceError: v,
|
|
1694
1734
|
approvalCheckPending: w,
|
|
1695
|
-
approvalRequired:
|
|
1696
|
-
authorizationCheckPending:
|
|
1697
|
-
authorizationRequired:
|
|
1698
|
-
inputSymbol:
|
|
1699
|
-
targetSymbol:
|
|
1700
|
-
counterSymbol:
|
|
1701
|
-
direction:
|
|
1735
|
+
approvalRequired: b,
|
|
1736
|
+
authorizationCheckPending: x,
|
|
1737
|
+
authorizationRequired: R,
|
|
1738
|
+
inputSymbol: D,
|
|
1739
|
+
targetSymbol: B,
|
|
1740
|
+
counterSymbol: S,
|
|
1741
|
+
direction: h
|
|
1702
1742
|
}) {
|
|
1703
|
-
const
|
|
1743
|
+
const A = !r, y = r && s, M = !!(r && !s && l.trim() && !u && c && !f && m && !v), V = !!(M && b), z = !!(M && !w && !b && !x && R), N = !!(M && !w && !b && !x && !R), te = !!(!t && n && (A || y || V || z || N)), K = e === "approving" ? `Approving ${D}` : e === "signing" ? "Signing permit" : e === "submitting" ? "Swapping" : e === "success" ? "Swapped" : n ? A ? "Connect wallet" : y ? `Switch to ${o}` : l.trim() ? u ? "Invalid amount" : c ? f ? `Insufficient ${D}` : I ? "Fetching quote" : E ? "Quote unavailable" : v ? "Approval unavailable" : w ? "Checking approval" : b ? `Approve ${D} & swap` : x ? "Checking authorization" : R ? h === "buy" ? `Approve & swap to ${B}` : `Approve & swap to ${S}` : h === "buy" ? `Swap to ${B}` : `Swap to ${S}` : "Invalid slippage" : "Enter amount" : a ? "Pool unavailable" : "No pools available";
|
|
1704
1744
|
return {
|
|
1705
|
-
canConnectWallet:
|
|
1706
|
-
canSwitchChain:
|
|
1707
|
-
validEntry:
|
|
1708
|
-
canApprove:
|
|
1709
|
-
canAuthorize:
|
|
1710
|
-
canSwap:
|
|
1711
|
-
canSubmit:
|
|
1712
|
-
primaryAction:
|
|
1713
|
-
ctaLabel:
|
|
1745
|
+
canConnectWallet: A,
|
|
1746
|
+
canSwitchChain: y,
|
|
1747
|
+
validEntry: M,
|
|
1748
|
+
canApprove: V,
|
|
1749
|
+
canAuthorize: z,
|
|
1750
|
+
canSwap: N,
|
|
1751
|
+
canSubmit: te,
|
|
1752
|
+
primaryAction: b ? "approve" : "swap",
|
|
1753
|
+
ctaLabel: K
|
|
1714
1754
|
};
|
|
1715
1755
|
}
|
|
1716
|
-
function
|
|
1756
|
+
function ps({
|
|
1717
1757
|
quote: t,
|
|
1718
1758
|
inputSymbol: e,
|
|
1719
1759
|
inputDecimals: n,
|
|
1720
1760
|
outputSymbol: a,
|
|
1721
|
-
outputDecimals:
|
|
1761
|
+
outputDecimals: r
|
|
1722
1762
|
}) {
|
|
1723
1763
|
if (!t) return [];
|
|
1724
|
-
const
|
|
1725
|
-
return
|
|
1764
|
+
const s = [], o = t.amountIn > 0n ? t.amountOut * 10n ** BigInt(n) / t.amountIn : null;
|
|
1765
|
+
return o !== null && s.push({
|
|
1726
1766
|
label: "Rate",
|
|
1727
|
-
value: `1 ${e} = ${
|
|
1728
|
-
}), t.mode === "exactOut" ?
|
|
1767
|
+
value: `1 ${e} = ${_e(o, r)} ${a}`
|
|
1768
|
+
}), t.mode === "exactOut" ? s.push({
|
|
1729
1769
|
label: "Max sold",
|
|
1730
|
-
value: `${
|
|
1731
|
-
}) :
|
|
1770
|
+
value: `${_e(t.amountInMaximum, n)} ${e}`
|
|
1771
|
+
}) : s.push({
|
|
1732
1772
|
label: "Min received",
|
|
1733
|
-
value: `${
|
|
1734
|
-
}),
|
|
1773
|
+
value: `${_e(t.userAmountOutMinimum, r)} ${a}`
|
|
1774
|
+
}), s;
|
|
1735
1775
|
}
|
|
1736
|
-
const
|
|
1737
|
-
function
|
|
1776
|
+
const On = 3e3, Bn = 420, kn = 30;
|
|
1777
|
+
function Ln(t) {
|
|
1738
1778
|
const e = t.trim().match(/^(\d*\.?\d+)(ms|s)$/);
|
|
1739
1779
|
if (!e) return null;
|
|
1740
1780
|
const n = Number(e[1]);
|
|
1741
1781
|
return Number.isFinite(n) ? e[2] === "s" ? n * 1e3 : n : null;
|
|
1742
1782
|
}
|
|
1743
|
-
function
|
|
1744
|
-
const e =
|
|
1783
|
+
function fs(t) {
|
|
1784
|
+
const e = On + Bn + kn, n = t == null ? void 0 : t.ownerDocument.defaultView;
|
|
1745
1785
|
if (!t || !n) return e;
|
|
1746
|
-
const a = n.getComputedStyle(t),
|
|
1747
|
-
return
|
|
1786
|
+
const a = n.getComputedStyle(t), r = Ln(a.getPropertyValue("--aegis-rail-hold")) ?? On, s = Ln(a.getPropertyValue("--aegis-rail-fade")) ?? Bn;
|
|
1787
|
+
return r + s + kn;
|
|
1748
1788
|
}
|
|
1749
|
-
function
|
|
1750
|
-
var
|
|
1789
|
+
function hs(t) {
|
|
1790
|
+
var dn, pn;
|
|
1751
1791
|
const {
|
|
1752
1792
|
provider: e,
|
|
1753
1793
|
account: n,
|
|
1754
1794
|
getProvider: a,
|
|
1755
|
-
onConnectWallet:
|
|
1756
|
-
onSubmitted:
|
|
1757
|
-
onSuccess:
|
|
1795
|
+
onConnectWallet: r,
|
|
1796
|
+
onSubmitted: s,
|
|
1797
|
+
onSuccess: o,
|
|
1758
1798
|
onError: l,
|
|
1759
1799
|
onQuote: u,
|
|
1760
1800
|
onStatusChange: c,
|
|
1761
|
-
onPoolChange:
|
|
1762
|
-
chainId:
|
|
1763
|
-
chains:
|
|
1764
|
-
networkOptions:
|
|
1765
|
-
pools:
|
|
1801
|
+
onPoolChange: f,
|
|
1802
|
+
chainId: m = wn,
|
|
1803
|
+
chains: I,
|
|
1804
|
+
networkOptions: E,
|
|
1805
|
+
pools: v,
|
|
1766
1806
|
defaultPoolId: w,
|
|
1767
|
-
poolIds:
|
|
1768
|
-
defaultDirection:
|
|
1769
|
-
defaultSlippagePercent:
|
|
1770
|
-
rpcUrls:
|
|
1771
|
-
metadataEndpoint:
|
|
1772
|
-
className:
|
|
1773
|
-
style:
|
|
1774
|
-
title:
|
|
1775
|
-
subtitle:
|
|
1776
|
-
ariaLabel:
|
|
1777
|
-
theme:
|
|
1778
|
-
accentColor:
|
|
1779
|
-
accentTextColor:
|
|
1780
|
-
showPoolLink:
|
|
1781
|
-
defaultApprovalMode:
|
|
1807
|
+
poolIds: b,
|
|
1808
|
+
defaultDirection: x,
|
|
1809
|
+
defaultSlippagePercent: R = 1,
|
|
1810
|
+
rpcUrls: D,
|
|
1811
|
+
metadataEndpoint: B,
|
|
1812
|
+
className: S,
|
|
1813
|
+
style: h,
|
|
1814
|
+
title: A = "",
|
|
1815
|
+
subtitle: y = "",
|
|
1816
|
+
ariaLabel: M = "Aegis direct pool swap",
|
|
1817
|
+
theme: V,
|
|
1818
|
+
accentColor: z,
|
|
1819
|
+
accentTextColor: N,
|
|
1820
|
+
showPoolLink: te = !0,
|
|
1821
|
+
defaultApprovalMode: K = "exact",
|
|
1782
1822
|
showApprovalMode: d = !0,
|
|
1783
|
-
showExecutionDetails:
|
|
1784
|
-
defaultExecutionDetailsOpen:
|
|
1785
|
-
statusSurface:
|
|
1786
|
-
toastPosition:
|
|
1787
|
-
} = t,
|
|
1788
|
-
const
|
|
1789
|
-
if (
|
|
1790
|
-
|
|
1791
|
-
const
|
|
1792
|
-
|
|
1793
|
-
} else
|
|
1794
|
-
return
|
|
1795
|
-
}, [
|
|
1796
|
-
() =>
|
|
1797
|
-
[
|
|
1798
|
-
),
|
|
1823
|
+
showExecutionDetails: _ = !0,
|
|
1824
|
+
defaultExecutionDetailsOpen: q = !1,
|
|
1825
|
+
statusSurface: k = "rail",
|
|
1826
|
+
toastPosition: ne = "bottom-right"
|
|
1827
|
+
} = t, re = Zn(V), L = $e(), g = $e(), T = $e(), H = $e(), $ = Ee(I), Y = Ee(v), pe = Ee(b), ue = Ee(D), Ke = Ee(h), je = Ee(E), ft = J(() => {
|
|
1828
|
+
const C = { ...Ke };
|
|
1829
|
+
if (z) {
|
|
1830
|
+
C["--aegis-swap-accent"] = z;
|
|
1831
|
+
const X = N ?? Yn(z);
|
|
1832
|
+
X && (C["--aegis-swap-accent-text"] = X);
|
|
1833
|
+
} else N && (C["--aegis-swap-accent-text"] = N);
|
|
1834
|
+
return C;
|
|
1835
|
+
}, [z, N, Ke]), Te = J(() => _i($), [$]), F = Te[m] ?? Ii[wn], Ce = F.fee ?? null, Bt = J(
|
|
1836
|
+
() => Si(Y, Te),
|
|
1837
|
+
[Te, Y]
|
|
1838
|
+
), Ie = J(
|
|
1799
1839
|
() => ({
|
|
1800
|
-
...
|
|
1801
|
-
...
|
|
1840
|
+
...Y != null && Y.length ? {} : Ai,
|
|
1841
|
+
...Bt
|
|
1802
1842
|
}),
|
|
1803
|
-
[
|
|
1804
|
-
),
|
|
1805
|
-
var
|
|
1806
|
-
return ((
|
|
1807
|
-
}), [
|
|
1808
|
-
() =>
|
|
1809
|
-
[
|
|
1843
|
+
[Bt, Y]
|
|
1844
|
+
), se = J(() => (pe && pe.length > 0 ? pe : Y != null && Y.length ? Y.map((X) => X.id) : bn).filter((X) => {
|
|
1845
|
+
var ge;
|
|
1846
|
+
return ((ge = Ie[X]) == null ? void 0 : ge.chainId) === F.chainId;
|
|
1847
|
+
}), [F.chainId, Y, Ie, pe]), kt = J(() => Array.isArray(ue) ? ue : (ue == null ? void 0 : ue[F.chainId]) ?? F.rpcUrls, [F, ue]), ia = B === void 0 ? F.metadataEndpoint : B, ra = kt.join(","), Xe = J(
|
|
1848
|
+
() => Ei(F.chain, kt),
|
|
1849
|
+
[F.chainId, ra]
|
|
1810
1850
|
// not activeChain.chain/resolvedRpcUrls identity
|
|
1811
|
-
),
|
|
1812
|
-
w ??
|
|
1813
|
-
), [
|
|
1814
|
-
() =>
|
|
1815
|
-
), [
|
|
1816
|
-
|
|
1817
|
-
const { owner:
|
|
1818
|
-
|
|
1819
|
-
const
|
|
1820
|
-
() =>
|
|
1821
|
-
[
|
|
1822
|
-
),
|
|
1823
|
-
publicClient:
|
|
1824
|
-
owner:
|
|
1851
|
+
), sa = xi(n), [Lt, oa] = P(
|
|
1852
|
+
w ?? bn[0]
|
|
1853
|
+
), [Ye, la] = P(
|
|
1854
|
+
() => cs(x)
|
|
1855
|
+
), [le, Me] = P("exactIn"), [Ft, Re] = P(""), [Ut, De] = P(""), ht = Pn(String(R)) || "1", [Se, $t] = P(ht), [ca, gt] = P(null), [Wt, ua] = P(K), [da, mt] = P(q), [pa, Ht] = P("trade"), [Oe, fa] = P(null), Vt = W(null), qt = W(/* @__PURE__ */ new Map()), wt = W(void 0);
|
|
1856
|
+
U(() => () => window.clearTimeout(wt.current), []);
|
|
1857
|
+
const { owner: Be, walletChainId: Gt, setWalletChainId: ha, getActiveProvider: ga, connectWallet: ma } = ls({ provider: e, controlledAccount: sa, getProvider: a, onConnectWallet: r }), me = se.includes(Lt) ? Lt : se[0];
|
|
1858
|
+
qr(f, me);
|
|
1859
|
+
const G = me ? Ie[me] ?? null : null, Qe = (G == null ? void 0 : G.token) ?? yn.WATER, Ze = (G == null ? void 0 : G.counterToken) ?? yn.USDC, Q = Ye === "buy" ? Ze : Qe, ae = Ye === "buy" ? Qe : Ze, Je = le === "exactOut" ? Ut : Ft, zt = le === "exactOut" ? ae : Q, bt = J(
|
|
1860
|
+
() => Lr(Je, zt.decimals),
|
|
1861
|
+
[Je, zt.decimals]
|
|
1862
|
+
), et = J(() => Tn(Se), [Se]), { balances: fe, refreshBalances: wa } = ss({
|
|
1863
|
+
publicClient: Xe,
|
|
1864
|
+
owner: Be,
|
|
1825
1865
|
inputToken: Q,
|
|
1826
|
-
outputToken:
|
|
1827
|
-
}),
|
|
1828
|
-
publicClient:
|
|
1829
|
-
owner:
|
|
1830
|
-
market:
|
|
1866
|
+
outputToken: ae
|
|
1867
|
+
}), Kt = W(!1), { quote: Z, quoteLoading: jt, quoteError: Xt, setQuote: ba, clearQuote: tt } = ts({
|
|
1868
|
+
publicClient: Xe,
|
|
1869
|
+
owner: Be,
|
|
1870
|
+
market: G,
|
|
1831
1871
|
inputToken: Q,
|
|
1832
|
-
outputToken:
|
|
1833
|
-
quoteMode:
|
|
1834
|
-
activeAmount:
|
|
1835
|
-
slippageBps:
|
|
1836
|
-
feeConfig:
|
|
1872
|
+
outputToken: ae,
|
|
1873
|
+
quoteMode: le,
|
|
1874
|
+
activeAmount: bt,
|
|
1875
|
+
slippageBps: et,
|
|
1876
|
+
feeConfig: Ce,
|
|
1837
1877
|
onQuote: u,
|
|
1838
|
-
pausedRef:
|
|
1839
|
-
}),
|
|
1840
|
-
allowanceAmount:
|
|
1841
|
-
allowanceError:
|
|
1842
|
-
approvalCheckPending:
|
|
1843
|
-
approvalRequired:
|
|
1844
|
-
authorizationCheckPending:
|
|
1845
|
-
authorizationRequired:
|
|
1846
|
-
authorizationPromptExpected:
|
|
1847
|
-
readAllowance:
|
|
1848
|
-
commitAllowance:
|
|
1849
|
-
refreshAllowances:
|
|
1850
|
-
} =
|
|
1851
|
-
submit:
|
|
1852
|
-
approveInputToken:
|
|
1853
|
-
reset:
|
|
1854
|
-
status:
|
|
1855
|
-
busy:
|
|
1856
|
-
txHash:
|
|
1857
|
-
actionError:
|
|
1858
|
-
approvalProgress:
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1878
|
+
pausedRef: Kt
|
|
1879
|
+
}), de = Z ? Nt(Z) : void 0, {
|
|
1880
|
+
allowanceAmount: Yt,
|
|
1881
|
+
allowanceError: Qt,
|
|
1882
|
+
approvalCheckPending: ya,
|
|
1883
|
+
approvalRequired: va,
|
|
1884
|
+
authorizationCheckPending: _a,
|
|
1885
|
+
authorizationRequired: Zt,
|
|
1886
|
+
authorizationPromptExpected: nt,
|
|
1887
|
+
readAllowance: Ia,
|
|
1888
|
+
commitAllowance: Sa,
|
|
1889
|
+
refreshAllowances: Aa
|
|
1890
|
+
} = ns({ publicClient: Xe, owner: Be, market: G, inputToken: Q, spendAmount: de }), {
|
|
1891
|
+
submit: Jt,
|
|
1892
|
+
approveInputToken: en,
|
|
1893
|
+
reset: ce,
|
|
1894
|
+
status: ee,
|
|
1895
|
+
busy: we,
|
|
1896
|
+
txHash: he,
|
|
1897
|
+
actionError: be,
|
|
1898
|
+
approvalProgress: tn,
|
|
1899
|
+
receiptSummary: oe
|
|
1900
|
+
} = Qr({
|
|
1901
|
+
publicClient: Xe,
|
|
1902
|
+
activeChain: F,
|
|
1903
|
+
market: G,
|
|
1863
1904
|
inputToken: Q,
|
|
1864
|
-
outputToken:
|
|
1865
|
-
quoteMode:
|
|
1866
|
-
activeAmount:
|
|
1867
|
-
slippageBps:
|
|
1868
|
-
feeConfig:
|
|
1905
|
+
outputToken: ae,
|
|
1906
|
+
quoteMode: le,
|
|
1907
|
+
activeAmount: bt,
|
|
1908
|
+
slippageBps: et,
|
|
1909
|
+
feeConfig: Ce,
|
|
1869
1910
|
quote: Z,
|
|
1870
|
-
setQuote:
|
|
1871
|
-
owner:
|
|
1872
|
-
getActiveProvider:
|
|
1873
|
-
connectWallet:
|
|
1874
|
-
setWalletChainId:
|
|
1875
|
-
readAllowance:
|
|
1876
|
-
commitAllowance:
|
|
1877
|
-
refreshAllowances:
|
|
1878
|
-
approvalMode:
|
|
1879
|
-
refreshBalances:
|
|
1880
|
-
onSubmitted:
|
|
1881
|
-
onSuccess:
|
|
1911
|
+
setQuote: ba,
|
|
1912
|
+
owner: Be,
|
|
1913
|
+
getActiveProvider: ga,
|
|
1914
|
+
connectWallet: ma,
|
|
1915
|
+
setWalletChainId: ha,
|
|
1916
|
+
readAllowance: Ia,
|
|
1917
|
+
commitAllowance: Sa,
|
|
1918
|
+
refreshAllowances: Aa,
|
|
1919
|
+
approvalMode: Wt,
|
|
1920
|
+
refreshBalances: wa,
|
|
1921
|
+
onSubmitted: s,
|
|
1922
|
+
onSuccess: o,
|
|
1882
1923
|
onError: l
|
|
1883
1924
|
});
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
}, [
|
|
1887
|
-
if (
|
|
1888
|
-
const
|
|
1889
|
-
return () => window.clearTimeout(
|
|
1890
|
-
}, [
|
|
1891
|
-
const
|
|
1892
|
-
const
|
|
1893
|
-
for (const
|
|
1894
|
-
const
|
|
1895
|
-
|
|
1925
|
+
U(() => {
|
|
1926
|
+
Kt.current = we;
|
|
1927
|
+
}, [we]), U(() => {
|
|
1928
|
+
if (ee !== "success") return;
|
|
1929
|
+
const C = window.setTimeout(() => ce(), fs(Vt.current));
|
|
1930
|
+
return () => window.clearTimeout(C);
|
|
1931
|
+
}, [ee, ce]);
|
|
1932
|
+
const Ea = J(() => {
|
|
1933
|
+
const C = /* @__PURE__ */ new Set();
|
|
1934
|
+
for (const X of se) {
|
|
1935
|
+
const ge = Ie[X];
|
|
1936
|
+
C.add(ge.token.address), C.add(ge.counterToken.address);
|
|
1896
1937
|
}
|
|
1897
|
-
return [...
|
|
1898
|
-
}, [
|
|
1899
|
-
endpoint:
|
|
1900
|
-
chainId:
|
|
1901
|
-
addresses:
|
|
1902
|
-
}),
|
|
1903
|
-
var
|
|
1904
|
-
if (!(!
|
|
1938
|
+
return [...C];
|
|
1939
|
+
}, [Ie, se]), xa = os({
|
|
1940
|
+
endpoint: ia,
|
|
1941
|
+
chainId: F.chainId,
|
|
1942
|
+
addresses: Ea
|
|
1943
|
+
}), Na = Gt !== null && Gt !== F.chainId, yt = Je.trim().length > 0 && bt === null, nn = se.length > 0, Pa = de !== void 0 && fe.input !== null && de > fe.input, Ta = G ? ((dn = F.poolExplorerUrl) == null ? void 0 : dn.call(F, G.poolId, G)) ?? null : null, Ca = !!(G && ca === G.poolId), ke = le === "exactOut" && Z ? Cn(Z.amountIn, Q.decimals) : Ft, vt = le === "exactIn" && Z ? Cn(Z.amountOut, ae.decimals) : Ut, Ma = O(async () => {
|
|
1944
|
+
var C;
|
|
1945
|
+
if (!(!G || !((C = navigator.clipboard) != null && C.writeText)))
|
|
1905
1946
|
try {
|
|
1906
|
-
await navigator.clipboard.writeText(
|
|
1947
|
+
await navigator.clipboard.writeText(G.poolId), gt(G.poolId), window.clearTimeout(wt.current), wt.current = window.setTimeout(() => gt(null), 1e3);
|
|
1907
1948
|
} catch {
|
|
1908
|
-
|
|
1949
|
+
gt(null);
|
|
1909
1950
|
}
|
|
1910
|
-
}, [
|
|
1911
|
-
(
|
|
1912
|
-
|
|
1951
|
+
}, [G]), at = O(
|
|
1952
|
+
(C) => {
|
|
1953
|
+
C !== null && (Me("exactIn"), Re(Ur(C, Q.decimals)), De(""), ce());
|
|
1913
1954
|
},
|
|
1914
|
-
[Q.decimals,
|
|
1915
|
-
),
|
|
1916
|
-
() =>
|
|
1917
|
-
[
|
|
1918
|
-
),
|
|
1919
|
-
const
|
|
1920
|
-
|
|
1921
|
-
}, [
|
|
1922
|
-
(
|
|
1923
|
-
const
|
|
1924
|
-
|
|
1955
|
+
[Q.decimals, ce]
|
|
1956
|
+
), Ra = O(
|
|
1957
|
+
() => at(fe.input === null ? null : fe.input / 2n),
|
|
1958
|
+
[fe.input, at]
|
|
1959
|
+
), Da = O(() => at(fe.input), [fe.input, at]), Oa = O(() => {
|
|
1960
|
+
const C = He(vt || ke);
|
|
1961
|
+
la((X) => X === "buy" ? "sell" : "buy"), Me("exactIn"), Re(C), De(""), tt(), ce();
|
|
1962
|
+
}, [vt, tt, ce, ke]), _t = O(
|
|
1963
|
+
(C) => {
|
|
1964
|
+
const X = He(ke);
|
|
1965
|
+
oa(C), Me("exactIn"), Re(X), De(""), tt(), ce();
|
|
1925
1966
|
},
|
|
1926
|
-
[
|
|
1927
|
-
),
|
|
1928
|
-
(
|
|
1929
|
-
var
|
|
1930
|
-
if (
|
|
1931
|
-
const
|
|
1932
|
-
if (
|
|
1933
|
-
|
|
1934
|
-
const
|
|
1935
|
-
|
|
1967
|
+
[tt, ce, ke]
|
|
1968
|
+
), Ba = O(
|
|
1969
|
+
(C) => {
|
|
1970
|
+
var hn;
|
|
1971
|
+
if (se.length === 0 || !me) return;
|
|
1972
|
+
const X = Math.max(se.indexOf(me), 0), ge = aa(C.key, X, se.length);
|
|
1973
|
+
if (ge === null) return;
|
|
1974
|
+
C.preventDefault();
|
|
1975
|
+
const fn = se[ge];
|
|
1976
|
+
_t(fn), (hn = qt.current.get(fn)) == null || hn.focus();
|
|
1936
1977
|
},
|
|
1937
|
-
[
|
|
1938
|
-
),
|
|
1939
|
-
(
|
|
1940
|
-
|
|
1978
|
+
[me, se, _t]
|
|
1979
|
+
), it = O(
|
|
1980
|
+
(C, X) => {
|
|
1981
|
+
C === "exactIn" ? (Me("exactIn"), Re(He(X)), De("")) : (Me("exactOut"), De(He(X)), Re("")), ce();
|
|
1941
1982
|
},
|
|
1942
|
-
[
|
|
1943
|
-
),
|
|
1944
|
-
(
|
|
1945
|
-
[
|
|
1946
|
-
),
|
|
1947
|
-
(
|
|
1948
|
-
[
|
|
1949
|
-
), { canSubmit:
|
|
1950
|
-
busy:
|
|
1951
|
-
status:
|
|
1952
|
-
hasMarket: !!
|
|
1953
|
-
hasAvailablePools:
|
|
1954
|
-
ownerConnected: !!
|
|
1955
|
-
wrongChain:
|
|
1956
|
-
activeChainName:
|
|
1957
|
-
activeInput:
|
|
1958
|
-
amountInvalid:
|
|
1959
|
-
slippageValid:
|
|
1960
|
-
insufficientBalance:
|
|
1983
|
+
[ce]
|
|
1984
|
+
), ka = O(
|
|
1985
|
+
(C) => it("exactIn", C),
|
|
1986
|
+
[it]
|
|
1987
|
+
), La = O(
|
|
1988
|
+
(C) => it("exactOut", C),
|
|
1989
|
+
[it]
|
|
1990
|
+
), { canSubmit: an, primaryAction: rt, ctaLabel: Fa } = ds({
|
|
1991
|
+
busy: we,
|
|
1992
|
+
status: ee,
|
|
1993
|
+
hasMarket: !!G,
|
|
1994
|
+
hasAvailablePools: nn,
|
|
1995
|
+
ownerConnected: !!Be,
|
|
1996
|
+
wrongChain: Na,
|
|
1997
|
+
activeChainName: F.name,
|
|
1998
|
+
activeInput: Je,
|
|
1999
|
+
amountInvalid: yt,
|
|
2000
|
+
slippageValid: et !== null,
|
|
2001
|
+
insufficientBalance: Pa,
|
|
1961
2002
|
hasQuote: !!Z,
|
|
1962
|
-
quoteLoading:
|
|
1963
|
-
quoteUnavailable: !!(
|
|
1964
|
-
allowanceError: !!
|
|
1965
|
-
approvalCheckPending:
|
|
1966
|
-
approvalRequired:
|
|
1967
|
-
authorizationCheckPending:
|
|
1968
|
-
authorizationRequired:
|
|
2003
|
+
quoteLoading: jt,
|
|
2004
|
+
quoteUnavailable: !!(Xt && !Z),
|
|
2005
|
+
allowanceError: !!Qt,
|
|
2006
|
+
approvalCheckPending: ya,
|
|
2007
|
+
approvalRequired: va,
|
|
2008
|
+
authorizationCheckPending: _a,
|
|
2009
|
+
authorizationRequired: Zt,
|
|
1969
2010
|
inputSymbol: Q.symbol,
|
|
1970
|
-
targetSymbol:
|
|
1971
|
-
counterSymbol:
|
|
1972
|
-
direction:
|
|
1973
|
-
}),
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
}, [
|
|
1977
|
-
const
|
|
1978
|
-
status:
|
|
2011
|
+
targetSymbol: Qe.symbol,
|
|
2012
|
+
counterSymbol: Ze.symbol,
|
|
2013
|
+
direction: Ye
|
|
2014
|
+
}), Ua = !!(tn.done && de !== void 0 && de > 0n && Yt !== null && Yt >= de), rn = W(nt);
|
|
2015
|
+
U(() => {
|
|
2016
|
+
ee === "idle" && !be && (rn.current = nt);
|
|
2017
|
+
}, [be, nt, ee]);
|
|
2018
|
+
const $a = ee === "idle" && !be ? nt : rn.current, j = Ni({
|
|
2019
|
+
status: ee,
|
|
1979
2020
|
inputSymbol: Q.symbol,
|
|
1980
|
-
txHash:
|
|
1981
|
-
actionError:
|
|
1982
|
-
approvalRequired:
|
|
1983
|
-
approvalDone:
|
|
1984
|
-
authorizationRequired:
|
|
1985
|
-
}),
|
|
1986
|
-
|
|
1987
|
-
status:
|
|
1988
|
-
progress:
|
|
1989
|
-
label: (
|
|
1990
|
-
walletPrompts: (
|
|
1991
|
-
completePct: (
|
|
1992
|
-
activeWidthPct: (
|
|
1993
|
-
txHash:
|
|
1994
|
-
error:
|
|
2021
|
+
txHash: he,
|
|
2022
|
+
actionError: be,
|
|
2023
|
+
approvalRequired: tn.required,
|
|
2024
|
+
approvalDone: Ua,
|
|
2025
|
+
authorizationRequired: $a
|
|
2026
|
+
}), sn = (j == null ? void 0 : j.state) ?? null;
|
|
2027
|
+
zr(c, {
|
|
2028
|
+
status: ee,
|
|
2029
|
+
progress: sn,
|
|
2030
|
+
label: (j == null ? void 0 : j.label) ?? null,
|
|
2031
|
+
walletPrompts: (j == null ? void 0 : j.walletPrompts) ?? { total: 0, completed: 0, active: null },
|
|
2032
|
+
completePct: (j == null ? void 0 : j.completePct) ?? null,
|
|
2033
|
+
activeWidthPct: (j == null ? void 0 : j.activeWidthPct) ?? null,
|
|
2034
|
+
txHash: he,
|
|
2035
|
+
error: be
|
|
1995
2036
|
});
|
|
1996
|
-
const
|
|
1997
|
-
|
|
1998
|
-
enabled:
|
|
1999
|
-
status:
|
|
2000
|
-
progress:
|
|
2001
|
-
txHash:
|
|
2002
|
-
explorerUrl:
|
|
2003
|
-
successDescription: Z ? `Received ~${
|
|
2037
|
+
const Wa = k === "rail" || k === "both", on = k === "toast" || k === "both", ln = he ? qn(he, F) : null, Ae = ln === "#" ? null : ln;
|
|
2038
|
+
Vr({
|
|
2039
|
+
enabled: on,
|
|
2040
|
+
status: ee,
|
|
2041
|
+
progress: j,
|
|
2042
|
+
txHash: he,
|
|
2043
|
+
explorerUrl: Ae,
|
|
2044
|
+
successDescription: Z ? `Received ~${_e(Z.amountOut, ae.decimals)} ${ae.symbol}` : null
|
|
2004
2045
|
});
|
|
2005
|
-
const
|
|
2006
|
-
|
|
2007
|
-
}, [
|
|
2008
|
-
(
|
|
2046
|
+
const Ha = O(() => {
|
|
2047
|
+
rt === "approve" ? en() : Jt();
|
|
2048
|
+
}, [en, rt, Jt]), Va = O(() => mt((C) => !C), []), qa = O(
|
|
2049
|
+
(C) => $t(Pn(C)),
|
|
2009
2050
|
[]
|
|
2010
|
-
),
|
|
2011
|
-
|
|
2012
|
-
}, [
|
|
2051
|
+
), Ga = O(() => {
|
|
2052
|
+
Tn(Se) === null && $t(ht);
|
|
2053
|
+
}, [ht, Se]), za = ps({
|
|
2013
2054
|
quote: Z,
|
|
2014
2055
|
inputSymbol: Q.symbol,
|
|
2015
2056
|
inputDecimals: Q.decimals,
|
|
2016
|
-
outputSymbol:
|
|
2017
|
-
outputDecimals:
|
|
2018
|
-
})
|
|
2057
|
+
outputSymbol: ae.symbol,
|
|
2058
|
+
outputDecimals: ae.decimals
|
|
2059
|
+
}), cn = de !== void 0 && de > 0n ? _e(de, Q.decimals) : null, Ka = be || ee === "success" || !cn || !an && !we ? null : rt === "approve" ? `To swap, approve ${cn} ${Q.symbol} in your wallet` : Zt ? `To swap, sign the ${Q.symbol} permit in your wallet — no gas` : null, un = ((pn = F.chain.nativeCurrency) == null ? void 0 : pn.symbol) ?? "ETH", Le = J(() => oe ? {
|
|
2060
|
+
transactionHash: oe.transactionHash,
|
|
2061
|
+
received: Z && ee === "success" ? `${_e(Z.amountOut, ae.decimals)} ${ae.symbol}` : null,
|
|
2062
|
+
txExplorerHref: Ae,
|
|
2063
|
+
rows: [
|
|
2064
|
+
oe.feeWei > 0n ? {
|
|
2065
|
+
kind: "network-fee",
|
|
2066
|
+
label: "Network fee",
|
|
2067
|
+
value: `${$r(oe.feeWei)} ${un}`
|
|
2068
|
+
} : null,
|
|
2069
|
+
oe.effectiveGasPrice > 0n ? {
|
|
2070
|
+
kind: "gas-price",
|
|
2071
|
+
label: "Gas price",
|
|
2072
|
+
value: `${Wr(oe.effectiveGasPrice)} gwei`
|
|
2073
|
+
} : null,
|
|
2074
|
+
oe.gasUsed > 0n ? { kind: "gas-used", label: "Gas used", value: oe.gasUsed.toString() } : null,
|
|
2075
|
+
oe.blockNumber > 0n ? { kind: "block", label: "Block", value: `#${oe.blockNumber.toString()}` } : null
|
|
2076
|
+
].filter((C) => C !== null)
|
|
2077
|
+
} : null, [
|
|
2078
|
+
Ae,
|
|
2079
|
+
un,
|
|
2080
|
+
ae.decimals,
|
|
2081
|
+
ae.symbol,
|
|
2082
|
+
Z,
|
|
2083
|
+
oe,
|
|
2084
|
+
ee
|
|
2085
|
+
]);
|
|
2086
|
+
U(() => {
|
|
2087
|
+
ee !== "success" || !Le || (fa(Le), Ht("transaction"), mt(!0));
|
|
2088
|
+
}, [ee, Le]);
|
|
2089
|
+
const ja = !!(A || y), Xa = Oe ? pa : "trade", Ya = O((C) => {
|
|
2090
|
+
Ht(C), mt(!0);
|
|
2091
|
+
}, []), Qa = he && Ae && !Le && (Oe == null ? void 0 : Oe.transactionHash) !== he ? Ae : null;
|
|
2019
2092
|
return {
|
|
2020
2093
|
// identity / layout
|
|
2021
|
-
rootRef:
|
|
2022
|
-
resolvedThemeMode:
|
|
2023
|
-
widgetStyle:
|
|
2024
|
-
className:
|
|
2025
|
-
ariaLabel:
|
|
2026
|
-
title:
|
|
2027
|
-
subtitle:
|
|
2028
|
-
hasBrandText:
|
|
2094
|
+
rootRef: Vt,
|
|
2095
|
+
resolvedThemeMode: re,
|
|
2096
|
+
widgetStyle: ft,
|
|
2097
|
+
className: S,
|
|
2098
|
+
ariaLabel: M,
|
|
2099
|
+
title: A,
|
|
2100
|
+
subtitle: y,
|
|
2101
|
+
hasBrandText: ja,
|
|
2029
2102
|
// toaster + surfaces
|
|
2030
|
-
theme:
|
|
2031
|
-
accentColor:
|
|
2032
|
-
accentTextColor:
|
|
2033
|
-
toastPosition:
|
|
2034
|
-
showRail:
|
|
2035
|
-
showToast:
|
|
2036
|
-
showExecutionDetails:
|
|
2037
|
-
showPoolLink:
|
|
2103
|
+
theme: V,
|
|
2104
|
+
accentColor: z,
|
|
2105
|
+
accentTextColor: N,
|
|
2106
|
+
toastPosition: ne,
|
|
2107
|
+
showRail: Wa,
|
|
2108
|
+
showToast: on,
|
|
2109
|
+
showExecutionDetails: _,
|
|
2110
|
+
showPoolLink: te,
|
|
2038
2111
|
showApprovalMode: d,
|
|
2039
2112
|
// progress
|
|
2040
|
-
progress:
|
|
2041
|
-
progressState:
|
|
2113
|
+
progress: j,
|
|
2114
|
+
progressState: sn,
|
|
2042
2115
|
// pools / network
|
|
2043
|
-
poolIds:
|
|
2044
|
-
activePoolId:
|
|
2045
|
-
marketMap:
|
|
2046
|
-
metadataByAddress:
|
|
2047
|
-
poolButtonRefs:
|
|
2048
|
-
onSelectPool:
|
|
2049
|
-
onPoolKeyDown:
|
|
2050
|
-
activeChain:
|
|
2051
|
-
networkOptions:
|
|
2052
|
-
hasAvailablePools:
|
|
2116
|
+
poolIds: se,
|
|
2117
|
+
activePoolId: me,
|
|
2118
|
+
marketMap: Ie,
|
|
2119
|
+
metadataByAddress: xa,
|
|
2120
|
+
poolButtonRefs: qt,
|
|
2121
|
+
onSelectPool: _t,
|
|
2122
|
+
onPoolKeyDown: Ba,
|
|
2123
|
+
activeChain: F,
|
|
2124
|
+
networkOptions: je,
|
|
2125
|
+
hasAvailablePools: nn,
|
|
2053
2126
|
// form: sell side
|
|
2054
|
-
balances:
|
|
2055
|
-
sellInputId:
|
|
2127
|
+
balances: fe,
|
|
2128
|
+
sellInputId: L,
|
|
2056
2129
|
inputToken: Q,
|
|
2057
|
-
sellFieldValue:
|
|
2058
|
-
sellInvalid:
|
|
2059
|
-
sellRefreshEnabled:
|
|
2060
|
-
onSellChange:
|
|
2061
|
-
onHalf:
|
|
2062
|
-
onMax:
|
|
2130
|
+
sellFieldValue: ke,
|
|
2131
|
+
sellInvalid: le === "exactIn" && yt,
|
|
2132
|
+
sellRefreshEnabled: le === "exactOut" && !we,
|
|
2133
|
+
onSellChange: ka,
|
|
2134
|
+
onHalf: Ra,
|
|
2135
|
+
onMax: Da,
|
|
2063
2136
|
// form: flip
|
|
2064
|
-
direction:
|
|
2065
|
-
market:
|
|
2066
|
-
onFlipDirection:
|
|
2137
|
+
direction: Ye,
|
|
2138
|
+
market: G,
|
|
2139
|
+
onFlipDirection: Oa,
|
|
2067
2140
|
// form: buy side
|
|
2068
|
-
buyInputId:
|
|
2069
|
-
outputToken:
|
|
2070
|
-
buyFieldValue:
|
|
2071
|
-
buyInvalid:
|
|
2072
|
-
buyRefreshEnabled:
|
|
2073
|
-
onBuyChange:
|
|
2141
|
+
buyInputId: g,
|
|
2142
|
+
outputToken: ae,
|
|
2143
|
+
buyFieldValue: vt,
|
|
2144
|
+
buyInvalid: le === "exactOut" && yt,
|
|
2145
|
+
buyRefreshEnabled: le === "exactIn" && !we,
|
|
2146
|
+
onBuyChange: La,
|
|
2074
2147
|
// submit
|
|
2075
|
-
busy:
|
|
2076
|
-
canSubmit:
|
|
2077
|
-
primaryAction:
|
|
2078
|
-
ctaLabel:
|
|
2079
|
-
onPrimaryAction:
|
|
2148
|
+
busy: we,
|
|
2149
|
+
canSubmit: an,
|
|
2150
|
+
primaryAction: rt,
|
|
2151
|
+
ctaLabel: Fa,
|
|
2152
|
+
onPrimaryAction: Ha,
|
|
2080
2153
|
// execution details
|
|
2081
|
-
executionDetailsOpen:
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2154
|
+
executionDetailsOpen: da,
|
|
2155
|
+
executionDetailsView: Xa,
|
|
2156
|
+
executionDetailsId: H,
|
|
2157
|
+
onToggleExecutionDetails: Va,
|
|
2158
|
+
onExecutionDetailsViewChange: Ya,
|
|
2159
|
+
latestTxSummary: Oe,
|
|
2160
|
+
tradeDetailRows: za,
|
|
2161
|
+
slippageInputId: T,
|
|
2162
|
+
slippageInput: Se,
|
|
2163
|
+
slippageInvalid: !!(Se.trim() && et === null),
|
|
2164
|
+
onSlippageChange: qa,
|
|
2165
|
+
onSlippageBlur: Ga,
|
|
2166
|
+
approvalMode: Wt,
|
|
2167
|
+
onApprovalModeChange: ua,
|
|
2168
|
+
counterToken: Ze,
|
|
2169
|
+
targetToken: Qe,
|
|
2170
|
+
poolUrl: Ta,
|
|
2171
|
+
onCopyPoolId: Ma,
|
|
2172
|
+
routePoolCopied: Ca,
|
|
2097
2173
|
// status / result
|
|
2098
|
-
status:
|
|
2099
|
-
txHash:
|
|
2174
|
+
status: ee,
|
|
2175
|
+
txHash: he,
|
|
2100
2176
|
quote: Z,
|
|
2101
|
-
quoteError:
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2177
|
+
quoteError: Xt,
|
|
2178
|
+
quoteLoading: jt,
|
|
2179
|
+
actionError: be,
|
|
2180
|
+
allowanceError: Qt,
|
|
2181
|
+
inlineTxExplorerHref: Qa,
|
|
2182
|
+
txExplorerHref: Ae,
|
|
2183
|
+
approvalHint: Ka,
|
|
2184
|
+
txSummary: Le
|
|
2105
2185
|
};
|
|
2106
2186
|
}
|
|
2107
|
-
const
|
|
2108
|
-
function
|
|
2109
|
-
return t === "base" ? /* @__PURE__ */
|
|
2187
|
+
const gs = 150;
|
|
2188
|
+
function Fn({ icon: t = "ethereum" }) {
|
|
2189
|
+
return t === "base" ? /* @__PURE__ */ i(Fi, { className: "aegis-swap-widget__chain-logo" }) : /* @__PURE__ */ i(Li, { className: "aegis-swap-widget__chain-logo" });
|
|
2110
2190
|
}
|
|
2111
|
-
const
|
|
2191
|
+
const ms = {
|
|
2112
2192
|
1: "ethereum",
|
|
2113
2193
|
8453: "base"
|
|
2114
|
-
},
|
|
2194
|
+
}, ws = ut(function({
|
|
2115
2195
|
activeChainName: e,
|
|
2116
2196
|
activeChainId: n,
|
|
2117
2197
|
options: a
|
|
2118
2198
|
}) {
|
|
2119
|
-
const [
|
|
2199
|
+
const [r, s] = P(!1), [o, l] = P(!1), u = W(null), c = W(null), f = W(null), m = W(), I = $e(), E = a != null && a.length ? a : [], v = E.find((S) => S.id === n) ?? E.find((S) => S.name === e), w = {
|
|
2120
2200
|
id: n,
|
|
2121
2201
|
name: e,
|
|
2122
|
-
icon:
|
|
2123
|
-
},
|
|
2124
|
-
var
|
|
2125
|
-
|
|
2126
|
-
}, []),
|
|
2127
|
-
window.clearTimeout(
|
|
2202
|
+
icon: ms[n]
|
|
2203
|
+
}, b = v ? E : [w, ...E], x = v ?? w, R = O((S = !1) => {
|
|
2204
|
+
var h;
|
|
2205
|
+
s(!1), l(!0), window.clearTimeout(m.current), m.current = window.setTimeout(() => l(!1), gs), S && ((h = c.current) == null || h.focus());
|
|
2206
|
+
}, []), D = O(() => {
|
|
2207
|
+
window.clearTimeout(m.current), l(!1), s(!0);
|
|
2128
2208
|
}, []);
|
|
2129
|
-
|
|
2130
|
-
const
|
|
2131
|
-
var
|
|
2132
|
-
const
|
|
2133
|
-
((
|
|
2209
|
+
U(() => () => window.clearTimeout(m.current), []);
|
|
2210
|
+
const B = (S) => {
|
|
2211
|
+
var M;
|
|
2212
|
+
const h = Array.from(
|
|
2213
|
+
((M = f.current) == null ? void 0 : M.querySelectorAll('[role="option"]:not(:disabled)')) ?? []
|
|
2134
2214
|
);
|
|
2135
|
-
if (
|
|
2136
|
-
const
|
|
2137
|
-
|
|
2215
|
+
if (h.length === 0) return;
|
|
2216
|
+
const A = h.indexOf(document.activeElement), y = aa(S.key, A, h.length);
|
|
2217
|
+
y !== null && (S.preventDefault(), h[y].focus());
|
|
2138
2218
|
};
|
|
2139
|
-
return
|
|
2140
|
-
if (!
|
|
2141
|
-
const
|
|
2142
|
-
var
|
|
2143
|
-
(
|
|
2144
|
-
},
|
|
2145
|
-
|
|
2219
|
+
return U(() => {
|
|
2220
|
+
if (!r) return;
|
|
2221
|
+
const S = (A) => {
|
|
2222
|
+
var y;
|
|
2223
|
+
(y = u.current) != null && y.contains(A.target) || R();
|
|
2224
|
+
}, h = (A) => {
|
|
2225
|
+
A.key === "Escape" && (A.stopPropagation(), R(!0));
|
|
2146
2226
|
};
|
|
2147
|
-
return document.addEventListener("pointerdown",
|
|
2148
|
-
document.removeEventListener("pointerdown",
|
|
2227
|
+
return document.addEventListener("pointerdown", S), document.addEventListener("keydown", h), () => {
|
|
2228
|
+
document.removeEventListener("pointerdown", S), document.removeEventListener("keydown", h);
|
|
2149
2229
|
};
|
|
2150
|
-
}, [
|
|
2151
|
-
/* @__PURE__ */
|
|
2230
|
+
}, [r, R]), /* @__PURE__ */ p("div", { className: "aegis-swap-widget__network", ref: u, children: [
|
|
2231
|
+
/* @__PURE__ */ p(
|
|
2152
2232
|
"button",
|
|
2153
2233
|
{
|
|
2154
2234
|
type: "button",
|
|
2155
2235
|
ref: c,
|
|
2156
2236
|
className: "aegis-swap-widget__chain",
|
|
2157
2237
|
"aria-haspopup": "listbox",
|
|
2158
|
-
"aria-expanded":
|
|
2159
|
-
"aria-controls":
|
|
2160
|
-
"aria-label": `Network: ${
|
|
2161
|
-
"data-open":
|
|
2162
|
-
onClick: () =>
|
|
2238
|
+
"aria-expanded": r,
|
|
2239
|
+
"aria-controls": I,
|
|
2240
|
+
"aria-label": `Network: ${x.name}. Change network`,
|
|
2241
|
+
"data-open": r || void 0,
|
|
2242
|
+
onClick: () => r ? R() : D(),
|
|
2163
2243
|
children: [
|
|
2164
|
-
/* @__PURE__ */
|
|
2165
|
-
/* @__PURE__ */
|
|
2244
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__chain-mark", "aria-hidden": "true", children: /* @__PURE__ */ i(Fn, { icon: x.icon }) }),
|
|
2245
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__chain-caret", "aria-hidden": "true", children: /* @__PURE__ */ i(jn, {}) })
|
|
2166
2246
|
]
|
|
2167
2247
|
}
|
|
2168
2248
|
),
|
|
2169
|
-
/* @__PURE__ */
|
|
2249
|
+
/* @__PURE__ */ p(
|
|
2170
2250
|
"div",
|
|
2171
2251
|
{
|
|
2172
|
-
className: `aegis-swap-widget__network-menu${
|
|
2173
|
-
"aria-hidden": !
|
|
2252
|
+
className: `aegis-swap-widget__network-menu${r ? " is-open" : ""}${o ? " is-closing" : ""}`,
|
|
2253
|
+
"aria-hidden": !r,
|
|
2174
2254
|
children: [
|
|
2175
|
-
/* @__PURE__ */
|
|
2255
|
+
/* @__PURE__ */ i(
|
|
2176
2256
|
"div",
|
|
2177
2257
|
{
|
|
2178
2258
|
role: "listbox",
|
|
2179
|
-
id:
|
|
2259
|
+
id: I,
|
|
2180
2260
|
"aria-label": "Network",
|
|
2181
2261
|
className: "aegis-swap-widget__network-list",
|
|
2182
|
-
ref:
|
|
2183
|
-
onKeyDown:
|
|
2184
|
-
children:
|
|
2185
|
-
const
|
|
2186
|
-
return /* @__PURE__ */
|
|
2262
|
+
ref: f,
|
|
2263
|
+
onKeyDown: B,
|
|
2264
|
+
children: b.map((S) => {
|
|
2265
|
+
const h = S === x, A = h ? !1 : S.disabled ?? !0;
|
|
2266
|
+
return /* @__PURE__ */ p(
|
|
2187
2267
|
"button",
|
|
2188
2268
|
{
|
|
2189
2269
|
type: "button",
|
|
2190
2270
|
role: "option",
|
|
2191
|
-
"aria-selected":
|
|
2192
|
-
tabIndex:
|
|
2193
|
-
disabled:
|
|
2271
|
+
"aria-selected": A ? void 0 : h,
|
|
2272
|
+
tabIndex: r && !A ? 0 : -1,
|
|
2273
|
+
disabled: A,
|
|
2194
2274
|
className: "aegis-swap-widget__network-option",
|
|
2195
|
-
onClick: () =>
|
|
2275
|
+
onClick: () => R(!0),
|
|
2196
2276
|
children: [
|
|
2197
|
-
/* @__PURE__ */
|
|
2198
|
-
/* @__PURE__ */
|
|
2199
|
-
/* @__PURE__ */
|
|
2200
|
-
|
|
2277
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__network-mark", "aria-hidden": "true", children: /* @__PURE__ */ i(Fn, { icon: S.icon }) }),
|
|
2278
|
+
/* @__PURE__ */ p("span", { className: "aegis-swap-widget__network-label", children: [
|
|
2279
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__network-name", children: S.name }),
|
|
2280
|
+
S.status ? /* @__PURE__ */ i("span", { className: "aegis-swap-widget__network-status", children: S.status }) : null
|
|
2201
2281
|
] }),
|
|
2202
|
-
|
|
2282
|
+
h ? /* @__PURE__ */ i("span", { className: "aegis-swap-widget__network-check", "aria-hidden": "true", children: /* @__PURE__ */ i(lt, {}) }) : null
|
|
2203
2283
|
]
|
|
2204
2284
|
},
|
|
2205
|
-
|
|
2285
|
+
S.id
|
|
2206
2286
|
);
|
|
2207
2287
|
})
|
|
2208
2288
|
}
|
|
2209
2289
|
),
|
|
2210
|
-
|
|
2290
|
+
E.length === 0 ? /* @__PURE__ */ i("p", { className: "aegis-swap-widget__network-soon", children: "More networks coming soon" }) : null
|
|
2211
2291
|
]
|
|
2212
2292
|
}
|
|
2213
2293
|
)
|
|
2214
2294
|
] });
|
|
2215
2295
|
});
|
|
2216
|
-
function
|
|
2296
|
+
function bs({
|
|
2217
2297
|
poolIds: t,
|
|
2218
2298
|
activePoolId: e,
|
|
2219
2299
|
marketMap: n,
|
|
2220
2300
|
metadataByAddress: a,
|
|
2221
|
-
busy:
|
|
2222
|
-
onSelectPool:
|
|
2223
|
-
onKeyDown:
|
|
2301
|
+
busy: r,
|
|
2302
|
+
onSelectPool: s,
|
|
2303
|
+
onKeyDown: o,
|
|
2224
2304
|
buttonRefs: l
|
|
2225
2305
|
}) {
|
|
2226
|
-
return /* @__PURE__ */
|
|
2306
|
+
return /* @__PURE__ */ i(
|
|
2227
2307
|
"div",
|
|
2228
2308
|
{
|
|
2229
2309
|
className: "aegis-swap-widget__targets",
|
|
2230
2310
|
role: "radiogroup",
|
|
2231
2311
|
"aria-label": "Swap pool",
|
|
2232
|
-
onKeyDown:
|
|
2312
|
+
onKeyDown: o,
|
|
2233
2313
|
style: {
|
|
2234
2314
|
"--aegis-seg-index": Math.max(t.indexOf(e ?? ""), 0),
|
|
2235
2315
|
"--aegis-seg-count": t.length
|
|
2236
2316
|
},
|
|
2237
2317
|
children: t.map((u) => {
|
|
2238
|
-
const c = n[u],
|
|
2239
|
-
return /* @__PURE__ */
|
|
2318
|
+
const c = n[u], f = u === e;
|
|
2319
|
+
return /* @__PURE__ */ p(
|
|
2240
2320
|
"button",
|
|
2241
2321
|
{
|
|
2242
2322
|
type: "button",
|
|
2243
2323
|
role: "radio",
|
|
2244
|
-
ref: (
|
|
2245
|
-
l.current.set(u,
|
|
2324
|
+
ref: (m) => {
|
|
2325
|
+
l.current.set(u, m);
|
|
2246
2326
|
},
|
|
2247
2327
|
className: "aegis-swap-widget__target",
|
|
2248
|
-
"aria-checked":
|
|
2249
|
-
tabIndex:
|
|
2250
|
-
disabled:
|
|
2251
|
-
onClick: () =>
|
|
2328
|
+
"aria-checked": f,
|
|
2329
|
+
tabIndex: f ? 0 : -1,
|
|
2330
|
+
disabled: r,
|
|
2331
|
+
onClick: () => s(u),
|
|
2252
2332
|
children: [
|
|
2253
|
-
/* @__PURE__ */
|
|
2254
|
-
|
|
2333
|
+
/* @__PURE__ */ i(
|
|
2334
|
+
Kn,
|
|
2255
2335
|
{
|
|
2256
2336
|
market: c,
|
|
2257
2337
|
metadataByAddress: a,
|
|
2258
2338
|
className: "aegis-swap-widget__target-pair"
|
|
2259
2339
|
}
|
|
2260
2340
|
),
|
|
2261
|
-
/* @__PURE__ */
|
|
2341
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__target-symbol", children: c.symbol ?? u })
|
|
2262
2342
|
]
|
|
2263
2343
|
},
|
|
2264
2344
|
u
|
|
@@ -2267,185 +2347,277 @@ function zr({
|
|
|
2267
2347
|
}
|
|
2268
2348
|
);
|
|
2269
2349
|
}
|
|
2270
|
-
function
|
|
2271
|
-
const [n, a] =
|
|
2272
|
-
return
|
|
2273
|
-
const
|
|
2274
|
-
if (
|
|
2350
|
+
function ys(t, e) {
|
|
2351
|
+
const [n, a] = P(!1), r = W(t);
|
|
2352
|
+
return U(() => {
|
|
2353
|
+
const s = r.current !== t;
|
|
2354
|
+
if (r.current = t, !e || !s || t === "") return;
|
|
2275
2355
|
a(!0);
|
|
2276
|
-
const
|
|
2356
|
+
const o = window.setTimeout(() => a(!1), 700);
|
|
2277
2357
|
return () => {
|
|
2278
|
-
window.clearTimeout(
|
|
2358
|
+
window.clearTimeout(o), a(!1);
|
|
2279
2359
|
};
|
|
2280
2360
|
}, [e, t]), n;
|
|
2281
2361
|
}
|
|
2282
|
-
function
|
|
2362
|
+
function Un({
|
|
2283
2363
|
inputId: t,
|
|
2284
2364
|
label: e,
|
|
2285
2365
|
token: n,
|
|
2286
2366
|
value: a,
|
|
2287
|
-
balance:
|
|
2288
|
-
invalid:
|
|
2289
|
-
busy:
|
|
2367
|
+
balance: r,
|
|
2368
|
+
invalid: s,
|
|
2369
|
+
busy: o,
|
|
2290
2370
|
refreshEnabled: l,
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2371
|
+
refreshing: u,
|
|
2372
|
+
metadataByAddress: c,
|
|
2373
|
+
onChange: f,
|
|
2374
|
+
quickActions: m
|
|
2294
2375
|
}) {
|
|
2295
|
-
const
|
|
2296
|
-
return /* @__PURE__ */
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2376
|
+
const I = ys(a, l ?? !1);
|
|
2377
|
+
return /* @__PURE__ */ p(
|
|
2378
|
+
"div",
|
|
2379
|
+
{
|
|
2380
|
+
className: "aegis-swap-widget__amount-box",
|
|
2381
|
+
"data-refreshed": I || void 0,
|
|
2382
|
+
"data-refreshing": l && u || void 0,
|
|
2383
|
+
children: [
|
|
2384
|
+
/* @__PURE__ */ p("span", { className: "aegis-swap-widget__field-label", children: [
|
|
2385
|
+
/* @__PURE__ */ i("label", { htmlFor: t, children: e }),
|
|
2386
|
+
m ? /* @__PURE__ */ p("span", { className: "aegis-swap-widget__quick", children: [
|
|
2387
|
+
/* @__PURE__ */ i(
|
|
2388
|
+
"button",
|
|
2389
|
+
{
|
|
2390
|
+
type: "button",
|
|
2391
|
+
className: "aegis-swap-widget__half",
|
|
2392
|
+
"aria-label": `Use half ${n.symbol} balance`,
|
|
2393
|
+
disabled: r === null || o,
|
|
2394
|
+
onClick: m.onHalf,
|
|
2395
|
+
children: "50%"
|
|
2396
|
+
}
|
|
2397
|
+
),
|
|
2398
|
+
/* @__PURE__ */ i(
|
|
2399
|
+
"button",
|
|
2400
|
+
{
|
|
2401
|
+
type: "button",
|
|
2402
|
+
className: "aegis-swap-widget__max",
|
|
2403
|
+
"aria-label": `Use max ${n.symbol} balance`,
|
|
2404
|
+
disabled: r === null || o,
|
|
2405
|
+
onClick: m.onMax,
|
|
2406
|
+
children: "Max"
|
|
2407
|
+
}
|
|
2408
|
+
)
|
|
2409
|
+
] }) : null
|
|
2410
|
+
] }),
|
|
2411
|
+
/* @__PURE__ */ p("span", { className: "aegis-swap-widget__amount-row", children: [
|
|
2412
|
+
/* @__PURE__ */ i(
|
|
2413
|
+
"input",
|
|
2414
|
+
{
|
|
2415
|
+
id: t,
|
|
2416
|
+
inputMode: "decimal",
|
|
2417
|
+
autoComplete: "off",
|
|
2418
|
+
value: a,
|
|
2419
|
+
"aria-invalid": s ? !0 : void 0,
|
|
2420
|
+
onChange: (E) => f(E.target.value),
|
|
2421
|
+
placeholder: "0",
|
|
2422
|
+
disabled: o
|
|
2423
|
+
}
|
|
2424
|
+
),
|
|
2425
|
+
/* @__PURE__ */ p("span", { className: "aegis-swap-widget__token", children: [
|
|
2426
|
+
/* @__PURE__ */ i(
|
|
2427
|
+
Pt,
|
|
2428
|
+
{
|
|
2429
|
+
token: n,
|
|
2430
|
+
metadataByAddress: c,
|
|
2431
|
+
className: "aegis-swap-widget__token-mark"
|
|
2432
|
+
}
|
|
2433
|
+
),
|
|
2434
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__token-symbol", children: n.symbol })
|
|
2435
|
+
] }, n.address)
|
|
2436
|
+
] }),
|
|
2437
|
+
/* @__PURE__ */ p("span", { className: "aegis-swap-widget__meta", children: [
|
|
2438
|
+
"Balance ",
|
|
2439
|
+
Fr(r, n.decimals),
|
|
2440
|
+
" ",
|
|
2441
|
+
n.symbol
|
|
2442
|
+
] })
|
|
2443
|
+
]
|
|
2444
|
+
}
|
|
2445
|
+
);
|
|
2357
2446
|
}
|
|
2358
|
-
function
|
|
2447
|
+
function vs({ kind: t }) {
|
|
2448
|
+
switch (t) {
|
|
2449
|
+
case "network-fee":
|
|
2450
|
+
return /* @__PURE__ */ i(Hi, {});
|
|
2451
|
+
case "gas-price":
|
|
2452
|
+
return /* @__PURE__ */ i(Vi, {});
|
|
2453
|
+
case "gas-used":
|
|
2454
|
+
return /* @__PURE__ */ i(qi, {});
|
|
2455
|
+
case "block":
|
|
2456
|
+
return /* @__PURE__ */ i(Gi, {});
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
function _s({
|
|
2359
2460
|
open: t,
|
|
2360
2461
|
panelId: e,
|
|
2361
2462
|
onToggle: n,
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2463
|
+
activeView: a,
|
|
2464
|
+
onViewChange: r,
|
|
2465
|
+
latestTxSummary: s,
|
|
2466
|
+
rows: o,
|
|
2467
|
+
slippageInputId: l,
|
|
2468
|
+
slippageValue: u,
|
|
2469
|
+
slippageInvalid: c,
|
|
2470
|
+
onSlippageChange: f,
|
|
2471
|
+
onSlippageBlur: m,
|
|
2472
|
+
showApprovalControl: I,
|
|
2473
|
+
approvalMode: E,
|
|
2474
|
+
onApprovalModeChange: v,
|
|
2475
|
+
busy: w,
|
|
2476
|
+
market: b,
|
|
2477
|
+
metadataByAddress: x,
|
|
2478
|
+
counterToken: R,
|
|
2479
|
+
targetToken: D,
|
|
2480
|
+
showPoolLink: B,
|
|
2481
|
+
poolUrl: S,
|
|
2482
|
+
onCopyPoolId: h,
|
|
2483
|
+
poolCopied: A
|
|
2380
2484
|
}) {
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
/* @__PURE__ */
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2485
|
+
const y = s && a === "transaction" ? "transaction" : "trade";
|
|
2486
|
+
return /* @__PURE__ */ p("div", { className: "aegis-swap-widget__execution", "data-open": t ? !0 : void 0, children: [
|
|
2487
|
+
/* @__PURE__ */ p("div", { className: "aegis-swap-widget__execution-header", children: [
|
|
2488
|
+
/* @__PURE__ */ p(
|
|
2489
|
+
"button",
|
|
2490
|
+
{
|
|
2491
|
+
type: "button",
|
|
2492
|
+
className: "aegis-swap-widget__execution-toggle",
|
|
2493
|
+
"aria-expanded": t,
|
|
2494
|
+
"aria-controls": e,
|
|
2495
|
+
"aria-label": t ? "Collapse trade details" : "Expand trade details",
|
|
2496
|
+
onClick: n,
|
|
2497
|
+
children: [
|
|
2498
|
+
/* @__PURE__ */ p("span", { className: "aegis-swap-widget__execution-toggle-label", children: [
|
|
2499
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__execution-toggle-icon", children: /* @__PURE__ */ i(Wi, {}) }),
|
|
2500
|
+
/* @__PURE__ */ i("span", { children: "Trade details" })
|
|
2501
|
+
] }),
|
|
2502
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__execution-chevron", children: /* @__PURE__ */ i(jn, {}) })
|
|
2503
|
+
]
|
|
2504
|
+
}
|
|
2505
|
+
),
|
|
2506
|
+
s ? /* @__PURE__ */ p(
|
|
2507
|
+
"span",
|
|
2508
|
+
{
|
|
2509
|
+
className: "aegis-swap-widget__execution-view-toggle",
|
|
2510
|
+
role: "group",
|
|
2511
|
+
"aria-label": "Details view",
|
|
2512
|
+
style: { "--aegis-seg-index": y === "trade" ? 0 : 1 },
|
|
2513
|
+
children: [
|
|
2514
|
+
/* @__PURE__ */ i(
|
|
2515
|
+
"button",
|
|
2516
|
+
{
|
|
2517
|
+
type: "button",
|
|
2518
|
+
"data-active": y === "trade" ? !0 : void 0,
|
|
2519
|
+
"aria-pressed": y === "trade",
|
|
2520
|
+
onClick: () => r("trade"),
|
|
2521
|
+
children: "Trade"
|
|
2522
|
+
}
|
|
2523
|
+
),
|
|
2524
|
+
/* @__PURE__ */ i(
|
|
2525
|
+
"button",
|
|
2526
|
+
{
|
|
2527
|
+
type: "button",
|
|
2528
|
+
"data-active": y === "transaction" ? !0 : void 0,
|
|
2529
|
+
"aria-pressed": y === "transaction",
|
|
2530
|
+
onClick: () => r("transaction"),
|
|
2531
|
+
children: "Latest tx"
|
|
2532
|
+
}
|
|
2533
|
+
)
|
|
2534
|
+
]
|
|
2535
|
+
}
|
|
2536
|
+
) : null
|
|
2537
|
+
] }),
|
|
2538
|
+
/* @__PURE__ */ i("div", { id: e, className: "aegis-swap-widget__execution-panel", children: /* @__PURE__ */ i("div", { className: "aegis-swap-widget__execution-panel-inner", children: y === "transaction" && s ? /* @__PURE__ */ p("div", { className: "aegis-swap-widget__receipt", role: "status", children: [
|
|
2539
|
+
/* @__PURE__ */ p("div", { className: "aegis-swap-widget__receipt-head", children: [
|
|
2540
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__success-check", "aria-hidden": "true", children: /* @__PURE__ */ i(lt, {}) }),
|
|
2541
|
+
/* @__PURE__ */ p("span", { children: [
|
|
2542
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__receipt-title", children: "Latest transaction" }),
|
|
2543
|
+
/* @__PURE__ */ p("span", { className: "aegis-swap-widget__receipt-subtitle", children: [
|
|
2544
|
+
"Swap complete",
|
|
2545
|
+
s.received ? /* @__PURE__ */ p(gn, { children: [
|
|
2546
|
+
" · received ",
|
|
2547
|
+
/* @__PURE__ */ i("strong", { children: s.received })
|
|
2548
|
+
] }) : null
|
|
2549
|
+
] })
|
|
2550
|
+
] })
|
|
2551
|
+
] }),
|
|
2552
|
+
s.rows.length > 0 ? /* @__PURE__ */ i("dl", { className: "aegis-swap-widget__receipt-list", children: s.rows.map((M) => /* @__PURE__ */ p("div", { className: "aegis-swap-widget__receipt-row", "data-kind": M.kind, children: [
|
|
2553
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__receipt-metric-icon", "aria-hidden": "true", children: /* @__PURE__ */ i(vs, { kind: M.kind }) }),
|
|
2554
|
+
/* @__PURE__ */ p("div", { className: "aegis-swap-widget__receipt-row-copy", children: [
|
|
2555
|
+
/* @__PURE__ */ i("dt", { children: M.label }),
|
|
2556
|
+
/* @__PURE__ */ i("dd", { children: M.value })
|
|
2557
|
+
] })
|
|
2558
|
+
] }, M.label)) }) : null,
|
|
2559
|
+
s.txExplorerHref ? /* @__PURE__ */ p(
|
|
2560
|
+
"a",
|
|
2561
|
+
{
|
|
2562
|
+
className: "aegis-swap-widget__receipt-link",
|
|
2563
|
+
href: s.txExplorerHref,
|
|
2564
|
+
target: "_blank",
|
|
2565
|
+
rel: "noreferrer",
|
|
2566
|
+
children: [
|
|
2567
|
+
"View transaction",
|
|
2568
|
+
/* @__PURE__ */ i(Tt, {})
|
|
2569
|
+
]
|
|
2570
|
+
}
|
|
2571
|
+
) : null
|
|
2572
|
+
] }) : /* @__PURE__ */ p(gn, { children: [
|
|
2573
|
+
o.length > 0 ? /* @__PURE__ */ i("div", { className: "aegis-swap-widget__quote-summary", children: o.map((M) => /* @__PURE__ */ p("div", { className: "aegis-swap-widget__detail-row", children: [
|
|
2574
|
+
/* @__PURE__ */ i("span", { children: M.label }),
|
|
2575
|
+
/* @__PURE__ */ i("strong", { children: M.value }, M.value)
|
|
2576
|
+
] }, M.label)) }) : null,
|
|
2577
|
+
/* @__PURE__ */ i("div", { className: "aegis-swap-widget__settings", children: /* @__PURE__ */ p("label", { htmlFor: l, children: [
|
|
2578
|
+
/* @__PURE__ */ i("span", { children: "Slippage" }),
|
|
2579
|
+
/* @__PURE__ */ p("span", { className: "aegis-swap-widget__slippage-input", children: [
|
|
2580
|
+
/* @__PURE__ */ i(
|
|
2409
2581
|
"input",
|
|
2410
2582
|
{
|
|
2411
|
-
id:
|
|
2412
|
-
value:
|
|
2583
|
+
id: l,
|
|
2584
|
+
value: u,
|
|
2413
2585
|
inputMode: "decimal",
|
|
2414
|
-
"aria-invalid":
|
|
2415
|
-
onChange: (
|
|
2416
|
-
onBlur:
|
|
2586
|
+
"aria-invalid": c ? !0 : void 0,
|
|
2587
|
+
onChange: (M) => f(M.target.value),
|
|
2588
|
+
onBlur: m
|
|
2417
2589
|
}
|
|
2418
2590
|
),
|
|
2419
|
-
/* @__PURE__ */
|
|
2591
|
+
/* @__PURE__ */ i("span", { children: "%" })
|
|
2420
2592
|
] })
|
|
2421
2593
|
] }) }),
|
|
2422
|
-
|
|
2423
|
-
/* @__PURE__ */
|
|
2424
|
-
/* @__PURE__ */
|
|
2594
|
+
I ? /* @__PURE__ */ p("div", { className: "aegis-swap-widget__approval-mode", children: [
|
|
2595
|
+
/* @__PURE__ */ i("span", { children: "Approval" }),
|
|
2596
|
+
/* @__PURE__ */ p(
|
|
2425
2597
|
"span",
|
|
2426
2598
|
{
|
|
2427
2599
|
className: "aegis-swap-widget__approval-options",
|
|
2428
2600
|
role: "group",
|
|
2429
2601
|
"aria-label": "Approval amount",
|
|
2430
|
-
style: { "--aegis-seg-index":
|
|
2602
|
+
style: { "--aegis-seg-index": E === "exact" ? 0 : 1 },
|
|
2431
2603
|
children: [
|
|
2432
|
-
/* @__PURE__ */
|
|
2604
|
+
/* @__PURE__ */ i(
|
|
2433
2605
|
"button",
|
|
2434
2606
|
{
|
|
2435
2607
|
type: "button",
|
|
2436
|
-
"data-active":
|
|
2437
|
-
disabled:
|
|
2438
|
-
onClick: () =>
|
|
2608
|
+
"data-active": E === "exact" ? !0 : void 0,
|
|
2609
|
+
disabled: w,
|
|
2610
|
+
onClick: () => v("exact"),
|
|
2439
2611
|
children: "Exact"
|
|
2440
2612
|
}
|
|
2441
2613
|
),
|
|
2442
|
-
/* @__PURE__ */
|
|
2614
|
+
/* @__PURE__ */ i(
|
|
2443
2615
|
"button",
|
|
2444
2616
|
{
|
|
2445
2617
|
type: "button",
|
|
2446
|
-
"data-active":
|
|
2447
|
-
disabled:
|
|
2448
|
-
onClick: () =>
|
|
2618
|
+
"data-active": E === "max" ? !0 : void 0,
|
|
2619
|
+
disabled: w,
|
|
2620
|
+
onClick: () => v("max"),
|
|
2449
2621
|
children: "Max"
|
|
2450
2622
|
}
|
|
2451
2623
|
)
|
|
@@ -2453,53 +2625,53 @@ function Vr({
|
|
|
2453
2625
|
}
|
|
2454
2626
|
)
|
|
2455
2627
|
] }) : null,
|
|
2456
|
-
|
|
2457
|
-
/* @__PURE__ */
|
|
2458
|
-
/* @__PURE__ */
|
|
2459
|
-
|
|
2628
|
+
b ? /* @__PURE__ */ i("div", { className: "aegis-swap-widget__details", children: /* @__PURE__ */ p("div", { className: "aegis-swap-widget__pool", children: [
|
|
2629
|
+
/* @__PURE__ */ p("span", { className: "aegis-swap-widget__pool-label", children: [
|
|
2630
|
+
/* @__PURE__ */ i(
|
|
2631
|
+
Kn,
|
|
2460
2632
|
{
|
|
2461
|
-
market:
|
|
2462
|
-
metadataByAddress:
|
|
2633
|
+
market: b,
|
|
2634
|
+
metadataByAddress: x,
|
|
2463
2635
|
className: "aegis-swap-widget__pool-pair"
|
|
2464
2636
|
}
|
|
2465
2637
|
),
|
|
2466
2638
|
"Route"
|
|
2467
2639
|
] }),
|
|
2468
|
-
/* @__PURE__ */
|
|
2640
|
+
/* @__PURE__ */ p(
|
|
2469
2641
|
"span",
|
|
2470
2642
|
{
|
|
2471
2643
|
className: "aegis-swap-widget__route-chip",
|
|
2472
|
-
"aria-label": `Uniswap v4 pool ${
|
|
2473
|
-
title: `${
|
|
2644
|
+
"aria-label": `Uniswap v4 pool ${b.poolId}`,
|
|
2645
|
+
title: `${b.label ?? `${R.symbol} / ${D.symbol}`}: ${b.poolId}`,
|
|
2474
2646
|
children: [
|
|
2475
|
-
/* @__PURE__ */
|
|
2476
|
-
/* @__PURE__ */
|
|
2477
|
-
/* @__PURE__ */
|
|
2647
|
+
/* @__PURE__ */ p("span", { className: "aegis-swap-widget__route-protocol", children: [
|
|
2648
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__route-version", children: "v4" }),
|
|
2649
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__route-kind", children: "Pool" })
|
|
2478
2650
|
] }),
|
|
2479
|
-
/* @__PURE__ */
|
|
2480
|
-
/* @__PURE__ */
|
|
2481
|
-
|
|
2651
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__route-id", children: us(b.poolId) }),
|
|
2652
|
+
/* @__PURE__ */ p("span", { className: "aegis-swap-widget__route-actions", children: [
|
|
2653
|
+
B && S ? /* @__PURE__ */ i(
|
|
2482
2654
|
"a",
|
|
2483
2655
|
{
|
|
2484
2656
|
className: "aegis-swap-widget__route-action",
|
|
2485
|
-
href:
|
|
2657
|
+
href: S,
|
|
2486
2658
|
target: "_blank",
|
|
2487
2659
|
rel: "noreferrer",
|
|
2488
2660
|
"aria-label": "Open pool",
|
|
2489
|
-
children: /* @__PURE__ */
|
|
2661
|
+
children: /* @__PURE__ */ i(Tt, {})
|
|
2490
2662
|
}
|
|
2491
2663
|
) : null,
|
|
2492
|
-
/* @__PURE__ */
|
|
2664
|
+
/* @__PURE__ */ p(
|
|
2493
2665
|
"button",
|
|
2494
2666
|
{
|
|
2495
2667
|
type: "button",
|
|
2496
2668
|
className: "aegis-swap-widget__route-action",
|
|
2497
|
-
"data-copied":
|
|
2498
|
-
onClick:
|
|
2499
|
-
"aria-label":
|
|
2669
|
+
"data-copied": A || void 0,
|
|
2670
|
+
onClick: h,
|
|
2671
|
+
"aria-label": A ? "Pool id copied" : "Copy pool id",
|
|
2500
2672
|
children: [
|
|
2501
|
-
/* @__PURE__ */
|
|
2502
|
-
/* @__PURE__ */
|
|
2673
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__copy-icon", "data-icon": "copy", "aria-hidden": "true", children: /* @__PURE__ */ i($i, {}) }),
|
|
2674
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__copy-icon", "data-icon": "check", "aria-hidden": "true", children: /* @__PURE__ */ i(lt, {}) })
|
|
2503
2675
|
]
|
|
2504
2676
|
}
|
|
2505
2677
|
)
|
|
@@ -2508,48 +2680,48 @@ function Vr({
|
|
|
2508
2680
|
}
|
|
2509
2681
|
)
|
|
2510
2682
|
] }) }) : null
|
|
2511
|
-
] }) })
|
|
2683
|
+
] }) }) })
|
|
2512
2684
|
] });
|
|
2513
2685
|
}
|
|
2514
|
-
const
|
|
2686
|
+
const Is = {
|
|
2515
2687
|
pending: { completePct: 0, activeWidthPct: 100 },
|
|
2516
2688
|
mining: { completePct: 0, activeWidthPct: 100 },
|
|
2517
2689
|
success: { completePct: 100, activeWidthPct: 0 },
|
|
2518
2690
|
error: { completePct: 100, activeWidthPct: 0 }
|
|
2519
2691
|
};
|
|
2520
|
-
function
|
|
2692
|
+
function Ss({
|
|
2521
2693
|
state: t,
|
|
2522
2694
|
label: e,
|
|
2523
2695
|
completePct: n,
|
|
2524
2696
|
activeWidthPct: a,
|
|
2525
|
-
className:
|
|
2697
|
+
className: r
|
|
2526
2698
|
}) {
|
|
2527
2699
|
if (!t) return null;
|
|
2528
|
-
const
|
|
2529
|
-
if (!
|
|
2530
|
-
const
|
|
2531
|
-
return /* @__PURE__ */
|
|
2700
|
+
const s = Is[t];
|
|
2701
|
+
if (!s) return null;
|
|
2702
|
+
const o = n ?? s.completePct, l = a ?? s.activeWidthPct;
|
|
2703
|
+
return /* @__PURE__ */ p(
|
|
2532
2704
|
"span",
|
|
2533
2705
|
{
|
|
2534
|
-
className: `aegis-swap-widget__progress-rail${
|
|
2706
|
+
className: `aegis-swap-widget__progress-rail${r ? ` ${r}` : ""}`,
|
|
2535
2707
|
"data-state": t,
|
|
2536
2708
|
title: e ? `${e} · ${t}` : t,
|
|
2537
2709
|
style: {
|
|
2538
|
-
"--aegis-swap-progress-complete": `${
|
|
2710
|
+
"--aegis-swap-progress-complete": `${o}%`,
|
|
2539
2711
|
"--aegis-swap-progress-active-width": `${l}%`
|
|
2540
2712
|
},
|
|
2541
2713
|
"aria-hidden": "true",
|
|
2542
2714
|
children: [
|
|
2543
|
-
/* @__PURE__ */
|
|
2544
|
-
l > 0 ? /* @__PURE__ */
|
|
2715
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__progress-complete" }),
|
|
2716
|
+
l > 0 ? /* @__PURE__ */ i("span", { className: "aegis-swap-widget__progress-active" }) : null
|
|
2545
2717
|
]
|
|
2546
2718
|
}
|
|
2547
2719
|
);
|
|
2548
2720
|
}
|
|
2549
|
-
function
|
|
2550
|
-
var
|
|
2551
|
-
const e =
|
|
2552
|
-
|
|
2721
|
+
function As(t) {
|
|
2722
|
+
var r, s, o;
|
|
2723
|
+
const e = hs(t), n = /* @__PURE__ */ i(
|
|
2724
|
+
bs,
|
|
2553
2725
|
{
|
|
2554
2726
|
poolIds: e.poolIds,
|
|
2555
2727
|
activePoolId: e.activePoolId,
|
|
@@ -2560,15 +2732,15 @@ function jr(t) {
|
|
|
2560
2732
|
onKeyDown: e.onPoolKeyDown,
|
|
2561
2733
|
buttonRefs: e.poolButtonRefs
|
|
2562
2734
|
}
|
|
2563
|
-
), a = /* @__PURE__ */
|
|
2564
|
-
|
|
2735
|
+
), a = /* @__PURE__ */ i(
|
|
2736
|
+
ws,
|
|
2565
2737
|
{
|
|
2566
2738
|
activeChainName: e.activeChain.name,
|
|
2567
2739
|
activeChainId: e.activeChain.chainId,
|
|
2568
2740
|
options: e.networkOptions
|
|
2569
2741
|
}
|
|
2570
2742
|
);
|
|
2571
|
-
return /* @__PURE__ */
|
|
2743
|
+
return /* @__PURE__ */ p(
|
|
2572
2744
|
"section",
|
|
2573
2745
|
{
|
|
2574
2746
|
ref: e.rootRef,
|
|
@@ -2579,21 +2751,21 @@ function jr(t) {
|
|
|
2579
2751
|
style: e.widgetStyle,
|
|
2580
2752
|
"aria-label": e.ariaLabel,
|
|
2581
2753
|
children: [
|
|
2582
|
-
e.showRail ? /* @__PURE__ */
|
|
2583
|
-
|
|
2754
|
+
e.showRail ? /* @__PURE__ */ i(
|
|
2755
|
+
Ss,
|
|
2584
2756
|
{
|
|
2585
2757
|
state: e.progressState,
|
|
2586
|
-
label: (
|
|
2587
|
-
completePct: (
|
|
2588
|
-
activeWidthPct: (
|
|
2758
|
+
label: (r = e.progress) == null ? void 0 : r.label,
|
|
2759
|
+
completePct: (s = e.progress) == null ? void 0 : s.completePct,
|
|
2760
|
+
activeWidthPct: (o = e.progress) == null ? void 0 : o.activeWidthPct
|
|
2589
2761
|
}
|
|
2590
2762
|
) : null,
|
|
2591
2763
|
e.showToast ? (
|
|
2592
2764
|
// Portals to document.body (the widget root's entrance transform
|
|
2593
2765
|
// would trap position: fixed) and yields to any host-mounted
|
|
2594
2766
|
// AegisSwapToaster via the toaster election.
|
|
2595
|
-
/* @__PURE__ */
|
|
2596
|
-
|
|
2767
|
+
/* @__PURE__ */ i(
|
|
2768
|
+
kr,
|
|
2597
2769
|
{
|
|
2598
2770
|
position: e.toastPosition,
|
|
2599
2771
|
theme: e.theme,
|
|
@@ -2602,32 +2774,32 @@ function jr(t) {
|
|
|
2602
2774
|
}
|
|
2603
2775
|
)
|
|
2604
2776
|
) : null,
|
|
2605
|
-
e.hasBrandText ? /* @__PURE__ */
|
|
2606
|
-
/* @__PURE__ */
|
|
2607
|
-
e.subtitle ? /* @__PURE__ */
|
|
2608
|
-
e.title ? /* @__PURE__ */
|
|
2777
|
+
e.hasBrandText ? /* @__PURE__ */ p("div", { className: "aegis-swap-widget__header", children: [
|
|
2778
|
+
/* @__PURE__ */ p("div", { className: "aegis-swap-widget__brand", children: [
|
|
2779
|
+
e.subtitle ? /* @__PURE__ */ i("span", { className: "aegis-swap-widget__eyebrow", children: e.subtitle }) : null,
|
|
2780
|
+
e.title ? /* @__PURE__ */ i("h2", { children: e.title }) : null
|
|
2609
2781
|
] }),
|
|
2610
2782
|
a
|
|
2611
2783
|
] }) : null,
|
|
2612
|
-
e.hasBrandText ? n : /* @__PURE__ */
|
|
2784
|
+
e.hasBrandText ? n : /* @__PURE__ */ p("div", { className: "aegis-swap-widget__topbar", children: [
|
|
2613
2785
|
n,
|
|
2614
2786
|
a
|
|
2615
2787
|
] }),
|
|
2616
|
-
e.hasAvailablePools ? null : /* @__PURE__ */
|
|
2788
|
+
e.hasAvailablePools ? null : /* @__PURE__ */ p("p", { className: "aegis-swap-widget__empty", role: "status", children: [
|
|
2617
2789
|
"No pools are configured for ",
|
|
2618
2790
|
e.activeChain.name,
|
|
2619
2791
|
"."
|
|
2620
2792
|
] }),
|
|
2621
|
-
/* @__PURE__ */
|
|
2793
|
+
/* @__PURE__ */ p(
|
|
2622
2794
|
"form",
|
|
2623
2795
|
{
|
|
2624
2796
|
onSubmit: (l) => {
|
|
2625
2797
|
l.preventDefault(), e.canSubmit && e.onPrimaryAction();
|
|
2626
2798
|
},
|
|
2627
2799
|
children: [
|
|
2628
|
-
/* @__PURE__ */
|
|
2629
|
-
/* @__PURE__ */
|
|
2630
|
-
|
|
2800
|
+
/* @__PURE__ */ p("div", { className: "aegis-swap-widget__panel", children: [
|
|
2801
|
+
/* @__PURE__ */ i(
|
|
2802
|
+
Un,
|
|
2631
2803
|
{
|
|
2632
2804
|
inputId: e.sellInputId,
|
|
2633
2805
|
label: "Sell",
|
|
@@ -2637,12 +2809,13 @@ function jr(t) {
|
|
|
2637
2809
|
invalid: e.sellInvalid,
|
|
2638
2810
|
busy: e.busy,
|
|
2639
2811
|
refreshEnabled: e.sellRefreshEnabled,
|
|
2812
|
+
refreshing: e.quoteLoading,
|
|
2640
2813
|
metadataByAddress: e.metadataByAddress,
|
|
2641
2814
|
onChange: e.onSellChange,
|
|
2642
2815
|
quickActions: { onHalf: e.onHalf, onMax: e.onMax }
|
|
2643
2816
|
}
|
|
2644
2817
|
),
|
|
2645
|
-
/* @__PURE__ */
|
|
2818
|
+
/* @__PURE__ */ i(
|
|
2646
2819
|
"button",
|
|
2647
2820
|
{
|
|
2648
2821
|
type: "button",
|
|
@@ -2651,11 +2824,11 @@ function jr(t) {
|
|
|
2651
2824
|
onClick: e.onFlipDirection,
|
|
2652
2825
|
disabled: !e.market || e.busy,
|
|
2653
2826
|
"aria-label": "Switch swap direction",
|
|
2654
|
-
children: /* @__PURE__ */
|
|
2827
|
+
children: /* @__PURE__ */ i(Ui, {})
|
|
2655
2828
|
}
|
|
2656
2829
|
),
|
|
2657
|
-
/* @__PURE__ */
|
|
2658
|
-
|
|
2830
|
+
/* @__PURE__ */ i(
|
|
2831
|
+
Un,
|
|
2659
2832
|
{
|
|
2660
2833
|
inputId: e.buyInputId,
|
|
2661
2834
|
label: "Buy",
|
|
@@ -2665,17 +2838,21 @@ function jr(t) {
|
|
|
2665
2838
|
invalid: e.buyInvalid,
|
|
2666
2839
|
busy: e.busy,
|
|
2667
2840
|
refreshEnabled: e.buyRefreshEnabled,
|
|
2841
|
+
refreshing: e.quoteLoading,
|
|
2668
2842
|
metadataByAddress: e.metadataByAddress,
|
|
2669
2843
|
onChange: e.onBuyChange
|
|
2670
2844
|
}
|
|
2671
2845
|
)
|
|
2672
2846
|
] }),
|
|
2673
|
-
e.showExecutionDetails ? /* @__PURE__ */
|
|
2674
|
-
|
|
2847
|
+
e.showExecutionDetails ? /* @__PURE__ */ i(
|
|
2848
|
+
_s,
|
|
2675
2849
|
{
|
|
2676
2850
|
open: e.executionDetailsOpen,
|
|
2677
2851
|
panelId: e.executionDetailsId,
|
|
2678
2852
|
onToggle: e.onToggleExecutionDetails,
|
|
2853
|
+
activeView: e.executionDetailsView,
|
|
2854
|
+
onViewChange: e.onExecutionDetailsViewChange,
|
|
2855
|
+
latestTxSummary: e.latestTxSummary,
|
|
2679
2856
|
rows: e.tradeDetailRows,
|
|
2680
2857
|
slippageInputId: e.slippageInputId,
|
|
2681
2858
|
slippageValue: e.slippageInput,
|
|
@@ -2699,7 +2876,7 @@ function jr(t) {
|
|
|
2699
2876
|
e.quoteError || e.actionError || e.allowanceError ? (
|
|
2700
2877
|
// Keyed on the message so a different error remounts and replays
|
|
2701
2878
|
// the shake; the same error staying up does not re-shake.
|
|
2702
|
-
/* @__PURE__ */
|
|
2879
|
+
/* @__PURE__ */ i(
|
|
2703
2880
|
"p",
|
|
2704
2881
|
{
|
|
2705
2882
|
className: "aegis-swap-widget__error",
|
|
@@ -2708,8 +2885,15 @@ function jr(t) {
|
|
|
2708
2885
|
},
|
|
2709
2886
|
e.quoteError ?? e.actionError ?? e.allowanceError
|
|
2710
2887
|
)
|
|
2888
|
+
) : e.approvalHint ? (
|
|
2889
|
+
// Aave-style caption to the CTA: names the exact wallet step the
|
|
2890
|
+
// user is about to take. Keyed so a phase change replays the enter.
|
|
2891
|
+
/* @__PURE__ */ p("p", { className: "aegis-swap-widget__hint", role: "note", children: [
|
|
2892
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__hint-icon", "aria-hidden": "true", children: /* @__PURE__ */ i(Xn, {}) }),
|
|
2893
|
+
e.approvalHint
|
|
2894
|
+
] }, e.approvalHint)
|
|
2711
2895
|
) : null,
|
|
2712
|
-
/* @__PURE__ */
|
|
2896
|
+
/* @__PURE__ */ i(
|
|
2713
2897
|
"button",
|
|
2714
2898
|
{
|
|
2715
2899
|
type: "submit",
|
|
@@ -2717,35 +2901,28 @@ function jr(t) {
|
|
|
2717
2901
|
disabled: !e.canSubmit,
|
|
2718
2902
|
"data-action": e.primaryAction,
|
|
2719
2903
|
"data-busy": e.busy || void 0,
|
|
2720
|
-
children: /* @__PURE__ */
|
|
2904
|
+
children: /* @__PURE__ */ i("span", { className: "aegis-swap-widget__submit-label", children: e.ctaLabel }, e.ctaLabel)
|
|
2721
2905
|
}
|
|
2722
2906
|
)
|
|
2723
2907
|
]
|
|
2724
2908
|
}
|
|
2725
2909
|
),
|
|
2726
|
-
e.
|
|
2727
|
-
/* @__PURE__ */ r("span", { className: "aegis-swap-widget__success-check", "aria-hidden": "true", children: /* @__PURE__ */ r(at, {}) }),
|
|
2728
|
-
"Swap complete · received ~",
|
|
2729
|
-
Ee(e.quote.amountOut, e.outputToken.decimals),
|
|
2730
|
-
" ",
|
|
2731
|
-
e.outputToken.symbol
|
|
2732
|
-
] }) : null,
|
|
2733
|
-
e.txHash && e.txExplorerHref ? /* @__PURE__ */ m(
|
|
2910
|
+
e.inlineTxExplorerHref ? /* @__PURE__ */ p(
|
|
2734
2911
|
"a",
|
|
2735
2912
|
{
|
|
2736
2913
|
className: "aegis-swap-widget__tx",
|
|
2737
|
-
href: e.
|
|
2914
|
+
href: e.inlineTxExplorerHref,
|
|
2738
2915
|
target: "_blank",
|
|
2739
2916
|
rel: "noreferrer",
|
|
2740
2917
|
children: [
|
|
2741
2918
|
"View transaction",
|
|
2742
|
-
/* @__PURE__ */
|
|
2919
|
+
/* @__PURE__ */ i(Tt, {})
|
|
2743
2920
|
]
|
|
2744
2921
|
}
|
|
2745
2922
|
) : null,
|
|
2746
|
-
/* @__PURE__ */
|
|
2747
|
-
/* @__PURE__ */
|
|
2748
|
-
/* @__PURE__ */
|
|
2923
|
+
/* @__PURE__ */ p("p", { className: "aegis-swap-widget__powered", children: [
|
|
2924
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__powered-prefix", children: "Powered by" }),
|
|
2925
|
+
/* @__PURE__ */ p(
|
|
2749
2926
|
"a",
|
|
2750
2927
|
{
|
|
2751
2928
|
className: "aegis-swap-widget__powered-link",
|
|
@@ -2753,8 +2930,8 @@ function jr(t) {
|
|
|
2753
2930
|
target: "_blank",
|
|
2754
2931
|
rel: "noreferrer",
|
|
2755
2932
|
children: [
|
|
2756
|
-
/* @__PURE__ */
|
|
2757
|
-
/* @__PURE__ */
|
|
2933
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__powered-mark", children: /* @__PURE__ */ i(ki, {}) }),
|
|
2934
|
+
/* @__PURE__ */ i("span", { className: "aegis-swap-widget__powered-brand", children: "AEGIS" })
|
|
2758
2935
|
]
|
|
2759
2936
|
}
|
|
2760
2937
|
)
|
|
@@ -2763,75 +2940,75 @@ function jr(t) {
|
|
|
2763
2940
|
}
|
|
2764
2941
|
);
|
|
2765
2942
|
}
|
|
2766
|
-
const
|
|
2943
|
+
const Rs = As;
|
|
2767
2944
|
export {
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2945
|
+
Bs as AEGIS_DYNAMIC_FEE_FLAG,
|
|
2946
|
+
Ii as AEGIS_SWAP_CHAINS,
|
|
2947
|
+
wn as AEGIS_SWAP_CHAIN_ID,
|
|
2948
|
+
ks as AEGIS_SWAP_DEFAULT_FEE_BPS,
|
|
2949
|
+
Ls as AEGIS_SWAP_DEFAULT_FEE_RECIPIENT,
|
|
2950
|
+
Fs as AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT,
|
|
2951
|
+
bn as AEGIS_SWAP_DEFAULT_POOL_IDS,
|
|
2952
|
+
Us as AEGIS_SWAP_DEFAULT_RPC_URLS,
|
|
2953
|
+
$s as AEGIS_SWAP_HOOK,
|
|
2954
|
+
Ws as AEGIS_SWAP_MAINNET_CHAIN,
|
|
2955
|
+
Hs as AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS,
|
|
2956
|
+
Ai as AEGIS_SWAP_MARKETS,
|
|
2957
|
+
Vs as AEGIS_SWAP_PERMIT2,
|
|
2958
|
+
qs as AEGIS_SWAP_ROUTER,
|
|
2959
|
+
yn as AEGIS_SWAP_TOKENS,
|
|
2960
|
+
Gs as AEGIS_SWAP_V4_QUOTER,
|
|
2961
|
+
As as AegisDirectSwapWidget,
|
|
2962
|
+
Ss as AegisSwapProgressRail,
|
|
2963
|
+
Ms as AegisSwapToaster,
|
|
2964
|
+
Rs as AegisSwapWidget,
|
|
2965
|
+
li as DEFAULT_PERMIT_EXPIRATION_SECONDS,
|
|
2966
|
+
zs as MAX_UINT128,
|
|
2967
|
+
Ks as MAX_UINT160,
|
|
2968
|
+
js as MAX_UINT256,
|
|
2969
|
+
Xs as PERMIT2_FAR_FUTURE_EXPIRATION,
|
|
2970
|
+
Wn as SWAP_TX_DEADLINE_SECONDS,
|
|
2971
|
+
Ys as UNISWAP_V4_CONTRACTS_BY_CHAIN,
|
|
2972
|
+
ye as aegisToast,
|
|
2973
|
+
hi as approveErc20ToPermit2,
|
|
2974
|
+
oi as approvePermit2ToRouter,
|
|
2975
|
+
Qs as assertUint128,
|
|
2976
|
+
di as buildExactInSwapTransaction,
|
|
2977
|
+
ui as buildExactOutSwapTransaction,
|
|
2978
|
+
ri as buildSignedPermitBatch,
|
|
2979
|
+
Zs as computePoolId,
|
|
2980
|
+
Js as createAegisSwapChainConfig,
|
|
2981
|
+
_i as createAegisSwapChains,
|
|
2982
|
+
Si as createAegisSwapMarketsFromPools,
|
|
2983
|
+
eo as createAegisSwapPoolMarket,
|
|
2984
|
+
to as createAegisSwapUniswapV4Contracts,
|
|
2985
|
+
Ei as createSwapPublicClient,
|
|
2986
|
+
As as default,
|
|
2987
|
+
Ne as errorMessage,
|
|
2988
|
+
Vn as fetchDirectSwapQuote,
|
|
2989
|
+
mi as fetchGlobalTokenMetadata,
|
|
2990
|
+
qn as getExplorerUrl,
|
|
2991
|
+
no as getIchiIconGuess,
|
|
2992
|
+
St as getInjectedProvider,
|
|
2993
|
+
vi as getProviderAccount,
|
|
2994
|
+
qe as getProviderChainId,
|
|
2995
|
+
ao as getZeroForOne,
|
|
2996
|
+
$n as isBusy,
|
|
2997
|
+
Ve as isDocumentVisible,
|
|
2998
|
+
io as isEip1193Provider,
|
|
2999
|
+
si as isUserRejectedError,
|
|
3000
|
+
xi as normalizeAccount,
|
|
3001
|
+
bi as normalizeWalletConnection,
|
|
3002
|
+
ci as outputFeeForQuote,
|
|
3003
|
+
Gn as pollUntil,
|
|
3004
|
+
Nt as quoteSpendAmount,
|
|
3005
|
+
Hn as readPermit2RouterAllowance,
|
|
3006
|
+
fi as reconcileSubmitQuote,
|
|
3007
|
+
yi as requestProviderAccount,
|
|
3008
|
+
ai as resolveTokenIconUrl,
|
|
3009
|
+
mn as retryOnError,
|
|
3010
|
+
gi as sameQuote,
|
|
3011
|
+
wi as subscribeProvider,
|
|
3012
|
+
pi as switchProviderChain,
|
|
3013
|
+
Ni as transactionProgressView
|
|
2837
3014
|
};
|