PageSourceSearch

https://1whnva.com/resources/v1/mf/modules/paywidget/bundle/setup-B0TllVkY.js

js 1whnva.com collected 2026-10-08 05:58:55 UTC 881,885 bytes, 27,196 lines download raw bytes

1import { isRef as El, unref as ch, ref as uh, nextTick as lh, inject as Ja } from "vue";
2import { L as Nr, bf as dh, cl as fh, cj as Al } from "./package-entrypoint-D3U0TeG0.js";
3var jt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
4function oo(e) {
5  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
6}
7function hh(e) {
8  if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
9  var t = e.default;
10  if (typeof t == "function") {
11    var n = function r() {
12      var s = !1;
13      try {
14        s = this instanceof r;
15      } catch {
16      }
17      return s ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
18    };
19    n.prototype = t.prototype;
20  } else n = {};
21  return Object.defineProperty(n, "__esModule", { value: !0 }), Object.keys(e).forEach(function(r) {
22    var s = Object.getOwnPropertyDescriptor(e, r);
23    Object.defineProperty(n, r, s.get ? s : {
24      enumerable: !0,
25      get: function() {
26        return e[r];
27      }
28    });
29  }), n;
30}
31const ph = "1.2.3";
32let ht = class aa extends Error {
33  constructor(t, n = {}) {
34    const r = n.cause instanceof aa ? n.cause.details : n.cause?.message ? n.cause.message : n.details, s = n.cause instanceof aa && n.cause.docsPath || n.docsPath, i = [
35      t || "An error occurred.",
36      "",
37      ...n.metaMessages ? [...n.metaMessages, ""] : [],
38      ...s ? [`Docs: https://abitype.dev${s}`] : [],
39      ...r ? [`Details: ${r}`] : [],
40      `Version: abitype@${ph}`
41    ].join(`
42`);
43    super(i), Object.defineProperty(this, "details", {
44      enumerable: !0,
45      configurable: !0,
46      writable: !0,
47      value: void 0
48    }), Object.defineProperty(this, "docsPath", {
49      enumerable: !0,
50      configurable: !0,
51      writable: !0,
52      value: void 0
53    }), Object.defineProperty(this, "metaMessages", {
54      enumerable: !0,
55      configurable: !0,
56      writable: !0,
57      value: void 0
58    }), Object.defineProperty(this, "shortMessage", {
59      enumerable: !0,
60      configurable: !0,
61      writable: !0,
62      value: void 0
63    }), Object.defineProperty(this, "name", {
64      enumerable: !0,
65      configurable: !0,
66      writable: !0,
67      value: "AbiTypeError"
68    }), n.cause && (this.cause = n.cause), this.details = r, this.docsPath = s, this.metaMessages = n.metaMessages, this.shortMessage = t;
69  }
70};
71function mn(e, t) {
72  return e.exec(t)?.groups;
73}
74const vl = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, _l = /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/, Nl = /^\(.+?\).*?$/, jc = /^tuple(?<array>(\[(\d*)\])*)$/;
75function ca(e) {
76  let t = e.type;
77  if (jc.test(e.type) && "components" in e) {
78    t = "(";
79    const n = e.components.length;
80    for (let s = 0; s < n; s++) {
81      const i = e.components[s];
82      t += ca(i), s < n - 1 && (t += ", ");
83    }
84    const r = mn(jc, e.type);
85    return t += `)${r?.array || ""}`, ca({
86      ...e,
87      type: t
88    });
89  }
90  return "indexed" in e && e.indexed && (t = `${t} indexed`), e.name ? `${t} ${e.name}` : t;
91}
92function zr(e) {
93  let t = "";
94  const n = e.length;
95  for (let r = 0; r < n; r++) {
96    const s = e[r];
97    t += ca(s), r !== n - 1 && (t += ", ");
98  }
99  return t;
100}
101function mh(e) {
102  return e.type === "function" ? `function ${e.name}(${zr(e.inputs)})${e.stateMutability && e.stateMutability !== "nonpayable" ? ` ${e.stateMutability}` : ""}${e.outputs?.length ? ` returns (${zr(e.outputs)})` : ""}` : e.type === "event" ? `event ${e.name}(${zr(e.inputs)})` : e.type === "error" ? `error ${e.name}(${zr(e.inputs)})` : e.type === "constructor" ? `constructor(${zr(e.inputs)})${e.stateMutability === "payable" ? " payable" : ""}` : e.type === "fallback" ? `fallback() external${e.stateMutability === "payable" ? " payable" : ""}` : "receive() external payable";
103}
104const Il = /^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
105function gh(e) {
106  return Il.test(e);
107}
108function yh(e) {
109  return mn(Il, e);
110}
111const Tl = /^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
112function bh(e) {
113  return Tl.test(e);
114}
115function wh(e) {
116  return mn(Tl, e);
117}
118const Sl = /^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;
119function Ch(e) {
120  return Sl.test(e);
121}
122function Eh(e) {
123  return mn(Sl, e);
124}
125const Rl = /^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;
126function xl(e) {
127  return Rl.test(e);
128}
129function Ah(e) {
130  return mn(Rl, e);
131}
132const Ol = /^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;
133function vh(e) {
134  return Ol.test(e);
135}
136function _h(e) {
137  return mn(Ol, e);
138}
139const Pl = /^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;
140function Nh(e) {
141  return Pl.test(e);
142}
143function Ih(e) {
144  return mn(Pl, e);
145}
146const Th = /^receive\(\) external payable$/;
147function Sh(e) {
148  return Th.test(e);
149}
150const bv = /* @__PURE__ */ new Set([
151  "memory",
152  "indexed",
153  "storage",
154  "calldata"
155]), Rh = /* @__PURE__ */ new Set(["indexed"]), ua = /* @__PURE__ */ new Set([
156  "calldata",
157  "memory",
158  "storage"
159]);
160class wv extends ht {
161  constructor({ signature: t }) {
162    super("Failed to parse ABI item.", {
163      details: `parseAbiItem(${JSON.stringify(t, null, 2)})`,
164      docsPath: "/api/human#parseabiitem-1"
165    }), Object.defineProperty(this, "name", {
166      enumerable: !0,
167      configurable: !0,
168      writable: !0,
169      value: "InvalidAbiItemError"
170    });
171  }
172}
173class xh extends ht {
174  constructor({ type: t }) {
175    super("Unknown type.", {
176      metaMessages: [
177        `Type "${t}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`
178      ]
179    }), Object.defineProperty(this, "name", {
180      enumerable: !0,
181      configurable: !0,
182      writable: !0,
183      value: "UnknownTypeError"
184    });
185  }
186}
187class Oh extends ht {
188  constructor({ type: t }) {
189    super("Unknown type.", {
190      metaMessages: [`Type "${t}" is not a valid ABI type.`]
191    }), Object.defineProperty(this, "name", {
192      enumerable: !0,
193      configurable: !0,
194      writable: !0,
195      value: "UnknownSolidityTypeError"
196    });
197  }
198}
199class Cv extends ht {
200  constructor({ params: t }) {
201    super("Failed to parse ABI parameters.", {
202      details: `parseAbiParameters(${JSON.stringify(t, null, 2)})`,
203      docsPath: "/api/human#parseabiparameters-1"
204    }), Object.defineProperty(this, "name", {
205      enumerable: !0,
206      configurable: !0,
207      writable: !0,
208      value: "InvalidAbiParametersError"
209    });
210  }
211}
212class Ph extends ht {
213  constructor({ param: t }) {
214    super("Invalid ABI parameter.", {
215      details: t
216    }), Object.defineProperty(this, "name", {
217      enumerable: !0,
218      configurable: !0,
219      writable: !0,
220      value: "InvalidParameterError"
221    });
222  }
223}
224class kh extends ht {
225  constructor({ param: t, name: n }) {
226    super("Invalid ABI parameter.", {
227      details: t,
228      metaMessages: [
229        `"${n}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`
230      ]
231    }), Object.defineProperty(this, "name", {
232      enumerable: !0,
233      configurable: !0,
234      writable: !0,
235      value: "SolidityProtectedKeywordError"
236    });
237  }
238}
239class Uh extends ht {
240  constructor({ param: t, type: n, modifier: r }) {
241    super("Invalid ABI parameter.", {
242      details: t,
243      metaMessages: [
244        `Modifier "${r}" not allowed${n ? ` in "${n}" type` : ""}.`
245      ]
246    }), Object.defineProperty(this, "name", {
247      enumerable: !0,
248      configurable: !0,
249      writable: !0,
250      value: "InvalidModifierError"
251    });
252  }
253}
254class Mh extends ht {
255  constructor({ param: t, type: n, modifier: r }) {
256    super("Invalid ABI parameter.", {
257      details: t,
258      metaMessages: [
259        `Modifier "${r}" not allowed${n ? ` in "${n}" type` : ""}.`,
260        `Data location can only be specified for array, struct, or mapping types, but "${r}" was given.`
261      ]
262    }), Object.defineProperty(this, "name", {
263      enumerable: !0,
264      configurable: !0,
265      writable: !0,
266      value: "InvalidFunctionModifierError"
267    });
268  }
269}
270class Lh extends ht {
271  constructor({ abiParameter: t }) {
272    super("Invalid ABI parameter.", {
273      details: JSON.stringify(t, null, 2),
274      metaMessages: ["ABI parameter type is invalid."]
275    }), Object.defineProperty(this, "name", {
276      enumerable: !0,
277      configurable: !0,
278      writable: !0,
279      value: "InvalidAbiTypeParameterError"
280    });
281  }
282}
283class Wr extends ht {
284  constructor({ signature: t, type: n }) {
285    super(`Invalid ${n} signature.`, {
286      details: t
287    }), Object.defineProperty(this, "name", {
288      enumerable: !0,
289      configurable: !0,
290      writable: !0,
291      value: "InvalidSignatureError"
292    });
293  }
294}
295class Bh extends ht {
296  constructor({ signature: t }) {
297    super("Unknown signature.", {
298      details: t
299    }), Object.defineProperty(this, "name", {
300      enumerable: !0,
301      configurable: !0,
302      writable: !0,
303      value: "UnknownSignatureError"
304    });
305  }
306}
307class Dh extends ht {
308  constructor({ signature: t }) {
309    super("Invalid struct signature.", {
310      details: t,
311      metaMessages: ["No properties exist."]
312    }), Object.defineProperty(this, "name", {
313      enumerable: !0,
314      configurable: !0,
315      writable: !0,
316      value: "InvalidStructSignatureError"
317    });
318  }
319}
320class Fh extends ht {
321  constructor({ type: t }) {
322    super("Circular reference detected.", {
323      metaMessages: [`Struct "${t}" is a circular reference.`]
324    }), Object.defineProperty(this, "name", {
325      enumerable: !0,
326      configurable: !0,
327      writable: !0,
328      value: "CircularReferenceError"
329    });
330  }
331}
332class jh extends ht {
333  constructor({ current: t, depth: n }) {
334    super("Unbalanced parentheses.", {
335      metaMessages: [
336        `"${t.trim()}" has too many ${n > 0 ? "opening" : "closing"} parentheses.`
337      ],
338      details: `Depth "${n}"`
339    }), Object.defineProperty(this, "name", {
340      enumerable: !0,
341      configurable: !0,
342      writable: !0,
343      value: "InvalidParenthesisError"
344    });
345  }
346}
347function Wh(e, t, n) {
348  let r = "";
349  if (n)
350    for (const s of Object.entries(n)) {
351      if (!s)
352        continue;
353      let i = "";
354      for (const o of s[1])
355        i += `[${o.type}${o.name ? `:${o.name}` : ""}]`;
356      r += `(${s[0]}{${i}})`;
357    }
358  return t ? `${t}:${e}${r}` : `${e}${r}`;
359}
360const To = /* @__PURE__ */ new Map([
361  // Unnamed
362  ["address", { type: "address" }],
363  ["bool", { type: "bool" }],
364  ["bytes", { type: "bytes" }],
365  ["bytes32", { type: "bytes32" }],
366  ["int", { type: "int256" }],
367  ["int256", { type: "int256" }],
368  ["string", { type: "string" }],
369  ["uint", { type: "uint256" }],
370  ["uint8", { type: "uint8" }],
371  ["uint16", { type: "uint16" }],
372  ["uint24", { type: "uint24" }],
373  ["uint32", { type: "uint32" }],
374  ["uint64", { type: "uint64" }],
375  ["uint96", { type: "uint96" }],
376  ["uint112", { type: "uint112" }],
377  ["uint160", { type: "uint160" }],
378  ["uint192", { type: "uint192" }],
379  ["uint256", { type: "uint256" }],
380  // Named
381  ["address owner", { type: "address", name: "owner" }],
382  ["address to", { type: "address", name: "to" }],
383  ["bool approved", { type: "bool", name: "approved" }],
384  ["bytes _data", { type: "bytes", name: "_data" }],
385  ["bytes data", { type: "bytes", name: "data" }],
386  ["bytes signature", { type: "bytes", name: "signature" }],
387  ["bytes32 hash", { type: "bytes32", name: "hash" }],
388  ["bytes32 r", { type: "bytes32", name: "r" }],
389  ["bytes32 root", { type: "bytes32", name: "root" }],
390  ["bytes32 s", { type: "bytes32", name: "s" }],
391  ["string name", { type: "string", name: "name" }],
392  ["string symbol", { type: "string", name: "symbol" }],
393  ["string tokenURI", { type: "string", name: "tokenURI" }],
394  ["uint tokenId", { type: "uint256", name: "tokenId" }],
395  ["uint8 v", { type: "uint8", name: "v" }],
396  ["uint256 balance", { type: "uint256", name: "balance" }],
397  ["uint256 tokenId", { type: "uint256", name: "tokenId" }],
398  ["uint256 value", { type: "uint256", name: "value" }],
399  // Indexed
400  [
401    "event:address indexed from",
402    { type: "address", name: "from", indexed: !0 }
403  ],
404  ["event:address indexed to", { type: "address", name: "to", indexed: !0 }],
405  [
406    "event:uint indexed tokenId",
407    { type: "uint256", name: "tokenId", indexed: !0 }
408  ],
409  [
410    "event:uint256 indexed tokenId",
411    { type: "uint256", name: "tokenId", indexed: !0 }
412  ]
413]);
414function $h(e, t = {}) {
415  if (Ch(e))
416    return Hh(e, t);
417  if (bh(e))
418    return qh(e, t);
419  if (gh(e))
420    return Gh(e, t);
421  if (vh(e))
422    return zh(e, t);
423  if (Nh(e))
424    return Vh(e);
425  if (Sh(e))
426    return {
427      type: "receive",
428      stateMutability: "payable"
429    };
430  throw new Bh({ signature: e });
431}
432function Hh(e, t = {}) {
433  const n = Eh(e);
434  if (!n)
435    throw new Wr({ signature: e, type: "function" });
436  const r = Tt(n.parameters), s = [], i = r.length;
437  for (let a = 0; a < i; a++)
438    s.push(tr(r[a], {
439      modifiers: ua,
440      structs: t,
441      type: "function"
442    }));
443  const o = [];
444  if (n.returns) {
445    const a = Tt(n.returns), u = a.length;
446    for (let c = 0; c < u; c++)
447      o.push(tr(a[c], {
448        modifiers: ua,
449        structs: t,
450        type: "function"
451      }));
452  }
453  return {
454    name: n.name,
455    type: "function",
456    stateMutability: n.stateMutability ?? "nonpayable",
457    inputs: s,
458    outputs: o
459  };
460}
461function qh(e, t = {}) {
462  const n = wh(e);
463  if (!n)
464    throw new Wr({ signature: e, type: "event" });
465  const r = Tt(n.parameters), s = [], i = r.length;
466  for (let o = 0; o < i; o++)
467    s.push(tr(r[o], {
468      modifiers: Rh,
469      structs: t,
470      type: "event"
471    }));
472  return { name: n.name, type: "event", inputs: s };
473}
474function Gh(e, t = {}) {
475  const n = yh(e);
476  if (!n)
477    throw new Wr({ signature: e, type: "error" });
478  const r = Tt(n.parameters), s = [], i = r.length;
479  for (let o = 0; o < i; o++)
480    s.push(tr(r[o], { structs: t, type: "error" }));
481  return { name: n.name, type: "error", inputs: s };
482}
483function zh(e, t = {}) {
484  const n = _h(e);
485  if (!n)
486    throw new Wr({ signature: e, type: "constructor" });
487  const r = Tt(n.parameters), s = [], i = r.length;
488  for (let o = 0; o < i; o++)
489    s.push(tr(r[o], { structs: t, type: "constructor" }));
490  return {
491    type: "constructor",
492    stateMutability: n.stateMutability ?? "nonpayable",
493    inputs: s
494  };
495}
496function Vh(e) {
497  const t = Ih(e);
498  if (!t)
499    throw new Wr({ signature: e, type: "fallback" });
500  return {
501    type: "fallback",
502    stateMutability: t.stateMutability ?? "nonpayable"
503  };
504}
505const Kh = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/, Yh = /^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/, Zh = /^u?int$/;
506function tr(e, t) {
507  const n = Wh(e, t?.type, t?.structs);
508  if (To.has(n))
509    return To.get(n);
510  const r = Nl.test(e), s = mn(r ? Yh : Kh, e);
511  if (!s)
512    throw new Ph({ param: e });
513  if (s.name && Jh(s.name))
514    throw new kh({ param: e, name: s.name });
515  const i = s.name ? { name: s.name } : {}, o = s.modifier === "indexed" ? { indexed: !0 } : {}, a = t?.structs ?? {};
516  let u, c = {};
517  if (r) {
518    u = "tuple";
519    const f = Tt(s.type), p = [], m = f.length;
520    for (let y = 0; y < m; y++)
521      p.push(tr(f[y], { structs: a }));
522    c = { components: p };
523  } else if (s.type in a)
524    u = "tuple", c = { components: a[s.type] };
525  else if (Zh.test(s.type))
526    u = `${s.type}256`;
527  else if (s.type === "address payable")
528    u = "address";
529  else if (u = s.type, t?.type !== "struct" && !kl(u))
530    throw new Oh({ type: u });
531  if (s.modifier) {
532    if (!t?.modifiers?.has?.(s.modifier))
533      throw new Uh({
534        param: e,
535        type: t?.type,
536        modifier: s.modifier
537      });
538    if (ua.has(s.modifier) && !Xh(u, !!s.array))
539      throw new Mh({
540        param: e,
541        type: t?.type,
542        modifier: s.modifier
543      });
544  }
545  const l = {
546    type: `${u}${s.array ?? ""}`,
547    ...i,
548    ...o,
549    ...c
550  };
551  return To.set(n, l), l;
552}
553function Tt(e, t = [], n = "", r = 0) {
554  const s = e.trim().length;
555  for (let i = 0; i < s; i++) {
556    const o = e[i], a = e.slice(i + 1);
557    switch (o) {
558      case ",":
559        return r === 0 ? Tt(a, [...t, n.trim()]) : Tt(a, t, `${n}${o}`, r);
560      case "(":
561        return Tt(a, t, `${n}${o}`, r + 1);
562      case ")":
563        return Tt(a, t, `${n}${o}`, r - 1);
564      default:
565        return Tt(a, t, `${n}${o}`, r);
566    }
567  }
568  if (n === "")
569    return t;
570  if (r !== 0)
571    throw new jh({ current: n, depth: r });
572  return t.push(n.trim()), t;
573}
574function kl(e) {
575  return e === "address" || e === "bool" || e === "function" || e === "string" || vl.test(e) || _l.test(e);
576}
577const Qh = /^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;
578function Jh(e) {
579  return e === "address" || e === "bool" || e === "function" || e === "string" || e === "tuple" || vl.test(e) || _l.test(e) || Qh.test(e);
580}
581function Xh(e, t) {
582  return t || e === "bytes" || e === "string" || e === "tuple";
583}
584function ep(e) {
585  const t = {}, n = e.length;
586  for (let o = 0; o < n; o++) {
587    const a = e[o];
588    if (!xl(a))
589      continue;
590    const u = Ah(a);
591    if (!u)
592      throw new Wr({ signature: a, type: "struct" });
593    const c = u.properties.split(";"), l = [], f = c.length;
594    for (let p = 0; p < f; p++) {
595      const y = c[p].trim();
596      if (!y)
597        continue;
598      const b = tr(y, {
599        type: "struct"
600      });
601      l.push(b);
602    }
603    if (!l.length)
604      throw new Dh({ signature: a });
605    t[u.name] = l;
606  }
607  const r = {}, s = Object.entries(t), i = s.length;
608  for (let o = 0; o < i; o++) {
609    const [a, u] = s[o];
610    r[a] = Ul(u, t);
611  }
612  return r;
613}
614const tp = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;
615function Ul(e = [], t = {}, n = /* @__PURE__ */ new Set()) {
616  const r = [], s = e.length;
617  for (let i = 0; i < s; i++) {
618    const o = e[i];
619    if (Nl.test(o.type))
620      r.push(o);
621    else {
622      const u = mn(tp, o.type);
623      if (!u?.type)
624        throw new Lh({ abiParameter: o });
625      const { array: c, type: l } = u;
626      if (l in t) {
627        if (n.has(l))
628          throw new Fh({ type: l });
629        r.push({
630          ...o,
631          type: `tuple${c ?? ""}`,
632          components: Ul(t[l], t, /* @__PURE__ */ new Set([...n, l]))
633        });
634      } else if (kl(l))
635        r.push(o);
636      else
637        throw new xh({ type: l });
638    }
639  }
640  return r;
641}
642function Ml(e) {
643  const t = ep(e), n = [], r = e.length;
644  for (let s = 0; s < r; s++) {
645    const i = e[s];
646    xl(i) || n.push($h(i, t));
647  }
648  return n;
649}
650function ke(e, t, n) {
651  const r = e[t.name];
652  if (typeof r == "function")
653    return r;
654  const s = e[n];
655  return typeof s == "function" ? s : (i) => t(e, i);
656}
657function Mn(e, { includeName: t = !1 } = {}) {
658  if (e.type !== "function" && e.type !== "event" && e.type !== "error")
659    throw new mp(e.type);
660  return `${e.name}(${ao(e.inputs, { includeName: t })})`;
661}
662function ao(e, { includeName: t = !1 } = {}) {
663  return e ? e.map((n) => np(n, { includeName: t })).join(t ? ", " : ",") : "";
664}
665function np(e, { includeName: t }) {
666  return e.type.startsWith("tuple") ? `(${ao(e.components, { includeName: t })})${e.type.slice(5)}` : e.type + (t && e.name ? ` ${e.name}` : "");
667}
668function Ln(e, { strict: t = !0 } = {}) {
669  return !e || typeof e != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(e) : e.startsWith("0x");
670}
671function Ze(e) {
672  return Ln(e, { strict: !1 }) ? Math.ceil((e.length - 2) / 2) : e.length;
673}
674const Ll = "2.48.4";
675let So = {
676  getDocsUrl: ({ docsBaseUrl: e, docsPath: t = "", docsSlug: n }) => t ? `${e ?? "https://viem.sh"}${t}${n ? `#${n}` : ""}` : void 0,
677  version: `viem@${Ll}`
678}
678, F = class la extends Error {
679  constructor(t, n = {}) {
680    const r = n.cause instanceof la ? n.cause.details : n.cause?.message ? n.cause.message : n.details, s = n.cause instanceof la && n.cause.docsPath || n.docsPath, i = So.getDocsUrl?.({ ...n, docsPath: s }), o = [
681      t || "An error occurred.",
682      "",
683      ...n.metaMessages ? [...n.metaMessages, ""] : [],
684      ...i ? [`Docs: ${i}`] : [],
685      ...r ? [`Details: ${r}`] : [],
686      ...So.version ? [`Version: ${So.version}`] : []
687    ].join(`
688`);
689    super(o, n.cause ? { cause: n.cause } : void 0), Object.defineProperty(this, "details", {
690      enumerable: !0,
691      configurable: !0,
692      writable: !0,
693      value: void 0
694    }), Object.defineProperty(this, "docsPath", {
695      enumerable: !0,
696      configurable: !0,
697      writable: !0,
698      value: void 0
699    }), Object.defineProperty(this, "metaMessages", {
700      enumerable: !0,
701      configurable: !0,
702      writable: !0,
703      value: void 0
704    }), Object.defineProperty(this, "shortMessage", {
705      enumerable: !0,
706      configurable: !0,
707      writable: !0,
708      value: void 0
709    }), Object.defineProperty(this, "version", {
710      enumerable: !0,
711      configurable: !0,
712      writable: !0,
713      value: void 0
714    }), Object.defineProperty(this, "name", {
715      enumerable: !0,
716      configurable: !0,
717      writable: !0,
718      value: "BaseError"
719    }), this.details = r, this.docsPath = s, this.metaMessages = n.metaMessages, this.name = n.name ?? this.name, this.shortMessage = t, this.version = Ll;
720  }
721  walk(t) {
722    return Bl(this, t);
723  }
724};
725function Bl(e, t) {
726  return t?.(e) ? e : e && typeof e == "object" && "cause" in e && e.cause !== void 0 ? Bl(e.cause, t) : t ? null : e;
727}
728class rp extends F {
729  constructor({ docsPath: t }) {
730    super([
731      "A constructor was not found on the ABI.",
732      "Make sure you are using the correct ABI and that the constructor exists on it."
733    ].join(`
734`), {
735      docsPath: t,
736      name: "AbiConstructorNotFoundError"
737    });
738  }
739}
740class Wc extends F {
741  constructor({ docsPath: t }) {
742    super([
743      "Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
744      "Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
745    ].join(`
746`), {
747      docsPath: t,
748      name: "AbiConstructorParamsNotFoundError"
749    });
750  }
751}
752class Dl extends F {
753  constructor({ data: t, params: n, size: r }) {
754    super([`Data size of ${r} bytes is too small for given parameters.`].join(`
755`), {
756      metaMessages: [
757        `Params: (${ao(n, { includeName: !0 })})`,
758        `Data:   ${t} (${r} bytes)`
759      ],
760      name: "AbiDecodingDataSizeTooSmallError"
761    }), Object.defineProperty(this, "data", {
762      enumerable: !0,
763      configurable: !0,
764      writable: !0,
765      value: void 0
766    }), Object.defineProperty(this, "params", {
767      enumerable: !0,
768      configurable: !0,
769      writable: !0,
770      value: void 0
771    }), Object.defineProperty(this, "size", {
772      enumerable: !0,
773      configurable: !0,
774      writable: !0,
775      value: void 0
776    }), this.data = t, this.params = n, this.size = r;
777  }
778}
779class Xa extends F {
780  constructor({ cause: t } = {}) {
781    super('Cannot decode zero data ("0x") with ABI parameters.', {
782      name: "AbiDecodingZeroDataError",
783      cause: t
784    });
785  }
786}
787class sp extends F {
788  constructor({ expectedLength: t, givenLength: n, type: r }) {
789    super([
790      `ABI encoding array length mismatch for type ${r}.`,
791      `Expected length: ${t}`,
792      `Given length: ${n}`
793    ].join(`
794`), { name: "AbiEncodingArrayLengthMismatchError" });
795  }
796}
797class ip extends F {
798  constructor({ expectedSize: t, value: n }) {
799    super(`Size of bytes "${n}" (bytes${Ze(n)}) does not match expected size (bytes${t}).`, { name: "AbiEncodingBytesSizeMismatchError" });
800  }
801}
802class op extends F {
803  constructor({ expectedLength: t, givenLength: n }) {
804    super([
805      "ABI encoding params/values length mismatch.",
806      `Expected length (params): ${t}`,
807      `Given length (values): ${n}`
808    ].join(`
809`), { name: "AbiEncodingLengthMismatchError" });
810  }
811}
812class Ev extends F {
813  constructor(t, { docsPath: n }) {
814    super([
815      `Arguments (\`args\`) were provided to "${t}", but "${t}" on the ABI does not contain any parameters (\`inputs\`).`,
816      "Cannot encode error result without knowing what the parameter types are.",
817      "Make sure you are using the correct ABI and that the inputs exist on it."
818    ].join(`
819`), {
820      docsPath: n,
821      name: "AbiErrorInputsNotFoundError"
822    });
823  }
824}
825class Av extends F {
826  constructor(t, { docsPath: n } = {}) {
827    super([
828      `Error ${t ? `"${t}" ` : ""}not found on ABI.`,
829      "Make sure you are using the correct ABI and that the error exists on it."
830    ].join(`
831`), {
832      docsPath: n,
833      name: "AbiErrorNotFoundError"
834    });
835  }
836}
837class Fl extends F {
838  constructor(t, { docsPath: n, cause: r }) {
839    super([
840      `Encoded error signature "${t}" not found on ABI.`,
841      "Make sure you are using the correct ABI and that the error exists on it.",
842      `You can look up the decoded signature here: https://4byte.sourcify.dev/?q=${t}.`
843    ].join(`
844`), {
845      docsPath: n,
846      name: "AbiErrorSignatureNotFoundError",
847      cause: r
848    }), Object.defineProperty(this, "signature", {
849      enumerable: !0,
850      configurable: !0,
851      writable: !0,
852      value: void 0
853    }), this.signature = t;
854  }
855}
856class ap extends F {
857  constructor({ docsPath: t }) {
858    super("Cannot extract event signature from empty topics.", {
859      docsPath: t,
860      name: "AbiEventSignatureEmptyTopicsError"
861    });
862  }
863}
864class cp extends F {
865  constructor(t, { docsPath: n }) {
866    super([
867      `Encoded event signature "${t}" not found on ABI.`,
868      "Make sure you are using the correct ABI and that the event exists on it.",
869      `You can look up the signature here: https://4byte.sourcify.dev/?q=${t}.`
870    ].join(`
871`), {
872      docsPath: n,
873      name: "AbiEventSignatureNotFoundError"
874    });
875  }
876}
877class vv extends F {
878  constructor(t, { docsPath: n } = {}) {
879    super([
880      `Event ${t ? `"${t}" ` : ""}not found on ABI.`,
881      "Make sure you are using the correct ABI and that the event exists on it."
882    ].join(`
883`), {
884      docsPath: n,
885      name: "AbiEventNotFoundError"
886    });
887  }
888}
889class Ui extends F {
890  constructor(t, { docsPath: n } = {}) {
891    super([
892      `Function ${t ? `"${t}" ` : ""}not found on ABI.`,
893      "Make sure you are using the correct ABI and that the function exists on it."
894    ].join(`
895`), {
896      docsPath: n,
897      name: "AbiFunctionNotFoundError"
898    });
899  }
900}
901class up extends F {
902  constructor(t, { docsPath: n }) {
903    super([
904      `Function "${t}" does not contain any \`outputs\` on ABI.`,
905      "Cannot decode function result without knowing what the parameter types are.",
906      "Make sure you are using the correct ABI and that the function exists on it."
907    ].join(`
908`), {
909      docsPath: n,
910      name: "AbiFunctionOutputsNotFoundError"
911    });
912  }
913}
914class _v extends F {
915  constructor(t, { docsPath: n }) {
916    super([
917      `Encoded function signature "${t}" not found on ABI.`,
918      "Make sure you are using the correct ABI and that the function exists on it.",
919      `You can look up the signature here: https://4byte.sourcify.dev/?q=${t}.`
920    ].join(`
921`), {
922      docsPath: n,
923      name: "AbiFunctionSignatureNotFoundError"
924    });
925  }
926}
927class lp extends F {
928  constructor(t, n) {
929    super("Found ambiguous types in overloaded ABI items.", {
930      metaMessages: [
931        `\`${t.type}\` in \`${Mn(t.abiItem)}\`, and`,
932        `\`${n.type}\` in \`${Mn(n.abiItem)}\``,
933        "",
934        "These types encode differently and cannot be distinguished at runtime.",
935        "Remove one of the ambiguous items in the ABI."
936      ],
937      name: "AbiItemAmbiguityError"
938    });
939  }
940}
941class Nv extends F {
942  constructor({ expectedSize: t, givenSize: n }) {
943    super(`Expected bytes${t}, got bytes${n}.`, {
944      name: "BytesSizeMismatchError"
945    });
946  }
947}
948class $c extends F {
949  constructor({ abiItem: t, data: n, params: r, size: s }) {
950    super([
951      `Data size of ${s} bytes is too small for non-indexed event parameters.`
952    ].join(`
953`), {
954      metaMessages: [
955        `Params: (${ao(r, { includeName: !0 })})`,
956        `Data:   ${n} (${s} bytes)`
957      ],
958      name: "DecodeLogDataMismatch"
959    }), Object.defineProperty(this, "abiItem", {
960      enumerable: !0,
961      configurable: !0,
962      writable: !0,
963      value: void 0
964    }), Object.defineProperty(this, "data", {
965      enumerable: !0,
966      configurable: !0,
967      writable: !0,
968      value: void 0
969    }), Object.defineProperty(this, "params", {
970      enumerable: !0,
971      configurable: !0,
972      writable: !0,
973      value: void 0
974    }), Object.defineProperty(this, "size", {
975      enumerable: !0,
976      configurable: !0,
977      writable: !0,
978      value: void 0
979    }), this.abiItem = t, this.data = n, this.params = r, this.size = s;
980  }
981}
982class dp extends F {
983  constructor({ abiItem: t, param: n }) {
984    super([
985      `Expected a topic for indexed event parameter${n.name ? ` "${n.name}"` : ""} on event "${Mn(t, { includeName: !0 })}".`
986    ].join(`
987`), { name: "DecodeLogTopicsMismatch" }), Object.defineProperty(this, "abiItem", {
988      enumerable: !0,
989      configurable: !0,
990      writable: !0,
991      value: void 0
992    }), this.abiItem = t;
993  }
994}
995class fp extends F {
996  constructor(t, { docsPath: n }) {
997    super([
998      `Type "${t}" is not a valid encoding type.`,
999      "Please provide a valid ABI type."
1000    ].join(`
1001`), { docsPath: n, name: "InvalidAbiEncodingType" });
1002  }
1003}
1004class hp extends F {
1005  constructor(t, { docsPath: n }) {
1006    super([
1007      `Type "${t}" is not a valid decoding type.`,
1008      "Please provide a valid ABI type."
1009    ].join(`
1010`), { docsPath: n, name: "InvalidAbiDecodingType" });
1011  }
1012}
1013class pp extends F {
1014  constructor(t) {
1015    super([`Value "${t}" is not a valid array.`].join(`
1016`), {
1017      name: "InvalidArrayError"
1018    });
1019  }
1020}
1021class mp extends F {
1022  constructor(t) {
1023    super([
1024      `"${t}" is not a valid definition type.`,
1025      'Valid types: "function", "event", "error"'
1026    ].join(`
1027`), { name: "InvalidDefinitionTypeError" });
1028  }
1029}
1030class Iv extends F {
1031  constructor(t) {
1032    super(`Type "${t}" is not supported for packed encoding.`, {
1033      name: "UnsupportedPackedAbiType"
1034    });
1035  }
1036}
1037let jl = class extends F {
1038  constructor({ offset: t, position: n, size: r }) {
1039    super(`Slice ${n === "start" ? "starting" : "ending"} at offset "${t}" is out-of-bounds (size: ${r}).`, { name: "SliceOffsetOutOfBoundsError" });
1040  }
1041}, Wl = class extends F {
1042  constructor({ size: t, targetSize: n, type: r }) {
1043    super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`, { name: "SizeExceedsPaddingSizeError" });
1044  }
1045};
1046class Hc extends F {
1047  constructor({ size: t, targetSize: n, type: r }) {
1048    super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} is expected to be ${n} ${r} long, but is ${t} ${r} long.`, { name: "InvalidBytesLengthError" });
1049  }
1050}
1051function $r(e, { dir: t, size: n = 32 } = {}) {
1052  return typeof e == "string" ? On(e, { dir: t, size: n }) : gp(e, { dir: t, size: n });
1053}
1054function On(e, { dir: t, size: n = 32 } = {}) {
1055  if (n === null)
1056    return e;
1057  const r = e.replace("0x", "");
1058  if (r.length > n * 2)
1059    throw new Wl({
1060      size: Math.ceil(r.length / 2),
1061      targetSize: n,
1062      type: "hex"
1063    });
1064  return `0x${r[t === "right" ? "padEnd" : "padStart"](n * 2, "0")}`;
1065}
1066function gp(e, { dir: t, size: n = 32 } = {}) {
1067  if (n === null)
1068    return e;
1069  if (e.length > n)
1070    throw new Wl({
1071      size: e.length,
1072      targetSize: n,
1073      type: "bytes"
1074    });
1075  const r = new Uint8Array(n);
1076  for (let s = 0; s < n; s++) {
1077    const i = t === "right";
1078    r[i ? s : n - s - 1] = e[i ? s : e.length - s - 1];
1079  }
1080  return r;
1081}
1082let ec = class extends F {
1083  constructor({ max: t, min: n, signed: r, size: s, value: i }) {
1084    super(`Number "${i}" is not in safe ${s ? `${s * 8}-bit ${r ? "signed" : "unsigned"} ` : ""}integer range ${t ? `(${n} to ${t})` : `(above ${n})`}`, { name: "IntegerOutOfRangeError" });
1085  }
1086}, yp = class extends F {
1087  constructor(t) {
1088    super(`Bytes value "${t}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`, {
1089      name: "InvalidBytesBooleanError"
1090    });
1091  }
1092};
1093class bp extends F {
1094  constructor(t) {
1095    super(`Hex value "${t}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`, { name: "InvalidHexBooleanError" });
1096  }
1097}
1098let wp = class extends F {
1099  constructor({ givenSize: t, maxSize: n }) {
1100    super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`, { name: "SizeOverflowError" });
1101  }
1102};
1103function Xn(e, { dir: t = "left" } = {}) {
1104  let n = typeof e == "string" ? e.replace("0x", "") : e, r = 0;
1105  for (let s = 0; s < n.length - 1 && n[t === "left" ? s : n.length - s - 1].toString() === "0"; s++)
1106    r++;
1107  return n = t === "left" ? n.slice(r) : n.slice(0, n.length - r), typeof e == "string" ? (n.length === 1 && t === "right" && (n = `${n}0`), `0x${n.length % 2 === 1 ? `0${n}` : n}`) : n;
1108}
1109function _t(e, { size: t }) {
1110  if (Ze(e) > t)
1111    throw new wp({
1112      givenSize: Ze(e),
1113      maxSize: t
1114    });
1115}
1116function Pv(e, t) {
1117  const n = { to: t }, r = n.to;
1118  return r === "number" ? Bn(e, n) : r === "bigint" ? nr(e, n) : r === "string" ? $l(e, n) : r === "boolean" ? Cp(e, n) : Pt(e, n);
1119}
1120function nr(e, t = {}) {
1121  const { signed: n } = t;
1122  t.size && _t(e, { size: t.size });
1123  const r = BigInt(e);
1124  if (!n)
1125    return r;
1126  const s = (e.length - 2) / 2, i = (1n << BigInt(s) * 8n - 1n) - 1n;
1127  return r <= i ? r : r - BigInt(`0x${"f".padStart(s * 2, "f")}`) - 1n;
1128}
1129function Cp(e, t = {}) {
1130  let n = e;
1131  if (t.size && (_t(n, { size: t.size }), n = Xn(n)), Xn(n) === "0x00")
1132    return !1;
1133  if (Xn(n) === "0x01")
1134    return !0;
1135  throw new bp(n);
1136}
1137function Bn(e, t = {}) {
1138  const n = nr(e, t), r = Number(n);
1139  if (!Number.isSafeInteger(r))
1140    throw new ec({
1141      max: `${Number.MAX_SAFE_INTEGER}`,
1142      min: `${Number.MIN_SAFE_INTEGER}`,
1143      signed: t.signed,
1144      size: t.size,
1145      value: `${n}n`
1146    });
1147  return r;
1148}
1149function $l(e, t = {}) {
1150  let n = Pt(e);
1151  return t.size && (_t(n, { size: t.size }), n = Xn(n, { dir: "right" })), new TextDecoder().decode(n);
1152}
1153const Ep = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
1154function ns(e, t = {}) {
1155  return typeof e == "number" || typeof e == "bigint" ? be(e, t) : typeof e == "string" ? tc(e, t) : typeof e == "boolean" ? Hl(e, t) : ft(e, t);
1156}
1157function Hl(e, t = {}) {
1158  const n = `0x${Number(e)}`;
1159  return typeof t.size == "number" ? (_t(n, { size: t.size }), $r(n, { size: t.size })) : n;
1160}
1161function ft(e, t = {}) {
1162  let n = "";
1163  for (let s = 0; s < e.length; s++)
1164    n += Ep[e[s]];
1165  const r = `0x${n}`;
1166  return typeof t.size == "number" ? (_t(r, { size: t.size }), $r(r, { dir: "right", size: t.size })) : r;
1167}
1168function be(e, t = {}) {
1169  const { signed: n, size: r } = t, s = BigInt(e);
1170  let i;
1171  r ? n ? i = (1n << BigInt(r) * 8n - 1n) - 1n : i = 2n ** (BigInt(r) * 8n) - 1n : typeof e == "number" && (i = BigInt(Number.MAX_SAFE_INTEGER));
1172  const o = typeof i == "bigint" && n ? -i - 1n : 0;
1173  if (i && s > i || s < o) {
1174    const u = typeof e == "bigint" ? "n" : "";
1175    throw new ec({
1176      max: i ? `${i}${u}` : void 0,
1177      min: `${o}${u}`,
1178      signed: n,
1179      size: r,
1180      value: `${e}${u}`
1181    });
1182  }
1183  const a = `0x${(n && s < 0 ? (1n << BigInt(r * 8)) + BigInt(s) : s).toString(16)}`;
1184  return r ? $r(a, { size: r }) : a;
1185}
1186const Ap = /* @__PURE__ */ new TextEncoder();
1187function tc(e, t = {}) {
1188  const n = Ap.encode(e);
1189  return ft(n, t);
1190}
1191const vp = /* @__PURE__ */ new TextEncoder();
1192function co(e, t = {}) {
1193  return typeof e == "number" || typeof e == "bigint" ? Np(e, t) : typeof e == "boolean" ? _p(e, t) : Ln(e) ? Pt(e, t) : ql(e, t);
1194}
1195function _p(e, t = {}) {
1196  const n = new Uint8Array(1);
1197  return n[0] = Number(e), typeof t.size == "number" ? (_t(n, { size: t.size }), $r(n, { size: t.size })) : n;
1198}
1199const Yt = {
1200  zero: 48,
1201  nine: 57,
1202  A: 65,
1203  F: 70,
1204  a: 97,
1205  f: 102
1206};
1207function qc(e) {
1208  if (e >= Yt.zero && e <= Yt.nine)
1209    return e - Yt.zero;
1210  if (e >= Yt.A && e <= Yt.F)
1211    return e - (Yt.A - 10);
1212  if (e >= Yt.a && e <= Yt.f)
1213    return e - (Yt.a - 10);
1214}
1215function Pt(e, t = {}) {
1216  let n = e;
1217  t.size && (_t(n, { size: t.size }), n = $r(n, { dir: "right", size: t.size }));
1218  let r = n.slice(2);
1219  r.length % 2 && (r = `0${r}`);
1220  const s = r.length / 2, i = new Uint8Array(s);
1221  for (let o = 0, a = 0; o < s; o++) {
1222    const u = qc(r.charCodeAt(a++)), c = qc(r.charCodeAt(a++));
1223    if (u === void 0 || c === void 0)
1224      throw new F(`Invalid byte sequence ("${r[a - 2]}${r[a - 1]}" in "${r}").`);
1225    i[o] = u * 16 + c;
1226  }
1227  return i;
1228}
1229function Np(e, t) {
1230  const n = be(e, t);
1231  return Pt(n);
1232}
1233function ql(e, t = {}) {
1234  const n = vp.encode(e);
1235  return typeof t.size == "number" ? (_t(n, { size: t.size }), $r(n, { dir: "right", size: t.size })) : n;
1236}
1237const ni = /* @__PURE__ */ BigInt(2 ** 32 - 1), Gc = /* @__PURE__ */ BigInt(32);
1238function Ip(e, t = !1) {
1239  return t ? { h: Number(e & ni), l: Number(e >> Gc & ni) } : { h: Number(e >> Gc & ni) | 0, l: Number(e & ni) | 0 };
1240}
1241function Gl(e, t = !1) {
1242  const n = e.length;
1243  let r = new Uint32Array(n), s = new Uint32Array(n);
1244  for (let i = 0; i < n; i++) {
1245    const { h: o, l: a } = Ip(e[i], t);
1246    [r[i], s[i]] = [o, a];
1247  }
1248  return [r, s];
1249}
1250const zc = (e, t, n) => e >>> n, Vc = (e, t, n) => e << 32 - n | t >>> n, yr = (e, t, n) => e >>> n | t << 32 - n, br = (e, t, n) => e << 32 - n | t >>> n, ri = (e, t, n) => e << 64 - n | t >>> n - 32, si = (e, t, n) => e >>> n - 32 | t << 64 - n, Tp = (e, t, n) => e << n | t >>> 32 - n, Sp = (e, t, n) => t << n | e >>> 32 - n, Rp = (e, t, n) => t << n - 32 | e >>> 64 - n, xp = (e, t, n) => e << n - 32 | t >>> 64 - n;
1251function Zt(e, t, n, r) {
1252  const s = (t >>> 0) + (r >>> 0);
1253  return { h: e + n + (s / 2 ** 32 | 0) | 0, l: s | 0 };
1254}
1255const Op = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), Pp = (e, t, n, r) => t + n + r + (e / 2 ** 32 | 0) | 0, kp = (e, t, n, r) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (r >>> 0), Up = (e, t, n, r, s) => t + n + r + s + (e / 2 ** 32 | 0) | 0, Mp = (e, t, n, r, s) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (r >>> 0) + (s >>> 0), Lp = (e, t, n, r, s, i) => t + n + r + s + i + (e / 2 ** 32 | 0) | 0, wr = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
1256function Bp(e) {
1257  return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
1258}
1259function Mi(e) {
1260  if (!Number.isSafeInteger(e) || e < 0)
1261    throw new Error("positive integer expected, got " + e);
1262}
1263function Or(e, ...t) {
1264  if (!Bp(e))
1265    throw new Error("Uint8Array expected");
1266  if (t.length > 0 && !t.includes(e.length))
1267    throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
1268}
1269function kv(e) {
1270  if (typeof e != "function" || typeof e.create != "function")
1271    throw new Error("Hash should be wrapped by utils.createHasher");
1272  Mi(e.outputLen), Mi(e.blockLen);
1273}
1274function Li(e, t = !0) {
1275  if (e.destroyed)
1276    throw new Error("Hash instance has been destroyed");
1277  if (t && e.finished)
1278    throw new Error("Hash#digest() has already been called");
1279}
1280function zl(e, t) {
1281  Or(e);
1282  const n = t.outputLen;
1283  if (e.length < n)
1284    throw new Error("digestInto() expects output buffer of length at least " + n);
1285}
1286function Dp(e) {
1287  return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
1288}
1289function rr(...e) {
1290  for (let t = 0; t < e.length; t++)
1291    e[t].fill(0);
1292}
1293function Ro(e) {
1294  return new DataView(e.buffer, e.byteOffset, e.byteLength);
1295}
1296function Dt(e, t) {
1297  return e << 32 - t | e >>> t;
1298}
1299const Fp = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1300function jp(e) {
1301  return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
1302}
1303function Wp(e) {
1304  for (let t = 0; t < e.length; t++)
1305    e[t] = jp(e[t]);
1306  return e;
1307}
1308const Kc = Fp ? (e) => e : Wp;
1309function $p(e) {
1310  if (typeof e != "string")
1311    throw new Error("string expected");
1312  return new Uint8Array(new TextEncoder().encode(e));
1313}
1314function nc(e) {
1315  return typeof e == "string" && (e = $p(e)), Or(e), e;
1316}
1317function Uv(...e) {
1318  let t = 0;
1319  for (let r = 0; r < e.length; r++) {
1320    const s = e[r];
1321    Or(s), t += s.length;
1322  }
1323  const n = new Uint8Array(t);
1324  for (let r = 0, s = 0; r < e.length; r++) {
1325    const i = e[r];
1326    n.set(i, s), s += i.length;
1327  }
1328  return n;
1329}
1330class Vl {
1331}
1332function uo(e) {
1333  const t = (r) => e().update(nc(r)).digest(), n = e();
1334  return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
1335}
1336function Mv(e = 32) {
1337  if (wr && typeof wr.getRandomValues == "function")
1338    return wr.getRandomValues(new Uint8Array(e));
1339  if (wr && typeof wr.randomBytes == "function")
1340    return Uint8Array.from(wr.randomBytes(e));
1341  throw new Error("crypto.getRandomValues must be defined");
1342}
1343const Hp = BigInt(0), Vr = BigInt(1), qp = BigInt(2), Gp = BigInt(7), zp = BigInt(256), Vp = BigInt(113), Kl = [], Yl = [], Zl = [];
1344for (let e = 0, t = Vr, n = 1, r = 0; e < 24; e++) {
1345  [n, r] = [r, (2 * n + 3 * r) % 5], Kl.push(2 * (5 * r + n)), Yl.push((e + 1) * (e + 2) / 2 % 64);
1346  let s = Hp;
1347  for (let i = 0; i < 7; i++)
1348    t = (t << Vr ^ (t >> Gp) * Vp) % zp, t & qp && (s ^= Vr << (Vr << /* @__PURE__ */ BigInt(i)) - Vr);
1349  Zl.push(s);
1350}
1351const Ql = Gl(Zl, !0), Kp = Ql[0], Yp = Ql[1], Yc = (e, t, n) => n > 32 ? Rp(e, t, n) : Tp(e, t, n), Zc = (e, t, n) => n > 32 ? xp(e, t, n) : Sp(e, t, n);
1352function Zp(e, t = 24) {
1353  const n = new Uint32Array(10);
1354  for (let r = 24 - t; r < 24; r++) {
1355    for (let o = 0; o < 10; o++)
1356      n[o] = e[o] ^ e[o + 10] ^ e[o + 20] ^ e[o + 30] ^ e[o + 40];
1357    for (let o = 0; o < 10; o += 2) {
1358      const a = (o + 8) % 10, u = (o + 2) % 10, c = n[u], l = n[u + 1], f = Yc(c, l, 1) ^ n[a], p = Zc(c, l, 1) ^ n[a + 1];
1359      for (let m = 0; m < 50; m += 10)
1360        e[o + m] ^= f, e[o + m + 1] ^= p;
1361    }
1362    let s = e[2], i = e[3];
1363    for (let o = 0; o < 24; o++) {
1364      const a = Yl[o], u = Yc(s, i, a), c = Zc(s, i, a), l = Kl[o];
1365      s = e[l], i = e[l + 1], e[l] = u, e[l + 1] = c;
1366    }
1367    for (let o = 0; o < 50; o += 10) {
1368      for (let a = 0; a < 10; a++)
1369        n[a] = e[o + a];
1370      for (let a = 0; a < 10; a++)
1371        e[o + a] ^= ~n[(a + 2) % 10] & n[(a + 4) % 10];
1372    }
1373    e[0] ^= Kp[r], e[1] ^= Yp[r];
1374  }
1375  rr(n);
1376}
1377class rc extends Vl {
1378  // NOTE: we accept arguments in bytes instead of bits here.
1379  constructor(t, n, r, s = !1, i = 24) {
1380    if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = t, this.suffix = n, this.outputLen = r, this.enableXOF = s, this.rounds = i, Mi(r), !(0 < t && t < 200))
1381      throw new Error("only keccak-f1600 function is supported");
1382    this.state = new Uint8Array(200), this.state32 = Dp(this.state);
1383  }
1384  clone() {
1385    return this._cloneInto();
1386  }
1387  keccak() {
1388    Kc(this.state32), Zp(this.state32, this.rounds), Kc(this.state32), this.posOut = 0, this.pos = 0;
1389  }
1390  update(t) {
1391    Li(this), t = nc(t), Or(t);
1392    const { blockLen: n, state: r } = this, s = t.length;
1393    for (let i = 0; i < s; ) {
1394      const o = Math.min(n - this.pos, s - i);
1395      for (let a = 0; a < o; a++)
1396        r[this.pos++] ^= t[i++];
1397      this.pos === n && this.keccak();
1398    }
1399    return this;
1400  }
1401  finish() {
1402    if (this.finished)
1403      return;
1404    this.finished = !0;
1405    const { state: t, suffix: n, pos: r, blockLen: s } = this;
1406    t[r] ^= n, (n & 128) !== 0 && r === s - 1 && this.keccak(), t[s - 1] ^= 128, this.keccak();
1407  }
1408  writeInto(t) {
1409    Li(this, !1), Or(t), this.finish();
1410    const n = this.state, { blockLen: r } = this;
1411    for (let s = 0, i = t.length; s < i; ) {
1412      this.posOut >= r && this.keccak();
1413      const o = Math.min(r - this.posOut, i - s);
1414      t.set(n.subarray(this.posOut, this.posOut + o), s), this.posOut += o, s += o;
1415    }
1416    return t;
1417  }
1418  xofInto(t) {
1419    if (!this.enableXOF)
1420      throw new Error("XOF is not possible for this instance");
1421    return this.writeInto(t);
1422  }
1423  xof(t) {
1424    return Mi(t), this.xofInto(new Uint8Array(t));
1425  }
1426  digestInto(t) {
1427    if (zl(t, this), this.finished)
1428      throw new Error("digest() was already called");
1429    return this.writeInto(t), this.destroy(), t;
1430  }
1431  digest() {
1432    return this.digestInto(new Uint8Array(this.outputLen));
1433  }
1434  destroy() {
1435    this.destroyed = !0, rr(this.state);
1436  }
1437  _cloneInto(t) {
1438    const { blockLen: n, suffix: r, outputLen: s, rounds: i, enableXOF: o } = this;
1439    return t || (t = new rc(n, r, s, o, i)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = i, t.suffix = r, t.outputLen = s, t.enableXOF = o, t.destroyed = this.destroyed, t;
1440  }
1441}
1442const Qp = (e, t, n) => uo(() => new rc(t, e, n)), Jp = Qp(1, 136, 256 / 8);
1443function Hs(e, t) {
1444  const n = t || "hex", r = Jp(Ln(e, { strict: !1 }) ? co(e) : e);
1445  return n === "bytes" ? r : ns(r);
1446}
1447const Xp = (e) => Hs(co(e));
1448function e0(e) {
1449  return Xp(e);
1450}
1451function t0(e) {
1452  let t = !0, n = "", r = 0, s = "", i = !1;
1453  for (let o = 0; o < e.length; o++) {
1454    const a = e[o];
1455    if (["(", ")", ","].includes(a) && (t = !0), a === "(" && r++, a === ")" && r--, !!t) {
1456      if (r === 0) {
1457        if (a === " " && ["event", "function", ""].includes(s))
1458          s = "";
1459        else if (s += a, a === ")") {
1460          i = !0;
1461          break;
1462        }
1463        continue;
1464      }
1465      if (a === " ") {
1466        e[o - 1] !== "," && n !== "," && n !== ",(" && (n = "", t = !1);
1467        continue;
1468      }
1469      s += a, n += a;
1470    }
1471  }
1472  if (!i)
1473    throw new F("Unable to normalize signature.");
1474  return s;
1475}
1476const n0 = (e) => {
1477  const t = typeof e == "string" ? e : mh(e);
1478  return t0(t);
1479};
1480function Jl(e) {
1481  return e0(n0(e));
1482}
1483const sc = Jl;
1484class sr extends F {
1485  constructor({ address: t }) {
1486    super(`Address "${t}
1486" is invalid.`, {
1487      metaMessages: [
1488        "- Address must be a hex value of 20 bytes (40 hex characters).",
1489        "- Address must match its checksum counterpart."
1490      ],
1491      name: "InvalidAddressError"
1492    });
1493  }
1494}
1495class qs extends Map {
1496  constructor(t) {
1497    super(), Object.defineProperty(this, "maxSize", {
1498      enumerable: !0,
1499      configurable: !0,
1500      writable: !0,
1501      value: void 0
1502    }), this.maxSize = t;
1503  }
1504  get(t) {
1505    const n = super.get(t);
1506    return super.has(t) && (super.delete(t), super.set(t, n)), n;
1507  }
1508  set(t, n) {
1509    if (super.has(t) && super.delete(t), super.set(t, n), this.maxSize && this.size > this.maxSize) {
1510      const r = super.keys().next().value;
1511      r !== void 0 && super.delete(r);
1512    }
1513    return this;
1514  }
1515}
1516const xo = /* @__PURE__ */ new qs(8192);
1517function Gs(e, t) {
1518  if (xo.has(`${e}.${t}`))
1519    return xo.get(`${e}.${t}`);
1520  const n = t ? `${t}${e.toLowerCase()}` : e.substring(2).toLowerCase(), r = Hs(ql(n), "bytes"), s = (t ? n.substring(`${t}0x`.length) : n).split("");
1521  for (let o = 0; o < 40; o += 2)
1522    r[o >> 1] >> 4 >= 8 && s[o] && (s[o] = s[o].toUpperCase()), (r[o >> 1] & 15) >= 8 && s[o + 1] && (s[o + 1] = s[o + 1].toUpperCase());
1523  const i = `0x${s.join("")}`;
1524  return xo.set(`${e}.${t}`, i), i;
1525}
1526function Vn(e, t) {
1527  if (!Gt(e, { strict: !1 }))
1528    throw new sr({ address: e });
1529  return Gs(e, t);
1530}
1531const r0 = /^0x[a-fA-F0-9]{40}$/, Oo = /* @__PURE__ */ new qs(8192);
1532function Gt(e, t) {
1533  const { strict: n = !0 } = t ?? {}, r = `${e}.${n}`;
1534  if (Oo.has(r))
1535    return Oo.get(r);
1536  const s = r0.test(e) ? e.toLowerCase() === e ? !0 : n ? Gs(e) === e : !0 : !1;
1537  return Oo.set(r, s), s;
1538}
1539function Dn(e) {
1540  return typeof e[0] == "string" ? lo(e) : s0(e);
1541}
1542function s0(e) {
1543  let t = 0;
1544  for (const s of e)
1545    t += s.length;
1546  const n = new Uint8Array(t);
1547  let r = 0;
1548  for (const s of e)
1549    n.set(s, r), r += s.length;
1550  return n;
1551}
1552function lo(e) {
1553  return `0x${e.reduce((t, n) => t + n.replace("0x", ""), "")}`;
1554}
1555function Bi(e, t, n, { strict: r } = {}) {
1556  return Ln(e, { strict: !1 }) ? i0(e, t, n, {
1557    strict: r
1558  }) : td(e, t, n, {
1559    strict: r
1560  });
1561}
1562function Xl(e, t) {
1563  if (typeof t == "number" && t > 0 && t > Ze(e) - 1)
1564    throw new jl({
1565      offset: t,
1566      position: "start",
1567      size: Ze(e)
1568    });
1569}
1570function ed(e, t, n) {
1571  if (typeof t == "number" && typeof n == "number" && Ze(e) !== n - t)
1572    throw new jl({
1573      offset: n,
1574      position: "end",
1575      size: Ze(e)
1576    });
1577}
1578function td(e, t, n, { strict: r } = {}) {
1579  Xl(e, t);
1580  const s = e.slice(t, n);
1581  return r && ed(s, t, n), s;
1582}
1583function i0(e, t, n, { strict: r } = {}) {
1584  Xl(e, t);
1585  const s = `0x${e.replace("0x", "").slice((t ?? 0) * 2, (n ?? e.length) * 2)}`;
1586  return r && ed(s, t, n), s;
1587}
1588const Lv = /^(.*)\[([0-9]*)\]$/, Bv = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, o0 = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
1589function nd(e, t) {
1590  if (e.length !== t.length)
1591    throw new op({
1592      expectedLength: e.length,
1593      givenLength: t.length
1594    });
1595  const n = a0({
1596    params: e,
1597    values: t
1598  }), r = oc(n);
1599  return r.length === 0 ? "0x" : r;
1600}
1601function a0({ params: e, values: t }) {
1602  const n = [];
1603  for (let r = 0; r < e.length; r++)
1604    n.push(ic({ param: e[r], value: t[r] }));
1605  return n;
1606}
1607function ic({ param: e, value: t }) {
1608  const n = ac(e.type);
1609  if (n) {
1610    const [r, s] = n;
1611    return u0(t, { length: r, param: { ...e, type: s } });
1612  }
1613  if (e.type === "tuple")
1614    return p0(t, {
1615      param: e
1616    });
1617  if (e.type === "address")
1618    return c0(t);
1619  if (e.type === "bool")
1620    return d0(t);
1621  if (e.type.startsWith("uint") || e.type.startsWith("int")) {
1622    const r = e.type.startsWith("int"), [, , s = "256"] = o0.exec(e.type) ?? [];
1623    return f0(t, {
1624      signed: r,
1625      size: Number(s)
1626    });
1627  }
1628  if (e.type.startsWith("bytes"))
1629    return l0(t, { param: e });
1630  if (e.type === "string")
1631    return h0(t);
1632  throw new fp(e.type, {
1633    docsPath: "/docs/contract/encodeAbiParameters"
1634  });
1635}
1636function oc(e) {
1637  let t = 0;
1638  for (let i = 0; i < e.length; i++) {
1639    const { dynamic: o, encoded: a } = e[i];
1640    o ? t += 32 : t += Ze(a);
1641  }
1642  const n = [], r = [];
1643  let s = 0;
1644  for (let i = 0; i < e.length; i++) {
1645    const { dynamic: o, encoded: a } = e[i];
1646    o ? (n.push(be(t + s, { size: 32 })), r.push(a), s += Ze(a)) : n.push(a);
1647  }
1648  return Dn([...n, ...r]);
1649}
1650function c0(e) {
1651  if (!Gt(e))
1652    throw new sr({ address: e });
1653  return { dynamic: !1, encoded: On(e.toLowerCase()) };
1654}
1655function u0(e, { length: t, param: n }) {
1656  const r = t === null;
1657  if (!Array.isArray(e))
1658    throw new pp(e);
1659  if (!r && e.length !== t)
1660    throw new sp({
1661      expectedLength: t,
1662      givenLength: e.length,
1663      type: `${n.type}[${t}]`
1664    });
1665  let s = !1;
1666  const i = [];
1667  for (let o = 0; o < e.length; o++) {
1668    const a = ic({ param: n, value: e[o] });
1669    a.dynamic && (s = !0), i.push(a);
1670  }
1671  if (r || s) {
1672    const o = oc(i);
1673    if (r) {
1674      const a = be(i.length, { size: 32 });
1675      return {
1676        dynamic: !0,
1677        encoded: i.length > 0 ? Dn([a, o]) : a
1678      };
1679    }
1680    if (s)
1681      return { dynamic: !0, encoded: o };
1682  }
1683  return {
1684    dynamic: !1,
1685    encoded: Dn(i.map(({ encoded: o }) => o))
1686  };
1687}
1688function l0(e, { param: t }) {
1689  const [, n] = t.type.split("bytes"), r = Ze(e);
1690  if (!n) {
1691    let s = e;
1692    return r % 32 !== 0 && (s = On(s, {
1693      dir: "right",
1694      size: Math.ceil((e.length - 2) / 2 / 32) * 32
1695    })), {
1696      dynamic: !0,
1697      encoded: Dn([On(be(r, { size: 32 })), s])
1698    };
1699  }
1700  if (r !== Number.parseInt(n, 10))
1701    throw new ip({
1702      expectedSize: Number.parseInt(n, 10),
1703      value: e
1704    });
1705  return { dynamic: !1, encoded: On(e, { dir: "right" }) };
1706}
1707function d0(e) {
1708  if (typeof e != "boolean")
1709    throw new F(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);
1710  return { dynamic: !1, encoded: On(Hl(e)) };
1711}
1712function f0(e, { signed: t, size: n = 256 }) {
1713  if (typeof n == "number") {
1714    const r = 2n ** (BigInt(n) - (t ? 1n : 0n)) - 1n, s = t ? -r - 1n : 0n;
1715    if (e > r || e < s)
1716      throw new ec({
1717        max: r.toString(),
1718        min: s.toString(),
1719        signed: t,
1720        size: n / 8,
1721        value: e.toString()
1722      });
1723  }
1724  return {
1725    dynamic: !1,
1726    encoded: be(e, {
1727      size: 32,
1728      signed: t
1729    })
1730  };
1731}
1732function h0(e) {
1733  const t = tc(e), n = Math.ceil(Ze(t) / 32), r = [];
1734  for (let s = 0; s < n; s++)
1735    r.push(On(Bi(t, s * 32, (s + 1) * 32), {
1736      dir: "right"
1737    }));
1738  return {
1739    dynamic: !0,
1740    encoded: Dn([
1741      On(be(Ze(t), { size: 32 })),
1742      ...r
1743    ])
1744  };
1745}
1746function p0(e, { param: t }) {
1747  let n = !1;
1748  const r = [];
1749  for (let s = 0; s < t.components.length; s++) {
1750    const i = t.components[s], o = Array.isArray(e) ? s : i.name, a = ic({
1751      param: i,
1752      value: e[o]
1753    });
1754    r.push(a), a.dynamic && (n = !0);
1755  }
1756  return {
1757    dynamic: n,
1758    encoded: n ? oc(r) : Dn(r.map(({ encoded: s }) => s))
1759  };
1760}
1761function ac(e) {
1762  const t = e.match(/^(.*)\[(\d+)?\]$/);
1763  return t ? (
1764    // Return `null` if the array is dynamic.
1765    [t[2] ? Number(t[2]) : null, t[1]]
1766  ) : void 0;
1767}
1768const cc = (e) => Bi(Jl(e), 0, 4);
1769function uc(e) {
1770  const { abi: t, args: n = [], name: r } = e, s = Ln(r, { strict: !1 }), i = t.filter((a) => s ? a.type === "function" ? cc(a) === r : a.type === "event" ? sc(a) === r : !1 : "name" in a && a.name === r);
1771  if (i.length === 0)
1772    return;
1773  if (i.length === 1)
1774    return i[0];
1775  let o;
1776  for (const a of i) {
1777    if (!("inputs" in a))
1778      continue;
1779    if (!n || n.length === 0) {
1780      if (!a.inputs || a.inputs.length === 0)
1781        return a;
1782      continue;
1783    }
1784    if (!a.inputs || a.inputs.length === 0 || a.inputs.length !== n.length)
1785      continue;
1786    if (n.every((c, l) => {
1787      const f = "inputs" in a && a.inputs[l];
1788      return f ? da(c, f) : !1;
1789    })) {
1790      if (o && "inputs" in o && o.inputs) {
1791        const c = rd(a.inputs, o.inputs, n);
1792        if (c)
1793          throw new lp({
1794            abiItem: a,
1795            type: c[0]
1796          }, {
1797            abiItem: o,
1798            type: c[1]
1799          });
1800      }
1801      o = a;
1802    }
1803  }
1804  return o || i[0];
1805}
1806function da(e, t) {
1807  const n = typeof e, r = t.type;
1808  switch (r) {
1809    case "address":
1810      return Gt(e, { strict: !1 });
1811    case "bool":
1812      return n === "boolean";
1813    case "function":
1814      return n === "string";
1815    case "string":
1816      return n === "string";
1817    default:
1818      return r === "tuple" && "components" in t ? Object.values(t.components).every((s, i) => n === "object" && da(Object.values(e)[i], s)) : /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r) ? n === "number" || n === "bigint" : /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r) ? n === "string" || e instanceof Uint8Array : /[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r) ? Array.isArray(e) && e.every((s) => da(s, {
1819        ...t,
1820        // Pop off `[]` or `[M]` from end of type
1821        type: r.replace(/(\[[0-9]{0,}\])$/, "")
1822      })) : !1;
1823  }
1824}
1825function rd(e, t, n) {
1826  for (const r in e) {
1827    const s = e[r], i = t[r];
1828    if (s.type === "tuple" && i.type === "tuple" && "components" in s && "components" in i)
1829      return rd(s.components, i.components, n[r]);
1830    const o = [s.type, i.type];
1831    if (o.includes("address") && o.includes("bytes20") ? !0 : o.includes("address") && o.includes("string") ? Gt(n[r], { strict: !1 }) : o.includes("address") && o.includes("bytes") ? Gt(n[r], { strict: !1 }) : !1)
1832      return o;
1833  }
1834}
1835function m0(e, { method: t }) {
1836  const n = {};
1837  return e.transport.type === "fallback" && e.transport.onResponse?.(({ method: r, response: s, status: i, transport: o }) => {
1838    i === "success" && t === r && (n[s] = o.request);
1839  }), ((r) => n[r] || e.request);
1840}
1841function vt(e) {
1842  return typeof e == "string" ? { address: e, type: "json-rpc" } : e;
1843}
1844const Qc = "/docs/contract/encodeFunctionData";
1845function g0(e) {
1846  const { abi: t, args: n, functionName: r }
1846 = e;
1847  let s = t[0];
1848  if (r) {
1849    const i = uc({
1850      abi: t,
1851      args: n,
1852      name: r
1853    });
1854    if (!i)
1855      throw new Ui(r, { docsPath: Qc });
1856    s = i;
1857  }
1858  if (s.type !== "function")
1859    throw new Ui(void 0, { docsPath: Qc });
1860  return {
1861    abi: [s],
1862    functionName: cc(Mn(s))
1863  };
1864}
1865function lc(e) {
1866  const { args: t } = e, { abi: n, functionName: r } = e.abi.length === 1 && e.functionName?.startsWith("0x") ? e : g0(e), s = n[0], i = r, o = "inputs" in s && s.inputs ? nd(s.inputs, t ?? []) : void 0;
1867  return lo([i, o ?? "0x"]);
1868}
1869const y0 = {
1870  1: "An `assert` condition failed.",
1871  17: "Arithmetic operation resulted in underflow or overflow.",
1872  18: "Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",
1873  33: "Attempted to convert to an invalid type.",
1874  34: "Attempted to access a storage byte array that is incorrectly encoded.",
1875  49: "Performed `.pop()` on an empty array",
1876  50: "Array index is out of bounds.",
1877  65: "Allocated too much memory or created an array which is too large.",
1878  81: "Attempted to call a zero-initialized variable of internal function type."
1879}, b0 = {
1880  inputs: [
1881    {
1882      name: "message",
1883      type: "string"
1884    }
1885  ],
1886  name: "Error",
1887  type: "error"
1888}, w0 = {
1889  inputs: [
1890    {
1891      name: "reason",
1892      type: "uint256"
1893    }
1894  ],
1895  name: "Panic",
1896  type: "error"
1897};
1898class Jc extends F {
1899  constructor({ offset: t }) {
1900    super(`Offset \`${t}\` cannot be negative.`, {
1901      name: "NegativeOffsetError"
1902    });
1903  }
1904}
1905class sd extends F {
1906  constructor({ length: t, position: n }) {
1907    super(`Position \`${n}\` is out of bounds (\`0 < position < ${t}\`).`, { name: "PositionOutOfBoundsError" });
1908  }
1909}
1910class C0 extends F {
1911  constructor({ count: t, limit: n }) {
1912    super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${t}\`).`, { name: "RecursiveReadLimitExceededError" });
1913  }
1914}
1915const E0 = {
1916  bytes: new Uint8Array(),
1917  dataView: new DataView(new ArrayBuffer(0)),
1918  position: 0,
1919  positionReadCount: /* @__PURE__ */ new Map(),
1920  recursiveReadCount: 0,
1921  recursiveReadLimit: Number.POSITIVE_INFINITY,
1922  assertReadLimit() {
1923    if (this.recursiveReadCount >= this.recursiveReadLimit)
1924      throw new C0({
1925        count: this.recursiveReadCount + 1,
1926        limit: this.recursiveReadLimit
1927      });
1928  },
1929  assertPosition(e) {
1930    if (e < 0 || e > this.bytes.length - 1)
1931      throw new sd({
1932        length: this.bytes.length,
1933        position: e
1934      });
1935  },
1936  decrementPosition(e) {
1937    if (e < 0)
1938      throw new Jc({ offset: e });
1939    const t = this.position - e;
1940    this.assertPosition(t), this.position = t;
1941  },
1942  getReadCount(e) {
1943    return this.positionReadCount.get(e || this.position) || 0;
1944  },
1945  incrementPosition(e) {
1946    if (e < 0)
1947      throw new Jc({ offset: e });
1948    const t = this.position + e;
1949    this.assertPosition(t), this.position = t;
1950  },
1951  inspectByte(e) {
1952    const t = e ?? this.position;
1953    return this.assertPosition(t), this.bytes[t];
1954  },
1955  inspectBytes(e, t) {
1956    const n = t ?? this.position;
1957    return this.assertPosition(n + e - 1), this.bytes.subarray(n, n + e);
1958  },
1959  inspectUint8(e) {
1960    const t = e ?? this.position;
1961    return this.assertPosition(t), this.bytes[t];
1962  },
1963  inspectUint16(e) {
1964    const t = e ?? this.position;
1965    return this.assertPosition(t + 1), this.dataView.getUint16(t);
1966  },
1967  inspectUint24(e) {
1968    const t = e ?? this.position;
1969    return this.assertPosition(t + 2), (this.dataView.getUint16(t) << 8) + this.dataView.getUint8(t + 2);
1970  },
1971  inspectUint32(e) {
1972    const t = e ?? this.position;
1973    return this.assertPosition(t + 3), this.dataView.getUint32(t);
1974  },
1975  pushByte(e) {
1976    this.assertPosition(this.position), this.bytes[this.position] = e, this.position++;
1977  },
1978  pushBytes(e) {
1979    this.assertPosition(this.position + e.length - 1), this.bytes.set(e, this.position), this.position += e.length;
1980  },
1981  pushUint8(e) {
1982    this.assertPosition(this.position), this.bytes[this.position] = e, this.position++;
1983  },
1984  pushUint16(e) {
1985    this.assertPosition(this.position + 1), this.dataView.setUint16(this.position, e), this.position += 2;
1986  },
1987  pushUint24(e) {
1988    this.assertPosition(this.position + 2), this.dataView.setUint16(this.position, e >> 8), this.dataView.setUint8(this.position + 2, e & 255), this.position += 3;
1989  },
1990  pushUint32(e) {
1991    this.assertPosition(this.position + 3), this.dataView.setUint32(this.position, e), this.position += 4;
1992  },
1993  readByte() {
1994    this.assertReadLimit(), this._touch();
1995    const e = this.inspectByte();
1996    return this.position++, e;
1997  },
1998  readBytes(e, t) {
1999    this.assertReadLimit(), this._touch();
2000    const n = this.inspectBytes(e);
2001    return this.position += t ?? e, n;
2002  },
2003  readUint8() {
2004    this.assertReadLimit(), this._touch();
2005    const e = this.inspectUint8();
2006    return this.position += 1, e;
2007  },
2008  readUint16() {
2009    this.assertReadLimit(), this._touch();
2010    const e = this.inspectUint16();
2011    return this.position += 2, e;
2012  },
2013  readUint24() {
2014    this.assertReadLimit(), this._touch();
2015    const e = this.inspectUint24();
2016    return this.position += 3, e;
2017  },
2018  readUint32() {
2019    this.assertReadLimit(), this._touch();
2020    const e = this.inspectUint32();
2021    return this.position += 4, e;
2022  },
2023  get remaining() {
2024    return this.bytes.length - this.position;
2025  },
2026  setPosition(e) {
2027    const t = this.position;
2028    return this.assertPosition(e), this.position = e, () => this.position = t;
2029  },
2030  _touch() {
2031    if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
2032      return;
2033    const e = this.getReadCount();
2034    this.positionReadCount.set(this.position, e + 1), e > 0 && this.recursiveReadCount++;
2035  }
2036};
2037function dc(e, { recursiveReadLimit: t = 8192 } = {}) {
2038  const n = Object.create(E0);
2039  return n.bytes = e, n.dataView = new DataView(e.buffer ?? e, e.byteOffset, e.byteLength), n.positionReadCount = /* @__PURE__ */ new Map(), n.recursiveReadLimit = t, n;
2040}
2041function A0(e, t = {}) {
2042  typeof t.size < "u" && _t(e, { size: t.size });
2043  const n = ft(e, t);
2044  return nr(n, t);
2045}
2046function v0(e, t = {}) {
2047  let n = e;
2048  if (typeof t.size < "u" && (_t(n, { size: t.size }), n = Xn(n)), n.length > 1 || n[0] > 1)
2049    throw new yp(n);
2050  return !!n[0];
2051}
2052function ln(e, t = {}) {
2053  typeof t.size < "u" && _t(e, { size: t.size });
2054  const n = ft(e, t);
2055  return Bn(n, t);
2056}
2057function _0(e, t = {}) {
2058  let n = e;
2059  return typeof t.size < "u" && (_t(n, { size: t.size }), n = Xn(n, { dir: "right" })), new TextDecoder().decode(n);
2060}
2061function fo(e, t) {
2062  const n = typeof t == "string" ? Pt(t) : t, r = dc(n);
2063  if (Ze(n) === 0 && e.length > 0)
2064    throw new Xa();
2065  if (Ze(t) && Ze(t) < 32)
2066    throw new Dl({
2067      data: typeof t == "string" ? t : ft(t),
2068      params: e,
2069      size: Ze(t)
2070    });
2071  let s = 0;
2072  const i = [];
2073  for (let o = 0; o < e.length; ++o) {
2074    const a = e[o];
2075    r.setPosition(s);
2076    const [u, c] = Ir(r, a, {
2077      staticPosition: 0
2078    });
2079    s += c, i.push(u);
2080  }
2081  return i;
2082}
2083function Ir(e, t, { staticPosition: n }) {
2084  const r = ac(t.type);
2085  if (r) {
2086    const [s, i] = r;
2087    return I0(e, { ...t, type: i }, { length: s, staticPosition: n });
2088  }
2089  if (t.type === "tuple")
2090    return x0(e, t, { staticPosition: n });
2091  if (t.type === "address")
2092    return N0(e);
2093  if (t.type === "bool")
2094    return T0(e);
2095  if (t.type.startsWith("bytes"))
2096    return S0(e, t, { staticPosition: n });
2097  if (t.type.startsWith("uint") || t.type.startsWith("int"))
2098    return R0(e, t);
2099  if (t.type === "string")
2100    return O0(e, { staticPosition: n });
2101  throw new hp(t.type, {
2102    docsPath: "/docs/contract/decodeAbiParameters"
2103  });
2104}
2105const Xc = 32, fa = 32;
2106function N0(e) {
2107  const t = e.readBytes(32);
2108  return [Gs(ft(td(t, -20))), 32];
2109}
2110function I0(e, t, { length: n, staticPosition: r }) {
2111  if (!n) {
2112    const o = ln(e.readBytes(fa)), a = r + o, u = a + Xc;
2113    e.setPosition(a);
2114    const c = ln(e.readBytes(Xc)), l = rs(t);
2115    let f = 0;
2116    const p = [];
2117    for (let m = 0; m < c; ++m) {
2118      e.setPosition(u + (l ? m * 32 : f));
2119      const [y, b] = Ir(e, t, {
2120        staticPosition: u
2121      });
2122      f += b, p.push(y);
2123    }
2124    return e.setPosition(r + 32), [p, 32];
2125  }
2126  if (rs(t)) {
2127    const o = ln(e.readBytes(fa)), a = r + o, u = [];
2128    for (let c = 0; c < n; ++c) {
2129      e.setPosition(a + c * 32);
2130      const [l] = Ir(e, t, {
2131        staticPosition: a
2132      });
2133      u.push(l);
2134    }
2135    return e.setPosition(r + 32), [u, 32];
2136  }
2137  let s = 0;
2138  const i = [];
2139  for (let o = 0; o < n; ++o) {
2140    const [a, u] = Ir(e, t, {
2141      staticPosition: r + s
2142    });
2143    s += u, i.push(a);
2144  }
2145  return [i, s];
2146}
2147function T0(e) {
2148  return [v0(e.readBytes(32), { size: 32 }), 32];
2149}
2150function S0(e, t, { staticPosition: n }) {
2151  const [r, s] = t.type.split("bytes");
2152  if (!s) {
2153    const o = ln(e.readBytes(32));
2154    e.setPosition(n + o);
2155    const a = ln(e.readBytes(32));
2156    if (a === 0)
2157      return e.setPosition(n + 32), ["0x", 32];
2158    const u = e.readBytes(a);
2159    return e.setPosition(n + 32), [ft(u), 32];
2160  }
2161  return [ft(e.readBytes(Number.parseInt(s, 10), 32)), 32];
2162}
2163function R0(e, t) {
2164  const n = t.type.startsWith("int"), r = Number.parseInt(t.type.split("int")[1] || "256", 10), s = e.readBytes(32);
2165  return [
2166    r > 48 ? A0(s, { signed: n }) : ln(s, { signed: n }),
2167    32
2168  ];
2169}
2170function x0(e, t, { staticPosition: n }) {
2171  const r = t.components.length === 0 || t.components.some(({ name: o }) => !o), s = r ? [] : {};
2172  let i = 0;
2173  if (rs(t)) {
2174    const o = ln(e.readBytes(fa)), a = n + o;
2175    for (let u = 0; u < t.components.length; ++u) {
2176      const c = t.components[u];
2177      e.setPosition(a + i);
2178      const [l, f] = Ir(e, c, {
2179        staticPosition: a
2180      });
2181      i += f, s[r ? u : c?.name] = l;
2182    }
2183    return e.setPosition(n + 32), [s, 32];
2184  }
2185  for (let o = 0; o < t.components.length; ++o) {
2186    const a = t.components[o], [u, c] = Ir(e, a, {
2187      staticPosition: n
2188    });
2189    s[r ? o : a?.name] = u, i += c;
2190  }
2191  return [s, i];
2192}
2193function O0(e, { staticPosition: t }) {
2194  const n = ln(e.readBytes(32)), r = t + n;
2195  e.setPosition(r);
2196  const s = ln(e.readBytes(32));
2197  if (s === 0)
2198    return e.setPosition(t + 32), ["", 32];
2199  const i = e.readBytes(s, 32), o = _0(Xn(i));
2200  return e.setPosition(t + 32), [o, 32];
2201}
2202function rs(e) {
2203  const { type: t } = e;
2204  if (t === "string" || t === "bytes" || t.endsWith("[]"))
2205    return !0;
2206  if (t === "tuple")
2207    return e.components?.some(rs);
2208  const n = ac(e.type);
2209  return !!(n && rs({ ...e, type: n[1] }));
2210}
2211function P0(e) {
2212  const { abi: t, data: n, cause: r } = e, s = Bi(n, 0, 4);
2213  if (s === "0x")
2214    throw new Xa({ cause: r });
2215  const o = [...t || [], b0, w0].find((a) => a.type === "error" && s === cc(Mn(a)));
2216  if (!o)
2217    throw new Fl(s, {
2218      docsPath: "/docs/contract/decodeErrorResult",
2219      cause: r
2220    });
2221  return {
2222    abiItem: o,
2223    args: "inputs" in o && o.inputs && o.inputs.length > 0 ? fo(o.inputs, Bi(n, 4)) : void 0,
2224    errorName: o.name
2225  };
2226}
2227const At = (e, t, n) => JSON.stringify(e, (r, s) => typeof s == "bigint" ? s.toString() : s, n);
2228function id({ abiItem: e, args: t, includeFunctionName: n = !0, includeName: r = !1 }) {
2229  if ("name" in e && "inputs" in e && e.inputs)
2230    return `${n ? e.name : ""}(${e.inputs.map((s, i) => `${r && s.name ? `${s.name}: ` : ""}${typeof t[i] == "object" ? At(t[i]) : t[i]}`).join(", ")})`;
2231}
2232const k0 = {
2233  gwei: 9,
2234  wei: 18
2235}, U0 = {
2236  ether: -9,
2237  wei: 9
2238};
2239function zs(e, t) {
2240  let n = e.toString();
2241  const r = n.startsWith("-");
2242  r && (n = n.slice(1)), n = n.padStart(t, "0");
2243  let [s, i] = [
2244    n.slice(0, n.length - t),
2245    n.slice(n.length - t)
2246  ];
2247  return i = i.replace(/(0+)$/, ""), `${r ? "-" : ""}${s || "0"}${i ? `.${i}` : ""}`;
2248}
2249function fc(e, t = "wei") {
2250  return zs(e, k0[t]);
2251}
2252function dt(e, t = "wei") {
2253  return zs(e, U0[t]);
2254}
2255class M0 extends F {
2256  constructor({ address: t }) {
2257    super(`State for account "${t}" is set multiple times.`, {
2258      name: "AccountStateConflictError"
2259    });
2260  }
2261}
2262class L0 extends F {
2263  constructor() {
2264    super("state and stateDiff are set on the same account.", {
2265      name: "StateAssignmentConflictError"
2266    });
2267  }
2268}
2269function eu(e) {
2270  return e.reduce((t, { slot: n, value: r }) => `${t}        ${n}: ${r}
2271`, "");
2272}
2273function B0(e) {
2274  return e.reduce((t, { address: n, ...r }) => {
2275    let s = `${t}    ${n}:
2276`;
2277    return r.nonce && (s += `      nonce: ${r.nonce}
2278`), r.balance && (s += `      balance: ${r.balance}
2279`), r.code && (s += `      code: ${r.code}
2280`), r.state && (s += `      state:
2281`, s += eu(r.state)), r.stateDiff && (s += `      stateDiff:
2282`, s += eu(r.stateDiff)), s;
2283  }, `  State Override:
2284`).slice(0, -1);
2285}
2286function Vs(e) {
2287  const t = Object.entries(e).map(([r, s]) => s === void 0 || s === !1 ? null : [r, s]).filter(Boolean), n = t.reduce((r, [s]) => Math.max(r, s.length), 0);
2288  return t.map(([r, s]) => `  ${`${r}:`.padEnd(n + 1)}  ${s}`).join(`
2289`);
2290}
2291class Dv extends F {
2292  constructor({ v: t }) {
2293    super(`Invalid \`v\` value "${t}". Expected 27 or 28.`, {
2294      name: "InvalidLegacyVError"
2295    });
2296  }
2297}
2298class D0 extends F {
2299  constructor({ transaction: t }) {
2300    super("Cannot infer a transaction type from provided transaction.", {
2301      metaMessages: [
2302        "Provided Transaction:",
2303        "{",
2304        Vs(t),
2305        "}",
2306        "",
2307        "To infer the type, either provide:",
2308        "- a `type` to the Transaction, or",
2309        "- an EIP-1559 Transaction with `maxFeePerGas`, or",
2310        "- an EIP-2930 Transaction with `gasPrice` & `accessList`, or",
2311        "- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or",
2312        "- an EIP-7702 Transaction with `authorizationList`, or",
2313        "- a Legacy Transaction with `gasPrice`"
2314      ],
2315      name: "InvalidSerializableTransactionError"
2316    });
2317  }
2318}
2319class Fv extends F {
2320  constructor({ storageKey: t }) {
2321    super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length - 2) / 2)} bytes.`, { name: "InvalidStorageKeySizeError" });
2322  }
2323}
2324class F0 extends F {
2325  constructor(t, { account: n, docsPath: r, chain: s, data: i, gas: o, gasPrice: a, maxFeePerGas: u, maxPriorityFeePerGas: c, nonce: l, to: f, value: p }) {
2326    const m = Vs({
2327      chain: s && `${s?.name} (id: ${s?.id})`,
2328      from: n?.address,
2329      to: f,
2330      value: typeof p < "u" && `${fc(p)} ${s?.nativeCurrency?.symbol || "ETH"}`,
2331      data: i,
2332      gas: o,
2333      gasPrice: typeof a < "u" && `${dt(a)} gwei`,
2334      maxFeePerGas: typeof u < "u" && `${dt(u)} gwei`,
2335      maxPriorityFeePerGas: typeof c < "u" && `${dt(c)} gwei`,
2336      nonce: l
2337    });
2338    super(t.shortMessage, {
2339      cause: t,
2340      docsPath: r,
2341      metaMessages: [
2342        ...t.metaMessages ? [...t.metaMessages, " "] : [],
2343        "Request Arguments:",
2344        m
2345      ].filter(Boolean),
2346      name: "TransactionExecutionError"
2347    }), Object.defineProperty(this, "cause", {
2348      enumerable: !0,
2349      configurable: !0,
2350      writable: !0,
2351      value: void 0
2352    }), this.cause = t;
2353  }
2354}
2355class od extends F {
2356  constructor({ blockHash: t, blockNumber: n, blockTag: r, hash: s, index: i }) {
2357    let o = "Transaction";
2358    r && i !== void 0 && (o = `Transaction at block time "${r}" at index "${i}"`), t && i !== void 0 && (o = `Transaction at block hash "${t}" at index "${i}"`), n && i !== void 0 && (o = `Transaction at block number "${n}" at index "${i}"`), s && (o = `Transaction with hash "${s}"`), super(`${o} could not be found.`, {
2359      name: "TransactionNotFoundError"
2360    });
2361  }
2362}
2363class ad extends F {
2364  constructor({ hash: t }) {
2365    super(`Transaction receipt with hash "${t}" could not be found. The Transaction may not be processed on a block yet.`, {
2366      name: "TransactionReceiptNotFoundError"
2367    });
2368  }
2369}
2370class jv extends F {
2371  constructor({ receipt: t }) {
2372    super(`Transaction with hash "${t.transactionHash}" reverted.`, {
2373      metaMessages: [
2374        'The receipt marked the transaction as "reverted". This could mean that the function on the contract you are trying to call threw an error.',
2375        " ",
2376        "You can attempt to extract the revert reason by:",
2377        "- calling the `simulateContract` or `simulateCalls` Action with the `abi` and `functionName` of the contract",
2378        "- using the `call` Action with raw `data`"
2379      ],
2380      name: "TransactionReceiptRevertedError"
2381    }), Object.defineProperty(this, "receipt", {
2382      enumerable: !0,
2383      configurable: !0,
2384      writable: !0,
2385      value: void 0
2386    }), this.receipt = t;
2387  }
2388}
2389class j0 extends F {
2390  constructor({ hash: t }) {
2391    super(`Timed out while waiting for transaction with hash "${t}" to be confirmed.`, { name: "WaitForTransactionReceiptTimeoutError" });
2392  }
2393}
2394const W0 = (e) => e, hc = (e) => e;
2395class $0 extends F {
2396  constructor(t, { account: n, docsPath: r, chain: s, data: i, gas: o, gasPrice: a, maxFeePerGas: u, maxPriorityFeePerGas: c, nonce: l, to: f, value: p, stateOverride: m }) {
2397    const y = n ? vt(n) : void 0;
2398    let b = Vs({
2399      from: y?.address,
2400      to: f,
2401      value: typeof p < "u" && `${fc(p)} ${s?.nativeCurrency?.symbol || "ETH"}`,
2402      data: i,
2403      gas: o,
2404      gasPrice: typeof a < "u" && `${dt(a)} gwei`,
2405      maxFeePerGas: typeof u < "u" && `${dt(u)} gwei`,
2406      maxPriorityFeePerGas: typeof c < "u" && `${dt(c)} gwei`,
2407      nonce: l
2408    });
2409    m && (b += `
2410${B0(m)}`), super(t.shortMessage, {
2411      cause: t,
2412      docsPath: r,
2413      metaMessages: [
2414        ...t.metaMessages ? [...t.metaMessages, " "] : [],
2415        "Raw Call Arguments:",
2416        b
2417      ].filter(Boolean),
2418      name: "CallExecutionError"
2419    }), Object.defineProperty(this, "cause", {
2420      enumerable: !0,
2421      configurable: !0,
2422      writable: !0,
2423      value: void 0
2424    }), this.cause = t;
2425  }
2426}
2427class H0 extends F {
2428  constructor(t, { abi: n, args: r, contractAddress: s, docsPath: i, functionName: o, sender: a }) {
2429    const u = uc({ abi: n, args: r, name: o }), c = u ? id({
2430      abiItem: u,
2431      args: r,
2432      includeFunctionName: !1,
2433      includeName: !1
2434    }) : void 0, l = u ? Mn(u, { includeName: !0 }) : void 0, f = Vs({
2435      address: s && W0(s),
2436      function: l,
2437      args: c && c !== "()" && `${[...Array(o?.length ?? 0).keys()].map(() => " ").join("")}${c}`,
2438      sender: a
2439    });
2440    super(t.shortMessage || `An unknown error occurred while executing the contract function "${o}".`, {
2441      cause: t,
2442      docsPath: i,
2443      metaMessages: [
2444        ...t.metaMessages ? [...t.metaMessages, " "] : [],
2445        f && "Contract Call:",
2446        f
2447      ].filter(Boolean),
2448      name: "ContractFunctionExecutionError"
2449    }), Object.defineProperty(this, "abi", {
2450      enumerable: !0,
2451      configurable: !0,
2452      writable: !0,
2453      value: void 0
2454    }), Object.defineProperty(this, "args", {
2455      enumerable: !0,
2456      configurable: !0,
2457      writable: !0,
2458      value: void 0
2459    }), Object.defineProperty(this, "cause", {
2460      enumerable: !0,
2461      configurable: !0,
2462      writable: !0,
2463      value: void 0
2464    }), Object.defineProperty(this, "contractAddress", {
2465      enumerable: !0,
2466      configurable: !0,
2467      writable: !0,
2468      value: void 0
2469    }), Object.defineProperty(this, "formattedArgs", {
2470      enumerable: !0,
2471      configurable: !0,
2472      writable: !0,
2473      value: void 0
2474    }), Object.defineProperty(this, "functionName", {
2475      enumerable: !0,
2476      configurable: !0,
2477      writable: !0,
2478      value: void 0
2479    }), Object.defineProperty(this, "sender", {
2480      enumerable: !0,
2481      configurable: !0,
2482      writable: !0,
2483      value: void 0
2484    }), this.abi = n, this.args = r, this.cause = t, this.contractAddress = s, this.functionName = o, this.sender = a;
2485  }
2486}
2487class q0 extends F {
2488  constructor({ abi: t, data: n, functionName: r, message: s, cause: i }) {
2489    let o, a, u, c;
2490    if (n && n !== "0x")
2491      try {
2492        a = P0({ abi: t, data: n, cause: i });
2493        const { abiItem: f, errorName: p, args: m } = a;
2494        if (p === "Error")
2495          c = m[0];
2496        else if (p === "Panic") {
2497          const [y] = m;
2498          c = y0[y];
2499        } else {
2500          const y = f ? Mn(f, { includeName: !0 }) : void 0, b = f && m ? id({
2501            abiItem: f,
2502            args: m,
2503            includeFunctionName: !1,
2504            includeName: !1
2505          }) : void 0;
2506          u = [
2507            y ? `Error: ${y}` : "",
2508            b && b !== "()" ? `       ${[...Array(p?.length ?? 0).keys()].map(() => " ").join("")}${b}` : ""
2509          ];
2510        }
2511      } catch (f) {
2512        o = f;
2513      }
2514    else s && (c = s);
2515    let l;
2516    o instanceof Fl && (l = o.signature, u = [
2517      `Unable to decode signature "${l}" as it was not found on the provided ABI.`,
2518      "Make sure you are using the correct ABI and that the error exists on it.",
2519      `You can look up the decoded signature here: https://4byte.sourcify.dev/?q=${l}.`
2520    ]), super(c && c !== "execution reverted" || l ? [
2521      `The contract function "${r}" reverted with the following ${l ? "signature" : "reason"}:`,
2522      c || l
2523    ].join(`
2524`) : `The contract function "${r}" reverted.`, {
2525      cause: o ?? i,
2526      metaMessages: u,
2527      name: "ContractFunctionRevertedError"
2528    }), Object.defineProperty(this, "data", {
2529      enumerable: !0,
2530      configurable: !0,
2531      writable: !0,
2532      value: void 0
2533    }), Object.defineProperty(this, "raw", {
2534      enumerable: !0,
2535      configurable: !0,
2536      writable: !0,
2537      value: void 0
2538    }), Object.defineProperty(this, "reason", {
2539      enumerable: !0,
2540      configurable: !0,
2541      writable: !0,
2542      value: void 0
2543    }), Object.defineProperty(this, "signature", {
2544      enumerable: !0,
2545      configurable: !0,
2546      writable: !0,
2547      value: void 0
2548    }), this.data = a, this.raw = n, this.reason = c, this.signature = l;
2549  }
2550}
2551class G0 extends F {
2552  constructor({ functionName: t, cause: n }) {
2553    super(`The contract function "${t}" returned no data ("0x").`, {
2554      metaMessages: [
2555        "This could be due to any of the following:",
2556        `  - The contract does not have the function "${t}",`,
2557        "  - The parameters passed to the contract function may be invalid, or",
2558        "  - The address is not a contract."
2559      ],
2560      name: "ContractFunctionZeroDataError",
2561      cause: n
2562    });
2563  }
2564}
2565class z0 extends F {
2566  constructor({ factory: t }) {
2567    super(`Deployment for counterfactual contract call failed${t ? ` for factory "${t}".` : ""}`, {
2568      metaMessages: [
2569        "Please ensure:",
2570        "- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).",
2571        "- The `factoryData` is a valid encoded function call for contract deployment function on the factory."
2572      ],
2573      name: "CounterfactualDeploymentFailedError"
2574    });
2575  }
2576}
2577class cd extends F {
2578  constructor({ data: t, message: n }) {
2579    super(n || "", { name: "RawContractError" }), Object.defineProperty(this, "code", {
2580      enumerable: !0,
2581      configurable: !0,
2582      writable: !0,
2583      value: 3
2584    }), Object.defineProperty(this, "data", {
2585      enumerable: !0,
2586      configurable: !0,
2587      writable: !0,
2588      value: void 0
2589    }), this.data = t;
2590  }
2591}
2592class ts extends F {
2593  constructor({ body: t, cause: n, details: r, headers: s, status: i, url: o }) {
2594    super("HTTP request failed.", {
2595      cause: n,
2596      details: r,
2597      metaMessages: [
2598        i && `Status: ${i}`,
2599        `URL: ${hc(o)}`,
2600        t && `Request body: ${At(t)}`
2601      ].filter(Boolean),
2602      name: "HttpRequestError"
2603    }), Object.defineProperty(this, "body", {
2604      enumerable: !0,
2605      configurable: !0,
2606      writable: !0,
2607      value: void 0
2608    }), Object.defineProperty(this, "headers", {
2609      enumerable: !0,
2610      configurable: !0,
2611      writable: !0,
2612      value: void 0
2613    }), Object.defineProperty(this, "status", {
2614      enumerable: !0,
2615      configurable: !0,
2616      writable: !0,
2617      value: void 0
2618    }), Object.defineProperty(this, "url", {
2619      enumerable: !0,
2620      configurable: !0,
2621      writable: !0,
2622      value: void 0
2623    }), this.body = t, this.headers = s, this.status = i, this.url = o;
2624  }
2625}
2626class pc extends F {
2627  constructor({ body: t, error: n, url: r }) {
2628    super("RPC Request failed.", {
2629      cause: n,
2630      details: n.message,
2631      metaMessages: [`URL: ${hc(r)}`, `Request body: ${At(t)}`],
2632      name: "RpcRequestError"
2633    }), Object.defineProperty(this, "code", {
2634      enumerable: !0,
2635      configurable: !0,
2636      writable: !0,
2637      value: void 0
2638    }), Object.defineProperty(this, "data", {
2639      enumerable: !0,
2640      configurable: !0,
2641      writable: !0,
2642      value: void 0
2643    }), Object.defineProperty(this, "url", {
2644      enumerable: !0,
2645      configurable: !0,
2646      writable: !0,
2647      value: void 0
2648    }), this.code = n.code, this.data = n.data, this.url = r;
2649  }
2650}
2651class tu extends F {
2652  constructor({ body: t, url: n }) {
2653    super("The request took too long to respond.", {
2654      details: "The request timed out.",
2655      metaMessages: [`URL: ${hc(n)}`, `Request body: ${At(t)}`],
2656      name: "TimeoutError"
2657    }), Object.defineProperty(this, "url", {
2658      enumerable: !0,
2659      configurable: !0,
2660      writable: !0,
2661      value: void 0
2662    }), this.url = n;
2663  }
2664}
2665const V0 = -1;
2666class pt extends F {
2667  constructor(t, { code: n, docsPath: r, metaMessages: s, name: i, shortMessage: o }) {
2668    super(o, {
2669      cause: t,
2670      docsPath: r,
2671      metaMessages: s || t?.metaMessages,
2672      name: i || "RpcError"
2673    }), Object.defineProperty(this, "code", {
2674      enumerable: !0,
2675      configurable: !0,
2676      writable: !0,
2677      value: void 0
2678    }), this.name = i || t.name, this.code = t instanceof pc ? t.code : n ?? V0;
2679  }
2680}
2681let mt = class extends pt {
2682  constructor(t, n) {
2683    super(t, n), Object.defineProperty(this, "data", {
2684      enumerable: !0,
2685      configurable: !0,
2686      writable: !0,
2687      value: void 0
2688    }), this.data = n.data;
2689  }
2690};
2691class ss extends pt {
2692  constructor(t) {
2693    super(t, {
2694      code: ss.code,
2695      name: "ParseRpcError",
2696      shortMessage: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
2697    });
2698  }
2699}
2700Object.defineProperty(ss, "code", {
2701  enumerable: !0,
2702  configurable: !0,
2703  writable: !0,
2704  value: -32700
2705});
2706class is extends pt {
2707  constructor(t) {
2708    super(t, {
2709      code: is.code,
2710      name: "InvalidRequestRpcError",
2711      shortMessage: "JSON is not a valid request object."
2712    });
2713  }
2714}
2715Object.defineProperty(is, "code", {
2716  enumerable: !0,
2717  configurable: !0,
2718  writable: !0,
2719  value: -32600
2720});
2721class os extends pt {
2722  constructor(t, { method: n } = {}) {
2723    super(t, {
2724      code: os.code,
2725      name: "MethodNotFoundRpcError",
2726      shortMessage: `The method${n ? ` "${n}"` : ""} does not exist / is not available.`
2727    });
2728  }
2729}
2730Object.defineProperty(os, "code", {
2731  enumerable: !0,
2732  configurable: !0,
2733  writable: !0,
2734  value: -32601
2735});
2736class as extends pt {
2737  constructor(t) {
2738    super(t, {
2739      code: as.code,
2740      name: "InvalidParamsRpcError",
2741      shortMessage: [
2742        "Invalid parameters were provided to the RPC method.",
2743        "Double check you have provided the correct parameters."
2744      ].join(`
2745`)
2746    });
2747  }
2748}
2749Object.defineProperty(as, "code", {
2750  enumerable: !0,
2751  configurable: !0,
2752  writable: !0,
2753  value: -32602
2754});
2755class ir extends pt {
2756  constructor(t) {
2757    super(t, {
2758      code: ir.code,
2759      name: "InternalRpcError",
2760      shortMessage: "An internal error was received."
2761    });
2762  }
2763}
2764Object.defineProperty(ir, "code", {
2765  enumerable: !0,
2766  configurable: !0,
2767  writable: !0,
2768  value: -32603
2769});
2770class Pr extends pt {
2771  constructor(t) {
2772    super(t, {
2773      code: Pr.code,
2774      name: "InvalidInputRpcError",
2775      shortMessage: [
2776        "Missing or invalid parameters.",
2777        "Double check you have provided the correct parameters."
2778      ].join(`
2779`)
2780    });
2781  }
2782}
2783Object.defineProperty(Pr, "code", {
2784  enumerable: !0,
2785  configurable: !0,
2786  writable: !0,
2787  value: -32e3
2788});
2789class cs extends pt {
2790  constructor(t) {
2791    super(t, {
2792      code: cs.code,
2793      name: "ResourceNotFoundRpcError",
2794      shortMessage: "Requested resource not found."
2795    }), Object.defineProperty(this, "name", {
2796      enumerable: !0,
2797      configurable: !0,
2798      writable: !0,
2799      value: "ResourceNotFoundRpcError"
2800    });
2801  }
2802}
2803Object.defineProperty(cs, "code", {
2804  enumerable: !0,
2805  configurable: !0,
2806  writable: !0,
2807  value: -32001
2808});
2809class Pn extends pt {
2810  constructor(t) {
2811    super(t, {
2812      code: Pn.code,
2813      name: "ResourceUnavailableRpcError",
2814      shortMessage: "Requested resource not available."
2815    });
2816  }
2817}
2818Object.defineProperty(Pn, "code", {
2819  enumerable: !0,
2820  configurable: !0,
2821  writable: !0,
2822  value: -32002
2823});
2824class kr extends pt {
2825  constructor(t) {
2826    super(t, {
2827      code: kr.code,
2828      name: "TransactionRejectedRpcError",
2829      shortMessage: "Transaction creation failed."
2830    });
2831  }
2832}
2833Object.defineProperty(kr, "code", {
2834  enumerable: !0,
2835  configurable: !0,
2836  writable: !0,
2837  value: -32003
2838});
2839class Kn extends pt {
2840  constructor(t, { method: n } = {}) {
2841    super(t, {
2842      code: Kn.code,
2843      name: "MethodNotSupportedRpcError",
2844      shortMessage: `Method${n ? ` "${n}"` : ""} is not supported.`
2845    });
2846  }
2847}
2848Object.defineProperty(Kn, "code", {
2849  enumerable: !0,
2850  configurable: !0,
2851  writable: !0,
2852  value: -32004
2853});
2854class Ur extends pt {
2855  constructor(t) {
2856    super(t, {
2857      code: Ur.code,
2858      name: "LimitExceededRpcError",
2859      shortMessage: "Request exceeds defined limit."
2860    });
2861  }
2862}
2863Object.defineProperty(Ur, "code", {
2864  enumerable: !0,
2865  configurable: !0,
2866  writable: !0,
2867  value: -32005
2868});
2869class us extends pt {
2870  constructor(t) {
2871    super(t, {
2872      code: us.code,
2873      name: "JsonRpcVersionUnsupportedError",
2874      shortMessage: "Version of JSON-RPC protocol is not supported."
2875    });
2876  }
2877}
2878Object.defineProperty(us, "code", {
2879  enumerable: !0,
2880  configurable: !0,
2881  writable: !0,
2882  value: -32006
2883});
2884let Ke = class ud extends mt {
2885  constructor(t) {
2886    super(t, {
2887      code: ud.code,
2888      name: "UserRejectedRequestError",
2889      shortMessage: "User rejected the request."
2890    });
2891  }
2892};
2893Object.defineProperty(Ke, "code", {
2894  enumerable: !0,
2895  configurable: !0,
2896  writable: !0,
2897  value: 4001
2898});
2899class ls extends mt {
2900  constructor(t) {
2901    super(t, {
2902      code: ls.code,
2903      name: "UnauthorizedProviderError",
2904      shortMessage: "The requested method and/or account has not been authorized by the user."
2905    });
2906  }
2907}
2908Object.defineProperty(ls, "code", {
2909  enumerable: !0,
2910  configurable: !0,
2911  writable: !0,
2912  value: 4100
2913});
2914class ds extends mt {
2915  constructor(t, { method: n } = {}) {
2916    super(t, {
2917      code: ds.code,
2918      name: "UnsupportedProviderMethodError",
2919      shortMessage: `The Provider does not support the requested method${n ? ` " ${n}"` : ""}.`
2920    });
2921  }
2922}
2923Object.defineProperty(ds, "code", {
2924  enumerable: !0,
2925  configurable: !0,
2926  writable: !0,
2927  value: 4200
2928});
2929class fs extends mt {
2930  constructor(t) {
2931    super(t, {
2932      code: fs.code,
2933      name: "ProviderDisconnectedError",
2934      shortMessage: "The Provider is disconnected from all chains."
2935    });
2936  }
2937}
2938Object.defineProperty(fs, "code", {
2939  enumerable: !0,
2940  configurable: !0,
2941  writable: !0,
2942  value: 4900
2943});
2944class hs extends mt {
2945  constructor(t) {
2946    super(t, {
2947      code: hs.code,
2948      name: "ChainDisconnectedError",
2949      shortMessage: "The Provider is not connected to the requested chain."
2950    });
2951  }
2952}
2953Object.defineProperty(hs, "code", {
2954  enumerable: !0,
2955  configurable: !0,
2956  writable: !0,
2957  value: 4901
2958});
2959class zt extends mt {
2960  constructor(t) {
2961    super(t, {
2962      code: zt.code,
2963      name: "SwitchChainError",
2964      shortMessage: "An error occurred when attempting to switch chain."
2965    });
2966  }
2967}
2968Object.defineProperty(zt, "code", {
2969  enumerable: !0,
2970  configurable: !0,
2971  writable: !0,
2972  value: 4902
2973});
2974class ps extends mt {
2975  constructor(t) {
2976    super(t, {
2977      code: ps.code,
2978      name: "UnsupportedNonOptionalCapabilityError",
2979      shortMessage: "This Wallet does not support a capability that was not marked as optional."
2980    });
2981  }
2982}
2983Object.defineProperty(ps, "code", {
2984  enumerable: !0,
2985  configurable: !0,
2986  writable: !0,
2987  value: 5700
2988});
2989class ms extends mt {
2990  constructor(t) {
2991    super(t, {
2992      code: ms.code,
2993      name: "UnsupportedChainIdError",
2994      shortMessage: "This Wallet does not support the requested chain ID."
2995    });
2996  }
2997}
2998Object.defineProperty(ms, "code", {
2999  enumerable: !0,
3000  configurable: !0,
3001  writable: !0,
3002  value: 5710
3003});
3004class gs extends mt {
3005  constructor(t) {
3006    super(t, {
3007      code: gs.code,
3008      name: "DuplicateIdError",
3009      shortMessage: "There is already a bundle submitted with this ID."
3010    });
3011  }
3012}
3013Object.defineProperty(gs, "code", {
3014  enumerable: !0,
3015  configurable: !0,
3016  writable: !0,
3017  value: 5720
3018});
3019class ys extends mt {
3020  constructor(t) {
3021    super(t, {
3022      code: ys.code,
3023      name: "UnknownBundleIdError",
3024      shortMessage: "This bundle id is unknown / has not been submitted"
3025    });
3026  }
3027}
3028Object.defineProperty(ys, "code", {
3029  enumerable: !0,
3030  configurable: !0,
3031  writable: !0,
3032  value: 5730
3033}
3033);
3034class bs extends mt {
3035  constructor(t) {
3036    super(t, {
3037      code: bs.code,
3038      name: "BundleTooLargeError",
3039      shortMessage: "The call bundle is too large for the Wallet to process."
3040    });
3041  }
3042}
3043Object.defineProperty(bs, "code", {
3044  enumerable: !0,
3045  configurable: !0,
3046  writable: !0,
3047  value: 5740
3048});
3049class ws extends mt {
3050  constructor(t) {
3051    super(t, {
3052      code: ws.code,
3053      name: "AtomicReadyWalletRejectedUpgradeError",
3054      shortMessage: "The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."
3055    });
3056  }
3057}
3058Object.defineProperty(ws, "code", {
3059  enumerable: !0,
3060  configurable: !0,
3061  writable: !0,
3062  value: 5750
3063});
3064class Cs extends mt {
3065  constructor(t) {
3066    super(t, {
3067      code: Cs.code,
3068      name: "AtomicityNotSupportedError",
3069      shortMessage: "The wallet does not support atomic execution but the request requires it."
3070    });
3071  }
3072}
3073Object.defineProperty(Cs, "code", {
3074  enumerable: !0,
3075  configurable: !0,
3076  writable: !0,
3077  value: 5760
3078});
3079class Mr extends mt {
3080  constructor(t) {
3081    super(t, {
3082      code: Mr.code,
3083      name: "WalletConnectSessionSettlementError",
3084      shortMessage: "WalletConnect session settlement failed."
3085    });
3086  }
3087}
3088Object.defineProperty(Mr, "code", {
3089  enumerable: !0,
3090  configurable: !0,
3091  writable: !0,
3092  value: 7e3
3093});
3094class K0 extends pt {
3095  constructor(t) {
3096    super(t, {
3097      name: "UnknownRpcError",
3098      shortMessage: "An unknown RPC error occurred."
3099    });
3100  }
3101}
3102const Y0 = 3;
3103function Z0(e, { abi: t, address: n, args: r, docsPath: s, functionName: i, sender: o }) {
3104  const a = e instanceof cd ? e : e instanceof F ? e.walk((y) => "data" in y) || e.walk() : {}, { code: u, data: c, details: l, message: f, shortMessage: p } = a, m = e instanceof Xa ? new G0({ functionName: i, cause: e }) : [Y0, ir.code].includes(u) && (c || l || f || p) || u === Pr.code && l === "execution reverted" && c ? new q0({
3105    abi: t,
3106    data: typeof c == "object" ? c.data : c,
3107    functionName: i,
3108    message: a instanceof pc ? l : p ?? f,
3109    cause: e
3110  }) : e;
3111  return new H0(m, {
3112    abi: t,
3113    args: r,
3114    contractAddress: n,
3115    docsPath: s,
3116    functionName: i,
3117    sender: o
3118  });
3119}
3120function Q0(e) {
3121  const t = Hs(`0x${e.substring(4)}`).substring(26);
3122  return Gs(`0x${t}`);
3123}
3124async function J0({ hash: e, signature: t }) {
3125  const n = Ln(e) ? e : ns(e), { secp256k1: r } = await import("./secp256k1-o98lgjK_.js").then((o) => o.a);
3126  return `0x${(() => {
3127    if (typeof t == "object" && "r" in t && "s" in t) {
3128      const { r: c, s: l, v: f, yParity: p } = t, m = Number(p ?? f), y = nu(m);
3129      return new r.Signature(nr(c), nr(l)).addRecoveryBit(y);
3130    }
3131    const o = Ln(t) ? t : ns(t);
3132    if (Ze(o) !== 65)
3133      throw new Error("invalid signature length");
3134    const a = Bn(`0x${o.slice(130)}`), u = nu(a);
3135    return r.Signature.fromCompact(o.substring(2, 130)).addRecoveryBit(u);
3136  })().recoverPublicKey(n.substring(2)).toHex(!1)}`;
3137}
3138function nu(e) {
3139  if (e === 0 || e === 1)
3140    return e;
3141  if (e === 27)
3142    return 0;
3143  if (e === 28)
3144    return 1;
3145  throw new Error("Invalid yParityOrV value");
3146}
3147async function X0({ hash: e, signature: t }) {
3148  return Q0(await J0({ hash: e, signature: t }));
3149}
3150function em(e, t = "hex") {
3151  const n = ld(e), r = dc(new Uint8Array(n.length));
3152  return n.encode(r), t === "hex" ? ft(r.bytes) : r.bytes;
3153}
3154function ld(e) {
3155  return Array.isArray(e) ? tm(e.map((t) => ld(t))) : nm(e);
3156}
3157function tm(e) {
3158  const t = e.reduce((s, i) => s + i.length, 0), n = dd(t);
3159  return {
3160    length: t <= 55 ? 1 + t : 1 + n + t,
3161    encode(s) {
3162      t <= 55 ? s.pushByte(192 + t) : (s.pushByte(247 + n), n === 1 ? s.pushUint8(t) : n === 2 ? s.pushUint16(t) : n === 3 ? s.pushUint24(t) : s.pushUint32(t));
3163      for (const { encode: i } of e)
3164        i(s);
3165    }
3166  };
3167}
3168function nm(e) {
3169  const t = typeof e == "string" ? Pt(e) : e, n = dd(t.length);
3170  return {
3171    length: t.length === 1 && t[0] < 128 ? 1 : t.length <= 55 ? 1 + t.length : 1 + n + t.length,
3172    encode(s) {
3173      t.length === 1 && t[0] < 128 ? s.pushBytes(t) : t.length <= 55 ? (s.pushByte(128 + t.length), s.pushBytes(t)) : (s.pushByte(183 + n), n === 1 ? s.pushUint8(t.length) : n === 2 ? s.pushUint16(t.length) : n === 3 ? s.pushUint24(t.length) : s.pushUint32(t.length), s.pushBytes(t));
3174    }
3175  };
3176}
3177function dd(e) {
3178  if (e < 2 ** 8)
3179    return 1;
3180  if (e < 2 ** 16)
3181    return 2;
3182  if (e < 2 ** 24)
3183    return 3;
3184  if (e < 2 ** 32)
3185    return 4;
3186  throw new F("Length is too large.");
3187}
3188function rm(e) {
3189  const { chainId: t, nonce: n, to: r } = e, s = e.contractAddress ?? e.address, i = Hs(lo([
3190    "0x05",
3191    em([
3192      t ? be(t) : "0x",
3193      s,
3194      n ? be(n) : "0x"
3195    ])
3196  ]));
3197  return r === "bytes" ? Pt(i) : i;
3198}
3199async function fd(e) {
3200  const { authorization: t, signature: n } = e;
3201  return X0({
3202    hash: rm(t),
3203    signature: n ?? t
3204  });
3205}
3206class sm extends F {
3207  constructor(t, { account: n, docsPath: r, chain: s, data: i, gas: o, gasPrice: a, maxFeePerGas: u, maxPriorityFeePerGas: c, nonce: l, to: f, value: p }) {
3208    const m = Vs({
3209      from: n?.address,
3210      to: f,
3211      value: typeof p < "u" && `${fc(p)} ${s?.nativeCurrency?.symbol || "ETH"}`,
3212      data: i,
3213      gas: o,
3214      gasPrice: typeof a < "u" && `${dt(a)} gwei`,
3215      maxFeePerGas: typeof u < "u" && `${dt(u)} gwei`,
3216      maxPriorityFeePerGas: typeof c < "u" && `${dt(c)} gwei`,
3217      nonce: l
3218    });
3219    super(t.shortMessage, {
3220      cause: t,
3221      docsPath: r,
3222      metaMessages: [
3223        ...t.metaMessages ? [...t.metaMessages, " "] : [],
3224        "Estimate Gas Arguments:",
3225        m
3226      ].filter(Boolean),
3227      name: "EstimateGasExecutionError"
3228    }), Object.defineProperty(this, "cause", {
3229      enumerable: !0,
3230      configurable: !0,
3231      writable: !0,
3232      value: void 0
3233    }), this.cause = t;
3234  }
3235}
3236class Yn extends F {
3237  constructor({ cause: t, message: n } = {}) {
3238    const r = n?.replace("execution reverted: ", "")?.replace("execution reverted", "");
3239    super(`Execution reverted ${r ? `with reason: ${r}` : "for an unknown reason"}.`, {
3240      cause: t,
3241      name: "ExecutionRevertedError"
3242    });
3243  }
3244}
3245Object.defineProperty(Yn, "code", {
3246  enumerable: !0,
3247  configurable: !0,
3248  writable: !0,
3249  value: 3
3250});
3251Object.defineProperty(Yn, "nodeMessage", {
3252  enumerable: !0,
3253  configurable: !0,
3254  writable: !0,
3255  value: /execution reverted|gas required exceeds allowance/
3256});
3257class Di extends F {
3258  constructor({ cause: t, maxFeePerGas: n } = {}) {
3259    super(`The fee cap (\`maxFeePerGas\`${n ? ` = ${dt(n)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, {
3260      cause: t,
3261      name: "FeeCapTooHighError"
3262    });
3263  }
3264}
3265Object.defineProperty(Di, "nodeMessage", {
3266  enumerable: !0,
3267  configurable: !0,
3268  writable: !0,
3269  value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/
3270});
3271class ha extends F {
3272  constructor({ cause: t, maxFeePerGas: n } = {}) {
3273    super(`The fee cap (\`maxFeePerGas\`${n ? ` = ${dt(n)}` : ""} gwei) cannot be lower than the block base fee.`, {
3274      cause: t,
3275      name: "FeeCapTooLowError"
3276    });
3277  }
3278}
3279Object.defineProperty(ha, "nodeMessage", {
3280  enumerable: !0,
3281  configurable: !0,
3282  writable: !0,
3283  value: /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/
3284});
3285class pa extends F {
3286  constructor({ cause: t, nonce: n } = {}) {
3287    super(`Nonce provided for the transaction ${n ? `(${n}) ` : ""}is higher than the next one expected.`, { cause: t, name: "NonceTooHighError" });
3288  }
3289}
3290Object.defineProperty(pa, "nodeMessage", {
3291  enumerable: !0,
3292  configurable: !0,
3293  writable: !0,
3294  value: /nonce too high/
3295});
3296class ma extends F {
3297  constructor({ cause: t, nonce: n } = {}) {
3298    super([
3299      `Nonce provided for the transaction ${n ? `(${n}) ` : ""}is lower than the current nonce of the account.`,
3300      "Try increasing the nonce or find the latest nonce with `getTransactionCount`."
3301    ].join(`
3302`), { cause: t, name: "NonceTooLowError" });
3303  }
3304}
3305Object.defineProperty(ma, "nodeMessage", {
3306  enumerable: !0,
3307  configurable: !0,
3308  writable: !0,
3309  value: /nonce too low|transaction already imported|already known/
3310});
3311class ga extends F {
3312  constructor({ cause: t, nonce: n } = {}) {
3313    super(`Nonce provided for the transaction ${n ? `(${n}) ` : ""}exceeds the maximum allowed nonce.`, { cause: t, name: "NonceMaxValueError" });
3314  }
3315}
3316Object.defineProperty(ga, "nodeMessage", {
3317  enumerable: !0,
3318  configurable: !0,
3319  writable: !0,
3320  value: /nonce has max value/
3321});
3322class ya extends F {
3323  constructor({ cause: t } = {}) {
3324    super([
3325      "The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."
3326    ].join(`
3327`), {
3328      cause: t,
3329      metaMessages: [
3330        "This error could arise when the account does not have enough funds to:",
3331        " - pay for the total gas fee,",
3332        " - pay for the value to send.",
3333        " ",
3334        "The cost of the transaction is calculated as `gas * gas fee + value`, where:",
3335        " - `gas` is the amount of gas needed for transaction to execute,",
3336        " - `gas fee` is the gas fee,",
3337        " - `value` is the amount of ether to send to the recipient."
3338      ],
3339      name: "InsufficientFundsError"
3340    });
3341  }
3342}
3343Object.defineProperty(ya, "nodeMessage", {
3344  enumerable: !0,
3345  configurable: !0,
3346  writable: !0,
3347  value: /insufficient funds|exceeds transaction sender account balance/
3348});
3349class ba extends F {
3350  constructor({ cause: t, gas: n } = {}) {
3351    super(`The amount of gas ${n ? `(${n}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`, {
3352      cause: t,
3353      name: "IntrinsicGasTooHighError"
3354    });
3355  }
3356}
3357Object.defineProperty(ba, "nodeMessage", {
3358  enumerable: !0,
3359  configurable: !0,
3360  writable: !0,
3361  value: /intrinsic gas too high|gas limit reached/
3362});
3363class wa extends F {
3364  constructor({ cause: t, gas: n } = {}) {
3365    super(`The amount of gas ${n ? `(${n}) ` : ""}provided for the transaction is too low.`, {
3366      cause: t,
3367      name: "IntrinsicGasTooLowError"
3368    });
3369  }
3370}
3371Object.defineProperty(wa, "nodeMessage", {
3372  enumerable: !0,
3373  configurable: !0,
3374  writable: !0,
3375  value: /intrinsic gas too low/
3376});
3377class Ca extends F {
3378  constructor({ cause: t }) {
3379    super("The transaction type is not supported for this chain.", {
3380      cause: t,
3381      name: "TransactionTypeNotSupportedError"
3382    });
3383  }
3384}
3385Object.defineProperty(Ca, "nodeMessage", {
3386  enumerable: !0,
3387  configurable: !0,
3388  writable: !0,
3389  value: /transaction type not valid/
3390});
3391class Fi extends F {
3392  constructor({ cause: t, maxPriorityFeePerGas: n, maxFeePerGas: r } = {}) {
3393    super([
3394      `The provided tip (\`maxPriorityFeePerGas\`${n ? ` = ${dt(n)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${r ? ` = ${dt(r)} gwei` : ""}).`
3395    ].join(`
3396`), {
3397      cause: t,
3398      name: "TipAboveFeeCapError"
3399    });
3400  }
3401}
3402Object.defineProperty(Fi, "nodeMessage", {
3403  enumerable: !0,
3404  configurable: !0,
3405  writable: !0,
3406  value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/
3407});
3408class ho extends F {
3409  constructor({ cause: t }) {
3410    super(`An error occurred while executing: ${t?.shortMessage}`, {
3411      cause: t,
3412      name: "UnknownNodeError"
3413    });
3414  }
3415}
3416function mc(e, t) {
3417  const n = (e.details || "").toLowerCase(), r = e instanceof F ? e.walk((s) => s?.code === Yn.code) : e;
3418  return r instanceof F ? new Yn({
3419    cause: e,
3420    message: r.details
3421  }) : Yn.nodeMessage.test(n) ? new Yn({
3422    cause: e,
3423    message: e.details
3424  }) : Di.nodeMessage.test(n) ? new Di({
3425    cause: e,
3426    maxFeePerGas: t?.maxFeePerGas
3427  }) : ha.nodeMessage.test(n) ? new ha({
3428    cause: e,
3429    maxFeePerGas: t?.maxFeePerGas
3430  }) : pa.nodeMessage.test(n) ? new pa({ cause: e, nonce: t?.nonce }) : ma.nodeMessage.test(n) ? new ma({ cause: e, nonce: t?.nonce }) : ga.nodeMessage.test(n) ? new ga({ cause: e, nonce: t?.nonce }) : ya.nodeMessage.test(n) ? new ya({ cause: e }) : ba.nodeMessage.test(n) ? new ba({ cause: e, gas: t?.gas }) : wa.nodeMessage.test(n) ? new wa({ cause: e, gas: t?.gas }) : Ca.nodeMessage.test(n) ? new Ca({ cause: e }) : Fi.nodeMessage.test(n) ? new Fi({
3431    cause: e,
3432    maxFeePerGas: t?.maxFeePerGas,
3433    maxPriorityFeePerGas: t?.maxPriorityFeePerGas
3434  }) : new ho({
3435    cause: e
3436  });
3437}
3438function im(e, { docsPath: t, ...n }) {
3439  const r = (() => {
3440    const s = mc(e, n);
3441    return s instanceof ho ? e : s;
3442  })();
3443  return new sm(r, {
3444    docsPath: t,
3445    ...n
3446  });
3447}
3448function po(e, { format: t }) {
3449  if (!t)
3450    return {};
3451  const n = {};
3452  function r(i) {
3453    const o = Object.keys(i);
3454    for (const a of o)
3455      a in e && (n[a] = e[a]), i[a] && typeof i[a] == "object" && !Array.isArray(i[a]) && r(i[a]);
3456  }
3457  const s = t(e || {});
3458  return r(s), n;
3459}
3460function mo(e, t) {
3461  return ({ exclude: n, format: r }) => ({
3462    exclude: n,
3463    format: (s, i) => {
3464      const o = t(s, i);
3465      if (n)
3466        for (const a of n)
3467          delete o[a];
3468      return {
3469        ...o,
3470        ...r(s, i)
3471      };
3472    },
3473    type: e
3474  });
3475}
3476const om = {
3477  legacy: "0x0",
3478  eip2930: "0x1",
3479  eip1559: "0x2",
3480  eip4844: "0x3",
3481  eip7702: "0x4"
3482};
3483function Ks(e, t) {
3484  const n = {};
3485  return typeof e.authorizationList < "u" && (n.authorizationList = am(e.authorizationList)), typeof e.accessList < "u" && (n.accessList = e.accessList), typeof e.blobVersionedHashes < "u" && (n.blobVersionedHashes = e.blobVersionedHashes), typeof e.blobs < "u" && (typeof e.blobs[0] != "string" ? n.blobs = e.blobs.map((r) => ft(r)) : n.blobs = e.blobs), typeof e.data < "u" && (n.data = e.data), e.account && (n.from = e.account.address), typeof e.from < "u" && (n.from = e.from), typeof e.gas < "u" && (n.gas = be(e.gas)), typeof e.gasPrice < "u" && (n.gasPrice = be(e.gasPrice)), typeof e.maxFeePerBlobGas < "u" && (n.maxFeePerBlobGas = be(e.maxFeePerBlobGas)), typeof e.maxFeePerGas < "u" && (n.maxFeePerGas = be(e.maxFeePerGas)), typeof e.maxPriorityFeePerGas < "u" && (n.maxPriorityFeePerGas = be(e.maxPriorityFeePerGas)), typeof e.nonce < "u" && (n.nonce = be(e.nonce)), typeof e.to < "u" && (n.to = e.to), typeof e.type < "u" && (n.type = om[e.type]), typeof e.value < "u" && (n.value = be(e.value)), n;
3486}
3487const $v = /* @__PURE__ */ mo("transactionRequest", Ks);
3488function am(e) {
3489  return e.map((t) => ({
3490    address: t.address,
3491    r: t.r ? be(BigInt(t.r)) : t.r,
3492    s: t.s ? be(BigInt(t.s)) : t.s,
3493    chainId: be(t.chainId),
3494    nonce: be(t.nonce),
3495    ...typeof t.yParity < "u" ? { yParity: be(t.yParity) } : {},
3496    ...typeof t.v < "u" && typeof t.yParity > "u" ? { v: be(t.v) } : {}
3497  }));
3498}
3499function ru(e) {
3500  if (!(!e || e.length === 0))
3501    return e.reduce((t, { slot: n, value: r }) => {
3502      if (n.length !== 66)
3503        throw new Hc({
3504          size: n.length,
3505          targetSize: 66,
3506          type: "hex"
3507        });
3508      if (r.length !== 66)
3509        throw new Hc({
3510          size: r.length,
3511          targetSize: 66,
3512          type: "hex"
3513        });
3514      return t[n] = r, t;
3515    }, {});
3516}
3517function cm(e) {
3518  const { balance: t, nonce: n, state: r, stateDiff: s, code: i } = e, o = {};
3519  if (i !== void 0 && (o.code = i), t !== void 0 && (o.balance = be(t)), n !== void 0 && (o.nonce = be(n)), r !== void 0 && (o.state = ru(r)), s !== void 0) {
3520    if (o.state)
3521      throw new L0();
3522    o.stateDiff = ru(s);
3523  }
3524  return o;
3525}
3526function hd(e) {
3527  if (!e)
3528    return;
3529  const t = {};
3530  for (const { address: n, ...r } of e) {
3531    if (!Gt(n, { strict: !1 }))
3532      throw new sr({ address: n });
3533    if (t[n])
3534      throw new M0({ address: n });
3535    t[n] = cm(r);
3536  }
3537  return t;
3538}
3539const Hv = 2n ** 16n - 1n, um = 2n ** 256n - 1n;
3540function Ys(e) {
3541  const { account: t, maxFeePerGas: n, maxPriorityFeePerGas: r, to: s } = e, i = t ? vt(t) : void 0;
3542  if (i && !Gt(i.address))
3543    throw new sr({ address: i.address });
3544  if (s && !Gt(s))
3545    throw new sr({ address: s });
3546  if (n && n > um)
3547    throw new Di({ maxFeePerGas: n });
3548  if (r && n && r > n)
3549    throw new Fi({ maxFeePerGas: n, maxPriorityFeePerGas: r });
3550}
3551class pd extends F {
3552  constructor() {
3553    super("`baseFeeMultiplier` must be greater than 1.", {
3554      name: "BaseFeeScalarError"
3555    });
3556  }
3557}
3558class gc extends F {
3559  constructor() {
3560    super("Chain does not support EIP-1559 fees.", {
3561      name: "Eip1559FeesNotSupportedError"
3562    });
3563  }
3564}
3565class lm extends F {
3566  constructor({ maxPriorityFeePerGas: t }) {
3567    super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${dt(t)}
3567 gwei).`, { name: "MaxFeePerGasTooLowError" });
3568  }
3569}
3570class md extends F {
3571  constructor({ blockHash: t, blockNumber: n }) {
3572    let r = "Block";
3573    t && (r = `Block at hash "${t}"`), n && (r = `Block at number "${n}"`), super(`${r} could not be found.`, { name: "BlockNotFoundError" });
3574  }
3575}
3576const gd = {
3577  "0x0": "legacy",
3578  "0x1": "eip2930",
3579  "0x2": "eip1559",
3580  "0x3": "eip4844",
3581  "0x4": "eip7702"
3582};
3583function go(e, t) {
3584  const n = {
3585    ...e,
3586    blockHash: e.blockHash ? e.blockHash : null,
3587    blockNumber: e.blockNumber ? BigInt(e.blockNumber) : null,
3588    chainId: e.chainId ? Bn(e.chainId) : void 0,
3589    gas: e.gas ? BigInt(e.gas) : void 0,
3590    gasPrice: e.gasPrice ? BigInt(e.gasPrice) : void 0,
3591    maxFeePerBlobGas: e.maxFeePerBlobGas ? BigInt(e.maxFeePerBlobGas) : void 0,
3592    maxFeePerGas: e.maxFeePerGas ? BigInt(e.maxFeePerGas) : void 0,
3593    maxPriorityFeePerGas: e.maxPriorityFeePerGas ? BigInt(e.maxPriorityFeePerGas) : void 0,
3594    nonce: e.nonce ? Bn(e.nonce) : void 0,
3595    to: e.to ? e.to : null,
3596    transactionIndex: e.transactionIndex ? Number(e.transactionIndex) : null,
3597    type: e.type ? gd[e.type] : void 0,
3598    typeHex: e.type ? e.type : void 0,
3599    value: e.value ? BigInt(e.value) : void 0,
3600    v: e.v ? BigInt(e.v) : void 0
3601  };
3602  return e.authorizationList && (n.authorizationList = dm(e.authorizationList)), n.yParity = (() => {
3603    if (e.yParity)
3604      return Number(e.yParity);
3605    if (typeof n.v == "bigint") {
3606      if (n.v === 0n || n.v === 27n)
3607        return 0;
3608      if (n.v === 1n || n.v === 28n)
3609        return 1;
3610      if (n.v >= 35n)
3611        return n.v % 2n === 0n ? 1 : 0;
3612    }
3613  })(), n.type === "legacy" && (delete n.accessList, delete n.maxFeePerBlobGas, delete n.maxFeePerGas, delete n.maxPriorityFeePerGas, delete n.yParity), n.type === "eip2930" && (delete n.maxFeePerBlobGas, delete n.maxFeePerGas, delete n.maxPriorityFeePerGas), n.type === "eip1559" && delete n.maxFeePerBlobGas, n;
3614}
3615const qv = /* @__PURE__ */ mo("transaction", go);
3616function dm(e) {
3617  return e.map((t) => ({
3618    address: t.address,
3619    chainId: Number(t.chainId),
3620    nonce: Number(t.nonce),
3621    r: t.r,
3622    s: t.s,
3623    yParity: Number(t.yParity)
3624  }));
3625}
3626function yd(e, t) {
3627  const n = (e.transactions ?? []).map((r) => typeof r == "string" ? r : go(r));
3628  return {
3629    ...e,
3630    baseFeePerGas: e.baseFeePerGas ? BigInt(e.baseFeePerGas) : null,
3631    blobGasUsed: e.blobGasUsed ? BigInt(e.blobGasUsed) : void 0,
3632    difficulty: e.difficulty ? BigInt(e.difficulty) : void 0,
3633    excessBlobGas: e.excessBlobGas ? BigInt(e.excessBlobGas) : void 0,
3634    gasLimit: e.gasLimit ? BigInt(e.gasLimit) : void 0,
3635    gasUsed: e.gasUsed ? BigInt(e.gasUsed) : void 0,
3636    hash: e.hash ? e.hash : null,
3637    logsBloom: e.logsBloom ? e.logsBloom : null,
3638    nonce: e.nonce ? e.nonce : null,
3639    number: e.number ? BigInt(e.number) : null,
3640    size: e.size ? BigInt(e.size) : void 0,
3641    timestamp: e.timestamp ? BigInt(e.timestamp) : void 0,
3642    transactions: n,
3643    totalDifficulty: e.totalDifficulty ? BigInt(e.totalDifficulty) : null
3644  };
3645}
3646const Gv = /* @__PURE__ */ mo("block", yd);
3647async function Lr(e, { blockHash: t, blockNumber: n, blockTag: r = e.experimental_blockTag ?? "latest", includeTransactions: s } = {}) {
3648  const i = s ?? !1, o = n !== void 0 ? be(n) : void 0;
3649  let a = null;
3650  if (t ? a = await e.request({
3651    method: "eth_getBlockByHash",
3652    params: [t, i]
3653  }, { dedupe: !0 }) : a = await e.request({
3654    method: "eth_getBlockByNumber",
3655    params: [o || r, i]
3656  }, { dedupe: !!o }), !a)
3657    throw new md({ blockHash: t, blockNumber: n });
3658  return (e.chain?.formatters?.block?.format || yd)(a, "getBlock");
3659}
3660async function bd(e) {
3661  const t = await e.request({
3662    method: "eth_gasPrice"
3663  });
3664  return BigInt(t);
3665}
3666async function zv(e, t) {
3667  return wd(e, t);
3668}
3669async function wd(e, t) {
3670  const { block: n, chain: r = e.chain, request: s } = t || {};
3671  try {
3672    const i = r?.fees?.maxPriorityFeePerGas ?? r?.fees?.defaultPriorityFee;
3673    if (typeof i == "function") {
3674      const a = n || await ke(e, Lr, "getBlock")({}), u = await i({
3675        block: a,
3676        client: e,
3677        request: s
3678      });
3679      if (u === null)
3680        throw new Error();
3681      return u;
3682    }
3683    if (typeof i < "u")
3684      return i;
3685    const o = await e.request({
3686      method: "eth_maxPriorityFeePerGas"
3687    });
3688    return nr(o);
3689  } catch {
3690    const [i, o] = await Promise.all([
3691      n ? Promise.resolve(n) : ke(e, Lr, "getBlock")({}),
3692      ke(e, bd, "getGasPrice")({})
3693    ]);
3694    if (typeof i.baseFeePerGas != "bigint")
3695      throw new gc();
3696    const a = o - i.baseFeePerGas;
3697    return a < 0n ? 0n : a;
3698  }
3699}
3700async function Vv(e, t) {
3701  return Ea(e, t);
3702}
3703async function Ea(e, t) {
3704  const { block: n, chain: r = e.chain, request: s, type: i = "eip1559" } = t || {}, o = await (async () => typeof r?.fees?.baseFeeMultiplier == "function" ? r.fees.baseFeeMultiplier({
3705    block: n,
3706    client: e,
3707    request: s
3708  }) : r?.fees?.baseFeeMultiplier ?? 1.2)();
3709  if (o < 1)
3710    throw new pd();
3711  const u = 10 ** (o.toString().split(".")[1]?.length ?? 0), c = (p) => p * BigInt(Math.ceil(o * u)) / BigInt(u), l = n || await ke(e, Lr, "getBlock")({});
3712  if (typeof r?.fees?.estimateFeesPerGas == "function") {
3713    const p = await r.fees.estimateFeesPerGas({
3714      block: n,
3715      client: e,
3716      multiply: c,
3717      request: s,
3718      type: i
3719    });
3720    if (p !== null)
3721      return p;
3722  }
3723  if (i === "eip1559") {
3724    if (typeof l.baseFeePerGas != "bigint")
3725      throw new gc();
3726    const p = typeof s?.maxPriorityFeePerGas == "bigint" ? s.maxPriorityFeePerGas : await wd(e, {
3727      block: l,
3728      chain: r,
3729      request: s
3730    }), m = c(l.baseFeePerGas);
3731    return {
3732      maxFeePerGas: s?.maxFeePerGas ?? m + p,
3733      maxPriorityFeePerGas: p
3734    };
3735  }
3736  return {
3737    gasPrice: s?.gasPrice ?? c(await ke(e, bd, "getGasPrice")({}))
3738  };
3739}
3740async function fm(e, { address: t, blockTag: n = "latest", blockNumber: r }) {
3741  const s = await e.request({
3742    method: "eth_getTransactionCount",
3743    params: [
3744      t,
3745      typeof r == "bigint" ? be(r) : n
3746    ]
3747  }, {
3748    dedupe: !!r
3749  });
3750  return Bn(s);
3751}
3752function Cd(e) {
3753  const { kzg: t } = e, n = e.to ?? (typeof e.blobs[0] == "string" ? "hex" : "bytes"), r = typeof e.blobs[0] == "string" ? e.blobs.map((i) => Pt(i)) : e.blobs, s = [];
3754  for (const i of r)
3755    s.push(Uint8Array.from(t.blobToKzgCommitment(i)));
3756  return n === "bytes" ? s : s.map((i) => ft(i));
3757}
3758function Ed(e) {
3759  const { kzg: t } = e, n = e.to ?? (typeof e.blobs[0] == "string" ? "hex" : "bytes"), r = typeof e.blobs[0] == "string" ? e.blobs.map((o) => Pt(o)) : e.blobs, s = typeof e.commitments[0] == "string" ? e.commitments.map((o) => Pt(o)) : e.commitments, i = [];
3760  for (let o = 0; o < r.length; o++) {
3761    const a = r[o], u = s[o];
3762    i.push(Uint8Array.from(t.computeBlobKzgProof(a, u)));
3763  }
3764  return n === "bytes" ? i : i.map((o) => ft(o));
3765}
3766function hm(e, t, n, r) {
3767  if (typeof e.setBigUint64 == "function")
3768    return e.setBigUint64(t, n, r);
3769  const s = BigInt(32), i = BigInt(4294967295), o = Number(n >> s & i), a = Number(n & i), u = r ? 4 : 0, c = r ? 0 : 4;
3770  e.setUint32(t + u, o, r), e.setUint32(t + c, a, r);
3771}
3772function pm(e, t, n) {
3773  return e & t ^ ~e & n;
3774}
3775function mm(e, t, n) {
3776  return e & t ^ e & n ^ t & n;
3777}
3778class Ad extends Vl {
3779  constructor(t, n, r, s) {
3780    super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = n, this.padOffset = r, this.isLE = s, this.buffer = new Uint8Array(t), this.view = Ro(this.buffer);
3781  }
3782  update(t) {
3783    Li(this), t = nc(t), Or(t);
3784    const { view: n, buffer: r, blockLen: s } = this, i = t.length;
3785    for (let o = 0; o < i; ) {
3786      const a = Math.min(s - this.pos, i - o);
3787      if (a === s) {
3788        const u = Ro(t);
3789        for (;
3789 s <= i - o; o += s)
3790          this.process(u, o);
3791        continue;
3792      }
3793      r.set(t.subarray(o, o + a), this.pos), this.pos += a, o += a, this.pos === s && (this.process(n, 0), this.pos = 0);
3794    }
3795    return this.length += t.length, this.roundClean(), this;
3796  }
3797  digestInto(t) {
3798    Li(this), zl(t, this), this.finished = !0;
3799    const { buffer: n, view: r, blockLen: s, isLE: i } = this;
3800    let { pos: o } = this;
3801    n[o++] = 128, rr(this.buffer.subarray(o)), this.padOffset > s - o && (this.process(r, 0), o = 0);
3802    for (let f = o; f < s; f++)
3803      n[f] = 0;
3804    hm(r, s - 8, BigInt(this.length * 8), i), this.process(r, 0);
3805    const a = Ro(t), u = this.outputLen;
3806    if (u % 4)
3807      throw new Error("_sha2: outputLen should be aligned to 32bit");
3808    const c = u / 4, l = this.get();
3809    if (c > l.length)
3810      throw new Error("_sha2: outputLen bigger than state");
3811    for (let f = 0; f < c; f++)
3812      a.setUint32(4 * f, l[f], i);
3813  }
3814  digest() {
3815    const { buffer: t, outputLen: n } = this;
3816    this.digestInto(t);
3817    const r = t.slice(0, n);
3818    return this.destroy(), r;
3819  }
3820  _cloneInto(t) {
3821    t || (t = new this.constructor()), t.set(...this.get());
3822    const { blockLen: n, buffer: r, length: s, finished: i, destroyed: o, pos: a } = this;
3823    return t.destroyed = o, t.finished = i, t.length = s, t.pos = a, s % n && t.buffer.set(r), t;
3824  }
3825  clone() {
3826    return this._cloneInto();
3827  }
3828}
3829const yn = /* @__PURE__ */ Uint32Array.from([
3830  1779033703,
3831  3144134277,
3832  1013904242,
3833  2773480762,
3834  1359893119,
3835  2600822924,
3836  528734635,
3837  1541459225
3838]), Xe = /* @__PURE__ */ Uint32Array.from([
3839  3418070365,
3840  3238371032,
3841  1654270250,
3842  914150663,
3843  2438529370,
3844  812702999,
3845  355462360,
3846  4144912697,
3847  1731405415,
3848  4290775857,
3849  2394180231,
3850  1750603025,
3851  3675008525,
3852  1694076839,
3853  1203062813,
3854  3204075428
3855]), et = /* @__PURE__ */ Uint32Array.from([
3856  1779033703,
3857  4089235720,
3858  3144134277,
3859  2227873595,
3860  1013904242,
3861  4271175723,
3862  2773480762,
3863  1595750129,
3864  1359893119,
3865  2917565137,
3866  2600822924,
3867  725511199,
3868  528734635,
3869  4215389547,
3870  1541459225,
3871  327033209
3872]), gm = /* @__PURE__ */ Uint32Array.from([
3873  1116352408,
3874  1899447441,
3875  3049323471,
3876  3921009573,
3877  961987163,
3878  1508970993,
3879  2453635748,
3880  2870763221,
3881  3624381080,
3882  310598401,
3883  607225278,
3884  1426881987,
3885  1925078388,
3886  2162078206,
3887  2614888103,
3888  3248222580,
3889  3835390401,
3890  4022224774,
3891  264347078,
3892  604807628,
3893  770255983,
3894  1249150122,
3895  1555081692,
3896  1996064986,
3897  2554220882,
3898  2821834349,
3899  2952996808,
3900  3210313671,
3901  3336571891,
3902  3584528711,
3903  113926993,
3904  338241895,
3905  666307205,
3906  773529912,
3907  1294757372,
3908  1396182291,
3909  1695183700,
3910  1986661051,
3911  2177026350,
3912  2456956037,
3913  2730485921,
3914  2820302411,
3915  3259730800,
3916  3345764771,
3917  3516065817,
3918  3600352804,
3919  4094571909,
3920  275423344,
3921  430227734,
3922  506948616,
3923  659060556,
3924  883997877,
3925  958139571,
3926  1322822218,
3927  1537002063,
3928  1747873779,
3929  1955562222,
3930  2024104815,
3931  2227730452,
3932  2361852424,
3933  2428436474,
3934  2756734187,
3935  3204031479,
3936  3329325298
3937]), bn = /* @__PURE__ */ new Uint32Array(64);
3938class ym extends Ad {
3939  constructor(t = 32) {
3940    super(64, t, 8, !1), this.A = yn[0] | 0, this.B = yn[1] | 0, this.C = yn[2] | 0, this.D = yn[3] | 0, this.E = yn[4] | 0, this.F = yn[5] | 0, this.G = yn[6] | 0, this.H = yn[7] | 0;
3941  }
3942  get() {
3943    const { A: t, B: n, C: r, D: s, E: i, F: o, G: a, H: u } = this;
3944    return [t, n, r, s, i, o, a, u];
3945  }
3946  // prettier-ignore
3947  set(t, n, r, s, i, o, a, u) {
3948    this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = s | 0, this.E = i | 0, this.F = o | 0, this.G = a | 0, this.H = u | 0;
3949  }
3950  process(t, n) {
3951    for (let f = 0; f < 16; f++, n += 4)
3952      bn[f] = t.getUint32(n, !1);
3953    for (let f = 16; f < 64; f++) {
3954      const p = bn[f - 15], m = bn[f - 2], y = Dt(p, 7) ^ Dt(p, 18) ^ p >>> 3, b = Dt(m, 17) ^ Dt(m, 19) ^ m >>> 10;
3955      bn[f] = b + bn[f - 7] + y + bn[f - 16] | 0;
3956    }
3957    let { A: r, B: s, C: i, D: o, E: a, F: u, G: c, H: l } = this;
3958    for (let f = 0; f < 64; f++) {
3959      const p = Dt(a, 6) ^ Dt(a, 11) ^ Dt(a, 25), m = l + p + pm(a, u, c) + gm[f] + bn[f] | 0, b = (Dt(r, 2) ^ Dt(r, 13) ^ Dt(r, 22)) + mm(r, s, i) | 0;
3960      l = c, c = u, u = a, a = o + m | 0, o = i, i = s, s = r, r = m + b | 0;
3961    }
3962    r = r + this.A | 0, s = s + this.B | 0, i = i + this.C | 0, o = o + this.D | 0, a = a + this.E | 0, u = u + this.F | 0, c = c + this.G | 0, l = l + this.H | 0, this.set(r, s, i, o, a, u, c, l);
3963  }
3964  roundClean() {
3965    rr(bn);
3966  }
3967  destroy() {
3968    this.set(0, 0, 0, 0, 0, 0, 0, 0), rr(this.buffer);
3969  }
3970}
3971const vd = Gl([
3972  "0x428a2f98d728ae22",
3973  "0x7137449123ef65cd",
3974  "0xb5c0fbcfec4d3b2f",
3975  "0xe9b5dba58189dbbc",
3976  "0x3956c25bf348b538",
3977  "0x59f111f1b605d019",
3978  "0x923f82a4af194f9b",
3979  "0xab1c5ed5da6d8118",
3980  "0xd807aa98a3030242",
3981  "0x12835b0145706fbe",
3982  "0x243185be4ee4b28c",
3983  "0x550c7dc3d5ffb4e2",
3984  "0x72be5d74f27b896f",
3985  "0x80deb1fe3b1696b1",
3986  "0x9bdc06a725c71235",
3987  "0xc19bf174cf692694",
3988  "0xe49b69c19ef14ad2",
3989  "0xefbe4786384f25e3",
3990  "0x0fc19dc68b8cd5b5",
3991  "0x240ca1cc77ac9c65",
3992  "0x2de92c6f592b0275",
3993  "0x4a7484aa6ea6e483",
3994  "0x5cb0a9dcbd41fbd4",
3995  "0x76f988da831153b5",
3996  "0x983e5152ee66dfab",
3997  "0xa831c66d2db43210",
3998  "0xb00327c898fb213f",
3999  "0xbf597fc7beef0ee4",
4000  "0xc6e00bf33da88fc2",
4001  "0xd5a79147930aa725",
4002  "0x06ca6351e003826f",
4003  "0x142929670a0e6e70",
4004  "0x27b70a8546d22ffc",
4005  "0x2e1b21385c26c926",
4006  "0x4d2c6dfc5ac42aed",
4007  "0x53380d139d95b3df",
4008  "0x650a73548baf63de",
4009  "0x766a0abb3c77b2a8",
4010  "0x81c2c92e47edaee6",
4011  "0x92722c851482353b",
4012  "0xa2bfe8a14cf10364",
4013  "0xa81a664bbc423001",
4014  "0xc24b8b70d0f89791",
4015  "0xc76c51a30654be30",
4016  "0xd192e819d6ef5218",
4017  "0xd69906245565a910",
4018  "0xf40e35855771202a",
4019  "0x106aa07032bbd1b8",
4020  "0x19a4c116b8d2d0c8",
4021  "0x1e376c085141ab53",
4022  "0x2748774cdf8eeb99",
4023  "0x34b0bcb5e19b48a8",
4024  "0x391c0cb3c5c95a63",
4025  "0x4ed8aa4ae3418acb",
4026  "0x5b9cca4f7763e373",
4027  "0x682e6ff3d6b2b8a3",
4028  "0x748f82ee5defb2fc",
4029  "0x78a5636f43172f60",
4030  "0x84c87814a1f0ab72",
4031  "0x8cc702081a6439ec",
4032  "0x90befffa23631e28",
4033  "0xa4506cebde82bde9",
4034  "0xbef9a3f7b2c67915",
4035  "0xc67178f2e372532b",
4036  "0xca273eceea26619c",
4037  "0xd186b8c721c0c207",
4038  "0xeada7dd6cde0eb1e",
4039  "0xf57d4f7fee6ed178",
4040  "0x06f067aa72176fba",
4041  "0x0a637dc5a2c898a6",
4042  "0x113f9804bef90dae",
4043  "0x1b710b35131c471b",
4044  "0x28db77f523047d84",
4045  "0x32caab7b40c72493",
4046  "0x3c9ebe0a15c9bebc",
4047  "0x431d67c49c100d4c",
4048  "0x4cc5d4becb3e42b6",
4049  "0x597f299cfc657e2a",
4050  "0x5fcb6fab3ad6faec",
4051  "0x6c44198c4a475817"
4052].map((e) => BigInt(e))), bm = vd[0], wm = vd[1], wn = /* @__PURE__ */ new Uint32Array(80), Cn = /* @__PURE__ */ new Uint32Array(80);
4053class _d extends Ad {
4054  constructor(t = 64) {
4055    super(128, t, 16, !1), this.Ah = et[0] | 0, this.Al = et[1] | 0, this.Bh = et[2] | 0, this.Bl = et[3] | 0, this.Ch = et[4] | 0, this.Cl = et[5] | 0, this.Dh = et[6] | 0, this.Dl = et[7] | 0, this.Eh = et[8] | 0, this.El = et[9] | 0, this.Fh = et[10] | 0, this.Fl = et[11] | 0, this.Gh = et[12] | 0, this.Gl = et[13] | 0, this.Hh = et[14] | 0, this.Hl = et[15] | 0;
4056  }
4057  // prettier-ignore
4058  get() {
4059    const { Ah: t, Al: n, Bh: r, Bl: s, Ch: i, Cl: o, Dh: a, Dl: u, Eh: c, El: l, Fh: f, Fl: p, Gh: m, Gl: y, Hh: b, Hl: C } = this;
4060    return [t, n, r, s, i, o, a, u, c, l, f, p, m, y, b, C];
4061  }
4062  // prettier-ignore
4063  set(t, n, r, s, i, o, a, u, c, l, f, p, m, y, b, C) {
4064    this.Ah = t | 0, this.Al = n | 0, this.Bh = r | 0, this.Bl = s | 0, this.Ch = i | 0, this.Cl = o | 0, this.Dh = a | 0, this.Dl = u | 0, this.Eh = c | 0, this.El = l | 0, this.Fh = f | 0, this.Fl = p | 0, this.Gh = m | 0, this.Gl = y | 0, this.Hh = b | 0, this.Hl = C | 0;
4065  }
4066  process(t, n) {
4067    for (let N = 0; N < 16; N++, n += 4)
4068      wn[N] = t.getUint32(n), Cn[N] = t.getUint32(n += 4);
4069    for (let N = 16; N < 80; N++) {
4070      const I = wn[N - 15] | 0, E = Cn[N - 15] | 0, T = yr(I, E, 1) ^ yr(I, E, 8) ^ zc(I, E, 7), O = br(I, E, 1) ^ br(I, E, 8) ^ Vc(I, E, 7), U = wn[N - 2] | 0, M = Cn[N - 2] | 0, L = yr(U, M, 19) ^ ri(U, M, 61) ^ zc(U, M, 6), re = br(U, M, 19) ^ si(U, M, 61) ^ Vc(U, M, 6), ne = kp(O, re, Cn[N - 7], Cn[N - 16]), fe = Up(ne, T, L, wn[N - 7], wn[N - 16]);
4071      wn[N] = fe | 0, Cn[N] = ne | 0;
4072    }
4073    let { Ah: r, Al: s, Bh: i, Bl: o, Ch: a, Cl: u, Dh: c, Dl: l, Eh: f, El: p, Fh: m, Fl: y, Gh: b, Gl: C, Hh: _, Hl: R } = this;
4074    for (let N = 0; N < 80; N++) {
4075      const I = yr(f, p, 14) ^ yr(f, p, 18) ^ ri(f, p, 41), E = br(f, p, 14) ^ br(f, p, 18) ^ si(f, p, 41), T = f & m ^ ~f & b, O = p & y ^ ~p & C, U = Mp(R, E, O, wm[N], Cn[N]), M = Lp(U, _, I, T, bm[N], wn[N]), L = U | 0, re = yr(r, s, 28) ^ ri(r, s, 34) ^ ri(r, s, 39), ne = br(r, s, 28) ^ si(r, s, 34) ^ si(r, s, 39), fe = r & i ^ r & a ^ i & a, ae = s & o ^ s & u ^ o & u;
4076      _ = b | 0, R = C | 0, b = m | 0, C = y | 0, m = f | 0, y = p | 0, { h: f, l: p } = Zt(c | 0, l | 0, M | 0, L | 0), c = a | 0, l = u | 0, a = i | 0, u = o | 0, i = r | 0, o = s | 0;
4077      const P = Op(L, ne, ae);
4078      r = Pp(P, M, re, fe), s = P | 0;
4079    }
4080    ({ h: r, l: s } = Zt(this.Ah | 0, this.Al | 0, r | 0, s | 0)), { h: i, l: o } = Zt(this.Bh | 0, this.Bl | 0, i | 0, o | 0), { h: a, l: u } = Zt(this.Ch | 0, this.Cl | 0, a | 0, u | 0), { h: c, l } = Zt(this.Dh | 0, this.Dl | 0, c | 0, l | 0), { h: f, l: p } = Zt(this.Eh | 0, this.El | 0, f | 0, p | 0), { h: m, l: y } = Zt(this.Fh | 0, this.Fl | 0, m | 0, y | 0), { h: b, l: C } = Zt(this.Gh | 0, this.Gl | 0, b | 0, C | 0), { h: _, l: R } = Zt(this.Hh | 0, this.Hl | 0, _ | 0, R | 0), this.set(r, s, i, o, a, u, c, l, f, p, m, y, b, C, _, R);
4081  }
4082  roundClean() {
4083    rr(wn, Cn);
4084  }
4085  destroy() {
4086    rr(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
4087  }
4088}
4089class Cm extends _d {
4090  constructor() {
4091    super(48), this.Ah = Xe[0] | 0, this.Al = Xe[1] | 0, this.Bh = Xe[2] | 0, this.Bl = Xe[3] | 0, this.Ch = Xe[4] | 0, this.Cl = Xe[5] | 0, this.Dh = Xe[6] | 0, this.Dl = Xe[7] | 0, this.Eh = Xe[8] | 0, this.El = Xe[9] | 0, this.Fh = Xe[10] | 0, this.Fl = Xe[11] | 0, this.Gh = Xe[12] | 0, this.Gl = Xe[13] | 0, this.Hh = Xe[14] | 0, this.Hl = Xe[15] | 0;
4092  }
4093}
4094const Em = /* @__PURE__ */ uo(() => new ym()), Kv = /* @__PURE__ */ uo(() => new _d()), Yv = /* @__PURE__ */ uo(() => new Cm()), Am = Em;
4095function vm(e, t) {
4096  const n = t || "hex", r = Am(Ln(e, { strict: !1 }) ? co(e) : e);
4097  return n === "bytes" ? r : ns(r);
4098}
4099function _m(e) {
4100  const { commitment: t, version: n = 1 } = e, r = e.to ?? (typeof t == "string" ? "hex" : "bytes"), s = vm(t, "bytes");
4101  return s.set([n], 0), r === "bytes" ? s : ft(s);
4102}
4103function Nm(e) {
4104  const { commitments: t, version: n } = e, r = e.to ?? (typeof t[0] == "string" ? "hex" : "bytes"), s = [];
4105  for (const i of t)
4106    s.push(_m({
4107      commitment: i,
4108      to: r,
4109      version: n
4110    }));
4111  return s;
4112}
4113const su = 6, Nd = 32, yc = 4096, Id = Nd * yc, iu = Id * su - // terminator byte (0x80).
41141 - // zero byte (0x00) appended to each field element.
41151 * yc * su, Im = 1;
4116class Tm extends F {
4117  constructor({ maxSize: t, size: n }) {
4118    super("Blob size is too large.", {
4119      metaMessages: [`Max: ${t} bytes`, `Given: ${n} bytes`],
4120      name: "BlobSizeTooLargeError"
4121    });
4122  }
4123}
4124class Sm extends F {
4125  constructor() {
4126    super("Blob data must not be empty.", { name: "EmptyBlobError" });
4127  }
4128}
4129class Zv extends F {
4130  constructor({ hash: t, size: n }) {
4131    super(`Versioned hash "${t}
4131" size is invalid.`, {
4132      metaMessages: ["Expected: 32", `Received: ${n}`],
4133      name: "InvalidVersionedHashSizeError"
4134    });
4135  }
4136}
4137class Qv extends F {
4138  constructor({ hash: t, version: n }) {
4139    super(`Versioned hash "${t}" version is invalid.`, {
4140      metaMessages: [
4141        `Expected: ${Im}`,
4142        `Received: ${n}`
4143      ],
4144      name: "InvalidVersionedHashVersionError"
4145    });
4146  }
4147}
4148function Rm(e) {
4149  const t = e.to ?? (typeof e.data == "string" ? "hex" : "bytes"), n = typeof e.data == "string" ? Pt(e.data) : e.data, r = Ze(n);
4150  if (!r)
4151    throw new Sm();
4152  if (r > iu)
4153    throw new Tm({
4154      maxSize: iu,
4155      size: r
4156    });
4157  const s = [];
4158  let i = !0, o = 0;
4159  for (; i; ) {
4160    const a = dc(new Uint8Array(Id));
4161    let u = 0;
4162    for (; u < yc; ) {
4163      const c = n.slice(o, o + (Nd - 1));
4164      if (a.pushByte(0), a.pushBytes(c), c.length < 31) {
4165        a.pushByte(128), i = !1;
4166        break;
4167      }
4168      u++, o += 31;
4169    }
4170    s.push(a);
4171  }
4172  return t === "bytes" ? s.map((a) => a.bytes) : s.map((a) => ft(a.bytes));
4173}
4174function xm(e) {
4175  const { data: t, kzg: n, to: r } = e, s = e.blobs ?? Rm({ data: t, to: r }), i = e.commitments ?? Cd({ blobs: s, kzg: n, to: r }
4175), o = e.proofs ?? Ed({ blobs: s, commitments: i, kzg: n, to: r }), a = [];
4176  for (let u = 0; u < s.length; u++)
4177    a.push({
4178      blob: s[u],
4179      commitment: i[u],
4180      proof: o[u]
4181    });
4182  return a;
4183}
4184function Om(e) {
4185  if (e.type)
4186    return e.type;
4187  if (typeof e.authorizationList < "u")
4188    return "eip7702";
4189  if (typeof e.blobs < "u" || typeof e.blobVersionedHashes < "u" || typeof e.maxFeePerBlobGas < "u" || typeof e.sidecars < "u")
4190    return "eip4844";
4191  if (typeof e.maxFeePerGas < "u" || typeof e.maxPriorityFeePerGas < "u")
4192    return "eip1559";
4193  if (typeof e.gasPrice < "u")
4194    return typeof e.accessList < "u" ? "eip2930" : "legacy";
4195  throw new D0({ transaction: e });
4196}
4197function Td(e, { docsPath: t, ...n }) {
4198  const r = (() => {
4199    const s = mc(e, n);
4200    return s instanceof ho ? e : s;
4201  })();
4202  return new F0(r, {
4203    docsPath: t,
4204    ...n
4205  });
4206}
4207async function bc(e) {
4208  const t = await e.request({
4209    method: "eth_chainId"
4210  }, { dedupe: !0 });
4211  return Bn(t);
4212}
4213async function Pm(e, t) {
4214  const { account: n = e.account, accessList: r, authorizationList: s, chain: i = e.chain, blobVersionedHashes: o, blobs: a, data: u, gas: c, gasPrice: l, maxFeePerBlobGas: f, maxFeePerGas: p, maxPriorityFeePerGas: m, nonce: y, nonceManager: b, to: C, type: _, value: R, ...N } = t, I = await (async () => {
4215    if (!n || !b || typeof y < "u")
4216      return y;
4217    const U = vt(n), M = i ? i.id : await ke(e, bc, "getChainId")({});
4218    return await b.consume({
4219      address: U.address,
4220      chainId: M,
4221      client: e
4222    });
4223  })();
4224  Ys(t);
4225  const E = i?.formatters?.transactionRequest?.format, O = (E || Ks)({
4226    // Pick out extra data that might exist on the chain's transaction request type.
4227    ...po(N, { format: E }),
4228    account: n ? vt(n) : void 0,
4229    accessList: r,
4230    authorizationList: s,
4231    blobs: a,
4232    blobVersionedHashes: o,
4233    data: u,
4234    gas: c,
4235    gasPrice: l,
4236    maxFeePerBlobGas: f,
4237    maxFeePerGas: p,
4238    maxPriorityFeePerGas: m,
4239    nonce: I,
4240    to: C,
4241    type: _,
4242    value: R
4243  }, "fillTransaction");
4244  try {
4245    const U = await e.request({
4246      method: "eth_fillTransaction",
4247      params: [O]
4248    }), L = (i?.formatters?.transaction?.format || go)(U.tx);
4249    delete L.blockHash, delete L.blockNumber, delete L.r, delete L.s, delete L.transactionIndex, delete L.v, delete L.yParity, L.data = L.input, L.gas && (L.gas = t.gas ?? L.gas), L.gasPrice && (L.gasPrice = t.gasPrice ?? L.gasPrice), L.maxFeePerBlobGas && (L.maxFeePerBlobGas = t.maxFeePerBlobGas ?? L.maxFeePerBlobGas), L.maxFeePerGas && (L.maxFeePerGas = t.maxFeePerGas ?? L.maxFeePerGas), L.maxPriorityFeePerGas && (L.maxPriorityFeePerGas = t.maxPriorityFeePerGas ?? L.maxPriorityFeePerGas), typeof L.nonce < "u" && (L.nonce = t.nonce ?? L.nonce);
4250    const re = await (async () => {
4251      if (typeof i?.fees?.baseFeeMultiplier == "function") {
4252        const P = await ke(e, Lr, "getBlock")({});
4253        return i.fees.baseFeeMultiplier({
4254          block: P,
4255          client: e,
4256          request: t
4257        });
4258      }
4259      return i?.fees?.baseFeeMultiplier ?? 1.2;
4260    })();
4261    if (re < 1)
4262      throw new pd();
4263    const fe = 10 ** (re.toString().split(".")[1]?.length ?? 0), ae = (P) => P * BigInt(Math.ceil(re * fe)) / BigInt(fe);
4264    return L.feePayerSignature || (L.maxFeePerGas && !t.maxFeePerGas && (L.maxFeePerGas = ae(L.maxFeePerGas)), L.gasPrice && !t.gasPrice && (L.gasPrice = ae(L.gasPrice))), {
4265      raw: U.raw,
4266      transaction: {
4267        from: O.from,
4268        ...L
4269      },
4270      ...U.capabilities ? { capabilities: U.capabilities } : {}
4271    };
4272  } catch (U) {
4273    throw Td(U, {
4274      ...t,
4275      chain: e.chain
4276    });
4277  }
4278}
4279const Sd = [
4280  "blobVersionedHashes",
4281  "chainId",
4282  "fees",
4283  "gas",
4284  "nonce",
4285  "type"
4286], ou = /* @__PURE__ */ new Map(), Po = /* @__PURE__ */ new qs(128);
4287async function wc(e, t) {
4288  let n = t;
4289  n.account ??= e.account, n.parameters ??= Sd;
4290  const { account: r, chain: s = e.chain, nonceManager: i, parameters: o } = n, a = (() => {
4291    if (typeof s?.prepareTransactionRequest == "function")
4292      return {
4293        fn: s.prepareTransactionRequest,
4294        runAt: ["beforeFillTransaction"]
4295      };
4296    if (Array.isArray(s?.prepareTransactionRequest))
4297      return {
4298        fn: s.prepareTransactionRequest[0],
4299        runAt: s.prepareTransactionRequest[1].runAt
4300      };
4301  })();
4302  let u;
4303  async function c() {
4304    return u || (typeof n.chainId < "u" ? n.chainId : s ? s.id : (u = await ke(e, bc, "getChainId")({}), u));
4305  }
4306  const l = r && vt(r);
4307  let f = n.nonce;
4308  if (o.includes("nonce") && typeof f > "u" && l && i) {
4309    const I = await c();
4310    f = await i.consume({
4311      address: l.address,
4312      chainId: I,
4313      client: e
4314    });
4315  }
4316  a?.fn && a.runAt?.includes("beforeFillTransaction") && (n = await a.fn({ ...n, chain: s }, {
4317    phase: "beforeFillTransaction"
4318  }), f ??= n.nonce);
4319  const m = ((o.includes("blobVersionedHashes") || o.includes("sidecars")) && n.kzg && n.blobs || Po.get(e.uid) === !1 || !["fees", "gas"].some((E) => o.includes(E)) ? !1 : !!(o.includes("chainId") && typeof n.chainId != "number" || o.includes("nonce") && typeof f != "number" || o.includes("fees") && typeof n.gasPrice != "bigint" && (typeof n.maxFeePerGas != "bigint" || typeof n.maxPriorityFeePerGas != "bigint") || o.includes("gas") && typeof n.gas != "bigint")) ? await ke(e, Pm, "fillTransaction")({ ...n, nonce: f }).then((I) => {
4320    const { chainId: E, from: T, gas: O, gasPrice: U, nonce: M, maxFeePerBlobGas: L, maxFeePerGas: re, maxPriorityFeePerGas: ne, t
4320ype: fe, ...ae } = I.transaction;
4321    return Po.set(e.uid, !0), {
4322      ...n,
4323      ...T ? { from: T } : {},
4324      ...fe && !n.type ? { type: fe } : {},
4325      ...typeof E < "u" ? { chainId: E } : {},
4326      ...typeof O < "u" ? { gas: O } : {},
4327      ...typeof U < "u" ? { gasPrice: U } : {},
4328      ...typeof M < "u" ? { nonce: M } : {},
4329      ...typeof L < "u" && n.type !== "legacy" && n.type !== "eip2930" ? { maxFeePerBlobGas: L } : {},
4330      ...typeof re < "u" && n.type !== "legacy" && n.type !== "eip2930" ? { maxFeePerGas: re } : {},
4331      ...typeof ne < "u" && n.type !== "legacy" && n.type !== "eip2930" ? { maxPriorityFeePerGas: ne } : {},
4332      ..."nonceKey" in ae && typeof ae.nonceKey < "u" ? { nonceKey: ae.nonceKey } : {},
4333      ..."keyAuthorization" in ae && typeof ae.keyAuthorization < "u" && ae.keyAuthorization !== null && !("keyAuthorization" in n) ? { keyAuthorization: ae.keyAuthorization } : {},
4334      ..."feePayerSignature" in ae && typeof ae.feePayerSignature < "u" && ae.feePayerSignature !== null ? { feePayerSignature: ae.feePayerSignature } : {},
4335      ..."feeToken" in ae && typeof ae.feeToken < "u" && ae.feeToken !== null && !("feeToken" in n) ? { feeToken: ae.feeToken } : {},
4336      ...I.capabilities ? { _capabilities: I.capabilities } : {}
4337    };
4338  }).catch((I) => {
4339    const E = I;
4340    if (E.name !== "TransactionExecutionError")
4341      return n;
4342    if (E.walk?.((U) => U.name === "ExecutionRevertedError"))
4343      throw I;
4344    return E.walk?.((U) => {
4345      const M = U;
4346      return M.name === "MethodNotFoundRpcError" || M.name === "MethodNotSupportedRpcError" || M.message?.includes("eth_fillTransaction is not available");
4347    }) && Po.set(e.uid, !1), n;
4348  }) : n;
4349  f ??= m.nonce, n = {
4350    ...m,
4351    ...l ? { from: l?.address } : {},
4352    ...typeof f < "u" ? { nonce: f } : {}
4353  };
4354  const { blobs: y, gas: b, kzg: C, type: _ } = n;
4355  a?.fn && a.runAt?.includes("beforeFillParameters") && (n = await a.fn({ ...n, chain: s }, {
4356    phase: "beforeFillParameters"
4357  }));
4358  let R;
4359  async function N() {
4360    return R || (R = await ke(e, Lr, "getBlock")({ blockTag: "latest" }), R);
4361  }
4362  if (o.includes("nonce") && typeof f > "u" && l && !i && (n.nonce = await ke(e, fm, "getTransactionCount")({
4363    address: l.address,
4364    blockTag: "pending"
4365  })), (o.includes("blobVersionedHashes") || o.includes("sidecars")) && y && C) {
4366    const I = Cd({ blobs: y, kzg: C });
4367    if (o.includes("blobVersionedHashes")) {
4368      const E = Nm({
4369        commitments: I,
4370        to: "hex"
4371      });
4372      n.blobVersionedHashes = E;
4373    }
4374    if (o.includes("sidecars")) {
4375      const E = Ed({ blobs: y, commitments: I, kzg: C }), T = xm({
4376        blobs: y,
4377        commitments: I,
4378        proofs: E,
4379        to: "hex"
4380      });
4381      n.sidecars = T;
4382    }
4383  }
4384  if (o.includes("chainId") && (n.chainId = await c()), (o.includes("fees") || o.includes("type")) && typeof _ > "u")
4385    try {
4386      n.type = Om(n);
4387    } catch {
4388      let I = ou.get(e.uid);
4389      typeof I > "u" && (I = typeof (await N())?.baseFeePerGas == "bigint", ou.set(e.uid, I)), n.type = I ? "eip1559" : "legacy";
4390    }
4391  if (o.includes("fees"))
4392    if (n.type !== "legacy" && n.type !== "eip2930") {
4393      if (typeof n.maxFeePerGas > "u" || typeof n.maxPriorityFeePerGas > "u") {
4394        const I = await N(), { maxFeePerGas: E, maxPriorityFeePerGas: T } = await Ea(e, {
4395          block: I,
4396          chain: s,
4397          request: n
4398        });
4399        if (typeof n.maxPriorityFeePerGas > "u" && n.maxFeePerGas && n.maxFeePerGas < T)
4400          throw new lm({
4401            maxPriorityFeePerGas: T
4402          });
4403        n.maxPriorityFeePerGas = T, n.maxFeePerGas = E;
4404      }
4405    } else {
4406      if (typeof n.maxFeePerGas < "u" || typeof n.maxPriorityFeePerGas < "u")
4407        throw new gc();
4408      if (typeof n.gasPrice > "u") {
4409        const I = await N(), { gasPrice: E } = await Ea(e, {
4410          block: I,
4411          chain: s,
4412          request: n,
4413          type: "legacy"
4414        });
4415        n.gasPrice = E;
4416      }
4417    }
4418  return o.includes("gas") && typeof b > "u" && (n.gas = await ke(e, Rd, "estimateGas")({
4419    ...n,
4420    account: l,
4421    prepare: l?.type === "local" ? [] : ["blobVersionedHashes"]
4422  })), a?.fn && a.runAt?.includes("afterFillParameters") && (n = await a.fn({ ...n, chain: s }, {
4423    phase: "afterFillParameters"
4424  })), Ys(n), delete n.parameters, n;
4425}
4426async function Rd(e, t) {
4427  const { account: n = e.account, prepare: r = !0 } = t, s = n ? vt(n) : void 0, i = (() => {
4428    if (Array.isArray(r))
4429      return r;
4430    if (s?.type !== "local")
4431      return ["blobVersionedHashes"];
4432  })();
4433  try {
4434    const o = await (async () => {
4435      if (t.to)
4436        return t.to;
4437      if (t.authorizationList && t.authorizationList.length > 0)
4438        return await fd({
4439          authorization: t.authorizationList[0]
4440        }).catch(() => {
4441          throw new F("`to` is required. Could not infer from `authorizationList`");
4442        });
4443    })(), { accessList: a, authorizationList: u, blobs: c, blobVersionedHashes: l, blockNumber: f, blockTag: p, data: m, gas: y, gasPrice: b, maxFeePerBlobGas: C, maxFeePerGas: _, maxPriorityFeePerGas: R, nonce: N, value: I, stateOverride: E, ...T } = r ? await wc(e, {
4444      ...t,
4445      parameters: i,
4446      to: o
4447    }) : t;
4448    if (y && t.gas !== y)
4449      return y;
4450    const U = (typeof f == "bigint" ? be(f) : void 0) || p, M = hd(E);
4451    Ys(t);
4452    const L = e.chain?.formatters?.transactionRequest?.format, ne = (L || Ks)({
4453      // Pick out extra data that might exist on the chain's transaction request type.
4454      ...po(T, { format: L }),
4455      account: s,
4456      accessList: a,
4457      authorizationList: u,
4458      blobs: c,
4459      blobVersionedHashes: l,
4460      data: m,
4461      gasPrice: b,
4462      maxFeePerBlobGas: C,
4463      maxFeePerGas: _,
4464      maxPriorityFeePerGas: R,
4465      nonce: N,
4466      to: o,
4467      value: I
4468    }, "estimateGas");
4469    return BigInt(await e.request({
4470      method: "eth_estimateGas",
4471      params: M ? [
4472        ne,
4473        U ?? e.experimental_blockTag ?? "latest",
4474        M
4475      ] : U ? [ne, U] : [ne]
4476    }));
4477  } catch (o) {
4478    throw im(o, {
4479      ...t,
4480      account: s,
4481      chain: e.chain
4482    });
4483  }
4484}
4485function km(e, t) {
4486  if (!Gt(e, { strict: !1 }))
4487    throw new sr({ address: e });
4488  if (!Gt(t, { strict: !1 }))
4489    throw new sr({ address: t });
4490  return e.toLowerCase() === t.toLowerCase();
4491}
4492function Cc(e, { args: t, eventName: n } = {}) {
4493  return {
4494    ...e,
4495    blockHash: e.blockHash ? e.blockHash : null,
4496    blockNumber: e.blockNumber ? BigInt(e.blockNumber) : null,
4497    blockTimestamp: e.blockTimestamp ? BigInt(e.blockTimestamp) : e.blockTimestamp === null ? null : void 0,
4498    logIndex: e.logIndex ? Number(e.logIndex) : null,
4499    transactionHash: e.transactionHash ? e.transactionHash : null,
4500    transactionIndex: e.transactionIndex ? Number(e.transactionIndex) : null,
4501    ...n ? { args: t, eventName: n } : {}
4502  };
4503}
4504const au = "/docs/contract/decodeEventLog";
4505function cu(e) {
4506  const { abi: t, data: n, strict: r, topics: s } = e, i = r ?? !0, [o, ...a] = s;
4507  if (!o)
4508    throw new ap({ docsPath: au });
4509  const u = t.find((_) => _.type === "event" && o === sc(Mn(_)));
4510  if (!(u && "name" in u) || u.type !== "event")
4511    throw new cp(o, { docsPath: au });
4512  const { name: c, inputs: l } = u, f = l?.some((_) => !("name" in _ && _.name)), p = f ? [] : {}, m = l.map((_, R) => [_, R]).filter(([_]) => "indexed" in _ && _.indexed), y = [];
4513  for (let _ = 0; _ < m.length; _++) {
4514    const [R, N] = m[_], I = a[_];
4515    if (!I) {
4516      if (i)
4517        throw new dp({
4518          abiItem: u,
4519          param: R
4520        });
4521      y.push([R, N]);
4522      continue;
4523    }
4524    p[f ? N : R.name || N] = Um({
4525      param: R,
4526      value: I
4527    });
4528  }
4529  const b = l.filter((_) => !("indexed" in _ && _.indexed)), C = i ? b : [...y.map(([_]) => _), ...b];
4530  if (C.length > 0) {
4531    if (n && n !== "0x")
4532      try {
4533        const _ = fo(C, n);
4534        if (_) {
4535          let R = 0;
4536          if (!i)
4537            for (const [N, I] of y)
4538              p[f ? I : N.name || I] = _[R++];
4539          if (f)
4540            for (let N = 0; N < l.length; N++)
4541              p[N] === void 0 && R < _.length && (p[N] = _[R++]);
4542          else
4543            for (let N = 0; N < b.length; N++)
4544              p[b[N].name] = _[R++];
4545        }
4546      } catch (_) {
4547        if (i)
4548          throw _ instanceof Dl || _ instanceof sd ? new $c({
4549            abiItem: u,
4550            data: n,
4551            params: C,
4552            size: Ze(n)
4553          }) : _;
4554      }
4555    else if (i)
4556      throw new $c({
4557        abiItem: u,
4558        data: "0x",
4559        params: C,
4560        size: 0
4561      });
4562  }
4563  return {
4564    eventName: c,
4565    args: Object.values(p).length > 0 ? p : void 0
4566  };
4567}
4568function Um({ param: e, value: t }) {
4569  return e.type === "string" || e.type === "bytes" || e.type === "tuple" || e.type.match(/^(.*)\[(\d+)?\]$/) ? t : (fo([e], t) || [])[0];
4570}
4571function Mm(e) {
4572  const { abi: t, args: n, logs: r, strict: s = !0 } = e, i = (() => {
4573    if (e.eventName)
4574      return Array.isArray(e.eventName) ? e.eventName : [e.eventName];
4575  })(), o = t.filter((a) => a.type === "event").map((a) => ({
4576    abi: a,
4577    selector: sc(a)
4578  }));
4579  return r.map((a) => {
4580    const u = typeof a.blockNumber == "string" ? Cc(a) : a, c = o.filter((p) => u.topics[0] === p.selector);
4581    if (c.length === 0)
4582      return null;
4583    let l, f;
4584    for (const p of c)
4585      try {
4586        l = cu({
4587          ...u,
4588          abi: [p.abi],
4589          strict: !0
4590        }), f = p;
4591        break;
4592      } catch {
4593      }
4594    if (!l && !s) {
4595      f = c[0];
4596      try {
4597        l = cu({
4598          data: u.data,
4599          topics: u.topics,
4600          abi: [f.abi],
4601          strict: !1
4602        });
4603      } catch {
4604        const p = f.abi.inputs?.some((m) => !("name" in m && m.name));
4605        return {
4606          ...u,
4607          args: p ? [] : {},
4608          eventName: f.abi.name
4609        };
4610      }
4611    }
4612    return !l || !f || i && !i.includes(l.eventName) || !Lm({
4613      args: l.args,
4614      inputs: f.abi.inputs,
4615      matchArgs: n
4616    }) ? null : { ...l, ...u };
4617  }).filter(Boolean);
4618}
4619function Lm(e) {
4620  const { args: t, inputs: n, matchArgs: r } = e;
4621  if (!r)
4622    return !0;
4623  if (!t)
4624    return !1;
4625  function s(i, o, a) {
4626    try {
4627      return i.type === "address" ? km(o, a) : i.type === "string" || i.type === "bytes" ? Hs(co(o)
4627) === a : o === a;
4628    } catch {
4629      return !1;
4630    }
4631  }
4632  return Array.isArray(t) && Array.isArray(r) ? r.every((i, o) => {
4633    if (i == null)
4634      return !0;
4635    const a = n[o];
4636    return a ? (Array.isArray(i) ? i : [i]).some((c) => s(a, c, t[o])) : !1;
4637  }) : typeof t == "object" && !Array.isArray(t) && typeof r == "object" && !Array.isArray(r) ? Object.entries(r).every(([i, o]) => {
4638    if (o == null)
4639      return !0;
4640    const a = n.find((c) => c.name === i);
4641    return a ? (Array.isArray(o) ? o : [o]).some((c) => s(a, c, t[i])) : !1;
4642  }) : !1;
4643}
4644const ko = "/docs/contract/decodeFunctionResult";
4645function xd(e) {
4646  const { abi: t, args: n, functionName: r, data: s } = e;
4647  let i = t[0];
4648  if (r) {
4649    const a = uc({ abi: t, args: n, name: r });
4650    if (!a)
4651      throw new Ui(r, { docsPath: ko });
4652    i = a;
4653  }
4654  if (i.type !== "function")
4655    throw new Ui(void 0, { docsPath: ko });
4656  if (!i.outputs)
4657    throw new up(i.name, { docsPath: ko });
4658  const o = fo(i.outputs, s);
4659  if (o && o.length > 1)
4660    return o;
4661  if (o && o.length === 1)
4662    return o[0];
4663}
4664const Ec = /* @__PURE__ */ BigInt(0), Aa = /* @__PURE__ */ BigInt(1);
4665function Ac(e) {
4666  return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
4667}
4668function vc(e) {
4669  if (!Ac(e))
4670    throw new Error("Uint8Array expected");
4671}
4672function Jv(e, t) {
4673  if (typeof t != "boolean")
4674    throw new Error(e + " boolean expected, got " + t);
4675}
4676function Xv(e) {
4677  const t = e.toString(16);
4678  return t.length & 1 ? "0" + t : t;
4679}
4680function Od(e) {
4681  if (typeof e != "string")
4682    throw new Error("hex string expected, got " + typeof e);
4683  return e === "" ? Ec : BigInt("0x" + e);
4684}
4685const Pd = (
4686  // @ts-ignore
4687  typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function"
4688), Bm = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
4689function kd(e) {
4690  if (vc(e), Pd)
4691    return e.toHex();
4692  let t = "";
4693  for (let n = 0; n < e.length; n++)
4694    t += Bm[e[n]];
4695  return t;
4696}
4697const Qt = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
4698function uu(e) {
4699  if (e >= Qt._0 && e <= Qt._9)
4700    return e - Qt._0;
4701  if (e >= Qt.A && e <= Qt.F)
4702    return e - (Qt.A - 10);
4703  if (e >= Qt.a && e <= Qt.f)
4704    return e - (Qt.a - 10);
4705}
4706function Ud(e) {
4707  if (typeof e != "string")
4708    throw new Error("hex string expected, got " + typeof e);
4709  if (Pd)
4710    return Uint8Array.fromHex(e);
4711  const t = e.length, n = t / 2;
4712  if (t % 2)
4713    throw new Error("hex string expected, got unpadded hex of length " + t);
4714  const r = new Uint8Array(n);
4715  for (let s = 0, i = 0; s < n; s++, i += 2) {
4716    const o = uu(e.charCodeAt(i)), a = uu(e.charCodeAt(i + 1));
4717    if (o === void 0 || a === void 0) {
4718      const u = e[i] + e[i + 1];
4719      throw new Error('hex string expected, got non-hex character "' + u + '" at index ' + i);
4720    }
4721    r[s] = o * 16 + a;
4722  }
4723  return r;
4724}
4725function e_(e) {
4726  return Od(kd(e));
4727}
4728function t_(e) {
4729  return vc(e), Od(kd(Uint8Array.from(e).reverse()));
4730}
4731function Dm(e, t) {
4732  return Ud(e.toString(16).padStart(t * 2, "0"));
4733}
4734function n_(e, t) {
4735  return Dm(e, t).reverse();
4736}
4737function r_(e, t, n) {
4738  let r;
4739  if (typeof t == "string")
4740    try {
4741      r = Ud(t);
4742    } catch (i) {
4743      throw new Error(e + " must be hex string or Uint8Array, cause: " + i);
4744    }
4745  else if (Ac(t))
4746    r = Uint8Array.from(t);
4747  else
4748    throw new Error(e + " must be hex string or Uint8Array");
4749  const s = r.length;
4750  if (typeof n == "number" && s !== n)
4751    throw new Error(e + " of length " + n + " expected, got " + s);
4752  return r;
4753}
4754function Fm(...e) {
4755  let t = 0;
4756  for (let r = 0; r < e.length; r++) {
4757    const s = e[r];
4758    vc(s), t += s.length;
4759  }
4760  const n = new Uint8Array(t);
4761  for (let r = 0, s = 0; r < e.length; r++) {
4762    const i = e[r];
4763    n.set(i, s), s += i.length;
4764  }
4765  return n;
4766}
4767function jm(e, t) {
4768  if (e.length !== t.length)
4769    return !1;
4770  let n = 0;
4771  for (let r = 0; r < e.length; r++)
4772    n |= e[r] ^ t[r];
4773  return n === 0;
4774}
4775const Uo = (e) => typeof e == "bigint" && Ec <= e;
4776function Wm(e, t, n) {
4777  return Uo(e) && Uo(t) && Uo(n) && t <= e && e < n;
4778}
4779function s_(e, t, n, r) {
4780  if (!Wm(t, n, r))
4781    throw new Error("expected valid " + e + ": " + n + " <= n < " + r + ", got " + t);
4782}
4783function i_(e) {
4784  let t;
4785  for (t = 0; e > Ec; e >>= Aa, t += 1)
4786    ;
4787  return t;
4788}
4789const o_ = (e) => (Aa << BigInt(e)) - Aa, Mo = (e) => new Uint8Array(e), lu = (e) => Uint8Array.from(e);
4790function a_(e, t, n) {
4791  if (typeof e != "number" || e < 2)
4792    throw new Error("hashLen must be a number");
4793  if (typeof t != "number" || t < 2)
4794    throw new Error("qByteLen must be a number");
4795  if (typeof n != "function")
4796    throw new Error("hmacFn must be a function");
4797  let r = Mo(e), s = Mo(e), i = 0;
4798  const o = () => {
4799    r.fill(1), s.fill(0), i = 0;
4800  }, a = (...f) => n(s, r, ...f), u = (f = Mo(0)) => {
4801    s = a(lu([0]), f), r = a(), f.length !== 0 && (s = a(lu([1]), f), r = a());
4802  }, c = () => {
4803    if (i++ >= 1e3)
4804      throw new Error("drbg: tried 1000 values");
4805    let f = 0;
4806    const p = [];
4807    for (; f < t; ) {
4808      r = a();
4809      const m = r.slice();
4810      p.push(m), f += r.length;
4811    }
4812    return Fm(...p);
4813  };
4814  return (f, p) => {
4815    o(), u(f);
4816    let m;
4817    for (; !(m = p(c())); )
4818      u();
4819    return o(), m;
4820  };
4821}
4822const $m = {
4823  bigint: (e) => typeof e == "bigint",
4824  function: (e) => typeof e == "function",
4825  boolean: (e) => typeof e == "boolean",
4826  string: (e) => typeof e == "string",
4827  stringOrUint8Array: (e) => typeof e == "string" || Ac(e),
4828  isSafeInteger: (e) => Number.isSafeInteger(e),
4829  array: (e) => Array.isArray(e),
4830  field: (e, t) => t.Fp.isValid(e),
4831  hash: (e) => typeof e == "function" && Number.isSafeInteger(e.outputLen)
4832};
4833function c_(e, t, n = {}) {
4834  const r = (s, i, o) => {
4835    const a = $m[i];
4836    if (typeof a != "function")
4837      throw new Error("invalid validator function");
4838    const u = e[s];
4839    if (!(o && u === void 0) && !a(u, e))
4840      throw new Error("param " + String(s) + " is invalid. Expected " + i + ", got " + u);
4841  };
4842  for (const [s, i] of Object.entries(t))
4843    r(s, i, !1);
4844  for (const [s, i] of Object.entries(n))
4845    r(s, i, !0);
4846  return e;
4847}
4848function u_(e) {
4849  const t = /* @__PURE__ */ new WeakMap();
4850  return (n, ...r) => {
4851    const s = t.get(n);
4852    if (s !== void 0)
4853      return s;
4854    const i = e(n, ...r);
4855    return t.set(n, i), i;
4856  };
4857}
4858const Hm = "0.1.1";
4859function qm() {
4860  return Hm;
4861}
4862class De extends Error {
4863  static setStaticOptions(t) {
4864    De.prototype.docsOrigin = t.docsOrigin, De.prototype.showVersion = t.showVersion, De.prototype.version = t.version;
4865  }
4866  constructor(t, n = {}) {
4867    const r = (() => {
4868      if (n.cause instanceof De) {
4869        if (n.cause.details)
4870          return n.cause.details;
4871        if (n.cause.shortMessage)
4872          return n.cause.shortMessage;
4873      }
4874      return n.cause && "details" in n.cause && typeof n.cause.details == "string" ? n.cause.details : n.cause?.message ? n.cause.message : n.details;
4875    })(), s = n.cause instanceof De && n.cause.docsPath || n.docsPath, i = n.docsOrigin ?? De.prototype.docsOrigin, o = `${i}${s ?? ""}`, a = !!(n.version ?? De.prototype.showVersion), u = n.version ?? De.prototype.version, c = [
4876      t || "An error occurred.",
4877      ...n.metaMessages ? ["", ...n.metaMessages] : [],
4878      ...r || s || a ? [
4879        "",
4880        r ? `Details: ${r}` : void 0,
4881        s ? `See: ${o}` : void 0,
4882        a ? `Version: ${u}` : void 0
4883      ] : []
4884    ].filter((l) => typeof l == "string").join(`
4885`);
4886    super(c, n.cause ? { cause: n.cause } : void 0), Object.defineProperty(this, "details", {
4887      enumerable: !0,
4888      configurable: !0,
4889      writable: !0,
4890      value: void 0
4891    }), Object.defineProperty(this, "docs", {
4892      enumerable: !0,
4893      configurable: !0,
4894      writable: !0,
4895      value: void 0
4896    }), Object.defineProperty(this, "docsOrigin", {
4897      enumerable: !0,
4898      configurable: !0,
4899      writable: !0,
4900      value: void 0
4901    }), Object.defineProperty(this, "docsPath", {
4902      enumerable: !0,
4903      configurable: !0,
4904      writable: !0,
4905      value: void 0
4906    }), Object.defineProperty(this, "shortMessage", {
4907      enumerable: !0,
4908      configurable: !0,
4909      writable: !0,
4910      value: void 0
4911    }), Object.defineProperty(this, "showVersion", {
4912      enumerable: !0,
4913      configurable: !0,
4914      writable: !0,
4915      value: void 0
4916    }), Object.defineProperty(this, "version", {
4917      enumerable: !0,
4918      configurable: !0,
4919      writable: !0,
4920      value: void 0
4921    }), Object.defineProperty(this, "cause", {
4922      enumerable: !0,
4923      configurable: !0,
4924      writable: !0,
4925      value: void 0
4926    }), Object.defineProperty(this, "name", {
4927      enumerable: !0,
4928      configurable: !0,
4929      writable: !0,
4930      value: "BaseError"
4931    }), this.cause = n.cause, this.details = r, this.docs = o, this.docsOrigin = i, this.docsPath = s, this.shortMessage = t, this.showVersion = a, this.version = u;
4932  }
4933  walk(t) {
4934    return Md(this, t);
4935  }
4936}
4937Object.defineProperty(De, "defaultStaticOptions", {
4938  enumerable: !0,
4939  configurable: !0,
4940  writable: !0,
4941  value: {
4942    docsOrigin: "https://oxlib.sh",
4943    showVersion: !1,
4944    version: `ox@${qm()}`
4945  }
4946});
4947De.setStaticOptions(De.defaultStaticOptions);
4948function Md(e, t) {
4949  return t?.(e) ? e : e && typeof e == "object" && "cause" in e && e.cause ? Md(e.cause, t) : t ? null : e;
4950}
4951function Hr(e, t) {
4952  if (fu(e) > t)
4953    throw new sg({
4954      givenSize: fu(e),
4955      maxSize: t
4956    });
4957}
4958const Jt = {
4959  zero: 48,
4960  nine: 57,
4961  A: 65,
4962  F: 70,
4963  a: 97,
4964  f: 102
4965};
4966function du(e) {
4967  if (e >= Jt.zero && e <= Jt.nine)
4968    return e - Jt.zero;
4969  if (e >= Jt.A && e <= Jt.F)
4970    return e - (Jt.A - 10);
4971  if (e >= Jt.a && e <= Jt.f)
4972    return e - (Jt.a - 10);
4973}
4974function Gm(e, t = {}) {
4975  const { dir: n, size: r = 32 } = t;
4976  if (r === 0)
4977    return e;
4978  if (e.length > r)
4979    throw new ig({
4980      size: e.length,
4981      targetSize: r,
4982      type: "Bytes"
4983    });
4984  const s = new Uint8Array(r);
4985  for (let i = 0; i < r; i++) {
4986    const o = n === "right";
4987    s[o ? i : r - i - 1] = e[o ? i : e.length - i - 1];
4988  }
4989  return s;
4990}
4991function Ld(e, t = {}) {
4992  const { dir: n = "left" } = t;
4993  let r = e, s = 0;
4994  for (let i = 0; i < r.length - 1 && r[n === "left" ? i : r.length - i - 1].toString() === "0"; i++)
4995    s++;
4996  return r = n === "left" ? r.slice(s) : r.slice(0, r.length - s), r;
4997}
4998function yo(e, t) {
4999  if (Dr(e) > t)
5000    throw new dg({
5001      givenSize: Dr(e),
5002      maxSize: t
5003    });
5004}
5005function zm(e, t) {
5006  if (typeof t == "number" && t > 0 && t > Dr(e) - 1)
5007    throw new qd({
5008      offset: t,
5009      position: "start",
5010      size: Dr(e)
5011    });
5012}
5013function Vm(e, t, n) {
5014  if (typeof t == "number" && typeof n == "number" && Dr(e) !== n - t)
5015    throw new qd({
5016      offset: n,
5017      position: "end",
5018      size: Dr(e)
5019    });
5020}
5021function Bd(e, t = {}) {
5022  const { dir: n, size: r = 32 } = t;
5023  if (r === 0)
5024    return e;
5025  const s = e.replace("0x", "");
5026  if (s.length > r * 2)
5027    throw new fg({
5028      size: Math.ceil(s.length / 2),
5029      targetSize: r,
5030      type: "Hex"
5031    });
5032  return `0x${s[n === "right" ? "padEnd" : "padStart"](r * 2, "0")}`;
5033}
5034function Km(e, t = {}) {
5035  const { dir: n = "left" } = t;
5036  let r = e.replace("0x", ""), s = 0;
5037  for (let i = 0; i < r.length - 1 && r[n === "left" ? i : r.length - i - 1].toString() === "0"; i++)
5038    s++;
5039  return r = n === "left" ? r.slice(s) : r.slice(0, r.length - s), r === "0" ? "0x" : n === "right" && r.length % 2 === 1 ? `0x${r}0` : `0x${r}`;
5040}
5041const Ym = "#__bigint";
5042function Dd(e, t, n) {
5043  return JSON.stringify(e, (r, s) => typeof s == "bigint" ? s.toString() + Ym : s, n);
5044}
5045const Zm = /* @__PURE__ */ new TextDecoder(), Qm = /* @__PURE__ */ new TextEncoder();
5046function Jm(e) {
5047  if (!(e instanceof Uint8Array)) {
5048    if (!e)
5049      throw new ii(e);
5050    if (typeof e != "object")
5051      throw new ii(e);
5052    if (!("BYTES_PER_ELEMENT" in e))
5053      throw new ii(e);
5054    if (e.BYTES_PER_ELEMENT !== 1 || e.constructor.name !== "Uint8Array")
5055      throw new ii(e);
5056  }
5057}
5058function l_(...e) {
5059  let t = 0;
5060  for (const r of e)
5061    t += r.length;
5062  const n = new Uint8Array(t);
5063  for (let r = 0, s = 0; r < e.length; r++) {
5064    const i = e[r];
5065    n.set(i, s), s += i.length;
5066  }
5067  return n;
5068}
5069function d_(e) {
5070  return e instanceof Uint8Array ? e : typeof e == "string" ? Fd(e) : Xm(e);
5071}
5072function Xm(e) {
5073  return e instanceof Uint8Array ? e : new Uint8Array(e);
5074}
5075function Fd(e, t = {}) {
5076  const { size: n } = t;
5077  let r = e;
5078  n && (yo(e, n), r = $d(e, n));
5079  let s = r.slice(2);
5080  s.length % 2 && (s = `0${s}`);
5081  const i = s.length / 2, o = new Uint8Array(i);
5082  for (let a = 0, u = 0; a < i; a++) {
5083    const c = du(s.charCodeAt(u++)), l = du(s.charCodeAt(u++));
5084    if (c === void 0 || l === void 0)
5085      throw new De(`Invalid byte sequence ("${s[u - 2]}${s[u - 1]}" in "${s}").`);
5086    o[a] = c << 4 | l;
5087  }
5088  return o;
5089}
5090function f_(e, t = {}) {
5091  const { size: n } = t, r = Qm.encode(e);
5092  return typeof n == "number" ? (Hr(r, n), eg(r, n)) : r;
5093}
5094function h_(e, t) {
5095  return jm(e, t);
5096}
5097function eg(e, t) {
5098  return Gm(e, { dir: "right", size: t });
5099}
5100function tg(e) {
5101  return crypto.getRandomValues(new Uint8Array(e));
5102}
5103function fu(e) {
5104  return e.length;
5105}
5106function p_(e, t, n, r = {}) {
5107  const { strict: s } = r;
5108  return e.slice(t, n);
5109}
5110function m_(e, t = {}) {
5111  const { size: n } = t;
5112  typeof n < "u" && Hr(e, n);
5113  const r = Br(e, t);
5114  return Hd(r, t);
5115}
5116function g_(e, t = {}) {
5117  const { size: n } = t;
5118  let r = e;
5119  if (typeof n < "u" && (Hr(r, n), r = ng(r)), r.length > 1 || r[0] > 1)
5120    throw new rg(r);
5121  return !!r[0];
5122}
5123function y_(e, t = {}) {
5124  const { size: n } = t;
5125  typeof n < "u" && Hr(e, n);
5126  const r = Br(e, t);
5127  return ug(r, t);
5128}
5129function b_(e, t = {}) {
5130  const { size: n } = t;
5131  let r = e;
5132  return typeof n < "u" && (Hr(r, n), r = jd(r)), Zm.decode(r);
5133}
5134function ng(e) {
5135  return Ld(e, { dir: "left" });
5136}
5137function jd(e) {
5138  return Ld(e, { dir: "right" });
5139}
5140function w_(e) {
5141  try {
5142    return Jm(e), !0;
5143  } catch {
5144    return !1;
5145  }
5146}
5147class rg extends De {
5148  constructor(t) {
5149    super(`Bytes value \`${t}\` is not a valid boolean.`, {
5150      metaMessages: [
5151        "The bytes array must contain a single byte of either a `0` or `1` value."
5152      ]
5153    }), Object.defineProperty(this, "name", {
5154      enumerable: !0,
5155      configurable: !0,
5156      writable: !0,
5157      value: "Bytes.InvalidBytesBooleanError"
5158    });
5159  }
5160}
5161class ii extends De {
5162  constructor(t) {
5163    super(`Value \`${typeof t == "object" ? Dd(t) : t}\` of type \`${typeof t}\` is an invalid Bytes value.`, {
5164      metaMessages: ["Bytes values must be of type `Bytes`."]
5165    }), Object.defineProperty(this, "name", {
5166      enumerable: !0,
5167      configurable: !0,
5168      writable: !0,
5169      value: "Bytes.InvalidBytesTypeError"
5170    });
5171  }
5172}
5173let sg = class extends De {
5174  constructor({ givenSize: t, maxSize: n }) {
5175    super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`), Object.defineProperty(this, "name", {
5176      enumerable: !0,
5177      configurable: !0,
5178      writable: !0,
5179      value: "Bytes.SizeOverflowError"
5180    });
5181  }
5182}, ig = class extends De {
5183  constructor({ size: t, targetSize: n, type: r }) {
5184    super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`), Object.defineProperty(this, "name", {
5185      enumerable: !0,
5186      configurable: !0,
5187      writable: !0,
5188      value: "Bytes.SizeExceedsPaddingSizeError"
5189    });
5190  }
5191};
5192const og = /* @__PURE__ */ new TextEncoder(), ag = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
5193function cg(e, t = {}) {
5194  const { strict: n = !1 } = t;
5195  if (!e)
5196    throw new hu(e);
5197  if (typeof e != "string")
5198    throw new hu(e);
5199  if (n && !/^0x[0-9a-fA-F]*$/.test(e))
5200    throw new pu(e);
5201  if (!e.startsWith("0x"))
5202    throw new pu(e);
5203}
5204function A_(...e) {
5205  return `0x${e.reduce((t, n) => t + n.replace("0x", ""), "")}`;
5206}
5207function v_(e) {
5208  return e instanceof Uint8Array ? Br(e) : Array.isArray(e) ? Br(new Uint8Array(e)) : e;
5209}
5210function __(e, t = {}) {
5211  const n = `0x${Number(e)}`;
5212  return typeof t.size == "number" ? (yo(n, t.size), Wd(n, t.size)) : n;
5213}
5214function Br(e, t = {}) {
5215  let n = "";
5216  for (let s = 0; s < e.length; s++)
5217    n += ag[e[s]];
5218  const r = `0x${n}`;
5219  return typeof t.size == "number" ? (yo(r, t.size), $d(r, t.size)) : r;
5220}
5221function an(e, t = {}) {
5222  const { signed: n, size: r } = t, s = BigInt(e);
5223  let i;
5224  r ? n ? i = (1n << BigInt(r) * 8n - 1n) - 1n : i = 2n ** (BigInt(r) * 8n) - 1n : typeof e == "number" && (i = BigInt(Number.MAX_SAFE_INTEGER));
5225  const o = typeof i == "bigint" && n ? -i - 1n : 0;
5226  if (i && s > i || s < o) {
5227    const c = typeof e == "bigint" ? "n" : "";
5228    throw new lg({
5229      max: i ? `${i}${c}` : void 0,
5230      min: `${o}${c}`,
5231      signed: n,
5232      size: r,
5233      value: `${e}${c}`
5234    });
5235  }
5236  const u = `0x${(n && s < 0 ? BigInt.asUintN(r * 8, BigInt(s)) : s).toString(16)}`;
5237  return r ? Wd(u, r) : u;
5238}
5239function N_(e, t = {}) {
5240  return Br(og.encode(e), t);
5241}
5242function Wd(e, t) {
5243  return Bd(e, { dir: "left", size: t });
5244}
5245function $d(e, t) {
5246  return Bd(e, { dir: "right", size: t });
5247}
5248function I_(e) {
5249  return Br(tg(e));
5250}
5251function T_(e, t, n, r = {}) {
5252  const { strict: s } = r;
5253  zm(e, t);
5254  const i = `0x${e.replace("0x", "").slice((t ?? 0) * 2, (n ?? e.length) * 2)}`;
5255  return s && Vm(i, t, n), i;
5256}
5257function Dr(e) {
5258  return Math.ceil((e.length - 2) / 2);
5259}
5260function S_(e) {
5261  return Km(e, { dir: "left" });
5262}
5263function Hd(e, t = {}) {
5264  const { signed: n } = t;
5265  t.size && yo(e, t.size);
5266  const r = BigInt(e);
5267  if (!n)
5268    return r;
5269  const s = (e.length - 2) / 2, i = (1n << BigInt(s) * 8n) - 1n, o = i >> 1n;
5270  return r <= o ? r : r - i - 1n;
5271}
5272function ug(e, t = {}) {
5273  const { signed: n, size: r } = t;
5274  return Number(!n && !r ? e : Hd(e, t));
5275}
5276function R_(e, t = {}) {
5277  const { size: n } = t;
5278  let r = Fd(e);
5279  return n && (Hr(r, n), r = jd(r)), new TextDecoder().decode(r);
5280}
5281function x_(e, t = {}) {
5282  const { strict: n = !1 } = t;
5283  try {
5284    return cg(e, { strict: n }), !0;
5285  } catch {
5286    return !1;
5287  }
5288}
5289class lg extends De {
5290  constructor({ max: t, min: n, signed: r, size: s, value: i }) {
5291    super(`Number \`${i}\` is not in safe${s ? ` ${s * 8}-bit` : ""}${r ? " signed" : " unsigned"} integer range ${t ? `(\`${n}\` to \`${t}\`)` : `(above \`${n}\`)`}`), Object.defineProperty(this, "name", {
5292      enumerable: !0,
5293      configurable: !0,
5294      writable: !0,
5295      value: "Hex.IntegerOutOfRangeError"
5296    });
5297  }
5298}
5299class hu extends De {
5300  constructor(t) {
5301    super(`Value \`${typeof t == "object" ? Dd(t) : t}\` of type \`${typeof t}
5301\` is an invalid hex type.`, {
5302      metaMessages: ['Hex types must be represented as `"0x${string}"`.']
5303    }), Object.defineProperty(this, "name", {
5304      enumerable: !0,
5305      configurable: !0,
5306      writable: !0,
5307      value: "Hex.InvalidHexTypeError"
5308    });
5309  }
5310}
5311class pu extends De {
5312  constructor(t) {
5313    super(`Value \`${t}\` is an invalid hex value.`, {
5314      metaMessages: [
5315        'Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).'
5316      ]
5317    }), Object.defineProperty(this, "name", {
5318      enumerable: !0,
5319      configurable: !0,
5320      writable: !0,
5321      value: "Hex.InvalidHexValueError"
5322    });
5323  }
5324}
5325class O_ extends De {
5326  constructor(t) {
5327    super(`Hex value \`"${t}"\` is an odd length (${t.length - 2} nibbles).`, {
5328      metaMessages: ["It must be an even length."]
5329    }), Object.defineProperty(this, "name", {
5330      enumerable: !0,
5331      configurable: !0,
5332      writable: !0,
5333      value: "Hex.InvalidLengthError"
5334    });
5335  }
5336}
5337class dg extends De {
5338  constructor({ givenSize: t, maxSize: n }) {
5339    super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`), Object.defineProperty(this, "name", {
5340      enumerable: !0,
5341      configurable: !0,
5342      writable: !0,
5343      value: "Hex.SizeOverflowError"
5344    });
5345  }
5346}
5347class qd extends De {
5348  constructor({ offset: t, position: n, size: r }) {
5349    super(`Slice ${n === "start" ? "starting" : "ending"} at offset \`${t}\` is out-of-bounds (size: \`${r}\`).`), Object.defineProperty(this, "name", {
5350      enumerable: !0,
5351      configurable: !0,
5352      writable: !0,
5353      value: "Hex.SliceOffsetOutOfBoundsError"
5354    });
5355  }
5356}
5357class fg extends De {
5358  constructor({ size: t, targetSize: n, type: r }) {
5359    super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`), Object.defineProperty(this, "name", {
5360      enumerable: !0,
5361      configurable: !0,
5362      writable: !0,
5363      value: "Hex.SizeExceedsPaddingSizeError"
5364    });
5365  }
5366}
5367function hg(e) {
5368  return {
5369    address: e.address,
5370    amount: an(e.amount),
5371    index: an(e.index),
5372    validatorIndex: an(e.validatorIndex)
5373  };
5374}
5375function pg(e) {
5376  return {
5377    ...typeof e.baseFeePerGas == "bigint" && {
5378      baseFeePerGas: an(e.baseFeePerGas)
5379    },
5380    ...typeof e.blobBaseFee == "bigint" && {
5381      blobBaseFee: an(e.blobBaseFee)
5382    },
5383    ...typeof e.feeRecipient == "string" && {
5384      feeRecipient: e.feeRecipient
5385    },
5386    ...typeof e.gasLimit == "bigint" && {
5387      gasLimit: an(e.gasLimit)
5388    },
5389    ...typeof e.number == "bigint" && {
5390      number: an(e.number)
5391    },
5392    ...typeof e.prevRandao == "bigint" && {
5393      prevRandao: an(e.prevRandao)
5394    },
5395    ...typeof e.time == "bigint" && {
5396      time: an(e.time)
5397    },
5398    ...e.withdrawals && {
5399      withdrawals: e.withdrawals.map(hg)
5400    }
5401  };
5402}
5403const ji = [
5404  {
5405    inputs: [
5406      {
5407        components: [
5408          {
5409            name: "target",
5410            type: "address"
5411          },
5412          {
5413            name: "allowFailure",
5414            type: "bool"
5415          },
5416          {
5417            name: "callData",
5418            type: "bytes"
5419          }
5420        ],
5421        name: "calls",
5422        type: "tuple[]"
5423      }
5424    ],
5425    name: "aggregate3",
5426    outputs: [
5427      {
5428        components: [
5429          {
5430            name: "success",
5431            type: "bool"
5432          },
5433          {
5434            name: "returnData",
5435            type: "bytes"
5436          }
5437        ],
5438        name: "returnData",
5439        type: "tuple[]"
5440      }
5441    ],
5442    stateMutability: "view",
5443    type: "function"
5444  },
5445  {
5446    inputs: [
5447      {
5448        name: "addr",
5449        type: "address"
5450      }
5451    ],
5452    name: "getEthBalance",
5453    outputs: [
5454      {
5455        name: "balance",
5456        type: "uint256"
5457      }
5458    ],
5459    stateMutability: "view",
5460    type: "function"
5461  },
5462  {
5463    inputs: [],
5464    name: "getCurrentBlockTimestamp",
5465    outputs: [
5466      {
5467        internalType: "uint256",
5468        name: "timestamp",
5469        type: "uint256"
5470      }
5471    ],
5472    stateMutability: "view",
5473    type: "function"
5474  }
5475], P_ = [
5476  {
5477    name: "query",
5478    type: "function",
5479    stateMutability: "view",
5480    inputs: [
5481      {
5482        type: "tuple[]",
5483        name: "queries",
5484        components: [
5485          {
5486            type: "address",
5487            name: "sender"
5488          },
5489          {
5490            type: "string[]",
5491            name: "urls"
5492          },
5493          {
5494            type: "bytes",
5495            name: "data"
5496          }
5497        ]
5498      }
5499    ],
5500    outputs: [
5501      {
5502        type: "bool[]",
5503        name: "failures"
5504      },
5505      {
5506        type: "bytes[]",
5507        name: "responses"
5508      }
5509    ]
5510  },
5511  {
5512    name: "HttpError",
5513    type: "error",
5514    inputs: [
5515      {
5516        type: "uint16",
5517        name: "status"
5518      },
5519      {
5520        type: "string",
5521        name: "message"
5522      }
5523    ]
5524  }
5525], Gd = [
5526  {
5527    inputs: [
5528      {
5529        name: "dns",
5530        type: "bytes"
5531      }
5532    ],
5533    name: "DNSDecodingFailed",
5534    type: "error"
5535  },
5536  {
5537    inputs: [
5538      {
5539        name: "ens",
5540        type: "string"
5541      }
5542    ],
5543    name: "DNSEncodingFailed",
5544    type: "error"
5545  },
5546  {
5547    inputs: [],
5548    name: "EmptyAddress",
5549    type: "error"
5550  },
5551  {
5552    inputs: [
5553      {
5554        name: "status",
5555        type: "uint16"
5556      },
5557      {
5558        name: "message",
5559        type: "string"
5560      }
5561    ],
5562    name: "HttpError",
5563    type: "error"
5564  },
5565  {
5566    inputs: [],
vendor: 6,057 bytes, lines 5567-5931
5567    name: "InvalidBatchGatewayResponse",
5568    type: "error"
5569  },
5570  {
5571    inputs: [
5572      {
5573        name: "errorData",
5574        type: "bytes"
5575      }
5576    ],
5577    name: "ResolverError",
5578    type: "error"
5579  },
5580  {
5581    inputs: [
5582      {
5583        name: "name",
5584        type: "bytes"
5585      },
5586      {
5587        name: "resolver",
5588        type: "address"
5589      }
5590    ],
5591    name: "ResolverNotContract",
5592    type: "error"
5593  },
5594  {
5595    inputs: [
5596      {
5597        name: "name",
5598        type: "bytes"
5599      }
5600    ],
5601    name: "ResolverNotFound",
5602    type: "error"
5603  },
5604  {
5605    inputs: [
5606      {
5607        name: "primary",
5608        type: "string"
5609      },
5610      {
5611        name: "primaryAddress",
5612        type: "bytes"
5613      }
5614    ],
5615    name: "ReverseAddressMismatch",
5616    type: "error"
5617  },
5618  {
5619    inputs: [
5620      {
5621        internalType: "bytes4",
5622        name: "selector",
5623        type: "bytes4"
5624      }
5625    ],
5626    name: "UnsupportedResolverProfile",
5627    type: "error"
5628  }
5629], k_ = [
5630  ...Gd,
5631  {
5632    name: "resolveWithGateways",
5633    type: "function",
5634    stateMutability: "view",
5635    inputs: [
5636      { name: "name", type: "bytes" },
5637      { name: "data", type: "bytes" },
5638      { name: "gateways", type: "string[]" }
5639    ],
5640    outputs: [
5641      { name: "", type: "bytes" },
5642      { name: "address", type: "address" }
5643    ]
5644  }
5645], U_ = [
5646  ...Gd,
5647  {
5648    name: "reverseWithGateways",
5649    type: "function",
5650    stateMutability: "view",
5651    inputs: [
5652      { type: "bytes", name: "reverseName" },
5653      { type: "uint256", name: "coinType" },
5654      { type: "string[]", name: "gateways" }
5655    ],
5656    outputs: [
5657      { type: "string", name: "resolvedName" },
5658      { type: "address", name: "resolver" },
5659      { type: "address", name: "reverseResolver" }
5660    ]
5661  }
5662], M_ = [
5663  {
5664    name: "text",
5665    type: "function",
5666    stateMutability: "view",
5667    inputs: [
5668      { name: "name", type: "bytes32" },
5669      { name: "key", type: "string" }
5670    ],
5671    outputs: [{ name: "", type: "string" }]
5672  }
5673], L_ = [
5674  {
5675    name: "addr",
5676    type: "function",
5677    stateMutability: "view",
5678    inputs: [{ name: "name", type: "bytes32" }],
5679    outputs: [{ name: "", type: "address" }]
5680  },
5681  {
5682    name: "addr",
5683    type: "function",
5684    stateMutability: "view",
5685    inputs: [
5686      { name: "name", type: "bytes32" },
5687      { name: "coinType", type: "uint256" }
5688    ],
5689    outputs: [{ name: "", type: "bytes" }]
5690  }
5691], B_ = [
5692  {
5693    name: "isValidSignature",
5694    type: "function",
5695    stateMutability: "view",
5696    inputs: [
5697      { name: "hash", type: "bytes32" },
5698      { name: "signature", type: "bytes" }
5699    ],
5700    outputs: [{ name: "", type: "bytes4" }]
5701  }
5702], D_ = [
5703  {
5704    inputs: [
5705      {
5706        name: "_signer",
5707        type: "address"
5708      },
5709      {
5710        name: "_hash",
5711        type: "bytes32"
5712      },
5713      {
5714        name: "_signature",
5715        type: "bytes"
5716      }
5717    ],
5718    stateMutability: "nonpayable",
5719    type: "constructor"
5720  },
5721  {
5722    inputs: [
5723      {
5724        name: "_signer",
5725        type: "address"
5726      },
5727      {
5728        name: "_hash",
5729        type: "bytes32"
5730      },
5731      {
5732        name: "_signature",
5733        type: "bytes"
5734      }
5735    ],
5736    outputs: [
5737      {
5738        type: "bool"
5739      }
5740    ],
5741    stateMutability: "nonpayable",
5742    type: "function",
5743    name: "isValidSig"
5744  }
5745], oi = [
5746  {
5747    type: "event",
5748    name: "Approval",
5749    inputs: [
5750      {
5751        indexed: !0,
5752        name: "owner",
5753        type: "address"
5754      },
5755      {
5756        indexed: !0,
5757        name: "spender",
5758        type: "address"
5759      },
5760      {
5761        indexed: !1,
5762        name: "value",
5763        type: "uint256"
5764      }
5765    ]
5766  },
5767  {
5768    type: "event",
5769    name: "Transfer",
5770    inputs: [
5771      {
5772        indexed: !0,
5773        name: "from",
5774        type: "address"
5775      },
5776      {
5777        indexed: !0,
5778        name: "to",
5779        type: "address"
5780      },
5781      {
5782        indexed: !1,
5783        name: "value",
5784        type: "uint256"
5785      }
5786    ]
5787  },
5788  {
5789    type: "function",
5790    name: "allowance",
5791    stateMutability: "view",
5792    inputs: [
5793      {
5794        name: "owner",
5795        type: "address"
5796      },
5797      {
5798        name: "spender",
5799        type: "address"
5800      }
5801    ],
5802    outputs: [
5803      {
5804        type: "uint256"
5805      }
5806    ]
5807  },
5808  {
5809    type: "function",
5810    name: "approve",
5811    stateMutability: "nonpayable",
5812    inputs: [
5813      {
5814        name: "spender",
5815        type: "address"
5816      },
5817      {
5818        name: "amount",
5819        type: "uint256"
5820      }
5821    ],
5822    outputs: [
5823      {
5824        type: "bool"
5825      }
5826    ]
5827  },
5828  {
5829    type: "function",
5830    name: "balanceOf",
5831    stateMutability: "view",
5832    inputs: [
5833      {
5834        name: "account",
5835        type: "address"
5836      }
5837    ],
5838    outputs: [
5839      {
5840        type: "uint256"
5841      }
5842    ]
5843  },
5844  {
5845    type: "function",
5846    name: "decimals",
5847    stateMutability: "view",
5848    inputs: [],
5849    outputs: [
5850      {
5851        type: "uint8"
5852      }
5853    ]
5854  },
5855  {
5856    type: "function",
5857    name: "name",
5858    stateMutability: "view",
5859    inputs: [],
5860    outputs: [
5861      {
5862        type: "string"
5863      }
5864    ]
5865  },
5866  {
5867    type: "function",
5868    name: "symbol",
5869    stateMutability: "view",
5870    inputs: [],
5871    outputs: [
5872      {
5873        type: "string"
5874      }
5875    ]
5876  },
5877  {
5878    type: "function",
5879    name: "totalSupply",
5880    stateMutability: "view",
5881    inputs: [],
5882    outputs: [
5883      {
5884        type: "uint256"
5885      }
5886    ]
5887  },
5888  {
5889    type: "function",
5890    name: "transfer",
5891    stateMutability: "nonpayable",
5892    inputs: [
5893      {
5894        name: "recipient",
5895        type: "address"
5896      },
5897      {
5898        name: "amount",
5899        type: "uint256"
5900      }
5901    ],
5902    outputs: [
5903      {
5904        type: "bool"
5905      }
5906    ]
5907  },
5908  {
5909    type: "function",
5910    name: "transferFrom",
5911    stateMutability: "nonpayable",
5912    inputs: [
5913      {
5914        name: "sender",
5915        type: "address"
5916      },
5917      {
5918        name: "recipient",
5919        type: "address"
5920      },
5921      {
5922        name: "amount",
5923        type: "uint256"
5924      }
5925    ],
5926    outputs: [
5927      {
5928        type: "bool"
5929      }
5930    ]
5931  }
5932], mg = "0x82ad56cb", gg = "0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe", yg = "0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe", F_ = "0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041
5932d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572", bg = "0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9
5932150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";
5933class va extends F {
5934  constructor({ blockNumber: t, chain: n, contract: r }) {
5935    super(`Chain "${n.name}" does not support contract "${r.name}".`, {
5936      metaMessages: [
5937        "This could be due to any of the following:",
5938        ...t && r.blockCreated && r.blockCreated > t ? [
5939          `- The contract "${r.name}" was not deployed until block ${r.blockCreated} (current block ${t}).`
5940        ] : [
5941          `- The chain does not have the contract "${r.name}" configured.`
5942        ]
5943      ],
5944      name: "ChainDoesNotSupportContract"
5945    });
5946  }
5947}
5948class wg extends F {
5949  constructor({ chain: t, currentChainId: n }) {
5950    super(`The current chain of the wallet (id: ${n}) does not match the target chain for the transaction (id: ${t.id} – ${t.name}).`, {
5951      metaMessages: [
5952        `Current Chain ID:  ${n}`,
5953        `Expected Chain ID: ${t.id} – ${t.name}`
5954      ],
5955      name: "ChainMismatchError"
5956    });
5957  }
5958}
5959class Cg extends F {
5960  constructor() {
5961    super([
5962      "No chain was provided to the request.",
5963      "Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."
5964    ].join(`
5965`), {
5966      name: "ChainNotFoundError"
5967    });
5968  }
5969}
5970class zd extends F {
5971  constructor() {
5972    super("No chain was provided to the Client.", {
5973      name: "ClientChainNotConfiguredError"
5974    });
5975  }
5976}
5977class j_ extends F {
5978  constructor({ chainId: t }) {
5979    super(typeof t == "number" ? `Chain ID "${t}
5979" is invalid.` : "Chain ID is invalid.", { name: "InvalidChainIdError" });
5980  }
5981}
5982const Lo = "/docs/contract/encodeDeployData";
5983function Vd(e) {
5984  const { abi: t, args: n, bytecode: r } = e;
5985  if (!n || n.length === 0)
5986    return r;
5987  const s = t.find((o) => "type" in o && o.type === "constructor");
5988  if (!s)
5989    throw new rp({ docsPath: Lo });
5990  if (!("inputs" in s))
5991    throw new Wc({ docsPath: Lo });
5992  if (!s.inputs || s.inputs.length === 0)
5993    throw new Wc({ docsPath: Lo });
5994  const i = nd(s.inputs, n);
5995  return lo([r, i]);
5996}
5997function Eg({ blockNumber: e, chain: t, contract: n }) {
5998  const r = t?.contracts?.[n];
5999  if (!r)
6000    throw new va({
6001      chain: t,
6002      contract: { name: n }
6003    });
6004  if (e && r.blockCreated && r.blockCreated > e)
6005    throw new va({
6006      blockNumber: e,
6007      chain: t,
6008      contract: {
6009        name: n,
6010        blockCreated: r.blockCreated
6011      }
6012    });
6013  return r.address;
6014}
6015function Ag(e, { docsPath: t, ...n }) {
6016  const r = (() => {
6017    const s = mc(e, n);
6018    return s instanceof ho ? e : s;
6019  })();
6020  return new $0(r, {
6021    docsPath: t,
6022    ...n
6023  });
6024}
6025function Kd() {
6026  let e = () => {
6027  }, t = () => {
6028  };
6029  return { promise: new Promise((r, s) => {
6030    e = r, t = s;
6031  }), resolve: e, reject: t };
6032}
6033const Bo = /* @__PURE__ */ new Map();
6034function Yd({ fn: e, id: t, shouldSplitBatch: n, wait: r = 0, sort: s }) {
6035  const i = async () => {
6036    const l = u();
6037    o();
6038    const f = l.map(({ args: p }) => p);
6039    f.length !== 0 && e(f).then((p) => {
6040      s && Array.isArray(p) && p.sort(s);
6041      for (let m = 0; m < l.length; m++) {
6042        const { resolve: y } = l[m];
6043        y?.([p[m], p]);
6044      }
6045    }).catch((p) => {
6046      for (let m = 0; m < l.length; m++) {
6047        const { reject: y } = l[m];
6048        y?.(p);
6049      }
6050    });
6051  }, o = () => Bo.delete(t), a = () => u().map(({ args: l }) => l), u = () => Bo.get(t) || [], c = (l) => Bo.set(t, [...u(), l]);
6052  return {
6053    flush: o,
6054    async schedule(l) {
6055      const { promise: f, resolve: p, reject: m } = Kd();
6056      return n?.([...a(), l]) && i(), u().length > 0 ? (c({ args: l, resolve: p, reject: m }), f) : (c({ args: l, resolve: p, reject: m }), setTimeout(i, r), f);
6057    }
6058  };
6059}
6060async function Zd(e, t) {
6061  const { account: n = e.account, authorizationList: r, batch: s = !!e.batch?.multicall, blockNumber: i, blockTag: o = e.experimental_blockTag ?? "latest", accessList: a, blobs: u, blockOverrides: c, code: l, data: f, factory: p, factoryData: m, gas: y, gasPrice: b, maxFeePerBlobGas: C, maxFeePerGas: _, maxPriorityFeePerGas: R, nonce: N, to: I, value: E, stateOverride: T, ...O } = t, U = n ? vt(n) : void 0;
6062  if (l && (p || m))
6063    throw new F("Cannot provide both `code` & `factory`/`factoryData` as parameters.");
6064  if (l && I)
6065    throw new F("Cannot provide both `code` & `to` as parameters.");
6066  const M = l && f, L = p && m && I && f, re = M || L, ne = M ? Qd({
6067    code: l,
6068    data: f
6069  }) : L ? Ng({
6070    data: f,
6071    factory: p,
6072    factoryData: m,
6073    to: I
6074  }) : f;
6075  try {
6076    Ys(t);
6077    const ae = (typeof i == "bigint" ? be(i) : void 0) || o, P = c ? pg(c) : void 0, D = hd(T), de = e.chain?.formatters?.transactionRequest?.format, Re = (de || Ks)({
6078      // Pick out extra data that might exist on the chain's transaction request type.
6079      ...po(O, { format: de }),
6080      accessList: a,
6081      account: U,
6082      authorizationList: r,
6083      blobs: u,
6084      data: ne,
6085      gas: y,
6086      gasPrice: b,
6087      maxFeePerBlobGas: C,
6088      maxFeePerGas: _,
6089      maxPriorityFeePerGas: R,
6090      nonce: N,
6091      to: re ? void 0 : I,
6092      value: E
6093    }, "call");
6094    if (s && vg({ request: Re }) && !D && !P)
6095      try {
6096        return await _g(e, {
6097          ...Re,
6098          blockNumber: i,
6099          blockTag: o
6100        });
6101      } catch (Oe) {
6102        if (!(Oe instanceof zd) && !(Oe instanceof va))
6103          throw Oe;
6104      }
6105    const ge = (() => {
6106      const Oe = [
6107        Re,
6108        ae
6109      ];
6110      return D && P ? [...Oe, D, P] : D ? [...Oe, D] : P ? [...Oe, {}, P] : Oe;
6111    })(), Ue = await e.request({
6112      method: "eth_call",
6113      params: ge
6114    });
6115    return Ue === "0x" ? { data: void 0 } : { data: Ue };
6116  } catch (fe) {
6117    const ae = Ig(fe), { offchainLookup: P, offchainLookupSignature: D } = await import("./ccip-jYYO5wbZ.js");
6118    if (e.ccipRead !== !1 && ae?.slice(0, 10) === D && I)
6119      return { data: await P(e, { data: ae, to: I }) };
6120    throw re && ae?.slice(0, 10) === "0x101bb98d" ? new z0({ factory: p }) : Ag(fe, {
6121      ...t,
6122      account: U,
6123      chain: e.chain
6124    });
6125  }
6126}
6127function vg({ request: e }) {
6128  const { data: t, to: n, ...r } = e;
6129  return !(!t || t.startsWith(mg) || !n || Object.values(r).filter((s) => typeof s < "u").length > 0);
6130}
6131async function _g(e, t) {
6132  const { batchSize: n = 1024, deployless: r = !1, wait: s = 0 } = typeof e.batch?.multicall == "object" ? e.batch.multicall : {}, { blockNumber: i, blockTag: o = e.experimental_blockTag ?? "latest", data: a, to: u } = t, c = (() => {
6133    if (r)
6134      return null;
6135    if (t.multicallAddress)
6136      return t.multicallAddress;
6137    if (e.chain)
6138      return Eg({
6139        blockNumber: i,
6140        chain: e.chain,
6141        contract: "multicall3"
6142      });
6143    throw new zd();
6144  })(), f = (typeof i == "bigint" ? be(i) : void 0) || o, { schedule: p } = Yd({
6145    id: `${e.uid}.${f}`,
6146    wait: s,
6147    shouldSplitBatch(b) {
6148      return b.reduce((_, { data: R }) => _ + (R.length - 2), 0) > n * 2;
6149    },
6150    fn: async (b) => {
6151      const C = b.map((N) => ({
6152        allowFailure: !0,
6153        callData: N.data,
6154        target: N.to
6155      })), _ = lc({
6156        abi: ji,
6157        args: [C],
6158        functionName: "aggregate3"
6159      }), R = await e.request({
6160        method: "eth_call",
6161        params: [
6162          {
6163            ...c === null ? {
6164              data: Qd({
6165                code: bg,
6166                data: _
6167              })
6168            } : { to: c, data: _ }
6169          },
6170          f
6171        ]
6172      });
6173      return xd({
6174        abi: ji,
6175        args: [C],
6176        functionName: "aggregate3",
6177        data: R || "0x"
6178      });
6179    }
6180  }), [{ returnData: m, success: y }] = await p({ data: a, to: u });
6181  if (!y)
6182    throw new cd({ data: m });
6183  return m === "0x" ? { data: void 0 } : { data: m };
6184}
6185function Qd(e) {
6186  const { code: t, data: n } = e;
6187  return Vd({
6188    abi: Ml(["constructor(bytes, bytes)"]),
6189    bytecode: gg,
6190    args: [t, n]
6191  });
6192}
6193function Ng(e) {
6194  const { data: t, factory: n, factoryData: r, to: s } = e;
6195  return Vd({
6196    abi: Ml(["constructor(address, bytes, address, bytes)"]),
6197    bytecode: yg,
6198    args: [s, t, n, r]
6199  });
6200}
6201function Ig(e) {
6202  if (!(e instanceof F))
6203    return;
6204  const t = e.walk();
6205  return typeof t?.data == "object" ? t.data?.data : t.data;
6206}
6207const Do = /* @__PURE__ */ new Map(), mu = /* @__PURE__ */ new Map();
6208let Tg = 0;
6209function Wi(e, t, n) {
6210  const r = ++Tg, s = () => Do.get(e) || [], i = () => {
6211    const l = s();
6212    Do.set(e, l.filter((f) => f.id !== r));
6213  }, o = () => {
6214    const l = s();
6215    if (!l.some((p) => p.id === r))
6216      return;
6217    const f = mu.get(e);
6218    if (l.length === 1 && f) {
6219      const p = f();
6220      p instanceof Promise && p.catch(() => {
6221      });
6222    }
6223    i();
6224  }, a = s();
6225  if (Do.set(e, [
6226    ...a,
6227    { id: r, fns: t }
6228  ]), a && a.length > 0)
6229    return o;
6230  const u = {};
6231  for (const l in t)
6232    u[l] = ((...f) => {
6233      const p = s();
6234      if (p.length !== 0)
6235        for (const m of p)
6236          m.fns[l]?.(...f);
6237    });
6238  const c = n(u);
6239  return typeof c == "function" && mu.set(e, c), o;
6240}
6241async function $i(e) {
6242  return new Promise((t) => setTimeout(t, e));
6243}
6244function Jd(e, { emitOnBegin: t, initialWaitTime: n, interval: r }) {
6245  let s = !0;
6246  const i = () => s = !1;
6247  return (async () => {
6248    let a;
6249    t && (a = await e({ unpoll: i }));
6250    const u = await n?.(a) ?? r;
6251    await $i(u);
6252    const c = async () => {
6253      s && (await e({ unpoll: i }), await $i(r), c());
6254    };
6255    c();
6256  })(), i;
6257}
6258const Sg = /* @__PURE__ */ new Map(), Rg = /* @__PURE__ */ new Map();
6259function xg(e) {
6260  const t = (s, i) => ({
6261    clear: () => i.delete(s),
6262    get: () => i.get(s),
6263    set: (o) => i.set(s, o)
6264  }), n = t(e, Sg), r = t(e, Rg);
6265  return {
6266    clear: () => {
6267      n.clear(), r.clear();
6268    },
6269    promise: n,
6270    response: r
6271  };
6272}
6273async function Og(e, { cacheKey: t, cacheTime: n = Number.POSITIVE_INFINITY }) {
6274  const r = xg(t), s = r.response.get();
6275  if (s && n > 0 && Date.now() - s.created.getTime() < n)
6276    return s.data;
6277  let i = r.promise.get();
6278  i || (i = e(), r.promise.set(i));
6279  try {
6280    const o = await i;
6281    return r.response.set({ created: /* @__PURE__ */ new Date(), data: o }), o;
6282  } finally {
6283    r.promise.clear();
6284  }
6285}
6286const Pg = (e) => `blockNumber.${e}`;
6287async function kg(e, { cacheTime: t = e.cacheTime } = {}) {
6288  const n = await Og(() => e.request({
6289    method: "eth_blockNumber"
6290  }), { cacheKey: Pg(e.uid), cacheTime: t });
6291  return BigInt(n);
6292}
6293async function Ug(e, { filter: t }) {
6294  const n = "strict" in t && t.strict, r = await t.request({
6295    method: "eth_getFilterChanges",
6296    params: [t.id]
6297  });
6298  if (typeof r[0] == "string")
6299    return r;
6300  const s = r.map((i) => Cc(i));
6301  return !("abi" in t) || !t.abi ? s : Mm({
6302    abi: t.abi,
6303    logs: s,
6304    strict: n
6305  });
6306}
6307async function Mg(e, { filter: t }) {
6308  return t.request({
6309    method: "eth_uninstallFilter",
6310    params: [t.id]
6311  });
6312}
6313class _c extends F {
6314  constructor({ docsPath: t } = {}) {
6315    super([
6316      "Could not find an Account to execute with this Action.",
6317      "Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."
6318    ].join(`
6319`), {
6320      docsPath: t,
6321      docsSlug: "account",
6322      name: "AccountNotFoundError"
6323    });
6324  }
6325}
6326class Fo extends F {
6327  constructor({ docsPath: t, metaMessages: n, type: r }) {
6328    super(`Account type "${r}" is not supported.`, {
6329      docsPath: t,
6330      metaMessages: n,
6331      name: "AccountTypeNotSupportedError"
6332    });
6333  }
6334}
6335function Lg({ chain: e, currentChainId: t }) {
6336  if (!e)
6337    throw new Cg();
6338  if (t !== e.id)
6339    throw new wg({ chain: e, currentChainId: t });
6340}
6341async function Bg(e, { serializedTransaction: t }) {
6342  return e.request({
6343    method: "eth_sendRawTransaction",
6344    params: [t]
6345  }, { retryCount: 0 });
6346}
6347const jo = new qs(128);
6348async function Xd(e, t) {
6349  const { account: n = e.account, assertChainId: r = !0, chain: s = e.chain, accessList: i, authorizationList: o, blobs: a, data: u, dataSuffix: c = typeof e.dataSuffix == "string" ? e.dataSuffix : e.dataSuffix?.value, gas: l, gasPrice: f, maxFeePerBlobGas: p, maxFeePerGas: m, maxPriorityFeePerGas: y, nonce: b, type: C, value: _, ...R } = t;
6350  if (typeof n > "u")
6351    throw new _c({
6352      docsPath: "/docs/actions/wallet/sendTransaction"
6353    });
6354  const N = n ? vt(n) : null;
6355  try {
6356    Ys(t);
6357    const I = await (async () => {
6358      if (t.to)
6359        return t.to;
6360      if (t.to !== null && o && o.length > 0)
6361        return await fd({
6362          authorization: o[0]
6363        }).catch(() => {
6364          throw new F("`to` is required. Could not infer from `authorizationList`.");
6365        });
6366    })();
6367    if (N?.type === "json-rpc" || N === null) {
6368      let E;
6369      s !== null && (E = await ke(e, bc, "getChainId")({}), r && Lg({
6370        currentChainId: E,
6371        chain: s
6372      }));
6373      const T = e.chain?.formatters?.transactionRequest?.format, U = (T || Ks)({
6374        // Pick out extra data that might exist on the chain's transaction request type.
6375        ...po(R, { format: T }),
6376        accessList: i,
6377        account: N,
6378        authorizationList: o,
6379        blobs: a,
6380        chainId: E,
6381        data: c ? Dn([u ?? "0x", c]) : u,
6382        gas: l,
6383        gasPrice: f,
6384        maxFeePerBlobGas: p,
6385        maxFeePerGas: m,
6386        maxPriorityFeePerGas: y,
6387        nonce: b,
6388        to: I,
6389        type: C,
6390        value: _
6391      }, "sendTransaction"), M = jo.get(e.uid), L = M ? "wallet_sendTransaction" : "eth_sendTransaction";
6392      try {
6393        return await e.request({
6394          method: L,
6395          params: [U]
6396        }, { retryCount: 0 });
6397      } catch (re) {
6398        if (M === !1)
6399          throw re;
6400        const ne = re;
6401        if (ne.name === "InvalidInputRpcError" || ne.name === "InvalidParamsRpcError" || ne.name === "MethodNotFoundRpcError" || ne.name === "MethodNotSupportedRpcError")
6402          return await e.request({
6403            method: "wallet_sendTransaction",
6404            params: [U]
6405          }, { retryCount: 0 }).then((fe) => (jo.set(e.uid, !0), fe)).catch((fe) => {
6406            const ae = fe;
6407            throw ae.name === "MethodNotFoundRpcError" || ae.name === "MethodNotSupportedRpcError" ? (jo.set(e.uid, !1), ne) : ae;
6408          });
6409        throw ne;
6410      }
6411    }
6412    if (N?.type === "local") {
6413      const E = await ke(e, wc, "prepareTransactionRequest")({
6414        account: N,
6415        accessList: i,
6416        authorizationList: o,
6417        blobs: a,
6418        chain: s,
6419        data: c ? Dn([u ?? "0x", c]) : u,
6420        gas: l,
6421        gasPrice: f,
6422        maxFeePerBlobGas: p,
6423        maxFeePerGas: m,
6424        maxPriorityFeePerGas: y,
6425        nonce: b,
6426        nonceManager: N.nonceManager,
6427        parameters: [...Sd, "sidecars"],
6428        type: C,
6429        value: _,
6430        ...R,
6431        to: I
6432      }), T = s?.serializers?.transaction, O = await N.signTransaction(E, {
6433        serializer: T
6434      });
6435      return await ke(e, Bg, "sendRawTransaction")({
6436        serializedTransaction: O
6437      });
6438    }
6439    throw N?.type === "smart" ? new Fo({
6440      metaMessages: [
6441        "Consider using the `sendUserOperation` Action instead."
6442      ],
6443      docsPath: "/docs/actions/bundler/sendUserOperation",
6444      type: "smart"
6445    }) : new Fo({
6446      docsPath: "/docs/actions/wallet/sendTransaction",
6447      type: N?.type
6448    });
6449  } catch (I) {
6450    throw I instanceof Fo ? I : Td(I, {
6451      ...t,
6452      account: N,
6453      chain: t.chain || void 0
6454    });
6455  }
6456}
6457async function Hi(e, t) {
6458  return Hi.internal(e, Xd, "sendTransaction", t);
6459}
6460(function(e) {
6461  async function t(n, r, s, i) {
6462    const { abi: o, account: a = n.account, address: u, args: c, functionName: l, ...f } = i;
6463    if (typeof a > "u")
6464      throw new _c({
6465        docsPath: "/docs/contract/writeContract"
6466      });
6467    const p = a ? vt(a) : null, m = lc({
6468      abi: o,
6469      args: c,
6470      functionName: l
6471    });
6472    try {
6473      return await ke(n, r, s)({
6474        data: m,
6475        to: u,
6476        account: p,
6477        ...f
6478      });
6479    } catch (y) {
6480      throw Z0(y, {
6481        abi: o,
6482        address: u,
6483        args: c,
6484        docsPath: "/docs/contract/writeContract",
6485        functionName: l,
6486        sender: p?.address
6487      });
6488    }
6489  }
6490  e.internal = t;
6491})(Hi || (Hi = {}));
6492function qi(e, { delay: t = 100, retryCount: n = 2, shouldRetry: r = () => !0 } = {}) {
6493  return new Promise((s, i) => {
6494    const o = async ({ count: a = 0 } = {}) => {
6495      const u = async ({ error: c }) => {
6496        const l = typeof t == "function" ? t({ count: a, error: c }) : t;
6497        l && await $i(l), o({ count: a + 1 });
6498      };
6499      try {
6500        const c = await e();
6501        s(c);
6502      } catch (c) {
6503        if (a < n && await r({ count: a, error: c }))
6504          return u({ error: c });
6505        i(c);
6506      }
6507    };
6508    o();
6509  });
6510}
6511const Dg = {
6512  "0x0": "reverted",
6513  "0x1": "success"
6514};
6515function ef(e, t) {
6516  const n = {
6517    ...e,
6518    blockNumber: e.blockNumber ? BigInt(e.blockNumber) : null,
6519    contractAddress: e.contractAddress ? e.contractAddress : null,
6520    cumulativeGasUsed: e.cumulativeGasUsed ? BigInt(e.cumulativeGasUsed) : null,
6521    effectiveGasPrice: e.effectiveGasPrice ? BigInt(e.effectiveGasPrice) : null,
6522    gasUsed: e.gasUsed ? BigInt(e.gasUsed) : null,
6523    logs: e.logs ? e.logs.map((r) => Cc(r)) : null,
6524    to: e.to ? e.to : null,
6525    transactionIndex: e.transactionIndex ? Bn(e.transactionIndex) : null,
6526    status: e.status ? Dg[e.status] : null,
6527    type: e.type ? gd[e.type] || e.type : null
6528  };
6529  return e.blobGasPrice && (n.blobGasPrice = BigInt(e.blobGasPrice)), e.blobGasUsed && (n.blobGasUsed = BigInt(e.blobGasUsed)), n;
6530}
6531const W_ = /* @__PURE__ */ mo("transactionReceipt", ef), _a = 256;
6532let ai = _a, ci;
6533function tf(e = 11) {
6534  if (!ci || ai + e > _a * 2) {
6535    ci = "", ai = 0;
6536    for (let t = 0; t < _a; t++)
6537      ci += (256 + Math.random() * 256 | 0).toString(16).substring(1);
6538  }
6539  return ci.substring(ai, ai++ + e);
6540}
6541function nf(e) {
6542  const { batch: t, chain: n, ccipRead: r, dataSuffix: s, key: i = "base", name: o = "Base Client", type: a = "base" } = e, u = e.experimental_blockTag ?? (typeof n?.experimental_preconfirmationTime == "number" ? "pending" : void 0), c = n?.blockTime ?? 12e3, l = Math.min(Math.max(Math.floor(c / 2), 500), 4e3), f = e.pollingInterval ?? l, p = e.cacheTime ?? f, m = e.account ? vt(e.account) : void 0, { config: y, request: b, value: C } = e.transport({
6543    account: m,
6544    chain: n,
6545    pollingInterval: f
6546  }), _ = { ...y, ...C }, R = {
6547    account: m,
6548    batch: t,
6549    cacheTime: p,
6550    ccipRead: r,
6551    chain: n,
6552    dataSuffix: s,
6553    key: i,
6554    name: o,
6555    pollingInterval: f,
6556    request: b,
6557    transport: _,
6558    type: a,
6559    uid: tf(),
6560    ...u ? { experimental_blockTag: u } : {}
6561  };
6562  function N(I) {
6563    return (E) => {
6564      const T = E(I);
6565      for (const U in R)
6566        delete T[U];
6567      const O = { ...I, ...T };
6568      return Object.assign(O, { extend: N(O) });
6569    };
6570  }
6571  return Object.assign(R, { extend: N(R) });
6572}
6573async function Fg(e) {
6574  const t = m0(e, {
6575    method: "eth_newPendingTransactionFilter"
6576  }), n = await e.request({
6577    method: "eth_newPendingTransactionFilter"
6578  });
6579  return { id: n, request: t(n), type: "transaction" };
6580}
6581async function jg(e, { address: t, blockNumber: n, blockTag: r = e.experimental_blockTag ?? "latest" }) {
6582  if (e.batch?.multicall && e.chain?.contracts?.multicall3) {
6583    const o = e.chain.contracts.multicall3.address, a = lc({
6584      abi: ji,
6585      functionName: "getEthBalance",
6586      args: [t]
6587    }), { data: u } = await ke(e, Zd, "call")({
6588      to: o,
6589      data: a,
6590      blockNumber: n,
6591      blockTag: r
6592    });
6593    return xd({
6594      abi: ji,
6595      functionName: "getEthBalance",
6596      args: [t],
6597      data: u || "0x"
6598    });
6599  }
6600  const s = typeof n == "bigint" ? be(n) : void 0, i = await e.request({
6601    method: "eth_getBalance",
6602    params: [t, s || r]
6603  });
6604  return BigInt(i);
6605}
6606const ui = /* @__PURE__ */ new qs(8192);
6607function Wg(e, { enabled: t = !0, id: n }) {
6608  if (!t || !n)
6609    return e();
6610  if (ui.get(n))
6611    return ui.get(n);
6612  const r = e().finally(() => ui.delete(n));
6613  return ui.set(n, r), r;
6614}
6615function $g(e, t = {}) {
6616  return async (n, r = {}) => {
6617    const { dedupe: s = !1, methods: i, retryDelay: o = 150, retryCount: a = 3, uid: u } = {
6618      ...t,
6619      ...r
6620    }, { method: c } = n;
6621    if (i?.exclude?.includes(c))
6622      throw new Kn(new Error("method not supported"), {
6623        method: c
6624      });
6625    if (i?.include && !i.include.includes(c))
6626      throw new Kn(new Error("method not supported"), {
6627        method: c
6628      });
6629    const l = s ? qg(`${u}.${At(n)}`) : void 0;
6630    return Wg(() => qi(async () => {
6631      try {
6632        return await e(n);
6633      } catch (f) {
6634        const p = f;
6635        switch (p.code) {
6636          // -32700
6637          case ss.code:
6638            throw new ss(p);
6639          // -32600
6640          case is.code:
6641            throw new is(p);
6642          // -32601
6643          case os.code:
6644            throw new os(p, { method: n.method });
6645          // -32602
6646          case as.code:
6647            throw new as(p);
6648          // -32603
6649          case ir.code:
6650            throw new ir(p);
6651          // -32000
6652          case Pr.code:
6653            throw new Pr(p);
6654          // -32001
6655          case cs.code:
6656            throw new cs(p);
6657          // -32002
6658          case Pn.code:
6659            throw new Pn(p);
6660          // -32003
6661          case kr.code:
6662            throw new kr(p);
6663          // -32004
6664          case Kn.code:
6665            throw new Kn(p, {
6666              method: n.method
6667            });
6668          // -32005
6669          case Ur.code:
6670            throw new Ur(p);
6671          // -32006
6672          case us.code:
6673            throw new us(p);
6674          // 4001
6675          case Ke.code:
6676            throw new Ke(p);
6677          // 4100
6678          case ls.code:
6679            throw new ls(p);
6680          // 4200
6681          case ds.code:
6682            throw new ds(p);
6683          // 4900
6684          case fs.code:
6685            throw new fs(p);
6686          // 4901
6687          case hs.code:
6688            throw new hs(p);
6689          // 4902
6690          case zt.code:
6691            throw new zt(p);
6692          // 5700
6693          case ps.code:
6694            throw new ps(p);
6695          // 5710
6696          case ms.code:
6697            throw new ms(p);
6698          // 5720
6699          case gs.code:
6700            throw new gs(p);
6701          // 5730
6702          case ys.code:
6703            throw new ys(p);
6704          // 5740
6705          case bs.code:
6706            throw new bs(p);
6707          // 5750
6708          case ws.code:
6709            throw new ws(p);
6710          // 5760
6711          case Cs.code:
6712            throw new Cs(p);
6713          // CAIP-25: User Rejected Error
6714          // https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes#rejected-caip-25
6715          case 5e3:
6716            throw new Ke(p);
6717          // WalletConnect: Session Settlement Failed
6718          // https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes
6719          case Mr.code:
6720            throw new Mr(p);
6721          default:
6722            throw f instanceof F ? f : new K0(p);
6723        }
6724      }
6725    }, {
6726      delay: ({ count: f, error: p }) => {
6727        if (p && p instanceof ts) {
6728          const m = p?.headers?.get("Retry-After");
6729          if (m?.match(/\d/))
6730            return Number.parseInt(m, 10) * 1e3;
6731        }
6732        return ~~(1 << f) * o;
6733      },
6734      retryCount: a,
6735      shouldRetry: ({ error: f }) => Hg(f)
6736    }), { enabled: s, id: l });
6737  };
6738}
6739function Hg(e) {
6740  return "code" in e && typeof e.code == "number" ? e.code === -1 || e.code === Ur.code || e.code === ir.code || e.code === 429 : e instanceof ts && e.status ? e.status === 403 || e.status === 408 || e.status === 413 || e.status === 429 || e.status === 500 || e.status === 502 || e.status === 503 || e.status === 504 : !0;
6741}
6742function qg(e, t = 0) {
6743  let n = 3735928559 ^ t, r = 1103547991 ^ t;
6744  for (let s = 0; s < e.length; s++) {
6745    const i = e.charCodeAt(s);
6746    n = Math.imul(n ^ i, 2654435761), r = Math.imul(r ^ i, 1597334677);
6747  }
6748  return n = Math.imul(n ^ n >>> 16, 2246822507), n ^= Math.imul(r ^ r >>> 16, 3266489909), r = Math.imul(r ^ r >>> 16, 2246822507), r ^= Math.imul(n ^ n >>> 16, 3266489909), (4294967296 * (2097151 & r) + (n >>> 0)).toString(36);
6749}
6750function rf(e) {
6751  const t = {
6752    formatters: void 0,
6753    fees: void 0,
6754    serializers: void 0,
6755    ...e
6756  };
6757  function n(r) {
6758    return (s) => {
6759      const i = typeof s == "function" ? s(r) : s, o = { ...r, ...i };
6760      return Object.assign(o, { extend: n(o) });
6761    };
6762  }
6763  return Object.assign(t, {
6764    extend: n(t)
6765  });
6766}
6767function $_() {
6768  return {};
6769}
6770function sf(e, { errorInstance: t = new Error("timed out"), timeout: n, signal: r }) {
6771  return new Promise((s, i) => {
6772    (async () => {
6773      let o;
6774      try {
6775        const a = new AbortController();
6776        n > 0 && (o = setTimeout(() => {
6777          r ? a.abort() : i(t);
6778        }, n)), s(await e({ signal: a?.signal || null }));
6779      } catch (a) {
6780        a?.name === "AbortError" && i(t), i(a);
6781      } finally {
6782        clearTimeout(o);
6783      }
6784    })();
6785  });
6786}
6787function Gg() {
6788  return {
6789    current: 0,
6790    take() {
6791      return this.current++;
6792    },
6793    reset() {
6794      this.current = 0;
6795    }
6796  };
6797}
6798const gu = /* @__PURE__ */ Gg();
6799function zg(e, t = {}) {
6800  const { url: n, headers: r } = Vg(e);
6801  return {
6802    async request(s) {
6803      const { body: i, fetchFn: o = t.fetchFn ?? fetch, onRequest: a = t.onRequest, onResponse: u = t.onResponse, timeout: c = t.timeout ?? 1e4 } = s, l = {
6804        ...t.fetchOptions ?? {},
6805        ...s.fetchOptions ?? {}
6806      }, { headers: f, method: p, signal: m } = l;
6807      try {
6808        const y = await sf(async ({ signal: C }) => {
6809          const _ = {
6810            ...l,
6811            body: Array.isArray(i) ? At(i.map((E) => ({
6812              jsonrpc: "2.0",
6813              id: E.id ?? gu.take(),
6814              ...E
6815            }))) : At({
6816              jsonrpc: "2.0",
6817              id: i.id ?? gu.take(),
6818              ...i
6819            }),
6820            headers: {
6821              ...r,
6822              "Content-Type": "application/json",
6823              ...f
6824            },
6825            method: p || "POST",
6826            signal: m || (c > 0 ? C : null)
6827          }, R = new Request(n, _), N = await a?.(R, _) ?? { ..._, url: n };
6828          return await o(N.url ?? n, N);
6829        }, {
6830          errorInstance: new tu({ body: i, url: n }),
6831          timeout: c,
6832          signal: !0
6833        });
6834        u && await u(y);
6835        let b;
6836        if (y.headers.get("Content-Type")?.startsWith("application/json"))
6837          b = await y.json();
6838        else {
6839          b = await y.text();
6840          try {
6841            b = JSON.parse(b || "{}");
6842          } catch (C) {
6843            if (y.ok)
6844              throw C;
6845            b = { error: b };
6846          }
6847        }
6848        if (!y.ok) {
6849          if (typeof b.error?.code == "number" && typeof b.error?.message == "string")
6850            return b;
6851          throw new ts({
6852            body: i,
6853            details: At(b.error) || y.statusText,
6854            headers: y.headers,
6855            status: y.status,
6856            url: n
6857          });
6858        }
6859        return b;
6860      } catch (y) {
6861        throw y instanceof ts || y instanceof tu ? y : new ts({
6862          body: i,
6863          cause: y,
6864          url: n
6865        });
6866      }
6867    }
6868  };
6869}
6870function Vg(e) {
6871  try {
6872    const t = new URL(e), n = (() => {
6873      if (t.username) {
6874        const r = `${decodeURIComponent(t.username)}:${decodeURIComponent(t.password)}`;
6875        return t.username = "", t.password = "", {
6876          url: t.toString(),
6877          headers: { Authorization: `Basic ${btoa(r)}` }
6878        };
6879      }
6880    })();
6881    return { url: t.toString(), ...n };
6882  } catch {
6883    return { url: e };
6884  }
6885}
6886class Kg extends F {
6887  constructor({ value: t }) {
6888    super(`Number \`${t}\` is not a valid decimal number.`, {
6889      name: "InvalidDecimalNumberError"
6890    });
6891  }
6892}
6893function Yg(e, t) {
6894  if (!/^(-?)([0-9]*)\.?([0-9]*)$/.test(e))
6895    throw new Kg({ value: e });
6896  let [n, r = "0"] = e.split(".");
6897  const s = n.startsWith("-");
6898  if (s && (n = n.slice(1)), r = r.replace(/(0+)$/, ""), t === 0)
6899    Math.round(+`.${r}`) === 1 && (n = `${BigInt(n) + 1n}`), r = "";
6900  else if (r.length > t) {
6901    const [i, o, a] = [
6902      r.slice(0, t - 1),
6903      r.slice(t - 1, t),
6904      r.slice(t)
6905    ], u = Math.round(+`${o}.${a}`);
6906    u > 9 ? r = `${BigInt(i) + BigInt(1)}0`.padStart(i.length + 1, "0") : r = `${i}${u}`, r.length > t && (r = r.slice(1), n = `${BigInt(n) + 1n}`), r = r.slice(0, t);
6907  } else
6908    r = r.padEnd(t, "0");
6909  return BigInt(`${s ? "-" : ""}${n}${r}`);
6910}
6911async function of(e, { blockHash: t, blockNumber: n, blockTag: r, hash: s, index: i, sender: o, nonce: a }) {
6912  const u = r || "latest", c = n !== void 0 ? be(n) : void 0;
6913  let l = null;
6914  if (s ? l = await e.request({
6915    method: "eth_getTransactionByHash",
6916    params: [s]
6917  }, { dedupe: !0 }) : t ? l = await e.request({
6918    method: "eth_getTransactionByBlockHashAndIndex",
6919    params: [t, be(i)]
6920  }, { dedupe: !0 }) : typeof i == "number" ? l = await e.request({
6921    method: "eth_getTransactionByBlockNumberAndIndex",
6922    params: [c || u, be(i)]
6923  }, { dedupe: !!c }) : o && typeof a == "number" && (l = await e.request({
6924    method: "eth_getTransactionBySenderAndNonce",
6925    params: [o, be(a)]
6926  }, { dedupe: !0 })), !l)
6927    throw new od({
6928      blockHash: t,
6929      blockNumber: n,
6930      blockTag: u,
6931      hash: s,
6932      index: i
6933    });
6934  return (e.chain?.formatters?.transaction?.format || go)(l, "getTransaction");
6935}
6936async function Wo(e, { hash: t }) {
6937  const n = await e.request({
6938    method: "eth_getTransactionReceipt",
6939    params: [t]
6940  }, { dedupe: !0 });
6941  if (!n)
6942    throw new ad({ hash: t });
6943  return (e.chain?.formatters?.transactionReceipt?.format || ef)(n, "getTransactionReceipt");
6944}
6945function Zg(e, { emitOnBegin: t = !1, emitMissed: n = !1, onBlockNumber: r, onError: s, poll: i, pollingInterval: o = e.pollingInterval }) {
6946  const a = typeof i < "u" ? i : !(e.transport.type === "webSocket" || e.transport.type === "ipc" || e.transport.type === "fallback" && (e.transport.transports[0].c
6946onfig.type === "webSocket" || e.transport.transports[0].config.type === "ipc"));
6947  let u;
6948  return a ? (() => {
6949    const f = At([
6950      "watchBlockNumber",
6951      e.uid,
6952      t,
6953      n,
6954      o
6955    ]);
6956    return Wi(f, { onBlockNumber: r, onError: s }, (p) => Jd(async () => {
6957      try {
6958        const m = await ke(e, kg, "getBlockNumber")({ cacheTime: 0 });
6959        if (u !== void 0) {
6960          if (m === u)
6961            return;
6962          if (m - u > 1 && n)
6963            for (let y = u + 1n; y < m; y++)
6964              p.onBlockNumber(y, u), u = y;
6965        }
6966        (u === void 0 || m > u) && (p.onBlockNumber(m, u), u = m);
6967      } catch (m) {
6968        p.onError?.(m);
6969      }
6970    }, {
6971      emitOnBegin: t,
6972      interval: o
6973    }));
6974  })() : (() => {
6975    const f = At([
6976      "watchBlockNumber",
6977      e.uid,
6978      t,
6979      n
6980    ]);
6981    return Wi(f, { onBlockNumber: r, onError: s }, (p) => {
6982      let m = !0, y = () => m = !1;
6983      return (async () => {
6984        try {
6985          const b = (() => {
6986            if (e.transport.type === "fallback") {
6987              const _ = e.transport.transports.find((R) => R.config.type === "webSocket" || R.config.type === "ipc");
6988              return _ ? _.value : e.transport;
6989            }
6990            return e.transport;
6991          })(), { unsubscribe: C } = await b.subscribe({
6992            params: ["newHeads"],
6993            onData(_) {
6994              if (!m)
6995                return;
6996              const R = nr(_.result?.number);
6997              p.onBlockNumber(R, u), u = R;
6998            },
6999            onError(_) {
7000              p.onError?.(_);
7001            }
7002          });
7003          y = C, m || y();
7004        } catch (b) {
7005          s?.(b);
7006        }
7007      })(), () => y();
7008    });
7009  })();
7010}
7011async function Qg(e, t) {
7012  const {
7013    checkReplacement: n = !0,
7014    confirmations: r = 1,
7015    hash: s,
7016    onReplaced: i,
7017    retryCount: o = 6,
7018    retryDelay: a = ({ count: E }) => ~~(1 << E) * 200,
7019    // exponential backoff
7020    timeout: u = 18e4
7021  } = t, c = At(["waitForTransactionReceipt", e.uid, s]), l = t.pollingInterval ? t.pollingInterval : e.chain?.experimental_preconfirmationTime ? e.chain.experimental_preconfirmationTime : e.pollingInterval;
7022  let f, p, m, y = !1, b, C;
7023  const { promise: _, resolve: R, reject: N } = Kd(), I = u ? setTimeout(() => {
7024    C?.(), b?.(), N(new j0({ hash: s }));
7025  }, u) : void 0;
7026  return b = Wi(c, { onReplaced: i, resolve: R, reject: N }, async (E) => {
7027    if (m = await ke(e, Wo, "getTransactionReceipt")({ hash: s }).catch(() => {
7028    }), m && r <= 1) {
7029      clearTimeout(I), E.resolve(m), b?.();
7030      return;
7031    }
7032    C = ke(e, Zg, "watchBlockNumber")({
7033      emitMissed: !0,
7034      emitOnBegin: !0,
7035      poll: !0,
7036      pollingInterval: l,
7037      async onBlockNumber(T) {
7038        const O = (M) => {
7039          clearTimeout(I), C?.(), M(), b?.();
7040        };
7041        let U = T;
7042        if (!y)
7043          try {
7044            if (m) {
7045              if (r > 1 && (!m.blockNumber || U - m.blockNumber + 1n < r))
7046                return;
7047              O(() => E.resolve(m));
7048              return;
7049            }
7050            if (n && !f && (y = !0, await qi(async () => {
7051              f = await ke(e, of, "getTransaction")({ hash: s }), f.blockNumber && (U = f.blockNumber);
7052            }, {
7053              delay: a,
7054              retryCount: o
7055            }), y = !1), m = await ke(e, Wo, "getTransactionReceipt")({ hash: s }), r > 1 && (!m.blockNumber || U - m.blockNumber + 1n < r))
7056              return;
7057            O(() => E.resolve(m));
7058          } catch (M) {
7059            if (M instanceof od || M instanceof ad) {
7060              if (!f) {
7061                y = !1;
7062                return;
7063              }
7064              try {
7065                p = f, y = !0;
7066                const L = await qi(() => ke(e, Lr, "getBlock")({
7067                  blockNumber: U,
7068                  includeTransactions: !0
7069                }), {
7070                  delay: a,
7071                  retryCount: o,
7072                  shouldRetry: ({ error: fe }) => fe instanceof md
7073                });
7074                y = !1;
7075                const re = L.transactions.find(({ from: fe, nonce: ae }) => fe === p.from && ae === p.nonce);
7076                if (!re || (m = await ke(e, Wo, "getTransactionReceipt")({
7077                  hash: re.hash
7078                }), r > 1 && (!m.blockNumber || U - m.blockNumber + 1n < r)))
7079                  return;
7080                let ne = "replaced";
7081                re.to === p.to && re.value === p.value && re.input === p.input ? ne = "repriced" : re.from === re.to && re.value === 0n && (ne = "cancelled"), O(() => {
7082                  E.onReplaced?.({
7083                    reason: ne,
7084                    replacedTransaction: p,
7085                    transaction: re,
7086                    transactionReceipt: m
7087                  }), E.resolve(m);
7088                });
7089              } catch (L) {
7090                O(() => E.reject(L));
7091              }
7092            } else
7093              O(() => E.reject(M));
7094          }
7095      }
7096    });
7097  }), _;
7098}
7099function Jg(e, { batch: t = !0, onError: n, onTransactions: r, poll: s, pollingInterval: i = e.pollingInterval }) {
7100  return (typeof s < "u" ? s : e.transport.type !== "webSocket" && e.transport.type !== "ipc") ? (() => {
7101    const c = At([
7102      "watchPendingTransactions",
7103      e.uid,
7104      t,
7105      i
7106    ]);
7107    return Wi(c, { onTransactions: r, onError: n }, (l) => {
7108      let f;
7109      const p = Jd(async () => {
7110        try {
7111          if (!f)
7112            try {
7113              f = await ke(e, Fg, "createPendingTransactionFilter")({});
7114              return;
7115            } catch (y) {
7116              throw p(), y;
7117            }
7118          const m = await ke(e, Ug, "getFilterChanges")({ filter: f });
7119          if (m.length === 0)
7120            return;
7121          if (t)
7122            l.onTransactions(m);
7123          else
7124            for (const y of m)
7125              l.onTransactions([y]);
7126        } catch (m) {
7127          l.onError?.(m);
7128        }
7129      }, {
7130        emitOnBegin: !0,
7131        interval: i
7132      });
7133      return async () => {
7134        f && await ke(e, Mg, "uninstallFilter")({ filter: f }), p();
7135      };
7136    });
7137  })() : (() => {
7138    let c = !0, l = () => c = !1;
7139    return (async () => {
7140      try {
7141        const { unsubscribe: f } = await e.transport.subscribe({
7142          params: ["newPendingTransactions"],
7143          onData(p) {
7144            if (!c)
7145              return;
7146            const m = p.result;
7147            r([m]);
7148          },
7149          onError(p) {
7150            n?.(p);
7151          }
7152        });
7153        l = f, c || l();
7154      } catch (f) {
7155        n?.(f);
7156      }
7157    })(), () => l();
7158  })();
7159}
7160async function Xg(e, { account: t = e.account, message: n }) {
7161  if (!t)
7162    throw new _c({
7163      docsPath: "/docs/actions/wallet/signMessage"
7164    });
7165  const r = vt(t);
7166  if (r.signMessage)
7167    return r.signMessage({ message: n });
7168  const s = typeof n == "string" ? tc(n) : n.raw instanceof Uint8Array ? ns(n.raw) : n.raw;
7169  return e.request({
7170    method: "personal_sign",
7171    params: [s, r.address]
7172  }, { retryCount: 0 });
7173}
7174function Nc({ key: e, methods: t, name: n, request: r, retryCount: s = 3, retryDelay: i = 150, timeout: o, type: a }, u) {
7175  const c = tf();
7176  return {
7177    config: {
7178      key: e,
7179      methods: t,
7180      name: n,
7181      request: r,
7182      retryCount: s,
7183      retryDelay: i,
7184      timeout: o,
7185      type: a
7186    },
7187    request: $g(r, { methods: t, retryCount: s, retryDelay: i, uid: c }),
7188    value: u
7189  };
7190}
7191function ey(e, t = {}) {
7192  const { key: n = "custom", methods: r, name: s = "Custom Provider", retryDelay: i } = t;
7193  return ({ retryCount: o }) => Nc({
7194    key: n,
7195    methods: r,
7196    name: s,
7197    request: e.request.bind(e),
7198    retryCount: t.retryCount ?? o,
7199    retryDelay: i,
7200    type: "custom"
7201  });
7202}
7203function yu(e, t = {}) {
7204  const { key: n = "fallback", name: r = "Fallback", rank: s = !1, shouldThrow: i = ty, retryCount: o, retryDelay: a } = t;
7205  return (({ chain: u, pollingInterval: c = 4e3, timeout: l, ...f }) => {
7206    let p = e, m = () => {
7207    };
7208    const y = Nc({
7209      key: n,
7210      name: r,
7211      async request({ method: b, params: C }) {
7212        let _;
7213        const R = async (N = 0) => {
7214          const I = p[N]({
7215            ...f,
7216            chain: u,
7217            retryCount: 0,
7218            timeout: l
7219          });
7220          try {
7221            const E = await I.request({
7222              method: b,
7223              params: C
7224            });
7225            return m({
7226              method: b,
7227              params: C,
7228              response: E,
7229              transport: I,
7230              status: "success"
7231            }), E;
7232          } catch (E) {
7233            if (m({
7234              error: E,
7235              method: b,
7236              params: C,
7237              transport: I,
7238              status: "error"
7239            }), i(E) || N === p.length - 1 || (_ ??= p.slice(N + 1).some((T) => {
7240              const { include: O, exclude: U } = T({ chain: u }).config.methods || {};
7241              return O ? O.includes(b) : U ? !U.includes(b) : !0;
7242            }), !_))
7243              throw E;
7244            return R(N + 1);
7245          }
7246        };
7247        return R();
7248      },
7249      retryCount: o,
7250      retryDelay: a,
7251      type: "fallback"
7252    }, {
7253      onResponse: (b) => m = b,
7254      transports: p.map((b) => b({ chain: u, retryCount: 0 }))
7255    });
7256    if (s) {
7257      const b = typeof s == "object" ? s : {};
7258      ny({
7259        chain: u,
7260        interval: b.interval ?? c,
7261        onTransports: (C) => p = C,
7262        ping: b.ping,
7263        sampleCount: b.sampleCount,
7264        timeout: b.timeout,
7265        transports: p,
7266        weights: b.weights
7267      });
7268    }
7269    return y;
7270  });
7271}
7272function ty(e) {
7273  return !!("code" in e && typeof e.code == "number" && (e.code === kr.code || e.code === Ke.code || e.code === Mr.code || Yn.nodeMessage.test(e.message) || e.code === 5e3));
7274}
7275function ny({ chain: e, interval: t = 4e3, onTransports: n, ping: r, sampleCount: s = 10, timeout: i = 1e3, transports: o, weights: a = {} }) {
7276  const { stability: u = 0.7, latency: c = 0.3 } = a, l = [], f = async () => {
7277    const p = await Promise.all(o.map(async (b) => {
7278      const C = b({ chain: e, retryCount: 0, timeout: i }), _ = Date.now();
7279      let R, N;
7280      try {
7281        await (r ? r({ transport: C }) : C.request({ method: "net_listening" })), N = 1;
7282      } catch {
7283        N = 0;
7284      } finally {
7285        R = Date.now();
7286      }
7287      return { latency: R - _, success: N };
7288    }));
7289    l.push(p), l.length > s && l.shift();
7290    const m = Math.max(...l.map((b) => Math.max(...b.map(({ latency: C }) => C)))), y = o.map((b, C) => {
7291      const _ = l.map((T) => T[C].latency), N = 1 - _.reduce((T, O) => T + O, 0) / _.length / m, I = l.map((T) => T[C].success), E = I.reduce((T, O) => T + O, 0) / I.length;
7292      return E === 0 ? [0, C] : [
7293        c * N + u * E,
7294        C
7295      ];
7296    }).sort((b, C) => C[0] - b[0]);
7297    n(y.map(([, b]) => o[b])), await $i(t), f();
7298  };
7299  f();
7300}
7301class ry extends F {
7302  constructor() {
7303    super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.", {
7304      docsPath: "/docs/clients/intro",
7305      name: "UrlRequiredError"
7306    });
7307  }
7308}
7309function li(e, t = {}) {
7310  const { batch: n, fetchFn: r, fetchOptions: s, key: i = "http", methods: o, name: a = "HTTP JSON-RPC", onFetchRequest: u, onFetchResponse: c, retryDelay: l, raw: f } = t;
7311  return ({ chain: p, retryCount: m, timeout: y }) => {
7312    const { batchSize: b = 1e3, wait: C = 0 } = typeof n == "object" ? n : {}, _ = t.retryCount ?? m, R = y ?? t.timeout ?? 1e4, N = e || p?.rpcUrls.default.http[0];
7313    if (!N)
7314      throw new ry();
7315    const I = zg(N, {
7316      fetchFn: r,
7317      fetchOptions: s,
7318      onRequest: u,
7319      onResponse: c,
7320      timeout: R
7321    });
7322    return Nc({
7323      key: i,
7324      methods: o,
7325      name: a,
7326      async request({ method: E, params: T }) {
7327        const O = { method: E, params: T }, { schedule: U } = Yd({
7328          id: N,
7329          wait: C,
7330          shouldSplitBatch(ne) {
7331            return ne.length > b;
7332          },
7333          fn: (ne) => I.request({
7334            body: ne
7335          }),
7336          sort: (ne, fe) => ne.id - fe.id
7337        }), M = async (ne) => n ? U(ne) : [
7338          await I.request({
7339            body: ne
7340          })
7341        ], [{ error: L, result: re }] = await M(O);
7342        if (f)
7343          return { error: L, result: re };
7344        if (L)
7345          throw new pc({
7346            body: O,
7347            error: L,
7348            url: N
7349          });
7350        return re;
7351      },
7352      retryCount: _,
7353      retryDelay: l,
7354      timeout: R,
7355      type: "http"
7356    }, {
vendor: 3,761 bytes, lines 7357-7439
7357      fetchOptions: s,
7358      url: N
7359    });
7360  };
7361}
7362var $o = {}, Kr = {}, bu;
7363function sy() {
7364  if (bu) return Kr;
7365  bu = 1, Kr.byteLength = a, Kr.toByteArray = c, Kr.fromByteArray = p;
7366  for (var e = [], t = [], n = typeof Uint8Array < "u" ? Uint8Array : Array, r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", s = 0, i = r.length; s < i; ++s)
7367    e[s] = r[s], t[r.charCodeAt(s)] = s;
7368  t[45] = 62, t[95] = 63;
7369  function o(m) {
7370    var y = m.length;
7371    if (y % 4 > 0)
7372      throw new Error("Invalid string. Length must be a multiple of 4");
7373    var b = m.indexOf("=");
7374    b === -1 && (b = y);
7375    var C = b === y ? 0 : 4 - b % 4;
7376    return [b, C];
7377  }
7378  function a(m) {
7379    var y = o(m), b = y[0], C = y[1];
7380    return (b + C) * 3 / 4 - C;
7381  }
7382  function u(m, y, b) {
7383    return (y + b) * 3 / 4 - b;
7384  }
7385  function c(m) {
7386    var y, b = o(m), C = b[0], _ = b[1], R = new n(u(m, C, _)), N = 0, I = _ > 0 ? C - 4 : C, E;
7387    for (E = 0; E < I; E += 4)
7388      y = t[m.charCodeAt(E)] << 18 | t[m.charCodeAt(E + 1)] << 12 | t[m.charCodeAt(E + 2)] << 6 | t[m.charCodeAt(E + 3)], R[N++] = y >> 16 & 255, R[N++] = y >> 8 & 255, R[N++] = y & 255;
7389    return _ === 2 && (y = t[m.charCodeAt(E)] << 2 | t[m.charCodeAt(E + 1)] >> 4, R[N++] = y & 255), _ === 1 && (y = t[m.charCodeAt(E)] << 10 | t[m.charCodeAt(E + 1)] << 4 | t[m.charCodeAt(E + 2)] >> 2, R[N++] = y >> 8 & 255, R[N++] = y & 255), R;
7390  }
7391  function l(m) {
7392    return e[m >> 18 & 63] + e[m >> 12 & 63] + e[m >> 6 & 63] + e[m & 63];
7393  }
7394  function f(m, y, b) {
7395    for (var C, _ = [], R = y; R < b; R += 3)
7396      C = (m[R] << 16 & 16711680) + (m[R + 1] << 8 & 65280) + (m[R + 2] & 255), _.push(l(C));
7397    return _.join("");
7398  }
7399  function p(m) {
7400    for (var y, b = m.length, C = b % 3, _ = [], R = 16383, N = 0, I = b - C; N < I; N += R)
7401      _.push(f(m, N, N + R > I ? I : N + R));
7402    return C === 1 ? (y = m[b - 1], _.push(
7403      e[y >> 2] + e[y << 4 & 63] + "=="
7404    )) : C === 2 && (y = (m[b - 2] << 8) + m[b - 1], _.push(
7405      e[y >> 10] + e[y >> 4 & 63] + e[y << 2 & 63] + "="
7406    )), _.join("");
7407  }
7408  return Kr;
7409}
7410var di = {};
7411var wu;
7412function iy() {
7413  return wu || (wu = 1, di.read = function(e, t, n, r, s) {
7414    var i, o, a = s * 8 - r - 1, u = (1 << a) - 1, c = u >> 1, l = -7, f = n ? s - 1 : 0, p = n ? -1 : 1, m = e[t + f];
7415    for (f += p, i = m & (1 << -l) - 1, m >>= -l, l += a; l > 0; i = i * 256 + e[t + f], f += p, l -= 8)
7416      ;
7417    for (o = i & (1 << -l) - 1, i >>= -l, l += r; l > 0; o = o * 256 + e[t + f], f += p, l -= 8)
7418      ;
7419    if (i === 0)
7420      i = 1 - c;
7421    else {
7422      if (i === u)
7423        return o ? NaN : (m ? -1 : 1) * (1 / 0);
7424      o = o + Math.pow(2, r), i = i - c;
7425    }
7426    return (m ? -1 : 1) * o * Math.pow(2, i - r);
7427  }, di.write = function(e, t, n, r, s, i) {
7428    var o, a, u, c = i * 8 - s - 1, l = (1 << c) - 1, f = l >> 1, p = s === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, m = r ? 0 : i - 1, y = r ? 1 : -1, b = t < 0 || t === 0 && 1 / t < 0 ? 1 : 0;
7429    for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (a = isNaN(t) ? 1 : 0, o = l) : (o = Math.floor(Math.log(t) / Math.LN2), t * (u = Math.pow(2, -o)) < 1 && (o--, u *= 2), o + f >= 1 ? t += p / u : t += p * Math.pow(2, 1 - f), t * u >= 2 && (o++, u /= 2), o + f >= l ? (a = 0, o = l) : o + f >= 1 ? (a = (t * u - 1) * Math.pow(2, s), o = o + f) : (a = t * Math.pow(2, f - 1) * Math.pow(2, s), o = 0)); s >= 8; e[n + m] = a & 255, m += y, a /= 256, s -= 8)
7430      ;
7431    for (o = o << s | a, c += s; c > 0; e[n + m] = o & 255, m += y, o /= 256, c -= 8)
7432      ;
7433    e[n + m - y] |= b * 128;
7434  }), di;
7435}
7436var Cu;
7437function oy() {
7438  return Cu || (Cu = 1, (function(e) {
7439    const t = sy(), n = iy(), r = typeof Symbol == "function" && typeof Symbol.for == "function" ? /* @__P
vendor: 30,557 bytes, lines 7439-8160
7439URE__ */ Symbol.for("nodejs.util.inspect.custom") : null;
7440    e.Buffer = a, e.SlowBuffer = R, e.INSPECT_MAX_BYTES = 50;
7441    const s = 2147483647;
7442    e.kMaxLength = s, a.TYPED_ARRAY_SUPPORT = i(), !a.TYPED_ARRAY_SUPPORT && typeof console < "u" && typeof console.error == "function" && console.error(
7443      "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
7444    );
7445    function i() {
7446      try {
7447        const w = new Uint8Array(1), d = { foo: function() {
7448          return 42;
7449        } };
7450        return Object.setPrototypeOf(d, Uint8Array.prototype), Object.setPrototypeOf(w, d), w.foo() === 42;
7451      } catch {
7452        return !1;
7453      }
7454    }
7455    Object.defineProperty(a.prototype, "parent", {
7456      enumerable: !0,
7457      get: function() {
7458        if (a.isBuffer(this))
7459          return this.buffer;
7460      }
7461    }), Object.defineProperty(a.prototype, "offset", {
7462      enumerable: !0,
7463      get: function() {
7464        if (a.isBuffer(this))
7465          return this.byteOffset;
7466      }
7467    });
7468    function o(w) {
7469      if (w > s)
7470        throw new RangeError('The value "' + w + '" is invalid for option "size"');
7471      const d = new Uint8Array(w);
7472      return Object.setPrototypeOf(d, a.prototype), d;
7473    }
7474    function a(w, d, h) {
7475      if (typeof w == "number") {
7476        if (typeof d == "string")
7477          throw new TypeError(
7478            'The "string" argument must be of type string. Received type number'
7479          );
7480        return f(w);
7481      }
7482      return u(w, d, h);
7483    }
7484    a.poolSize = 8192;
7485    function u(w, d, h) {
7486      if (typeof w == "string")
7487        return p(w, d);
7488      if (ArrayBuffer.isView(w))
7489        return y(w);
7490      if (w == null)
7491        throw new TypeError(
7492          "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof w
7493        );
7494      if (Bt(w, ArrayBuffer) || w && Bt(w.buffer, ArrayBuffer) || typeof SharedArrayBuffer < "u" && (Bt(w, SharedArrayBuffer) || w && Bt(w.buffer, SharedArrayBuffer)))
7495        return b(w, d, h);
7496      if (typeof w == "number")
7497        throw new TypeError(
7498          'The "value" argument must not be of type number. Received type number'
7499        );
7500      const A = w.valueOf && w.valueOf();
7501      if (A != null && A !== w)
7502        return a.from(A, d, h);
7503      const S = C(w);
7504      if (S) return S;
7505      if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof w[Symbol.toPrimitive] == "function")
7506        return a.from(w[Symbol.toPrimitive]("string"), d, h);
7507      throw new TypeError(
7508        "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof w
7509      );
7510    }
7511    a.from = function(w, d, h) {
7512      return u(w, d, h);
7513    }, Object.setPrototypeOf(a.prototype, Uint8Array.prototype), Object.setPrototypeOf(a, Uint8Array);
7514    function c(w) {
7515      if (typeof w != "number")
7516        throw new TypeError('"size" argument must be of type number');
7517      if (w < 0)
7518        throw new RangeError('The value "' + w + '" is invalid for option "size"');
7519    }
7520    function l(w, d, h) {
7521      return c(w), w <= 0 ? o(w) : d !== void 0 ? typeof h == "string" ? o(w).fill(d, h) : o(w).fill(d) : o(w);
7522    }
7523    a.alloc = function(w, d, h) {
7524      return l(w, d, h);
7525    };
7526    function f(w) {
7527      return c(w), o(w < 0 ? 0 : _(w) | 0);
7528    }
7529    a.allocUnsafe = function(w) {
7530      return f(w);
7531    }, a.allocUnsafeSlow = function(w) {
7532      return f(w);
7533    };
7534    function p(w, d) {
7535      if ((typeof d != "string" || d === "") && (d = "utf8"), !a.isEncoding(d))
7536        throw new TypeError("Unknown encoding: " + d);
7537      const h = N(w, d) | 0;
7538      let A = o(h);
7539      const S = A.write(w, d);
7540      return S !== h && (A = A.slice(0, S)), A;
7541    }
7542    function m(w) {
7543      const d = w.length < 0 ? 0 : _(w.length) | 0, h = o(d);
7544      for (let A = 0; A < d; A += 1)
7545        h[A] = w[A] & 255;
7546      return h;
7547    }
7548    function y(w) {
7549      if (Bt(w, Uint8Array)) {
7550        const d = new Uint8Array(w);
7551        return b(d.buffer, d.byteOffset, d.byteLength);
7552      }
7553      return m(w);
7554    }
7555    function b(w, d, h) {
7556      if (d < 0 || w.byteLength < d)
7557        throw new RangeError('"offset" is outside of buffer bounds');
7558      if (w.byteLength < d + (h || 0))
7559        throw new RangeError('"length" is outside of buffer bounds');
7560      let A;
7561      return d === void 0 && h === void 0 ? A = new Uint8Array(w) : h === void 0 ? A = new Uint8Array(w, d) : A = new Uint8Array(w, d, h), Object.setPrototypeOf(A, a.prototype), A;
7562    }
7563    function C(w) {
7564      if (a.isBuffer(w)) {
7565        const d = _(w.length) | 0, h = o(d);
7566        return h.length === 0 || w.copy(h, 0, 0, d), h;
7567      }
7568      if (w.length !== void 0)
7569        return typeof w.length != "number" || Io(w.length) ? o(0) : m(w);
7570      if (w.type === "Buffer" && Array.isArray(w.data))
7571        return m(w.data);
7572    }
7573    function _(w) {
7574      if (w >= s)
7575        throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + s.toString(16) + " bytes");
7576      return w | 0;
7577    }
7578    function R(w) {
7579      return +w != w && (w = 0), a.alloc(+w);
7580    }
7581    a.isBuffer = function(d) {
7582      return d != null && d._isBuffer === !0 && d !== a.prototype;
7583    }, a.compare = function(d, h) {
7584      if (Bt(d, Uint8Array) && (d = a.from(d, d.offset, d.byteLength)), Bt(h, Uint8Array) && (h = a.from(h, h.offset, h.byteLength)), !a.isBuffer(d) || !a.isBuffer(h))
7585        throw new TypeError(
7586          'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
7587        );
7588      if (d === h) return 0;
7589      let A = d.length, S = h.length;
7590      for (let k = 0, B = Math.min(A, S); k < B; ++k)
7591        if (d[k] !== h[k]) {
7592          A = d[k], S = h[k];
7593          break;
7594        }
7595      return A < S ? -1 : S < A ? 1 : 0;
7596    }, a.isEncoding = function(d) {
7597      switch (String(d).toLowerCase()) {
7598        case "hex":
7599        case "utf8":
7600        case "utf-8":
7601        case "ascii":
7602        case "latin1":
7603        case "binary":
7604        case "base64":
7605        case "ucs2":
7606        case "ucs-2":
7607        case "utf16le":
7608        case "utf-16le":
7609          return !0;
7610        default:
7611          return !1;
7612      }
7613    }, a.concat = function(d, h) {
7614      if (!Array.isArray(d))
7615        throw new TypeError('"list" argument must be an Array of Buffers');
7616      if (d.length === 0)
7617        return a.alloc(0);
7618      let A;
7619      if (h === void 0)
7620        for (h = 0, A = 0; A < d.length; ++A)
7621          h += d[A].length;
7622      const S = a.allocUnsafe(h);
7623      let k = 0;
7624      for (A = 0; A < d.length; ++A) {
7625        let B = d[A];
7626        if (Bt(B, Uint8Array))
7627          k + B.length > S.length ? (a.isBuffer(B) || (B = a.from(B)), B.copy(S, k)) : Uint8Array.prototype.set.call(
7628            S,
7629            B,
7630            k
7631          );
7632        else if (a.isBuffer(B))
7633          B.copy(S, k);
7634        else
7635          throw new TypeError('"list" argument must be an Array of Buffers');
7636        k += B.length;
7637      }
7638      return S;
7639    };
7640    function N(w, d) {
7641      if (a.isBuffer(w))
7642        return w.length;
7643      if (ArrayBuffer.isView(w) || Bt(w, ArrayBuffer))
7644        return w.byteLength;
7645      if (typeof w != "string")
7646        throw new TypeError(
7647          'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof w
7648        );
7649      const h = w.length, A = arguments.length > 2 && arguments[2] === !0;
7650      if (!A && h === 0) return 0;
7651      let S = !1;
7652      for (; ; )
7653        switch (d) {
7654          case "ascii":
7655          case "latin1":
7656          case "binary":
7657            return h;
7658          case "utf8":
7659          case "utf-8":
7660            return No(w).length;
7661          case "ucs2":
7662          case "ucs-2":
7663          case "utf16le":
7664          case "utf-16le":
7665            return h * 2;
7666          case "hex":
7667            return h >>> 1;
7668          case "base64":
7669            return Fc(w).length;
7670          default:
7671            if (S)
7672              return A ? -1 : No(w).length;
7673            d = ("" + d).toLowerCase(), S = !0;
7674        }
7675    }
7676    a.byteLength = N;
7677    function I(w, d, h) {
7678      let A = !1;
7679      if ((d === void 0 || d < 0) && (d = 0), d > this.length || ((h === void 0 || h > this.length) && (h = this.length), h <= 0) || (h >>>= 0, d >>>= 0, h <= d))
7680        return "";
7681      for (w || (w = "utf8"); ; )
7682        switch (w) {
7683          case "hex":
7684            return Re(this, d, h);
7685          case "utf8":
7686          case "utf-8":
7687            return ae(this, d, h);
7688          case "ascii":
7689            return de(this, d, h);
7690          case "latin1":
7691          case "binary":
7692            return Ie(this, d, h);
7693          case "base64":
7694            return fe(this, d, h);
7695          case "ucs2":
7696          case "ucs-2":
7697          case "utf16le":
7698          case "utf-16le":
7699            return ge(this, d, h);
7700          default:
7701            if (A) throw new TypeError("Unknown encoding: " + w);
7702            w = (w + "").toLowerCase(), A = !0;
7703        }
7704    }
7705    a.prototype._isBuffer = !0;
7706    function E(w, d, h) {
7707      const A = w[d];
7708      w[d] = w[h], w[h] = A;
7709    }
7710    a.prototype.swap16 = function() {
7711      const d = this.length;
7712      if (d % 2 !== 0)
7713        throw new RangeError("Buffer size must be a multiple of 16-bits");
7714      for (let h = 0; h < d; h += 2)
7715        E(this, h, h + 1);
7716      return this;
7717    }, a.prototype.swap32 = function() {
7718      const d = this.length;
7719      if (d % 4 !== 0)
7720        throw new RangeError("Buffer size must be a multiple of 32-bits");
7721      for (let h = 0; h < d; h += 4)
7722        E(this, h, h + 3), E(this, h + 1, h + 2);
7723      return this;
7724    }, a.prototype.swap64 = function() {
7725      const d = this.length;
7726      if (d % 8 !== 0)
7727        throw new RangeError("Buffer size must be a multiple of 64-bits");
7728      for (let h = 0; h < d; h += 8)
7729        E(this, h, h + 7), E(this, h + 1, h + 6), E(this, h + 2, h + 5), E(this, h + 3, h + 4);
7730      return this;
7731    }, a.prototype.toString = function() {
7732      const d = this.length;
7733      return d === 0 ? "" : arguments.length === 0 ? ae(this, 0, d) : I.apply(this, arguments);
7734    }, a.prototype.toLocaleString = a.prototype.toString, a.prototype.equals = function(d) {
7735      if (!a.isBuffer(d)) throw new TypeError("Argument must be a Buffer");
7736      return this === d ? !0 : a.compare(this, d) === 0;
7737    }, a.prototype.inspect = function() {
7738      let d = "";
7739      const h = e.INSPECT_MAX_BYTES;
7740      return d = this.toString("hex", 0, h).replace(/(.{2})/g, "$1 ").trim(), this.length > h && (d += " ... "), "<Buffer " + d + ">";
7741    }, r && (a.prototype[r] = a.prototype.inspect), a.prototype.compare = function(d, h, A, S, k) {
7742      if (Bt(d, Uint8Array) && (d = a.from(d, d.offset, d.byteLength)), !a.isBuffer(d))
7743        throw new TypeError(
7744          'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof d
7745        );
7746      if (h === void 0 && (h = 0), A === void 0 && (A = d ? d.length : 0), S === void 0 && (S = 0), k === void 0 && (k = this.length), h < 0 || A > d.length || S < 0 || k > this.length)
7747        throw new RangeError("out of range index");
7748      if (S >= k && h >= A)
7749        return 0;
7750      if (S >= k)
7751        return -1;
7752      if (h >= A)
7753        return 1;
7754      if (h >>>= 0, A >>>= 0, S >>>= 0, k >>>= 0, this === d) return 0;
7755      let B = k - S, we = A - h;
7756      const je = Math.min(B, we), Le = this.slice(S, k), We = d.slice(h, A);
7757      for (let Pe = 0; Pe < je; ++Pe)
7758        if (Le[Pe] !== We[Pe]) {
7759          B = Le[Pe], we = We[Pe];
7760          break;
7761        }
7762      return B < we ? -1 : we < B ? 1 : 0;
7763    };
7764    function T(w, d, h, A, S) {
7765      if (w.length === 0) return -1;
7766      if (typeof h == "string" ? (A = h, h = 0) : h > 2147483647 ? h = 2147483647 : h < -2147483648 && (h = -2147483648), h = +h, Io(h) && (h = S ? 0 : w.length - 1), h < 0 && (h = w.length + h), h >= w.length) {
7767        if (S) return -1;
7768        h = w.length - 1;
7769      } else if (h < 0)
7770        if (S) h = 0;
7771        else return -1;
7772      if (typeof d == "string" && (d = a.from(d, A)), a.isBuffer(d))
7773        return d.length === 0 ? -1 : O(w, d, h, A, S);
7774      if (typeof d == "number")
7775        return d = d & 255, typeof Uint8Array.prototype.indexOf == "function" ? S ? Uint8Array.prototype.indexOf.call(w, d, h) : Uint8Array.prototype.lastIndexOf.call(w, d, h) : O(w, [d], h, A, S);
7776      throw new TypeError("val must be string, number or Buffer");
7777    }
7778    function O(w, d, h, A, S) {
7779      let k = 1, B = w.length, we = d.length;
7780      if (A !== void 0 && (A = String(A).toLowerCase(), A === "ucs2" || A === "ucs-2" || A === "utf16le" || A === "utf-16le")) {
7781        if (w.length < 2 || d.length < 2)
7782          return -1;
7783        k = 2, B /= 2, we /= 2, h /= 2;
7784      }
7785      function je(We, Pe) {
7786        return k === 1 ? We[Pe] : We.readUInt16BE(Pe * k);
7787      }
7788      let Le;
7789      if (S) {
7790        let We = -1;
7791        for (Le = h; Le < B; Le++)
7792          if (je(w, Le) === je(d, We === -1 ? 0 : Le - We)) {
7793            if (We === -1 && (We = Le), Le - We + 1 === we) return We * k;
7794          } else
7795            We !== -1 && (Le -= Le - We), We = -1;
7796      } else
7797        for (h + we > B && (h = B - we), Le = h; Le >= 0; Le--) {
7798          let We = !0;
7799          for (let Pe = 0; Pe < we; Pe++)
7800            if (je(w, Le + Pe) !== je(d, Pe)) {
7801              We = !1;
7802              break;
7803            }
7804          if (We) return Le;
7805        }
7806      return -1;
7807    }
7808    a.prototype.includes = function(d, h, A) {
7809      return this.indexOf(d, h, A) !== -1;
7810    }, a.prototype.indexOf = function(d, h, A) {
7811      return T(this, d, h, A, !0);
7812    }, a.prototype.lastIndexOf = function(d, h, A) {
7813      return T(this, d, h, A, !1);
7814    };
7815    function U(w, d, h, A) {
7816      h = Number(h) || 0;
7817      const S = w.length - h;
7818      A ? (A = Number(A), A > S && (A = S)) : A = S;
7819      const k = d.length;
7820      A > k / 2 && (A = k / 2);
7821      let B;
7822      for (B = 0; B < A; ++B) {
7823        const we = parseInt(d.substr(B * 2, 2), 16);
7824        if (Io(we)) return B;
7825        w[h + B] = we;
7826      }
7827      return B;
7828    }
7829    function M(w, d, h, A) {
7830      return ti(No(d, w.length - h), w, h, A);
7831    }
7832    function L(w, d, h, A) {
7833      return ti(sh(d), w, h, A);
7834    }
7835    function re(w, d, h, A) {
7836      return ti(Fc(d), w, h, A);
7837    }
7838    function ne(w, d, h, A) {
7839      return ti(ih(d, w.length - h), w, h, A);
7840    }
7841    a.prototype.write = function(d, h, A, S) {
7842      if (h === void 0)
7843        S = "utf8", A = this.length, h = 0;
7844      else if (A === void 0 && typeof h == "string")
7845        S = h, A = this.length, h = 0;
7846      else if (isFinite(h))
7847        h = h >>> 0, isFinite(A) ? (A = A >>> 0, S === void 0 && (S = "utf8")) : (S = A, A = void 0);
7848      else
7849        throw new Error(
7850          "Buffer.write(string, encoding, offset[, length]) is no longer supported"
7851        );
7852      const k = this.length - h;
7853      if ((A === void 0 || A > k) && (A = k), d.length > 0 && (A < 0 || h < 0) || h > this.length)
7854        throw new RangeError("Attempt to write outside buffer bounds");
7855      S || (S = "utf8");
7856      let B = !1;
7857      for (; ; )
7858        switch (S) {
7859          case "hex":
7860            return U(this, d, h, A);
7861          case "utf8":
7862          case "utf-8":
7863            return M(this, d, h, A);
7864          case "ascii":
7865          case "latin1":
7866          case "binary":
7867            return L(this, d, h, A);
7868          case "base64":
7869            return re(this, d, h, A);
7870          case "ucs2":
7871          case "ucs-2":
7872          case "utf16le":
7873          case "utf-16le":
7874            return ne(this, d, h, A);
7875          default:
7876            if (B) throw new TypeError("Unknown encoding: " + S);
7877            S = ("" + S).toLowerCase(), B = !0;
7878        }
7879    }, a.prototype.toJSON = function() {
7880      return {
7881        type: "Buffer",
7882        data: Array.prototype.slice.call(this._arr || this, 0)
7883      };
7884    };
7885    function fe(w, d, h) {
7886      return d === 0 && h === w.length ? t.fromByteArray(w) : t.fromByteArray(w.slice(d, h));
7887    }
7888    function ae(w, d, h) {
7889      h = Math.min(w.length, h);
7890      const A = [];
7891      let S = d;
7892      for (; S < h; ) {
7893        const k = w[S];
7894        let B = null, we = k > 239 ? 4 : k > 223 ? 3 : k > 191 ? 2 : 1;
7895        if (S + we <= h) {
7896          let je, Le, We, Pe;
7897          switch (we) {
7898            case 1:
7899              k < 128 && (B = k);
7900              break;
7901            case 2:
7902              je = w[S + 1], (je & 192) === 128 && (Pe = (k & 31) << 6 | je & 63, Pe > 127 && (B = Pe));
7903              break;
7904            case 3:
7905              je = w[S + 1], Le = w[S + 2], (je & 192) === 128 && (Le & 192) === 128 && (Pe = (k & 15) << 12 | (je & 63) << 6 | Le & 63, Pe > 2047 && (Pe < 55296 || Pe > 57343) && (B = Pe));
7906              break;
7907            case 4:
7908              je = w[S + 1], Le = w[S + 2], We = w[S + 3], (je & 192) === 128 && (Le & 192) === 128 && (We & 192) === 128 && (Pe = (k & 15) << 18 | (je & 63) << 12 | (Le & 63) << 6 | We & 63, Pe > 65535 && Pe < 1114112 && (B = Pe));
7909          }
7910        }
7911        B === null ? (B = 65533, we = 1) : B > 65535 && (B -= 65536, A.push(B >>> 10 & 1023 | 55296), B = 56320 | B & 1023), A.push(B), S += we;
7912      }
7913      return D(A);
7914    }
7915    const P = 4096;
7916    function D(w) {
7917      const d = w.length;
7918      if (d <= P)
7919        return String.fromCharCode.apply(String, w);
7920      let h = "", A = 0;
7921      for (; A < d; )
7922        h += String.fromCharCode.apply(
7923          String,
7924          w.slice(A, A += P)
7925        );
7926      return h;
7927    }
7928    function de(w, d, h) {
7929      let A = "";
7930      h = Math.min(w.length, h);
7931      for (let S = d; S < h; ++S)
7932        A += String.fromCharCode(w[S] & 127);
7933      return A;
7934    }
7935    function Ie(w, d, h) {
7936      let A = "";
7937      h = Math.min(w.length, h);
7938      for (let S = d; S < h; ++S)
7939        A += String.fromCharCode(w[S]);
7940      return A;
7941    }
7942    function Re(w, d, h) {
7943      const A = w.length;
7944      (!d || d < 0) && (d = 0), (!h || h < 0 || h > A) && (h = A);
7945      let S = "";
7946      for (let k = d; k < h; ++k)
7947        S += oh[w[k]];
7948      return S;
7949    }
7950    function ge(w, d, h) {
7951      const A = w.slice(d, h);
7952      let S = "";
7953      for (let k = 0; k < A.length - 1; k += 2)
7954        S += String.fromCharCode(A[k] + A[k + 1] * 256);
7955      return S;
7956    }
7957    a.prototype.slice = function(d, h) {
7958      const A = this.length;
7959      d = ~~d, h = h === void 0 ? A : ~~h, d < 0 ? (d += A, d < 0 && (d = 0)) : d > A && (d = A), h < 0 ? (h += A, h < 0 && (h = 0)) : h > A && (h = A), h < d && (h = d);
7960      const S = this.subarray(d, h);
7961      return Object.setPrototypeOf(S, a.prototype), S;
7962    };
7963    function Ue(w, d, h) {
7964      if (w % 1 !== 0 || w < 0) throw new RangeError("offset is not uint");
7965      if (w + d > h) throw new RangeError("Trying to access beyond buffer length");
7966    }
7967    a.prototype.readUintLE = a.prototype.readUIntLE = function(d, h, A) {
7968      d = d >>> 0, h = h >>> 0, A || Ue(d, h, this.length);
7969      let S = this[d], k = 1, B = 0;
7970      for (; ++B < h && (k *= 256); )
7971        S += this[d + B] * k;
7972      return S;
7973    }, a.prototype.readUintBE = a.prototype.readUIntBE = function(d, h, A) {
7974      d = d >>> 0, h = h >>> 0, A || Ue(d, h, this.length);
7975      let S = this[d + --h], k = 1;
7976      for (; h > 0 && (k *= 256); )
7977        S += this[d + --h] * k;
7978      return S;
7979    }, a.prototype.readUint8 = a.prototype.readUInt8 = function(d, h) {
7980      return d = d >>> 0, h || Ue(d, 1, this.length), this[d];
7981    }, a.prototype.readUint16LE = a.prototype.readUInt16LE = function(d, h) {
7982      return d = d >>> 0, h || Ue(d, 2, this.length), this[d] | this[d + 1] << 8;
7983    }, a.prototype.readUint16BE = a.prototype.readUInt16BE = function(d, h) {
7984      return d = d >>> 0, h || Ue(d, 2, this.length), this[d] << 8 | this[d + 1];
7985    }, a.prototype.readUint32LE = a.prototype.readUInt32LE = function(d, h) {
7986      return d = d >>> 0, h || Ue(d, 4, this.length), (this[d] | this[d + 1] << 8 | this[d + 2] << 16) + this[d + 3] * 16777216;
7987    }, a.prototype.readUint32BE = a.prototype.readUInt32BE = function(d, h) {
7988      return d = d >>> 0, h || Ue(d, 4, this.length), this[d] * 16777216 + (this[d + 1] << 16 | this[d + 2] << 8 | this[d + 3]);
7989    }, a.prototype.readBigUInt64LE = gn(function(d) {
7990      d = d >>> 0, gr(d, "offset");
7991      const h = this[d], A = this[d + 7];
7992      (h === void 0 || A === void 0) && Gr(d, this.length - 8);
7993      const S = h + this[++d] * 2 ** 8 + this[++d] * 2 ** 16 + this[++d] * 2 ** 24, k = this[++d] + this[++d] * 2 ** 8 + this[++d] * 2 ** 16 + A * 2 ** 24;
7994      return BigInt(S) + (BigInt(k) << BigInt(32));
7995    }), a.prototype.readBigUInt64BE = gn(function(d) {
7996      d = d >>> 0, gr(d, "offset");
7997      const h = this[d], A = this[d + 7];
7998      (h === void 0 || A === void 0) && Gr(d, this.length - 8);
7999      const S = h * 2 ** 24 + this[++d] * 2 ** 16 + this[++d] * 2 ** 8 + this[++d], k = this[++d] * 2 ** 24 + this[++d] * 2 ** 16 + this[++d] * 2 ** 8 + A;
8000      return (BigInt(S) << BigInt(32)) + BigInt(k);
8001    }), a.prototype.readIntLE = function(d, h, A) {
8002      d = d >>> 0, h = h >>> 0, A || Ue(d, h, this.length);
8003      let S = this[d], k = 1, B = 0;
8004      for (; ++B < h && (k *= 256); )
8005        S += this[d + B] * k;
8006      return k *= 128, S >= k && (S -= Math.pow(2, 8 * h)), S;
8007    }, a.prototype.readIntBE = function(d, h, A) {
8008      d = d >>> 0, h = h >>> 0, A || Ue(d, h, this.length);
8009      let S = h, k = 1, B = this[d + --S];
8010      for (; S > 0 && (k *= 256); )
8011        B += this[d + --S] * k;
8012      return k *= 128, B >= k && (B -= Math.pow(2, 8 * h)), B;
8013    }, a.prototype.readInt8 = function(d, h) {
8014      return d = d >>> 0, h || Ue(d, 1, this.length), this[d] & 128 ? (255 - this[d] + 1) * -1 : this[d];
8015    }, a.prototype.readInt16LE = function(d, h) {
8016      d = d >>> 0, h || Ue(d, 2, this.length);
8017      const A = this[d] | this[d + 1] << 8;
8018      return A & 32768 ? A | 4294901760 : A;
8019    }, a.prototype.readInt16BE = function(d, h) {
8020      d = d >>> 0, h || Ue(d, 2, this.length);
8021      const A = this[d + 1] | this[d] << 8;
8022      return A & 32768 ? A | 4294901760 : A;
8023    }, a.prototype.readInt32LE = function(d, h) {
8024      return d = d >>> 0, h || Ue(d, 4, this.length), this[d] | this[d + 1] << 8 | this[d + 2] << 16 | this[d + 3] << 24;
8025    }, a.prototype.readInt32BE = function(d, h) {
8026      return d = d >>> 0, h || Ue(d, 4, this.length), this[d] << 24 | this[d + 1] << 16 | this[d + 2] << 8 | this[d + 3];
8027    }, a.prototype.readBigInt64LE = gn(function(d) {
8028      d = d >>> 0, gr(d, "offset");
8029      const h = this[d], A = this[d + 7];
8030      (h === void 0 || A === void 0) && Gr(d, this.length - 8);
8031      const S = this[d + 4] + this[d + 5] * 2 ** 8 + this[d + 6] * 2 ** 16 + (A << 24);
8032      return (BigInt(S) << BigInt(32)) + BigInt(h + this[++d] * 2 ** 8 + this[++d] * 2 ** 16 + this[++d] * 2 ** 24);
8033    }), a.prototype.readBigInt64BE = gn(function(d) {
8034      d = d >>> 0, gr(d, "offset");
8035      const h = this[d], A = this[d + 7];
8036      (h === void 0 || A === void 0) && Gr(d, this.length - 8);
8037      const S = (h << 24) + // Overflow
8038      this[++d] * 2 ** 16 + this[++d] * 2 ** 8 + this[++d];
8039      return (BigInt(S) << BigInt(32)) + BigInt(this[++d] * 2 ** 24 + this[++d] * 2 ** 16 + this[++d] * 2 ** 8 + A);
8040    }), a.prototype.readFloatLE = function(d, h) {
8041      return d = d >>> 0, h || Ue(d, 4, this.length), n.read(this, d, !0, 23, 4);
8042    }, a.prototype.readFloatBE = function(d, h) {
8043      return d = d >>> 0, h || Ue(d, 4, this.length), n.read(this, d, !1, 23, 4);
8044    }, a.prototype.readDoubleLE = function(d, h) {
8045      return d = d >>> 0, h || Ue(d, 8, this.length), n.read(this, d, !0, 52, 8);
8046    }, a.prototype.readDoubleBE = function(d, h) {
8047      return d = d >>> 0, h || Ue(d, 8, this.length), n.read(this, d, !1, 52, 8);
8048    };
8049    function Oe(w, d, h, A, S, k) {
8050      if (!a.isBuffer(w)) throw new TypeError('"buffer" argument must be a Buffer instance');
8051      if (d > S || d < k) throw new RangeError('"value" argument is out of bounds');
8052      if (h + A > w.length) throw new RangeError("Index out of range");
8053    }
8054    a.prototype.writeUintLE = a.prototype.writeUIntLE = function(d, h, A, S) {
8055      if (d = +d, h = h >>> 0, A = A >>> 0, !S) {
8056        const we = Math.pow(2, 8 * A) - 1;
8057        Oe(this, d, h, A, we, 0);
8058      }
8059      let k = 1, B = 0;
8060      for (this[h] = d & 255; ++B < A && (k *= 256); )
8061        this[h + B] = d / k & 255;
8062      return h + A;
8063    }, a.prototype.writeUintBE = a.prototype.writeUIntBE = function(d, h, A, S) {
8064      if (d = +d, h = h >>> 0, A = A >>> 0, !S) {
8065        const we = Math.pow(2, 8 * A) - 1;
8066        Oe(this, d, h, A, we, 0);
8067      }
8068      let k = A - 1, B = 1;
8069      for (this[h + k] = d & 255; --k >= 0 && (B *= 256); )
8070        this[h + k] = d / B & 255;
8071      return h + A;
8072    }, a.prototype.writeUint8 = a.prototype.writeUInt8 = function(d, h, A) {
8073      return d = +d, h = h >>> 0, A || Oe(this, d, h, 1, 255, 0), this[h] = d & 255, h + 1;
8074    }, a.prototype.writeUint16LE = a.prototype.writeUInt16LE = function(d, h, A) {
8075      return d = +d, h = h >>> 0, A || Oe(this, d, h, 2, 65535, 0), this[h] = d & 255, this[h + 1] = d >>> 8, h + 2;
8076    }, a.prototype.writeUint16BE = a.prototype.writeUInt16BE = function(d, h, A) {
8077      return d = +d, h = h >>> 0, A || Oe(this, d, h, 2, 65535, 0), this[h] = d >>> 8, this[h + 1] = d & 255, h + 2;
8078    }, a.prototype.writeUint32LE = a.prototype.writeUInt32LE = function(d, h, A) {
8079      return d = +d, h = h >>> 0, A || Oe(this, d, h, 4, 4294967295, 0), this[h + 3] = d >>> 24, this[h + 2] = d >>> 16, this[h + 1] = d >>> 8, this[h] = d & 255, h + 4;
8080    }, a.prototype.writeUint32BE = a.prototype.writeUInt32BE = function(d, h, A) {
8081      return d = +d, h = h >>> 0, A || Oe(this, d, h, 4, 4294967295, 0), this[h] = d >>> 24, this[h + 1] = d >>> 16, this[h + 2] = d >>> 8, this[h + 3] = d & 255, h + 4;
8082    };
8083    function qr(w, d, h, A, S) {
8084      Dc(d, A, S, w, h, 7);
8085      let k = Number(d & BigInt(4294967295));
8086      w[h++] = k, k = k >> 8, w[h++] = k, k = k >> 8, w[h++] = k, k = k >> 8, w[h++] = k;
8087      let B = Number(d >> BigInt(32) & BigInt(4294967295));
8088      return w[h++] = B, B = B >> 8, w[h++] = B, B = B >> 8, w[h++] = B, B = B >> 8, w[h++] = B, h;
8089    }
8090    function qe(w, d, h, A, S) {
8091      Dc(d, A, S, w, h, 7);
8092      let k = Number(d & BigInt(4294967295));
8093      w[h + 7] = k, k = k >> 8, w[h + 6] = k, k = k >> 8, w[h + 5] = k, k = k >> 8, w[h + 4] = k;
8094      let B = Number(d >> BigInt(32) & BigInt(4294967295));
8095      return w[h + 3] = B, B = B >> 8, w[h + 2] = B, B = B >> 8, w[h + 1] = B, B = B >> 8, w[h] = B, h + 8;
8096    }
8097    a.prototype.writeBigUInt64LE = gn(function(d, h = 0) {
8098      return qr(this, d, h, BigInt(0), BigInt("0xffffffffffffffff"));
8099    }), a.prototype.writeBigUInt64BE = gn(function(d, h = 0) {
8100      return qe(this, d, h, BigInt(0), BigInt("0xffffffffffffffff"));
8101    }), a.prototype.writeIntLE = function(d, h, A, S) {
8102      if (d = +d, h = h >>> 0, !S) {
8103        const je = Math.pow(2, 8 * A - 1);
8104        Oe(this, d, h, A, je - 1, -je);
8105      }
8106      let k = 0, B = 1, we = 0;
8107      for (this[h] = d & 255; ++k < A && (B *= 256); )
8108        d < 0 && we === 0 && this[h + k - 1] !== 0 && (we = 1), this[h + k] = (d / B >> 0) - we & 255;
8109      return h + A;
8110    }, a.prototype.writeIntBE = function(d, h, A, S) {
8111      if (d = +d, h = h >>> 0, !S) {
8112        const je = Math.pow(2, 8 * A - 1);
8113        Oe(this, d, h, A, je - 1, -je);
8114      }
8115      let k = A - 1, B = 1, we = 0;
8116      for (this[h + k] = d & 255; --k >= 0 && (B *= 256); )
8117        d < 0 && we === 0 && this[h + k + 1] !== 0 && (we = 1), this[h + k] = (d / B >> 0) - we & 255;
8118      return h + A;
8119    }, a.prototype.writeInt8 = function(d, h, A) {
8120      return d = +d, h = h >>> 0, A || Oe(this, d, h, 1, 127, -128), d < 0 && (d = 255 + d + 1), this[h] = d & 255, h + 1;
8121    }, a.prototype.writeInt16LE = function(d, h, A) {
8122      return d = +d, h = h >>> 0, A || Oe(this, d, h, 2, 32767, -32768), this[h] = d & 255, this[h + 1] = d >>> 8, h + 2;
8123    }, a.prototype.writeInt16BE = function(d, h, A) {
8124      return d = +d, h = h >>> 0, A || Oe(this, d, h, 2, 32767, -32768), this[h] = d >>> 8, this[h + 1] = d & 255, h + 2;
8125    }, a.prototype.writeInt32LE = function(d, h, A) {
8126      return d = +d, h = h >>> 0, A || Oe(this, d, h, 4, 2147483647, -2147483648), this[h] = d & 255, this[h + 1] = d >>> 8, this[h + 2] = d >>> 16, this[h + 3] = d >>> 24, h + 4;
8127    }, a.prototype.writeInt32BE = function(d, h, A) {
8128      return d = +d, h = h >>> 0, A || Oe(this, d, h, 4, 2147483647, -2147483648), d < 0 && (d = 4294967295 + d + 1), this[h] = d >>> 24, this[h + 1] = d >>> 16, this[h + 2] = d >>> 8, this[h + 3] = d & 255, h + 4;
8129    }, a.prototype.writeBigInt64LE = gn(function(d, h = 0) {
8130      return qr(this, d, h, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
8131    }), a.prototype.writeBigInt64BE = gn(function(d, h = 0) {
8132      return qe(this, d, h, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
8133    });
8134    function Lt(w, d, h, A, S, k) {
8135      if (h + A > w.length) throw new RangeError("Index out of range");
8136      if (h < 0) throw new RangeError("Index out of range");
8137    }
8138    function Mc(w, d, h, A, S) {
8139      return d = +d, h = h >>> 0, S || Lt(w, d, h, 4), n.write(w, d, h, A, 23, 4), h + 4;
8140    }
8141    a.prototype.writeFloatLE = function(d, h, A) {
8142      return Mc(this, d, h, !0, A);
8143    }, a.prototype.writeFloatBE = function(d, h, A) {
8144      return Mc(this, d, h, !1, A);
8145    };
8146    function Lc(w, d, h, A, S) {
8147      return d = +d, h = h >>> 0, S || Lt(w, d, h, 8), n.write(w, d, h, A, 52, 8), h + 8;
8148    }
8149    a.prototype.writeDoubleLE = function(d, h, A) {
8150      return Lc(this, d, h, !0, A);
8151    }, a.prototype.writeDoubleBE = function(d, h, A) {
8152      return Lc(this, d, h, !1, A);
8153    }, a.prototype.copy = function(d, h, A, S) {
8154      if (!a.isBuffer(d)) throw new TypeError("argument should be a Buffer");
8155      if (A || (A = 0), !S && S !== 0 && (S = this.length), h >= d.length && (h = d.length), h || (h = 0), S > 0 && S < A && (S = A), S === A || d.length === 0 || this.length === 0) return 0;
8156      if (h < 0)
8157        throw new RangeError("targetStart out of bounds");
8158      if (A < 0 || A >= this.length) throw new RangeError("Index out of range");
8159      if (S < 0) throw new RangeError("sourceEnd out of bounds");
8160      S >
vendor: 4,488 bytes, lines 8160-8282
8160 this.length && (S = this.length), d.length - h < S - A && (S = d.length - h + A);
8161      const k = S - A;
8162      return this === d && typeof Uint8Array.prototype.copyWithin == "function" ? this.copyWithin(h, A, S) : Uint8Array.prototype.set.call(
8163        d,
8164        this.subarray(A, S),
8165        h
8166      ), k;
8167    }, a.prototype.fill = function(d, h, A, S) {
8168      if (typeof d == "string") {
8169        if (typeof h == "string" ? (S = h, h = 0, A = this.length) : typeof A == "string" && (S = A, A = this.length), S !== void 0 && typeof S != "string")
8170          throw new TypeError("encoding must be a string");
8171        if (typeof S == "string" && !a.isEncoding(S))
8172          throw new TypeError("Unknown encoding: " + S);
8173        if (d.length === 1) {
8174          const B = d.charCodeAt(0);
8175          (S === "utf8" && B < 128 || S === "latin1") && (d = B);
8176        }
8177      } else typeof d == "number" ? d = d & 255 : typeof d == "boolean" && (d = Number(d));
8178      if (h < 0 || this.length < h || this.length < A)
8179        throw new RangeError("Out of range index");
8180      if (A <= h)
8181        return this;
8182      h = h >>> 0, A = A === void 0 ? this.length : A >>> 0, d || (d = 0);
8183      let k;
8184      if (typeof d == "number")
8185        for (k = h; k < A; ++k)
8186          this[k] = d;
8187      else {
8188        const B = a.isBuffer(d) ? d : a.from(d, S), we = B.length;
8189        if (we === 0)
8190          throw new TypeError('The value "' + d + '" is invalid for argument "value"');
8191        for (k = 0; k < A - h; ++k)
8192          this[k + h] = B[k % we];
8193      }
8194      return this;
8195    };
8196    const mr = {};
8197    function _o(w, d, h) {
8198      mr[w] = class extends h {
8199        constructor() {
8200          super(), Object.defineProperty(this, "message", {
8201            value: d.apply(this, arguments),
8202            writable: !0,
8203            configurable: !0
8204          }), this.name = `${this.name} [${w}]`, this.stack, delete this.name;
8205        }
8206        get code() {
8207          return w;
8208        }
8209        set code(S) {
8210          Object.defineProperty(this, "code", {
8211            configurable: !0,
8212            enumerable: !0,
8213            value: S,
8214            writable: !0
8215          });
8216        }
8217        toString() {
8218          return `${this.name} [${w}]: ${this.message}`;
8219        }
8220      };
8221    }
8222    _o(
8223      "ERR_BUFFER_OUT_OF_BOUNDS",
8224      function(w) {
8225        return w ? `${w} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds";
8226      },
8227      RangeError
8228    ), _o(
8229      "ERR_INVALID_ARG_TYPE",
8230      function(w, d) {
8231        return `The "${w}" argument must be of type number. Received type ${typeof d}`;
8232      },
8233      TypeError
8234    ), _o(
8235      "ERR_OUT_OF_RANGE",
8236      function(w, d, h) {
8237        let A = `The value of "${w}" is out of range.`, S = h;
8238        return Number.isInteger(h) && Math.abs(h) > 2 ** 32 ? S = Bc(String(h)) : typeof h == "bigint" && (S = String(h), (h > BigInt(2) ** BigInt(32) || h < -(BigInt(2) ** BigInt(32))) && (S = Bc(S)), S += "n"), A += ` It must be ${d}. Received ${S}`, A;
8239      },
8240      RangeError
8241    );
8242    function Bc(w) {
8243      let d = "", h = w.length;
8244      const A = w[0] === "-" ? 1 : 0;
8245      for (; h >= A + 4; h -= 3)
8246        d = `_${w.slice(h - 3, h)}${d}`;
8247      return `${w.slice(0, h)}${d}`;
8248    }
8249    function th(w, d, h) {
8250      gr(d, "offset"), (w[d] === void 0 || w[d + h] === void 0) && Gr(d, w.length - (h + 1));
8251    }
8252    function Dc(w, d, h, A, S, k) {
8253      if (w > h || w < d) {
8254        const B = typeof d == "bigint" ? "n" : "";
8255        let we;
8256        throw d === 0 || d === BigInt(0) ? we = `>= 0${B} and < 2${B} ** ${(k + 1) * 8}${B}` : we = `>= -(2${B} ** ${(k + 1) * 8 - 1}${B}) and < 2 ** ${(k + 1) * 8 - 1}${B}`, new mr.ERR_OUT_OF_RANGE("value", we, w);
8257      }
8258      th(A, S, k);
8259    }
8260    function gr(w, d) {
8261      if (typeof w != "number")
8262        throw new mr.ERR_INVALID_ARG_TYPE(d, "number", w);
8263    }
8264    function Gr(w, d, h) {
8265      throw Math.floor(w) !== w ? (gr(w, h), new mr.ERR_OUT_OF_RANGE("offset", "an integer", w)) : d < 0 ? new mr.ERR_BUFFER_OUT_OF_BOUNDS() : new mr.ERR_OUT_OF_RANGE(
8266        "offset",
8267        `>= 0 and <= ${d}`,
8268        w
8269      );
8270    }
8271    const nh = /[^+/0-9A-Za-z-_]/g;
8272    function rh(w) {
8273      if (w = w.split("=")[0], w = w.trim().replace(nh, ""), w.length < 2) return "";
8274      for (; w.length % 4 !== 0; )
8275        w = w + "=";
8276      return w;
8277    }
8278    function No(w, d) {
8279      d = d || 1 / 0;
8280      let h;
8281      const A = w.length;
8282      let S = null;
8283      const k = [];
8284      for (let B = 0; B < A; ++B) {
8285        if (h = w.charCodeAt(B), h > 55295 && h < 57344) {
8286          if (!S) {
8287            if (h > 56319) {
8288              (d -= 3) > -1 && k.push(239, 191, 189);
8289              continue;
8290            } else if (B + 1 === A) {
8291              (d -= 3) > -1 && k.push(239, 191, 189);
8292              continue;
8293            }
8294            S = h;
8295            continue;
8296          }
8297          if (h < 56320) {
8298            (d -= 3) > -1 && k.push(239, 191, 189), S = h;
8299            continue;
8300          }
8301          h = (S - 55296 << 10 | h - 56320) + 65536;
8302        } else S && (d -= 3) > -1 && k.push(239, 191, 189);
8303        if (S = null, h < 128) {
8304          if ((d -= 1) < 0) break;
8305          k.push(h);
8306        } else if (h < 2048) {
8307          if ((d -= 2) < 0) break;
8308          k.push(
8309            h >> 6 | 192,
8310            h & 63 | 128
8311          );
8312        } else if (h < 65536) {
8313          if ((d -= 3) < 0) break;
8314          k.push(
8315            h >> 12 | 224,
8316            h >> 6 & 63 | 128,
8317            h & 63 | 128
8318          );
8319        } else if (h < 1114112) {
8320          if ((d -= 4) < 0) break;
8321          k.push(
8322            h >> 18 | 240,
8323            h >> 12 & 63 | 128,
8324            h >> 6 & 63 | 128,
8325            h & 63 | 128
8326          );
8327        } else
8328          throw new Error("Invalid code point");
8329      }
8330      return k;
8331    }
8332    function sh(w) {
8333      const d = [];
8334      for (let h = 0; h < w.length; ++h)
8335        d.push(w.charCodeAt(h) & 255);
8336      return d;
8337    }
8338    function ih(w, d) {
8339      let h, A, S;
8340      const k = [];
8341      for (let B = 0; B < w.length && !((d -= 2) < 0); ++B)
8342        h = w.charCodeAt(B), A = h >> 8, S = h % 256, k.push(S), k.push(A);
8343      return k;
8344    }
8345    function Fc(w) {
8346      return t.toByteArray(rh(w));
8347    }
8348    function ti(w, d, h, A) {
8349      let S;
8350      for (S = 0; S < A && !(S + h >= d.length || S >= w.length); ++S)
8351        d[S + h] = w[S];
8352      return S;
8353    }
8354    function Bt(w, d) {
8355      return w instanceof d || w != null && w.constructor != null && w.constructor.name != null && w.constructor.name === d.name;
8356    }
8357    function Io(w) {
8358      return w !== w;
8359    }
8360    const oh = (function() {
8361      const w = "0123456789abcdef", d = new Array(256);
8362      for (let h = 0; h < 16; ++h) {
8363        const A = h * 16;
8364        for (let S = 0; S < 16; ++S)
8365          d[A + S] = w[h] + w[S];
8366      }
8367      return d;
8368    })();
8369    function gn(w) {
8370      return typeof BigInt > "u" ? ah : w;
8371    }
8372    function ah() {
8373      throw new Error("BigInt not supported");
8374    }
8375  })($o)), $o;
8376}
8377var ay = oy();
8378if (typeof window < "u") {
8379  const e = window;
8380  e.Buffer ??= ay.Buffer, e.global ??= window;
8381  const t = e.process;
8382  t ? t.env ??= {} : e.process = { env: {} };
8383}
8384const af = /* @__PURE__ */ rf({
8385  id: 56,
8386  name: "BNB Smart Chain",
8387  blockTime: 750,
8388  nativeCurrency: {
8389    decimals: 18,
8390    name: "BNB",
8391    symbol: "BNB"
8392  },
8393  rpcUrls: {
8394    default: { http: ["https://56.rpc.thirdweb.com"] }
8395  },
8396  blockExplorers: {
8397    default: {
8398      name: "BscScan",
8399      url: "https://bscscan.com",
8400      apiUrl: "https://api.bscscan.com/api"
8401    }
8402  },
8403  contracts: {
8404    multicall3: {
8405      address: "0xca11bde05977b3631167028862be2a173976ca11",
8406      blockCreated: 15921452
8407    }
8408  }
8409}), cf = /* @__PURE__ */ rf({
8410  id: 1,
8411  name: "Ethereum",
8412  nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
8413  blockTime: 12e3,
8414  rpcUrls: {
8415    default: {
8416      http: ["https://eth.merkle.io"]
8417    }
8418  },
8419  blockExplorers: {
8420    default: {
8421      name: "Etherscan",
8422      url: "https://etherscan.io",
8423      apiUrl: "https://api.etherscan.io/api"
8424    }
8425  },
8426  contracts: {
8427    ensUniversalResolver: {
8428      address: "0xeeeeeeee14d718c2b47d9923deab1335e144eeee",
8429      blockCreated: 23085558
8430    },
8431    multicall3: {
8432      address: "0xca11bde05977b3631167028862be2a173976ca11",
8433      blockCreated: 14353601
8434    }
8435  }
8436});
8437function Ut(e) {
8438  return {
8439    formatters: void 0,
8440    fees: void 0,
8441    serializers: void 0,
8442    ...e
8443  };
8444}
8445Ut({
8446  id: "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
8447  name: "Solana",
8448  network: "solana-mainnet",
8449  nativeCurrency: { name: "Solana", symbol: "SOL", decimals: 9 },
8450  rpcUrls: {
8451    default: { http: ["https://rpc.walletconnect.org/v1"] }
8452  },
8453  blockExplorers: { default: { name: "Solscan", url: "https://solscan.io" } },
8454  testnet: !1,
8455  chainNamespace: "solana",
8456  caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
8457  deprecatedCaipNetworkId: "solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"
8458});
8459Ut({
8460  id: "EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
8461  name: "Solana Devnet",
8462  network: "solana-devnet",
8463  nativeCurrency: { name: "Solana", symbol: "SOL", decimals: 9 },
8464  rpcUrls: {
8465    default: { http: ["https://rpc.walletconnect.org/v1"] }
8466  },
8467  blockExplorers: { default: { name: "Solscan", url: "https://solscan.io" } },
8468  testnet: !0,
8469  chainNamespace: "solana",
8470  caipNetworkId: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
8471  deprecatedCaipNetworkId: "solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"
8472});
8473Ut({
8474  id: "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",
8475  name: "Solana Testnet",
8476  network: "solana-testnet",
8477  nativeCurrency: { name: "Solana", symbol: "SOL", decimals: 9 },
8478  rpcUrls: {
8479    default: { http: ["https://rpc.walletconnect.org/v1"] }
8480  },
8481  blockExplorers: { default: { name: "Solscan", url: "https://solscan.io" } },
8482  testnet: !0,
8483  chainNamespace: "solana",
8484  caipNetworkId: "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"
8485});
8486Ut({
8487  id: "000000000019d6689c085ae165831e93",
8488  caipNetworkId: "bip122:000000000019d6689c085ae165831e93",
8489  chainNamespace: "bip122",
8490  name: "Bitcoin",
8491  nativeCurrency: {
8492    name: "Bitcoin",
8493    symbol: "BTC",
8494    decimals: 8
8495  },
8496  rpcUrls: {
8497    default: { http: ["https://rpc.walletconnect.org/v1"] }
8498  }
8499});
8500Ut({
8501  id: "000000000933ea01ad0ee984209779ba",
8502  caipNetworkId: "bip122:000000000933ea01ad0ee984209779ba",
8503  chainNamespace: "bip122",
8504  name: "Bitcoin Testnet",
8505  nativeCurrency: {
8506    name: "Bitcoin",
8507    symbol: "BTC",
8508    decimals: 8
8509  },
8510  rpcUrls: {
8511    default: { http: ["https://rpc.walletconnect.org/v1"] }
8512  },
8513  testnet: !0
8514});
8515Ut({
8516  id: "00000008819873e925422c1ff0f99f7c",
8517  caipNetworkId: "bip122:00000008819873e925422c1ff0f99f7c",
8518  chainNamespace: "bip122",
8519  name: "Bitcoin Signet",
8520  nativeCurrency: {
8521    name: "Bitcoin",
8522    symbol: "BTC",
8523    decimals: 8
8524  },
8525  rpcUrls: {
8526    default: { http: ["https://rpc.walletconnect.org/v1"] }
8527  },
8528  testnet: !0
8529});
8530Ut({
8531  id: "-239",
8532  name: "TON",
8533  network: "ton-mainnet",
8534  nativeCurrency: { name: "TON", symbol: "TON", decimals: 9 },
8535  rpcUrls: {
8536    default: { http: ["https://rpc.walletconnect.org/v1"] }
8537  },
8538  blockExplorers: { default: { name: "Tonscan", url: "https://tonscan.org" } },
8539  testnet: !1,
8540  chainNamespace: "ton",
8541  caipNetworkId: "ton:-239"
8542});
8543Ut({
8544  id: "-3",
8545  name: "TON Testnet",
8546  network: "ton-testnet",
8547  nativeCurrency: { name: "TON", symbol: "TON", decimals: 9 },
8548  rpcUrls: {
8549    default: { http: ["https://rpc.walletconnect.org/v1"] }
8550  },
8551  blockExplorers: { default: { name: "Tonscan", url: "https://testnet.tonscan.org" } },
8552  testnet: !0,
8553  chainNamespace: "ton",
8554  caipNetworkId: "ton:-3"
8555});
8556const cy = Ut({
8557  id: "0x2b6653dc",
8558  name: "TRON",
8559  network: "tron-mainnet",
8560  nativeCurrency: { name: "TRX", symbol: "TRX", decimals: 6 },
8561  rpcUrls: {
8562    default: { http: ["https://rpc.walletconnect.org/v1"] },
8563    chainDefault: { http: ["https://api.trongrid.io"] }
8564  },
8565  blockExplorers: { default: { name: "Tronscan", url: "https://tronscan.org" } },
8566  testnet: !1,
8567  chainNamespace: "tron",
8568  caipNetworkId: "tron:0x2b6653dc"
8569});
8570Ut({
8571  id: "0x94a9059e",
8572  name: "TRON Shasta",
8573  network: "tron-shasta",
8574  nativeCurrency: { name: "TRX", symbol: "TRX", decimals: 6 },
8575  rpcUrls: {
8576    default: { http: ["https://rpc.walletconnect.org/v1"] },
8577    chainDefault: { http: ["https://api.shasta.trongrid.io"] }
8578  },
8579  blockExplorers: { default: { name: "Tronscan", url: "https://shasta.tronscan.org" } },
8580  testnet: !0,
8581  chainNamespace: "tron",
8582  caipNetworkId: "tron:0x94a9059e"
8583});
8584Ut({
8585  id: "0xcd8690dc",
8586  name: "TRON Nile",
8587  network: "tron-nile",
8588  nativeCurrency: { name: "TRX", symbol: "TRX", decimals: 6 },
8589  rpcUrls: {
8590    default: { http: ["https://rpc.walletconnect.org/v1"] },
8591    chainDefault: { http: ["https://nile.trongrid.io"] }
8592  },
8593  blockExplorers: { default: { name: "Tronscan", url: "https://nile.tronscan.org" } },
8594  testnet: !0,
8595  chainNamespace: "tron",
8596  caipNetworkId: "tron:0xcd8690dc"
8597});
8598const uf = {
8599  isLowerCaseMatch(e, t) {
8600    return e?.toLowerCase() === t?.toLowerCase();
8601  }
8602}, x = {
8603  WC_NAME_SUFFIX: ".reown.id",
8604  WC_NAME_SUFFIX_LEGACY: ".wcn.id",
8605  BLOCKCHAIN_API_RPC_URL: "https://rpc.walletconnect.org",
8606  PULSE_API_URL: "https://pulse.walletconnect.org",
8607  W3M_API_URL: "https://api.web3modal.org",
8608  CONNECTOR_ID: {
8609    WALLET_CONNECT: "walletConnect",
8610    INJECTED: "injected",
8611    WALLET_STANDARD: "announced",
8612    COINBASE: "coinbaseWallet",
8613    COINBASE_SDK: "coinbaseWalletSDK",
8614    BASE_ACCOUNT: "baseAccount",
8615    SAFE: "safe",
8616    LEDGER: "ledger",
8617    OKX: "okx",
8618    EIP6963: "eip6963",
8619    AUTH: "AUTH"
8620  },
8621  CONNECTOR_NAMES: {
8622    AUTH: "Auth"
8623  },
8624  AUTH_CONNECTOR_SUPPORTED_CHAINS: ["eip155", "solana"],
8625  LIMITS: {
8626    PENDING_TRANSACTIONS: 99
8627  },
8628  CHAIN: {
8629    EVM: "eip155",
8630    SOLANA: "solana",
8631    POLKADOT: "polkadot",
8632    BITCOIN: "bip122",
8633    TON: "ton",
8634    TRON: "tron"
8635  },
8636  CHAIN_NAME_MAP: {
8637    eip155: "EVM Networks",
8638    solana: "Solana",
8639    polkadot: "Polkadot",
8640    bip122: "Bitcoin",
8641    cosmos: "Cosmos",
8642    sui: "Sui",
8643    stacks: "Stacks",
8644    ton: "TON",
8645    tron: "TRON"
8646  },
8647  ADAPTER_TYPES: {
8648    BITCOIN: "bitcoin",
8649    SOLANA: "solana",
8650    WAGMI: "wagmi",
8651    ETHERS: "ethers",
8652    ETHERS5: "ethers5",
8653    TON: "ton",
8654    TRON: "tron"
8655  },
8656  USDT_CONTRACT_ADDRESSES: [
8657    "0xdac17f958d2ee523a2206206994597c13d831ec7",
8658    "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
8659    "0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7",
8660    "0x919C1c267BC06a7039e03fcc2eF738525769109c",
8661    "0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e",
8662    "0x55d398326f99059fF775485246999027B3197955",
8663    "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"
8664  ],
8665  SOLANA_SPL_TOKEN_ADDRESSES: {
8666    SOL: "So11111111111111111111111111111111111111112"
8667  },
8668  NATIVE_IMAGE_IDS_BY_NAMESPACE: {
8669    eip155: "ba0ba0cd-17c6-4806-ad93-f9d174f17900",
8670    solana: "3e8119e5-2a6f-4818-c50c-1937011d5900",
8671    bip122: "0b4838db-0161-4ffe-022d-532bf03dba00"
8672  },
8673  TOKEN_SYMBOLS_BY_ADDRESS: {
8674    "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "USDC",
8675    "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913": "USDC",
8676    "0x0b2c639c533813f4aa9d7837caf62653d097ff85": "USDC",
8677    "0xaf88d065e77c8cc2239327c5edb3a432268e5831": "USDC",
8678    "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359": "USDC",
8679    "0x2791bca1f2de4661ed88a30c99a7a9449aa84174": "USDC",
8680    EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: "USDC",
8681    "0xdac17f958d2ee523a2206206994597c13d831ec7": "USDT",
8682    "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58": "USDT",
8683    "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9": "USDT",
8684    "0xc2132d05d31c914a87c6611c10748aeb04b58e8f": "USDT",
8685    Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB: "USDT"
8686  },
8687  HTTP_STATUS_CODES: {
8688    SERVER_ERROR: 500,
8689    TOO_MANY_REQUESTS: 429,
8690    SERVICE_UNAVAILABLE: 503,
8691    FORBIDDEN: 403
8692  },
8693  UNSUPPORTED_NETWORK_NAME: "Unknown Network",
8694  SECURE_SITE_SDK_ORIGIN: (typeof process < "u" && typeof process.env < "u" ? process.env.NEXT_PUBLIC_SECURE_SITE_ORIGIN : void 0) || "https://secure.walletconnect.org",
8695  REMOTE_FEATURES_ALERTS: {
8696    MULTI_WALLET_NOT_ENABLED: {
8697      DEFAULT: {
8698        displayMessage: "Multi-Wallet Not Enabled",
8699        debugMessage: "Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com."
8700      },
8701      CONNECTIONS_HOOK: {
8702        displayMessage: "Multi-Wallet Not Enabled",
8703        debugMessage: "Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com to use the useAppKitConnections hook."
8704      },
8705      CONNECTION_HOOK: {
8706        displayMessage: "Multi-Wallet Not Enabled",
8707        debugMessage: "Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com to use the useAppKitConnection hook."
8708      }
8709    },
8710    HEADLESS_NOT_ENABLED: {
8711      DEFAULT: {
8712        displayMessage: "",
8713        debugMessage: "Headless support is not enabled. Please enable it with the features.headless option in the AppKit configuration and make sure your current plan supports it."
8714      }
8715    }
8716  },
8717  IS_DEVELOPMENT: typeof process < "u" && process.env.NODE_ENV === "development",
8718  DEFAULT_ALLOWED_ANCESTORS: [
8719    "http://localhost:*",
8720    "https://localhost:*",
8721    "http://127.0.0.1:*",
8722    "https://127.0.0.1:*",
8723    "https://*.pages.dev",
8724    "https://*.vercel.app",
8725    "https://*.ngrok-free.app",
8726    "https://secure-mobile.walletconnect.com",
8727    "https://secure-mobile.walletconnect.org"
8728  ],
8729  METMASK_CONNECTOR_NAME: "MetaMask",
8730  TRUST_CONNECTOR_NAME: "Trust Wallet",
8731  SOLFLARE_CONNECTOR_NAME: "Solflare",
8732  PHANTOM_CONNECTOR_NAME: "Phantom",
8733  COIN98_CONNECTOR_NAME: "Coin98",
8734  MAGIC_EDEN_CONNECTOR_NAME: "Magic Eden",
8735  BACKPACK_CONNECTOR_NAME: "Backpack",
8736  BITGET_CONNECTOR_NAME: "Bitget Wallet",
8737  FRONTIER_CONNECTOR_NAME: "Frontier",
8738  XVERSE_CONNECTOR_NAME: "Xverse Wallet",
8739  LEATHER_CONNECTOR_NAME: "Leather",
8740  OKX_CONNECTOR_NAME: "OKX Wallet",
8741  BINANCE_CONNECTOR_NAME: "Binance Wallet",
8742  EIP155: "eip155",
8743  ADD_CHAIN_METHOD: "wallet_addEthereumChain",
8744  EIP6963_ANNOUNCE_EVENT: "eip6963:announceProvider",
8745  EIP6963_REQUEST_EVENT: "eip6963:requestProvider",
8746  CONNECTOR_RDNS_MAP: {
8747    coinbaseWallet: "com.coinbase.wallet",
8748    coinbaseWalletSDK: "com.coinbase.wallet"
8749  },
8750  CONNECTOR_TYPE_EXTERNAL: "EXTERNAL",
8751  CONNECTOR_TYPE_WALLET_CONNECT: "WALLET_CONNECT",
8752  CONNECTOR_TYPE_INJECTED: "INJECTED",
8753  CONNECTOR_TYPE_ANNOUNCED: "ANNOUNCED",
8754  CONNECTOR_TYPE_AUTH: "AUTH",
8755  CONNECTOR_TYPE_MULTI_CHAIN: "MULTI_CHAIN",
8756  CONNECTOR_TYPE_W3M_AUTH: "AUTH"
8757}, Gi = {
8758  caipNetworkIdToNumber(e) {
8759    return e ? Number(e.split(":")[1]) : void 0;
8760  },
8761  parseEvmChainId(e) {
8762    return typeof e == "string" ? this.caipNetworkIdToNumber(e) : e;
8763  },
8764  getNetworksByNamespace(e, t) {
8765    return e?.filter((n) => n.chainNamespace === t) || [];
8766  },
8767  getFirstNetworkByNamespace(e, t) {
8768    return this.getNetworksByNamespace(e, t)[0];
8769  },
8770  getNetworkNameByCaipNetworkId(e, t) {
8771    if (!t)
8772      return;
8773    const n = e.find((s) => s.caipNetworkId === t);
8774    if (n)
8775      return n.name;
8776    const [r] = t.split(":");
8777    return x.CHAIN_NAME_MAP?.[r] || void 0;
8778  }
8779}, lf = [
8780  "eip155",
8781  "solana",
8782  "polkadot",
8783  "bip122",
8784  "cosmos",
8785  "sui",
8786  "stacks"
8787];
8788var uy = 20, ly = 1, or = 1e6, Eu = 1e6, dy = -7, fy = 21, hy = !1, Zs = "[big.js] ", dr = Zs + "Invalid ", bo = dr + "decimal places", py = dr + "rounding mode", df = Zs + "Division by zero", xe = {}, Ht = void 0, my = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
8789function ff() {
8790  function e(t) {
8791    var n = this;
8792    if (!(n instanceof e)) return t === Ht ? ff() : new e(t);
8793    if (t instanceof e)
8794      n.s = t.s, n.e = t.e, n.c = t.c.slice();
8795    else {
8796      if (typeof t != "string") {
8797        if (e.strict === !0 && typeof t != "bigint")
8798          throw TypeError(dr + "value");
8799        t = t === 0 && 1 / t < 0 ? "-0" : String(t);
8800      }
8801      gy(n, t);
8802    }
8803    n.constructor = e;
8804  }
8805  return e.prototype = xe, e.DP = uy, e.RM = ly, e.NE = dy, e.PE = fy, e.strict = hy, e.roundDown = 0, e.roundHalfUp = 1, e.roundHalfEven = 2, e.roundUp = 3, e;
8806}
8807function gy(e, t) {
8808  var n, r, s;
8809  if (!my.test(t))
8810    throw Error(dr + "number");
8811  for (e.s = t.charAt(0) == "-" ? (t = t.slice(1), -1) : 1, (n = t.indexOf(".")) > -1 && (t = t.replace(".", "")), (r = t.search(/e/i)) > 0 ? (n < 0 && (n = r), n += +t.slice(r + 1), t = t.substring(0, r)) : n < 0 && (n = t.length), s = t.length, r = 0; r < s && t.charAt(r) == "0"; ) ++r;
8812  if (r == s)
8813    e.c = [e.e = 0];
8814  else {
8815    for (; s > 0 && t.charAt(--s) == "0"; ) ;
8816    for (e.e = n - r - 1, e.c = [], n = 0; r <= s; ) e.c[n++] = +t.charAt(r++);
8817  }
8818  return e;
8819}
8820function fr(e, t, n, r) {
8821  var s = e.c;
8822  if (n === Ht && (n = e.constructor.RM), n !== 0 && n !== 1 && n !== 2 && n !== 3)
8823    throw Error(py);
8824  if (t < 1)
8825    r = n === 3 && (r || !!s[0]) || t === 0 && (n === 1 && s[0] >= 5 || n === 2 && (s[0] > 5 || s[0] === 5 && (r || s[1] !== Ht))), s.length = 1, r ? (e.e = e.e - t + 1, s[0] = 1) : s[0] = e.e = 0;
8826  else if (t < s.length) {
8827    if (r = n === 1 && s[t] >= 5 || n === 2 && (s[t] > 5 || s[t] === 5 && (r || s[t + 1] !== Ht || s[t - 1] & 1)) || n === 3 && (r || !!s[0]), s.length = t, r) {
8828      for (; ++s[--t] > 9; )
8829        if (s[t] = 0, t === 0) {
8830          ++e.e, s.unshift(1);
8831          break;
8832        }
8833    }
8834    for (t = s.length; !s[--t]; ) s.pop();
8835  }
8836  return e;
8837}
8838function hr(e, t, n) {
8839  var r = e.e, s = e.c.join(""), i = s.length;
8840  if (t)
8841    s = s.charAt(0) + (i > 1 ? "." + s.slice(1) : "") + (r < 0 ? "e" : "e+") + r;
8842  else if (r < 0) {
8843    for (; ++r; ) s = "0" + s;
8844    s = "0." + s;
8845  } else if (r > 0)
8846    if (++r > i)
8847      for (r -= i; r--; ) s += "0";
8848    else r < i && (s = s.slice(0, r) + "." + s.slice(r));
8849  else i > 1 && (s = s.charAt(0) + "." + s.slice(1));
8850  return e.s < 0 && n ? "-" + s : s;
8851}
8852xe.abs = function() {
8853  var e = new this.constructor(this);
8854  return e.s = 1, e;
8855};
8856xe.cmp = function(e) {
8857  var t, n = this, r = n.c, s = (e = new n.constructor(e)).c, i = n.s, o = e.s, a = n.e, u = e.e;
8858  if (!r[0] || !s[0]) return r[0] ? i : s[0] ? -o : 0;
8859  if (i != o) return i;
8860  if (t = i < 0, a != u) return a > u ^ t ? 1 : -1;
8861  for (o = (a = r.length) < (u = s.length) ? a : u, i = -1; ++i < o; )
8862    if (r[i] != s[i]) return r[i] > s[i] ^ t ? 1 : -1;
8863  return a == u ? 0 : a > u ^ t ? 1 : -1;
8864};
8865xe.div = function(e) {
8866  var t = this, n = t.constructor, r = t.c, s = (e = new n(e)).c, i = t.s == e.s ? 1 : -1, o = n.DP;
8867  if (o !== ~~o || o < 0 || o > or)
8868    throw Error(bo);
8869  if (!s[0])
8870    throw Error(df);
8871  if (!r[0])
8872    return e.s = i, e.c = [e.e = 0], e;
8873  var a, u, c, l, f, p = s.slice(), m = a = s.length, y = r.length, b = r.slice(0, a), C = b.length, _ = e, R = _.c = [], N = 0, I = o + (_.e = t.e - e.e) + 1;
8874  for (_.s = i, i = I < 0 ? 0 : I, p.unshift(0); C++ < a; ) b.push(0);
8875  do {
8876    for (c = 0; c < 10; c++) {
8877      if (a != (C = b.length))
8878        l = a > C ? 1 : -1;
8879      else
8880        for (f = -1, l = 0; ++f < a; )
8881          if (s[f] != b[f]) {
8882            l = s[f] > b[f] ? 1 : -1;
8883            break;
8884          }
8885      if (l < 0) {
8886        for (u = C == a ? s : p; C; ) {
8887          if (b[--C] < u[C]) {
8888            for (f = C; f && !b[--f]; ) b[f] = 9;
8889            --b[f], b[C] += 10;
8890          }
8891          b[C] -= u[C];
8892        }
8893        for (; !b[0]; ) b.shift();
8894      } else
8895        break;
8896    }
8897    R[N++] = l ? c : ++c, b[0] && l ? b[C] = r[m] || 0 : b = [r[m]];
8898  } while ((m++ < y || b[0] !== Ht) && i--);
8899  return !R[0] && N != 1 && (R.shift(), _.e--, I--), N > I && fr(_, I, n.RM, b[0] !== Ht), _;
8900};
8901xe.eq = function(e) {
8902  return this.cmp(e) === 0;
8903};
8904xe.gt = function(e) {
8905  return this.cmp(e) > 0;
8906};
8907xe.gte = function(e) {
8908  return this.cmp(e) > -1;
8909};
8910xe.lt = function(e) {
8911  return this.cmp(e) < 0;
8912};
8913xe.lte = function(e) {
8914  return this.cmp(e) < 1;
8915};
8916xe.minus = xe.sub = function(e) {
8917  var t, n, r, s, i = this, o = i.constructor, a = i.s, u = (e = new o(e)).s;
8918  if (a != u)
8919    return e.s = -u, i.plus(e);
8920  var c = i.c.slice(), l = i.e, f = e.c, p = e.e;
8921  if (!c[0] || !f[0])
8922    return f[0] ? e.s = -u : c[0] ? e = new o(i) : e.s = 1, e;
8923  if (a = l - p) {
8924    for ((s = a < 0) ? (a = -a, r = c) : (p = l, r = f), r.reverse(), u = a; u--; ) r.push(0);
8925    r.reverse();
8926  } else
8927    for (n = ((s = c.length < f.length) ? c : f).length, a = u = 0; u < n; u++)
8928      if (c[u] != f[u]) {
8929        s = c[u] < f[u];
8930        break;
8931      }
8932  if (s && (r = c, c = f, f = r, e.s = -e.s), (u = (n = f.length) - (t = c.length)) > 0) for (; u--; ) c[t++] = 0;
8933  for (u = t; n > a; ) {
8934    if (c[--n] < f[n]) {
8935      for (t = n; t && !c[--t]; ) c[t] = 9;
8936      --c[t], c[n] += 10;
8937    }
8938    c[n] -= f[n];
8939  }
8940  for (; c[--u] === 0; ) c.pop();
8941  for (; c[0] === 0; )
8942    c.shift(), --p;
8943  return c[0] || (e.s = 1, c = [p = 0]), e.c = c, e.e = p, e;
8944};
8945xe.mod = function(e) {
8946  var t, n = this, r = n.constructor, s = n.s, i = (e = new r(e)).s;
8947  if (!e.c[0])
8948    throw Error(df);
8949  return n.s = e.s = 1, t = e.cmp(n) == 1, n.s = s, e.s = i, t ? new r(n) : (s = r.DP, i = r.RM, r.DP = r.RM = 0, n = n.div(e), r.DP = s, r.RM = i, this.minus(n.times(e)));
8950};
8951xe.neg = function() {
8952  var e = new this.constructor(this);
8953  return e.s = -e.s, e;
8954};
8955xe.plus = xe.add = function(e) {
8956  var t, n, r, s = this, i = s.constructor;
8957  if (e = new i(e), s.s != e.s)
8958    return e.s = -e.s, s.minus(e);
8959  var o = s.e, a = s.c, u = e.e, c = e.c;
8960  if (!a[0] || !c[0])
8961    return c[0] || (a[0] ? e = new i(s) : e.s = s.s), e;
8962  if (a = a.slice(), t = o - u) {
8963    for (t > 0 ? (u = o, r = c) : (t = -t, r = a), r.reverse(); t--; ) r.push(0);
8964    r.reverse();
8965  }
8966  for (a.length - c.length < 0 && (r = c, c = a, a = r), t = c.length, n = 0; t; a[t] %= 10) n = (a[--t] = a[t] + c[t] + n) / 10 | 0;
8967  for (n && (a.unshift(n), ++u), t = a.length; a[--t] === 0; ) a.pop();
8968  return e.c = a, e.e = u, e;
8969};
8970xe.pow = function(e) {
8971  var t = this, n = new t.constructor("1"), r = n, s = e < 0;
8972  if (e !== ~~e || e < -Eu || e > Eu)
8973    throw Error(dr + "exponent");
8974  for (s && (e = -e); e & 1 && (r = r.times(t)), e >>= 1, !!e; )
8975    t = t.times(t);
8976  return s ? n.div(r) : r;
8977};
8978xe.prec = function(e, t) {
8979  if (e !== ~~e || e < 1 || e > or)
8980    throw Error(dr + "precision");
8981  return fr(new this.constructor(this), e, t);
8982};
8983xe.round = function(e, t) {
8984  if (e === Ht) e = 0;
8985  else if (e !== ~~e || e < -or || e > or)
8986    throw Error(bo);
8987  return fr(new this.constructor(this), e + this.e + 1, t);
8988};
8989xe.sqrt = function() {
8990  var e, t, n, r = this, s = r.constructor, i = r.s, o = r.e, a = new s("0.5");
8991  if (!r.c[0]) return new s(r);
8992  if (i < 0)
8993    throw Error(Zs + "No square root");
8994  i = Math.sqrt(+hr(r, !0, !0)), i === 0 || i === 1 / 0 ? (t = r.c.join(""), t.length + o & 1 || (t += "0"), i = Math.sqrt(t), o = ((o + 1) / 2 | 0) - (o < 0 || o & 1), e = new s((i == 1 / 0 ? "5e" : (i = i.toExponential()).slice(0, i.indexOf("e") + 1)) + o)) : e = new s(i + ""), o = e.e + (s.DP += 4);
8995  do
8996    n = e, e = a.times(n.plus(r.div(n)));
8997  while (n.c.slice(0, o).join("") !== e.c.slice(0, o).join(""));
8998  return fr(e, (s.DP -= 4) + e.e + 1, s.RM);
8999};
9000xe.times = xe.mul = function(e) {
9001  var t, n = this, r = n.constructor, s = n.c, i = (e = new r(e)).c, o = s.length, a = i.length, u = n.e, c = e.e;
9002  if (e.s = n.s == e.s ? 1 : -1, !s[0] || !i[0])
9003    return e.c = [e.e = 0], e;
9004  for (e.e = u + c, o < a && (t = s, s = i, i = t, c = o, o = a, a = c), t = new Array(c = o + a); c--; ) t[c] = 0;
9005  for (u = a; u--; ) {
9006    for (a = 0, c = o + u; c > u; )
9007      a = t[c] + i[u] * s[c - u - 1] + a, t[c--] = a % 10, a = a / 10 | 0;
9008    t[c] = a;
9009  }
9010  for (a ? ++e.e : t.shift(), u = t.length; !t[--u]; ) t.pop();
9011  return e.c = t, e;
9012};
9013xe.toExponential = function(e, t) {
9014  var n = this, r = n.c[0];
9015  if (e !== Ht) {
9016    if (e !== ~~e || e < 0 || e > or)
9017      throw Error(bo);
9018    for (n = fr(new n.constructor(n), ++e, t); n.c.length < e; ) n.c.push(0);
9019  }
9020  return hr(n, !0, !!r);
9021};
9022xe.toFixed = function(e, t) {
9023  var n = this, r = n.c[0];
9024  if (e !== Ht) {
9025    if (e !== ~~e || e < 0 || e > or)
9026      throw Error(bo);
9027    for (n = fr(new n.constructor(n), e + n.e + 1, t), e = e + n.e + 1; n.c.length < e; ) n.c.push(0);
9028  }
9029  return hr(n, !1, !!r);
9030};
9031xe[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = xe.toJSON = xe.toString = function() {
9032  var e = this, t = e.constructor;
9033  return hr(e, e.e <= t.NE || e.e >= t.PE, !!e.c[0]);
9034};
9035xe.toNumber = function() {
9036  var e = +hr(this, !0, !0);
9037  if (this.constructor.strict === !0 && !this.eq(e.toString()))
9038    throw Error(Zs + "Imprecise conversion");
9039  return e;
9040};
9041xe.toPrecision = function(e, t) {
9042  var n = this, r = n.constructor, s = n.c[0];
9043  if (e !== Ht) {
9044    if (e !== ~~e || e < 1 || e > or)
9045      throw Error(dr + "precision");
9046    for (n = fr(new r(n), e, t); n.c.length < e; ) n.c.push(0);
9047  }
9048  return hr(n, e <= n.e || n.e <= r.NE || n.e >= r.PE, !!s);
9049};
9050xe.valueOf = function() {
9051  var e = this, t = e.constructor;
9052  if (t.strict === !0)
9053    throw Error(Zs + "valueOf disallowed");
9054  return hr(e, e.e <= t.NE || e.e >= t.PE, !0);
9055};
9056var Ft = ff();
9057const Ic = {
9058  bigNumber(e, t = {
9059    safe: !1
9060  }) {
9061    try {
9062      return e ? new Ft(e) : new Ft(0);
9063    } catch (n) {
9064      if (t.safe)
9065        return new Ft(0);
9066      throw n;
9067    }
9068  },
9069  formatNumber(e, t) {
9070    const { decimals: n, round: r = 8, safe: s = !0 } = t;
9071    return Ic.bigNumber(e, { safe: s }).div(new Ft(10).pow(n)).round(r);
9072  },
9073  multiply(e, t) {
9074    if (e === void 0 || t === void 0)
9075      return new Ft(0);
9076    const n = new Ft(e), r = new Ft(t);
9077    return n.times(r);
9078  },
9079  toFixed(e, t = 2) {
9080    return e === void 0 || e === "" ? new Ft(0).toFixed(t) : new Ft(e).toFixed(t);
9081  },
9082  formatNumberToLocalString(e, t = 2) {
9083    return e === void 0 || e === "" ? "0.00" : typeof e == "number" ? e.toLocaleStr
9083ing("en-US", {
9084      maximumFractionDigits: t,
9085      minimumFractionDigits: t,
9086      roundingMode: "floor"
9087    }) : parseFloat(e).toLocaleString("en-US", {
9088      maximumFractionDigits: t,
9089      minimumFractionDigits: t,
9090      roundingMode: "floor"
9091    });
9092  },
9093  parseLocalStringToNumber(e) {
9094    if (e === void 0 || e === "")
9095      return 0;
9096    const t = e.replace(/,/gu, "");
9097    return new Ft(t).toNumber();
9098  }
9099}, yy = [
9100  {
9101    type: "function",
9102    name: "transfer",
9103    stateMutability: "nonpayable",
9104    inputs: [
9105      {
9106        name: "_to",
9107        type: "address"
9108      },
9109      {
9110        name: "_value",
9111        type: "uint256"
9112      }
9113    ],
9114    outputs: [
9115      {
9116        name: "",
9117        type: "bool"
9118      }
9119    ]
9120  },
9121  {
9122    type: "function",
9123    name: "transferFrom",
9124    stateMutability: "nonpayable",
9125    inputs: [
9126      {
9127        name: "_from",
9128        type: "address"
9129      },
9130      {
9131        name: "_to",
9132        type: "address"
9133      },
9134      {
9135        name: "_value",
9136        type: "uint256"
9137      }
9138    ],
9139    outputs: [
9140      {
9141        name: "",
9142        type: "bool"
9143      }
9144    ]
9145  }
9146], by = [
9147  {
9148    type: "function",
9149    name: "approve",
9150    stateMutability: "nonpayable",
9151    inputs: [
9152      { name: "spender", type: "address" },
9153      { name: "amount", type: "uint256" }
9154    ],
9155    outputs: [{ type: "bool" }]
9156  }
9157], wy = [
9158  {
9159    type: "function",
9160    name: "transfer",
9161    stateMutability: "nonpayable",
9162    inputs: [
9163      {
9164        name: "recipient",
9165        type: "address"
9166      },
9167      {
9168        name: "amount",
9169        type: "uint256"
9170      }
9171    ],
9172    outputs: []
9173  },
9174  {
9175    type: "function",
9176    name: "transferFrom",
9177    stateMutability: "nonpayable",
9178    inputs: [
9179      {
9180        name: "sender",
9181        type: "address"
9182      },
9183      {
9184        name: "recipient",
9185        type: "address"
9186      },
9187      {
9188        name: "amount",
9189        type: "uint256"
9190      }
9191    ],
9192    outputs: [
9193      {
9194        name: "",
9195        type: "bool"
9196      }
9197    ]
9198  }
9199], Cy = {
9200  getERC20Abi: (e) => x.USDT_CONTRACT_ADDRESSES.includes(e) ? wy : yy,
9201  getSwapAbi: () => by
9202}, it = {
9203  ConnectorExplorerIds: {
9204    [x.CONNECTOR_ID.COINBASE]: "d0ca99ff52b99abc48743dad0f7fc891e041be73574f7fac4afe5d4bb83845c8",
9205    [x.CONNECTOR_ID.COINBASE_SDK]: "d0ca99ff52b99abc48743dad0f7fc891e041be73574f7fac4afe5d4bb83845c8",
9206    [x.CONNECTOR_ID.BASE_ACCOUNT]: "fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",
9207    [x.CONNECTOR_ID.SAFE]: "225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",
9208    [x.CONNECTOR_ID.LEDGER]: "19177a98252e07ddfc9af2083ba8e07ef627cb6103467ffebb3f8f4205fd7927",
9209    [x.CONNECTOR_ID.OKX]: "971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",
9210    [x.METMASK_CONNECTOR_NAME]: "c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",
9211    [x.TRUST_CONNECTOR_NAME]: "4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",
9212    [x.SOLFLARE_CONNECTOR_NAME]: "1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",
9213    [x.PHANTOM_CONNECTOR_NAME]: "a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",
9214    [x.COIN98_CONNECTOR_NAME]: "2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",
9215    [x.MAGIC_EDEN_CONNECTOR_NAME]: "8b830a2b724a9c3fbab63af6f55ed29c9dfa8a55e732dc88c80a196a2ba136c6",
9216    [x.BACKPACK_CONNECTOR_NAME]: "2bd8c14e035c2d48f184aaa168559e86b0e3433228d3c4075900a221785019b0",
9217    [x.BITGET_CONNECTOR_NAME]: "38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",
9218    [x.FRONTIER_CONNECTOR_NAME]: "85db431492aa2e8672e93f4ea7acf10c88b97b867b0d373107af63dc4880f041",
9219    [x.XVERSE_CONNECTOR_NAME]: "2a87d74ae02e10bdd1f51f7ce6c4e1cc53cd5f2c0b6b5ad0d7b3007d2b13de7b",
9220    [x.LEATHER_CONNECTOR_NAME]: "483afe1df1df63daf313109971ff3ef8356ddf1cc4e45877d205eee0b7893a13",
9221    [x.OKX_CONNECTOR_NAME]: "971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",
9222    [x.BINANCE_CONNECTOR_NAME]: "2fafea35bb471d22889ccb49c08d99dd0a18a37982602c33f696a5723934ba25"
9223  },
9224  ConnectorImageIds: {
9225    [x.CONNECTOR_ID.COINBASE]: "0c2840c3-5b04-4c44-9661-fbd4b49e1800",
9226    [x.CONNECTOR_ID.COINBASE_SDK]: "0c2840c3-5b04-4c44-9661-fbd4b49e1800",
9227    [x.CONNECTOR_ID.BASE_ACCOUNT]: "bba2c8be-7fd1-463e-42b1-796ecb0ad200",
9228    [x.CONNECTOR_ID.SAFE]: "461db637-8616-43ce-035a-d89b8a1d5800",
9229    [x.CONNECTOR_ID.LEDGER]: "54a1aa77-d202-4f8d-0fb2-5d2bb6db0300",
9230    [x.CONNECTOR_ID.WALLET_CONNECT]: "ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400",
9231    [x.CONNECTOR_ID.INJECTED]: "07ba87ed-43aa-4adf-4540-9e6a2b9cae00"
9232  },
9233  ConnectorNamesMap: {
9234    [x.CONNECTOR_ID.INJECTED]: "Browser Wallet",
9235    [x.CONNECTOR_ID.WALLET_CONNECT]: "WalletConnect",
9236    [x.CONNECTOR_ID.COINBASE]: "Coinbase",
9237    [x.CONNECTOR_ID.COINBASE_SDK]: "Coinbase",
9238    [x.CONNECTOR_ID.BASE_ACCOUNT]: "Base Account",
9239    [x.CONNECTOR_ID.LEDGER]: "Ledger",
9240    [x.CONNECTOR_ID.SAFE]: "Safe"
9241  },
9242  ConnectorTypesMap: {
9243    [x.CONNECTOR_ID.INJECTED]: "INJECTED",
9244    [x.CONNECTOR_ID.WALLET_CONNECT]: "WALLET_CONNECT",
9245    [x.CONNECTOR_ID.EIP6963]: "ANNOUNCED",
9246    [x.CONNECTOR_ID.AUTH]: "AUTH",
9247    [x.CONNECTOR_ID.COINBASE]: "EXTERNAL",
9248    [x.CONNECTOR_ID.COINBASE_SDK]: "EXTERNAL",
9249    [x.CONNECTOR_ID.BASE_ACCOUNT]: "EXTERNAL"
9250  }
9251}, wt = {
9252  validateCaipAddress(e) {
9253    if (e.split(":")?.length !== 3)
9254      throw new Error("Invalid CAIP Address");
9255    return e;
9256  },
9257  parseCaipAddress(e) {
9258    const t = e.split(":");
9259    if (t.length !== 3)
9260      throw new Error(`Invalid CAIP-10 address: ${e}`);
9261    const [n, r, s] = t;
9262    if (!n || !r || !s)
9263      throw new Error(`Invalid CAIP-10 address: ${e}`);
9264    return {
9265      chainNamespace: n,
9266      chainId: r,
9267      address: s
9268    };
9269  },
9270  parseCaipNetworkId(e) {
9271    const t = e.split(":");
9272    if (t.length !== 2)
9273      throw new Error(`Invalid CAIP-2 network id: ${e}`);
9274    const [n, r] = t;
9275    if (!n || !r)
9276      throw new Error(`Invalid CAIP-2 network id: ${e}`);
9277    return {
9278      chainNamespace: n,
9279      chainId: r
9280    };
9281  }
9282}, St = {
9283  RPC_ERROR_CODE: {
9284    USER_REJECTED_REQUEST: 4001,
9285    USER_REJECTED_METHODS: 5002,
9286    USER_REJECTED: 5e3,
9287    SEND_TRANSACTION_ERROR: 5001
9288  },
9289  PROVIDER_RPC_ERROR_NAME: {
9290    PROVIDER_RPC: "ProviderRpcError",
9291    USER_REJECTED_REQUEST: "UserRejectedRequestError",
9292    SEND_TRANSACTION_ERROR: "SendTransactionError"
9293  },
9294  isRpcProviderError(e) {
9295    try {
9296      if (typeof e == "object" && e !== null) {
9297        const t = e, n = typeof t.message == "string", r = typeof t.code == "number";
9298        return n && r;
9299      }
9300      return !1;
9301    } catch {
9302      return !1;
9303    }
9304  },
9305  isUserRejectedMessage(e) {
9306    return e.toLowerCase().includes("user rejected") || e.toLowerCase().includes("user cancelled") || e.toLowerCase().includes("user canceled");
9307  },
9308  isUserRejectedRequestError(e) {
9309    if (St.isRpcProviderError(e)) {
9310      const t = e.code === St.RPC_ERROR_CODE.USER_REJECTED_REQUEST, n = e.code === St.RPC_ERROR_CODE.USER_REJECTED_METHODS;
9311      return t || n || St.isUserRejectedMessage(e.message);
9312    }
9313    return e instanceof Error ? St.isUserRejectedMessage(e.message) : !1;
9314  }
9315};
9316class Ey extends Error {
9317  constructor(t, n) {
9318    super(n.message, { cause: t }), this.name = St.PROVIDER_RPC_ERROR_NAME.PROVIDER_RPC, this.code = n.code;
9319  }
9320}
9321class Zn extends Ey {
9322  constructor(t) {
9323    super(t, {
9324      code: St.RPC_ERROR_CODE.USER_REJECTED_REQUEST,
9325      message: "User rejected the request"
9326    }), this.name = St.PROVIDER_RPC_ERROR_NAME.USER_REJECTED_REQUEST;
9327  }
9328}
9329const te = {
9330  WALLET_ID: "@appkit/wallet_id",
9331  WALLET_NAME: "@appkit/wallet_name",
9332  SOLANA_WALLET: "@appkit/solana_wallet",
9333  SOLANA_CAIP_CHAIN: "@appkit/solana_caip_chain",
9334  ACTIVE_CAIP_NETWORK_ID: "@appkit/active_caip_network_id",
9335  CONNECTED_SOCIAL: "@appkit/connected_social",
9336  CONNECTED_SOCIAL_USERNAME: "@appkit-wallet/SOCIAL_USERNAME",
9337  RECENT_WALLETS: "@appkit/recent_wallets",
9338  RECENT_WALLET: "@appkit/recent_wallet",
9339  DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE",
9340  ACTIVE_NAMESPACE: "@appkit/active_namespace",
9341  CONNECTED_NAMESPACES: "@appkit/connected_namespaces",
9342  CONNECTION_STATUS: "@appkit/connection_status",
9343  SIWX_AUTH_TOKEN: "@appkit/siwx-auth-token",
9344  SIWX_NONCE_TOKEN: "@appkit/siwx-nonce-token",
9345  TELEGRAM_SOCIAL_PROVIDER: "@appkit/social_provider",
9346  NATIVE_BALANCE_CACHE: "@appkit/native_balance_cache",
9347  PORTFOLIO_CACHE: "@appkit/portfolio_cache",
9348  ENS_CACHE: "@appkit/ens_cache",
9349  IDENTITY_CACHE: "@appkit/identity_cache",
9350  PREFERRED_ACCOUNT_TYPES: "@appkit/preferred_account_types",
9351  CONNECTIONS: "@appkit/connections",
9352  DISCONNECTED_CONNECTOR_IDS: "@appkit/disconnected_connector_ids",
9353  HISTORY_TRANSACTIONS_CACHE: "@appkit/history_transactions_cache",
9354  TOKEN_PRICE_CACHE: "@appkit/token_price_cache",
9355  RECENT_EMAILS: "@appkit/recent_emails",
9356  LATEST_APPKIT_VERSION: "@appkit/latest_version",
9357  TON_WALLETS_CACHE: "@appkit/ton_wallets_cache"
9358};
9359function Ho(e) {
9360  if (!e)
9361    throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");
9362  return `@appkit/${e}:connected_connector_id`;
9363}
9364const Q = {
9365  setItem(e, t) {
9366    Jr() && t !== void 0 && localStorage.setItem(e, t);
9367  },
9368  getItem(e) {
9369    if (Jr())
9370      return localStorage.getItem(e) || void 0;
9371  },
9372  removeItem(e) {
9373    Jr() && localStorage.removeItem(e);
9374  },
9375  clear() {
9376    Jr() && localStorage.clear();
9377  }
9378};
9379function Jr() {
9380  return typeof window < "u" && typeof localStorage < "u";
9381}
9382function zi(e, t) {
9383  const n = e?.["--apkt-accent"] ?? e?.["--w3m-accent"];
9384  return t === "light" ? {
9385    "--w3m-accent": n || "hsla(231, 100%, 70%, 1)",
9386    "--w3m-background": "#fff"
9387  } : {
9388    "--w3m-accent": n || "hsla(230, 100%, 67%, 1)",
9389    "--w3m-background": "#202020"
9390  };
9391}
9392var fi = { exports: {} }, Au;
9393function Ay() {
9394  if (Au) return fi.exports;
9395  Au = 1;
9396  var e = typeof Reflect == "object" ? Reflect : null, t = e && typeof e.apply == "function" ? e.apply : function(E, T, O) {
9397    return Function.prototype.apply.call(E, T, O);
9398  }, n;
9399  e && typeof e.ownKeys == "function" ? n = e.ownKeys : Object.getOwnPropertySymbols ? n = function(E) {
9400    return Object.getOwnPropertyNames(E).concat(Object.getOwnPropertySymbols(E));
9401  } : n = function(E) {
9402    return Object.getOwnPropertyNames(E);
9403  };
9404  function r(I) {
9405    console && console.warn && console.warn(I);
9406  }
9407  var s = Number.isNaN || function(E) {
9408    return E !== E;
9409  };
9410  function i() {
9411    i.init.call(this);
9412  }
9413  fi.exports = i, fi.exports.once = _, i.EventEmitter = i, i.prototype._events = void 0, i.prototype._eventsCount = 0, i.prototype._maxListeners = void 0;
9414  var o = 10;
9415  function a(I) {
9416    if (typeof I != "function")
9417      throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof I);
9418  }
9419  Object.defineProperty(i, "defaultMaxListeners", {
9420    enumerable: !0,
9421    get: function() {
9422      return o;
9423    },
9424    set: function(I) {
9425      if (typeof I != "number" || I < 0 || s(I))
9426        throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + I + ".");
9427      o = I;
9428    }
9429  }), i.init = function() {
9430    (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
9431  }, i.prototype.setMaxListeners = function(E) {
9432    if (typeof E != "number" || E < 0 || s(E))
9433      throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + E + ".");
9434    return this._maxListeners = E, this;
9435  };
9436  function u(I) {
9437    return I._maxListeners === void 0 ? i.defaultMaxListeners : I._maxListeners;
9438  }
9439  i.prototype.getMaxListeners = function() {
9440    return u(this);
9441  }, i.prototype.emit = function(E) {
9442    for (var T = [], O = 1; O < arguments.length; O++) T.push(arguments[O]);
9443    var U = E === "error", M = this._events;
9444    if (M !== void 0)
9445      U = U && M.error === void 0;
9446    else if (!U)
9447      return !1;
9448    if (U) {
9449      var L;
9450      if (T.length > 0 && (L = T[0]), L instanceof Error)
9451        throw L;
9452      var re = new Error("Unhandled error." + (L ? " (" + L.message + ")" : ""));
9453      throw re.context = L, re;
9454    }
9455    var ne = M[E];
9456    if (ne === void 0)
9457      return !1;
9458    if (typeof ne == "function")
9459      t(ne, this, T);
9460    else
9461      for (var fe = ne.length, ae = y(ne, fe), O = 0; O < fe; ++O)
9462        t(ae[O], this, T);
9463    return !0;
9464  };
9465  function c(I, E, T, O) {
9466    var U, M, L;
9467    if (a(T), M = I._events, M === void 0 ? (M = I._events = /* @__PURE__ */ Object.create(null), I._eventsCount = 0) : (M.newListener !== void 0 && (I.emit(
9468      "newListener",
9469      E,
9470      T.listener ? T.listener : T
9471    ), M = I._events), L = M[E]), L === void 0)
9472      L = M[E] = T, ++I._eventsCount;
9473    else if (typeof L == "function" ? L = M[E] = O ? [T, L] : [L, T] : O ? L.unshift(T) : L.push(T), U = u(I), U > 0 && L.length > U && !L.warned) {
9474      L.warned = !0;
9475      var re = new Error("Possible EventEmitter memory leak detected. " + L.length + " " + String(E) + " listeners added. Use emitter.setMaxListeners() to increase limit");
9476      re.name = "MaxListenersExceededWarning", re.emitter = I, re.type = E, re.count = L.length, r(re);
9477    }
9478    return I;
9479  }
9480  i.prototype.addListener = function(E, T) {
9481    return c(this, E, T, !1);
9482  }, i.prototype.on = i.prototype.addListener, i.prototype.prependListener = function(E, T) {
9483    return c(this, E, T, !0);
9484  };
9485  function l() {
9486    if (!this.fired)
9487      return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
9488  }
9489  function f(I, E, T) {
9490    var O = { fired: !1, wrapFn: void 0, target: I, type: E, listener: T }, U = l.bind(O);
9491    return U.listener = T, O.wrapFn = U, U;
9492  }
9493  i.prototype.once = function(E, T) {
9494    return a(T), this.on(E, f(this, E, T)), this;
9495  }, i.prototype.prependOnceListener = function(E, T) {
9496    return a(T), this.prependListener(E, f(this, E, T)), this;
9497  }, i.prototype.removeListener = function(E, T) {
9498    var O, U, M, L, re;
9499    if (a(T), U = this._events, U === void 0)
9500      return this;
9501    if (O = U[E], O === void 0)
9502      return this;
9503    if (O === T || O.listener === T)
9504      --this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete U[E], U.removeListener && this.emit
9504("removeListener", E, O.listener || T));
9505    else if (typeof O != "function") {
9506      for (M = -1, L = O.length - 1; L >= 0; L--)
9507        if (O[L] === T || O[L].listener === T) {
9508          re = O[L].listener, M = L;
9509          break;
9510        }
9511      if (M < 0)
9512        return this;
9513      M === 0 ? O.shift() : b(O, M), O.length === 1 && (U[E] = O[0]), U.removeListener !== void 0 && this.emit("removeListener", E, re || T);
9514    }
9515    return this;
9516  }, i.prototype.off = i.prototype.removeListener, i.prototype.removeAllListeners = function(E) {
9517    var T, O, U;
9518    if (O = this._events, O === void 0)
9519      return this;
9520    if (O.removeListener === void 0)
9521      return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : O[E] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete O[E]), this;
9522    if (arguments.length === 0) {
9523      var M = Object.keys(O), L;
9524      for (U = 0; U < M.length; ++U)
9525        L = M[U], L !== "removeListener" && this.removeAllListeners(L);
9526      return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this;
9527    }
9528    if (T = O[E], typeof T == "function")
9529      this.removeListener(E, T);
9530    else if (T !== void 0)
9531      for (U = T.length - 1; U >= 0; U--)
9532        this.removeListener(E, T[U]);
9533    return this;
9534  };
9535  function p(I, E, T) {
9536    var O = I._events;
9537    if (O === void 0)
9538      return [];
9539    var U = O[E];
9540    return U === void 0 ? [] : typeof U == "function" ? T ? [U.listener || U] : [U] : T ? C(U) : y(U, U.length);
9541  }
9542  i.prototype.listeners = function(E) {
9543    return p(this, E, !0);
9544  }, i.prototype.rawListeners = function(E) {
9545    return p(this, E, !1);
9546  }, i.listenerCount = function(I, E) {
9547    return typeof I.listenerCount == "function" ? I.listenerCount(E) : m.call(I, E);
9548  }, i.prototype.listenerCount = m;
9549  function m(I) {
9550    var E = this._events;
9551    if (E !== void 0) {
9552      var T = E[I];
9553      if (typeof T == "function")
9554        return 1;
9555      if (T !== void 0)
9556        return T.length;
9557    }
9558    return 0;
9559  }
9560  i.prototype.eventNames = function() {
9561    return this._eventsCount > 0 ? n(this._events) : [];
9562  };
9563  function y(I, E) {
9564    for (var T = new Array(E), O = 0; O < E; ++O)
9565      T[O] = I[O];
9566    return T;
9567  }
9568  function b(I, E) {
9569    for (; E + 1 < I.length; E++)
9570      I[E] = I[E + 1];
9571    I.pop();
9572  }
9573  function C(I) {
9574    for (var E = new Array(I.length), T = 0; T < E.length; ++T)
9575      E[T] = I[T].listener || I[T];
9576    return E;
9577  }
9578  function _(I, E) {
9579    return new Promise(function(T, O) {
9580      function U(L) {
9581        I.removeListener(E, M), O(L);
9582      }
9583      function M() {
9584        typeof I.removeListener == "function" && I.removeListener("error", U), T([].slice.call(arguments));
9585      }
9586      N(I, E, M, { once: !0 }), E !== "error" && R(I, U, { once: !0 });
9587    });
9588  }
9589  function R(I, E, T) {
9590    typeof I.on == "function" && N(I, "error", E, T);
9591  }
9592  function N(I, E, T, O) {
9593    if (typeof I.on == "function")
9594      O.once ? I.once(E, T) : I.on(E, T);
9595    else if (typeof I.addEventListener == "function")
9596      I.addEventListener(E, function U(M) {
9597        O.once && I.removeEventListener(E, U), T(M);
9598      });
9599    else
9600      throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof I);
9601  }
9602  return fi.exports;
9603}
9604var vy = Ay();
9605const q_ = /* @__PURE__ */ oo(vy);
9606var $t = { exports: {} };
9607function _y(e) {
9608  try {
9609    return JSON.stringify(e);
9610  } catch {
9611    return '"[Circular]"';
9612  }
9613}
9614var Ny = Iy;
9615function Iy(e, t, n) {
9616  var r = n && n.stringify || _y, s = 1;
9617  if (typeof e == "object" && e !== null) {
9618    var i = t.length + s;
9619    if (i === 1) return e;
9620    var o = new Array(i);
9621    o[0] = r(e);
9622    for (var a = 1; a < i; a++) o[a] = r(t[a]);
9623    return o.join(" ");
9624  }
9625  if (typeof e != "string") return e;
9626  var u = t.length;
9627  if (u === 0) return e;
9628  for (var c = "", l = 1 - s, f = -1, p = e && e.length || 0, m = 0; m < p; ) {
9629    if (e.charCodeAt(m) === 37 && m + 1 < p) {
9630      switch (f = f > -1 ? f : 0, e.charCodeAt(m + 1)) {
9631        case 100:
9632        case 102:
9633          if (l >= u || t[l] == null) break;
9634          f < m && (c += e.slice(f, m)), c += Number(t[l]), f = m + 2, m++;
9635          break;
9636        case 105:
9637          if (l >= u || t[l] == null) break;
9638          f < m && (c += e.slice(f, m)), c += Math.floor(Number(t[l])), f = m + 2, m++;
9639          break;
9640        case 79:
9641        case 111:
9642        case 106:
9643          if (l >= u || t[l] === void 0) break;
9644          f < m && (c += e.slice(f, m));
9645          var y = typeof t[l];
9646          if (y === "string") {
9647            c += "'" + t[l] + "'", f = m + 2, m++;
9648            break;
9649          }
9650          if (y === "function") {
9651            c += t[l].name || "<anonymous>", f = m + 2, m++;
9652            break;
9653          }
9654          c += r(t[l]), f = m + 2, m++;
9655          break;
9656        case 115:
9657          if (l >= u) break;
9658          f < m && (c += e.slice(f, m)), c += String(t[l]), f = m + 2, m++;
9659          break;
9660        case 37:
9661          f < m && (c += e.slice(f, m)), c += "%", f = m + 2, m++, l--;
9662          break;
9663      }
9664      ++l;
9665    }
9666    ++m;
9667  }
9668  return f === -1 ? e : (f < p && (c += e.slice(f)), c);
9669}
9670const vu = Ny;
9671$t.exports = dn;
9672const Es = Wy().console || {}, Ty = { mapHttpRequest: hi, mapHttpResponse: hi, wrapRequestSerializer: qo, wrapResponseSerializer: qo, wrapErrorSerializer: qo, req: hi, res: hi, err: Nu, errWithCause: Nu };
9673function Tn(e, t) {
9674  return e === "silent" ? 1 / 0 : t.levels.values[e];
9675}
9676const Tc = /* @__PURE__ */ Symbol("pino.logFuncs"), Na = /* @__PURE__ */ Symbol("pino.hierarchy"), Sy = { error: "log", fatal: "error", warn: "error", info: "log", debug: "log", trace: "log" };
9677function _u(e, t) {
9678  const n = { logger: t, parent: e[Na] };
9679  t[Na] = n;
9680}
9681function Ry(e, t, n) {
9682  const r = {};
9683  t.forEach((s) => {
9684    r[s] = n[s] ? n[s] : Es[s] || Es[Sy[s] || "log"] || Tr;
9685  }), e[Tc] = r;
9686}
9687function xy(e, t) {
9688  return Array.isArray(e) ? e.filter(function(n) {
9689    return n !== "!stdSerializers.err";
9690  }) : e === !0 ? Object.keys(t) : !1;
9691}
9692function dn(e) {
9693  e = e || {}, e.browser = e.browser || {};
9694  const t = e.browser.transmit;
9695  if (t && typeof t.send != "function") throw Error("pino: transmit option must have a send function");
9696  const n = e.browser.write || Es;
9697  e.browser.write && (e.browser.asObject = !0);
9698  const r = e.serializers || {}, s = xy(e.browser.serialize, r);
9699  let i = e.browser.serialize;
9700  Array.isArray(e.browser.serialize) && e.browser.serialize.indexOf("!stdSerializers.err") > -1 && (i = !1);
9701  const o = Object.keys(e.customLevels || {}), a = ["error", "fatal", "warn", "info", "debug", "trace"].concat(o);
9702  typeof n == "function" && a.forEach(function(b) {
9703    n[b] = n;
9704  }), (e.enabled === !1 || e.browser.disabled) && (e.level = "silent");
9705  const u = e.level || "info", c = Object.create(n);
9706  c.log || (c.log = Tr), Ry(c, a, n), _u({}, c), Object.defineProperty(c, "levelVal", { get: f }), Object.defineProperty(c, "level", { get: p, set: m });
9707  const l = { transmit: t, serialize: s, asObject: e.browser.asObject, asObjectBindingsOnly: e.browser.asObjectBindingsOnly, formatters: e.browser.formatters, levels: a, timestamp: Dy(e), messageKey: e.messageKey || "msg", onChild: e.onChild || Tr };
9708  c.levels = Oy(e), c.level = u, c.isLevelEnabled = function(b) {
9709    return this.levels.values[b] ? this.levels.values[b] >
9709= this.levels.values[this.level] : !1;
9710  }, c.setMaxListeners = c.getMaxListeners = c.emit = c.addListener = c.on = c.prependListener = c.once = c.prependOnceListener = c.removeListener = c.removeAllListeners = c.listeners = c.listenerCount = c.eventNames = c.write = c.flush = Tr, c.serializers = r, c._serialize = s, c._stdErrSerialize = i, c.child = function(...b) {
9711    return y.call(this, l, ...b);
9712  }, t && (c._logEvent = Ia());
9713  function f() {
9714    return Tn(this.level, this);
9715  }
9716  function p() {
9717    return this._level;
9718  }
9719  function m(b) {
9720    if (b !== "silent" && !this.levels.values[b]) throw Error("unknown level " + b);
9721    this._level = b, qn(this, l, c, "error"), qn(this, l, c, "fatal"), qn(this, l, c, "warn"), qn(this, l, c, "info"), qn(this, l, c, "debug"), qn(this, l, c, "trace"), o.forEach((C) => {
9722      qn(this, l, c, C);
9723    });
9724  }
9725  function y(b, C, _) {
9726    if (!C) throw new Error("missing bindings for child Pino");
9727    _ = _ || {}, s && C.serializers && (_.serializers = C.serializers);
9728    const R = _.serializers;
9729    if (s && R) {
9730      var N = Object.assign({}, r, R), I = e.browser.serialize === !0 ? Object.keys(N) : s;
9731      delete C.serializers, Sc([C], I, N, this._stdErrSerialize);
9732    }
9733    function E(O) {
9734      this._childLevel = (O._childLevel | 0) + 1, this.bindings = C, N && (this.serializers = N, this._serialize = I), t && (this._logEvent = Ia([].concat(O._logEvent.bindings, C)));
9735    }
9736    E.prototype = this;
9737    const T = new E(this);
9738    return _u(this, T), T.child = function(...O) {
9739      return y.call(this, b, ...O);
9740    }, T.level = _.level || this.level, b.onChild(T), T;
9741  }
9742  return c;
9743}
9744function Oy(e) {
9745  const t = e.customLevels || {}, n = Object.assign({}, dn.levels.values, t), r = Object.assign({}, dn.levels.labels, Py(t));
9746  return { values: n, labels: r };
9747}
9748function Py(e) {
9749  const t = {};
9750  return Object.keys(e).forEach(function(n) {
9751    t[e[n]] = n;
9752  }), t;
9753}
9754dn.levels = { values: { fatal: 60, error: 50, warn: 40, info: 30, debug: 20, trace: 10 }, labels: { 10: "trace", 20: "debug", 30: "info", 40: "warn", 50: "error", 60: "fatal" } }, dn.stdSerializers = Ty, dn.stdTimeFunctions = Object.assign({}, { nullTime: hf, epochTime: pf, unixTime: Fy, isoTime: jy });
9755function ky(e) {
9756  const t = [];
9757  e.bindings && t.push(e.bindings);
9758  let n = e[Na];
9759  for (; n.parent; ) n = n.parent, n.logger.bindings && t.push(n.logger.bindings);
9760  return t.reverse();
9761}
9762function qn(e, t, n, r) {
9763  if (Object.defineProperty(e, r, { value: Tn(e.level, n) > Tn(r, n) ? Tr : n[Tc][r], writable: !0, enumerable: !0, configurable: !0 }), e[r] === Tr) {
9764    if (!t.transmit) return;
9765    const i = t.transmit.level || e.level, o = Tn(i, n);
9766    if (Tn(r, n) < o) return;
9767  }
9768  e[r] = My(e, t, n, r);
9769  const s = ky(e);
9770  s.length !== 0 && (e[r] = Uy(s, e[r]));
9771}
9772function Uy(e, t) {
9773  return function() {
9774    return t.apply(this, [...e, ...arguments]);
9775  };
9776}
9777function My(e, t, n, r) {
9778  return /* @__PURE__ */ (function(s) {
9779    return function() {
9780      const i = t.timestamp(), o = new Array(arguments.length), a = Object.getPrototypeOf && Object.getPrototypeOf(this) === Es ? Es : this;
9781      for (var u = 0; u < o.length; u++) o[u] = arguments[u];
9782      var c = !1;
9783      if (t.serialize && (Sc(o, this._serialize, this.serializers, this._stdErrSerialize), c = !0), t.asObject || t.formatters ? s.call(a, ...Ly(this, r, o, i, t)) : s.apply(a, o), t.transmit) {
9784        const l = t.transmit.level || e._level, f = Tn(l, n), p = Tn(r, n);
9785        if (p < f) return;
9786        By(this, { ts: i, methodLevel: r, methodValue: p, transmitValue: n.levels.values[t.transmit.level || e._level], send: t.transmit.send, val: Tn(e._level, n) }, o, c);
9787      }
9788    };
9789  })(e[Tc][r]);
9790}
9791function Ly(e, t, n, r, s) {
9792  const { level: i, log: o = (f) => f } = s.formatters || {}, a = n.slice();
9793  let u = a[0];
9794  const c = {};
9795  let l = (e._childLevel | 0) + 1;
9796  if (l < 1 && (l = 1), r && (c.time = r), i) {
9797    const f = i(t, e.levels.values[t]);
9798    Object.assign(c, f);
9799  } else c.level = e.levels.values[t];
9800  if (s.asObjectBindingsOnly) {
9801    if (u !== null && typeof u == "object") for (; l-- && typeof a[0] == "object"; ) Object.assign(c, a.shift());
9802    return [o(c), ...a];
9803  } else {
9804    if (u !== null && typeof u == "object") {
9805      for (; l-- && typeof a[0] == "object"; ) Object.assign(c, a.shift());
9806      u = a.length ? vu(a.shift(), a) : void 0;
9807    } else typeof u == "string" && (u = vu(a.shift(), a));
9808    return u !== void 0 && (c[s.messageKey] = u), [o(c)];
9809  }
9810}
9811function Sc(e, t, n, r) {
9812  for (const s in e) if (r && e[s] instanceof Error) e[s] = dn.stdSerializers.err(e[s]);
9813  else if (typeof e[s] == "object" && !Array.isArray(e[s]) && t) for (const i in e[s]) t.indexOf(i) > -1 && i in n && (e[s][i] = n[i](e[s][i]));
9814}
9815function By(e, t, n, r = !1) {
9816  const s = t.send, i = t.ts, o = t.methodLevel, a = t.methodValue, u = t.val, c = e._logEvent.bindings;
9817  r || Sc(n, e._serialize || Object.keys(e.serializers), e.serializers, e._stdErrSerialize === void 0 ? !0 : e._stdErrSerialize), e._logEvent.ts = i, e._logEvent.messages = n.filter(function(l) {
9818    return c.indexOf(l) === -1;
9819  }), e._logEvent.level.label = o, e._logEvent.level.value = a, s(o, e._logEvent, u), e._logEvent = Ia(c);
9820}
9821function Ia(e) {
9822  return { ts: 0, messages: [], bindings: e || [], level: { label: "", value: 0 } };
9823}
9824function Nu(e) {
9825  const t = { type: e.constructor.name, msg: e.message, stack: e.stack };
9826  for (const n in e) t[n] === void 0 && (t[n] = e[n]);
9827  return t;
9828}
9829function Dy(e) {
9830  return typeof e.timestamp == "function" ? e.timestamp : e.timestamp === !1 ? hf : pf;
9831}
9832function hi() {
9833  return {};
9834}
9835function qo(e) {
9836  return e;
9837}
9838function Tr() {
9839}
9840function hf() {
9841  return !1;
9842}
9843function pf() {
9844  return Date.now();
9845}
9846function Fy() {
9847  return Math.round(Date.now() / 1e3);
9848}
9849function jy() {
9850  return new Date(Date.now()).toISOString();
9851}
9852function Wy() {
9853  function e(t) {
9854    return typeof t < "u" && t;
9855  }
9856  try {
9857    return typeof globalThis < "u" || Object.defineProperty(Object.prototype, "globalThis", { get: function() {
9858      return delete Object.prototype.globalThis, this.globalThis = this;
9859    }, configurable: !0 }), globalThis;
9860  } catch {
9861    return e(self) || e(window) || e(this) || {};
9862  }
9863}
9864$t.exports.default = dn;
9865$t.exports.pino = dn;
9866const $y = { level: "info" }, wo = "custom_context", Rc = 1e3 * 1024;
9867var Hy = Object.defineProperty, qy = (e, t, n) => t in e ? Hy(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Nn = (e, t, n) => qy(e, typeof t != "symbol" ? t + "" : t, n);
9868class Gy {
9869  constructor(t) {
9870    Nn(this, "nodeValue"), Nn(this, "sizeInBytes"), Nn(this, "next"), this.nodeValue = t, this.sizeInBytes = new TextEncoder().encode(this.nodeValue).length, this.next = null;
9871  }
9872  get value() {
9873    return this.nodeValue;
9874  }
9875  get size() {
9876    return this.sizeInBytes;
9877  }
9878}
9879class Iu {
9880  constructor(t) {
9881    Nn(this, "lengthInNodes"), Nn(this, "sizeInBytes"), Nn(this, "head"), Nn(this, "tail"), Nn(this, "maxSizeInBytes"), this.head = null, this.tail = null, this.lengthInNodes = 0, this.maxSizeInBytes = t, this.sizeInBytes = 0;
9882  }
9883  append(t) {
9884    const n = new Gy(t);
9885    if (n.size > this.maxSizeInBytes) throw new Error(`[LinkedList] Value too big to insert into list: ${t} with size ${n.size}`);
9886    for (; this.size + n.size > this.maxSizeInBytes; ) this.shift();
9887    this.head ? (this.tail && (this.tail.next = n), this.tail = n) : (this.head = n, this.tail = n), this.lengthInNodes++, this.sizeInBytes += n.size;
9888  }
9889  shift() {
9890    if (!this.head) return;
9891    const t = this.head;
9892    this.head = this.head.next, this.head || (this.tail = null), this.lengthInNodes--, this.sizeInBytes -= t.size;
9893  }
9894  toArray() {
9895    const t = [];
9896    let n = this.head;
9897    for (; n !== null; ) t.push(n.value), n = n.next;
9898    return t;
9899  }
9900  get length() {
9901    return this.lengthInNodes;
9902  }
9903  get size() {
9904    return this.sizeInBytes;
9905  }
9906  toOrderedArray() {
9907    return Array.from(this);
9908  }
9909  [Symbol.iterator]() {
9910    let t = this.head;
9911    return { next: () => {
9912      if (!t) return { done: !0, value: null };
9913      const n = t.value;
9914      return t = t.next, { done: !1, value: n };
9915    } };
9916  }
9917}
9918const zy = (e) => JSON.stringify(e, (t, n) => typeof n == "bigint" ? n.toString() + "n" : n);
9919function Tu(e) {
9920  return typeof e == "string" ? e : zy(e) || "";
9921}
9922var Vy = Object.defineProperty, Ky = (e, t, n) => t in e ? Vy(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, pi = (e, t, n) => Ky(e, typeof t != "symbol" ? t + "" : t, n);
9923class mf {
9924  constructor(t, n = Rc) {
9925    pi(this, "logs"), pi(this, "level"), pi(this, "levelValue"), pi(this, "MAX_LOG_SIZE_IN_BYTES"), this.level = t ?? "error", this.levelValue = $t.exports.levels.values[this.level], this.MAX_LOG_SIZE_IN_BYTES = n, this.logs = new Iu(this.MAX_LOG_SIZE_IN_BYTES);
9926  }
9927  forwardToConsole(t, n) {
9928    n === $t.exports.levels.values.error ? console.error(t) : n === $t.exports.levels.values.warn ? console.warn(t) : n === $t.exports.levels.values.debug ? console.debug(t) : n === $t.exports.levels.values.trace ? console.trace(t) : console.log(t);
9929  }
9930  appendToLogs(t) {
9931    this.logs.append(Tu({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), log: t }));
9932    const n = typeof t == "string" ? JSON.parse(t).level : t.level;
9933    n >= this.levelValue && this.forwardToConsole(t, n);
9934  }
9935  getLogs() {
9936    return this.logs;
9937  }
9938  clearLogs() {
9939    this.logs = new Iu(this.MAX_LOG_SIZE_IN_BYTES);
9940  }
9941  getLogArray() {
9942    return Array.from(this.logs);
9943  }
9944  logsToBlob(t) {
9945    const n = this.getLogArray();
9946    return n.push(Tu({ extraMetadata: t })), new Blob(n, { type: "application/json" });
9947  }
9948}
9949var Yy = Object.defineProperty, Zy = (e, t, n) => t in e ? Yy(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Qy = (e, t, n) => Zy(e, t + "", n);
9950class Jy {
9951  constructor(t, n = Rc) {
9952    Qy(this, "baseChunkLogger"), this.baseChunkLogger = new mf(t, n);
9953  }
9954  write(t) {
9955    this.baseChunkLogger.appendToLogs(t);
9956  }
9957  getLogs() {
9958    return this.baseChunkLogger.getLogs();
9959  }
9960  clearLogs() {
9961    this.baseChunkLogger.clearLogs();
9962  }
9963  getLogArray() {
9964    return this.baseChunkLogger.getLogArray();
9965  }
9966  logsToBlob(t) {
9967    return this.baseChunkLogger.logsToBlob(t);
9968  }
9969  downloadLogsBlobInBrowser(t) {
9970    const n = URL.createObjectURL(this.logsToBlob(t)), r = document.createElement("a");
9971    r.href = n, r.download = `walletconnect-logs-${(/* @__PURE__ */ new Date()).toISOString()}.txt`, document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(n);
9972  }
9973}
9974var Xy = Object.defineProperty, eb = (e, t, n) => t in e ? Xy(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, tb = (e, t, n) => eb(e, t + "", n);
9975class nb {
9976  constructor(t, n = Rc) {
9977    tb(this, "baseChunkLogger"), this.baseChunkLogger = new mf(t, n);
9978  }
9979  write(t) {
9980    this.baseChunkLogger.appendToLogs(t);
9981  }
9982  getLogs() {
9983    return this.baseChunkLogger.getLogs();
9984  }
9985  clearLogs() {
9986    this.baseChunkLogger.clearLogs();
9987  }
9988  getLogArray() {
9989    return this.baseChunkLogger.getLogArray();
9990  }
9991  logsToBlob(t) {
9992    return this.baseChunkLogger.logsToBlob(t);
9993  }
9994}
9995var rb = Object.defineProperty, sb = Object.defineProperties, ib = Object.getOwnPropertyDescriptors, Su = Object.getOwnPropertySymbols, ob = Object.prototype.hasOwnProperty, ab = Object.prototype.propertyIsEnumerable, Ru = (e, t, n) => t in e ? rb(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, kn = (e, t) => {
9996  for (var n in t || (t = {})) ob.call(t, n) && Ru(e, n, t[n]);
9997  if (Su) for (var n of Su(t)) ab.call(t, n) && Ru(e, n, t[n]);
9998  return e;
9999}, Un = (e, t) => sb(e, ib(t));
10000function cb(e) {
10001  return Un(kn({}, e), { level: e?.level || $y.level });
10002}
10003function ub(e, t, n = wo) {
10004  return e[n] = t, e;
10005}
10006function lb(e, t = wo) {
10007  return e[t] || "";
10008}
10009function db(e, t, n = wo) {
10010  const r = lb(e, n);
10011  return r.trim() ? `${r}/${t}` : t;
10012}
10013function fb(e, t, n = wo) {
10014  const r = db(e, t, n), s = e.child({ context: r });
10015  return ub(s, r, n);
10016}
10017function hb(e) {
10018  var t, n;
10019  const r = new Jy((t = e.opts) == null ? void 0 : t.level, e.maxSizeInBytes);
10020  return { logger: $t.exports(Un(kn({}, e.opts), { level: "trace", browser: Un(kn({}, (n = e.opts) == null ? void 0 : n.browser), { write: (s) => r.write(s) }) })), chunkLoggerController: r };
10021}
10022function pb(e) {
10023  var t, n;
10024  const r = new nb((t = e.opts) == null ? void 0 : t.level, e.maxSizeInBytes);
10025  return { logger: $t.exports(Un(kn({}, e.opts), { level: "trace", browser: Un(kn({}, (n = e.opts) == null ? void 0 : n.browser), { write: (s) => r.write(s) }) }), r), chunkLoggerController: r };
10026}
10027function mb(e) {
10028  var t;
10029  if (typeof e.loggerOverride < "u" && typeof e.loggerOverride != "string") return { logger: e.loggerOverride, chunkLoggerController: null };
10030  const n = Un(kn({}, e.opts), { level: typeof e.loggerOverride == "string" ? e.loggerOverride : (t = e.opts) == null ? void 0 : t.level });
10031  return typeof window < "u" ? hb(Un(kn({}, e), { opts: n })) : pb(Un(kn({}, e), { opts: n }));
10032}
10033var Go = { exports: {} }, xu;
10034function gb() {
10035  return xu || (xu = 1, (function(e) {
10036    var t = Object.prototype.hasOwnProperty, n = "~";
10037    function r() {
10038    }
10039    Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (n = !1));
10040    function s(u, c, l) {
10041      this.fn = u, this.context = c, this.once = l || !1;
10042    }
10043    function i(u, c, l, f, p) {
10044      if (typeof l != "function")
10045        throw new TypeError("The listener must be a function");
10046      var m = new s(l, f || u, p), y = n ? n + c : c;
10047      return u._events[y] ? u._events[y].fn ? u._events[y] = [u._events[y], m] : u._events[y].push(m) : (u._events[y] = m, u._eventsCount++), u;
10048    }
10049    function o(u, c) {
10050      --u._eventsCount === 0 ? u._events = new r() : delete u._events[c];
10051    }
10052    function a() {
10053      this._events = new r(), this._eventsCount = 0;
10054    }
10055    a.prototype.eventNames = function() {
10056      var c = [], l, f;
10057      if (this._eventsCount === 0) return c;
10058      for (f in l = this._events)
10059        t.call(l, f) && c.push(n ? f.slice(1) : f);
10060      return Object.getOwnPropertySymbols ? c.concat(Object.getOwnPropertySymbols(l)) : c;
10061    }, a.prototype.listeners = function(c) {
10062      var l = n ? n + c : c, f = this._events[l];
10063      if (!f) return [];
10064      if (f.fn) return [f.fn];
10065      for (var p = 0, m = f.length, y = new Array(m); p < m; p++)
10066        y[p] = f[p].fn;
10067      return y;
10068    }, a.prototype.listenerCount = function(c) {
10069      var l = n ? n + c : c, f = this._events[l];
10070      return f ? f.fn ? 1 : f.length : 0;
10071    }, a.prototype.emit = function(c, l, f, p, m, y) {
10072      var b = n ? n + c : c;
10073      if (!this._events[b]) return !1;
10074      var C = this._events[b], _ = arguments.length, R, N;
10075      if (C.fn) {
10076        switch (C.once && this.removeListener(c, C.fn, void 0, !0), _) {
10077          case 1:
10078            return C.fn.call(C.context), !0;
10079          case 2:
10080            return C.fn.call(C.context, l), !0;
10081          case 3:
10082            return C.fn.call(C.context, l, f), !0;
10083          case 4:
10084            return C.fn.call(C.context, l, f, p), !0;
10085          case 5:
10086            return C.fn.call(C.context, l, f, p, m), !0;
10087          case 6:
10088            return C.fn.call(C.context, l, f, p, m, y), !0;
10089        }
10090        for (N = 1, R = new Array(_ - 1); N < _; N++)
10091          R[N - 1] = arguments[N];
10092        C.fn.apply(C.context, R);
10093      } else {
10094        var I = C.length, E;
10095        for (N = 0; N < I; N++)
10096          switch (C[N].once && this.removeListener(c, C[N].fn, void 0, !0), _) {
10097            case 1:
10098              C[N].fn.call(C[N].context);
10099              break;
10100            case 2:
10101              C[N].fn.call(C[N].context, l);
10102              break;
10103            case 3:
10104              C[N].fn.call(C[N].context, l, f);
10105              break;
10106            case 4:
10107              C[N].fn.call(C[N].context, l, f, p);
10108              break;
10109            default:
10110              if (!R) for (E = 1, R = new Array(_ - 1); E < _; E++)
10111                R[E - 1] = arguments[E];
10112              C[N].fn.apply(C[N].context, R);
10113          }
10114      }
10115      return !0;
10116    }, a.prototype.on = function(c, l, f) {
10117      return i(this, c, l, f, !1);
10118    }, a.prototype.once = function(c, l, f) {
10119      return i(this, c, l, f, !0);
10120    }, a.prototype.removeListener = function(c, l, f, p) {
10121      var m = n ? n + c : c;
10122      if (!this._events[m]) return this;
10123      if (!l)
10124        return o(this, m), this;
10125      var y = this._events[m];
10126      if (y.fn)
10127        y.fn === l && (!p || y.once) && (!f || y.context === f) && o(this, m);
10128      else {
10129        for (var b = 0, C = [], _ = y.length; b < _; b++)
10130          (y[b].fn !== l || p && !y[b].once || f && y[b].context !== f) && C.push(y[b]);
10131        C.length ? this._events[m] = C.length === 1 ? C[0] : C : o(this, m);
10132      }
10133      return this;
10134    }, a.prototype.removeAllListeners = function(c) {
10135      var l;
10136      return c ? (l = n ? n + c : c, this._events[l] && o(this, l)) : (this._events = new r(), this._eventsCount = 0), this;
10137    }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = n, a.EventEmitter = a, e.exports = a;
10138  })(Go)), Go.exports;
10139}
10140var yb = gb();
10141const bb = /* @__PURE__ */ oo(yb);
10142var zo = {};
10143var Ta = function(e, t) {
10144  return Ta = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, r) {
10145    n.__proto__ = r;
10146  } || function(n, r) {
10147    for (var s in r) r.hasOwnProperty(s) && (n[s] = r[s]);
10148  }, Ta(e, t);
10149};
10150function wb(e, t) {
10151  Ta(e, t);
10152  function n() {
10153    this.constructor = e;
10154  }
10155  e.prototype = t === null ? Object.create(t) : (n.prototype = t.prototype, new n());
10156}
10157var Sa = function() {
10158  return Sa = Object.assign || function(t) {
10159    for (var n, r = 1, s = arguments.length; r < s; r++) {
10160      n = arguments[r];
10161      for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && (t[i] = n[i]);
10162    }
10163    return t;
10164  }, Sa.apply(this, arguments);
10165};
10166function Cb(e, t) {
10167  var n = {};
10168  for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
10169  if (e != null && typeof Object.getOwnPropertySymbols == "function")
10170    for (var s = 0, r = Object.getOwnPropertySymbols(e); s < r.length; s++)
10171      t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[s]) && (n[r[s]] = e[r[s]]);
10172  return n;
10173}
10174function Eb(e, t, n, r) {
10175  var s = arguments.length, i = s < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
10176  if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(e, t, n, r);
10177  else for (var a = e.length - 1; a >= 0; a--) (o = e[a]) && (i = (s < 3 ? o(i) : s > 3 ? o(t, n, i) : o(t, n)) || i);
10178  return s > 3 && i && Object.defineProperty(t, n, i), i;
10179}
10180function Ab(e, t) {
10181  return function(n, r) {
10182    t(n, r, e);
10183  };
10184}
10185function vb(e, t) {
10186  if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, t);
10187}
10188function _b(e, t, n, r) {
10189  function s(i) {
10190    return i instanceof n ? i : new n(function(o) {
10191      o(i);
10192    });
10193  }
10194  return new (n || (n = Promise))(function(i, o) {
10195    function a(l) {
vendor: 4,479 bytes, lines 10196-10363
10196      try {
10197        c(r.next(l));
10198      } catch (f) {
10199        o(f);
10200      }
10201    }
10202    function u(l) {
10203      try {
10204        c(r.throw(l));
10205      } catch (f) {
10206        o(f);
10207      }
10208    }
10209    function c(l) {
10210      l.done ? i(l.value) : s(l.value).then(a, u);
10211    }
10212    c((r = r.apply(e, t || [])).next());
10213  });
10214}
10215function Nb(e, t) {
10216  var n = { label: 0, sent: function() {
10217    if (i[0] & 1) throw i[1];
10218    return i[1];
10219  }, trys: [], ops: [] }, r, s, i, o;
10220  return o = { next: a(0), throw: a(1), return: a(2) }, typeof Symbol == "function" && (o[Symbol.iterator] = function() {
10221    return this;
10222  }), o;
10223  function a(c) {
10224    return function(l) {
10225      return u([c, l]);
10226    };
10227  }
10228  function u(c) {
10229    if (r) throw new TypeError("Generator is already executing.");
10230    for (; n; ) try {
10231      if (r = 1, s && (i = c[0] & 2 ? s.return : c[0] ? s.throw || ((i = s.return) && i.call(s), 0) : s.next) && !(i = i.call(s, c[1])).done) return i;
10232      switch (s = 0, i && (c = [c[0] & 2, i.value]), c[0]) {
10233        case 0:
10234        case 1:
10235          i = c;
10236          break;
10237        case 4:
10238          return n.label++, { value: c[1], done: !1 };
10239        case 5:
10240          n.label++, s = c[1], c = [0];
10241          continue;
10242        case 7:
10243          c = n.ops.pop(), n.trys.pop();
10244          continue;
10245        default:
10246          if (i = n.trys, !(i = i.length > 0 && i[i.length - 1]) && (c[0] === 6 || c[0] === 2)) {
10247            n = 0;
10248            continue;
10249          }
10250          if (c[0] === 3 && (!i || c[1] > i[0] && c[1] < i[3])) {
10251            n.label = c[1];
10252            break;
10253          }
10254          if (c[0] === 6 && n.label < i[1]) {
10255            n.label = i[1], i = c;
10256            break;
10257          }
10258          if (i && n.label < i[2]) {
10259            n.label = i[2], n.ops.push(c);
10260            break;
10261          }
10262          i[2] && n.ops.pop(), n.trys.pop();
10263          continue;
10264      }
10265      c = t.call(e, n);
10266    } catch (l) {
10267      c = [6, l], s = 0;
10268    } finally {
10269      r = i = 0;
10270    }
10271    if (c[0] & 5) throw c[1];
10272    return { value: c[0] ? c[1] : void 0, done: !0 };
10273  }
10274}
10275function Ib(e, t, n, r) {
10276  r === void 0 && (r = n), e[r] = t[n];
10277}
10278function Tb(e, t) {
10279  for (var n in e) n !== "default" && !t.hasOwnProperty(n) && (t[n] = e[n]);
10280}
10281function Ra(e) {
10282  var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], r = 0;
10283  if (n) return n.call(e);
10284  if (e && typeof e.length == "number") return {
10285    next: function() {
10286      return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e };
10287    }
10288  };
10289  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
10290}
10291function gf(e, t) {
10292  var n = typeof Symbol == "function" && e[Symbol.iterator];
10293  if (!n) return e;
10294  var r = n.call(e), s, i = [], o;
10295  try {
10296    for (; (t === void 0 || t-- > 0) && !(s = r.next()).done; ) i.push(s.value);
10297  } catch (a) {
10298    o = { error: a };
10299  } finally {
10300    try {
10301      s && !s.done && (n = r.return) && n.call(r);
10302    } finally {
10303      if (o) throw o.error;
10304    }
10305  }
10306  return i;
10307}
10308function Sb() {
10309  for (var e = [], t = 0; t < arguments.length; t++)
10310    e = e.concat(gf(arguments[t]));
10311  return e;
10312}
10313function Rb() {
10314  for (var e = 0, t = 0, n = arguments.length; t < n; t++) e += arguments[t].length;
10315  for (var r = Array(e), s = 0, t = 0; t < n; t++)
10316    for (var i = arguments[t], o = 0, a = i.length; o < a; o++, s++)
10317      r[s] = i[o];
10318  return r;
10319}
10320function As(e) {
10321  return this instanceof As ? (this.v = e, this) : new As(e);
10322}
10323function xb(e, t, n) {
10324  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
10325  var r = n.apply(e, t || []), s, i = [];
10326  return s = {}, o("next"), o("throw"), o("return"), s[Symbol.asyncIterator] = function() {
10327    return this;
10328  }, s;
10329  function o(p) {
10330    r[p] && (s[p] = function(m) {
10331      return new Promise(function(y, b) {
10332        i.push([p, m, y, b]) > 1 || a(p, m);
10333      });
10334    });
10335  }
10336  function a(p, m) {
10337    try {
10338      u(r[p](m));
10339    } catch (y) {
10340      f(i[0][3], y);
10341    }
10342  }
10343  function u(p) {
10344    p.value instanceof As ? Promise.resolve(p.value.v).then(c, l) : f(i[0][2], p);
10345  }
10346  function c(p) {
10347    a("next", p);
10348  }
10349  function l(p) {
10350    a("throw", p);
10351  }
10352  function f(p, m) {
10353    p(m), i.shift(), i.length && a(i[0][0], i[0][1]);
10354  }
10355}
10356function Ob(e) {
10357  var t, n;
10358  return t = {}, r("next"), r("throw", function(s) {
10359    throw s;
10360  }), r("return"), t[Symbol.iterator] = function() {
10361    return this;
10362  }, t;
10363  function r(s, i) {
10364    t[s] = e[s] ? function(o) {
10365      return (n = !n) ? { value: As(e[s](o)), done: s === "return" } : i ? i(o) : o;
10366    } : i;
10367  }
10368}
10369function Pb(e) {
10370  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
10371  var t = e[Symbol.asyncIterator], n;
10372  return t ? t.call(e) : (e = typeof Ra == "function" ? Ra(e) : e[Symbol.iterator](), n = {}, r("next"), r("throw"), r("return"), n[Symbol.asyncIterator] = function() {
10373    return this;
10374  }, n);
10375  function r(i) {
10376    n[i] = e[i] && function(o) {
10377      return new Promise(function(a, u) {
10378        o = e[i](o), s(a, u, o.done, o.value);
10379      });
10380    };
10381  }
10382  function s(i, o, a, u) {
10383    Promise.resolve(u).then(function(c) {
10384      i({ value: c, done: a });
10385    }, o);
10386  }
10387}
10388function kb(e, t) {
10389  return Object.defineProperty ? Object.defineProperty(e, "raw", { value: t }) : e.raw = t, e;
10390}
10391function Ub(e) {
10392  if (e && e.__esModule) return e;
10393  var t = {};
10394  if (e != null) for (var n in e) Object.hasOwnProperty.call(e, n) && (t[n] = e[n]);
10395  return t.default = e, t;
10396}
10397function Mb(e) {
10398  return e && e.__esModule ? e : { default: e };
10399}
10400function Lb(e, t) {
10401  if (!t.has(e))
10402    throw new TypeError("attempted to get private field on non-instance");
10403  return t.get(e);
10404}
10405function Bb(e, t, n) {
10406  if (!t.has(e))
10407    throw new TypeError("attempted to set private field on non-instance");
10408  return t.set(e, n), n;
10409}
10410const Db = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10411  __proto__: null,
10412  get __assign() {
10413    return Sa;
10414  },
10415  __asyncDelegator: Ob,
10416  __asyncGenerator: xb,
10417  __asyncValues: Pb,
10418  __await: As,
10419  __awaiter: _b,
10420  __classPrivateFieldGet: Lb,
10421  __classPrivateFieldSet: Bb,
10422  __createBinding: Ib,
10423  __decorate: Eb,
10424  __exportStar: Tb,
10425  __extends: wb,
10426  __generator: Nb,
10427  __importDefault: Mb,
10428  __importStar: Ub,
10429  __makeTemplateObject: kb,
10430  __metadata: vb,
10431  __param: Ab,
10432  __read: gf,
10433  __rest: Cb,
10434  __spread: Sb,
10435  __spreadArrays: Rb,
10436  __values: Ra
10437}, Symbol.toStringTag, { value: "Module" })), Fb = /* @__PURE__ */ hh(Db);
10438var Xt = {}, Ou;
10439function jb() {
10440  if (Ou) return Xt;
10441  Ou = 1, Object.defineProperty(Xt, "__esModule", { value: !0 }), Xt.isBrowserCryptoAvailable = Xt.getSubtleCrypto = Xt.getBrowerCrypto = void 0;
10442  function e() {
10443    return jt?.crypto || jt?.msCrypto || {};
10444  }
10445  Xt.getBrowerCrypto = e;
10446  function t() {
10447    const r = e();
10448    return r.subtle || r.webkitSubtle;
10449  }
10450  Xt.getSubtleCrypto = t;
10451  function n() {
10452    return !!e() && !!t();
10453  }
10454  return Xt.isBrowserCryptoAvailable = n, Xt;
10455}
10456var en = {}, Pu;
10457function Wb() {
10458  if (Pu) return en;
10459  Pu = 1, Object.defineProperty(en, "__esModule", { value: !0 }), en.isBrowser = en.isNode = en.isReactNative = void 0;
10460  function e() {
10461    return typeof document > "u" && typeof navigator < "u" && navigator.product === "ReactNative";
10462  }
10463  en.isReactNative = e;
10464  function t() {
10465    return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u";
10466  }
10467  en.isNode = t;
10468  function n() {
10469    return !e() && !t();
10470  }
10471  return en.isBrowser = n, en;
10472}
10473var ku;
10474function $b() {
10475  return ku || (ku = 1, (function(e) {
10476    Object.defineProperty(e, "__esModule", { value: !0 });
10477    const t = Fb;
10478    t.__exportStar(jb(), e), t.__exportStar(Wb(), e);
10479  })(zo)), zo;
10480}
10481var G_ = $b(), mi = { exports: {} }, Uu;
10482function Hb() {
10483  return Uu || (Uu = 1, (function(e, t) {
10484    var n = typeof globalThis < "u" && globalThis || typeof self < "u" && self || typeof jt < "u" && jt, r = (function() {
10485      function i() {
10486        this.fetch = !1, this.DOMException = n.DOMException;
10487      }
10488      return i.prototype = n, new i();
10489    })();
10490    (function(i) {
10491      (function(o) {
10492        var a = typeof i < "u" && i || typeof self < "u" && self || // eslint-disable-next-line no-undef
10493        typeof jt < "u" && jt || {}, u = {
10494          searchParams: "URLSearchParams" in a,
10495          iterable: "Symbol" in a && "iterator" in Symbol,
10496          blob: "FileReader" in a && "Blob" in a && (function() {
10497            try {
10498              return new Blob(), !0;
10499            } catch {
10500              return !1;
10501            }
10502          })(),
10503          formData: "FormData" in a,
10504          arrayBuffer: "ArrayBuffer" in a
10505        };
10506        function c(P) {
10507          return P && DataView.prototype.isPrototypeOf(P);
10508        }
10509        if (u.arrayBuffer)
10510          var l = [
10511            "[object Int8Array]",
10512            "[object Uint8Array]",
10513            "[object Uint8ClampedArray]",
10514            "[object Int16Array]",
10515            "[object Uint16Array]",
10516            "[object Int32Array]",
10517            "[object Uint32Array]",
10518            "[object Float32Array]",
10519            "[object Float64Array]"
10520          ], f = ArrayBuffer.isView || function(P) {
10521            return P && l.indexOf(Object.prototype.toString.call(P)) > -1;
10522          };
10523        function p(P) {
10524          if (typeof P != "string" && (P = String(P)), /[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(P) || P === "")
10525            throw new TypeError('Invalid character in header field name: "' + P + '"');
10526          return P.toLowerCase();
10527        }
10528        function m(P) {
10529          return typeof P != "string" && (P = String(P)), P;
10530        }
10531        function y(P) {
10532          var D = {
10533            next: function() {
10534              var de = P.shift();
10535              return { done: de === void 0, value: de };
10536            }
10537          };
10538          return u.iterable && (D[Symbol.iterator] = function() {
10539            return D;
10540          }), D;
10541        }
10542        function b(P) {
10543          this.map = {}, P instanceof b ? P.forEach(function(D, de) {
10544            this.append(de, D);
10545          }, this) : Array.isArray(P) ? P.forEach(function(D) {
10546            if (D.length != 2)
10547              throw new TypeError("Headers constructor: expected name/value pair to be length 2, found" + D.length);
10548            this.append(D[0], D[1]);
10549          }, this) : P && Object.getOwnPropertyNames(P).forEach(function(D) {
10550            this.append(D, P[D]);
10551          }, this);
10552        }
10553        b.prototype.append = function(P, D) {
10554          P = p(P), D = m(D);
10555          var de = this.map[P];
10556          this.map[P] = de ? de + ", " + D : D;
10557        }, b.prototype.delete = function(P) {
10558          delete this.map[p(P)];
10559        }, b.prototype.get = function(P) {
10560          return P = p(P), this.has(P) ? this.map[P] : null;
10561        }, b.prototype.has = function(P) {
10562          return this.map.hasOwnProperty(p(P));
10563        }, b.prototype.set = function(P, D) {
10564          this.map[p(P)] = m(D);
10565        }, b.prototype.forEach = function(P, D) {
10566          for (var de in this.map)
10567            this.map.hasOwnProperty(de) && P.call(D, this.map[de], de, this);
10568        }, b.prototype.keys = function() {
10569          var P = [];
10570          return this.forEach(function(D, de) {
10571            P.push(de);
10572          }), y(P);
10573        }, b.prototype.values = function() {
10574          var P = [];
10575          return this.forEach(function(D) {
10576            P.push(D);
10577          }), y(P);
10578        }, b.prototype.entries = function() {
10579          var P = [];
10580          return this.forEach(function(D, de) {
10581            P.push([de, D]);
10582          }), y(P);
10583        }, u.iterable && (b.prototype[Symbol.iterator] = b.prototype.entries);
10584        function C(P) {
10585          if (!P._noBody) {
10586            if (P.bodyUsed)
10587              return Promise.reject(new TypeError("Already read"));
10588            P.bodyUsed = !0;
10589          }
10590        }
10591        function _(P) {
10592          return new Promise(function(D, de) {
10593            P.onload = function() {
10594              D(P.result);
10595            }, P.onerror = function() {
10596              de(P.error);
10597            };
10598          });
10599        }
10600        function R(P) {
10601          var D = new FileReader(), de = _(D);
10602          return D.readAsArrayBuffer(P), de;
10603        }
10604        function N(P) {
10605          var D = new FileReader(), de = _(D), Ie = /charset=([A-Za-z0-9_-]+)/.exec(P.type), Re = Ie ? Ie[1] : "utf-8";
10606          return D.readAsText(P, Re), de;
10607        }
10608        function I(P) {
10609          for (var D = new Uint8Array(P), de = new Array(D.length), Ie = 0; Ie < D.length; Ie++)
10610            de[Ie] = String.fromCharCode(D[Ie]);
10611          return de.join("");
10612        }
10613        function E(P) {
10614          if (P.slice)
10615            return P.slice(0);
10616          var D = new Uint8Array(P.byteLength);
10617          return D.set(new Uint8Array(P)), D.buffer;
10618        }
10619        function T() {
10620          return this.bodyUsed = !1, this._initBody = function(P) {
10621            this.bodyUsed = this.bodyUsed, this._bodyInit = P, P ? typeof P == "string" ? this._bodyText = P : u.blob && Blob.prototype.isPrototypeOf(P) ? this._bodyBlob = P : u.formData && FormData.prototype.isPrototypeOf(P) ? this._bodyFormData = P : u.searchParams && URLSearchParams.prototype.isPrototypeOf(P) ? this._bodyText = P.toString() : u.arrayBuffer && u.blob && c(P) ? (this._bodyArrayBuffer = E(P.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : u.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(P) || f(P)) ? this._bodyArrayBuffer = E(P) : this._bodyText = P = Object.prototype.toString.call(P) : (this._noBody = !0, this._bodyText = ""), this.headers.get("content-type") || (typeof P == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : u.searchParams && URLSearchParams.prototype.isPrototypeOf(P) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
10622          }, u.blob && (this.blob = function() {
10623            var P = C(this);
10624            if (P)
10625              return P;
10626            if (this._bodyBlob)
10627              return Promise.resolve(this._bodyBlob);
10628            if (this._bodyArrayBuffer)
10629              return Promise.resolve(new Blob([this._bodyArrayBuffer]));
10630            if (this._bodyFormData)
10631              throw new Error("could not read FormData body as blob");
10632            return Promise.resolve(new Blob([this._bodyText]));
10633          }), this.arrayBuffer = function() {
10634            if (this._bodyArrayBuffer) {
10635              var P = C(this);
10636              return P || (ArrayBuffer.isView(this._bodyArrayBuffer) ? Promise.resolve(
10637                this._bodyArrayBuffer.buffer.slice(
10638                  this._bodyArrayBuffer.byteOffset,
10639                  this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
10640                )
10641              ) : Promise.resolve(this._bodyArrayBuffer));
10642            } else {
10643              if (u.blob)
10644                return this.blob().then(R);
10645              throw new Error("could not read as ArrayBuffer");
10646            }
10647          }, this.text = function() {
10648            var P = C(this);
10649            if (P)
10650              return P;
10651            if (this._bodyBlob)
10652              return N(this._bodyBlob);
10653            if (this._bodyArrayBuffer)
10654              return Promise.resolve(I(this._bodyArrayBuffer));
10655            if (this._bodyFormData)
10656              throw new Error("could not read FormData body as text");
10657            return Promise.resolve(this._bodyText);
10658          }, u.formData && (this.formData = function() {
10659            return this.text().then(L);
10660          }), this.json = function() {
10661            return this.text().then(JSON.parse);
10662          }, this;
10663        }
10664        var O = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
10665        function U(P) {
10666          var D = P.toUpperCase();
10667          return O.indexOf(D) > -1 ? D : P;
10668        }
10669        function M(P, D) {
10670          if (!(this instanceof M))
10671            throw new TypeError('Please use the "new" operator, this DOM object c
10671onstructor cannot be called as a function.');
10672          D = D || {};
10673          var de = D.body;
10674          if (P instanceof M) {
10675            if (P.bodyUsed)
10676              throw new TypeError("Already read");
10677            this.url = P.url, this.credentials = P.credentials, D.headers || (this.headers = new b(P.headers)), this.method = P.method, this.mode = P.mode, this.signal = P.signal, !de && P._bodyInit != null && (de = P._bodyInit, P.bodyUsed = !0);
10678          } else
10679            this.url = String(P);
10680          if (this.credentials = D.credentials || this.credentials || "same-origin", (D.headers || !this.headers) && (this.headers = new b(D.headers)), this.method = U(D.method || this.method || "GET"), this.mode = D.mode || this.mode || null, this.signal = D.signal || this.signal || (function() {
10681            if ("AbortController" in a) {
10682              var ge = new AbortController();
10683              return ge.signal;
10684            }
10685          })(), this.referrer = null, (this.method === "GET" || this.method === "HEAD") && de)
10686            throw new TypeError("Body not allowed for GET or HEAD requests");
10687          if (this._initBody(de), (this.method === "GET" || this.method === "HEAD") && (D.cache === "no-store" || D.cache === "no-cache")) {
10688            var Ie = /([?&])_=[^&]*/;
10689            if (Ie.test(this.url))
10690              this.url = this.url.replace(Ie, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
10691            else {
10692              var Re = /\?/;
10693              this.url += (Re.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
10694            }
10695          }
10696        }
10697        M.prototype.clone = function() {
10698          return new M(this, { body: this._bodyInit });
10699        };
10700        function L(P) {
10701          var D = new FormData();
10702          return P.trim().split("&").forEach(function(de) {
10703            if (de) {
10704              var Ie = de.split("="), Re = Ie.shift().replace(/\+/g, " "), ge = Ie.join("=").replace(/\+/g, " ");
10705              D.append(decodeURIComponent(Re), decodeURIComponent(ge));
10706            }
10707          }), D;
10708        }
10709        function re(P) {
10710          var D = new b(), de = P.replace(/\r?\n[\t ]+/g, " ");
10711          return de.split("\r").map(function(Ie) {
10712            return Ie.indexOf(`
10713`) === 0 ? Ie.substr(1, Ie.length) : Ie;
10714          }
10714).forEach(function(Ie) {
10715            var Re = Ie.split(":"), ge = Re.shift().trim();
10716            if (ge) {
10717              var Ue = Re.join(":").trim();
10718              try {
10719                D.append(ge, Ue);
10720              } catch (Oe) {
10721                console.warn("Response " + Oe.message);
10722              }
10723            }
10724          }), D;
10725        }
10726        T.call(M.prototype);
10727        function ne(P, D) {
10728          if (!(this instanceof ne))
10729            throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
10730          if (D || (D = {}), this.type = "default", this.status = D.status === void 0 ? 200 : D.status, this.status < 200 || this.status > 599)
10731            throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");
10732          this.ok = this.status >= 200 && this.status < 300, this.statusText = D.statusText === void 0 ? "" : "" + D.statusText, this.headers = new b(D.headers), this.url = D.url || "", this._initBody(P);
10733        }
10734        T.call(ne.prototype), ne.prototype.clone = function() {
10735          return new ne(this._bodyInit, {
10736            status: this.status,
10737            statusText: this.statusText,
10738            headers: new b(this.headers),
10739            url: this.url
10740          });
10741        }, ne.error = function() {
10742          var P = new ne(null, { status: 200, statusText: "" });
10743          return P.ok = !1, P.status = 0, P.type = "error", P;
10744        };
10745        var fe = [301, 302, 303, 307, 308];
10746        ne.redirect = function(P, D) {
10747          if (fe.indexOf(D) === -1)
10748            throw new RangeError("Invalid status code");
10749          return new ne(null, { status: D, headers: { location: P } });
10750        }, o.DOMException = a.DOMException;
10751        try {
10752          new o.DOMException();
10753        } catch {
10754          o.DOMException = function(D, de) {
10755            this.message = D, this.name = de;
10756            var Ie = Error(D);
10757            this.stack = Ie.stack;
10758          }, o.DOMException.prototype = Object.create(Error.prototype), o.DOMException.prototype.constructor = o.DOMException;
10759        }
10760        function ae(P, D) {
10761          return new Promise(function(de, Ie) {
10762            var Re = new M(P, D);
10763            if (Re.signal && Re.signal.aborted)
10764              return Ie(new o.DOMException("Aborted", "AbortError"));
10765            var ge = new XMLHttpRequest();
10766            function Ue() {
10767              ge.abort();
10768            }
10769            ge.onload = function() {
10770              var qe = {
10771                statusText: ge.statusText,
10772                headers: re(ge.getAllResponseHeaders() || "")
10773              };
10774              Re.url.indexOf("file://") === 0 && (ge.status < 200 || ge.status > 599) ? qe.status = 200 : qe.status = ge.status, qe.url = "responseURL" in ge ? ge.responseURL : qe.headers.get("X-Request-URL");
10775              var Lt = "response" in ge ? ge.response : ge.responseText;
10776              setTimeout(function() {
10777                de(new ne(Lt, qe));
10778              }, 0);
10779            }, ge.onerror = function() {
10780              setTimeout(function() {
10781                Ie(new TypeError("Network request failed"));
10782              }, 0);
10783            }, ge.ontimeout = function() {
10784              setTimeout(function() {
10785                Ie(new TypeError("Network request timed out"));
10786              }, 0);
10787            }, ge.onabort = function() {
10788              setTimeout(function() {
10789                Ie(new o.DOMException("Aborted", "AbortError"));
10790              }, 0);
10791            };
10792            function Oe(qe) {
10793              try {
10794                return qe === "" && a.location.href ? a.location.href : qe;
10795              } catch {
10796                return qe;
10797              }
10798            }
10799            if (ge.open(Re.method, Oe(Re.url), !0), Re.credentials === "include" ? ge.withCredentials = !0 : Re.credentials === "omit" && (ge.withCredentials = !1), "responseType" in ge && (u.blob ? ge.responseType = "blob" : u.arrayBuffer && (ge.responseType = "arraybuffer")), D && typeof D.headers == "object" && !(D.headers instanceof b || a.Headers && D.headers instanceof a.Headers)) {
10800              var qr = [];
10801              Object.getOwnPropertyNames(D.headers).forEach(function(qe) {
10802                qr.push(p(qe)), ge.setRequestHeader(qe, m(D.headers[qe]));
10803              }), Re.headers.forEach(function(qe, Lt) {
10804                qr.indexOf(Lt) === -1 && ge.setRequestHeader(Lt, qe);
10805              });
10806            } else
10807              Re.headers.forEach(function(qe, Lt) {
10808                ge.setRequestHeader(Lt, qe);
10809              });
10810            Re.signal && (Re.signal.addEventListener("abort", Ue), ge.onreadystatechange = function() {
10811              ge.readyState === 4 && Re.signal.removeEventListener("abort", Ue);
10812            }), ge.send(typeof Re._bodyInit > "u" ? null : Re._bodyInit);
10813          });
10814        }
10815        return ae.polyfill = !0, a.fetch || (a.fetch = ae, a.Headers = b, a.Request = M, a.Response = ne), o.Headers = b, o.Request = M, o.Response = ne, o.fetch = ae, Object.defineProperty(o, "__esModule", { value: !0 }), o;
10816      })({});
10817    })(r), r.fetch.ponyfill = !0, delete r.fetch.polyfill;
10818    var s = n.fetch ? n : r;
10819    t = s.fetch, t.default = s.fetch, t.fetch = s.fetch, t.Headers = s.Headers, t.Request = s.Request, t.Response = s.Response, e.exports = t;
10820  })(mi, mi.exports)), mi.exports;
10821}
10822var qb = Hb();
10823const z_ = /* @__PURE__ */ oo(qb), Gb = /* @__PURE__ */ Symbol(), Mu = Object.getPrototypeOf, xa = /* @__PURE__ */ new WeakMap(), zb = (e) => e && (xa.has(e) ? xa.get(e) : Mu(e) === Object.prototype || Mu(e) === Array.prototype), Vb = (e) => zb(e) && e[Gb] || null, Lu = (e, t = !0) => {
10824  xa.set(e, t);
10825}, Vi = {}, xc = (e) => typeof e == "object" && e !== null, Kb = (e) => xc(e) && !Qs.has(e) && (Array.isArray(e) || !(Symbol.iterator in e)) && !(e instanceof WeakMap) && !(e instanceof WeakSet) && !(e instanceof Error) && !(e instanceof Number) && !(e instanceof Date) && !(e instanceof String) && !(e instanceof RegExp) && !(e instanceof ArrayBuffer) && !(e instanceof Promise), yf = (e, t) => {
10826  const n = Oa.get(e);
10827  if (n?.[0] === t)
10828    return n[1];
10829  const r = Array.isArray(e) ? [] : Object.create(Object.getPrototypeOf(e));
10830  return Lu(r, !0), Oa.set(e, [t, r]), Reflect.ownKeys(e).forEach((s) => {
10831    if (Object.getOwnPropertyDescriptor(r, s))
10832      return;
10833    const i = Reflect.get(e, s), { enumerable: o } = Reflect.getOwnPropertyDescriptor(
10834      e,
10835      s
10836    ), a = {
10837      value: i,
10838      enumerable: o,
10839      // This is intentional to avoid copying with proxy-compare.
10840      // It's still non-writable, so it avoids assigning a value.
10841      configurable: !0
10842    };
10843    if (Qs.has(i))
10844      Lu(i, !1);
10845    else if (Fn.has(i)) {
10846      const [u, c] = Fn.get(
10847        i
10848      );
10849      a.value = yf(u, c());
10850    }
10851    Object.defineProperty(r, s, a);
10852  }), Object.preventExtensions(r);
10853}, Yb = (e, t, n, r) => ({
10854  deleteProperty(s, i) {
10855    const o = Reflect.get(s, i);
10856    n(i);
10857    const a = Reflect.deleteProperty(s, i);
10858    return a && r(["delete", [i], o]), a;
10859  },
10860  set(s, i, o, a) {
10861    const u = !e() && Reflect.has(s, i), c = Reflect.get(s, i, a);
10862    if (u && (Bu(c, o) || vs.has(o) && Bu(c, vs.get(o))))
10863      return !0;
10864    n(i), xc(o) && (o = Vb(o) || o);
10865    const l = !Fn.has(o) && Qb(o) ? Me(o) : o;
10866    return t(i, l), Reflect.set(s, i, l, a), r(["set", [i], o, c]), !0;
10867  }
10868}), Fn = /* @__PURE__ */ new WeakMap(), Qs = /* @__PURE__ */ new WeakSet(), Oa = /* @__PURE__ */ new WeakMap(), Ii = [1], vs = /* @__PURE__ */ new WeakMap();
10869let Bu = Object.is, Zb = (e, t) => new Proxy(e, t), Qb = Kb, Jb = yf, Xb = Yb;
10870function Me(e = {}) {
10871  if (!xc(e))
10872    throw new Error("object required");
10873  const t = vs.get(e);
10874  if (t)
10875    return t;
10876  let n = Ii[0];
10877  const r = /* @__PURE__ */ new Set(), s = (C, _ = ++Ii[0]) => {
10878    n !== _ && (i = n = _, r.forEach((R) => R(C, _)));
10879  };
10880  let i = n;
10881  const o = (C = Ii[0]) => (i !== C && (i = C, u.forEach(([_]) => {
10882    const R = _[1](C);
10883    R > n && (n = R);
10884  })), n), a = (C) => (_, R) => {
10885    const N = [..._];
10886    N[1] = [C, ...N[1]], s(N, R);
10887  }, u = /* @__PURE__ */ new Map(), c = (C, _) => {
10888    const R = !Qs.has(_) && Fn.get(_);
10889    if (R) {
10890      if ((Vi ? "production.universal" : void 0) !== "production" && u.has(C))
10891        throw new Error("prop listener already exists");
10892      if (r.size) {
10893        const N = R[2](a(C));
10894        u.set(C, [R, N]);
10895      } else
10896        u.set(C, [R]);
10897    }
10898  }, l = (C) => {
10899    var _;
10900    const R = u.get(C);
10901    R && (u.delete(C), (_ = R[1]) == null || _.call(R));
10902  }, f = (C) => (r.add(C), r.size === 1 && u.forEach(([R, N], I) => {
10903    if ((Vi ? "production.universal" : void 0) !== "production" && N)
10904      throw new Error("remove already exists");
10905    const E = R[2](a(I));
10906    u.set(I, [R, E]);
10907  }), () => {
10908    r.delete(C), r.size === 0 && u.forEach(([R, N], I) => {
10909      N && (N(), u.set(I, [R]));
10910    });
10911  });
10912  let p = !0;
10913  const m = Xb(
10914    () => p,
10915    c,
10916    l,
10917    s
10918  ), y = Zb(e, m);
10919  vs.set(e, y);
10920  const b = [e, o, f];
10921  return Fn.set(y, b), Reflect.ownKeys(e).forEach((C) => {
10922    const _ = Object.getOwnPropertyDescriptor(
10923      e,
10924      C
10925    );
10926    "value" in _ && _.writable && (y[C] = e[C]);
10927  }), p = !1, y;
10928}
10929function tt(e, t, n) {
10930  const r = Fn.get(e);
10931  (Vi ? "production.universal" : void 0) !== "production" && !r && console.warn("Please use proxy object");
10932  let s;
10933  const i = [], o = r[2];
10934  let a = !1;
10935  const c = o((l) => {
10936    i.push(l), s || (s = Promise.resolve().then(() => {
10937      s = void 0, a && t(i.splice(0));
10938    }));
10939  });
10940  return a = !0, () => {
10941    a = !1, c();
10942  };
10943}
10944function _s(e) {
10945  const t = Fn.get(e);
10946  (Vi ? "production.universal" : void 0) !== "production" && !t && console.warn("Please use proxy object");
10947  const [n, r] = t;
10948  return Jb(n, r());
10949}
10950function Ns(e) {
10951  return Qs.add(e), e;
10952}
10953function ew() {
10954  return {
10955    proxyStateMap: Fn,
10956    refSet: Qs,
10957    snapCache: Oa,
10958    versionHolder: Ii,
10959    proxyCache: vs
10960  };
10961}
10962function Je(e, t, n, r) {
10963  let s = e[t];
10964  return tt(
10965    e,
10966    () => {
10967      const i = e[t];
10968      Object.is(s, i) || n(s = i);
10969    }
10970  );
10971}
10972const { proxyStateMap: tw, snapCache: nw } = ew(), gi = (e) => tw.has(e);
10973function rw(e) {
10974  const t = [];
10975  let n = 0;
10976  const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new WeakMap(), i = () => {
10977    const c = nw.get(a), l = c?.[1];
10978    if (l && !s.has(l)) {
10979      const f = new Map(r);
10980      s.set(l, f);
10981    }
10982  }, o = (c) => s.get(c) || r, a = {
10983    data: t,
10984    index: n,
10985    epoch: 0,
10986    get size() {
10987      return gi(this) || i(), o(this).size;
10988    },
10989    get(c) {
10990      const f = o(this).get(c);
10991      if (f === void 0) {
10992        this.epoch;
10993        return;
10994      }
10995      return this.data[f];
10996    },
10997    has(c) {
10998      const l = o(this);
10999      return this.epoch, l.has(c);
11000    },
11001    set(c, l) {
11002      if (!gi(this))
11003        throw new Error("Cannot perform mutations on a snapshot");
11004      const f = r.get(c);
11005      return f === void 0 ? (r.set(c, this.index), this.data[this.index++] = l) : this.data[f] = l, this.epoch++, this;
11006    },
11007    delete(c) {
11008      if (!gi(this))
11009        throw new Error("Cannot perform mutations on a snapshot");
11010      const l = r.get(c);
11011      return l === void 0 ? !1 : (delete this.data[l], r.delete(c), this.epoch++, !0);
11012    },
11013    clear() {
11014      if (!gi(this))
11015        throw new Error("Cannot perform mutations on a snapshot");
11016      this.data.length = 0, this.index = 0, this.epoch++, r.clear();
11017    },
11018    forEach(c) {
11019      this.epoch, o(this).forEach((f, p) => {
11020        c(this.data[f], p, this);
11021      });
11022    },
11023    *entries() {
11024      this.epoch;
11025      const c = o(this);
11026      for (const [l, f] of c)
11027        yield [l, this.data[f]];
11028    },
11029    *keys() {
11030      this.epoch;
11031      const c = o(this);
11032      for (const l of c.keys())
11033        yield l;
11034    },
11035    *values() {
11036      this.epoch;
11037      const c = o(this);
11038      for (const l of c.values())
11039        yield this.data[l];
11040    },
11041    [Symbol.iterator]() {
11042      return this.entries();
11043    },
11044    get [Symbol.toStringTag]() {
11045      return "Map";
11046    },
11047    toJSON() {
11048      return new Map(this.entries());
11049    }
11050  }, u = Me(a);
11051  return Object.defineProperties(u, {
11052    size: { enumerable: !1 },
11053    index: { enumerable: !1 },
11054    epoch: { enumerable: !1 },
11055    data: { enumerable: !1 },
11056    toJSON: { enumerable: !1 }
11057  }), Object.seal(u), u;
11058}
11059const Vo = (
11060  // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
11061  (typeof process < "u" && typeof process.env < "u" ? process.env.NEXT_PUBLIC_SECURE_SITE_ORIGIN : void 0) || "https://secure.walletconnect.org"
11062), V_ = [
11063  {
11064    label: "Meld.io",
11065    name: "meld",
11066    feeRange: "1-2%",
11067    url: "https://meldcrypto.com",
11068    supportedChains: ["eip155", "solana"]
11069  }
11070], K_ = "WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU", Qe = {
11071  FOUR_MINUTES_MS: 24e4,
11072  TEN_SEC_MS: 1e4,
11073  FIVE_SEC_MS: 5e3,
11074  THREE_SEC_MS: 3e3,
11075  ONE_SEC_MS: 1e3,
11076  SECURE_SITE: Vo,
11077  SECURE_SITE_DASHBOARD: `${Vo}/dashboard`,
11078  SECURE_SITE_FAVICON: `${Vo}/images/favicon.png`,
11079  SOLANA_NATIVE_TOKEN_ADDRESS: "So11111111111111111111111111111111111111111",
11080  RESTRICTED_TIMEZONES: [
11081    "ASIA/SHANGHAI",
11082    "ASIA/URUMQI",
11083    "ASIA/CHONGQING",
11084    "ASIA/HARBIN",
11085    "ASIA/KASHGAR",
11086    "ASIA/MACAU",
11087    "ASIA/HONG_KONG",
11088    "ASIA/MACAO",
11089    "ASIA/BEIJING",
11090    "ASIA/HARBIN"
11091  ],
11092  SWAP_SUGGESTED_TOKENS: [
11093    "ETH",
11094    "UNI",
11095    "1INCH",
11096    "AAVE",
11097    "SOL",
11098    "ADA",
11099    "AVAX",
11100    "DOT",
11101    "LINK",
11102    "NITRO",
11103    "GAIA",
11104    "MILK",
11105    "TRX",
11106    "NEAR",
11107    "GNO",
11108    "WBTC",
11109    "DAI",
11110    "WETH",
11111    "USDC",
11112    "USDT",
11113    "ARB",
11114    "BAL",
11115    "BICO",
11116    "CRV",
11117    "ENS",
11118    "MATIC",
11119    "OP"
11120  ],
11121  SWAP_POPULAR_TOKENS: [
11122    "ETH",
11123    "UNI",
11124    "1INCH",
11125    "AAVE",
11126    "SOL",
11127    "ADA",
11128    "AVAX",
11129    "DOT",
11130    "LINK",
11131    "NITRO",
11132    "GAIA",
11133    "MILK",
11134    "TRX",
11135    "NEAR",
11136    "GNO",
11137    "WBTC",
11138    "DAI",
11139    "WETH",
11140    "USDC",
11141    "USDT",
11142    "ARB",
11143    "BAL",
11144    "BICO",
11145    "CRV",
11146    "ENS",
11147    "MATIC",
11148    "OP",
11149    "METAL",
11150    "DAI",
11151    "CHAMP",
11152    "WOLF",
11153    "SALE",
11154    "BAL",
11155    "BUSD",
11156    "MUST",
11157    "BTCpx",
11158    "ROUTE",
11159    "HEX",
11160    "WELT",
11161    "amDAI",
11162    "VSQ",
11163    "VISION",
11164    "AURUM",
11165    "pSP",
11166    "SNX",
11167    "VC",
11168    "LINK",
11169    "CHP",
11170    "amUSDT",
11171    "SPHERE",
11172    "FOX",
11173    "GIDDY",
11174    "GFC",
11175    "OMEN",
11176    "OX_OLD",
11177    "DE",
11178    "WNT"
11179  ],
11180  SUGGESTED_TOKENS_BY_CHAIN: {
11181    // Arbitrum One
11182    "eip155:42161": ["USD₮0"]
11183  },
11184  BALANCE_SUPPORTED_CHAINS: [
11185    x.CHAIN.EVM,
11186    x.CHAIN.SOLANA
11187  ],
11188  SEND_PARAMS_SUPPORTED_CHAINS: [x.CHAIN.EVM],
11189  SWAP_SUPPORTED_NETWORKS: [
11190    // Ethereum'
11191    "eip155:1",
11192    // Arbitrum One'
11193    "eip155:42161",
11194    // Optimism'
11195    "eip155:10",
11196    // ZKSync Era'
11197    "eip155:324",
11198    // Base'
11199    "eip155:8453",
11200    // BNB Smart Chain'
11201    "eip155:56",
11202    // Polygon'
11203    "eip155:137",
11204    // Gnosis'
11205    "eip155:100",
11206    // Avalanche'
11207    "eip155:43114",
11208    // Fantom'
11209    "eip155:250",
11210    // Klaytn'
11211    "eip155:8217",
11212    // Aurora
11213    "eip155:1313161554"
11214  ],
11215  NAMES_SUPPORTED_CHAIN_NAMESPACES: [x.CHAIN.EVM],
11216  ONRAMP_SUPPORTED_CHAIN_NAMESPACES: [
11217    x.CHAIN.EVM,
11218    x.CHAIN.SOLANA
11219  ],
11220  PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES: [
11221    x.CHAIN.EVM,
11222    x.CHAIN.SOLANA
11223  ],
11224  ACTIVITY_ENABLED_CHAIN_NAMESPACES: [
11225    x.CHAIN.EVM,
11226    x.CHAIN.TON
11227  ],
11228  NATIVE_TOKEN_ADDRESS: {
11229    eip155: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
11230    solana: "So11111111111111111111111111111111111111111",
11231    polkadot: "0x",
11232    bip122: "0x",
11233    cosmos: "0x",
11234    sui: "0x",
11235    stacks: "0x",
11236    ton: "0x",
11237    tron: "0x"
11238  },
11239  CONVERT_SLIPPAGE_TOLERANCE: 1,
11240  CONNECT_LABELS: {
11241    MOBILE: "Open and continue in the wallet app",
11242    WEB: "Open and continue in the wallet app"
11243  },
11244  SEND_SUPPORTED_NAMESPACES: [
11245    x.CHAIN.EVM,
11246    x.CHAIN.SOLANA
11247  ],
11248  DEFAULT_REMOTE_FEATURES: {
11249    swaps: ["1inch"],
11250    onramp: ["meld"],
11251    email: !0,
11252    socials: [
11253      "google",
11254      "x",
11255      "discord",
11256      "farcaster",
11257      "github",
11258      "apple",
11259      "facebook"
11260    ],
11261    activity: !0,
11262    reownBranding: !0,
11263    multiWallet: !1,
11264    emailCapture: !1,
11265    payWithExchange: !1,
11266    payments: !1,
11267    reownAuthentication: !1,
11268    headless: !1
11269  },
11270  DEFAULT_REMOTE_FEATURES_DISABLED: {
11271    email: !1,
11272    socials: !1,
11273    swaps: !1,
11274    onramp: !1,
11275    activity: !1,
11276    reownBranding: !1,
11277    emailCapture: !1,
11278    reownAuthentication: !1,
11279    headless: !1
11280  },
11281  DEFAULT_FEATURES: {
11282    receive: !0,
11283    send: !0,
11284    emailShowWallets: !0,
11285    connectorTypeOrder: [
11286      "walletConnect",
11287      "recent",
11288      "injected",
11289      "featured",
11290      "custom",
11291      "external",
11292      "recommended"
11293    ],
11294    analytics: !0,
11295    allWallets: !0,
11296    legalCheckbox: !1,
11297    smartSessions: !1,
11298    collapseWallets: !1,
11299    walletFeaturesOrder: ["onramp", "swaps", "receive", "send"],
11300    connectMethodsOrder: void 0,
11301    pay: !1,
11302    reownAuthentication: !1,
11303    headless: !1
11304  },
11305  DEFAULT_SOCIALS: [
11306    "google",
11307    "x",
11308    "farcaster",
11309    "discord",
11310    "apple",
11311    "github",
11312    "facebook"
11313  ],
11314  DEFAULT_ACCOUNT_TYPES: {
11315    bip122: "payment",
11316    eip155: "smartAccount",
11317    polkadot: "eoa",
11318    solana: "eoa",
11319    ton: "eoa",
11320    tron: "eoa"
11321  },
11322  ADAPTER_TYPES: {
11323    UNIVERSAL: "universal",
11324    SOLANA: "solana",
11325    WAGMI: "wagmi",
11326    ETHERS: "ethers",
11327    ETHERS5: "ethers5",
11328    BITCOIN: "bitcoin"
11329  },
11330  SIWX_DEFAULTS: {
11331    signOutOnDisconnect: !0
11332  },
11333  MANDATORY_WALLET_IDS_ON_MOBILE: [
11334    it.ConnectorExplorerIds[x.CONNECTOR_ID.COINBASE],
11335    it.ConnectorExplorerIds[x.CONNECTOR_ID.COINBASE_SDK],
11336    it.ConnectorExplorerIds[x.CONNECTOR_ID.BASE_ACCOUNT],
11337    it.ConnectorExplorerIds[x.SOLFLARE_CONNECTOR_NAME],
11338    it.ConnectorExplorerIds[x.PHANTOM_CONNECTOR_NAME],
11339    it.ConnectorExplorerIds[x.BINANCE_CONNECTOR_NAME]
11340  ],
11341  DEFAULT_CONNECT_METHOD_ORDER: ["email", "social", "wallet"]
11342}, W = {
11343  // Cache expiry in milliseconds
11344  cacheExpiry: {
11345    portfolio: 3e4,
11346    nativeBalance: 3e4,
11347    ens: 3e5,
11348    identity: 3e5,
11349    transactionsHistory: 15e3,
11350    tokenPrice: 15e3,
11351    // 7 Days
11352    latestAppKitVersion: 6048e5,
11353    // 1 Day
11354    tonWallets: 864e5
11355  },
11356  isCacheExpired(e, t) {
11357    return Date.now() - e > t;
11358  },
11359  getActiveNetworkProps() {
11360    const e = W.getActiveNamespace(), t = W.getActiveCaipNetworkId(), n = t ? t.split(":")[1] : void 0, r = n ? isNaN(Number(n)) ? n : Number(n) : void 0;
11361    return {
11362      namespace: e,
11363      caipNetworkId: t,
11364      chainId: r
11365    };
11366  },
11367  setWalletConnectDeepLink({ name: e, href: t }) {
11368    try {
11369      Q.setItem(te.DEEPLINK_CHOICE, JSON.stringify({ href: t, name: e }));
11370    } catch {
11371      console.info("Unable to set WalletConnect deep link");
11372    }
11373  },
11374  getWalletConnectDeepLink() {
11375    try {
11376      const e = Q.getItem(te.DEEPLINK_CHOICE);
11377      if (e)
11378        return JSON.parse(e);
11379    } catch {
11380      console.info("Unable to get WalletConnect deep link");
11381    }
11382  },
11383  deleteWalletConnectDeepLink() {
11384    try {
11385      Q.removeItem(te.DEEPLINK_CHOICE);
11386    } catch {
11387      console.info("Unable to delete WalletConnect deep link");
11388    }
11389  },
11390  setActiveNamespace(e) {
11391    try {
11392      Q.setItem(te.ACTIVE_NAMESPACE, e);
11393    } catch {
11394      console.info("Unable to set active namespace");
11395    }
11396  },
11397  setActiveCaipNetworkId(e) {
11398    try {
11399      Q.setItem(te.ACTIVE_CAIP_NETWORK_ID, e), W.setActiveNamespace(e.split(":")[0]);
11400    } catch {
11401      console.info("Unable to set active caip network id");
11402    }
11403  },
11404  getActiveCaipNetworkId() {
11405    try {
11406      return Q.getItem(te.ACTIVE_CAIP_NETWORK_ID);
11407    } catch {
11408      console.info("Unable to get active caip network id");
11409      return;
11410    }
11411  },
11412  deleteActiveCaipNetworkId() {
11413    try {
11414      Q.removeItem(te.ACTIVE_CAIP_NETWORK_ID);
11415    } catch {
11416      console.info("Unable to delete active caip network id");
11417    }
11418  },
11419  deleteConnectedConnectorId(e) {
11420    try {
11421      const t = Ho(e);
11422      Q.removeItem(t);
11423    } catch {
11424      console.info("Unable to delete connected connector id");
11425    }
11426  },
11427  setAppKitRecent(e) {
11428    try {
11429      const t = W.getRecentWallets();
11430      t.find((r) => r.id === e.id) || (t.unshift(e), t.length > 2 && t.pop(), Q.setItem(te.RECENT_WALLETS, JSON.stringify(t)), Q.setItem(te.RECENT_WALLET, JSON.stringify(e)));
11431    } catch {
11432      console.info("Unable to set AppKit recent");
11433    }
11434  },
11435  getRecentWallets() {
11436    try {
11437      const e = Q.getItem(te.RECENT_WALLETS);
11438      return e ? JSON.parse(e) : [];
11439    } catch {
11440      console.info("Unable to get AppKit recent");
11441    }
11442    return [];
11443  },
11444  getRecentWallet() {
11445    try {
11446      const e = Q.getItem(te.RECENT_WALLET);
11447      return e ? JSON.parse(e) : null;
11448    } catch {
11449      console.info("Unable to get AppKit recent");
11450    }
11451    return null;
11452  },
11453  deleteRecentWallet() {
11454    try {
11455      Q.removeItem(te.RECENT_WALLET);
11456    } catch {
11457      console.info("Unable to delete AppKit recent");
11458    }
11459  },
11460  setConnectedConnectorId(e, t) {
11461    try {
11462      const n = Ho(e);
11463      Q.setItem(n, t);
11464    } catch {
11465      console.info("Unable to set Connected Connector Id");
11466    }
11467  },
11468  getActiveNamespace() {
11469    try {
11470      return Q.getItem(te.ACTIVE_NAMESPACE);
11471    } catch {
11472      console.info("Unable to get active namespace");
11473    }
11474  },
11475  getConnectedConnectorId(e) {
11476    if (e)
11477      try {
11478        const t = Ho(e);
11479        return Q.getItem(t);
11480      } catch {
11481        console.info("Unable to get connected connector id in namespace", e);
11482      }
11483  },
11484  setConnectedSocialProvider(e) {
11485    try {
11486      Q.setItem(te.CONNECTED_SOCIAL, e);
11487    } catch {
11488      console.info("Unable to set connected social provider");
11489    }
11490  },
11491  getConnectedSocialProvider() {
11492    try {
11493      return Q.getItem(te.CONNECTED_SOCIAL);
11494    } catch {
11495      console.info("Unable to get connected social provider");
11496    }
11497  },
11498  deleteConnectedSocialProvider() {
11499    try {
11500      Q.removeItem(te.CONNECTED_SOCIAL);
11501    } catch {
11502      console.info("Unable to delete connected social provider");
11503    }
11504  },
11505  getConnectedSocialUsername() {
11506    try {
11507      return Q.getItem(te.CONNECTED_SOCIAL_USERNAME);
11508    } catch {
11509      console.info("Unable to get connected social username");
11510    }
11511  },
11512  getStoredActiveCaipNetworkId() {
11513    return Q.getItem(te.ACTIVE_CAIP_NETWORK_ID)?.split(":")?.[1];
11514  },
11515  setConnectionStatus(e) {
11516    try {
11517      Q.setItem(te.CONNECTION_STATUS, e);
11518    } catch {
11519      console.info("Unable to set connection status");
11520    }
11521  },
11522  getConnectionStatus() {
11523    try {
11524      return Q.getItem(te.CONNECTION_STATUS);
11525    } catch {
11526      return;
11527    }
11528  },
11529  getConnectedNamespaces() {
11530    try {
11531      const e = Q.getItem(te.CONNECTED_NAMESPACES);
11532      return e?.length ? e.split(",") : [];
11533    } catch {
11534      return [];
11535    }
11536  },
11537  setConnectedNamespaces(e) {
11538    try {
11539      const t = Array.from(new Set(e));
11540      Q.setItem(te.CONNECTED_NAMESPACES, t.join(","));
11541    } catch {
11542      console.info("Unable to set namespaces in storage");
11543    }
11544  },
11545  addConnectedNamespace(e) {
11546    try {
11547      const t = W.getConnectedNamespaces();
11548      t.includes(e) || (t.push(e), W.setConnectedNamespaces(t));
11549    } catch {
11550      console.info("Unable to add connected namespace");
11551    }
11552  },
11553  removeConnectedNamespace(e) {
11554    try {
11555      const t = W.getConnectedNamespaces(), n = t.indexOf(e);
11556      n > -1 && (t.splice(n, 1), W.setConnectedNamespaces(t));
11557    } catch {
11558      console.info("Unable to remove connected namespace");
11559    }
11560  },
11561  getTelegramSocialProvider() {
11562    try {
11563      return Q.getItem(te.TELEGRAM_SOCIAL_PROVIDER);
11564    } catch {
11565      return console.info("Unable to get telegram social provider"), null;
11566    }
11567  },
11568  setTelegramSocialProvider(e) {
11569    try {
11570      Q.setItem(te.TELEGRAM_SOCIAL_PROVIDER, e);
11571    } catch {
11572      console.info("Unable to set telegram social provider");
11573    }
11574  },
11575  removeTelegramSocialProvider() {
11576    try {
11577      Q.removeItem(te.TELEGRAM_SOCIAL_PROVIDER);
11578    } catch {
11579      console.info("Unable to remove telegram social provider");
11580    }
11581  },
11582  getBalanceCache() {
11583    let e = {};
11584    try {
11585      const t = Q.getItem(te.PORTFOLIO_CACHE);
11586      e = t ? JSON.parse(t) : {};
11587    } catch {
11588      console.info("Unable to get balance cache");
11589    }
11590    return e;
11591  },
11592  removeAddressFromBalanceCache(e) {
11593    try {
11594      const t = W.getBalanceCache();
11595      Q.setItem(te.PORTFOLIO_CACHE, JSON.stringify({ ...t, [e]: void 0 }));
11596    } catch {
11597      console.info("Unable to remove address from balance cache", e);
11598    }
11599  },
11600  getBalanceCacheForCaipAddress(e) {
11601    try {
11602      const n = W.getBalanceCache()[e];
11603      if (n && !this.isCacheExpired(n.timestamp, this.cacheExpiry.portfolio))
11604        return n.balance;
11605      W.removeAddressFromBalanceCache(e);
11606    } catch {
11607      console.info("Unable to get balance cache for address", e);
11608    }
11609  },
11610  updateBalanceCache(e) {
11611    try {
11612      const t = W.getBalanceCache();
11613      t[e.caipAddress] = e, Q.setItem(te.PORTFOLIO_CACHE, JSON.stringify(t));
11614    } catch {
11615      console.info("Unable to update balance cache", e);
11616    }
11617  },
11618  getNativeBalanceCache() {
11619    let e = {};
11620    try {
11621      const t = Q.getItem(te.NATIVE_BALANCE_CACHE);
11622      e = t ? JSON.parse(t) : {};
11623    } catch {
11624      console.info("Unable to get balance cache");
11625    }
11626    return e;
11627  },
11628  removeAddressFromNativeBalanceCache(e) {
11629    try {
11630      const t = W.getBalanceCache();
11631      Q.setItem(te.NATIVE_BALANCE_CACHE, JSON.stringify({ ...t, [e]: void 0 }));
11632    } catch {
11633      console.info("Unable to remove address from balance cache", e);
11634    }
11635  },
11636  getNativeBalanceCacheForCaipAddress(e) {
11637    try {
11638      const n = W.getNativeBalanceCache()[e];
11639      if (n && !this.isCacheExpired(n.timestamp, this.cacheExpiry.nativeBalance))
11640        return n;
11641      console.info("Discarding cache for address", e), W.removeAddressFromBalanceCache(e);
11642    } catch {
11643      console.info("Unable to get balance cache for address", e);
11644    }
11645  },
11646  updateNativeBalanceCache(e) {
11647    try {
11648      const t = W.getNativeBalanceCache();
11649      t[e.caipAddress] = e, Q.setItem(te.NATIVE_BALANCE_CACHE, JSON.stringify(t));
11650    } catch {
11651      console.info("Unable to update balance cache", e);
11652    }
11653  },
11654  getEnsCache() {
11655    let e = {};
11656    try {
11657      const t = Q.getItem(te.ENS_CACHE);
11658      e = t ? JSON.parse(t) : {};
11659    } catch {
11660      console.info("Unable to get ens name cache");
11661    }
11662    return e;
11663  },
11664  getEnsFromCacheForAddress(e) {
11665    try {
11666      const n = W.getEnsCache()[e];
11667      if (n && !this.isCacheExpired(n.timestamp, this.cacheExpiry.ens))
11668        return n.ens;
11669      W.removeEnsFromCache(e);
11670    } catch {
11671      console.info("Unable to get ens name from cache", e);
11672    }
11673  },
11674  updateEnsCache(e) {
11675    try {
11676      const t = W.getEnsCache();
11677      t[e.address] = e, Q.setItem(te.ENS_CACHE, JSON.stringify(t));
11678    } catch {
11679      console.info("Unable to update ens name cache", e);
11680    }
11681  },
11682  removeEnsFromCache(e) {
11683    try {
11684      const t = W.getEnsCache();
11685      Q.setItem(te.ENS_CACHE, JSON.stringify({ ...t, [e]: void 0 }));
11686    } catch {
11687      console.info("Unable to remove ens name from cache", e);
11688    }
11689  },
11690  getIdentityCache() {
11691    let e = {};
11692    try {
11693      const t = Q.getItem(te.IDENTITY_CACHE);
11694      e = t ? JSON.parse(t) : {};
11695    } catch {
11696      console.info("Unable to get identity cache");
11697    }
11698    return e;
11699  },
11700  getIdentityFromCacheForAddress(e) {
11701    try {
11702      const n = W.getIdentityCache()[e];
11703      if (n && !this.isCacheExpired(n.timestamp, this.cacheExpiry.identity))
11704        return n.identity;
11705      W.removeIdentityFromCache(e);
11706    } catch {
11707      console.info("Unable to get identity from cache", e);
11708    }
11709  },
11710  updateIdentityCache(e) {
11711    try {
11712      const t = W.getIdentityCache();
11713      t[e.address] = {
11714        identity: e.identity,
11715        timestamp: e.timestamp
11716      }, Q.setItem(te.IDENTITY_CACHE, JSON.stringify(t));
11717    } catch {
11718      console.info("Unable to update identity cache", e);
11719    }
11720  },
11721  removeIdentityFromCache(e) {
11722    try {
11723      const t = W.getIdentityCache();
11724      Q.setItem(te.IDENTITY_CACHE, JSON.stringify({ ...t, [e]: void 0 }));
11725    } catch {
11726      console.info("Unable to remove identity from cache", e);
11727    }
11728  },
11729  getTonWalletsCache() {
11730    try {
11731      const e = Q.getItem(te.TON_WALLETS_CACHE), t = e ? JSON.parse(e) : void 0;
11732      if (t && !this.isCacheExpired(t.timestamp, this.cacheExpiry.tonWallets))
11733        return t;
11734      W.removeTonWalletsCache();
11735    } catch {
11736      console.info("Unable to get ton wallets cache");
11737    }
11738  },
11739  updateTonWalletsCache(e) {
11740    try {
11741      const t = W.getTonWalletsCache() || { timestamp: 0, wallets: [] };
11742      t.timestamp = (/* @__PURE__ */ new Date()).getTime(), t.wallets = e, Q.setItem(te.TON_WALLETS_CACHE, JSON.stringify(t));
11743    } catch {
11744      console.info("Unable to update ton wallets cache", e);
11745    }
11746  },
11747  removeTonWalletsCache() {
11748    try {
11749      Q.removeItem(te.TON_WALLETS_CACHE);
11750    } catch {
11751      console.info("Unable to remove ton wallets cache");
11752    }
11753  },
11754  clearAddressCache() {
11755    try {
11756      Q.removeItem(te.PORTFOLIO_CACHE), Q.removeItem(te.NATIVE_BALANCE_CACHE), Q.removeItem(te.ENS_CACHE), Q.removeItem(te.IDENTITY_CACHE), Q.removeItem(te.HISTORY_TRANSACTIONS_CACHE);
11757    } catch {
11758      console.info("Unable to clear address cache");
11759    }
11760  },
11761  setPreferredAccountTypes(e) {
11762    try {
11763      Q.setItem(te.PREFERRED_ACCOUNT_TYPES, JSON.stringify(e));
11764    } catch {
11765      console.info("Unable to set preferred account types", e);
11766    }
11767  },
11768  getPreferredAccountTypes() {
11769    try {
11770      const e = Q.getItem(te.PREFERRED_ACCOUNT_TYPES);
11771      return e ? JSON.parse(e) : {};
11772    } catch {
11773      console.info("Unable to get preferred account types");
11774    }
11775    return {};
11776  },
11777  setConnections(e, t) {
11778    try {
11779      const n = W.getConnections(), r = n[t] ?? [], s = /* @__PURE__ */ new Map();
11780      for (const o of r)
11781        s.set(o.connectorId, { ...o });
11782      for (const o of e) {
11783        const a = s.get(o.connectorId), u = o.connectorId === x.CONNECTOR_ID.AUTH;
11784        if (a && !u) {
11785          const c = new Set(a.accounts.map((f) => f.address.toLowerCase())), l = o.accounts.filter((f) => !c.has(f.address.toLowerCase()));
11786          a.accounts.push(...l);
11787        } else
11788          s.set(o.connectorId, { ...o });
11789      }
11790      const i = {
11791        ...n,
11792        [t]: Array.from(s.values())
11793      };
11794      Q.setItem(te.CONNECTIONS, JSON.stringify(i));
11795    } catch (n) {
11796      console.error("Unable to sync connections to storage", n);
11797    }
11798  },
11799  getConnections() {
11800    try {
11801      const e = Q.getItem(te.CONNECTIONS);
11802      return e ? JSON.parse(e) : {};
11803    } catch (e) {
11804      return console.error("Unable to get connections from storage", e), {};
11805    }
11806  },
11807  deleteAddressFromConnection({ connectorId: e, address: t, namespace: n }) {
11808    try {
11809      const r = W.getConnections(), s = r[n] ?? [], i = new Map(s.map((a) => [a.connectorId, a])), o = i.get(e);
11810      o && (o.accounts.filter((u) => u.address.toLowerCase() !== t.toLowerCase()).length === 0 ? i.delete(e) : i.set(e, {
11811        ...o,
11812        accounts: o.accounts.filter((u) => u.address.toLowerCase() !== t.toLowerCase())
11813      })), Q.setItem(te.CONNECTIONS, JSON.stringify({
11814        ...r,
11815        [n]: Array.from(i.values())
11816      }));
11817    } catch {
11818      console.error(`Unable to remove address "${t}" from connector "${e}" in namespace "${n}"`);
11819    }
11820  },
11821  getDisconnectedConnectorIds() {
11822    try {
11823      const e = Q.getItem(te.DISCONNECTED_CONNECTOR_IDS);
11824      return e ? JSON.parse(e) : {};
11825    } catch {
11826      console.info("Unable to get disconnected connector ids");
11827    }
11828    return {};
11829  },
11830  addDisconnectedConnectorId(e, t) {
11831    try {
11832      const n = W.getDisconnectedConnectorIds(), r = n[t] ?? [];
11833      r.push(e), Q.setItem(te.DISCONNECTED_CONNECTOR_IDS, JSON.stringify({
11834        ...n,
11835        [t]: Array.from(new Set(r))
11836      }));
11837    } catch {
11838      console.error(`Unable to set disconnected connector id "${e}" for namespace "${t}"`);
11839    }
11840  },
11841  removeDisconnectedConnectorId(e, t) {
11842    try {
11843      const n = W.getDisconnectedConnectorIds();
11844      let r = n[t] ?? [];
11845      r = r.filter((s) => s.toLowerCase() !== e.toLowerCase()), Q.setItem(te.DISCONNECTED_CONNECTOR_IDS, JSON.stringify({
11846        ...n,
11847        [t]: Array.from(new Set(r))
11848      }));
11849    } catch {
11850      console.error(`Unable to remove disconnected connector id "${e}" for namespace "${t}"`);
11851    }
11852  },
11853  isConnectorDisconnected(e, t) {
11854    try {
11855      return (W.getDisconnectedConnectorIds()[t] ?? []).some((s) => s.toLowerCase() === e.toLowerCase());
11856    } catch {
11857      console.info(`Unable to get disconnected connector id "${e}" for namespace "${t}"`);
11858    }
11859    return !1;
11860  },
11861  getTransactionsCache() {
11862    try {
11863      const e = Q.getItem(te.HISTORY_TRANSACTIONS_CACHE);
11864      return e ? JSON.parse(e) : {};
11865    } catch {
11866      console.info("Unable to get transactions cache");
11867    }
11868    return {};
11869  },
11870  getTransactionsCacheForAddress({ address: e, chainId: t = "" }) {
11871    try {
11872      const r = W.getTransactionsCache()[e]?.[t];
11873      if (r && !this.isCacheExpired(r.timestamp, this.cacheExpiry.transactionsHistory)
11873)
11874        return r.transactions;
11875      W.removeTransactionsCache({ address: e, chainId: t });
11876    } catch {
11877      console.info("Unable to get transactions cache");
11878    }
11879  },
11880  updateTransactionsCache({ address: e, chainId: t = "", timestamp: n, transactions: r }) {
11881    try {
11882      const s = W.getTransactionsCache();
11883      s[e] = {
11884        ...s[e],
11885        [t]: {
11886          timestamp: n,
11887          transactions: r
11888        }
11889      }, Q.setItem(te.HISTORY_TRANSACTIONS_CACHE, JSON.stringify(s));
11890    } catch {
11891      console.info("Unable to update transactions cache", {
11892        address: e,
11893        chainId: t,
11894        timestamp: n,
11895        transactions: r
11896      });
11897    }
11898  },
11899  removeTransactionsCache({ address: e, chainId: t }) {
11900    try {
11901      const n = W.getTransactionsCache(), r = n?.[e] || {}, { [t]: s, ...i } = r;
11902      Q.setItem(te.HISTORY_TRANSACTIONS_CACHE, JSON.stringify({
11903        ...n,
11904        [e]: i
11905      }));
11906    } catch {
11907      console.info("Unable to remove transactions cache", { address: e, chainId: t });
11908    }
11909  },
11910  getTokenPriceCache() {
11911    try {
11912      const e = Q.getItem(te.TOKEN_PRICE_CACHE);
11913      return e ? JSON.parse(e) : {};
11914    } catch {
11915      console.info("Unable to get token price cache");
11916    }
11917    return {};
11918  },
11919  getTokenPriceCacheForAddresses(e) {
11920    try {
11921      const n = W.getTokenPriceCache()[e.join(",")];
11922      if (n && !this.isCacheExpired(n.timestamp, this.cacheExpiry.tokenPrice))
11923        return n.tokenPrice;
11924      W.removeTokenPriceCache(e);
11925    } catch {
11926      console.info("Unable to get token price cache for addresses", e);
11927    }
11928  },
11929  updateTokenPriceCache(e) {
11930    try {
11931      const t = W.getTokenPriceCache();
11932      t[e.addresses.join(",")] = {
11933        timestamp: e.timestamp,
11934        tokenPrice: e.tokenPrice
11935      }, Q.setItem(te.TOKEN_PRICE_CACHE, JSON.stringify(t));
11936    } catch {
11937      console.info("Unable to update token price cache", e);
11938    }
11939  },
11940  removeTokenPriceCache(e) {
11941    try {
11942      const t = W.getTokenPriceCache();
11943      Q.setItem(te.TOKEN_PRICE_CACHE, JSON.stringify({ ...t, [e.join(",")]: void 0 }));
11944    } catch {
11945      console.info("Unable to remove token price cache", e);
11946    }
11947  },
11948  /* ----- AppKit Latest Version ------------------------- */
11949  getLatestAppKitVersion() {
11950    try {
11951      const e = this.getLatestAppKitVersionCache(), t = e?.version;
11952      return t && !this.isCacheExpired(e.timestamp, this.cacheExpiry.latestAppKitVersion) ? t : void 0;
11953    } catch {
11954      console.info("Unable to get latest AppKit version");
11955    }
11956  },
11957  getLatestAppKitVersionCache() {
11958    try {
11959      const e = Q.getItem(te.LATEST_APPKIT_VERSION);
11960      return e ? JSON.parse(e) : {};
11961    } catch {
11962      console.info("Unable to get latest AppKit version cache");
11963    }
11964    return {};
11965  },
11966  updateLatestAppKitVersion(e) {
11967    try {
11968      const t = W.getLatestAppKitVersionCache();
11969      t.timestamp = e.timestamp, t.version = e.version, Q.setItem(te.LATEST_APPKIT_VERSION, JSON.stringify(t));
11970    } catch {
11971      console.info("Unable to update latest AppKit version on local storage", e);
11972    }
11973  }
11974}, q = {
11975  getWindow() {
11976    if (!(typeof window > "u"))
11977      return window;
11978  },
11979  isMobile() {
11980    return this.isClient() ? !!(window?.matchMedia && typeof window.matchMedia == "function" && window.matchMedia("(pointer:coarse)")?.matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)) : !1;
11981  },
11982  checkCaipNetwork(e, t = "") {
11983    return e?.caipNetworkId.toLocaleLowerCase().includes(t.toLowerCase());
11984  },
11985  isAndroid() {
11986    if (!this.isMobile())
11987      return !1;
11988    const e = window?.navigator.userAgent.toLowerCase();
11989    return q.isMobile() && e.includes("android");
11990  },
11991  isIos() {
11992    if (!this.isMobile())
11993      return !1;
11994    const e = window?.navigator.userAgent.toLowerCase();
11995    return e.includes("iphone") || e.includes("ipad");
11996  },
11997  isSafari() {
11998    return this.isClient() ? (window?.navigator.userAgent.toLowerCase()).includes("safari") : !1;
11999  },
12000  isClient() {
12001    return typeof window < "u";
12002  },
12003  isPairingExpired(e) {
12004    return e ? e - Date.now() <= Qe.TEN_SEC_MS : !0;
12005  },
12006  isAllowedRetry(e, t = Qe.ONE_SEC_MS) {
12007    return Date.now() - e >= t;
12008  },
12009  copyToClopboard(e) {
12010    navigator.clipboard.writeText(e);
12011  },
12012  isIframe() {
12013    try {
12014      return window?.self !== window?.top;
12015    } catch {
12016      return !1;
12017    }
12018  },
12019  isSafeApp() {
12020    if (q.isClient() && window.self !== window.top)
12021      try {
12022        const e = window?.location?.ancestorOrigins?.[0], t = "https://app.safe.global";
12023        if (e) {
12024          const n = new URL(e), r = new URL(t);
12025          return n.hostname === r.hostname;
12026        }
12027      } catch {
12028        return !1;
12029      }
12030    return !1;
12031  },
12032  getPairingExpiry() {
12033    return Date.now() + Qe.FOUR_MINUTES_MS;
12034  },
12035  getNetworkId(e) {
12036    return e?.split(":")[1];
12037  },
12038  getPlainAddress(e) {
12039    return e?.split(":")[2];
12040  },
12041  async wait(e) {
12042    return new Promise((t) => {
12043      setTimeout(t, e);
12044    });
12045  },
12046  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12047  debounce(e, t = 500) {
12048    let n;
12049    return (...r) => {
12050      function s() {
12051        e(...r);
12052      }
12053      n && clearTimeout(n), n = setTimeout(s, t);
12054    };
12055  },
12056  isHttpUrl(e) {
12057    return e.startsWith("http://") || e.startsWith("https://");
12058  },
12059  formatNativeUrl(e, t, n = null) {
12060    if (q.isHttpUrl(e))
12061      return this.formatUniversalUrl(e, t);
12062    let r = e, s = n;
12063    r.includes("://") || (r = e.replaceAll("/", "").replaceAll(":", ""), r = `${r}://`), r.endsWith("/") || (r = `${r}/`), s && !s?.endsWith("/") && (s = `${s}/`), this.isTelegram() && this.isAndroid() && (t = encodeURIComponent(t));
12064    const i = encodeURIComponent(t);
12065    return {
12066      redirect: `${r}wc?uri=${i}`,
12067      redirectUniversalLink: s ? `${s}wc?uri=${i}` : void 0,
12068      href: r
12069    };
12070  },
12071  formatUniversalUrl(e, t) {
12072    if (!q.isHttpUrl(e))
12073      return this.formatNativeUrl(e, t);
12074    let n = e;
12075    n.endsWith("/") || (n = `${n}/`);
12076    const r = encodeURIComponent(t);
12077    return {
12078      redirect: `${n}wc?uri=${r}`,
12079      href: n
12080    };
12081  },
12082  getOpenTargetForPlatform(e) {
12083    return e === "popupWindow" ? e : this.isTelegram() ? W.getTelegramSocialProvider() ? "_top" : "_blank" : e;
12084  },
12085  openHref(e, t, n) {
12086    window?.open(e, this.getOpenTargetForPlatform(t), n || "noreferrer noopener");
12087  },
12088  returnOpenHref(e, t, n) {
12089    return window?.open(e, this.getOpenTargetForPlatform(t), n || "noreferrer noopener");
12090  },
12091  isTelegram() {
12092    return typeof window < "u" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
12093    (!!window.TelegramWebviewProxy || // eslint-disable-next-line @typescript-eslint/no-explicit-any
12094    !!window.Telegram || // eslint-disable-next-line @typescript-eslint/no-explicit-any
12095    !!window.TelegramWebviewProxyProto);
12096  },
12097  isPWA() {
12098    if (typeof window > "u")
12099      return !1;
12100    const e = window?.matchMedia && typeof window.matchMedia == "function" ? window.matchMedia("(display-mode: standalone)")?.matches : !1, t = window?.navigator?.standalone;
12101    return !!(e || t);
12102  },
12103  async preloadImage(e) {
12104    const t = new Promise((n, r) => {
12105      const s = new Image();
12106      s.onload = n, s.onerror = r, s.crossOrigin = "anonymous", s.src = e;
12107    });
12108    return Promise.race([t, q.wait(2e3)]);
12109  },
12110  parseBalance(e, t) {
12111    let n = "0.000";
12112    if (typeof e == "string") {
12113      const u = Number(e);
12114      if (!isNaN(u)) {
12115        const c = (Math.floor(u * 1e3) / 1e3).toFixed(3);
12116        c && (n = c);
12117      }
12118    }
12119    const [r, s] = n.split("."), i = r || "0", o = s || "000";
12120    return {
12121      formattedText: `${i}.${o}${t ? ` ${t}` : ""}`,
12122      value: i,
12123      decimals: o,
12124      symbol: t
12125    };
12126  },
12127  getApiUrl() {
12128    return x.W3M_API_URL;
12129  },
12130  getBlockchainApiUrl() {
12131    return x.BLOCKCHAIN_API_RPC_URL;
12132  },
12133  getAnalyticsUrl() {
12134    return x.PULSE_API_URL;
12135  },
12136  getUUID() {
12137    return crypto?.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu, (e) => {
12138      const t = Math.random() * 16 | 0;
12139      return (e === "x" ? t : t & 3 | 8).toString(16);
12140    });
12141  },
12142  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12143  parseError(e) {
12144    return typeof e == "string" ? e : typeof e?.issues?.[0]?.message == "string" ? e.issues[0].message : e instanceof Error ? e.message : "Unknown error";
12145  },
12146  sortRequestedNetworks(e, t = []) {
12147    const n = {};
12148    return t && e && (e.forEach((r, s) => {
12149      n[r] = s;
12150    }), t.sort((r, s) => {
12151      const i = n[r.id], o = n[s.id];
12152      return i !== void 0 && o !== void 0 ? i - o : i !== void 0 ? -1 : o !== void 0 ? 1 : 0;
12153    })), t;
12154  },
12155  calculateBalance(e) {
12156    let t = 0;
12157    for (const n of e)
12158      t += n.value ?? 0;
12159    return t;
12160  },
12161  formatTokenBalance(e) {
12162    const t = e.toFixed(2), [n, r] = t.split(".");
12163    return { dollars: n, pennies: r };
12164  },
12165  isAddress(e, t = "eip155") {
12166    switch (t) {
12167      case "eip155":
12168        if (/^(?:0x)?[0-9a-f]{40}$/iu.test(e)) {
12169          if (/^(?:0x)?[0-9a-f]{40}$/iu.test(e) || /^(?:0x)?[0-9A-F]{40}$/iu.test(e))
12170            return !0;
12171        } else return !1;
12172        return !1;
12173      case "solana":
12174        return /[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(e);
12175      case "bip122": {
12176        const n = /^[1][a-km-zA-HJ-NP-Z1-9]{25,34}$/u.test(e), r = /^[3][a-km-zA-HJ-NP-Z1-9]{25,34}$/u.test(e), s = /^bc1[a-z0-9]{39,87}$/u.test(e), i = /^bc1p[a-z0-9]{58}$/u.test(e);
12177        return n || r || s || i;
12178      }
12179      default:
12180        return !1;
12181    }
12182  },
12183  uniqueBy(e, t) {
12184    const n = /* @__PURE__ */ new Set();
12185    return e.filter((r) => {
12186      const s = r[t];
12187      return n.has(s) ? !1 : (n.add(s), !0);
12188    });
12189  },
12190  generateSdkVersion(e, t, n) {
12191    const s = e.length === 0 ? Qe.ADAPTER_TYPES.UNIVERSAL : e.map((i) => i.adapterType).join(",");
12192    return `${t}-${s}-${n}`;
12193  },
12194  createAccount(e) {
12195    const { chainNamespace: t, chainId: n, address: r } = wt.parseCaipAddress(e.caipAddress);
12196    return {
12197      namespace: t,
12198      address: r,
12199      chainId: n,
12200      caipAddress: e.caipAddress,
12201      type: e.type,
12202      publicKey: e.publicKey,
12203      path: e.path
12204    };
12205  },
12206  isCaipAddress(e) {
12207    if (typeof e != "string")
12208      return !1;
12209    const t = e.split(":"), n = t[0];
12210    return t.filter(Boolean).length === 3 && n in x.CHAIN_NAME_MAP;
12211  },
12212  getAccount(e) {
12213    return e ? typeof e == "string" ? {
12214      address: e,
12215      chainId: void 0
12216    } : {
12217      address: e.address,
12218      chainId: e.chainId
12219    } : {
12220      address: void 0,
12221      chainId: void 0
12222    };
12223  },
12224  isMac() {
12225    const e = window?.navigator.userAgent.toLowerCase();
12226    return e.includes("macintosh") && !e.includes("safari");
12227  },
12228  formatTelegramSocialLoginUrl(e) {
12229    const t = `--${encodeURIComponent(window?.location.href)}`, n = "state=";
12230    if (new URL(e).host === "auth.magic.link") {
12231      const s = "provider_authorization_url=", i = e.substring(e.indexOf(s) + s.length), o = this.injectIntoUrl(decodeURIComponent(i), n, t);
12232      return e.replace(i, encodeURIComponent(o));
12233    }
12234    return this.injectIntoUrl(e, n, t);
12235  },
12236  injectIntoUrl(e, t, n) {
12237    const r = e.indexOf(t);
12238    if (r === -1)
12239      throw new Error(`${t} parameter not found in the URL: ${e}`);
12240    const s = e.indexOf("&", r), i = t.length, o = s !== -1 ? s : e.length, a = e.substring(0, r + i), u = e.substring(r + i, o), c = e.substring(s), l = u + n;
12241    return a + l + c;
12242  },
12243  isNumber(e) {
12244    return typeof e != "number" && typeof e != "string" ? !1 : !isNaN(Number(e));
12245  },
12246  appendPayToUri(e, t) {
12247    return t ? `${e}&pay=${encodeURIComponent(t)}` : e;
12248  }
12249}, sw = "https://secure.walletconnect.org/sdk", iw = (typeof process < "u" && typeof process.env < "u" ? process.env.NEXT_PUBLIC_SECURE_SITE_SDK_URL : void 0) || sw, ow = (typeof process < "u" && typeof process.env < "u" ? process.env.NEXT_PUBLIC_DEFAULT_LOG_LEVEL : void 0) || "error", aw = (typeof process < "u" && typeof process.env < "u" ? process.env.NEXT_PUBLIC_SECURE_SITE_SDK_VERSION : void 0) || "4", Z = {
12250  APP_EVENT_KEY: "@w3m-app/",
12251  FRAME_EVENT_KEY: "@w3m-frame/",
12252  RPC_METHOD_KEY: "RPC_",
12253  STORAGE_KEY: "@appkit-wallet/",
12254  SESSION_TOKEN_KEY: "SESSION_TOKEN_KEY",
12255  EMAIL_LOGIN_USED_KEY: "EMAIL_LOGIN_USED_KEY",
12256  LAST_USED_CHAIN_KEY: "LAST_USED_CHAIN_KEY",
12257  LAST_EMAIL_LOGIN_TIME: "LAST_EMAIL_LOGIN_TIME",
12258  EMAIL: "EMAIL",
12259  PREFERRED_ACCOUNT_TYPE: "PREFERRED_ACCOUNT_TYPE",
12260  SMART_ACCOUNT_ENABLED: "SMART_ACCOUNT_ENABLED",
12261  SMART_ACCOUNT_ENABLED_NETWORKS: "SMART_ACCOUNT_ENABLED_NETWORKS",
12262  SOCIAL_USERNAME: "SOCIAL_USERNAME",
12263  APP_SWITCH_NETWORK: "@w3m-app/SWITCH_NETWORK",
12264  APP_CONNECT_EMAIL: "@w3m-app/CONNECT_EMAIL",
12265  APP_CONNECT_DEVICE: "@w3m-app/CONNECT_DEVICE",
12266  APP_CONNECT_OTP: "@w3m-app/CONNECT_OTP",
12267  APP_CONNECT_SOCIAL: "@w3m-app/CONNECT_SOCIAL",
12268  APP_GET_SOCIAL_REDIRECT_URI: "@w3m-app/GET_SOCIAL_REDIRECT_URI",
12269  APP_GET_USER: "@w3m-app/GET_USER",
12270  APP_SIGN_OUT: "@w3m-app/SIGN_OUT",
12271  APP_IS_CONNECTED: "@w3m-app/IS_CONNECTED",
12272  APP_GET_CHAIN_ID: "@w3m-app/GET_CHAIN_ID",
12273  APP_RPC_REQUEST: "@w3m-app/RPC_REQUEST",
12274  APP_UPDATE_EMAIL: "@w3m-app/UPDATE_EMAIL",
12275  APP_UPDATE_EMAIL_PRIMARY_OTP: "@w3m-app/UPDATE_EMAIL_PRIMARY_OTP",
12276  APP_UPDATE_EMAIL_SECONDARY_OTP: "@w3m-app/UPDATE_EMAIL_SECONDARY_OTP",
12277  APP_AWAIT_UPDATE_EMAIL: "@w3m-app/AWAIT_UPDATE_EMAIL",
12278  APP_SYNC_THEME: "@w3m-app/SYNC_THEME",
12279  APP_SYNC_DAPP_DATA: "@w3m-app/SYNC_DAPP_DATA",
12280  APP_GET_SMART_ACCOUNT_ENABLED_NETWORKS: "@w3m-app/GET_SMART_ACCOUNT_ENABLED_NETWORKS",
12281  APP_INIT_SMART_ACCOUNT: "@w3m-app/INIT_SMART_ACCOUNT",
12282  APP_SET_PREFERRED_ACCOUNT: "@w3m-app/SET_PREFERRED_ACCOUNT",
12283  APP_CONNECT_FARCASTER: "@w3m-app/CONNECT_FARCASTER",
12284  APP_GET_FARCASTER_URI: "@w3m-app/GET_FARCASTER_URI",
12285  APP_RELOAD: "@w3m-app/RELOAD",
12286  APP_RPC_ABORT: "@w3m-app/RPC_ABORT",
12287  FRAME_SWITCH_NETWORK_ERROR: "@w3m-frame/SWITCH_NETWORK_ERROR",
12288  FRAME_SWITCH_NETWORK_SUCCESS: "@w3m-frame/SWITCH_NETWORK_SUCCESS",
12289  FRAME_CONNECT_EMAIL_ERROR: "@w3m-frame/CONNECT_EMAIL_ERROR",
12290  FRAME_CONNECT_EMAIL_SUCCESS: "@w3m-frame/CONNECT_EMAIL_SUCCESS",
12291  FRAME_CONNECT_DEVICE_ERROR: "@w3m-frame/CONNECT_DEVICE_ERROR",
12292  FRAME_CONNECT_DEVICE_SUCCESS: "@w3m-frame/CONNECT_DEVICE_SUCCESS",
12293  FRAME_CONNECT_OTP_SUCCESS: "@w3m-frame/CONNECT_OTP_SUCCESS",
12294  FRAME_CONNECT_OTP_ERROR: "@w3m-frame/CONNECT_OTP_ERROR",
12295  FRAME_CONNECT_SOCIAL_SUCCESS: "@w3m-frame/CONNECT_SOCIAL_SUCCESS",
12296  FRAME_CONNECT_SOCIAL_ERROR: "@w3m-frame/CONNECT_SOCIAL_ERROR",
12297  FRAME_CONNECT_FARCASTER_SUCCESS: "@w3m-frame/CONNECT_FARCASTER_SUCCESS",
12298  FRAME_CONNECT_FARCASTER_ERROR: "@w3m-frame/CONNECT_FARCASTER_ERROR",
12299  FRAME_GET_FARCASTER_URI_SUCCESS: "@w3m-frame/GET_FARCASTER_URI_SUCCESS",
12300  FRAME_GET_FARCASTER_URI_ERROR: "@w3m-frame/GET_FARCASTER_URI_ERROR",
12301  FRAME_GET_SOCIAL_REDIRECT_URI_SUCCESS: "@w3m-frame/GET_SOCIAL_REDIRECT_URI_SUCCESS",
12302  FRAME_GET_SOCIAL_REDIRECT_URI_ERROR: "@w3m-frame/GET_SOCIAL_REDIRECT_URI_ERROR",
12303  FRAME_GET_USER_SUCCESS: "@w3m-frame/GET_USER_SUCCESS",
12304  FRAME_GET_USER_ERROR: "@w3m-frame/GET_USER_ERROR",
12305  FRAME_SIGN_OUT_SUCCESS: "@w3m-frame/SIGN_OUT_SUCCESS",
12306  FRAME_SIGN_OUT_ERROR: "@w3m-frame/SIGN_OUT_ERROR",
12307  FRAME_IS_CONNECTED_SUCCESS: "@w3m-frame/IS_CONNECTED_SUCCESS",
12308  FRAME_IS_CONNECTED_ERROR: "@w3m-frame/IS_CONNECTED_ERROR",
12309  FRAME_GET_CHAIN_ID_SUCCESS: "@w3m-frame/GET_CHAIN_ID_SUCCESS",
12310  FRAME_GET_CHAIN_ID_ERROR: "@w3m-frame/GET_CHAIN_ID_ERROR",
12311  FRAME_RPC_REQUEST_SUCCESS: "@w3m-frame/RPC_REQUEST_SUCCESS",
12312  FRAME_RPC_REQUEST_ERROR: "@w3m-frame/RPC_REQUEST_ERROR",
12313  FRAME_SESSION_UPDATE: "@w3m-frame/SESSION_UPDATE",
12314  FRAME_UPDATE_EMAIL_SUCCESS: "@w3m-frame/UPDATE_EMAIL_SUCCESS",
12315  FRAME_UPDATE_EMAIL_ERROR: "@w3m-frame/UPDATE_EMAIL_ERROR",
12316  FRAME_UPDATE_EMAIL_PRIMARY_OTP_SUCCESS: "@w3m-frame/UPDATE_EMAIL_PRIMARY_OTP_SUCCESS",
12317  FRAME_UPDATE_EMAIL_PRIMARY_OTP_ERROR: "@w3m-frame/UPDATE_EMAIL_PRIMARY_OTP_ERROR",
12318  FRAME_UPDATE_EMAIL_SECONDARY_OTP_SUCCESS: "@w3m-frame/UPDATE_EMAIL_SECONDARY_OTP_SUCCESS",
12319  FRAME_UPDATE_EMAIL_SECONDARY_OTP_ERROR: "@w3m-frame/UPDATE_EMAIL_SECONDARY_OTP_ERROR",
12320  FRAME_SYNC_THEME_SUCCESS: "@w3m-frame/SYNC_THEME_SUCCESS",
12321  FRAME_SYNC_THEME_ERROR: "@w3m-frame/SYNC_THEME_ERROR",
12322  FRAME_SYNC_DAPP_DATA_SUCCESS: "@w3m-frame/SYNC_DAPP_DATA_SUCCESS",
12323  FRAME_SYNC_DAPP_DATA_ERROR: "@w3m-frame/SYNC_DAPP_DATA_ERROR",
12324  FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_SUCCESS: "@w3m-frame/GET_SMART_ACCOUNT_ENABLED_NETWORKS_SUCCESS",
12325  FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_ERROR: "@w3m-frame/GET_SMART_ACCOUNT_ENABLED_NETWORKS_ERROR",
12326  FRAME_INIT_SMART_ACCOUNT_SUCCESS: "@w3m-frame/INIT_SMART_ACCOUNT_SUCCESS",
12327  FRAME_INIT_SMART_ACCOUNT_ERROR: "@w3m-frame/INIT_SMART_ACCOUNT_ERROR",
12328  FRAME_SET_PREFERRED_ACCOUNT_SUCCESS: "@w3m-frame/SET_PREFERRED_ACCOUNT_SUCCESS",
12329  FRAME_SET_PREFERRED_ACCOUNT_ERROR: "@w3m-frame/SET_PREFERRED_ACCOUNT_ERROR",
12330  FRAME_READY: "@w3m-frame/READY",
12331  FRAME_RELOAD_SUCCESS: "@w3m-frame/RELOAD_SUCCESS",
12332  FRAME_RELOAD_ERROR: "@w3m-frame/RELOAD_ERROR",
12333  FRAME_RPC_ABORT_SUCCESS: "@w3m-frame/RPC_ABORT_SUCCESS",
12334  FRAME_RPC_ABORT_ERROR: "@w3m-frame/RPC_ABORT_ERROR",
12335  RPC_RESPONSE_TYPE_ERROR: "RPC_RESPONSE_ERROR",
12336  RPC_RESPONSE_TYPE_TX: "RPC_RESPONSE_TRANSACTION_HASH",
12337  RPC_RESPONSE_TYPE_OBJECT: "RPC_RESPONSE_OBJECT"
12338}, Ye = {
12339  SAFE_RPC_METHODS: [
12340    "eth_accounts",
12341    "eth_blockNumber",
12342    "eth_call",
12343    "eth_chainId",
12344    "eth_estimateGas",
12345    "eth_feeHistory",
12346    "eth_gasPrice",
12347    "eth_getAccount",
12348    "eth_getBalance",
12349    "eth_getBlockByHash",
12350    "eth_getBlockByNumber",
12351    "eth_getBlockReceipts",
12352    "eth_getBlockTransactionCountByHash",
12353    "eth_getBlockTransactionCountByNumber",
12354    "eth_getCode",
12355    "eth_getFilterChanges",
12356    "eth_getFilterLogs",
12357    "eth_getLogs",
12358    "eth_getProof",
12359    "eth_getStorageAt",
12360    "eth_getTransactionByBlockHashAndIndex",
12361    "eth_getTransactionByBlockNumberAndIndex",
12362    "eth_getTransactionByHash",
12363    "eth_getTransactionCount",
12364    "eth_getTransactionReceipt",
12365    "eth_getUncleCountByBlockHash",
12366    "eth_getUncleCountByBlockNumber",
12367    "eth_maxPriorityFeePerGas",
12368    "eth_newBlockFilter",
12369    "eth_newFilter",
12370    "eth_newPendingTransactionFilter",
12371    "eth_sendRawTransaction",
12372    "eth_syncing",
12373    "eth_uninstallFilter",
12374    "wallet_getCapabilities",
12375    "wallet_getCallsStatus",
12376    "eth_getUserOperationReceipt",
12377    "eth_estimateUserOperationGas",
12378    "eth_getUserOperationByHash",
12379    "eth_supportedEntryPoints",
12380    "wallet_getAssets"
12381  ],
12382  NOT_SAFE_RPC_METHODS: [
12383    "personal_sign",
12384    "eth_signTypedData_v4",
12385    "eth_sendTransaction",
12386    "solana_signMessage",
12387    "solana_signTransaction",
12388    "solana_signAllTransactions",
12389    "solana_signAndSendTransaction",
12390    "wallet_sendCalls",
12391    "wallet_grantPermissions",
12392    "wallet_revokePermissions",
12393    "eth_sendUserOperation"
12394  ],
12395  GET_CHAIN_ID: "eth_chainId",
12396  RPC_METHOD_NOT_ALLOWED_MESSAGE: "Requested RPC call is not allowed",
12397  RPC_METHOD_NOT_ALLOWED_UI_MESSAGE: "Action not allowed",
12398  ACCOUNT_TYPES: {
12399    EOA: "eoa",
12400    SMART_ACCOUNT: "smartAccount"
12401  }
12402}, Du = {
12403  transactionHash: /^0x(?:[A-Fa-f0-9]{64})$/u,
12404  signedMessage: /^0x(?:[a-fA-F0-9]{62,})$/u
12405}, Ve = {
12406  set(e, t) {
12407    Wt.isClient && localStorage.setItem(`${Z.STORAGE_KEY}${e}`, t);
12408  },
12409  get(e) {
12410    return Wt.isClient ? localStorage.getItem(`${Z.STORAGE_KEY}${e}`) : null;
12411  },
12412  delete(e, t) {
12413    Wt.isClient && (t ? localStorage.removeItem(e) : localStorage.removeItem(`${Z.STORAGE_KEY}${e}`));
12414  }
12415}, yi = 30 * 1e3, Wt = {
12416  checkIfAllowedToTriggerEmail() {
12417    const e = Ve.get(Z.LAST_EMAIL_LOGIN_TIME);
12418    if (e) {
12419      const t = Date.now() - Number(e);
12420      if (t < yi) {
12421        const n = Math.ceil((yi - t) / 1e3);
12422        throw new Error(`Please try again after ${n} seconds`);
12423      }
12424    }
12425  },
12426  getTimeToNextEmailLogin() {
12427    const e = Ve.get(Z.LAST_EMAIL_LOGIN_TIME);
12428    if (e) {
12429      const t = Date.now() - Number(e);
12430      if (t < yi)
12431        return Math.ceil((yi - t) / 1e3);
12432    }
12433    return 0;
12434  },
12435  checkIfRequestExists(e) {
12436    return Ye.NOT_SAFE_RPC_METHODS.includes(e.method) || Ye.SAFE_RPC_METHODS.includes(e.method);
12437  },
12438  getResponseType(e) {
12439    return typeof e == "string" && (e?.match(Du.transactionHash) || e?.match(Du.signedMessage)) ? Z.RPC_RESPONSE_TYPE_TX : Z.RPC_RESPONSE_TYPE_OBJECT;
12440  },
12441  checkIfRequestIsSafe(e) {
12442    return Ye.SAFE_RPC_METHODS.includes(e.method);
12443  },
12444  isClient: typeof window < "u"
12445};
12446var _e;
12447(function(e) {
12448  e.assertEqual = (s) => s;
12449  function t(s) {
12450  }
12451  e.assertIs = t;
12452  function n(s) {
12453    throw new Error();
12454  }
12455  e.assertNever = n, e.arrayToEnum = (s) => {
12456    const i = {};
12457    for (const o of s)
12458      i[o] = o;
12459    return i;
12460  }, e.getValidEnumValues = (s) => {
12461    const i = e.objectKeys(s).filter((a) => typeof s[s[a]] != "number"), o = {};
12462    for (const a of i)
12463      o[a] = s[a];
12464    return e.objectValues(o);
12465  }, e.objectValues = (s) => e.objectKeys(s).map(function(i) {
12466    return s[i];
12467  }), e.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
12468    const i = [];
12469    for (const o in s)
12470      Object.prototype.hasOwnProperty.call(s, o) && i.push(o);
12471    return i;
12472  }, e.find = (s, i) => {
12473    for (const o of s)
12474      if (i(o))
12475        return o;
12476  }, e.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && isFinite(s) && Math.floor(s) === s;
12477  function r(s, i = " | ") {
12478    return s.map((o) => typeof o == "string" ? `'${o}'` : o).join(i);
12479  }
12480  e.joinValues = r, e.jsonStringifyReplacer = (s, i) => typeof i == "bigint" ? i.toString() : i;
12481})(_e || (_e = {}));
12482var Pa;
12483(function(e) {
12484  e.mergeShapes = (t, n) => ({
12485    ...t,
12486    ...n
12487    // second overwrites first
12488  });
12489})(Pa || (Pa = {}));
12490const G = _e.arrayToEnum([
12491  "string",
12492  "nan",
12493  "number",
12494  "integer",
12495  "float",
12496  "boolean",
12497  "date",
12498  "bigint",
12499  "symbol",
12500  "function",
12501  "undefined",
12502  "null",
12503  "array",
12504  "object",
12505  "unknown",
12506  "promise",
12507  "void",
12508  "never",
12509  "map",
12510  "set"
12511]), In = (e) => {
12512  switch (typeof e) {
12513    case "undefined":
12514      return G.undefined;
12515    case "string":
12516      return G.string;
12517    case "number":
12518      return isNaN(e) ? G.nan : G.number;
12519    case "boolean":
12520      return G.boolean;
12521    case "function":
12522      return G.function;
12523    case "bigint":
12524      return G.bigint;
12525    case "symbol":
12526      return G.symbol;
12527    case "object":
12528      return Array.isArray(e) ? G.array : e === null ? G.null : e.then && typeof e.then == "function" && e.catch && typeof e.catch == "function" ? G.promise : typeof Map < "u" && e instanceof Map ? G.map : typeof Set < "u" && e instanceof Set ? G.set : typeof Date < "u" && e instanceof Date ? G.date : G.object;
12529    default:
12530      return G.unknown;
12531  }
12532}, j = _e.arrayToEnum([
12533  "invalid_type",
12534  "invalid_literal",
12535  "custom",
12536  "invalid_union",
12537  "invalid_union_discriminator",
12538  "invalid_enum_value",
12539  "unrecognized_keys",
12540  "invalid_arguments",
12541  "invalid_return_type",
12542  "invalid_date",
12543  "invalid_string",
12544  "too_small",
12545  "too_big",
12546  "invalid_intersection_types",
12547  "not_multiple_of",
12548  "not_finite"
12549]), cw = (e) => JSON.stringify(e, null, 2).replace(/"([^"]+)":/g, "$1:");
vendor: 21,186 bytes, lines 12550-13136
12550class xt extends Error {
12551  constructor(t) {
12552    super(), this.issues = [], this.addIssue = (r) => {
12553      this.issues = [...this.issues, r];
12554    }, this.addIssues = (r = []) => {
12555      this.issues = [...this.issues, ...r];
12556    };
12557    const n = new.target.prototype;
12558    Object.setPrototypeOf ? Object.setPrototypeOf(this, n) : this.__proto__ = n, this.name = "ZodError", this.issues = t;
12559  }
12560  get errors() {
12561    return this.issues;
12562  }
12563  format(t) {
12564    const n = t || function(i) {
12565      return i.message;
12566    }, r = { _errors: [] }, s = (i) => {
12567      for (const o of i.issues)
12568        if (o.code === "invalid_union")
12569          o.unionErrors.map(s);
12570        else if (o.code === "invalid_return_type")
12571          s(o.returnTypeError);
12572        else if (o.code === "invalid_arguments")
12573          s(o.argumentsError);
12574        else if (o.path.length === 0)
12575          r._errors.push(n(o));
12576        else {
12577          let a = r, u = 0;
12578          for (; u < o.path.length; ) {
12579            const c = o.path[u];
12580            u === o.path.length - 1 ? (a[c] = a[c] || { _errors: [] }, a[c]._errors.push(n(o))) : a[c] = a[c] || { _errors: [] }, a = a[c], u++;
12581          }
12582        }
12583    };
12584    return s(this), r;
12585  }
12586  toString() {
12587    return this.message;
12588  }
12589  get message() {
12590    return JSON.stringify(this.issues, _e.jsonStringifyReplacer, 2);
12591  }
12592  get isEmpty() {
12593    return this.issues.length === 0;
12594  }
12595  flatten(t = (n) => n.message) {
12596    const n = {}, r = [];
12597    for (const s of this.issues)
12598      s.path.length > 0 ? (n[s.path[0]] = n[s.path[0]] || [], n[s.path[0]].push(t(s))) : r.push(t(s));
12599    return { formErrors: r, fieldErrors: n };
12600  }
12601  get formErrors() {
12602    return this.flatten();
12603  }
12604}
12605xt.create = (e) => new xt(e);
12606const Is = (e, t) => {
12607  let n;
12608  switch (e.code) {
12609    case j.invalid_type:
12610      e.received === G.undefined ? n = "Required" : n = `Expected ${e.expected}, received ${e.received}`;
12611      break;
12612    case j.invalid_literal:
12613      n = `Invalid literal value, expected ${JSON.stringify(e.expected, _e.jsonStringifyReplacer)}`;
12614      break;
12615    case j.unrecognized_keys:
12616      n = `Unrecognized key(s) in object: ${_e.joinValues(e.keys, ", ")}`;
12617      break;
12618    case j.invalid_union:
12619      n = "Invalid input";
12620      break;
12621    case j.invalid_union_discriminator:
12622      n = `Invalid discriminator value. Expected ${_e.joinValues(e.options)}`;
12623      break;
12624    case j.invalid_enum_value:
12625      n = `Invalid enum value. Expected ${_e.joinValues(e.options)}, received '${e.received}'`;
12626      break;
12627    case j.invalid_arguments:
12628      n = "Invalid function arguments";
12629      break;
12630    case j.invalid_return_type:
12631      n = "Invalid function return type";
12632      break;
12633    case j.invalid_date:
12634      n = "Invalid date";
12635      break;
12636    case j.invalid_string:
12637      typeof e.validation == "object" ? "includes" in e.validation ? (n = `Invalid input: must include "${e.validation.includes}"`, typeof e.validation.position == "number" && (n = `${n} at one or more positions greater than or equal to ${e.validation.position}`)) : "startsWith" in e.validation ? n = `Invalid input: must start with "${e.validation.startsWith}"` : "endsWith" in e.validation ? n = `Invalid input: must end with "${e.validation.endsWith}"` : _e.assertNever(e.validation) : e.validation !== "regex" ? n = `Invalid ${e.validation}` : n = "Invalid";
12638      break;
12639    case j.too_small:
12640      e.type === "array" ? n = `Array must contain ${e.exact ? "exactly" : e.inclusive ? "at least" : "more than"} ${e.minimum} element(s)` : e.type === "string" ? n = `String must contain ${e.exact ? "exactly" : e.inclusive ? "at least" : "over"} ${e.minimum} character(s)` : e.type === "number" ? n = `Number must be ${e.exact ? "exactly equal to " : e.inclusive ? "greater than or equal to " : "greater than "}${e.minimum}` : e.type === "date" ? n = `Date must be ${e.exact ? "exactly equal to " : e.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(e.minimum))}` : n = "Invalid input";
12641      break;
12642    case j.too_big:
12643      e.type === "array" ? n = `Array must contain ${e.exact ? "exactly" : e.inclusive ? "at most" : "less than"} ${e.maximum} element(s)` : e.type === "string" ? n = `String must contain ${e.exact ? "exactly" : e.inclusive ? "at most" : "under"} ${e.maximum} character(s)` : e.type === "number" ? n = `Number must be ${e.exact ? "exactly" : e.inclusive ? "less than or equal to" : "less than"} ${e.maximum}` : e.type === "bigint" ? n = `BigInt must be ${e.exact ? "exactly" : e.inclusive ? "less than or equal to" : "less than"} ${e.maximum}` : e.type === "date" ? n = `Date must be ${e.exact ? "exactly" : e.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(e.maximum))}` : n = "Invalid input";
12644      break;
12645    case j.custom:
12646      n = "Invalid input";
12647      break;
12648    case j.invalid_intersection_types:
12649      n = "Intersection results could not be merged";
12650      break;
12651    case j.not_multiple_of:
12652      n = `Number must be a multiple of ${e.multipleOf}`;
12653      break;
12654    case j.not_finite:
12655      n = "Number must be finite";
12656      break;
12657    default:
12658      n = t.defaultError, _e.assertNever(e);
12659  }
12660  return { message: n };
12661};
12662let bf = Is;
12663function uw(e) {
12664  bf = e;
12665}
12666function Ki() {
12667  return bf;
12668}
12669const Yi = (e) => {
12670  const { data: t, path: n, errorMaps: r, issueData: s } = e, i = [...n, ...s.path || []], o = {
12671    ...s,
12672    path: i
12673  };
12674  let a = "";
12675  const u = r.filter((c) => !!c).slice().reverse();
12676  for (const c of u)
12677    a = c(o, { data: t, defaultError: a }).message;
12678  return {
12679    ...s,
12680    path: i,
12681    message: s.message || a
12682  };
12683}, lw = [];
12684function Y(e, t) {
12685  const n = Yi({
12686    issueData: t,
12687    data: e.data,
12688    path: e.path,
12689    errorMaps: [
12690      e.common.contextualErrorMap,
12691      e.schemaErrorMap,
12692      Ki(),
12693      Is
12694      // then global default map
12695    ].filter((r) => !!r)
12696  });
12697  e.common.issues.push(n);
12698}
12699class nt {
12700  constructor() {
12701    this.value = "valid";
12702  }
12703  dirty() {
12704    this.value === "valid" && (this.value = "dirty");
12705  }
12706  abort() {
12707    this.value !== "aborted" && (this.value = "aborted");
12708  }
12709  static mergeArray(t, n) {
12710    const r = [];
12711    for (const s of n) {
12712      if (s.status === "aborted")
12713        return le;
12714      s.status === "dirty" && t.dirty(), r.push(s.value);
12715    }
12716    return { status: t.value, value: r };
12717  }
12718  static async mergeObjectAsync(t, n) {
12719    const r = [];
12720    for (const s of n)
12721      r.push({
12722        key: await s.key,
12723        value: await s.value
12724      });
12725    return nt.mergeObjectSync(t, r);
12726  }
12727  static mergeObjectSync(t, n) {
12728    const r = {};
12729    for (const s of n) {
12730      const { key: i, value: o } = s;
12731      if (i.status === "aborted" || o.status === "aborted")
12732        return le;
12733      i.status === "dirty" && t.dirty(), o.status === "dirty" && t.dirty(), i.value !== "__proto__" && (typeof o.value < "u" || s.alwaysSet) && (r[i.value] = o.value);
12734    }
12735    return { status: t.value, value: r };
12736  }
12737}
12738const le = Object.freeze({
12739  status: "aborted"
12740}), wf = (e) => ({ status: "dirty", value: e }), at = (e) => ({ status: "valid", value: e }), ka = (e) => e.status === "aborted", Ua = (e) => e.status === "dirty", Ts = (e) => e.status === "valid", Zi = (e) => typeof Promise < "u" && e instanceof Promise;
12741var se;
12742(function(e) {
12743  e.errToObj = (t) => typeof t == "string" ? { message: t } : t || {}, e.toString = (t) => typeof t == "string" ? t : t?.message;
12744})(se || (se = {}));
12745class Vt {
12746  constructor(t, n, r, s) {
12747    this._cachedPath = [], this.parent = t, this.data = n, this._path = r, this._key = s;
12748  }
12749  get path() {
12750    return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
12751  }
12752}
12753const Fu = (e, t) => {
12754  if (Ts(t))
12755    return { success: !0, data: t.value };
12756  if (!e.common.issues.length)
12757    throw new Error("Validation failed but no issues detected.");
12758  return {
12759    success: !1,
12760    get error() {
12761      if (this._error)
12762        return this._error;
12763      const n = new xt(e.common.issues);
12764      return this._error = n, this._error;
12765    }
12766  };
12767};
12768function he(e) {
12769  if (!e)
12770    return {};
12771  const { errorMap: t, invalid_type_error: n, required_error: r, description: s } = e;
12772  if (t && (n || r))
12773    throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
12774  return t ? { errorMap: t, description: s } : { errorMap: (o, a) => o.code !== "invalid_type" ? { message: a.defaultError } : typeof a.data > "u" ? { message: r ?? a.defaultError } : { message: n ?? a.defaultError }, description: s };
12775}
12776class me {
12777  constructor(t) {
12778    this.spa = this.safeParseAsync, this._def = t, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this);
12779  }
12780  get description() {
12781    return this._def.description;
12782  }
12783  _getType(t) {
12784    return In(t.data);
12785  }
12786  _getOrReturnCtx(t, n) {
12787    return n || {
12788      common: t.parent.common,
12789      data: t.data,
12790      parsedType: In(t.data),
12791      schemaErrorMap: this._def.errorMap,
12792      path: t.path,
12793      parent: t.parent
12794    };
12795  }
12796  _processInputParams(t) {
12797    return {
12798      status: new nt(),
12799      ctx: {
12800        common: t.parent.common,
12801        data: t.data,
12802        parsedType: In(t.data),
12803        schemaErrorMap: this._def.errorMap,
12804        path: t.path,
12805        parent: t.parent
12806      }
12807    };
12808  }
12809  _parseSync(t) {
12810    const n = this._parse(t);
12811    if (Zi(n))
12812      throw new Error("Synchronous parse encountered promise.");
12813    return n;
12814  }
12815  _parseAsync(t) {
12816    const n = this._parse(t);
12817    return Promise.resolve(n);
12818  }
12819  parse(t, n) {
12820    const r = this.safeParse(t, n);
12821    if (r.success)
12822      return r.data;
12823    throw r.error;
12824  }
12825  safeParse(t, n) {
12826    var r;
12827    const s = {
12828      common: {
12829        issues: [],
12830        async: (r = n?.async) !== null && r !== void 0 ? r : !1,
12831        contextualErrorMap: n?.errorMap
12832      },
12833      path: n?.path || [],
12834      schemaErrorMap: this._def.errorMap,
12835      parent: null,
12836      data: t,
12837      parsedType: In(t)
12838    }, i = this._parseSync({ data: t, path: s.path, parent: s });
12839    return Fu(s, i);
12840  }
12841  async parseAsync(t, n) {
12842    const r = await this.safeParseAsync(t, n);
12843    if (r.success)
12844      return r.data;
12845    throw r.error;
12846  }
12847  async safeParseAsync(t, n) {
12848    const r = {
12849      common: {
12850        issues: [],
12851        contextualErrorMap: n?.errorMap,
12852        async: !0
12853      },
12854      path: n?.path || [],
12855      schemaErrorMap: this._def.errorMap,
12856      parent: null,
12857      data: t,
12858      parsedType: In(t)
12859    }, s = this._parse({ data: t, path: r.path, parent: r }), i = await (Zi(s) ? s : Promise.resolve(s));
12860    return Fu(r, i);
12861  }
12862  refine(t, n) {
12863    const r = (s) => typeof n == "string" || typeof n > "u" ? { message: n } : typeof n == "function" ? n(s) : n;
12864    return this._refinement((s, i) => {
12865      const o = t(s), a = () => i.addIssue({
12866        code: j.custom,
12867        ...r(s)
12868      });
12869      return typeof Promise < "u" && o instanceof Promise ? o.then((u) => u ? !0 : (a(), !1)) : o ? !0 : (a(), !1);
12870    });
12871  }
12872  refinement(t, n) {
12873    return this._refinement((r, s) => t(r) ? !0 : (s.addIssue(typeof n == "function" ? n(r, s) : n), !1));
12874  }
12875  _refinement(t) {
12876    return new kt({
12877      schema: this,
12878      typeName: oe.ZodEffects,
12879      effect: { type: "refinement", refinement: t }
12880    });
12881  }
12882  superRefine(t) {
12883    return this._refinement(t);
12884  }
12885  optional() {
12886    return fn.create(this, this._def);
12887  }
12888  nullable() {
12889    return ur.create(this, this._def);
12890  }
12891  nullish() {
12892    return this.nullable().optional();
12893  }
12894  array() {
12895    return Ot.create(this, this._def);
12896  }
12897  promise() {
12898    return jr.create(this, this._def);
12899  }
12900  or(t) {
12901    return Os.create([this, t], this._def);
12902  }
12903  and(t) {
12904    return Ps.create(this, t, this._def);
12905  }
12906  transform(t) {
12907    return new kt({
12908      ...he(this._def),
12909      schema: this,
12910      typeName: oe.ZodEffects,
12911      effect: { type: "transform", transform: t }
12912    });
12913  }
12914  default(t) {
12915    const n = typeof t == "function" ? t : () => t;
12916    return new Bs({
12917      ...he(this._def),
12918      innerType: this,
12919      defaultValue: n,
12920      typeName: oe.ZodDefault
12921    });
12922  }
12923  brand() {
12924    return new Ef({
12925      typeName: oe.ZodBranded,
12926      type: this,
12927      ...he(this._def)
12928    });
12929  }
12930  catch(t) {
12931    const n = typeof t == "function" ? t : () => t;
12932    return new eo({
12933      ...he(this._def),
12934      innerType: this,
12935      catchValue: n,
12936      typeName: oe.ZodCatch
12937    });
12938  }
12939  describe(t) {
12940    const n = this.constructor;
12941    return new n({
12942      ...this._def,
12943      description: t
12944    });
12945  }
12946  pipe(t) {
12947    return Js.create(this, t);
12948  }
12949  readonly() {
12950    return no.create(this);
12951  }
12952  isOptional() {
12953    return this.safeParse(void 0).success;
12954  }
12955  isNullable() {
12956    return this.safeParse(null).success;
12957  }
12958}
12959const dw = /^c[^\s-]{8,}$/i, fw = /^[a-z][a-z0-9]*$/, hw = /^[0-9A-HJKMNP-TV-Z]{26}$/, pw = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, mw = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, gw = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
12960let Ko;
12961const yw = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/, bw = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, ww = (e) => e.precision ? e.offset ? new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`) : new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}Z$`) : e.precision === 0 ? e.offset ? new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$") : new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$") : e.offset ? new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$") : new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");
12962function Cw(e, t) {
12963  return !!((t === "v4" || !t) && yw.test(e) || (t === "v6" || !t) && bw.test(e));
12964}
12965class Rt extends me {
12966  _parse(t) {
12967    if (this._def.coerce && (t.data = String(t.data)), this._getType(t) !== G.string) {
12968      const i = this._getOrReturnCtx(t);
12969      return Y(
12970        i,
12971        {
12972          code: j.invalid_type,
12973          expected: G.string,
12974          received: i.parsedType
12975        }
12976        //
12977      ), le;
12978    }
12979    const r = new nt();
12980    let s;
12981    for (const i of this._def.checks)
12982      if (i.kind === "min")
12983        t.data.length < i.value && (s = this._getOrReturnCtx(t, s), Y(s, {
12984          code: j.too_small,
12985          minimum: i.value,
12986          type: "string",
12987          inclusive: !0,
12988          exact: !1,
12989          message: i.message
12990        }), r.dirty());
12991      else if (i.kind === "max")
12992        t.data.length > i.value && (s = this._getOrReturnCtx(t, s), Y(s, {
12993          code: j.too_big,
12994          maximum: i.value,
12995          type: "string",
12996          inclusive: !0,
12997          exact: !1,
12998          message: i.message
12999        }), r.dirty());
13000      else if (i.kind === "length") {
13001        const o = t.data.length > i.value, a = t.data.length < i.value;
13002        (o || a) && (s = this._getOrReturnCtx(t, s), o ? Y(s, {
13003          code: j.too_big,
13004          maximum: i.value,
13005          type: "string",
13006          inclusive: !0,
13007          exact: !0,
13008          message: i.message
13009        }) : a && Y(s, {
13010          code: j.too_small,
13011          minimum: i.value,
13012          type: "string",
13013          inclusive: !0,
13014          exact: !0,
13015          message: i.message
13016        }), r.dirty());
13017      } else if (i.kind === "email")
13018        mw.test(t.data) || (s = this._getOrReturnCtx(t, s), Y(s, {
13019          validation: "email",
13020          code: j.invalid_string,
13021          message: i.message
13022        }), r.dirty());
13023      else if (i.kind === "emoji")
13024        Ko || (Ko = new RegExp(gw, "u")), Ko.test(t.data) || (s = this._getOrReturnCtx(t, s), Y(s, {
13025          validation: "emoji",
13026          code: j.invalid_string,
13027          message: i.message
13028        }), r.dirty());
13029      else if (i.kind === "uuid")
13030        pw.test(t.data) || (s = this._getOrReturnCtx(t, s), Y(s, {
13031          validation: "uuid",
13032          code: j.invalid_string,
13033          message: i.message
13034        }), r.dirty());
13035      else if (i.kind === "cuid")
13036        dw.test(t.data) || (s = this._getOrReturnCtx(t, s), Y(s, {
13037          validation: "cuid",
13038          code: j.invalid_string,
13039          message: i.message
13040        }), r.dirty());
13041      else if (i.kind === "cuid2")
13042        fw.test(t.data) || (s = this._getOrReturnCtx(t, s), Y(s, {
13043          validation: "cuid2",
13044          code: j.invalid_string,
13045          message: i.message
13046        }), r.dirty());
13047      else if (i.kind === "ulid")
13048        hw.test(t.data) || (s = this._getOrReturnCtx(t, s), Y(s, {
13049          validation: "ulid",
13050          code: j.invalid_string,
13051          message: i.message
13052        }), r.dirty());
13053      else if (i.kind === "url")
13054        try {
13055          new URL(t.data);
13056        } catch {
13057          s = this._getOrReturnCtx(t, s), Y(s, {
13058            validation: "url",
13059            code: j.invalid_string,
13060            message: i.message
13061          }), r.dirty();
13062        }
13063      else i.kind === "regex" ? (i.regex.lastIndex = 0, i.regex.test(t.data) || (s = this._getOrReturnCtx(t, s), Y(s, {
13064        validation: "regex",
13065        code: j.invalid_string,
13066        message: i.message
13067      }), r.dirty())) : i.kind === "trim" ? t.data = t.data.trim() : i.kind === "includes" ? t.data.includes(i.value, i.position) || (s = this._getOrReturnCtx(t, s), Y(s, {
13068        code: j.invalid_string,
13069        validation: { includes: i.value, position: i.position },
13070        message: i.message
13071      }), r.dirty()) : i.kind === "toLowerCase" ? t.data = t.data.toLowerCase() : i.kind === "toUpperCase" ? t.data = t.data.toUpperCase() : i.kind === "startsWith" ? t.data.startsWith(i.value) || (s = this._getOrReturnCtx(t, s), Y(s, {
13072        code: j.invalid_string,
13073        validation: { startsWith: i.value },
13074        message: i.message
13075      }), r.dirty()) : i.kind === "endsWith" ? t.data.endsWith(i.value) || (s = this._getOrReturnCtx(t, s), Y(s, {
13076        code: j.invalid_string,
13077        validation: { endsWith: i.value },
13078        message: i.message
13079      }), r.dirty()) : i.kind === "datetime" ? ww(i).test(t.data) || (s = this._getOrReturnCtx(t, s), Y(s, {
13080        code: j.invalid_string,
13081        validation: "datetime",
13082        message: i.message
13083      }), r.dirty()) : i.kind === "ip" ? Cw(t.data, i.version) || (s = this._getOrReturnCtx(t, s), Y(s, {
13084        validation: "ip",
13085        code: j.invalid_string,
13086        message: i.message
13087      }), r.dirty()) : _e.assertNever(i);
13088    return { status: r.value, value: t.data };
13089  }
13090  _regex(t, n, r) {
13091    return this.refinement((s) => t.test(s), {
13092      validation: n,
13093      code: j.invalid_string,
13094      ...se.errToObj(r)
13095    });
13096  }
13097  _addCheck(t) {
13098    return new Rt({
13099      ...this._def,
13100      checks: [...this._def.checks, t]
13101    });
13102  }
13103  email(t) {
13104    return this._addCheck({ kind: "email", ...se.errToObj(t) });
13105  }
13106  url(t) {
13107    return this._addCheck({ kind: "url", ...se.errToObj(t) });
13108  }
13109  emoji(t) {
13110    return this._addCheck({ kind: "emoji", ...se.errToObj(t) });
13111  }
13112  uuid(t) {
13113    return this._addCheck({ kind: "uuid", ...se.errToObj(t) });
13114  }
13115  cuid(t) {
13116    return this._addCheck({ kind: "cuid", ...se.errToObj(t) });
13117  }
13118  cuid2(t) {
13119    return this._addCheck({ kind: "cuid2", ...se.errToObj(t) });
13120  }
13121  ulid(t) {
13122    return this._addCheck({ kind: "ulid", ...se.errToObj(t) });
13123  }
13124  ip(t) {
13125    return this._addCheck({ kind: "ip", ...se.errToObj(t) });
13126  }
13127  datetime(t) {
13128    var n;
13129    return typeof t == "string" ? this._addCheck({
13130      kind: "datetime",
13131      precision: null,
13132      offset: !1,
13133      message: t
13134    }) : this._addCheck({
13135      kind: "datetime",
13136      precision: typeof t?.precision > "u" ? null : t?.precision,
vendor: 17,256 bytes, lines 13137-13840
13137      offset: (n = t?.offset) !== null && n !== void 0 ? n : !1,
13138      ...se.errToObj(t?.message)
13139    });
13140  }
13141  regex(t, n) {
13142    return this._addCheck({
13143      kind: "regex",
13144      regex: t,
13145      ...se.errToObj(n)
13146    });
13147  }
13148  includes(t, n) {
13149    return this._addCheck({
13150      kind: "includes",
13151      value: t,
13152      position: n?.position,
13153      ...se.errToObj(n?.message)
13154    });
13155  }
13156  startsWith(t, n) {
13157    return this._addCheck({
13158      kind: "startsWith",
13159      value: t,
13160      ...se.errToObj(n)
13161    });
13162  }
13163  endsWith(t, n) {
13164    return this._addCheck({
13165      kind: "endsWith",
13166      value: t,
13167      ...se.errToObj(n)
13168    });
13169  }
13170  min(t, n) {
13171    return this._addCheck({
13172      kind: "min",
13173      value: t,
13174      ...se.errToObj(n)
13175    });
13176  }
13177  max(t, n) {
13178    return this._addCheck({
13179      kind: "max",
13180      value: t,
13181      ...se.errToObj(n)
13182    });
13183  }
13184  length(t, n) {
13185    return this._addCheck({
13186      kind: "length",
13187      value: t,
13188      ...se.errToObj(n)
13189    });
13190  }
13191  /**
13192   * @deprecated Use z.string().min(1) instead.
13193   * @see {@link ZodString.min}
13194   */
13195  nonempty(t) {
13196    return this.min(1, se.errToObj(t));
13197  }
13198  trim() {
13199    return new Rt({
13200      ...this._def,
13201      checks: [...this._def.checks, { kind: "trim" }]
13202    });
13203  }
13204  toLowerCase() {
13205    return new Rt({
13206      ...this._def,
13207      checks: [...this._def.checks, { kind: "toLowerCase" }]
13208    });
13209  }
13210  toUpperCase() {
13211    return new Rt({
13212      ...this._def,
13213      checks: [...this._def.checks, { kind: "toUpperCase" }]
13214    });
13215  }
13216  get isDatetime() {
13217    return !!this._def.checks.find((t) => t.kind === "datetime");
13218  }
13219  get isEmail() {
13220    return !!this._def.checks.find((t) => t.kind === "email");
13221  }
13222  get isURL() {
13223    return !!this._def.checks.find((t) => t.kind === "url");
13224  }
13225  get isEmoji() {
13226    return !!this._def.checks.find((t) => t.kind === "emoji");
13227  }
13228  get isUUID() {
13229    return !!this._def.checks.find((t) => t.kind === "uuid");
13230  }
13231  get isCUID() {
13232    return !!this._def.checks.find((t) => t.kind === "cuid");
13233  }
13234  get isCUID2() {
13235    return !!this._def.checks.find((t) => t.kind === "cuid2");
13236  }
13237  get isULID() {
13238    return !!this._def.checks.find((t) => t.kind === "ulid");
13239  }
13240  get isIP() {
13241    return !!this._def.checks.find((t) => t.kind === "ip");
13242  }
13243  get minLength() {
13244    let t = null;
13245    for (const n of this._def.checks)
13246      n.kind === "min" && (t === null || n.value > t) && (t = n.value);
13247    return t;
13248  }
13249  get maxLength() {
13250    let t = null;
13251    for (const n of this._def.checks)
13252      n.kind === "max" && (t === null || n.value < t) && (t = n.value);
13253    return t;
13254  }
13255}
13256Rt.create = (e) => {
13257  var t;
13258  return new Rt({
13259    checks: [],
13260    typeName: oe.ZodString,
13261    coerce: (t = e?.coerce) !== null && t !== void 0 ? t : !1,
13262    ...he(e)
13263  });
13264};
13265function Ew(e, t) {
13266  const n = (e.toString().split(".")[1] || "").length, r = (t.toString().split(".")[1] || "").length, s = n > r ? n : r, i = parseInt(e.toFixed(s).replace(".", "")), o = parseInt(t.toFixed(s).replace(".", ""));
13267  return i % o / Math.pow(10, s);
13268}
13269class jn extends me {
13270  constructor() {
13271    super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
13272  }
13273  _parse(t) {
13274    if (this._def.coerce && (t.data = Number(t.data)), this._getType(t) !== G.number) {
13275      const i = this._getOrReturnCtx(t);
13276      return Y(i, {
13277        code: j.invalid_type,
13278        expected: G.number,
13279        received: i.parsedType
13280      }), le;
13281    }
13282    let r;
13283    const s = new nt();
13284    for (const i of this._def.checks)
13285      i.kind === "int" ? _e.isInteger(t.data) || (r = this._getOrReturnCtx(t, r), Y(r, {
13286        code: j.invalid_type,
13287        expected: "integer",
13288        received: "float",
13289        message: i.message
13290      }), s.dirty()) : i.kind === "min" ? (i.inclusive ? t.data < i.value : t.data <= i.value) && (r = this._getOrReturnCtx(t, r), Y(r, {
13291        code: j.too_small,
13292        minimum: i.value,
13293        type: "number",
13294        inclusive: i.inclusive,
13295        exact: !1,
13296        message: i.message
13297      }), s.dirty()) : i.kind === "max" ? (i.inclusive ? t.data > i.value : t.data >= i.value) && (r = this._getOrReturnCtx(t, r), Y(r, {
13298        code: j.too_big,
13299        maximum: i.value,
13300        type: "number",
13301        inclusive: i.inclusive,
13302        exact: !1,
13303        message: i.message
13304      }), s.dirty()) : i.kind === "multipleOf" ? Ew(t.data, i.value) !== 0 && (r = this._getOrReturnCtx(t, r), Y(r, {
13305        code: j.not_multiple_of,
13306        multipleOf: i.value,
13307        message: i.message
13308      }), s.dirty()) : i.kind === "finite" ? Number.isFinite(t.data) || (r = this._getOrReturnCtx(t, r), Y(r, {
13309        code: j.not_finite,
13310        message: i.message
13311      }), s.dirty()) : _e.assertNever(i);
13312    return { status: s.value, value: t.data };
13313  }
13314  gte(t, n) {
13315    return this.setLimit("min", t, !0, se.toString(n));
13316  }
13317  gt(t, n) {
13318    return this.setLimit("min", t, !1, se.toString(n));
13319  }
13320  lte(t, n) {
13321    return this.setLimit("max", t, !0, se.toString(n));
13322  }
13323  lt(t, n) {
13324    return this.setLimit("max", t, !1, se.toString(n));
13325  }
13326  setLimit(t, n, r, s) {
13327    return new jn({
13328      ...this._def,
13329      checks: [
13330        ...this._def.checks,
13331        {
13332          kind: t,
13333          value: n,
13334          inclusive: r,
13335          message: se.toString(s)
13336        }
13337      ]
13338    });
13339  }
13340  _addCheck(t) {
13341    return new jn({
13342      ...this._def,
13343      checks: [...this._def.checks, t]
13344    });
13345  }
13346  int(t) {
13347    return this._addCheck({
13348      kind: "int",
13349      message: se.toString(t)
13350    });
13351  }
13352  positive(t) {
13353    return this._addCheck({
13354      kind: "min",
13355      value: 0,
13356      inclusive: !1,
13357      message: se.toString(t)
13358    });
13359  }
13360  negative(t) {
13361    return this._addCheck({
13362      kind: "max",
13363      value: 0,
13364      inclusive: !1,
13365      message: se.toString(t)
13366    });
13367  }
13368  nonpositive(t) {
13369    return this._addCheck({
13370      kind: "max",
13371      value: 0,
13372      inclusive: !0,
13373      message: se.toString(t)
13374    });
13375  }
13376  nonnegative(t) {
13377    return this._addCheck({
13378      kind: "min",
13379      value: 0,
13380      inclusive: !0,
13381      message: se.toString(t)
13382    });
13383  }
13384  multipleOf(t, n) {
13385    return this._addCheck({
13386      kind: "multipleOf",
13387      value: t,
13388      message: se.toString(n)
13389    });
13390  }
13391  finite(t) {
13392    return this._addCheck({
13393      kind: "finite",
13394      message: se.toString(t)
13395    });
13396  }
13397  safe(t) {
13398    return this._addCheck({
13399      kind: "min",
13400      inclusive: !0,
13401      value: Number.MIN_SAFE_INTEGER,
13402      message: se.toString(t)
13403    })._addCheck({
13404      kind: "max",
13405      inclusive: !0,
13406      value: Number.MAX_SAFE_INTEGER,
13407      message: se.toString(t)
13408    });
13409  }
13410  get minValue() {
13411    let t = null;
13412    for (const n of this._def.checks)
13413      n.kind === "min" && (t === null || n.value > t) && (t = n.value);
13414    return t;
13415  }
13416  get maxValue() {
13417    let t = null;
13418    for (const n of this._def.checks)
13419      n.kind === "max" && (t === null || n.value < t) && (t = n.value);
13420    return t;
13421  }
13422  get isInt() {
13423    return !!this._def.checks.find((t) => t.kind === "int" || t.kind === "multipleOf" && _e.isInteger(t.value));
13424  }
13425  get isFinite() {
13426    let t = null, n = null;
13427    for (const r of this._def.checks) {
13428      if (r.kind === "finite" || r.kind === "int" || r.kind === "multipleOf")
13429        return !0;
13430      r.kind === "min" ? (n === null || r.value > n) && (n = r.value) : r.kind === "max" && (t === null || r.value < t) && (t = r.value);
13431    }
13432    return Number.isFinite(n) && Number.isFinite(t);
13433  }
13434}
13435jn.create = (e) => new jn({
13436  checks: [],
13437  typeName: oe.ZodNumber,
13438  coerce: e?.coerce || !1,
13439  ...he(e)
13440});
13441class Wn extends me {
13442  constructor() {
13443    super(...arguments), this.min = this.gte, this.max = this.lte;
13444  }
13445  _parse(t) {
13446    if (this._def.coerce && (t.data = BigInt(t.data)), this._getType(t) !== G.bigint) {
13447      const i = this._getOrReturnCtx(t);
13448      return Y(i, {
13449        code: j.invalid_type,
13450        expected: G.bigint,
13451        received: i.parsedType
13452      }), le;
13453    }
13454    let r;
13455    const s = new nt();
13456    for (const i of this._def.checks)
13457      i.kind === "min" ? (i.inclusive ? t.data < i.value : t.data <= i.value) && (r = this._getOrReturnCtx(t, r), Y(r, {
13458        code: j.too_small,
13459        type: "bigint",
13460        minimum: i.value,
13461        inclusive: i.inclusive,
13462        message: i.message
13463      }), s.dirty()) : i.kind === "max" ? (i.inclusive ? t.data > i.value : t.data >= i.value) && (r = this._getOrReturnCtx(t, r), Y(r, {
13464        code: j.too_big,
13465        type: "bigint",
13466        maximum: i.value,
13467        inclusive: i.inclusive,
13468        message: i.message
13469      }), s.dirty()) : i.kind === "multipleOf" ? t.data % i.value !== BigInt(0) && (r = this._getOrReturnCtx(t, r), Y(r, {
13470        code: j.not_multiple_of,
13471        multipleOf: i.value,
13472        message: i.message
13473      }), s.dirty()) : _e.assertNever(i);
13474    return { status: s.value, value: t.data };
13475  }
13476  gte(t, n) {
13477    return this.setLimit("min", t, !0, se.toString(n));
13478  }
13479  gt(t, n) {
13480    return this.setLimit("min", t, !1, se.toString(n));
13481  }
13482  lte(t, n) {
13483    return this.setLimit("max", t, !0, se.toString(n));
13484  }
13485  lt(t, n) {
13486    return this.setLimit("max", t, !1, se.toString(n));
13487  }
13488  setLimit(t, n, r, s) {
13489    return new Wn({
13490      ...this._def,
13491      checks: [
13492        ...this._def.checks,
13493        {
13494          kind: t,
13495          value: n,
13496          inclusive: r,
13497          message: se.toString(s)
13498        }
13499      ]
13500    });
13501  }
13502  _addCheck(t) {
13503    return new Wn({
13504      ...this._def,
13505      checks: [...this._def.checks, t]
13506    });
13507  }
13508  positive(t) {
13509    return this._addCheck({
13510      kind: "min",
13511      value: BigInt(0),
13512      inclusive: !1,
13513      message: se.toString(t)
13514    });
13515  }
13516  negative(t) {
13517    return this._addCheck({
13518      kind: "max",
13519      value: BigInt(0),
13520      inclusive: !1,
13521      message: se.toString(t)
13522    });
13523  }
13524  nonpositive(t) {
13525    return this._addCheck({
13526      kind: "max",
13527      value: BigInt(0),
13528      inclusive: !0,
13529      message: se.toString(t)
13530    });
13531  }
13532  nonnegative(t) {
13533    return this._addCheck({
13534      kind: "min",
13535      value: BigInt(0),
13536      inclusive: !0,
13537      message: se.toString(t)
13538    });
13539  }
13540  multipleOf(t, n) {
13541    return this._addCheck({
13542      kind: "multipleOf",
13543      value: t,
13544      message: se.toString(n)
13545    });
13546  }
13547  get minValue() {
13548    let t = null;
13549    for (const n of this._def.checks)
13550      n.kind === "min" && (t === null || n.value > t) && (t = n.value);
13551    return t;
13552  }
13553  get maxValue() {
13554    let t = null;
13555    for (const n of this._def.checks)
13556      n.kind === "max" && (t === null || n.value < t) && (t = n.value);
13557    return t;
13558  }
13559}
13560Wn.create = (e) => {
13561  var t;
13562  return new Wn({
13563    checks: [],
13564    typeName: oe.ZodBigInt,
13565    coerce: (t = e?.coerce) !== null && t !== void 0 ? t : !1,
13566    ...he(e)
13567  });
13568};
13569class Ss extends me {
13570  _parse(t) {
13571    if (this._def.coerce && (t.data = !!t.data), this._getType(t) !== G.boolean) {
13572      const r = this._getOrReturnCtx(t);
13573      return Y(r, {
13574        code: j.invalid_type,
13575        expected: G.boolean,
13576        received: r.parsedType
13577      }), le;
13578    }
13579    return at(t.data);
13580  }
13581}
13582Ss.create = (e) => new Ss({
13583  typeName: oe.ZodBoolean,
13584  coerce: e?.coerce || !1,
13585  ...he(e)
13586});
13587class ar extends me {
13588  _parse(t) {
13589    if (this._def.coerce && (t.data = new Date(t.data)), this._getType(t) !== G.date) {
13590      const i = this._getOrReturnCtx(t);
13591      return Y(i, {
13592        code: j.invalid_type,
13593        expected: G.date,
13594        received: i.parsedType
13595      }), le;
13596    }
13597    if (isNaN(t.data.getTime())) {
13598      const i = this._getOrReturnCtx(t);
13599      return Y(i, {
13600        code: j.invalid_date
13601      }), le;
13602    }
13603    const r = new nt();
13604    let s;
13605    for (const i of this._def.checks)
13606      i.kind === "min" ? t.data.getTime() < i.value && (s = this._getOrReturnCtx(t, s), Y(s, {
13607        code: j.too_small,
13608        message: i.message,
13609        inclusive: !0,
13610        exact: !1,
13611        minimum: i.value,
13612        type: "date"
13613      }), r.dirty()) : i.kind === "max" ? t.data.getTime() > i.value && (s = this._getOrReturnCtx(t, s), Y(s, {
13614        code: j.too_big,
13615        message: i.message,
13616        inclusive: !0,
13617        exact: !1,
13618        maximum: i.value,
13619        type: "date"
13620      }), r.dirty()) : _e.assertNever(i);
13621    return {
13622      status: r.value,
13623      value: new Date(t.data.getTime())
13624    };
13625  }
13626  _addCheck(t) {
13627    return new ar({
13628      ...this._def,
13629      checks: [...this._def.checks, t]
13630    });
13631  }
13632  min(t, n) {
13633    return this._addCheck({
13634      kind: "min",
13635      value: t.getTime(),
13636      message: se.toString(n)
13637    });
13638  }
13639  max(t, n) {
13640    return this._addCheck({
13641      kind: "max",
13642      value: t.getTime(),
13643      message: se.toString(n)
13644    });
13645  }
13646  get minDate() {
13647    let t = null;
13648    for (const n of this._def.checks)
13649      n.kind === "min" && (t === null || n.value > t) && (t = n.value);
13650    return t != null ? new Date(t) : null;
13651  }
13652  get maxDate() {
13653    let t = null;
13654    for (const n of this._def.checks)
13655      n.kind === "max" && (t === null || n.value < t) && (t = n.value);
13656    return t != null ? new Date(t) : null;
13657  }
13658}
13659ar.create = (e) => new ar({
13660  checks: [],
13661  coerce: e?.coerce || !1,
13662  typeName: oe.ZodDate,
13663  ...he(e)
13664});
13665class Qi extends me {
13666  _parse(t) {
13667    if (this._getType(t) !== G.symbol) {
13668      const r = this._getOrReturnCtx(t);
13669      return Y(r, {
13670        code: j.invalid_type,
13671        expected: G.symbol,
13672        received: r.parsedType
13673      }), le;
13674    }
13675    return at(t.data);
13676  }
13677}
13678Qi.create = (e) => new Qi({
13679  typeName: oe.ZodSymbol,
13680  ...he(e)
13681});
13682class Rs extends me {
13683  _parse(t) {
13684    if (this._getType(t) !== G.undefined) {
13685      const r = this._getOrReturnCtx(t);
13686      return Y(r, {
13687        code: j.invalid_type,
13688        expected: G.undefined,
13689        received: r.parsedType
13690      }), le;
13691    }
13692    return at(t.data);
13693  }
13694}
13695Rs.create = (e) => new Rs({
13696  typeName: oe.ZodUndefined,
13697  ...he(e)
13698});
13699class xs extends me {
13700  _parse(t) {
13701    if (this._getType(t) !== G.null) {
13702      const r = this._getOrReturnCtx(t);
13703      return Y(r, {
13704        code: j.invalid_type,
13705        expected: G.null,
13706        received: r.parsedType
13707      }), le;
13708    }
13709    return at(t.data);
13710  }
13711}
13712xs.create = (e) => new xs({
13713  typeName: oe.ZodNull,
13714  ...he(e)
13715});
13716class Fr extends me {
13717  constructor() {
13718    super(...arguments), this._any = !0;
13719  }
13720  _parse(t) {
13721    return at(t.data);
13722  }
13723}
13724Fr.create = (e) => new Fr({
13725  typeName: oe.ZodAny,
13726  ...he(e)
13727});
13728class er extends me {
13729  constructor() {
13730    super(...arguments), this._unknown = !0;
13731  }
13732  _parse(t) {
13733    return at(t.data);
13734  }
13735}
13736er.create = (e) => new er({
13737  typeName: oe.ZodUnknown,
13738  ...he(e)
13739});
13740class pn extends me {
13741  _parse(t) {
13742    const n = this._getOrReturnCtx(t);
13743    return Y(n, {
13744      code: j.invalid_type,
13745      expected: G.never,
13746      received: n.parsedType
13747    }), le;
13748  }
13749}
13750pn.create = (e) => new pn({
13751  typeName: oe.ZodNever,
13752  ...he(e)
13753});
13754class Ji extends me {
13755  _parse(t) {
13756    if (this._getType(t) !== G.undefined) {
13757      const r = this._getOrReturnCtx(t);
13758      return Y(r, {
13759        code: j.invalid_type,
13760        expected: G.void,
13761        received: r.parsedType
13762      }), le;
13763    }
13764    return at(t.data);
13765  }
13766}
13767Ji.create = (e) => new Ji({
13768  typeName: oe.ZodVoid,
13769  ...he(e)
13770});
13771class Ot extends me {
13772  _parse(t) {
13773    const { ctx: n, status: r } = this._processInputParams(t), s = this._def;
13774    if (n.parsedType !== G.array)
13775      return Y(n, {
13776        code: j.invalid_type,
13777        expected: G.array,
13778        received: n.parsedType
13779      }), le;
13780    if (s.exactLength !== null) {
13781      const o = n.data.length > s.exactLength.value, a = n.data.length < s.exactLength.value;
13782      (o || a) && (Y(n, {
13783        code: o ? j.too_big : j.too_small,
13784        minimum: a ? s.exactLength.value : void 0,
13785        maximum: o ? s.exactLength.value : void 0,
13786        type: "array",
13787        inclusive: !0,
13788        exact: !0,
13789        message: s.exactLength.message
13790      }), r.dirty());
13791    }
13792    if (s.minLength !== null && n.data.length < s.minLength.value && (Y(n, {
13793      code: j.too_small,
13794      minimum: s.minLength.value,
13795      type: "array",
13796      inclusive: !0,
13797      exact: !1,
13798      message: s.minLength.message
13799    }), r.dirty()), s.maxLength !== null && n.data.length > s.maxLength.value && (Y(n, {
13800      code: j.too_big,
13801      maximum: s.maxLength.value,
13802      type: "array",
13803      inclusive: !0,
13804      exact: !1,
13805      message: s.maxLength.message
13806    }), r.dirty()), n.common.async)
13807      return Promise.all([...n.data].map((o, a) => s.type._parseAsync(new Vt(n, o, n.path, a)))).then((o) => nt.mergeArray(r, o));
13808    const i = [...n.data].map((o, a) => s.type._parseSync(new Vt(n, o, n.path, a)));
13809    return nt.mergeArray(r, i);
13810  }
13811  get element() {
13812    return this._def.type;
13813  }
13814  min(t, n) {
13815    return new Ot({
13816      ...this._def,
13817      minLength: { value: t, message: se.toString(n) }
13818    });
13819  }
13820  max(t, n) {
13821    return new Ot({
13822      ...this._def,
13823      maxLength: { value: t, message: se.toString(n) }
13824    });
13825  }
13826  length(t, n) {
13827    return new Ot({
13828      ...this._def,
13829      exactLength: { value: t, message: se.toString(n) }
13830    });
13831  }
13832  nonempty(t) {
13833    return this.min(1, t);
13834  }
13835}
13836Ot.create = (e, t) => new Ot({
13837  type: e,
13838  minLength: null,
13839  maxLength: null,
13840  exactLength: null,
vendor: 33,660 bytes, lines 13841-15061
13841  typeName: oe.ZodArray,
13842  ...he(t)
13843});
13844function _r(e) {
13845  if (e instanceof Fe) {
13846    const t = {};
13847    for (const n in e.shape) {
13848      const r = e.shape[n];
13849      t[n] = fn.create(_r(r));
13850    }
13851    return new Fe({
13852      ...e._def,
13853      shape: () => t
13854    });
13855  } else return e instanceof Ot ? new Ot({
13856    ...e._def,
13857    type: _r(e.element)
13858  }) : e instanceof fn ? fn.create(_r(e.unwrap())) : e instanceof ur ? ur.create(_r(e.unwrap())) : e instanceof Kt ? Kt.create(e.items.map((t) => _r(t))) : e;
13859}
13860class Fe extends me {
13861  constructor() {
13862    super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
13863  }
13864  _getCached() {
13865    if (this._cached !== null)
13866      return this._cached;
13867    const t = this._def.shape(), n = _e.objectKeys(t);
13868    return this._cached = { shape: t, keys: n };
13869  }
13870  _parse(t) {
13871    if (this._getType(t) !== G.object) {
13872      const c = this._getOrReturnCtx(t);
13873      return Y(c, {
13874        code: j.invalid_type,
13875        expected: G.object,
13876        received: c.parsedType
13877      }), le;
13878    }
13879    const { status: r, ctx: s } = this._processInputParams(t), { shape: i, keys: o } = this._getCached(), a = [];
13880    if (!(this._def.catchall instanceof pn && this._def.unknownKeys === "strip"))
13881      for (const c in s.data)
13882        o.includes(c) || a.push(c);
13883    const u = [];
13884    for (const c of o) {
13885      const l = i[c], f = s.data[c];
13886      u.push({
13887        key: { status: "valid", value: c },
13888        value: l._parse(new Vt(s, f, s.path, c)),
13889        alwaysSet: c in s.data
13890      });
13891    }
13892    if (this._def.catchall instanceof pn) {
13893      const c = this._def.unknownKeys;
13894      if (c === "passthrough")
13895        for (const l of a)
13896          u.push({
13897            key: { status: "valid", value: l },
13898            value: { status: "valid", value: s.data[l] }
13899          });
13900      else if (c === "strict")
13901        a.length > 0 && (Y(s, {
13902          code: j.unrecognized_keys,
13903          keys: a
13904        }), r.dirty());
13905      else if (c !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
13906    } else {
13907      const c = this._def.catchall;
13908      for (const l of a) {
13909        const f = s.data[l];
13910        u.push({
13911          key: { status: "valid", value: l },
13912          value: c._parse(
13913            new Vt(s, f, s.path, l)
13914            //, ctx.child(key), value, getParsedType(value)
13915          ),
13916          alwaysSet: l in s.data
13917        });
13918      }
13919    }
13920    return s.common.async ? Promise.resolve().then(async () => {
13921      const c = [];
13922      for (const l of u) {
13923        const f = await l.key;
13924        c.push({
13925          key: f,
13926          value: await l.value,
13927          alwaysSet: l.alwaysSet
13928        });
13929      }
13930      return c;
13931    }).then((c) => nt.mergeObjectSync(r, c)) : nt.mergeObjectSync(r, u);
13932  }
13933  get shape() {
13934    return this._def.shape();
13935  }
13936  strict(t) {
13937    return se.errToObj, new Fe({
13938      ...this._def,
13939      unknownKeys: "strict",
13940      ...t !== void 0 ? {
13941        errorMap: (n, r) => {
13942          var s, i, o, a;
13943          const u = (o = (i = (s = this._def).errorMap) === null || i === void 0 ? void 0 : i.call(s, n, r).message) !== null && o !== void 0 ? o : r.defaultError;
13944          return n.code === "unrecognized_keys" ? {
13945            message: (a = se.errToObj(t).message) !== null && a !== void 0 ? a : u
13946          } : {
13947            message: u
13948          };
13949        }
13950      } : {}
13951    });
13952  }
13953  strip() {
13954    return new Fe({
13955      ...this._def,
13956      unknownKeys: "strip"
13957    });
13958  }
13959  passthrough() {
13960    return new Fe({
13961      ...this._def,
13962      unknownKeys: "passthrough"
13963    });
13964  }
13965  // const AugmentFactory =
13966  //   <Def extends ZodObjectDef>(def: Def) =>
13967  //   <Augmentation extends ZodRawShape>(
13968  //     augmentation: Augmentation
13969  //   ): ZodObject<
13970  //     extendShape<ReturnType<Def["shape"]>, Augmentation>,
13971  //     Def["unknownKeys"],
13972  //     Def["catchall"]
13973  //   > => {
13974  //     return new ZodObject({
13975  //       ...def,
13976  //       shape: () => ({
13977  //         ...def.shape(),
13978  //         ...augmentation,
13979  //       }),
13980  //     }) as any;
13981  //   };
13982  extend(t) {
13983    return new Fe({
13984      ...this._def,
13985      shape: () => ({
13986        ...this._def.shape(),
13987        ...t
13988      })
13989    });
13990  }
13991  /**
13992   * Prior to [email protected] there was a bug in the
13993   * inferred type of merged objects. Please
13994   * upgrade if you are experiencing issues.
13995   */
13996  merge(t) {
13997    return new Fe({
13998      unknownKeys: t._def.unknownKeys,
13999      catchall: t._def.catchall,
14000      shape: () => ({
14001        ...this._def.shape(),
14002        ...t._def.shape()
14003      }),
14004      typeName: oe.ZodObject
14005    });
14006  }
14007  // merge<
14008  //   Incoming extends AnyZodObject,
14009  //   Augmentation extends Incoming["shape"],
14010  //   NewOutput extends {
14011  //     [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
14012  //       ? Augmentation[k]["_output"]
14013  //       : k extends keyof Output
14014  //       ? Output[k]
14015  //       : never;
14016  //   },
14017  //   NewInput extends {
14018  //     [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
14019  //       ? Augmentation[k]["_input"]
14020  //       : k extends keyof Input
14021  //       ? Input[k]
14022  //       : never;
14023  //   }
14024  // >(
14025  //   merging: Incoming
14026  // ): ZodObject<
14027  //   extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
14028  //   Incoming["_def"]["unknownKeys"],
14029  //   Incoming["_def"]["catchall"],
14030  //   NewOutput,
14031  //   NewInput
14032  // > {
14033  //   const merged: any = new ZodObject({
14034  //     unknownKeys: merging._def.unknownKeys,
14035  //     catchall: merging._def.catchall,
14036  //     shape: () =>
14037  //       objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
14038  //     typeName: ZodFirstPartyTypeKind.ZodObject,
14039  //   }) as any;
14040  //   return merged;
14041  // }
14042  setKey(t, n) {
14043    return this.augment({ [t]: n });
14044  }
14045  // merge<Incoming extends AnyZodObject>(
14046  //   merging: Incoming
14047  // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
14048  // ZodObject<
14049  //   extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
14050  //   Incoming["_def"]["unknownKeys"],
14051  //   Incoming["_def"]["catchall"]
14052  // > {
14053  //   // const mergedShape = objectUtil.mergeShapes(
14054  //   //   this._def.shape(),
14055  //   //   merging._def.shape()
14056  //   // );
14057  //   const merged: any = new ZodObject({
14058  //     unknownKeys: merging._def.unknownKeys,
14059  //     catchall: merging._def.catchall,
14060  //     shape: () =>
14061  //       objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
14062  //     typeName: ZodFirstPartyTypeKind.ZodObject,
14063  //   }) as any;
14064  //   return merged;
14065  // }
14066  catchall(t) {
14067    return new Fe({
14068      ...this._def,
14069      catchall: t
14070    });
14071  }
14072  pick(t) {
14073    const n = {};
14074    return _e.objectKeys(t).forEach((r) => {
14075      t[r] && this.shape[r] && (n[r] = this.shape[r]);
14076    }), new Fe({
14077      ...this._def,
14078      shape: () => n
14079    });
14080  }
14081  omit(t) {
14082    const n = {};
14083    return _e.objectKeys(this.shape).forEach((r) => {
14084      t[r] || (n[r] = this.shape[r]);
14085    }), new Fe({
14086      ...this._def,
14087      shape: () => n
14088    });
14089  }
14090  /**
14091   * @deprecated
14092   */
14093  deepPartial() {
14094    return _r(this);
14095  }
14096  partial(t) {
14097    const n = {};
14098    return _e.objectKeys(this.shape).forEach((r) => {
14099      const s = this.shape[r];
14100      t && !t[r] ? n[r] = s : n[r] = s.optional();
14101    }), new Fe({
14102      ...this._def,
14103      shape: () => n
14104    });
14105  }
14106  required(t) {
14107    const n = {};
14108    return _e.objectKeys(this.shape).forEach((r) => {
14109      if (t && !t[r])
14110        n[r] = this.shape[r];
14111      else {
14112        let i = this.shape[r];
14113        for (; i instanceof fn; )
14114          i = i._def.innerType;
14115        n[r] = i;
14116      }
14117    }), new Fe({
14118      ...this._def,
14119      shape: () => n
14120    });
14121  }
14122  keyof() {
14123    return Cf(_e.objectKeys(this.shape));
14124  }
14125}
14126Fe.create = (e, t) => new Fe({
14127  shape: () => e,
14128  unknownKeys: "strip",
14129  catchall: pn.create(),
14130  typeName: oe.ZodObject,
14131  ...he(t)
14132});
14133Fe.strictCreate = (e, t) => new Fe({
14134  shape: () => e,
14135  unknownKeys: "strict",
14136  catchall: pn.create(),
14137  typeName: oe.ZodObject,
14138  ...he(t)
14139});
14140Fe.lazycreate = (e, t) => new Fe({
14141  shape: e,
14142  unknownKeys: "strip",
14143  catchall: pn.create(),
14144  typeName: oe.ZodObject,
14145  ...he(t)
14146});
14147class Os extends me {
14148  _parse(t) {
14149    const { ctx: n } = this._processInputParams(t), r = this._def.options;
14150    function s(i) {
14151      for (const a of i)
14152        if (a.result.status === "valid")
14153          return a.result;
14154      for (const a of i)
14155        if (a.result.status === "dirty")
14156          return n.common.issues.push(...a.ctx.common.issues), a.result;
14157      const o = i.map((a) => new xt(a.ctx.common.issues));
14158      return Y(n, {
14159        code: j.invalid_union,
14160        unionErrors: o
14161      }), le;
14162    }
14163    if (n.common.async)
14164      return Promise.all(r.map(async (i) => {
14165        const o = {
14166          ...n,
14167          common: {
14168            ...n.common,
14169            issues: []
14170          },
14171          parent: null
14172        };
14173        return {
14174          result: await i._parseAsync({
14175            data: n.data,
14176            path: n.path,
14177            parent: o
14178          }),
14179          ctx: o
14180        };
14181      })).then(s);
14182    {
14183      let i;
14184      const o = [];
14185      for (const u of r) {
14186        const c = {
14187          ...n,
14188          common: {
14189            ...n.common,
14190            issues: []
14191          },
14192          parent: null
14193        }, l = u._parseSync({
14194          data: n.data,
14195          path: n.path,
14196          parent: c
14197        });
14198        if (l.status === "valid")
14199          return l;
14200        l.status === "dirty" && !i && (i = { result: l, ctx: c }), c.common.issues.length && o.push(c.common.issues);
14201      }
14202      if (i)
14203        return n.common.issues.push(...i.ctx.common.issues), i.result;
14204      const a = o.map((u) => new xt(u));
14205      return Y(n, {
14206        code: j.invalid_union,
14207        unionErrors: a
14208      }), le;
14209    }
14210  }
14211  get options() {
14212    return this._def.options;
14213  }
14214}
14215Os.create = (e, t) => new Os({
14216  options: e,
14217  typeName: oe.ZodUnion,
14218  ...he(t)
14219});
14220const Ti = (e) => e instanceof Us ? Ti(e.schema) : e instanceof kt ? Ti(e.innerType()) : e instanceof Ms ? [e.value] : e instanceof $n ? e.options : e instanceof Ls ? Object.keys(e.enum) : e instanceof Bs ? Ti(e._def.innerType) : e instanceof Rs ? [void 0] : e instanceof xs ? [null] : null;
14221class Co extends me {
14222  _parse(t) {
14223    const { ctx: n } = this._processInputParams(t);
14224    if (n.parsedType !== G.object)
14225      return Y(n, {
14226        code: j.invalid_type,
14227        expected: G.object,
14228        received: n.parsedType
14229      }), le;
14230    const r = this.discriminator, s = n.data[r], i = this.optionsMap.get(s);
14231    return i ? n.common.async ? i._parseAsync({
14232      data: n.data,
14233      path: n.path,
14234      parent: n
14235    }) : i._parseSync({
14236      data: n.data,
14237      path: n.path,
14238      parent: n
14239    }) : (Y(n, {
14240      code: j.invalid_union_discriminator,
14241      options: Array.from(this.optionsMap.keys()),
14242      path: [r]
14243    }), le);
14244  }
14245  get discriminator() {
14246    return this._def.discriminator;
14247  }
14248  get options() {
14249    return this._def.options;
14250  }
14251  get optionsMap() {
14252    return this._def.optionsMap;
14253  }
14254  /**
14255   * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
14256   * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
14257   * have a different value for each object in the union.
14258   * @param discriminator the name of the discriminator property
14259   * @param types an array of object schemas
14260   * @param params
14261   */
14262  static create(t, n, r) {
14263    const s = /* @__PURE__ */ new Map();
14264    for (const i of n) {
14265      const o = Ti(i.shape[t]);
14266      if (!o)
14267        throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);
14268      for (const a of o) {
14269        if (s.has(a))
14270          throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);
14271        s.set(a, i);
14272      }
14273    }
14274    return new Co({
14275      typeName: oe.ZodDiscriminatedUnion,
14276      discriminator: t,
14277      options: n,
14278      optionsMap: s,
14279      ...he(r)
14280    });
14281  }
14282}
14283function Ma(e, t) {
14284  const n = In(e), r = In(t);
14285  if (e === t)
14286    return { valid: !0, data: e };
14287  if (n === G.object && r === G.object) {
14288    const s = _e.objectKeys(t), i = _e.objectKeys(e).filter((a) => s.indexOf(a) !== -1), o = { ...e, ...t };
14289    for (const a of i) {
14290      const u = Ma(e[a], t[a]);
14291      if (!u.valid)
14292        return { valid: !1 };
14293      o[a] = u.data;
14294    }
14295    return { valid: !0, data: o };
14296  } else if (n === G.array && r === G.array) {
14297    if (e.length !== t.length)
14298      return { valid: !1 };
14299    const s = [];
14300    for (let i = 0; i < e.length; i++) {
14301      const o = e[i], a = t[i], u = Ma(o, a);
14302      if (!u.valid)
14303        return { valid: !1 };
14304      s.push(u.data);
14305    }
14306    return { valid: !0, data: s };
14307  } else return n === G.date && r === G.date && +e == +t ? { valid: !0, data: e } : { valid: !1 };
14308}
14309class Ps extends me {
14310  _parse(t) {
14311    const { status: n, ctx: r } = this._processInputParams(t), s = (i, o) => {
14312      if (ka(i) || ka(o))
14313        return le;
14314      const a = Ma(i.value, o.value);
14315      return a.valid ? ((Ua(i) || Ua(o)) && n.dirty(), { status: n.value, value: a.data }) : (Y(r, {
14316        code: j.invalid_intersection_types
14317      }), le);
14318    };
14319    return r.common.async ? Promise.all([
14320      this._def.left._parseAsync({
14321        data: r.data,
14322        path: r.path,
14323        parent: r
14324      }),
14325      this._def.right._parseAsync({
14326        data: r.data,
14327        path: r.path,
14328        parent: r
14329      })
14330    ]).then(([i, o]) => s(i, o)) : s(this._def.left._parseSync({
14331      data: r.data,
14332      path: r.path,
14333      parent: r
14334    }), this._def.right._parseSync({
14335      data: r.data,
14336      path: r.path,
14337      parent: r
14338    }));
14339  }
14340}
14341Ps.create = (e, t, n) => new Ps({
14342  left: e,
14343  right: t,
14344  typeName: oe.ZodIntersection,
14345  ...he(n)
14346});
14347class Kt extends me {
14348  _parse(t) {
14349    const { status: n, ctx: r } = this._processInputParams(t);
14350    if (r.parsedType !== G.array)
14351      return Y(r, {
14352        code: j.invalid_type,
14353        expected: G.array,
14354        received: r.parsedType
14355      }), le;
14356    if (r.data.length < this._def.items.length)
14357      return Y(r, {
14358        code: j.too_small,
14359        minimum: this._def.items.length,
14360        inclusive: !0,
14361        exact: !1,
14362        type: "array"
14363      }), le;
14364    !this._def.rest && r.data.length > this._def.items.length && (Y(r, {
14365      code: j.too_big,
14366      maximum: this._def.items.length,
14367      inclusive: !0,
14368      exact: !1,
14369      type: "array"
14370    }), n.dirty());
14371    const i = [...r.data].map((o, a) => {
14372      const u = this._def.items[a] || this._def.rest;
14373      return u ? u._parse(new Vt(r, o, r.path, a)) : null;
14374    }).filter((o) => !!o);
14375    return r.common.async ? Promise.all(i).then((o) => nt.mergeArray(n, o)) : nt.mergeArray(n, i);
14376  }
14377  get items() {
14378    return this._def.items;
14379  }
14380  rest(t) {
14381    return new Kt({
14382      ...this._def,
14383      rest: t
14384    });
14385  }
14386}
14387Kt.create = (e, t) => {
14388  if (!Array.isArray(e))
14389    throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
14390  return new Kt({
14391    items: e,
14392    typeName: oe.ZodTuple,
14393    rest: null,
14394    ...he(t)
14395  });
14396};
14397class ks extends me {
14398  get keySchema() {
14399    return this._def.keyType;
14400  }
14401  get valueSchema() {
14402    return this._def.valueType;
14403  }
14404  _parse(t) {
14405    const { status: n, ctx: r } = this._processInputParams(t);
14406    if (r.parsedType !== G.object)
14407      return Y(r, {
14408        code: j.invalid_type,
14409        expected: G.object,
14410        received: r.parsedType
14411      }), le;
14412    const s = [], i = this._def.keyType, o = this._def.valueType;
14413    for (const a in r.data)
14414      s.push({
14415        key: i._parse(new Vt(r, a, r.path, a)),
14416        value: o._parse(new Vt(r, r.data[a], r.path, a))
14417      });
14418    return r.common.async ? nt.mergeObjectAsync(n, s) : nt.mergeObjectSync(n, s);
14419  }
14420  get element() {
14421    return this._def.valueType;
14422  }
14423  static create(t, n, r) {
14424    return n instanceof me ? new ks({
14425      keyType: t,
14426      valueType: n,
14427      typeName: oe.ZodRecord,
14428      ...he(r)
14429    }) : new ks({
14430      keyType: Rt.create(),
14431      valueType: t,
14432      typeName: oe.ZodRecord,
14433      ...he(n)
14434    });
14435  }
14436}
14437class Xi extends me {
14438  get keySchema() {
14439    return this._def.keyType;
14440  }
14441  get valueSchema() {
14442    return this._def.valueType;
14443  }
14444  _parse(t) {
14445    const { status: n, ctx: r } = this._processInputParams(t);
14446    if (r.parsedType !== G.map)
14447      return Y(r, {
14448        code: j.invalid_type,
14449        expected: G.map,
14450        received: r.parsedType
14451      }), le;
14452    const s = this._def.keyType, i = this._def.valueType, o = [...r.data.entries()].map(([a, u], c) => ({
14453      key: s._parse(new Vt(r, a, r.path, [c, "key"])),
14454      value: i._parse(new Vt(r, u, r.path, [c, "value"]))
14455    }));
14456    if (r.common.async) {
14457      const a = /* @__PURE__ */ new Map();
14458      return Promise.resolve().then(async () => {
14459        for (const u of o) {
14460          const c = await u.key, l = await u.value;
14461          if (c.status === "aborted" || l.status === "aborted")
14462            return le;
14463          (c.status === "dirty" || l.status === "dirty") && n.dirty(), a.set(c.value, l.value);
14464        }
14465        return { status: n.value, value: a };
14466      });
14467    } else {
14468      const a = /* @__PURE__ */ new Map();
14469      for (const u of o) {
14470        const c = u.key, l = u.value;
14471        if (c.status === "aborted" || l.status === "aborted")
14472          return le;
14473        (c.status === "dirty" || l.status === "dirty") && n.dirty(), a.set(c.value, l.value);
14474      }
14475      return { status: n.value, value: a };
14476    }
14477  }
14478}
14479Xi.create = (e, t, n) => new Xi({
14480  valueType: t,
14481  keyType: e,
14482  typeName: oe.ZodMap,
14483  ...he(n)
14484});
14485class cr extends me {
14486  _parse(t) {
14487    const { status: n, ctx: r } = this._processInputParams(t);
14488    if (r.parsedType !== G.set)
14489      return Y(r, {
14490        code: j.invalid_type,
14491        expected: G.set,
14492        received: r.parsedType
14493      }), le;
14494    const s = this._def;
14495    s.minSize !== null && r.data.size < s.minSize.value && (Y(r, {
14496      code: j.too_small,
14497      minimum: s.minSize.value,
14498      type: "set",
14499      inclusive: !0,
14500      exact: !1,
14501      message: s.minSize.message
14502    }), n.dirty()), s.maxSize !== null && r.data.size > s.maxSize.value && (Y(r, {
14503      code: j.too_big,
14504      maximum: s.maxSize.value,
14505      type: "set",
14506      inclusive: !0,
14507      exact: !1,
14508      message: s.maxSize.message
14509    }), n.dirty());
14510    const i = this._def.valueType;
14511    function o(u) {
14512      const c = /* @__PURE__ */ new Set();
14513      for (const l of u) {
14514        if (l.status === "aborted")
14515          return le;
14516        l.status === "dirty" && n.dirty(), c.add(l.value);
14517      }
14518      return { status: n.value, value: c };
14519    }
14520    const a = [...r.data.values()].map((u, c) => i._parse(new Vt(r, u, r.path, c)));
14521    return r.common.async ? Promise.all(a).then((u) => o(u)) : o(a);
14522  }
14523  min(t, n) {
14524    return new cr({
14525      ...this._def,
14526      minSize: { value: t, message: se.toString(n) }
14527    });
14528  }
14529  max(t, n) {
14530    return new cr({
14531      ...this._def,
14532      maxSize: { value: t, message: se.toString(n) }
14533    });
14534  }
14535  size(t, n) {
14536    return this.min(t, n).max(t, n);
14537  }
14538  nonempty(t) {
14539    return this.min(1, t);
14540  }
14541}
14542cr.create = (e, t) => new cr({
14543  valueType: e,
14544  minSize: null,
14545  maxSize: null,
14546  typeName: oe.ZodSet,
14547  ...he(t)
14548});
14549class Sr extends me {
14550  constructor() {
14551    super(...arguments), this.validate = this.implement;
14552  }
14553  _parse(t) {
14554    const { ctx: n } = this._processInputParams(t);
14555    if (n.parsedType !== G.function)
14556      return Y(n, {
14557        code: j.invalid_type,
14558        expected: G.function,
14559        received: n.parsedType
14560      }), le;
14561    function r(a, u) {
14562      return Yi({
14563        data: a,
14564        path: n.path,
14565        errorMaps: [
14566          n.common.contextualErrorMap,
14567          n.schemaErrorMap,
14568          Ki(),
14569          Is
14570        ].filter((c) => !!c),
14571        issueData: {
14572          code: j.invalid_arguments,
14573          argumentsError: u
14574        }
14575      });
14576    }
14577    function s(a, u) {
14578      return Yi({
14579        data: a,
14580        path: n.path,
14581        errorMaps: [
14582          n.common.contextualErrorMap,
14583          n.schemaErrorMap,
14584          Ki(),
14585          Is
14586        ].filter((c) => !!c),
14587        issueData: {
14588          code: j.invalid_return_type,
14589          returnTypeError: u
14590        }
14591      });
14592    }
14593    const i = { errorMap: n.common.contextualErrorMap }, o = n.data;
14594    if (this._def.returns instanceof jr) {
14595      const a = this;
14596      return at(async function(...u) {
14597        const c = new xt([]), l = await a._def.args.parseAsync(u, i).catch((m) => {
14598          throw c.addIssue(r(u, m)), c;
14599        }), f = await Reflect.apply(o, this, l);
14600        return await a._def.returns._def.type.parseAsync(f, i).catch((m) => {
14601          throw c.addIssue(s(f, m)), c;
14602        });
14603      });
14604    } else {
14605      const a = this;
14606      return at(function(...u) {
14607        const c = a._def.args.safeParse(u, i);
14608        if (!c.success)
14609          throw new xt([r(u, c.error)]);
14610        const l = Reflect.apply(o, this, c.data), f = a._def.returns.safeParse(l, i);
14611        if (!f.success)
14612          throw new xt([s(l, f.error)]);
14613        return f.data;
14614      });
14615    }
14616  }
14617  parameters() {
14618    return this._def.args;
14619  }
14620  returnType() {
14621    return this._def.returns;
14622  }
14623  args(...t) {
14624    return new Sr({
14625      ...this._def,
14626      args: Kt.create(t).rest(er.create())
14627    });
14628  }
14629  returns(t) {
14630    return new Sr({
14631      ...this._def,
14632      returns: t
14633    });
14634  }
14635  implement(t) {
14636    return this.parse(t);
14637  }
14638  strictImplement(t) {
14639    return this.parse(t);
14640  }
14641  static create(t, n, r) {
14642    return new Sr({
14643      args: t || Kt.create([]).rest(er.create()),
14644      returns: n || er.create(),
14645      typeName: oe.ZodFunction,
14646      ...he(r)
14647    });
14648  }
14649}
14650class Us extends me {
14651  get schema() {
14652    return this._def.getter();
14653  }
14654  _parse(t) {
14655    const { ctx: n } = this._processInputParams(t);
14656    return this._def.getter()._parse({ data: n.data, path: n.path, parent: n });
14657  }
14658}
14659Us.create = (e, t) => new Us({
14660  getter: e,
14661  typeName: oe.ZodLazy,
14662  ...he(t)
14663});
14664class Ms extends me {
14665  _parse(t) {
14666    if (t.data !== this._def.value) {
14667      const n = this._getOrReturnCtx(t);
14668      return Y(n, {
14669        received: n.data,
14670        code: j.invalid_literal,
14671        expected: this._def.value
14672      }), le;
14673    }
14674    return { status: "valid", value: t.data };
14675  }
14676  get value() {
14677    return this._def.value;
14678  }
14679}
14680Ms.create = (e, t) => new Ms({
14681  value: e,
14682  typeName: oe.ZodLiteral,
14683  ...he(t)
14684});
14685function Cf(e, t) {
14686  return new $n({
14687    values: e,
14688    typeName: oe.ZodEnum,
14689    ...he(t)
14690  });
14691}
14692class $n extends me {
14693  _parse(t) {
14694    if (typeof t.data != "string") {
14695      const n = this._getOrReturnCtx(t), r = this._def.values;
14696      return Y(n, {
14697        expected: _e.joinValues(r),
14698        received: n.parsedType,
14699        code: j.invalid_type
14700      }), le;
14701    }
14702    if (this._def.values.indexOf(t.data) === -1) {
14703      const n = this._getOrReturnCtx(t), r = this._def.values;
14704      return Y(n, {
14705        received: n.data,
14706        code: j.invalid_enum_value,
14707        options: r
14708      }), le;
14709    }
14710    return at(t.data);
14711  }
14712  get options() {
14713    return this._def.values;
14714  }
14715  get enum() {
14716    const t = {};
14717    for (const n of this._def.values)
14718      t[n] = n;
14719    return t;
14720  }
14721  get Values() {
14722    const t = {};
14723    for (const n of this._def.values)
14724      t[n] = n;
14725    return t;
14726  }
14727  get Enum() {
14728    const t = {};
14729    for (const n of this._def.values)
14730      t[n] = n;
14731    return t;
14732  }
14733  extract(t) {
14734    return $n.create(t);
14735  }
14736  exclude(t) {
14737    return $n.create(this.options.filter((n) => !t.includes(n)));
14738  }
14739}
14740$n.create = Cf;
14741class Ls extends me {
14742  _parse(t) {
14743    const n = _e.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(t);
14744    if (r.parsedType !== G.string && r.parsedType !== G.number) {
14745      const s = _e.objectValues(n);
14746      return Y(r, {
14747        expected: _e.joinValues(s),
14748        received: r.parsedType,
14749        code: j.invalid_type
14750      }), le;
14751    }
14752    if (n.indexOf(t.data) === -1) {
14753      const s = _e.objectValues(n);
14754      return Y(r, {
14755        received: r.data,
14756        code: j.invalid_enum_value,
14757        options: s
14758      }), le;
14759    }
14760    return at(t.data);
14761  }
14762  get enum() {
14763    return this._def.values;
14764  }
14765}
14766Ls.create = (e, t) => new Ls({
14767  values: e,
14768  typeName: oe.ZodNativeEnum,
14769  ...he(t)
14770});
14771class jr extends me {
14772  unwrap() {
14773    return this._def.type;
14774  }
14775  _parse(t) {
14776    const { ctx: n } = this._processInputParams(t);
14777    if (n.parsedType !== G.promise && n.common.async === !1)
14778      return Y(n, {
14779        code: j.invalid_type,
14780        expected: G.promise,
14781        received: n.parsedType
14782      }), le;
14783    const r = n.parsedType === G.promise ? n.data : Promise.resolve(n.data);
14784    return at(r.then((s) => this._def.type.parseAsync(s, {
14785      path: n.path,
14786      errorMap: n.common.contextualErrorMap
14787    })));
14788  }
14789}
14790jr.create = (e, t) => new jr({
14791  type: e,
14792  typeName: oe.ZodPromise,
14793  ...he(t)
14794});
14795class kt extends me {
14796  innerType() {
14797    return this._def.schema;
14798  }
14799  sourceType() {
14800    return this._def.schema._def.typeName === oe.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
14801  }
14802  _parse(t) {
14803    const { status: n, ctx: r } = this._processInputParams(t), s = this._def.effect || null, i = {
14804      addIssue: (o) => {
14805        Y(r, o), o.fatal ? n.abort() : n.dirty();
14806      },
14807      get path() {
14808        return r.path;
14809      }
14810    };
14811    if (i.addIssue = i.addIssue.bind(i), s.type === "preprocess") {
14812      const o = s.transform(r.data, i);
14813      return r.common.issues.length ? {
14814        status: "dirty",
14815        value: r.data
14816      } : r.common.async ? Promise.resolve(o).then((a) => this._def.schema._parseAsync({
14817        data: a,
14818        path: r.path,
14819        parent: r
14820      })) : this._def.schema._parseSync({
14821        data: o,
14822        path: r.path,
14823        parent: r
14824      });
14825    }
14826    if (s.type === "refinement") {
14827      const o = (a) => {
14828        const u = s.refinement(a, i);
14829        if (r.common.async)
14830          return Promise.resolve(u);
14831        if (u instanceof Promise)
14832          throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
14833        return a;
14834      };
14835      if (r.common.async === !1) {
14836        const a = this._def.schema._parseSync({
14837          data: r.data,
14838          path: r.path,
14839          parent: r
14840        });
14841        return a.status === "aborted" ? le : (a.status === "dirty" && n.dirty(), o(a.value), { status: n.value, value: a.value });
14842      } else
14843        return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((a) => a.status === "aborted" ? le : (a.status === "dirty" && n.dirty(), o(a.value).then(() => ({ status: n.value, value: a.value }))));
14844    }
14845    if (s.type === "transform")
14846      if (r.common.async === !1) {
14847        const o = this._def.schema._parseSync({
14848          data: r.data,
14849          path: r.path,
14850          parent: r
14851        });
14852        if (!Ts(o))
14853          return o;
14854        const a = s.transform(o.value, i);
14855        if (a instanceof Promise)
14856          throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
14857        return { status: n.value, value: a };
14858      } else
14859        return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((o) => Ts(o) ? Promise.resolve(s.transform(o.value, i)).then((a) => ({ status: n.value, value: a })) : o);
14860    _e.assertNever(s);
14861  }
14862}
14863kt.create = (e, t, n) => new kt({
14864  schema: e,
14865  typeName: oe.ZodEffects,
14866  effect: t,
14867  ...he(n)
14868});
14869kt.createWithPreprocess = (e, t, n) => new kt({
14870  schema: t,
14871  effect: { type: "preprocess", transform: e },
14872  typeName: oe.ZodEffects,
14873  ...he(n)
14874});
14875class fn extends me {
14876  _parse(t) {
14877    return this._getType(t) === G.undefined ? at(void 0) : this._def.innerType._parse(t);
14878  }
14879  unwrap() {
14880    return this._def.innerType;
14881  }
14882}
14883fn.create = (e, t) => new fn({
14884  innerType: e,
14885  typeName: oe.ZodOptional,
14886  ...he(t)
14887});
14888class ur extends me {
14889  _parse(t) {
14890    return this._getType(t) === G.null ? at(null) : this._def.innerType._parse(t);
14891  }
14892  unwrap() {
14893    return this._def.innerType;
14894  }
14895}
14896ur.create = (e, t) => new ur({
14897  innerType: e,
14898  typeName: oe.ZodNullable,
14899  ...he(t)
14900});
14901class Bs extends me {
14902  _parse(t) {
14903    const { ctx: n } = this._processInputParams(t);
14904    let r = n.data;
14905    return n.parsedType === G.undefined && (r = this._def.defaultValue()), this._def.innerType._parse({
14906      data: r,
14907      path: n.path,
14908      parent: n
14909    });
14910  }
14911  removeDefault() {
14912    return this._def.innerType;
14913  }
14914}
14915Bs.create = (e, t) => new Bs({
14916  innerType: e,
14917  typeName: oe.ZodDefault,
14918  defaultValue: typeof t.default == "function" ? t.default : () => t.default,
14919  ...he(t)
14920});
14921class eo extends me {
14922  _parse(t) {
14923    const { ctx: n } = this._processInputParams(t), r = {
14924      ...n,
14925      common: {
14926        ...n.common,
14927        issues: []
14928      }
14929    }, s = this._def.innerType._parse({
14930      data: r.data,
14931      path: r.path,
14932      parent: {
14933        ...r
14934      }
14935    });
14936    return Zi(s) ? s.then((i) => ({
14937      status: "valid",
14938      value: i.status === "valid" ? i.value : this._def.catchValue({
14939        get error() {
14940          return new xt(r.common.issues);
14941        },
14942        input: r.data
14943      })
14944    })) : {
14945      status: "valid",
14946      value: s.status === "valid" ? s.value : this._def.catchValue({
14947        get error() {
14948          return new xt(r.common.issues);
14949        },
14950        input: r.data
14951      })
14952    };
14953  }
14954  removeCatch() {
14955    return this._def.innerType;
14956  }
14957}
14958eo.create = (e, t) => new eo({
14959  innerType: e,
14960  typeName: oe.ZodCatch,
14961  catchValue: typeof t.catch == "function" ? t.catch : () => t.catch,
14962  ...he(t)
14963});
14964class to extends me {
14965  _parse(t) {
14966    if (this._getType(t) !== G.nan) {
14967      const r = this._getOrReturnCtx(t);
14968      return Y(r, {
14969        code: j.invalid_type,
14970        expected: G.nan,
14971        received: r.parsedType
14972      }), le;
14973    }
14974    return { status: "valid", value: t.data };
14975  }
14976}
14977to.create = (e) => new to({
14978  typeName: oe.ZodNaN,
14979  ...he(e)
14980});
14981const Aw = /* @__PURE__ */ Symbol("zod_brand");
14982class Ef extends me {
14983  _parse(t) {
14984    const { ctx: n } = this._processInputParams(t), r = n.data;
14985    return this._def.type._parse({
14986      data: r,
14987      path: n.path,
14988      parent: n
14989    });
14990  }
14991  unwrap() {
14992    return this._def.type;
14993  }
14994}
14995class Js extends me {
14996  _parse(t) {
14997    const { status: n, ctx: r } = this._processInputParams(t);
14998    if (r.common.async)
14999      return (async () => {
15000        const i = await this._def.in._parseAsync({
15001          data: r.data,
15002          path: r.path,
15003          parent: r
15004        });
15005        return i.status === "aborted" ? le : i.status === "dirty" ? (n.dirty(), wf(i.value)) : this._def.out._parseAsync({
15006          data: i.value,
15007          path: r.path,
15008          parent: r
15009        });
15010      })();
15011    {
15012      const s = this._def.in._parseSync({
15013        data: r.data,
15014        path: r.path,
15015        parent: r
15016      });
15017      return s.status === "aborted" ? le : s.status === "dirty" ? (n.dirty(), {
15018        status: "dirty",
15019        value: s.value
15020      }) : this._def.out._parseSync({
15021        data: s.value,
15022        path: r.path,
15023        parent: r
15024      });
15025    }
15026  }
15027  static create(t, n) {
15028    return new Js({
15029      in: t,
15030      out: n,
15031      typeName: oe.ZodPipeline
15032    });
15033  }
15034}
15035class no extends me {
15036  _parse(t) {
15037    const n = this._def.innerType._parse(t);
15038    return Ts(n) && (n.value = Object.freeze(n.value)), n;
15039  }
15040}
15041no.create = (e, t) => new no({
15042  innerType: e,
15043  typeName: oe.ZodReadonly,
15044  ...he(t)
15045});
15046const Af = (e, t = {}, n) => e ? Fr.create().superRefine((r, s) => {
15047  var i, o;
15048  if (!e(r)) {
15049    const a = typeof t == "function" ? t(r) : typeof t == "string" ? { message: t } : t, u = (o = (i = a.fatal) !== null && i !== void 0 ? i : n) !== null && o !== void 0 ? o : !0, c = typeof a == "string" ? { message: a } : a;
15050    s.addIssue({ code: "custom", ...c, fatal: u });
15051  }
15052}) : Fr.create(), vw = {
15053  object: Fe.lazycreate
15054};
15055var oe;
15056(function(e) {
15057  e.ZodString = "ZodString", e.ZodNumber = "ZodNumber", e.ZodNaN = "ZodNaN", e.ZodBigInt = "ZodBigInt", e.ZodBoolean = "ZodBoolean", e.ZodDate = "ZodDate", e.ZodSymbol = "ZodSymbol", e.ZodUndefined = "ZodUndefined", e.ZodNull = "ZodNull", e.ZodAny = "ZodAny", e.ZodUnknown = "ZodUnknown", e.ZodNever = "ZodNever", e.ZodVoid = "ZodVoid", e.ZodArray = "ZodArray", e.ZodObject = "ZodObject", e.ZodUnion = "ZodUnion", e.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", e.ZodIntersection = "ZodIntersection", e.ZodTuple = "ZodTuple", e.ZodRecord = "ZodRecord", e.ZodMap = "ZodMap", e.ZodSet = "ZodSet", e.ZodFunction = "ZodFunction", e.ZodLazy = "ZodLazy", e.ZodLiteral = "ZodLiteral", e.ZodEnum = "ZodEnum", e.ZodEffects = "ZodEffects", e.ZodNativeEnum = "ZodNativeEnum", e.ZodOptional = "ZodOptional", e.ZodNullable = "ZodNullable", e.ZodDefault = "ZodDefault", e.ZodCatch = "ZodCatch", e.ZodPromise = "ZodPromise", e.ZodBranded = "ZodBranded", e.ZodPipeline = "ZodPipeline", e.ZodReadonly = "ZodReadonly";
15058})(oe || (oe = {}));
15059const _w = (e, t = {
15060  message: `Input not instance of ${e.name}`
15061}) => Af((n) => n instanceof e, t), vf = Rt.create, _f = jn.create, Nw = to.create, Iw = Wn.create, Nf = Ss.create, Tw = ar.create, Sw = Qi.create, Rw = Rs.create, xw = xs.create, Ow = Fr.create, Pw = er.create, kw = pn.create, Uw = Ji.create, Mw = Ot.create, Lw = Fe.create, Bw = Fe.strictCreate, Dw = Os.create, Fw = Co.create, jw = Ps.create, Ww = 
15061Kt.create, $w = ks.create, Hw = Xi.create, qw = cr.create, Gw = Sr.create, zw = Us.create, Vw = Ms.create, Kw = $n.create, Yw = Ls.create, Zw = jr.create, ju = kt.create, Qw = fn.create, Jw = ur.create, Xw = kt.createWithPreprocess, e1 = Js.create, t1 = () => vf().optional(), n1 = () => _f().optional(), r1 = () => Nf().optional(), s1 = {
15062  string: ((e) => Rt.create({ ...e, coerce: !0 })),
15063  number: ((e) => jn.create({ ...e, coerce: !0 })),
15064  boolean: ((e) => Ss.create({
15065    ...e,
15066    coerce: !0
15067  })),
15068  bigint: ((e) => Wn.create({ ...e, coerce: !0 })),
15069  date: ((e) => ar.create({ ...e, coerce: !0 }))
15070}, i1 = le;
15071var g = /* @__PURE__ */ Object.freeze({
15072  __proto__: null,
15073  defaultErrorMap: Is,
15074  setErrorMap: uw,
15075  getErrorMap: Ki,
15076  makeIssue: Yi,
15077  EMPTY_PATH: lw,
15078  addIssueToContext: Y,
15079  ParseStatus: nt,
15080  INVALID: le,
15081  DIRTY: wf,
15082  OK: at,
15083  isAborted: ka,
15084  isDirty: Ua,
15085  isValid: Ts,
15086  isAsync: Zi,
15087  get util() {
15088    return _e;
15089  },
15090  get objectUtil() {
15091    return Pa;
15092  },
15093  ZodParsedType: G,
15094  getParsedType: In,
15095  ZodType: me,
15096  ZodString: Rt,
15097  ZodNumber: jn,
15098  ZodBigInt: Wn,
15099  ZodBoolean: Ss,
15100  ZodDate: ar,
15101  ZodSymbol: Qi,
15102  ZodUndefined: Rs,
15103  ZodNull: xs,
15104  ZodAny: Fr,
15105  ZodUnknown: er,
15106  ZodNever: pn,
15107  ZodVoid: Ji,
15108  ZodArray: Ot,
15109  ZodObject: Fe,
15110  ZodUnion: Os,
15111  ZodDiscriminatedUnion: Co,
15112  ZodIntersection: Ps,
15113  ZodTuple: Kt,
15114  ZodRecord: ks,
15115  ZodMap: Xi,
15116  ZodSet: cr,
15117  ZodFunction: Sr,
15118  ZodLazy: Us,
15119  ZodLiteral: Ms,
15120  ZodEnum: $n,
15121  ZodNativeEnum: Ls,
15122  ZodPromise: jr,
15123  ZodEffects: kt,
15124  ZodTransformer: kt,
15125  ZodOptional: fn,
15126  ZodNullable: ur,
15127  ZodDefault: Bs,
15128  ZodCatch: eo,
15129  ZodNaN: to,
15130  BRAND: Aw,
15131  ZodBranded: Ef,
15132  ZodPipeline: Js,
15133  ZodReadonly: no,
15134  custom: Af,
15135  Schema: me,
15136  ZodSchema: me,
15137  late: vw,
15138  get ZodFirstPartyTypeKind() {
15139    return oe;
15140  },
15141  coerce: s1,
15142  any: Ow,
15143  array: Mw,
15144  bigint: Iw,
15145  boolean: Nf,
15146  date: Tw,
15147  discriminatedUnion: Fw,
15148  effect: ju,
15149  enum: Kw,
15150  function: Gw,
15151  instanceof: _w,
15152  intersection: jw,
15153  lazy: zw,
15154  literal: Vw,
15155  map: Hw,
15156  nan: Nw,
15157  nativeEnum: Yw,
15158  never: kw,
15159  null: xw,
15160  nullable: Jw,
15161  number: _f,
15162  object: Lw,
15163  oboolean: r1,
15164  onumber: n1,
15165  optional: Qw,
15166  ostring: t1,
15167  pipeline: e1,
15168  preprocess: Xw,
15169  promise: Zw,
15170  record: $w,
15171  set: qw,
15172  strictObject: Bw,
15173  string: vf,
15174  symbol: Sw,
15175  transformer: ju,
15176  tuple: Ww,
15177  undefined: Rw,
15178  union: Dw,
15179  unknown: Pw,
15180  void: Uw,
15181  NEVER: i1,
15182  ZodIssueCode: j,
15183  quotelessJson: cw,
15184  ZodError: xt
15185});
15186const $e = g.object({ message: g.string() });
15187function V(e) {
15188  return g.literal(Z[e]);
15189}
15190const Eo = g.object({
15191  serializedMessage: g.string().optional(),
15192  accountAddress: g.string(),
15193  chainId: g.string(),
15194  notBefore: g.string().optional(),
15195  domain: g.string(),
15196  uri: g.string(),
15197  version: g.string(),
15198  nonce: g.string(),
15199  statement: g.string().optional(),
15200  resources: g.array(g.string()).optional(),
15201  requestId: g.string().optional(),
15202  issuedAt: g.string().optional(),
15203  expirationTime: g.string().optional()
15204});
15205g.object({
15206  accessList: g.array(g.string()),
15207  blockHash: g.string().nullable(),
15208  blockNumber: g.string().nullable(),
15209  chainId: g.string().or(g.number()),
15210  from: g.string(),
15211  gas: g.string(),
15212  hash: g.string(),
15213  input: g.string().nullable(),
15214  maxFeePerGas: g.string(),
15215  maxPriorityFeePerGas: g.string(),
15216  nonce: g.string(),
15217  r: g.string(),
15218  s: g.string(),
15219  to: g.string(),
15220  transactionIndex: g.string().nullable(),
15221  type: g.string(),
15222  v: g.string(),
15223  value: g.string()
15224});
15225const o1 = g.object({
15226  chainId: g.string().or(g.number()),
15227  rpcUrl: g.optional(g.string())
15228}), a1 = g.object({ email: g.string().email() }), c1 = g.object({ otp: g.string() }), u1 = g.object({
15229  uri: g.string(),
15230  preferredAccountType: g.optional(g.string()),
15231  chainId: g.optional(g.string().or(g.number())),
15232  siwxMessage: g.optional(Eo),
15233  rpcUrl: g.optional(g.string())
15234}), l1 = g.object({
15235  chainId: g.optional(g.string().or(g.number())),
15236  preferredAccountType: g.optional(g.string()),
15237  socialUri: g.optional(g.string()),
15238  siwxMessage: g.optional(Eo),
15239  rpcUrl: g.optional(g.string())
15240}), d1 = g.object({
15241  provider: g.enum(["google", "github", "apple", "facebook", "x", "discord"])
15242}), f1 = g.object({ email: g.string().email() }), h1 = g.object({ otp: g.string() }), p1 = g.object({ otp: g.string() }), m1 = g.object({
15243  themeMode: g.optional(g.enum(["light", "dark"])),
15244  themeVariables: g.optional(g.record(g.string(), g.string().or(g.number()))),
15245  w3mThemeVariables: g.optional(g.record(g.string(), g.string()))
15246}), g1 = g.object({
15247  metadata: g.object({
15248    name: g.string(),
15249    description: g.string(),
15250    url: g.string(),
15251    icons: g.array(g.string())
15252  }).optional(),
15253  sdkVersion: g.string().optional(),
15254  sdkType: g.string().optional(),
15255  projectId: g.string()
15256}), y1 = g.object({ type: g.string() }), b1 = g.object({
15257  action: g.enum(["VERIFY_DEVICE", "VERIFY_OTP", "CONNECT"])
15258}), w1 = g.object({
15259  url: g.string()
15260}), C1 = g.object({
15261  userName: g.string()
15262}), E1 = g.object({
15263  email: g.string().optional().nullable(),
15264  address: g.string(),
15265  chainId: g.string().or(g.number()),
15266  accounts: g.array(g.object({
15267    address: g.string(),
15268    type: g.enum([
15269      Ye.ACCOUNT_TYPES.EOA,
15270      Ye.ACCOUNT_TYPES.SMART_ACCOUNT
15271    ])
15272  })).optional(),
15273  userName: g.string().optional().nullable(),
15274  preferredAccountType: g.optional(g.string()),
15275  signature: g.string().optional(),
15276  message: g.string().optional(),
15277  siwxMessage: g.optional(Eo)
15278}), A1 = g.object({
15279  action: g.enum(["VERIFY_PRIMARY_OTP", "VERIFY_SECONDARY_OTP"])
15280}), v1 = g.object({
15281  email: g.string().email().optional().nullable(),
15282  address: g.string(),
15283  chainId: g.string().or(g.number()),
15284  smartAccountDeployed: g.optional(g.boolean()),
15285  accounts: g.array(g.object({
15286    address: g.string(),
15287    type: g.enum([
15288      Ye.ACCOUNT_TYPES.EOA,
15289      Ye.ACCOUNT_TYPES.SMART_ACCOUNT
15290    ])
15291  })).optional(),
15292  preferredAccountType: g.optional(g.string()),
15293  signature: g.string().optional(),
15294  message: g.string().optional(),
15295  siwxMessage: g.optional(Eo)
15296}), _1 = g.object({ uri: g.string() }), N1 = g.object({ isConnected: g.boolean() }), I1 = g.object({ chainId: g.string().or(g.number()) }), T1 = g.object({ chainId: g.string().or(g.number()) }), S1 = g.object({ newEmail: g.string().email() }), R1 = g.object({
15297  smartAccountEnabledNetworks: g.array(g.number())
15298});
15299g.object({
15300  address: g.string(),
15301  isDeployed: g.boolean()
15302});
15303const x1 = g.object({
15304  version: g.string().optional()
15305}), O1 = g.object({ type: g.string(), address: g.string() }
15305), P1 = g.any(), k1 = g.object({
15306  method: g.literal("eth_accounts")
15307}), U1 = g.object({
15308  method: g.literal("eth_blockNumber")
15309}), M1 = g.object({
15310  method: g.literal("eth_call"),
15311  params: g.array(g.any())
15312}), L1 = g.object({
15313  method: g.literal("eth_chainId")
15314}), B1 = g.object({
15315  method: g.literal("eth_estimateGas"),
15316  params: g.array(g.any())
15317}), D1 = g.object({
15318  method: g.literal("eth_feeHistory"),
15319  params: g.array(g.any())
15320}), F1 = g.object({
15321  method: g.literal("eth_gasPrice")
15322}), j1 = g.object({
15323  method: g.literal("eth_getAccount"),
15324  params: g.array(g.any())
15325}), W1 = g.object({
15326  method: g.literal("eth_getBalance"),
15327  params: g.array(g.any())
15328}), $1 = g.object({
15329  method: g.literal("eth_getBlockByHash"),
15330  params: g.array(g.any())
15331}), H1 = g.object({
15332  method: g.literal("eth_getBlockByNumber"),
15333  params: g.array(g.any())
15334}), q1 = g.object({
15335  method: g.literal("eth_getBlockReceipts"),
15336  params: g.array(g.any())
15337}), G1 = g.object({
15338  method: g.literal("eth_getBlockTransactionCountByHash"),
15339  params: g.array(g.any())
15340}), z1 = g.object({
15341  method: g.literal("eth_getBlockTransactionCountByNumber"),
15342  params: g.array(g.any())
15343}), V1 = g.object({
15344  method: g.literal("eth_getCode"),
15345  params: g.array(g.any())
15346}), K1 = g.object({
15347  method: g.literal("eth_getFilterChanges"),
15348  params: g.array(g.any())
15349}), Y1 = g.object({
15350  method: g.literal("eth_getFilterLogs"),
15351  params: g.array(g.any())
15352}), Z1 = g.object({
15353  method: g.literal("eth_getLogs"),
15354  params: g.array(g.any())
15355}), Q1 = g.object({
15356  method: g.literal("eth_getProof"),
15357  params: g.array(g.any())
15358}), J1 = g.object({
15359  method: g.literal("eth_getStorageAt"),
15360  params: g.array(g.any())
15361}), X1 = g.object({
15362  method: g.literal("eth_getTransactionByBlockHashAndIndex"),
15363  params: g.array(g.any())
15364}), eC = g.object({
15365  method: g.literal("eth_getTransactionByBlockNumberAndIndex"),
15366  params: g.array(g.any())
15367}), tC = g.object({
15368  method: g.literal("eth_getTransactionByHash"),
15369  params: g.array(g.any())
15370}), nC = g.object({
15371  method: g.literal("eth_getTransactionCount"),
15372  params: g.array(g.any())
15373}), rC = g.object({
15374  method: g.literal("eth_getTransactionReceipt"),
15375  params: g.array(g.any())
15376}), sC = g.object({
15377  method: g.literal("eth_getUncleCountByBlockHash"),
15378  params: g.array(g.any())
15379}), iC = g.object({
15380  method: g.literal("eth_getUncleCountByBlockNumber"),
15381  params: g.array(g.any())
15382}), oC = g.object({
15383  method: g.literal("eth_maxPriorityFeePerGas")
15384}), aC = g.object({
15385  method: g.literal("eth_newBlockFilter")
15386}), cC = g.object({
15387  method: g.literal("eth_newFilter"),
15388  params: g.array(g.any())
15389}), uC = g.object({
15390  method: g.literal("eth_newPendingTransactionFilter")
15391}), lC = g.object({
15392  method: g.literal("eth_sendRawTransaction"),
15393  params: g.array(g.any())
15394}), dC = g.object({
15395  method: g.literal("eth_syncing"),
15396  params: g.array(g.any())
15397}), fC = g.object({
15398  method: g.literal("eth_uninstallFilter"),
15399  params: g.array(g.any())
15400}), Wu = g.object({
15401  method: g.literal("personal_sign"),
15402  params: g.array(g.any())
15403}), hC = g.object({
15404  method: g.literal("eth_signTypedData_v4"),
15405  params: g.array(g.any())
15406}), pC = g.object({
15407  method: g.literal("eth_sendTransaction"),
15408  params: g.array(g.any())
15409}), mC = g.object({
15410  method: g.literal("solana_signMessage"),
15411  params: g.object({
15412    message: g.string(),
15413    pubkey: g.string()
15414  })
15415}), gC = g.object({
15416  method: g.literal("solana_signTransaction"),
15417  params: g.object({
15418    transaction: g.string()
15419  })
15420}), yC = g.object({
15421  method: g.literal("solana_signAllTransactions"),
15422  params: g.object({
15423    transactions: g.array(g.string())
15424  })
15425}), bC = g.object({
15426  method: g.literal("solana_signAndSendTransaction"),
15427  params: g.object({
15428    transaction: g.string(),
15429    options: g.object({
15430      skipPreflight: g.boolean().optional(),
15431      preflightCommitment: g.enum([
15432        "processed",
15433        "confirmed",
15434        "finalized",
15435        "recent",
15436        "single",
15437        "singleGossip",
15438        "root",
15439        "max"
15440      ]).optional(),
15441      maxRetries: g.number().optional(),
15442      minContextSlot: g.number().optional()
15443    }).optional()
15444  })
15445}), wC = g.object({
15446  method: g.literal("wallet_sendCalls"),
15447  params: g.array(g.object({
15448    chainId: g.string().or(g.number()).optional(),
15449    from: g.string().optional(),
15450    version: g.string().optional(),
15451    capabilities: g.any().optional(),
15452    calls: g.array(g.object({
15453      to: g.string().startsWith("0x"),
15454      data: g.string().startsWith("0x").optional(),
15455      value: g.string().optional()
15456    }))
15457  }))
15458}), CC = g.object({
15459  method: g.literal("wallet_getCallsStatus"),
15460  params: g.array(g.string())
15461}), EC = g.object({
15462  method: g.literal("wallet_getCapabilities"),
15463  params: g.array(g.string().or(g.number()).optional()).optional()
15464}), AC = g.object({
15465  method: g.literal("wallet_grantPermissions"),
15466  params: g.array(g.any())
15467}), vC = g.object({
15468  method: g.literal("wallet_revokePermissions"),
15469  params: g.any()
15470}), _C = g.object({
15471  method: g.literal("wallet_getAssets"),
15472  params: g.any()
15473}), $u = g.object({
15474  token: g.string()
15475}), K = g.object({
15476  id: g.string().optional()
15477}), Yo = {
15478  appEvent: K.extend({
15479    type: V("APP_SWITCH_NETWORK"),
15480    payload: o1
15481  }).or(K.extend({
15482    type: V("APP_CONNECT_EMAIL"),
15483    payload: a1
15484  })).or(K.extend({ type: V("APP_CONNECT_DEVICE") })).or(K.extend({ type: V("APP_CONNECT_OTP"), payload: c1 })).or(K.extend({
15485    type: V("APP_CONNECT_SOCIAL"),
15486    payload: u1
15487  })).or(K.extend({ type: V("APP_GET_FARCASTER_URI") })).or(K.extend({ type: V("APP_CONNECT_FARCASTER") })).or(K.extend({
15488    type: V("APP_GET_USER"),
15489    payload: g.optional(l1)
15490  })).or(K.extend({
15491    type: V("APP_GET_SOCIAL_REDIRECT_URI"),
15492    payload: d1
15493  })).or(K.extend({ type: V("APP_SIGN_OUT") })).or(K.extend({
15494    type: V("APP_IS_CONNECTED"),
15495    payload: g.optional($u)
15496  })).or(K.extend({ type: V("APP_GET_CHAIN_ID") })).or(K.extend({ type: V("APP_GET_SMART_ACCOUNT_ENABLED_NETWORKS") })).or(K.extend({ type: V("APP_INIT_SMART_ACCOUNT") })).or(K.extend({
15497    type: V("APP_SET_PREFERRED_ACCOUNT"),
15498    payload: y1
15499  })).or(K.extend({
15500    type: V("APP_RPC_REQUEST"),
15501    payload: Wu.or(_C).or(k1).or(U1).or(M1).or(L1).or(B1).or(D1).or(F1).or(j1).or(W1).or($1).or(H1).or(q1).or(G1).or(z1).or(V1).or(K1).or(Y1).or(Z1).or(Q1).or(J1).or(X1).or(eC).or(tC).or(nC).or(rC).or(sC).or(iC).or(oC).or(aC).or(cC).or(uC).or(lC).or(dC).or(fC).or(Wu).or(hC).or(pC).or(mC).or(gC).or(yC).or(bC).or(CC).or(wC).or(EC).or(AC).or(vC).and(g.object({
15502      chainId: g.string().or(g.number()).optional(),
15503      chainNamespace: g.enum(["eip155", "solana", "polkadot", "bip122", "cosmos"]).optional(),
15504      rpcUrl: g.string().optional()
15505    }))
15506  })).or(K.extend({ type: V("APP_UPDATE_EMAIL"), payload: f1 })).or(K.extend({
15507    type: V("APP_UPDATE_EMAIL_PRIMARY_OTP"),
15508    payload: h1
15509  })).or(K.extend({
15510    type: V("APP_UPDATE_EMAIL_SECONDARY_OTP"),
15511    payload: p1
15512  })).or(K.extend({ type: V("APP_SYNC_THEME"), payload: m1 })).or(K.extend({
15513    type: V("APP_SYNC_DAPP_DATA"),
15514    payload: g1
15515  })).or(K.extend({
15516    type: V("APP_RELOAD")
15517  })).or(K.extend({
15518    type: V("APP_RPC_ABORT")
15519  })),
15520  frameEvent: K.extend({ type: V("FRAME_SWITCH_NETWORK_ERROR"), payload: $e }).or(K.extend({
15521    type: V("FRAME_SWITCH_NETWORK_SUCCESS"),
15522    payload: T1
15523  })).or(K.extend({
15524    type: V("FRAME_CONNECT_EMAIL_SUCCESS"),
15525    payload: b1
15526  })).or(K.extend({ type: V("FRAME_CONNECT_EMAIL_ERROR"), payload: $e })).or(K.extend({
15527    type: V("FRAME_GET_FARCASTER_URI_SUCCESS"),
15528    payload: w1
15529  })).or(K.extend({ type: V("FRAME_GET_FARCASTER_URI_ERROR"), payload: $e })).or(K.extend({
15530    type: V("FRAME_CONNECT_FARCASTER_SUCCESS"),
15531    payload: C1
15532  })).or(K.extend({ type: V("FRAME_CONNECT_FARCASTER_ERROR"), payload: $e })).or(K.extend({ type: V("FRAME_CONNECT_OTP_ERROR"), payload: $e })).or(K.extend({ type: V("FRAME_CONNECT_OTP_SUCCESS") })).or(K.extend({ type: V("FRAME_CONNECT_DEVICE_ERROR"), payload: $e })).or(K.extend({ type: V("FRAME_CONNECT_DEVICE_SUCCESS") })).or(K.extend({
15533    type: V("FRAME_CONNECT_SOCIAL_SUCCESS"),
15534    payload: E1
15535  })).or(K.extend({
15536    type: V("FRAME_CONNECT_SOCIAL_ERROR"),
15537    payload: $e
15538  })).or(K.extend({ type: V("FRAME_GET_USER_ERROR"), payload: $e })).or(K.extend({
15539    type: V("FRAME_GET_USER_SUCCESS"),
15540    payload: v1
15541  })).or(K.extend({
15542    type: V("FRAME_GET_SOCIAL_REDIRECT_URI_ERROR"),
15543    payload: $e
15544  })).or(K.extend({
15545    type: V("FRAME_GET_SOCIAL_REDIRECT_URI_SUCCESS"),
15546    payload: _1
15547  })).or(K.extend({ type: V("FRAME_SIGN_OUT_ERROR"), payload: $e })).or(K.extend({ type: V("FRAME_SIGN_OUT_SUCCESS") })).or(K.extend({ type: V("FRAME_IS_CONNECTED_ERROR"), payload: $e })).or(K.extend({
15548    type: V("FRAME_IS_CONNECTED_SUCCESS"),
15549    payload: N1
15550  })).or(K.extend({ type: V("FRAME_GET_CHAIN_ID_ERROR"), payload: $e })).or(K.extend({
15551    type: V("FRAME_GET_CHAIN_ID_SUCCESS"),
15552    payload: I1
15553  })).or(K.extend({ type: V("FRAME_RPC_REQUEST_ERROR"), payload: $e })).or(K.extend({ type: V("FRAME_RPC_REQUEST_SUCCESS"), payload: P1 })).or(K.extend({ type: V("FRAME_SESSION_UPDATE"), payload: $u })).or(K.extend({ type: V("FRAME_UPDATE_EMAIL_ERROR"), payload: $e })).or(K.extend({
15554    type: V("FRAME_UPDATE_EMAIL_SUCCESS"),
15555    payload: A1
15556  })).or(K.extend({
15557    type: V("FRAME_UPDATE_EMAIL_PRIMARY_OTP_ERROR"),
15558    payload: $e
15559  })).or(K.extend({ type: V("FRAME_UPDATE_EMAIL_PRIMARY_OTP_SUCCESS") })).or(K.extend({
15560    type: V("FRAME_UPDATE_EMAIL_SECONDARY_OTP_ERROR"),
15561    payload: $e
15562  })).or(K.extend({
15563    type: V("FRAME_UPDATE_EMAIL_SECONDARY_OTP_SUCCESS"),
15564    payload: S1
15565  })).or(K.extend({ type: V("FRAME_SYNC_THEME_ERROR"), payload: $e })).or(K.extend({ type: V("FRAME_SYNC_THEME_SUCCESS") })).or(K.extend({ type: V("FRAME_SYNC_DAPP_DATA_ERROR"), payload: $e })).or(K.extend({ type: V("FRAME_SYNC_DAPP_DATA_SUCCESS") })).or(K.extend({
15566    type: V("FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_SUCCESS"),
15567    payload: R1
15568  })).or(K.extend({
15569    type: V("FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_ERROR"),
15570    payload: $e
15571  })).or(K.extend({ type: V("FRAME_INIT_SMART_ACCOUNT_ERROR"), payload: $e })).or(K.extend({
15572    type: V("FRAME_SET_PREFERRED_ACCOUNT_SUCCESS"),
15573    payload: O1
15574  })).or(K.extend({
15575    type: V("FRAME_SET_PREFERRED_ACCOUNT_ERROR"),
15576    payload: $e
15577  })).or(K.extend({ type: V("FRAME_READY"), payload: x1 })).or(K.extend({
15578    type: V("FRAME_RELOAD_ERROR"),
15579    payload: $e
15580  })).or(K.extend({ type: V("FRAME_RELOAD_SUCCESS") }))
15581};
15582function Zo(e, t = {}) {
15583  return typeof t?.type == "string" && t?.type?.includes(e);
15584}
15585function NC({ projectId: e, chainId: t, enableLogger: n, rpcUrl: r = x.BLOCKCHAIN_API_RPC_URL, enableCloudAuthAccount: s = !1 }) {
15586  const i = new URL(iw);
15587  i.searchParams.set("projectId", e), i.searchParams.set("chainId", String(t)), i.searchParams.set("version", aw), i.searchParams.set("enableLogger", String(n)), i.searchParams.set("rpcUrl", r);
15588  const o = Ve.get("dapp_smart_account_version");
15589  return o && (o === "v6" || o === "v7") && (console.warn(">> AppKit - Forcing smart account version", o), i.searchParams.set("smartAccountVersion", o)), s && i.searchParams.set("enableCloudAuthAccount", "true"), i.toString();
15590}
15591class IC {
15592  constructor({ projectId: t, isAppClient: n = !1, chainId: r = "eip155:1", enableLogger: s = !0, enableCloudAuthAccount: i = !1, rpcUrl: o = x.BLOCKCHAIN_API_RPC_URL }) {
15593    if (this.iframe = null, this.iframeIsReady = !1, this.initFrame = () => {
15594      const a = document.getElementById("w3m-iframe");
15595      this.iframe && !a && document.body.appendChild(this.iframe);
15596    }, this.events = {
15597      registerFrameEventHandler: (a, u, c) => {
15598        function l({ data: f }) {
15599          if (!Zo(Z.FRAME_EVENT_KEY, f))
15600            return;
15601          const p = Yo.frameEvent.safeParse(f);
15602          if (!p.success) {
15603            console.warn("W3mFrame: invalid frame event", p.error.message);
15604            return;
15605          }
15606          p.data?.id === a && (u(p.data), window.removeEventListener("message", l));
15607        }
15608        Wt.isClient && (window.addEventListener("message", l), c.addEventListener("abort", () => {
15609          window.removeEventListener("message", l);
15610        }));
15611      },
15612      onFrameEvent: (a) => {
15613        Wt.isClient && window.addEventListener("message", ({ data: u }) => {
15614          if (!Zo(Z.FRAME_EVENT_KEY, u))
15615            return;
15616          const c = Yo.frameEvent.safeParse(u);
15617          c.success ? a(c.data) : console.warn("W3mFrame: invalid frame event", c.error.message);
15618        });
15619      },
15620      onAppEvent: (a) => {
15621        Wt.isClient && window.addEventListener("message", ({ data: u }) => {
15622          if (!Zo(Z.APP_EVENT_KEY, u))
15623            return;
15624          const c = Yo.appEvent.safeParse(u);
15625          c.success || console.warn("W3mFrame: invalid app event", c.error.message), a(u);
15626        });
15627      },
15628      postAppEvent: (a) => {
15629        if (Wt.isClient) {
15630          if (!this.iframe?.contentWindow)
15631            throw new Error("W3mFrame: iframe is not set");
15632          this.iframe.contentWindow.postMessage(a, "*");
15633        }
15634      },
15635      postFrameEvent: (a) => {
15636        if (Wt.isClient) {
15637          if (!parent)
15638            throw new Error("W3mFrame: parent is not set");
15639          parent.postMessage(a, "*");
15640        }
15641      }
15642    }, this.projectId = t, this.frameLoadPromise = new Promise((a, u) => {
15643      this.frameLoadPromiseResolver = { resolve: a, reject: u };
15644    }), this.rpcUrl = o, n && (this.frameLoadPromise = new Promise((a, u) => {
15645      this.frameLoadPromiseResolver = { resolve: a, reject: u };
15646    }), Wt.isClient)) {
15647      const a = document.createElement("iframe");
15648      a.id = "w3m-iframe", a.src = NC({
15649        projectId: t,
15650        chainId: r,
15651        enableLogger: s,
15652        rpcUrl: this.rpcUrl,
15653        enableCloudAuthAccount: i
15654      }), a.name = "w3m-secure-iframe", a.style.position = "fixed", a.style.zIndex = "999999", a.style.display = "none", a.style.border = "none", a.style.animationDelay = "0s, 50ms", a.style.borderBottomLeftRadius = "clamp(0px, var(--apkt-borderRadius-8), 44px)", a.style.borderBottomRightRadius = "clamp(0px, var(--apkt-borderRadius-8), 44px)", this.iframe = a, this.iframe.onerror = () => {
15655        this.frameLoadPromiseResolver?.reject("Unable to load email login dependency");
15656      }, this.events.onFrameEvent((u) => {
15657        u.type === "@w3m-frame/READY" && (this.iframeIsReady = !0, this.frameLoadPromiseResolver?.resolve(void 0));
15658      });
15659    }
15660  }
15661  get networks() {
15662    const t = [
15663      "eip155:1",
15664      "eip155:5",
15665      "eip155:11155111",
15666      "eip155:10",
15667      "eip155:420",
15668      "eip155:42161",
15669      "eip155:421613",
15670      "eip155:137",
15671      "eip155:80001",
15672      "eip155:42220",
15673      "eip155:1313161554",
15674      "eip155:1313161555",
15675      "eip155:56",
15676      "eip155:97",
15677      "eip155:43114",
15678      "eip155:43113",
15679      "eip155:324",
15680      "eip155:280",
15681      "eip155:100",
15682      "eip155:8453",
15683      "eip155:84531",
15684      "eip155:84532",
15685      "eip155:7777777",
15686      "eip155:999",
15687      "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
15688      "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",
15689      "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"
15690    ].map((n) => ({
15691      [n]: {
15692        rpcUrl: `${this.rpcUrl}/v1/?chainId=${n}&projectId=${this.projectId}`,
15693        chainId: n
15694      }
15695    }));
15696    return Object.assign({}, ...t);
15697  }
15698}
15699class TC {
15700  constructor(t) {
15701    const n = cb({
15702      level: ow
15703    }), { logger: r, chunkLoggerController: s } = mb({
15704      opts: n
15705    });
15706    this.logger = fb(r, this.constructor.name), this.chunkLoggerController = s, typeof window < "u" && this.chunkLoggerController?.downloadLogsBlobInBrowser && (window.downloadAppKitLogsBlob || (window.downloadAppKitLogsBlob = {}), window.downloadAppKitLogsBlob.sdk = () => {
15707      this.chunkLoggerController?.downloadLogsBlobInBrowser && this.chunkLoggerController.downloadLogsBlobInBrowser({
15708        projectId: t
15709      });
15710    });
15711  }
15712}
15713function La(e) {
15714  if (typeof e == "bigint")
15715    return `0x${e.toString(16)}`;
15716  if (Array.isArray(e))
15717    return e.map(La);
15718  if (e !== null && typeof e == "object") {
15719    const t = {};
15720    for (const [n, r] of Object.entries(e))
15721      t[n] = La(r);
15722    return t;
15723  }
15724  return e;
15725}
15726class SC {
15727  constructor({ projectId: t, chainId: n, enableLogger: r = !0, onTimeout: s, abortController: i, getActiveCaipNetwork: o, getCaipNetworks: a, enableCloudAuthAccount: u, metadata: c, sdkVersion: l, sdkType: f }) {
15728    this.openRpcRequests = /* @__PURE__ */ new Map(), this.isInitialized = !1, r && (this.w3mLogger = new TC(t)), this.abortController = i, this.getActiveCaipNetwork = o, this.getCaipNetworks = a;
15729    const p = this.getRpcUrl(n);
15730    this.projectId = t, this.sdkVersion = l, this.sdkType = f, this.metadata = c, this.w3mFrame = new IC({
15731      projectId: t,
15732      isAppClient: !0,
15733      chainId: n,
15734      enableLogger: r,
15735      rpcUrl: p,
15736      enableCloudAuthAccount: u
15737    }), this.onTimeout = s, this.getLoginEmailUsed() && this.createFrame();
15738  }
15739  async createFrame() {
15740    this.w3mFrame.initFrame(), this.initPromise = new Promise((t) => {
15741      this.w3mFrame.events.onFrameEvent((n) => {
15742        n.type === Z.FRAME_READY && setTimeout(() => {
15743          t();
15744        }, 500);
15745      });
15746    }), await this.initPromise, await this.syncDappData({
15747      metadata: this.metadata,
15748      projectId: this.projectId,
15749      sdkVersion: this.sdkVersion,
15750      sdkType: this.sdkType
15751    }
15751), await this.getSmartAccountEnabledNetworks(), this.isInitialized = !0, this.initPromise = void 0;
15752  }
15753  async init() {
15754    if (!this.isInitialized) {
15755      if (this.initPromise) {
15756        await this.initPromise;
15757        return;
15758      }
15759      await this.createFrame();
15760    }
15761  }
15762  getLoginEmailUsed() {
15763    return !!Ve.get(Z.EMAIL_LOGIN_USED_KEY);
15764  }
15765  getEmail() {
15766    return Ve.get(Z.EMAIL);
15767  }
15768  getUsername() {
15769    return Ve.get(Z.SOCIAL_USERNAME);
15770  }
15771  async reload() {
15772    try {
15773      await this.appEvent({
15774        type: Z.APP_RELOAD
15775      });
15776    } catch (t) {
15777      throw this.w3mLogger?.logger.error({ error: t }, "Error reloading iframe"), t;
15778    }
15779  }
15780  async connectEmail(t) {
15781    try {
15782      Wt.checkIfAllowedToTriggerEmail(), await this.init();
15783      const n = await this.appEvent({
15784        type: Z.APP_CONNECT_EMAIL,
15785        payload: t
15786      });
15787      return this.setNewLastEmailLoginTime(), n;
15788    } catch (n) {
15789      throw this.w3mLogger?.logger.error({ error: n }, "Error connecting email"), n;
15790    }
15791  }
15792  async connectDevice() {
15793    try {
15794      return this.appEvent({
15795        type: Z.APP_CONNECT_DEVICE
15796      });
15797    } catch (t) {
15798      throw this.w3mLogger?.logger.error({ error: t }, "Error connecting device"), t;
15799    }
15800  }
15801  async connectOtp(t) {
15802    try {
15803      return this.appEvent({
15804        type: Z.APP_CONNECT_OTP,
15805        payload: t
15806      });
15807    } catch (n) {
15808      throw this.w3mLogger?.logger.error({ error: n }, "Error connecting otp"), n;
15809    }
15810  }
15811  async isConnected() {
15812    try {
15813      if (!this.getLoginEmailUsed())
15814        return { isConnected: !1 };
15815      const t = await this.appEvent({
15816        type: Z.APP_IS_CONNECTED
15817      });
15818      return t?.isConnected || this.deleteAuthLoginCache(), t;
15819    } catch (t) {
15820      throw this.deleteAuthLoginCache(), this.w3mLogger?.logger.error({ error: t }, "Error checking connection"), t;
15821    }
15822  }
15823  async getChainId() {
15824    try {
15825      const t = await this.appEvent({
15826        type: Z.APP_GET_CHAIN_ID
15827      });
15828      return this.setLastUsedChainId(t.chainId), t;
15829    } catch (t) {
15830      throw this.w3mLogger?.logger.error({ error: t }, "Error getting chain id"), t;
15831    }
15832  }
15833  async getSocialRedirectUri(t) {
15834    try {
15835      return await this.init(), this.appEvent({
15836        type: Z.APP_GET_SOCIAL_REDIRECT_URI,
15837        payload: t
15838      });
15839    } catch (n) {
15840      throw this.w3mLogger?.logger.error({ error: n }, "Error getting social redirect uri"), n;
15841    }
15842  }
15843  async updateEmail(t) {
15844    try {
15845      const n = await this.appEvent({
15846        type: Z.APP_UPDATE_EMAIL,
15847        payload: t
15848      });
15849      return this.setNewLastEmailLoginTime(), n;
15850    } catch (n) {
15851      throw this.w3mLogger?.logger.error({ error: n }, "Error updating email"), n;
15852    }
15853  }
15854  async updateEmailPrimaryOtp(t) {
15855    try {
15856      return this.appEvent({
15857        type: Z.APP_UPDATE_EMAIL_PRIMARY_OTP,
15858        payload: t
15859      });
15860    } catch (n) {
15861      throw this.w3mLogger?.logger.error({ error: n }, "Error updating email primary otp"), n;
15862    }
15863  }
15864  async updateEmailSecondaryOtp(t) {
15865    try {
15866      const n = await this.appEvent({
15867        type: Z.APP_UPDATE_EMAIL_SECONDARY_OTP,
15868        payload: t
15869      });
15870      return this.setLoginSuccess(n.newEmail), n;
15871    } catch (n) {
15872      throw this.w3mLogger?.logger.error({ error: n }, "Error updating email secondary otp"), n;
15873    }
15874  }
15875  async syncTheme(t) {
15876    try {
15877      return this.appEvent({
15878        type: Z.APP_SYNC_THEME,
15879        payload: t
15880      });
15881    } catch (n) {
15882      throw this.w3mLogger?.logger.error({ error: n }, "Error syncing theme"), n;
15883    }
15884  }
15885  async syncDappData(t) {
15886    try {
15887      return this.appEvent({
15888        type: Z.APP_SYNC_DAPP_DATA,
15889        payload: t
15890      });
15891    } catch (n) {
15892      throw this.w3mLogger?.logger.error({ error: n }, "Error syncing dapp data"), n;
15893    }
15894  }
15895  async getSmartAccountEnabledNetworks() {
15896    try {
15897      const t = await this.appEvent({
15898        type: Z.APP_GET_SMART_ACCOUNT_ENABLED_NETWORKS
15899      });
15900      return this.persistSmartAccountEnabledNetworks(t.smartAccountEnabledNetworks), t;
15901    } catch (t) {
15902      throw this.persistSmartAccountEnabledNetworks([]), this.w3mLogger?.logger.error({ error: t }, "Error getting smart account enabled networks"), t;
15903    }
15904  }
15905  async setPreferredAccount(t) {
15906    try {
15907      return this.appEvent({
15908        type: Z.APP_SET_PREFERRED_ACCOUNT,
15909        payload: { type: t }
15910      });
15911    } catch (n) {
15912      throw this.w3mLogger?.logger.error({ error: n }, "Error setting preferred account"), n;
15913    }
15914  }
15915  async connect(t) {
15916    if (t?.socialUri)
15917      try {
15918        await this.init();
15919        const n = this.getRpcUrl(t.chainId), r = await this.appEvent({
15920          type: Z.APP_CONNECT_SOCIAL,
15921          payload: {
15922            uri: t.socialUri,
15923            preferredAccountType: t.preferredAccountType,
15924            chainId: t.chainId,
15925            siwxMessage: t.siwxMessage,
15926            rpcUrl: n
15927          }
15928        });
15929        return r.userName && this.setSocialLoginSuccess(r.userName), this.setLoginSuccess(r.email), this.setLastUsedChainId(r.chainId), this.user = r, r;
15930      } catch (n) {
15931        throw this.w3mLogger?.logger.error({ error: n }, "Error connecting social"), n;
15932      }
15933    else
15934      try {
15935        const n = t?.chainId || this.getLastUsedChainId() || 1, r = await this.getUser({
15936          chainId: n,
15937          preferredAccountType: t?.preferredAccountType,
15938          siwxMessage: t?.siwxMessage,
15939          rpcUrl: this.getRpcUrl(n)
15940        });
15941        return this.setLoginSuccess(r.email), this.setLastUsedChainId(r.chainId), this.user = r, r;
15942      } catch (n) {
15943        throw this.w3mLogger?.logger.error({ error: n }, "Error connecting"), n;
15944      }
15945  }
15946  async getUser(t) {
15947    try {
15948      await this.init();
15949      const n = t?.chainId || this.getLastUsedChainId() || 1, r = await this.appEvent({
15950        type: Z.APP_GET_USER,
15951        payload: { ...t, chainId: n, rpcUrl: this.getRpcUrl(n) }
15952      });
15953      return this.user = r, r;
15954    } catch (n) {
15955      throw this.w3mLogger?.logger.error({ error: n }, "Error connecting"), n;
15956    }
15957  }
15958  async connectSocial({ uri: t, chainId: n, preferredAccountType: r }) {
15959    try {
15960      await this.init();
15961      const s = this.getRpcUrl(n), i = await this.appEvent({
15962        type: Z.APP_CONNECT_SOCIAL,
15963        payload: { uri: t, chainId: n, rpcUrl: s, preferredAccountType: r }
15964      });
15965      return i.userName && this.setSocialLoginSuccess(i.userName), i;
15966    } catch (s) {
15967      throw this.w3mLogger?.logger.error({ error: s }, "Error connecting social"), s;
15968    }
15969  }
15970  async getFarcasterUri() {
15971    try {
15972      return await this.init(), await this.appEvent({
15973        type: Z.APP_GET_FARCASTER_URI
15974      });
15975    } catch (t) {
15976      throw this.w3mLogger?.logger.error({ error: t }, "Error getting farcaster uri"), t;
15977    }
15978  }
15979  async connectFarcaster() {
15980    try {
15981      const t = await this.appEvent({
15982        type: Z.APP_CONNECT_FARCASTER
15983      });
15984      return t.userName && this.setSocialLoginSuccess(t.userName), t;
15985    } catch (t) {
15986      throw this.w3mLogger?.logger.error({ error: t }, "Error connecting farcaster"), t;
15987    }
15988  }
15989  async switchNetwork({ chainId: t }) {
15990    try {
15991      const n = this.getRpcUrl(t), r = await this.appEvent({
15992        type: Z.APP_SWITCH_NETWORK,
15993        payload: { chainId: t, rpcUrl: n }
15994      });
15995      return this.setLastUsedChainId(r.chainId), r;
15996    } catch (n) {
15997      throw this.w3mLogger?.logger.error({ error: n }, "Error switching network"), n;
15998    }
15999  }
16000  async disconnect() {
16001    try {
16002      return this.deleteAuthLoginCache(), await new Promise(async (n) => {
16003        const r = setTimeout(() => {
16004          n();
16005        }, 3e3);
16006        await this.appEvent({
16007          type: Z.APP_SIGN_OUT
16008        }), clearTimeout(r), n();
16009      });
16010    } catch (t) {
16011      throw this.w3mLogger?.logger.error({ error: t }, "Error disconnecting"), t;
16012    }
16013  }
16014  async request(t) {
16015    const n = t;
16016    try {
16017      if (Ye.GET_CHAIN_ID === t.method)
16018        return this.getLastUsedChainId();
16019      const r = t.chainNamespace || "eip155", s = this.getActiveCaipNetwork(r)?.id;
16020      n.chainNamespace = r, n.chainId = s, n.rpcUrl = this.getRpcUrl(s), this.rpcRequestHandler?.(t);
16021      const i = await this.appEvent({
16022        type: Z.APP_RPC_REQUEST,
16023        payload: La(n)
16024      });
16025      return this.rpcSuccessHandler?.(i, n), i;
16026    } catch (r) {
16027      throw this.rpcErrorHandler?.(r, n), this.w3mLogger?.logger.error({ error: r }, "Error requesting"), r;
16028    }
16029  }
16030  onRpcRequest(t) {
16031    this.rpcRequestHandler = t;
16032  }
16033  onRpcSuccess(t) {
16034    this.rpcSuccessHandler = t;
16035  }
16036  onRpcError(t) {
16037    this.rpcErrorHandler = t;
16038  }
16039  onIsConnected(t) {
16040    this.w3mFrame.events.onFrameEvent((n) => {
16041      n.type === Z.FRAME_IS_CONNECTED_SUCCESS && n.payload.isConnected && t();
16042    });
16043  }
16044  onNotConnected(t) {
16045    this.w3mFrame.events.onFrameEvent((n) => {
16046      n.type === Z.FRAME_IS_CONNECTED_ERROR && t(), n.type === Z.FRAME_IS_CONNECTED_SUCCESS && !n.payload.isConnected && t();
16047    });
16048  }
16049  onConnect(t) {
16050    this.w3mFrame.events.onFrameEvent((n) => {
16051      n.type === Z.FRAME_GET_USER_SUCCESS && t(n.payload);
16052    });
16053  }
16054  onSocialConnected(t) {
16055    this.w3mFrame.events.onFrameEvent((n) => {
16056      n.type === Z.FRAME_CONNECT_SOCIAL_SUCCESS && t(n.payload);
16057    });
16058  }
16059  async getCapabilities() {
16060    try {
16061      return await this.request({
16062        method: "wallet_getCapabilities"
16063      }) || {};
16064    } catch {
16065      return {};
16066    }
16067  }
16068  onSetPreferredAccount(t) {
16069    this.w3mFrame.events.onFrameEvent((n) => {
16070      n.type === Z.FRAME_SET_PREFERRED_ACCOUNT_SUCCESS ? t(n.payload) : n.type === Z.FRAME_SET_PREFERRED_ACCOUNT_ERROR && t({ type: Ye.ACCOUNT_TYPES.EOA });
16071    });
16072  }
16073  getAvailableChainIds() {
16074    return Object.keys(this.w3mFrame.networks);
16075  }
16076  async rejectRpcRequests() {
16077    try {
16078      await Promise.all(Array.from(this.openRpcRequests.values()).map(async ({ abortController: t, method: n }) => {
16079        Ye.SAFE_RPC_METHODS.includes(n) || t.abort(), await this.appEvent({
16080          type: Z.APP_RPC_ABORT
16081        });
16082      })), this.openRpcRequests.clear();
16083    } catch (t) {
16084      this.w3mLogger?.logger.error({ error: t }, "Error aborting RPC request");
16085    }
16086  }
16087  async appEvent(t) {
16088    let n, r;
16089    function s(u) {
16090      return u.replace("@w3m-app/", "");
16091    }
16092    const i = [
16093      Z.APP_SYNC_DAPP_DATA,
16094      Z.APP_SYNC_THEME,
16095      Z.APP_SET_PREFERRED_ACCOUNT
16096    ], o = s(t.type);
16097    return !this.w3mFrame.iframeIsReady && !i.includes(t.type) && (r = setTimeout(() => {
16098      this.onTimeout?.("iframe_load_failed"), this.abortController.abort();
16099    }, 2e4)), await this.w3mFrame.frameLoadPromise, clearTimeout(r), [
16100      Z.APP_CONNECT_EMAIL,
16101      Z.APP_CONNECT_DEVICE,
16102      Z.APP_CONNECT_OTP,
16103      Z.APP_CONNECT_SOCIAL,
16104      Z.APP_GET_SOCIAL_REDIRECT_URI
16105    ].map(s).includes(o) && (n = setTimeout(() => {
16106      this.onTimeout?.("iframe_request_timeout"), this.abortController.abort();
16107    }, 12e4)), new Promise((u, c) => {
16108      const l = Math.random().toString(36).substring(7);
16109      this.w3mLogger?.logger.info?.({ event: t, id: l }, "Sending app event"), this.w3mFrame.events.postAppEvent({ ...t, id: l });
16110      const f = new AbortController();
16111      if (o === "RPC_REQUEST") {
16112        const m = t;
16113        this.openRpcRequests.set(l, { ...m.payload, abortController: f });
16114      }
16115      f.signal.addEventListener("abort", () => {
16116        o === "RPC_REQUEST" ? c(new Error("Request was aborted")) : o !== "GET_FARCASTER_URI" && c(new Error("Something went wrong"));
16117      });
16118      const p = (m, y) => {
16119        m.id === l && (y?.logger.info?.({ framEvent: m, id: l }, "Received frame response"), this.openRpcRequests.delete(m.id), m.type === `@w3m-frame/${o}_SUCCESS` ? (n && clearTimeout(n), r && clearTimeout(r), "payload" in m && u(m.payload), u(void 0)) : m.type === `@w3m-frame/${o}_ERROR` && (n && clearTimeout(n), r && clearTimeout(r), "payload" in m && c(new Error(m.payload?.message || "An error occurred")), c(new Error("An error occurred"))));
16120      };
16121      this.w3mFrame.events.registerFrameEventHandler(l, (m) => p(m, this.w3mLogger), this.abortController.signal);
16122    });
16123  }
16124  setNewLastEmailLoginTime() {
16125    Ve.set(Z.LAST_EMAIL_LOGIN_TIME, Date.now().toString());
16126  }
16127  setSocialLoginSuccess(t) {
16128    Ve.set(Z.SOCIAL_USERNAME, t);
16129  }
16130  setLoginSuccess(t) {
16131    t && Ve.set(Z.EMAIL, t), Ve.set(Z.EMAIL_LOGIN_USED_KEY, "true"), Ve.delete(Z.LAST_EMAIL_LOGIN_TIME);
16132  }
16133  deleteAuthLoginCache() {
16134    Ve.delete(Z.EMAIL_LOGIN_USED_KEY), Ve.delete(Z.EMAIL), Ve.delete(Z.LAST_USED_CHAIN_KEY), Ve.delete(Z.SOCIAL_USERNAME);
16135  }
16136  setLastUsedChainId(t) {
16137    t && Ve.set(Z.LAST_USED_CHAIN_KEY, String(t));
16138  }
16139  getLastUsedChainId() {
16140    const t = Ve.get(Z.LAST_USED_CHAIN_KEY) ?? void 0, n = Number(t);
16141    return isNaN(n) ? t : n;
16142  }
16143  persistSmartAccountEnabledNetworks(t) {
16144    Ve.set(Z.SMART_ACCOUNT_ENABLED_NETWORKS, t.join(","));
16145  }
16146  getRpcUrl(t) {
16147    let n = t === void 0 ? void 0 : "eip155";
16148    typeof t == "string" && (t.includes(":") ? n = wt.parseCaipNetworkId(t)?.chainNamespace : Number.isInteger(Number(t)) ? n = "eip155" : n = "solana");
16149    const r = this.getCaipNetworks(n);
16150    return (t ? r.find((i) => String(i.id) === String(t) || i.caipNetworkId === t) : r[0])?.rpcUrls.default.http?.[0];
16151  }
16152}
16153async function Yr(...e) {
16154  const t = await fetch(...e);
16155  if (!t.ok)
16156    throw new Error(`HTTP status code: ${t.status}`, {
16157      cause: t
16158    });
16159  return t;
16160}
16161class Xs {
16162  constructor({ baseUrl: t, clientId: n }) {
16163    this.baseUrl = t, this.clientId = n;
16164  }
16165  async get({ headers: t, signal: n, cache: r, ...s }) {
16166    const i = this.createUrl(s);
16167    return (await Yr(i, { method: "GET", headers: t, signal: n, cache: r })).json();
16168  }
16169  async getBlob({ headers: t, signal: n, ...r }) {
16170    const s = this.createUrl(r);
16171    return (await Yr(s, { method: "GET", headers: t, signal: n })).blob();
16172  }
16173  async post({ body: t, headers: n, signal: r, ...s }) {
16174    const i = this.createUrl(s);
16175    return (await Yr(i, {
16176      method: "POST",
16177      headers: n,
16178      body: t ? JSON.stringify(t) : void 0,
16179      signal: r
16180    })).json();
16181  }
16182  async put({ body: t, headers: n, signal: r, ...s }) {
16183    const i = this.createUrl(s);
16184    return (await Yr(i, {
16185      method: "PUT",
16186      headers: n,
16187      body: t ? JSON.stringify(t) : void 0,
16188      signal: r
16189    })).json();
16190  }
16191  async delete({ body: t, headers: n, signal: r, ...s }) {
16192    const i = this.createUrl(s);
16193    return (await Yr(i, {
16194      method: "DELETE",
16195      headers: n,
16196      body: t ? JSON.stringify(t) : void 0,
16197      signal: r
16198    })).json();
16199  }
16200  createUrl({ path: t, params: n }) {
16201    const r = new URL(t, this.baseUrl);
16202    return n && Object.entries(n).forEach(([s, i]) => {
16203      i != null && r.searchParams.append(s, i);
16204    }), this.clientId && r.searchParams.append("clientId", this.clientId), r;
16205  }
16206  sendBeacon({ body: t, ...n }) {
16207    const r = this.createUrl(n);
16208    return navigator.sendBeacon(r.toString(), t ? JSON.stringify(t) : void 0);
16209  }
16210}
16211const Ba = {
16212  getFeatureValue(e, t) {
16213    const n = t?.[e];
16214    return n === void 0 ? Qe.DEFAULT_FEATURES[e] : n;
16215  },
16216  filterSocialsByPlatform(e) {
16217    if (!e || !e.length)
16218      return e;
16219    let t = e;
16220    return q.isTelegram() && (q.isIos() && (t = t.filter((n) => n !== "google")), q.isMac() && (t = t.filter((n) => n !== "x")), q.isAndroid() && (t = t.filter((n) => !["facebook", "x"].includes(n)))), q.isMobile() && (t = t.filter((n) => n !== "facebook")), t;
16221  },
16222  isSocialsEnabled() {
16223    return Array.isArray(z.state.features?.socials) && z.state.features?.socials.length > 0 || Array.isArray(z.state.remoteFeatures?.socials) && z.state.remoteFeatures?.socials.length > 0;
16224  },
16225  isEmailEnabled() {
16226    return !!(z.state.features?.email || z.state.remoteFeatures?.email);
16227  }
16228}, X = Me({
16229  features: Qe.DEFAULT_FEATURES,
16230  projectId: "",
16231  sdkType: "appkit",
16232  sdkVersion: "html-wagmi-undefined",
16233  defaultAccountTypes: Qe.DEFAULT_ACCOUNT_TYPES,
16234  enableNetworkSwitch: !0,
16235  experimental_preferUniversalLinks: !1,
16236  remoteFeatures: {},
16237  enableMobileFullScreen: !1,
16238  coinbasePreference: "all"
16239}), z = {
16240  state: X,
16241  subscribeKey(e, t) {
16242    return Je(X, e, t);
16243  },
16244  setOptions(e) {
16245    Object.assign(X, e);
16246  },
16247  setRemoteFeatures(e) {
16248    if (!e)
16249      return;
16250    const t = { ...X.remoteFeatures, ...e };
16251    X.remoteFeatures = t, X.remoteFeatures?.socials && (X.remoteFeatures.socials = Ba.filterSocialsByPlatform(X.remoteFeatures.socials)), X.features?.pay && (X.remoteFeatures.email = !1, X.remoteFeatures.socials = !1);
16252  },
16253  setFeatures(e) {
16254    if (!e)
16255      return;
16256    X.features || (X.features = Qe.DEFAULT_FEATURES);
16257    const t = { ...X.features, ...e };
16258    X.features = t, X.features?.pay && X.remoteFeatures && (X.remoteFeatures.email = !1, X.remoteFeatures.socials = !1);
16259  },
16260  setProjectId(e) {
16261    X.projectId = e;
16262  },
16263  setCustomRpcUrls(e) {
16264    X.customRpcUrls = e;
16265  },
16266  setAllWallets(e) {
16267    X.allWallets = e;
16268  },
16269  setIncludeWalletIds(e) {
16270    X.includeWalletIds = e;
16271  },
16272  setExcludeWalletIds(e) {
16273    X.excludeWalletIds = e;
16274  },
16275  setFeaturedWalletIds(e) {
16276    X.featuredWalletIds = e;
16277  },
16278  setTokens(e) {
16279    X.tokens = e;
16280  },
16281  setTermsConditionsUrl(e) {
16282    X.termsConditionsUrl = e;
16283  },
16284  setPrivacyPolicyUrl(e) {
16285    X.privacyPolicyUrl = e;
16286  },
16287  setCustomWallets(e) {
16288    X.customWallets = e;
16289  },
16290  setIsSiweEnabled(e) {
16291    X.isSiweEnabled = e;
16292  },
16293  setIsUniversalProvider(e) {
16294    X.isUniversalProvider = e;
16295  },
16296  setSdkVersion(e) {
16297    X.sdkVersion = e;
16298  },
16299  setMetadata(e) {
16300    X.metadata = e;
16301  },
16302  setDisableAppend(e) {
16303    X.disableAppend = e;
16304  },
16305  setEIP6963Enabled(e) {
16306    X.enableEIP6963 = e;
16307  },
16308  setEnableInjected(e) {
16309    X.enableInjected = e;
16310  },
16311  setEnableCoinbase(e) {
16312    X.enableCoinbase = e;
16313  },
16314  setEnableBaseAccount(e) {
16315    X.enableBaseAccount = e;
16316  },
16317  setDebug(e) {
16318    X.debug = e;
16319  },
16320  setEnableWalletGuide(e) {
16321    X.enableWalletGuide = e;
16322  },
16323  setEnableAuthLogger(e) {
16324    X.enableAuthLogger = e;
16325  },
16326  setEnableWallets(e) {
16327    X.enableWallets = e;
16328  },
16329  setPreferUniversalLinks(e) {
16330    X.experimental_preferUniversalLinks = e;
16331  },
16332  setSIWX(e) {
16333    if (e)
16334      for (const [t, n] of Object.entries(Qe.SIWX_DEFAULTS))
16335        e[t] ??= n;
16336    X.siwx = e;
16337  },
16338  setConnectMethodsOrder(e) {
16339    X.features = {
16340      ...X.features,
16341      connectMethodsOrder: e
16342    };
16343  },
16344  setWalletFeaturesOrder(e) {
16345    X.features = {
16346      ...X.features,
16347      walletFeaturesOrder: e
16348    };
16349  },
16350  setSocialsOrder(e) {
16351    X.remoteFeatures = {
16352      ...X.remoteFeatures,
16353      socials: e
16354    };
16355  },
16356  setCollapseWallets(e) {
16357    X.features = {
16358      ...X.features,
16359      collapseWallets: e
16360    };
16361  },
16362  setEnableEmbedded(e) {
16363    X.enableEmbedded = e;
16364  },
16365  setAllowUnsupportedChain(e) {
16366    X.allowUnsupportedChain = e;
16367  },
16368  setManualWCControl(e) {
16369    X.manualWCControl = e;
16370  },
16371  setEnableNetworkSwitch(e) {
16372    X.enableNetworkSwitch = e;
16373  },
16374  setEnableMobileFullScreen(e) {
16375    X.enableMobileFullScreen = q.isMobile() && e;
16376  },
16377  setEnableReconnect(e) {
16378    X.enableReconnect = e;
16379  },
16380  setCoinbasePreference(e) {
16381    X.coinbasePreference = e;
16382  },
16383  setDefaultAccountTypes(e = {}) {
16384    Object.entries(e).forEach(([t, n]) => {
16385      n && (X.defaultAccountTypes[t] = n);
16386    });
16387  },
16388  setUniversalProviderConfigOverride(e) {
16389    X.universalProviderConfigOverride = e;
16390  },
16391  getUniversalProviderConfigOverride() {
16392    return X.universalProviderConfigOverride;
16393  },
16394  getSnapshot() {
16395    return _s(X);
16396  }
16397}, zn = Object.freeze({
16398  message: "",
16399  variant: "success",
16400  svg: void 0,
16401  open: !1,
16402  autoClose: !0
16403}), Ge = Me({
16404  ...zn
16405}), RC = {
16406  state: Ge,
16407  subscribeKey(e, t) {
16408    return Je(Ge, e, t);
16409  },
16410  showLoading(e, t = {}) {
16411    this._showMessage({ message: e, variant: "loading", ...t });
16412  },
16413  showSuccess(e) {
16414    this._showMessage({ message: e, variant: "success" });
16415  },
16416  showSvg(e, t) {
16417    this._showMessage({ message: e, svg: t });
16418  },
16419  showError(e) {
16420    const t = q.parseError(e);
16421    this._showMessage({ message: t, variant: "error" });
16422  },
16423  hide() {
16424    Ge.message = zn.message, Ge.variant = zn.variant, Ge.svg = zn.svg, Ge.open = zn.open, Ge.autoClose = zn.autoClose;
16425  },
16426  _showMessage({ message: e, svg: t, variant: n = "success", autoClose: r = zn.autoClose }) {
16427    Ge.open ? (Ge.open = !1, setTimeout(() => {
16428      Ge.message = e, Ge.variant = n, Ge.svg = t, Ge.open = !0, Ge.autoClose = r;
16429    }, 150)) : (Ge.message = e, Ge.variant = n, Ge.svg = t, Ge.open = !0, Ge.autoClose = r);
16430  }
16431}, Sn = RC, xC = {
16432  purchaseCurrencies: [
16433    {
16434      id: "2b92315d-eab7-5bef-84fa-089a131333f5",
16435      name: "USD Coin",
16436      symbol: "USDC",
16437      networks: [
16438        {
16439          name: "ethereum-mainnet",
16440          display_name: "Ethereum",
16441          chain_id: "1",
16442          contract_address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
16443        },
16444        {
16445          name: "polygon-mainnet",
16446          display_name: "Polygon",
16447          chain_id: "137",
16448          contract_address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"
16449        }
16450      ]
16451    },
16452    {
16453      id: "2b92315d-eab7-5bef-84fa-089a131333f5",
16454      name: "Ether",
16455      symbol: "ETH",
16456      networks: [
16457        {
16458          name: "ethereum-mainnet",
16459          display_name: "Ethereum",
16460          chain_id: "1",
16461          contract_address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
16462        },
16463        {
16464          name: "polygon-mainnet",
16465          display_name: "Polygon",
16466          chain_id: "137",
16467          contract_address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"
16468        }
16469      ]
16470    }
16471  ],
16472  paymentCurrencies: [
16473    {
16474      id: "USD",
16475      payment_method_limits: [
16476        {
16477          id: "card",
16478          min: "10.00",
16479          max: "7500.00"
16480        },
16481        {
16482          id: "ach_bank_account",
16483          min: "10.00",
16484          max: "25000.00"
16485        }
16486      ]
16487    },
16488    {
16489      id: "EUR",
16490      payment_method_limits: [
16491        {
16492          id: "card",
16493          min: "10.00",
16494          max: "7500.00"
16495        },
16496        {
16497          id: "ach_bank_account",
16498          min: "10.00",
16499          max: "25000.00"
16500        }
16501      ]
16502    }
16503  ]
16504}, If = q.getBlockchainApiUrl(), rt = Me({
16505  clientId: null,
16506  api: new Xs({ baseUrl: If, clientId: null }),
16507  supportedChains: { http: [], ws: [] }
16508}), ce = {
16509  state: rt,
16510  async get(e) {
16511    const { st: t, sv: n } = ce.getSdkProperties(), r = z.state.projectId, s = {
16512      ...e.params || {},
16513      st: t,
16514      sv: n,
16515      projectId: r
16516    };
16517    return rt.api.get({
16518      ...e,
16519      params: s
16520    });
16521  },
16522  getSdkProperties() {
16523    const { sdkType: e, sdkVersion: t } = z.state;
16524    return {
16525      st: e || "unknown",
16526      sv: t || "unknown"
16527    };
16528  },
16529  async isNetworkSupported(e) {
16530    if (!e)
16531      return !1;
16532    try {
16533      rt.supportedChains.http.length || await ce.getSupportedNetworks();
16534    } catch {
16535      return !1;
16536    }
16537    return rt.supportedChains.http.includes(e);
16538  },
16539  async getSupportedNetworks() {
16540    try {
16541      const e = await ce.get({
16542        path: "v1/supported-chains"
16543      });
16544      return rt.supportedChains = e, e;
16545    } catch {
16546      return rt.supportedChains;
16547    }
16548  },
16549  async fetchIdentity({ address: e }) {
16550    const t = W.getIdentityFromCacheForAddress(e);
16551    if (t)
16552      return t;
16553    const n = await ce.get({
16554      path: `/v1/identity/${e}`,
16555      params: {
16556        sender: v.state.activeCaipAddress ? q.getPlainAddress(v.state.activeCaipAddress) : void 0
16557      }
16558    });
16559    return W.updateIdentityCache({
16560      address: e,
16561      identity: n,
16562      timestamp: Date.now()
16563    }), n;
16564  },
16565  async fetchTransactions({ account: e, cursor: t, signal: n, cache: r, chainId: s }) {
16566    if (!await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId))
16567      return { data: [], next: void 0 };
16568    const o = W.getTransactionsCacheForAddress({
16569      address: e,
16570      chainId: s
16571    });
16572    if (o)
16573      return o;
16574    const a = await ce.get({
16575      path: `/v1/account/${e}/history`,
16576      params: {
16577        cursor: t,
16578        chainId: s
16579      },
16580      signal: n,
16581      cache: r
16582    });
16583    return W.updateTransactionsCache({
16584      address: e,
16585      chainId: s,
16586      timestamp: Date.now(),
16587      transactions: a
16588    }), a;
16589  },
16590  async fetchSwapQuote({ amount: e, userAddress: t, from: n, to: r, gasPrice: s }) {
16591    return await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId) ? ce.get({
16592      path: "/v1/convert/quotes",
16593      headers: {
16594        "Content-Type": "application/json"
16595      },
16596      params: {
16597        amount: e,
16598        userAddress: t,
16599        from: n,
16600        to: r,
16601        gasPrice: s
16602      }
16603    }) : { quotes: [] };
16604  },
16605  async fetchSwapTokens({ chainId: e }) {
16606    return await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId) ? ce.get({
16607      path: "/v1/convert/tokens",
16608      params: { chainId: e }
16609    }) : { tokens: [] };
16610  },
16611  async getAddressBalance({ caipNetworkId: e, address: t, method: n = "getAddressBalance", params: r }) {
16612    return rt.api.post({
16613      path: `/v1?chainId=${e}&projectId=${z.state.projectId}`,
16614      body: {
16615        id: "1",
16616        jsonrpc: "2.0",
16617        method: n,
16618        params: r ?? { address: t }
16619      }
16620    }).then((s) => s.result);
16621  },
16622  async fetchTokenPrice({ addresses: e, caipNetworkId: t = v.state.activeCaipNetwork?.caipNetworkId }) {
16623    if (!await ce.isNetworkSupported(t))
16624      return { fungibles: [] };
16625    const r = W.getTokenPriceCacheForAddresses(e);
16626    if (r)
16627      return r;
16628    const s = await rt.api.post({
16629      path: "/v1/fungible/price",
16630      body: {
16631        currency: "usd",
16632        addresses: e,
16633        projectId: z.state.projectId
16634      },
16635      headers: {
16636        "Content-Type": "application/json"
16637      }
16638    });
16639    return W.updateTokenPriceCache({
16640      addresses: e,
16641      timestamp: Date.now(),
16642      tokenPrice: s
16643    }), s;
16644  },
16645  async fetchSwapAllowance({ tokenAddress: e, userAddress: t }) {
16646    return await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId) ? ce.get({
16647      path: "/v1/convert/allowance",
16648      params: {
16649        tokenAddress: e,
16650        userAddress: t
16651      },
16652      headers: {
16653        "Content-Type": "application/json"
16654      }
16655    }) : { allowance: "0" };
16656  },
16657  async fetchGasPrice({ chainId: e }) {
16658    const { st: t, sv: n } = ce.getSdkProperties();
16659    if (!await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId))
16660      throw new Error("Network not supported for Gas Price");
16661    return ce.get({
16662      path: "/v1/convert/gas-price",
16663      headers: {
16664        "Content-Type": "application/json"
16665      },
16666      params: {
16667        chainId: e,
16668        st: t,
16669        sv: n
16670      }
16671    });
16672  },
16673  async generateSwapCalldata({ amount: e, from: t, to: n, userAddress: r, disableEstimate: s }) {
16674    if (!await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId))
16675      throw new Error("Network not supported for Swaps");
16676    return rt.api.post({
16677      path: "/v1/convert/build-transaction",
16678      headers: {
16679        "Content-Type": "application/json"
16680      },
16681      body: {
16682        amount: e,
16683        eip155: {
16684          slippage: Qe.CONVERT_SLIPPAGE_TOLERANCE
16685        },
16686        projectId: z.state.projectId,
16687        from: t,
16688        to: n,
16689        userAddress: r,
16690        disableEstimate: s
16691      }
16692    });
16693  },
16694  async generateApproveCalldata({ from: e, to: t, userAddress: n }) {
16695    const { st: r, sv: s } = ce.getSdkProperties();
16696    if (!await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId))
16697      throw new Error("Network not supported for Swaps");
16698    return ce.get({
16699      path: "/v1/convert/build-approve",
16700      headers: {
16701        "Content-Type": "application/json"
16702      },
16703      params: {
16704        userAddress: n,
16705        from: e,
16706        to: t,
16707        st: r,
16708        sv: s
16709      }
16710    });
16711  },
16712  async getBalance(e, t, n) {
16713    const { st: r, sv: s } = ce.getSdkProperties();
16714    if (!await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId))
16715      return Sn.showError("Token Balance Unavailable"), { balances: [] };
16716    const o = `${t}:${e}`, a = W.getBalanceCacheForCaipAddress(o);
16717    if (a)
16718      return a;
16719    const u = await ce.get({
16720      path: `/v1/account/${e}/balance`,
16721      params: {
16722        currency: "usd",
16723        chainId: t,
16724        forceUpdate: n,
16725        st: r,
16726        sv: s
16727      }
16728    });
16729    return W.updateBalanceCache({
16730      caipAddress: o,
16731      balance: u,
16732      timestamp: Date.now()
16733    }), u;
16734  },
16735  async lookupEnsName(e) {
16736    return await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId) ? ce.get({
16737      path: `/v1/profile/account/${e}`,
16738      params: { apiVersion: "2" }
16739    }) : { addresses: {}, attributes: [] };
16740  },
16741  async reverseLookupEnsName({ address: e }) {
16742    if (!await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId))
16743      return [];
16744    const n = v.getAccountData()?.address;
16745    return ce.get({
16746      path: `/v1/profile/reverse/${e}`,
16747      params: {
16748        sender: n,
16749        apiVersion: "2"
16750      }
16751    });
16752  },
16753  async getEnsNameSuggestions(e) {
16754    return await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId) ? ce.get({
16755      path: `/v1/profile/suggestions/${e}`,
16756      params: { zone: "reown.id" }
16757    }) : { suggestions: [] };
16758  },
16759  async registerEnsName({ coinType: e, address: t, message: n, signature: r }) {
16760    return await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId) ? rt.api.post({
16761      path: "/v1/profile/account",
16762      body: { coin_type: e, address: t, message: n, signature: r },
16763      headers: {
16764        "Content-Type": "application/json"
16765      }
16766    }) : { success: !1 };
16767  },
16768  async generateOnRampURL({ destinationWallets: e, partnerUserId: t, defaultNetwork: n, purchaseAmount: r, paymentAmount: s }) {
16769    return await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId) ? (await rt.api.post({
16770      path: "/v1/generators/onrampurl",
16771      params: {
16772        projectId: z.state.projectId
16773      },
16774      body: {
16775        destinationWallets: e,
16776        defaultNetwork: n,
16777        partnerUserId: t,
16778        defaultExperience: "buy",
16779        presetCryptoAmount: r,
16780        presetFiatAmount: s
16781      }
16782    })).url : "";
16783  },
16784  async getOnrampOptions() {
16785    if (!await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId))
16786      return { paymentCurrencies: [], purchaseCurrencies: [] };
16787    try {
16788      return await ce.get({
16789        path: "/v1/onramp/options"
16790      });
16791    } catch {
16792      return xC;
16793    }
16794  },
16795  async getOnrampQuote({ purchaseCurrency: e, paymentCurrency: t, amount: n, network: r }) {
16796    try {
16797      return await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId) ? await rt.api.post({
16798        path: "/v1/onramp/quote",
16799        params: {
16800          projectId: z.state.projectId
16801        },
16802        body: {
16803          purchaseCurrency: e,
16804          paymentCurrency: t,
16805          amount: n,
16806          network: r
16807        }
16808      }) : null;
16809    } catch {
16810      return {
16811        networkFee: { amount: n, currency: t.id },
16812        paymentSubtotal: { amount: n, currency: t.id },
16813        paymentTotal: { amount: n, currency: t.id },
16814        purchaseAmount: { amount: n, currency: t.id },
16815        quoteId: "mocked-quote-id"
16816      };
16817    }
16818  },
16819  async getSmartSessions(e) {
16820    return await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId) ? ce.get({
16821      path: `/v1/sessions/${e}`
16822    }) : [];
16823  },
16824  async revokeSmartSession(e, t, n) {
16825    return await ce.isNetworkSupported(v.state.activeCaipNetwork?.caipNetworkId) ? rt.api.post({
16826      path: `/v1/sessions/${e}/revoke`,
16827      params: {
16828        projectId: z.state.projectId
16829      },
16830      body: {
16831        pci: t,
16832        signature: n
16833      }
16834    }) : { success: !1 };
16835  },
16836  setClientId(e) {
16837    rt.clientId = e, rt.api = new Xs({ baseUrl: If, clientId: e });
16838  }
16839}, OC = Object.freeze({
16840  enabled: !0,
16841  events: []
16842}), PC = new Xs({ baseUrl: q.getAnalyticsUrl(), clientId: null }), kC = 5, UC = 60 * 1e3, En = Me({
16843  ...OC
16844}), MC = {
16845  state: En,
16846  subscribeKey(e, t) {
16847    return Je(En, e, t);
16848  },
16849  async sendError(e, t) {
16850    if (!En.enabled)
16851      return;
16852    const n = Date.now();
16853    if (En.events.filter((i) => {
16854      const o = new Date(i.properties.timestamp || "").getTime();
16855      return n - o < UC;
16856    }).length >= kC)
16857      return;
16858    const s = {
16859      type: "error",
16860      event: t,
16861      properties: {
16862        errorType: e.name,
16863        errorMessage: e.message,
16864        stackTrace: e.stack,
16865        timestamp: (/* @__PURE__ */ new Date()).toISOString()
16866      }
16867    };
16868    En.events.push(s);
16869    try {
16870      if (typeof window > "u")
16871        return;
16872      const { projectId: i, sdkType: o, sdkVersion: a } = z.state;
16873      await PC.post({
16874        path: "/e",
16875        params: {
16876          projectId: i,
16877          st: o,
16878          sv: a || "html-wagmi-4.2.2"
16879        },
16880        body: {
16881          eventId: q.getUUID(),
16882          url: window.location.href,
16883          domain: window.location.hostname,
16884          timestamp: (/* @__PURE__ */ new Date()).toISOString(),
16885          props: {
16886            type: "error",
16887            event: t,
16888            errorType: e.name,
16889            errorMessage: e.message,
16890            stackTrace: e.stack
16891          }
16892        }
16893      });
16894    } catch {
16895    }
16896  },
16897  enable() {
16898    En.enabled = !0;
16899  },
16900  disable() {
16901    En.enabled = !1;
16902  },
16903  clearEvents() {
16904    En.events = [];
16905  }
16906};
16907class lr extends Error {
16908  constructor(t, n, r) {
16909    super(t), this.originalName = "AppKitError", this.name = "AppKitError", this.category = n, this.originalError = r, r && r instanceof Error && (this.originalName = r.name), Object.setPrototypeOf(this, lr.prototype);
16910    let s = !1;
16911    if (r instanceof Error && typeof r.stack == "string" && r.stack) {
16912      const i = r.stack, o = i.indexOf(`
16913`);
16914      if (o > -1) {
16915        const a = i.substring(o + 1);
16916        this.stack = `${this.name}: ${this.message}
16917${a}`, s = !0;
16918      }
16919    }
16920    s || (Error.captureStackTrace ? Error.captureStackTrace(this, lr) : this.stack || (this.stack = `${this.name}: ${this.message}`));
16921  }
16922}
16923function Hu(e, t) {
16924  let n = "";
16925  try {
16926    e instanceof Error ? n = e.message : typeof e == "string" ? n = e : typeof e == "object" && e !== null ? Object.keys(e).length === 0 ? n = "Unknown error" : n = e?.message || JSON.stringify(e) : n = String(e);
16927  } catch (s) {
16928    n = "Unknown error", console.error("Error parsing error message", s);
16929  }
16930  const r = e instanceof lr ? e : new lr(n, t, e);
16931  throw MC.sendError(r, r.category), r;
16932}
16933function Mt(e, t = "INTERNAL_SDK_ERROR") {
16934  const n = {};
16935  return Object.keys(e).forEach((r) => {
16936    const s = e[r];
16937    if (typeof s == "function") {
16938      let i = s;
16939      s.constructor.name === "AsyncFunction" ? i = async (...o) => {
16940        try {
16941          return await s(...o);
16942        } catch (a) {
16943          return Hu(a, t);
16944        }
16945      } : i = (...o) => {
16946        try {
16947          return s(...o);
16948        } catch (a) {
16949          return Hu(a, t);
16950        }
16951      }, n[r] = i;
16952    } else
16953      n[r] = s;
16954  }), n;
16955}
16956const gt = Me({
16957  walletImages: {},
16958  networkImages: {},
16959  chainImages: {},
16960  connectorImages: {},
16961  tokenImages: {},
16962  currencyImages: {}
16963}), LC = {
16964  state: gt,
16965  subscribeNetworkImages(e) {
16966    return tt(gt.networkImages, () => e(gt.networkImages));
16967  },
16968  subscribeKey(e, t) {
16969    return Je(gt, e, t);
16970  },
16971  subscribe(e) {
16972    return tt(gt, () => e(gt));
16973  },
16974  setWalletImage(e, t) {
16975    gt.walletImages[e] = t;
16976  },
16977  setNetworkImage(e, t) {
16978    gt.networkImages[e] = t;
16979  },
16980  setChainImage(e, t) {
16981    gt.chainImages[e] = t;
16982  },
16983  setConnectorImage(e, t) {
16984    gt.connectorImages = { ...gt.connectorImages, [e]: t };
16985  },
16986  setTokenImage(e, t) {
16987    gt.tokenImages[e] = t;
16988  },
16989  setCurrencyImage(e, t) {
16990    gt.currencyImages[e] = t;
16991  }
16992}, bt = Mt(LC), qu = {
16993  // Ethereum
16994  eip155: "ba0ba0cd-17c6-4806-ad93-f9d174f17900",
16995  // Solana
16996  solana: "a1b58899-f671-4276-6a5e-56ca5bd59700",
16997  // Polkadot
16998  polkadot: "",
16999  // Bitcoin
17000  bip122: "0b4838db-0161-4ffe-022d-532bf03dba00",
17001  // Cosmos
17002  cosmos: "",
17003  // Sui
17004  sui: "",
17005  // Stacks
17006  stacks: "",
17007  // TON
17008  ton: "20f673c0-095e-49b2-07cf-eb5049dcf600",
17009  // TRON
17010  tron: "3502bb86-cc4e-420f-a387-59ea63a28b00"
17011}, Cr = Me({
17012  networkImagePromises: {},
17013  tokenImagePromises: {}
17014}), Da = {
17015  async fetchWalletImage(e) {
17016    if (e)
17017      return await ee._fetchWalletImage(e), this.getWalletImageById(e);
17018  },
17019  async fetchNetworkImage(e) {
17020    if (!e)
17021      return;
17022    const t = this.getNetworkImageById(e);
17023    return t || (Cr.networkImagePromises[e] || (Cr.networkImagePromises[e] = ee._fetchNetworkImage(e)), await Cr.networkImagePromises[e], this.getNetworkImageById(e));
17024  },
17025  /**
17026   * Fetches the token image for the given image ID.
17027   * @param imageId - The image id of the token.
17028   * @returns The token image.
17029   */
17030  async fetchTokenImage(e) {
17031    if (e)
17032      return Cr.tokenImagePromises[e] || (Cr.tokenImagePromises[e] = ee._fetchTokenImage(e)), await Cr.tokenImagePromises[e], this.getTokenImage(e);
17033  },
17034  getWalletImageById(e) {
17035    if (e)
17036      return bt.state.walletImages[e];
17037  },
17038  getWalletImage(e) {
17039    if (e?.image_url)
17040      return e?.image_url;
17041    if (e?.image_id)
17042      return bt.state.walletImages[e.image_id];
17043  },
17044  getNetworkImage(e) {
17045    if (e?.assets?.imageUrl)
17046      return e?.assets?.imageUrl;
17047    if (e?.assets?.imageId)
17048      return bt.state.networkImages[e.assets.imageId];
17049  },
17050  getNetworkImageById(e) {
17051    if (e)
17052      return bt.state.networkImages[e];
17053  },
17054  getConnectorImage(e) {
17055    if (e?.imageUrl)
17056      return e.imageUrl;
17057    if (e?.info?.icon)
17058      return e.info.icon;
17059    if (e?.imageId)
17060      return bt.state.connectorImages[e.imageId];
17061  },
17062  getChainImage(e) {
17063    return bt.state.networkImages[qu[e]];
17064  },
17065  getTokenImage(e) {
17066    if (e)
17067      return bt.state.tokenImages[e];
17068  },
17069  /**
17070   * Get the explorer wallet's image URL for the given image ID.
17071   * @param imageId - The image id of the wallet.
17072   * @returns The image URL for the wallet.
17073   */
17074  getWalletImageUrl(e) {
17075    if (!e)
17076      return "";
17077    const { projectId: t, sdkType: n, sdkVersion: r } = z.state, s = new URL(`${x.W3M_API_URL}/getWalletImage/${e}`);
17078    return s.searchParams.set("projectId", t), s.searchParams.set("st", n), s.searchParams.set("sv", r), s.toString();
17079  },
17080  /**
17081   * Get the public asset's image URL with the given image ID.
17082   * @param imageId - The image id of the asset.
17083   * @returns The image URL for the asset.
17084   */
17085  getAssetImageUrl(e) {
17086    if (!e)
17087      return "";
17088    const { projectId: t, sdkType: n, sdkVersion: r } = z.state, s = new URL(`${x.W3M_API_URL}/public/getAssetImage/${e}`);
17089    return s.searchParams.set("projectId", t), s.searchParams.set("st", n), s.searchParams.set("sv", r), s.toString();
17090  },
17091  /**
17092   * Get the image URL for the given chain namespace.
17093   * @param chainNamespace - The chain namespace to get the image URL for.
17094   * @returns The image URL for the chain namespace.
17095   */
17096  getChainNamespaceImageUrl(e) {
17097    return this.getAssetImageUrl(qu[e]);
17098  },
17099  /**
17100   * Get the image id for the given token and namespace.
17101   * @param token - The token address or 'native' to get the image id for.
17102   * @param namespace - The namespace to get the image id for.
17103   * @returns The image URL for the token.
17104   */
17105  async getImageByToken(e, t) {
17106    if (e === "native") {
17107      const r = x.NATIVE_IMAGE_IDS_BY_NAMESPACE[t] ?? null;
17108      return r ? Da.fetchNetworkImage(r) : void 0;
17109    }
17110    const [, n] = Object.entries(x.TOKEN_SYMBOLS_BY_ADDRESS).find(([r]) => r.toLowerCase() === e.toLowerCase()) ?? [];
17111    if (n)
17112      return Da.fetchTokenImage(n);
17113  }
17114}, ze = {
17115  PHANTOM: {
17116    id: "a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",
17117    url: "https://phantom.app",
17118    androidPackage: "app.phantom"
17119  },
17120  SOLFLARE: {
17121    id: "1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",
17122    url: "https://solflare.com"
17123  },
17124  COINBASE: {
17125    id: "d0ca99ff52b99abc48743dad0f7fc891e041be73574f7fac4afe5d4bb83845c8",
17126    url: "https://go.cb-w.com",
17127    evmDeeplink: "cbwallet://miniapp"
17128  },
17129  /*
17130   * Got details from their npm package:
17131   * https://www.npmjs.com/package/@binance/w3w-utils?activeTab=code
17132   * https://developers.binance.com/docs/binance-w3w/evm-compatible-provider#getdeeplink
17133   */
17134  BINANCE: {
17135    id: "2fafea35bb471d22889ccb49c08d99dd0a18a37982602c33f696a5723934ba25",
17136    appId: "yFK5FCqYprrXDiVFbhyRx7",
17137    deeplink: "bnc://app.binance.com/mp/app",
17138    url: "https://app.binance.com/en/download"
17139  }
17140}, BC = {
17141  /**
17142   * Checks if a wallet is a custom deeplink wallet that uses Universal Links
17143   * instead of WalletConnect deeplinks for the given chain namespace.
17144   *
17145   * Only returns true for supported wallet-chain combinations:
17146   * - Phantom: Solana, EVM, and Bitcoin (doesn't support WalletConnect)
17147   * - Solflare: Solana only
17148   * - Coinbase: Solana and EVM
17149   * - Binance: Bitcoin only
17150   *
17151   * @param {string} id - The id of the wallet.
17152   * @param {ChainControllerState['activeChain']} namespace - The chain namespace.
17153   * @returns {boolean} Whether the wallet is a custom deeplink wallet for the given namespace.
17154   */
17155  isCustomDeeplinkWallet(e, t) {
17156    return e === ze.PHANTOM.id ? t === x.CHAIN.SOLANA || t === x.CHAIN.EVM || t === x.CHAIN.BITCOIN : e === ze.SOLFLARE.id ? t === x.CHAIN.SOLANA : e === ze.COINBASE.id ? t === x.CHAIN.SOLANA || t === x.CHAIN.EVM : e === ze.BINANCE.id ? t === x.CHAIN.BITCOIN : !1;
17157  },
17158  /**
17159   * Handles mobile wallet redirection for wallets that have Universal Links and doesn't support WalletConnect Deep Links.
17160   *
17161   * @param {string} id - The id of the wallet.
17162   * @param {ChainNamespace} namespace - The namespace of the chain.
17163   * @param {object} options - Optional configuration.
17164   * @param {boolean} options.isCoinbaseDisabled - Whether Coinbase wallet is disabled. When true, always trigger deeplink.
17165   */
17166  handleMobileDeeplinkRedirect(e, t, n) {
17167    const r = window.location.href, s = encodeURIComponent(r), i = n?.isCoinbaseDisabled ?? !1;
17168    if (e === ze.PHANTOM.id && !("phantom" in window)) {
17169      const o = r.startsWith("https") ? "https" : "http", a = r.split("/")[2], u = encodeURIComponent(`${o}://${a}`), c = `${ze.PHANTOM.url}/ul/browse/${s}?ref=${u}`;
17170      if (q.isAndroid()) {
17171        const l = `intent://browse/${s}?ref=${u}#Intent;scheme=phantom;package=${ze.PHANTOM.androidPackage};end`;
17172        window.location.href = l;
17173      } else
17174        window.location.href = c;
17175    }
17176    if (e === ze.SOLFLARE.id && t === x.CHAIN.SOLANA && !("solflare" in window) && (window.location.href = `${ze.SOLFLARE.url}/ul/v1/browse/${s}?ref=${s}`), t === x.CHAIN.SOLANA && e === ze.COINBASE.id && (i || !("coinbaseSolana" in window)) && (window.location.href = `${ze.COINBASE.url}/dapp?cb_url=${s}`), t === x.CHAIN.EVM && e === ze.COINBASE.id && (i || !("coinbaseWalletExtension" in window)) && (window.location.href = `${ze.COINBASE.evmDeeplink}?url=${s}`), t === x.CHAIN.BITCOIN && e === ze.BINANCE.id && !("binancew3w" in window)) {
17177      const o = v.state.activeCaipNetwork, a = window.btoa("/pages/browser/index"), u = window.btoa(`url=${s}&defaultChainId=${o?.id ?? 1}`), c = new URL(ze.BINANCE.deeplink);
17178      c.searchParams.set("appId", ze.BINANCE.appId), c.searchParams.set("startPagePath", a), c.searchParams.set("startPageQuery", u);
17179      const l = new URL(ze.BINANCE.url);
17180      l.searchParams.set("_dp", window.btoa(c.toString())), window.location.href = l.toString();
17181    }
17182  }
17183}, DC = q.getAnalyticsUrl(), FC = new Xs({ baseUrl: DC, clientId: null }), jC = ["MODAL_CREATED"], WC = 45, Gu = 1e3 * 10, He = Me({
17184  timestamp: Date.now(),
17185  lastFlush: Date.now(),
17186  reportedErrors: {},
17187  data: {
17188    type: "track",
17189    event: "MODAL_CREATED"
17190  },
17191  pendingEvents: [],
17192  subscribedToVisibilityChange: !1,
17193  walletImpressions: []
17194}), ve = {
17195  state: He,
17196  subscribe(e) {
17197    return tt(He, () => e(He));
17198  },
17199  getSdkProperties() {
17200    const { projectId: e, sdkType: t, sdkVersion: n } = z.state;
17201    return {
17202      projectId: e,
17203      st: t,
17204      sv: n || "html-wagmi-4.2.2"
17205    };
17206  },
17207  shouldFlushEvents() {
17208    const e = JSON.stringify(He.pendingEvents).length / 1024 > WC, t = He.lastFlush + Gu < Date.now();
17209    return e || t;
17210  },
17211  _setPendingEvent(e) {
17212    try {
17213      let t = v.getAccountData()?.address;
17214      if ("address" in e.data && e.data.address && (t = e.data.address), jC.includes(e.data.event) || typeof window > "u")
17215        return;
17216      const n = v.getActiveCaipNetwork()?.caipNetworkId;
17217      this.state.pendingEvents.push({
17218        eventId: q.getUUID(),
17219        url: window.location.href,
17220        domain: window.location.hostname,
17221        timestamp: e.timestamp,
17222        props: {
17223          ...e.data,
17224          address: t,
17225          properties: {
17226            ..."properties" in e.data ? e.data.properties : {},
17227            caipNetworkId: n
17228          }
17229        }
17230      }), He.reportedErrors.FORBIDDEN = !1, ve.shouldFlushEvents() && ve._submitPendingEvents();
17231    } catch (t) {
17232      console.warn("_setPendingEvent", t);
17233    }
17234  },
17235  sendEvent(e) {
17236    He.timestamp = Date.now(), He.data = e;
17237    const t = [
17238      "INITIALIZE",
17239      "CONNECT_SUCCESS",
17240      "SOCIAL_LOGIN_SUCCESS"
17241    ];
17242    (z.state.features?.analytics || t.includes(e.event)) && ve._setPendingEvent(He), this.subscribeToFlushTriggers();
17243  },
17244  /**
17245   * Adds a wallet impression item to the aggregated list. These are flushed as a single
17246   * WALLET_IMPRESSION_V2 batch in _submitPendingEvents.
17247   */
17248  sendWalletImpressionEvent(e) {
17249    He.walletImpressions.push(e);
17250  },
17251  _transformPendingEventsForBatch(e) {
17252    try {
17253      return e.filter((t) => t.props.event !== "WALLET_IMPRESSION_V2");
17254    } catch {
17255      return e;
17256    }
17257  },
17258  _submitPendingEvents() {
17259    if (He.lastFlush = Date.now(), !(He.pendingEvents.length === 0 && He.walletImpressions.length === 0))
17260      try {
17261        const e = ve._transformPendingEventsForBatch(He.pendingEvents);
17262        He.walletImpressions.length && e.push({
17263          eventId: q.getUUID(),
17264          url: window.location.href,
17265          domain: window.location.hostname,
17266          timestamp: Date.now(),
17267          props: {
17268            type: "track",
17269            event: "WALLET_IMPRESSION_V2",
17270            items: [...He.walletImpressions]
17271          }
17272        }), FC.sendBeacon({
17273          path: "/batch",
17274          params: ve.getSdkProperties(),
17275          body: e
17276        }), He.reportedErrors.FORBIDDEN = !1, He.pendingEvents = [], He.walletImpressions = [];
17277      } catch {
17278        He.reportedErrors.FORBIDDEN = !0;
17279      }
17280  },
17281  subscribeToFlushTriggers() {
17282    He.subscribedToVisibilityChange || typeof document > "u" || (He.subscribedToVisibilityChange = !0, document?.addEventListener?.("visibilitychange", () => {
17283      document.visibilityState === "hidden" && ve._submitPendingEvents();
17284    }), document?.addEventListener?.("freeze", () => {
17285      ve._submitPendingEvents();
17286    }), window?.addEventListener?.("pagehide", () => {
17287      ve._submitPendingEvents();
17288    }), setInterval(() => {
17289      ve._submitPendingEvents();
17290    }, Gu));
17291  }
17292}, $C = q.getApiUrl(), st = new Xs({
17293  baseUrl: $C,
17294  clientId: null
17295}), HC = 40, zu = 4, qC = 20, ue = Me({
17296  promises: {},
17297  page: 1,
17298  count: 0,
17299  featured: [],
17300  allFeatured: [],
17301  recommended: [],
17302  allRecommended: [],
17303  wallets: [],
17304  filteredWallets: [],
17305  search: [],
17306  isAnalyticsEnabled: !1,
17307  excludedWallets: [],
17308  isFetchingRecommendedWallets: !1,
17309  explorerWallets: [],
17310  explorerFilteredWallets: [],
17311  plan: {
17312    tier: "none",
17313    hasExceededUsageLimit: !1,
17314    limits: {
17315      isAboveRpcLimit: !1,
17316      isAboveMauLimit: !1
17317    }
17318  }
17319}), ee = {
17320  state: ue,
17321  subscribeKey(e, t) {
17322    return Je(ue, e, t);
17323  },
17324  _getSdkProperties() {
17325    const { projectId: e, sdkType: t, sdkVersion: n } = z.state;
17326    return {
17327      projectId: e,
17328      st: t || "appkit",
17329      sv: n || "html-wagmi-4.2.2"
17330    };
17331  },
17332  _filterOutExtensions(e) {
17333    return z.state.isUniversalProvider ? e.filter((t) => !!(t.mobile_link || t.desktop_link || t.webapp_link)) : e;
17334  },
17335  async _fetchWalletImage(e) {
17336    const t = `${st.baseUrl}/getWalletImage/${e}`, n = await st.getBlob({ path: t, params: ee._getSdkProperties() });
17337    bt.setWalletImage(e, URL.createObjectURL(n));
17338  },
17339  async _fetchNetworkImage(e) {
17340    const t = `${st.baseUrl}/public/getAssetImage/${e}`, n = await st.getBlob({ path: t, params: ee._getSdkProperties() });
17341    bt.setNetworkImage(e, URL.createObjectURL(n));
17342  },
17343  async _fetchConnectorImage(e) {
17344    const t = `${st.baseUrl}/public/getAssetImage/${e}`, n = await st.getBlob({ path: t, params: ee._getSdkProperties() });
17345    bt.setConnectorImage(e, URL.createObjectURL(n));
17346  },
17347  async _fetchCurrencyImage(e) {
17348    const t = `${st.baseUrl}/public/getCurrencyImage/${e}`, n = await st.getBlob({ path: t, params: ee._getSdkProperties() });
17349    bt.setCurrencyImage(e, URL.createObjectURL(n));
17350  },
17351  async _fetchTokenImage(e) {
17352    const t = `${st.baseUrl}/public/getTokenImage/${e}`, n = await st.getBlob({ path: t, params: ee._getSdkProperties() });
17353    bt.setTokenImage(e, URL.createObjectURL(n));
17354  },
17355  _filterWalletsByPlatform(e) {
17356    const t = e.length, n = q.isMobile() ? e?.filter((s) => s.mobile_link || s.webapp_link ? !0 : Object.values(ze).map((o) => o.id).includes(s.id)) : e, r = t - n.length;
17357    return { filteredWallets: n, mobileFilteredOutWalletsLength: r };
17358  },
17359  async fetchProjectConfig() {
17360    return (await st.get({
17361      path: "/appkit/v1/config",
17362      params: ee._getSdkProperties()
17363    })).features;
17364  },
17365  async fetchUsage() {
17366    try {
17367      const e = await st.get({
17368        path: "/appkit/v1/project-limits",
17369        params: ee._getSdkProperties()
17370      }
17370), { tier: t, isAboveMauLimit: n, isAboveRpcLimit: r } = e.planLimits, s = t === "starter", i = n || r;
17371      ee.state.plan = {
17372        tier: t,
17373        hasExceededUsageLimit: s && i,
17374        limits: {
17375          isAboveRpcLimit: r,
17376          isAboveMauLimit: n
17377        }
17378      };
17379    } catch (e) {
17380      console.warn("Failed to fetch usage", e);
17381    }
17382  },
17383  async fetchAllowedOrigins() {
17384    try {
17385      const { allowedOrigins: e } = await st.get({
17386        path: "/projects/v1/origins",
17387        params: ee._getSdkProperties()
17388      });
17389      return e;
17390    } catch (e) {
17391      if (e instanceof Error && e.cause instanceof Response) {
17392        const t = e.cause.status;
17393        if (t === x.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)
17394          throw new Error("RATE_LIMITED", { cause: e });
17395        if (t >= x.HTTP_STATUS_CODES.SERVER_ERROR && t < 600)
17396          throw new Error("SERVER_ERROR", { cause: e });
17397        return [];
17398      }
17399      return [];
17400    }
17401  },
17402  async fetchNetworkImages() {
17403    const t = v.getAllRequestedCaipNetworks()?.map(({ assets: n }) => n?.imageId).filter(Boolean).filter((n) => !Da.getNetworkImageById(n));
17404    t && await Promise.allSettled(t.map((n) => ee._fetchNetworkImage(n)));
17405  },
17406  async fetchConnectorImages() {
17407    const { connectors: e } = H.state, t = e.map(({ imageId: n }) => n).filter(Boolean);
17408    await Promise.allSettled(t.map((n) => ee._fetchConnectorImage(n)));
17409  },
17410  async fetchCurrencyImages(e = []) {
17411    await Promise.allSettled(e.map((t) => ee._fetchCurrencyImage(t)));
17412  },
17413  async fetchTokenImages(e = []) {
17414    await Promise.allSettled(e.map((t) => ee._fetchTokenImage(t)));
17415  },
17416  async fetchWallets(e) {
17417    const t = e.exclude ?? [];
17418    ee._getSdkProperties().sv.startsWith("html-core-") && t.push(...Object.values(ze).map((o) => o.id));
17419    const r = await st.get({
17420      path: "/getWallets",
17421      params: {
17422        ...ee._getSdkProperties(),
17423        ...e,
17424        page: String(e.page),
17425        entries: String(e.entries),
17426        include: e.include?.join(",") || void 0,
17427        exclude: t.join(",") || void 0,
17428        include_pay_only: e.include_pay_only ? "true" : void 0
17429      }
17430    }), { filteredWallets: s, mobileFilteredOutWalletsLength: i } = ee._filterWalletsByPlatform(r?.data);
17431    return {
17432      data: s || [],
17433      // Keep original count for display on main page
17434      count: r?.count,
17435      mobileFilteredOutWalletsLength: i
17436    };
17437  },
17438  async prefetchWalletRanks() {
17439    const e = H.state.connectors;
17440    if (!e?.length)
17441      return;
17442    const t = {
17443      page: 1,
17444      entries: 20,
17445      badge: "certified"
17446    };
17447    if (t.names = e.map((s) => s.name).join(","), v.state.activeChain === x.CHAIN.EVM) {
17448      const s = [
17449        ...e.flatMap((i) => i.connectors?.map((o) => o.info?.rdns) || []),
17450        ...e.map((i) => i.info?.rdns)
17451      ].filter((i) => typeof i == "string" && i.length > 0);
17452      s.length && (t.rdns = s.join(","));
17453    }
17454    const { data: n } = await ee.fetchWallets(t);
17455    ue.explorerWallets = n, H.extendConnectorsWithExplorerWallets(n);
17456    const r = v.getRequestedCaipNetworkIds().join(",");
17457    ue.explorerFilteredWallets = n.filter((s) => s.chains?.some((i) => r.includes(i)));
17458  },
17459  async fetchFeaturedWallets() {
17460    const { featuredWalletIds: e } = z.state;
17461    if (e?.length) {
17462      const t = {
17463        ...ee._getSdkProperties(),
17464        page: 1,
17465        entries: e?.length ?? zu,
17466        include: e
17467      }, { data: n } = await ee.fetchWallets(t), r = [...n].sort((i, o) => e.indexOf(i.id) - e.indexOf(o.id)), s = r.map((i) => i.image_id).filter(Boolean);
17468      await Promise.allSettled(s.map((i) => ee._fetchWalletImage(i))), ue.featured = r, ue.allFeatured = r;
17469    }
17470  },
17471  async fetchRecommendedWallets() {
17472    try {
17473      ue.isFetchingRecommendedWallets = !0;
17474      const { includeWalletIds: e, excludeWalletIds: t, featuredWalletIds: n } = z.state, r = [...t ?? [], ...n ?? []].filter(Boolean), s = v.getRequestedCaipNetworkIds().join(","), i = {
17475        page: 1,
17476        entries: zu,
17477        include: e,
17478        exclude: r,
17479        chains: s
17480      }, { data: o, count: a } = await ee.fetchWallets(i), u = W.getRecentWallets(), c = o.map((f) =>
17480 f.image_id).filter(Boolean), l = u.map((f) => f.image_id).filter(Boolean);
17481      await Promise.allSettled([...c, ...l].map((f) => ee._fetchWalletImage(f))), ue.recommended = o, ue.allRecommended = o, ue.count = a ?? 0;
17482    } catch {
17483    } finally {
17484      ue.isFetchingRecommendedWallets = !1;
17485    }
17486  },
17487  async fetchWalletsByPage({ page: e, entries: t, badge: n, include: r, exclude: s, includePayOnly: i, sort: o }) {
17488    const { includeWalletIds: a, excludeWalletIds: u, featuredWalletIds: c } = z.state, l = v.getRequestedCaipNetworkIds().join(","), f = [
17489      ...ue.recommended.map(({ id: _ }) => _),
17490      ...u ?? [],
17491      ...c ?? []
17492    ].filter(Boolean), p = {
17493      page: e,
17494      entries: t ?? HC,
17495      include: r ?? a,
17496      exclude: s ?? f,
17497      badge_type: n,
17498      include_pay_only: i,
17499      sort: o,
17500      chains: l
17501    }, { data: m, count: y, mobileFilteredOutWalletsLength: b } = await ee.fetchWallets(p);
17502    ue.mobileFilteredOutWalletsLength = b + (ue.mobileFilteredOutWalletsLength ?? 0);
17503    const C = m.slice(0, qC).map((_) => _.image_id).filter(Boolean);
17504    await Promise.allSettled(C.map((_) => ee._fetchWalletImage(_))), ue.wallets = q.uniqueBy([...ue.wallets, ...ee._filterOutExtensions(m)], "id").filter((_) => _.chains?.some((R) => l.includes(R))), ue.count = y > ue.count ? y : ue.count, ue.page = e;
17505  },
17506  async initializeExcludedWallets({ ids: e }) {
17507    const t = {
17508      page: 1,
17509      entries: e.length,
17510      include: e
17511    }, { data: n } = await ee.fetchWallets(t);
17512    n && n.forEach((r) => {
17513      ue.excludedWallets.push({ rdns: r.rdns, name: r.name });
17514    });
17515  },
17516  async searchWallet({ search: e, badge: t, entries: n, page: r, include: s, exclude: i, includePayOnly: o, sort: a }) {
17517    const { includeWalletIds: u, excludeWalletIds: c } = z.state, l = v.getRequestedCaipNetworkIds().join(",");
17518    ue.search = [];
17519    const f = {
17520      page: r ?? 1,
17521      entries: n ?? 100,
17522      search: e?.trim() || void 0,
17523      badge_type: t,
17524      include: s ?? u,
17525      exclude: i ?? c,
17526      include_pay_only: o,
17527      sort: a,
17528      chains: l
17529    }, { data: p } = await ee.fetchWallets(f);
17530    ve.sendEvent({
17531      type: "track",
17532      event: "SEARCH_WALLET",
17533      properties: { badge: t ?? "", search: e ?? "" }
17534    });
17535    const m = p.map((y) => y.image_id).filter(Boolean);
17536    await Promise.allSettled([
17537      ...m.map((y) => ee._fetchWalletImage(y)),
17538      q.wait(300)
17539    ]), ue.search = ee._filterOutExtensions(p);
17540  },
17541  initPromise(e, t) {
17542    const n = ue.promises[e];
17543    return n || (ue.promises[e] = t());
17544  },
17545  prefetch({ fetchConnectorImages: e = !0, fetchFeaturedWallets: t = !0, fetchRecommendedWallets: n = !0, fetchNetworkImages: r = !0, fetchWalletRanks: s = !0 } = {}) {
17546    const i = [
17547      e && ee.initPromise("connectorImages", ee.fetchConnectorImages),
17548      t && ee.initPromise("featuredWallets", ee.fetchFeaturedWallets),
17549      n && ee.initPromise("recommendedWallets", ee.fetchRecommendedWallets),
17550      r && ee.initPromise("networkImages", ee.fetchNetworkImages),
17551      s && ee.initPromise("walletRanks", ee.prefetchWalletRanks)
17552    ].filter(Boolean);
17553    return Promise.allSettled(i);
17554  },
17555  prefetchAnalyticsConfig() {
17556    z.state.features?.analytics && ee.fetchAnalyticsConfig();
17557  },
17558  async fetchAnalyticsConfig() {
17559    try {
17560      const { isAnalyticsEnabled: e } = await st.get({
17561        path: "/getAnalyticsConfig",
17562        params: ee._getSdkProperties()
17563      });
17564      z.setFeatures({ analytics: e });
17565    } catch {
17566      z.setFeatures({ analytics: !1 });
17567    }
17568  },
17569  filterByNamespaces(e) {
17570    if (!e?.length) {
17571      ue.featured = ue.allFeatured, ue.recommended = ue.allRecommended;
17572      return;
17573    }
17574    const t = v.getRequestedCaipNetworkIds().join(",");
17575    ue.featured = ue.allFeatured.filter((n) => n.chains?.some((r) => t.includes(r))), ue.recommended = ue.allRecommended.filter((n) => n.chains?.some((r) => t.includes(r))), ue.filteredWallets = ue.wallets.filter((n) => n.chains?.some((r) => t.includes(r)));
17576  },
17577  clearFilterByNamespaces() {
17578    ue.filteredWallets = [];
17579  },
17580  setFilterByNamespace(e) {
17581    if (!e) {
17582      ue.featured = ue.allFeatured, ue.recommended = ue.allRecommended;
17583      return;
17584    }
17585    const t = v.getRequestedCaipNetworkIds().join(",");
17586    ue.featured = ue.allFeatured.filter((n) => n.chains?.some((r) => t.includes(r))), ue.recommended = ue.allRecommended.filter((n) => n.chains?.some((r) => t.includes(r))), ue.filteredWallets = ue.wallets.filter((n) => n.chains?.some((r) => t.includes(r)));
17587  }
17588}, Qn = {
17589  filterOutDuplicatesByRDNS(e) {
17590    const t = H.state.connectors, n = W.getRecentWallets(), r = t.map((a) => a.info?.rdns).filter(Boolean), s = n.map((a) => a.rdns).filter(Boolean), i = r.concat(s);
17591    if (i.includes("io.metamask.mobile") && q.isMobile()) {
17592      const a = i.indexOf("io.metamask.mobile");
17593      i[a] = "io.metamask";
17594    }
17595    return e.filter((a) => !(a?.rdns && i.includes(String(a.rdns)) || !a?.rdns && t.some((c) => c.name === a.name)));
17596  },
17597  filterOutDuplicatesByIds(e) {
17598    const t = H.state.connectors.filter((a) => a.type === "ANNOUNCED" || a.type === "INJECTED" || a.type === "MULTI_CHAIN"), n = W.getRecentWallets(), r = t.map((a) => a.explorerId || a.explorerWallet?.id || a.id), s = n.map((a) => a.id), i = r.concat(s);
17599    return e.filter((a) => !i.includes(a?.id));
17600  },
17601  filterOutDuplicateWallets(e) {
17602    const t = this.filterOutDuplicatesByRDNS(e);
17603    return this.filterOutDuplicatesByIds(t);
17604  },
17605  /**
17606   * Marks wallets as installed based on available connectors and sorts them
17607   * according to both installation status and featuredWalletIds order.
17608   *
17609   * @param wallets - Array of wallets to process
17610   * @returns Array of wallets marked as installed and sorted by priority
17611   */
17612  markWalletsAsInstalled(e) {
17613    const { connectors: t } = H.state, { featuredWalletIds: n } = z.state, r = t.filter((o) => o.type === "ANNOUNCED").reduce((o, a) => (a.info?.rdns && (o[a.info.rdns] = !0), o), {});
17614    return e.map((o) => ({
17615      ...o,
17616      installed: !!o.rdns && !!r[o.rdns ?? ""]
17617    })).sort((o, a) => {
17618      const u = Number(a.installed) - Number(o.installed);
17619      if (u !== 0)
17620        return u;
17621      if (n?.length) {
17622        const c = n.indexOf(o.id), l = n.indexOf(a.id);
17623        if (c !== -1 && l !== -1)
17624          return c - l;
17625        if (c !== -1)
17626          return -1;
17627        if (l !== -1)
17628          return 1;
17629      }
17630      return 0;
17631    });
17632  },
17633  getConnectOrderMethod(e, t) {
17634    const n = e?.connectMethodsOrder || z.state.features?.connectMethodsOrder, r = t || H.state.connectors;
17635    if (n)
17636      return n;
17637    const { injected: s, announced: i } = lt.getConnectorsByType(r, ee.state.recommended, ee.state.featured), o = s.filter(lt.showConnector), a = i.filter(lt.showConnector);
17638    return o.length || a.length ? ["wallet", "email", "social"] : Qe.DEFAULT_CONNECT_METHOD_ORDER;
17639  },
17640  isExcluded(e) {
17641    const t = !!e.rdns && ee.state.excludedWallets.some((r) => r.rdns === e.rdns), n = !!e.name && ee.state.excludedWallets.some((r) => uf.isLowerCaseMatch(r.name, e.name));
17642    return t || n;
17643  },
17644  markWalletsWithDisplayIndex(e) {
17645    return e.map((t, n) => ({ ...t, display_index: n }));
17646  },
17647  /**
17648   * Filters wallets based on WalletConnect support and platform requirements.
17649   *
17650   * On mobile only wallets with WalletConnect support and some mandatory wallets are shown.
17651   * On desktop with Appkit Core only wallets with WalletConnect support are shown.
17652   * On desktop with Appkit all wallets are shown.
17653   *
17654   * @param wallets - Array of wallets to filter
17655   * @returns Filtered array of wallets based on WalletConnect support and platform
17656   */
17657  filterWalletsByWcSupport(e) {
17658    return J.state.wcBasic ? e.filter((t) => t.supports_wc) : q.isMobile() ? e.filter((t) => t.supports_wc || Qe.MANDATORY_WALLET_IDS_ON_MOBILE.includes(t.id)) : e;
17659  },
17660  getWalletConnectWallets(e) {
17661    const t = [...ee.state.featured, ...ee.state.recommended];
17662    ee.state.filteredWallets?.length > 0 ? t.push(...ee.state.filteredWallets) : t.push(...e);
17663    const n = q.uniqueBy(t, "id"), r = Qn.markWalletsAsInstalled(n), s = Qn.filterWalletsByWcSupport(r);
17664    return Qn.markWalletsWithDisplayIndex(s);
17665  }
17666}, lt = {
17667  getConnectorsByType(e, t, n) {
17668    const { customWallets: r } = z.state, s = W.getRecentWallets(), i = Qn.filterOutDuplicateWallets(t), o = Qn.filterOutDuplicateWallets(n), a = e.filter((f) => f.type === "MULTI_CHAIN"), u = e.filter((f) => f.type === "ANNOUNCED"), c = e.filter((f) => f.type === "INJECTED"), l = e.filter((f) =>
17668 f.type === "EXTERNAL");
17669    return {
17670      custom: r,
17671      recent: s,
17672      external: l,
17673      multiChain: a,
17674      announced: u,
17675      injected: c,
17676      recommended: i,
17677      featured: o
17678    };
17679  },
17680  showConnector(e) {
17681    const t = e.info?.rdns, n = !!t && ee.state.excludedWallets.some((a) => !!a.rdns && a.rdns === t), r = !!e.name && ee.state.excludedWallets.some((a) => uf.isLowerCaseMatch(a.name, e.name));
17682    if (e.type === "INJECTED" && (e.name === "Browser Wallet" && (!q.isMobile() || q.isMobile() && !t && !J.checkInstalled()) || n || r) || (e.type === "ANNOUNCED" || e.type === "EXTERNAL") && (n || r))
17683      return !1;
17684    const { includeWalletIds: s, excludeWalletIds: i } = z.state;
17685    if (e.type === "INJECTED" || e.type === "ANNOUNCED" || e.type === "MULTI_CHAIN") {
17686      const a = e.explorerId || e.explorerWallet?.id;
17687      if (i?.length && a && i.includes(a) || s?.length && (!a || !s.includes(a)))
17688        return !1;
17689    }
17690    return !0;
17691  },
17692  /**
17693   * Returns true if the user is connected to a WalletConnect connector in the any of the available namespaces.
17694   * @returns boolean
17695   */
17696  getIsConnectedWithWC() {
17697    return Array.from(v.state.chains.values()).some((n) => H.getConnectorId(n.namespace) === x.CONNECTOR_ID.WALLET_CONNECT);
17698  },
17699  /**
17700   * Returns the connector positions in the order of the user's preference.
17701   * @returns ConnectorTypeOrder[]
17702   */
17703  getConnectorTypeOrder({ recommended: e, featured: t, custom: n, recent: r, announced: s, injected: i, multiChain: o, external: a, overriddenConnectors: u = z.state.features?.connectorTypeOrder ?? [] }) {
17704    const l = [
17705      { type: "walletConnect", isEnabled: !0 },
17706      { type: "recent", isEnabled: r.length > 0 },
17707      { type: "injected", isEnabled: [...i, ...s, ...o].length > 0 },
17708      { type: "featured", isEnabled: t.length > 0 },
17709      { type: "custom", isEnabled: n && n.length > 0 },
17710      { type: "external", isEnabled: a.length > 0 },
17711      { type: "recommended", isEnabled: e.length > 0 }
17712    ].filter((y) => y.isEnabled), f = new Set(l.map((y) => y.type)), p = u.filter((y) => f.has(y)).map((y) => ({ type: y, isEnabled: !0 })), m = l.filter(({ type: y }) => !p.some(({ type: C }) => C === y));
17713    return Array.from(new Set([...p, ...m].map(({ type: y }) => y)));
17714  },
17715  sortConnectorsByExplorerWallet(e) {
17716    return [...e].sort((t, n) => t.explorerWallet && n.explorerWallet ? (t.explorerWallet.order ?? 0) - (n.explorerWallet.order ?? 0) : t.explorerWallet ? -1 : n.explorerWallet ? 1 : 0);
17717  },
17718  /**
17719   * Returns the priority of a connector. Base Account has highest priority, followed by Coinbase then the rest.
17720   *
17721   * This is needed because Base Account and Coinbase share the same explorer wallet ID.
17722   * Without prioritization, selecting Base Account could incorrectly trigger the Coinbase Wallet extension.
17723   *
17724   * @param connector - The connector to get the priority of.
17725   * @returns The priority of the connector.
17726   */
17727  getPriority(e) {
17728    return e.id === x.CONNECTOR_ID.BASE_ACCOUNT ? 0 : e.id === x.CONNECTOR_ID.COINBASE || e.id === x.CONNECTOR_ID.COINBASE_SDK ? 1 : 2;
17729  },
17730  /**
17731   * Sorts connectors by priority.
17732   * @param connectors - The connectors to sort.
17733   * @returns Sorted connectors.
17734   */
17735  sortConnectorsByPriority(e) {
17736    return [...e].sort((t, n) => lt.getPriority(t) - lt.getPriority(n));
17737  },
17738  getAuthName({ email: e, socialUsername: t, socialProvider: n }) {
17739    return t ? n && n === "discord" && t.endsWith("0") ? t.slice(0, -1) : t : e.length > 30 ? `${e.slice(0, -3)}...` : e;
17740  },
17741  async fetchProviderData(e) {
17742    try {
17743      if (e.name === "Browser Wallet" && !q.isMobile())
17744        return { accounts: [], chainId: void 0 };
17745      if (e.id === x.CONNECTOR_ID.AUTH)
17746        return { accounts: [], chainId: void 0 };
17747      const [t, n] = await Promise.all([
17748        e.provider?.request({ method: "eth_accounts" }),
17749        e.provider?.request({ method: "eth_chainId" }).then((r) => Number(r))
17750      ]);
17751      return { accounts: t, chainId: n };
17752    } catch (t) {
17753      return console.warn(`Failed to fetch provider data for ${e.name}`, t), { accounts: [], chainId: void 0 };
17754    }
17755  },
17756  /**
17757   * Filter out duplicate custom wallets by RDNS
17758   * @param wallets
17759   */
17760  getFilteredCustomWallets(e) {
17761    const t = W.getRecentWallets(), n = H.state.connectors.map((o) =>
17761 o.info?.rdns).filter(Boolean), r = t.map((o) => o.rdns).filter(Boolean), s = n.concat(r);
17762    if (s.includes("io.metamask.mobile") && q.isMobile()) {
17763      const o = s.indexOf("io.metamask.mobile");
17764      s[o] = "io.metamask";
17765    }
17766    return e.filter((o) => !s.includes(String(o?.rdns)));
17767  },
17768  hasWalletConnector(e) {
17769    return H.state.connectors.some((t) => t.id === e.id || t.name === e.name);
17770  },
17771  isWalletCompatibleWithCurrentChain(e) {
17772    const t = v.state.activeChain;
17773    return t && e.chains ? e.chains.some((n) => {
17774      const r = n.split(":")[0];
17775      return t === r;
17776    }) : !0;
17777  },
17778  getFilteredRecentWallets() {
17779    return W.getRecentWallets().filter((n) => !Qn.isExcluded(n)).filter((n) => !this.hasWalletConnector(n)).filter((n) => this.isWalletCompatibleWithCurrentChain(n));
17780  },
17781  getCappedRecommendedWallets(e) {
17782    const { connectors: t } = H.state, { customWallets: n, featuredWalletIds: r } = z.state, s = t.find((R) => R.id === "walletConnect"), i = t.filter((R) => R.type === "INJECTED" || R.type === "ANNOUNCED" || R.type === "MULTI_CHAIN");
17783    if (!s && !i.length && !n?.length)
17784      return [];
17785    const o = Ba.isEmailEnabled(), a = Ba.isSocialsEnabled(), u = i.filter((R) => R.name !== "Browser Wallet" && R.name !== "WalletConnect"), c = r?.length || 0, l = n?.length || 0, f = u.length || 0, p = o ? 1 : 0, m = a ? 1 : 0, y = c + l + f + p + m, C = Math.max(0, 4 - y);
17786    return C <= 0 ? [] : Qn.filterOutDuplicateWallets(e).slice(0, C);
17787  },
17788  processConnectorsByType(e, t = !0) {
17789    const n = lt.sortConnectorsByExplorerWallet([...e]);
17790    return t ? n.filter(lt.showConnector) : n;
17791  },
17792  connectorList() {
17793    const e = lt.getConnectorsByType(H.state.connectors, ee.state.recommended, ee.state.featured), t = this.processConnectorsByType(e.announced.filter((m) => m.id !== "walletConnect")), n = this.processConnectorsByType(e.injected), r = this.processConnectorsByType(e.multiChain.filter((m) => m.name !== "WalletConnect"), !1), s = e.custom, i = e.recent, o = this.processConnectorsByType(e.external.filter((m) => m.id !== x.CONNECTOR_ID.COINBASE_SDK && m.id !== x.CONNECTOR_ID.BASE_ACCOUNT)), a = e.recommended, u = e.featured, c = lt.getConnectorTypeOrder({
17794      custom: s,
17795      recent: i,
17796      announced: t,
17797      injected: n,
17798      multiChain: r,
17799      recommended: a,
17800      featured: u,
17801      external: o
17802    }), l = H.state.connectors.find((m) => m.id === "walletConnect"), f = q.isMobile(), p = [];
17803    for (const m of c)
17804      switch (m) {
17805        case "walletConnect": {
17806          !f && l && p.push({ kind: "connector", subtype: "walletConnect", connector: l });
17807          break;
17808        }
17809        case "recent": {
17810          lt.getFilteredRecentWallets().forEach((b) => p.push({ kind: "wallet", subtype: "recent", wallet: b }));
17811          break;
17812        }
17813        case "injected": {
17814          r.forEach((y) => p.push({ kind: "connector", subtype: "multiChain", connector: y })), t.forEach((y) => p.push({ kind: "connector", subtype: "announced", connector: y }
17814)), n.forEach((y) => p.push({ kind: "connector", subtype: "injected", connector: y }));
17815          break;
17816        }
17817        case "featured": {
17818          u.forEach((y) => p.push({ kind: "wallet", subtype: "featured", wallet: y }));
17819          break;
17820        }
17821        case "custom": {
17822          lt.getFilteredCustomWallets(s ?? []).forEach((b) => p.push({ kind: "wallet", subtype: "custom", wallet: b }));
17823          break;
17824        }
17825        case "external": {
17826          o.forEach((y) => p.push({ kind: "connector", subtype: "external", connector: y }));
17827          break;
17828        }
17829        case "recommended": {
17830          lt.getCappedRecommendedWallets(a).forEach((b) => p.push({ kind: "wallet", subtype: "recommended", wallet: b }));
17831          break;
17832        }
17833        default:
17834          console.warn(`Unknown connector type: ${m}`);
17835      }
17836    return p;
17837  },
17838  hasInjectedConnectors() {
17839    return H.state.connectors.filter((e) => (e.type === "INJECTED" || e.type === "ANNOUNCED" || e.type === "MULTI_CHAIN") && e.name !== "Browser Wallet" && e.name !== "WalletConnect").length;
17840  }
17841}, GC = [
17842  "ConnectingExternal",
17843  "ConnectingMultiChain",
17844  "ConnectingSocial",
17845  "ConnectingFarcaster"
17846], Te = Me({
17847  view: "Connect",
17848  history: ["Connect"],
17849  transactionStack: []
17850}), zC = {
17851  state: Te,
17852  subscribeKey(e, t) {
17853    return Je(Te, e, t);
17854  },
17855  pushTransactionStack(e) {
17856    Te.transactionStack.push(e);
17857  },
17858  popTransactionStack(e) {
17859    const t = Te.transactionStack.pop();
17860    if (!t)
17861      return;
17862    const { onSuccess: n, onError: r, onCancel: s } = t;
17863    switch (e) {
17864      case "success":
17865        n?.();
17866        break;
17867      case "error":
17868        r?.(), ie.goBack();
17869        break;
17870      case "cancel":
17871        s?.(), ie.goBack();
17872        break;
17873    }
17874  },
17875  push(e, t) {
17876    let n = e, r = t;
17877    ee.state.plan.hasExceededUsageLimit && GC.includes(e) && (n = "UsageExceeded", r = void 0), n !== Te.view && (Te.view = n, Te.history.push(n), Te.data = r);
17878  },
17879  reset(e, t) {
17880    Te.view = e, Te.history = [e], Te.data = t;
17881  },
17882  replace(e, t) {
17883    Te.history.at(-1) === e || (Te.view = e, Te.history[Te.history.length - 1] = e, Te.data = t);
17884  },
17885  goBack() {
17886    const e = v.state.activeCaipAddress, t = ie.state.view === "ConnectingFarcaster", n = !e && t;
17887    if (Te.history.length > 1) {
17888      Te.history.pop();
17889      const [r] = Te.history.slice(-1);
17890      r && (e && r === "Connect" ? Te.view = "Account" : Te.view = r);
17891    } else
17892      Se.close();
17893    Te.data?.wallet && (Te.data.wallet = void 0), Te.data?.redirectView && (Te.data.redirectView = void 0), setTimeout(() => {
17894      if (n) {
17895        v.setAccountProp("farcasterUrl", void 0, v.state.activeChain);
17896        const r = H.getAuthConnector();
17897        r?.provider?.reload();
17898        const s = _s(z.state);
17899        r?.provider?.syncDappData?.({
17900          metadata: s.metadata,
17901          sdkVersion: s.sdkVersion,
17902          projectId: s.projectId,
17903          sdkType: s.sdkType
17904        });
17905      }
17906    }, 100);
17907  },
17908  goBackToIndex(e) {
17909    if (Te.history.length > 1) {
17910      Te.history = Te.history.slice(0, e + 1);
17911      const [t] = Te.history.slice(-1);
17912      t && (Te.view = t);
17913    }
17914  },
17915  goBackOrCloseModal() {
17916    ie.state.history.length > 1 ? ie.goBack() : Se.close();
17917  }
17918}, ie = Mt(zC), tn = Me({
17919  themeMode: "dark",
17920  themeVariables: {},
17921  w3mThemeVariables: void 0
17922}), Fa = {
17923  state: tn,
17924  subscribe(e) {
17925    return tt(tn, () => e(tn));
17926  },
17927  setThemeMode(e) {
17928    tn.themeMode = e;
17929    try {
17930      const t = H.getAuthConnector();
17931      if (t) {
17932        const n = Fa.getSnapshot().themeVariables;
17933        t.provider.syncTheme({
17934          themeMode: e,
17935          themeVariables: n,
17936          w3mThemeVariables: zi(n, e)
17937        });
17938      }
17939    } catch {
17940      console.info("Unable to sync theme to auth connector");
17941    }
17942  },
17943  setThemeVariables(e) {
17944    tn.themeVariables = { ...tn.themeVariables, ...e };
17945    try {
17946      const t = H.getAuthConnector();
17947      if (t) {
17948        const n = Fa.getSnapshot().themeVariables;
17949        t.provider.syncTheme({
17950          themeVariables: n,
17951          w3mThemeVariables: zi(tn.themeVariables, tn.themeMode)
17952        });
17953      }
17954    } catch {
17955      console.info("Unable to sync theme to auth connector");
17956    }
17957  },
17958  getSnapshot() {
17959    return _s(tn);
17960  }
17961}, bi = Mt(Fa), Tf = Object.fromEntries(lf.map((e) => [e, void 0])), VC = Object.fromEntries(lf.map((e) => [e, !0])), Ee = Me({
17962  allConnectors: [],
17963  connectors: [],
17964  activeConnector: void 0,
17965  filterByNamespace: void 0,
17966  activeConnectorIds: Tf,
17967  filterByNamespaceMap: VC
17968}), KC = {
17969  state: Ee,
17970  subscribe(e) {
17971    return tt(Ee, () => {
17972      e(Ee);
17973    });
17974  },
17975  subscribeKey(e, t) {
17976    return Je(Ee, e, t);
17977  },
17978  initialize(e) {
17979    e.forEach((t) => {
17980      const n = W.getConnectedConnectorId(t);
17981      n && H.setConnectorId(n, t);
17982    });
17983  },
17984  setActiveConnector(e) {
17985    e && (Ee.activeConnector = Ns(e));
17986  },
17987  setConnectors(e) {
17988    e.filter((s) => !Ee.allConnectors.some((i) => i.id === s.id && H.getConnectorName(i.name) === H.getConnectorName(s.name) && i.chain === s.chain)).forEac
17988h((s) => {
17989      s.type !== "MULTI_CHAIN" && Ee.allConnectors.push(Ns(s));
17990    });
17991    const n = H.getEnabledNamespaces(), r = H.getEnabledConnectors(n);
17992    Ee.connectors = H.mergeMultiChainConnectors(r);
17993  },
17994  filterByNamespaces(e) {
17995    Object.keys(Ee.filterByNamespaceMap).forEach((t) => {
17996      Ee.filterByNamespaceMap[t] = !1;
17997    }), e.forEach((t) => {
17998      Ee.filterByNamespaceMap[t] = !0;
17999    }), H.updateConnectorsForEnabledNamespaces();
18000  },
18001  filterByNamespace(e, t) {
18002    Ee.filterByNamespaceMap[e] = t, H.updateConnectorsForEnabledNamespaces();
18003  },
18004  updateConnectorsForEnabledNamespaces() {
18005    const e = H.getEnabledNamespaces(), t = H.getEnabledConnectors(e), n = H.areAllNamespacesEnabled();
18006    Ee.connectors = H.mergeMultiChainConnectors(t), n ? ee.clearFilterByNamespaces() : ee.filterByNamespaces(e);
18007  },
18008  getEnabledNamespaces() {
18009    return Object.entries(Ee.filterByNamespaceMap).filter(([e, t]) => t).map(([e]) => e);
18010  },
18011  getEnabledConnectors(e) {
18012    return Ee.allConnectors.filter((t) => e.includes(t.chain));
18013  },
18014  areAllNamespacesEnabled() {
18015    return Object.values(Ee.filterByNamespaceMap).every((e) => e);
18016  },
18017  mergeMultiChainConnectors(e) {
18018    const t = H.generateConnectorMapByName(e), n = [];
18019    return t.forEach((r) => {
18020      const s = r[0], i = s?.id === x.CONNECTOR_ID.AUTH;
18021      r.length > 1 && s ? n.push({
18022        name: s.name,
18023        imageUrl: s.imageUrl,
18024        imageId: s.imageId,
18025        connectors: [...r],
18026        type: i ? "AUTH" : "MULTI_CHAIN",
18027        // These values are just placeholders, we don't use them in multi-chain connector select screen
18028        chain: "eip155",
18029        id: s?.id || ""
18030      }) : s && n.push(s);
18031    }), n;
18032  },
18033  generateConnectorMapByName(e) {
18034    const t = /* @__PURE__ */ new Map();
18035    return e.forEach((n) => {
18036      const { name: r } = n, s = H.getConnectorName(r);
18037      if (!s)
18038        return;
18039      const i = t.get(s) || [];
18040      i.find((a) => a.chain === n.chain) || i.push(n), t.set(s, i);
18041    }), t;
18042  },
18043  getConnectorName(e) {
18044    return e && ({
18045      "Trust Wallet": "Trust"
18046    }[e] || e);
18047  },
18048  getUniqueConnectorsByName(e) {
18049    const t = [];
18050    return e.forEach((n) => {
18051      t.find((r) => r.chain === n.chain) || t.push(n);
18052    }), t;
18053  },
18054  addConnector(e) {
18055    if (e.id === x.CONNECTOR_ID.AUTH) {
18056      const t = e, n = _s(z.state), r = bi.getSnapshot().themeMode, s = bi.getSnapshot().themeVariables;
18057      t?.provider?.syncDappData?.({
18058        metadata: n.metadata,
18059        sdkVersion: n.sdkVersion,
18060        projectId: n.projectId,
18061        sdkType: n.sdkType
18062      }), t?.provider?.syncTheme({
18063        themeMode: r,
18064        themeVariables: s,
18065        w3mThemeVariables: zi(s, r)
18066      }), H.setConnectors([e]);
18067    } else
18068      H.setConnectors([e]);
18069  },
18070  getAuthConnector(e) {
18071    const t = e || v.state.activeChain, n = Ee.connectors.find((r) => r.id === x.CONNECTOR_ID.AUTH);
18072    if (n)
18073      return n?.connectors?.length ? n.connectors.find((s) => s.chain === t) : n;
18074  },
18075  getAnnouncedConnectorRdns() {
18076    return Ee.connectors.filter((e) => e.type === "ANNOUNCED").map((e) => e.info?.rdns);
18077  },
18078  getConnectorById(e) {
18079    return lt.sortConnectorsByPriority(Ee.allConnectors).find((n) => n.id === e);
18080  },
18081  getConnector({ id: e, namespace: t }) {
18082    const n = t || v.state.activeChain, r = Ee.allConnectors.filter((o) => o.chain === n);
18083    return lt.sortConnectorsByPriority(r).find((o) => o.id === e || o.explorerId === e);
18084  },
18085  syncIfAuthConnector(e) {
18086    if (e.id !== "AUTH")
18087      return;
18088    const t = e, n = _s(z.state), r = bi.getSnapshot().themeMode, s = bi.getSnapshot().themeVariables;
18089    t?.provider?.syncDappData?.({
18090      metadata: n.metadata,
18091      sdkVersion: n.sdkVersion,
18092      sdkType: n.sdkType,
18093      projectId: n.projectId
18094    }), t.provider.syncTheme({
18095      themeMode: r,
18096      themeVariables: s,
18097      w3mThemeVariables: zi(s, r)
18098    });
18099  },
18100  /**
18101   * Returns the connectors filtered by namespace.
18102   * @param namespace - The namespace to filter the connectors by.
18103   * @returns ConnectorWithProviders[].
18104   */
18105  getConnectorsByNamespace(e) {
18106    const t = Ee.allConnectors.filter((n) => n.chain === e);
18107    return H.mergeMultiChainConnectors(t);
18108  },
18109  canSwitchToSmartAccount(e) {
18110    return v.checkIfSmartAccountEnabled() && Et(e) === Ye.ACCOUNT_TYPES.EOA;
18111  },
18112  selectWalletConnector(e) {
18113    const t = ie.state.data?.redirectView, n = v.state.activeChain, r = n ? H.getConnector({ id: e.id, namespace: n }) : void 0;
18114    BC.handleMobileDeeplinkRedirect(r?.explorerId || e.id, v.state.activeChain, { isCoinbaseDisabled: z.state.enableCoinbase === !1 }
18114), r ? ie.push("ConnectingExternal", { connector: r, wallet: e, redirectView: t }) : ie.push("ConnectingWalletConnect", { wallet: e, redirectView: t });
18115  },
18116  /**
18117   * Returns the connectors. If a namespace is provided, the connectors are filtered by namespace.
18118   * @param namespace - The namespace to filter the connectors by. If not provided, all connectors are returned.
18119   * @returns ConnectorWithProviders[].
18120   */
18121  getConnectors(e) {
18122    return e ? H.getConnectorsByNamespace(e) : H.mergeMultiChainConnectors(Ee.allConnectors);
18123  },
18124  /**
18125   * Sets the filter by namespace and updates the connectors.
18126   * @param namespace - The namespace to filter the connectors by.
18127   */
18128  setFilterByNamespace(e) {
18129    Ee.filterByNamespace = e, Ee.connectors = H.getConnectors(e), ee.setFilterByNamespace(e);
18130  },
18131  setConnectorId(e, t) {
18132    e && (Ee.activeConnectorIds = {
18133      ...Ee.activeConnectorIds,
18134      [t]: e
18135    }, W.setConnectedConnectorId(t, e));
18136  },
18137  removeConnectorId(e) {
18138    Ee.activeConnectorIds = {
18139      ...Ee.activeConnectorIds,
18140      [e]: void 0
18141    }, W.deleteConnectedConnectorId(e);
18142  },
18143  getConnectorId(e) {
18144    if (e)
18145      return Ee.activeConnectorIds[e];
18146  },
18147  isConnected(e) {
18148    return e ? !!Ee.activeConnectorIds[e] : Object.values(Ee.activeConnectorIds).some((t) => !!t);
18149  },
18150  resetConnectorIds() {
18151    Ee.activeConnectorIds = { ...Tf };
18152  },
18153  extendConnectorsWithExplorerWallets(e) {
18154    Ee.allConnectors.forEach((r) => {
18155      const s = e.find((i) => i.id === r.id || i.rdns && i.rdns === r.info?.rdns);
18156      s && (r.explorerWallet = s);
18157    });
18158    const t = H.getEnabledNamespaces(), n = H.getEnabledConnectors(t);
18159    Ee.connectors = H.mergeMultiChainConnectors(n);
18160  },
18161  /**
18162   * Opens the connect modal and waits until the user connects their wallet.
18163   * @param params - Connection parameters.
18164   * @returns Promise resolving to the connected wallet's CAIP address.
18165   */
18166  async connect(e = {}) {
18167    const { namespace: t } = e;
18168    return H.setFilterByNamespace(t), ie.push("Connect", {
18169      addWalletForNamespace: t
18170    }), new Promise((n, r) => {
18171      if (t) {
18172        const s = v.subscribeChainProp("accountState", (o) => {
18173          o?.caipAddress && (n({ caipAddress: o?.caipAddress }), s());
18174        }, t), i = Se.subscribeKey("open", (o) => {
18175          o || (r(new Error("Modal closed")), i());
18176        });
18177      } else {
18178        const s = v.subscribeKey("activeCaipAddress", (o) => {
18179          o && (n({ caipAddress: o }), s());
18180        }), i = Se.subscribeKey("open", (o) => {
18181          o || (r(new Error("Modal closed")), i());
18182        });
18183      }
18184    });
18185  }
18186}, H = Mt(KC), YC = 1e3, Zr = {
18187  checkNamespaceConnectorId(e, t) {
18188    return H.getConnectorId(e) === t;
18189  },
18190  isSocialProvider(e) {
18191    return Qe.DEFAULT_REMOTE_FEATURES.socials.includes(e);
18192  },
18193  connectWalletConnect({ walletConnect: e, connector: t, closeModalOnConnect: n = !0, redirectViewOnModalClose: r = "Connect", onOpen: s, onConnect: i }) {
18194    return new Promise((o, a) => {
18195      if (e && H.setActiveConnector(t), s?.(q.isMobile() && e), r) {
18196        const c = Se.subscribeKey("open", (l) => {
18197          l || (ie.state.view !== r && ie.replace(r), c(), a(new Error("Modal closed")));
18198        });
18199      }
18200      const u = v.subscribeKey("activeCaipAddress", (c) => {
18201        c && (i?.(), n && Se.close(), u(), o(wt.parseCaipAddress(c)));
18202      });
18203    });
18204  },
18205  connectExternal(e) {
18206    return new Promise((t, n) => {
18207      const r = v.subscribeKey("activeCaipAddress", (s) => {
18208        s && (Se.close(), r(), t(wt.parseCaipAddress(s)));
18209      });
18210      J.connectExternal(e, e.chain).catch(() => {
18211        r(), n(new Error("Connection rejected"));
18212      });
18213    });
18214  },
18215  connectSocial({ social: e, namespace: t, closeModalOnConnect: n = !0, onOpenFarcaster: r, onConnect: s }) {
18216    let i, o = !1, a = null;
18217    const u = t || v.state.activeChain, c = v.subscribeKey("activeCaipAddress", (l) => {
18218      l && (n && Se.close(), c());
18219    });
18220    return new Promise((l, f) => {
18221      async function p(y) {
18222        if (y.data?.resultUri)
18223          if (y.origin === x.SECURE_SITE_SDK_ORIGIN) {
18224            window.removeEventListener("message", p, !1);
18225            try {
18226              const b = H.getAuthConnector(u);
18227              if (b && !o) {
18228                i && i.close(), o = !0;
18229                const C = y.data.resultUri;
18230                ve.sendEvent({
18231                  type: "track",
18232                  event: "SOCIAL_LOGIN_REQUEST_USER_DATA",
18233                  properties: { provider: e }
18234                }), W.setConnectedSocialProvider(e), await J.connectExternal({
18235                  id: b.id,
18236                  type: b.type,
18237                  socialUri: C
18238                }, b.chain);
18239                const _ = v.state.activeCaipAddress;
18240                if (!_) {
18241                  f(new Error("Failed to connect"));
18242                  return;
18243                }
18244                l(wt.parseCaipAddress(_)), ve.sendEvent({
18245                  type: "track",
18246                  event: "SOCIAL_LOGIN_SUCCESS",
18247                  properties: { provider: e }
18248                });
18249              }
18250            } catch (b) {
18251              ve.sendEvent({
18252                type: "track",
18253                event: "SOCIAL_LOGIN_ERROR",
18254                properties: { provider: e, message: q.parseError(b) }
18255              }), f(new Error("Failed to connect"));
18256            }
18257          } else
18258            ve.sendEvent({
18259              type: "track",
18260              event: "SOCIAL_LOGIN_ERROR",
18261              properties: { provider: e, message: "Untrusted Origin" }
18262            });
18263      }
18264      async function m() {
18265        if (ve.sendEvent({
18266          type: "track",
18267          event: "SOCIAL_LOGIN_STARTED",
18268          properties: { provider: e }
18269        }), e === "farcaster") {
18270          r?.();
18271          const y = Se.subscribeKey("open", (C) => {
18272            !C && e === "farcaster" && (f(new Error("Popup closed")), s?.(), y());
18273          }), b = H.getAuthConnector();
18274          if (b && !v.getAccountData(u)?.farcasterUrl)
18275            try {
18276              const { url: _ } = await b.provider.getFarcasterUri();
18277              v.setAccountProp("farcasterUrl", _, u);
18278            } catch {
18279              f(new Error("Failed to connect to farcaster"));
18280            }
18281        } else {
18282          const y = H.getAuthConnector();
18283          a = q.returnOpenHref(`${x.SECURE_SITE_SDK_ORIGIN}/loading`, "popupWindow", "width=600,height=800,scrollbars=yes");
18284          try {
18285            if (y) {
18286              const { uri: b } = await y.provider.getSocialRedirectUri({
18287                provider: e
18288              });
18289              if (a && b) {
18290                a.location.href = b, i = a;
18291                const C = setInterval(() => {
18292                  i?.closed && !o && (f(new Error("Popup closed")), clearInterval(C));
18293                }, 1e3);
18294                window.addEventListener("message", p, !1);
18295              } else
18296                a?.close(), f(new Error("Failed to initiate social connection"));
18297            }
18298          } catch {
18299            f(new Error("Failed to initiate social connection")), a?.close();
18300          }
18301        }
18302      }
18303      m();
18304    });
18305  },
18306  connectEmail({ closeModalOnConnect: e = !0, redirectViewOnModalClose: t = "Connect", onOpen: n, onConnect: r }) {
18307    return new Promise((s, i) => {
18308      if (n?.(), t) {
18309        const a = Se.subscribeKey("open", (u) => {
18310          u || (ie.state.view !== t && ie.replace(t), a(), i(new Error("Modal closed")));
18311        });
18312      }
18313      const o = v.subscribeKey("activeCaipAddress", (a) => {
18314        a && (r?.(), e && Se.close(), o(), s(wt.parseCaipAddress(a)));
18315      });
18316    });
18317  },
18318  async updateEmail() {
18319    const e = W.getConnectedConnectorId(v.state.activeChain), t = H.getAuthConnector();
18320    if (!t)
18321      throw new Error("No auth connector found");
18322    if (e !== x.CONNECTOR_ID.AUTH)
18323      throw new Error("Not connected to email or social");
18324    const n = t.provider.getEmail() ?? "";
18325    return await Se.open({
18326      view: "UpdateEmailWallet",
18327      data: {
18328        email: n,
18329        redirectView: void 0
18330      }
18331    }), new Promise((r, s) => {
18332      const i = setInterval(() => {
18333        const a = t.provider.getEmail() ?? "";
18334        a !== n && (Se.close(), clearInterval(i), o(), r({ email: a }));
18335      }, YC), o = Se.subscribeKey("open", (a) => {
18336        a || (ie.state.view !== "Connect" && ie.push("Connect"), clearInterval(i), o(), s(new Error("Modal closed")));
18337      });
18338    });
18339  },
18340  canSwitchToSmartAccount(e) {
18341    return v.checkIfSmartAccountEnabled() && Et(e) === Ye.ACCOUNT_TYPES.EOA;
18342  }
18343};
18344function Sf() {
18345  const e = v.state.activeCaipNetwork?.chainNamespace || "eip155", t = v.state.activeCaipNetwork?.id || 1, n = Qe.NATIVE_TOKEN_ADDRESS[e];
18346  return `${e}:${t}:${n}`;
18347}
18348function Y_(e) {
18349  return Qe.NATIVE_TOKEN_ADDRESS[e];
18350}
18351function Et(e) {
18352  return v.getAccountData(e)?.preferredAccountType;
18353}
18354function Rn(e) {
18355  return e ? v.state.chains.get(e)?.networkState?.caipNetwork : v.state.activeCaipNetwork;
18356}
18357const Rf = {
18358  getConnectionStatus(e, t) {
18359    const n = H.state.activeConnectorIds[t], r = J.getConnections(t);
18360    return !!n && e.connectorId === n ? "connected" : r.some((o) => o.connectorId.toLowerCase() === e.connectorId.toLowerCase()) ? "active" : "disconnected";
18361  },
18362  excludeConnectorAddressFromConnections({ connections: e, connectorId: t, addresses: n }) {
18363    return e.map((r) => {
18364      if ((t ? r.connectorId.toLowerCase() === t.toLowerCase() : !1) && n) {
18365        const i = r.accounts.filter((o) => !n.some((u) => u.toLowerCase() === o.address.toLowerCase()));
18366        return { ...r, accounts: i };
18367      }
18368      return r;
18369    });
18370  },
18371  excludeExistingConnections(e, t) {
18372    const n = new Set(e);
18373    return t.filter((r) => !n.has(r.connectorId));
18374  },
18375  getConnectionsByConnectorId(e, t) {
18376    return e.filter((n) => n.connectorId.toLowerCase() === t.toLowerCase());
18377  },
18378  getConnectionsData(e) {
18379    const t = !!z.state.remoteFeatures?.multiWallet, n = H.state.activeConnectorIds[e], r = J.getConnections(e), i = (J.state.recentConnections.get(e) ?? []).filter((a) => H.getConnectorById(a.connectorId)), o = Rf.excludeExistingConnections([...r.map((a) => a.connectorId), ...n ? [n] : []], i);
18380    return t ? {
18381      connections: r,
18382      recentConnections: o
18383    } : {
18384      connections: r.filter((a) => a.connectorId.toLowerCase() === n?.toLowerCase()),
18385      recentConnections: []
18386    };
18387  },
18388  onConnectMobile(e, t) {
18389    const n = J.state.wcUri;
18390    if (e?.mobile_link && n)
18391      try {
18392        J.setWcError(!1);
18393        const { mobile_link: r, link_mode: s, name: i } = e, o = q.appendPayToUri(n, t), { redirect: a, redirectUniversalLink: u, href: c } = q.formatNativeUrl(r, o, s), l = a, f = u, p = q.isIframe() ? "_top" : "_self";
18394        J.setWcLinking({ name: i, href: c }), J.setRecentWallet(e), z.state.experimental_preferUniversalLinks && f ? q.openHref(f, p) : q.openHref(l, p);
18395      } catch (r) {
18396        ve.sendEvent({
18397          type: "track",
18398          event: "CONNECT_PROXY_ERROR",
18399          properties: {
18400            message: r instanceof Error ? r.message : "Error parsing the deep link",
18401            uri: n,
18402            mobile_link: e.mobile_link,
18403            name: e.name
18404          }
18405        }), J.setWcError(!0);
18406      }
18407  }
18408}, Er = Me({
18409  loading: !1,
18410  open: !1,
18411  selectedNetworkId: void 0,
18412  activeChain: void 0,
18413  initialized: !1,
18414  connectingWallet: void 0
18415}), un = {
18416  state: Er,
18417  subscribe(e) {
18418    return tt(Er, () => e(Er));
18419  },
18420  subscribeOpen(e) {
18421    return Je(Er, "open", e);
18422  },
18423  set(e) {
18424    Object.assign(Er, { ...Er, ...e });
18425  }
18426}, Be = Me({
18427  transactions: [],
18428  transactionsByYear: {},
18429  lastNetworkInView: void 0,
18430  loading: !1,
18431  empty: !1,
18432  next: void 0
18433}), ZC = {
18434  state: Be,
18435  subscribe(e) {
18436    return tt(Be, () => e(Be));
18437  },
18438  setLastNetworkInView(e) {
18439    Be.lastNetworkInView = e;
18440  },
18441  async fetchTransactions(e) {
18442    if (!e)
18443      throw new Error("Transactions can't be fetched without an accountAddress");
18444    Be.loading = !0;
18445    try {
18446      const t = await ce.fetchTransactions({
18447        account: e,
18448        cursor: Be.next,
18449        chainId: v.state.activeCaipNetwork?.caipNetworkId
18450      }), n = Si.filterSpamTransactions(t.data), r = Si.filterByConnectedChain(n), s = [...Be.transactions, ...r];
18451      Be.loading = !1, Be.transactions = s, Be.transactionsByYear = Si.groupTransactionsByYearAndMonth(Be.transactionsByYear, r), Be.empty = s.length === 0, Be.next = t.next ? t.next : void 0;
18452    } catch {
18453      const n = v.state.activeChain;
18454      ve.sendEvent({
18455        type: "track",
18456        event: "ERROR_FETCH_TRANSACTIONS",
18457        properties: {
18458          address: e,
18459          projectId: z.state.projectId,
18460          cursor: Be.next,
18461          isSmartAccount: Et(n) === Ye.ACCOUNT_TYPES.SMART_ACCOUNT
18462        }
18463      }), Sn.showError("Failed to fetch transactions"), Be.loading = !1, Be.empty = !0, Be.next = void 0;
18464    }
18465  },
18466  groupTransactionsByYearAndMonth(e = {}, t = []) {
18467    const n = e;
18468    return t.forEach((r) => {
18469      const s = new Date(r.metadata.minedAt).getFullYear(), i = new Date(r.metadata.minedAt).getMonth(), o = n[s] ?? {}, u = (o[i] ?? []).filter((c) => c.id !== r.id);
18470      n[s] = {
18471        ...o,
18472        [i]: [...u, r].sort((c, l) => new Date(l.metadata.minedAt).getTime() - new Date(c.metadata.minedAt).getTime())
18473      };
18474    }), n;
18475  },
18476  filterSpamTransactions(e) {
18477    return e.filter((t) => !t.transfers?.every((r) => r.nft_info?.flags.is_spam === !0));
18478  },
18479  filterByConnectedChain(e) {
18480    const t = v.state.activeCaipNetwork?.caipNetworkId;
18481    return e.filter((r) => r.metadata.chain === t);
18482  },
18483  clearCursor() {
18484    Be.next = void 0;
18485  },
18486  resetTransactions() {
18487    Be.transactions = [], Be.transactionsByYear = {}, Be.lastNetworkInView = void 0, Be.loading = !1, Be.empty = !1, Be.next = void 0;
18488  }
18489}, Si = Mt(ZC, "API_ERROR"), pe = Me({
18490  connections: /* @__PURE__ */ new Map(),
18491  recentConnections: /* @__PURE__ */ new Map(),
18492  isSwitchingConnection: !1,
18493  wcError: !1,
18494  wcFetchingUri: !1,
18495  buffering: !1,
18496  status: "disconnected"
18497});
18498let An;
18499const QC = {
18500  state: pe,
18501  subscribe(e) {
18502    return tt(pe, () => e(pe));
18503  },
18504  subscribeKey(e, t) {
18505    return Je(pe, e, t);
18506  },
18507  _getClient() {
18508    return pe._client;
18509  },
18510  setClient(e) {
18511    pe._client = Ns(e);
18512  },
18513  initialize(e) {
18514    const t = e.filter((n) => !!n.namespace).map((n) => n.namespace);
18515    J.syncStorageConnections(t);
18516  },
18517  syncStorageConnections(e) {
18518    const t = W.getConnections(), n = e ?? Array.from(v.state.chains.keys());
18519    for (const r of n) {
18520      const s = t[r] ?? [], i = new Map(pe.recentConnections);
18521      i.set(r, s), pe.recentConnections = i;
18522    }
18523  },
18524  getConnections(e) {
18525    return e ? pe.connections.get(e) ?? [] : [];
18526  },
18527  hasAnyConnection(e) {
18528    const t = J.state.connections;
18529    return Array.from(t.values()).flatMap((n) => n).some(({ connectorId: n }) => n === e);
18530  },
18531  async connectWalletConnect({ cache: e = "auto" } = {}) {
18532    pe.wcFetchingUri = !0;
18533    const t = q.isTelegram() || q.isSafari() && q.isIos();
18534    try {
18535      if (e === "always" || e === "auto" && t) {
18536        if (An) {
18537          await An, An = void 0;
18538          return;
18539        }
18540        if (!q.isPairingExpired(pe?.wcPairingExpiry)) {
18541          const n = pe.wcUri;
18542          pe.wcUri = n;
18543          return;
18544        }
18545        An = J._getClient()?.connectWalletConnect?.(), J.state.status = "connecting", await An, An = void 0, pe.wcPairingExpiry = void 0, J.state.status = "connected";
18546      } else
18547        await J._getClient()?.connectWalletConnect?.();
18548    } catch (n) {
18549      throw pe.wcError = !0, pe.wcFetchingUri = !1, pe.status = "disconnected", An = void 0, n;
18550    }
18551  },
18552  async connectExternal(e, t, n = !0) {
18553    const r = await J._getClient()?.connectExternal?.(e);
18554    n && v.setActiveNamespace(t);
18555    const s = H.state.allConnectors.find((o) => o.id === e?.id), i = e.type === "AUTH" ? "email" : "browser";
18556    return ve.sendEvent({
18557      type: "track",
18558      event: "CONNECT_SUCCESS",
18559      properties: {
18560        method: i,
18561        name: s?.name || "Unknown",
18562        view: ie.state.view,
18563        walletRank: s?.explorerWallet?.order
18564      }
18565    }), r;
18566  },
18567  async reconnectExternal(e) {
18568    await J._getClient()?.reconnectExternal?.(e);
18569    const t = e.chain || v.state.activeChain;
18570    t && H.setConnectorId(e.id, t);
18571  },
18572  async setPreferredAccountType(e, t) {
18573    if (!t)
18574      return;
18575    Se.setLoading(!0, v.state.activeChain);
18576    const n = H.getAuthConnector();
18577    n && (v.setAccountProp("preferredAccountType", e, t), await n.provider.setPreferredAccount(e), W.setPreferredAccountTypes(Object.entries(v.state.chains).reduce((r, [s, i]) => {
18578      const o = s, a = Et(o);
18579      return a !== void 0 && (r[o] = a), r;
18580    }, {})), await J.reconnectExternal(n), Se.setLoading(!1, v.state.activeChain), ve.sendEvent({
18581      type: "track",
18582      event: "SET_PREFERRED_ACCOUNT_TYPE",
18583      properties: {
18584        accountType: e,
18585        network: v.state.activeCaipNetwork?.caipNetworkId || ""
18586      }
18587    }));
18588  },
18589  async signMessage(e) {
18590    return J._getClient()?.signMessage(e);
18591  },
18592  parseUnits(e, t) {
18593    return J._getClient()?.parseUnits(e, t);
18594  },
18595  formatUnits(e, t) {
18596    return J._getClient()?.formatUnits(e, t);
18597  },
18598  updateBalance(e) {
18599    return J._getClient()?.updateBalance(e);
18600  },
18601  async sendTransaction(e) {
18602    return J._getClient()?.sendTransaction(e);
18603  },
18604  async getCapabilities(e) {
18605    return J._getClient()?.getCapabilities(e);
18606  },
18607  async grantPermissions(e) {
18608    return J._getClient()?.grantPermissions(e);
18609  },
18610  async walletGetAssets(e) {
18611    return J._getClient()?.walletGetAssets(e) ?? {};
18612  },
18613  async estimateGas(e) {
18614    return J._getClient()?.estimateGas(e);
18615  },
18616  async writeContract(e) {
18617    return J._getClient()?.writeContract(e);
18618  },
18619  async writeSolanaTransaction(e) {
18620    return J._getClient()?.writeSolanaTransaction(e);
18621  },
18622  async getEnsAddress(e) {
18623    return J._getClient()?.getEnsAddress(e);
18624  },
18625  async getEnsAvatar(e) {
18626    return J._getClient()?.getEnsAvatar(e);
18627  },
18628  checkInstalled(e) {
18629    return J._getClient()?.checkInstalled?.(e) || !1;
18630  },
18631  resetWcConnection() {
18632    pe.wcUri = void 0, pe.wcPairingExpiry = void 0, pe.wcLinking = void 0, pe.recentWallet = void 0, pe.wcFetchingUri = !1, pe.status = "disconnected", Si.resetTransactions(), W.deleteWalletConnectDeepLink(), W.deleteRecentWallet(), un.set({ connectingWallet: void 0 });
18633  },
18634  resetUri() {
18635    pe.wcUri = void 0, pe.wcPairingExpiry = void 0, An = void 0, pe.wcFetchingUri = !1, un.set({ connectingWallet: void 0 });
18636  },
18637  finalizeWcConnection(e) {
18638    const { wcLinking: t, recentWallet: n } = J.state;
18639    t && W.setWalletConnectDeepLink(t), n && W.setAppKitRecent(n), e && ve.sendEvent({
18640      type: "track",
18641      event: "CONNECT_SUCCESS",
18642      address: e,
18643      properties: {
18644        method: t ? "mobile" : "qrcode",
18645        name: ie.state.data?.wallet?.name || "Unknown",
18646        view: ie.state.view,
18647        walletRank: n?.order
18648      }
18649    });
18650  },
18651  setWcBasic(e) {
18652    pe.wcBasic = e;
18653  },
18654  setUri(e) {
18655    pe.wcUri = e, pe.wcFetchingUri = !1, pe.wcPairingExpiry = q.getPairingExpiry();
18656  },
18657  setWcLinking(e) {
18658    pe.wcLinking = e;
18659  },
18660  setWcError(e) {
18661    pe.wcError = e, pe.wcFetchingUri = !1, pe.buffering = !1;
18662  },
18663  setRecentWallet(e) {
18664    pe.recentWallet = e;
18665  },
18666  setBuffering(e) {
18667    pe.buffering = e;
18668  },
18669  setStatus(e) {
18670    pe.status = e;
18671  },
18672  setIsSwitchingConnection(e) {
18673    pe.isSwitchingConnection = e;
18674  },
18675  async disconnect({ id: e, namespace: t, initialDisconnect: n } = {}) {
18676    try {
18677      await J._getClient()?.disconnect({
18678        id: e,
18679        chainNamespace: t,
18680        initialDisconnect: n
18681      });
18682    } catch (r) {
18683      throw new lr("Failed to disconnect", "INTERNAL_SDK_ERROR", r);
18684    }
18685  },
18686  async disconnectConnector({ id: e, namespace: t }) {
18687    try {
18688      await J._getClient()?.disconnectConnector({ id: e, namespace: t });
18689    } catch (n) {
18690      throw new lr("Failed to disconnect connector", "INTERNAL_SDK_ERROR", n);
18691    }
18692  },
18693  setConnections(e, t) {
18694    const n = new Map(pe.connections);
18695    n.set(t, e), pe.connections = n;
18696  },
18697  async handleAuthAccountSwitch({ address: e, namespace: t }) {
18698    const r = v.getAccountData(t)?.user?.accounts?.find((i) => i.type === "smartAccount"), s = r && r.address.toLowerCase() === e.toLowerCase() && Zr.canSwitchToSmartAccount(t) ? "smartAccount" : "eoa";
18699    await J.setPreferredAccountType(s, t);
18700  },
18701  async handleActiveConnection({ connection: e, namespace: t, address: n }) {
18702    const r = H.getConnectorById(e.connectorId), s = e.connectorId === x.CONNECTOR_ID.AUTH;
18703    if (!r)
18704      throw new Error(`No connector found for connection: ${e.connectorId}`);
18705    if (s)
18706      n && await J.handleAuthAccountSwitch({ address: n, namespace: t });
18707    else return (await J.connectExternal({
18708      id: r.id,
18709      type: r.type,
18710      provider: r.provider,
18711      address: n,
18712      chain: t
18713    }, t))?.address;
18714    return n;
18715  },
18716  async handleDisconnectedConnection({ connection: e, namespace: t, address: n, closeModalOnConnect: r }) {
18717    const s = H.getConnectorById(e.connectorId), i = e.auth?.name?.toLowerCase(), o = e.connectorId === x.CONNECTOR_ID.AUTH, a = e.connectorId === x.CONNECTOR_ID.WALLET_CONNECT;
18718    if (!s)
18719      throw new Error(`No connector found for connection: ${e.connectorId}`);
18720    let u;
18721    if (o)
18722      if (i && Zr.isSocialProvider(i)) {
18723        const { address: c } = await Zr.connectSocial({
18724          social: i,
18725          closeModalOnConnect: r,
18726          onOpenFarcaster() {
18727            Se.open({ view: "ConnectingFarcaster" });
18728          },
18729          onConnect() {
18730            ie.replace("ProfileWallets");
18731          }
18732        });
18733        u = c;
18734      } else {
18735        const { address: c } = await Zr.connectEmail({
18736          closeModalOnConnect: r,
18737          onOpen() {
18738            Se.open({ view: "EmailLogin" });
18739          },
18740          onConnect() {
18741            ie.replace("ProfileWallets");
18742          }
18743        });
18744        u = c;
18745      }
18746    else if (a) {
18747      const { address: c } = await Zr.connectWalletConnect({
18748        walletConnect: !0,
18749        connector: s,
18750        closeModalOnConnect: r,
18751        onOpen(l) {
18752          const f = l ? "AllWallets" : "ConnectingWalletConnect";
18753          Se.state.open ? ie.push(f) : Se.open({ view: f });
18754        },
18755        onConnect() {
18756          ie.replace("ProfileWallets");
18757        }
18758      });
18759      u = c;
18760    } else {
18761      const c = await J.connectExternal({
18762        id: s.id,
18763        type: s.type,
18764        provider: s.provider,
18765        chain: t
18766      }, t);
18767      c && (u = c.address);
18768    }
18769    return o && n && await J.handleAuthAccountSwitch({ address: n, namespace: t }), u;
18770  },
18771  async switchConnection({ connection: e, address: t, namespace: n, closeModalOnConnect: r, onChange: s }) {
18772    let i;
18773    const o = v.getAccountData(n)?.caipAddress;
18774    if (o) {
18775      const { address: u } = wt.parseCaipAddress(o);
18776      i = u;
18777    }
18778    const a = Rf.getConnectionStatus(e, n);
18779    switch (a) {
18780      case "connected":
18781      case "active": {
18782        const u = await J.handleActiveConnection({
18783          connection: e,
18784          namespace: n,
18785          address: t
18786        });
18787        if (i && u) {
18788          const c = u.toLowerCase() !== i.toLowerCase();
18789          s?.({
18790            address: u,
18791            namespace: n,
18792            hasSwitchedAccount: c,
18793            hasSwitchedWallet: a === "active"
18794          });
18795        }
18796        break;
18797      }
18798      case "disconnected": {
18799        const u = await J.handleDisconnectedConnection({
18800          connection: e,
18801          namespace: n,
18802          address: t,
18803          closeModalOnConnect: r
18804        });
18805        u && s?.({
18806          address: u,
18807          namespace: n,
18808          hasSwitchedAccount: !0,
18809          hasSwitchedWallet: !0
18810        });
18811        break;
18812      }
18813      default:
18814        throw new Error(`Invalid connection status: ${a}`);
18815    }
18816  }
18817}, J = Mt(QC), Qo = {
18818  /**
18819   * Creates a Balance object from an ERC7811 Asset object
18820   * @param asset - Asset object to convert
18821   * @param chainId - Chain ID in CAIP-2 format
18822   * @returns Balance object
18823   */
18824  createBalance(e, t) {
18825    const n = {
18826      name: e.metadata.name || "",
18827      symbol: e.metadata.symbol || "",
18828      decimals: e.metadata.decimals || 0,
18829      value: e.metadata.value || 0,
18830      price: e.metadata.price || 0,
18831      iconUrl: e.metadata.iconUrl || ""
18832    };
18833    return {
18834      name: n.name,
18835      symbol: n.symbol,
18836      chainId: t,
18837      address: e.address === "native" ? void 0 : this.convertAddressToCAIP10Address(e.address, t),
18838      value: n.value,
18839      price: n.price,
18840      quantity: {
18841        decimals: n.decimals.toString(),
18842        numeric: this.convertHexToBalance({
18843          hex: e.balance,
18844          decimals: n.decimals
18845        })
18846      },
18847      iconUrl: n.iconUrl
18848    };
18849  },
18850  /**
18851   * Converts a hex string to a Balance object
18852   * @param hex - Hex string to convert
18853   * @param decimals - Number of decimals to use
18854   * @returns Balance object
18855   */
18856  convertHexToBalance({ hex: e, decimals: t }) {
18857    return zs(BigInt(e), t);
18858  },
18859  /**
18860   * Converts an address to a CAIP-10 address
18861   * @param address - Address to convert
18862   * @param chainId - Chain ID in CAIP-2 format
18863   * @returns CAIP-10 address
18864   */
18865  convertAddressToCAIP10Address(e, t) {
18866    return `${t}:${e}`;
18867  },
18868  /**
18869   *  Creates a CAIP-2 Chain ID from a chain ID and namespace
18870   * @param chainId  - Chain ID in hex format
18871   * @param namespace  - Chain namespace
18872   * @returns
18873   */
18874  createCAIP2ChainId(e, t) {
18875    return `${t}:${parseInt(e, 16)}`;
18876  },
18877  /**
18878   * Gets the chain ID in hex format from a CAIP-2 Chain ID
18879   * @param caip2ChainId - CAIP-2 Chain ID
18880   * @returns Chain ID in hex format
18881   */
18882  getChainIdHexFromCAIP2ChainId(e) {
18883    const t = e.split(":");
18884    if (t.length < 2 || !t[1])
18885      return "0x0";
18886    const n = t[1], r = parseInt(n, 10);
18887    return isNaN(r) ? "0x0" : `0x${r.toString(16)}`;
18888  },
18889  /**
18890   * Checks if a response is a valid WalletGetAssetsResponse
18891   * @param response - The response to check
18892   * @returns True if the response is a valid WalletGetAssetsResponse, false otherwise
18893   */
18894  isWalletGetAssetsResponse(e) {
18895    return typeof e != "object" || e === null ? !1 : Object.values(e).every((t) => Array.isArray(t) && t.every((n) => this.isValidAsset(n)));
18896  },
18897  /**
18898   * Checks if an asset object is valid.
18899   * @param asset - The asset object to check.
18900   * @returns True if the asset is valid, false otherwise.
18901   */
18902  isValidAsset(e) {
18903    return typeof e == "object" && e !== null && typeof e.address == "string" && typeof e.balance == "string" && (e.type === "ERC20" || e.type === "NATIVE") && typeof e.metadata == "object" && e.metadata !== null && typeof e.metadata.name == "string" && typeof e.metadata.symbol == "string" && typeof e.metadata.decimals == "number" && typeof e.metadata.price == "number" && typeof e.metadata.iconUrl == "string";
18904  }
18905};
18906let Jo;
18907async function Vu() {
18908  if (!Jo) {
18909    const { createPublicClient: e, http: t, defineChain: n } = await import("./index-CvEGnoek.js");
18910    Jo = {
18911      createPublicClient: e,
18912      http: t,
18913      defineChain: n
18914    };
18915  }
18916  return Jo;
18917}
18918const ja = {
18919  getBlockchainApiRpcUrl(e, t) {
18920    const n = new URL("https://rpc.walletconnect.org/v1/");
18921    return n.searchParams.set("chainId", e), n.searchParams.set("projectId", t), n.toString();
18922  },
18923  async getViemChain(e) {
18924    const { defineChain: t } = await Vu(), { chainId: n } = wt.parseCaipNetworkId(e.caipNetworkId);
18925    return t({ ...e, id: Number(n) });
18926  },
18927  async createViemPublicClient(e) {
18928    const { createPublicClient: t, http: n } = await Vu(), r = z.state.projectId, s = await
18928 ja.getViemChain(e);
18929    if (!s)
18930      throw new Error(`Chain ${e.caipNetworkId} not found in viem/chains`);
18931    return t({
18932      chain: s,
18933      transport: n(ja.getBlockchainApiRpcUrl(e.caipNetworkId, r))
18934    });
18935  }
18936}, Oc = {
18937  /**
18938   * Get the balances of the user's tokens. If user connected with Auth provider or and on the EIP155 network,
18939   * it'll use the `wallet_getAssets` and `wallet_getCapabilities` calls to fetch the balance rather than Blockchain API
18940   * @param forceUpdate - If true, the balances will be fetched from the server
18941   * @returns The balances of the user's tokens
18942   */
18943  async getMyTokensWithBalance(e = {
18944    forceUpdate: void 0,
18945    caipNetwork: v.state.activeCaipNetwork,
18946    address: v.getAccountData()?.address
18947  }) {
18948    const { forceUpdate: t, caipNetwork: n, address: r } = e, s = H.getConnectorId("eip155") === x.CONNECTOR_ID.AUTH;
18949    if (!r)
18950      return [];
18951    const i = n ? `${n.caipNetworkId}:${r}` : r, o = W.getBalanceCacheForCaipAddress(i);
18952    if (o)
18953      return o.balances;
18954    if (n && n.chainNamespace === x.CHAIN.EVM && s) {
18955      const u = await this.getEIP155Balances(r, n);
18956      if (u)
18957        return this.filterLowQualityTokens(u);
18958    }
18959    const a = await ce.getBalance(r, n?.caipNetworkId, t);
18960    return this.filterLowQualityTokens(a.balances);
18961  },
18962  /**
18963   * Get the balances of the user's tokens on the EIP155 network using native `wallet_getAssets` and `wallet_getCapabilities` calls
18964   * @param address - The address of the user
18965   * @param caipNetwork - The CAIP network
18966   * @returns The balances of the user's tokens on the EIP155 network
18967   */
18968  async getEIP155Balances(e, t) {
18969    try {
18970      const n = Qo.getChainIdHexFromCAIP2ChainId(t.caipNetworkId);
18971      if (!(await J.getCapabilities(e))?.[n]?.assetDiscovery?.supported)
18972        return null;
18973      const s = await J.walletGetAssets({
18974        account: e,
18975        chainFilter: [n]
18976      });
18977      if (!Qo.isWalletGetAssetsResponse(s))
18978        return null;
18979      const o = (s[n] || []).map((a) => Qo.createBalance(a, t.caipNetworkId));
18980      return W.updateBalanceCache({
18981        caipAddress: `${t.caipNetworkId}:${e}`,
18982        balance: { balances: o },
18983        timestamp: Date.now()
18984      }), o;
18985    } catch {
18986      return null;
18987    }
18988  },
18989  /**
18990   * The 1Inch API includes many low-quality tokens in the balance response,
18991   * which appear inconsistently. This filter prevents them from being displayed.
18992   */
18993  filterLowQualityTokens(e) {
18994    return e.filter((t) => t.quantity.decimals !== "0");
18995  },
18996  async fetchERC20Balance({ caipAddress: e, assetAddress: t, caipNetwork: n }) {
18997    const r = await ja.createViemPublicClient(n), { address: s } = wt.parseCaipAddress(e), [{ result: i }, { result: o }, { result: a }, { result: u }] = await r.multicall({
18998      contracts: [
18999        {
19000          address: t,
19001          functionName: "name",
19002          args: [],
19003          abi: oi
19004        },
19005        {
19006          address: t,
19007          functionName: "symbol",
19008          args: [],
19009          abi: oi
19010        },
19011        {
19012          address: t,
19013          functionName: "balanceOf",
19014          args: [s],
19015          abi: oi
19016        },
19017        {
19018          address: t,
19019          functionName: "decimals",
19020          args: [],
19021          abi: oi
19022        }
19023      ]
19024    });
19025    return {
19026      name: i,
19027      symbol: o,
19028      decimals: u,
19029      balance: a && u ? zs(a, u) : "0"
19030    };
19031  }
19032}, Xo = {
19033  adapters: {}
19034}, JC = {
19035  state: Xo,
19036  initialize(e) {
19037    Xo.adapters = { ...e };
19038  },
19039  get(e) {
19040    return Xo.adapters[e];
19041  }
19042}, ro = {
19043  eip155: void 0,
19044  solana: void 0,
19045  polkadot: void 0,
19046  bip122: void 0,
19047  cosmos: void 0,
19048  sui: void 0,
19049  stacks: void 0,
19050  ton: void 0,
19051  tron: void 0
19052}, ct = Me({
19053  providers: { ...ro },
19054  providerIds: { ...ro }
19055}), Ds = {
19056  state: ct,
19057  subscribeKey(e, t) {
19058    return Je(ct, e, t);
19059  },
19060  subscribe(e) {
19061    return tt(ct, () => {
19062      e(ct);
19063    });
19064  },
19065  subscribeProviders(e) {
19066    return tt(ct.providers, () => e(ct.providers));
19067  },
19068  setProvider(e, t) {
19069    e && t && (ct.providers[e] = Ns(t));
19070  },
19071  getProvider(e) {
19072    if (e)
19073      return ct.providers[e];
19074  },
19075  setProviderId(e, t) {
19076    t && (ct.providerIds[e] = t);
19077  },
19078  getProviderId(e) {
19079    if (e)
19080      return ct.providerIds[e];
19081  },
19082  reset() {
19083    ct.providers = { ...ro }, ct.providerIds = { ...ro };
19084  },
19085  resetChain(e) {
19086    ct.providers[e] = void 0, ct.providerIds[e] = void 0;
19087  }
19088}, XC = {
19089  async getTokenList(e) {
19090    return (await ce.fetchSwapTokens({
19091      chainId: e
19092    }))?.tokens?.map((r) => ({
19093      ...r,
19094      eip2612: !1,
19095      quantity: {
19096        decimals: "0",
19097        numeric: "0"
19098      },
19099      price: 0,
19100      value: 0
19101    })) || [];
19102  },
19103  async fetchGasPrice() {
19104    const e = v.state.activeCaipNetwork;
19105    if (!e)
19106      return null;
19107    try {
19108      if (e.chainNamespace === "solana") {
19109        const t = (await J?.estimateGas({ chainNamespace: "solana" }))?.toString();
19110        return {
19111          standard: t,
19112          fast: t,
19113          instant: t
19114        };
19115      } else
19116        return await ce.fetchGasPrice({
19117          chainId: e.caipNetworkId
19118        });
19119    } catch {
19120      return null;
19121    }
19122  },
19123  async fetchSwapAllowance({ tokenAddress: e, userAddress: t, sourceTokenAmount: n, sourceTokenDecimals: r }) {
19124    const s = await ce.fetchSwapAllowance({
19125      tokenAddress: e,
19126      userAddress: t
19127    });
19128    if (s?.allowance && n && r) {
19129      const i = J.parseUnits(n, r) || 0;
19130      return BigInt(s.allowance) >= i;
19131    }
19132    return !1;
19133  },
19134  async getMyTokensWithBalance(e) {
19135    const t = await Oc.getMyTokensWithBalance({
19136      forceUpdate: e,
19137      caipNetwork: v.state.activeCaipNetwork,
19138      address: v.getAccountData()?.address
19139    });
19140    return v.setAccountProp("tokenBalance", t, v.state.activeChain), this.mapBalancesToSwapTokens(t);
19141  },
19142  /**
19143   * Maps the balances from Blockchain API to SwapTokenWithBalance array
19144   * @param balances
19145   * @returns SwapTokenWithBalance[]
19146   */
19147  mapBalancesToSwapTokens(e) {
19148    return e?.map((t) => ({
19149      ...t,
19150      address: t?.address ? t.address : Sf(),
19151      decimals: parseInt(t.quantity.decimals, 10),
19152      logoUri: t.iconUrl,
19153      eip2612: !1
19154    })) || [];
19155  },
19156  async handleSwapError(e) {
19157    try {
19158      const t = e?.cause;
19159      return t?.json && (await t.json())?.reasons?.[0]?.description?.includes("insufficient liquidity") ? "Insufficient liquidity" : void 0;
19160    } catch {
19161      return;
19162    }
19163  }
19164}, Ae = Me({
19165  tokenBalances: [],
19166  loading: !1
19167}), eE = {
19168  state: Ae,
19169  subscribe(e) {
19170    return tt(Ae, () => e(Ae));
19171  },
19172  subscribeKey(e, t) {
19173    return Je(Ae, e, t);
19174  },
19175  setToken(e) {
19176    e && (Ae.token = Ns(e));
19177  },
19178  setTokenAmount(e) {
19179    Ae.sendTokenAmount = e;
19180  },
19181  setReceiverAddress(e) {
19182    Ae.receiverAddress = e;
19183  },
19184  setReceiverProfileImageUrl(e) {
19185    Ae.receiverProfileImageUrl = e;
19186  },
19187  setReceiverProfileName(e) {
19188    Ae.receiverProfileName = e;
19189  },
19190  setNetworkBalanceInUsd(e) {
19191    Ae.networkBalanceInUSD = e;
19192  },
19193  setLoading(e) {
19194    Ae.loading = e;
19195  },
19196  getSdkEventProperties(e) {
19197    return {
19198      message: q.parseError(e),
19199      isSmartAccount: Et(v.state.activeChain) === Ye.ACCOUNT_TYPES.SMART_ACCOUNT,
19200      token: Ae.token?.symbol || "",
19201      amount: Number(Ae.sendTokenAmount ?? "0"),
19202      network: v.state.activeCaipNetwork?.caipNetworkId || ""
19203    };
19204  },
19205  async sendToken() {
19206    try {
19207      switch (ye.setLoading(!0), v.state.activeCaipNetwork?.chainNamespace) {
19208        case "eip155":
19209          await ye.sendEvmToken();
19210          return;
19211        case "solana":
19212          await ye.sendSolanaToken();
19213          return;
19214        default:
19215          throw new Error("Unsupported chain");
19216      }
19217    } catch (e) {
19218      throw St.isUserRejectedRequestError(e) ? new Zn(e) : e;
19219    } finally {
19220      ye.setLoading(!1);
19221    }
19222  },
19223  async sendEvmToken() {
19224    const e = v.state.activeChain;
19225    if (!e)
19226      throw new Error("SendController:sendEvmToken - activeChainNamespace is required");
19227    const t = Et(e);
19228    if (!ye.state.sendTokenAmount || !ye.state.receiverAddress)
19229      throw new Error("An amount and receiver address are required");
19230    if (!ye.state.token)
19231      throw new Error("A token is required");
19232    if (ye.state.token?.address) {
19233      ve.sendEvent({
19234        type: "track",
19235        event: "SEND_INITIATED",
19236        properties: {
19237          isSmartAccount: t === Ye.ACCOUNT_TYPES.SMART_ACCOUNT,
19238          token: ye.state.token.address,
19239          amount: Number(ye.state.sendTokenAmount),
19240          network: v.state.activeCaipNetwork?.caipNetworkId || ""
19241        }
19242      });
19243      const { hash: n } = await ye.sendERC20Token({
19244        receiverAddress: ye.state.receiverAddress,
19245        tokenAddress: ye.state.token.address,
19246        sendTokenAmount: ye.state.sendTokenAmount,
19247        decimals: ye.state.token.quantity.decimals
19248      });
19249      n && (Ae.hash = n);
19250    } else {
19251      ve.sendEvent({
19252        type: "track",
19253        event: "SEND_INITIATED",
19254        properties: {
19255          isSmartAccount: t === Ye.ACCOUNT_TYPES.SMART_ACCOUNT,
19256          token: ye.state.token.symbol || "",
19257          amount: Number(ye.state.sendTokenAmount),
19258          network: v.state.activeCaipNetwork?.caipNetworkId || ""
19259        }
19260      });
19261      const { hash: n } = await ye.sendNativeToken({
19262        receiverAddress: ye.state.receiverAddress,
19263        sendTokenAmount: ye.state.sendTokenAmount,
19264        decimals: ye.state.token.quantity.decimals
19265      });
19266      n && (Ae.hash = n);
19267    }
19268  },
19269  async fetchTokenBalance(e) {
19270    Ae.loading = !0;
19271    const t = v.state.activeChain, n = v.state.activeCaipNetwork?.caipNetworkId, r = v.state.activeCaipNetwork?.chainNamespace, s = v.getAccountData(t)?.caipAddress ?? v.state.activeCaipAddress, i = s ? q.getPlainAddress(s) : void 0;
19272    if (Ae.lastRetry && !q.isAllowedRetry(Ae.lastRetry, 30 * Qe.ONE_SEC_MS))
19273      return Ae.loading = !1, [];
19274    try {
19275      if (i && n && r) {
19276        const o = await Oc.getMyTokensWithBalance();
19277        return Ae.tokenBalances = o, Ae.lastRetry = void 0, o;
19278      }
19279    } catch (o) {
19280      Ae.lastRetry = Date.now(), e?.(o), Sn.showError("Token Balance Unavailable");
19281    } finally {
19282      Ae.loading = !1;
19283    }
19284    return [];
19285  },
19286  fetchNetworkBalance() {
19287    if (Ae.tokenBalances.length === 0)
19288      return;
19289    const e = XC.mapBalancesToSwapTokens(Ae.tokenBalances);
19290    if (!e)
19291      return;
19292    const t = e.find((n) => n.address === Sf());
19293    t && (Ae.networkBalanceInUSD = t ? Ic.multiply(t.quantity.numeric, t.price).toString() : "0");
19294  },
19295  async sendNativeToken(e) {
19296    ie.pushTransactionStack({});
19297    const t = e.receiverAddress, n = v.getAccountData()?.address, r = J.parseUnits(e.sendTokenAmount.toString(), Number(e.decimals)), i = await J.sendTransaction({
19298      chainNamespace: x.CHAIN.EVM,
19299      to: t,
19300      address: n,
19301      data: "0x",
19302      value: r ?? BigInt(0)
19303    });
19304    return ve.sendEvent({
19305      type: "track",
19306      event: "SEND_SUCCESS",
19307      properties: {
19308        isSmartAccount: Et("eip155") === Ye.ACCOUNT_TYPES.SMART_ACCOUNT,
19309        token: ye.state.token?.symbol || "",
19310        amount: Number(e.sendTokenAmount),
19311        network: v.state.activeCaipNetwork?.caipNetworkId || "",
19312        hash: i || ""
19313      }
19314    }), J._getClient()?.updateBalance("eip155"), ye.resetSend(), { hash: i };
19315  },
19316  async sendERC20Token(e) {
19317    ie.pushTransactionStack({
19318      onSuccess() {
19319        ie.replace("Account");
19320      }
19321    });
19322    const t = J.parseUnits(e.sendTokenAmount.toString(), Number(e.decimals)), n = v.getAccountData()?.address;
19323    if (n && e.sendTokenAmount && e.receiverAddress && e.tokenAddress) {
19324      const r = q.getPlainAddress(e.tokenAddress);
19325      if (!r)
19326        throw new Error("SendController:sendERC20Token - tokenAddress is required");
19327      const s = await J.writeContract({
19328        fromAddress: n,
19329        tokenAddress: r,
19330        args: [e.receiverAddress, t ?? BigInt(0)],
19331        method: "transfer",
19332        abi: Cy.getERC20Abi(r),
19333        chainNamespace: x.CHAIN.EVM
19334      });
19335      return ve.sendEvent({
19336        type: "track",
19337        event: "SEND_SUCCESS",
19338        properties: {
19339          isSmartAccount: Et("eip155") === Ye.ACCOUNT_TYPES.SMART_ACCOUNT,
19340          token: ye.state.token?.symbol || "",
19341          amount: Number(e.sendTokenAmount),
19342          network: v.state.activeCaipNetwork?.caipNetworkId || "",
19343          hash: s || ""
19344        }
19345      }), ye.resetSend(), { hash: s };
19346    }
19347    return { hash: void 0 };
19348  },
19349  async sendSolanaToken() {
19350    if (!ye.state.sendTokenAmount || !ye.state.receiverAddress)
19351      throw new Error("An amount and receiver address are required");
19352    ie.pushTransactionStack({
19353      onSuccess() {
19354        ie.replace("Account");
19355      }
19356    });
19357    let e;
19358    ye.state.token && ye.state.token.address !== Qe.SOLANA_NATIVE_TOKEN_ADDRESS && (q.isCaipAddress(ye.state.token.address) ? e = q.getPlainAddress(ye.state.token.address) : e = ye.state.token.address);
19359    const t = await J.sendTransaction({
19360      chainNamespace: "solana",
19361      tokenMint: e,
19362      to: ye.state.receiverAddress,
19363      value: Number(ye.state.sendTokenAmount)
19364    });
19365    t && (Ae.hash = t), J._getClient()?.updateBalance("solana"), ve.sendEvent({
19366      type: "track",
19367      event: "SEND_SUCCESS",
19368      properties: {
19369        isSmartAccount: !1,
19370        token: ye.state.token?.symbol || "",
19371        amount: Number(ye.state.sendTokenAmount),
19372        network: v.state.activeCaipNetwork?.caipNetworkId || "",
19373        hash: t || ""
19374      }
19375    }), ye.resetSend();
19376  },
19377  resetSend() {
19378    Ae.token = void 0, Ae.sendTokenAmount = void 0, Ae.receiverAddress = void 0, Ae.receiverProfileImageUrl = void 0, Ae.receiverProfileName = void 0, Ae.loading = !1, Ae.tokenBalances = [];
19379  }
19380}, ye = Mt(eE), ea = {
19381  currentTab: 0,
19382  tokenBalance: [],
19383  smartAccountDeployed: !1,
19384  addressLabels: /* @__PURE__ */ new Map(),
19385  user: void 0,
19386  preferredAccountType: void 0
19387}, wi = {
19388  caipNetwork: void 0,
19389  supportsAllNetworks: !0,
19390  smartAccountEnabledNetworks: []
19391}, $ = Me({
19392  chains: rw(),
19393  activeCaipAddress: void 0,
19394  activeChain: void 0,
19395  activeCaipNetwork: void 0,
19396  noAdapters: !1,
19397  universalAdapter: {
19398    connectionControllerClient: void 0
19399  },
19400  isSwitchingNamespace: !1
19401}), xf = {
19402  state: $,
19403  subscribe(e) {
19404    return tt($, () => {
19405      e($);
19406    });
19407  },
19408  subscribeKey(e, t) {
19409    return Je($, e, t);
19410  },
19411  subscribeAccountStateProp(e, t, n) {
19412    const r = n || $.activeChain;
19413    return r ? Je($.chains.get(r)?.accountState || {}, e, t) : () => {
19414    };
19415  },
19416  subscribeChainProp(e, t, n) {
19417    let r;
19418    return tt($.chains, () => {
19419      const s = n || $.activeChain;
19420      if (s) {
19421        const i = $.chains.get(s)?.[e];
19422        r !== i && (r = i, t(i));
19423      }
19424    });
19425  },
19426  initialize(e, t, n) {
19427    const { chainId: r, namespace: s } = W.getActiveNetworkProps(), i = t?.find((l) => l.id.toString() === r?.toString()), a = e.find((l) => l?.namespace === s) || e?.[0], u = e.map((l) => l.namespace).filter((l) =>
19427 l !== void 0), c = z.state.enableEmbedded ? /* @__PURE__ */ new Set([...u]) : /* @__PURE__ */ new Set([...t?.map((l) => l.chainNamespace) ?? []]);
19428    (e?.length === 0 || !a) && ($.noAdapters = !0), $.noAdapters || ($.activeChain = a?.namespace, $.activeCaipNetwork = i, v.setChainNetworkData(a?.namespace, {
19429      caipNetwork: i
19430    }), $.activeChain && un.set({ activeChain: a?.namespace })), c.forEach((l) => {
19431      const f = t?.filter((y) => y.chainNamespace === l), p = W.getPreferredAccountTypes() || {}, m = { ...z.state.defaultAccountTypes, ...p };
19432      v.state.chains.set(l, {
19433        namespace: l,
19434        networkState: Me({ ...wi, caipNetwork: f?.[0] }),
19435        accountState: Me({
19436          ...ea,
19437          preferredAccountType: m[l]
19438        }),
19439        caipNetworks: f ?? [],
19440        ...n
19441      }), v.setRequestedCaipNetworks(f ?? [], l);
19442    });
19443  },
19444  removeAdapter(e) {
19445    if ($.activeChain === e) {
19446      const t = Array.from($.chains.entries()).find(([n]) => n !== e);
19447      if (t) {
19448        const n = t[1]?.caipNetworks?.[0];
19449        n && v.setActiveCaipNetwork(n);
19450      }
19451    }
19452    $.chains.delete(e);
19453  },
19454  addAdapter(e, { connectionControllerClient: t }, n) {
19455    if (!e.namespace)
19456      throw new Error("ChainController:addAdapter - adapter must have a namespace");
19457    $.chains.set(e.namespace, {
19458      namespace: e.namespace,
19459      networkState: { ...wi, caipNetwork: n[0] },
19460      accountState: { ...ea },
19461      caipNetworks: n,
19462      connectionControllerClient: t
19463    }), v.setRequestedCaipNetworks(n?.filter((r) => r.chainNamespace === e.namespace) ?? [], e.namespace);
19464  },
19465  addNetwork(e) {
19466    const t = $.chains.get(e.chainNamespace);
19467    if (t) {
19468      const n = [...t.caipNetworks || []];
19469      t.caipNetworks?.find((r) => r.id === e.id) || n.push(e), $.chains.set(e.chainNamespace, { ...t, caipNetworks: n }), v.setRequestedCaipNetworks(n, e.chainNamespace), H.filterByNamespace(e.chainNamespace, !0);
19470    }
19471  },
19472  removeNetwork(e, t) {
19473    const n = $.chains.get(e);
19474    if (n) {
19475      const r = $.activeCaipNetwork?.id === t, s = [
19476        ...n.caipNetworks?.filter((i) => i.id !== t) || []
19477      ];
19478      r && n?.caipNetworks?.[0] && v.setActiveCaipNetwork(n.caipNetworks[0]), $.chains.set(e, { ...n, caipNetworks: s }), v.setRequestedCaipNetworks(s || [], e), s.length === 0 && H.filterByNamespace(e, !1);
19479    }
19480  },
19481  setAdapterNetworkState(e, t) {
19482    const n = $.chains.get(e);
19483    n && (n.networkState = {
19484      ...n.networkState || wi,
19485      ...t
19486    }, $.chains.set(e, n));
19487  },
19488  setChainAccountData(e, t, n = !0) {
19489    if (!e)
19490      throw new Error("Chain is required to update chain account data");
19491    const r = $.chains.get(e);
19492    if (r) {
19493      const s = {
19494        ...r.accountState || ea,
19495        ...t
19496      };
19497      $.chains.set(e, { ...r, accountState: s }), ($.chains.size === 1 || $.activeChain === e) && t.caipAddress && ($.activeCaipAddress = t.caipAddress);
19498    }
19499  },
19500  setChainNetworkData(e, t) {
19501    if (!e)
19502      return;
19503    const n = $.chains.get(e);
19504    if (n) {
19505      const r = { ...n.networkState || wi, ...t };
19506      $.chains.set(e, { ...n, networkState: r });
19507    }
19508  },
19509  // eslint-disable-next-line max-params
19510  setAccountProp(e, t, n, r = !0) {
19511    v.setChainAccountData(n, { [e]: t }, r);
19512  },
19513  setActiveNamespace(e) {
19514    $.activeChain = e;
19515    const t = e ? $.chains.get(e) : void 0, n = t?.networkState?.caipNetwork;
19516    n?.id && e && ($.activeCaipAddress = t?.accountState?.caipAddress, $.activeCaipNetwork = n, v.setChainNetworkData(e, { caipNetwork: n }), W.setActiveCaipNetworkId(n?.caipNetworkId), un.set({
19517      activeChain: e,
19518      selectedNetworkId: n?.caipNetworkId
19519    }));
19520  },
19521  setActiveCaipNetwork(e) {
19522    if (!e)
19523      return;
19524    const t = $.activeChain === e.chainNamespace;
19525    t || v.setIsSwitchingNamespace(!0);
19526    const n = $.chains.get(e.chainNamespace);
19527    $.activeChain = e.chainNamespace, $.activeCaipNetwork = e, v.setChainNetworkData(e.chainNamespace, { caipNetwork: e });
19528    let r = n?.accountState?.address;
19529    if (r)
19530      $.activeCaipAddress = `${e.chainNamespace}:${e.id}:${r}`;
19531    else if (t && $.activeCaipAddress) {
19532      const { address: i } = wt.parseCaipAddress($.activeCaipAddress);
19533      r = i, $.activeCaipAddress = `${e.caipNetworkId}:${r}`;
19534    } else
19535      $.activeCaipAddress = void 0;
19536    v.setChainAccountData(e.chainNamespace, {
19537      address: r,
19538      caipAddress: $.activeCaipAddress
19539    }), ye.resetSend(), un.set({
19540      activeChain: $.activeChain,
19541      selectedNetworkId: $.activeCaipNetwork?.caipNetworkId
19542    }), W.setActiveCaipNetworkId(e.caipNetworkId), !v.checkIfSupportedNetwork(e.chainNamespace) && z.state.enableNetworkSwitch && !z.state.allowUnsupportedChain && !J.state.wcBasic && v.showUnsupportedChainUI();
19543  },
19544  addCaipNetwork(e) {
19545    if (!e)
19546      return;
19547    const t = $.chains.get(e.chainNamespace);
19548    t && t?.caipNetworks?.push(e);
19549  },
19550  async switchActiveNamespace(e) {
19551    if (!e)
19552      return;
19553    const t = e !== v.state.activeChain, n = v.getNetworkData(e)?.caipNetwork, r = v.getCaipNetworkByNamespace(e, n?.id);
19554    t && r && await v.switchActiveNetwork(r);
19555  },
19556  async switchActiveNetwork(e, { throwOnFailure: t = !1 } = {}) {
19557    const n = v.state.activeChain;
19558    if (!n)
19559      throw new Error("ChainController:switchActiveNetwork - namespace is required");
19560    const r = Ds.getProviderId($.activeChain) === "AUTH", s = v.getAccountData(n)?.address, i = x.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(e.chainNamespace);
19561    try {
19562      if (s && e.chainNamespace === n || r && i) {
19563        const o = JC.get(e.chainNamespace);
19564        if (!o)
19565          throw new Error("Adapter not found");
19566        await o.switchNetwork({ caipNetwork: e });
19567      }
19568      v.setActiveCaipNetwork(e);
19569    } catch (o) {
19570      if (t)
19571        throw o;
19572    }
19573    ve.sendEvent({
19574      type: "track",
19575      event: "SWITCH_NETWORK",
19576      properties: { network: e.caipNetworkId }
19577    });
19578  },
19579  getConnectionControllerClient(e) {
19580    const t = e || $.activeChain;
19581    if (!t)
19582      throw new Error("Chain is required to get connection controller client");
19583    const n = $.chains.get(t);
19584    if (!n?.connectionControllerClient)
19585      throw new Error("ConnectionController client not set");
19586    return n.connectionControllerClient;
19587  },
19588  getNetworkProp(e, t) {
19589    const n = $.chains.get(t)?.networkState;
19590    if (n)
19591      return n[e];
19592  },
19593  getRequestedCaipNetworks(e) {
19594    const t = $.chains.get(e), { approvedCaipNetworkIds: n = [], requestedCaipNetworks: r = [] } = t?.networkState || {};
19595    return q.sortRequestedNetworks(n, r).filter((o) => o?.id);
19596  },
19597  getAllRequestedCaipNetworks() {
19598    const e = [];
19599    return $.chains.forEach((t) => {
19600      if (!t.namespace)
19601        throw new Error("ChainController:getAllRequestedCaipNetworks - chainAdapter must have a namespace");
19602      const n = v.getRequestedCaipNetworks(t.namespace);
19603      e.push(...n);
19604    }), e;
19605  },
19606  setRequestedCaipNetworks(e, t) {
19607    v.setAdapterNetworkState(t, { requestedCaipNetworks: e });
19608    const r = v.getAllRequestedCaipNetworks().map((i) => i.chainNamespace), s = Array.from(new Set(r));
19609    H.filterByNamespaces(s);
19610  },
19611  getAllApprovedCaipNetworkIds() {
19612    const e = [];
19613    return $.chains.forEach((t) => {
19614      if (!t.namespace)
19615        throw new Error("ChainController:getAllApprovedCaipNetworkIds - chainAdapter must have a namespace");
19616      const n = v.getApprovedCaipNetworkIds(t.namespace);
19617      e.push(...n);
19618    }), e;
19619  },
19620  getActiveCaipNetwork(e) {
19621    return e ? $.chains.get(e)?.networkState?.caipNetwork : $.activeCaipNetwork;
19622  },
19623  getActiveCaipAddress() {
19624    return $.activeCaipAddress;
19625  },
19626  getApprovedCaipNetworkIds(e) {
19627    return $.chains.get(e)?.networkState?.approvedCaipNetworkIds || [];
19628  },
19629  setApprovedCaipNetworksData(e, t) {
19630    v.setAdapterNetworkState(e, t);
19631  },
19632  checkIfSupportedNetwork(e, t) {
19633    const n = t || $.activeCaipNetwork?.caipNetworkId, r = v.getRequestedCaipNetworks(e);
19634    return r.length ? r?.some((s) => s.caipNetworkId === n) : !0;
19635  },
19636  checkIfSupportedChainId(e) {
19637    return $.activeChain ? v.getRequestedCaipNetworks($.activeChain)?.some((n) => n.id === e) : !0;
19638  },
19639  checkIfSmartAccountEnabled() {
19640    const e = Gi.caipNetworkIdToNumber($.activeCaipNetwork?.caipNetworkId);
19641    return !$.activeChain || !e ? !1 : !!(Ve.get(Z.SMART_ACCOUNT_ENABLED_NETWORKS)?.split(",") || [])?.includes(e.toString());
19642  },
19643  showUnsupportedChainUI() {
19644    Se.open({ view: "UnsupportedChain" });
19645  },
19646  checkIfNamesSupported() {
19647    const e = $.activeCaipNetwork;
19648    return !!(e?.chainNamespace && Qe.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(e.chainNamespace));
19649  },
19650  resetNetwork(e) {
19651    v.setAdapterNetworkState(e, {
19652      approvedCaipNetworkIds: void 0,
19653      supportsAllNetworks: !0
19654    });
19655  },
19656  resetAccount(e) {
19657    const t = e;
19658    if (!t)
19659      throw new Error("Chain is required to set account prop");
19660    const n = v.state.chains.get(t)?.accountState?.preferredAccountType, r = z.state.defaultAccountTypes[t];
19661    $.activeCaipAddress = void 0, v.setChainAccountData(t, {
19662      smartAccountDeployed: !1,
19663      currentTab: 0,
19664      caipAddress: void 0,
19665      address: void 0,
19666      balance: void 0,
19667      balanceSymbol: void 0,
19668      profileName: void 0,
19669      profileImage: void 0,
19670      addressExplorerUrl: void 0,
19671      tokenBalance: [],
19672      connectedWalletInfo: void 0,
19673      preferredAccountType: r || n,
19674      socialProvider: void 0,
19675      socialWindow: void 0,
19676      farcasterUrl: void 0,
19677      user: void 0,
19678      status: "disconnected"
19679    }), H.removeConnectorId(t);
19680  },
19681  setIsSwitchingNamespace(e) {
19682    $.isSwitchingNamespace = e;
19683  },
19684  getFirstCaipNetworkSupportsAuthConnector() {
19685    const e = [];
19686    let t;
19687    if ($.chains.forEach((n) => {
19688      x.AUTH_CONNECTOR_SUPPORTED_CHAINS.find((r) => r === n.namespace) && n.namespace && e.push(n.namespace);
19689    }), e.length > 0) {
19690      const n = e[0];
19691      return t = n ? $.chains.get(n)?.caipNetworks?.[0] : void 0, t;
19692    }
19693  },
19694  getAccountData(e) {
19695    const t = e || $.activeChain;
19696    if (t)
19697      return v.state.chains.get(t)?.accountState;
19698  },
19699  getNetworkData(e) {
19700    const t = e || $.activeChain;
19701    if (t)
19702      return v.state.chains.get(t)?.networkState;
19703  },
19704  getCaipNetworkByNamespace(e, t) {
19705    if (!e)
19706      return;
19707    const n = v.state.chains.get(e), r = n?.caipNetworks?.find((s) => s.id.toString() === t?.toString());
19708    return r || n?.networkState?.caipNetwork || n?.caipNetworks?.[0];
19709  },
19710  /**
19711   * Get the requested CaipNetwork IDs for a given namespace. If namespace is not provided, all requested CaipNetwork IDs will be returned
19712   * @param namespace - The namespace to get the requested CaipNetwork IDs for
19713   * @returns The requested CaipNetwork IDs
19714   */
19715  getRequestedCaipNetworkIds() {
19716    const e = H.state.filterByNamespace;
19717    return (e ? [$.chains.get(e)] : Array.from($.chains.values())).flatMap((n) => n?.caipNetworks || []).map((n) => n.caipNetworkId);
19718  },
19719  getCaipNetworks(e) {
19720    return e ? v.getRequestedCaipNetworks(e) : v.getAllRequestedCaipNetworks();
19721  },
19722  getCaipNetworkById(e, t) {
19723    return xf.getCaipNetworks(t).find((n) => n.id.toString() === e.toString() || n.caipNetworkId.toString() === e.toString());
19724  },
19725  setLastConnectedSIWECaipNetwork(e) {
19726    $.lastConnectedSIWECaipNetwork = e;
19727  },
19728  getLastConnectedSIWECaipNetwork() {
19729    return $.lastConnectedSIWECaipNetwork;
19730  },
19731  async fetchTokenBalance(e) {
19732    const t = v.getAccountData();
19733    if (!t)
19734      return [];
19735    const n = v.state.activeCaipNetwork?.caipNetworkId, r = v.state.activeCaipNetwork?.chainNamespace, s = v.state.activeCaipAddress, i = s ? q.getPlainAddress(s) : void 0;
19736    if (v.setAccountProp("balanceLoading", !0, r), t.lastRetry && !q.isAllowedRetry(t.lastRetry, 30 * Qe.ONE_SEC_MS))
19737      return v.setAccountProp("balanceLoading", !1, r), [];
19738    try {
19739      if (i && n && r) {
19740        const o = await Oc.getMyTokensWithBalance();
19741        return v.setAccountProp("tokenBalance", o, r), v.setAccountProp("lastRetry", void 0, r), v.setAccountProp("balanceLoading", !1, r), o;
19742      }
19743    } catch (o) {
19744      v.setAccountProp("lastRetry", Date.now(), r), e?.(o), Sn.showError("Token Balance Unavailable");
19745    } finally {
19746      v.setAccountProp("balanceLoading", !1, r);
19747    }
19748    return [];
19749  },
19750  isCaipNetworkDisabled(e) {
19751    const t = e.chainNamespace, n = !!v.getAccountData(t)?.caipAddress, r = v.getAllApprovedCaipNetworkIds(), s = v.getNetworkProp("supportsAllNetworks", t) !== !1, i = H.getConnectorId(t), o = H.getAuthConnector(), a = i === x.CONNECTOR_ID.AUTH && o;
19752    return !n || s || a ? !1 : !r?.includes(e.caipNetworkId);
19753  }
19754}, v = Mt(xf), tE = {
19755  /**
19756   * Function to handle the network switch.
19757   * This function has variety of conditions to handle the network switch depending on the connectors or namespace's connection states.
19758   * @param args.network - The network to switch to.
19759   * @param args.shouldConfirmSwitch - Whether to confirm the switch. If true, the user will be asked to confirm the switch if necessary.
19760   * @returns void
19761   */
19762  onSwitchNetwork({ network: e, ignoreSwitchConfirmation: t = !1 }) {
19763    const n = v.state.activeCaipNetwork, r = v.state.activeChain, s = ie.state.data;
19764    if (e.id === n?.id)
19765      return;
19766    const o = !!v.getAccountData(r)?.address, a = !!v.getAccountData(e.chainNamespace)?.address, u = e.chainNamespace !== r, l = H.getConnectorId(r) === x.CONNECTOR_ID.AUTH, f = x.AUTH_CONNECTOR_SUPPORTED_CHAINS.find((p) => p === e.chainNamespace);
19767    t || l && f ? ie.push("SwitchNetwork", { ...s, network: e }) : /** * If user switching to a different namespace and next namespace is not connected, we need to show switch active chain view for confirmation first. */ o && u && !a ? ie.push("SwitchActiveChain", {
19768      switchToChain: e.chainNamespace,
19769      navigateTo: "Connect",
19770      navigateWithReplace: !0,
19771      network: e
19772    }) : ie.push("SwitchNetwork", { ...s, network: e });
19773  }
19774}, ut = Me({
19775  loading: !1,
19776  loadingNamespaceMap: /* @__PURE__ */ new Map(),
19777  open: !1,
19778  shake: !1,
19779  namespace: void 0
19780}), nE = {
19781  state: ut,
19782  subscribe(e) {
19783    return tt(ut, () => e(ut));
19784  },
19785  subscribeKey(e, t) {
19786    return Je(ut, e, t);
19787  },
19788  async open(e) {
19789    const t = e?.namespace, n = v.state.activeChain, r = t && t !== n, s = v.getAccountData(e?.namespace)?.caipAddress, i = v.state.noAdapters;
19790    if (J.state.wcBasic ? ee.prefetch({
19791      fetchNetworkImages: !1,
19792      fetchConnectorImages: !1,
19793      fetchWalletRanks: !1
19794    }) : await ee.prefetch(), H.setFilterByNamespace(e?.namespace), Se.setLoading(!0, t), t && r) {
19795      const o = v.getNetworkData(t)?.caipNetwork || v.getRequestedCaipNetworks(t)[0];
19796      o && (i ? (await v.switchActiveNetwork(o), ie.push("ConnectingWalletConnectBasic")) : tE.onSwitchNetwork({ network: o, ignoreSwitchConfirmation: !0 }));
19797    } else z.state.manualWCControl || i && !s ? q.isMobile() ? ie.reset("AllWallets") : ie.reset("ConnectingWalletConnectBasic") : e?.view ? ie.reset(e.view, e.data) : s ? ie.reset("Account") : ie.reset("Connect");
19798    ut.open = !0, un.set({ open: !0 }), ve.sendEvent({
19799      type: "track",
19800      event: "MODAL_OPEN",
19801      properties: { connected: !!s }
19802    });
19803  },
19804  close() {
19805    const e = z.state.enableEmbedded, t = !!v.state.activeCaipAddress;
19806    ut.open && ve.sendEvent({
19807      type: "track",
19808      event: "MODAL_CLOSE",
19809      properties: { connected: t }
19810    }), ut.open = !1, ie.reset("Connect"), Se.clearLoading(), e ? t ? ie.replace("Account") : ie.push("Connect") : un.set({ open: !1 }), J.resetUri();
19811  },
19812  setLoading(e, t) {
19813    t && ut.loadingNamespaceMap.set(t, e), ut.loading = e, un.set({ loading: e });
19814  },
19815  clearLoading() {
19816    ut.loadingNamespaceMap.clear(), ut.loading = !1, un.set({ loading: !1 });
19817  },
19818  shake() {
19819    ut.shake || (ut.shake = !0, setTimeout(() => {
19820      ut.shake = !1;
19821    }, 500));
19822  }
19823}, Se = Mt(nE), Ku = 2147483648, rE = {
19824  convertEVMChainIdToCoinType(e) {
19825    if (e >= Ku)
19826      throw new Error("Invalid chainId");
19827    return (Ku | e) >>> 0;
19828  }
19829}, Ct = Me({
19830  suggestions: [],
19831  loading: !1
19832}), sE = {
19833  state: Ct,
19834  subscribe(e) {
19835    return tt(Ct, () => e(Ct));
19836  },
19837  subscribeKey(e, t) {
19838    return Je(Ct, e, t);
19839  },
19840  async resolveName(e) {
19841    try {
19842      return await ce.lookupEnsName(e);
19843    } catch (t) {
19844      const n = t;
19845      throw new Error(n?.reasons?.[0]?.description || "Error resolving name");
19846    }
19847  },
19848  async isNameRegistered(e) {
19849    try {
19850      return await ce.lookupEnsName(e), !0;
19851    } catch {
19852      return !1;
19853    }
19854  },
19855  async getSuggestions(e) {
19856    try {
19857      Ct.loading = !0, Ct.suggestions = [];
19858      const t = await ce.getEnsNameSuggestions(e);
19859      return Ct.suggestions = t.suggestions || [], Ct.suggestions;
19860    } catch (t) {
19861      const n = Ri.parseEnsApiError(t, "Error fetching name suggestions");
19862      throw new Error(n);
19863    } finally {
19864      Ct.loading = !1;
19865    }
19866  },
19867  async getNamesForAddress(e) {
19868    try {
19869      if (!v.state.activeCaipNetwork)
19870        return [];
19871      const n = W.getEnsFromCacheForAddress(e);
19872      if (n)
19873        return n;
19874      const r = await ce.reverseLookupEnsName({ address: e });
19875      return W.updateEnsCache({
19876        address: e,
19877        ens: r,
19878        timestamp: Date.now()
19879      }), r;
19880    } catch (t) {
19881      const n = Ri.parseEnsApiError(t, "Error fetching names for address");
19882      throw new Error(n);
19883    }
19884  },
19885  async registerName(e) {
19886    const t = v.state.activeCaipNetwork, n = v.getAccountData(t?.chainNamespace)?.address, r = H.getAuthConnector();
19887    if (!t)
19888      throw new Error("Network not found");
19889    if (!n || !r)
19890      throw new Error("Address or auth connector not found");
19891    Ct.loading = !0;
19892    try {
19893      const s = JSON.stringify({
19894        name: e,
19895        attributes: {},
19896        // Unix timestamp
19897        timestamp: Math.floor(Date.now() / 1e3)
19898      });
19899      ie.pushTransactionStack({
19900        onCancel() {
19901          ie.replace("RegisterAccountName");
19902        }
19903      });
19904      const i = await J.signMessage(s);
19905      Ct.loading = !1;
19906      const o = t.id;
19907      if (!o)
19908        throw new Error("Network not found");
19909      const a = rE.convertEVMChainIdToCoinType(Number(o));
19910      await ce.registerEnsName({
19911        coinType: a,
19912        address: n,
19913        signature: i,
19914        message: s
19915      }), v.setAccountProp("profileName", e, t.chainNamespace), W.updateEnsCache({
19916        address: n,
19917        ens: [
19918          {
19919            name: e,
19920            registered_at: (/* @__PURE__ */ new Date()).toISOString(),
19921            updated_at: void 0,
19922            addresses: {},
19923            attributes: []
19924          }
19925        ],
19926        timestamp: Date.now()
19927      }), ie.replace("RegisterAccountNameSuccess");
19928    } catch (s) {
19929      const i = Ri.parseEnsApiError(s, `Error registering name ${e}`);
19930      throw ie.replace("RegisterAccountName"), new Error(i);
19931    } finally {
19932      Ct.loading = !1;
19933    }
19934  },
19935  validateName(e) {
19936    return /^[a-zA-Z0-9-]{4,}$/u.test(e);
19937  },
19938  parseEnsApiError(e, t) {
19939    return e?.reasons?.[0]?.description || t;
19940  }
19941}, Ri = Mt(sE);
19942function Wa(e) {
19943  try {
19944    return new URL(e);
19945  } catch {
19946    return null;
19947  }
19948}
19949function iE(e) {
19950  const t = e.split("/"), n = t.length > 0 && t[0] !== void 0 ? t[0] : "", r = n.lastIndexOf(":");
19951  return r === -1 ? { host: n } : {
19952    host: n.slice(0, r),
19953    port: n.slice(r + 1)
19954  };
19955}
19956function oE(e) {
19957  const t = e.indexOf("://");
19958  if (t === -1)
19959    return null;
19960  const n = e.slice(0, t), r = t + 3;
19961  let s = e.indexOf("/", r);
19962  s === -1 && (s = e.length);
19963  const i = e.slice(r, s), o = i.lastIndexOf(":");
19964  return o === -1 ? { scheme: n, host: i } : { scheme: n, host: i.slice(0, o), port: i.slice(o + 1) };
19965}
19966function aE(e, t) {
19967  if (t.includes("://")) {
19968    const o = Wa(t);
19969    return o ? o.origin === e : !1;
19970  }
19971  const { host: n, port: r } = iE(t), s = e.indexOf("://");
19972  if (s !== -1) {
19973    const o = s + 3;
19974    let a = e.indexOf("/", o);
19975    a === -1 && (a = e.length);
19976    const u = e.slice(o, a);
19977    if (r !== void 0)
19978      return `${n}:${r}` === u;
19979    const c = u.split(":")[0];
19980    return n === c;
19981  }
19982  const i = Wa(e);
19983  return i ? r !== void 0 ? n === i.hostname && r === (i.port || void 0) : n === i.hostname : !1;
19984}
19985function cE(e, t, n) {
19986  let r = n, s;
19987  const i = r.indexOf("://");
19988  i !== -1 && (s = r.slice(0, i), r = r.slice(i + 3));
19989  const o = r.indexOf("/");
19990  o !== -1 && (r = r.slice(0, o));
19991  let a = r, u;
19992  const c = a.lastIndexOf(":");
19993  c !== -1 && (u = a.slice(c + 1), a = a.slice(0, c));
19994  const l = a.split(".");
19995  for (const b of l)
19996    if (b.includes("*") && b !== "*")
19997      return !1;
19998  const f = e.protocol.replace(/:$/u, "");
19999  if (s && s !== f || u !== void 0 && u !== "*" && u !== e.port)
20000    return !1;
20001  const p = oE(t), y = (p ? p.host : e.hostname).split(".");
20002  if (l.length !== y.length)
20003    return !1;
20004  for (let b = l.length - 1; b >= 0; b -= 1) {
20005    const C = l[b], _ = y[b];
20006    if (C !== "*" && C !== _)
20007      return !1;
20008  }
20009  return !0;
20010}
20011const uE = {
20012  ton: ["ton_sendMessage", "ton_signData"],
20013  solana: [
20014    "solana_signMessage",
20015    "solana_signTransaction",
20016    "solana_requestAccounts",
20017    "solana_getAccounts",
20018    "solana_signAllTransactions",
20019    "solana_signAndSendTransaction"
20020  ],
20021  eip155: [
20022    "eth_accounts",
20023    "eth_requestAccounts",
20024    "eth_sendRawTransaction",
20025    "eth_sign",
20026    "eth_signTransaction",
20027    "eth_signTypedData",
20028    "eth_signTypedData_v3",
20029    "eth_signTypedData_v4",
20030    "eth_sendTransaction",
20031    "personal_sign",
20032    "wallet_switchEthereumChain",
20033    "wallet_addEthereumChain",
20034    "wallet_getPermissions",
20035    "wallet_requestPermissions",
20036    "wallet_registerOnboarding",
20037    "wallet_watchAsset",
20038    "wallet_scanQRCode",
20039    // EIP-5792
20040    "wallet_getCallsStatus",
20041    "wallet_showCallsStatus",
20042    "wallet_sendCalls",
20043    "wallet_getCapabilities",
20044    // EIP-7715
20045    "wallet_grantPermissions",
20046    "wallet_revokePermissions",
20047    //EIP-7811
20048    "wallet_getAssets"
20049  ],
20050  bip122: ["sendTransfer", "signMessage", "signPsbt", "getAccountAddresses"],
20051  tron: ["tron_signMessage", "tron_signTransaction"]
20052}, hn = {
20053  RPC_ERROR_CODE: {
20054    USER_REJECTED: 5e3,
20055    USER_REJECTED_METHODS: 5002
20056  },
20057  /**
20058   * Retrieves the array of supported methods for a given chain namespace.
20059   * @param chainNamespace - The chain namespace.
20060   * @returns An array of method strings.
20061   */
20062  getMethodsByChainNamespace(e) {
20063    return uE[e] || [];
20064  },
20065  /**
20066   * Creates a default WalletConnect namespace configuration for the given chain namespace.
20067   * @param chainNamespace - The chain namespace.
20068   * @returns The default Namespace object.
20069   */
20070  createDefaultNamespace(e) {
20071    return {
20072      methods: this.getMethodsByChainNamespace(e),
20073      events: ["accountsChanged", "chainChanged"],
20074      chains: [],
20075      rpcMap: {}
20076    };
20077  },
20078  /**
20079   * Applies overrides to the base WalletConnect NamespaceConfig.
20080   * @param baseNamespaces - The base namespace configuration.
20081   * @param overrides - Optional overrides for methods, chains, events, rpcMap.
20082   * @returns The resulting NamespaceConfig with overrides applied.
20083   */
20084  applyNamespaceOverrides(e, t) {
20085    if (!t)
20086      return { ...e };
20087    const n = { ...e }, r = /* @__PURE__ */ new Set();
20088    if (t.methods && Object.keys(t.methods).forEach((s) => r.add(s)), t.chains && Object.keys(t.chains).forEach((s) => r.add(s)), t.events && Object.keys(t.events).forEach((s) => r.add(s)), t.rpcMap && Object.keys(t.rpcMap).forEach((s) => {
20089      const [i] = s.split(":");
20090      i && r.add(i);
20091    }), r.forEach((s) => {
20092      n[s] || (n[s] = this.createDefaultNamespace(s));
20093    }), t.methods && Object.entries(t.methods).forEach(([s, i]) => {
20094      n[s] && (n[s].methods = i);
20095    }), t.chains && Object.entries(t.chains).forEach(([s, i]) => {
20096      n[s] && (n[s].chains = i);
20097    }), t.events && Object.entries(t.events).forEach(([s, i]) => {
20098      n[s] && (n[s].events = i);
20099    }), t.rpcMap) {
20100      const s = /* @__PURE__ */ new Set();
20101      Object.entries(t.rpcMap).forEach(([i, o]) => {
20102        const [a, u] = i.split(":");
20103        !a || !u || !n[a] || (n[a].rpcMap || (n[a].rpcMap = {}), s.has(a) || (n[a].rpcMap = {}, s.add(a)), n[a].rpcMap[u] = o);
20104      });
20105    }
20106    return n;
20107  },
20108  /**
20109   * Creates WalletConnect namespaces based on CAIP network definitions,
20110   * optionally applying custom overrides.
20111   * @param caipNetworks - Array of CaipNetwork definitions.
20112   * @param configOverride - Optional overrides for namespaces.
20113   * @returns The resulting NamespaceConfig.
20114   */
20115  createNamespaces(e, t) {
20116    const n = e.reduce((r, s) => {
20117      const { id: i, chainNamespace: o, rpcUrls: a } = s, u = a.default.http[0];
20118      r[o] || (r[o] = this.createDefaultNamespace(o));
20119      const c = `${o}:${i}`, l = r[o];
20120      switch (l.chains.push(c), c) {
20121        case "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp":
20122          l.chains.push("solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ");
20123          break;
20124        case "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1":
20125          l.chains.push("solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K");
20126          break;
20127      }
20128      return l?.rpcMap && u && (l.rpcMap[i] = u), r;
20129    }, {});
20130    return this.applyNamespaceOverrides(n, t);
20131  },
20132  /**
20133   * Resolves a Reown/ENS name to its first matching address across configured networks.
20134   * @param name - The ENS or Reown name to resolve.
20135   * @returns The resolved address as a string, or false if not found.
20136   */
20137  resolveReownName: async (e) => {
20138    const t = await Ri.resolveName(e);
20139    return (t?.addresses ? Object.values(t.addresses) : [])[0]?.address || !1;
20140  },
20141  /**
20142   * Extracts all CAIP network IDs used in given WalletConnect namespaces.
20143   * @param namespaces - WalletConnect Namespaces object.
20144   * @returns Array of CAIP network IDs (chainNamespace:chainId).
20145   */
20146  getChainsFromNamespaces(e = {}) {
20147    return Object.values(e).flatMap((t) => {
20148      const n = t.chains || [], r = t.accounts.map((s) => {
20149        const [i, o] = s.split(":");
20150        return `${i}:${o}`;
20151      });
20152      return Array.from(/* @__PURE__ */ new Set([...n, ...r]));
20153    });
20154  },
20155  /**
20156   * Type guard to check if an object is a WalletConnect session event data.
20157   * @param data - The data to check.
20158   * @returns True if data matches SessionEventData structure.
20159   */
20160  isSessionEventData(e) {
20161    return typeof e == "object" && e !== null && "id" in e && "topic" in e && "params" in e && typeof e.params == "object" && e.params !== null && "chainId" in e.params && "event" in e.params && typeof e.params.event == "object" && e.params.event !== null;
20162  },
20163  /**
20164   * Detects if an error object represents a user-rejected WalletConnect request.
20165   * @param error - The error object to check.
20166   * @returns True if user rejected request, otherwise false.
20167   */
20168  isUserRejectedRequestError(e) {
20169    try {
20170      if (typeof e == "object" && e !== null) {
20171        const t = e, n = typeof t.code == "number", r = n && t.code === hn.RPC_ERROR_CODE.USER_REJECTED_METHODS, s = n && t.code === hn.RPC_ERROR_CODE.USER_REJECTED;
20172        return r || s;
20173      }
20174      return !1;
20175    } catch {
20176      return !1;
20177    }
20178  },
20179  /**
20180   * Checks if a current origin is allowed by configured allowed and default origin patterns.
20181   * Localhost and 127.0.0.1 are always allowed.
20182   * @param currentOrigin - The current web origin.
20183   * @param allowedPatterns - Patterns from project configuration.
20184   * @param defaultAllowedOrigins - Built-in or default allowed patterns.
20185   * @returns True if the origin is allowed, false otherwise.
20186   */
20187  isOriginAllowed(e, t, n) {
20188    const r = [...t, ...n];
20189    if (t.length === 0)
20190      return !0;
20191    const s = Wa(e);
20192    if (!s)
20193      return r.some((i) => !i.includes("*") && i === e);
20194    if (s.hostname === "localhost" || s.hostname === "127.0.0.1")
20195      return !0;
20196    for (const i of r)
20197      if (i.includes("*")) {
20198        if (cE(s, e, i))
20199          return !0;
20200      } else if (aE(e, i))
20201        return !0;
20202    return !1;
20203  },
20204  /**
20205   * Attaches event listeners to a UniversalProvider instance for WalletConnect events.
20206   * @param params - The listener parameters including handlers for connect, disconnect, etc.
20207   */
20208  listenWcProvider({ universalProvider: e, namespace: t, onConnect: n, onDisconnect: r, onAccountsChanged: s, onChainChanged: i, onDisplayUri: o }) {
20209    n && e.on("connect", () => {
20210      const a = hn.getWalletConnectAccounts(e, t);
20211      n(a);
20212    }), r && e.on("disconnect", () => {
20213      r();
20214    }), s && e.on("accountsChanged", (a) => {
20215      try {
20216        const u = e.session?.namespaces?.[t]?.accounts || [], c = e.rpcProviders?.[t]?.getDefaultChain(), l = a.map((f) => {
20217          const p = u.find((b) => b.includes(`${t}:${c}:${f}`));
20218          if (!p)
20219            return;
20220          const { chainId: m, chainNamespace: y } = wt.parseCaipAddress(p);
20221          return {
20222            address: f,
20223            chainId: m,
20224            chainNamespace: y
20225          };
20226        }).filter((f) => f !== void 0);
20227        l.length > 0 && s(l);
20228      } catch (u) {
20229        console.warn("Failed to parse accounts for namespace on accountsChanged event", t, a, u);
20230      }
20231    }), i && e.on("chainChanged", (a) => {
20232      i(a);
20233    }), o && e.on("display_uri", (a) => {
20234      o(a);
20235    });
20236  },
20237  /**
20238   * Retrieves and parses the unique set of accounts for a given WalletConnect namespace.
20239   * @param universalProvider - The UniversalProvider instance.
20240   * @param namespace - The chain namespace to extract accounts for.
20241   * @returns Array of parsed CaipAddress objects.
20242   */
20243  getWalletConnectAccounts(e, t) {
20244    const n = /* @__PURE__ */ new Set(), r = e?.session?.namespaces?.[t]?.accounts?.map((s) => wt.parseCaipAddress(s)).filter(({ address: s }) => n.has(s.toLowerCase()) ? !1 : (n.add(s.toLowerCase()), !0));
20245    return r && r.length > 0 ? r : [];
20246  }
20247}, lE = [
20248  x.CONNECTOR_ID.AUTH,
20249  x.CONNECTOR_ID.WALLET_CONNECT
20250];
20251class Of {
20252  /**
20253   * Creates an instance of AdapterBlueprint.
20254   * @param {AdapterBlueprint.Params} params - The parameters for initializing the adapter
20255   */
20256  constructor(t) {
20257    this.availableConnectors = [], this.availableConnections = [], this.providerHandlers = {}, this.eventListeners = /* @__PURE__ */ new Map(), this.getCaipNetworks = (n) => v.getCaipNetworks(n), this.getConnectorId = (n) => H.getConnectorId(n), t && this.construct(t);
20258  }
20259  /**
20260   * Initializes the adapter with the given parameters.
20261   * @param {AdapterBlueprint.Params} params - The parameters for initializing the adapter
20262   */
20263  construct(t) {
20264    this.projectId = t.projectId, this.namespace = t.namespace, this.adapterType = t.adapterType;
20265  }
20266  /**
20267   * Gets the available connectors.
20268   * @returns {Connector[]} An array of available connectors
20269   */
20270  get connectors() {
20271    return this.availableConnectors;
20272  }
20273  /**
20274   * Gets the available connections.
20275   * @returns {Connection[]} An array of available connections
20276   */
20277  get connections() {
20278    return this.availableConnections;
20279  }
20280  /**
20281   * Gets the supported networks.
20282   * @returns {CaipNetwork[]} An array of supported networks
20283   */
20284  get networks() {
20285    return this.getCaipNetworks(this.namespace);
20286  }
20287  /**
20288   * Handles the auth connected event.
20289   * @param {W3mFrameTypes.Responses['FrameGetUserResponse']} user - The user response
20290   */
20291  onAuthConnected({ accounts: t, chainId: n }) {
20292    const r = this.getCaipNetworks().filter((s) => s.chainNamespace === this.namespace).find((s) => s.id.toString() === n?.toString());
20293    t && r && this.addConnection({
20294      connectorId: x.CONNECTOR_ID.AUTH,
20295      accounts: t,
20296      caipNetwork: r
20297    });
20298  }
20299  /**
20300   * Sets the auth provider.
20301   * @param {W3mFrameProvider} authProvider - The auth provider instance
20302   */
20303  setAuthProvider(t) {
20304    t.onConnect(this.onAuthConnected.bind(this)), t.onSocialConnected(this.onAuthConnected.bind(this)), this.addConnector({
20305      id: x.CONNECTOR_ID.AUTH,
20306      type: "AUTH",
20307      name: x.CONNECTOR_NAMES.AUTH,
20308      provider: t,
20309      imageId: void 0,
20310      chain: this.namespace,
20311      chains: []
20312    });
20313  }
20314  /**
20315   * Adds one or more connectors to the available connectors list.
20316   * @param {...Connector} connectors - The connectors to add
20317   */
20318  addConnector(...t) {
20319    const n = /* @__PURE__ */ new Set();
20320    this.availableConnectors = [...t, ...this.availableConnectors].filter((r) =>
20320 n.has(r.id) ? !1 : (n.add(r.id), !0)), this.emit("connectors", this.availableConnectors);
20321  }
20322  /**
20323   * Adds connections to the available connections list
20324   * @param {...Connection} connections - The connections to add
20325   */
20326  addConnection(...t) {
20327    const n = /* @__PURE__ */ new Set();
20328    this.availableConnections = [...t, ...this.availableConnections].filter((r) => n.has(r.connectorId.toLowerCase()) ? !1 : (n.add(r.connectorId.toLowerCase()), !0)), this.emit("connections", this.availableConnections);
20329  }
20330  /**
20331   * Deletes a connection from the available connections list
20332   * @param {string} connectorId - The connector ID of the connection to delete
20333   */
20334  deleteConnection(t) {
20335    this.availableConnections = this.availableConnections.filter((n) => n.connectorId.toLowerCase() !== t.toLowerCase()), this.emit("connections", this.availableConnections);
20336  }
20337  /**
20338   * Clears all connections from the available connections list
20339   * @param {boolean} emit - Whether to emit the connections event
20340   */
20341  clearConnections(t = !1) {
20342    this.availableConnections = [], t && this.emit("connections", this.availableConnections);
20343  }
20344  setStatus(t, n) {
20345    v.setAccountProp("status", t, n);
20346  }
20347  /**
20348   * Adds an event listener for a specific event.
20349   * @template T
20350   * @param {T} eventName - The name of the event
20351   * @param {EventCallback<T>} callback - The callback function to be called when the event is emitted
20352   */
20353  on(t, n) {
20354    this.eventListeners.has(t) || this.eventListeners.set(t, /* @__PURE__ */ new Set()), this.eventListeners.get(t)?.add(n);
20355  }
20356  /**
20357   * Removes an event listener for a specific event.
20358   * @template T
20359   * @param {T} eventName - The name of the event
20360   * @param {EventCallback<T>} callback - The callback function to be removed
20361   */
20362  off(t, n) {
20363    const r = this.eventListeners.get(t);
20364    r && r.delete(n);
20365  }
20366  /**
20367   * Removes all event listeners.
20368   */
20369  removeAllEventListeners() {
20370    this.eventListeners.forEach((t) => {
20371      t.clear();
20372    });
20373  }
20374  /**
20375   * Emits an event with the given name and optional data.
20376   * @template T
20377   * @param {T} eventName - The name of the event to emit
20378   * @param {EventData[T]} [data] - The optional data to be passed to the event listeners
20379   */
20380  emit(t, n) {
20381    const r = this.eventListeners.get(t);
20382    r && r.forEach((s) => s(n));
20383  }
20384  /**
20385   * Connects to WalletConnect.
20386   * @param {number | string} [_chainId] - Optional chain ID to connect to
20387   */
20388  async connectWalletConnect(t) {
20389    try {
20390      return { clientId: (await this.getWalletConnectConnector().connectWalletConnect()).clientId };
20391    } catch (n) {
20392      throw hn.isUserRejectedRequestError(n) ? new Zn(n) : n;
20393    }
20394  }
20395  /**
20396   * Switches the network.
20397   * @param {AdapterBlueprint.SwitchNetworkParams} params - Network switching parameters
20398   */
20399  async switchNetwork(t) {
20400    const { caipNetwork: n } = t, r = Ds.getProviderId(n.chainNamespace), s = Ds.getProvider(n.chainNamespace);
20401    if (!s)
20402      throw new Error("Provider not found");
20403    if (r === "WALLET_CONNECT") {
20404      s.setDefaultChain(n.caipNetworkId);
20405      return;
20406    }
20407    if (r === "AUTH") {
20408      const i = H.getAuthConnector()?.provider;
20409      if (!i)
20410        throw new Error("Auth provider not found");
20411      const o = Et(n.chainNamespace);
20412      await i.switchNetwork({ chainId: n.caipNetworkId });
20413      const a = await i.getUser({
20414        chainId: n.caipNetworkId,
20415        preferredAccountType: o
20416      });
20417      this.emit("switchNetwork", a);
20418    }
20419  }
20420  getWalletConnectConnector() {
20421    const t = this.connectors.find((n) => n.id === "walletConnect");
20422    if (!t)
20423      throw new Error("WalletConnectConnector not found");
20424    return t;
20425  }
20426  /**
20427   * Handles connect event for a specific connector.
20428   * @param {string[]} accounts - The accounts that changed
20429   * @param {string} connectorId - The ID of the connector
20430   */
20431  onConnect(t, n) {
20432    if (t.length > 0) {
20433      const { address: r, chainId: s } = q.getAccount(t[0]), i = this.getCaipNetworks().filter((a) => a.chainNamespace === this.namespace).find((a) => a.id.toString() === s?.toString()), o = this.connectors.find((a) => a.id === n);
20434      r && (this.emit("accountChanged", {
20435        address: r,
20436        chainId: s,
20437        connector: o
20438      }), this.addConnection({
20439        connectorId: n,
20440        accounts: t.map((a) => {
20441          const { address: u } = q.getAccount(a);
20442          return { address: u };
20443        }),
20444        caipNetwork: i
20445      }));
20446    }
20447  }
20448  /**
20449   * Handles accounts changed event for a specific connector.
20450   * @param {string[]} accounts - The accounts that changed
20451   * @param {string} connectorId - The ID of the connector
20452   */
20453  onAccountsChanged(t, n, r = !0) {
20454    if (t.length > 0) {
20455      const { address: s } = q.getAccount(t[0]), i = this.getConnection({
20456        connectorId: n,
20457        connections: this.connections,
20458        connectors: this.connectors
20459      });
20460      s && this.getConnectorId(x.CHAIN.EVM)?.toLowerCase() === n.toLowerCase() && this.emit("accountChanged", {
20461        address: s,
20462        chainId: i?.caipNetwork?.id,
20463        connector: i?.connector
20464      }), this.addConnection({
20465        connectorId: n,
20466        accounts: t.map((o) => {
20467          const { address: a } = q.getAccount(o);
20468          return { address: a };
20469        }),
20470        caipNetwork: i?.caipNetwork
20471      });
20472    } else r && this.onDisconnect(n);
20473  }
20474  /**
20475   * Handles disconnect event for a specific connector.
20476   * @param {string} connectorId - The ID of the connector
20477   */
20478  onDisconnect(t) {
20479    this.removeProviderListeners(t), this.deleteConnection(t), this.getConnectorId(x.CHAIN.EVM)?.toLowerCase() === t.toLowerCase() && this.emitFirstAvailableConnection(), this.connections.length === 0 && this.emit("disconnect");
20480  }
20481  /**
20482   * Handles chain changed event for a specific connector.
20483   * @param {string} chainId - The ID of the chain that changed
20484   * @param {string} connectorId - The ID of the connector
20485   */
20486  onChainChanged(t, n) {
20487    const r = typeof t == "string" && t.startsWith("0x") ? parseInt(t, 16).toString() : t.toString(), s = this.getConnection({
20488      connectorId: n,
20489      connections: this.connections,
20490      connectors: this.connectors
20491    }), i = this.getCaipNetworks().filter((o) => o.chainNamespace === this.namespace).find((o) => o.id.toString() === r);
20492    s && this.addConnection({
20493      connectorId: n,
20494      accounts: s.accounts,
20495      caipNetwork: i
20496    }), this.getConnectorId(x.CHAIN.EVM)?.toLowerCase() === n.toLowerCase() && this.emit("switchNetwork", { chainId: r });
20497  }
20498  /**
20499   * Listens to provider events for a specific connector.
20500   * @param {string} connectorId - The ID of the connector
20501   * @param {Provider | CombinedProvider} provider - The provider to listen to
20502   */
20503  listenProviderEvents(t, n) {
20504    if (lE.includes(t))
20505      return;
20506    const r = (o) => this.onAccountsChanged(o, t), s = (o) => this.onChainChanged(o, t), i = () => this.onDisconnect(t);
20507    this.providerHandlers[t] || (n.on("disconnect", i), n.on("accountsChanged", r), n.on("chainChanged", s), this.providerHandlers[t] = {
20508      provider: n,
20509      disconnect: i,
20510      accountsChanged: r,
20511      chainChanged: s
20512    });
20513  }
20514  /**
20515   * Removes provider listeners for a specific connector.
20516   * @param {string} connectorId - The ID of the connector
20517   */
20518  removeProviderListeners(t) {
20519    if (this.providerHandlers[t]) {
20520      const { provider: n, disconnect: r, accountsChanged: s, chainChanged: i } = this.providerHandlers[t];
20521      n.removeListener("disconnect", r), n.removeListener("accountsChanged", s), n.removeListener("chainChanged", i), this.providerHandlers[t] = null;
20522    }
20523  }
20524  /**
20525   * Emits the first available connection.
20526   */
20527  emitFirstAvailableConnection() {
20528    const t = this.getConnection({
20529      connections: this.connections,
20530      connectors: this.connectors
20531    });
20532    if (t) {
20533      const [n] = t.accounts;
20534      this.emit("accountChanged", {
20535        address: n?.address,
20536        chainId: t.caipNetwork?.id,
20537        connector: t.connector
20538      });
20539    }
20540  }
20541  /**
20542   * Gets a connection based on provided parameters.
20543   * If connectorId is provided, returns connection for that specific connector.
20544   * Otherwise, returns the first available valid connection.
20545   *
20546   * @param params - Connection parameters
20547   * @param params.address - Optional address to filter by
20548   * @param params.connectorId - Optional connector ID to filter by
20549   * @param params.connections - List of available connections
20550   * @param params.connectors - List of available connectors
20551   * @returns Connection or null if none found
20552   */
20553  getConnection({ address: t, connectorId: n, connections: r, connectors: s }) {
20554    if (n) {
20555      const o = r.find((c) => c.connectorId.toLowerCase() === n.toLowerCase());
20556      if (!o)
20557        return null;
20558      const a = s.find((c) => c.id.toLowerCase() === o.connectorId.toLowerCase()), u = t ? o.accounts.find((c) => c.address.toLowerCase() === t.toLowerCase()) : o.accounts[0];
20559      return { ...o, account: u, connector: a };
20560    }
20561    const i = r.find((o) => o.accounts.length > 0 && s.some((a) => a.id.toLowerCase() === o.connectorId.toLowerCase()));
20562    if (i) {
20563      const [o] = i.accounts, a = s.find((u) => u.id.toLowerCase() === i.connectorId.toLowerCase());
20564      return {
20565        ...i,
20566        account: o,
20567        connector: a
20568      };
20569    }
20570    return null;
20571  }
20572}
20573let Gn = null;
20574const sn = {
20575  getSIWX() {
20576    return z.state.siwx;
20577  },
20578  async initializeIfEnabled(e = v.getActiveCaipAddress()) {
20579    const t = z.state.siwx;
20580    if (!(t && e))
20581      return;
20582    const [n, r, s] = e.split(":");
20583    if (v.checkIfSupportedNetwork(n, `${n}:${r}`))
20584      try {
20585        if (z.state.remoteFeatures?.emailCapture) {
20586          const o = v.getAccountData(n)?.user;
20587          await Se.open({
20588            view: "DataCapture",
20589            data: {
20590              email: o?.email ?? void 0
20591            }
20592          });
20593          return;
20594        }
20595        if (Gn && await Gn, (await t.getSessions(`${n}:${r}`, s)).length)
20596          return;
20597        await Se.open({
20598          view: "SIWXSignMessage"
20599        });
20600      } catch (i) {
20601        console.error("SIWXUtil:initializeIfEnabled", i), ve.sendEvent({
20602          type: "track",
20603          event: "SIWX_AUTH_ERROR",
20604          properties: this.getSIWXEventProperties(i)
20605        }), await J._getClient()?.disconnect().catch(console.error), ie.reset("Connect"), Sn.showError("A problem occurred while trying initialize authentication");
20606      }
20607  },
20608  async isAuthenticated(e = v.getActiveCaipAddress()) {
20609    if (!z.state.siwx || !e)
20610      return !0;
20611    const { chainNamespace: n, chainId: r, address: s } = wt.parseCaipAddress(e), i = `${n}:${r}`;
20612    return (await sn.getSessions({
20613      address: s,
20614      caipNetworkId: i
20615    })).length > 0;
20616  },
20617  async requestSignMessage() {
20618    const e = z.state.siwx, t = q.getPlainAddress(v.getActiveCaipAddress()), n = Rn();
20619    if (!e)
20620      throw new Error("SIWX is not enabled");
20621    if (!t)
20622      throw new Error("No ActiveCaipAddress found");
20623    if (!n)
20624      throw new Error("No ActiveCaipNetwork or client found");
20625    try {
20626      const r = await e.createMessage({
20627        chainId: n.caipNetworkId,
20628        accountAddress: t
20629      }), s = r.toString();
20630      let i = "";
20631      e.signMessage ? i = await e.signMessage({
20632        message: s,
20633        chainId: n.caipNetworkId,
20634        accountAddress: t
20635      }) : (H.getConnectorId(n.chainNamespace) === x.CONNECTOR_ID.AUTH && ie.pushTransactionStack({}), i = await J.signMessage(s) || ""), await e.addSession({
20636        data: r,
20637        message: s,
20638        signature: i
20639      }), v.setLastConnectedSIWECaipNetwork(n), Se.close(), ve.sendEvent({
20640        type: "track",
20641        event: "SIWX_AUTH_SUCCESS",
20642        properties: this.getSIWXEventProperties()
20643      });
20644    } catch (r) {
20645      (!Se.state.open || ie.state.view === "ApproveTransaction") && await Se.open({
20646        view: "SIWXSignMessage"
20647      }), Sn.showError("Error signing message"), ve.sendEvent({
20648        type: "track",
20649        event: "SIWX_AUTH_ERROR",
20650        properties: this.getSIWXEventProperties(r)
20651      }), console.error("SWIXUtil:requestSignMessage", r);
20652    }
20653  },
20654  async cancelSignMessage() {
20655    try {
20656      const e = this.getSIWX();
20657      if (e?.getRequired?.()) {
20658        const n = v.getLastConnectedSIWECaipNetwork();
20659        if (n) {
20660          const r = await e?.getSessions(n?.caipNetworkId, q.getPlainAddress(v.getActiveCaipAddress()) || "");
20661          r && r.length > 0 ? await v.switchActiveNetwork(n) : await J.disconnect();
20662        } else
20663          await J.disconnect();
20664      } else
20665        Se.close();
20666      Se.close(), ve.sendEvent({
20667        event: "CLICK_CANCEL_SIWX",
20668        type: "track",
20669        properties: this.getSIWXEventProperties()
20670      });
20671    } catch (e) {
20672      console.error("SIWXUtil:cancelSignMessage", e);
20673    }
20674  },
20675  async getAllSessions() {
20676    const e = this.getSIWX(), t = v.getAllRequestedCaipNetworks(), n = [];
20677    return await Promise.all(t.map(async (r) => {
20678      const s = await e?.getSessions(r.caipNetworkId, q.getPlainAddress(v.getActiveCaipAddress()) || "");
20679      s && n.push(...s);
20680    })), n;
20681  },
20682  async getSessions(e) {
20683    const t = z.state.siwx;
20684    let n = e?.address;
20685    if (!n) {
20686      const s = v.getActiveCaipAddress();
20687      n = q.getPlainAddress(s);
20688    }
20689    let r = e?.caipNetworkId;
20690    return r || (r = v.getActiveCaipNetwork()?.caipNetworkId), t && n && r ? t.getSessions(r, n) : [];
20691  },
20692  async isSIWXCloseDisabled() {
20693    const e = this.getSIWX();
20694    if (e) {
20695      const t = ie.state.view === "ApproveTransaction", n = ie.state.view === "SIWXSignMessage";
20696      if (t || n)
20697        return e.getRequired?.() && (await this.getSessions()).length === 0;
20698    }
20699    return !1;
20700  },
20701  async authConnectorAuthenticate({ authConnector: e, chainId: t, socialUri: n, preferredAccountType: r, chainNamespace: s }) {
20702    const i = sn.getSIWX(), o = Rn();
20703    if (!i || !s.includes(x.CHAIN.EVM) || // Request to input email and sign message when email capture is enabled
20704    z.state.remoteFeatures?.emailCapture) {
20705      const f = await e.connect({
20706        chainId: t,
20707        socialUri: n,
20708        preferredAccountType: r
20709      });
20710      return {
20711        address: f.address,
20712        chainId: f.chainId,
20713        accounts: f.accounts
20714      };
20715    }
20716    const a = `${s}:${t}`, u = await i.createMessage({
20717      chainId: a,
20718      accountAddress: "<<AccountAddress>>"
20719    }), c = {
20720      accountAddress: u.accountAddress,
20721      chainId: u.chainId,
20722      domain: u.domain,
20723      uri: u.uri,
20724      version: u.version,
20725      nonce: u.nonce,
20726      notBefore: u.notBefore,
20727      statement: u.statement,
20728      resources: u.resources,
20729      requestId: u.requestId,
20730      issuedAt: u.issuedAt,
20731      expirationTime: u.expirationTime,
20732      serializedMessage: u.toString()
20733    }, l = await e.connect({
20734      chainId: t,
20735      socialUri: n,
20736      siwxMessage: c,
20737      preferredAccountType: r
20738    });
20739    return c.accountAddress = l.address, c.serializedMessage = l.message || "", l.signature && l.message && await sn.addEmbeddedWalletSession(c, l.message, l.signature), v.setLastConnectedSIWECaipNetwork(o), {
20740      address: l.address,
20741      chainId: l.chainId,
20742      accounts: l.accounts
20743    };
20744  },
20745  async addEmbeddedWalletSession(e, t, n) {
20746    if (Gn)
20747      return Gn;
20748    const r = sn.getSIWX();
20749    return r ? (Gn = r.addSession({
20750      data: e,
20751      message: t,
20752      signature: n
20753    }).finally(() => {
20754      Gn = null;
20755    }), Gn) : Promise.resolve();
20756  },
20757  async universalProviderAuthenticate({ universalProvider: e, chains: t, methods: n }) {
20758    const r = sn.getSIWX(), s = Rn(), i = new Set(t.map((c) => c.split(":")[0]));
20759    if (!r || i.size !== 1 || !i.has("eip155"))
20760      return !1;
20761    const o = await r.createMessage({
20762      chainId: Rn()?.caipNetworkId || "",
20763      accountAddress: ""
20764    }), a = await e.authenticate({
20765      nonce: o.nonce,
20766      domain: o.domain,
20767      uri: o.uri,
20768      exp: o.expirationTime,
20769      iat: o.issuedAt,
20770      nbf: o.notBefore,
20771      requestId: o.requestId,
20772      version: o.version,
20773      resources: o.resources,
20774      statement: o.statement,
20775      chainId: o.chainId,
20776      methods: n,
20777      // The first chainId is what is used for universal provider to build the message
20778      chains: [o.chainId, ...t.filter((c) => c !== o.chainId)]
20779    });
20780    Sn.showLoading("Authenticating...", { autoClose: !1 });
20781    const u = {
20782      ...a.session.peer.metadata,
20783      name: a.session.peer.metadata.name,
20784      icon: a.session.peer.metadata.icons?.[0],
20785      type: "WALLET_CONNECT"
20786    };
20787    if (v.setAccountProp("connectedWalletInfo", u, Array.from(i)[0]), a?.auths?.length) {
20788      const c = a.auths.map((l) => {
20789        const f = e.client.formatAuthMessage({
20790          request: l.p,
20791          iss: l.p.iss
20792        });
20793        return {
20794          data: {
20795            ...l.p,
20796            accountAddress: l.p.iss.split(":").slice(-1).join(""),
20797            chainId: l.p.iss.split(":").slice(2, 4).join(":"),
20798            uri: l.p.aud ?? "",
20799            version: l.p.version || o.version,
20800            expirationTime: l.p.exp,
20801            issuedAt: l.p.iat,
20802            notBefore: l.p.nbf
20803          },
20804          message: f,
20805          signature: l.s.s,
20806          cacao: l
20807        };
20808      });
20809      try {
20810        await r.setSessions(c), s && v.setLastConnectedSIWECaipNetwork(s), ve.sendEvent({
20811          type: "track",
20812          event: "SIWX_AUTH_SUCCESS",
20813          properties: sn.getSIWXEventProperties()
20814        });
20815      } catch (l) {
20816        throw console.error("SIWX:universalProviderAuth - failed to set sessions", l), ve.sendEvent({
20817          type: "track",
20818          event: "SIWX_AUTH_ERROR",
20819          properties: sn.getSIWXEventProperties(l)
20820        }), await e.disconnect().catch(console.error), l;
20821      } finally {
20822        Sn.hide();
20823      }
20824    }
20825    return !0;
20826  },
20827  getSIWXEventProperties(e) {
20828    const t = v.state.activeChain;
20829    if (!t)
20830      throw new Error("SIWXUtil:getSIWXEventProperties - namespace is required");
20831    return {
20832      network: v.state.activeCaipNetwork?.caipNetworkId || "",
20833      isSmartAccount: Et(t) === Ye.ACCOUNT_TYPES.SMART_ACCOUNT,
20834      message: e ? q.parseError(e) : void 0
20835    };
20836  },
20837  async clearSessions() {
20838    const e = this.getSIWX();
20839    e && await e.setSessions([]);
20840  }
20841};
20842class Pf {
20843  constructor({ provider: t, namespace: n }) {
20844    this.id = x.CONNECTOR_ID.WALLET_CONNECT, this.name = "WalletConnect", this.type = "WALLET_CONNECT", this.imageId = "ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400", this.getCaipNetworks = v.getCaipNetworks.bind(v), this.caipNetworks = this.getCaipNetworks(), this.provider = t, this.chain = n;
20845  }
20846  get chains() {
20847    return this.getCaipNetworks();
20848  }
20849  async connectWalletConnect() {
20850    if (!await this.authenticate()) {
20851      const n = this.getCaipNetworks(), r = z.state.universalProviderConfigOverride, s = hn.createNamespaces(n, r);
20852      await this.provider.connect({ optionalNamespaces: s });
20853    }
20854    return {
20855      clientId: await this.provider.client.core.crypto.getClientId(),
20856      session: this.provider.session
20857    };
20858  }
20859  async disconnect() {
20860    await this.provider.disconnect();
20861  }
20862  async authenticate() {
20863    const t = this.chains.map((n) => n.caipNetworkId);
20864    return sn.universalProviderAuthenticate({
20865      universalProvider: this.provider,
20866      chains: t,
20867      methods: dE
20868    });
20869  }
20870}
20871const dE = [
20872  "eth_accounts",
20873  "eth_requestAccounts",
20874  "eth_sendRawTransaction",
20875  "eth_sign",
20876  "eth_signTransaction",
20877  "eth_signTypedData",
20878  "eth_signTypedData_v3",
20879  "eth_signTypedData_v4",
20880  "eth_sendTransaction",
20881  "personal_sign",
20882  "wallet_switchEthereumChain",
20883  "wallet_addEthereumChain",
20884  "wallet_getPermissions",
20885  "wallet_requestPermissions",
20886  "wallet_registerOnboarding",
20887  "wallet_watchAsset",
20888  "wallet_scanQRCode",
20889  // EIP-5792
20890  "wallet_getCallsStatus",
20891  "wallet_sendCalls",
20892  "wallet_getCapabilities",
20893  // EIP-7715
20894  "wallet_grantPermissions",
20895  "wallet_revokePermissions",
20896  //EIP-7811
20897  "wallet_getAssets"
20898], Nt = Me({
20899  message: "",
20900  variant: "info",
20901  open: !1
20902}), fE = {
20903  state: Nt,
20904  subscribeKey(e, t) {
20905    return Je(Nt, e, t);
20906  },
20907  open(e, t) {
20908    const { debug: n } = z.state, { code: r, displayMessage: s, debugMessage: i } = e;
20909    if (s && n && (Nt.message = s, Nt.variant = t, Nt.open = !0), i) {
20910      if (!x.IS_DEVELOPMENT)
20911        return;
20912      const o = typeof i == "function" ? i() : i, a = r ? { code: r } : void 0;
20913      t === "error" ? console.error(o, a) : t === "warning" ? console.warn(o, a) : console.info(o, a);
20914    }
20915  },
20916  warn(e, t, n) {
20917    Nt.open = !0, Nt.message = e, Nt.variant = "warning", t && console.warn(t, n);
20918  },
20919  close() {
20920    Nt.open = !1, Nt.message = "", Nt.variant = "info";
20921  }
20922}, Ar = Mt(fE), hE = {
20923  /* Connector names */
20924  METMASK_CONNECTOR_NAME: "MetaMask",
20925  TRUST_CONNECTOR_NAME: "Trust Wallet",
20926  SOLFLARE_CONNECTOR_NAME: "Solflare",
20927  PHANTOM_CONNECTOR_NAME: "Phantom",
20928  COIN98_CONNECTOR_NAME: "Coin98",
20929  MAGIC_EDEN_CONNECTOR_NAME: "Magic Eden",
20930  BACKPACK_CONNECTOR_NAME: "Backpack",
20931  BITGET_CONNECTOR_NAME: "Bitget Wallet",
20932  FRONTIER_CONNECTOR_NAME: "Frontier",
20933  XVERSE_CONNECTOR_NAME: "Xverse Wallet",
20934  LEATHER_CONNECTOR_NAME: "Leather",
20935  OKX_CONNECTOR_NAME: "OKX Wallet",
20936  BINANCE_CONNECTOR_NAME: "Binance Wallet",
20937  EIP155: x.CHAIN.EVM,
20938  ADD_CHAIN_METHOD: "wallet_addEthereumChain",
20939  EIP6963_ANNOUNCE_EVENT: "eip6963:announceProvider",
20940  EIP6963_REQUEST_EVENT: "eip6963:requestProvider",
20941  CONNECTOR_RDNS_MAP: {
20942    coinbaseWallet: "com.coinbase.wallet",
20943    coinbaseWalletSDK: "com.coinbase.wallet"
20944  },
20945  CONNECTOR_TYPE_EXTERNAL: "EXTERNAL",
20946  CONNECTOR_TYPE_WALLET_CONNECT: "WALLET_CONNECT",
20947  CONNECTOR_TYPE_INJECTED: "INJECTED",
20948  CONNECTOR_TYPE_ANNOUNCED: "ANNOUNCED",
20949  CONNECTOR_TYPE_AUTH: "AUTH",
20950  CONNECTOR_TYPE_MULTI_CHAIN: "MULTI_CHAIN",
20951  CONNECTOR_TYPE_W3M_AUTH: "AUTH",
20952  getSDKVersionWarningMessage(e, t) {
20953    return `
20954     @@@@@@@           @@@@@@@@@@@@@@@@@@      
20955   @@@@@@@@@@@      @@@@@@@@@@@@@@@@@@@@@@@@   
20956  @@@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@  
20957 @@@@@@@@@@@@@@@  @@@@@@@@@@@@@@@@@@@@@@@@@@@  
20958 @@@@@@@@@@@@@@@  @@@@@@@@@@@@@@   @@@@@@@@@@@ 
20959 @@@@@@@@@@@@@@@  @@@@@@@@@@@@@   @@@@@@@@@@@@ 
20960 @@@@@@@@@@@@@@@  @@@@@@@@@@@@@  @@@@@@@@@@@@@
20961 @@@@@@@@@@@@@@@  @@@@@@@@@@@@   @@@@@@@@@@@@@    
20962 @@@@@@   @@@@@@  @@@@@@@@@@@   @@@@@@@@@@@@@@    
20963 @@@@@@   @@@@@@  @@@@@@@@@@@  @@@@@@@@@@@@@@@ 
20964 @@@@@@@@@@@@@@@  @@@@@@@@@@   @@@@@@@@@@@@@@@ 
20965 @@@@@@@@@@@@@@@  @@@@@@@@@@@@@@@@@@@@@@@@@@@  
20966  @@@@@@@@@@@@@    @@@@@@@@@@@@@@@@@@@@@@@@@@  
20967   @@@@@@@@@@@      @@@@@@@@@@@@@@@@@@@@@@@@   
20968      @@@@@            @@@@@@@@@@@@@@@@@@  
20969      
20970AppKit SDK version ${e} is outdated. Latest version is ${t}. Please update to the latest version for bug fixes and new features.
20971            
20972Changelog: https://github.com/reown-com/appkit/releases
20973NPM Registry: https://www.npmjs.com/package/@reown/appkit`;
20974  }
20975}, pE = {
20976  NetworkImageIds: {
20977    // Ethereum
20978    1: "ba0ba0cd-17c6-4806-ad93-f9d174f17900",
20979    // Arbitrum
20980    42161: "3bff954d-5cb0-47a0-9a23-d20192e74600",
20981    // Avalanche
20982    43114: "30c46e53-e989-45fb-4549-be3bd4eb3b00",
20983    // Binance Smart Chain
20984    56: "93564157-2e8e-4ce7-81df-b264dbee9b00",
20985    // Fantom
20986    250: "06b26297-fe0c-4733-5d6b-ffa5498aac00",
20987    // Optimism
20988    10: "ab9c186a-c52f-464b-2906-ca59d760a400",
20989    // Polygon
20990    137: "41d04d42-da3b-4453-8506-668cc0727900",
20991    // Mantle
20992    5e3: "e86fae9b-b770-4eea-e520-150e12c81100",
20993    // Hedera Mainnet
20994    295: "6a97d510-cac8-4e58-c7ce-e8681b044c00",
20995    // Sepolia
20996    11155111: "e909ea0a-f92a-4512-c8fc-748044ea6800",
20997    // Base Sepolia
20998    84532: "a18a7ecd-e307-4360-4746-283182228e00",
20999    // Unichain Sepolia
21000    1301: "4eeea7ef-0014-4649-5d1d-07271a80f600",
21001    // Unichain Mainnet
21002    130: "2257980a-3463-48c6-cbac-a42d2a956e00",
21003    // Monad
21004    10143: "0a728e83-bacb-46db-7844-948f05434900",
21005    143: "0a728e83-bacb-46db-7844-948f05434900",
21006    // Gnosis
21007    100: "02b53f6a-e3d4-479e-1cb4-21178987d100",
21008    // EVMos
21009    9001: "f926ff41-260d-4028-635e-91913fc28e00",
21010    // ZkSync
21011    324: "b310f07f-4ef7-49f3-7073-2a0a39685800",
21012    // Filecoin
21013    314: "5a73b3dd-af74-424e-cae0-0de859ee9400",
21014    // Iotx
21015    4689: "34e68754-e536-40da-c153-6ef2e7188a00",
21016    // Metis,
21017    1088: "3897a66d-40b9-4833-162f-a2c90531c900",
21018    // Moonbeam
21019    1284: "161038da-44ae-4ec7-1208-0ea569454b00",
21020    // Moonriver
21021    1285: "f1d73bb6-5450-4e18-38f7-fb6484264a00",
21022    // Zora
21023    7777777: "845c60df-d429-4991-e687-91ae45791600",
21024    // Celo
21025    42220: "ab781bbc-ccc6-418d-d32d-789b15da1f00",
21026    // Base
21027    8453: "7289c336-3981-4081-c5f4-efc26ac64a00",
21028    // Aurora
21029    1313161554: "3ff73439-a619-4894-9262-4470c773a100",
21030    // Ronin Mainnet
21031    2020: "b8101fc0-9c19-4b6f-ec65-f6dfff106e00",
21032    // Saigon Testnet (a.k.a. Ronin)
21033    2021: "b8101fc0-9c19-4b6f-ec65-f6dfff106e00",
21034    // Berachain Mainnet
21035    80094: "e329c2c9-59b0-4a02-83e4-212ff3779900",
21036    // Abstract Mainnet
21037    2741: "fc2427d1-5af9-4a9c-8da5-6f94627cd900",
21038    // Solana networks
21039    "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp": "a1b58899-f671-4276-6a5e-56ca5bd59700",
21040    "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z": "a1b58899-f671-4276-6a5e-56ca5bd59700",
21041    EtWTRABZaYq6iMfeYKouRu166VU2xqa1: "a1b58899-f671-4276-6a5e-56ca5bd59700",
21042    // Bitcoin
21043    "000000000019d6689c085ae165831e93": "0b4838db-0161-4ffe-022d-532bf03dba00",
21044    // Bitcoin Testnet
21045    "000000000933ea01ad0ee984209779ba": "39354064-d79b-420b-065d-f980c4b78200",
21046    // Bitcoin Signet
21047    "00000008819873e925422c1ff0f99f7c": "b3406e4a-bbfc-44fb-e3a6-89673c78b700",
21048    // TON
21049    "-239": "20f673c0-095e-49b2-07cf-eb5049dcf600",
21050    // TON Testnet
21051    "-3": "20f673c0-095e-49b2-07cf-eb5049dcf600",
21052    // TRON
21053    "0x2b6653dc": "3502bb86-cc4e-420f-a387-59ea63a28b00",
21054    // TRON Shasta Testnet
21055    "0x94a9059e": "3502bb86-cc4e-420f-a387-59ea63a28b00",
21056    // TRON Nile Testnet
21057    "0xcd8690dc": "3502bb86-cc4e-420f-a387-59ea63a28b00"
21058  }
21059}, Jn = {
21060  getCaipTokens(e) {
21061    if (!e)
21062      return;
21063    const t = {};
21064    return Object.entries(e).forEach(([n, r]) => {
21065      t[`${hE.EIP155}:${n}`] = r;
21066    }), t;
21067  },
21068  isLowerCaseMatch(e, t) {
21069    return e?.toLowerCase() === t?.toLowerCase();
21070  },
21071  /**
21072   * Iterates the Auth connector supported chains and returns the namespace that is last connected to the active chain.
21073   * @returns ChainNamespace | undefined
21074   */
21075  getActiveNamespaceConnectedToAuth() {
21076    const e = v.state.activeChain;
21077    return x.AUTH_CONNECTOR_SUPPORTED_CHAINS.find((t) => H.getConnectorId(t) === x.CONNECTOR_ID.AUTH && t === e);
21078  },
21079  /**
21080   * Runs a condition function again and again until it returns true or the max number of tries is reached.
21081   *
21082   * @param conditionFn - A function (can be async) that returns true when the condition is met.
21083   * @param intervalMs - Time to wait between tries, in milliseconds.
21084   * @param maxRetries - Maximum number of times to try before stopping.
21085   * @returns A Promise that resolves to true if the condition becomes true in t
21085ime, or false if it doesn't.
21086   */
21087  withRetry({ conditionFn: e, intervalMs: t, maxRetries: n }) {
21088    let r = 0;
21089    return new Promise((s) => {
21090      async function i() {
21091        return r += 1, await e() ? s(!0) : r >= n ? s(!1) : (setTimeout(i, t), null);
21092      }
21093      i();
21094    });
21095  },
21096  /**
21097   * Returns the chain namespace from user's chainId which is returned from Auth provider.
21098   * @param chainId - The chainId to parse.
21099   * @returns The chain namespace.
21100   */
21101  userChainIdToChainNamespace(e) {
21102    if (typeof e == "number")
21103      return x.CHAIN.EVM;
21104    const [t] = e.split(":");
21105    return t;
21106  },
21107  /**
21108   * Get all auth namespaces except the active one
21109   * @param activeNamespace - The active namespace
21110   * @returns All auth namespaces except the active one
21111   */
21112  getOtherAuthNamespaces(e) {
21113    return e ? x.AUTH_CONNECTOR_SUPPORTED_CHAINS.filter((r) => r !== e) : [];
21114  },
21115  /**
21116   * Gets the storage info for a connector
21117   * @param connectorId - The ID of the connector
21118   * @param namespace - The namespace of the connector
21119   * @returns
21120   */
21121  getConnectorStorageInfo(e, t) {
21122    const r = W.getConnections()[t] ?? [];
21123    return {
21124      hasDisconnected: W.isConnectorDisconnected(e, t),
21125      hasConnected: r.some((s) => Jn.isLowerCaseMatch(s.connectorId, e))
21126    };
21127  }
21128}, mE = new AbortController(), vn = {
21129  EmbeddedWalletAbortController: mE,
21130  /**
21131   * Universal Provider errors. Make sure the `message` is matching with the errors thrown by the Universal Provider.
21132   * We use the `alertErrorKey` to map the error to the correct AppKit alert error.
21133   */
21134  UniversalProviderErrors: {
21135    UNAUTHORIZED_DOMAIN_NOT_ALLOWED: {
21136      message: "Unauthorized: origin not allowed",
21137      alertErrorKey: "ORIGIN_NOT_ALLOWED"
21138    },
21139    JWT_VALIDATION_ERROR: {
21140      message: "JWT validation error: JWT Token is not yet valid",
21141      alertErrorKey: "JWT_TOKEN_NOT_VALID"
21142    },
21143    INVALID_KEY: {
21144      message: "Unauthorized: invalid key",
21145      alertErrorKey: "INVALID_PROJECT_ID"
21146    }
21147  },
21148  ALERT_ERRORS: {
21149    SWITCH_NETWORK_NOT_FOUND: {
21150      code: "APKT001",
21151      displayMessage: "Network Not Found",
21152      debugMessage: "The specified network is not recognized. Please ensure it is included in the `networks` array of your `createAppKit` configuration."
21153    },
21154    ORIGIN_NOT_ALLOWED: {
21155      code: "APKT002",
21156      displayMessage: "Invalid App Configuration",
21157      debugMessage: () => `The origin ${Jr() ? window.origin : "unknown"} is not in your allow list. Please update your allowed domains at https://dashboard.reown.com. [PID: ${z.state.projectId}]`
21158    },
21159    IFRAME_LOAD_FAILED: {
21160      code: "APKT003",
21161      displayMessage: "Network Error: Wallet Load Failed",
21162      debugMessage: () => "Failed to load the embedded wallet. This may be due to network issues or server downtime. Please check your network connection and try again shortly. Contact support if the issue persists."
21163    },
21164    IFRAME_REQUEST_TIMEOUT: {
21165      code: "APKT004",
21166      displayMessage: "Wallet Request Timeout",
21167      debugMessage: () => "The request to the embedded wallet timed out. Please check your network connection and try again shortly. Contact support if the issue persists."
21168    },
21169    UNVERIFIED_DOMAIN: {
21170      code: "APKT005",
21171      displayMessage: "Unverified Domain",
21172      debugMessage: () => "Embedded wallet load failed. Ensure your domain is verified in https://dashboard.reown.com."
21173    },
21174    JWT_TOKEN_NOT_VALID: {
21175      code: "APKT006",
21176      displayMessage: "Session Expired",
21177      debugMessage: "Your session is invalid or expired. Please check your system’s date and time settings, then reconnect."
21178    },
21179    INVALID_PROJECT_ID: {
21180      code: "APKT007",
21181      displayMessage: "Invalid Project ID",
21182      debugMessage: "The specified project ID is invalid. Please visit https://dashboard.reown.com to obtain a valid project ID."
21183    },
21184    PROJECT_ID_NOT_CONFIGURED: {
21185      code: "APKT008",
21186      displayMessage: "Project ID Missing",
21187      debugMessage: "No project ID is configured. You can create and configure a project ID at https://dashboard.reown.com."
21188    },
21189    SERVER_ERROR_APP_CONFIGURATION: {
21190      code: "APKT009",
21191      displayMessage: "Server Error",
21192      debugMessage: (e) => `Unable to fetch App Configuration. ${e}. Please check your network connection and try again shortly. Contact support if the issue persists.`
21193    },
21194    RATE_LIMITED_APP_CONFIGURATION: {
21195      code: "APKT010",
21196      displayMessage: "Rate Limited",
21197      debugMessage: "You have been rate limited while retrieving App Configuration. Please wait a few minutes and try again. Contact support if the issue persists."
21198    }
21199  },
21200  ALERT_WARNINGS: {
21201    LOCAL_CONFIGURATION_IGNORED: {
21202      debugMessage: (e) => `[Reown Config Notice] ${e}`
21203    },
21204    INACTIVE_NAMESPACE_NOT_CONNECTED: {
21205      code: "APKTW001",
21206      displayMessage: "Inactive Namespace Not Connected",
21207      debugMessage: (e, t) => `An error occurred while connecting an inactive namespace ${e}: "${t}"`
21208    },
21209    INVALID_EMAIL: {
21210      code: "APKTW002",
21211      displayMessage: "Invalid Email Address",
21212      debugMessage: "Please enter a valid email address"
21213    }
21214  }
21215}, gE = "rpc.walletconnect.org";
21216function Yu(e, t) {
21217  const n = new URL("https://rpc.walletconnect.org/v1/");
21218  return n.searchParams.set("chainId", e), n.searchParams.set("projectId", t), n.toString();
21219}
21220const ta = [
21221  "near:mainnet",
21222  "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
21223  "eip155:1101",
21224  "eip155:56",
21225  "eip155:42161",
21226  "eip155:7777777",
21227  "eip155:59144",
21228  "eip155:324",
21229  "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
21230  "eip155:5000",
21231  "solana:4sgjmw1sunhzsxgspuhpqldx6wiyjntz",
21232  "eip155:80084",
21233  "eip155:5003",
21234  "eip155:100",
21235  "eip155:8453",
21236  "eip155:42220",
21237  "eip155:1313161555",
21238  "eip155:17000",
21239  "eip155:1",
21240  "eip155:300",
21241  "eip155:1313161554",
21242  "eip155:1329",
21243  "eip155:84532",
21244  "eip155:421614",
21245  "eip155:11155111",
21246  "eip155:8217",
21247  "eip155:43114",
21248  "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",
21249  "eip155:999999999",
21250  "eip155:11155420",
21251  "eip155:80002",
21252  "eip155:97",
21253  "eip155:43113",
21254  "eip155:137",
21255  "eip155:10",
21256  "eip155:1301",
21257  "eip155:80094",
21258  "eip155:80069",
21259  "eip155:560048",
21260  "eip155:31",
21261  "eip155:2818",
21262  "eip155:57054",
21263  "eip155:911867",
21264  "eip155:534351",
21265  "eip155:1112",
21266  "eip155:534352",
21267  "eip155:1111",
21268  "eip155:146",
21269  "eip155:130",
21270  "eip155:1284",
21271  "eip155:30",
21272  "eip155:2810",
21273  "eip155:55931",
21274  "bip122:000000000019d6689c085ae165831e93",
21275  "bip122:000000000933ea01ad0ee984209779ba",
21276  "tron:0x2b6653dc",
21277  "tron:0xcd8690dc"
21278], xn = {
21279  /**
21280   * Extends the RPC URL with the project ID if the RPC URL is a Reown URL
21281   * @param rpcUrl - The RPC URL to extend
21282   * @param projectId - The project ID to extend the RPC URL with
21283   * @returns The extended RPC URL
21284   */
21285  extendRpcUrlWithProjectId(e, t) {
21286    let n = !1;
21287    try {
21288      n = new URL(e).host === gE;
21289    } catch {
21290      n = !1;
21291    }
21292    if (n) {
21293      const r = new URL(e);
21294      return r.searchParams.has("projectId") || r.searchParams.set("projectId", t), r.toString();
21295    }
21296    return e;
21297  },
21298  isCaipNetwork(e) {
21299    return "chainNamespace" in e && "caipNetworkId" in e;
21300  },
21301  getChainNamespace(e) {
21302    return this.isCaipNetwork(e) ? e.chainNamespace : x.CHAIN.EVM;
21303  },
21304  getCaipNetworkId(e) {
21305    return this.isCaipNetwork(e) ? e.caipNetworkId : `${x.CHAIN.EVM}:${e.id}`;
21306  },
21307  // eslint-disable-next-line max-params
21308  getDefaultRpcUrl(e, t, n) {
21309    const r = e.rpcUrls?.default?.http?.[0];
21310    return ta.includes(t) ? Yu(t, n) : r || "";
21311  },
21312  /**
21313   * Extends the CaipNetwork object with the image ID and image URL if the image ID is not provided
21314   * @param params - The parameters object
21315   * @param params.caipNetwork - The CaipNetwork object to extend
21316   * @param params.networkImageIds - The network image IDs
21317   * @param params.customNetworkImageUrls - The custom network image URLs
21318   * @param params.projectId - The project ID
21319   * @param params.customRpc - Boolean to indicate if the custom RPC URL should be used
21320   * @param params.customRpcUrls - The map of chain and custom RPC URLs to be used by the AppKit
21321   * @returns The extended array of CaipNetwork objects
21322   */
21323  extendCaipNetwork(e, { customNetworkImageUrls: t, projectId: n, customRpcUrls: r }) {
21324    const s = this.getChainNamespace(e), i = this.getCaipNetworkId(e), o = e.rpcUrls?.default?.http?.[0], a = this.getDefaultRpcUrl(e, i, n), u = e?.rpcUrls?.chainDefault?.http?.[0] || o, c = r?.[i]?.map((p) => p.url) || [], l = [...c, ...a ? [a] : []], f = [...c];
21325    return u && !f.includes(u) && f.push(u), {
21326      ...e,
21327      chainNamespace: s,
21328      caipNetworkId: i,
21329      assets: {
21330        imageId: pE.NetworkImageIds[e.id],
21331        imageUrl: t?.[e.id]
21332      },
21333      rpcUrls: {
21334        ...e.rpcUrls,
21335        default: {
21336          http: l
21337        },
21338        // Save the networks original RPC URL default
21339        chainDefault: {
21340          http: f
21341        }
21342      }
21343    };
21344  },
21345  /**
21346   * Extends the array of CaipNetwork objects with the image ID and image URL if the image ID is not provided
21347   * @param caipNetworks - The array of CaipNetwork objects to extend
21348   * @param params - The parameters object
21349   * @param params.networkImageIds - The network image IDs
21350   * @param params.customNetworkImageUrls - The custom network image URLs
21351   * @param params.customRpcUrls - The map of chain and custom RPC URLs to be used by the AppKit
21352   * @param params.projectId - The project ID
21353   * @returns The extended array of CaipNetwork objects
21354   */
21355  extendCaipNetworks(e, { customNetworkImageUrls: t, projectId: n, customRpcUrls: r }) {
21356    return e.map((s) => xn.extendCaipNetwork(s, {
21357      customNetworkImageUrls: t,
21358      customRpcUrls: r,
21359      projectId: n
21360    }));
21361  },
21362  getViemTransport(e, t, n) {
21363    const r = [];
21364    return n?.forEach((s) => {
21365      r.push(li(s.url, s.config));
21366    }), ta.includes(e.caipNetworkId) && r.push(li(Yu(e.caipNetworkId, t), {
21367      /*
21368       * The Blockchain API uses "Content-Type: text/plain" to avoid OPTIONS preflight requests
21369       * It will only work for viem >= 2.17.7
21370       */
21371      fetchOptions: {
21372        headers: {
21373          "Content-Type": "text/plain"
21374        }
21375      }
21376    })), e?.rpcUrls?.default?.http?.forEach((s) => {
21377      r.push(li(s));
21378    }), yu(r);
21379  },
21380  extendWagmiTransports(e, t, n) {
21381    if (ta.includes(e.caipNetworkId)) {
21382      const r = this.getDefaultRpcUrl(e, e.caipNetworkId, t);
21383      return yu([n, li(r)]);
21384    }
21385    return n;
21386  },
21387  /**
21388   * Generates the unsupported network object with the given CaipNetwork ID
21389   * @param caipNetworkId - The CAIP network ID
21390   * @returns The unsupported CAIP network object
21391   */
21392  getUnsupportedNetwork(e) {
21393    return {
21394      id: e.split(":")[1],
21395      caipNetworkId: e,
21396      name: x.UNSUPPORTED_NETWORK_NAME,
21397      chainNamespace: e.split(":")[0],
21398      nativeCurrency: {
21399        name: "",
21400        decimals: 0,
21401        symbol: ""
21402      },
21403      rpcUrls: {
21404        default: {
21405          http: []
21406        }
21407      }
21408    };
21409  },
21410  /**
21411   * Gets the CaipNetwork object from the storage if `@appkit/active_caip_network_id` is being set
21412   * @returns CaipNetwork or undefined
21413   */
21414  getCaipNetworkFromStorage(e) {
21415    const t = W.getActiveCaipNetworkId(), n = v.getAllRequestedCaipNetworks(), r = Array.from(v.state.chains?.keys() || []), s = t?.split(":")[0], i = s ? r.includes(s) : !1, o = n?.find((u) => u.caipNetworkId === t);
21416    return i && !o && t ? this.getUnsupportedNetwork(t) : o || e || n?.[0];
21417  }
21418};
21419class kf {
21420  constructor() {
21421    this.listeners = {
21422      accountsChanged: [],
21423      chainChanged: [],
21424      connect: [],
21425      disconnect: [],
21426      display_uri: [],
21427      message: []
21428    };
21429  }
21430  on(t, n) {
21431    this.listeners[t].push(n);
21432  }
21433  removeListener(t, n) {
21434    t in this.listeners && (this.listeners[t] = this.listeners[t].filter((r) => r !== n));
21435  }
21436  emit(t, n) {
21437    t in this.listeners && this.listeners[t].forEach((r) => r(n));
21438  }
21439}
21440class yE {
21441  constructor({ adapter: t, chains: n }) {
21442    this.chain = "tron", this.type = "INJECTED", this.eventEmitter = new kf(), this.emit = this.eventEmitter.emit.bind(this.eventEmitter), this.on = this.eventEmitter.on.bind(this.eventEmitter), this.removeListener = this.eventEmitter.removeListener.bind(this.eventEmitter), this.adapter = t, this.requestedChains = n, this.setupAdapterListeners();
21443  }
21444  get id() {
21445    return this.adapter.name;
21446  }
21447  get name() {
21448    return this.adapter.name;
21449  }
21450  get imageUrl() {
21451    return this.adapter.icon;
21452  }
21453  get chains() {
21454    return this.requestedChains;
21455  }
21456  get provider() {
21457    return this;
21458  }
21459  request(t) {
21460    const { method: n, params: r } = t;
21461    switch (n) {
21462      case "tron_requestAccounts":
21463        return this.connect().then((s) => [s]);
21464      case "tron_signMessageV2": {
21465        const { message: s } = r;
21466        return this.adapter.signMessage(s);
21467      }
21468      case "tron_sendTransaction": {
21469        const { transaction: s } = r;
21470        return this.adapter.signTransaction(s);
21471      }
21472      default:
21473        throw new Error(`Unsupported method: ${n}`);
21474    }
21475  }
21476  async connect() {
21477    await this.adapter.connect();
21478    const t = this.adapter.address;
21479    if (!t)
21480      throw new Error("No address available after connect");
21481    return this.emit("accountsChanged", [t]), t;
21482  }
21483  async disconnect() {
21484    try {
21485      await this.adapter.disconnect();
21486    } catch {
21487    }
21488  }
21489  async signMessage(t) {
21490    return await this.adapter.signMessage(t.message) || "";
21491  }
21492  async sendTransaction(t) {
21493    const n = this.getRpcUrl(), i = (await (await fetch(n, {
21494      method: "POST",
21495      headers: { "Content-Type": "text/plain" },
21496      body: JSON.stringify({
21497        jsonrpc: "2.0",
21498        id: 1,
21499        method: "tron_createTransaction",
21500        params: [t.from, t.to, parseInt(t.value, 10), !0]
21501      })
21502    })).json())?.result;
21503    if (!i?.txID)
21504      throw new Error(i?.Error || "Failed to create transaction");
21505    const o = await this.adapter.signTransaction(i), u = await (await fetch(n, {
21506      method: "POST",
21507      headers: { "Content-Type": "text/plain" },
21508      body: JSON.stringify({
21509        jsonrpc: "2.0",
21510        id: 1,
21511        method: "tron_broadcastTransaction",
21512        params: [
21513          o.txID || i.txID,
21514          o.visible ?? i.visible ?? !0,
21515          o.raw_data || i.raw_data,
21516          o.raw_data_hex || i.raw_data_hex,
21517          o.signature
21518        ]
21519      })
21520    })).json();
21521    if (!u?.result?.result)
21522      throw new Error(u?.result?.message || "Failed to broadcast transaction");
21523    return i.txID;
21524  }
21525  async switchNetwork() {
21526    return Promise.resolve();
21527  }
21528  getRpcUrl() {
21529    const t = v.getCaipNetworkByNamespace("tron"), n = z.state.projectId;
21530    if (t)
21531      return xn.getDefaultRpcUrl(t, t.caipNetworkId, n);
21532    const r = this.requestedChains[0];
21533    return r ? xn.getDefaultRpcUrl(r, r.caipNetworkId, n) : "";
21534  }
21535  setupAdapterListeners() {
21536    this.adapter.on("connect", (t) => {
21537      typeof t == "string" && t && this.emit("accountsChanged", [t]);
21538    }), this.adapter.on("disconnect", () => {
21539      this.emit("disconnect", void 0);
21540    }), this.adapter.on("accountsChanged", (t) => {
21541      typeof t == "string" && t && this.emit("accountsChanged", [t]);
21542    }), this.adapter.on("chainChanged", (t) => {
21543      typeof t == "object" && t !== null && "chainId" in t ? this.emit("chainChanged", t.chainId) : typeof t == "string" && this.emit("chainChanged", t);
21544    });
21545  }
21546}
21547class Zu extends Pf {
21548  constructor({ provider: t, chains: n }) {
21549    super({ provider: t, caipNetworks: n, namespace: x.CHAIN.TRON }), this.chain = x.CHAIN.TRON, this.eventEmitter = new kf(), this.emit = this.eventEmitter.emit.bind(this.eventEmitter), this.on = this.eventEmitter.on.bind(this.eventEmitter), this.removeListener = this.eventEmitter.removeListener.bind(this.eventEmitter);
21550  }
21551  get imageUrl() {
21552  }
21553  get info() {
21554  }
21555  get chainsList() {
21556    return this.chains;
21557  }
21558  get chains() {
21559    return this.sessionChains.map((t) => this.caipNetworks.find((n) => n.caipNetworkId === t)).filter(Boolean);
21560  }
21561  async connect() {
21562    return Promise.reject(new Error("Connection of WalletConnectProvider should be done via UniversalAdapter"));
21563  }
21564  async signMessage(t) {
21565    const n = v.getCaipNetworkByNamespace(x.CHAIN.TRON);
21566    if (!n)
21567      throw new Error("Chain not found");
21568    const r = {
21569      method: "tron_signMessage",
21570      params: {
21571        address: t.from,
21572        message: t.message
21573      }
21574    }, s = await this.provider.request(r, n.caipNetworkId);
21575    return typeof s == "string" ? s : s?.signature || "";
21576  }
21577  async sendTransaction(t) {
21578    const n = v.getCaipNetworkByNamespace(x.CHAIN.TRON);
21579    if (!n)
21580      throw new Error("Chain not found");
21581    const r = this.getRpcUrl(n), o = (await (await fetch(r, {
21582      method: "POST",
21583      headers: { "Content-Type": "text/plain" },
21584      body: JSON.stringify({
21585        jsonrpc: "2.0",
21586        id: 1,
21587        method: "tron_createTransaction",
21588        params: [t.from, t.to, parseInt(t.value, 10), !0]
21589      })
21590    })).json())?.result;
21591    if (!o?.txID)
21592      throw new Error(o?.Error || "Failed to create transaction");
21593    const a = {
21594      method: "tron_signTransaction",
21595      params: {
21596        address: t.from,
21597        transaction: o
21598      }
21599    }, u = await this.provider.request(a, n.caipNetworkId);
21600    if (!u?.signature?.length)
21601      throw new Error("Transaction signing failed");
21602    const l = await (await fetch(r, {
21603      method: "POST",
21604      headers: { "Content-Type": "text/plain" },
21605      body: JSON.stringify({
21606        jsonrpc: "2.0",
21607        id: 1,
21608        method: "tron_broadcastTransaction",
21609        params: [
21610          u.txID || o.txID,
21611          u.visible ?? o.visible ?? !0,
21612          u.raw_data || o.raw_data,
21613          u.raw_data_hex || o.raw_data_hex,
21614          u.signature
21615        ]
21616      })
21617    })).json();
21618    if (!l?.result?.result)
21619      throw new Error(l?.result?.message || "Failed to broadcast transaction");
21620    return u.txID || o.txID;
21621  }
21622  async switchNetwork() {
21623    return Promise.resolve();
21624  }
21625  request(t) {
21626    return this.internalRequest(t);
21627  }
21628  setDefaultChain(t) {
21629    this.provider?.setDefaultChain(t);
21630  }
21631  getRpcUrl(t) {
21632    const n = z.state.projectId;
21633    return xn.getDefaultRpcUrl(t, t.caipNetworkId, n);
21634  }
21635  get sessionChains() {
21636    return hn.getChainsFromNamespaces(this.provider.session?.namespaces);
21637  }
21638}
21639var na = { exports: {} }, Qu;
21640function bE() {
21641  return Qu || (Qu = 1, (function(e) {
21642    var t = Object.prototype.hasOwnProperty, n = "~";
21643    function r() {
21644    }
21645    Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (n = !1));
21646    function s(u, c, l) {
21647      this.fn = u, this.context = c, this.once = l || !1;
21648    }
21649    function i(u, c, l, f, p) {
21650      if (typeof l != "function")
21651        throw new TypeError("The listener must be a function");
21652      var m = new s(l, f || u, p), y = n ? n + c : c;
21653      return u._events[y] ? u._events[y].fn ? u._events[y] = [u._events[y], m] : u._events[y].push(m) : (u._events[y] = m, u._eventsCount++), u;
21654    }
21655    function o(u, c) {
21656      --u._eventsCount === 0 ? u._events = new r() : delete u._events[c];
21657    }
21658    function a() {
21659      this._events = new r(), this._eventsCount = 0;
21660    }
21661    a.prototype.eventNames = function() {
21662      var c = [], l, f;
21663      if (this._eventsCount === 0) return c;
21664      for (f in l = this._events)
21665        t.call(l, f) && c.push(n ? f.slice(1) : f);
21666      return Object.getOwnPropertySymbols ? c.concat(Object.getOwnPropertySymbols(l)) : c;
21667    }, a.prototype.listeners = function(c) {
21668      var l = n ? n + c : c, f = this._events[l];
21669      if (!f) return [];
21670      if (f.fn) return [f.fn];
21671      for (var p = 0, m = f.length, y = new Array(m); p < m; p++)
21672        y[p] = f[p].fn;
21673      return y;
21674    }, a.prototype.listenerCount = function(c) {
21675      var l = n ? n + c : c, f = this._events[l];
21676      return f ? f.fn ? 1 : f.length : 0;
21677    }, a.prototype.emit = function(c, l, f, p, m, y) {
21678      var b = n ? n + c : c;
21679      if (!this._events[b]) return !1;
21680      var C = this._events[b], _ = arguments.length, R, N;
21681      if (C.fn) {
21682        switch (C.once && this.removeListener(c, C.fn, void 0, !0), _) {
21683          case 1:
21684            return C.fn.call(C.context), !0;
21685          case 2:
21686            return C.fn.call(C.context, l), !0;
21687          case 3:
21688            return C.fn.call(C.context, l, f), !0;
21689          case 4:
21690            return C.fn.call(C.context, l, f, p), !0;
21691          case 5:
21692            return C.fn.call(C.context, l, f, p, m), !0;
21693          case 6:
21694            return C.fn.call(C.context, l, f, p, m, y), !0;
21695        }
21696        for (N = 1, R = new Array(_ - 1); N < _; N++)
21697          R[N - 1] = arguments[N];
21698        C.fn.apply(C.context, R);
21699      } else {
21700        var I = C.length, E;
21701        for (N = 0; N < I; N++)
21702          switch (C[N].once && this.removeListener(c, C[N].fn, void 0, !0), _) {
21703            case 1:
21704              C[N].fn.call(C[N].context);
21705              break;
21706            case 2:
21707              C[N].fn.call(C[N].context, l);
21708              break;
21709            case 3:
21710              C[N].fn.call(C[N].context, l, f);
21711              break;
21712            case 4:
21713              C[N].fn.call(C[N].context, l, f, p);
21714              break;
21715            default:
21716              if (!R) for (E = 1, R = new Array(_ - 1); E < _; E++)
21717                R[E - 1] = arguments[E];
21718              C[N].fn.apply(C[N].context, R);
21719          }
21720      }
21721      return !0;
21722    }, a.prototype.on = function(c, l, f) {
21723      return i(this, c, l, f, !1);
21724    }, a.prototype.once = function(c, l, f) {
21725      return i(this, c, l, f, !0);
21726    }, a.prototype.removeListener = function(c, l, f, p) {
21727      var m = n ? n + c : c;
21728      if (!this._events[m]) return this;
21729      if (!l)
21730        return o(this, m), this;
21731      var y = this._events[m];
21732      if (y.fn)
21733        y.fn === l && (!p || y.once) && (!f || y.context === f) && o(this, m);
21734      else {
21735        for (var b = 0, C = [], _ = y.length; b < _; b++)
21736          (y[b].fn !== l || p && !y[b].once || f && y[b].context !== f) && C.push(y[b]);
21737        C.length ? this._events[m] = C.length === 1 ? C[0] : C : o(this, m);
21738      }
21739      return this;
21740    }, a.prototype.removeAllListeners = function(c) {
21741      var l;
21742      return c ? (l = n ? n + c : c, this._events[l] && o(this, l)) : (this._events = new r(), this._eventsCount = 0), this;
21743    }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = n, a.EventEmitter = a, e.exports = a;
21744  })(na)), na.exports;
21745}
21746var wE = bE();
21747const CE = /* @__PURE__ */ oo(wE);
21748var yt;
21749(function(e) {
21750  e.Loading = "Loading", e.NotFound = "NotFound", e.Found = "Found";
21751})(yt || (yt = {}));
21752var Ne;
21753(function(e) {
21754  e.Loading = "Loading", e.NotFound = "NotFound", e.Disconnect = "Disconnected", e.Connected = "Connected";
21755})(Ne || (Ne = {}));
21756class EE extends CE {
21757  get connected() {
21758    return this.state === Ne.Connected;
21759  }
21760  /**
21761   * Some wallets such as TronLink don't support disconnect() method.
21762   */
21763  disconnect() {
21764    return console.info("The current adapter doesn't support disconnect by DApp."), Promise.resolve();
21765  }
21766  // eslint-disable-next-line @typescript-eslint/no-unused-vars
21767  multiSign(...t) {
21768    return Promise.reject("The current wallet doesn't support multiSign.");
21769  }
21770  // eslint-disable-next-line @typescript-eslint/no-unused-vars
21771  switchChain(t) {
21772    return Promise.reject("The current wallet doesn't support switch chain.");
21773  }
21774}
21775class pr extends Error {
21776  constructor(t, n) {
21777    super(t), this.error = n;
21778  }
21779}
21780class ra extends pr {
21781  constructor() {
21782    super(...arguments), this.name = "WalletNotFoundError", this.message = "The wallet is not found.";
21783  }
21784}
21785class Ci extends pr {
21786  constructor() {
21787    super(...arguments), this.name = "WalletDisconnectedError", this.message = "The wallet is disconnected. Please connect first.";
21788  }
21789}
21790class vr extends pr {
21791  constructor() {
21792    super(...arguments), this.name = "WalletConnectionError";
21793  }
21794}
21795class Ju extends pr {
21796  constructor() {
21797    super(...arguments), this.name = "WalletSignMessageError";
21798  }
21799}
21800class Ei extends pr {
21801  constructor() {
21802    super(...arguments), this.name = "WalletSignTransactionError";
21803  }
21804}
21805class Xu extends pr {
21806  constructor() {
21807    super(...arguments), this.name = "WalletSwitchChainError";
21808  }
21809}
21810class AE extends pr {
21811  constructor() {
21812    super(...arguments), this.name = "WalletGetNetworkError";
21813  }
21814}
21815var Rr;
21816(function(e) {
21817  e.Mainnet = "Mainnet", e.Shasta = "Shasta", e.Nile = "Nile", e.Unknown = "Unknown";
21818})(Rr || (Rr = {}));
21819var el;
21820(function(e) {
21821  e.Mainnet = "Mainnet", e.Shasta = "Shasta", e.Nile = "Nile";
21822})(el || (el = {}));
21823function Xr() {
21824  return typeof window < "u" && typeof document < "u" && typeof navigator < "u";
21825}
21826function es() {
21827  return typeof navigator < "u" && navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/i);
21828}
21829var vE = function(e, t, n, r) {
21830  function s(i) {
21831    return i instanceof n ? i : new n(function(o) {
21832      o(i);
21833    });
21834  }
21835  return new (n || (n = Promise))(function(i, o) {
21836    function a(l) {
21837      try {
21838        c(r.next(l));
21839      } catch (f) {
21840        o(f);
21841      }
21842    }
21843    function u(l) {
21844      try {
21845        c(r.throw(l));
21846      } catch (f) {
21847        o(f);
21848      }
21849    }
21850    function c(l) {
21851      l.done ? i(l.value) : s(l.value).then(a, u);
21852    }
21853    c((r = r.apply(e, t || [])).next());
21854  });
21855};
21856function $a() {
21857  return !!(window.tron && window.tron.isTronLink);
21858}
21859function Uf() {
21860  return !!($a() || window.tronLink || window.tronWeb);
21861}
21862function _E() {
21863  return Xr() && typeof window.iTron < "u";
21864}
21865function NE({ dappIcon: e, dappName: t } = { dappIcon: "", dappName: "" }) {
21866  if (!Uf() && es() && !_E()) {
21867    let n = "", r = "";
21868    try {
21869      n = document.title;
21870      const l = document.querySelector('link[rel*="icon"]');
21871      l && (r = new URL(l.getAttribute("href") || "", location.href).toString());
21872    } catch {
21873    }
21874    const { origin: s, pathname: i, search: o, hash: a } = window.location, u = s + i + o + (a.includes("?") ? a : `${a}?_=1`), c = {
21875      action: "open",
21876      actionId: Date.now() + "",
21877      callbackUrl: "http://someurl.com",
21878      // no need callback
21879      dappIcon: e || r,
21880      dappName: t || n,
21881      url: u,
21882      protocol: "TronLink",
21883      version: "1.0",
21884      chainId: "0x2b6653dc"
21885    };
21886    return window.location.href = `tronlinkoutside://pull.activity?param=${encodeURIComponent(JSON.stringify(c))}`, !0;
21887  }
21888  return !1;
21889}
21890function IE(e) {
21891  return vE(this, void 0, void 0, function* () {
21892    return new Promise((t, n) => {
21893      const r = setInterval(() => {
21894        e.tronWeb && (clearInterval(r), clearTimeout(s), t());
21895      }, 50), s = setTimeout(() => {
21896        clearInterval(r), n("`window.tron.tronweb` is not ready.");
21897      }, 2e3);
21898    });
21899  });
21900}
21901var nn = function(e, t, n, r) {
21902  function s(i) {
21903    return i instanceof n ? i : new n(function(o) {
21904      o(i);
21905    });
21906  }
21907  return new (n || (n = Promise))(function(i, o) {
21908    function a(l) {
21909      try {
21910        c(r.next(l));
21911      } catch (f) {
21912        o(f);
21913      }
21914    }
21915    function u(l) {
21916      try {
21917        c(r.throw(l));
21918      } catch (f) {
21919        o(f);
21920      }
21921    }
21922    function c(l) {
21923      l.done ? i(l.value) : s(l.value).then(a, u);
21924    }
21925    c((r = r.apply(e, t || [])).next());
21926  });
21927};
21928const TE = {
21929  "0x2b6653dc": Rr.Mainnet,
21930  "0x94a9059e": Rr.Shasta,
21931  "0xcd8690dc": Rr.Nile
21932};
21933function SE(e) {
21934  return nn(this, void 0, void 0, function* () {
21935    var t, n, r;
21936    const { blockID: s = "" } = yield e.trx.getBlockByNumber(0), i = `0x${s.slice(-8)}`;
21937    return {
21938      networkType: TE[i] || Rr.Unknown,
21939      chainId: i,
21940      fullNode: ((t = e.fullNode) === null || t === void 0 ? void 0 : t.host) || "",
21941      solidityNode: ((n = e.solidityNode) === null || n === void 0 ? void 0 : n.host) || "",
21942      eventServer: ((r = e.eventServer) === null || r === void 0 ? void 0 : r.host) || ""
21943    };
21944  });
21945}
21946const RE = "TronLink";
21947class xE extends EE {
21948  // record if first connect event has emitted or not
21949  constructor(t = {}) {
21950    super(), this.name = RE, this.url = "https://www.tronlink.org/", this.icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAF0AAABdCAYAAADHcWrDAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAUGVYSWZNTQAqAAAACAACARIAAwAAAAEAAQAAh2kABAAAAAEAAAAmAAAAAAADoAEAAwAAAAEAAQAAoAIABAAAAAEAAABdoAMABAAAAAEAAABdAAAAAMkTBfIAAAFZaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA2LjAuMCI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIj4KICAgICAgICAgPHRpZmY6T3JpZW50YXRpb24+MTwvdGlmZjpPcmllbnRhdGlvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Chle4QcAABZhSURBVHgB7V0JlBTVuf6runtWllkA2QeYQQRBZHNFxZjw4jFqMEFxCWIS1yOaTeJ76nk5Lyc5CUZNfCoa0BgUxRh3QD2CJs8lELaIgOCw78sszN4z0131vu/W1NDTfbtneqa7Zx5v/nN6prrq1q2q77//ev9bbUgcNHjm/sya7PIiIxA43TCNUbYEcw3bsOLo4v98U9sWAxSwbbvYI7LDCDZ+dezl847G82BGWxrnzVl/nmF5bhCxviG2FBoen0+Ep9ptOf0UbOPAZlsNhOCYmOYawzaXirfynZLnpla19sAxQc+5ac14jyf9IbHsqw1vute2GoF78P8x2Bo4DVMME2OQqAQDW8W2flv64oQXMCijjsiooOfP3jAXvf0SHfa2A/XsUnXc/ScGAgAfqgfgB18zGqvvKVk69ZCudSTot63z5fvNRw0z7W7bCpB9uvO698VAwPBmAraGzXbQuq5sycSt4U3NljtsA4D/wfBk3I2TugFvCU6bv9mBOigJ71jTY7zd++Z1heEntgA976b1P8YIv9MO+NGuW52EgxXPdzsIlexJK/Ra5uK+d23pEXpuM+h9blo30TS9/6WMZTfgoRi1e5uD1/BmXGBV1j0Y2okD+i9smGDjV2L6smF9Q493b3cQATXiTc/c3BvXjXO7UqD32bn2Itv0TlcN3CPd/xODAAax4UnP8pjmvW6HCnTbNm+B4sd2tx53gUnkfw5mW6wZUOED2K+ZM2djDoLLy+wgAp9uSg4CarRn5Ikpl/ICpinWGfBvBnXr8uTg3dwrIlfkbS5yQLdkPNxEBEndqqUZoGRsqCDTHK1At2yZZnd7LMmAuUWfDsZ236LLV6SbGPXZ3aO8BT7J/OLx98iBSre79UoyUW7RN3Jh/O4ERy2OdH9JNgLdoCcbYU3/3aBrQEn2rm7Qk42wpn+vZl/cuzgTUtvgJMo8piEesNLE/8gZkri7PiVP6DDojUFb5s0YIIPz02TDzhr58oBf9hyrl9KqgGIEZq/ABEOY2UEFQTcjMIw6DHoAoO891iAPfHeg3HxpH4a6cryyUXYfrZdNe+tk055aMKJO9h5vUIyog0ScZASYQGackuM5+kN1GPR0nykrN1XIobIGGZiXpgDt19sn/Jx7ujNhgqhXjlU4jPhiby0YUdfEiHopg0TUNbKYxJUIgwmhU5o6DDo0hhw90Sjvb6yQWy7rqwWLbfrn+NTn/FEnGcHzdh7xyxeQCDKDqmlficOI+iZGeHGyxwNGnELi0GHQiTIBeWNNucz5Wl81YrXIh+3kOQNyfeozdXRPdTQIkThWEZAdh/1QTY5EbD9YB0Y0SFl1QBpOEUYkBPQ0WMm1xTVCgM4YnBkGb9u/0uC6jLhojMMI2gxKxI4j9UoaaCO2HfTLfjCinIwIOKrJC2ng+WRmV6eEgE59XFEblHfWnugQ6DqwCOYgeEb8XHLmSUYcLm+U4kNQTfsc1bTdZURNQBq7OCMSAjrB8gGcd9adkHuv7C9p3uQONzJiSJ809fnaWb0Ur+i6HgEjviIjqJrwISMOQCJO1ASFxykFtA+dLREJBX0zRt16+OqusdSN3GTtI9NdRlzWxAiqHkrEV4coDScl4kCpwwiqrs5gRMJAp7Ptr7fkzdXlnQK6jpmUuIK+aerzjfG9VRN6RXRvt0MiNkMayAxKBxlBFekywrURVJ2JpsSBjjvjQ77/rwp5YOZA6ZWF6u02Ui2YRXvQI9OUcUOz4O/7hA+dDEr3GTL8tHT1+eYElxGWHCxrVOqIqsllxEEyoi4owSaJSBQjEgo6b2oXItGPv6ySKybltBmzrHRTRgCIW5/ardTBqEEZws+4giwZOzRTRg7IkP5wL6lCkkEM8Hh9fi6f6DDCj8iZo9+RCETWYAYN90FISWWtJXRvGcSpOAI6Kh6JMPJnr38LtV9XCSt0E0AM82dNzZdn7x4ed29MFcx5fJd8AqZRaphS4P/cHl6lr88AI84a1sSIgRlyGgIuPnSqiM9GV5UGevM+RyJcRlTVtcIIE+PbDmzLrKufmHDQLSQb83p65ONfj1E+d7yAlFQG1IhnhEsJIDGNQBEPYMNlRB4YMRT6mnHBuIJMSESWnE5G9PaqDGe8121ve6pGMmIbYhSqJTKj+FC9shvVfqgm4KEkwusTjxHcluVPAui8eY6IBbcPk9lIgLWHqv2WzF24R175pEwyAbxuLIczgrqajCjomw5GQCKgms6EaiqCako1I2pw/4yiGSwqGwGvrvhIQI6W1W3zVPsTP9IJcn2jJV+Ht/D6/SO1gG3YVQs9nS49M6MbW7p7//7Cfnnm/WNCndsWnUkpozRQ31IiyIj8ng4jRkMixg/LBCOypLB/uvRFQi6FmkmofpB53bNkU81ZCTWk7qhmWmDNV9XK8FDkw6myNiB3PH1YnoI09I7i5VCX/27OUKXP579xWHkzrYFEMU5TjU7KBrOYzOesxv2QERlppmLEMKim0UOomhwb4TLi5Jnhd92x7z3hmcE58BTu8FO7J544KhkF0g386dX9Iy5wwRk9Zd6f98u1D++QxfeOUAYxohF2sJ8H4X7m9fDIgy8dVCOY0WQ8xBks4Mze1GnAXUqR72c+57Pt1WofJalPL68M65cuY5ptRCa8mQxIROIgYgxA8mSNv/16zCSMSnQtI7unSN14cb4Ku9XVmv4QuEr4vwveOyb/RKLskrG91IgObRO6PWVkDxXgrNxUqRJcBLK9xDO5GIv3QBdUuaHYWQOjR4O4DhH1uxsqlD1Z+kmpLENqYyPUISNbgkYpdg18vPeAnFDlF/vqFySOjWF34IN6oCXfsLtGzgVo4fStybny6NtHZO2OGvnub4vlT/eMgM7NCm/W/H3WRfmSA0N5x4LdSPMGlSvZfLCDG2QEmcC53VCJ4MQLwf5kK5aGolEmRKavKxFQTXRfx8FYD4N/TyPeVkraSOeD0J3KyfLCqDpJqdCbooH7eGu1mk8liO/CRTx7eJbyPkLbhW7TE+Fs1EdfVCKtG0xa1Mpr8v5NVyIwgCgRjvQG1dQjJXTF+hNKIuhlrYB0fL67Vo6CUXQTacTJpFAKBqVy0z7/gqSBzotRJxPQG6BiqDdDicfq4aFQfGncqG64TcOrM77uuUxqXQp1xKiXWcVkpQvc64X+1zICnKjCve/GPDGdBz4D1dJfwAgOJOb/jyH2AAvBNKuy5EjjgoQHR6E3yW26fq/8rKg5vA49fhj5jqn/sVUxhqLt6sxHbhki35sW28ffe7xebvnv3bIGxpC+fFciekkW/gSwBFelC8Ct7Kx0yc+2vyrq0zgh6XfLi76xpkyLyQAktqZh1DYEII8gjtpGyOY9i/bJH5bFfscBgyAyczqSVlRjXYkoxbQRVDE0upRkDqhD5Y3Wxi0NWFWXZKK//dEXVcpF011qxnm5CI8puA7xZvn1wSUH5BdLD6oR4x4L/0+jRpfzuql5qsaGOrerEp/JVYVJB50gMn+98vMKLR4XYy50BCJERpIu4RTlnTz85mH50bP7xI8INxoxqn3mzuFyx7/1k3qkHyjaXZ2SDjoBIJdfX3NCCwjz7tPP7q1m+kPB4jm0/os+OC63Prkb6dTo7yigND2C6PX+7wxU03Ih/AvtstO3OXd74ABNagqIAcVqGDzWuOhoxrm5Su/pBil14mv/KJcbH9sZVUWxT6WSEL3+5nuD8c3Jv+iu1Vn7mI+aMDw77aNFRU44kOwbobpguQTdKR1NKspWkxVumBzehsB/iGiUaQNOksSiuy4/TZ68bZhyUaP1F+v8ZByjoZ8Fu/PKzwp9PTP6pgZ0PgiNyNvIxeiAoHr41uQcVToR7aHpFq7fheh1frHyfaO14/7rEb0+P3eE9M72KJc1VttkHqN9YZr7tun95KnbhkpOthfPUJ4a9cIHY1qAgcK/ELXp6MopOSrjGMsQZiDA4kzNTIx4zi7Fom9i2m3pT4tkENxSTkanmmhX6AqzovnR7w9FROvEIbyPlOh0XggaRvnTb6L8TkejBmXKlJHZrY5MRraMRG94dGdUdeX2z1KQV+eNFE7zcc4zVeTk82351U1D5D+vGxSRt08Z6HxgqpH3EBozoxdO1Ps0qIzkWiNKDb2ZHzyxW174W0nM5pzY/uvPi+QcJN0o6skmqk/maR7/YYHcc8Vp2sulFHTqdaqHT7c5eezwO6LryMlmzgC1RuyLKYZ7Fu2V
21950x9sSvd5XKNMxm5XM6JUuIeOGZ+8eETONkVLQCSSDIFb46oj1igyW3LSArk3oProBzI2fjF5Dj7bc7tvLJ4t/1BS9wptoXZ5ant/aNw6AfjleWfLjQqF9ikUpB50qhu4fc9U6mnFenvK5dcd0+6iWqG6c6HWvmp/VteM+Fb3ekfjolREzC5heva9ILm4qctXdgw+5GFLKQWdagEU8qwC8jliZywcITQvo2oXuC41ef9ha9IoHf+SWofLzaxITvdJOcPLltXlFmA/Aiv8Y9MHnlf4nH14bSDnovCeC9AZqHnWUA99alxbQtQ3fF0/0+tC1jF6HqC7obbSHaB+oDukhcYIlFj31fqnM/v3O4KaqCqtTQGda4B9IC+yKkhb4NtMCcA3bA4WKXjGz1LbotZ88cWuBpON+dEFbLBAJOHX3Sz8plIEo+YtGfIZf//UQykkOqGnowYMHp1698Oaoh7nkcfl6feZxCtICY4ZkxA2E++BMlLFkm3OvDMhiEWe1nsf8bFujV4JYB8A5yfInRL0s+YtGarnn8/sV6PS2zKYyn04Z6bxJJy1QrgWWAdAVraQFoj2ou58TB8WH69scvb78E0avaTENMUMIJq7mwv9+8raCmFUBrPK68+k98uR7RyUd90KV6lKngU6PgykB1v/p6Kopuarcug2xku50tY8zN270ujxKss09+YIzGL0WoSAoUxtEudVjD84cJL+ZPaR5QsI9P/Q/C5xYCPvS/5RKFgEPPYjtTgOdN8LREC0twDK4yYWtpwXCnifiqxu9fv+JXfLi31uPXumFsGQkNHqloeVInQ+w779GvXAu4jruDnpmsx7ZKcs3nIgqCZ0GOm+SPvsK3JwuSmSJHA1qsCNDvQkJN3qdu7AN0SuqvJCCFa7c4H1RL9OoL7hjmNyO2alYxBLqmfN3IOKuUiOcbWkDLDCNwVPz+xOSVeEV6+bcY6zUYmn0+SizY0F+OLHIk6UM/qb1o+HH4/nOGham3eArKwAuHtOrhZ4N7Ss7w6Nsyh6UVVA9PYew/upzckObRGzTcDMJxwXIzL0Q5AA+XFiWhxqfsQXZMu3MHhWXFHj+GN30RnSbnB0cSfTZv960OCv0KqxxoR/8+uoyNbMUeqw92/SaKF2MXjmpMv/moWrGXtcXo9enMbqpLmLV4fDc5Sg6cqcUaYwL+qE4VdVEOuXaHFDMKUFo0579sNzT6aC7aQGOeBZxhtOM83OjlnCEt23Ldw54ejYLMffKQih6IdHWR9Hnbw1wLiT+++YqFLoOUhVqnGQ/DRIa6q2491UDdUWKfEq3RYr+My2wv7RePmRAc2FexFWnIS1QAD17EMWdFNVEEHtxotcyrKgLyMK7hketHG7tekWos59/sxPZttbWPd6phtS9CVqbaGkBBh80aizBSzQR+FXQ8df+bgfK4mLPvUa7dnvWPHUJ0NPgHdDiR3twTm6kwedOPOwo8+DcKyqHv8PoFSvoUkFdAnQaOOr0d2GQdHQOpvFYrB9vfkTXl26fil6xOIvuXmtzr7rz27rPrbnsEqDzppFzkrf+iWoBTcaPoHBdKmdmkkWMXlmLfj3cvk9bmfSO5x6YNuDrtT74vFp+/86RhpWfHg52uiF1H8AH1DeixGIz0gKsUw+nq87JkceXH1WjXecZhLdvz3d6UiVNr8K6sOkdNPH0Q4BRJKqmJJne4Mo6Lv51Vl6jODbQ2JhvNXYd0AkklzK+vbZcC/oYrHyYWJiFUVitfO14wIinLdO8g/tEBmrhfbC6gKunnYW8dbJlP94xAPeR+yo0b93web0ImiDOSDV5YZ26zCvkONKWr6uQ+64eEFFzTtfy24gK6ROzXTKIGQdmBHXxAq/H1Rer8L4yBTBG8CHU17MqgbaGdsl9rQnzPfxEI6TA7MSsT492hTj2M0fCBa+ri/XVApdPzFEvZNOo/TiuEr0pLUY2vBkuzdERl1Y+gBJuvumDo5q5GQ4Aup60Owz/CX4Msr3Z9bZpW57PDDe7HqN1qg65aQHd9bgs/UKkYNtaLaDrI9Y+JqZyUfrGFEA48VhpVaP0RF6GAKtJidgAt+jC4LsQxa7Y8/y0euSBrA34obsWDTrzC0cOly4yJ60jLiKI41l1XUTdRwl
21950icoqjPZyqMaqZNmhlJIefdvI7QbfNYiTdbNMTSNuCtzOUqrdSnmzSaVvU3fvwNowPN+urBS4d1wtvxEhXa3kSfZMczXyPgM474gt4KvB+ML5Ftb1kiPUZzzWPvTzuKK7yqfvzju3tMLHnOZlHXZ/Ut1wimYyiUI50ZgN1pF5ji9HeLsjBRfzsTq0R9Kxi30qO8GuCLzjpdt3lUr+P1QKMDLmCTkcqLRDDO9Cd09Z9fEWhjo6jOIr5H50U6NqH7jM8aYDXXnX8pQlQL02g9/L1WQZObFQHQ1t30jYl+DheosDl4jriAl6++YhGN5FEQJkP1xEnM9qXhsAotwKWYdiPuf2qkb7n+eF+6PmH8LvJSPi2S4Dc/hL2n7r9LdQ86gqB6KJ1tFpAd6N0+aKpF/rk7Zk5xA8G4rzAKyWLJ3/kXrPZTJf8efJysRueMXyxK5XcE5P9n17MBqQFGIjoiNUCPTJQkJSgwa4CI2Q7+WJmHTEvE7dqwS/x2kH/Pgn65oX22Qw6d5p1mfPwc46r+MuxnU18QL5F4x0kwXQ0Fq+QmjAC1QIJUjHkXTaYyFdh6ehweUN8oKu3uliVhhW8uWzJ+AOhfbYA/firZ1Y3NFqzwJ0PDS+TTp2rahhKc/4xtBzCvXlOHnCymO/2SgTRXeQLf3RTdzx2HKnn0EXGMa9Jwyn2CSMYuKHkxSl/C2/bAnQerHp5cgl+6niGHax7Tsitpl8KDz8xFd8Z9fGF93x5so4un9Rb5Uno6nWU2AdfH5KVHjnSObdZjmBNBZWxLoQGSkvYwS3A8IqSF6GyNRQBOtuULTmvsnTxxB9YVuB6VG1sxW9O4zc1wb24lZrminHsopzRH482lTccc6eszEpEWoDLbmhEdbEPk1p8U5NTxqF5AAxORyUbVWI1PNbQEJhW9uI5n2laql36zE5T6/IXJi7Nu3H1CsO0r4OmmY2M5CT8oGmmw3IMjURZsWh3h/3pGbas3OKXE5hJy4lMs8s1WESwbAMOejwdUoaIVaR/nt6JKK1GoVAQDEF61lG4+Ks2GPRgQbId3InZl7cxQBeWLJ70ZYzHUYdigs4WHPX4txA9L8qfs34UfM7J2B6NFVmDxLB6i92q0KkLtfcPhX0vSqq3H6geC/98RHg/VwL0MW8e/hjvVy/Xim34CVG+21h+ePawjAk4HDG1byFN4q+r/dQH74aaDGOtFvnw4wC+2BJzo8db/XnJc1Njr7EMua7DuJAdXXXTrq8fI2lpUyPvz8LSjjXLjCEXHIw8Ft8eu65sqmTkjok4K+AvNnyZH0Xsb+eO/wWrg46Do/7gYAAAAABJRU5ErkJggg==", this._readyState = Xr() ? yt.Loading : yt.NotFound, this._state = Ne.Loading, this._supportNewTronProtocol = !1, this._tronLinkMessageHandler = (a) => {
21951      var u, c, l, f, p;
21952      const m = (u = a.data) === null || u === void 0 ? void 0 : u.message;
21953      if (m)
21954        if (m.action === "accountsChanged")
21955          setTimeout(() => {
21956            var y;
21957            const b = this.address || "";
21958            if (!((y = this._wallet) === null || y === void 0) && y.ready) {
21959              const C = m.data.address;
21960              this.setAddress(C), this.setState(Ne.Connected);
21961            } else
21962              this.setAddress(null), this.setState(Ne.Disconnect);
21963            this.emit("accountsChanged", this.address || "", b), !b && this.address ? this.emit("connect", this.address) : b && !this.address && this.emit("disconnect");
21964          }, 200);
21965        else if (m.action === "setNode")
21966          this.emit("chainChanged", { chainId: ((l = (c = m.data) === null || c === void 0 ? void 0 : c.node) === null || l === void 0 ? void 0 : l.chainId) || "" });
21967        else if (m.action === "connect") {
21968          const y = ((p = (f = this._wallet.tronWeb) === null || f === void 0 ? void 0 : f.defaultAddress) === null || p === void 0 ? void 0 : p.base58) || "";
21969          this.setAddress(y), this.setState(Ne.Connected), this.emit("connect", y);
21970        } else m.action === "disconnect" && (this.setAddress(null), this.setState(Ne.Disconnect), this.emit("disconnect"));
21971    }, this._onChainChanged = (a) => {
21972      this.emit("chainChanged", a);
21973    }, this._onAccountsChanged = () => {
21974      var a, u, c;
21975      const l = this.address || "", f = ((a = this._wallet) === null || a === void 0 ? void 0 : a.tronWeb) && ((c = (u = this._wallet) === null || u === void 0 ? void 0 : u.tronWeb.defaultAddress) === null || c === void 0 ? void 0 : c.base58) || "";
21976      if (!f)
21977        this.setAddress(null), this.setState(Ne.Disconnect);
21978      else {
21979        const p = f;
21980        this.setAddress(p), this.setState(Ne.Connected);
21981      }
21982      this.emit("accountsChanged", this.address || "", l), !l && this.address ? this.emit("connect", this.address) : l && !this.address && this.emit("disconnect");
21983    }, this._checkPromise = null, this._updateWallet = () => {
21984      var a, u, c, l, f, p, m, y, b;
21985      let C = this.state, _ = this.address;
21986      if (es())
21987        window.tronLink ? this._wallet = window.tronLink : this._wallet = {
21988          ready: !!(!((a = window.tronWeb) === null || a === void 0) && a.defaultAddress),
21989          tronWeb: window.tronWeb,
21990          request: () => Promise.resolve(!0)
21991        }, _ = ((c = (u = this._wallet.tronWeb) === null || u === void 0 ? void 0 : u.defaultAddress) === null || c === void 0 ? void 0 : c.base58) || null, C = _ ? Ne.Connected : Ne.Disconnect;
21992      else if (window.tron && window.tron.isTronLink) {
21993        this._supportNewTronProtocol = !0, this._wallet = window.tron, this._listenTronEvent();
21994        try {
21995          _ = ((l = this._wallet) === null || l === void 0 ? void 0 : l.tronWeb) && ((p = (f = this._wallet.tronWeb) === null || f === void 0 ? void 0 : f.defaultAddress) === null || p === void 0 ? void 0 : p.base58) || null, C = _ ? Ne.Connected : Ne.Disconnect;
21996        } catch (R) {
21997          console.error("Unknow error: " + R, " Please install TronLink extension wallet."), _ = null, C = Ne.Disconnect, this._readyState = yt.N
21997otFound, this.emit("readyStateChanged", this.readyState);
21998          return;
21999        }
22000      } else window.tronLink ? (this._wallet = window.tronLink, this._listenTronLinkEvent(), _ = ((y = (m = this._wallet.tronWeb) === null || m === void 0 ? void 0 : m.defaultAddress) === null || y === void 0 ? void 0 : y.base58) || null, C = this._wallet.ready ? Ne.Connected : Ne.Disconnect) : window.tronWeb ? (this._wallet = {
22001        ready: window.tronWeb.ready,
22002        tronWeb: window.tronWeb,
22003        request: () => Promise.resolve(!0)
22004      }, _ = ((b = this._wallet.tronWeb.defaultAddress) === null || b === void 0 ? void 0 : b.base58) || null, C = this._wallet.ready ? Ne.Connected : Ne.Disconnect) : (this._wallet = null, _ = null, C = Ne.NotFound);
22005      es() && C === Ne.Disconnect && this.checkForWalletReadyForApp(), this.setAddress(_), this.setState(C);
22006    }, this.checkReadyInterval = null;
22007    const { checkTimeout: n = 30 * 1e3, dappIcon: r = "", dappName: s = "", openUrlWhenWalletNotFound: i = !0, openTronLinkAppOnMobile: o = !0 } = t;
22008    if (typeof n != "number")
22009      throw new Error("[TronLinkAdapter] config.checkTimeout should be a number");
22010    if (this.config = {
22011      checkTimeout: n,
22012      openTronLinkAppOnMobile: o,
22013      openUrlWhenWalletNotFound: i,
22014      dappIcon: r,
22015      dappName: s
22016    }, this._connecting = !1, this._wallet = null, this._address = null, !Xr()) {
22017      this._readyState = yt.NotFound, this.setState(Ne.NotFound);
22018      return;
22019    }
22020    $a() || es() && (window.tronLink || window.tronWeb) ? (this._readyState = yt.Found, this._updateWallet()) : this._checkWallet().then(() => {
22021      this.connected && this.emit("connect", this.address || "");
22022    });
22023  }
22024  get address() {
22025    return this._address;
22026  }
22027  get state() {
22028    return this._state;
22029  }
22030  get readyState() {
22031    return this._readyState;
22032  }
22033  get connecting() {
22034    return this._connecting;
22035  }
22036  /**
22037   * Get network information used by TronLink.
22038   * @returns {Network} Current network information.
22039   */
22040  network() {
22041    return nn(this, void 0, void 0, function* () {
22042      var t;
22043      try {
22044        if (yield this._checkWallet(), this.state !== Ne.Connected)
22045          throw new Ci();
22046        const n = ((t = this._wallet) === null || t === void 0 ? void 0 : t.tronWeb) || window.tronWeb;
22047        if (!n)
22048          throw new Ci();
22049        try {
22050          return yield SE(n);
22051        } catch (r) {
22052          throw new AE(r?.message, r);
22053        }
22054      } catch (n) {
22055        throw this.emit("error", n), n;
22056      }
22057    });
22058  }
22059  connect() {
22060    return nn(this, void 0, void 0, function* () {
22061      var t, n;
22062      try {
22063        if (this.checkIfOpenTronLink(), this.connected || this.connecting)
22064          return;
22065        if (yield this._checkWallet(), this.state === Ne.NotFound)
22066          throw this.config.openUrlWhenWalletNotFound !== !1 && Xr() && window.open(this.url, "_blank"), new ra();
22067        if (!this._wallet)
22068          return;
22069        if (this._connecting = !0, this._supportNewTronProtocol) {
22070          const r = this._wallet;
22071          try {
22072            const i = (yield r.request({ method: "eth_requestAccounts" }))[0];
22073            this.setAddress(i), this.setState(Ne.Connected), this._listenTronEvent(), this._wallet.tronWeb || (yield IE(this._wallet));
22074          } catch (s) {
22075            let i = s?.message || s || "Connect TronLink wallet failed.";
22076            throw s.code === -32002 && (i = "The same DApp has already initiated a request to connect to TronLink wallet, and the pop-up window has not been closed."), s.code === 4001 && (i = "The user rejected connection."), new vr(i, s);
22077          }
22078        } else if (window.tronLink) {
22079          const r = this._wallet;
22080          try {
22081            const i = yield r.request({ method: "tron_requestAccounts" });
22082            if (!i)
22083              throw new vr("TronLink wallet is locked or no wallet account is avaliable.");
22084            if (i.code === 4e3)
22085              throw new vr("The same DApp has already initiated a request to connect to TronLink wallet, and the pop-up window has not been closed.");
22086            if (i.code === 4001)
22087              throw new vr("The user rejected connection.");
22088          } catch (i) {
22089            throw new vr(i?.message, i);
22090          }
22091          const s = ((t = r.tronWeb.defaultAddress) === null || t === void 0 ? void 0 : t.base58) || "";
22092          this.setAddress(s), this.setState(Ne.Connected), this._listenTronLinkEvent();
22093        } else if (window.tronWeb) {
22094          const s = ((n = this._wallet.tronWeb.defaultAddress) === null || n === void 0 ? void 0 : n.base58) || "";
22095          this.setAddress(s), this.setState(Ne.Connected);
22096        } else
22097          throw new vr("Cannot connect wallet.");
22098        this.connected && this.emit("connect", this.address || "");
22099      } catch (r) {
22100        throw this.emit("error", r), r;
22101      } finally {
22102        this._connecting = !1;
22103      }
22104    });
22105  }
22106  disconnect() {
22107    return nn(this, void 0, void 0, function* () {
22108      this._supportNewTronProtocol ? this._stopListenTronEvent() : this._stopListenTronLinkEvent(), this.state === Ne.Connected && (this.setAddress(null), this.setState(Ne.Disconnect), this.emit("disconnect"));
22109    });
22110  }
22111  signTransaction(t, n) {
22112    return nn(this, void 0, void 0, function* () {
22113      try {
22114        const r = yield this.checkAndGetWallet();
22115        try {
22116          return yield r.tronWeb.trx.sign(t, n);
22117        } catch (s) {
22118          throw s instanceof Error ? new Ei(s.message, s) : new Ei(s, new Error(s));
22119        }
22120      } catch (r) {
22121        throw this.emit("error", r), r;
22122      }
22123    });
22124  }
22125  multiSign(t, n, r) {
22126    return nn(this, void 0, void 0, function* () {
22127      try {
22128        const s = yield this.checkAndGetWallet();
22129        try {
22130          return yield s.tronWeb.trx.multiSign(t, n, r);
22131        } catch (i) {
22132          throw i instanceof Error ? new Ei(i.message, i) : new Ei(i, new Error(i));
22133        }
22134      } catch (s) {
22135        throw this.emit("error", s), s;
22136      }
22137    });
22138  }
22139  signMessage(t, n) {
22140    return nn(this, void 0, void 0, function* () {
22141      try {
22142        const r = yield this.checkAndGetWallet();
22143        try {
22144          return yield r.tronWeb.trx.signMessageV2(t, n);
22145        } catch (s) {
22146          throw s instanceof Error ? new Ju(s.message, s) : new Ju(s, new Error(s));
22147        }
22148      } catch (r) {
22149        throw this.emit("error", r), r;
22150      }
22151    });
22152  }
22153  /**
22154   * Switch to target chain. If current chain is the same as target chain, the call will success immediately.
22155   * Available chainIds:
22156   * - Mainnet: 0x2b6653dc
22157   * - Shasta: 0x94a9059e
22158   * - Nile: 0xcd8690dc
22159   * @param chainId chainId
22160   */
22161  switchChain(t) {
22162    return nn(this, void 0, void 0, function* () {
22163      try {
22164        if (yield this._checkWallet(), this.state === Ne.NotFound)
22165          throw this.config.openUrlWhenWalletNotFound !== !1 && Xr() && window.open(this.url, "_blank"), new ra();
22166        if (!this._supportNewTronProtocol)
22167          throw new Xu("Current version of TronLink doesn't support switch chain operation.");
22168        const n = this._wallet;
22169        try {
22170          yield n.request({
22171            method: "wallet_switchEthereumChain",
22172            params: [{ chainId: t }]
22173          });
22174        } catch (r) {
22175          throw new Xu(r?.message || r, r instanceof Error ? r : new Error(r));
22176        }
22177      } catch (n) {
22178        throw this.emit("error", n), n;
22179      }
22180    });
22181  }
22182  checkAndGetWallet() {
22183    return nn(this, void 0, void 0, function* () {
22184      if (this.checkIfOpenTronLink(), yield this._checkWallet(), this.state !== Ne.Connected)
22185        throw new Ci();
22186      const t = this._wallet;
22187      if (!t || !t.tronWeb)
22188        throw new Ci();
22189      return t;
22190    });
22191  }
22192  _listenTronLinkEvent() {
22193    this._stopListenTronLinkEvent(), window.addEventListener("message", this._tronLinkMessageHandler);
22194  }
22195  _stopListenTronLinkEvent() {
22196    window.removeEventListener("message", this._tronLinkMessageHandler);
22197  }
22198  checkIfOpenTronLink() {
22199    const { dappName: t = "", dappIcon: n = "" } = this.config;
22200    if (this.config.openTronLinkAppOnMobile !== !1 && NE({ dappIcon: n, dappName: t }))
22201      throw new ra();
22202  }
22203  // following code is for TIP-1193
22204  _listenTronEvent() {
22205    var t, n;
22206    this._stopListenTronEvent(), this._stopListenTronLinkEvent();
22207    const r = this._wallet;
22208    (t = r.on) === null || t === void 0 || t.call(r, "chainChanged", this._onChainChanged), (n = r.on) === null || n === void 0 || n.call(r, "accountsChanged", this._onAccountsChanged);
22209  }
22210  _stopListenTronEvent() {
22211    var t, n;
22212    const r = this._wallet;
22213    (t = r.removeListener) === null || t === void 0 || t.call(r, "chainChanged", this._onChainChanged), (n = r.removeListener) === null || n === void 0 || n.call(r, "accountsChanged", this._onAccountsChanged);
22214  }
22215  /**
22216   * check if wallet exists by interval, the promise only resolve when wallet detected or timeout
22217   * @returns if wallet exists
22218   */
22219  _checkWallet() {
22220    if (this.readyState === yt.Found)
22221      return Promise.resolve(!0);
22222    if (this._checkPromise)
22223      return this._checkPromise;
22224    const t = 100, n = Math.floor(2e3 / t), r = Math.floor(this.config.checkTimeout / t);
22225    let s = 0, i;
22226    return this._checkPromise = new Promise((o) => {
22227      const a = () => {
22228        s++;
22229        const u = s < n && !es() ? $a() : Uf();
22230        (u || s > r) && (i && clearInterval(i), this._readyState = u ? yt.Found : yt.NotFound, this._updateWallet(), this.emit
22230("readyStateChanged", this.readyState), o(u));
22231      };
22232      i = setInterval(a, t), a();
22233    }), this._checkPromise;
22234  }
22235  checkForWalletReadyForApp() {
22236    if (this.checkReadyInterval)
22237      return;
22238    let t = 0;
22239    const n = Math.floor(this.config.checkTimeout / 200), r = () => {
22240      var s, i;
22241      (window.tronLink ? !((s = window.tronLink.tronWeb) === null || s === void 0) && s.defaultAddress : !((i = window.tronWeb) === null || i === void 0) && i.defaultAddress) ? (this.checkReadyInterval && clearInterval(this.checkReadyInterval), this.checkReadyInterval = null, this._updateWallet(), this.emit("connect", this.address || "")) : t > n ? (this.checkReadyInterval && clearInterval(this.checkReadyInterval), this.checkReadyInterval = null) : t++;
22242    };
22243    this.checkReadyInterval = setInterval(r, 200);
22244  }
22245  setAddress(t) {
22246    this._address = t;
22247  }
22248  setState(t) {
22249    const n = this.state;
22250    t !== n && (this._state = t, this.emit("stateChanged", t));
22251  }
22252}
22253function Ha(e) {
22254  const t = q.getWindow();
22255  if (e instanceof xE) {
22256    const n = t.tron, r = t.tronLink, s = n?.isTronLink === !0, i = r?.ready === !0;
22257    return s || i;
22258  }
22259  return !0;
22260}
22261function OE(e, t, n) {
22262  function r(s) {
22263    s === yt.Found && Ha(e) && (t(e), e.removeListener("readyStateChanged", r));
22264  }
22265  e.on("readyStateChanged", r), n.push(() => e.removeListener("readyStateChanged", r));
22266}
22267const PE = {
22268  watchWalletAdapters(e, t) {
22269    if (!q.isClient())
22270      return () => {
22271      };
22272    console.log("[TronConnectUtil] Watching wallet adapters:", {
22273      count: e.length,
22274      adapters: e.map((r) => ({
22275        name: r.name || r.constructor.name,
22276        readyState: r.readyState,
22277        isGenuine: Ha(r)
22278      }))
22279    });
22280    const n = [];
22281    for (const r of e)
22282      r.readyState === yt.Found ? Ha(r) ? t(r) : console.log("[TronConnectUtil] Adapter not genuine, skipping:", r.name) : r.readyState === yt.Loading && (console.log("[TronConnectUtil] Adapter loading, listening for ready:", r.name), OE(r, t, n));
22283    return () => n.forEach((r) => r());
22284  }
22285};
22286class kE extends Of {
22287  constructor(t) {
22288    super({
22289      namespace: x.CHAIN.TRON,
22290      adapterType: x.ADAPTER_TYPES.TRON,
22291      ...t
22292    }), this.universalProvider = void 0, this.walletAdapters = t?.walletAdapters || [];
22293  }
22294  syncConnectors() {
22295    const t = v.getCaipNetworks();
22296    this.cleanupWalletWatch?.(), this.cleanupWalletWatch = PE.watchWalletAdapters(this.walletAdapters, (n) => {
22297      this.addConnector(new yE({ adapter: n, chains: t }));
22298    });
22299  }
22300  async connect(t) {
22301    const n = this.connectors.find((o) => o.id === t.id);
22302    if (!n)
22303      throw new Error("Connector not found");
22304    const r = n.chains.find((o) => o.id === t.chainId) || n.chains[0];
22305    if (!r)
22306      throw new Error("The connector does not support any of the requested chains");
22307    const s = this.getConnection({
22308      address: t.address,
22309      connectorId: n.id,
22310      connections: this.connections,
22311      connectors: this.connectors
22312    });
22313    if (s?.account)
22314      return this.emit("accountChanged", {
22315        address: s.account.address,
22316        chainId: s.caipNetwork?.id,
22317        connector: n
22318      }), {
22319        id: n.id,
22320        type: n.type,
22321        address: s.account.address,
22322        chainId: r.id,
22323        provider: n
22324      };
22325    const i = await n.connect().catch((o) => {
22326      throw new Zn(o);
22327    });
22328    return this.emit("accountChanged", {
22329      address: i,
22330      chainId: r.id,
22331      connector: n
22332    }), this.addConnection({
22333      connectorId: n.id,
22334      accounts: [{ address: i, type: "eoa" }],
22335      caipNetwork: r
22336    }), n.id !== x.CONNECTOR_ID.WALLET_CONNECT && this.listenProviderEvents(n.id, n), {
22337      id: n.id,
22338      type: n.type,
22339      address: i,
22340      chainId: r.id,
22341      provider: n
22342    };
22343  }
22344  getActiveConnector() {
22345    return this.connector;
22346  }
22347  async getAccounts() {
22348    return Promise.resolve({
22349      accounts: []
22350    });
22351  }
22352  async signMessage(t) {
22353    const n = t.provider;
22354    if (!n)
22355      throw new Error("TronAdapter:signMessage - connector is undefined");
22356    return { signature: await n.signMessage({
22357      message: t.message,
22358      from: t.address
22359    }) };
22360  }
22361  async sendTransaction() {
22362    return Promise.resolve({ hash: "" });
22363  }
22364  async writeSolanaTransaction() {
22365    return Promise.resolve({ hash: "" });
22366  }
22367  async disconnect(t) {
22368    if (t?.id) {
22369      const n = this.connectors.find((s) => s.id === t.id);
22370      if (!n)
22371        throw new Error("TronAdapter:disconnect - connector not found");
22372      const r = this.getConnection({
22373        connectorId: n.id,
22374        connections: this.connections,
22375        connectors: this.connectors
22376      });
22377      try {
22378        await n.disconnect();
22379      } catch (s) {
22380        console.error("[TronAdapter] disconnect error:", s);
22381      }
22382      return this.removeProviderListeners(n.id), this.deleteConnection(n.id), this.connections.length === 0 ? this.emit("disconnect") : this.emitFirstAvailableConnection(), { connections: r ? [r] : [] };
22383    }
22384    return this.disconnectAll();
22385  }
22386  async disconnectAll() {
22387    return { connections: await Promise.all(this.connections.map(async (n) => {
22388      const r = this.connectors.find((s) => Jn.isLowerCaseMatch(s.id, n.connectorId));
22389      if (!r)
22390        throw new Error("Connector not found");
22391      return await this.disconnect({
22392        id: r.id
22393      }), n;
22394    })) };
22395  }
22396  async switchNetwork(t) {
22397    const n = Ds.getProviderId(t.caipNetwork.chainNamespace), r = Ds.getProvider(t.caipNetwork.chainNamespace);
22398    if (n === "WALLET_CONNECT" || n === "AUTH")
22399      return await super.switchNetwork(t);
22400    if (!r)
22401      throw new Error("Provider not found");
22402    await r.switchNetwork(t.caipNetwork.caipNetworkId);
22403    const s = this.getConnection({
22404      connectorId: r.id,
22405      connections: this.connections,
22406      connectors: this.connectors
22407    });
22408    if (!s?.accounts[0])
22409      return Promise.resolve();
22410    const i = s.accounts[0].address;
22411    return this.addConnection({
22412      connectorId: r.id,
22413      accounts: s.accounts,
22414      caipNetwork: t.caipNetwork
22415    }), v.setChainAccountData(t.caipNetwork.chainNamespace, {
22416      address: i,
22417      caipAddress: `${t.caipNetwork.caipNetworkId}:${i}`
22418    }), v.setActiveCaipNetwork(t.caipNetwork), this.emit("switchNetwork", {
22419      address: i,
22420      chainId: t.caipNetwork.id
22421    }), Promise.resolve();
22422  }
22423  async setUniversalProvider(t) {
22424    this.universalProvider = t;
22425    const n = x.CONNECTOR_ID.WALLET_CONNECT;
22426    return hn.listenWcProvider({
22427      universalProvider: t,
22428      namespace: x.CHAIN.TRON,
22429      onConnect: (r) => this.onConnect(r, n),
22430      onDisconnect: () => this.onDisconnect(n),
22431      onAccountsChanged: (r) => super.onAccountsChanged(r, n, !1)
22432    }), this.addConnector(new Zu({
22433      provider: t,
22434      chains: v.getCaipNetworks()
22435    })), Promise.resolve();
22436  }
22437  async getBalance(t) {
22438    const n = t.caipNetwork?.caipNetworkId, r = t.address;
22439    if (!r || !n)
22440      return { balance: "0", symbol: "TRX" };
22441    try {
22442      const i = (await ce.getAddressBalance({
22443        caipNetworkId: n,
22444        address: r,
22445        method: "tron_getAddressBalance",
22446        params: [{ address: r }]
22447      }))?.data?.[0]?.balance ?? 0;
22448      return { balance: Ic.bigNumber(i).div(10 ** 6).toString(), symbol: "TRX" };
22449    } catch (s) {
22450      return console.error("[TronAdapter] getBalance error:", s), { balance: "0", symbol: "TRX" };
22451    }
22452  }
22453  parseUnits() {
22454    return BigInt(0);
22455  }
22456  formatUnits() {
22457    return "";
22458  }
22459  async syncConnections({ connectToFirstConnector: t, caipNetwork: n }) {
22460    await Promise.all(this.connectors.filter((r) => {
22461      const { hasDisconnected: s, hasConnected: i } = Jn.getConnectorStorageInfo(r.id, this.namespace);
22462      return !s && i;
22463    }).map(async (r) => {
22464      if (r.id === x.CONNECTOR_ID.WALLET_CONNECT) {
22465        const s = hn.getWalletConnectAccounts(this.universalProvider, this.namespace);
22466        s.length > 0 && this.addConnection({
22467          connectorId: r.id,
22468          accounts: s.map((i) => ({ address: i.address })),
22469          caipNetwork: n
22470        });
22471      } else {
22472        const s = await r.connect({});
22473        s && (this.addConnection({
22474          connectorId: r.id,
22475          accounts: [{ address: s }],
22476          caipNetwork: n
22477        }), this.listenProviderEvents(r.id, r));
22478      }
22479    })), t && this.emitFirstAvailableConnection();
22480  }
22481  async syncConnection(t) {
22482    const n = this.connectors.find((r) => r.id === t.id);
22483    return n ? this.connect({
22484      id: n.id,
22485      chainId: t.chainId,
22486      type: n.type
22487    }) : { id: "", address: "", chainId: "", provider: void 0, type: "EXTERNAL" };
22488  }
22489  async estimateGas(t) {
22490    return Promise.resolve({ gas: BigInt(0) });
22491  }
22492  async writeContract(t) {
22493    return Promise.resolve({ hash: "" });
22494  }
22495  async grantPermissions(t) {
22496    return Promise.resolve({});
22497  }
22498  async getCapabilities(t) {
22499    return Promise.resolve({});
22500  }
22501  async revokePermissions(t) {
22502    return Promise.resolve("0x0000000000000000000000000000000000000000");
22503  }
22504  async walletGetAssets(t) {
22505    return Promise.resolve({});
22506  }
22507  getWalletConnectProvider(t) {
22508    return new Zu({
22509      provider: t.provider,
22510      chains: t.caipNetworks
22511    });
22512  }
22513}
22514function qt(e, t, n) {
22515  const r = e[t.name];
22516  if (typeof r == "function")
22517    return r;
22518  const s = e[n];
22519  return typeof s == "function" ? s : (i) => t(e, i);
22520}
22521const xi = "3.5.4", UE = () => `@wagmi/core@${xi}`;
22522var Mf = function(e, t, n, r) {
22523  if (n === "a" && !r) throw new TypeError("Private accessor was defined without a getter");
22524  if (typeof t == "function" ? e !== t || !r : !t.has(e)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
22525  return n === "m" ? r : n === "a" ? r.call(e) : r ? r.value : t.get(e);
22526}, so, Lf;
22527let Hn = class qa extends Error {
22528  get docsBaseUrl() {
22529    return "https://wagmi.sh/core";
22530  }
22531  get version() {
22532    return UE();
22533  }
22534  constructor(t, n = {}) {
22535    super(), so.add(this), Object.defineProperty(this, "details", {
22536      enumerable: !0,
22537      configurable: !0,
22538      writable: !0,
22539      value: void 0
22540    }), Object.defineProperty(this, "docsPath", {
22541      enumerable: !0,
22542      configurable: !0,
22543      writable: !0,
22544      value: void 0
22545    }), Object.defineProperty(this, "metaMessages", {
22546      enumerable: !0,
22547      configurable: !0,
22548      writable: !0,
22549      value: void 0
22550    }), Object.defineProperty(this, "shortMessage", {
22551      enumerable: !0,
22552      configurable: !0,
22553      writable: !0,
22554      value: void 0
22555    }), Object.defineProperty(this, "name", {
22556      enumerable: !0,
22557      configurable: !0,
22558      writable: !0,
22559      value: "WagmiCoreError"
22560    });
22561    const r = n.cause instanceof qa ? n.cause.details : n.cause?.message ? n.cause.message : n.details, s = n.cause instanceof qa && n.cause.docsPath || n.docsPath;
22562    this.message = [
22563      t || "An error occurred.",
22564      "",
22565      ...n.metaMessages ? [...n.metaMessages, ""] : [],
22566      ...s ? [
22567        `Docs: ${this.docsBaseUrl}${s}.html${n.docsSlug ? `#${n.docsSlug}` : ""}`
22568      ] : [],
22569      ...r ? [`Details: ${r}`] : [],
22570      `Version: ${this.version}`
22571    ].join(`
22572`), n.cause && (this.cause = n.cause), this.details = r, this.docsPath = s, this.metaMessages = n.metaMessages, this.shortMessage = t;
22573  }
22574  walk(t) {
22575    return Mf(this, so, "m", Lf).call(this, this, t);
22576  }
22577};
22578so = /* @__PURE__ */ new WeakSet(), Lf = function e(t, n) {
22579  return n?.(t) ? t : t.cause ? Mf(this, so, "m", e).call(this, t.cause, n) : t;
22580};
22581class Fs extends Hn {
22582  constructor() {
22583    super("Chain not configured."), Object.defineProperty(this, "name", {
22584      enumerable: !0,
22585      configurable: !0,
22586      writable: !0,
22587      value: "ChainNotConfiguredError"
22588    });
22589  }
22590}
22591class ME extends Hn {
22592  constructor() {
22593    super("Connector already connected."), Object.defineProperty(this, "name", {
22594      enumerable: !0,
22595      configurable: !0,
22596      writable: !0,
22597      value: "ConnectorAlreadyConnectedError"
22598    });
22599  }
22600}
22601class LE extends Hn {
22602  constructor() {
22603    super("Connector not connected."), Object.defineProperty(this, "name", {
22604      enumerable: !0,
22605      configurable: !0,
22606      writable: !0,
22607      value: "ConnectorNotConnectedError"
22608    });
22609  }
22610}
22611class BE extends Hn {
22612  constructor({ address: t, connector: n }) {
22613    super(`Account "${t}" not found for connector "${n.name}".`), Object.defineProperty(this, "name", {
22614      enumerable: !0,
22615      configurable: !0,
22616      writable: !0,
22617      value: "ConnectorAccountNotFoundError"
22618    });
22619  }
22620}
22621class DE extends Hn {
22622  constructor({ connectionChainId: t, connectorChainId: n }) {
22623    super(`The current chain of the connector (id: ${n}) does not match the connection's chain (id: ${t}).`, {
22624      metaMessages: [
22625        `Current Chain ID:  ${n}`,
22626        `Expected Chain ID: ${t}`
22627      ]
22628    }), Object.defineProperty(this, "name", {
22629      enumerable: !0,
22630      configurable: !0,
22631      writable: !0,
22632      value: "ConnectorChainMismatchError"
22633    });
22634  }
22635}
22636class FE extends Hn {
22637  constructor({ connector: t }) {
22638    super(`Connector "${t.name}" unavailable while reconnecting.`, {
22639      details: [
22640        "During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.",
22641        "All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.",
22642        "This error commonly occurs for connectors that asynchronously inject after reconnection has already started."
22643      ].join(" ")
22644    }), Object.defineProperty(this, "name", {
22645      enumerable: !0,
22646      configurable: !0,
22647      writable: !0,
22648      value: "ConnectorUnavailableReconnectingError"
22649    });
22650  }
22651}
22652async function sa(e, t) {
22653  let n;
22654  if (typeof t.connector == "function" ? n = e._internal.connectors.setup(t.connector) : n = t.connector, n.uid === e.state.current)
22655    throw new ME();
22656  try {
22657    e.setState((o) => ({ ...o, status: "connecting" })), n.emitter.emit("message", { type: "connecting" });
22658    const { connector: r, ...s } = t, i = await n.connect(s);
22659    return n.emitter.off("connect", e._internal.events.connect), n.emitter.on("change", e._internal.events.change), n.emitter.on("disconnect", e._internal.events.disconnect), await e.storage?.setItem("recentConnectorId", n.id), e.setState((o) => ({
22660      ...o,
22661      connections: new Map(o.connections).set(n.uid, {
22662        accounts: s.withCapabilities ? i.accounts.map((a) => typeof a == "object" ? a.address : a) : i.accounts,
22663        chainId: i.chainId,
22664        connector: n
22665      }),
22666      current: n.uid,
22667      status: "connected"
22668    })), {
22669      // TODO(v3): Remove `withCapabilities: true` default behavior so remove compat marshalling
22670      // Workaround so downstream connectors work with `withCapabilities` without any changes required
22671      accounts: s.withCapabilities ? i.accounts.map((o) => typeof o == "object" ? o : { address: o, capabilities: {} }) : i.accounts,
22672      chainId: i.chainId
22673    };
22674  } catch (r) {
22675    throw e.setState((s) => ({
22676      ...s,
22677      // Keep existing connector connected in case of error
22678      status: s.current ? "connected" : "disconnected"
22679    })), r;
22680  }
22681}
22682async function ei(e, t = {}) {
22683  const { assertChainId: n = !0 } = t;
22684  let r;
22685  if (t.connector) {
22686    const { connector: l } = t;
22687    if (e.state.status === "reconnecting" && !l.getAccounts && !l.getChainId)
22688      throw new FE({ connector: l });
22689    const [f, p] = await Promise.all([
22690      l.getAccounts().catch((m) => {
22691        if (t.account === null)
22692          return [];
22693        throw m;
22694      }),
22695      l.getChainId()
22696    ]);
22697    r = {
22698      accounts: f,
22699      chainId: p,
22700      connector: l
22701    };
22702  } else
22703    r = e.state.connections.get(e.state.current);
22704  if (!r)
22705    throw new LE();
22706  const s = t.chainId ?? r.chainId, i = await r.connector.getChainId();
22707  if (n && i !== s)
22708    throw new DE({
22709      connectionChainId: s,
22710      connectorChainId: i
22711    });
22712  const o = r.connector;
22713  if (o.getClient)
22714    return o.getClient({ chainId: s });
22715  const a = vt(t.account ?? r.accounts[0]);
22716  if (a && (a.address = Vn(a.address)), t.account && !r.accounts.some((l) => l.toLowerCase() === a.address.toLowerCase()))
22717    throw new BE({
22718      address: a.address,
22719      connector: o
22720    });
22721  const u = e.chains.find((l) => l.id === s), c = await r.connector.getProvider({ chainId: s });
22722  return nf({
22723    account: a,
22724    chain: u,
22725    name: "Connector Client",
22726    transport: (l) => ey(c)({ ...l, retryCount: 0 })
22727  });
22728}
22729async function tl(e, t = {}) {
22730  let n;
22731  if (t.connector)
22732    n = t.connector;
22733  else {
22734    const { connections: s, current: i } = e.state;
22735    n = s.get(i)?.connector;
22736  }
22737  const r = e.state.connections;
22738  n && (await n.disconnect(), n.emitter.off("change", e._internal.events.change), n.emitter.off("disconnect", e._internal.events.disconnect), n.emitter.on("connect", e._internal.events.connect), r.delete(n.uid)), e.setState((s) => {
22739    if (r.size === 0)
22740      return {
22741        ...s,
22742        connections: /* @__PURE__ */ new Map(),
22743        current: null,
22744        status: "disconnected"
22745      };
22746    const i = r.values().next().value;
22747    return {
22748      ...s,
22749      connections: new Map(r),
22750      current: i.connector.uid
22751    };
22752  });
22753  {
22754    const s = e.state.current;
22755    if (!s)
22756      return;
22757    const i = e.state.connections.get(s)?.connector;
22758    if (!i)
22759      return;
22760    await e.storage?.setItem("recentConnectorId", i.id);
22761  }
22762}
22763async function jE(e, t) {
22764  const { chainId: n, connector: r, ...s } = t;
22765  let i;
22766  t.account ? i = t.account : i = (await ei(e, {
22767    account: t.account,
22768    assertChainId: !1,
22769    chainId: n,
22770    connector: r
22771  })).account;
22772  const o = e.getClient({ chainId: n });
22773  return qt(o, Rd, "estimateGas")({ ...s, account: i });
22774}
22775async function WE(e, t) {
22776  const { address: n, blockNumber: r, blockTag: s, chainId: i } = t, o = e.getClient({ chainId: i }), u = await qt(o, jg, "getBalance")(r ? { address: n, blockNumber: r } : { address: n, blockTag: s }), c = e.chains.find((l) => l.id === i) ?? o.chain;
22777  return {
22778    decimals: c.nativeCurrency.decimals,
22779    symbol: c.nativeCurrency.symbol,
22780    value: u
22781  };
22782}
22783function js(e, t) {
22784  if (e === t)
22785    return !0;
22786  if (e && t && typeof e == "object" && typeof t == "object") {
22787    if (e.constructor !== t.constructor)
22788      return !1;
22789    let n, r;
22790    if (Array.isArray(e) && Array.isArray(t)) {
22791      if (n = e.length, n !== t.length)
22792        return !1;
22793      for (r = n; r-- !== 0; )
22794        if (!js(e[r], t[r]))
22795          return !1;
22796      return !0;
22797    }
22798    if (typeof e.valueOf == "function" && e.valueOf !== Object.prototype.valueOf)
22799      return e.valueOf() === t.valueOf();
22800    if (typeof e.toString == "function" && e.toString !== Object.prototype.toString)
22801      return e.toString() === t.toString();
22802    const s = Object.keys(e);
22803    if (n = s.length, n !== Object.keys(t).length)
22804      return !1;
22805    for (r = n; r-- !== 0; )
22806      if (!Object.hasOwn(t, s[r]))
22807        return !1;
22808    for (r = n; r-- !== 0; ) {
22809      const i = s[r];
22810      if (i && !js(e[i], t[i]))
22811        return !1;
22812    }
22813    return !0;
22814  }
22815  return e !== e && t !== t;
22816}
22817function Oi(e) {
22818  const t = e.state.current, n = e.state.connections.get(t), r = n?.accounts, s = r?.[0], i = e.chains.find((a) => a.id === n?.chainId), o = e.state.status;
22819  switch (o) {
22820    case "connected":
22821      return {
22822        address: s,
22823        addresses: r,
22824        chain: i,
22825        chainId: n?.chainId,
22826        connector: n?.connector,
22827        isConnected: !0,
22828        isConnecting: !1,
22829        isDisconnected: !1,
22830        isReconnecting: !1,
22831        status: o
22832      };
22833    case "reconnecting":
22834      return {
22835        address: s,
22836        addresses: r,
22837        chain: i,
22838        chainId: n?.chainId,
22839        connector: n?.connector,
22840        isConnected: !!s,
22841        isConnecting: !1,
22842        isDisconnected: !1,
22843        isReconnecting: !0,
22844        status: o
22845      };
22846    case "connecting":
22847      return {
22848        address: s,
22849        addresses: r,
22850        chain: i,
22851        chainId: n?.chainId,
22852        connector: n?.connector,
22853        isConnected: !1,
22854        isConnecting: !0,
22855        isDisconnected: !1,
22856        isReconnecting: !1,
22857        status: o
22858      };
22859    case "disconnected":
22860      return {
22861        address: void 0,
22862        addresses: void 0,
22863        chain: void 0,
22864        chainId: void 0,
22865        connector: void 0,
22866        isConnected: !1,
22867        isConnecting: !1,
22868        isDisconnected: !0,
22869        isReconnecting: !1,
22870        status: o
22871      };
22872  }
22873}
22874let Ai = [];
22875function rn(e) {
22876  const t = [...e.state.connections.values()];
22877  return e.state.status === "reconnecting" || js(Ai, t) ? Ai : (Ai = t, t);
22878}
22879async function $E(e, t) {
22880  const { account: n, chainId: r, connector: s, ...i } = t;
22881  let o;
22882  return typeof n == "object" && n?.type === "local" ? o = e.getClient({ chainId: r }) : o = await ei(e, {
22883    account: n ?? void 0,
22884    assertChainId: !1,
22885    chainId: r,
22886    connector: s
22887  }), qt(o, wc, "prepareTransactionRequest")({
22888    ...i,
22889    ...n ? { account: n } : {}
22890  });
22891}
22892let ia = !1;
22893async function Pi(e, t = {}) {
22894  if (ia)
22895    return [];
22896  ia = !0, e.setState((c) => ({
22897    ...c,
22898    status: c.current ? "reconnecting" : "connecting"
22899  }));
22900  const n = [];
22901  if (t.connectors?.length)
22902    for (const c of t.connectors) {
22903      let l;
22904      typeof c == "function" ? l = e._internal.connectors.setup(c) : l = c, n.push(l);
22905    }
22906  else
22907    n.push(...e.connectors);
22908  let r;
22909  try {
22910    r = await e.storage?.getItem("recentConnectorId");
22911  } catch {
22912  }
22913  const s = {};
22914  for (const [, c] of e.state.connections)
22915    s[c.connector.id] = 1;
22916  r && (s[r] = 0);
22917  const i = Object.keys(s).length > 0 ? (
22918    // .toSorted()
22919    [...n].sort((c, l) => (s[c.id] ?? 10) - (s[l.id] ?? 10))
22920  ) : n;
22921  let o = !1;
22922  const a = [], u = [];
22923  for (const c of i) {
22924    const l = await c.getProvider().catch(() => {
22925    });
22926    if (!l || u.some((m) => m === l) || !await c.isAuthorized())
22927      continue;
22928    const p = await c.connect({ isReconnecting: !0 }).catch(() => null);
22929    p && (c.emitter.off("connect", e._internal.events.connect), c.emitter.on("change", e._internal.events.change), c.emitter.on("disconnect", e._internal.events.disconnect), e.setState((m) => {
22930      const y = new Map(o ? m.connections : /* @__PURE__ */ new Map()).set(c.uid, { accounts: p.accounts, chainId: p.chainId, connector: c });
22931      return {
22932        ...m,
22933        current: o ? m.current : c.uid,
22934        connections: y
22935      };
22936    }), a.push({
22937      accounts: p.accounts,
22938      chainId: p.chainId,
22939      connector: c
22940    }), u.push(l), o = !0);
22941  }
22942  return (e.state.status === "reconnecting" || e.state.status === "connecting") && (o ? e.setState((c) => ({ ...c, status: "connected" })) : e.setState((c) => ({
22943    ...c,
22944    connections: /* @__PURE__ */ new Map(),
22945    current: null,
22946    status: "disconnected"
22947  }))), ia = !1, a;
22948}
22949async function HE(e, t) {
22950  const { account: n, chainId: r, connector: s, ...i } = t;
22951  let o;
22952  typeof n == "object" && n?.type === "local" ? o = e.getClient({ chainId: r }) : o = await ei(e, {
22953    account: n ?? void 0,
22954    assertChainId: !1,
22955    chainId: r,
22956    connector: s
22957  });
22958  const a = !r || o.chain?.id === r ? o.chain : { id: r };
22959  return await qt(o, Xd, "sendTransaction")({
22960    ...i,
22961    ...n ? { account: n } : {},
22962    assertChainId: !!r,
22963    chain: a,
22964    gas: i.gas ?? void 0
22965  });
22966}
22967async function qE(e, t) {
22968  const { account: n, connector: r, ...s } = t;
22969  let i;
22970  return typeof n == "object" && n.type === "local" ? i = e.getClient() : i = await ei(e, { account: n, connector: r }), qt(i, Xg, "signMessage")({
22971    ...s,
22972    ...n ? { account: n } : {}
22973  });
22974}
22975class _n extends Hn {
22976  constructor() {
22977    super("Provider not found."), Object.defineProperty(this, "name", {
22978      enumerable: !0,
22979      configurable: !0,
22980      writable: !0,
22981      value: "ProviderNotFoundError"
22982    });
22983  }
22984}
22985class GE extends Hn {
22986  constructor({ connector: t }) {
22987    super(`"${t.name}" does not support programmatic chain switching.`), Object.defineProperty(this, "name", {
22988      enumerable: !0,
22989      configurable: !0,
22990      writable: !0,
22991      value: "SwitchChainNotSupportedError"
22992    });
22993  }
22994}
22995async function nl(e, t) {
22996  const { addEthereumChainParameter: n, chainId: r } = t, s = e.state.connections.get(t.connector?.uid ?? e.state.current);
22997  if (s) {
22998    const o = s.connector;
22999    if (!o.switchChain)
23000      throw new GE({ connector: o });
23001    return await o.switchChain({
23002      addEthereumChainParameter: n,
23003      chainId: r
23004    });
23005  }
23006  const i = e.chains.find((o) => o.id === r);
23007  if (!i)
23008    throw new Fs();
23009  return e.setState((o) => ({ ...o, chainId: r })), i;
23010}
23011async function zE(e, t) {
23012  const { chainId: n, timeout: r = 0, ...s } = t, i = e.getClient({ chainId: n }), a = await qt(i, Qg, "waitForTransactionReceipt")({ ...s, timeout: r });
23013  if (a.status === "reverted") {
23014    const u = qt(i, of, "getTransaction"), { from: c, ...l } = await u({
23015      hash: a.transactionHash
23016    }), p = await qt(i, Zd, "call")({
23017      ...l,
23018      account: c,
23019      data: l.input,
23020      gasPrice: l.type !== "eip1559" ? l.gasPrice : void 0,
23021      maxFeePerGas: l.type === "eip1559" ? l.maxFeePerGas : void 0,
23022      maxPriorityFeePerGas: l.type === "eip1559" ? l.maxPriorityFeePerGas : void 0
23023    }), m = p?.data ? $l(`0x${p.data.substring(138)}`) : "unknown reason";
23024    throw new Error(m);
23025  }
23026  return {
23027    ...a,
23028    chainId: i.chain.id
23029  };
23030}
23031function VE(e, t) {
23032  const { onChange: n } = t;
23033  return e.subscribe(() => Oi(e), n, {
23034    equalityFn(r, s) {
23035      const { connector: i, ...o }
23035 = r, { connector: a, ...u } = s;
23036      return js(o, u) && // check connector separately
23037      i?.id === a?.id && i?.uid === a?.uid;
23038    }
23039  });
23040}
23041function KE(e, t) {
23042  const { onChange: n } = t;
23043  return e.subscribe(() => rn(e), n, {
23044    equalityFn: js
23045  });
23046}
23047function YE(e, t) {
23048  const { onChange: n } = t;
23049  return e._internal.connectors.subscribe((r, s) => {
23050    n(Object.values(r), s);
23051  });
23052}
23053function ZE(e, t) {
23054  const { syncConnectedChain: n = e._internal.syncConnectedChain, ...r } = t;
23055  let s;
23056  const i = (u) => {
23057    s && s();
23058    const c = e.getClient({ chainId: u });
23059    return s = qt(c, Jg, "watchPendingTransactions")(r), s;
23060  }, o = i(t.chainId);
23061  let a;
23062  return n && !t.chainId && (a = e.subscribe(({ chainId: u }) => u, async (u) => i(u))), () => {
23063    o?.(), a?.();
23064  };
23065}
23066async function QE(e, t) {
23067  const { account: n, chainId: r, connector: s, ...i } = t;
23068  let o;
23069  typeof n == "object" && n?.type === "local" ? o = e.getClient({ chainId: r }) : o = await ei(e, {
23070    account: n ?? void 0,
23071    assertChainId: !1,
23072    chainId: r,
23073    connector: s
23074  });
23075  const a = !r || o.chain?.id === r ? o.chain : { id: r };
23076  return await qt(o, Hi, "writeContract")({
23077    ...i,
23078    ...n ? { account: n } : {},
23079    assertChainId: !!r,
23080    chain: a
23081  });
23082}
23083function Z_(e) {
23084  return e;
23085}
23086Ao.type = "injected";
23087function Ao(e = {}) {
23088  const { shimDisconnect: t = !0, unstable_shimAsyncInject: n } = e;
23089  function r() {
23090    const u = e.target;
23091    if (typeof u == "function") {
23092      const c = u();
23093      if (c)
23094        return c;
23095    }
23096    return typeof u == "object" ? u : typeof u == "string" ? {
23097      ...JE[u] ?? {
23098        id: u,
23099        name: `${u[0].toUpperCase()}${u.slice(1)}`,
23100        provider: `is${u[0].toUpperCase()}${u.slice(1)}`
23101      }
23102    } : {
23103      id: "injected",
23104      name: "Injected",
23105      provider(c) {
23106        return c?.ethereum;
23107      }
23108    };
23109  }
23110  let s, i, o, a;
23111  return (u) => ({
23112    get icon() {
23113      return r().icon;
23114    },
23115    get id() {
23116      return r().id;
23117    },
23118    get name() {
23119      return r().name;
23120    },
23121    type: Ao.type,
23122    async setup() {
23123      const c = await this.getProvider();
23124      c?.on && e.target && (o || (o = this.onConnect.bind(this), c.on("connect", o)), s || (s = this.onAccountsChanged.bind(this), c.on("accountsChanged", s)));
23125    },
23126    async connect({ chainId: c, isReconnecting: l, withCapabilities: f } = {}) {
23127      const p = await this.getProvider();
23128      if (!p)
23129        throw new _n();
23130      let m = [];
23131      if (l)
23132        m = await this.getAccounts().catch(() => []);
23133      else if (t)
23134        try {
23135          m = (await p.request({
23136            method: "wallet_requestPermissions",
23137            params: [{ eth_accounts: {} }]
23138          }))[0]?.caveats?.[0]?.value?.map((b) => Vn(b)), m.length > 0 && (m = await this.getAccounts());
23139        } catch (y) {
23140          const b = y;
23141          if (b.code === Ke.code)
23142            throw new Ke(b);
23143          if (b.code === Pn.code)
23144            throw b;
23145        }
23146      try {
23147        !m?.length && !l && (m = (await p.request({
23148          method: "eth_requestAccounts"
23149        })).map((C) => Vn(C))), o && (p.removeListener("connect", o), o = void 0), s || (s = this.onAccountsChanged.bind(this), p.on("accountsChanged", s)), i || (i = this.onChainChanged.bind(this), p.on("chainChanged", i)), a || (a = this.onDisconnect.bind(this), p.on("disconnect", a));
23150        let y = await this.getChainId();
23151        return c && y !== c && (y = (await this.switchChain({ chainId: c }).catch((C) => {
23152          if (C.code === Ke.code)
23153            throw C;
23154          return { id: y };
23155        }))?.id ?? y), t && await u.storage?.removeItem(`${this.id}.disconnected`), e.target || await u.storage?.setItem("injected.connected", !0), {
23156          accounts: f ? m.map((b) => ({ address: b, capabilities: {} })) : m,
23157          chainId: y
23158        };
23159      } catch (y) {
23160        const b = y;
23161        throw b.code === Ke.code ? new Ke(b) : b.code === Pn.code ? new Pn(b) : b;
23162      }
23163    },
23164    async disconnect() {
23165      const c = await this.getProvider();
23166      if (!c)
23167        throw new _n();
23168      i && (c.removeListener("chainChanged", i), i = void 0), a && (c.removeListener("disconnect", a), a = void 0), o || (o = this.onConnect.bind(this), c.on("connect", o));
23169      try {
23170        await sf(() => (
23171          // TODO: Remove explicit type for viem@3
23172          c.request({
23173            // `'wallet_revokePermissions'` added in `[email protected]`
23174            method: "wallet_revokePermissions",
23175            params: [{ eth_accounts: {} }]
23176          })
23177        ), { timeout: 100 });
23178      } catch {
23179      }
23180      t && await u.storage?.setItem(`${this.id}.disconnected`, !0), e.target || await u.storage?.removeItem("injected.connected");
23181    },
23182    async getAccounts() {
23183      const c = await this.getProvider();
23184      if (!c)
23185        throw new _n();
23186      return (await c.request({ method: "eth_accounts" })).map((f) => Vn(f));
23187    },
23188    async getChainId() {
23189      const c = await this.getProvider();
23190      if (!c)
23191        throw new _n();
23192      const l = await c.request({ method: "eth_chainId" });
23193      return Number(l);
23194    },
23195    async getProvider() {
23196      if (typeof window > "u")
23197        return;
23198      let c;
23199      const l = r();
23200      return typeof l.provider == "function" ? c = l.provider(window) : typeof l.provider == "string" ? c = ki(window, l.provider) : c = l.provider, c && !c.removeListener && ("off" in c && typeof c.off == "function" ? c.removeListener = c.off : c.removeListener = () => {
23201      }), c;
23202    },
23203    async isAuthorized() {
23204      try {
23205        if (t && // If shim exists in storage, connector is disconnected
23206        await u.storage?.getItem(`${this.id}.disconnected`) || !e.target && !await u.storage?.getItem("injected.connected"))
23207          return !1;
23208        if (!await this.getProvider()) {
23209          if (n !== void 0 && n !== !1) {
23210            const p = async () => (typeof window < "u" && window.removeEventListener("ethereum#initialized", p), !!await this.getProvider()), m = typeof n == "number" ? n : 1e3;
23211            if (await Promise.race([
23212              ...typeof window < "u" ? [
23213                new Promise((b) => window.addEventListener("ethereum#initialized", () => b(p()), { once: !0 }))
23214              ] : [],
23215              new Promise((b) => setTimeout(() => b(p()), m))
23216            ]))
23217              return !0;
23218          }
23219          throw new _n();
23220        }
23221        return !!(await qi(() => this.getAccounts())).length;
23222      } catch {
23223        return !1;
23224      }
23225    },
23226    async switchChain({ addEthereumChainParameter: c, chainId: l }) {
23227      const f = await this.getProvider();
23228      if (!f)
23229        throw new _n();
23230      const p = u.chains.find((y) => y.id === l);
23231      if (!p)
23232        throw new zt(new Fs());
23233      const m = new Promise((y) => {
23234        const b = ((C) => {
23235          "chainId" in C && C.chainId === l && (u.emitter.off("change", b), y());
23236        });
23237        u.emitter.on("change", b);
23238      });
23239      try {
23240        return await Promise.all([
23241          f.request({
23242            method: "wallet_switchEthereumChain",
23243            params: [{ chainId: be(l) }]
23244          }).then(async () => {
23245            await this.getChainId() === l && u.emitter.emit("change", { chainId: l });
23246          }),
23247          m
23248        ]), p;
23249      } catch (y) {
23250        const b = y;
23251        if (b.code === 4902 || // Unwrapping for MetaMask Mobile
23252        // https://github.com/MetaMask/metamask-mobile/issues/2944#issuecomment-976988719
23253        b?.data?.originalError?.code === 4902)
23254          try {
23255            const { default: C, ..._ } = p.blockExplorers ?? {};
23256            let R;
23257            c?.blockExplorerUrls ? R = c.blockExplorerUrls : C && (R = [
23258              C.url,
23259              ...Object.values(_).map((E) => E.url)
23260            ]);
23261            let N;
23262            c?.rpcUrls?.length ? N = c.rpcUrls : N = [p.rpcUrls.default?.http[0] ?? ""];
23263            const I = {
23264              blockExplorerUrls: R,
23265              chainId: be(l),
23266              chainName: c?.chainName ?? p.name,
23267              iconUrls: c?.iconUrls,
23268              nativeCurrency: c?.nativeCurrency ?? p.nativeCurrency,
23269              rpcUrls: N
23270            };
23271            return await Promise.all([
23272              f.request({
23273                method: "wallet_addEthereumChain",
23274                params: [I]
23275              }).then(async () => {
23276                if (await this.getChainId() === l)
23277                  u.emitter.emit("change", { chainId: l });
23278                else
23279                  throw new Ke(new Error("User rejected switch after adding network."));
23280              }),
23281              m
23282            ]), p;
23283          } catch (C) {
23284            throw new Ke(C);
23285          }
23286        throw b.code === Ke.code ? new Ke(b) : new zt(b);
23287      }
23288    },
23289    async onAccountsChanged(c) {
23290      if (c.length === 0)
23291        this.onDisconnect();
23292      else if (u.emitter.listenerCount("connect")) {
23293        const l = (await this.getChainId()).toString();
23294        this.onConnect({ chainId: l }), t && await u.storage?.removeItem(`${this.id}.disconnected`);
23295      } else
23296        u.emitter.emit("change", {
23297          accounts: c.map((l) => Vn(l))
23298        });
23299    },
23300    onChainChanged(c) {
23301      const l = Number(c);
23302      u.emitter.emit("change", { chainId: l });
23303    },
23304    async onConnect(c) {
23305      const l = await this.getAccounts();
23306      if (l.length === 0)
23307        return;
23308      const f = Number(c.chainId);
23309      u.emitter.emit("connect", { accounts: l, chainId: f });
23310      const p = await this.getProvider();
23311      p && (o && (p.removeListener("connect", o), o = void 0), s || (s = this.onAccountsChanged.bind(this), p.on("accountsChanged", s)), i || (i = this.onChainChanged.bind(this), p.on("chainChanged", i)), a || (a = this.onDisconnect.bind(this), p.on("disconnect", a)));
23312    },
23313    async onDisconnect(c) {
23314      const l = await this.getProvider();
23315      c && c.code === 1013 && l && (await this.getAccounts()).length || (u.emitter.emit("disconnect"), l && (i && (l.removeListener("chainChanged", i), i = void 0), a && (l.removeListener("disconnect", a), a = void 0), o || (o = this.onConnect.bind(this), l.on("connect", o))));
23316    }
23317  });
23318}
23319const JE = {
23320  coinbaseWallet: {
23321    id: "coinbaseWallet",
23322    name: "Coinbase Wallet",
23323    provider(e) {
23324      return e?.coinbaseWalletExtension ? e.coinbaseWalletExtension : ki(e, "isCoinbaseWallet");
23325    }
23326  },
23327  metaMask: {
23328    id: "metaMask",
23329    name: "MetaMask",
23330    provider(e) {
23331      return ki(e, (t) => {
23332        if (!t.isMetaMask || t.isBraveWallet && !t._events && !t._state)
23333          return !1;
23334        const n = [
23335          "isApexWallet",
23336          "isAvalanche",
23337          "isBitKeep",
23338          "isBlockWallet",
23339          "isKuCoinWallet",
23340          "isMathWallet",
23341          "isOkxWallet",
23342          "isOKExWallet",
23343          "isOneInchIOSWallet",
23344          "isOneInchAndroidWallet",
23345          "isOpera",
23346          "isPhantom",
23347          "isPortal",
23348          "isRabby",
23349          "isTokenPocket",
23350          "isTokenary",
23351          "isUniswapWallet",
23352          "isZerion"
23353        ];
23354        for (const r of n)
23355          if (t[r])
23356            return !1;
23357        return !0;
23358      });
23359    }
23360  },
23361  phantom: {
23362    id: "phantom",
23363    name: "Phantom",
23364    provider(e) {
23365      return e?.phantom?.ethereum ? e.phantom?.ethereum : ki(e, "isPhantom");
23366    }
23367  }
23368};
23369function ki(e, t) {
23370  function n(s) {
23371    return typeof t == "function" ? t(s) : typeof t == "string" ? s[t] : !0;
23372  }
23373  const r = e.ethereum;
23374  if (r?.providers)
23375    return r.providers.find((s) => n(s));
23376  if (r && n(r))
23377    return r;
23378}
23379function XE(e) {
23380  if (typeof window > "u")
23381    return;
23382  const t = (n) => e(n.detail);
23383  return window.addEventListener("eip6963:announceProvider", t), window.dispatchEvent(new CustomEvent("eip6963:requestProvider")), () => window.removeEventListener("eip6963:announceProvider", t);
23384}
23385function eA() {
23386  const e = /* @__PURE__ */ new Set();
23387  let t = [];
23388  const n = () => XE((s) => {
23389    t.some(({ info: i }) => i.uuid === s.info.uuid) || (t = [...t, s], e.forEach((i) => i(t, { added: [s] })));
23390  });
23391  let r = n();
23392  return {
23393    _listeners() {
23394      return e;
23395    },
23396    clear() {
23397      e.forEach((s) => s([], { removed: [...t] })), t = [];
23398    },
23399    destroy() {
23400      this.clear(), e.clear(), r?.();
23401    },
23402    findProvider({ rdns: s }) {
23403      return t.find((i) => i.info.rdns === s);
23404    },
23405    getProviders() {
23406      return t;
23407    },
23408    reset() {
23409      this.clear(), r?.(), r = n();
23410    },
23411    subscribe(s, { emitImmediately: i } = {}) {
23412      return e.add(s), i && s(t, { added: t }), () => e.delete(s);
23413    }
23414  };
23415}
23416const tA = (e) => (t, n, r) => {
23417  const s = r.subscribe;
23418  return r.subscribe = (o, a, u) => {
23419    let c = o;
23420    if (a) {
23421      const l = u?.equalityFn || Object.is;
23422      let f = o(r.getState());
23423      c = (p) => {
23424        const m = o(p);
23425        if (!l(f, m)) {
23426          const y = f;
23427          a(f = m, y);
23428        }
23429      }, u?.fireImmediately && a(f, f);
23430    }
23431    return s(c);
23432  }, e(t, n, r);
23433}, nA = tA;
23434function rA(e, t) {
23435  let n;
23436  try {
23437    n = e();
23438  } catch {
23439    return;
23440  }
23441  return {
23442    getItem: (s) => {
23443      var i;
23444      const o = (u) => u === null ? null : JSON.parse(u, void 0), a = (i = n.getItem(s)) != null ? i : null;
23445      return a instanceof Promise ? a.then(o) : o(a);
23446    },
23447    setItem: (s, i) => n.setItem(
23448      s,
23449      JSON.stringify(i, void 0)
23450    ),
23451    removeItem: (s) => n.removeItem(s)
23452  };
23453}
23454const Ga = (e) => (t) => {
23455  try {
23456    const n = e(t);
23457    return n instanceof Promise ? n : {
23458      then(r) {
23459        return Ga(r)(n);
23460      },
23461      catch(r) {
23462        return this;
23463      }
23464    };
23465  } catch (n) {
23466    return {
23467      then(r) {
23468        return this;
23469      },
23470      catch(r) {
23471        return Ga(r)(n);
23472      }
23473    };
23474  }
23475}, sA = (e, t) => (n, r, s) => {
23476  let i = {
23477    storage: rA(() => localStorage),
23478    partialize: (b) => b,
23479    version: 0,
23480    merge: (b, C) => ({
23481      ...C,
23482      ...b
23483    }),
23484    ...t
23485  }, o = !1;
23486  const a = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
23487  let c = i.storage;
23488  if (!c)
23489    return e(
23490      (...b) => {
23491        console.warn(
23492          `[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`
23493        ), n(...b);
23494      },
23495      r,
23496      s
23497    );
23498  const l = () => {
23499    const b = i.partialize({ ...r() });
23500    return c.setItem(i.name, {
23501      state: b,
23502      version: i.version
23503    });
23504  }, f = s.setState;
23505  s.setState = (b, C) => {
23506    f(b, C), l();
23507  };
23508  const p = e(
23509    (...b) => {
23510      n(...b), l();
23511    },
23512    r,
23513    s
23514  );
23515  s.getInitialState = () => p;
23516  let m;
23517  const y = () => {
23518    var b, C;
23519    if (!c) return;
23520    o = !1, a.forEach((R) => {
23521      var N;
23522      return R((N = r()) != null ? N : p);
23523    });
23524    const _ = ((C = i.onRehydrateStorage) == null ? void 0 : C.call(i, (b = r()) != null ? b : p)) || void 0;
23525    return Ga(c.getItem.bind(c))(i.name).then((R) => {
23526      if (R)
23527        if (typeof R.version == "number" && R.version !== i.version) {
23528          if (i.migrate)
23529            return [
23530              !0,
23531              i.migrate(
23532                R.state,
23533                R.version
23534              )
23535            ];
23536          console.error(
23537            "State loaded from storage couldn't be migrated since no migrate function was provided"
23538          );
23539        } else
23540          return [!1, R.state];
23541      return [!1, void 0];
23542    }).then((R) => {
23543      var N;
23544      const [I, E] = R;
23545      if (m = i.merge(
23546        E,
23547        (N = r()) != null ? N : p
23548      ), n(m, !0), I)
23549        return l();
23550    }).then(() => {
23551      _?.(m, void 0), m = r(), o = !0, u.forEach((R) => R(m));
23552    }).catch((R) => {
23553      _?.(void 0, R);
23554    });
23555  };
23556  return s.persist = {
23557    setOptions: (b) => {
23558      i = {
23559        ...i,
23560        ...b
23561      }, b.storage && (c = b.storage);
23562    },
23563    clearStorage: () => {
23564      c?.removeItem(i.name);
23565    },
23566    getOptions: () => i,
23567    rehydrate: () => y(),
23568    hasHydrated: () => o,
23569    onHydrate: (b) => (a.add(b), () => {
23570      a.delete(b);
23571    }),
23572    onFinishHydration: (b) => (u.add(b), () => {
23573      u.delete(b);
23574    })
23575  }, i.skipHydration || y(), m || p;
23576}, iA = sA, rl = (e) => {
23577  let t;
23578  const n = /* @__PURE__ */ new Set(), r = (c, l) => {
23579    const f = typeof c == "function" ? c(t) : c;
23580    if (!Object.is(f, t)) {
23581      const p = t;
23582      t = l ?? (typeof f != "object" || f === null) ? f : Object.assign({}, t, f), n.forEach((m) => m(t, p));
23583    }
23584  }, s = () => t, a = { setState: r, getState: s, getInitialState: () => u, subscribe: (c) => (n.add(c), () => n.delete(c)) }, u = t = e(r, s, a);
23585  return a;
23586}, oa = (e) => e ? rl(e) : rl;
23587class oA {
23588  constructor(t) {
23589    Object.defineProperty(this, "uid", {
23590      enumerable: !0,
23591      configurable: !0,
23592      writable: !0,
23593      value: t
23594    }), Object.defineProperty(this, "_emitter", {
23595      enumerable: !0,
23596      configurable: !0,
23597      writable: !0,
23598      value: new bb()
23599    });
23600  }
23601  on(t, n) {
23602    this._emitter.on(t, n);
23603  }
23604  once(t, n) {
23605    this._emitter.once(t, n);
23606  }
23607  off(t, n) {
23608    this._emitter.off(t, n);
23609  }
23610  emit(t, ...n) {
23611    const r = n[0];
23612    this._emitter.emit(t, { uid: this.uid, ...r });
23613  }
23614  listenerCount(t) {
23615    return this._emitter.listenerCount(t);
23616  }
23617}
23618function aA(e) {
23619  return new oA(e);
23620}
23621function cA(e, t) {
23622  return JSON.parse(e, (n, r) => {
23623    let s = r;
23624    return s?.__type === "bigint" && (s = BigInt(s.value)), s?.__type === "Map" && (s = new Map(s.value)), t?.(n, s) ?? s;
23625  });
23626}
23627function sl(e, t) {
23628  return e.slice(0, t).join(".") || ".";
23629}
23630function il(e, t) {
23631  const { length: n } = e;
23632  for (let r = 0; r < n; ++r)
23633    if (e[r] === t)
23634      return r + 1;
23635  return 0;
23636}
23637function uA(e, t) {
23638  const n = typeof e == "function", r = typeof t == "function", s = [], i = [];
23639  return function(a, u) {
23640    if (typeof u == "object")
23641      if (s.length) {
23642        const c = il(s, this);
23643        c === 0 ? s[s.length] = this : (s.splice(c), i.splice(c)), i[i.length] = a;
23644        const l = il(s, u);
23645        if (l !== 0)
23646          return r ? t.call(this, a, u, sl(i, l)) : `[ref=${sl(i, l)}]`;
23647      } else
23648        s[0] = u, i[0] = a;
23649    return n ? e.call(this, a, u) : u;
23650  };
23651}
23652function lA(e, t, n, r) {
23653  return JSON.stringify(e, uA((s, i) => {
23654    let o = i;
23655    return typeof o == "bigint" && (o = { __type: "bigint", value: i.toString() }), o instanceof Map && (o = { __type: "Map", value: Array.from(i.entries()) }), t?.(s, o) ?? o;
23656  }, r), n ?? void 0);
23657}
23658function dA(e) {
23659  const { deserialize: t = cA, key: n = "wagmi", serialize: r = lA, storage: s = Bf } = e;
23660  function i(o) {
23661    return o instanceof Promise ? o.then((a) => a).catch(() => null) : o;
23662  }
23663  return {
23664    ...s,
23665    key: n,
23666    async getItem(o, a) {
23667      const u = s.getItem(`${n}.${o}`), c = await i(u);
23668      return c ? t(c) ?? null : a ?? null;
23669    },
23670    async setItem(o, a) {
23671      const u = `${n}.${o}`;
23672      a === null ? await i(s.removeItem(u)) : await i(s.setItem(u, r(a)));
23673    },
23674    async removeItem(o) {
23675      await i(s.removeItem(`${n}.${o}`));
23676    }
23677  };
23678}
23679const Bf = {
23680  getItem: () => null,
23681  setItem: () => {
23682  },
23683  removeItem: () => {
23684  }
23685};
23686function fA() {
23687  const e = typeof window < "u" && window.localStorage ? window.localStorage : Bf;
23688  return {
23689    getItem(t) {
23690      return e.getItem(t);
23691    },
23692    removeItem(t) {
23693      e.removeItem(t);
23694    },
23695    setItem(t, n) {
23696      try {
23697        e.setItem(t, n);
23698      } catch {
23699      }
23700    }
23701  };
23702}
23703const za = 256;
23704let vi = za, _i;
23705function hA(e = 11) {
23706  if (!_i || vi + e > za * 2) {
23707    _i = "", vi = 0;
23708    for (let t = 0; t < za; t++)
23709      _i += (256 + Math.random() * 256 | 0).toString(16).substring(1);
23710  }
23711  return _i.substring(vi, vi++ + e);
23712}
23713function pA(e) {
23714  const { multiInjectedProviderDiscovery: t = !0, storage: n = dA({
23715    storage: fA()
23716  }), syncConnectedChain: r = !0, ssr: s = !1, ...i } = e, o = typeof window < "u" && t ? eA() : void 0, a = oa(() => i.chains), u = oa(() => {
23717    const E = [], T = /* @__PURE__ */ new Set();
23718    for (const O of i.connectors ?? []) {
23719      const U = c(O);
23720      if (E.push(U), !s && U.rdns) {
23721        const M = typeof U.rdns == "string" ? [U.rdns] : U.rdns;
23722        for (const L of M)
23723          T.add(L);
23724      }
23725    }
23726    if (!s && o) {
23727      const O = o.getProviders();
23728      for (const U of O)
23729        T.has(U.info.rdns) || E.push(c(l(U)));
23730    }
23731    return E;
23732  });
23733  function c(E) {
23734    const T = aA(hA());
23735    let O;
23736    const U = {
23737      ...E({
23738        emitter: T,
23739        chains: a.getState(),
23740        get providers() {
23741          if (!o || !O)
23742            return [];
23743          const M = typeof O == "string" ? [O] : O, L = o.getProviders();
23744          return M.flatMap((re) => L.filter((ne) => ne.info.rdns === re));
23745        },
23746        storage: n,
23747        transports: i.transports
23748      }),
23749      emitter: T,
23750      uid: T.uid
23751    };
23752    return O = U.rdns, T.on("connect", N), U.setup?.(), U;
23753  }
23754  function l(E) {
23755    const { info: T } = E, O = E.provider;
23756    return Ao({ target: { ...T, id: T.rdns, provider: O } });
23757  }
23758  const f = /* @__PURE__ */ new Map();
23759  function p(E = {}) {
23760    const T = E.chainId ?? C.getState().chainId, O = a.getState().find((M) => M.id === T);
23761    if (E.chainId && !O)
23762      throw new Fs();
23763    {
23764      const M = f.get(C.getState().chainId);
23765      if (M && !O)
23766        return M;
23767      if (!O)
23768        throw new Fs();
23769    }
23770    {
23771      const M = f.get(T);
23772      if (M)
23773        return M;
23774    }
23775    let U;
23776    if (i.client)
23777      U = i.client({ chain: O });
23778    else {
23779      const M = O.id, L = a.getState().map((fe) => fe.id), re = {}, ne = Object.entries(i);
23780      for (const [fe, ae] of ne)
23781        if (!(fe === "chains" || fe === "client" || fe === "connectors" || fe === "transports"))
23782          if (typeof ae == "object")
23783            if (M in ae)
23784              re[fe] = ae[M];
23785            else {
23786              if (L.some((D) => D in ae))
23787                continue;
23788              re[fe] = ae;
23789            }
23790          else
23791            re[fe] = ae;
23792      U = nf({
23793        ...re,
23794        chain: O,
23795        batch: re.batch ?? { multicall: !0 },
23796        transport: (fe) => i.transports[M]({ ...fe, connectors: u })
23797      });
23798    }
23799    return f.set(T, U), U;
23800  }
23801  function m() {
23802    return {
23803      chainId: a.getState()[0].id,
23804      connections: /* @__PURE__ */ new Map(),
23805      current: null,
23806      status: "disconnected"
23807    };
23808  }
23809  let y;
23810  const b = "0.0.0-canary-";
23811  xi.startsWith(b) ? y = Number.parseInt(xi.replace(b, ""), 10) : y = Number.parseInt(xi.split(".")[0] ?? "0", 10);
23812  const C = oa(nA(
23813    // only use persist middleware if storage exists
23814    n ? iA(m, {
23815      migrate(E, T) {
23816        if (T === y)
23817          return E;
23818        const O = m(), U = _(E, O.chainId);
23819        return { ...O, chainId: U };
23820      },
23821      name: "store",
23822      partialize(E) {
23823        return {
23824          connections: {
23825            __type: "Map",
23826            value: Array.from(E.connections.entries()).map(([T, O]) => {
23827              const { id: U, name: M, type: L, uid: re } = O.connector;
23828              return [T, { ...O, connector: { id: U, name: M, type: L, uid: re } }];
23829            })
23830          },
23831          chainId: E.chainId,
23832          current: E.current
23833        };
23834      },
23835      merge(E, T) {
23836        typeof E == "object" && E && "status" in E && delete E.status;
23837        const O = _(E, T.chainId);
23838        return {
23839          ...T,
23840          ...E,
23841          chainId: O
23842        };
23843      },
23844      skipHydration: s,
23845      storage: n,
23846      version: y
23847    }) : m
23848  ));
23849  C.setState(m());
23850  function _(E, T) {
23851    return E && typeof E == "object" && "chainId" in E && typeof E.chainId == "number" && a.getState().some((O) => O.id === E.chainId) ? E.chainId : T;
23852  }
23853  r && C.subscribe(({ connections: E, current: T }) => T ? E.get(T)?.chainId : void 0, (E) => {
23854    if (a.getState().some((O) => O.id === E))
23855      return C.setState((O) => ({
23856        ...O,
23857        chainId: E ?? O.chainId
23858      }));
23859  }), o?.subscribe((E) => {
23860    const T = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Set();
23861    for (const M of u.getState())
23862      if (T.add(M.id), M.rdns) {
23863        const L = typeof M.rdns == "string" ? [M.rdns] : M.rdns;
23864        for (const re of L)
23865          O.add(re);
23866      }
23867    const U = [];
23868    for (const M of E) {
23869      if (O.has(M.info.rdns))
23870        continue;
23871      const L = c(l(M));
23872      T.has(L.id) || U.push(L);
23873    }
23874    n && !C.persist.hasHydrated() || u.setState((M) => [...M, ...U], !0);
23875  });
23876  function R(E) {
23877    C.setState((T) => {
23878      const O = T.connections.get(E.uid);
23879      return O ? {
23880        ...T,
23881        connections: new Map(T.connections).set(E.uid, {
23882          accounts: E.accounts ?? O.accounts,
23883          chainId: E.chainId ?? O.chainId,
23884          connector: O.connector
23885        })
23886      } : T;
23887    });
23888  }
23889  function N(E) {
23890    C.getState().status === "connecting" || C.getState().status === "reconnecting" || C.setState((T) => {
23891      const O = u.getState().find((U) => U.uid === E.uid);
23892      return O ? (O.emitter.listenerCount("connect") && O.emitter.off("connect", R), O.emitter.listenerCount("change") || O.emitter.on("change", R), O.emitter.listenerCount("disconnect") || O.emitter.on("disconnect", I), {
23893        ...T,
23894        connections: new Map(T.connections).set(E.uid, {
23895          accounts: E.accounts,
23896          chainId: E.chainId,
23897          connector: O
23898        }),
23899        current: E.uid,
23900        status: "connected"
23901      }) : T;
23902    });
23903  }
23904  function I(E) {
23905    C.setState((T) => {
23906      const O = T.connections.get(E.uid);
23907      if (O) {
23908        const M = O.connector;
23909        M.emitter.listenerCount("change") && O.connector.emitter.off("change", R), M.emitter.listenerCount("disconnect") && O.connector.emitter.off("disconnect", I), M.emitter.listenerCount("connect") || O.connector.emitter.on("connect", N);
23910      }
23911      if (T.connections.delete(E.uid), T.connections.size === 0)
23912        return {
23913          ...T,
23914          connections: /* @__PURE__ */ new Map(),
23915          current: null,
23916          status: "disconnected"
23917        };
23918      const U = T.connections.values().next().value;
23919      return {
23920        ...T,
23921        connections: new Map(T.connections),
23922        current: U.connector.uid
23923      };
23924    });
23925  }
23926  return {
23927    get chains() {
23928      return a.getState();
23929    },
23930    get connectors() {
23931      return u.getState();
23932    },
23933    storage: n,
23934    getClient: p,
23935    get state() {
23936      return C.getState();
23937    },
23938    setState(E) {
23939      let T;
23940      typeof E == "function" ? T = E(C.getState()) : T = E;
23941      const O = m();
23942      typeof T != "object" && (T = O), Object.keys(O).some((M) => !(M in T)) && (T = O), C.setState(T, !0);
23943    },
23944    subscribe(E, T, O) {
23945      return C.subscribe(E, T, O ? {
23946        ...O,
23947        fireImmediately: O.emitImmediately
23948        // Workaround cast since Zustand does not support `'exactOptionalPropertyTypes'`
23949      } : void 0);
23950    },
23951    _internal: {
23952      mipd: o,
23953      async revalidate() {
23954        const E = C.getState(), T = E.connections;
23955        let O = E.current;
23956        for (const [, U] of T) {
23957          const M = U.connector;
23958          M.isAuthorized && await M.isAuthorized() || (T.delete(M.uid), O === M.uid && (O = null));
23959        }
23960        C.setState((U) => ({ ...U, connections: T, current: O }));
23961      },
23962      store: C,
23963      ssr: !!s,
23964      syncConnectedChain: r,
23965      transports: i.transports,
23966      chains: {
23967        setState(E) {
23968          const T = typeof E == "function" ? E(a.getState()) : E;
23969          if (T.length !== 0)
23970            return a.setState(T, !0);
23971        },
23972        subscribe(E) {
23973          return a.subscribe(E);
23974        }
23975      },
23976      connectors: {
23977        providerDetailToConnector: l,
23978        setup: c,
23979        setState(E) {
23980          return u.setState(typeof E == "function" ? E(u.getState()) : E, !0);
23981        },
23982        subscribe(E) {
23983          return u.subscribe(E);
23984        }
23985      },
23986      events: { change: R, connect: N, disconnect: I }
23987    }
23988  };
23989}
23990function mA(e, t) {
23991  const { initialState: n, reconnectOnMount: r }
23991 = t;
23992  return n && !e._internal.store.persist.hasHydrated() && e.setState({
23993    ...n,
23994    chainId: e.chains.some((s) => s.id === n.chainId) ? n.chainId : e.chains[0].id,
23995    connections: r ? n.connections : /* @__PURE__ */ new Map(),
23996    status: r ? "reconnecting" : "disconnected"
23997  }), {
23998    async onMount() {
23999      e._internal.ssr && (await e._internal.store.persist.rehydrate(), e._internal.mipd && e._internal.connectors.setState((s) => {
24000        const i = /* @__PURE__ */ new Set();
24001        for (const u of s ?? [])
24002          if (u.rdns) {
24003            const c = Array.isArray(u.rdns) ? u.rdns : [u.rdns];
24004            for (const l of c)
24005              i.add(l);
24006          }
24007        const o = [], a = e._internal.mipd?.getProviders() ?? [];
24008        for (const u of a) {
24009          if (i.has(u.info.rdns))
24010            continue;
24011          const c = e._internal.connectors.providerDetailToConnector(u), l = e._internal.connectors.setup(c);
24012          o.push(l);
24013        }
24014        return [...s, ...o];
24015      })), r ? Pi(e) : e.storage && e.setState((s) => ({
24016        ...s,
24017        connections: /* @__PURE__ */ new Map()
24018      }));
24019    }
24020  };
24021}
24022class xr {
24023  // eslint-disable-next-line @typescript-eslint/no-empty-function -- This is a singleton
24024  constructor() {
24025  }
24026  static getInstance({ projectId: t, chainId: n, enableLogger: r, onTimeout: s, abortController: i, getActiveCaipNetwork: o, getCaipNetworks: a }) {
24027    const { metadata: u, sdkVersion: c, sdkType: l } = z.getSnapshot();
24028    return xr.instance || (xr.instance = new SC({
24029      projectId: t,
24030      chainId: n,
24031      enableLogger: r,
24032      onTimeout: s,
24033      abortController: i,
24034      getActiveCaipNetwork: o,
24035      getCaipNetworks: a,
24036      enableCloudAuthAccount: !!z.state.remoteFeatures?.emailCapture,
24037      metadata: u,
24038      sdkVersion: c,
24039      sdkType: l
24040    })), xr.instance;
24041  }
24042}
24043function gA(e) {
24044  let t = [], n, r;
24045  function s(a) {
24046    const u = v.getCaipNetworks(x.CHAIN.EVM);
24047    let c = Number(Gi.parseEvmChainId(a));
24048    if (!u.some((l) => String(l.id) === String(a))) {
24049      const l = v.getActiveCaipNetwork(x.CHAIN.EVM)?.id || u[0]?.id;
24050      l && Number.isInteger(Number(l)) && (c = Number(l));
24051    }
24052    if (!c)
24053      throw new Error("ChainId not found in networks");
24054    return c;
24055  }
24056  function i() {
24057    return n || (n = xr.getInstance({
24058      projectId: e.options.projectId,
24059      chainId: Rn()?.caipNetworkId,
24060      enableLogger: e.options.enableAuthLogger,
24061      onTimeout: (a) => {
24062        a === "iframe_load_failed" ? Ar.open(vn.ALERT_ERRORS.IFRAME_LOAD_FAILED, "error") : a === "iframe_request_timeout" ? Ar.open(vn.ALERT_ERRORS.IFRAME_REQUEST_TIMEOUT, "error") : a === "unverified_domain" && Ar.open(vn.ALERT_ERRORS.UNVERIFIED_DOMAIN, "error");
24063      },
24064      abortController: vn.EmbeddedWalletAbortController,
24065      getActiveCaipNetwork: (a) => Rn(a),
24066      getCaipNetworks: (a) => v.getCaipNetworks(a)
24067    })), n;
24068  }
24069  async function o(a = {}) {
24070    const u = i();
24071    let c = a.chainId;
24072    if (a.isReconnecting) {
24073      const b = Gi.parseEvmChainId(u.getLastUsedChainId() || ""), C = e.chains?.[0].id;
24074      if (c = b || C, !c)
24075        throw new Error("ChainId not found in provider");
24076    }
24077    const l = Et("eip155"), { address: f, chainId: p, accounts: m } = await sn.authConnectorAuthenticate({
24078      authConnector: u,
24079      chainId: c,
24080      preferredAccountType: l,
24081      socialUri: a.socialUri,
24082      chainNamespace: x.CHAIN.EVM
24083    });
24084    t = m?.map((b) => b.address) || [f];
24085    const y = s(p);
24086    return {
24087      accounts: t,
24088      account: f,
24089      chainId: y,
24090      chain: {
24091        id: y,
24092        unsupported: !1
24093      }
24094    };
24095  }
24096  return (a) => ({
24097    id: x.CONNECTOR_ID.AUTH,
24098    name: x.CONNECTOR_NAMES.AUTH,
24099    type: "AUTH",
24100    chain: x.CHAIN.EVM,
24101    async connect(u = {}) {
24102      if (r) {
24103        const l = await r;
24104        return {
24105          accounts: u.withCapabilities ? l.accounts.map((f) => ({ address: f, capabilities: {} })) : l.accounts,
24106          chainId: l.chainId
24107        };
24108      }
24109      r || (r = new Promise((l) => {
24110        l(o(u));
24111      }));
24112      const c = await r;
24113      return r = void 0, {
24114        accounts: u.withCapabilities ? c.accounts.map((l) => ({ address: l, capabilities: {} })) : c.accounts,
24115        chainId: c.chainId
24116      };
24117    },
24118    async disconnect() {
24119      await (await this.getProvider()).disconnect();
24120    },
24121    getAccounts() {
24122      return t?.length ? (a.emitter.emit("change", { accounts: t }), Promise.resolve(t)) : Promise.resolve([]);
24123    },
24124    async getProvider() {
24125      return this.provider || (this.provider = xr.getInstance({
24126        projectId: e.options.projectId,
24127        chainId: Rn()?.caipNetworkId,
24128        enableLogger: e.options.enableAuthLogger,
24129        abortController: vn.EmbeddedWalletAbortController,
24130        onTimeout: (u) => {
24131          u === "iframe_load_failed" ? Ar.open(vn.ALERT_ERRORS.IFRAME_LOAD_FAILED, "error") : u === "iframe_request_timeout" ? Ar.open(vn.ALERT_ERRORS.IFRAME_REQUEST_TIMEOUT, "error") : u === "unverified_domain" && Ar.open(vn.ALERT_ERRORS.UNVERIFIED_DOMAIN, "error");
24132        },
24133        getActiveCaipNetwork: (u) => Rn(u),
24134        getCaipNetworks: (u) => v.getCaipNetworks(u)
24135      })), Promise.resolve(this.provider);
24136    },
24137    async getChainId() {
24138      const u = await this.getProvider(), { chainId: c } = await u.getChainId();
24139      return s(c);
24140    },
24141    async isAuthorized() {
24142      const c = v.state.activeChain === x.CHAIN.EVM;
24143      if (x.AUTH_CONNECTOR_SUPPORTED_CHAINS.some((p) => H.getConnectorId(p) === x.CONNECTOR_ID.AUTH) && !c)
24144        return !1;
24145      const f = await this.getProvider();
24146      return Promise.resolve(f.getLoginEmailUsed());
24147    },
24148    async switchChain({ chainId: u }) {
24149      try {
24150        const c = a.chains.find((m) => m.id === u);
24151        if (!c)
24152          throw new zt(new Error("chain not found on connector."));
24153        const l = await this.getProvider(), f = Et("eip155"), p = await l.connect({
24154          chainId: u,
24155          preferredAccountType: f
24156        });
24157        return t = p?.accounts?.map((m) => m.address) || [p.address], a.emitter.emit("change", {
24158          chainId: Number(u),
24159          accounts: t
24160        }), c;
24161      } catch (c) {
24162        throw c instanceof Error ? new zt(c) : c;
24163      }
24164    },
24165    onAccountsChanged(u) {
24166      u.length === 0 ? this.onDisconnect() : a.emitter.emit("change", { accounts: u.map(Vn) });
24167    },
24168    onChainChanged(u) {
24169      const c = Number(u);
24170      a.emitter.emit("change", { chainId: c });
24171    },
24172    async onDisconnect(u) {
24173      await (await this.getProvider()).disconnect();
24174    }
24175  });
24176}
24177Pc.type = "walletConnect";
24178function Pc(e) {
24179  const t = e.isNewChainsStale ?? !0;
24180  let n, r, s, i, o, a, u;
24181  return (c) => ({
24182    id: "walletConnect",
24183    name: "WalletConnect",
24184    type: Pc.type,
24185    provider: e.universalProvider,
24186    async setup() {
24187      const l = await this.getProvider().catch(() => null);
24188      l && (i || (i = this.onConnect.bind(this), l.on("connect", i)), a || (a = this.onSessionDelete.bind(this), l.on("session_delete", a)));
24189    },
24190    async connect({ ...l } = {}) {
24191      try {
24192        const f = v.getCaipNetworks(), p = await this.getProvider();
24193        if (!p)
24194          throw new _n();
24195        o || (o = this.onDisplayUri, p.on("display_uri", o));
24196        const m = await this.isChainsStale();
24197        p.session && m && await p.disconnect();
24198        const y = z.state.universalProviderConfigOverride;
24199        if (!p.session || m) {
24200          const E = hn.createNamespaces(f, y);
24201          await p.connect({
24202            optionalNamespaces: E,
24203            ..."pairingTopic" in l ? { pairingTopic: l.pairingTopic } : {}
24204          }), this.setRequestedChainsIds(f.map((T) => Number(T.id)));
24205        }
24206        const b = await this.getAccounts(), C = await this.getChainId(), _ = p.session?.namespaces?.eip155?.chains, R = _?.some((E) => Number(E.split(":")[1]) === C);
24207        let N = 1;
24208        R ? N = C : _?.[0] && (N = Number(_[0].split(":")[1])), o && (p.removeListener("display_uri", o), o = void 0), i && (p.removeListener("connect", i), i = void 0), r || (r = this.onAccountsChanged.bind(this), p.on("accountsChanged", r)), s || (s = this.onChainChanged.bind(this), p.on("chainChanged", s)), u || (u = this.onDisconnect.bind(this), p.on("disconnect", u)), a || (a = this.onSessionDelete.bind(this), p.on("session_delete", a));
24209        const I = y?.defaultChain;
24210        return p.setDefaultChain(I ?? `eip155:${N}`), {
24211          accounts: b,
24212          chainId: N
24213        };
24214      } catch (f) {
24215        throw /(user rejected|connection request reset)/i.test(f?.message) ? new Ke(f) : f;
24216      }
24217    },
24218    async disconnect() {
24219      const l = await this.getProvider();
24220      try {
24221        await l?.disconnect();
24222      } catch (f) {
24223        if (!/No matching key/i.test(f.message))
24224          throw f;
24225      } finally {
24226        s && (l?.removeListener("chainChanged", s), s = void 0), u && (l?.removeListener("disconnect", u), u = void 0), i || (i = this.onConnect.bind(this), l?.on("connect", i)), r && (l?.removeListener("accountsChanged", r), r = void 0), a && (l?.removeListener("session_delete", a), a = void 0), this.setRequestedChainsIds([]);
24227      }
24228    },
24229    async getAccounts() {
24230      const l = await this.getProvider();
24231      if (!l?.session?.namespaces)
24232        return [];
24233      const p = l?.session?.namespaces[x.CHAIN.EVM]?.accounts?.map((b) => b.split(":")[2]) ?? [], m = /* @__PURE__ */ new Set();
24234      return p.filter((b) => {
24235        const C = b?.toLowerCase();
24236        return m.has(C) ? !1 : (m.add(C), !0);
24237      });
24238    },
24239    async getProvider({ chainId: l } = {}) {
24240      n || (n = e.universalProvider, n?.events.setMaxListeners(Number.POSITIVE_INFINITY));
24241      const f = W.getActiveNamespace(), p = v.getActiveCaipNetwork()?.id;
24242      if (l && p !== l && f) {
24243        const m = W.getStoredActiveCaipNetworkId(), b = (f ? v.getCaipNetworks(f) : [])?.find((C) => C.id === m);
24244        b && b.chainNamespace === x.CHAIN.EVM && await this.switchChain?.({ chainId: Number(b.id) });
24245      }
24246      return n;
24247    },
24248    async getChainId() {
24249      const l = v.getActiveCaipNetwork(x.CHAIN.EVM)?.id;
24250      if (l)
24251        return l;
24252      const p = (await this.getProvider()).session?.namespaces[x.CHAIN.EVM]?.chains?.[0];
24253      return v.getCaipNetworks().find((y) => y.id === p)?.id;
24254    },
24255    async isAuthorized() {
24256      try {
24257        const [l, f] = await Promise.all([this.getAccounts(), this.getProvider()]);
24258        return l.length ? await this.isChainsStale() && f.session ? (await f.disconnect().catch(() => {
24259        }), !1) : !0 : !1;
24260      } catch {
24261        return !1;
24262      }
24263    },
24264    async switchChain({ addEthereumChainParameter: l, chainId: f }) {
24265      const p = await this.getProvider();
24266      if (!p)
24267        throw new _n();
24268      const m = v.getCaipNetworks().find((y) => y.id === f);
24269      if (!m)
24270        throw new zt(new Fs());
24271      try {
24272        await p.request({
24273          method: "wallet_switchEthereumChain",
24274          params: [{ chainId: be(f) }]
24275        }), m?.caipNetworkId && p.setDefaultChain(m?.caipNetworkId), c.emitter.emit("change", { chainId: Number(f) });
24276        const y = await this.getRequestedChainsIds();
24277        return this.setRequestedChainsIds([...y, f]), { ...m, id: m.id };
24278      } catch (y) {
24279        const b = y;
24280        if (/(?:user rejected)/iu.test(b.message))
24281          throw new Ke(b);
24282        try {
24283          let C;
24284          l?.blockExplorerUrls ? C = l.blockExplorerUrls : C = m.blockExplorers?.default.url ? [m.blockExplorers?.default.url] : [];
24285          const _ = m.rpcUrls?.chainDefault?.http || [], R = {
24286            blockExplorerUrls: C,
24287            chainId: be(f),
24288            chainName: m.name,
24289            iconUrls: l?.iconUrls,
24290            nativeCurrency: m.nativeCurrency,
24291            rpcUrls: _
24292          };
24293          await p.request({
24294            method: "wallet_addEthereumChain",
24295            params: [R]
24296          });
24297          const N = await this.getRequestedChainsIds();
24298          return this.setRequestedChainsIds([...N, f]), { ...m, id: m.id };
24299        } catch (C) {
24300          throw new Ke(C);
24301        }
24302      }
24303    },
24304    onAccountsChanged(l) {
24305      l.length === 0 ? this.onDisconnect() : c.emitter.emit("change", {
24306        accounts: l.map((f) => Vn(f))
24307      });
24308    },
24309    onChainChanged(l) {
24310      const f = Number(l);
24311      c.emitter.emit("change", { chainId: f });
24312    },
24313    onConnect(l) {
24314      this.setRequestedChainsIds(v.getCaipNetworks().map((f) => Number(f.id)));
24315    },
24316    async onDisconnect(l) {
24317      this.setRequestedChainsIds([]), c.emitter.emit("disconnect");
24318      const f = await this.getProvider();
24319      r && (f.removeListener("accountsChanged", r), r = void 0), s && (f.removeListener("chainChanged", s), s = void 0), u && (f.removeListener("disconnect", u), u = void 0), a && (f.removeListener("session_delete", a), a = void 0), i || (i = this.onConnect.bind(this), f.on("connect", i));
24320    },
24321    onDisplayUri(l) {
24322      c.emitter.emit("message", { type: "display_uri", data: l });
24323    },
24324    onSessionDelete() {
24325      this.onDisconnect();
24326    },
24327    getNamespaceChainsIds() {
24328      return n?.session?.namespaces ? n?.session?.namespaces[x.CHAIN.EVM]?.accounts?.map((p) => Number.parseInt(p.split(":")[1] ?? "")) ?? [] : [];
24329    },
24330    async getRequestedChainsIds() {
24331      const l = await c.storage?.getItem(this.requestedChainsStorageKey) ?? [];
24332      return [...new Set(l)];
24333    },
24334    async isChainsStale() {
24335      if (!t)
24336        return !1;
24337      const l = c.chains.map((m) => m.id), f = this.getNamespaceChainsIds();
24338      if (f.length && !f.some((m) => l.includes(m)))
24339        return !1;
24340      const p = await this.getRequestedChainsIds();
24341      return !l.every((m) => p.includes(Number(m)));
24342    },
24343    async setRequestedChainsIds(l) {
24344      await c.storage?.setItem(this.requestedChainsStorageKey, l);
24345    },
24346    get requestedChainsStorageKey() {
24347      return `${this.id}.requestedChains`;
24348    }
24349  });
24350}
24351const Qr = Me({
24352  pendingTransactions: 0
24353}), ol = {
24354  state: Qr,
24355  subscribeKey(e, t) {
24356    return Je(Qr, e, t);
24357  },
24358  increase(e) {
24359    Qr[e] += 1;
24360  },
24361  decrease(e) {
24362    Qr[e] -= 1;
24363  },
24364  reset(e) {
24365    Qr[e] = 0;
24366  }
24367};
24368async function yA(e) {
24369  if (q.isSafeApp()) {
24370    const { safe: t } = await import("./index-Ojy1Lcmv.js");
24371    if (t && !e.some((n) => n.type === "safe"))
24372      return t();
24373  }
24374  return null;
24375}
24376async function bA(e) {
24377  try {
24378    const { baseAccount: t } = await import("./index-Ojy1Lcmv.js");
24379    if (t && !e.some((n) => n.id === "baseAccount"))
24380      return t();
24381  } catch (t) {
24382    console.error("Failed to import Base Account SDK:", t);
24383  }
24384  return null;
24385}
24386async function wA(e) {
24387  try {
24388    const { coinbaseWallet: t } = await import("./index-Ojy1Lcmv.js");
24389    if (t && !e.some((n) => n.id === "coinbaseWallet"))
24390      return t();
24391  } catch (t) {
24392    console.error("Failed to import Coinbase Wallet SDK:", t);
24393  }
24394  return null;
24395}
24396const CA = {
24397  enable: !1,
24398  pollingInterval: 3e4
24399};
24400class EA extends Of {
24401  constructor(t) {
24402    const n = xn.extendCaipNetworks(t.networks, {
24403      projectId: t.projectId,
24404      customNetworkImageUrls: {},
24405      customRpcUrls: t.customRpcUrls
24406    });
24407    super(), this.balancePromises = {}, this.namespace = x.CHAIN.EVM, this.adapterType = x.ADAPTER_TYPES.WAGMI, this.projectId = t.projectId, this.pendingTransactionsFilter = {
24408      ...CA,
24409      ...t.pendingTransactionsFilter ?? {}
24410    }, this.createConfig({ ...t, networks: n }), this.checkChainId();
24411  }
24412  construct(t) {
24413    this.checkChainId(), this.setupWatchers();
24414  }
24415  async getAccounts(t) {
24416    const n = this.getWagmiConnector(t.id);
24417    if (!n)
24418      return { accounts: [] };
24419    if (n.id === x.CONNECTOR_ID.AUTH) {
24420      const o = await n.getProvider();
24421      if (!o?.user)
24422        return { accounts: [] };
24423      const { address: a, accounts: u, chainId: c } = o.user;
24424      return Promise.resolve({
24425        accounts: (u || [{ address: a, type: "eoa" }]).map((l) => q.createAccount({
24426          caipAddress: `eip155:${c}:${l.address}`,
24427          type: l.type
24428        }))
24429      });
24430    }
24431    const { addresses: r, address: s, chainId: i } = Oi(this.wagmiConfig);
24432    return Promise.resolve({
24433      accounts: i ? [...new Set(r || [s])].map((o) => q.createAccount({
24434        caipAddress: `eip155:${i}:${o || ""}`,
24435        type: "eoa"
24436      })) : []
24437    });
24438  }
24439  checkChainId() {
24440    const { chainId: t } = Oi(this.wagmiConfig);
24441    t && this.emit("switchNetwork", {
24442      chainId: t
24443    });
24444  }
24445  getWagmiConnector(t) {
24446    return this.wagmiConfig.connectors.find((n) => n.id === t);
24447  }
24448  createConfig(t) {
24449    this.wagmiChains = t.networks.filter((s) => s.chainNamespace === x.CHAIN.EVM);
24450    const n = {}, r = [...t.connectors ?? []];
24451    this.wagmiChains.forEach((s) => {
24452      const i = t.transports?.[s.id], o = xn.getCaipNetworkId(s);
24453      i ? n[s.id] = xn.extendWagmiTransports(s, t.projectId, i) : n[s.id] = xn.getViemTransport(s, t.projectId, t.customRpcUrls?.[o]);
24454    }), this.wagmiConfig = pA({
24455      ...t,
24456      chains: this.wagmiChains,
24457      connectors: r,
24458      transports: n
24459    });
24460  }
24461  setupWatchPendingTransactions() {
24462    if (!this.pendingTransactionsFilter.enable || this.unwatchPendingTransactions)
24463      return;
24464    this.unwatchPendingTransactions = ZE(this.wagmiConfig, {
24465      pollingInterval: this.pendingTransactionsFilter.pollingInterval,
24466      onError: () => {
24467      },
24468      onTransactions: () => {
24469        this.emit("pendingTransactions"), ol.increase("pendingTransactions");
24470      }
24471    });
24472    const t = ol.subscribeKey("pendingTransactions", (n) => {
24473      n >= x.LIMITS.PENDING_TRANSACTIONS && (this.unwatchPendingTransactions?.(), t());
24474    });
24475  }
24476  setupWatchers() {
24477    KE(this.wagmiConfig, {
24478      onChange: (t) => {
24479        this.clearConnections(), this.addConnection(...t.map((n) => {
24480          const r = this.getCaipNetworks().find((i) => i.id === n.chainId), s = n.connector.id === x.CONNECTOR_ID.AUTH;
24481          return {
24482            accounts: n.accounts.map((i) => ({
24483              address: this.toChecksummedAddress(i)
24484            })),
24485            caipNetwork: r,
24486            connectorId: n.connector.id,
24487            auth: s ? {
24488              name: W.getConnectedSocialProvider(),
24489              username: W.getConnectedSocialUsername()
24490            } : void 0
24491          };
24492        }));
24493      }
24494    }), VE(this.wagmiConfig, {
24495      onChange: (t, n) => {
24496        if (t.status === "disconnected" && n.address && this.emit("disconnect"), t?.chainId && t?.chainId !== n?.chainId && this.emit("switchNetwork", {
24497          chainId: t.chainId
24498        }), t.status === "connected") {
24499          const r = t.address !== n?.address, s = t.connector.id !== n.connector?.id, i = n.status !== "connected";
24500          (r || s || i) && (this.setupWatchPendingTransactions(), this.handleAccountChanged({
24501            address: t.address,
24502            chainId: t.chainId,
24503            connector: t.connector
24504          }));
24505        }
24506      }
24507    });
24508  }
24509  async addThirdPartyConnectors() {
24510    const t = [], { enableCoinbase: n, enableBaseAccount: r } = z.state || {};
24511    if (r !== !1) {
24512      const i = await bA(this.wagmiConfig.connectors);
24513      i && t.push(i);
24514    }
24515    if (n !== !1) {
24516      const i = await wA(this.wagmiConfig.connectors);
24517      i && t.push(i);
24518    }
24519    const s = await yA(this.wagmiConfig.connectors);
24520    s && t.push(s), await Promise.all(t.map((i) => {
24521      const o = this.configureInternalConnector(i);
24522      return this.addWagmiConnector(o);
24523    }));
24524  }
24525  addWagmiConnectors() {
24526    const t = [];
24527    z.state.enableInjected !== !1 && t.push(Ao({ shimDisconnect: !0 }));
24528    const { features: n, remoteFeatures: r, projectId: s, enableAuthLogger: i } = z.state, o = r?.email ?? n?.email ?? !0, a = r?.socials ?? n?.socials, u = Array.isArray(a) && a?.length > 0;
24529    (o || u) && t.push(gA({
24530      chains: this.wagmiChains,
24531      options: { projectId: s, enableAuthLogger: i }
24532    })), t.forEach((c) => {
24533      this.configureInternalConnector(c);
24534    });
24535  }
24536  configureInternalConnector(t) {
24537    const n = this.wagmiConfig._internal.connectors.setup(t);
24538    return this.wagmiConfig._internal.connectors.setState((r) => [...r, n]), n;
24539  }
24540  async handleAccountChanged({ address: t, chainId: n, connector: r }) {
24541    if (!this.namespace)
24542      throw new Error("WagmiAdapter:handleAccountChanged - namespace is required");
24543    const s = await r.getProvider().catch(() => {
24544    });
24545    this.emit("accountChanged", {
24546      address: this.toChecksummedAddress(t),
24547      chainId: n,
24548      connector: {
24549        id: r.id,
24550        name: it.ConnectorNamesMap[r.id] ?? r.name,
24551        imageId: it.ConnectorImageIds[r.id],
24552        type: it.ConnectorTypesMap[r.type] ?? "EXTERNAL",
24553        info: r.id === x.CONNECTOR_ID.INJECTED ? void 0 : { rdns: r.id },
24554        provider: s,
24555        chain: this.namespace,
24556        chains: []
24557      }
24558    });
24559  }
24560  async writeSolanaTransaction() {
24561    return Promise.resolve({ hash: "" });
24562  }
24563  async signMessage(t) {
24564    try {
24565      return { signature: await qE(this.wagmiConfig, {
24566        message: t.message,
24567        account: t.address
24568      }) };
24569    } catch {
24570      throw new Error("WagmiAdapter:signMessage - Sign message failed");
24571    }
24572  }
24573  async sendTransaction(t) {
24574    const { chainId: n, address: r } = Oi(this.wagmiConfig), s = this.wagmiChains?.find((a) => a.id === n), i = {
24575      account: r,
24576      to: t.to,
24577      value: Number.isNaN(Number(t.value)) ? BigInt(0) : BigInt(t.value),
24578      gas: t.gas ? BigInt(t.gas) : void 0,
24579      gasPrice: t.gasPrice ? BigInt(t.gasPrice) : void 0,
24580      data: t.data,
24581      chain: s,
24582      type: "legacy",
24583      parameters: ["nonce"]
24584    };
24585    await $E(this.wagmiConfig, i);
24586    const o = await HE(this.wagmiConfig, i);
24587    return await zE(this.wagmiConfig, { hash: o, timeout: 25e3 }), { hash: o };
24588  }
24589  async writeContract(t) {
24590    const { caipNetwork: n, ...r } = t, s = Number(Gi.caipNetworkIdToNumber(n.caipNetworkId)), i = this.wagmiChains?.find((a) => a.id === s);
24591    return { hash: await QE(this.wagmiConfig, {
24592      chain: i,
24593      address: r.tokenAddress,
24594      account: r.fromAddress,
24595      abi: r.abi,
24596      functionName: r.method,
24597      args: r.args,
24598      __mode: "prepared"
24599    }) };
24600  }
24601  async estimateGas(t) {
24602    try {
24603      return { gas: await jE(this.wagmiConfig, {
24604        account: t.address,
24605        to: t.to,
24606        data: t.data,
24607        type: "legacy"
24608      }) };
24609    } catch {
24610      throw new Error("WagmiAdapter:estimateGas - error estimating gas");
24611    }
24612  }
24613  parseUnits(t) {
24614    return Yg(t.value, t.decimals);
24615  }
24616  formatUnits(t) {
24617    return zs(t.value, t.decimals);
24618  }
24619  async addWagmiConnector(t) {
24620    if (!this.namespace)
24621      throw new Error("WagmiAdapter:addWagmiConnector - namespace is required");
24622    const { enableEIP6963: n, enableInjected: r } = z.state || {}, s = t.type === x.CONNECTOR_ID.INJECTED, i = t.id === x.CONNECTOR_ID.INJECTED, o = s && !i;
24623    if (i && r === !1 || o && n === !1 || t.id === x.CONNECTOR_ID.AUTH || t.id === x.CONNECTOR_ID.WALLET_CONNECT)
24624      return;
24625    let a;
24626    t.id !== x.CONNECTOR_ID.BASE_ACCOUNT && (a = await t.getProvider().catch(() => {
24627    }));
24628    const u = bt.state.connectorImages;
24629    this.addConnector({
24630      id: t.id,
24631      explorerId: it.ConnectorExplorerIds[t.id] ?? it.ConnectorExplorerIds[t.name],
24632      imageUrl: u?.[t.id] ?? t.icon,
24633      name: it.ConnectorNamesMap[t.id] ?? t.name,
24634      imageId: it.ConnectorImageIds[t.id],
24635      type: it.ConnectorTypesMap[t.type] ?? "EXTERNAL",
24636      info: t.id === x.CONNECTOR_ID.INJECTED ? void 0 : { rdns: t.id },
24637      provider: a,
24638      chain: this.namespace,
24639      chains: []
24640    });
24641  }
24642  async syncConnectors() {
24643    YE(this.wagmiConfig, {
24644      onChange: (t) => {
24645        t.forEach((n) => this.addWagmiConnector(n));
24646      }
24647    }), this.addWagmiConnectors(), await Promise.all(this.wagmiConfig.connectors.map((t) => this.addWagmiConnector(t))), await this.addThirdPartyConnectors();
24648  }
24649  async syncConnections() {
24650    const t = this.connectors.filter((n) => {
24651      const { hasDisconnected: r, hasConnected: s } = Jn.getConnectorStorageInfo(n.id, this.namespace);
24652      return !r && s;
24653    }).map((n) => this.getWagmiConnector(n.id)).filter(Boolean);
24654    await Pi(this.wagmiConfig, {
24655      connectors: t
24656    });
24657  }
24658  async syncConnection(t) {
24659    const { id: n, chainId: r } = t, i = rn(this.wagmiConfig).find((c) => c.connector.id === n), a = await this.getWagmiConnector(n)?.getProvider();
24660    if (q.isSafeApp() && n === x.CONNECTOR_ID.SAFE && !i?.accounts.length) {
24661      const c = this.getWagmiConnector("safe");
24662      if (c) {
24663        const l = await sa(this.wagmiConfig, {
24664          connector: c,
24665          chainId: Number(r)
24666        }), f = await c.getProvider();
24667        return {
24668          chainId: Number(r),
24669          address: this.toChecksummedAddress(l.accounts[0]),
24670          provider: f,
24671          type: i?.connector.type?.toUpperCase(),
24672          id: i?.connector.id
24673        };
24674      }
24675    }
24676    return {
24677      chainId: Number(i?.chainId),
24678      address: this.toChecksummedAddress(i?.accounts[0]),
24679      provider: a,
24680      type: i?.connector.type?.toUpperCase(),
24681      id: i?.connector.id
24682    };
24683  }
24684  async connectWalletConnect(t) {
24685    try {
24686      const n = this.getWalletConnectConnector();
24687      await n.authenticate();
24688      const r = this.getWagmiConnector("walletConnect");
24689      if (!r)
24690        throw new Error("UniversalAdapter:connectWalletConnect - connector not found");
24691      const s = await sa(this.wagmiConfig, {
24692        connector: r,
24693        chainId: t ? Number(t) : void 0
24694      });
24695      return s.chainId !== Number(t) && await nl(this.wagmiConfig, { chainId: s.chainId }), { clientId: await n.provider.client.core.crypto.getClientId() };
24696    } catch (n) {
24697      throw n instanceof Ke ? new Zn(n) : St.isUserRejectedRequestError(n) ? new Zn(n) : n;
24698    }
24699  }
24700  async connect(t) {
24701    try {
24702      const { id: n, address: r, provider: s, type: i, info: o, chainId: a, socialUri: u } = t, c = this.getWagmiConnector(n);
24703      if (!c)
24704        throw new Error("connectionControllerClient:connectExternal - connector is undefined");
24705      s && o && c.id === x.CONNECTOR_ID.EIP6963 && c.setEip6963Wallet?.({ provider: s, info: o });
24706      const l = this.wagmiConfig.state?.connections?.get(c.uid);
24707      if (l) {
24708        await this.wagmiConfig.storage?.setItem("recentConnectorId", c.id);
24709        const m = [...l.accounts].sort((y, b) => Jn.isLowerCaseMatch(y, r) ? -1 : Jn.isLowerCaseMatch(b, r) ? 1 : 0);
24710        return this.wagmiConfig?.setState((y) => ({
24711          ...y,
24712          connections: new Map(y.connections).set(c.uid, {
24713            accounts: m,
24714            chainId: l.chainId,
24715            connector: l.connector
24716          }),
24717          current: c.uid,
24718          status: "connected"
24719        })), {
24720          address: this.toChecksummedAddress(m[0]),
24721          chainId: l.chainId,
24722          provider: s,
24723          type: i,
24724          id: n
24725        };
24726      }
24727      const f = await sa(this.wagmiConfig, {
24728        connector: c,
24729        chainId: a ? Number(a) : void 0,
24730        socialUri: u
24731      }), p = s ?? await c.getProvider();
24732      return {
24733        address: this.toChecksummedAddress(f.accounts[0]),
24734        chainId: f.chainId,
24735        provider: p,
24736        type: i,
24737        id: n
24738      };
24739    } catch (n) {
24740      throw n instanceof Ke ? new Zn(n) : St.isUserRejectedRequestError(n) ? new Zn(n) : n;
24741    }
24742  }
24743  get connections() {
24744    return Array.from(this.wagmiConfig.state.connections.values()).map((t) => ({
24745      accounts: t.accounts.map((n) => ({
24746        address: this.toChecksummedAddress(n)
24747      })),
24748      connectorId: t.connector.id
24749    }));
24750  }
24751  async reconnect(t) {
24752    const { id: n } = t, r = this.getWagmiConnector(n);
24753    if (!r)
24754      throw new Error("connectionControllerClient:connectExternal - connector is undefined");
24755    await Pi(this.wagmiConfig, {
24756      connectors: [r]
24757    });
24758  }
24759  async getBalance(t) {
24760    const n = t.address, r = this.getCaipNetworks().find((s) => s.id === t.chainId);
24761    if (!n)
24762      return Promise.resolve({ balance: "0.00", symbol: "ETH" });
24763    if (r && this.wagmiConfig) {
24764      const s = `${r.caipNetworkId}:${t.address}`, i = this.balancePromises[s];
24765      if (i)
24766        return i;
24767      const o = W.getNativeBalanceCacheForCaipAddress(s);
24768      return o ? { balance: o.balance, symbol: o.symbol } : (this.balancePromises[s] = new Promise(async (a) => {
24769        try {
24770          const u = Number(t.chainId), c = await WE(this.wagmiConfig, {
24771            address: t.address,
24772            chainId: u,
24773            token: t.tokens?.[r.caipNetworkId]?.address
24774          });
24775          W.updateNativeBalanceCache({
24776            caipAddress: s,
24777            balance: c.formatted,
24778            symbol: c.symbol,
24779            timestamp: Date.now()
24780          }), a({ balance: c.formatted, symbol: c.symbol });
24781        } catch (u) {
24782          console.warn("Appkit:WagmiAdapter:getBalance - Error getting balance", u), a({ balance: "0.00", symbol: "ETH" });
24783        }
24784      }).finally(() => {
24785        delete this.balancePromises[s];
24786      }), this.balancePromises[s] || { balance: "0.00", symbol: "ETH" });
24787    }
24788    return { balance: "", symbol: "" };
24789  }
24790  getWalletConnectProvider() {
24791    return this.getWagmiConnector("walletConnect")?.provider;
24792  }
24793  async disconnect(t) {
24794    if (t.id) {
24795      const n = this.getWagmiConnector(t.id), s = rn(this.wagmiConfig).find((i) => Jn.isLowerCaseMatch(i.connector.id, t.id));
24796      return await tl(this.wagmiConfig, { connector: n }), z.state.enableReconnect === !1 && this.deleteConnection(t.id), s ? {
24797        connections: [
24798          {
24799            accounts: s.accounts.map((i) => ({
24800              address: this.toChecksummedAddress(i)
24801            })),
24802            connectorId: s.connector.id
24803          }
24804        ]
24805      } : { connections: [] };
24806    }
24807    return this.disconnectAll();
24808  }
24809  async disconnectAll() {
24810    const t = rn(this.wagmiConfig), n = await Promise.allSettled(t.map(async (r) => {
24811      const s = this.getWagmiConnector(r.connector.id);
24812      return s && await tl(this.wagmiConfig, { connector: s }), r;
24813    }));
24814    return this.wagmiConfig.state.connections.clear(), {
24815      connections: n.filter((r) => r.status === "fulfilled").map(({ value: r }) => ({
24816        accounts: r.accounts.map((s) => ({
24817          address: this.toChecksummedAddress(s)
24818        })),
24819        connectorId: r.connector.id
24820      }))
24821    };
24822  }
24823  async switchNetwork(t) {
24824    const { caipNetwork: n } = t, r = this.wagmiConfig.chains.find((m) => m.id.toString() === n.id.toString());
24825    if (!r)
24826      throw new Error("connectionControllerClient:switchNetwork - wagmiChain is undefined");
24827    const { name: s, nativeCurrency: i, rpcUrls: o, blockExplorers: a, id: u } = r, c = n.rpcUrls?.chainDefault?.http?.[0] ?? o.default.http[0] ?? "", l = a?.default.url ?? n.blockExplorers?.default?.url ?? "", f = i ?? n.nativeCurrency, p = s ?? n.name;
24828    await nl(this.wagmiConfig, {
24829      chainId: u,
24830      addEthereumChainParameter: {
24831        chainName: p,
24832        nativeCurrency: f,
24833        rpcUrls: [c],
24834        blockExplorerUrls: [l]
24835      }
24836    }), await super.switchNetwork(t);
24837  }
24838  async getCapabilities(t) {
24839    if (!this.wagmiConfig)
24840      throw new Error("connectionControllerClient:getCapabilities - wagmiConfig is undefined");
24841    const r = rn(this.wagmiConfig)[0], s = r ? this.getWagmiConnector(r.connector.id) : null;
24842    if (!s)
24843      throw new Error("connectionControllerClient:getCapabilities - connector is undefined");
24844    const i = await s.getProvider();
24845    if (!i)
24846      throw new Error("connectionControllerClient:getCapabilities - provider is undefined");
24847    return await i.request({ method: "wallet_getCapabilities", params: [t] });
24848  }
24849  async grantPermissions(t) {
24850    if (!this.wagmiConfig)
24851      throw new Error("connectionControllerClient:grantPermissions - wagmiConfig is undefined");
24852    const r = rn(this.wagmiConfig)[0], s = r ? this.getWagmiConnector(r.connector.id) : null;
24853    if (!s)
24854      throw new Error("connectionControllerClient:grantPermissions - connector is undefined");
24855    const i = await s.getProvider();
24856    if (!i)
24857      throw new Error("connectionControllerClient:grantPermissions - provider is undefined");
24858    return i.request({ method: "wallet_grantPermissions", params: t });
24859  }
24860  async revokePermissions(t) {
24861    if (!this.wagmiConfig)
24862      throw new Error("connectionControllerClient:revokePermissions - wagmiConfig is undefined");
24863    const r = rn(this.wagmiConfig)[0], s = r ? this.getWagmiConnector(r.connector.id) : null;
24864    if (!s)
24865      throw new Error("connectionControllerClient:revokePermissions - connector is undefined");
24866    const i = await s.getProvider();
24867    if (!i)
24868      throw new Error("connectionControllerClient:revokePermissions - provider is undefined");
24869    return i.request({ method: "wallet_revokePermissions", params: t });
24870  }
24871  async walletGetAssets(t) {
24872    if (!this.wagmiConfig)
24873      throw new Error("connectionControllerClient:walletGetAssets - wagmiConfig is undefined");
24874    const r = rn(this.wagmiConfig)[0], s = r ? this.getWagmiConnector(r.connector.id) : null;
24875    if (!s)
24876      throw new Error("connectionControllerClient:walletGetAssets - connector is undefined");
24877    const i = await s.getProvider();
24878    if (!i)
24879      throw new Error("connectionControllerClient:walletGetAssets - provider is undefined");
24880    return i.request({ method: "wallet_getAssets", params: [t] });
24881  }
24882  setAuthProvider(t) {
24883    if (!this.namespace)
24884      throw new Error("WagmiAdapter:setAuthProvider - namespace is required");
24885    this.addConnector({
24886      id: x.CONNECTOR_ID.AUTH,
24887      type: "AUTH",
24888      name: x.CONNECTOR_NAMES.AUTH,
24889      provider: t,
24890      imageId: it.ConnectorImageIds[x.CONNECTOR_ID.AUTH],
24891      chain: this.namespace,
24892      chains: []
24893    });
24894  }
24895  async setUniversalProvider(t) {
24896    t.on("connect", () => {
24897      const r = rn(this.wagmiConfig), s = this.getWagmiConnector("walletConnect");
24898      if (s && !r.find((i) => i.connector.id === s.id)) {
24899        if (v.state.activeChain === "eip155")
24900          return;
24901        Pi(this.wagmiConfig, {
24902          connectors: [s]
24903        });
24904      }
24905    });
24906    const n = Pc({
24907      universalProvider: t
24908    });
24909    return this.configureInternalConnector(n), this.addConnector(new Pf({
24910      provider: t,
24911      caipNetworks: this.getCaipNetworks(),
24912      namespace: "eip155"
24913    })), Promise.resolve();
24914  }
24915  toChecksummedAddress(t) {
24916    if (!t)
24917      return t;
24918    try {
24919      return Gs(t.toLowerCase());
24920    } catch {
24921      return t;
24922    }
24923  }
24924}
24925var vo = class {
24926  constructor() {
24927    this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
24928  }
24929  subscribe(e) {
24930    return this.listeners.add(e), this.onSubscribe(), () => {
24931      this.listeners.delete(e), this.onUnsubscribe();
24932    };
24933  }
24934  hasListeners() {
24935    return this.listeners.size > 0;
24936  }
24937  onSubscribe() {
24938  }
24939  onUnsubscribe() {
24940  }
24941}, AA = class extends vo {
24942  #e;
24943  #n;
24944  #t;
24945  constructor() {
24946    super(), this.#t = (e) => {
24947      if (typeof window < "u" && window.addEventListener) {
24948        const t = () => e();
24949        return window.addEventListener("visibilitychange", t, !1), () => {
24950          window.removeEventListener("visibilitychange", t);
24951        };
24952      }
24953    };
24954  }
24955  onSubscribe() {
24956    this.#n || this.setEventListener(this.#t);
24957  }
24958  onUnsubscribe() {
24959    this.hasListeners() || (this.#n?.(), this.#n = void 0);
24960  }
24961  setEventListener(e) {
24962    this.#t = e, this.#n?.(), this.#n = e((t) => {
24963      typeof t == "boolean" ? this.setFocused(t) : this.onFocus();
24964    });
24965  }
24966  setFocused(e) {
24967    this.#e !== e && (this.#e = e, this.onFocus());
24968  }
24969  onFocus() {
24970    const e = this.isFocused();
vendor: 6,662 bytes, lines 24971-25227
24971    this.listeners.forEach((t) => {
24972      t(e);
24973    });
24974  }
24975  isFocused() {
24976    return typeof this.#e == "boolean" ? this.#e : globalThis.document?.visibilityState !== "hidden";
24977  }
24978}, Df = new AA(), vA = {
24979  // We need the wrapper function syntax below instead of direct references to
24980  // global setTimeout etc.
24981  //
24982  // BAD: `setTimeout: setTimeout`
24983  // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
24984  //
24985  // If we use direct references here, then anything that wants to spy on or
24986  // replace the global setTimeout (like tests) won't work since we'll already
24987  // have a hard reference to the original implementation at the time when this
24988  // file was imported.
24989  setTimeout: (e, t) => setTimeout(e, t),
24990  clearTimeout: (e) => clearTimeout(e),
24991  setInterval: (e, t) => setInterval(e, t),
24992  clearInterval: (e) => clearInterval(e)
24993}, _A = class {
24994  // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
24995  // type at app boot; and if we leave that type, then any new timer provider
24996  // would need to support ReturnType<typeof setTimeout>, which is infeasible.
24997  //
24998  // We settle for type safety for the TimeoutProvider type, and accept that
24999  // this class is unsafe internally to allow for extension.
25000  #e = vA;
25001  #n = !1;
25002  setTimeoutProvider(e) {
25003    this.#e = e;
25004  }
25005  setTimeout(e, t) {
25006    return this.#e.setTimeout(e, t);
25007  }
25008  clearTimeout(e) {
25009    this.#e.clearTimeout(e);
25010  }
25011  setInterval(e, t) {
25012    return this.#e.setInterval(e, t);
25013  }
25014  clearInterval(e) {
25015    this.#e.clearInterval(e);
25016  }
25017}, Va = new _A();
25018function NA(e) {
25019  setTimeout(e, 0);
25020}
25021var Ff = typeof window > "u" || "Deno" in globalThis;
25022function It() {
25023}
25024function IA(e, t) {
25025  return typeof e == "function" ? e(t) : e;
25026}
25027function TA(e) {
25028  return typeof e == "number" && e >= 0 && e !== 1 / 0;
25029}
25030function SA(e, t) {
25031  return Math.max(e + (t || 0) - Date.now(), 0);
25032}
25033function Ka(e, t) {
25034  return typeof e == "function" ? e(t) : e;
25035}
25036function RA(e, t) {
25037  return typeof e == "function" ? e(t) : e;
25038}
25039function al(e, t) {
25040  const {
25041    type: n = "all",
25042    exact: r,
25043    fetchStatus: s,
25044    predicate: i,
25045    queryKey: o,
25046    stale: a
25047  } = e;
25048  if (o) {
25049    if (r) {
25050      if (t.queryHash !== kc(o, t.options))
25051        return !1;
25052    } else if (!$s(t.queryKey, o))
25053      return !1;
25054  }
25055  if (n !== "all") {
25056    const u = t.isActive();
25057    if (n === "active" && !u || n === "inactive" && u)
25058      return !1;
25059  }
25060  return !(typeof a == "boolean" && t.isStale() !== a || s && s !== t.state.fetchStatus || i && !i(t));
25061}
25062function cl(e, t) {
25063  const { exact: n, status: r, predicate: s, mutationKey: i } = e;
25064  if (i) {
25065    if (!t.options.mutationKey)
25066      return !1;
25067    if (n) {
25068      if (Ws(t.options.mutationKey) !== Ws(i))
25069        return !1;
25070    } else if (!$s(t.options.mutationKey, i))
25071      return !1;
25072  }
25073  return !(r && t.state.status !== r || s && !s(t));
25074}
25075function kc(e, t) {
25076  return (t?.queryKeyHashFn || Ws)(e);
25077}
25078function Ws(e) {
25079  return JSON.stringify(
25080    e,
25081    (t, n) => Ya(n) ? Object.keys(n).sort().reduce((r, s) => (r[s] = n[s], r), {}) : n
25082  );
25083}
25084function $s(e, t) {
25085  return e === t ? !0 : typeof e != typeof t ? !1 : e && t && typeof e == "object" && typeof t == "object" ? Object.keys(t).every((n) => $s(e[n], t[n])) : !1;
25086}
25087var xA = Object.prototype.hasOwnProperty;
25088function jf(e, t, n = 0) {
25089  if (e === t)
25090    return e;
25091  if (n > 500) return t;
25092  const r = ul(e) && ul(t);
25093  if (!r && !(Ya(e) && Ya(t))) return t;
25094  const i = (r ? e : Object.keys(e)).length, o = r ? t : Object.keys(t), a = o.length, u = r ? new Array(a) : {};
25095  let c = 0;
25096  for (let l = 0; l < a; l++) {
25097    const f = r ? l : o[l], p = e[f], m = t[f];
25098    if (p === m) {
25099      u[f] = p, (r ? l < i : xA.call(e, f)) && c++;
25100      continue;
25101    }
25102    if (p === null || m === null || typeof p != "object" || typeof m != "object") {
25103      u[f] = m;
25104      continue;
25105    }
25106    const y = jf(p, m, n + 1);
25107    u[f] = y, y === p && c++;
25108  }
25109  return i === a && c === i ? e : u;
25110}
25111function Q_(e, t) {
25112  if (!t || Object.keys(e).length !== Object.keys(t).length)
25113    return !1;
25114  for (const n in e)
25115    if (e[n] !== t[n])
25116      return !1;
25117  return !0;
25118}
25119function ul(e) {
25120  return Array.isArray(e) && e.length === Object.keys(e).length;
25121}
25122function Ya(e) {
25123  if (!ll(e))
25124    return !1;
25125  const t = e.constructor;
25126  if (t === void 0)
25127    return !0;
25128  const n = t.prototype;
25129  return !(!ll(n) || !n.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
25130}
25131function ll(e) {
25132  return Object.prototype.toString.call(e) === "[object Object]";
25133}
25134function OA(e) {
25135  return new Promise((t) => {
25136    Va.setTimeout(t, e);
25137  });
25138}
25139function PA(e, t, n) {
25140  return typeof n.structuralSharing == "function" ? n.structuralSharing(e, t) : n.structuralSharing !== !1 ? jf(e, t) : t;
25141}
25142function kA(e, t, n = 0) {
25143  const r = [...e, t];
25144  return n && r.length > n ? r.slice(1) : r;
25145}
25146function UA(e, t, n = 0) {
25147  const r = [t, ...e];
25148  return n && r.length > n ? r.slice(0, -1) : r;
25149}
25150var Uc = /* @__PURE__ */ Symbol();
25151function Wf(e, t) {
25152  return !e.queryFn && t?.initialPromise ? () => t.initialPromise : !e.queryFn || e.queryFn === Uc ? () => Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)) : e.queryFn;
25153}
25154function J_(e, t) {
25155  return typeof e == "function" ? e(...t) : !!e;
25156}
25157function MA(e, t, n) {
25158  let r = !1, s;
25159  return Object.defineProperty(e, "signal", {
25160    enumerable: !0,
25161    get: () => (s ??= t(), r || (r = !0, s.aborted ? n() : s.addEventListener("abort", n, { once: !0 })), s)
25162  }), e;
25163}
25164var $f = /* @__PURE__ */ (() => {
25165  let e = () => Ff;
25166  return {
25167    /**
25168     * Returns whether the current runtime should be treated as a server environment.
25169     */
25170    isServer() {
25171      return e();
25172    },
25173    /**
25174     * Overrides the server check globally.
25175     */
25176    setIsServer(t) {
25177      e = t;
25178    }
25179  };
25180})();
25181function LA() {
25182  let e, t;
25183  const n = new Promise((s, i) => {
25184    e = s, t = i;
25185  });
25186  n.status = "pending", n.catch(() => {
25187  });
25188  function r(s) {
25189    Object.assign(n, s), delete n.resolve, delete n.reject;
25190  }
25191  return n.resolve = (s) => {
25192    r({
25193      status: "fulfilled",
25194      value: s
25195    }), e(s);
25196  }, n.reject = (s) => {
25197    r({
25198      status: "rejected",
25199      reason: s
25200    }), t(s);
25201  }, n;
25202}
25203var BA = NA;
25204function DA() {
25205  let e = [], t = 0, n = (a) => {
25206    a();
25207  }, r = (a) => {
25208    a();
25209  }, s = BA;
25210  const i = (a) => {
25211    t ? e.push(a) : s(() => {
25212      n(a);
25213    });
25214  }, o = () => {
25215    const a = e;
25216    e = [], a.length && s(() => {
25217      r(() => {
25218        a.forEach((u) => {
25219          n(u);
25220        });
25221      });
25222    });
25223  };
25224  return {
25225    batch: (a) => {
25226      let u;
25227      t++;
25228      try {
25229        u = a();
25230      } finally {
25231        t--, t || o();
25232      }
25233      return u;
25234    },
25235    /**
25236     * All calls to the wrapped function will be batched.
25237     */
25238    batchCalls: (a) => (...u) => {
25239      i(() => {
25240        a(...u);
25241      });
25242    },
25243    schedule: i,
25244    /**
25245     * Use this method to set a custom notify function.
25246     * This can be used to for example wrap notifications with `React.act` while running tests.
25247     */
25248    setNotifyFunction: (a) => {
25249      n = a;
25250    },
25251    /**
25252     * Use this method to set a custom function to batch notifications together into a single tick.
25253     * By default React Query will use the batch function provided by ReactDOM or React Native.
25254     */
25255    setBatchNotifyFunction: (a) => {
25256      r = a;
25257    },
25258    setScheduler: (a) => {
25259      s = a;
25260    }
25261  };
25262}
25263var ot = DA(), FA = class extends vo {
25264  #e = !0;
25265  #n;
25266  #t;
25267  constructor() {
25268    super(), this.#t = (e) => {
25269      if (typeof window < "u" && window.addEventListener) {
25270        const t = () => e(!0), n = () => e(!1);
25271        return window.addEventListener("online", t, !1), window.addEventListener("offline", n, !1), () => {
25272          window.removeEventListener("online", t), window.removeEventListener("offline", n);
25273        };
25274      }
25275    };
25276  }
25277  onSubscribe() {
25278    this.#n || this.setEventListener(this.#t);
25279  }
25280  onUnsubscribe() {
25281    this.hasListeners() || (this.#n?.(), this.#n = void 0);
25282  }
25283  setEventListener(e) {
25284    this.#t = e, this.#n?.(), this.#n = e(this.setOnline.bind(this));
25285  }
25286  setOnline(e) {
25287    this.#e !== e && (this.#e = e, this.listeners.forEach((n) => {
25288      n(e);
25289    }));
25290  }
25291  isOnline() {
25292    return this.#e;
25293  }
25294}, io = new FA();
25295function jA(e) {
25296  return Math.min(1e3 * 2 ** e, 3e4);
25297}
25298function Hf(e) {
25299  return (e ?? "online") === "online" ? io.isOnline() : !0;
25300}
25301var Za = class extends Error {
25302  constructor(e) {
25303    super("CancelledError"), this.revert = e?.revert, this.silent = e?.silent;
25304  }
25305};
25306function qf(e) {
25307  let t = !1, n = 0, r;
25308  const s = LA(), i = () => s.status !== "pending", o = (b) => {
25309    if (!i()) {
25310      const C = new Za(b);
25311      p(C), e.onCancel?.(C);
25312    }
25313  }, a = () => {
25314    t = !0;
25315  }, u = () => {
25316    t = !1;
25317  }, c = () => Df.isFocused() && (e.networkMode === "always" || io.isOnline()) && e.canRun(), l = () => Hf(e.networkMode) && e.canRun(), f = (b) => {
25318    i() || (r?.(), s.resolve(b));
25319  }, p = (b) => {
25320    i() || (r?.(), s.reject(b));
25321  }, m = () => new Promise((b) => {
25322    r = (C) => {
25323      (i() || c()) && b(C);
25324    }, e.onPause?.();
25325  }).then(() => {
25326    r = void 0, i() || e.onContinue?.();
25327  }), y = () => {
25328    if (i())
25329      return;
25330    let b;
25331    const C = n === 0 ? e.initialPromise : void 0;
25332    try {
25333      b = C ?? e.fn();
25334    } catch (_) {
25335      b = Promise.reject(_);
25336    }
25337    Promise.resolve(b).then(f).catch((_) => {
25338      if (i())
25339        return;
25340      const R = e.retry ?? ($f.isServer() ? 0 : 3), N = e.retryDelay ?? jA, I = typeof N == "function" ? N(n, _) : N, E = R === !0 || typeof R == "number" && n < R || typeof R == "function" && R(n, _);
25341      if (t || !E) {
25342        p(_);
25343        return;
25344      }
25345      n++, e.onFail?.(n, _), OA(I).then(() => c() ? void 0 : m()).then(() => {
25346        t ? p(_) : y();
25347      });
25348    });
25349  };
25350  return {
25351    promise: s,
25352    status: () => s.status,
25353    cancel: o,
25354    continue: () => (r?.(), s),
25355    cancelRetry: a,
25356    continueRetry: u,
25357    canStart: l,
25358    start: () => (l() ? y() : m().then(y), s)
25359  };
25360}
25361var Gf = class {
25362  #e;
25363  destroy() {
25364    this.clearGcTimeout();
25365  }
25366  scheduleGc() {
25367    this.clearGcTimeout(), TA(this.gcTime) && (this.#e = Va.setTimeout(() => {
25368      this.optionalRemove();
25369    }, this.gcTime));
25370  }
25371  updateGcTime(e) {
25372    this.gcTime = Math.max(
25373      this.gcTime || 0,
25374      e ?? ($f.isServer() ? 1 / 0 : 300 * 1e3)
25375    );
25376  }
25377  clearGcTimeout() {
25378    this.#e && (Va.clearTimeout(this.#e), this.#e = void 0);
25379  }
25380}, WA = class extends Gf {
25381  #e;
25382  #n;
25383  #t;
25384  #s;
25385  #r;
25386  #i;
25387  #o;
25388  constructor(e) {
25389    super(), this.#o = !1, this.#i = e.defaultOptions, this.setOptions(e.options), this.observers = [], this.#s = e.client, this.#t = this.#s.getQueryCache(), this.queryKey = e.queryKey, this.queryHash = e.queryHash, this.#e = fl(this.options), this.state = e.state ?? this.#e, this.scheduleGc();
25390  }
25391  get meta() {
25392    return this.options.meta;
25393  }
25394  get promise() {
25395    return this.#r?.promise;
25396  }
25397  setOptions(e) {
25398    if (this.options = { ...this.#i, ...e }, this.updateGcTime(this.options.gcTime), this.state && this.state.data === void 0) {
25399      const t = fl(this.options);
25400      t.data !== void 0 && (this.setState(
25401        dl(t.data, t.dataUpdatedAt)
25402      ), this.#e = t);
25403    }
25404  }
25405  optionalRemove() {
25406    !this.observers.length && this.state.fetchStatus === "idle" && this.#t.remove(this);
25407  }
25408  setData(e, t) {
25409    const n = PA(this.state.data, e, this.options);
25410    return this.#a({
25411      data: n,
25412      type: "success",
25413      dataUpdatedAt: t?.updatedAt,
25414      manual: t?.manual
25415    }), n;
25416  }
25417  setState(e, t) {
25418    this.#a({ type: "setState", state: e, setStateOptions: t });
25419  }
25420  cancel(e) {
25421    const t = this.#r?.promise;
25422    return this.#r?.cancel(e), t ? t.then(It).catch(It) : Promise.resolve();
25423  }
25424  destroy() {
25425    super.destroy(), this.cancel({ silent: !0 });
25426  }
25427  get resetState() {
25428    return this.#e;
25429  }
25430  reset() {
25431    this.destroy(), this.setState(this.resetState);
25432  }
25433  isActive() {
25434    return this.observers.some(
25435      (e) => RA(e.options.enabled, this) !== !1
25436    );
25437  }
25438  isDisabled() {
25439    return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === Uc || !this.isFetched();
25440  }
25441  isFetched() {
25442    return this.state.dataUpdateCount + this.state.errorUpdateCount > 0;
25443  }
25444  isStatic() {
25445    return this.getObserversCount() > 0 ? this.observers.some(
25446      (e) => Ka(e.options.staleTime, this) === "static"
25447    ) : !1;
25448  }
25449  isStale() {
25450    return this.getObserversCount() > 0 ? this.observers.some(
25451      (e) => e.getCurrentResult().isStale
25452    ) : this.state.data === void 0 || this.state.isInvalidated;
25453  }
25454  isStaleByTime(e = 0) {
25455    return this.state.data === void 0 ? !0 : e === "static" ? !1 : this.state.isInvalidated ? !0 : !SA(this.state.dataUpdatedAt, e);
25456  }
25457  onFocus() {
25458    this.observers.find((t) => t.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#r?.continue();
25459  }
25460  onOnline() {
25461    this.observers.find((t) => t.shouldFetchOnReconnect())?.refetch({ cancelRefetch: !1 }), this.#r?.continue();
25462  }
25463  addObserver(e) {
25464    this.observers.includes(e) || (this.observers.push(e), this.clearGcTimeout(), this.#t.notify({ type: "observerAdded", query: this, observer: e }));
25465  }
25466  removeObserver(e) {
25467    this.observers.includes(e) && (this.observers = this.observers.filter((t) => t !== e), this.observers.length || (this.#r && (this.#o || this.#c() ? this.#r.cancel({ revert: !0 }) : this.#r.cancelRetry()), this.scheduleGc()), this.#t.notify({ type: "observerRemoved", query: this, observer: e }));
25468  }
25469  getObserversCount() {
25470    return this.observers.length;
25471  }
25472  #c() {
25473    return this.state.fetchStatus === "paused" && this.state.status === "pending";
25474  }
25475  invalidate() {
25476    this.state.isInvalidated || this.#a({ type: "invalidate" });
25477  }
25478  async fetch(e, t) {
25479    if (this.state.fetchStatus !== "idle" && // If the promise in the retryer is already rejected, we have to definitely
25480    // re-start the fetch; there is a chance that the query is still in a
25481    // pending state when that happens
25482    this.#r?.status() !== "rejected") {
25483      if (this.state.data !== void 0 && t?.cancelRefetch)
25484        this.cancel({ silent: !0 });
25485      else if (this.#r)
25486        return this.#r.continueRetry(), this.#r.promise;
25487    }
25488    if (e && this.setOptions(e), !this.options.queryFn) {
25489      const a = this.observers.find((u) => u.options.queryFn);
25490      a && this.setOptions(a.options);
25491    }
25492    const n = new AbortController(), r = (a) => {
25493      Object.defineProperty(a, "signal", {
25494        enumerable: !0,
25495        get: () => (this.#o = !0, n.signal)
25496      });
25497    }, s = () => {
25498      const a = Wf(this.options, t), c = (() => {
25499        const l = {
25500          client: this.#s,
25501          queryKey: this.queryKey,
25502          meta: this.meta
25503        };
25504        return r(l), l;
25505      })();
25506      return this.#o = !1, this.options.persister ? this.options.persister(
25507        a,
25508        c,
25509        this
25510      ) : a(c);
25511    }, o = (() => {
25512      const a = {
25513        fetchOptions: t,
25514        options: this.options,
25515        queryKey: this.queryKey,
25516        client: this.#s,
25517        state: this.state,
25518        fetchFn: s
25519      };
25520      return r(a), a;
25521    })();
25522    this.options.behavior?.onFetch(o, this), this.#n = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== o.fetchOptions?.meta) && this.#a({ type: "fetch", meta: o.fetchOptions?.meta }), this.#r = qf({
25523      initialPromise: t?.initialPromise,
25524      fn: o.fetchFn,
25525      onCancel: (a) => {
25526        a instanceof Za && a.revert && this.setState({
25527          ...this.#n,
25528          fetchStatus: "idle"
25529        }), n.abort();
25530      },
25531      onFail: (a, u) => {
25532        this.#a({ type: "failed", failureCount: a, error: u });
25533      },
25534      onPause: () => {
25535        this.#a({ type: "pause" });
25536      },
25537      onContinue: () => {
25538        this.#a({ type: "continue" });
25539      },
25540      retry: o.options.retry,
25541      retryDelay: o.options.retryDelay,
25542      networkMode: o.options.networkMode,
25543      canRun: () => !0
25544    });
25545    try {
25546      const a = await this.#r.start();
25547      if (a === void 0)
25548        throw new Error(`${this.queryHash} data is undefined`);
25549      return this.setData(a), this.#t.config.onSuccess?.(a, this), this.#t.config.onSettled?.(
25550        a,
25551        this.state.error,
25552        this
25553      ), a;
25554    } catch (a) {
25555      if (a instanceof Za) {
25556        if (a.silent)
25557          return this.#r.promise;
25558        if (a.revert) {
25559          if (this.state.data === void 0)
25560            throw a;
25561          return this.state.data;
25562        }
25563      }
25564      throw this.#a({
25565        type: "error",
25566        error: a
25567      }), this.#t.config.onError?.(
25568        a,
25569        this
25570      ), this.#t.config.onSettled?.(
25571        this.state.data,
25572        a,
25573        this
25574      ), a;
25575    } finally {
25576      this.scheduleGc();
25577    }
25578  }
25579  #a(e) {
25580    const t = (n) => {
25581      switch (e.type) {
25582        case "failed":
25583          return {
25584            ...n,
25585            fetchFailureCount: e.failureCount,
25586            fetchFailureReason: e.error
25587          };
25588        case "pause":
25589          return {
25590            ...n,
25591            fetchStatus: "paused"
25592          };
25593        case "continue":
25594          return {
25595            ...n,
25596            fetchStatus: "fetching"
25597          };
25598        case "fetch":
25599          return {
25600            ...n,
25601            ...$A(n.data, this.options),
25602            fetchMeta: e.meta ?? null
25603          };
25604        case "success":
25605          const r = {
25606            ...n,
25607            ...dl(e.data, e.dataUpdatedAt),
25608            dataUpdateCount: n.dataUpdateCount + 1,
25609            ...!e.manual && {
25610              fetchStatus: "idle",
25611              fetchFailureCount: 0,
25612              fetchFailureReason: null
25613            }
25614          };
25615          return this.#n = e.manual ? r : void 0, r;
25616        case "error":
25617          const s = e.error;
25618          return {
25619            ...n,
25620            error: s,
25621            errorUpdateCount: n.errorUpdateCount + 1,
25622            errorUpdatedAt: Date.now(),
25623            fetchFailureCount: n.fetchFailureCount + 1,
25624            fetchFailureReason: s,
25625            fetchStatus: "idle",
25626            status: "error",
25627            // flag existing data as invalidated if we get a background error
25628            // note that "no data" always means stale so we can set unconditionally here
25629            isInvalidated: !0
25630          };
25631        case "invalidate":
25632          return {
25633            ...n,
25634            isInvalidated: !0
25635          };
25636        case "setState":
25637          return {
25638            ...n,
25639            ...e.state
25640          };
25641      }
25642    };
25643    this.state = t(this.state), ot.batch(() => {
25644      this.observers.forEach((n) => {
25645        n.onQueryUpdate();
25646      }), this.#t.notify({ query: this, type: "updated", action: e });
25647    });
25648  }
25649};
25650function $A(e, t) {
25651  return {
25652    fetchFailureCount: 0,
25653    fetchFailureReason: null,
25654    fetchStatus: Hf(t.networkMode) ? "fetching" : "paused",
25655    ...e === void 0 && {
25656      error: null,
25657      status: "pending"
25658    }
25659  };
25660}
25661function dl(e, t) {
25662  return {
25663    data: e,
25664    dataUpdatedAt: t ?? Date.now(),
25665    error: null,
25666    isInvalidated: !1,
25667    status: "success"
25668  };
25669}
25670function fl(e) {
25671  const t = typeof e.initialData == "function" ? e.initialData() : e.initialData, n = t !== void 0, r = n ? typeof e.initialDataUpdatedAt == "function" ? e.initialDataUpdatedAt() : e.initialDataUpdatedAt : 0;
25672  return {
25673    data: t,
25674    dataUpdateCount: 0,
25675    dataUpdatedAt: n ? r ?? Date.now() : 0,
25676    error: null,
25677    errorUpdateCount: 0,
25678    errorUpdatedAt: 0,
25679    fetchFailureCount: 0,
25680    fetchFailureReason: null,
25681    fetchMeta: null,
25682    isInvalidated: !1,
25683    status: n ? "success" : "pending",
25684    fetchStatus: "idle"
25685  };
25686}
25687function hl(e) {
25688  return {
25689    onFetch: (t, n) => {
25690      const r = t.options, s = t.fetchOptions?.meta?.fetchMore?.direction, i = t.state.data?.pages || [], o = t.state.data?.pageParams || [];
25691      let a = { pages: [], pageParams: [] }, u = 0;
25692      const c = async () => {
25693        let l = !1;
25694        const f = (y) => {
25695          MA(
25696            y,
25697            () => t.signal,
25698            () => l = !0
25699          );
25700        }, p = Wf(t.options, t.fetchOptions), m = async (y, b, C) => {
25701          if (l)
25702            return Promise.reject();
25703          if (b == null && y.pages.length)
25704            return Promise.resolve(y);
25705          const R = (() => {
25706            const T = {
25707              client: t.client,
25708              queryKey: t.queryKey,
25709              pageParam: b,
25710              direction: C ? "backward" : "forward",
25711              meta: t.options.meta
25712            };
25713            return f(T), T;
25714          })(), N = await p(R), { maxPages: I } = t.options, E = C ? UA : kA;
25715          return {
25716            pages: E(y.pages, N, I),
25717            pageParams: E(y.pageParams, b, I)
25718          };
25719        };
25720        if (s && i.length) {
25721          const y = s === "backward", b = y ? HA : pl, C = {
25722            pages: i,
25723            pageParams: o
25724          }, _ = b(r, C);
25725          a = await m(C, _, y);
25726        } else {
25727          const y = e ?? i.length;
25728          do {
25729            const b = u === 0 ? o[0] ?? r.initialPageParam : pl(r, a);
25730            if (u > 0 && b == null)
25731              break;
25732            a = await m(a, b), u++;
25733          } while (u < y);
25734        }
25735        return a;
25736      };
25737      t.options.persister ? t.fetchFn = () => t.options.persister?.(
25738        c,
25739        {
25740          client: t.client,
25741          queryKey: t.queryKey,
25742          meta: t.options.meta,
25743          signal: t.signal
25744        },
25745        n
25746      ) : t.fetchFn = c;
25747    }
25748  };
25749}
25750function pl(e, { pages: t, pageParams: n }) {
25751  const r = t.length - 1;
25752  return t.length > 0 ? e.getNextPageParam(
25753    t[r],
25754    t,
25755    n[r],
25756    n
25757  ) : void 0;
25758}
25759function HA(e, { pages: t, pageParams: n }) {
25760  return t.length > 0 ? e.getPreviousPageParam?.(t[0], t, n[0], n) : void 0;
25761}
25762var qA = class extends Gf {
25763  #e;
25764  #n;
25765  #t;
25766  #s;
25767  constructor(e) {
25768    super(), this.#e = e.client, this.mutationId = e.mutationId, this.#t = e.mutationCache, this.#n = [], this.state = e.state || GA(), this.setOptions(e.options), this.scheduleGc();
25769  }
25770  setOptions(e) {
25771    this.options = e, this.updateGcTime(this.options.gcTime);
25772  }
25773  get meta() {
25774    return this.options.meta;
25775  }
25776  addObserver(e) {
25777    this.#n.includes(e) || (this.#n.push(e), this.clearGcTimeout(), this.#t.notify({
25778      type: "observerAdded",
25779      mutation: this,
25780      observer: e
25781    }));
25782  }
25783  removeObserver(e) {
25784    this.#n = this.#n.filter((t) => t !== e), this.scheduleGc(), this.#t.notify({
25785      type: "observerRemoved",
25786      mutation: this,
25787      observer: e
25788    });
25789  }
25790  optionalRemove() {
25791    this.#n.length || (this.state.status === "pending" ? this.scheduleGc() : this.#t.remove(this));
25792  }
25793  continue() {
25794    return this.#s?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
25795    this.execute(this.state.variables);
25796  }
25797  async execute(e) {
25798    const t = () => {
25799      this.#r({ type: "continue" });
25800    }, n = {
25801      client: this.#e,
25802      meta: this.options.meta,
25803      mutationKey: this.options.mutationKey
25804    };
25805    this.#s = qf({
25806      fn: () => this.options.mutationFn ? this.options.mutationFn(e, n) : Promise.reject(new Error("No mutationFn found")),
25807      onFail: (i, o) => {
25808        this.#r({ type: "failed", failureCount: i, error: o });
25809      },
25810      onPause: () => {
25811        this.#r({ type: "pause" });
25812      },
25813      onContinue: t,
25814      retry: this.options.retry ?? 0,
25815      retryDelay: this.options.retryDelay,
25816      networkMode: this.options.networkMode,
25817      canRun: () => this.#t.canRun(this)
25818    });
25819    const r = this.state.status === "pending", s = !this.#s.canStart();
25820    try {
25821      if (r)
25822        t();
25823      else {
25824        this.#r({ type: "pending", variables: e, isPaused: s }), this.#t.config.onMutate && await this.#t.config.onMutate(
25825          e,
25826          this,
25827          n
25828        );
25829        const o = await this.options.onMutate?.(
25830          e,
25831          n
25832        );
25833        o !== this.state.context && this.#r({
25834          type: "pending",
25835          context: o,
25836          variables: e,
25837          isPaused: s
25838        });
25839      }
25840      const i = await this.#s.start();
25841      return await this.#t.config.onSuccess?.(
25842        i,
25843        e,
25844        this.state.context,
25845        this,
25846        n
25847      ), await this.options.onSuccess?.(
25848        i,
25849        e,
25850        this.state.context,
25851        n
25852      ), await this.#t.config.onSettled?.(
25853        i,
25854        null,
25855        this.state.variables,
25856        this.state.context,
25857        this,
25858        n
25859      ), await this.options.onSettled?.(
25860        i,
25861        null,
25862        e,
25863        this.state.context,
25864        n
25865      ), this.#r({ type: "success", data: i }), i;
25866    } catch (i) {
25867      try {
25868        await this.#t.config.onError?.(
25869          i,
25870          e,
25871          this.state.context,
25872          this,
25873          n
25874        );
25875      } catch (o) {
25876        Promise.reject(o);
25877      }
25878      try {
25879        await this.options.onError?.(
25880          i,
25881          e,
25882          this.state.context,
25883          n
25884        );
25885      } catch (o) {
25886        Promise.reject(o);
25887      }
25888      try {
25889        await this.#t.config.onSettled?.(
25890          void 0,
25891          i,
25892          this.state.variables,
25893          this.state.context,
25894          this,
25895          n
25896        );
25897      } catch (o) {
25898        Promise.reject(o);
25899      }
25900      try {
25901        await this.options.onSettled?.(
25902          void 0,
25903          i,
25904          e,
25905          this.state.context,
25906          n
25907        );
25908      } catch (o) {
25909        Promise.reject(o);
25910      }
25911      throw this.#r({ type: "error", error: i }), i;
25912    } finally {
25913      this.#t.runNext(this);
25914    }
25915  }
25916  #r(e) {
25917    const t = (n) => {
25918      switch (e.type) {
25919        case "failed":
25920          return {
25921            ...n,
25922            failureCount: e.failureCount,
25923            failureReason: e.error
25924          };
25925        case "pause":
25926          return {
25927            ...n,
25928            isPaused: !0
25929          };
25930        case "continue":
25931          return {
25932            ...n,
25933            isPaused: !1
25934          };
25935        case "pending":
25936          return {
25937            ...n,
25938            context: e.context,
25939            data: void 0,
25940            failureCount: 0,
25941            failureReason: null,
25942            error: null,
25943            isPaused: e.isPaused,
25944            status: "pending",
25945            variables: e.variables,
25946            submittedAt: Date.now()
25947          };
25948        case "success":
25949          return {
25950            ...n,
25951            data: e.data,
25952            failureCount: 0,
25953            failureReason: null,
25954            error: null,
25955            status: "success",
25956            isPaused: !1
25957          };
25958        case "error":
25959          return {
25960            ...n,
25961            data: void 0,
25962            error: e.error,
25963            failureCount: n.failureCount + 1,
25964            failureReason: e.error,
25965            isPaused: !1,
25966            status: "error"
25967          };
25968      }
25969    };
25970    this.state = t(this.state), ot.batch(() => {
25971      this.#n.forEach((n) => {
25972        n.onMutationUpdate(e);
25973      }), this.#t.notify({
25974        mutation: this,
25975        type: "updated",
25976        action: e
25977      });
25978    });
25979  }
25980};
25981function GA() {
25982  return {
25983    context: void 0,
25984    data: void 0,
25985    error: null,
25986    failureCount: 0,
25987    failureReason: null,
25988    isPaused: !1,
25989    status: "idle",
25990    variables: void 0,
25991    submittedAt: 0
25992  };
25993}
25994var zf = class extends vo {
25995  constructor(t = {}) {
25996    super(), this.config = t, this.#e = /* @__PURE__ */ new Set(), this.#n = /* @__PURE__ */ new Map(), this.#t = 0;
25997  }
25998  #e;
25999  #n;
26000  #t;
26001  build(t, n, r) {
26002    const s = new qA({
26003      client: t,
26004      mutationCache: this,
26005      mutationId: ++this.#t,
26006      options: t.defaultMutationOptions(n),
26007      state: r
26008    });
26009    return this.add(s), s;
26010  }
26011  add(t) {
26012    this.#e.add(t);
26013    const n = Ni(t);
26014    if (typeof n == "string") {
26015      const r = this.#n.get(n);
26016      r ? r.push(t) : this.#n.set(n, [t]);
26017    }
26018    this.notify({ type: "added", mutation: t });
26019  }
26020  remove(t) {
26021    if (this.#e.delete(t)) {
26022      const n = Ni(t);
26023      if (typeof n == "string") {
26024        const r = this.#n.get(n);
26025        if (r)
26026          if (r.length > 1) {
26027            const s = r.indexOf(t);
26028            s !== -1 && r.splice(s, 1);
26029          } else r[0] === t && this.#n.delete(n);
26030      }
26031    }
26032    this.notify({ type: "removed", mutation: t });
26033  }
26034  canRun(t) {
26035    const n = Ni(t);
26036    if (typeof n == "string") {
26037      const s = this.#n.get(n)?.find(
26038        (i) => i.state.status === "pending"
26039      );
26040      return !s || s === t;
26041    } else
26042      return !0;
26043  }
26044  runNext(t) {
26045    const n = Ni(t);
26046    return typeof n == "string" ? this.#n.get(n)?.find((s) => s !== t && s.state.isPaused)?.continue() ?? Promise.resolve() : Promise.resolve();
26047  }
26048  clear() {
26049    ot.batch(() => {
26050      this.#e.forEach((t) => {
26051        this.notify({ type: "removed", mutation: t });
26052      }), this.#e.clear(), this.#n.clear();
26053    });
26054  }
26055  getAll() {
26056    return Array.from(this.#e);
26057  }
26058  find(t) {
26059    const n = { exact: !0, ...t };
26060    return this.getAll().find(
26061      (r) => cl(n, r)
26062    );
26063  }
26064  findAll(t = {}) {
26065    return this.getAll().filter((n) => cl(t, n));
26066  }
26067  notify(t) {
26068    ot.batch(() => {
26069      this.listeners.forEach((n) => {
26070        n(t);
26071      });
26072    });
26073  }
26074  resumePausedMutations() {
26075    const t = this.getAll().filter((n) => n.state.isPaused);
26076    return ot.batch(
26077      () => Promise.all(
26078        t.map((n) => n.continue().catch(It))
26079      )
26080    );
26081  }
26082};
26083function Ni(e) {
26084  return e.options.scope?.id;
26085}
26086var Vf = class extends vo {
26087  constructor(t = {}) {
26088    super(), this.config = t, this.#e = /* @__PURE__ */ new Map();
26089  }
26090  #e;
26091  build(t, n, r) {
26092    const s = n.queryKey, i = n.queryHash ?? kc(s, n);
26093    let o = this.get(i);
26094    return o || (o = new WA({
26095      client: t,
26096      queryKey: s,
26097      queryHash: i,
26098      options: t.defaultQueryOptions(n),
26099      state: r,
26100      defaultOptions: t.getQueryDefaults(s)
26101    }), this.add(o)), o;
26102  }
26103  add(t) {
26104    this.#e.has(t.queryHash) || (this.#e.set(t.queryHash, t), this.notify({
26105      type: "added",
26106      query: t
26107    }));
26108  }
26109  remove(t) {
26110    const n = this.#e.get(t.queryHash);
26111    n && (t.destroy(), n === t && this.#e.delete(t.queryHash), this.notify({ type: "removed", query: t }));
26112  }
26113  clear() {
26114    ot.batch(() => {
26115      this.getAll().forEach((t) => {
26116        this.remove(t);
26117      });
26118    });
26119  }
26120  get(t) {
26121    return this.#e.get(t);
26122  }
26123  getAll() {
26124    return [...this.#e.values()];
26125  }
26126  find(t) {
26127    const n = { exact: !0, ...t };
26128    return this.getAll().find(
26129      (r) => al(n, r)
26130    );
26131  }
26132  findAll(t = {}) {
26133    const n = this.getAll();
26134    return Object.keys(t).length > 0 ? n.filter((r) => al(t, r)) : n;
26135  }
26136  notify(t) {
26137    ot.batch(() => {
26138      this.listeners.forEach((n) => {
26139        n(t);
26140      });
26141    });
26142  }
26143  onFocus() {
26144    ot.batch(() => {
26145      this.getAll().forEach((t) => {
26146        t.onFocus();
26147      });
26148    });
26149  }
26150  onOnline() {
26151    ot.batch(() => {
26152      this.getAll().forEach((t) => {
26153        t.onOnline();
26154      });
26155    });
26156  }
26157}, zA = class {
26158  #e;
26159  #n;
26160  #t;
26161  #s;
26162  #r;
26163  #i;
26164  #o;
26165  #c;
26166  constructor(t = {}) {
26167    this.#e = t.queryCache || new Vf(), this.#n = t.mutationCache || new zf(), this.#t = t.defaultOptions || {}, this.#s = /* @__PURE__ */ new Map(), this.#r = /* @__PURE__ */ new Map(), this.#i = 0;
26168  }
26169  mount() {
26170    this.#i++, this.#i === 1 && (this.#o = Df.subscribe(async (t) => {
26171      t && (await this.resumePausedMutations(), this.#e.onFocus());
26172    }), this.#c = io.subscribe(async (t) => {
26173      t && (await this.resumePausedMutations(), this.#e.onOnline());
26174    }));
26175  }
26176  unmount() {
26177    this.#i--, this.#i === 0 && (this.#o?.(), this.#o = void 0, this.#c?.(), this.#c = void 0);
26178  }
26179  isFetching(t) {
26180    return this.#e.findAll({ ...t, fetchStatus: "fetching" }).length;
26181  }
26182  isMutating(t) {
26183    return this.#n.findAll({ ...t, status: "pending" }).length;
26184  }
26185  /**
26186   * Imperative (non-reactive) way to retrieve data for a QueryKey.
26187   * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
26188   *
26189   * Hint: Do not use this function inside a component, because it won't receive updates.
26190   * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
26191   */
26192  getQueryData(t) {
26193    const n = this.defaultQueryOptions({ queryKey: t });
26194    return this.#e.get(n.queryHash)?.state.data;
26195  }
26196  ensureQueryData(t) {
26197    const n = this.defaultQueryOptions(t), r = this.#e.build(this, n), s = r.state.data;
26198    return s === void 0 ? this.fetchQuery(t) : (t.revalidateIfStale && r.isStaleByTime(Ka(n.staleTime, r)) && this.prefetchQuery(n), Promise.resolve(s));
26199  }
26200  getQueriesData(t) {
26201    return this.#e.findAll(t).map(({ queryKey: n, state: r }) => {
26202      const s = r.data;
26203      return [n, s];
26204    });
26205  }
26206  setQueryData(t, n, r) {
26207    const s = this.defaultQueryOptions({ queryKey: t }), o = this.#e.get(
26208      s.queryHash
26209    )?.state.data, a = IA(n, o);
26210    if (a !== void 0)
26211      return this.#e.build(this, s).setData(a, { ...r, manual: !0 });
26212  }
26213  setQueriesData(t, n, r) {
26214    return ot.batch(
26215      () => this.#e.findAll(t).map(({ queryKey: s }) => [
26216        s,
26217        this.setQueryData(s, n, r)
26218      ])
26219    );
26220  }
26221  getQueryState(t) {
26222    const n = this.defaultQueryOptions({ queryKey: t });
26223    return this.#e.get(
26224      n.queryHash
26225    )?.state;
26226  }
26227  removeQueries(t) {
26228    const n = this.#e;
26229    ot.batch(() => {
26230      n.findAll(t).forEach((r) => {
26231        n.remove(r);
26232      });
26233    });
26234  }
26235  resetQueries(t, n) {
26236    const r = this.#e;
26237    return ot.batch(() => (r.findAll(t).forEach((s) => {
26238      s.reset();
26239    }), this.refetchQueries(
26240      {
26241        type: "active",
26242        ...t
26243      },
26244      n
26245    )));
26246  }
26247  cancelQueries(t, n = {}) {
26248    const r = { revert: !0, ...n }, s = ot.batch(
26249      () => this.#e.findAll(t).map((i) => i.cancel(r))
26250    );
26251    return Promise.all(s).then(It).catch(It);
26252  }
26253  invalidateQueries(t, n = {}) {
26254    return ot.batch(() => (this.#e.findAll(t).forEach((r) => {
26255      r.invalidate();
26256    }), t?.refetchType === "none" ? Promise.resolve() : this.refetchQueries(
26257      {
26258        ...t,
26259        type: t?.refetchType ?? t?.type ?? "active"
26260      },
26261      n
26262    )));
26263  }
26264  refetchQueries(t, n = {}) {
26265    const r = {
26266      ...n,
26267      cancelRefetch: n.cancelRefetch ?? !0
26268    }, s = ot.batch(
26269      () => this.#e.findAll(t).filter((i) => !i.isDisabled() && !i.isStatic()).map((i) => {
26270        let o = i.fetch(void 0, r);
26271        return r.throwOnError || (o = o.catch(It)), i.state.fetchStatus === "paused" ? Promise.resolve() : o;
26272      })
26273    );
26274    return Promise.all(s).then(It);
26275  }
26276  fetchQuery(t) {
26277    const n = this.defaultQueryOptions(t);
26278    n.retry === void 0 && (n.retry = !1);
26279    const r = this.#e.build(this, n);
26280    return r.isStaleByTime(
26281      Ka(n.staleTime, r)
26282    ) ? r.fetch(n) : Promise.resolve(r.state.data);
26283  }
26284  prefetchQuery(t) {
26285    return this.fetchQuery(t).then(It).catch(It);
26286  }
26287  fetchInfiniteQuery(t) {
26288    return t.behavior = hl(t.pages), this.fetchQuery(t);
26289  }
26290  prefetchInfiniteQuery(t) {
26291    return this.fetchInfiniteQuery(t).then(It).catch(It);
26292  }
26293  ensureInfiniteQueryData(t) {
26294    return t.behavior = hl(t.pages), this.ensureQueryData(t);
26295  }
26296  resumePausedMutations() {
26297    return io.isOnline() ? this.#n.resumePausedMutations() : Promise.resolve();
26298  }
26299  getQueryCache() {
26300    return this.#e;
26301  }
26302  getMutationCache() {
26303    return this.#n;
26304  }
26305  getDefaultOptions() {
26306    return this.#t;
26307  }
26308  setDefaultOptions(t) {
26309    this.#t = t;
26310  }
26311  setQueryDefaults(t, n) {
26312    this.#s.set(Ws(t), {
26313      queryKey: t,
26314      defaultOptions: n
26315    });
26316  }
26317  getQueryDefaults(t) {
26318    const n = [...this.#s.values()], r = {};
26319    return n.forEach((s) => {
26320      $s(t, s.queryKey) && Object.assign(r, s.defaultOptions);
26321    }), r;
26322  }
26323  setMutationDefaults(t, n) {
26324    this.#r.set(Ws(t), {
26325      mutationKey: t,
26326      defaultOptions: n
26327    });
26328  }
26329  getMutationDefaults(t) {
26330    const n = [...this.#r.values()], r = {};
26331    return n.forEach((s) => {
26332      $s(t, s.mutationKey) && Object.assign(r, s.defaultOptions);
26333    }), r;
26334  }
26335  defaultQueryOptions(t) {
26336    if (t._defaulted)
26337      return t;
26338    const n = {
26339      ...this.#t.queries,
26340      ...this.getQueryDefaults(t.queryKey),
26341      ...t,
26342      _defaulted: !0
26343    };
26344    return n.queryHash || (n.queryHash = kc(
26345      n.queryKey,
26346      n
26347    )), n.refetchOnReconnect === void 0 && (n.refetchOnReconnect = n.networkMode !== "always"), n.throwOnError === void 0 && (n.throwOnError = !!n.suspense), !n.networkMode && n.persister && (n.networkMode = "offlineFirst"), n.queryFn === Uc && (n.enabled = !1), n;
26348  }
26349  defaultMutationOptions(t) {
26350    return t?._defaulted ? t : {
26351      ...this.#t.mutations,
26352      ...t?.mutationKey && this.getMutationDefaults(t.mutationKey),
26353      ...t,
26354      _defaulted: !0
26355    };
26356  }
26357  clear() {
26358    this.#e.clear(), this.#n.clear();
26359  }
26360}, VA = "VUE_QUERY_CLIENT";
26361function KA(e) {
26362  const t = e ? `:${e}` : "";
26363  return `${VA}${t}`;
26364}
26365function n5(e, t) {
26366  Object.keys(e).forEach((n) => {
26367    e[n] = t[n];
26368  });
26369}
26370function Qa(e, t, n = "", r = 0) {
26371  if (t) {
26372    const s = t(e, n, r);
26373    if (s === void 0 && El(e) || s !== void 0)
26374      return s;
26375  }
26376  if (Array.isArray(e))
26377    return e.map(
26378      (s, i) => Qa(s, t, String(i), r + 1)
26379    );
26380  if (typeof e == "object" && ZA(e)) {
26381    const s = Object.entries(e).map(([i, o]) => [
26382      i,
26383      Qa(o, t, i, r + 1)
26384    ]);
26385    return Object.fromEntries(s);
26386  }
26387  return e;
26388}
26389function YA(e, t) {
26390  return Qa(e, t);
26391}
26392function Ce(e, t = !1) {
26393  return YA(e, (n, r, s) => {
26394    if (s === 1 && r === "queryKey")
26395      return Ce(n, !0);
26396    if (t && QA(n))
26397      return Ce(n(), t);
26398    if (El(n))
26399      return Ce(ch(n), t);
26400  });
26401}
26402function ZA(e) {
26403  if (Object.prototype.toString.call(e) !== "[object Object]")
26404    return !1;
26405  const t = Object.getPrototypeOf(e);
26406  return t === null || t === Object.prototype;
26407}
26408function QA(e) {
26409  return typeof e == "function";
26410}
26411var JA = class extends Vf {
26412  find(e) {
26413    return super.find(Ce(e));
26414  }
26415  findAll(e = {}) {
26416    return super.findAll(Ce(e));
26417  }
26418}, XA = class extends zf {
26419  find(e) {
26420    return super.find(Ce(e));
26421  }
26422  findAll(e = {}) {
26423    return super.findAll(Ce(e));
26424  }
26425}, ev = class extends zA {
26426  constructor(e = {}) {
26427    const t = {
26428      defaultOptions: e.defaultOptions,
26429      queryCache: e.queryCache || new JA(),
26430      mutationCache: e.mutationCache || new XA()
26431    };
26432    super(t), this.isRestoring = uh(!1);
26433  }
26434  isFetching(e = {}) {
26435    return super.isFetching(Ce(e));
26436  }
26437  isMutating(e = {}) {
26438    return super.isMutating(Ce(e));
26439  }
26440  getQueryData(e) {
26441    return super.getQueryData(Ce(e));
26442  }
26443  ensureQueryData(e) {
26444    return super.ensureQueryData(Ce(e));
26445  }
26446  getQueriesData(e) {
26447    return super.getQueriesData(Ce(e));
26448  }
26449  setQueryData(e, t, n = {}) {
26450    return super.setQueryData(
26451      Ce(e),
26452      t,
26453      Ce(n)
26454    );
26455  }
26456  setQueriesData(e, t, n = {}) {
26457    return super.setQueriesData(
26458      Ce(e),
26459      t,
26460      Ce(n)
26461    );
26462  }
26463  getQueryState(e) {
26464    return super.getQueryState(Ce(e));
26465  }
26466  removeQueries(e = {}) {
26467    return super.removeQueries(Ce(e));
26468  }
26469  resetQueries(e = {}, t = {}) {
26470    return super.resetQueries(Ce(e), Ce(t));
26471  }
26472  cancelQueries(e = {}, t = {}) {
26473    return super.cancelQueries(Ce(e), Ce(t));
26474  }
26475  invalidateQueries(e = {}, t = {}) {
26476    const n = Ce(e), r = Ce(t);
26477    if (super.invalidateQueries(
26478      { ...n, refetchType: "none" },
26479      r
26480    ), n.refetchType === "none")
26481      return Promise.resolve();
26482    const s = {
26483      ...n,
26484      type: n.refetchType ?? n.type ?? "active"
26485    };
26486    return lh().then(() => super.refetchQueries(s, r));
26487  }
26488  refetchQueries(e = {}, t = {}) {
26489    return super.refetchQueries(
26490      Ce(e),
26491      Ce(t)
26492    );
26493  }
26494  fetchQuery(e) {
26495    return super.fetchQuery(Ce(e));
26496  }
26497  prefetchQuery(e) {
26498    return super.prefetchQuery(Ce(e));
26499  }
26500  fetchInfiniteQuery(e) {
26501    return super.fetchInfiniteQuery(Ce(e));
26502  }
26503  prefetchInfiniteQuery(e) {
26504    return super.prefetchInfiniteQuery(Ce(e));
26505  }
26506  setDefaultOptions(e) {
26507    super.setDefaultOptions(Ce(e));
26508  }
26509  setQueryDefaults(e, t) {
26510    super.setQueryDefaults(Ce(e), Ce(t));
26511  }
26512  getQueryDefaults(e) {
26513    return super.getQueryDefaults(Ce(e));
26514  }
26515  setMutationDefaults(e, t) {
26516    super.setMutationDefaults(
26517      Ce(e),
26518      Ce(t)
26519    );
26520  }
26521  getMutationDefaults(e) {
26522    return super.getMutationDefaults(Ce(e));
26523  }
26524}, tv = {
26525  install: (e, t = {}) => {
26526    const n = KA(t.queryClientKey);
26527    let r;
26528    if ("queryClient" in t && t.queryClient)
26529      r = t.queryClient;
26530    else {
26531      const o = "queryClientConfig" in t ? t.queryClientConfig : void 0;
26532      r = new ev(o);
26533    }
26534    Ff || r.mount();
26535    let s = () => {
26536    };
26537    if (t.clientPersister) {
26538      r.isRestoring && (r.isRestoring.value = !0);
26539      const [o, a] = t.clientPersister(r);
26540      s = o, a.then(() => {
26541        r.isRestoring && (r.isRestoring.value = !1), t.clientPersisterOnSuccess?.(r);
26542      });
26543    }
26544    const i = () => {
26545      r.unmount(), s();
26546    };
26547    if (e.onUnmount)
26548      e.onUnmount(i);
26549    else {
26550      const o = e.unmount;
26551      e.unmount = function() {
26552        i(), o();
26553      };
26554    }
26555    e.provide(n, r);
26556  }
26557};
26558const nv = /* @__PURE__ */ Symbol(), rv = {
26559  install(e, t) {
26560    const { config: n, reconnectOnMount: r = !0 } = t;
26561    e.provide(nv, n);
26562    const { onMount: s } = mA(n, { ...t, reconnectOnMount: r });
26563    s();
26564  }
26565}, Kf = (e, t) => {
26566  const n = e;
26567  if (n.__errorSinkArmed__)
26568    return;
26569  Object.defineProperty(n, "__errorSinkArmed__", { configurable: !0, value: !0 });
26570  let r = !1;
26571  const s = (o) => {
26572    r || (r = !0, Nr.trackEvent("error", "web3_init", {
26573      message: o instanceof Error ? o.message : "non-error rejection",
26574      params: ["relayer_socket_error", t]
26575    }));
26576  };
26577  let i = n.provider;
26578  i.on?.("error", s), Object.defineProperty(n, "provider", {
26579    configurable: !0,
26580    enumerable: !0,
26581    get: () => i,
26582    set: (o) => {
26583      o !== i && (i = o, o.on?.("error", s));
26584    }
26585  });
26586}, ml = "__APPKIT_SINGLETON__";
26587let gl = !1;
26588const Yf = (e) => {
26589  Nr.trackEvent("error", "web3_init", {
26590    message: e instanceof Error ? e.message : "non-error rejection",
26591    params: ["relayer_sink_arm_failed", "external"]
26592  });
26593}, yl = (e) => {
26594  try {
26595    const t = e?.client?.core?.relayer;
26596    t && Kf(t, "external");
26597  } catch (t) {
26598    Yf(t);
26599  }
26600}, sv = (e) => {
26601  if (e.universalProvider) {
26602    yl(e.universalProvider);
26603    return;
26604  }
26605  let t;
26606  Object.defineProperty(e, "universalProvider", {
26607    configurable: !0,
26608    enumerable: !0,
26609    get: () => t,
26610    set: (n) => {
26611      t = n, yl(n);
26612    }
26613  });
26614}, iv = () => {
26615  if (!gl) {
26616    gl = !0;
26617    try {
26618      const e = globalThis;
26619      let t = e[ml];
26620      const n = (r) => {
26621        r?.appkit && sv(r.appkit);
26622      };
26623      n(t), Object.defineProperty(e, ml, {
26624        configurable: !0,
26625        enumerable: !0,
26626        get: () => t,
26627        set: (r) => {
26628          t = r, n(r);
26629        }
26630      });
26631    } catch (e) {
26632      Yf(e);
26633    }
26634  }
26635}, Zf = /* @__PURE__ */ Symbol.for("WEB3_ADAPTER"), Qf = /* @__PURE__ */ Symbol.for("WEB3_TRON_ADAPTER"), Jf = /* @__PURE__ */ Symbol.for("WEB3_NETWORKS"), ov = "__APPKIT_SINGLETON__", bl = {
26636  "BEP-20": af,
26637  "ERC-20": cf,
26638  "TRC-20": cy
26639}, Xf = () => globalThis[ov];
26640let cn, wl = !1;
26641const av = async () => {
26642  const e = Xf();
26643  if (!e)
26644    return;
26645  const t = performance.now();
26646  iv();
26647  try {
26648    cn = await e.getAppkit?.();
26649    try {
26650      const n = await cn?.appkit.getUniversalProvider();
26651      n && Kf(n.client.core.relayer, "external");
26652    } catch (n) {
26653      Nr.trackEvent("error", "web3_init", {
26654        message: n instanceof Error ? n.message : "non-error rejection",
26655        params: ["relayer_sink_arm_failed", "external"]
26656      });
26657    }
26658    await cn?.appkit.ready(), wl || (wl = !0, Nr.trackEvent("info", "web3_init", {
26659      params: ["external_wc_init_ready", cn ? "external" : "local", {
26660        ms: Math.round(performance.now() - t)
26661      }]
26662    }));
26663  } catch (n) {
26664    dh().isWeb3InitFailed = !0, Nr.trackEvent("error", "web3_init", {
26665      params: ["external_wc_init_failed", "local", {
26666        ms: Math.round(performance.now() - t),
26667        error: n instanceof Error ? n.message : "non-error rejection"
26668      }]
26669    }), Nr.captureError(n);
26670  }
26671  return cn;
26672}, eh = /* @__PURE__ */ new Set();
26673let on;
26674const cv = () => new kE({
26675  walletAdapters: [],
26676  projectId: Al
26677}), Cl = ({
26678  app: e,
26679  wagmiAdapter: t,
26680  tronAdapter: n,
26681  networks: r
26682}) => {
26683  e.provide(Zf, t), e.provide(Qf, n), e.provide(Jf, r), e.use(tv), e.use(rv, { config: t.wagmiConfig }), eh.add(e);
26684}, uv = (e) => {
26685  if (on)
26686    return eh.has(e) || Cl({
26687      app: e,
26688      wagmiAdapter: on.web3Adapter,
26689      tronAdapter: on.web3TronAdapter,
26690      networks: on.web3Networks
26691    }), on;
26692  const t = cn?.wagmiAdapter ?? new EA({
26693    projectId: Al,
26694    networks: [cf, af]
26695  }), n = cn?.tronAdapter ?? cv();
26696  return Cl({
26697    app: e,
26698    wagmiAdapter: t,
26699    tronAdapter: n,
26700    networks: bl
26701  }), on = { web3Adapter: t, web3TronAdapter: n, web3Networks: bl }, on;
26702}, lv = () => Ja(Zf, void 0), dv = () => Ja(Qf, void 0), fv = () => Ja(Jf, void 0), hv = () => cn?.appkit, pv = (e, t) => cn?.controllers[e] ?? t, mv = () => {
26703  const e = lv(), t = dv(), n = fv();
26704  if (e && t && n)
26705    return {
26706      web3Adapter: e,
26707      web3TronAdapter: t,
26708      web3Networks: n
26709    };
26710  const r = fh();
26711  if (!r) {
26712    if (on)
26713      return on;
26714    throw new Error("No Vue app found in injection context.");
26715  }
26716  return uv(r);
26717}, r5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
26718  __proto__: null,
26719  ensureWagmi: mv,
26720  getExternalAppKit: hv,
26721  getExternalController: pv,
26722  getExternalSingleton: Xf,
26723  prepareExternalWeb3: av
26724}, Symbol.toStringTag, { value: "Module" }));
26725export {
26726  wv as $,
26727  rp as A,
26728  F as B,
26729  $0 as C,
26730  wg as D,
26731  Cg as E,
26732  Fh as F,
26733  zd as G,
26734  H0 as H,
26735  q0 as I,
26736  G0 as J,
26737  z0 as K,
26738  $c as L,
26739  dp as M,
26740  gs as N,
26741  gc as O,
26742  sm as P,
26743  Yn as Q,
26744  Di as R,
26745  ha as S,
26746  ts as T,
26747  ya as U,
26748  ec as V,
26749  ir as W,
26750  ba as X,
26751  wa as Y,
26752  hp as Z,
26753  fp as _,
26754  Wc as a,
26755  Lg as a$,
26756  Cv as a0,
26757  Lh as a1,
26758  sr as a2,
26759  pp as a3,
26760  yp as a4,
26761  j_ as a5,
26762  Kg as a6,
26763  mp as a7,
26764  Mh as a8,
26765  bp as a9,
26766  pc as aA,
26767  Wl as aB,
26768  wp as aC,
26769  jl as aD,
26770  kh as aE,
26771  L0 as aF,
26772  zt as aG,
26773  tu as aH,
26774  Fi as aI,
26775  F0 as aJ,
26776  od as aK,
26777  ad as aL,
26778  kr as aM,
26779  Ca as aN,
26780  ls as aO,
26781  ys as aP,
26782  ho as aQ,
26783  K0 as aR,
26784  Bh as aS,
26785  xh as aT,
26786  ms as aU,
26787  ps as aV,
26788  Iv as aW,
26789  ds as aX,
26790  ry as aY,
26791  Ke as aZ,
26792  j0 as a_,
26793  Pr as aa,
26794  Dv as ab,
26795  Uh as ac,
26796  Ph as ad,
26797  as as ae,
26798  jh as af,
26799  is as ag,
26800  D0 as ah,
26801  Wr as ai,
26802  Fv as aj,
26803  Dh as ak,
26804  us as al,
26805  Ur as am,
26806  lm as an,
26807  os as ao,
26808  Kn as ap,
26809  ga as aq,
26810  pa as ar,
26811  ma as as,
26812  ss as at,
26813  fs as au,
26814  mt as av,
26815  cd as aw,
26816  cs as ax,
26817  Pn as ay,
26818  pt as az,
26819  Dl as b,
26820  Ln as b$,
26821  Ys as b0,
26822  Cd as b1,
26823  Ed as b2,
26824  _p as b3,
26825  Hl as b4,
26826  A0 as b5,
26827  v0 as b6,
26828  ft as b7,
26829  ln as b8,
26830  _0 as b9,
26831  $_ as bA,
26832  yu as bB,
26833  yd as bC,
26834  fc as bD,
26835  dt as bE,
26836  Cc as bF,
26837  go as bG,
26838  ef as bH,
26839  Ks as bI,
26840  zs as bJ,
26841  Pv as bK,
26842  uc as bL,
26843  Vn as bM,
26844  Eg as bN,
26845  Z0 as bO,
26846  sc as bP,
26847  n0 as bQ,
26848  cc as bR,
26849  Om as bS,
26850  U0 as bT,
26851  nr as bU,
26852  Cp as bV,
26853  Pt as bW,
26854  Bn as bX,
26855  $l as bY,
26856  Gt as bZ,
26857  km as b_,
26858  Gs as ba,
26859  _m as bb,
26860  Nm as bc,
26861  Dn as bd,
26862  s0 as be,
26863  lo as bf,
26864  nf as bg,
26865  Nc as bh,
26866  ey as bi,
26867  fo as bj,
26868  P0 as bk,
26869  cu as bl,
26870  xd as bm,
26871  Gv as bn,
26872  qv as bo,
26873  W_ as bp,
26874  $v as bq,
26875  gg as br,
26876  yg as bs,
26877  nd as bt,
26878  Vd as bu,
26879  lc as bv,
26880  oi as bw,
26881  D_ as bx,
26882  F_ as by,
26883  k0 as bz,
26884  Xa as c,
26885  Ye as c$,
26886  Hs as c0,
26887  Hv as c1,
26888  um as c2,
26889  ji as c3,
26890  Np as c4,
26891  be as c5,
26892  $r as c6,
26893  gp as c7,
26894  On as c8,
26895  Ml as c9,
26896  ke as cA,
26897  Zd as cB,
26898  Vl as cC,
26899  kv as cD,
26900  nc as cE,
26901  rr as cF,
26902  Li as cG,
26903  Or as cH,
26904  av as cI,
26905  v as cJ,
26906  ve as cK,
26907  q as cL,
26908  Sn as cM,
26909  Qe as cN,
26910  z as cO,
26911  Ic as cP,
26912  Sf as cQ,
26913  ce as cR,
26914  Je as cS,
26915  tt as cT,
26916  Me as cU,
26917  hc as cV,
26918  Mt as cW,
26919  ie as cX,
26920  J as cY,
26921  x as cZ,
26922  Et as c_,
26923  Mm as ca,
26924  Yg as cb,
26925  g0 as cc,
26926  X0 as cd,
26927  J0 as ce,
26928  om as cf,
26929  vm as cg,
26930  ty as ch,
26931  Ze as ci,
26932  Bi as cj,
26933  td as ck,
26934  i0 as cl,
26935  ql as cm,
26936  tc as cn,
26937  At as co,
26938  xm as cp,
26939  Rm as cq,
26940  co as cr,
26941  Jl as cs,
26942  ns as ct,
26943  em as cu,
26944  gd as cv,
26945  Xn as cw,
26946  Og as cx,
26947  qi as cy,
26948  sf as cz,
26949  rf as d,
26950  St as d$,
26951  XC as d0,
26952  Ar as d1,
26953  Oc as d2,
26954  H as d3,
26955  Gi as d4,
26956  te as d5,
26957  Rn as d6,
26958  Q as d7,
26959  ee as d8,
26960  Mn as d9,
26961  Jv as dA,
26962  kd as dB,
26963  Wm as dC,
26964  Xv as dD,
26965  u_ as dE,
26966  Mv as dF,
26967  Uv as dG,
26968  Em as dH,
26969  Wt as dI,
26970  o0 as dJ,
26971  Bv as dK,
26972  hE as dL,
26973  SC as dM,
26974  vn as dN,
26975  zg as dO,
26976  Z_ as dP,
26977  Fs as dQ,
26978  LE as dR,
26979  vt as dS,
26980  _n as dT,
26981  Ao as dU,
26982  zi as dV,
26983  Ve as dW,
26984  ye as dX,
26985  Ri as dY,
26986  bt as dZ,
26987  lr as d_,
26988  P_ as da,
26989  b0 as db,
26990  Da as dc,
26991  bi as dd,
26992  Sm as de,
26993  Zv as df,
26994  Im as dg,
26995  Qv as dh,
26996  Ns as di,
26997  W as dj,
26998  Se as dk,
26999  t_ as dl,
27000  e_ as dm,
27001  n_ as dn,
27002  Dm as dp,
27003  o_ as dq,
27004  c_ as dr,
27005  Mi as ds,
27006  i_ as dt,
27007  Fm as du,
27008  s_ as dv,
27009  r_ as dw,
27010  Ud as dx,
27011  Ac as dy,
27012  a_ as dz,
27013  sp as e,
27014  Wd as e$,
27015  oo as e0,
27016  Si as e1,
27017  sn as e2,
27018  JC as e3,
27019  Ds as e4,
27020  Cy as e5,
27021  wt as e6,
27022  Xs as e7,
27023  Jn as e8,
27024  Y_ as e9,
27025  M_ as eA,
27026  U_ as eB,
27027  po as eC,
27028  Ag as eD,
27029  Lv as eE,
27030  fd as eF,
27031  qs as eG,
27032  Jp as eH,
27033  d_ as eI,
27034  Br as eJ,
27035  x_ as eK,
27036  Dr as eL,
27037  w_ as eM,
27038  A_ as eN,
27039  an as eO,
27040  T_ as eP,
27041  De as eQ,
27042  v_ as eR,
27043  Dd as eS,
27044  Fd as eT,
27045  f_ as eU,
27046  y_ as eV,
27047  p_ as eW,
27048  g_ as eX,
27049  m_ as eY,
27050  b_ as eZ,
27051  ng as e_,
27052  _c as ea,
27053  bc as eb,
27054  fm as ec,
27055  Yv as ed,
27056  Kv as ee,
27057  Vs as ef,
27058  Vv as eg,
27059  hd as eh,
27060  Wi as ei,
27061  Jd as ej,
27062  Am as ek,
27063  $h as el,
27064  ep as em,
27065  xl as en,
27066  Tt as eo,
27067  tr as ep,
27068  bv as eq,
27069  m0 as er,
27070  Rd as es,
27071  Ug as et,
27072  kg as eu,
27073  Mg as ev,
27074  Dg as ew,
27075  Kd as ex,
27076  L_ as ey,
27077  k_ as ez,
27078  ip as f,
27079  Va as f$,
27080  __ as f0,
27081  lg as f1,
27082  $d as f2,
27083  N_ as f3,
27084  fu as f4,
27085  zr as f5,
27086  S_ as f6,
27087  ug as f7,
27088  of as f8,
27089  bg as f9,
27090  mb as fA,
27091  G_ as fB,
27092  cb as fC,
27093  fb as fD,
27094  lb as fE,
27095  q_ as fF,
27096  z_ as fG,
27097  V_ as fH,
27098  K_ as fI,
27099  Of as fJ,
27100  Pf as fK,
27101  hn as fL,
27102  un as fM,
27103  xr as fN,
27104  pv as fO,
27105  mv as fP,
27106  hv as fQ,
27107  Kf as fR,
27108  vo as fS,
27109  LA as fT,
27110  RA as fU,
27111  Q_ as fV,
27112  Ka as fW,
27113  It as fX,
27114  $f as fY,
27115  TA as fZ,
27116  SA as f_,
27117  pg as fa,
27118  mc as fb,
27119  mh as fc,
27120  B_ as fd,
27121  Lr as fe,
27122  jv as ff,
27123  Jg as fg,
27124  Zg as fh,
27125  Qg as fi,
27126  Bg as fj,
27127  wc as fk,
27128  Wo as fl,
27129  Pm as fm,
27130  zv as fn,
27131  bd as fo,
27132  jg as fp,
27133  Fg as fq,
27134  bb as fr,
27135  lt as fs,
27136  Rf as ft,
27137  Qn as fu,
27138  xn as fv,
27139  BC as fw,
27140  tE as fx,
27141  hh as fy,
27142  vy as fz,
27143  op as g,
27144  Df as g0,
27145  $A as g1,
27146  PA as g2,
27147  ot as g3,
27148  Ws as g4,
27149  GA as g5,
27150  KA as g6,
27151  Ce as g7,
27152  n5 as g8,
27153  J_ as g9,
27154  Hn as ga,
27155  jE as gb,
27156  WE as gc,
27157  HE as gd,
27158  qE as ge,
27159  QE as gf,
27160  nv as gg,
27161  Oi as gh,
27162  VE as gi,
27163  jt as gj,
27164  O_ as gk,
27165  h_ as gl,
27166  l_ as gm,
27167  Hd as gn,
27168  R_ as go,
27169  cg as gp,
27170  I_ as gq,
27171  Xd as gr,
27172  Hi as gs,
27173  af as gt,
27174  cf as gu,
27175  Ay as gv,
27176  r5 as gw,
27177  li as h,
27178  Ev as i,
27179  Av as j,
27180  Fl as k,
27181  vv as l,
27182  ap as m,
27183  cp as n,
27184  Ui as o,
27185  up as p,
27186  _v as q,
27187  M0 as r,
27188  ws as s,
27189  Cs as t,
27190  pd as u,
27191  md as v,
27192  bs as w,
27193  Nv as x,
27194  hs as y,
27195  va as z
27196};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.