@deloraprotocol/widget 1.0.1 → 1.0.2

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/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- var ut = Object.defineProperty;
2
- var He = (t) => {
3
- throw TypeError(t);
1
+ var kt = Object.defineProperty;
2
+ var Ye = (e) => {
3
+ throw TypeError(e);
4
4
  };
5
- var ft = (t, e, n) => e in t ? ut(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
6
- var Ce = (t, e, n) => ft(t, typeof e != "symbol" ? e + "" : e, n), Ie = (t, e, n) => e.has(t) || He("Cannot " + n);
7
- var b = (t, e, n) => (Ie(t, e, "read from private field"), n ? n.call(t) : e.get(t)), ge = (t, e, n) => e.has(t) ? He("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), ye = (t, e, n, r) => (Ie(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n), E = (t, e, n) => (Ie(t, e, "access private method"), n);
8
- import { jsxs as A, jsx as d, Fragment as ht } from "react/jsx-runtime";
9
- import { useState as U, useEffect as oe, useCallback as D, useRef as se, useLayoutEffect as pt, useMemo as ie } from "react";
10
- const mt = {
5
+ var bt = (e, t, n) => t in e ? kt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
6
+ var Fe = (e, t, n) => bt(e, typeof t != "symbol" ? t + "" : t, n), Re = (e, t, n) => t.has(e) || Ye("Cannot " + n);
7
+ var x = (e, t, n) => (Re(e, t, "read from private field"), n ? n.call(e) : t.get(e)), Ne = (e, t, n) => t.has(e) ? Ye("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), Te = (e, t, n, r) => (Re(e, t, "write to private field"), r ? r.call(e, n) : t.set(e, n), n), j = (e, t, n) => (Re(e, t, "access private method"), n);
8
+ import { jsxs as A, jsx as d, Fragment as xt } from "react/jsx-runtime";
9
+ import { useState as B, useRef as X, useMemo as ue, useEffect as re, useCallback as M, useLayoutEffect as yt } from "react";
10
+ const At = {
11
11
  bg: "#ffffff",
12
12
  fg: "#111216",
13
13
  accent: "#7ca7f5",
@@ -27,7 +27,7 @@ const mt = {
27
27
  fontSize: "13px",
28
28
  lineHeight: "1.2",
29
29
  letterSpacing: "-0.05em"
30
- }, gt = {
30
+ }, vt = {
31
31
  bg: "#090909",
32
32
  fg: "#ffffff",
33
33
  accent: "#7ca7f5",
@@ -47,14 +47,14 @@ const mt = {
47
47
  fontSize: "13px",
48
48
  lineHeight: "1.2",
49
49
  letterSpacing: "-0.05em"
50
- }, bt = {
51
- light: mt,
52
- dark: gt
50
+ }, Nt = {
51
+ light: At,
52
+ dark: vt
53
53
  };
54
- function et(t, e) {
55
- return { ...bt[t], ...e };
54
+ function dt(e, t) {
55
+ return { ...Nt[e], ...t };
56
56
  }
57
- const xt = {
57
+ const St = {
58
58
  bg: "--dw-bg",
59
59
  fg: "--dw-fg",
60
60
  accent: "--dw-accent",
@@ -75,23 +75,23 @@ const xt = {
75
75
  lineHeight: "--dw-line-height",
76
76
  letterSpacing: "--dw-letter-spacing"
77
77
  };
78
- function tt(t) {
79
- const e = {};
80
- for (const [n, r] of Object.entries(t)) {
81
- const s = xt[n];
82
- s && r != null && (e[s] = r);
78
+ function lt(e) {
79
+ const t = {};
80
+ for (const [n, r] of Object.entries(e)) {
81
+ const s = St[n];
82
+ s && r != null && (t[s] = r);
83
83
  }
84
- return e;
84
+ return t;
85
85
  }
86
- function mn(t) {
86
+ function An(e) {
87
87
  const {
88
- theme: e = "light",
88
+ theme: t = "light",
89
89
  vars: n,
90
90
  className: r,
91
91
  style: s,
92
- ...a
93
- } = t, i = et(e, n), h = {
94
- ...tt(i),
92
+ ...l
93
+ } = e, i = dt(t, n), p = {
94
+ ...lt(i),
95
95
  ...s
96
96
  };
97
97
  return /* @__PURE__ */ A(
@@ -99,8 +99,8 @@ function mn(t) {
99
99
  {
100
100
  "data-delora-widget-root": !0,
101
101
  className: `dw-flex dw-flex-col dw-gap-3 dw-rounded-[var(--dw-radius)] dw-border dw-border-[var(--dw-border)] dw-bg-[var(--dw-bg)] dw-p-4 dw-shadow-sm ${r ?? ""}`,
102
- style: h,
103
- ...a,
102
+ style: p,
103
+ ...l,
104
104
  children: [
105
105
  /* @__PURE__ */ d("h3", { className: "dw-text-base dw-font-semibold dw-text-[var(--dw-fg)]", children: "Delora" }),
106
106
  /* @__PURE__ */ d("p", { className: "dw-text-sm dw-text-[var(--dw-muted)]", children: "A simple widget with theme support." }),
@@ -116,534 +116,633 @@ function mn(t) {
116
116
  }
117
117
  );
118
118
  }
119
- const ke = "https://api.delora.build", nt = "0x1111111111111111111111111111111111111111", rt = "11111111111111111111111111111111", ot = "1111111111111111111111111111111111111111111111111111111111111111";
120
- function st(t) {
121
- return (t || ke).replace(/\/$/, "");
119
+ const Be = "https://api.delora.build", at = "0x1111111111111111111111111111111111111111", it = "11111111111111111111111111111111", ct = "1111111111111111111111111111111111111111111111111111111111111111";
120
+ function wt(e) {
121
+ return (e || Be).replace(/\/$/, "");
122
122
  }
123
- function At(t, e, n) {
124
- if (!t) return;
125
- const r = t.replace(/\/+$/, "");
126
- return r.includes("/token/") || r.includes("/coin/") ? `${r}/` : e === "MVM" || n === "sui" ? `${r}/coin/` : `${r}/token/`;
123
+ function Ct(e, t, n) {
124
+ if (!e) return;
125
+ const r = e.replace(/\/+$/, "");
126
+ return r.includes("/token/") || r.includes("/coin/") ? `${r}/` : t === "MVM" || n === "sui" ? `${r}/coin/` : `${r}/token/`;
127
127
  }
128
- function vt(t) {
129
- var e, n, r;
128
+ function It(e) {
129
+ var t, n, r;
130
130
  return {
131
- id: t.id,
132
- name: t.name,
133
- rpcUrls: t.rpcUrls ?? [],
134
- logoURI: t.logoURI,
135
- idHex: t.idHex,
136
- chainType: t.chainType,
137
- explorerUrl: At(
138
- t.blockExplorerUrls,
139
- t.chainType,
140
- t.key
131
+ id: e.id,
132
+ name: e.name,
133
+ rpcUrls: e.rpcUrls ?? [],
134
+ logoURI: e.logoURI,
135
+ idHex: e.idHex,
136
+ chainType: e.chainType,
137
+ explorerUrl: Ct(
138
+ e.blockExplorerUrls,
139
+ e.chainType,
140
+ e.key
141
141
  ),
142
- key: t.key,
142
+ key: e.key,
143
143
  nativeCurrency: {
144
- name: ((e = t.nativeToken) == null ? void 0 : e.name) ?? t.name,
145
- symbol: ((n = t.nativeToken) == null ? void 0 : n.symbol) ?? "",
146
- decimals: ((r = t.nativeToken) == null ? void 0 : r.decimals) ?? 18
144
+ name: ((t = e.nativeToken) == null ? void 0 : t.name) ?? e.name,
145
+ symbol: ((n = e.nativeToken) == null ? void 0 : n.symbol) ?? "",
146
+ decimals: ((r = e.nativeToken) == null ? void 0 : r.decimals) ?? 18
147
147
  }
148
148
  };
149
149
  }
150
- function yt(t) {
150
+ function Tt(e) {
151
151
  return {
152
- symbol: t.symbol,
153
- name: t.name,
154
- contractAddress: t.address,
155
- chainId: t.chainId,
156
- imageUrl: t.logoURI ?? "",
157
- decimals: t.decimals,
158
- priceUSD: t.priceUSD
152
+ symbol: e.symbol,
153
+ name: e.name,
154
+ contractAddress: e.address,
155
+ chainId: e.chainId,
156
+ imageUrl: e.logoURI ?? "",
157
+ decimals: e.decimals,
158
+ priceUSD: e.priceUSD
159
159
  };
160
160
  }
161
- async function kt(t) {
162
- const e = st(t), n = await fetch(`${e}/v1/chains`);
161
+ async function Bt(e) {
162
+ const t = wt(e), n = await fetch(`${t}/v1/chains`);
163
163
  if (!n.ok) throw new Error(`Failed to fetch networks: ${n.status}`);
164
- return ((await n.json()).chains ?? []).map(vt);
164
+ return ((await n.json()).chains ?? []).map(It);
165
165
  }
166
- async function Nt(t) {
167
- const e = st(t), n = await fetch(`${e}/v1/tokens`);
166
+ async function Ut(e) {
167
+ const t = wt(e), n = await fetch(`${t}/v1/tokens`);
168
168
  if (!n.ok) throw new Error(`Failed to fetch tokens: ${n.status}`);
169
169
  return { byChainId: await n.json() };
170
170
  }
171
- function ae(t, e) {
172
- const n = String(e);
173
- return (t.byChainId[n] ?? []).map(yt);
171
+ function ke(e, t) {
172
+ const n = String(t);
173
+ return (e.byChainId[n] ?? []).map(Tt);
174
+ }
175
+ function Ft(e, t) {
176
+ return ke(e, t);
177
+ }
178
+ function Rt(e) {
179
+ const t = "0x0000000000000000000000000000000000000000", n = "11111111111111111111111111111111", r = "1111111111111111111111111111111111111111111111111111111111111111";
180
+ return e.find(
181
+ (s) => s.contractAddress === t || s.contractAddress === n || s.contractAddress === r
182
+ ) ?? e[0];
174
183
  }
175
- function St(t, e) {
176
- return ae(t, e);
184
+ function Je(e) {
185
+ return e.startsWith("0x");
177
186
  }
178
- function Ct(t) {
179
- const e = "0x0000000000000000000000000000000000000000", n = "11111111111111111111111111111111", r = "1111111111111111111111111111111111111111111111111111111111111111";
180
- return t.find(
181
- (s) => s.contractAddress === e || s.contractAddress === n || s.contractAddress === r
182
- ) ?? t[0];
187
+ function Et(e, t) {
188
+ return Je(e) || Je(t) ? e.toLowerCase() === t.toLowerCase() : e === t;
183
189
  }
184
- function It(t) {
185
- const [e, n] = U([]), [r, s] = U(null), [a, i] = U(null), [w, h] = U(!0), [p, k] = U(null), [x, m] = U(), [u, v] = U(), [o, M] = U(), [R, O] = U();
186
- oe(() => {
187
- let c = !1;
188
- return h(!0), k(null), Promise.all([kt(t.apiBase), Nt(t.apiBase)]).then(([f, S]) => {
189
- c || (n(f), s(S), i(S), f.length >= 2 ? (m(f[0]), v(f[1])) : f.length === 1 && (m(f[0]), v(f[0])));
190
- }).catch((f) => {
191
- c || k((f == null ? void 0 : f.message) ?? "Failed to load data");
190
+ function Ge(e, t) {
191
+ if (t)
192
+ return e.find(
193
+ (n) => n.chainId === t.chainId && Et(n.contractAddress, t.address)
194
+ );
195
+ }
196
+ function Lt(e) {
197
+ const [t, n] = B([]), [r, s] = B(null), [l, i] = B(
198
+ null
199
+ ), [u, p] = B(!0), [g, C] = B(null), [I, k] = B(), [m, y] = B(), [v, $] = B(), [D, T] = B(), O = X(""), K = X(""), q = X(""), L = X(""), c = X(/* @__PURE__ */ new Set()), h = !!(e.lockSellNetwork || e.lockSellToken), b = !!(e.lockBuyNetwork || e.lockBuyToken), N = ue(
200
+ () => {
201
+ var w;
202
+ return e.initialSellNetworkId ?? ((w = e.initialSellToken) == null ? void 0 : w.chainId);
203
+ },
204
+ [e.initialSellNetworkId, e.initialSellToken]
205
+ ), o = ue(
206
+ () => {
207
+ var w;
208
+ return e.initialBuyNetworkId ?? ((w = e.initialBuyToken) == null ? void 0 : w.chainId);
209
+ },
210
+ [e.initialBuyNetworkId, e.initialBuyToken]
211
+ );
212
+ re(() => {
213
+ let w = !1;
214
+ return p(!0), C(null), Promise.all([Bt(e.apiBase), Ut(e.apiBase)]).then(([a, S]) => {
215
+ w || (n(a), s(S), i(S), a.length >= 2 ? (k(a[0]), y(a[1])) : a.length === 1 && (k(a[0]), y(a[0])));
216
+ }).catch((a) => {
217
+ var W;
218
+ if (w) return;
219
+ const S = (a == null ? void 0 : a.message) ?? "Failed to load data";
220
+ C(S), (W = e.onError) == null || W.call(e, {
221
+ source: "metadata",
222
+ message: S,
223
+ status: a == null ? void 0 : a.status,
224
+ statusCode: a == null ? void 0 : a.statusCode,
225
+ error: a
226
+ });
192
227
  }).finally(() => {
193
- c || h(!1);
228
+ w || p(!1);
194
229
  }), () => {
195
- c = !0;
230
+ w = !0;
196
231
  };
197
- }, [t.apiBase]), oe(() => {
198
- if (!x || !r) return;
199
- const c = ae(r, x.id);
200
- (c.length && !o || o && !c.some((f) => f.contractAddress === o.contractAddress && f.chainId === o.chainId)) && M(c[0]);
201
- }, [x, r, o]), oe(() => {
202
- if (!u || !r) return;
203
- const c = ae(r, u.id);
204
- if (c.length && !R) {
205
- const f = o ? c.find((S) => !(S.contractAddress === o.contractAddress && S.chainId === o.chainId)) : void 0;
206
- O(f ?? c[0]);
207
- } else if (R && !c.some((f) => f.contractAddress === R.contractAddress && f.chainId === R.chainId)) {
208
- const f = o ? c.find((S) => !(S.contractAddress === o.contractAddress && S.chainId === o.chainId)) : void 0;
209
- O(f ?? c[0]);
232
+ }, [e.apiBase, e.onError]), re(() => {
233
+ if (!t.length || !N) return;
234
+ const w = String(N);
235
+ if (O.current === w) return;
236
+ const a = t.find((S) => S.id === N);
237
+ a && (k(a), O.current = w);
238
+ }, [N, t]), re(() => {
239
+ if (!t.length || !o) return;
240
+ const w = String(o);
241
+ if (K.current === w) return;
242
+ const a = t.find((S) => S.id === o);
243
+ a && (y(a), K.current = w);
244
+ }, [o, t]), re(() => {
245
+ var W;
246
+ if (!I || !r) return;
247
+ const w = ke(r, I.id), a = e.initialSellToken ? `${e.initialSellToken.chainId}:${e.initialSellToken.address}` : "", S = Ge(w, e.initialSellToken);
248
+ if (S && q.current !== a) {
249
+ $(S), q.current = a;
250
+ return;
251
+ }
252
+ e.initialSellToken && !S && !c.current.has(`sell:${a}`) && (c.current.add(`sell:${a}`), (W = e.onError) == null || W.call(e, {
253
+ source: "selection",
254
+ message: `Initial sell token ${e.initialSellToken.address} was not found on chain ${e.initialSellToken.chainId}`
255
+ })), (w.length && !v || v && !w.some(
256
+ (Q) => Q.contractAddress === v.contractAddress && Q.chainId === v.chainId
257
+ )) && $(w[0]);
258
+ }, [e.initialSellToken, e.onError, I, v, r]), re(() => {
259
+ var W;
260
+ if (!m || !r) return;
261
+ const w = ke(r, m.id), a = e.initialBuyToken ? `${e.initialBuyToken.chainId}:${e.initialBuyToken.address}` : "", S = Ge(w, e.initialBuyToken);
262
+ if (S && L.current !== a) {
263
+ T(S), L.current = a;
264
+ return;
265
+ }
266
+ if (e.initialBuyToken && !S && !c.current.has(`buy:${a}`) && (c.current.add(`buy:${a}`), (W = e.onError) == null || W.call(e, {
267
+ source: "selection",
268
+ message: `Initial buy token ${e.initialBuyToken.address} was not found on chain ${e.initialBuyToken.chainId}`
269
+ })), w.length && !D) {
270
+ const Q = v ? w.find(
271
+ (z) => !(z.contractAddress === v.contractAddress && z.chainId === v.chainId)
272
+ ) : void 0;
273
+ T(Q ?? w[0]);
274
+ } else if (D && !w.some(
275
+ (Q) => Q.contractAddress === D.contractAddress && Q.chainId === D.chainId
276
+ )) {
277
+ const Q = v ? w.find(
278
+ (z) => !(z.contractAddress === v.contractAddress && z.chainId === v.chainId)
279
+ ) : void 0;
280
+ T(Q ?? w[0]);
210
281
  }
211
- }, [u, r, R, o]);
212
- const L = D(
213
- (c) => r ? ae(r, c) : [],
282
+ }, [D, e.initialBuyToken, e.onError, m, v, r]);
283
+ const E = M(
284
+ (w) => r ? ke(r, w) : [],
214
285
  [r]
215
- ), V = D(
216
- (c) => a ? St(a, c) : ae(r ?? { byChainId: {} }, c),
217
- [a, r]
218
- ), $ = D(
219
- (c) => {
220
- const f = ae(r ?? { byChainId: {} }, c);
221
- return Ct(f);
286
+ ), V = M(
287
+ (w) => l ? Ft(l, w) : ke(r ?? { byChainId: {} }, w),
288
+ [l, r]
289
+ ), J = M(
290
+ (w) => {
291
+ const a = ke(r ?? { byChainId: {} }, w);
292
+ return Rt(a);
222
293
  },
223
294
  [r]
224
- ), l = D(
225
- (c) => e.find((f) => f.id === c),
226
- [e]
227
- ), C = D((c) => {
228
- const f = e.find((S) => S.id === c);
229
- f && m(f);
230
- }, [e]), g = D((c) => {
231
- const f = e.find((S) => S.id === c);
232
- f && v(f);
233
- }, [e]), y = D((c) => {
234
- v(c);
235
- }, []);
295
+ ), G = M(
296
+ (w) => t.find((a) => a.id === w),
297
+ [t]
298
+ ), ie = M(
299
+ (w) => {
300
+ if (h) return;
301
+ const a = t.find((S) => S.id === w);
302
+ a && k(a);
303
+ },
304
+ [t, h]
305
+ ), fe = M(
306
+ (w) => {
307
+ if (b) return;
308
+ const a = t.find((S) => S.id === w);
309
+ a && y(a);
310
+ },
311
+ [b, t]
312
+ ), ee = M(
313
+ (w) => {
314
+ h || k(w);
315
+ },
316
+ [h]
317
+ ), ce = M(
318
+ (w) => {
319
+ b || y(w);
320
+ },
321
+ [b]
322
+ ), de = M(
323
+ (w) => {
324
+ e.lockSellToken || $(w);
325
+ },
326
+ [e.lockSellToken]
327
+ ), oe = M(
328
+ (w) => {
329
+ e.lockBuyToken || T(w);
330
+ },
331
+ [e.lockBuyToken]
332
+ );
236
333
  return {
237
- networks: e,
238
- networkSell: x,
239
- networkBuy: u,
240
- sellToken: o,
241
- buyToken: R,
242
- setSellToken: M,
243
- setBuyToken: O,
244
- setNetworkSell: (c) => m(c),
245
- setNetworkBuy: y,
246
- updateNetworkSell: C,
247
- updateNetworkBuy: g,
248
- getTokensForNetworkId: L,
334
+ networks: t,
335
+ networkSell: I,
336
+ networkBuy: m,
337
+ sellToken: v,
338
+ buyToken: D,
339
+ setSellToken: de,
340
+ setBuyToken: oe,
341
+ setNetworkSell: ee,
342
+ setNetworkBuy: ce,
343
+ updateNetworkSell: ie,
344
+ updateNetworkBuy: fe,
345
+ getTokensForNetworkId: E,
249
346
  getAllTokensForNetworkId: V,
250
- getNativeToken: $,
251
- getNetworkById: l,
252
- loading: w,
253
- error: p
347
+ getNativeToken: J,
348
+ getNetworkById: G,
349
+ sellNetworkLocked: h,
350
+ buyNetworkLocked: b,
351
+ loading: u,
352
+ error: g
254
353
  };
255
354
  }
256
- const Bt = "6.16.0";
257
- function Ee(t, e, n) {
258
- for (let r in e) {
259
- let s = e[r];
260
- Object.defineProperty(t, r, { enumerable: !0, value: s, writable: !1 });
355
+ const Mt = "6.16.0";
356
+ function Pe(e, t, n) {
357
+ for (let r in t) {
358
+ let s = t[r];
359
+ Object.defineProperty(e, r, { enumerable: !0, value: s, writable: !1 });
261
360
  }
262
361
  }
263
- function le(t, e) {
264
- if (t == null)
362
+ function be(e, t) {
363
+ if (e == null)
265
364
  return "null";
266
- if (e == null && (e = /* @__PURE__ */ new Set()), typeof t == "object") {
267
- if (e.has(t))
365
+ if (t == null && (t = /* @__PURE__ */ new Set()), typeof e == "object") {
366
+ if (t.has(e))
268
367
  return "[Circular]";
269
- e.add(t);
368
+ t.add(e);
270
369
  }
271
- if (Array.isArray(t))
272
- return "[ " + t.map((n) => le(n, e)).join(", ") + " ]";
273
- if (t instanceof Uint8Array) {
370
+ if (Array.isArray(e))
371
+ return "[ " + e.map((n) => be(n, t)).join(", ") + " ]";
372
+ if (e instanceof Uint8Array) {
274
373
  const n = "0123456789abcdef";
275
374
  let r = "0x";
276
- for (let s = 0; s < t.length; s++)
277
- r += n[t[s] >> 4], r += n[t[s] & 15];
375
+ for (let s = 0; s < e.length; s++)
376
+ r += n[e[s] >> 4], r += n[e[s] & 15];
278
377
  return r;
279
378
  }
280
- if (typeof t == "object" && typeof t.toJSON == "function")
281
- return le(t.toJSON(), e);
282
- switch (typeof t) {
379
+ if (typeof e == "object" && typeof e.toJSON == "function")
380
+ return be(e.toJSON(), t);
381
+ switch (typeof e) {
283
382
  case "boolean":
284
383
  case "number":
285
384
  case "symbol":
286
- return t.toString();
385
+ return e.toString();
287
386
  case "bigint":
288
- return BigInt(t).toString();
387
+ return BigInt(e).toString();
289
388
  case "string":
290
- return JSON.stringify(t);
389
+ return JSON.stringify(e);
291
390
  case "object": {
292
- const n = Object.keys(t);
293
- return n.sort(), "{ " + n.map((r) => `${le(r, e)}: ${le(t[r], e)}`).join(", ") + " }";
391
+ const n = Object.keys(e);
392
+ return n.sort(), "{ " + n.map((r) => `${be(r, t)}: ${be(e[r], t)}`).join(", ") + " }";
294
393
  }
295
394
  }
296
395
  return "[ COULD NOT SERIALIZE ]";
297
396
  }
298
- function Tt(t, e, n) {
299
- let r = t;
397
+ function $t(e, t, n) {
398
+ let r = e;
300
399
  {
301
- const a = [];
400
+ const l = [];
302
401
  if (n) {
303
402
  if ("message" in n || "code" in n || "name" in n)
304
- throw new Error(`value will overwrite populated values: ${le(n)}`);
403
+ throw new Error(`value will overwrite populated values: ${be(n)}`);
305
404
  for (const i in n) {
306
405
  if (i === "shortMessage")
307
406
  continue;
308
- const w = n[i];
309
- a.push(i + "=" + le(w));
407
+ const u = n[i];
408
+ l.push(i + "=" + be(u));
310
409
  }
311
410
  }
312
- a.push(`code=${e}`), a.push(`version=${Bt}`), a.length && (t += " (" + a.join(", ") + ")");
411
+ l.push(`code=${t}`), l.push(`version=${Mt}`), l.length && (e += " (" + l.join(", ") + ")");
313
412
  }
314
413
  let s;
315
- switch (e) {
414
+ switch (t) {
316
415
  case "INVALID_ARGUMENT":
317
- s = new TypeError(t);
416
+ s = new TypeError(e);
318
417
  break;
319
418
  case "NUMERIC_FAULT":
320
419
  case "BUFFER_OVERRUN":
321
- s = new RangeError(t);
420
+ s = new RangeError(e);
322
421
  break;
323
422
  default:
324
- s = new Error(t);
423
+ s = new Error(e);
325
424
  }
326
- return Ee(s, { code: e }), n && Object.assign(s, n), s.shortMessage == null && Ee(s, { shortMessage: r }), s;
425
+ return Pe(s, { code: t }), n && Object.assign(s, n), s.shortMessage == null && Pe(s, { shortMessage: r }), s;
327
426
  }
328
- function z(t, e, n, r) {
329
- if (!t)
330
- throw Tt(e, n, r);
427
+ function Z(e, t, n, r) {
428
+ if (!e)
429
+ throw $t(t, n, r);
331
430
  }
332
- function j(t, e, n, r) {
333
- z(t, e, "INVALID_ARGUMENT", { argument: n, value: r });
431
+ function H(e, t, n, r) {
432
+ Z(e, t, "INVALID_ARGUMENT", { argument: n, value: r });
334
433
  }
335
- ["NFD", "NFC", "NFKD", "NFKC"].reduce((t, e) => {
434
+ ["NFD", "NFC", "NFKD", "NFKC"].reduce((e, t) => {
336
435
  try {
337
- if ("test".normalize(e) !== "test")
436
+ if ("test".normalize(t) !== "test")
338
437
  throw new Error("bad");
339
- if (e === "NFD" && "é".normalize("NFD") !== "é")
438
+ if (t === "NFD" && "é".normalize("NFD") !== "é")
340
439
  throw new Error("broken");
341
- t.push(e);
440
+ e.push(t);
342
441
  } catch {
343
442
  }
344
- return t;
443
+ return e;
345
444
  }, []);
346
- function Ut(t, e, n) {
347
- if (t !== e) {
445
+ function Dt(e, t, n) {
446
+ if (e !== t) {
348
447
  let r = n, s = "new";
349
- r += ".", s += " " + n, z(!1, `private constructor; use ${r}from* methods`, "UNSUPPORTED_OPERATION", {
448
+ r += ".", s += " " + n, Z(!1, `private constructor; use ${r}from* methods`, "UNSUPPORTED_OPERATION", {
350
449
  operation: s
351
450
  });
352
451
  }
353
452
  }
354
- function Ft(t, e, n) {
355
- if (t instanceof Uint8Array)
356
- return t;
357
- if (typeof t == "string" && t.length % 2 === 0 && t.match(/^0x[0-9a-f]*$/i)) {
358
- const r = new Uint8Array((t.length - 2) / 2);
453
+ function Ot(e, t, n) {
454
+ if (e instanceof Uint8Array)
455
+ return e;
456
+ if (typeof e == "string" && e.length % 2 === 0 && e.match(/^0x[0-9a-f]*$/i)) {
457
+ const r = new Uint8Array((e.length - 2) / 2);
359
458
  let s = 2;
360
- for (let a = 0; a < r.length; a++)
361
- r[a] = parseInt(t.substring(s, s + 2), 16), s += 2;
459
+ for (let l = 0; l < r.length; l++)
460
+ r[l] = parseInt(e.substring(s, s + 2), 16), s += 2;
362
461
  return r;
363
462
  }
364
- j(!1, "invalid BytesLike value", e, t);
463
+ H(!1, "invalid BytesLike value", t, e);
365
464
  }
366
- function Rt(t, e) {
367
- return Ft(t, e);
465
+ function Pt(e, t) {
466
+ return Ot(e, t);
368
467
  }
369
- const dt = BigInt(0), ce = BigInt(1), we = 9007199254740991;
370
- function Le(t, e) {
371
- const n = at(t, "value"), r = BigInt(Ae(e, "width"));
372
- if (z(n >> r === dt, "overflow", "NUMERIC_FAULT", {
468
+ const ut = BigInt(0), xe = BigInt(1), ye = 9007199254740991;
469
+ function je(e, t) {
470
+ const n = ft(e, "value"), r = BigInt(Ie(t, "width"));
471
+ if (Z(n >> r === ut, "overflow", "NUMERIC_FAULT", {
373
472
  operation: "fromTwos",
374
473
  fault: "overflow",
375
- value: t
376
- }), n >> r - ce) {
377
- const s = (ce << r) - ce;
378
- return -((~n & s) + ce);
474
+ value: e
475
+ }), n >> r - xe) {
476
+ const s = (xe << r) - xe;
477
+ return -((~n & s) + xe);
379
478
  }
380
479
  return n;
381
480
  }
382
- function ze(t, e) {
383
- const n = at(t, "value"), r = BigInt(Ae(e, "bits"));
384
- return n & (ce << r) - ce;
481
+ function _e(e, t) {
482
+ const n = ft(e, "value"), r = BigInt(Ie(t, "bits"));
483
+ return n & (xe << r) - xe;
385
484
  }
386
- function Ve(t, e) {
387
- switch (typeof t) {
485
+ function Ke(e, t) {
486
+ switch (typeof e) {
388
487
  case "bigint":
389
- return t;
488
+ return e;
390
489
  case "number":
391
- return j(Number.isInteger(t), "underflow", e || "value", t), j(t >= -we && t <= we, "overflow", e || "value", t), BigInt(t);
490
+ return H(Number.isInteger(e), "underflow", t || "value", e), H(e >= -ye && e <= ye, "overflow", t || "value", e), BigInt(e);
392
491
  case "string":
393
492
  try {
394
- if (t === "")
493
+ if (e === "")
395
494
  throw new Error("empty string");
396
- return t[0] === "-" && t[1] !== "-" ? -BigInt(t.substring(1)) : BigInt(t);
495
+ return e[0] === "-" && e[1] !== "-" ? -BigInt(e.substring(1)) : BigInt(e);
397
496
  } catch (n) {
398
- j(!1, `invalid BigNumberish string: ${n.message}`, e || "value", t);
497
+ H(!1, `invalid BigNumberish string: ${n.message}`, t || "value", e);
399
498
  }
400
499
  }
401
- j(!1, "invalid BigNumberish value", e || "value", t);
500
+ H(!1, "invalid BigNumberish value", t || "value", e);
402
501
  }
403
- function at(t, e) {
404
- const n = Ve(t, e);
405
- return z(n >= dt, "unsigned value cannot be negative", "NUMERIC_FAULT", {
502
+ function ft(e, t) {
503
+ const n = Ke(e, t);
504
+ return Z(n >= ut, "unsigned value cannot be negative", "NUMERIC_FAULT", {
406
505
  fault: "overflow",
407
506
  operation: "getUint",
408
- value: t
507
+ value: e
409
508
  }), n;
410
509
  }
411
- const Ye = "0123456789abcdef";
412
- function Mt(t) {
413
- if (t instanceof Uint8Array) {
414
- let e = "0x0";
415
- for (const n of t)
416
- e += Ye[n >> 4], e += Ye[n & 15];
417
- return BigInt(e);
510
+ const Xe = "0123456789abcdef";
511
+ function jt(e) {
512
+ if (e instanceof Uint8Array) {
513
+ let t = "0x0";
514
+ for (const n of e)
515
+ t += Xe[n >> 4], t += Xe[n & 15];
516
+ return BigInt(t);
418
517
  }
419
- return Ve(t);
518
+ return Ke(e);
420
519
  }
421
- function Ae(t, e) {
422
- switch (typeof t) {
520
+ function Ie(e, t) {
521
+ switch (typeof e) {
423
522
  case "bigint":
424
- return j(t >= -we && t <= we, "overflow", e || "value", t), Number(t);
523
+ return H(e >= -ye && e <= ye, "overflow", t || "value", e), Number(e);
425
524
  case "number":
426
- return j(Number.isInteger(t), "underflow", e || "value", t), j(t >= -we && t <= we, "overflow", e || "value", t), t;
525
+ return H(Number.isInteger(e), "underflow", t || "value", e), H(e >= -ye && e <= ye, "overflow", t || "value", e), e;
427
526
  case "string":
428
527
  try {
429
- if (t === "")
528
+ if (e === "")
430
529
  throw new Error("empty string");
431
- return Ae(BigInt(t), e);
530
+ return Ie(BigInt(e), t);
432
531
  } catch (n) {
433
- j(!1, `invalid numeric string: ${n.message}`, e || "value", t);
532
+ H(!1, `invalid numeric string: ${n.message}`, t || "value", e);
434
533
  }
435
534
  }
436
- j(!1, "invalid numeric value", e || "value", t);
535
+ H(!1, "invalid numeric value", t || "value", e);
437
536
  }
438
- const Et = BigInt(-1), K = BigInt(0), ue = BigInt(1), Lt = BigInt(5), de = {};
439
- let fe = "0000";
440
- for (; fe.length < 80; )
441
- fe += fe;
442
- function te(t) {
443
- let e = fe;
444
- for (; e.length < t; )
445
- e += e;
446
- return BigInt("1" + e.substring(0, t));
537
+ const Vt = BigInt(-1), te = BigInt(0), Ae = BigInt(1), Wt = BigInt(5), ge = {};
538
+ let ve = "0000";
539
+ for (; ve.length < 80; )
540
+ ve += ve;
541
+ function pe(e) {
542
+ let t = ve;
543
+ for (; t.length < e; )
544
+ t += t;
545
+ return BigInt("1" + t.substring(0, e));
447
546
  }
448
- function be(t, e, n) {
449
- const r = BigInt(e.width);
450
- if (e.signed) {
451
- const s = ue << r - ue;
452
- z(n == null || t >= -s && t < s, "overflow", "NUMERIC_FAULT", {
547
+ function Se(e, t, n) {
548
+ const r = BigInt(t.width);
549
+ if (t.signed) {
550
+ const s = Ae << r - Ae;
551
+ Z(n == null || e >= -s && e < s, "overflow", "NUMERIC_FAULT", {
453
552
  operation: n,
454
553
  fault: "overflow",
455
- value: t
456
- }), t > K ? t = Le(ze(t, r), r) : t = -Le(ze(-t, r), r);
554
+ value: e
555
+ }), e > te ? e = je(_e(e, r), r) : e = -je(_e(-e, r), r);
457
556
  } else {
458
- const s = ue << r;
459
- z(n == null || t >= 0 && t < s, "overflow", "NUMERIC_FAULT", {
557
+ const s = Ae << r;
558
+ Z(n == null || e >= 0 && e < s, "overflow", "NUMERIC_FAULT", {
460
559
  operation: n,
461
560
  fault: "overflow",
462
- value: t
463
- }), t = (t % s + s) % s & s - ue;
561
+ value: e
562
+ }), e = (e % s + s) % s & s - Ae;
464
563
  }
465
- return t;
564
+ return e;
466
565
  }
467
- function Be(t) {
468
- typeof t == "number" && (t = `fixed128x${t}`);
469
- let e = !0, n = 128, r = 18;
470
- if (typeof t == "string") {
471
- if (t !== "fixed") if (t === "ufixed")
472
- e = !1;
566
+ function Ee(e) {
567
+ typeof e == "number" && (e = `fixed128x${e}`);
568
+ let t = !0, n = 128, r = 18;
569
+ if (typeof e == "string") {
570
+ if (e !== "fixed") if (e === "ufixed")
571
+ t = !1;
473
572
  else {
474
- const a = t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
475
- j(a, "invalid fixed format", "format", t), e = a[1] !== "u", n = parseInt(a[2]), r = parseInt(a[3]);
573
+ const l = e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
574
+ H(l, "invalid fixed format", "format", e), t = l[1] !== "u", n = parseInt(l[2]), r = parseInt(l[3]);
476
575
  }
477
- } else if (t) {
478
- const a = t, i = (w, h, p) => a[w] == null ? p : (j(typeof a[w] === h, "invalid fixed format (" + w + " not " + h + ")", "format." + w, a[w]), a[w]);
479
- e = i("signed", "boolean", e), n = i("width", "number", n), r = i("decimals", "number", r);
576
+ } else if (e) {
577
+ const l = e, i = (u, p, g) => l[u] == null ? g : (H(typeof l[u] === p, "invalid fixed format (" + u + " not " + p + ")", "format." + u, l[u]), l[u]);
578
+ t = i("signed", "boolean", t), n = i("width", "number", n), r = i("decimals", "number", r);
480
579
  }
481
- j(n % 8 === 0, "invalid FixedNumber width (not byte aligned)", "format.width", n), j(r <= 80, "invalid FixedNumber decimals (too large)", "format.decimals", r);
482
- const s = (e ? "" : "u") + "fixed" + String(n) + "x" + String(r);
483
- return { signed: e, width: n, decimals: r, name: s };
580
+ H(n % 8 === 0, "invalid FixedNumber width (not byte aligned)", "format.width", n), H(r <= 80, "invalid FixedNumber decimals (too large)", "format.decimals", r);
581
+ const s = (t ? "" : "u") + "fixed" + String(n) + "x" + String(r);
582
+ return { signed: t, width: n, decimals: r, name: s };
484
583
  }
485
- function Dt(t, e) {
584
+ function Qt(e, t) {
486
585
  let n = "";
487
- t < K && (n = "-", t *= Et);
488
- let r = t.toString();
489
- if (e === 0)
586
+ e < te && (n = "-", e *= Vt);
587
+ let r = e.toString();
588
+ if (t === 0)
490
589
  return n + r;
491
- for (; r.length <= e; )
492
- r = fe + r;
493
- const s = r.length - e;
590
+ for (; r.length <= t; )
591
+ r = ve + r;
592
+ const s = r.length - t;
494
593
  for (r = r.substring(0, s) + "." + r.substring(s); r[0] === "0" && r[1] !== "."; )
495
594
  r = r.substring(1);
496
595
  for (; r[r.length - 1] === "0" && r[r.length - 2] !== "."; )
497
596
  r = r.substring(0, r.length - 1);
498
597
  return n + r;
499
598
  }
500
- var q, F, Q, B, ne, _, Oe, $e, Pe, je;
501
- const Z = class Z {
599
+ var ne, R, Y, U, he, ae, We, Qe, qe, He;
600
+ const we = class we {
502
601
  // Use this when changing this file to get some typing info,
503
602
  // but then switch to any to mask the internal type
504
603
  //constructor(guard: any, value: bigint, format: _FixedFormat) {
505
604
  /**
506
605
  * @private
507
606
  */
508
- constructor(e, n, r) {
509
- ge(this, B);
607
+ constructor(t, n, r) {
608
+ Ne(this, U);
510
609
  /**
511
610
  * The specific fixed-point arithmetic field for this value.
512
611
  */
513
- Ce(this, "format");
514
- ge(this, q);
612
+ Fe(this, "format");
613
+ Ne(this, ne);
515
614
  // The actual value (accounting for decimals)
516
- ge(this, F);
615
+ Ne(this, R);
517
616
  // A base-10 value to multiple values by to maintain the magnitude
518
- ge(this, Q);
617
+ Ne(this, Y);
519
618
  /**
520
619
  * This is a property so console.log shows a human-meaningful value.
521
620
  *
522
621
  * @private
523
622
  */
524
- Ce(this, "_value");
525
- Ut(e, de, "FixedNumber"), ye(this, F, n), ye(this, q, r);
526
- const s = Dt(n, r.decimals);
527
- Ee(this, { format: r.name, _value: s }), ye(this, Q, te(r.decimals));
623
+ Fe(this, "_value");
624
+ Dt(t, ge, "FixedNumber"), Te(this, R, n), Te(this, ne, r);
625
+ const s = Qt(n, r.decimals);
626
+ Pe(this, { format: r.name, _value: s }), Te(this, Y, pe(r.decimals));
528
627
  }
529
628
  /**
530
629
  * If true, negative values are permitted, otherwise only
531
630
  * positive values and zero are allowed.
532
631
  */
533
632
  get signed() {
534
- return b(this, q).signed;
633
+ return x(this, ne).signed;
535
634
  }
536
635
  /**
537
636
  * The number of bits available to store the value.
538
637
  */
539
638
  get width() {
540
- return b(this, q).width;
639
+ return x(this, ne).width;
541
640
  }
542
641
  /**
543
642
  * The number of decimal places in the fixed-point arithment field.
544
643
  */
545
644
  get decimals() {
546
- return b(this, q).decimals;
645
+ return x(this, ne).decimals;
547
646
  }
548
647
  /**
549
648
  * The value as an integer, based on the smallest unit the
550
649
  * [[decimals]] allow.
551
650
  */
552
651
  get value() {
553
- return b(this, F);
652
+ return x(this, R);
554
653
  }
555
654
  /**
556
655
  * Returns a new [[FixedNumber]] with the result of %%this%% added
557
656
  * to %%other%%, ignoring overflow.
558
657
  */
559
- addUnsafe(e) {
560
- return E(this, B, Oe).call(this, e);
658
+ addUnsafe(t) {
659
+ return j(this, U, We).call(this, t);
561
660
  }
562
661
  /**
563
662
  * Returns a new [[FixedNumber]] with the result of %%this%% added
564
663
  * to %%other%%. A [[NumericFaultError]] is thrown if overflow
565
664
  * occurs.
566
665
  */
567
- add(e) {
568
- return E(this, B, Oe).call(this, e, "add");
666
+ add(t) {
667
+ return j(this, U, We).call(this, t, "add");
569
668
  }
570
669
  /**
571
670
  * Returns a new [[FixedNumber]] with the result of %%other%% subtracted
572
671
  * from %%this%%, ignoring overflow.
573
672
  */
574
- subUnsafe(e) {
575
- return E(this, B, $e).call(this, e);
673
+ subUnsafe(t) {
674
+ return j(this, U, Qe).call(this, t);
576
675
  }
577
676
  /**
578
677
  * Returns a new [[FixedNumber]] with the result of %%other%% subtracted
579
678
  * from %%this%%. A [[NumericFaultError]] is thrown if overflow
580
679
  * occurs.
581
680
  */
582
- sub(e) {
583
- return E(this, B, $e).call(this, e, "sub");
681
+ sub(t) {
682
+ return j(this, U, Qe).call(this, t, "sub");
584
683
  }
585
684
  /**
586
685
  * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
587
686
  * by %%other%%, ignoring overflow and underflow (precision loss).
588
687
  */
589
- mulUnsafe(e) {
590
- return E(this, B, Pe).call(this, e);
688
+ mulUnsafe(t) {
689
+ return j(this, U, qe).call(this, t);
591
690
  }
592
691
  /**
593
692
  * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
594
693
  * by %%other%%. A [[NumericFaultError]] is thrown if overflow
595
694
  * occurs.
596
695
  */
597
- mul(e) {
598
- return E(this, B, Pe).call(this, e, "mul");
696
+ mul(t) {
697
+ return j(this, U, qe).call(this, t, "mul");
599
698
  }
600
699
  /**
601
700
  * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
602
701
  * by %%other%%. A [[NumericFaultError]] is thrown if overflow
603
702
  * occurs or if underflow (precision loss) occurs.
604
703
  */
605
- mulSignal(e) {
606
- E(this, B, ne).call(this, e);
607
- const n = b(this, F) * b(e, F);
608
- return z(n % b(this, Q) === K, "precision lost during signalling mul", "NUMERIC_FAULT", {
704
+ mulSignal(t) {
705
+ j(this, U, he).call(this, t);
706
+ const n = x(this, R) * x(t, R);
707
+ return Z(n % x(this, Y) === te, "precision lost during signalling mul", "NUMERIC_FAULT", {
609
708
  operation: "mulSignal",
610
709
  fault: "underflow",
611
710
  value: this
612
- }), E(this, B, _).call(this, n / b(this, Q), "mulSignal");
711
+ }), j(this, U, ae).call(this, n / x(this, Y), "mulSignal");
613
712
  }
614
713
  /**
615
714
  * Returns a new [[FixedNumber]] with the result of %%this%% divided
616
715
  * by %%other%%, ignoring underflow (precision loss). A
617
716
  * [[NumericFaultError]] is thrown if overflow occurs.
618
717
  */
619
- divUnsafe(e) {
620
- return E(this, B, je).call(this, e);
718
+ divUnsafe(t) {
719
+ return j(this, U, He).call(this, t);
621
720
  }
622
721
  /**
623
722
  * Returns a new [[FixedNumber]] with the result of %%this%% divided
624
723
  * by %%other%%, ignoring underflow (precision loss). A
625
724
  * [[NumericFaultError]] is thrown if overflow occurs.
626
725
  */
627
- div(e) {
628
- return E(this, B, je).call(this, e, "div");
726
+ div(t) {
727
+ return j(this, U, He).call(this, t, "div");
629
728
  }
630
729
  /**
631
730
  * Returns a new [[FixedNumber]] with the result of %%this%% divided
632
731
  * by %%other%%. A [[NumericFaultError]] is thrown if underflow
633
732
  * (precision loss) occurs.
634
733
  */
635
- divSignal(e) {
636
- z(b(e, F) !== K, "division by zero", "NUMERIC_FAULT", {
734
+ divSignal(t) {
735
+ Z(x(t, R) !== te, "division by zero", "NUMERIC_FAULT", {
637
736
  operation: "div",
638
737
  fault: "divide-by-zero",
639
738
  value: this
640
- }), E(this, B, ne).call(this, e);
641
- const n = b(this, F) * b(this, Q);
642
- return z(n % b(e, F) === K, "precision lost during signalling div", "NUMERIC_FAULT", {
739
+ }), j(this, U, he).call(this, t);
740
+ const n = x(this, R) * x(this, Y);
741
+ return Z(n % x(t, R) === te, "precision lost during signalling div", "NUMERIC_FAULT", {
643
742
  operation: "divSignal",
644
743
  fault: "underflow",
645
744
  value: this
646
- }), E(this, B, _).call(this, n / b(e, F), "divSignal");
745
+ }), j(this, U, ae).call(this, n / x(t, R), "divSignal");
647
746
  }
648
747
  /**
649
748
  * Returns a comparison result between %%this%% and %%other%%.
@@ -652,40 +751,40 @@ const Z = class Z {
652
751
  * is smaller, ``1`` implies %%this%% is larger and ``0`` implies
653
752
  * both are equal.
654
753
  */
655
- cmp(e) {
656
- let n = this.value, r = e.value;
657
- const s = this.decimals - e.decimals;
658
- return s > 0 ? r *= te(s) : s < 0 && (n *= te(-s)), n < r ? -1 : n > r ? 1 : 0;
754
+ cmp(t) {
755
+ let n = this.value, r = t.value;
756
+ const s = this.decimals - t.decimals;
757
+ return s > 0 ? r *= pe(s) : s < 0 && (n *= pe(-s)), n < r ? -1 : n > r ? 1 : 0;
659
758
  }
660
759
  /**
661
760
  * Returns true if %%other%% is equal to %%this%%.
662
761
  */
663
- eq(e) {
664
- return this.cmp(e) === 0;
762
+ eq(t) {
763
+ return this.cmp(t) === 0;
665
764
  }
666
765
  /**
667
766
  * Returns true if %%other%% is less than to %%this%%.
668
767
  */
669
- lt(e) {
670
- return this.cmp(e) < 0;
768
+ lt(t) {
769
+ return this.cmp(t) < 0;
671
770
  }
672
771
  /**
673
772
  * Returns true if %%other%% is less than or equal to %%this%%.
674
773
  */
675
- lte(e) {
676
- return this.cmp(e) <= 0;
774
+ lte(t) {
775
+ return this.cmp(t) <= 0;
677
776
  }
678
777
  /**
679
778
  * Returns true if %%other%% is greater than to %%this%%.
680
779
  */
681
- gt(e) {
682
- return this.cmp(e) > 0;
780
+ gt(t) {
781
+ return this.cmp(t) > 0;
683
782
  }
684
783
  /**
685
784
  * Returns true if %%other%% is greater than or equal to %%this%%.
686
785
  */
687
- gte(e) {
688
- return this.cmp(e) >= 0;
786
+ gte(t) {
787
+ return this.cmp(t) >= 0;
689
788
  }
690
789
  /**
691
790
  * Returns a new [[FixedNumber]] which is the largest **integer**
@@ -694,8 +793,8 @@ const Z = class Z {
694
793
  * The decimal component of the result will always be ``0``.
695
794
  */
696
795
  floor() {
697
- let e = b(this, F);
698
- return b(this, F) < K && (e -= b(this, Q) - ue), e = b(this, F) / b(this, Q) * b(this, Q), E(this, B, _).call(this, e, "floor");
796
+ let t = x(this, R);
797
+ return x(this, R) < te && (t -= x(this, Y) - Ae), t = x(this, R) / x(this, Y) * x(this, Y), j(this, U, ae).call(this, t, "floor");
699
798
  }
700
799
  /**
701
800
  * Returns a new [[FixedNumber]] which is the smallest **integer**
@@ -704,32 +803,32 @@ const Z = class Z {
704
803
  * The decimal component of the result will always be ``0``.
705
804
  */
706
805
  ceiling() {
707
- let e = b(this, F);
708
- return b(this, F) > K && (e += b(this, Q) - ue), e = b(this, F) / b(this, Q) * b(this, Q), E(this, B, _).call(this, e, "ceiling");
806
+ let t = x(this, R);
807
+ return x(this, R) > te && (t += x(this, Y) - Ae), t = x(this, R) / x(this, Y) * x(this, Y), j(this, U, ae).call(this, t, "ceiling");
709
808
  }
710
809
  /**
711
810
  * Returns a new [[FixedNumber]] with the decimal component
712
811
  * rounded up on ties at %%decimals%% places.
713
812
  */
714
- round(e) {
715
- if (e == null && (e = 0), e >= this.decimals)
813
+ round(t) {
814
+ if (t == null && (t = 0), t >= this.decimals)
716
815
  return this;
717
- const n = this.decimals - e, r = Lt * te(n - 1);
816
+ const n = this.decimals - t, r = Wt * pe(n - 1);
718
817
  let s = this.value + r;
719
- const a = te(n);
720
- return s = s / a * a, be(s, b(this, q), "round"), new Z(de, s, b(this, q));
818
+ const l = pe(n);
819
+ return s = s / l * l, Se(s, x(this, ne), "round"), new we(ge, s, x(this, ne));
721
820
  }
722
821
  /**
723
822
  * Returns true if %%this%% is equal to ``0``.
724
823
  */
725
824
  isZero() {
726
- return b(this, F) === K;
825
+ return x(this, R) === te;
727
826
  }
728
827
  /**
729
828
  * Returns true if %%this%% is less than ``0``.
730
829
  */
731
830
  isNegative() {
732
- return b(this, F) < K;
831
+ return x(this, R) < te;
733
832
  }
734
833
  /**
735
834
  * Returns the string representation of %%this%%.
@@ -753,8 +852,8 @@ const Z = class Z {
753
852
  *
754
853
  * This will throw if the value cannot fit into %%format%%.
755
854
  */
756
- toFormat(e) {
757
- return Z.fromString(this.toString(), e);
855
+ toFormat(t) {
856
+ return we.fromString(this.toString(), t);
758
857
  }
759
858
  /**
760
859
  * Creates a new [[FixedNumber]] for %%value%% divided by
@@ -764,19 +863,19 @@ const Z = class Z {
764
863
  * for %%decimals%%) cannot fit in %%format%%, either due to overflow
765
864
  * or underflow (precision loss).
766
865
  */
767
- static fromValue(e, n, r) {
768
- const s = n == null ? 0 : Ae(n), a = Be(r);
769
- let i = Ve(e, "value");
770
- const w = s - a.decimals;
771
- if (w > 0) {
772
- const h = te(w);
773
- z(i % h === K, "value loses precision for format", "NUMERIC_FAULT", {
866
+ static fromValue(t, n, r) {
867
+ const s = n == null ? 0 : Ie(n), l = Ee(r);
868
+ let i = Ke(t, "value");
869
+ const u = s - l.decimals;
870
+ if (u > 0) {
871
+ const p = pe(u);
872
+ Z(i % p === te, "value loses precision for format", "NUMERIC_FAULT", {
774
873
  operation: "fromValue",
775
874
  fault: "underflow",
776
- value: e
777
- }), i /= h;
778
- } else w < 0 && (i *= te(-w));
779
- return be(i, a, "fromValue"), new Z(de, i, a);
875
+ value: t
876
+ }), i /= p;
877
+ } else u < 0 && (i *= pe(-u));
878
+ return Se(i, l, "fromValue"), new we(ge, i, l);
780
879
  }
781
880
  /**
782
881
  * Creates a new [[FixedNumber]] for %%value%% with %%format%%.
@@ -784,20 +883,20 @@ const Z = class Z {
784
883
  * This will throw a [[NumericFaultError]] if %%value%% cannot fit
785
884
  * in %%format%%, either due to overflow or underflow (precision loss).
786
885
  */
787
- static fromString(e, n) {
788
- const r = e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);
789
- j(r && r[2].length + r[3].length > 0, "invalid FixedNumber string value", "value", e);
790
- const s = Be(n);
791
- let a = r[2] || "0", i = r[3] || "";
886
+ static fromString(t, n) {
887
+ const r = t.match(/^(-?)([0-9]*)\.?([0-9]*)$/);
888
+ H(r && r[2].length + r[3].length > 0, "invalid FixedNumber string value", "value", t);
889
+ const s = Ee(n);
890
+ let l = r[2] || "0", i = r[3] || "";
792
891
  for (; i.length < s.decimals; )
793
- i += fe;
794
- z(i.substring(s.decimals).match(/^0*$/), "too many decimals for format", "NUMERIC_FAULT", {
892
+ i += ve;
893
+ Z(i.substring(s.decimals).match(/^0*$/), "too many decimals for format", "NUMERIC_FAULT", {
795
894
  operation: "fromString",
796
895
  fault: "underflow",
797
- value: e
896
+ value: t
798
897
  }), i = i.substring(0, s.decimals);
799
- const w = BigInt(r[1] + a + i);
800
- return be(w, s, "fromString"), new Z(de, w, s);
898
+ const u = BigInt(r[1] + l + i);
899
+ return Se(u, s, "fromString"), new we(ge, u, s);
801
900
  }
802
901
  /**
803
902
  * Creates a new [[FixedNumber]] with the big-endian representation
@@ -806,31 +905,31 @@ const Z = class Z {
806
905
  * This will throw a [[NumericFaultError]] if %%value%% cannot fit
807
906
  * in %%format%% due to overflow.
808
907
  */
809
- static fromBytes(e, n) {
810
- let r = Mt(Rt(e, "value"));
811
- const s = Be(n);
812
- return s.signed && (r = Le(r, s.width)), be(r, s, "fromBytes"), new Z(de, r, s);
908
+ static fromBytes(t, n) {
909
+ let r = jt(Pt(t, "value"));
910
+ const s = Ee(n);
911
+ return s.signed && (r = je(r, s.width)), Se(r, s, "fromBytes"), new we(ge, r, s);
813
912
  }
814
913
  };
815
- q = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), B = new WeakSet(), ne = function(e) {
816
- j(this.format === e.format, "incompatible format; use fixedNumber.toFormat", "other", e);
817
- }, _ = function(e, n) {
818
- return e = be(e, b(this, q), n), new Z(de, e, b(this, q));
819
- }, Oe = function(e, n) {
820
- return E(this, B, ne).call(this, e), E(this, B, _).call(this, b(this, F) + b(e, F), n);
821
- }, $e = function(e, n) {
822
- return E(this, B, ne).call(this, e), E(this, B, _).call(this, b(this, F) - b(e, F), n);
823
- }, Pe = function(e, n) {
824
- return E(this, B, ne).call(this, e), E(this, B, _).call(this, b(this, F) * b(e, F) / b(this, Q), n);
825
- }, je = function(e, n) {
826
- return z(b(e, F) !== K, "division by zero", "NUMERIC_FAULT", {
914
+ ne = new WeakMap(), R = new WeakMap(), Y = new WeakMap(), U = new WeakSet(), he = function(t) {
915
+ H(this.format === t.format, "incompatible format; use fixedNumber.toFormat", "other", t);
916
+ }, ae = function(t, n) {
917
+ return t = Se(t, x(this, ne), n), new we(ge, t, x(this, ne));
918
+ }, We = function(t, n) {
919
+ return j(this, U, he).call(this, t), j(this, U, ae).call(this, x(this, R) + x(t, R), n);
920
+ }, Qe = function(t, n) {
921
+ return j(this, U, he).call(this, t), j(this, U, ae).call(this, x(this, R) - x(t, R), n);
922
+ }, qe = function(t, n) {
923
+ return j(this, U, he).call(this, t), j(this, U, ae).call(this, x(this, R) * x(t, R) / x(this, Y), n);
924
+ }, He = function(t, n) {
925
+ return Z(x(t, R) !== te, "division by zero", "NUMERIC_FAULT", {
827
926
  operation: "div",
828
927
  fault: "divide-by-zero",
829
928
  value: this
830
- }), E(this, B, ne).call(this, e), E(this, B, _).call(this, b(this, F) * b(this, Q) / b(e, F), n);
929
+ }), j(this, U, he).call(this, t), j(this, U, ae).call(this, x(this, R) * x(this, Y) / x(t, R), n);
831
930
  };
832
- let De = Z;
833
- const Ot = [
931
+ let Ve = we;
932
+ const qt = [
834
933
  "wei",
835
934
  "kwei",
836
935
  "mwei",
@@ -839,293 +938,314 @@ const Ot = [
839
938
  "finney",
840
939
  "ether"
841
940
  ];
842
- function $t(t, e) {
843
- j(typeof t == "string", "value must be a string", "value", t);
941
+ function Ht(e, t) {
942
+ H(typeof e == "string", "value must be a string", "value", e);
844
943
  let n = 18;
845
- if (typeof e == "string") {
846
- const r = Ot.indexOf(e);
847
- j(r >= 0, "invalid unit", "unit", e), n = 3 * r;
848
- } else e != null && (n = Ae(e, "unit"));
849
- return De.fromString(t, { decimals: n, width: 512 }).value;
944
+ if (typeof t == "string") {
945
+ const r = qt.indexOf(t);
946
+ H(r >= 0, "invalid unit", "unit", t), n = 3 * r;
947
+ } else t != null && (n = Ie(t, "unit"));
948
+ return Ve.fromString(e, { decimals: n, width: 512 }).value;
850
949
  }
851
- const Pt = "0x0000000000000000000000000000000000000000";
852
- function Te(t, e) {
853
- return (Number(t) / Math.pow(10, e)).toString();
950
+ const Kt = "0x0000000000000000000000000000000000000000";
951
+ function Le(e, t) {
952
+ return (Number(e) / Math.pow(10, t)).toString();
854
953
  }
855
- async function jt(t, e = ke) {
954
+ async function zt(e, t = Be) {
856
955
  const n = new URLSearchParams({
857
- senderAddress: t.senderAddress,
858
- receiverAddress: t.receiverAddress ?? t.senderAddress,
859
- originChainId: String(t.originChainId),
860
- destinationChainId: String(t.destinationChainId),
861
- amount: t.amount,
862
- originCurrency: t.originCurrency,
863
- destinationCurrency: t.destinationCurrency
956
+ senderAddress: e.senderAddress,
957
+ receiverAddress: e.receiverAddress ?? e.senderAddress,
958
+ originChainId: String(e.originChainId),
959
+ destinationChainId: String(e.destinationChainId),
960
+ amount: e.amount,
961
+ originCurrency: e.originCurrency,
962
+ destinationCurrency: e.destinationCurrency
864
963
  });
865
- t.slippage != null && n.set("slippage", String(t.slippage));
866
- const r = `${e}/v1/quotes?${n.toString()}`, s = await fetch(r);
964
+ e.slippage != null && n.set("slippage", String(e.slippage));
965
+ const r = `${t}/v1/quotes?${n.toString()}`, s = await fetch(r);
867
966
  if (!s.ok) {
868
- const a = await s.json().catch(() => ({})), i = new Error((a == null ? void 0 : a.message) ?? `HTTP ${s.status}`);
869
- throw i.status = s.status, i.statusCode = a == null ? void 0 : a.statusCode, i.error = a, i;
967
+ const l = await s.json().catch(() => ({})), i = new Error((l == null ? void 0 : l.message) ?? `HTTP ${s.status}`);
968
+ throw i.status = s.status, i.statusCode = l == null ? void 0 : l.statusCode, i.error = l, i;
870
969
  }
871
970
  return s.json();
872
971
  }
873
- function Vt(t, e) {
874
- if (e < 0 || !t.includes(".")) return t;
875
- const [n, r] = t.split(".");
876
- if (!r || r.length <= e) return t;
877
- const s = r.slice(0, e);
972
+ function Yt(e, t) {
973
+ if (t < 0 || !e.includes(".")) return e;
974
+ const [n, r] = e.split(".");
975
+ if (!r || r.length <= t) return e;
976
+ const s = r.slice(0, t);
878
977
  return s ? `${n}.${s}` : n || "0";
879
978
  }
880
- function Wt() {
881
- const [t, e] = U(null), [n, r] = U(""), [s, a] = U(""), [i, w] = U(0), [h, p] = U(null), [k, x] = U(), [m, u] = U(), [v, o] = U("swap"), M = se(null), R = se(0), O = D(() => {
882
- var $;
883
- ($ = M.current) == null || $.abort(), M.current = null;
884
- }, []), L = D(() => {
885
- e(null), o("finding");
886
- }, []), V = D(
887
- ($) => {
888
- O();
889
- const l = ++R.current, C = new AbortController();
890
- M.current = C;
979
+ function Jt(e = {}) {
980
+ const [t, n] = B(null), [r, s] = B(null), [l, i] = B(""), [u, p] = B(""), [g, C] = B(0), [I, k] = B(null), [m, y] = B(), [v, $] = B(), [D, T] = B("swap"), O = X(null), K = X(0), q = M(() => {
981
+ var h;
982
+ (h = O.current) == null || h.abort(), O.current = null;
983
+ }, []), L = M(() => {
984
+ n(null), s(null), T("finding");
985
+ }, []), c = M(
986
+ (h) => {
987
+ q();
988
+ const b = ++K.current, N = new AbortController();
989
+ O.current = N;
891
990
  const {
892
- sellNetworkId: g,
893
- buyNetworkId: y,
894
- sellToken: c,
895
- buyToken: f,
896
- sellAmountStr: S,
897
- slippage: N,
898
- fromAddress: T,
899
- toAddress: P,
900
- apiBase: J = ke
901
- } = $, G = Vt(
902
- S || "0",
903
- c.decimals
991
+ sellNetworkId: o,
992
+ buyNetworkId: E,
993
+ sellToken: V,
994
+ buyToken: J,
995
+ sellAmountStr: G,
996
+ slippage: ie,
997
+ fromAddress: fe,
998
+ toAddress: ee,
999
+ apiBase: ce = Be
1000
+ } = h, de = Yt(
1001
+ G || "0",
1002
+ V.decimals
904
1003
  );
905
- let H;
1004
+ let oe;
906
1005
  try {
907
- H = $t(G, c.decimals);
1006
+ oe = Ht(de, V.decimals);
908
1007
  } catch {
909
- o("swap");
1008
+ T("swap");
910
1009
  return;
911
1010
  }
912
- if (H <= 0n) {
913
- o("swap");
1011
+ if (oe <= 0n) {
1012
+ T("swap");
914
1013
  return;
915
1014
  }
916
- o("finding"), e(null), x(void 0), u(void 0);
917
- const ve = P && P !== "" ? P : void 0;
918
- jt(
1015
+ T("finding"), n(null), s(null), y(void 0), $(void 0);
1016
+ const w = ee && ee !== "" ? ee : void 0;
1017
+ zt(
919
1018
  {
920
- originChainId: g,
921
- destinationChainId: y,
922
- originCurrency: c.contractAddress,
923
- destinationCurrency: f.contractAddress,
924
- amount: H.toString(),
925
- senderAddress: T,
926
- receiverAddress: ve,
927
- slippage: N ?? 5e-3
1019
+ originChainId: o,
1020
+ destinationChainId: E,
1021
+ originCurrency: V.contractAddress,
1022
+ destinationCurrency: J.contractAddress,
1023
+ amount: oe.toString(),
1024
+ senderAddress: fe,
1025
+ receiverAddress: w,
1026
+ slippage: ie ?? 5e-3
928
1027
  },
929
- J
930
- ).then((I) => {
931
- var ee, W, Ne, X, he, pe;
932
- if (l !== R.current) return;
933
- const Y = (W = (ee = I == null ? void 0 : I.fees) == null ? void 0 : ee.breakdown) == null ? void 0 : W.find(
934
- (me) => me.type === "gas"
1028
+ ce
1029
+ ).then((a) => {
1030
+ var W, Q, z, f, F, P;
1031
+ if (b !== K.current) return;
1032
+ n(a);
1033
+ const S = (Q = (W = a == null ? void 0 : a.fees) == null ? void 0 : W.breakdown) == null ? void 0 : Q.find(
1034
+ (_) => _.type === "gas"
935
1035
  );
936
- if (Y && (u(String(Y.amount)), Y.gasPrice !== void 0 && x(String(Y.gasPrice))), I != null && I.calldata) {
937
- const me = I.outputAmount ?? "0", We = (String(me).includes(".") ? Number(me) : Number(
938
- Te(
939
- String(me),
940
- f.decimals
1036
+ if (S && ($(String(S.amount)), S.gasPrice !== void 0 && y(String(S.gasPrice))), a != null && a.calldata) {
1037
+ const _ = a.outputAmount ?? "0", se = (String(_).includes(".") ? Number(_) : Number(
1038
+ Le(
1039
+ String(_),
1040
+ J.decimals
941
1041
  )
942
- )).toFixed(f.decimals).replace(/\.?0+$/, "");
943
- r(We), a(We);
944
- const it = Number(
945
- ((X = (Ne = I.fees) == null ? void 0 : Ne.total) == null ? void 0 : X.amount) || "0"
946
- ), lt = Number(
947
- ((pe = (he = I.fees) == null ? void 0 : he.total) == null ? void 0 : pe.decimals) ?? 18
948
- ), Se = it / Math.pow(10, lt);
949
- p(
950
- Se <= 0 ? null : Se < 0.01 ? "$<0.01" : `$${Se.toFixed(2)}`
1042
+ )).toFixed(J.decimals).replace(/\.?0+$/, "");
1043
+ i(se), p(se);
1044
+ const pt = Number(
1045
+ ((f = (z = a.fees) == null ? void 0 : z.total) == null ? void 0 : f.amount) || "0"
1046
+ ), ht = Number(
1047
+ ((P = (F = a.fees) == null ? void 0 : F.total) == null ? void 0 : P.decimals) ?? 18
1048
+ ), Ue = pt / Math.pow(10, ht);
1049
+ k(
1050
+ Ue <= 0 ? null : Ue < 0.01 ? "$<0.01" : `$${Ue.toFixed(2)}`
951
1051
  );
952
- const Qe = parseFloat(
953
- Te(
954
- I.inputAmount ?? "0",
955
- c.decimals
1052
+ const ze = parseFloat(
1053
+ Le(
1054
+ a.inputAmount ?? "0",
1055
+ V.decimals
956
1056
  )
957
- ), ct = parseFloat(
958
- Te(
959
- I.outputAmount ?? "0",
960
- f.decimals
1057
+ ), mt = parseFloat(
1058
+ Le(
1059
+ a.outputAmount ?? "0",
1060
+ J.decimals
961
1061
  )
962
1062
  );
963
- Qe > 0 && w(Number((ct / Qe).toFixed(3))), e(I.calldata ?? null);
964
- const wt = c.contractAddress === "0x0000000000000000000000000000000000000000";
965
- o(wt ? "swap" : "approve");
1063
+ ze > 0 && C(Number((mt / ze).toFixed(3))), s(a.calldata ?? null);
1064
+ const gt = V.contractAddress === "0x0000000000000000000000000000000000000000";
1065
+ T(gt ? "swap" : "approve");
966
1066
  }
967
- }).catch((I) => {
968
- var W;
969
- if (l !== R.current || (I == null ? void 0 : I.name) === "AbortError") return;
970
- const Y = String(((W = I == null ? void 0 : I.error) == null ? void 0 : W.message) ?? (I == null ? void 0 : I.message) ?? ""), ee = (I == null ? void 0 : I.statusCode) ?? (I == null ? void 0 : I.status);
971
- Y.includes("No available quotes") || ee === 422 ? o("no-available-quotes") : Y.includes("Invalid toAddress") || Y.includes("Invalid fromAddress") ? o("wrong-address") : ee === 429 || Y.includes("Rate limit") ? o("rate-limit") : o("no-available-quotes");
1067
+ }).catch((a) => {
1068
+ var Q, z;
1069
+ if (b !== K.current || (a == null ? void 0 : a.name) === "AbortError") return;
1070
+ const S = String(((Q = a == null ? void 0 : a.error) == null ? void 0 : Q.message) ?? (a == null ? void 0 : a.message) ?? ""), W = (a == null ? void 0 : a.statusCode) ?? (a == null ? void 0 : a.status);
1071
+ S.includes("No available quotes") || W === 422 ? T("no-available-quotes") : S.includes("Invalid toAddress") || S.includes("Invalid fromAddress") ? T("wrong-address") : W === 429 || S.includes("Rate limit") ? T("rate-limit") : T("no-available-quotes"), (z = e.onError) == null || z.call(e, {
1072
+ source: "quote",
1073
+ message: S || "Failed to fetch quote",
1074
+ status: a == null ? void 0 : a.status,
1075
+ statusCode: W,
1076
+ error: a
1077
+ });
972
1078
  });
973
1079
  },
974
- [O]
1080
+ [q, e]
975
1081
  );
976
1082
  return {
977
- txData: t,
978
- buyAmount: n,
979
- buyAmountForInput: s,
980
- setBuyAmount: r,
981
- setBuyAmountForInput: a,
982
- price: i,
983
- gasCostUSD: h,
984
- gasPriceRaw: k,
985
- gasLimitRaw: m,
986
- buttonState: v,
987
- setButtonState: o,
988
- fetchQuote: V,
989
- cancelRequest: O,
1083
+ quote: t,
1084
+ txData: r,
1085
+ buyAmount: l,
1086
+ buyAmountForInput: u,
1087
+ setBuyAmount: i,
1088
+ setBuyAmountForInput: p,
1089
+ price: g,
1090
+ gasCostUSD: I,
1091
+ gasPriceRaw: m,
1092
+ gasLimitRaw: v,
1093
+ buttonState: D,
1094
+ setButtonState: T,
1095
+ fetchQuote: c,
1096
+ cancelRequest: q,
990
1097
  invalidateQuote: L
991
1098
  };
992
1099
  }
993
- const Ue = "delora-slippage-selectedIndex", Fe = "delora-slippage-customValue", Ke = "delora-slippage-value", qe = ["Auto", "0.1%", "0.5%"], Re = 5e-3;
994
- function Qt() {
995
- const [t, e] = U(0), [n, r] = U(""), [s, a] = U(Re);
996
- oe(() => {
997
- const p = localStorage.getItem(Ue), k = localStorage.getItem(Fe);
998
- p !== null && e(JSON.parse(p)), k && r(k);
1100
+ const Me = "delora-slippage-selectedIndex", $e = "delora-slippage-customValue", Ze = "delora-slippage-value", et = ["Auto", "0.1%", "0.5%"], De = 5e-3;
1101
+ function Gt() {
1102
+ const [e, t] = B(0), [n, r] = B(""), [s, l] = B(De);
1103
+ re(() => {
1104
+ const g = localStorage.getItem(Me), C = localStorage.getItem($e);
1105
+ g !== null && t(JSON.parse(g)), C && r(C);
999
1106
  }, []);
1000
- const i = D((p) => {
1001
- e(p), r(""), localStorage.setItem(Ue, JSON.stringify(p)), localStorage.setItem(Fe, ""), a(p === 0 ? Re : parseFloat(qe[p].replace("%", "")) / 100);
1002
- }, []), w = D((p) => {
1003
- e(null), r(p), localStorage.setItem(Ue, "null"), localStorage.setItem(Fe, p);
1004
- const k = parseFloat(p.replace("%", ""));
1005
- !isNaN(k) && k <= 49.9 && a(k / 100);
1006
- }, []), h = D(
1007
- (p) => {
1008
- if (p === "Auto") {
1009
- const m = Re;
1010
- return a(m), localStorage.setItem(Ke, p), m;
1107
+ const i = M((g) => {
1108
+ t(g), r(""), localStorage.setItem(Me, JSON.stringify(g)), localStorage.setItem($e, ""), l(g === 0 ? De : parseFloat(et[g].replace("%", "")) / 100);
1109
+ }, []), u = M((g) => {
1110
+ t(null), r(g), localStorage.setItem(Me, "null"), localStorage.setItem($e, g);
1111
+ const C = parseFloat(g.replace("%", ""));
1112
+ !isNaN(C) && C <= 49.9 && l(C / 100);
1113
+ }, []), p = M(
1114
+ (g) => {
1115
+ if (g === "Auto") {
1116
+ const k = De;
1117
+ return l(k), localStorage.setItem(Ze, g), k;
1011
1118
  }
1012
- const k = parseFloat(p.replace("%", ""));
1013
- if (k > 49.9) throw new Error("Slippage is too high!");
1014
- const x = k / 100;
1015
- return a(x), localStorage.setItem(Ke, p), x;
1119
+ const C = parseFloat(g.replace("%", ""));
1120
+ if (C > 49.9) throw new Error("Slippage is too high!");
1121
+ const I = C / 100;
1122
+ return l(I), localStorage.setItem(Ze, g), I;
1016
1123
  },
1017
1124
  []
1018
1125
  );
1019
1126
  return {
1020
- options: qe,
1021
- selectedIndex: t,
1127
+ options: et,
1128
+ selectedIndex: e,
1022
1129
  customValue: n,
1023
1130
  slippage: s,
1024
1131
  selectOption: i,
1025
- setCustom: w,
1026
- save: h
1132
+ setCustom: u,
1133
+ save: p
1027
1134
  };
1028
1135
  }
1029
- const Ht = 1e3;
1030
- function xe(t, e) {
1031
- if (!t.includes(".")) return t;
1032
- const [n, r] = t.split(".");
1033
- return `${n}.${(r ?? "").slice(0, e)}`;
1136
+ const _t = 1e3;
1137
+ function Ce(e, t) {
1138
+ if (!e.includes(".")) return e;
1139
+ const [n, r] = e.split(".");
1140
+ return `${n}.${(r ?? "").slice(0, t)}`;
1034
1141
  }
1035
- function Je(t) {
1036
- return t === "EVM" ? nt : t === "SVM" ? rt : ot;
1142
+ function tt(e) {
1143
+ return e === "EVM" ? at : e === "SVM" ? it : ct;
1037
1144
  }
1038
- function zt(t) {
1039
- var V, $, l, C;
1040
- const e = It({ apiBase: t.apiBase }), n = Wt(), r = Qt(), [s, a] = U(""), [i, w] = U(0), [h, p] = U(!1), k = se(null), x = 0, m = 0, u = !!e.sellToken && !!e.buyToken && i > 0, v = D(() => {
1041
- if (!e.networkSell || !e.networkBuy || !e.sellToken || !e.buyToken || i <= 0 || h)
1145
+ function Xt(e) {
1146
+ var q, L, c, h;
1147
+ const t = Lt({
1148
+ apiBase: e.apiBase,
1149
+ initialSellToken: e.initialSellToken,
1150
+ initialBuyToken: e.initialBuyToken,
1151
+ initialSellNetworkId: e.initialSellNetworkId,
1152
+ initialBuyNetworkId: e.initialBuyNetworkId,
1153
+ lockBuyToken: e.lockBuyToken,
1154
+ lockSellToken: e.lockSellToken,
1155
+ lockBuyNetwork: e.lockBuyNetwork,
1156
+ lockSellNetwork: e.lockSellNetwork,
1157
+ onError: e.onError
1158
+ }), n = Jt({ onError: e.onError }), r = Gt(), s = !!e.lockBuyToken || !!e.lockSellToken || !!e.lockBuyNetwork || !!e.lockSellNetwork, [l, i] = B(""), [u, p] = B(0), [g, C] = B(!1), I = X(null), k = 0, m = 0, y = !!t.sellToken && !!t.buyToken && u > 0, v = M(() => {
1159
+ if (!t.networkSell || !t.networkBuy || !t.sellToken || !t.buyToken || u <= 0 || g)
1042
1160
  return;
1043
- const g = Je(e.networkSell.chainType), y = Je(e.networkBuy.chainType);
1161
+ const b = tt(t.networkSell.chainType), N = tt(t.networkBuy.chainType);
1044
1162
  n.fetchQuote({
1045
- sellNetworkId: e.networkSell.id,
1046
- buyNetworkId: e.networkBuy.id,
1047
- sellToken: e.sellToken,
1048
- buyToken: e.buyToken,
1049
- sellAmountStr: s || "0",
1163
+ sellNetworkId: t.networkSell.id,
1164
+ buyNetworkId: t.networkBuy.id,
1165
+ sellToken: t.sellToken,
1166
+ buyToken: t.buyToken,
1167
+ sellAmountStr: l || "0",
1050
1168
  slippage: r.slippage,
1051
- fromAddress: g,
1052
- toAddress: y,
1053
- apiBase: t.apiBase ?? ke
1169
+ fromAddress: b,
1170
+ toAddress: N,
1171
+ apiBase: e.apiBase ?? Be
1054
1172
  });
1055
1173
  }, [
1056
- e.networkSell,
1057
- e.networkBuy,
1058
- e.sellToken,
1059
- e.buyToken,
1060
- i,
1061
- s,
1174
+ t.networkSell,
1175
+ t.networkBuy,
1176
+ t.sellToken,
1177
+ t.buyToken,
1178
+ u,
1179
+ l,
1062
1180
  r.slippage,
1063
- h,
1064
- t.apiBase,
1181
+ g,
1182
+ e.apiBase,
1065
1183
  n
1066
1184
  ]);
1067
- oe(() => {
1068
- if (!u) {
1185
+ re(() => {
1186
+ if (!y) {
1069
1187
  n.cancelRequest(), n.setBuyAmount(""), n.setBuyAmountForInput(""), n.setButtonState("swap");
1070
1188
  return;
1071
1189
  }
1072
1190
  v();
1073
1191
  }, [
1192
+ y,
1193
+ (q = t.networkSell) == null ? void 0 : q.id,
1194
+ (L = t.networkBuy) == null ? void 0 : L.id,
1195
+ (c = t.sellToken) == null ? void 0 : c.contractAddress,
1196
+ (h = t.buyToken) == null ? void 0 : h.contractAddress,
1074
1197
  u,
1075
- (V = e.networkSell) == null ? void 0 : V.id,
1076
- ($ = e.networkBuy) == null ? void 0 : $.id,
1077
- (l = e.sellToken) == null ? void 0 : l.contractAddress,
1078
- (C = e.buyToken) == null ? void 0 : C.contractAddress,
1079
- i,
1080
- s,
1198
+ l,
1081
1199
  r.slippage,
1082
- h
1083
- ]), oe(() => {
1084
- i === 0 && (n.setBuyAmount(""), n.setBuyAmountForInput(""));
1085
- }, [i]);
1086
- const o = D((g) => {
1087
- const y = g.replace(/[^0-9.]/g, "").replace(/\.+/g, ".").replace(/^(\.)/g, ""), c = xe(y, 6), f = Number(c);
1088
- a(c), w(isNaN(f) ? 0 : f), p(!0), n.invalidateQuote(), k.current && clearTimeout(k.current), k.current = setTimeout(() => {
1089
- p(!1), k.current = null;
1090
- }, Ht);
1091
- }, [n]), M = D(() => {
1092
- a(String(x)), w(x), p(!1), u && v();
1093
- }, [x, u, v]), R = D(
1094
- (g) => {
1095
- const y = x * g / 100, c = xe(String(y), 6);
1096
- a(c), w(y), p(!1), u && v();
1200
+ g
1201
+ ]), re(() => {
1202
+ u === 0 && (n.setBuyAmount(""), n.setBuyAmountForInput(""));
1203
+ }, [u]);
1204
+ const $ = M((b) => {
1205
+ const N = b.replace(/[^0-9.]/g, "").replace(/\.+/g, ".").replace(/^(\.)/g, ""), o = Ce(N, 6), E = Number(o);
1206
+ i(o), p(isNaN(E) ? 0 : E), C(!0), n.invalidateQuote(), I.current && clearTimeout(I.current), I.current = setTimeout(() => {
1207
+ C(!1), I.current = null;
1208
+ }, _t);
1209
+ }, [n]), D = M(() => {
1210
+ i(String(k)), p(k), C(!1), y && v();
1211
+ }, [k, y, v]), T = M(
1212
+ (b) => {
1213
+ const N = k * b / 100, o = Ce(String(N), 6);
1214
+ i(o), p(N), C(!1), y && v();
1097
1215
  },
1098
- [x, u, v]
1099
- ), O = D(() => {
1100
- const g = e.sellToken, y = e.buyToken;
1101
- if (!g || !y) return;
1102
- const c = s || "0", f = n.buyAmountForInput || n.buyAmount || "0";
1103
- if (n.cancelRequest(), n.invalidateQuote(), e.updateNetworkSell(y.chainId), e.updateNetworkBuy(g.chainId), e.setSellToken(y), e.setBuyToken(g), f !== "0" && f !== "0.0") {
1104
- const S = xe(f, 6);
1105
- a(S), w(Number(S));
1216
+ [k, y, v]
1217
+ ), O = M(() => {
1218
+ if (s) return;
1219
+ const b = t.sellToken, N = t.buyToken;
1220
+ if (!b || !N) return;
1221
+ const o = l || "0", E = n.buyAmountForInput || n.buyAmount || "0";
1222
+ if (n.cancelRequest(), n.invalidateQuote(), t.updateNetworkSell(N.chainId), t.updateNetworkBuy(b.chainId), t.setSellToken(N), t.setBuyToken(b), E !== "0" && E !== "0.0") {
1223
+ const V = Ce(E, 6);
1224
+ i(V), p(Number(V));
1106
1225
  } else
1107
- a(""), w(0);
1108
- c !== "0" && c !== "0.0" ? (n.setBuyAmount(xe(c, 6)), n.setBuyAmountForInput(xe(c, 6))) : (n.setBuyAmount(""), n.setBuyAmountForInput(""));
1109
- }, [e, n, s]);
1226
+ i(""), p(0);
1227
+ o !== "0" && o !== "0.0" ? (n.setBuyAmount(Ce(o, 6)), n.setBuyAmountForInput(Ce(o, 6))) : (n.setBuyAmount(""), n.setBuyAmountForInput(""));
1228
+ }, [t, n, l, s]);
1110
1229
  return {
1111
- ...e,
1230
+ ...t,
1112
1231
  ...n,
1113
1232
  slippage: r,
1114
- sellAmountForInput: s,
1115
- setSellAmountForInput: a,
1116
- validatedSellAmount: i,
1117
- processSellInput: o,
1118
- setMaxSellAmount: M,
1119
- setSellAmountByPercent: R,
1233
+ swapLocked: s,
1234
+ sellAmountForInput: l,
1235
+ setSellAmountForInput: i,
1236
+ validatedSellAmount: u,
1237
+ processSellInput: $,
1238
+ setMaxSellAmount: D,
1239
+ setSellAmountByPercent: T,
1120
1240
  swapTokens: O,
1121
- balance: x,
1241
+ balance: k,
1122
1242
  balanceBuy: m,
1123
- allFieldsReady: u,
1124
- isProcessingInput: h,
1125
- isSameToken: (g, y) => !!g && !!y && g.contractAddress === y.contractAddress && g.chainId === y.chainId
1243
+ allFieldsReady: y,
1244
+ isProcessingInput: g,
1245
+ isSameToken: (b, N) => !!b && !!N && b.contractAddress === N.contractAddress && b.chainId === N.chainId
1126
1246
  };
1127
1247
  }
1128
- const Yt = {
1248
+ const Zt = {
1129
1249
  trade: {
1130
1250
  possibleChars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+{}:"<>?|',
1131
1251
  glitchChars: '!@#$%^&*()_+{}:"<>?|\\',
@@ -1141,72 +1261,72 @@ const Yt = {
1141
1261
  animationSpeed: 25
1142
1262
  }
1143
1263
  };
1144
- function Kt({
1145
- ref: t,
1146
- text: e,
1264
+ function en({
1265
+ ref: e,
1266
+ text: t,
1147
1267
  enabled: n,
1148
1268
  preset: r = "trade",
1149
1269
  onAnimationStart: s,
1150
- onAnimationEnd: a
1270
+ onAnimationEnd: l
1151
1271
  }) {
1152
- const i = se(null);
1153
- pt(() => {
1154
- const w = t.current;
1155
- w && (!n || !e || e === "0" || e === "0.0") && (w.textContent = e);
1156
- }, [t, e, n]), oe(() => {
1157
- const w = t.current;
1158
- if (!w) return;
1159
- if (!n || !e || e === "0" || e === "0.0") {
1160
- w.textContent = e;
1272
+ const i = X(null);
1273
+ yt(() => {
1274
+ const u = e.current;
1275
+ u && (!n || !t || t === "0" || t === "0.0") && (u.textContent = t);
1276
+ }, [e, t, n]), re(() => {
1277
+ const u = e.current;
1278
+ if (!u) return;
1279
+ if (!n || !t || t === "0" || t === "0.0") {
1280
+ u.textContent = t;
1161
1281
  return;
1162
1282
  }
1163
- const { possibleChars: h, glitchChars: p, cyberChars: k, animationFrames: x, animationSpeed: m } = Yt[r], u = String(e);
1283
+ const { possibleChars: p, glitchChars: g, cyberChars: C, animationFrames: I, animationSpeed: k } = Zt[r], m = String(t);
1164
1284
  i.current && (clearTimeout(i.current), i.current = null);
1165
- let v = 0;
1166
- const o = Array(u.length).fill(!1), M = Array(u.length).fill(!1), R = () => {
1167
- if (!t.current) return;
1168
- if (v >= x) {
1169
- t.current.textContent = u, i.current = null, a == null || a();
1285
+ let y = 0;
1286
+ const v = Array(m.length).fill(!1), $ = Array(m.length).fill(!1), D = () => {
1287
+ if (!e.current) return;
1288
+ if (y >= I) {
1289
+ e.current.textContent = m, i.current = null, l == null || l();
1170
1290
  return;
1171
1291
  }
1172
- v === 0 && (s == null || s());
1173
- let L = "";
1174
- const V = v / x, $ = Math.pow(V, 0.6), l = Math.floor(u.length * $);
1175
- for (let g = 0; g < l; g++)
1176
- M[g] || (M[g] = !0);
1177
- if (v % 2 === 0) {
1178
- const g = 0.05 + V * 0.1;
1179
- for (let y = 0; y < u.length; y++)
1180
- Math.random() < g && (o[y] = !o[y]);
1292
+ y === 0 && (s == null || s());
1293
+ let O = "";
1294
+ const K = y / I, q = Math.pow(K, 0.6), L = Math.floor(m.length * q);
1295
+ for (let h = 0; h < L; h++)
1296
+ $[h] || ($[h] = !0);
1297
+ if (y % 2 === 0) {
1298
+ const h = 0.05 + K * 0.1;
1299
+ for (let b = 0; b < m.length; b++)
1300
+ Math.random() < h && (v[b] = !v[b]);
1181
1301
  }
1182
- for (let g = 0; g < u.length; g++)
1183
- if (M[g])
1184
- o[g] && v < x * 0.95 && u[g] !== " " ? Math.random() < 0.3 ? L += k[Math.floor(Math.random() * k.length)] : L += p[Math.floor(Math.random() * p.length)] : L += u[g];
1185
- else if (u[g] === " ")
1186
- L += " ";
1302
+ for (let h = 0; h < m.length; h++)
1303
+ if ($[h])
1304
+ v[h] && y < I * 0.95 && m[h] !== " " ? Math.random() < 0.3 ? O += C[Math.floor(Math.random() * C.length)] : O += g[Math.floor(Math.random() * g.length)] : O += m[h];
1305
+ else if (m[h] === " ")
1306
+ O += " ";
1187
1307
  else {
1188
- const y = Math.random();
1189
- y < 0.2 ? L += p[Math.floor(Math.random() * p.length)] : y < 0.4 ? L += k[Math.floor(Math.random() * k.length)] : L += h[Math.floor(Math.random() * h.length)];
1308
+ const b = Math.random();
1309
+ b < 0.2 ? O += g[Math.floor(Math.random() * g.length)] : b < 0.4 ? O += C[Math.floor(Math.random() * C.length)] : O += p[Math.floor(Math.random() * p.length)];
1190
1310
  }
1191
- t.current.textContent = L, v++;
1192
- let C = m;
1193
- V < 0.3 ? C = m * 0.8 : V > 0.7 ? C = m * 0.7 : C = m * 1.2, i.current = setTimeout(R, C);
1194
- }, O = setTimeout(() => {
1195
- t.current && R();
1311
+ e.current.textContent = O, y++;
1312
+ let c = k;
1313
+ K < 0.3 ? c = k * 0.8 : K > 0.7 ? c = k * 0.7 : c = k * 1.2, i.current = setTimeout(D, c);
1314
+ }, T = setTimeout(() => {
1315
+ e.current && D();
1196
1316
  }, 0);
1197
1317
  return () => {
1198
- clearTimeout(O), i.current && (clearTimeout(i.current), i.current = null), a == null || a();
1318
+ clearTimeout(T), i.current && (clearTimeout(i.current), i.current = null), l == null || l();
1199
1319
  };
1200
- }, [t, e, n, r]);
1320
+ }, [e, t, n, r]);
1201
1321
  }
1202
- function re(t, e) {
1203
- if (!t) return "";
1204
- if (t.startsWith("http://") || t.startsWith("https://") || t.startsWith("data:"))
1205
- return t;
1206
- const n = (e == null ? void 0 : e.replace(/\/$/, "")) ?? "";
1207
- return t.startsWith("/") ? `${n}${t}` : `${n}/${t}`;
1322
+ function me(e, t) {
1323
+ if (!e) return "";
1324
+ if (e.startsWith("http://") || e.startsWith("https://") || e.startsWith("data:"))
1325
+ return e;
1326
+ const n = (t == null ? void 0 : t.replace(/\/$/, "")) ?? "";
1327
+ return e.startsWith("/") ? `${n}${e}` : `${n}/${e}`;
1208
1328
  }
1209
- const qt = "data:image/svg+xml,%3csvg%20width='27'%20height='27'%20viewBox='0%200%2027%2027'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7.42142%203.29834C6.61961%203.29834%205.85064%203.61686%205.28367%204.18383C4.71671%204.75079%204.39819%205.51976%204.39819%206.32158V22.5371H4.12335C3.90467%2022.5371%203.69495%2022.624%203.54032%2022.7786C3.3857%2022.9332%203.29883%2023.143%203.29883%2023.3616C3.29883%2023.5803%203.3857%2023.79%203.54032%2023.9447C3.69495%2024.0993%203.90467%2024.1862%204.12335%2024.1862H18.9647C19.1834%2024.1862%2019.3931%2024.0993%2019.5477%2023.9447C19.7023%2023.79%2019.7892%2023.5803%2019.7892%2023.3616C19.7892%2023.143%2019.7023%2022.9332%2019.5477%2022.7786C19.3931%2022.624%2019.1834%2022.5371%2018.9647%2022.5371H18.6899V20.555C19.1499%2020.7915%2019.6631%2020.9058%2020.1801%2020.8868C20.697%2020.8679%2021.2005%2020.7163%2021.642%2020.4468C22.0835%2020.1772%2022.4484%2019.7987%2022.7015%2019.3475C22.9546%2018.8963%2023.0874%2018.3877%2023.0873%2017.8703V11.4523C23.0873%2010.7981%2022.8751%2010.1617%2022.4826%209.63834L21.2733%208.02558C21.1421%207.85064%2020.9468%207.73499%2020.7303%207.70406C20.5139%207.67314%2020.294%207.72947%2020.119%207.86068C19.9441%207.99189%2019.8284%208.18721%2019.7975%208.40369C19.7666%208.62017%2019.8229%208.84007%2019.9541%209.01501L21.1634%2010.6278C21.3415%2010.8652%2021.4383%2011.1555%2021.4383%2011.4523V17.8703C21.4383%2018.0501%2021.4028%2018.2281%2021.3341%2018.3941C21.2653%2018.5602%2021.1645%2018.7111%2021.0374%2018.8382C20.9103%2018.9653%2020.7594%2019.0661%2020.5933%2019.1349C20.4273%2019.2036%2020.2493%2019.239%2020.0695%2019.239C19.8898%2019.239%2019.7118%2019.2036%2019.5458%2019.1349C19.3797%2019.0661%2019.2288%2018.9653%2019.1017%2018.8382C18.9746%2018.7111%2018.8738%2018.5602%2018.805%2018.3941C18.7363%2018.2281%2018.7008%2018.0501%2018.7008%2017.8703V15.941C18.6999%2015.8964%2018.6962%2015.852%2018.6899%2015.8079V6.32158C18.6899%205.92456%2018.6117%205.53143%2018.4597%205.16463C18.3078%204.79784%2018.0851%204.46456%2017.8044%204.18383C17.5236%203.90309%2017.1904%203.6804%2016.8236%203.52847C16.4568%203.37654%2016.0636%203.29834%2015.6666%203.29834H7.42142ZM7.69626%207.42094C7.69626%207.20226%207.78313%206.99254%207.93776%206.83791C8.09239%206.68329%208.30211%206.59642%208.52078%206.59642H14.5673C14.7859%206.59642%2014.9957%206.68329%2015.1503%206.83791C15.3049%206.99254%2015.3918%207.20226%2015.3918%207.42094V11.2687C15.3918%2011.4874%2015.3049%2011.6971%2015.1503%2011.8517C14.9957%2012.0063%2014.7859%2012.0932%2014.5673%2012.0932H8.52078C8.30211%2012.0932%208.09239%2012.0063%207.93776%2011.8517C7.78313%2011.6971%207.69626%2011.4874%207.69626%2011.2687V7.42094Z'%20fill='white'/%3e%3c/svg%3e", Jt = {
1329
+ const tn = "data:image/svg+xml,%3csvg%20width='27'%20height='27'%20viewBox='0%200%2027%2027'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7.42142%203.29834C6.61961%203.29834%205.85064%203.61686%205.28367%204.18383C4.71671%204.75079%204.39819%205.51976%204.39819%206.32158V22.5371H4.12335C3.90467%2022.5371%203.69495%2022.624%203.54032%2022.7786C3.3857%2022.9332%203.29883%2023.143%203.29883%2023.3616C3.29883%2023.5803%203.3857%2023.79%203.54032%2023.9447C3.69495%2024.0993%203.90467%2024.1862%204.12335%2024.1862H18.9647C19.1834%2024.1862%2019.3931%2024.0993%2019.5477%2023.9447C19.7023%2023.79%2019.7892%2023.5803%2019.7892%2023.3616C19.7892%2023.143%2019.7023%2022.9332%2019.5477%2022.7786C19.3931%2022.624%2019.1834%2022.5371%2018.9647%2022.5371H18.6899V20.555C19.1499%2020.7915%2019.6631%2020.9058%2020.1801%2020.8868C20.697%2020.8679%2021.2005%2020.7163%2021.642%2020.4468C22.0835%2020.1772%2022.4484%2019.7987%2022.7015%2019.3475C22.9546%2018.8963%2023.0874%2018.3877%2023.0873%2017.8703V11.4523C23.0873%2010.7981%2022.8751%2010.1617%2022.4826%209.63834L21.2733%208.02558C21.1421%207.85064%2020.9468%207.73499%2020.7303%207.70406C20.5139%207.67314%2020.294%207.72947%2020.119%207.86068C19.9441%207.99189%2019.8284%208.18721%2019.7975%208.40369C19.7666%208.62017%2019.8229%208.84007%2019.9541%209.01501L21.1634%2010.6278C21.3415%2010.8652%2021.4383%2011.1555%2021.4383%2011.4523V17.8703C21.4383%2018.0501%2021.4028%2018.2281%2021.3341%2018.3941C21.2653%2018.5602%2021.1645%2018.7111%2021.0374%2018.8382C20.9103%2018.9653%2020.7594%2019.0661%2020.5933%2019.1349C20.4273%2019.2036%2020.2493%2019.239%2020.0695%2019.239C19.8898%2019.239%2019.7118%2019.2036%2019.5458%2019.1349C19.3797%2019.0661%2019.2288%2018.9653%2019.1017%2018.8382C18.9746%2018.7111%2018.8738%2018.5602%2018.805%2018.3941C18.7363%2018.2281%2018.7008%2018.0501%2018.7008%2017.8703V15.941C18.6999%2015.8964%2018.6962%2015.852%2018.6899%2015.8079V6.32158C18.6899%205.92456%2018.6117%205.53143%2018.4597%205.16463C18.3078%204.79784%2018.0851%204.46456%2017.8044%204.18383C17.5236%203.90309%2017.1904%203.6804%2016.8236%203.52847C16.4568%203.37654%2016.0636%203.29834%2015.6666%203.29834H7.42142ZM7.69626%207.42094C7.69626%207.20226%207.78313%206.99254%207.93776%206.83791C8.09239%206.68329%208.30211%206.59642%208.52078%206.59642H14.5673C14.7859%206.59642%2014.9957%206.68329%2015.1503%206.83791C15.3049%206.99254%2015.3918%207.20226%2015.3918%207.42094V11.2687C15.3918%2011.4874%2015.3049%2011.6971%2015.1503%2011.8517C14.9957%2012.0063%2014.7859%2012.0932%2014.5673%2012.0932H8.52078C8.30211%2012.0932%208.09239%2012.0063%207.93776%2011.8517C7.78313%2011.6971%207.69626%2011.4874%207.69626%2011.2687V7.42094Z'%20fill='white'/%3e%3c/svg%3e", nn = {
1210
1330
  swap: "Swap",
1211
1331
  finding: "Finding Routes...",
1212
1332
  approve: "Approve",
@@ -1216,57 +1336,61 @@ const qt = "data:image/svg+xml,%3csvg%20width='27'%20height='27'%20viewBox='0%20
1216
1336
  "wrong-address": "Wrong address",
1217
1337
  "rate-limit": "Try later"
1218
1338
  };
1219
- function Gt(t) {
1339
+ function rn(e) {
1220
1340
  const {
1221
- sellToken: e,
1341
+ sellToken: t,
1222
1342
  buyToken: n,
1223
1343
  networkSellLogo: r,
1224
1344
  networkBuyLogo: s,
1225
- assetBaseUrl: a,
1345
+ assetBaseUrl: l,
1226
1346
  sellAmountForInput: i,
1227
- buyAmountForInput: w,
1228
- onSellAmountChange: h,
1229
- onSellInputProcess: p,
1230
- onOpenSellToken: k,
1231
- onOpenBuyToken: x,
1232
- onSwapTokens: m,
1233
- onRefresh: u,
1234
- onOpenSettings: v,
1235
- balance: o,
1236
- balanceBuy: M,
1237
- sellPriceUsd: R,
1238
- buyPriceUsd: O,
1239
- onMaxClick: L,
1240
- onSet50Percent: V,
1241
- onSet25Percent: $,
1242
- buttonState: l,
1243
- txData: C,
1244
- loading: g,
1245
- price: y,
1246
- gasCostUSD: c,
1247
- truncateTo6Decimals: f,
1248
- isWalletConnected: S = !1,
1249
- onConnectWallet: N
1250
- } = t, T = !!i && Number(i) > 0, P = l === "insufficient" || l === "no-available-quotes" || l === "wrong-address", J = !T || g || S && !C && l !== "finding" || l === "no-available-quotes" || l === "insufficient", G = se(null), H = se(null), ve = se(0), I = () => {
1251
- u(), ve.current += 1;
1252
- const W = H.current;
1253
- W && (W.style.transform = `rotate(${ve.current * -720}deg)`);
1347
+ buyAmountForInput: u,
1348
+ onSellAmountChange: p,
1349
+ onSellInputProcess: g,
1350
+ onOpenSellToken: C,
1351
+ onOpenBuyToken: I,
1352
+ onSwapTokens: k,
1353
+ onRefresh: m,
1354
+ onOpenSettings: y,
1355
+ balance: v,
1356
+ balanceBuy: $,
1357
+ sellPriceUsd: D,
1358
+ buyPriceUsd: T,
1359
+ onMaxClick: O,
1360
+ onSet50Percent: K,
1361
+ onSet25Percent: q,
1362
+ buttonState: L,
1363
+ txData: c,
1364
+ loading: h,
1365
+ price: b,
1366
+ gasCostUSD: N,
1367
+ truncateTo6Decimals: o,
1368
+ isWalletConnected: E = !1,
1369
+ onConnectWallet: V,
1370
+ onAction: J,
1371
+ swapDisabled: G = !1,
1372
+ sellTokenLocked: ie = !1,
1373
+ buyTokenLocked: fe = !1
1374
+ } = e, ee = !!i && Number(i) > 0, ce = L === "insufficient" || L === "no-available-quotes" || L === "wrong-address", de = !ee || h || E && !c && L !== "finding" || L === "no-available-quotes" || L === "insufficient", oe = E ? de : !1, w = X(null), a = X(null), S = X(0), W = () => {
1375
+ m(), S.current += 1;
1376
+ const f = a.current;
1377
+ f && (f.style.transform = `rotate(${S.current * -720}deg)`);
1254
1378
  };
1255
- Kt({
1256
- ref: G,
1257
- text: w || "0.0",
1258
- enabled: !!(n != null && n.symbol) && Number(i) > 0 && !!w && w !== "0" && w !== "0.0",
1379
+ en({
1380
+ ref: w,
1381
+ text: u || "0.0",
1382
+ enabled: !!(n != null && n.symbol) && Number(i) > 0 && !!u && u !== "0" && u !== "0.0",
1259
1383
  preset: "trade"
1260
1384
  });
1261
- const Y = (W) => {
1262
- if ([",", ".", "/", "б", "ю"].includes(W.key)) {
1263
- W.preventDefault();
1264
- const X = W.target;
1265
- if (X.value.includes(".")) return;
1266
- const he = X.selectionStart ?? X.value.length, pe = X.value.slice(0, he) + "." + X.value.slice(he);
1267
- h(pe), p(pe);
1385
+ const Q = (f) => {
1386
+ if ([",", ".", "/", "б", "ю"].includes(f.key)) {
1387
+ f.preventDefault();
1388
+ const P = f.target;
1389
+ if (P.value.includes(".")) return;
1390
+ const _ = P.selectionStart ?? P.value.length, le = P.value.slice(0, _) + "." + P.value.slice(_);
1391
+ p(le), g(le);
1268
1392
  }
1269
- }, ee = S ? `dw-w-full dw-h-[38px] dw-rounded-[var(--dw-radius)] dw-border dw-text-[13px] dw-font-normal dw-transition-colors ${P ? "dw-bg-[var(--dw-danger)] dw-border-[var(--dw-danger)] dw-text-white" : J ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-border)] dw-text-[var(--dw-muted)]" : "dw-bg-[var(--dw-accent)] dw-border-[var(--dw-accent)] dw-text-white hover:dw-bg-[var(--dw-accent-hover)] hover:dw-border-[var(--dw-accent-hover)]"}` : "dw-w-full dw-h-[38px] dw-rounded-[var(--dw-radius)] dw-border dw-border-[var(--dw-accent)] dw-text-[13px] dw-font-normal dw-transition-colors dw-bg-[var(--dw-accent)] dw-text-white hover:dw-bg-[var(--dw-accent-hover)] hover:dw-border-[var(--dw-accent-hover)]";
1393
+ }, z = E ? `dw-w-full dw-h-[38px] dw-rounded-[var(--dw-radius)] dw-border dw-text-[13px] dw-font-normal dw-transition-colors ${ce ? "dw-bg-[var(--dw-danger)] dw-border-[var(--dw-danger)] dw-text-white" : de ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-border)] dw-text-[var(--dw-muted)]" : "dw-bg-[var(--dw-accent)] dw-border-[var(--dw-accent)] dw-text-white hover:dw-bg-[var(--dw-accent-hover)] hover:dw-border-[var(--dw-accent-hover)]"}` : "dw-w-full dw-h-[38px] dw-rounded-[var(--dw-radius)] dw-border dw-border-[var(--dw-accent)] dw-text-[13px] dw-font-normal dw-transition-colors dw-bg-[var(--dw-accent)] dw-text-white hover:dw-bg-[var(--dw-accent-hover)] hover:dw-border-[var(--dw-accent-hover)]";
1270
1394
  return /* @__PURE__ */ A("div", { className: "dw-widget-shell dw-elevated-surface dw-flex dw-flex-col dw-gap-1.5 dw-font-mono", children: [
1271
1395
  /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between dw-mb-0.5", children: [
1272
1396
  /* @__PURE__ */ d("h3", { className: "dw-text-[14px] dw-font-normal dw-text-[var(--dw-fg)]", children: "Trade" }),
@@ -1276,15 +1400,15 @@ function Gt(t) {
1276
1400
  {
1277
1401
  type: "button",
1278
1402
  className: "dw-icon-button dw-w-4 dw-h-4 dw-flex dw-items-center dw-justify-center dw-rounded-[4px] dw-cursor-pointer dw-opacity-70",
1279
- onMouseDown: I,
1403
+ onMouseDown: W,
1280
1404
  "aria-label": "Refresh",
1281
1405
  children: /* @__PURE__ */ d(
1282
1406
  "span",
1283
1407
  {
1284
- ref: H,
1408
+ ref: a,
1285
1409
  className: "dw-w-full dw-h-full dw-flex dw-items-center dw-justify-center",
1286
1410
  style: { transition: "transform 1s ease-in-out" },
1287
- children: /* @__PURE__ */ d(Zt, {})
1411
+ children: /* @__PURE__ */ d(dn, {})
1288
1412
  }
1289
1413
  )
1290
1414
  }
@@ -1294,9 +1418,9 @@ function Gt(t) {
1294
1418
  {
1295
1419
  type: "button",
1296
1420
  className: "dw-icon-button dw-w-4 dw-h-4 dw-flex dw-items-center dw-justify-center dw-rounded-[4px] dw-cursor-pointer dw-opacity-70",
1297
- onClick: v,
1421
+ onClick: y,
1298
1422
  "aria-label": "Settings",
1299
- children: /* @__PURE__ */ d(en, {})
1423
+ children: /* @__PURE__ */ d(ln, {})
1300
1424
  }
1301
1425
  )
1302
1426
  ] })
@@ -1306,50 +1430,53 @@ function Gt(t) {
1306
1430
  "button",
1307
1431
  {
1308
1432
  type: "button",
1309
- className: "dw-widget-section dw-group dw-w-[30px] dw-h-[30px] dw-absolute dw-left-1/2 dw-top-1/2 dw-z-10 dw--translate-x-1/2 dw--translate-y-1/2 dw-cursor-pointer dw-flex dw-justify-center dw-items-center",
1310
- onClick: m,
1433
+ className: `dw-widget-section dw-group dw-w-[30px] dw-h-[30px] dw-absolute dw-left-1/2 dw-top-1/2 dw-z-10 dw--translate-x-1/2 dw--translate-y-1/2 dw-flex dw-justify-center dw-items-center ${G ? "dw-cursor-not-allowed dw-opacity-40" : "dw-cursor-pointer"}`,
1434
+ onClick: k,
1311
1435
  "aria-label": "Swap tokens",
1312
- children: /* @__PURE__ */ d(Xt, {})
1436
+ disabled: G,
1437
+ children: /* @__PURE__ */ d(sn, {})
1313
1438
  }
1314
1439
  ),
1315
1440
  /* @__PURE__ */ d(
1316
- Ge,
1441
+ nt,
1317
1442
  {
1318
1443
  label: "From",
1319
1444
  labelTone: "danger",
1320
- token: e,
1445
+ token: t,
1321
1446
  networkLogo: r,
1322
- assetBaseUrl: a,
1447
+ assetBaseUrl: l,
1323
1448
  amount: i,
1324
1449
  amountPlaceholder: "0.0",
1325
- usdValue: R || "$0.000",
1326
- balance: f(o),
1327
- onOpenToken: k,
1328
- onInputChange: (W) => {
1329
- h(W), p(W);
1450
+ usdValue: D || "$0.000",
1451
+ balance: o(v),
1452
+ onOpenToken: C,
1453
+ tokenLocked: ie,
1454
+ onInputChange: (f) => {
1455
+ p(f), g(f);
1330
1456
  },
1331
- onKeyDown: Y,
1332
- amountToneClassName: P ? "dw-text-[var(--dw-danger)]" : "dw-text-[var(--dw-fg)]",
1333
- quickActions: /* @__PURE__ */ A(ht, { children: [
1334
- /* @__PURE__ */ d(Me, { label: "MAX", onClick: L }),
1335
- /* @__PURE__ */ d(Me, { label: "50%", onClick: V }),
1336
- /* @__PURE__ */ d(Me, { label: "25%", onClick: $ })
1457
+ onKeyDown: Q,
1458
+ amountToneClassName: ce ? "dw-text-[var(--dw-danger)]" : "dw-text-[var(--dw-fg)]",
1459
+ quickActions: /* @__PURE__ */ A(xt, { children: [
1460
+ /* @__PURE__ */ d(Oe, { label: "MAX", onClick: O }),
1461
+ /* @__PURE__ */ d(Oe, { label: "50%", onClick: K }),
1462
+ /* @__PURE__ */ d(Oe, { label: "25%", onClick: q })
1337
1463
  ] })
1338
1464
  }
1339
1465
  ),
1340
1466
  /* @__PURE__ */ d(
1341
- Ge,
1467
+ nt,
1342
1468
  {
1343
1469
  label: "To",
1344
1470
  labelTone: "success",
1345
1471
  token: n,
1346
1472
  networkLogo: s,
1347
- assetBaseUrl: a,
1348
- amount: w || "0.0",
1349
- usdValue: O || "$0.000",
1350
- balance: f(M),
1351
- onOpenToken: x,
1352
- amountRef: G,
1473
+ assetBaseUrl: l,
1474
+ amount: u || "0.0",
1475
+ usdValue: T || "$0.000",
1476
+ balance: o($),
1477
+ onOpenToken: I,
1478
+ tokenLocked: fe,
1479
+ amountRef: w,
1353
1480
  readOnly: !0
1354
1481
  }
1355
1482
  ),
@@ -1357,42 +1484,42 @@ function Gt(t) {
1357
1484
  "button",
1358
1485
  {
1359
1486
  type: "button",
1360
- className: ee,
1361
- disabled: S ? J : !1,
1362
- onClick: S ? () => {
1363
- } : N,
1364
- children: S ? Jt[l] : "Connect Wallet"
1487
+ className: z,
1488
+ disabled: oe,
1489
+ onClick: E ? J : V,
1490
+ children: E ? nn[L] : "Connect Wallet"
1365
1491
  }
1366
1492
  ),
1367
1493
  /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between dw-min-h-[12px] dw-px-0.5", children: [
1368
1494
  /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-1 dw-min-w-0", children: [
1369
- /* @__PURE__ */ d("img", { src: qt, alt: "", className: "dw-w-[10px] dw-h-[10px]" }),
1370
- /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)]", children: C ? c ?? "—" : "$<0.01" })
1495
+ /* @__PURE__ */ d("img", { src: tn, alt: "", className: "dw-w-[10px] dw-h-[10px]" }),
1496
+ /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)]", children: c ? N ?? "—" : "$<0.01" })
1371
1497
  ] }),
1372
- /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] dw-truncate dw-ml-3", children: C && (e != null && e.symbol) && (n != null && n.symbol) ? `1 ${e.symbol} = ${y} ${n.symbol}` : "" })
1498
+ /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] dw-truncate dw-ml-3", children: c && (t != null && t.symbol) && (n != null && n.symbol) ? `1 ${t.symbol} = ${b} ${n.symbol}` : "" })
1373
1499
  ] })
1374
1500
  ] })
1375
1501
  ] });
1376
1502
  }
1377
- function Ge(t) {
1503
+ function nt(e) {
1378
1504
  const {
1379
- label: e,
1505
+ label: t,
1380
1506
  labelTone: n,
1381
1507
  token: r,
1382
1508
  networkLogo: s,
1383
- assetBaseUrl: a,
1509
+ assetBaseUrl: l,
1384
1510
  amount: i,
1385
- amountPlaceholder: w = "0.0",
1386
- usdValue: h,
1387
- balance: p,
1388
- onOpenToken: k,
1389
- onInputChange: x,
1390
- onKeyDown: m,
1391
- amountToneClassName: u = "dw-text-[var(--dw-fg)]",
1392
- amountRef: v,
1393
- readOnly: o = !1,
1394
- quickActions: M
1395
- } = t;
1511
+ amountPlaceholder: u = "0.0",
1512
+ usdValue: p,
1513
+ balance: g,
1514
+ onOpenToken: C,
1515
+ onInputChange: I,
1516
+ onKeyDown: k,
1517
+ amountToneClassName: m = "dw-text-[var(--dw-fg)]",
1518
+ amountRef: y,
1519
+ readOnly: v = !1,
1520
+ quickActions: $,
1521
+ tokenLocked: D = !1
1522
+ } = e;
1396
1523
  return /* @__PURE__ */ A("div", { className: "dw-widget-section dw-relative dw-flex dw-flex-col dw-w-full dw-min-h-[91px] dw-px-4 dw-py-3", children: [
1397
1524
  /* @__PURE__ */ A("div", { className: "dw-flex dw-items-start dw-justify-between", children: [
1398
1525
  /* @__PURE__ */ A("div", { className: "dw-flex dw-flex-col dw-gap-2", children: [
@@ -1400,81 +1527,82 @@ function Ge(t) {
1400
1527
  "h6",
1401
1528
  {
1402
1529
  className: `dw-font-normal dw-text-[11px] ${n === "danger" ? "dw-text-[var(--dw-danger)]" : "dw-text-[var(--dw-success)]"}`,
1403
- children: e
1530
+ children: t
1404
1531
  }
1405
1532
  ),
1406
1533
  /* @__PURE__ */ A(
1407
1534
  "button",
1408
1535
  {
1409
1536
  type: "button",
1410
- className: "dw-flex dw-items-center dw-gap-2 dw-cursor-pointer",
1411
- onClick: k,
1537
+ className: `dw-flex dw-items-center dw-gap-2 ${D ? "dw-cursor-not-allowed dw-opacity-60" : "dw-cursor-pointer"}`,
1538
+ onClick: C,
1539
+ disabled: D,
1412
1540
  children: [
1413
1541
  /* @__PURE__ */ d(
1414
- _t,
1542
+ on,
1415
1543
  {
1416
1544
  token: r,
1417
1545
  networkLogo: s,
1418
- assetBaseUrl: a,
1546
+ assetBaseUrl: l,
1419
1547
  sizeClassName: "dw-w-[28px] dw-h-[28px]",
1420
1548
  badgeClassName: "dw-w-[10px] dw-h-[10px]"
1421
1549
  }
1422
1550
  ),
1423
1551
  /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[13px] dw-text-[var(--dw-fg)]", children: (r == null ? void 0 : r.symbol) ?? "Select" }),
1424
- /* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: "▼" })
1552
+ /* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: D ? "LOCK" : "▼" })
1425
1553
  ]
1426
1554
  }
1427
1555
  )
1428
1556
  ] }),
1429
1557
  /* @__PURE__ */ A("div", { className: "dw-flex dw-flex-col dw-items-end dw-min-w-0", children: [
1430
- o ? /* @__PURE__ */ d(
1558
+ v ? /* @__PURE__ */ d(
1431
1559
  "p",
1432
1560
  {
1433
- ref: v,
1434
- className: `dw-font-normal dw-text-[20px] dw-min-w-[70px] dw-max-w-[124px] dw-text-right dw-truncate ${u}`,
1435
- children: i || w
1561
+ ref: y,
1562
+ className: `dw-font-normal dw-text-[20px] dw-min-w-[70px] dw-max-w-[124px] dw-text-right dw-truncate ${m}`,
1563
+ children: i || u
1436
1564
  }
1437
1565
  ) : /* @__PURE__ */ d(
1438
1566
  "input",
1439
1567
  {
1440
1568
  type: "text",
1441
- placeholder: w,
1569
+ placeholder: u,
1442
1570
  value: i,
1443
- onChange: (R) => x == null ? void 0 : x(R.target.value),
1444
- onKeyDown: m,
1445
- className: `dw-h-[28px] dw-w-[124px] dw-font-normal dw-text-right dw-bg-transparent dw-outline-none dw-border-none dw-text-[20px] ${u}`
1571
+ onChange: (T) => I == null ? void 0 : I(T.target.value),
1572
+ onKeyDown: k,
1573
+ className: `dw-h-[28px] dw-w-[124px] dw-font-normal dw-text-right dw-bg-transparent dw-outline-none dw-border-none dw-text-[20px] ${m}`
1446
1574
  }
1447
1575
  ),
1448
- /* @__PURE__ */ d("p", { className: "dw-mt-1 dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: h })
1576
+ /* @__PURE__ */ d("p", { className: "dw-mt-1 dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: p })
1449
1577
  ] })
1450
1578
  ] }),
1451
1579
  /* @__PURE__ */ d("div", { className: "dw-w-full dw-flex dw-items-center dw-justify-between dw-mt-2 dw-min-h-[12px]", children: /* @__PURE__ */ A("div", { className: "dw-flex dw-gap-2 dw-items-center dw-min-w-0", children: [
1452
- /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: p }),
1453
- M
1580
+ /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: g }),
1581
+ $
1454
1582
  ] }) })
1455
1583
  ] });
1456
1584
  }
1457
- function Me(t) {
1585
+ function Oe(e) {
1458
1586
  return /* @__PURE__ */ d(
1459
1587
  "button",
1460
1588
  {
1461
1589
  type: "button",
1462
1590
  className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)] dw-cursor-pointer hover:dw-text-[var(--dw-text-subtle)]",
1463
- onClick: t.onClick,
1464
- children: t.label
1591
+ onClick: e.onClick,
1592
+ children: e.label
1465
1593
  }
1466
1594
  );
1467
1595
  }
1468
- function _t(t) {
1469
- var h;
1596
+ function on(e) {
1597
+ var p;
1470
1598
  const {
1471
- token: e,
1599
+ token: t,
1472
1600
  networkLogo: n,
1473
1601
  assetBaseUrl: r,
1474
1602
  sizeClassName: s = "dw-w-[28px] dw-h-[28px]",
1475
- badgeClassName: a = "dw-w-[10px] dw-h-[10px]"
1476
- } = t;
1477
- if (!e)
1603
+ badgeClassName: l = "dw-w-[10px] dw-h-[10px]"
1604
+ } = e;
1605
+ if (!t)
1478
1606
  return /* @__PURE__ */ d(
1479
1607
  "div",
1480
1608
  {
@@ -1482,26 +1610,26 @@ function _t(t) {
1482
1610
  children: /* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-font-normal dw-text-[var(--dw-fg)]", children: "?" })
1483
1611
  }
1484
1612
  );
1485
- const i = re(e.imageUrl, r), w = re(n, r);
1613
+ const i = me(t.imageUrl, r), u = me(n, r);
1486
1614
  return /* @__PURE__ */ A("div", { className: "dw-relative", children: [
1487
1615
  /* @__PURE__ */ d(
1488
1616
  "div",
1489
1617
  {
1490
1618
  className: `${s} dw-rounded-full dw-bg-cover dw-flex dw-items-center dw-justify-center dw-border dw-border-[var(--dw-border)] dw-bg-[var(--dw-surface-hover)]`,
1491
1619
  style: { backgroundImage: i ? `url(${i})` : "none" },
1492
- children: !i && /* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-font-normal dw-text-[var(--dw-fg)]", children: ((h = e.symbol[0]) == null ? void 0 : h.toUpperCase()) ?? "?" })
1620
+ children: !i && /* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-font-normal dw-text-[var(--dw-fg)]", children: ((p = t.symbol[0]) == null ? void 0 : p.toUpperCase()) ?? "?" })
1493
1621
  }
1494
1622
  ),
1495
- w && /* @__PURE__ */ d(
1623
+ u && /* @__PURE__ */ d(
1496
1624
  "div",
1497
1625
  {
1498
- className: `dw-absolute dw--bottom-0.5 dw--left-0.5 ${a} dw-rounded-full dw-bg-cover dw-border dw-border-[var(--dw-surface)]`,
1499
- style: { backgroundImage: `url(${w})` }
1626
+ className: `dw-absolute dw--bottom-0.5 dw--left-0.5 ${l} dw-rounded-full dw-bg-cover dw-border dw-border-[var(--dw-surface)]`,
1627
+ style: { backgroundImage: `url(${u})` }
1500
1628
  }
1501
1629
  )
1502
1630
  ] });
1503
1631
  }
1504
- function Xt() {
1632
+ function sn() {
1505
1633
  return /* @__PURE__ */ A("div", { className: "dw-flex dw-flex-row dw-justify-center dw-items-center dw-w-[14px] dw-h-[14px] dw-gap-0", children: [
1506
1634
  /* @__PURE__ */ A(
1507
1635
  "svg",
@@ -1561,7 +1689,7 @@ function Xt() {
1561
1689
  )
1562
1690
  ] });
1563
1691
  }
1564
- function Zt() {
1692
+ function dn() {
1565
1693
  return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ d(
1566
1694
  "path",
1567
1695
  {
@@ -1573,7 +1701,7 @@ function Zt() {
1573
1701
  }
1574
1702
  ) });
1575
1703
  }
1576
- function en() {
1704
+ function ln() {
1577
1705
  return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ d(
1578
1706
  "path",
1579
1707
  {
@@ -1585,112 +1713,115 @@ function en() {
1585
1713
  }
1586
1714
  ) });
1587
1715
  }
1588
- const tn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAHaSURBVHgB7Zj/dYIwEMcPX/+vGzRuYDewG3QD7QS1G3SDugF0go4AG+gG4ASywfUi4XnEBAkJ4h983ruXQMjlm19ADuDBicARRJxTMgdHoigqIDRSDNmWLCbL0Z+YTEAIyNE72QmHYd1VR2QR90nJzlKnVOaK0K7faNozcEVOgdbbnOybbInV+uuF8pszv/su9SKDo5iSjbosyF6pp6WtUXBDkP3BZZO5j6LWy5VWJkfhB8NsmHp24s4dVdNYc9LK1jjcppEYN86Tds3X2IGPHCWJoX4B/TC9SxNq59g65fTAhvUoZvdTbE7LCj02jPI5V35y5ju9VWnLHt4xRxwBAcHrt0aj4zPteV5Y79wlu5eF/mQpfxm7teLlM7iNYPkChuHI8q0jaEJYHIWktLTXSeA9sH46H0WglUmgL5NAXyaBvkwCfZkE+qIL5N9Erx/SUOgCDyy/Dv1z2oeGQHUeqEXKEZS/4C8wIqY1+MXyAi5nZMndp/1KoBrFD8vzzzAMguULXmDcxSQyoWRB9tviKCR8GRXgwtinuq5O0rHOxZ0irFjFaEyH6r6hOFuUdtH7WIvNqENoZMxnA75gtV5kDGWPYcixij0KW5vOQXRNcK+A+rnhIYLqY/APHpl3hlZpXEMAAAAASUVORK5CYII=", nn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAERSURBVHgB7dShDoMwEAbgK0EgJiYmEAgEAjGx93+KCR4AMTkxMYEgYXdJSbqOo4WVgrg/uRRo034pTQEkEolk3yiInGEYMmyuWNS2SqmH2Z9AxGjMDeuElWKV9phoIAOTGZ972APEYDqsuz128zM0h8Hz00FMEGLorIwH2InZFKQxtDOpL2Yz0FoMJeEm1P8+KoaiJiassCn0K11cLUTCUKZ2qDCeS1ykhEgYDvSy3p2oUBgO1GC9wRMVEkNRzCI0Od0fZ6vr60zhuBybKhSGBRkL1tjkMIHSmNrqo51t1mKcoBnUE+sCvxjamR7+iNfFyKCCY7xBDlQwzCIQgwqKWQzSqPEmp/uqCYmRSCSSI+QD+pyUWCGG+FwAAAAASUVORK5CYII=", rn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAwCAYAAAAhOEsMAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAABZSURBVHgB7c7RCQAgCEVRa5JGbONGKT8KgtQsCPp4FwQRDkh0WRhL5eigSC/jZxJPqVOnqLiggNIWSqjfdaghE1pIhTskQg9aoBdJMHvQAidsIoQQQgj9VgNcp//kKP+JUgAAAABJRU5ErkJggg==";
1589
- function _e(t) {
1716
+ const an = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAHaSURBVHgB7Zj/dYIwEMcPX/+vGzRuYDewG3QD7QS1G3SDugF0go4AG+gG4ASywfUi4XnEBAkJ4h983ruXQMjlm19ADuDBicARRJxTMgdHoigqIDRSDNmWLCbL0Z+YTEAIyNE72QmHYd1VR2QR90nJzlKnVOaK0K7faNozcEVOgdbbnOybbInV+uuF8pszv/su9SKDo5iSjbosyF6pp6WtUXBDkP3BZZO5j6LWy5VWJkfhB8NsmHp24s4dVdNYc9LK1jjcppEYN86Tds3X2IGPHCWJoX4B/TC9SxNq59g65fTAhvUoZvdTbE7LCj02jPI5V35y5ju9VWnLHt4xRxwBAcHrt0aj4zPteV5Y79wlu5eF/mQpfxm7teLlM7iNYPkChuHI8q0jaEJYHIWktLTXSeA9sH46H0WglUmgL5NAXyaBvkwCfZkE+qIL5N9Erx/SUOgCDyy/Dv1z2oeGQHUeqEXKEZS/4C8wIqY1+MXyAi5nZMndp/1KoBrFD8vzzzAMguULXmDcxSQyoWRB9tviKCR8GRXgwtinuq5O0rHOxZ0irFjFaEyH6r6hOFuUdtH7WIvNqENoZMxnA75gtV5kDGWPYcixij0KW5vOQXRNcK+A+rnhIYLqY/APHpl3hlZpXEMAAAAASUVORK5CYII=", cn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAERSURBVHgB7dShDoMwEAbgK0EgJiYmEAgEAjGx93+KCR4AMTkxMYEgYXdJSbqOo4WVgrg/uRRo034pTQEkEolk3yiInGEYMmyuWNS2SqmH2Z9AxGjMDeuElWKV9phoIAOTGZ972APEYDqsuz128zM0h8Hz00FMEGLorIwH2InZFKQxtDOpL2Yz0FoMJeEm1P8+KoaiJiassCn0K11cLUTCUKZ2qDCeS1ykhEgYDvSy3p2oUBgO1GC9wRMVEkNRzCI0Od0fZ6vr60zhuBybKhSGBRkL1tjkMIHSmNrqo51t1mKcoBnUE+sCvxjamR7+iNfFyKCCY7xBDlQwzCIQgwqKWQzSqPEmp/uqCYmRSCSSI+QD+pyUWCGG+FwAAAAASUVORK5CYII=", wn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAwCAYAAAAhOEsMAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAABZSURBVHgB7c7RCQAgCEVRa5JGbONGKT8KgtQsCPp4FwQRDkh0WRhL5eigSC/jZxJPqVOnqLiggNIWSqjfdaghE1pIhTskQg9aoBdJMHvQAidsIoQQQgj9VgNcp//kKP+JUgAAAABJRU5ErkJggg==";
1717
+ function rt(e) {
1590
1718
  const {
1591
- mode: e,
1719
+ mode: t,
1592
1720
  selectedNetworkId: n,
1593
1721
  selectedToken: r,
1594
1722
  excludeToken: s,
1595
- getAllTokensForNetwork: a,
1723
+ getAllTokensForNetwork: l,
1596
1724
  getNetworkById: i,
1597
- onSelectToken: w,
1598
- onSelectNetwork: h,
1599
- onOpenNetworkSelector: p,
1600
- onClose: k,
1601
- assetBaseUrl: x,
1602
- displayedNetworks: m,
1603
- additionalNetworksCount: u
1604
- } = t, [v, o] = U(""), [M, R] = U(
1725
+ onSelectToken: u,
1726
+ onSelectNetwork: p,
1727
+ onOpenNetworkSelector: g,
1728
+ onClose: C,
1729
+ assetBaseUrl: I,
1730
+ displayedNetworks: k,
1731
+ additionalNetworksCount: m,
1732
+ networkSelectionLocked: y = !1
1733
+ } = e, [v, $] = B(""), [D, T] = B(
1605
1734
  /* @__PURE__ */ new Set()
1606
- ), O = D(
1607
- (l) => {
1608
- const C = i(l.chainId);
1609
- return C ? C.chainType === "SVM" ? l.symbol === "SOL" : C.chainType === "MVM" ? l.symbol === "SUI" : l.contractAddress === Pt : !1;
1735
+ ), O = M(
1736
+ (c) => {
1737
+ const h = i(c.chainId);
1738
+ return h ? h.chainType === "SVM" ? c.symbol === "SOL" : h.chainType === "MVM" ? c.symbol === "SUI" : c.contractAddress === Kt : !1;
1610
1739
  },
1611
1740
  [i]
1612
- ), L = D(
1613
- (l, C) => {
1614
- C.stopPropagation(), navigator.clipboard.writeText(l).then(() => {
1615
- R((g) => new Set(g).add(l)), setTimeout(() => {
1616
- R((g) => {
1617
- const y = new Set(g);
1618
- return y.delete(l), y;
1741
+ ), K = M(
1742
+ (c, h) => {
1743
+ h.stopPropagation(), navigator.clipboard.writeText(c).then(() => {
1744
+ T((b) => new Set(b).add(c)), setTimeout(() => {
1745
+ T((b) => {
1746
+ const N = new Set(b);
1747
+ return N.delete(c), N;
1619
1748
  });
1620
1749
  }, 2e3);
1621
1750
  }).catch(() => console.error("Failed to copy to clipboard"));
1622
1751
  },
1623
1752
  []
1624
- ), $ = ie(() => {
1625
- var y;
1626
- const l = n ?? ((y = m[0]) == null ? void 0 : y.id);
1627
- if (!l) return [];
1628
- const C = a(l);
1753
+ ), L = ue(() => {
1754
+ var N;
1755
+ const c = n ?? ((N = k[0]) == null ? void 0 : N.id);
1756
+ if (!c) return [];
1757
+ const h = l(c);
1629
1758
  if (!v.trim())
1630
- return C.filter(
1631
- (c) => !s || !(c.contractAddress === s.contractAddress && c.chainId === s.chainId)
1759
+ return h.filter(
1760
+ (o) => !s || !(o.contractAddress === s.contractAddress && o.chainId === s.chainId)
1632
1761
  );
1633
- const g = v.toLowerCase();
1634
- return C.filter(
1635
- (c) => {
1636
- var f, S;
1637
- return (((f = c.symbol) == null ? void 0 : f.toLowerCase().includes(g)) || ((S = c.contractAddress) == null ? void 0 : S.toLowerCase().includes(g))) && (!s || !(c.contractAddress === s.contractAddress && c.chainId === s.chainId));
1762
+ const b = v.toLowerCase();
1763
+ return h.filter(
1764
+ (o) => {
1765
+ var E, V;
1766
+ return (((E = o.symbol) == null ? void 0 : E.toLowerCase().includes(b)) || ((V = o.contractAddress) == null ? void 0 : V.toLowerCase().includes(b))) && (!s || !(o.contractAddress === s.contractAddress && o.chainId === s.chainId));
1638
1767
  }
1639
1768
  );
1640
1769
  }, [
1641
1770
  n,
1642
- a,
1771
+ l,
1643
1772
  v,
1644
1773
  s,
1645
- m
1774
+ k
1646
1775
  ]);
1647
1776
  return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-top-0 dw-left-1/2 dw--translate-x-1/2 dw-max-h-[420px] dw-h-full dw-z-50 dw-flex dw-items-start dw-justify-center", children: /* @__PURE__ */ A(
1648
1777
  "div",
1649
1778
  {
1650
1779
  className: "dw-modal-surface dw-popup-content dw-w-[304px] dw-h-full dw-flex dw-flex-col dw-rounded-[var(--dw-radius)] dw-p-3 dw-overflow-hidden",
1651
- onClick: (l) => l.stopPropagation(),
1780
+ onClick: (c) => c.stopPropagation(),
1652
1781
  children: [
1653
1782
  /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between", children: [
1654
- /* @__PURE__ */ d("h3", { className: "dw-text-[14px] dw-font-normal dw-text-[var(--dw-fg)]", children: e === "sell" ? "Exchange from" : "Exchange to" }),
1783
+ /* @__PURE__ */ d("h3", { className: "dw-text-[14px] dw-font-normal dw-text-[var(--dw-fg)]", children: t === "sell" ? "Exchange from" : "Exchange to" }),
1655
1784
  /* @__PURE__ */ d(
1656
1785
  "button",
1657
1786
  {
1658
1787
  type: "button",
1659
1788
  className: "dw-icon-button dw-w-4 dw-h-4 dw-rounded-[4px] dw-opacity-70 dw-cursor-pointer",
1660
- onClick: k,
1789
+ onClick: C,
1661
1790
  "aria-label": "Close",
1662
- children: /* @__PURE__ */ d(on, {})
1791
+ children: /* @__PURE__ */ d(un, {})
1663
1792
  }
1664
1793
  )
1665
1794
  ] }),
1666
1795
  /* @__PURE__ */ A("div", { className: "dw-flex dw-gap-1 dw-mt-3 dw-flex-wrap", children: [
1667
- m.map((l) => /* @__PURE__ */ d(
1796
+ k.map((c) => /* @__PURE__ */ d(
1668
1797
  "button",
1669
1798
  {
1670
1799
  type: "button",
1671
- className: `dw-w-[34px] dw-h-[34px] dw-flex dw-items-center dw-justify-center dw-border dw-rounded-[6px] dw-transition ${n === l.id ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)]" : "dw-bg-[var(--dw-surface-alt)] dw-border-[var(--dw-border)] hover:dw-bg-[var(--dw-surface-hover)]"}`,
1672
- onClick: () => h(l),
1673
- title: l.name,
1674
- children: l.logoURI && /* @__PURE__ */ d(
1800
+ className: `dw-w-[34px] dw-h-[34px] dw-flex dw-items-center dw-justify-center dw-border dw-rounded-[6px] dw-transition ${n === c.id ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)]" : "dw-bg-[var(--dw-surface-alt)] dw-border-[var(--dw-border)] hover:dw-bg-[var(--dw-surface-hover)]"} ${y ? "dw-cursor-not-allowed dw-opacity-50" : ""}`,
1801
+ onClick: () => p(c),
1802
+ title: c.name,
1803
+ disabled: y,
1804
+ children: c.logoURI && /* @__PURE__ */ d(
1675
1805
  "img",
1676
1806
  {
1677
- src: re(l.logoURI, x),
1807
+ src: me(c.logoURI, I),
1678
1808
  alt: "",
1679
1809
  className: "dw-w-5 dw-h-5 dw-object-cover"
1680
1810
  }
1681
1811
  )
1682
1812
  },
1683
- l.id
1813
+ c.id
1684
1814
  )),
1685
- u > 0 && /* @__PURE__ */ d(
1815
+ m > 0 && /* @__PURE__ */ d(
1686
1816
  "button",
1687
1817
  {
1688
1818
  type: "button",
1689
- className: "dw-min-w-[34px] dw-h-[34px] dw-px-2 dw-flex dw-items-center dw-justify-center dw-rounded-[6px] dw-border dw-border-[var(--dw-border)] dw-bg-[var(--dw-surface-alt)] hover:dw-bg-[var(--dw-surface-hover)] dw-transition dw-cursor-pointer",
1690
- onClick: p,
1819
+ className: `dw-min-w-[34px] dw-h-[34px] dw-px-2 dw-flex dw-items-center dw-justify-center dw-rounded-[6px] dw-border dw-border-[var(--dw-border)] dw-bg-[var(--dw-surface-alt)] hover:dw-bg-[var(--dw-surface-hover)] dw-transition ${y ? "dw-cursor-not-allowed dw-opacity-50" : "dw-cursor-pointer"}`,
1820
+ onClick: g,
1691
1821
  title: "More networks",
1822
+ disabled: y,
1692
1823
  children: /* @__PURE__ */ A("p", { className: "dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)]", children: [
1693
- u,
1824
+ m,
1694
1825
  "+"
1695
1826
  ] })
1696
1827
  }
@@ -1703,25 +1834,25 @@ function _e(t) {
1703
1834
  type: "text",
1704
1835
  placeholder: "Search by name or contract address",
1705
1836
  value: v,
1706
- onChange: (l) => o(l.target.value),
1837
+ onChange: (c) => $(c.target.value),
1707
1838
  className: "dw-flex-1 dw-h-5 dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)] dw-bg-transparent dw-outline-none dw-border-none"
1708
1839
  }
1709
1840
  ),
1710
- /* @__PURE__ */ d(sn, {})
1841
+ /* @__PURE__ */ d(fn, {})
1711
1842
  ] }),
1712
1843
  /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between dw-mt-2.5 dw-px-0.5", children: [
1713
1844
  /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[11px] dw-text-[var(--dw-text-subtle)]", children: "Token list" }),
1714
1845
  /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[11px] dw-text-[var(--dw-text-subtle)]", children: "Contracts" })
1715
1846
  ] }),
1716
- /* @__PURE__ */ d("div", { className: "dw-widget-list dw-flex-1 dw-overflow-y-auto dw-mt-2 dw-pr-1 dw-flex dw-flex-col dw-gap-1", children: $.map((l) => {
1717
- var N;
1718
- const C = i(l.chainId), y = `${(C == null ? void 0 : C.explorerUrl) ?? "https://etherscan.io/token/"}${l.contractAddress}`, c = l.contractAddress.length > 10 ? `${l.contractAddress.slice(0, 4)}…${l.contractAddress.slice(-3)}` : l.contractAddress, f = M.has(l.contractAddress), S = !O(l);
1847
+ /* @__PURE__ */ d("div", { className: "dw-widget-list dw-flex-1 dw-overflow-y-auto dw-mt-2 dw-pr-1 dw-flex dw-flex-col dw-gap-1", children: L.map((c) => {
1848
+ var J;
1849
+ const h = i(c.chainId), N = `${(h == null ? void 0 : h.explorerUrl) ?? "https://etherscan.io/token/"}${c.contractAddress}`, o = c.contractAddress.length > 10 ? `${c.contractAddress.slice(0, 4)}…${c.contractAddress.slice(-3)}` : c.contractAddress, E = D.has(c.contractAddress), V = !O(c);
1719
1850
  return /* @__PURE__ */ A(
1720
1851
  "button",
1721
1852
  {
1722
1853
  type: "button",
1723
- className: `dw-w-full dw-min-h-[48px] dw-flex dw-items-center dw-justify-between dw-rounded-[6px] dw-px-3 dw-py-2 dw-text-left dw-transition dw-cursor-pointer dw-border ${(r == null ? void 0 : r.contractAddress) === l.contractAddress && (r == null ? void 0 : r.chainId) === l.chainId ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)]" : "dw-bg-transparent dw-border-transparent hover:dw-bg-[var(--dw-surface-alt)] hover:dw-border-[var(--dw-border)]"}`,
1724
- onClick: () => w(l),
1854
+ className: `dw-w-full dw-min-h-[48px] dw-flex dw-items-center dw-justify-between dw-rounded-[6px] dw-px-3 dw-py-2 dw-text-left dw-transition dw-cursor-pointer dw-border ${(r == null ? void 0 : r.contractAddress) === c.contractAddress && (r == null ? void 0 : r.chainId) === c.chainId ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)]" : "dw-bg-transparent dw-border-transparent hover:dw-bg-[var(--dw-surface-alt)] hover:dw-border-[var(--dw-border)]"}`,
1855
+ onClick: () => u(c),
1725
1856
  children: [
1726
1857
  /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-2 dw-min-w-0", children: [
1727
1858
  /* @__PURE__ */ d(
@@ -1729,69 +1860,69 @@ function _e(t) {
1729
1860
  {
1730
1861
  className: "dw-w-[28px] dw-h-[28px] dw-rounded-full dw-flex dw-items-center dw-justify-center dw-bg-cover dw-bg-[var(--dw-surface-hover)] dw-border dw-border-[var(--dw-border)] dw-flex-shrink-0",
1731
1862
  style: {
1732
- backgroundImage: re(
1733
- l.imageUrl,
1734
- x
1735
- ) ? `url(${re(l.imageUrl, x)})` : "none"
1863
+ backgroundImage: me(
1864
+ c.imageUrl,
1865
+ I
1866
+ ) ? `url(${me(c.imageUrl, I)})` : "none"
1736
1867
  },
1737
- children: !re(l.imageUrl, x) && /* @__PURE__ */ d("span", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)]", children: ((N = l.symbol[0]) == null ? void 0 : N.toUpperCase()) ?? "?" })
1868
+ children: !me(c.imageUrl, I) && /* @__PURE__ */ d("span", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)]", children: ((J = c.symbol[0]) == null ? void 0 : J.toUpperCase()) ?? "?" })
1738
1869
  }
1739
1870
  ),
1740
1871
  /* @__PURE__ */ A("div", { className: "dw-min-w-0", children: [
1741
- /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)] dw-truncate", children: l.symbol }),
1742
- l.name && /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] dw-truncate", children: l.name })
1872
+ /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)] dw-truncate", children: c.symbol }),
1873
+ c.name && /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] dw-truncate", children: c.name })
1743
1874
  ] })
1744
1875
  ] }),
1745
1876
  /* @__PURE__ */ A("div", { className: "dw-flex dw-flex-col dw-items-end dw-gap-1 dw-flex-shrink-0", children: [
1746
- S && /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-2.5", children: [
1877
+ V && /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-2.5", children: [
1747
1878
  /* @__PURE__ */ d(
1748
1879
  "button",
1749
1880
  {
1750
1881
  type: "button",
1751
- className: `dw-w-[12px] dw-h-[12px] dw-flex-shrink-0 dw-bg-cover dw-bg-no-repeat dw-cursor-pointer dw-transition-opacity hover:dw-opacity-100 ${f ? "dw-opacity-100" : "dw-opacity-50"}`,
1882
+ className: `dw-w-[12px] dw-h-[12px] dw-flex-shrink-0 dw-bg-cover dw-bg-no-repeat dw-cursor-pointer dw-transition-opacity hover:dw-opacity-100 ${E ? "dw-opacity-100" : "dw-opacity-50"}`,
1752
1883
  style: {
1753
- backgroundImage: `url(${f ? nn : tn})`
1884
+ backgroundImage: `url(${E ? cn : an})`
1754
1885
  },
1755
- onClick: (T) => L(l.contractAddress, T),
1886
+ onClick: (G) => K(c.contractAddress, G),
1756
1887
  "aria-label": "Copy address"
1757
1888
  }
1758
1889
  ),
1759
1890
  /* @__PURE__ */ A(
1760
1891
  "a",
1761
1892
  {
1762
- href: y,
1893
+ href: N,
1763
1894
  target: "_blank",
1764
1895
  rel: "noopener noreferrer",
1765
1896
  className: "dw-flex dw-items-center dw-gap-1 dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] hover:dw-text-[var(--dw-fg)] dw-transition-colors",
1766
- onClick: (T) => T.stopPropagation(),
1897
+ onClick: (G) => G.stopPropagation(),
1767
1898
  children: [
1768
- /* @__PURE__ */ d("span", { children: c }),
1899
+ /* @__PURE__ */ d("span", { children: o }),
1769
1900
  /* @__PURE__ */ d(
1770
1901
  "span",
1771
1902
  {
1772
1903
  className: "dw-w-[6px] dw-h-[10px] dw-flex-shrink-0 dw-bg-cover dw-bg-no-repeat",
1773
- style: { backgroundImage: `url(${rn})` }
1904
+ style: { backgroundImage: `url(${wn})` }
1774
1905
  }
1775
1906
  )
1776
1907
  ]
1777
1908
  }
1778
1909
  )
1779
1910
  ] }),
1780
- !S && /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: "Native" })
1911
+ !V && /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: "Native" })
1781
1912
  ] })
1782
1913
  ]
1783
1914
  },
1784
- `${l.chainId}-${l.contractAddress}`
1915
+ `${c.chainId}-${c.contractAddress}`
1785
1916
  );
1786
1917
  }) })
1787
1918
  ]
1788
1919
  }
1789
1920
  ) });
1790
1921
  }
1791
- function on() {
1922
+ function un() {
1792
1923
  return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ d("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) });
1793
1924
  }
1794
- function sn() {
1925
+ function fn() {
1795
1926
  return /* @__PURE__ */ d("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ d(
1796
1927
  "path",
1797
1928
  {
@@ -1803,17 +1934,17 @@ function sn() {
1803
1934
  }
1804
1935
  ) });
1805
1936
  }
1806
- function Xe(t) {
1807
- const { networks: e, onSelectNetwork: n, onClose: r, assetBaseUrl: s } = t, [a, i] = U(""), w = ie(() => {
1808
- if (!a.trim()) return e;
1809
- const h = a.toLowerCase();
1810
- return e.filter((p) => p.name.toLowerCase().includes(h));
1811
- }, [e, a]);
1937
+ function ot(e) {
1938
+ const { networks: t, onSelectNetwork: n, onClose: r, assetBaseUrl: s } = e, [l, i] = B(""), u = ue(() => {
1939
+ if (!l.trim()) return t;
1940
+ const p = l.toLowerCase();
1941
+ return t.filter((g) => g.name.toLowerCase().includes(p));
1942
+ }, [t, l]);
1812
1943
  return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-top-0 dw-left-1/2 dw--translate-x-1/2 dw-max-h-[420px] dw-h-full dw-z-[60] dw-flex dw-items-start dw-justify-center", children: /* @__PURE__ */ A(
1813
1944
  "div",
1814
1945
  {
1815
1946
  className: "dw-modal-surface dw-popup-content dw-w-[304px] dw-h-full dw-flex dw-flex-col dw-rounded-[var(--dw-radius)] dw-p-3 dw-overflow-hidden",
1816
- onClick: (h) => h.stopPropagation(),
1947
+ onClick: (p) => p.stopPropagation(),
1817
1948
  children: [
1818
1949
  /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between", children: [
1819
1950
  /* @__PURE__ */ d("h3", { className: "dw-text-[14px] dw-font-normal dw-text-[var(--dw-fg)]", children: "Select ecosystem" }),
@@ -1824,7 +1955,7 @@ function Xe(t) {
1824
1955
  className: "dw-icon-button dw-w-4 dw-h-4 dw-rounded-[4px] dw-opacity-70 dw-cursor-pointer",
1825
1956
  onClick: r,
1826
1957
  "aria-label": "Close",
1827
- children: /* @__PURE__ */ d(dn, {})
1958
+ children: /* @__PURE__ */ d(pn, {})
1828
1959
  }
1829
1960
  )
1830
1961
  ] }),
@@ -1834,42 +1965,42 @@ function Xe(t) {
1834
1965
  {
1835
1966
  type: "text",
1836
1967
  placeholder: "Search by name",
1837
- value: a,
1838
- onChange: (h) => i(h.target.value),
1968
+ value: l,
1969
+ onChange: (p) => i(p.target.value),
1839
1970
  className: "dw-flex-1 dw-h-5 dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)] dw-bg-transparent dw-outline-none dw-border-none"
1840
1971
  }
1841
1972
  ),
1842
- /* @__PURE__ */ d(an, {})
1973
+ /* @__PURE__ */ d(hn, {})
1843
1974
  ] }),
1844
- /* @__PURE__ */ d("div", { className: "dw-widget-list dw-flex-1 dw-overflow-y-auto dw-mt-3 dw-pr-1 dw-grid dw-grid-cols-2 dw-gap-1.5", children: w.map((h) => /* @__PURE__ */ A(
1975
+ /* @__PURE__ */ d("div", { className: "dw-widget-list dw-flex-1 dw-overflow-y-auto dw-mt-3 dw-pr-1 dw-grid dw-grid-cols-2 dw-gap-1.5", children: u.map((p) => /* @__PURE__ */ A(
1845
1976
  "button",
1846
1977
  {
1847
1978
  type: "button",
1848
1979
  className: "dw-w-full dw-min-h-[36px] dw-flex dw-items-center dw-gap-2 dw-rounded-[6px] dw-px-2.5 dw-py-2 dw-text-left dw-transition dw-cursor-pointer dw-bg-transparent dw-border dw-border-transparent hover:dw-bg-[var(--dw-surface-alt)] hover:dw-border-[var(--dw-border)]",
1849
- onClick: () => n(h),
1980
+ onClick: () => n(p),
1850
1981
  children: [
1851
1982
  /* @__PURE__ */ d(
1852
1983
  "div",
1853
1984
  {
1854
1985
  className: "dw-w-[18px] dw-h-[18px] dw-rounded-[4px] dw-flex-shrink-0 dw-bg-cover dw-bg-center",
1855
1986
  style: {
1856
- backgroundImage: h.logoURI ? `url(${re(h.logoURI, s)})` : "none"
1987
+ backgroundImage: p.logoURI ? `url(${me(p.logoURI, s)})` : "none"
1857
1988
  }
1858
1989
  }
1859
1990
  ),
1860
- /* @__PURE__ */ d("h6", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)] dw-truncate", children: h.name })
1991
+ /* @__PURE__ */ d("h6", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)] dw-truncate", children: p.name })
1861
1992
  ]
1862
1993
  },
1863
- h.id
1994
+ p.id
1864
1995
  )) })
1865
1996
  ]
1866
1997
  }
1867
1998
  ) });
1868
1999
  }
1869
- function dn() {
2000
+ function pn() {
1870
2001
  return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ d("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) });
1871
2002
  }
1872
- function an() {
2003
+ function hn() {
1873
2004
  return /* @__PURE__ */ d("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ d(
1874
2005
  "path",
1875
2006
  {
@@ -1881,40 +2012,40 @@ function an() {
1881
2012
  }
1882
2013
  ) });
1883
2014
  }
1884
- const ln = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIFSURBVHgB7Vf/VcMgEL5MYJxAnMBuIBvYDewIbtJukG5QnSB1AusEwQkaJzjvBF5ICg1Jaf/ie+979KUHHNwvDiAj47ooIDEQsaRhQXwhCvNbOCItURl+EvdFURzGFl0QBcxTSBIr4hGnoyGuQguvHcHKbFSOKCOIb8Qa02Bn1y6cTTCwP1+zvX4La56zihu0DsHMESFhMmvfvRKemk1ZEVcYcAv6XqK2CN9248z98gmzWbY4H7XZKOYWh3vL4dzCdxoaJHFJfAJtNh/YNGxmG1l7SIiodOExSUuKtJCRMY7kJcnC+KUEnbcezMh++Qtd4Bxu4qsm7Nc4rSzVeCbn8aKvqJNdxRtAJFAnyxRlqWEd7LpuSWqgXyoUdHlqWP1ZzuY4CenAaeh+qNgR4mpfLPbEb9CHUoP/+EDPcPokUqTYY0/S2LnBy1DjxLKE2i+3OPL0EUbBOl6Xf0ff4AS/jEEwXWD3EmWWhnegw12BDnmukQoyMsK4WkmyML7ai9IYv7xG+yZB5ygebeD4cDD8AB1EbWhBW1okTFcmRVmq0Fcv6ePOEWqskhhIltjlvArn9ZI+1Hb92JKkoN9+lRDfuvFct9YKM9fbS/jat0s6pN6pUd+2gDNAbf7lYN9NSHhuvbS9pIQZQO0WvRssAoL2OcPRJeC061agzfNDfIdbvUQzMhLiDyT6chuOT10RAAAAAElFTkSuQmCC";
1885
- function cn(t) {
2015
+ const mn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIFSURBVHgB7Vf/VcMgEL5MYJxAnMBuIBvYDewIbtJukG5QnSB1AusEwQkaJzjvBF5ICg1Jaf/ie+979KUHHNwvDiAj47ooIDEQsaRhQXwhCvNbOCItURl+EvdFURzGFl0QBcxTSBIr4hGnoyGuQguvHcHKbFSOKCOIb8Qa02Bn1y6cTTCwP1+zvX4La56zihu0DsHMESFhMmvfvRKemk1ZEVcYcAv6XqK2CN9248z98gmzWbY4H7XZKOYWh3vL4dzCdxoaJHFJfAJtNh/YNGxmG1l7SIiodOExSUuKtJCRMY7kJcnC+KUEnbcezMh++Qtd4Bxu4qsm7Nc4rSzVeCbn8aKvqJNdxRtAJFAnyxRlqWEd7LpuSWqgXyoUdHlqWP1ZzuY4CenAaeh+qNgR4mpfLPbEb9CHUoP/+EDPcPokUqTYY0/S2LnBy1DjxLKE2i+3OPL0EUbBOl6Xf0ff4AS/jEEwXWD3EmWWhnegw12BDnmukQoyMsK4WkmyML7ai9IYv7xG+yZB5ygebeD4cDD8AB1EbWhBW1okTFcmRVmq0Fcv6ePOEWqskhhIltjlvArn9ZI+1Hb92JKkoN9+lRDfuvFct9YKM9fbS/jat0s6pN6pUd+2gDNAbf7lYN9NSHhuvbS9pIQZQO0WvRssAoL2OcPRJeC061agzfNDfIdbvUQzMhLiDyT6chuOT10RAAAAAElFTkSuQmCC";
2016
+ function gn(e) {
1886
2017
  const {
1887
- options: e,
2018
+ options: t,
1888
2019
  selectedIndex: n,
1889
2020
  customValue: r,
1890
2021
  onSelectOption: s,
1891
- onCustomChange: a,
2022
+ onCustomChange: l,
1892
2023
  onSave: i,
1893
- onClose: w
1894
- } = t, [h, p] = U(r), k = (m) => {
1895
- let u = m.target.value.replace(/,/g, ".");
1896
- u.startsWith(".") && (u = "0" + u), u = u.replace(/[^0-9.]/g, "");
1897
- const v = u.indexOf(".");
1898
- v >= 0 && (u = u.slice(0, v + 1) + u.slice(v + 1).replace(/\./g, "")), u = u.slice(0, 4), p(u), a(u);
1899
- }, x = () => {
1900
- let m;
2024
+ onClose: u
2025
+ } = e, [p, g] = B(r), C = (k) => {
2026
+ let m = k.target.value.replace(/,/g, ".");
2027
+ m.startsWith(".") && (m = "0" + m), m = m.replace(/[^0-9.]/g, "");
2028
+ const y = m.indexOf(".");
2029
+ y >= 0 && (m = m.slice(0, y + 1) + m.slice(y + 1).replace(/\./g, "")), m = m.slice(0, 4), g(m), l(m);
2030
+ }, I = () => {
2031
+ let k;
1901
2032
  if (n !== null)
1902
- m = e[n];
1903
- else if (h)
1904
- m = h + "%";
2033
+ k = t[n];
2034
+ else if (p)
2035
+ k = p + "%";
1905
2036
  else
1906
2037
  return;
1907
2038
  try {
1908
- i(m), w();
1909
- } catch (u) {
1910
- console.error(u);
2039
+ i(k), u();
2040
+ } catch (m) {
2041
+ console.error(m);
1911
2042
  }
1912
2043
  };
1913
2044
  return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-inset-0 dw-z-50 dw-flex dw-items-center dw-justify-center", children: /* @__PURE__ */ A(
1914
2045
  "div",
1915
2046
  {
1916
2047
  className: "dw-modal-surface dw-popup-content dw-w-[304px] dw-flex dw-flex-col dw-rounded-[var(--dw-radius)] dw-p-3",
1917
- onClick: (m) => m.stopPropagation(),
2048
+ onClick: (k) => k.stopPropagation(),
1918
2049
  children: [
1919
2050
  /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between", children: [
1920
2051
  /* @__PURE__ */ d("h3", { className: "dw-font-normal dw-text-[14px] dw-text-[var(--dw-fg)]", children: "Settings" }),
@@ -1923,9 +2054,9 @@ function cn(t) {
1923
2054
  {
1924
2055
  type: "button",
1925
2056
  className: "dw-icon-button dw-w-4 dw-h-4 dw-rounded-[4px] dw-opacity-70 dw-cursor-pointer",
1926
- onClick: w,
2057
+ onClick: u,
1927
2058
  "aria-label": "Close",
1928
- children: /* @__PURE__ */ d(wn, {})
2059
+ children: /* @__PURE__ */ d(kn, {})
1929
2060
  }
1930
2061
  )
1931
2062
  ] }),
@@ -1933,7 +2064,7 @@ function cn(t) {
1933
2064
  /* @__PURE__ */ d(
1934
2065
  "img",
1935
2066
  {
1936
- src: ln,
2067
+ src: mn,
1937
2068
  alt: "",
1938
2069
  className: "dw-w-[14px] dw-h-[14px] dw-object-cover"
1939
2070
  }
@@ -1941,34 +2072,34 @@ function cn(t) {
1941
2072
  /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)]", children: "Slippage limit" })
1942
2073
  ] }),
1943
2074
  /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-1 dw-mt-3 dw-flex-wrap", children: [
1944
- e.map((m, u) => /* @__PURE__ */ d(
2075
+ t.map((k, m) => /* @__PURE__ */ d(
1945
2076
  "button",
1946
2077
  {
1947
2078
  type: "button",
1948
- className: `dw-font-normal dw-text-[11px] dw-px-3 dw-py-1.5 dw-rounded-[6px] dw-border dw-transition ${n === u ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)] dw-text-[var(--dw-fg)]" : "dw-bg-transparent dw-border-[var(--dw-border)] dw-text-[var(--dw-text-subtle)] hover:dw-bg-[var(--dw-surface-alt)] hover:dw-text-[var(--dw-fg)]"}`,
1949
- onClick: () => s(u),
1950
- children: m
2079
+ className: `dw-font-normal dw-text-[11px] dw-px-3 dw-py-1.5 dw-rounded-[6px] dw-border dw-transition ${n === m ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)] dw-text-[var(--dw-fg)]" : "dw-bg-transparent dw-border-[var(--dw-border)] dw-text-[var(--dw-text-subtle)] hover:dw-bg-[var(--dw-surface-alt)] hover:dw-text-[var(--dw-fg)]"}`,
2080
+ onClick: () => s(m),
2081
+ children: k
1951
2082
  },
1952
- m
2083
+ k
1953
2084
  )),
1954
2085
  /* @__PURE__ */ A(
1955
2086
  "div",
1956
2087
  {
1957
- className: `dw-relative dw-w-[72px] dw-h-[30px] dw-flex dw-items-center dw-justify-center dw-rounded-[6px] dw-border ${n === null && h ? "dw-border-[var(--dw-accent)] dw-bg-[var(--dw-surface-hover)]" : "dw-border-[var(--dw-border)] dw-bg-[var(--dw-surface-alt)]"}`,
2088
+ className: `dw-relative dw-w-[72px] dw-h-[30px] dw-flex dw-items-center dw-justify-center dw-rounded-[6px] dw-border ${n === null && p ? "dw-border-[var(--dw-accent)] dw-bg-[var(--dw-surface-hover)]" : "dw-border-[var(--dw-border)] dw-bg-[var(--dw-surface-alt)]"}`,
1958
2089
  children: [
1959
2090
  /* @__PURE__ */ d(
1960
2091
  "input",
1961
2092
  {
1962
2093
  type: "text",
1963
2094
  placeholder: "Custom",
1964
- value: h,
1965
- onChange: k,
1966
- onFocus: () => a(""),
2095
+ value: p,
2096
+ onChange: C,
2097
+ onFocus: () => l(""),
1967
2098
  maxLength: 4,
1968
2099
  className: "dw-w-10 dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)] dw-bg-transparent dw-border-none dw-outline-none dw-text-center"
1969
2100
  }
1970
2101
  ),
1971
- h && /* @__PURE__ */ d("span", { className: "dw-absolute dw-right-2 dw-pointer-events-none dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)]", children: "%" })
2102
+ p && /* @__PURE__ */ d("span", { className: "dw-absolute dw-right-2 dw-pointer-events-none dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)]", children: "%" })
1972
2103
  ]
1973
2104
  }
1974
2105
  )
@@ -1978,7 +2109,7 @@ function cn(t) {
1978
2109
  {
1979
2110
  type: "button",
1980
2111
  className: "dw-w-full dw-h-[34px] dw-mt-4 dw-bg-[var(--dw-accent)] dw-border dw-border-transparent dw-rounded-[6px] dw-font-normal dw-text-[12px] dw-text-white hover:dw-bg-[var(--dw-accent-hover)] dw-cursor-pointer",
1981
- onClick: x,
2112
+ onClick: I,
1982
2113
  children: "Save"
1983
2114
  }
1984
2115
  )
@@ -1986,52 +2117,129 @@ function cn(t) {
1986
2117
  }
1987
2118
  ) });
1988
2119
  }
1989
- function wn() {
2120
+ function kn() {
1990
2121
  return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ d("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) });
1991
2122
  }
1992
- function Ze(t) {
1993
- return t === "EVM" ? nt : t === "SVM" ? rt : ot;
2123
+ function st(e) {
2124
+ return e === "EVM" ? at : e === "SVM" ? it : ct;
1994
2125
  }
1995
- function gn(t) {
1996
- var $, l, C, g, y, c, f, S;
2126
+ function vn(e) {
2127
+ var de, oe, w, a, S, W, Q, z;
1997
2128
  const {
1998
- theme: e = "dark",
2129
+ theme: t = "dark",
1999
2130
  vars: n,
2000
2131
  className: r,
2001
2132
  style: s,
2002
- config: a,
2003
- ...i
2004
- } = t, w = et(e, n), p = {
2005
- ...tt(w),
2133
+ config: l,
2134
+ initialSellToken: i,
2135
+ initialBuyToken: u,
2136
+ initialSellNetworkId: p,
2137
+ initialBuyNetworkId: g,
2138
+ lockBuyToken: C = !1,
2139
+ lockSellToken: I = !1,
2140
+ lockBuyNetwork: k = !1,
2141
+ lockSellNetwork: m = !1,
2142
+ onApprove: y,
2143
+ onSwap: v,
2144
+ onQuote: $,
2145
+ onError: D,
2146
+ ...T
2147
+ } = e, O = dt(t, n), q = {
2148
+ ...lt(O),
2006
2149
  ...s
2007
- }, k = a.assetBaseUrl ?? a.dataBaseUrl ?? a.apiBase ?? (typeof window < "u" ? window.location.origin : ""), [x, m] = U(null), [u, v] = U(null), o = zt({
2008
- apiBase: a.apiBase
2009
- }), M = ie(() => {
2010
- var G;
2011
- const N = o.networks, T = (G = o.networkSell) == null ? void 0 : G.id, P = N.slice(0, 6);
2012
- if (!T || P.some((H) => H.id === T)) return P;
2013
- const J = N.find((H) => H.id === T);
2014
- return J ? [...P.slice(0, 5), J] : P;
2015
- }, [o.networks, ($ = o.networkSell) == null ? void 0 : $.id]), R = ie(() => {
2016
- const N = new Set(M.map((T) => T.id));
2017
- return o.networks.filter((T) => !N.has(T.id));
2018
- }, [o.networks, M]), O = ie(() => {
2019
- var G;
2020
- const N = o.networks, T = (G = o.networkBuy) == null ? void 0 : G.id, P = N.slice(0, 6);
2021
- if (!T || P.some((H) => H.id === T)) return P;
2022
- const J = N.find((H) => H.id === T);
2023
- return J ? [...P.slice(0, 5), J] : P;
2024
- }, [o.networks, (l = o.networkBuy) == null ? void 0 : l.id]), L = ie(() => {
2025
- const N = new Set(O.map((T) => T.id));
2026
- return o.networks.filter((T) => !N.has(T.id));
2027
- }, [o.networks, O]), V = (N) => Math.trunc(N * 1e6) / 1e6;
2150
+ }, L = l.assetBaseUrl ?? l.dataBaseUrl ?? l.apiBase ?? (typeof window < "u" ? window.location.origin : ""), [c, h] = B(null), [b, N] = B(null), o = Xt({
2151
+ apiBase: l.apiBase,
2152
+ initialSellToken: i,
2153
+ initialBuyToken: u,
2154
+ initialSellNetworkId: p,
2155
+ initialBuyNetworkId: g,
2156
+ lockBuyToken: C,
2157
+ lockSellToken: I,
2158
+ lockBuyNetwork: k,
2159
+ lockSellNetwork: m,
2160
+ onError: D
2161
+ }), E = X(""), V = ue(() => {
2162
+ var le;
2163
+ const f = o.networks, F = (le = o.networkSell) == null ? void 0 : le.id, P = f.slice(0, 6);
2164
+ if (!F || P.some((se) => se.id === F)) return P;
2165
+ const _ = f.find((se) => se.id === F);
2166
+ return _ ? [...P.slice(0, 5), _] : P;
2167
+ }, [o.networks, (de = o.networkSell) == null ? void 0 : de.id]), J = ue(() => {
2168
+ const f = new Set(V.map((F) => F.id));
2169
+ return o.networks.filter((F) => !f.has(F.id));
2170
+ }, [o.networks, V]), G = ue(() => {
2171
+ var le;
2172
+ const f = o.networks, F = (le = o.networkBuy) == null ? void 0 : le.id, P = f.slice(0, 6);
2173
+ if (!F || P.some((se) => se.id === F)) return P;
2174
+ const _ = f.find((se) => se.id === F);
2175
+ return _ ? [...P.slice(0, 5), _] : P;
2176
+ }, [o.networks, (oe = o.networkBuy) == null ? void 0 : oe.id]), ie = ue(() => {
2177
+ const f = new Set(G.map((F) => F.id));
2178
+ return o.networks.filter((F) => !f.has(F.id));
2179
+ }, [o.networks, G]), fe = (f) => Math.trunc(f * 1e6) / 1e6, ee = M(
2180
+ (f) => !o.networkSell || !o.networkBuy || !o.sellToken || !o.buyToken ? null : {
2181
+ action: f,
2182
+ sellNetwork: o.networkSell,
2183
+ buyNetwork: o.networkBuy,
2184
+ sellToken: o.sellToken,
2185
+ buyToken: o.buyToken,
2186
+ sellAmount: o.sellAmountForInput,
2187
+ buyAmount: o.buyAmountForInput,
2188
+ slippage: o.slippage.slippage,
2189
+ quote: o.quote,
2190
+ txData: o.txData,
2191
+ price: o.price,
2192
+ gasCostUSD: o.gasCostUSD
2193
+ },
2194
+ [o]
2195
+ );
2196
+ re(() => {
2197
+ o.quote || (E.current = "");
2198
+ }, [o.quote]), re(() => {
2199
+ var F, P;
2200
+ if (!$ || !o.quote || !o.networkSell || !o.networkBuy || !o.sellToken || !o.buyToken)
2201
+ return;
2202
+ const f = [
2203
+ o.networkSell.id,
2204
+ o.networkBuy.id,
2205
+ o.sellToken.contractAddress,
2206
+ o.buyToken.contractAddress,
2207
+ o.sellAmountForInput,
2208
+ o.buyAmountForInput,
2209
+ o.quote.inputAmount ?? "",
2210
+ o.quote.outputAmount ?? "",
2211
+ ((F = o.txData) == null ? void 0 : F.to) ?? "",
2212
+ ((P = o.txData) == null ? void 0 : P.data) ?? ""
2213
+ ].join("|");
2214
+ E.current !== f && (E.current = f, $({
2215
+ sellNetwork: o.networkSell,
2216
+ buyNetwork: o.networkBuy,
2217
+ sellToken: o.sellToken,
2218
+ buyToken: o.buyToken,
2219
+ sellAmount: o.sellAmountForInput,
2220
+ buyAmount: o.buyAmountForInput,
2221
+ slippage: o.slippage.slippage,
2222
+ quote: o.quote
2223
+ }));
2224
+ }, [$, o]);
2225
+ const ce = M(() => {
2226
+ if (o.buttonState === "approve") {
2227
+ const f = ee("approve");
2228
+ f && (y == null || y(f));
2229
+ return;
2230
+ }
2231
+ if (o.buttonState === "swap") {
2232
+ const f = ee("swap");
2233
+ f && (v == null || v(f));
2234
+ }
2235
+ }, [ee, y, v, o.buttonState]);
2028
2236
  return o.loading ? /* @__PURE__ */ d(
2029
2237
  "div",
2030
2238
  {
2031
2239
  "data-delora-widget-root": !0,
2032
2240
  className: `dw-flex dw-items-center dw-justify-center dw-p-8 ${r ?? ""}`,
2033
- style: p,
2034
- ...i,
2241
+ style: q,
2242
+ ...T,
2035
2243
  children: /* @__PURE__ */ d("p", { className: "dw-text-[var(--dw-muted)]", children: "Loading..." })
2036
2244
  }
2037
2245
  ) : o.error ? /* @__PURE__ */ d(
@@ -2039,8 +2247,8 @@ function gn(t) {
2039
2247
  {
2040
2248
  "data-delora-widget-root": !0,
2041
2249
  className: `dw-flex dw-items-center dw-justify-center dw-p-8 ${r ?? ""}`,
2042
- style: p,
2043
- ...i,
2250
+ style: q,
2251
+ ...T,
2044
2252
  children: /* @__PURE__ */ d("p", { className: "dw-text-[#ff7e7e]", children: o.error })
2045
2253
  }
2046
2254
  ) : /* @__PURE__ */ A(
@@ -2048,23 +2256,27 @@ function gn(t) {
2048
2256
  {
2049
2257
  "data-delora-widget-root": !0,
2050
2258
  className: `dw-font-mono dw-relative dw-inline-block ${r ?? ""}`,
2051
- style: p,
2052
- ...i,
2259
+ style: q,
2260
+ ...T,
2053
2261
  children: [
2054
2262
  /* @__PURE__ */ d(
2055
- Gt,
2263
+ rn,
2056
2264
  {
2057
- assetBaseUrl: k,
2265
+ assetBaseUrl: L,
2058
2266
  sellToken: o.sellToken,
2059
2267
  buyToken: o.buyToken,
2060
- networkSellLogo: (C = o.networkSell) == null ? void 0 : C.logoURI,
2061
- networkBuyLogo: (g = o.networkBuy) == null ? void 0 : g.logoURI,
2268
+ networkSellLogo: (w = o.networkSell) == null ? void 0 : w.logoURI,
2269
+ networkBuyLogo: (a = o.networkBuy) == null ? void 0 : a.logoURI,
2062
2270
  sellAmountForInput: o.sellAmountForInput,
2063
2271
  buyAmountForInput: o.buyAmountForInput,
2064
- onSellAmountChange: (N) => o.setSellAmountForInput(N),
2272
+ onSellAmountChange: (f) => o.setSellAmountForInput(f),
2065
2273
  onSellInputProcess: o.processSellInput,
2066
- onOpenSellToken: () => m("tokenSell"),
2067
- onOpenBuyToken: () => m("tokenBuy"),
2274
+ onOpenSellToken: () => {
2275
+ I || h("tokenSell");
2276
+ },
2277
+ onOpenBuyToken: () => {
2278
+ C || h("tokenBuy");
2279
+ },
2068
2280
  onSwapTokens: o.swapTokens,
2069
2281
  onRefresh: () => {
2070
2282
  o.networkSell && o.networkBuy && o.sellToken && o.buyToken && o.validatedSellAmount > 0 && o.fetchQuote({
@@ -2074,16 +2286,16 @@ function gn(t) {
2074
2286
  buyToken: o.buyToken,
2075
2287
  sellAmountStr: o.sellAmountForInput || "0",
2076
2288
  slippage: o.slippage.slippage,
2077
- fromAddress: Ze(o.networkSell.chainType),
2078
- toAddress: Ze(o.networkBuy.chainType),
2079
- apiBase: a.apiBase
2289
+ fromAddress: st(o.networkSell.chainType),
2290
+ toAddress: st(o.networkBuy.chainType),
2291
+ apiBase: l.apiBase
2080
2292
  });
2081
2293
  },
2082
- onOpenSettings: () => m("settings"),
2294
+ onOpenSettings: () => h("settings"),
2083
2295
  balance: o.balance,
2084
2296
  balanceBuy: o.balanceBuy,
2085
- sellPriceUsd: (y = o.sellToken) != null && y.priceUSD && o.sellAmountForInput && Number(o.sellAmountForInput) > 0 ? `$${(Number(o.sellAmountForInput) * Number(o.sellToken.priceUSD)).toFixed(3)}` : "",
2086
- buyPriceUsd: (c = o.buyToken) != null && c.priceUSD && o.buyAmountForInput && Number(o.buyAmountForInput) > 0 ? `$${(Number(o.buyAmountForInput) * Number(o.buyToken.priceUSD)).toFixed(3)}` : "",
2297
+ sellPriceUsd: (S = o.sellToken) != null && S.priceUSD && o.sellAmountForInput && Number(o.sellAmountForInput) > 0 ? `$${(Number(o.sellAmountForInput) * Number(o.sellToken.priceUSD)).toFixed(3)}` : "",
2298
+ buyPriceUsd: (W = o.buyToken) != null && W.priceUSD && o.buyAmountForInput && Number(o.buyAmountForInput) > 0 ? `$${(Number(o.buyAmountForInput) * Number(o.buyToken.priceUSD)).toFixed(3)}` : "",
2087
2299
  onMaxClick: o.setMaxSellAmount,
2088
2300
  onSet50Percent: () => o.setSellAmountByPercent(50),
2089
2301
  onSet25Percent: () => o.setSellAmountByPercent(25),
@@ -2092,93 +2304,103 @@ function gn(t) {
2092
2304
  loading: o.buttonState === "finding",
2093
2305
  price: o.price,
2094
2306
  gasCostUSD: o.gasCostUSD,
2095
- truncateTo6Decimals: V,
2096
- isWalletConnected: !!a.isWalletConnected,
2097
- onConnectWallet: a.onConnectWallet
2307
+ truncateTo6Decimals: fe,
2308
+ isWalletConnected: !!l.isWalletConnected,
2309
+ onConnectWallet: l.onConnectWallet,
2310
+ onAction: ce,
2311
+ swapDisabled: o.swapLocked,
2312
+ sellTokenLocked: I,
2313
+ buyTokenLocked: C
2098
2314
  }
2099
2315
  ),
2100
- x === "tokenSell" && /* @__PURE__ */ d(
2101
- _e,
2316
+ c === "tokenSell" && /* @__PURE__ */ d(
2317
+ rt,
2102
2318
  {
2103
2319
  mode: "sell",
2104
2320
  networks: o.networks,
2105
- selectedNetworkId: (f = o.networkSell) == null ? void 0 : f.id,
2321
+ selectedNetworkId: (Q = o.networkSell) == null ? void 0 : Q.id,
2106
2322
  selectedToken: o.sellToken,
2107
2323
  excludeToken: o.buyToken,
2108
2324
  getAllTokensForNetwork: o.getAllTokensForNetworkId,
2109
2325
  getNetworkById: o.getNetworkById,
2110
- displayedNetworks: M,
2111
- additionalNetworksCount: R.length,
2112
- onOpenNetworkSelector: () => v("sell"),
2113
- onSelectToken: (N) => {
2114
- o.setSellToken(N), o.cancelRequest(), m(null);
2326
+ displayedNetworks: V,
2327
+ additionalNetworksCount: J.length,
2328
+ onOpenNetworkSelector: () => {
2329
+ o.sellNetworkLocked || N("sell");
2115
2330
  },
2116
- onSelectNetwork: (N) => {
2117
- var T;
2118
- o.updateNetworkSell(N.id), ((T = o.networkBuy) == null ? void 0 : T.id) !== N.id && o.setNetworkBuy(N);
2331
+ onSelectToken: (f) => {
2332
+ o.setSellToken(f), o.cancelRequest(), h(null);
2119
2333
  },
2120
- onClose: () => m(null),
2121
- assetBaseUrl: k
2334
+ onSelectNetwork: (f) => {
2335
+ var F;
2336
+ o.updateNetworkSell(f.id), ((F = o.networkBuy) == null ? void 0 : F.id) !== f.id && o.setNetworkBuy(f);
2337
+ },
2338
+ onClose: () => h(null),
2339
+ assetBaseUrl: L,
2340
+ networkSelectionLocked: o.sellNetworkLocked
2122
2341
  }
2123
2342
  ),
2124
- x === "tokenBuy" && /* @__PURE__ */ d(
2125
- _e,
2343
+ c === "tokenBuy" && /* @__PURE__ */ d(
2344
+ rt,
2126
2345
  {
2127
2346
  mode: "buy",
2128
2347
  networks: o.networks,
2129
- selectedNetworkId: (S = o.networkBuy) == null ? void 0 : S.id,
2348
+ selectedNetworkId: (z = o.networkBuy) == null ? void 0 : z.id,
2130
2349
  selectedToken: o.buyToken,
2131
2350
  excludeToken: o.sellToken,
2132
2351
  getAllTokensForNetwork: o.getAllTokensForNetworkId,
2133
2352
  getNetworkById: o.getNetworkById,
2134
- displayedNetworks: O,
2135
- additionalNetworksCount: L.length,
2136
- onOpenNetworkSelector: () => v("buy"),
2137
- onSelectToken: (N) => {
2138
- o.setBuyToken(N), o.cancelRequest(), m(null);
2353
+ displayedNetworks: G,
2354
+ additionalNetworksCount: ie.length,
2355
+ onOpenNetworkSelector: () => {
2356
+ o.buyNetworkLocked || N("buy");
2357
+ },
2358
+ onSelectToken: (f) => {
2359
+ o.setBuyToken(f), o.cancelRequest(), h(null);
2139
2360
  },
2140
- onSelectNetwork: (N) => {
2141
- o.setNetworkBuy(N);
2361
+ onSelectNetwork: (f) => {
2362
+ o.setNetworkBuy(f);
2142
2363
  },
2143
- onClose: () => m(null),
2144
- assetBaseUrl: k
2364
+ onClose: () => h(null),
2365
+ assetBaseUrl: L,
2366
+ networkSelectionLocked: o.buyNetworkLocked
2145
2367
  }
2146
2368
  ),
2147
- u === "sell" && x === "tokenSell" && /* @__PURE__ */ d(
2148
- Xe,
2369
+ b === "sell" && c === "tokenSell" && /* @__PURE__ */ d(
2370
+ ot,
2149
2371
  {
2150
- networks: R,
2151
- assetBaseUrl: k,
2152
- onSelectNetwork: (N) => {
2153
- var T;
2154
- o.updateNetworkSell(N.id), ((T = o.networkBuy) == null ? void 0 : T.id) !== N.id && o.setNetworkBuy(N), v(null);
2372
+ networks: J,
2373
+ assetBaseUrl: L,
2374
+ onSelectNetwork: (f) => {
2375
+ var F;
2376
+ o.updateNetworkSell(f.id), ((F = o.networkBuy) == null ? void 0 : F.id) !== f.id && o.setNetworkBuy(f), N(null);
2155
2377
  },
2156
- onClose: () => v(null)
2378
+ onClose: () => N(null)
2157
2379
  }
2158
2380
  ),
2159
- u === "buy" && x === "tokenBuy" && /* @__PURE__ */ d(
2160
- Xe,
2381
+ b === "buy" && c === "tokenBuy" && /* @__PURE__ */ d(
2382
+ ot,
2161
2383
  {
2162
- networks: L,
2163
- assetBaseUrl: k,
2164
- onSelectNetwork: (N) => {
2165
- o.setNetworkBuy(N), v(null);
2384
+ networks: ie,
2385
+ assetBaseUrl: L,
2386
+ onSelectNetwork: (f) => {
2387
+ o.setNetworkBuy(f), N(null);
2166
2388
  },
2167
- onClose: () => v(null)
2389
+ onClose: () => N(null)
2168
2390
  }
2169
2391
  ),
2170
- x === "settings" && /* @__PURE__ */ d(
2171
- cn,
2392
+ c === "settings" && /* @__PURE__ */ d(
2393
+ gn,
2172
2394
  {
2173
2395
  options: o.slippage.options,
2174
2396
  selectedIndex: o.slippage.selectedIndex,
2175
2397
  customValue: o.slippage.customValue,
2176
2398
  onSelectOption: o.slippage.selectOption,
2177
2399
  onCustomChange: o.slippage.setCustom,
2178
- onSave: (N) => {
2179
- o.slippage.save(N), m(null);
2400
+ onSave: (f) => {
2401
+ o.slippage.save(f), h(null);
2180
2402
  },
2181
- onClose: () => m(null)
2403
+ onClose: () => h(null)
2182
2404
  }
2183
2405
  )
2184
2406
  ]
@@ -2186,7 +2408,7 @@ function gn(t) {
2186
2408
  );
2187
2409
  }
2188
2410
  export {
2189
- mn as MyWidget,
2190
- gn as TradeWidget
2411
+ An as MyWidget,
2412
+ vn as TradeWidget
2191
2413
  };
2192
2414
  //# sourceMappingURL=index.js.map