@deloraprotocol/widget 1.0.0

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