@chainrails/react 0.0.36 → 0.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,56 +1,56 @@
1
- import { useState as le, useRef as W, useEffect as F, useMemo as te, useSyncExternalStore as ke, useCallback as Ne, useLayoutEffect as qe, useDebugValue as _e } from "react";
2
- import { jsx as S, Fragment as Ue, jsxs as se } from "react/jsx-runtime";
3
- import './index.css';class D extends Error {
1
+ import { useState as Fe, useRef as he, useEffect as de, useMemo as ve, useSyncExternalStore as Ot, useCallback as Dt, useLayoutEffect as Nt, useDebugValue as Mt } from "react";
2
+ import { jsx as U, Fragment as Bt, jsxs as Pe } from "react/jsx-runtime";
3
+ import './index.css';class X extends Error {
4
4
  response;
5
5
  request;
6
6
  options;
7
- constructor(e, s, r) {
8
- const n = e.status || e.status === 0 ? e.status : "", i = e.statusText ?? "", o = `${n} ${i}`.trim(), a = o ? `status code ${o}` : "an unknown error";
9
- super(`Request failed with ${a}: ${s.method} ${s.url}`), this.name = "HTTPError", this.response = e, this.request = s, this.options = r;
7
+ constructor(t, s, n) {
8
+ const r = t.status || t.status === 0 ? t.status : "", i = t.statusText ?? "", o = `${r} ${i}`.trim(), a = o ? `status code ${o}` : "an unknown error";
9
+ super(`Request failed with ${a}: ${s.method} ${s.url}`), this.name = "HTTPError", this.response = t, this.request = s, this.options = n;
10
10
  }
11
11
  }
12
- class fe extends Error {
12
+ class He extends Error {
13
13
  name = "NonError";
14
14
  value;
15
- constructor(e) {
15
+ constructor(t) {
16
16
  let s = "Non-error value was thrown";
17
17
  try {
18
- typeof e == "string" ? s = e : e && typeof e == "object" && "message" in e && typeof e.message == "string" && (s = e.message);
18
+ typeof t == "string" ? s = t : t && typeof t == "object" && "message" in t && typeof t.message == "string" && (s = t.message);
19
19
  } catch {
20
20
  }
21
- super(s), this.value = e;
21
+ super(s), this.value = t;
22
22
  }
23
23
  }
24
- class M extends Error {
24
+ class F extends Error {
25
25
  name = "ForceRetryError";
26
26
  customDelay;
27
27
  code;
28
28
  customRequest;
29
- constructor(e) {
30
- const s = e?.cause ? e.cause instanceof Error ? e.cause : new fe(e.cause) : void 0;
31
- super(e?.code ? `Forced retry: ${e.code}` : "Forced retry", s ? { cause: s } : void 0), this.customDelay = e?.delay, this.code = e?.code, this.customRequest = e?.request;
29
+ constructor(t) {
30
+ const s = t?.cause ? t.cause instanceof Error ? t.cause : new He(t.cause) : void 0;
31
+ super(t?.code ? `Forced retry: ${t.code}` : "Forced retry", s ? { cause: s } : void 0), this.customDelay = t?.delay, this.code = t?.code, this.customRequest = t?.request;
32
32
  }
33
33
  }
34
- const re = (() => {
35
- let t = !1, e = !1;
36
- const s = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function";
37
- if (s && r)
34
+ const Ue = (() => {
35
+ let e = !1, t = !1;
36
+ const s = typeof globalThis.ReadableStream == "function", n = typeof globalThis.Request == "function";
37
+ if (s && n)
38
38
  try {
39
- e = new globalThis.Request("https://empty.invalid", {
39
+ t = new globalThis.Request("https://empty.invalid", {
40
40
  body: new globalThis.ReadableStream(),
41
41
  method: "POST",
42
42
  // @ts-expect-error - Types are outdated.
43
43
  get duplex() {
44
- return t = !0, "half";
44
+ return e = !0, "half";
45
45
  }
46
46
  }).headers.has("Content-Type");
47
- } catch (n) {
48
- if (n instanceof Error && n.message === "unsupported BodyInit type")
47
+ } catch (r) {
48
+ if (r instanceof Error && r.message === "unsupported BodyInit type")
49
49
  return !1;
50
- throw n;
50
+ throw r;
51
51
  }
52
- return t && !e;
53
- })(), je = typeof globalThis.AbortController == "function", he = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", Me = typeof globalThis.ReadableStream == "function", xe = typeof globalThis.FormData == "function", de = ["get", "post", "put", "patch", "head", "delete"], Le = {
52
+ return e && !t;
53
+ })(), $t = typeof globalThis.AbortController == "function", Ke = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", _t = typeof globalThis.ReadableStream == "function", Lt = typeof globalThis.FormData == "function", We = ["get", "post", "put", "patch", "head", "delete"], zt = {
54
54
  json: "application/json",
55
55
  text: "text/*",
56
56
  formData: "multipart/form-data",
@@ -59,14 +59,14 @@ const re = (() => {
59
59
  // Supported in modern Fetch implementations (for example, browsers and recent Node.js/undici).
60
60
  // We still feature-check at runtime before exposing the shortcut.
61
61
  bytes: "*/*"
62
- }, x = 2147483647, De = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, pe = Symbol("stop");
63
- class ye {
62
+ }, H = 2147483647, jt = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, Ve = Symbol("stop");
63
+ class Ye {
64
64
  options;
65
- constructor(e) {
66
- this.options = e;
65
+ constructor(t) {
66
+ this.options = t;
67
67
  }
68
68
  }
69
- const Ie = (t) => new ye(t), Be = {
69
+ const qt = (e) => new Ye(e), Ft = {
70
70
  json: !0,
71
71
  parseJson: !0,
72
72
  stringifyJson: !0,
@@ -80,10 +80,10 @@ const Ie = (t) => new ye(t), Be = {
80
80
  onUploadProgress: !0,
81
81
  fetch: !0,
82
82
  context: !0
83
- }, He = {
83
+ }, Ht = {
84
84
  next: !0
85
85
  // Next.js cache revalidation (revalidate, tags)
86
- }, Ke = {
86
+ }, Kt = {
87
87
  method: !0,
88
88
  headers: !0,
89
89
  body: !0,
@@ -98,243 +98,243 @@ const Ie = (t) => new ye(t), Be = {
98
98
  signal: !0,
99
99
  window: !0,
100
100
  duplex: !0
101
- }, $e = (t) => {
102
- if (!t)
101
+ }, Wt = (e) => {
102
+ if (!e)
103
103
  return 0;
104
- if (t instanceof FormData) {
105
- let e = 0;
106
- for (const [s, r] of t)
107
- e += De, e += new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).length, e += typeof r == "string" ? new TextEncoder().encode(r).length : r.size;
108
- return e;
104
+ if (e instanceof FormData) {
105
+ let t = 0;
106
+ for (const [s, n] of e)
107
+ t += jt, t += new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).length, t += typeof n == "string" ? new TextEncoder().encode(n).length : n.size;
108
+ return t;
109
109
  }
110
- if (t instanceof Blob)
111
- return t.size;
112
- if (t instanceof ArrayBuffer)
113
- return t.byteLength;
114
- if (typeof t == "string")
115
- return new TextEncoder().encode(t).length;
116
- if (t instanceof URLSearchParams)
117
- return new TextEncoder().encode(t.toString()).length;
118
- if ("byteLength" in t)
119
- return t.byteLength;
120
- if (typeof t == "object" && t !== null)
110
+ if (e instanceof Blob)
111
+ return e.size;
112
+ if (e instanceof ArrayBuffer)
113
+ return e.byteLength;
114
+ if (typeof e == "string")
115
+ return new TextEncoder().encode(e).length;
116
+ if (e instanceof URLSearchParams)
117
+ return new TextEncoder().encode(e.toString()).length;
118
+ if ("byteLength" in e)
119
+ return e.byteLength;
120
+ if (typeof e == "object" && e !== null)
121
121
  try {
122
- const e = JSON.stringify(t);
123
- return new TextEncoder().encode(e).length;
122
+ const t = JSON.stringify(e);
123
+ return new TextEncoder().encode(t).length;
124
124
  } catch {
125
125
  return 0;
126
126
  }
127
127
  return 0;
128
- }, ge = (t, e, s) => {
129
- let r, n = 0;
130
- return t.pipeThrough(new TransformStream({
128
+ }, Xe = (e, t, s) => {
129
+ let n, r = 0;
130
+ return e.pipeThrough(new TransformStream({
131
131
  transform(i, o) {
132
- if (o.enqueue(i), r) {
133
- n += r.byteLength;
134
- let a = e === 0 ? 0 : n / e;
135
- a >= 1 && (a = 1 - Number.EPSILON), s?.({ percent: a, totalBytes: Math.max(e, n), transferredBytes: n }, r);
132
+ if (o.enqueue(i), n) {
133
+ r += n.byteLength;
134
+ let a = t === 0 ? 0 : r / t;
135
+ a >= 1 && (a = 1 - Number.EPSILON), s?.({ percent: a, totalBytes: Math.max(t, r), transferredBytes: r }, n);
136
136
  }
137
- r = i;
137
+ n = i;
138
138
  },
139
139
  flush() {
140
- r && (n += r.byteLength, s?.({ percent: 1, totalBytes: Math.max(e, n), transferredBytes: n }, r));
140
+ n && (r += n.byteLength, s?.({ percent: 1, totalBytes: Math.max(t, r), transferredBytes: r }, n));
141
141
  }
142
142
  }));
143
- }, We = (t, e) => {
144
- if (!t.body)
145
- return t;
146
- if (t.status === 204)
143
+ }, Vt = (e, t) => {
144
+ if (!e.body)
145
+ return e;
146
+ if (e.status === 204)
147
147
  return new Response(null, {
148
- status: t.status,
149
- statusText: t.statusText,
150
- headers: t.headers
148
+ status: e.status,
149
+ statusText: e.statusText,
150
+ headers: e.headers
151
151
  });
152
- const s = Math.max(0, Number(t.headers.get("content-length")) || 0);
153
- return new Response(ge(t.body, s, e), {
154
- status: t.status,
155
- statusText: t.statusText,
156
- headers: t.headers
152
+ const s = Math.max(0, Number(e.headers.get("content-length")) || 0);
153
+ return new Response(Xe(e.body, s, t), {
154
+ status: e.status,
155
+ statusText: e.statusText,
156
+ headers: e.headers
157
157
  });
158
- }, Fe = (t, e, s) => {
159
- if (!t.body)
160
- return t;
161
- const r = $e(s ?? t.body);
162
- return new Request(t, {
158
+ }, Yt = (e, t, s) => {
159
+ if (!e.body)
160
+ return e;
161
+ const n = Wt(s ?? e.body);
162
+ return new Request(e, {
163
163
  // @ts-expect-error - Types are outdated.
164
164
  duplex: "half",
165
- body: ge(t.body, r, e)
165
+ body: Xe(e.body, n, t)
166
166
  });
167
- }, E = (t) => t !== null && typeof t == "object", k = (...t) => {
168
- for (const e of t)
169
- if ((!E(e) || Array.isArray(e)) && e !== void 0)
167
+ }, v = (e) => e !== null && typeof e == "object", N = (...e) => {
168
+ for (const t of e)
169
+ if ((!v(t) || Array.isArray(t)) && t !== void 0)
170
170
  throw new TypeError("The `options` argument must be an object");
171
- return Y({}, ...t);
172
- }, me = (t = {}, e = {}) => {
173
- const s = new globalThis.Headers(t), r = e instanceof globalThis.Headers, n = new globalThis.Headers(e);
174
- for (const [i, o] of n.entries())
175
- r && o === "undefined" || o === void 0 ? s.delete(i) : s.set(i, o);
171
+ return pe({}, ...e);
172
+ }, Je = (e = {}, t = {}) => {
173
+ const s = new globalThis.Headers(e), n = t instanceof globalThis.Headers, r = new globalThis.Headers(t);
174
+ for (const [i, o] of r.entries())
175
+ n && o === "undefined" || o === void 0 ? s.delete(i) : s.set(i, o);
176
176
  return s;
177
177
  };
178
- function N(t, e, s) {
179
- return Object.hasOwn(e, s) && e[s] === void 0 ? [] : Y(t[s] ?? [], e[s] ?? []);
180
- }
181
- const we = (t = {}, e = {}) => ({
182
- beforeRequest: N(t, e, "beforeRequest"),
183
- beforeRetry: N(t, e, "beforeRetry"),
184
- afterResponse: N(t, e, "afterResponse"),
185
- beforeError: N(t, e, "beforeError")
186
- }), Ye = (t, e) => {
178
+ function M(e, t, s) {
179
+ return Object.hasOwn(t, s) && t[s] === void 0 ? [] : pe(e[s] ?? [], t[s] ?? []);
180
+ }
181
+ const Ge = (e = {}, t = {}) => ({
182
+ beforeRequest: M(e, t, "beforeRequest"),
183
+ beforeRetry: M(e, t, "beforeRetry"),
184
+ afterResponse: M(e, t, "afterResponse"),
185
+ beforeError: M(e, t, "beforeError")
186
+ }), Xt = (e, t) => {
187
187
  const s = new URLSearchParams();
188
- for (const r of [t, e])
189
- if (r !== void 0)
190
- if (r instanceof URLSearchParams)
191
- for (const [n, i] of r.entries())
192
- s.append(n, i);
193
- else if (Array.isArray(r))
194
- for (const n of r) {
195
- if (!Array.isArray(n) || n.length !== 2)
188
+ for (const n of [e, t])
189
+ if (n !== void 0)
190
+ if (n instanceof URLSearchParams)
191
+ for (const [r, i] of n.entries())
192
+ s.append(r, i);
193
+ else if (Array.isArray(n))
194
+ for (const r of n) {
195
+ if (!Array.isArray(r) || r.length !== 2)
196
196
  throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
197
- s.append(String(n[0]), String(n[1]));
197
+ s.append(String(r[0]), String(r[1]));
198
198
  }
199
- else if (E(r))
200
- for (const [n, i] of Object.entries(r))
201
- i !== void 0 && s.append(n, String(i));
199
+ else if (v(n))
200
+ for (const [r, i] of Object.entries(n))
201
+ i !== void 0 && s.append(r, String(i));
202
202
  else {
203
- const n = new URLSearchParams(r);
204
- for (const [i, o] of n.entries())
203
+ const r = new URLSearchParams(n);
204
+ for (const [i, o] of r.entries())
205
205
  s.append(i, o);
206
206
  }
207
207
  return s;
208
- }, Y = (...t) => {
209
- let e = {}, s = {}, r = {}, n;
208
+ }, pe = (...e) => {
209
+ let t = {}, s = {}, n = {}, r;
210
210
  const i = [];
211
- for (const o of t)
211
+ for (const o of e)
212
212
  if (Array.isArray(o))
213
- Array.isArray(e) || (e = []), e = [...e, ...o];
214
- else if (E(o)) {
213
+ Array.isArray(t) || (t = []), t = [...t, ...o];
214
+ else if (v(o)) {
215
215
  for (let [a, c] of Object.entries(o)) {
216
216
  if (a === "signal" && c instanceof globalThis.AbortSignal) {
217
217
  i.push(c);
218
218
  continue;
219
219
  }
220
220
  if (a === "context") {
221
- if (c != null && (!E(c) || Array.isArray(c)))
221
+ if (c != null && (!v(c) || Array.isArray(c)))
222
222
  throw new TypeError("The `context` option must be an object");
223
- e = {
224
- ...e,
225
- context: c == null ? {} : { ...e.context, ...c }
223
+ t = {
224
+ ...t,
225
+ context: c == null ? {} : { ...t.context, ...c }
226
226
  };
227
227
  continue;
228
228
  }
229
229
  if (a === "searchParams") {
230
- c == null ? n = void 0 : n = n === void 0 ? c : Ye(n, c);
230
+ c == null ? r = void 0 : r = r === void 0 ? c : Xt(r, c);
231
231
  continue;
232
232
  }
233
- E(c) && a in e && (c = Y(e[a], c)), e = { ...e, [a]: c };
233
+ v(c) && a in t && (c = pe(t[a], c)), t = { ...t, [a]: c };
234
234
  }
235
- E(o.hooks) && (r = we(r, o.hooks), e.hooks = r), E(o.headers) && (s = me(s, o.headers), e.headers = s);
235
+ v(o.hooks) && (n = Ge(n, o.hooks), t.hooks = n), v(o.headers) && (s = Je(s, o.headers), t.headers = s);
236
236
  }
237
- return n !== void 0 && (e.searchParams = n), i.length > 0 && (i.length === 1 ? e.signal = i[0] : he ? e.signal = AbortSignal.any(i) : e.signal = i.at(-1)), e.context === void 0 && (e.context = {}), e;
238
- }, ze = (t) => de.includes(t) ? t.toUpperCase() : t, Ve = ["get", "put", "head", "delete", "options", "trace"], Je = [408, 413, 429, 500, 502, 503, 504], Ge = [413, 429, 503], ne = {
237
+ return r !== void 0 && (t.searchParams = r), i.length > 0 && (i.length === 1 ? t.signal = i[0] : Ke ? t.signal = AbortSignal.any(i) : t.signal = i.at(-1)), t.context === void 0 && (t.context = {}), t;
238
+ }, Jt = (e) => We.includes(e) ? e.toUpperCase() : e, Gt = ["get", "put", "head", "delete", "options", "trace"], Zt = [408, 413, 429, 500, 502, 503, 504], Qt = [413, 429, 503], Ce = {
239
239
  limit: 2,
240
- methods: Ve,
241
- statusCodes: Je,
242
- afterStatusCodes: Ge,
240
+ methods: Gt,
241
+ statusCodes: Zt,
242
+ afterStatusCodes: Qt,
243
243
  maxRetryAfter: Number.POSITIVE_INFINITY,
244
244
  backoffLimit: Number.POSITIVE_INFINITY,
245
- delay: (t) => 0.3 * 2 ** (t - 1) * 1e3,
245
+ delay: (e) => 0.3 * 2 ** (e - 1) * 1e3,
246
246
  jitter: void 0,
247
247
  retryOnTimeout: !1
248
- }, Xe = (t = {}) => {
249
- if (typeof t == "number")
248
+ }, es = (e = {}) => {
249
+ if (typeof e == "number")
250
250
  return {
251
- ...ne,
252
- limit: t
251
+ ...Ce,
252
+ limit: e
253
253
  };
254
- if (t.methods && !Array.isArray(t.methods))
254
+ if (e.methods && !Array.isArray(e.methods))
255
255
  throw new Error("retry.methods must be an array");
256
- if (t.statusCodes && !Array.isArray(t.statusCodes))
256
+ if (e.statusCodes && !Array.isArray(e.statusCodes))
257
257
  throw new Error("retry.statusCodes must be an array");
258
258
  return {
259
- ...ne,
260
- ...t
259
+ ...Ce,
260
+ ...e
261
261
  };
262
262
  };
263
- class I extends Error {
263
+ class J extends Error {
264
264
  request;
265
- constructor(e) {
266
- super(`Request timed out: ${e.method} ${e.url}`), this.name = "TimeoutError", this.request = e;
265
+ constructor(t) {
266
+ super(`Request timed out: ${t.method} ${t.url}`), this.name = "TimeoutError", this.request = t;
267
267
  }
268
268
  }
269
- async function Ze(t, e, s, r) {
270
- return new Promise((n, i) => {
269
+ async function ts(e, t, s, n) {
270
+ return new Promise((r, i) => {
271
271
  const o = setTimeout(() => {
272
- s && s.abort(), i(new I(t));
273
- }, r.timeout);
274
- r.fetch(t, e).then(n).catch(i).then(() => {
272
+ s && s.abort(), i(new J(e));
273
+ }, n.timeout);
274
+ n.fetch(e, t).then(r).catch(i).then(() => {
275
275
  clearTimeout(o);
276
276
  });
277
277
  });
278
278
  }
279
- async function Qe(t, { signal: e }) {
280
- return new Promise((s, r) => {
281
- e && (e.throwIfAborted(), e.addEventListener("abort", n, { once: !0 }));
282
- function n() {
283
- clearTimeout(i), r(e.reason);
279
+ async function ss(e, { signal: t }) {
280
+ return new Promise((s, n) => {
281
+ t && (t.throwIfAborted(), t.addEventListener("abort", r, { once: !0 }));
282
+ function r() {
283
+ clearTimeout(i), n(t.reason);
284
284
  }
285
285
  const i = setTimeout(() => {
286
- e?.removeEventListener("abort", n), s();
287
- }, t);
286
+ t?.removeEventListener("abort", r), s();
287
+ }, e);
288
288
  });
289
289
  }
290
- const et = (t, e) => {
290
+ const ns = (e, t) => {
291
291
  const s = {};
292
- for (const r in e)
293
- Object.hasOwn(e, r) && !(r in Ke) && !(r in Be) && (!(r in t) || r in He) && (s[r] = e[r]);
292
+ for (const n in t)
293
+ Object.hasOwn(t, n) && !(n in Kt) && !(n in Ft) && (!(n in e) || n in Ht) && (s[n] = t[n]);
294
294
  return s;
295
- }, tt = (t) => t === void 0 ? !1 : Array.isArray(t) ? t.length > 0 : t instanceof URLSearchParams ? t.size > 0 : typeof t == "object" ? Object.keys(t).length > 0 : typeof t == "string" ? t.trim().length > 0 : !!t;
296
- function st(t) {
297
- return t instanceof D || t?.name === D.name;
295
+ }, rs = (e) => e === void 0 ? !1 : Array.isArray(e) ? e.length > 0 : e instanceof URLSearchParams ? e.size > 0 : typeof e == "object" ? Object.keys(e).length > 0 : typeof e == "string" ? e.trim().length > 0 : !!e;
296
+ function os(e) {
297
+ return e instanceof X || e?.name === X.name;
298
298
  }
299
- function rt(t) {
300
- return t instanceof I || t?.name === I.name;
299
+ function is(e) {
300
+ return e instanceof J || e?.name === J.name;
301
301
  }
302
302
  class O {
303
- static create(e, s) {
304
- const r = new O(e, s), n = async () => {
305
- if (typeof r.#e.timeout == "number" && r.#e.timeout > x)
306
- throw new RangeError(`The \`timeout\` option cannot be greater than ${x}`);
303
+ static create(t, s) {
304
+ const n = new O(t, s), r = async () => {
305
+ if (typeof n.#e.timeout == "number" && n.#e.timeout > H)
306
+ throw new RangeError(`The \`timeout\` option cannot be greater than ${H}`);
307
307
  await Promise.resolve();
308
- let o = await r.#y();
309
- for (const a of r.#e.hooks.afterResponse) {
310
- const c = r.#l(o.clone()), u = await a(r.request, r.#a(), c, { retryCount: r.#s });
311
- if (u instanceof globalThis.Response && (o = u), u instanceof ye)
308
+ let o = await n.#g();
309
+ for (const a of n.#e.hooks.afterResponse) {
310
+ const c = n.#l(o.clone()), u = await a(n.request, n.#a(), c, { retryCount: n.#s });
311
+ if (u instanceof globalThis.Response && (o = u), u instanceof Ye)
312
312
  throw await Promise.all([
313
313
  c.body?.cancel(),
314
314
  o.body?.cancel()
315
- ]), new M(u.options);
315
+ ]), new F(u.options);
316
316
  }
317
- if (r.#l(o), !o.ok && (typeof r.#e.throwHttpErrors == "function" ? r.#e.throwHttpErrors(o.status) : r.#e.throwHttpErrors)) {
318
- let a = new D(o, r.request, r.#a());
319
- for (const c of r.#e.hooks.beforeError)
320
- a = await c(a, { retryCount: r.#s });
317
+ if (n.#l(o), !o.ok && (typeof n.#e.throwHttpErrors == "function" ? n.#e.throwHttpErrors(o.status) : n.#e.throwHttpErrors)) {
318
+ let a = new X(o, n.request, n.#a());
319
+ for (const c of n.#e.hooks.beforeError)
320
+ a = await c(a, { retryCount: n.#s });
321
321
  throw a;
322
322
  }
323
- if (r.#e.onDownloadProgress) {
324
- if (typeof r.#e.onDownloadProgress != "function")
323
+ if (n.#e.onDownloadProgress) {
324
+ if (typeof n.#e.onDownloadProgress != "function")
325
325
  throw new TypeError("The `onDownloadProgress` option must be a function");
326
- if (!Me)
326
+ if (!_t)
327
327
  throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
328
- return We(o.clone(), r.#e.onDownloadProgress);
328
+ return Vt(o.clone(), n.#e.onDownloadProgress);
329
329
  }
330
330
  return o;
331
- }, i = r.#f(n).finally(async () => {
332
- const o = r.#o, a = [];
333
- o && !o.bodyUsed && a.push(o.body?.cancel()), r.request.bodyUsed || a.push(r.request.body?.cancel()), await Promise.all(a);
331
+ }, i = n.#f(r).finally(async () => {
332
+ const o = n.#o, a = [];
333
+ o && !o.bodyUsed && a.push(o.body?.cancel()), n.request.bodyUsed || a.push(n.request.body?.cancel()), await Promise.all(a);
334
334
  });
335
- for (const [o, a] of Object.entries(Le))
335
+ for (const [o, a] of Object.entries(zt))
336
336
  o === "bytes" && typeof globalThis.Response?.prototype?.bytes != "function" || (i[o] = async () => {
337
- r.request.headers.set("accept", r.request.headers.get("accept") || a);
337
+ n.request.headers.set("accept", n.request.headers.get("accept") || a);
338
338
  const c = await i;
339
339
  if (o === "json") {
340
340
  if (c.status === 204)
@@ -347,33 +347,33 @@ class O {
347
347
  return i;
348
348
  }
349
349
  // eslint-disable-next-line unicorn/prevent-abbreviations
350
- static #d(e) {
351
- return e && typeof e == "object" && !Array.isArray(e) && !(e instanceof URLSearchParams) ? Object.fromEntries(Object.entries(e).filter(([, s]) => s !== void 0)) : e;
350
+ static #d(t) {
351
+ return t && typeof t == "object" && !Array.isArray(t) && !(t instanceof URLSearchParams) ? Object.fromEntries(Object.entries(t).filter(([, s]) => s !== void 0)) : t;
352
352
  }
353
353
  request;
354
- #r;
354
+ #n;
355
355
  #s = 0;
356
356
  // eslint-disable-next-line @typescript-eslint/prefer-readonly -- False positive: #input is reassigned on line 202
357
357
  #t;
358
358
  #e;
359
359
  #o;
360
- #n;
360
+ #r;
361
361
  #i;
362
362
  // eslint-disable-next-line complexity
363
- constructor(e, s = {}) {
364
- if (this.#t = e, this.#e = {
363
+ constructor(t, s = {}) {
364
+ if (this.#t = t, this.#e = {
365
365
  ...s,
366
- headers: me(this.#t.headers, s.headers),
367
- hooks: we({
366
+ headers: Je(this.#t.headers, s.headers),
367
+ hooks: Ge({
368
368
  beforeRequest: [],
369
369
  beforeRetry: [],
370
370
  beforeError: [],
371
371
  afterResponse: []
372
372
  }, s.hooks),
373
- method: ze(s.method ?? this.#t.method ?? "GET"),
373
+ method: Jt(s.method ?? this.#t.method ?? "GET"),
374
374
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
375
375
  prefixUrl: String(s.prefixUrl || ""),
376
- retry: Xe(s.retry),
376
+ retry: es(s.retry),
377
377
  throwHttpErrors: s.throwHttpErrors ?? !0,
378
378
  timeout: s.timeout ?? 1e4,
379
379
  fetch: s.fetch ?? globalThis.fetch.bind(globalThis),
@@ -385,73 +385,73 @@ class O {
385
385
  throw new Error("`input` must not begin with a slash when using `prefixUrl`");
386
386
  this.#e.prefixUrl.endsWith("/") || (this.#e.prefixUrl += "/"), this.#t = this.#e.prefixUrl + this.#t;
387
387
  }
388
- je && he && (this.#n = this.#e.signal ?? this.#t.signal, this.#r = new globalThis.AbortController(), this.#e.signal = this.#n ? AbortSignal.any([this.#n, this.#r.signal]) : this.#r.signal), re && (this.#e.duplex = "half"), this.#e.json !== void 0 && (this.#e.body = this.#e.stringifyJson?.(this.#e.json) ?? JSON.stringify(this.#e.json), this.#e.headers.set("content-type", this.#e.headers.get("content-type") ?? "application/json"));
389
- const r = s.headers && new globalThis.Headers(s.headers).has("content-type");
390
- if (this.#t instanceof globalThis.Request && (xe && this.#e.body instanceof globalThis.FormData || this.#e.body instanceof URLSearchParams) && !r && this.#e.headers.delete("content-type"), this.request = new globalThis.Request(this.#t, this.#e), tt(this.#e.searchParams)) {
388
+ $t && Ke && (this.#r = this.#e.signal ?? this.#t.signal, this.#n = new globalThis.AbortController(), this.#e.signal = this.#r ? AbortSignal.any([this.#r, this.#n.signal]) : this.#n.signal), Ue && (this.#e.duplex = "half"), this.#e.json !== void 0 && (this.#e.body = this.#e.stringifyJson?.(this.#e.json) ?? JSON.stringify(this.#e.json), this.#e.headers.set("content-type", this.#e.headers.get("content-type") ?? "application/json"));
389
+ const n = s.headers && new globalThis.Headers(s.headers).has("content-type");
390
+ if (this.#t instanceof globalThis.Request && (Lt && this.#e.body instanceof globalThis.FormData || this.#e.body instanceof URLSearchParams) && !n && this.#e.headers.delete("content-type"), this.request = new globalThis.Request(this.#t, this.#e), rs(this.#e.searchParams)) {
391
391
  const i = "?" + (typeof this.#e.searchParams == "string" ? this.#e.searchParams.replace(/^\?/, "") : new URLSearchParams(O.#d(this.#e.searchParams)).toString()), o = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, i);
392
392
  this.request = new globalThis.Request(o, this.#e);
393
393
  }
394
394
  if (this.#e.onUploadProgress) {
395
395
  if (typeof this.#e.onUploadProgress != "function")
396
396
  throw new TypeError("The `onUploadProgress` option must be a function");
397
- if (!re)
397
+ if (!Ue)
398
398
  throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
399
399
  this.request = this.#h(this.request, this.#e.body ?? void 0);
400
400
  }
401
401
  }
402
402
  #c() {
403
- const e = this.#e.retry.delay(this.#s);
404
- let s = e;
405
- return this.#e.retry.jitter === !0 ? s = Math.random() * e : typeof this.#e.retry.jitter == "function" && (s = this.#e.retry.jitter(e), (!Number.isFinite(s) || s < 0) && (s = e)), Math.min(this.#e.retry.backoffLimit, s);
403
+ const t = this.#e.retry.delay(this.#s);
404
+ let s = t;
405
+ return this.#e.retry.jitter === !0 ? s = Math.random() * t : typeof this.#e.retry.jitter == "function" && (s = this.#e.retry.jitter(t), (!Number.isFinite(s) || s < 0) && (s = t)), Math.min(this.#e.retry.backoffLimit, s);
406
406
  }
407
- async #p(e) {
407
+ async #p(t) {
408
408
  if (this.#s++, this.#s > this.#e.retry.limit)
409
- throw e;
410
- const s = e instanceof Error ? e : new fe(e);
411
- if (s instanceof M)
409
+ throw t;
410
+ const s = t instanceof Error ? t : new He(t);
411
+ if (s instanceof F)
412
412
  return s.customDelay ?? this.#c();
413
413
  if (!this.#e.retry.methods.includes(this.request.method.toLowerCase()))
414
- throw e;
414
+ throw t;
415
415
  if (this.#e.retry.shouldRetry !== void 0) {
416
- const r = await this.#e.retry.shouldRetry({ error: s, retryCount: this.#s });
417
- if (r === !1)
418
- throw e;
419
- if (r === !0)
416
+ const n = await this.#e.retry.shouldRetry({ error: s, retryCount: this.#s });
417
+ if (n === !1)
418
+ throw t;
419
+ if (n === !0)
420
420
  return this.#c();
421
421
  }
422
- if (rt(e) && !this.#e.retry.retryOnTimeout)
423
- throw e;
424
- if (st(e)) {
425
- if (!this.#e.retry.statusCodes.includes(e.response.status))
426
- throw e;
427
- const r = e.response.headers.get("Retry-After") ?? e.response.headers.get("RateLimit-Reset") ?? e.response.headers.get("X-RateLimit-Retry-After") ?? e.response.headers.get("X-RateLimit-Reset") ?? e.response.headers.get("X-Rate-Limit-Reset");
428
- if (r && this.#e.retry.afterStatusCodes.includes(e.response.status)) {
429
- let n = Number(r) * 1e3;
430
- Number.isNaN(n) ? n = Date.parse(r) - Date.now() : n >= Date.parse("2024-01-01") && (n -= Date.now());
431
- const i = this.#e.retry.maxRetryAfter ?? n;
432
- return n < i ? n : i;
422
+ if (is(t) && !this.#e.retry.retryOnTimeout)
423
+ throw t;
424
+ if (os(t)) {
425
+ if (!this.#e.retry.statusCodes.includes(t.response.status))
426
+ throw t;
427
+ const n = t.response.headers.get("Retry-After") ?? t.response.headers.get("RateLimit-Reset") ?? t.response.headers.get("X-RateLimit-Retry-After") ?? t.response.headers.get("X-RateLimit-Reset") ?? t.response.headers.get("X-Rate-Limit-Reset");
428
+ if (n && this.#e.retry.afterStatusCodes.includes(t.response.status)) {
429
+ let r = Number(n) * 1e3;
430
+ Number.isNaN(r) ? r = Date.parse(n) - Date.now() : r >= Date.parse("2024-01-01") && (r -= Date.now());
431
+ const i = this.#e.retry.maxRetryAfter ?? r;
432
+ return r < i ? r : i;
433
433
  }
434
- if (e.response.status === 413)
435
- throw e;
434
+ if (t.response.status === 413)
435
+ throw t;
436
436
  }
437
437
  return this.#c();
438
438
  }
439
- #l(e) {
440
- return this.#e.parseJson && (e.json = async () => this.#e.parseJson(await e.text())), e;
439
+ #l(t) {
440
+ return this.#e.parseJson && (t.json = async () => this.#e.parseJson(await t.text())), t;
441
441
  }
442
- async #f(e) {
442
+ async #f(t) {
443
443
  try {
444
- return await e();
444
+ return await t();
445
445
  } catch (s) {
446
- const r = Math.min(await this.#p(s), x);
446
+ const n = Math.min(await this.#p(s), H);
447
447
  if (this.#s < 1)
448
448
  throw s;
449
- if (await Qe(r, this.#n ? { signal: this.#n } : {}), s instanceof M && s.customRequest) {
450
- const n = this.#e.signal ? new globalThis.Request(s.customRequest, { signal: this.#e.signal }) : new globalThis.Request(s.customRequest);
451
- this.#u(n);
449
+ if (await ss(n, this.#r ? { signal: this.#r } : {}), s instanceof F && s.customRequest) {
450
+ const r = this.#e.signal ? new globalThis.Request(s.customRequest, { signal: this.#e.signal }) : new globalThis.Request(s.customRequest);
451
+ this.#u(r);
452
452
  }
453
- for (const n of this.#e.hooks.beforeRetry) {
454
- const i = await n({
453
+ for (const r of this.#e.hooks.beforeRetry) {
454
+ const i = await r({
455
455
  request: this.request,
456
456
  options: this.#a(),
457
457
  error: s,
@@ -463,92 +463,719 @@ class O {
463
463
  }
464
464
  if (i instanceof globalThis.Response)
465
465
  return i;
466
- if (i === pe)
466
+ if (i === Ve)
467
467
  return;
468
468
  }
469
- return this.#f(e);
469
+ return this.#f(t);
470
470
  }
471
471
  }
472
- async #y() {
473
- this.#r?.signal.aborted && (this.#r = new globalThis.AbortController(), this.#e.signal = this.#n ? AbortSignal.any([this.#n, this.#r.signal]) : this.#r.signal, this.request = new globalThis.Request(this.request, { signal: this.#e.signal }));
472
+ async #g() {
473
+ this.#n?.signal.aborted && (this.#n = new globalThis.AbortController(), this.#e.signal = this.#r ? AbortSignal.any([this.#r, this.#n.signal]) : this.#n.signal, this.request = new globalThis.Request(this.request, { signal: this.#e.signal }));
474
474
  for (const s of this.#e.hooks.beforeRequest) {
475
- const r = await s(this.request, this.#a(), { retryCount: this.#s });
476
- if (r instanceof Response)
477
- return r;
478
- if (r instanceof globalThis.Request) {
479
- this.#u(r);
475
+ const n = await s(this.request, this.#a(), { retryCount: this.#s });
476
+ if (n instanceof Response)
477
+ return n;
478
+ if (n instanceof globalThis.Request) {
479
+ this.#u(n);
480
480
  break;
481
481
  }
482
482
  }
483
- const e = et(this.request, this.#e);
484
- return this.#o = this.request, this.request = this.#o.clone(), this.#e.timeout === !1 ? this.#e.fetch(this.#o, e) : Ze(this.#o, e, this.#r, this.#e);
483
+ const t = ns(this.request, this.#e);
484
+ return this.#o = this.request, this.request = this.#o.clone(), this.#e.timeout === !1 ? this.#e.fetch(this.#o, t) : ts(this.#o, t, this.#n, this.#e);
485
485
  }
486
486
  #a() {
487
487
  if (!this.#i) {
488
- const { hooks: e, ...s } = this.#e;
488
+ const { hooks: t, ...s } = this.#e;
489
489
  this.#i = Object.freeze(s);
490
490
  }
491
491
  return this.#i;
492
492
  }
493
- #u(e) {
494
- this.#i = void 0, this.request = this.#h(e);
493
+ #u(t) {
494
+ this.#i = void 0, this.request = this.#h(t);
495
495
  }
496
- #h(e, s) {
497
- return !this.#e.onUploadProgress || !e.body ? e : Fe(e, this.#e.onUploadProgress, s ?? this.#e.body ?? void 0);
496
+ #h(t, s) {
497
+ return !this.#e.onUploadProgress || !t.body ? t : Yt(t, this.#e.onUploadProgress, s ?? this.#e.body ?? void 0);
498
498
  }
499
499
  }
500
500
  /*! MIT License © Sindre Sorhus */
501
- const B = (t) => {
502
- const e = (s, r) => O.create(s, k(t, r));
503
- for (const s of de)
504
- e[s] = (r, n) => O.create(r, k(t, n, { method: s }));
505
- return e.create = (s) => B(k(s)), e.extend = (s) => (typeof s == "function" && (s = s(t ?? {})), B(k(t, s))), e.stop = pe, e.retry = Ie, e;
506
- }, nt = B();
507
- var ot = /* @__PURE__ */ ((t) => (t.ARBITRUM = "ARBITRUM_MAINNET", t.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", t.AVALANCHE = "AVALANCHE_MAINNET", t.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", t.BASE = "BASE_MAINNET", t.BASE_TESTNET = "BASE_TESTNET", t.BSC = "BSC_MAINNET", t.ETHEREUM = "ETHEREUM_MAINNET", t.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", t.STARKNET = "STARKNET_MAINNET", t))(ot || {}), it = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(it || {}), z = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(z || {});
508
- class d {
509
- constructor({ api_key: e, env: s }) {
510
- this.api_key = e, this.jwt = "", this.env = s ?? z.PRODUCTION;
511
- }
512
- static async config(e) {
513
- if (!d.app) {
514
- if (!e)
515
- throw new Error("Please provide an api_key");
516
- d.app = new d(e);
501
+ const G = (e) => {
502
+ const t = (s, n) => O.create(s, N(e, n));
503
+ for (const s of We)
504
+ t[s] = (n, r) => O.create(n, N(e, r, { method: s }));
505
+ return t.create = (s) => G(N(s)), t.extend = (s) => (typeof s == "function" && (s = s(e ?? {})), G(N(e, s))), t.stop = Ve, t.retry = qt, t;
506
+ }, as = G();
507
+ var E = /* @__PURE__ */ ((e) => (e.USDC = "USDC", e))(E || {});
508
+ const Ze = {
509
+ type: "evm",
510
+ chainId: 42161,
511
+ name: "Arbitrum",
512
+ cctpDomain: 3,
513
+ logoURI: "/images/chains/arbitrum.svg"
514
+ }, Qe = {
515
+ type: "evm",
516
+ chainId: 421614,
517
+ name: "Arbitrum Sepolia",
518
+ cctpDomain: 3,
519
+ logoURI: "/images/chains/arbitrum.svg"
520
+ }, et = {
521
+ type: "evm",
522
+ chainId: 8453,
523
+ name: "Base",
524
+ cctpDomain: 6,
525
+ logoURI: "/images/chains/base.webp"
526
+ }, tt = {
527
+ type: "evm",
528
+ chainId: 84532,
529
+ name: "Base Sepolia",
530
+ cctpDomain: 6,
531
+ logoURI: "/images/chains/base.webp"
532
+ }, st = {
533
+ type: "evm",
534
+ chainId: 56,
535
+ name: "BNB Chain",
536
+ cctpDomain: null,
537
+ logoURI: "/images/chains/bsc.webp"
538
+ }, nt = {
539
+ type: "evm",
540
+ chainId: 1,
541
+ name: "Ethereum",
542
+ cctpDomain: 0,
543
+ logoURI: "/images/chains/ethereum.svg"
544
+ }, rt = {
545
+ type: "evm",
546
+ chainId: 11155111,
547
+ name: "Ethereum Sepolia",
548
+ cctpDomain: 0,
549
+ logoURI: "/images/chains/ethereum.svg"
550
+ }, ot = {
551
+ type: "evm",
552
+ chainId: 43114,
553
+ name: "Avalanche",
554
+ cctpDomain: 1,
555
+ logoURI: "/images/chains/avalanche.svg"
556
+ }, it = {
557
+ type: "evm",
558
+ chainId: 43113,
559
+ name: "Avalanche Fuji",
560
+ cctpDomain: 1,
561
+ logoURI: "/images/chains/avalanche.svg"
562
+ }, at = {
563
+ type: "starknet",
564
+ chainId: "0x534e5f4d41494e",
565
+ // SN_MAIN
566
+ name: "Starknet",
567
+ cctpDomain: null,
568
+ logoURI: "/images/chains/starknet.svg"
569
+ };
570
+ function ge(e, { strict: t = !0 } = {}) {
571
+ return !e || typeof e != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(e) : e.startsWith("0x");
572
+ }
573
+ function xe(e) {
574
+ return ge(e, { strict: !1 }) ? Math.ceil((e.length - 2) / 2) : e.length;
575
+ }
576
+ const ct = "2.43.4";
577
+ let K = {
578
+ getDocsUrl: ({ docsBaseUrl: e, docsPath: t = "", docsSlug: s }) => t ? `${e ?? "https://viem.sh"}${t}${s ? `#${s}` : ""}` : void 0,
579
+ version: `viem@${ct}`
580
+ };
581
+ class A extends Error {
582
+ constructor(t, s = {}) {
583
+ const n = s.cause instanceof A ? s.cause.details : s.cause?.message ? s.cause.message : s.details, r = s.cause instanceof A && s.cause.docsPath || s.docsPath, i = K.getDocsUrl?.({ ...s, docsPath: r }), o = [
584
+ t || "An error occurred.",
585
+ "",
586
+ ...s.metaMessages ? [...s.metaMessages, ""] : [],
587
+ ...i ? [`Docs: ${i}`] : [],
588
+ ...n ? [`Details: ${n}`] : [],
589
+ ...K.version ? [`Version: ${K.version}`] : []
590
+ ].join(`
591
+ `);
592
+ super(o, s.cause ? { cause: s.cause } : void 0), Object.defineProperty(this, "details", {
593
+ enumerable: !0,
594
+ configurable: !0,
595
+ writable: !0,
596
+ value: void 0
597
+ }), Object.defineProperty(this, "docsPath", {
598
+ enumerable: !0,
599
+ configurable: !0,
600
+ writable: !0,
601
+ value: void 0
602
+ }), Object.defineProperty(this, "metaMessages", {
603
+ enumerable: !0,
604
+ configurable: !0,
605
+ writable: !0,
606
+ value: void 0
607
+ }), Object.defineProperty(this, "shortMessage", {
608
+ enumerable: !0,
609
+ configurable: !0,
610
+ writable: !0,
611
+ value: void 0
612
+ }), Object.defineProperty(this, "version", {
613
+ enumerable: !0,
614
+ configurable: !0,
615
+ writable: !0,
616
+ value: void 0
617
+ }), Object.defineProperty(this, "name", {
618
+ enumerable: !0,
619
+ configurable: !0,
620
+ writable: !0,
621
+ value: "BaseError"
622
+ }), this.details = n, this.docsPath = r, this.metaMessages = s.metaMessages, this.name = s.name ?? this.name, this.shortMessage = t, this.version = ct;
623
+ }
624
+ walk(t) {
625
+ return ut(this, t);
626
+ }
627
+ }
628
+ function ut(e, t) {
629
+ return t?.(e) ? e : e && typeof e == "object" && "cause" in e && e.cause !== void 0 ? ut(e.cause, t) : t ? null : e;
630
+ }
631
+ class lt extends A {
632
+ constructor({ size: t, targetSize: s, type: n }) {
633
+ super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
634
+ }
635
+ }
636
+ function j(e, { dir: t, size: s = 32 } = {}) {
637
+ return typeof e == "string" ? cs(e, { dir: t, size: s }) : us(e, { dir: t, size: s });
638
+ }
639
+ function cs(e, { dir: t, size: s = 32 } = {}) {
640
+ if (s === null)
641
+ return e;
642
+ const n = e.replace("0x", "");
643
+ if (n.length > s * 2)
644
+ throw new lt({
645
+ size: Math.ceil(n.length / 2),
646
+ targetSize: s,
647
+ type: "hex"
648
+ });
649
+ return `0x${n[t === "right" ? "padEnd" : "padStart"](s * 2, "0")}`;
650
+ }
651
+ function us(e, { dir: t, size: s = 32 } = {}) {
652
+ if (s === null)
653
+ return e;
654
+ if (e.length > s)
655
+ throw new lt({
656
+ size: e.length,
657
+ targetSize: s,
658
+ type: "bytes"
659
+ });
660
+ const n = new Uint8Array(s);
661
+ for (let r = 0; r < s; r++) {
662
+ const i = t === "right";
663
+ n[i ? r : s - r - 1] = e[i ? r : e.length - r - 1];
664
+ }
665
+ return n;
666
+ }
667
+ class ls extends A {
668
+ constructor({ max: t, min: s, signed: n, size: r, value: i }) {
669
+ super(`Number "${i}" is not in safe ${r ? `${r * 8}-bit ${n ? "signed" : "unsigned"} ` : ""}integer range ${t ? `(${s} to ${t})` : `(above ${s})`}`, { name: "IntegerOutOfRangeError" });
670
+ }
671
+ }
672
+ class fs extends A {
673
+ constructor({ givenSize: t, maxSize: s }) {
674
+ super(`Size cannot exceed ${s} bytes. Given size: ${t} bytes.`, { name: "SizeOverflowError" });
675
+ }
676
+ }
677
+ function me(e, { size: t }) {
678
+ if (xe(e) > t)
679
+ throw new fs({
680
+ givenSize: xe(e),
681
+ maxSize: t
682
+ });
683
+ }
684
+ function hs(e, t = {}) {
685
+ const { signed: s, size: n } = t, r = BigInt(e);
686
+ let i;
687
+ n ? s ? i = (1n << BigInt(n) * 8n - 1n) - 1n : i = 2n ** (BigInt(n) * 8n) - 1n : typeof e == "number" && (i = BigInt(Number.MAX_SAFE_INTEGER));
688
+ const o = typeof i == "bigint" && s ? -i - 1n : 0;
689
+ if (i && r > i || r < o) {
690
+ const c = typeof e == "bigint" ? "n" : "";
691
+ throw new ls({
692
+ max: i ? `${i}${c}` : void 0,
693
+ min: `${o}${c}`,
694
+ signed: s,
695
+ size: n,
696
+ value: `${e}${c}`
697
+ });
698
+ }
699
+ const a = `0x${(s && r < 0 ? (1n << BigInt(n * 8)) + BigInt(r) : r).toString(16)}`;
700
+ return n ? j(a, { size: n }) : a;
701
+ }
702
+ const ds = /* @__PURE__ */ new TextEncoder();
703
+ function ps(e, t = {}) {
704
+ return typeof e == "number" || typeof e == "bigint" ? ms(e, t) : typeof e == "boolean" ? gs(e, t) : ge(e) ? ft(e, t) : ht(e, t);
705
+ }
706
+ function gs(e, t = {}) {
707
+ const s = new Uint8Array(1);
708
+ return s[0] = Number(e), typeof t.size == "number" ? (me(s, { size: t.size }), j(s, { size: t.size })) : s;
709
+ }
710
+ const S = {
711
+ zero: 48,
712
+ nine: 57,
713
+ A: 65,
714
+ F: 70,
715
+ a: 97,
716
+ f: 102
717
+ };
718
+ function ke(e) {
719
+ if (e >= S.zero && e <= S.nine)
720
+ return e - S.zero;
721
+ if (e >= S.A && e <= S.F)
722
+ return e - (S.A - 10);
723
+ if (e >= S.a && e <= S.f)
724
+ return e - (S.a - 10);
725
+ }
726
+ function ft(e, t = {}) {
727
+ let s = e;
728
+ t.size && (me(s, { size: t.size }), s = j(s, { dir: "right", size: t.size }));
729
+ let n = s.slice(2);
730
+ n.length % 2 && (n = `0${n}`);
731
+ const r = n.length / 2, i = new Uint8Array(r);
732
+ for (let o = 0, a = 0; o < r; o++) {
733
+ const c = ke(n.charCodeAt(a++)), u = ke(n.charCodeAt(a++));
734
+ if (c === void 0 || u === void 0)
735
+ throw new A(`Invalid byte sequence ("${n[a - 2]}${n[a - 1]}" in "${n}").`);
736
+ i[o] = c * 16 + u;
737
+ }
738
+ return i;
739
+ }
740
+ function ms(e, t) {
741
+ const s = hs(e, t);
742
+ return ft(s);
743
+ }
744
+ function ht(e, t = {}) {
745
+ const s = ds.encode(e);
746
+ return typeof t.size == "number" ? (me(s, { size: t.size }), j(s, { dir: "right", size: t.size })) : s;
747
+ }
748
+ const B = /* @__PURE__ */ BigInt(2 ** 32 - 1), Oe = /* @__PURE__ */ BigInt(32);
749
+ function ys(e, t = !1) {
750
+ return t ? { h: Number(e & B), l: Number(e >> Oe & B) } : { h: Number(e >> Oe & B) | 0, l: Number(e & B) | 0 };
751
+ }
752
+ function ws(e, t = !1) {
753
+ const s = e.length;
754
+ let n = new Uint32Array(s), r = new Uint32Array(s);
755
+ for (let i = 0; i < s; i++) {
756
+ const { h: o, l: a } = ys(e[i], t);
757
+ [n[i], r[i]] = [o, a];
758
+ }
759
+ return [n, r];
760
+ }
761
+ const bs = (e, t, s) => e << s | t >>> 32 - s, Es = (e, t, s) => t << s | e >>> 32 - s, Ss = (e, t, s) => t << s - 32 | e >>> 64 - s, Rs = (e, t, s) => e << s - 32 | t >>> 64 - s;
762
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
763
+ function Ts(e) {
764
+ return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
765
+ }
766
+ function De(e) {
767
+ if (!Number.isSafeInteger(e) || e < 0)
768
+ throw new Error("positive integer expected, got " + e);
769
+ }
770
+ function $(e, ...t) {
771
+ if (!Ts(e))
772
+ throw new Error("Uint8Array expected");
773
+ if (t.length > 0 && !t.includes(e.length))
774
+ throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
775
+ }
776
+ function Ne(e, t = !0) {
777
+ if (e.destroyed)
778
+ throw new Error("Hash instance has been destroyed");
779
+ if (t && e.finished)
780
+ throw new Error("Hash#digest() has already been called");
781
+ }
782
+ function As(e, t) {
783
+ $(e);
784
+ const s = t.outputLen;
785
+ if (e.length < s)
786
+ throw new Error("digestInto() expects output buffer of length at least " + s);
787
+ }
788
+ function Is(e) {
789
+ return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
790
+ }
791
+ function dt(...e) {
792
+ for (let t = 0; t < e.length; t++)
793
+ e[t].fill(0);
794
+ }
795
+ const vs = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
796
+ function Ps(e) {
797
+ return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
798
+ }
799
+ function Us(e) {
800
+ for (let t = 0; t < e.length; t++)
801
+ e[t] = Ps(e[t]);
802
+ return e;
803
+ }
804
+ const Me = vs ? (e) => e : Us;
805
+ function Cs(e) {
806
+ if (typeof e != "string")
807
+ throw new Error("string expected");
808
+ return new Uint8Array(new TextEncoder().encode(e));
809
+ }
810
+ function pt(e) {
811
+ return typeof e == "string" && (e = Cs(e)), $(e), e;
812
+ }
813
+ class xs {
814
+ }
815
+ function ks(e) {
816
+ const t = (n) => e().update(pt(n)).digest(), s = e();
817
+ return t.outputLen = s.outputLen, t.blockLen = s.blockLen, t.create = () => e(), t;
818
+ }
819
+ const Os = BigInt(0), C = BigInt(1), Ds = BigInt(2), Ns = BigInt(7), Ms = BigInt(256), Bs = BigInt(113), gt = [], mt = [], yt = [];
820
+ for (let e = 0, t = C, s = 1, n = 0; e < 24; e++) {
821
+ [s, n] = [n, (2 * s + 3 * n) % 5], gt.push(2 * (5 * n + s)), mt.push((e + 1) * (e + 2) / 2 % 64);
822
+ let r = Os;
823
+ for (let i = 0; i < 7; i++)
824
+ t = (t << C ^ (t >> Ns) * Bs) % Ms, t & Ds && (r ^= C << (C << /* @__PURE__ */ BigInt(i)) - C);
825
+ yt.push(r);
826
+ }
827
+ const wt = ws(yt, !0), $s = wt[0], _s = wt[1], Be = (e, t, s) => s > 32 ? Ss(e, t, s) : bs(e, t, s), $e = (e, t, s) => s > 32 ? Rs(e, t, s) : Es(e, t, s);
828
+ function Ls(e, t = 24) {
829
+ const s = new Uint32Array(10);
830
+ for (let n = 24 - t; n < 24; n++) {
831
+ for (let o = 0; o < 10; o++)
832
+ s[o] = e[o] ^ e[o + 10] ^ e[o + 20] ^ e[o + 30] ^ e[o + 40];
833
+ for (let o = 0; o < 10; o += 2) {
834
+ const a = (o + 8) % 10, c = (o + 2) % 10, u = s[c], l = s[c + 1], w = Be(u, l, 1) ^ s[a], d = $e(u, l, 1) ^ s[a + 1];
835
+ for (let y = 0; y < 50; y += 10)
836
+ e[o + y] ^= w, e[o + y + 1] ^= d;
837
+ }
838
+ let r = e[2], i = e[3];
839
+ for (let o = 0; o < 24; o++) {
840
+ const a = mt[o], c = Be(r, i, a), u = $e(r, i, a), l = gt[o];
841
+ r = e[l], i = e[l + 1], e[l] = c, e[l + 1] = u;
842
+ }
843
+ for (let o = 0; o < 50; o += 10) {
844
+ for (let a = 0; a < 10; a++)
845
+ s[a] = e[o + a];
846
+ for (let a = 0; a < 10; a++)
847
+ e[o + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
517
848
  }
518
- return e && (d.app.api_key = e.api_key, e.env !== void 0 && (d.app.env = e.env), await this.updateJWT(), setInterval(this.updateJWT.bind(this), 1500 * 1e3)), d.app;
849
+ e[0] ^= $s[n], e[1] ^= _s[n];
519
850
  }
520
- static async updateJWT() {
521
- try {
522
- const e = await (await fetch(this.getBaseUrl() + "/client/api-keys/session-token", {
523
- method: "POST",
524
- headers: {
525
- "content-type": "application/json"
526
- },
527
- body: JSON.stringify({
528
- apiKey: d.app.api_key
529
- })
530
- })).json();
531
- this.app.jwt = e.token;
532
- } catch {
851
+ dt(s);
852
+ }
853
+ class ye extends xs {
854
+ // NOTE: we accept arguments in bytes instead of bits here.
855
+ constructor(t, s, n, r = !1, i = 24) {
856
+ if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = t, this.suffix = s, this.outputLen = n, this.enableXOF = r, this.rounds = i, De(n), !(0 < t && t < 200))
857
+ throw new Error("only keccak-f1600 function is supported");
858
+ this.state = new Uint8Array(200), this.state32 = Is(this.state);
859
+ }
860
+ clone() {
861
+ return this._cloneInto();
862
+ }
863
+ keccak() {
864
+ Me(this.state32), Ls(this.state32, this.rounds), Me(this.state32), this.posOut = 0, this.pos = 0;
865
+ }
866
+ update(t) {
867
+ Ne(this), t = pt(t), $(t);
868
+ const { blockLen: s, state: n } = this, r = t.length;
869
+ for (let i = 0; i < r; ) {
870
+ const o = Math.min(s - this.pos, r - i);
871
+ for (let a = 0; a < o; a++)
872
+ n[this.pos++] ^= t[i++];
873
+ this.pos === s && this.keccak();
874
+ }
875
+ return this;
876
+ }
877
+ finish() {
878
+ if (this.finished)
879
+ return;
880
+ this.finished = !0;
881
+ const { state: t, suffix: s, pos: n, blockLen: r } = this;
882
+ t[n] ^= s, (s & 128) !== 0 && n === r - 1 && this.keccak(), t[r - 1] ^= 128, this.keccak();
883
+ }
884
+ writeInto(t) {
885
+ Ne(this, !1), $(t), this.finish();
886
+ const s = this.state, { blockLen: n } = this;
887
+ for (let r = 0, i = t.length; r < i; ) {
888
+ this.posOut >= n && this.keccak();
889
+ const o = Math.min(n - this.posOut, i - r);
890
+ t.set(s.subarray(this.posOut, this.posOut + o), r), this.posOut += o, r += o;
891
+ }
892
+ return t;
893
+ }
894
+ xofInto(t) {
895
+ if (!this.enableXOF)
896
+ throw new Error("XOF is not possible for this instance");
897
+ return this.writeInto(t);
898
+ }
899
+ xof(t) {
900
+ return De(t), this.xofInto(new Uint8Array(t));
901
+ }
902
+ digestInto(t) {
903
+ if (As(t, this), this.finished)
904
+ throw new Error("digest() was already called");
905
+ return this.writeInto(t), this.destroy(), t;
906
+ }
907
+ digest() {
908
+ return this.digestInto(new Uint8Array(this.outputLen));
909
+ }
910
+ destroy() {
911
+ this.destroyed = !0, dt(this.state);
912
+ }
913
+ _cloneInto(t) {
914
+ const { blockLen: s, suffix: n, outputLen: r, rounds: i, enableXOF: o } = this;
915
+ return t || (t = new ye(s, n, r, o, i)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = i, t.suffix = n, t.outputLen = r, t.enableXOF = o, t.destroyed = this.destroyed, t;
916
+ }
917
+ }
918
+ const zs = (e, t, s) => ks(() => new ye(t, e, s)), js = zs(1, 136, 256 / 8);
919
+ function qs(e, t) {
920
+ return js(ge(e, { strict: !1 }) ? ps(e) : e);
921
+ }
922
+ class Fs extends A {
923
+ constructor({ address: t }) {
924
+ super(`Address "${t}" is invalid.`, {
925
+ metaMessages: [
926
+ "- Address must be a hex value of 20 bytes (40 hex characters).",
927
+ "- Address must match its checksum counterpart."
928
+ ],
929
+ name: "InvalidAddressError"
930
+ });
931
+ }
932
+ }
933
+ class bt extends Map {
934
+ constructor(t) {
935
+ super(), Object.defineProperty(this, "maxSize", {
936
+ enumerable: !0,
937
+ configurable: !0,
938
+ writable: !0,
939
+ value: void 0
940
+ }), this.maxSize = t;
941
+ }
942
+ get(t) {
943
+ const s = super.get(t);
944
+ return super.has(t) && s !== void 0 && (this.delete(t), super.set(t, s)), s;
945
+ }
946
+ set(t, s) {
947
+ if (super.set(t, s), this.maxSize && this.size > this.maxSize) {
948
+ const n = this.keys().next().value;
949
+ n && this.delete(n);
950
+ }
951
+ return this;
952
+ }
953
+ }
954
+ const W = /* @__PURE__ */ new bt(8192);
955
+ function Et(e, t) {
956
+ if (W.has(`${e}.${t}`))
957
+ return W.get(`${e}.${t}`);
958
+ const s = e.substring(2).toLowerCase(), n = qs(ht(s)), r = s.split("");
959
+ for (let o = 0; o < 40; o += 2)
960
+ n[o >> 1] >> 4 >= 8 && r[o] && (r[o] = r[o].toUpperCase()), (n[o >> 1] & 15) >= 8 && r[o + 1] && (r[o + 1] = r[o + 1].toUpperCase());
961
+ const i = `0x${r.join("")}`;
962
+ return W.set(`${e}.${t}`, i), i;
963
+ }
964
+ function R(e, t) {
965
+ if (!Ks(e, { strict: !1 }))
966
+ throw new Fs({ address: e });
967
+ return Et(e, t);
968
+ }
969
+ const Hs = /^0x[a-fA-F0-9]{40}$/, V = /* @__PURE__ */ new bt(8192);
970
+ function Ks(e, t) {
971
+ const { strict: s = !0 } = t ?? {}, n = `${e}.${s}`;
972
+ if (V.has(n))
973
+ return V.get(n);
974
+ const r = Hs.test(e) ? e.toLowerCase() === e ? !0 : s ? Et(e) === e : !0 : !1;
975
+ return V.set(n, r), r;
976
+ }
977
+ const Z = {
978
+ chainId: Qe.chainId,
979
+ address: R("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),
980
+ symbol: "USDC",
981
+ fiatISO: "USD",
982
+ decimals: 6,
983
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
984
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
985
+ }, Q = {
986
+ chainId: Ze.chainId,
987
+ address: R("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),
988
+ symbol: "USDC",
989
+ name: "USD Coin",
990
+ decimals: 6,
991
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png"
992
+ /* USDC */
993
+ }, ee = {
994
+ chainId: it.chainId,
995
+ address: R("0x5425890298aed601595a70ab815c96711a31bc65"),
996
+ symbol: "USDC",
997
+ fiatISO: "USD",
998
+ decimals: 6,
999
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1000
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1001
+ }, te = {
1002
+ chainId: ot.chainId,
1003
+ address: R("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),
1004
+ symbol: "USDC",
1005
+ fiatISO: "USD",
1006
+ decimals: 6,
1007
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1008
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1009
+ }, se = {
1010
+ chainId: tt.chainId,
1011
+ address: R("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),
1012
+ symbol: "USDC",
1013
+ fiatISO: "USD",
1014
+ decimals: 6,
1015
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1016
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1017
+ }, ne = {
1018
+ chainId: et.chainId,
1019
+ address: R("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
1020
+ symbol: "USDC",
1021
+ fiatISO: "USD",
1022
+ decimals: 6,
1023
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1024
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1025
+ }, re = {
1026
+ chainId: st.chainId,
1027
+ address: R("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
1028
+ symbol: "USDC",
1029
+ decimals: 18,
1030
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1031
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1032
+ }, oe = {
1033
+ chainId: rt.chainId,
1034
+ address: R("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
1035
+ symbol: "USDC",
1036
+ decimals: 6,
1037
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1038
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1039
+ }, ie = {
1040
+ chainId: nt.chainId,
1041
+ address: R("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
1042
+ symbol: "USDC",
1043
+ decimals: 6,
1044
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1045
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1046
+ }, Ws = {
1047
+ chainId: at.chainId,
1048
+ address: "0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8",
1049
+ symbol: "USDC",
1050
+ decimals: 6,
1051
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1052
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1053
+ }, Vs = {
1054
+ [Z.chainId]: Z,
1055
+ [Q.chainId]: Q,
1056
+ [ee.chainId]: ee,
1057
+ [te.chainId]: te,
1058
+ [se.chainId]: se,
1059
+ [ne.chainId]: ne,
1060
+ [oe.chainId]: oe,
1061
+ [ie.chainId]: ie,
1062
+ [re.chainId]: re
1063
+ }, ae = {
1064
+ ARBITRUM_MAINNET: {
1065
+ ...Ze,
1066
+ tokens: {
1067
+ [E.USDC]: Q
1068
+ },
1069
+ explorer: "https://arbiscan.io"
1070
+ },
1071
+ ARBITRUM_TESTNET: {
1072
+ ...Qe,
1073
+ explorer: "https://sepolia.arbiscan.io",
1074
+ tokens: {
1075
+ [E.USDC]: Z
1076
+ }
1077
+ },
1078
+ AVALANCHE_MAINNET: {
1079
+ ...ot,
1080
+ tokens: {
1081
+ [E.USDC]: te
1082
+ },
1083
+ explorer: "https://snowtrace.io"
1084
+ },
1085
+ AVALANCHE_TESTNET: {
1086
+ ...it,
1087
+ tokens: {
1088
+ [E.USDC]: ee
1089
+ },
1090
+ explorer: "https://testnet.snowtrace.io"
1091
+ },
1092
+ BASE_MAINNET: {
1093
+ ...et,
1094
+ tokens: {
1095
+ [E.USDC]: ne
1096
+ },
1097
+ explorer: "https://basescan.org"
1098
+ },
1099
+ BASE_TESTNET: {
1100
+ ...tt,
1101
+ tokens: {
1102
+ [E.USDC]: se
1103
+ },
1104
+ explorer: "https://sepolia.basescan.org"
1105
+ },
1106
+ BSC_MAINNET: {
1107
+ ...st,
1108
+ tokens: {
1109
+ [E.USDC]: re
1110
+ },
1111
+ explorer: "https://bscscan.com"
1112
+ },
1113
+ ETHEREUM_MAINNET: {
1114
+ ...nt,
1115
+ tokens: {
1116
+ [E.USDC]: ie
1117
+ },
1118
+ explorer: "https://etherscan.io"
1119
+ },
1120
+ ETHEREUM_TESTNET: {
1121
+ ...rt,
1122
+ tokens: {
1123
+ [E.USDC]: oe
1124
+ },
1125
+ explorer: "https://sepolia.etherscan.io"
1126
+ },
1127
+ STARKNET_MAINNET: {
1128
+ ...at,
1129
+ tokens: {
1130
+ [E.USDC]: Ws
1131
+ },
1132
+ explorer: ""
1133
+ }
1134
+ };
1135
+ var ce = /* @__PURE__ */ ((e) => (e.ARBITRUM = "ARBITRUM_MAINNET", e.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", e.AVALANCHE = "AVALANCHE_MAINNET", e.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", e.BASE = "BASE_MAINNET", e.BASE_TESTNET = "BASE_TESTNET", e.BSC = "BSC_MAINNET", e.ETHEREUM = "ETHEREUM_MAINNET", e.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", e.STARKNET = "STARKNET_MAINNET", e))(ce || {}), St = /* @__PURE__ */ ((e) => (e.USDC = "USDC", e))(St || {});
1136
+ function Ys(e) {
1137
+ return Vs[ae[e || ""].chainId]?.decimals || 6;
1138
+ }
1139
+ const Xs = (e) => {
1140
+ const t = e?.trim().toUpperCase();
1141
+ if (ae[t])
1142
+ return ae[t];
1143
+ };
1144
+ function Js(e, t) {
1145
+ return Xs(e)?.tokens[t]?.address;
1146
+ }
1147
+ var we = /* @__PURE__ */ ((e) => (e.PRODUCTION = "production", e.STAGING = "staging", e))(we || {});
1148
+ class h {
1149
+ constructor({ api_key: t, env: s, seesion_token: n }) {
1150
+ this.api_key = t || "", this.sessionToken = n || "", this.env = s ?? we.PRODUCTION;
1151
+ }
1152
+ static async config(t) {
1153
+ if (!h.app) {
1154
+ if (!t)
1155
+ throw new Error("Please provide an api_key");
1156
+ h.app = new h(t);
533
1157
  }
1158
+ return t && (t.api_key !== void 0 && (h.app.api_key = t.api_key), t.seesion_token !== void 0 && (h.app.sessionToken = t.seesion_token), t.env !== void 0 && (h.app.env = t.env)), h.app;
534
1159
  }
535
1160
  static getApiKey() {
536
- if (!d.app)
1161
+ if (!h.app)
537
1162
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
538
- return d.app.api_key;
1163
+ return h.app.api_key;
539
1164
  }
540
- static getSessionKey() {
541
- return d.app.jwt;
1165
+ static getSessionToken() {
1166
+ if (!h.app)
1167
+ throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1168
+ return h.app.sessionToken;
542
1169
  }
543
1170
  static getEnv() {
544
- if (!d.app)
1171
+ if (!h.app)
545
1172
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
546
- return d.app.env === "internal" ? "staging" : d.app.env;
1173
+ return h.app.env === "internal" ? "staging" : h.app.env;
547
1174
  }
548
1175
  static getBaseUrl() {
549
- if (!d.app)
1176
+ if (!h.app)
550
1177
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
551
- switch (d.app.env) {
1178
+ switch (h.app.env) {
552
1179
  case "production":
553
1180
  return "https://api.chainrails.io/api/v1";
554
1181
  case "staging":
@@ -559,313 +1186,346 @@ class d {
559
1186
  return "https://api.chainrails.io/api/v1";
560
1187
  }
561
1188
  }
562
- static getPayModalUrl(e, s, r, n) {
563
- if (!d.app)
1189
+ static getPayModalUrl(t, s, n, r) {
1190
+ if (!h.app)
564
1191
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
565
- const i = d.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", o = n && n > 0 ? "/pay/" : "/deposit/", a = `_chain_/${e}/_token_/${s}/_to_/${r}${n ? "/_amount_/" + n * 100 : ""}`;
1192
+ const i = h.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", o = r && r > 0 ? "/pay/" : "/deposit/", a = `_chain_/${t}/_token_/${s}/_to_/${n}${r ? "/_amount_/" + r * 100 : ""}`;
566
1193
  return i + o + a;
567
1194
  }
568
1195
  }
569
- let H = null;
570
- function at() {
571
- H = nt.create({
572
- prefixUrl: d.getBaseUrl(),
1196
+ let ue = null;
1197
+ function Gs() {
1198
+ ue = as.create({
1199
+ prefixUrl: h.getBaseUrl(),
573
1200
  headers: {
574
1201
  "Content-Type": "application/json"
575
1202
  },
576
1203
  hooks: {
577
1204
  beforeRequest: [
578
- (t) => {
579
- const e = d.getSessionKey();
580
- t.headers.set("Authorization", `Bearer ${e}`);
1205
+ (e) => {
1206
+ const t = h.getSessionToken() || h.getApiKey();
1207
+ e.headers.set("Authorization", `Bearer ${t}`);
581
1208
  }
582
1209
  ],
583
- afterResponse: [(t, e, s) => s]
1210
+ afterResponse: [(e, t, s) => s]
584
1211
  },
585
1212
  retry: {
586
1213
  limit: 2
587
1214
  }
588
1215
  });
589
1216
  }
590
- function g() {
591
- return H || at(), H;
1217
+ function m() {
1218
+ return ue || Gs(), ue;
592
1219
  }
593
- class ct {
594
- async getById(e) {
595
- return await g().get("intents/" + e).json();
1220
+ class Zs {
1221
+ async getById(t) {
1222
+ return await m().get("intents/" + t).json();
1223
+ }
1224
+ async getForSender(t) {
1225
+ return await m().get("intents/user/" + t).json();
1226
+ }
1227
+ async getForAddress(t) {
1228
+ return await m().get("intents/address/" + t).json();
596
1229
  }
597
- async getForSender(e) {
598
- return await g().get("intents/user/" + e).json();
1230
+ async getForSession(t) {
1231
+ return await m().get("modal/sessions/intents/" + t).json();
599
1232
  }
600
- async getForAddress(e) {
601
- return await g().get("intents/address/" + e).json();
1233
+ async getAll(t) {
1234
+ return await m().get("intents", { searchParams: t }).json();
602
1235
  }
603
- async getAll(e) {
604
- return await g().get("intents", { searchParams: e }).json();
1236
+ async create(t) {
1237
+ return await m().post("intents", { json: t }).json();
605
1238
  }
606
- async create(e) {
607
- return await g().post("intents", { json: e }).json();
1239
+ async createForSession(t) {
1240
+ return await m().post("modal/sessions/intents", { json: t }).json();
608
1241
  }
609
- async update(e, s) {
610
- return await g().post("intents", { json: s }).json();
1242
+ async update(t, s) {
1243
+ return await m().post("intents", { json: s }).json();
611
1244
  }
612
- async triggerProcessing(e) {
613
- return await g().post(`intents/${e}/trigger-processing`).json();
1245
+ async triggerProcessing(t) {
1246
+ return await m().post(`intents/${t}/trigger-processing`).json();
1247
+ }
1248
+ async triggerProcessingForSession(t) {
1249
+ return await m().post(`modal/sessions/intents/${t}/process`).json();
614
1250
  }
615
1251
  }
616
- class ut {
617
- async getFromSpecificBridge(e) {
618
- return await g().get("quotes/single", { searchParams: e }).json();
1252
+ class Qs {
1253
+ async getFromSpecificBridge(t) {
1254
+ return await m().get("quotes/single", { searchParams: t }).json();
1255
+ }
1256
+ async getFromAllBridges(t) {
1257
+ return await m().get("quotes/multiple", { searchParams: t }).json();
619
1258
  }
620
- async getFromAllBridges(e) {
621
- return await g().get("quotes/multiple", { searchParams: e }).json();
1259
+ async getBestAcrossBridges(t) {
1260
+ return await m().get("quotes/best", { searchParams: t }).json();
622
1261
  }
623
- async getBestAcrossBridges(e) {
624
- return await g().get("quotes/best", { searchParams: e }).json();
1262
+ async getAll(t) {
1263
+ return await m().get("quotes/multi-source", { searchParams: t }).json();
625
1264
  }
626
- async getAll(e) {
627
- return await g().get("quotes/multi-source", { searchParams: e }).json();
1265
+ async getAllForSession(t) {
1266
+ return await m().get("modal/sessions/quotes", { searchParams: t }).json();
628
1267
  }
629
1268
  }
630
- class lt {
631
- async getOptimalRoutes(e) {
632
- return await g().get("router/optimal-route", { searchParams: e }).json();
1269
+ class en {
1270
+ async getOptimalRoutes(t) {
1271
+ return await m().get("router/optimal-route", { searchParams: t }).json();
633
1272
  }
634
1273
  async getAllSupportedBridges() {
635
- return await g().get("router/supported-bridges/all").json();
1274
+ return await m().get("router/supported-bridges/all").json();
636
1275
  }
637
- async getSupportedBridges(e) {
638
- return await g().get("router/supported-bridges/route", { searchParams: e }).json();
1276
+ async getSupportedBridges(t) {
1277
+ return await m().get("router/supported-bridges/route", { searchParams: t }).json();
639
1278
  }
640
- async getSupportedRoutes(e, s) {
641
- return await g().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
1279
+ async getSupportedRoutes(t, s) {
1280
+ return await m().get("router/supported-bridges/bridge/" + t, { searchParams: s }).json();
642
1281
  }
643
1282
  }
644
- class ft {
645
- async getSupported(e) {
646
- return await g().get("chains", { searchParams: e }).json();
1283
+ class tn {
1284
+ async getSupported(t) {
1285
+ return await m().get("chains", { searchParams: t }).json();
647
1286
  }
648
1287
  }
649
- class ht {
1288
+ class sn {
650
1289
  async getClientInfo() {
651
- return await g().get("client/auth/client-info").json();
1290
+ return await m().get("client/auth/client-info").json();
1291
+ }
1292
+ }
1293
+ class nn {
1294
+ getSessionToken(t) {
1295
+ const s = {
1296
+ recipient: t.recipient,
1297
+ tokenOut: Js(
1298
+ ce[t.destinationChain],
1299
+ St[t.token]
1300
+ ),
1301
+ destinationChain: ce[t.destinationChain],
1302
+ amount: t.amount
1303
+ };
1304
+ return m().post("modal/sessions", { json: s }).json();
652
1305
  }
653
1306
  }
654
- const xt = {
655
- router: new lt(),
656
- quotes: new ut(),
657
- intents: new ct(),
658
- chains: new ft(),
659
- client: new ht()
1307
+ const xn = {
1308
+ router: new en(),
1309
+ quotes: new Qs(),
1310
+ intents: new Zs(),
1311
+ chains: new tn(),
1312
+ client: new sn(),
1313
+ auth: new nn()
660
1314
  };
661
- function Te(t) {
662
- var e, s, r = "";
663
- if (typeof t == "string" || typeof t == "number") r += t;
664
- else if (typeof t == "object") if (Array.isArray(t)) {
665
- var n = t.length;
666
- for (e = 0; e < n; e++) t[e] && (s = Te(t[e])) && (r && (r += " "), r += s);
667
- } else for (s in t) t[s] && (r && (r += " "), r += s);
668
- return r;
669
- }
670
- function dt() {
671
- for (var t, e, s = 0, r = "", n = arguments.length; s < n; s++) (t = arguments[s]) && (e = Te(t)) && (r && (r += " "), r += e);
672
- return r;
673
- }
674
- function Lt(t) {
1315
+ function Rt(e) {
1316
+ var t, s, n = "";
1317
+ if (typeof e == "string" || typeof e == "number") n += e;
1318
+ else if (typeof e == "object") if (Array.isArray(e)) {
1319
+ var r = e.length;
1320
+ for (t = 0; t < r; t++) e[t] && (s = Rt(e[t])) && (n && (n += " "), n += s);
1321
+ } else for (s in e) e[s] && (n && (n += " "), n += s);
1322
+ return n;
1323
+ }
1324
+ function rn() {
1325
+ for (var e, t, s = 0, n = "", r = arguments.length; s < r; s++) (e = arguments[s]) && (t = Rt(e)) && (n && (n += " "), n += t);
1326
+ return n;
1327
+ }
1328
+ function kn(e) {
675
1329
  const {
676
- to: e,
1330
+ to: t,
677
1331
  token: s,
678
- chain: r,
679
- amount: n,
1332
+ chain: n,
1333
+ amount: r,
680
1334
  isOpen: i,
681
1335
  isPending: o,
682
1336
  open: a,
683
1337
  close: c,
684
1338
  onCancel: u,
685
- onSuccess: y,
1339
+ onSuccess: l,
686
1340
  data: w
687
- } = t, [p, m] = le(!0), R = W(null);
688
- F(() => {
689
- l();
690
- const f = document.body.style.overflow;
691
- i ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = f || "";
692
- const h = (T) => {
693
- T.data === "closed" && (c(), u?.()), T.data === "completed" && (window.setTimeout(c, 2e3), y?.());
1341
+ } = e, [d, y] = Fe(!0), T = he(null);
1342
+ de(() => {
1343
+ f();
1344
+ const p = document.body.style.overflow;
1345
+ i ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = p || "";
1346
+ const g = (b) => {
1347
+ b.data === "closed" && (c(), u?.()), b.data === "completed" && (window.setTimeout(c, 2e3), l?.());
694
1348
  };
695
- return window.addEventListener("message", h), () => {
696
- document.body.style.overflow = f || "", window.removeEventListener("message", h);
1349
+ return window.addEventListener("message", g), () => {
1350
+ document.body.style.overflow = p || "", window.removeEventListener("message", g);
697
1351
  };
698
- }, [i, u, y]);
699
- function j() {
700
- m(!1), l();
1352
+ }, [i, u, l]);
1353
+ function q() {
1354
+ y(!1), f();
701
1355
  }
702
- function l() {
1356
+ function f() {
703
1357
  if (!w?.sessionToken) return;
704
- const f = {
1358
+ const p = {
705
1359
  type: "session",
706
1360
  session_token: w.sessionToken,
707
- environment: d.getEnv() || z.PRODUCTION
1361
+ environment: h.getEnv() || we.PRODUCTION
708
1362
  };
709
- R.current?.contentWindow?.postMessage(f, "https://app.chainrails.io"), R.current?.contentWindow?.postMessage(f, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
1363
+ T.current?.contentWindow?.postMessage(p, "https://app.chainrails.io"), T.current?.contentWindow?.postMessage(p, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
710
1364
  }
711
- return w?.sessionToken ? /* @__PURE__ */ se("div", {
712
- className: dt("payment-modal-wrapper", p || o ? "loading" : "not-loading", i ? "open" : "closed"),
713
- children: [(p || o) && /* @__PURE__ */ S("div", {
1365
+ return w?.sessionToken ? /* @__PURE__ */ Pe("div", {
1366
+ className: rn("payment-modal-wrapper", d || o ? "loading" : "not-loading", i ? "open" : "closed"),
1367
+ children: [(d || o) && /* @__PURE__ */ U("div", {
714
1368
  role: "status",
715
1369
  className: "payment-modal-loader",
716
- children: /* @__PURE__ */ se("svg", {
1370
+ children: /* @__PURE__ */ Pe("svg", {
717
1371
  "aria-hidden": "true",
718
1372
  className: "icon",
719
1373
  viewBox: "0 0 100 101",
720
1374
  fill: "none",
721
1375
  xmlns: "http://www.w3.org/2000/svg",
722
- children: [/* @__PURE__ */ S("path", {
1376
+ children: [/* @__PURE__ */ U("path", {
723
1377
  d: "M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",
724
1378
  fill: "currentColor"
725
- }), /* @__PURE__ */ S("path", {
1379
+ }), /* @__PURE__ */ U("path", {
726
1380
  d: "M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",
727
1381
  fill: "currentFill"
728
1382
  })]
729
1383
  })
730
- }), /* @__PURE__ */ S("iframe", {
1384
+ }), /* @__PURE__ */ U("iframe", {
731
1385
  allow: "clipboard-read *; clipboard-write *",
732
- src: d.getPayModalUrl(r, s, e, n),
733
- onLoad: j,
734
- className: `payment-modal ${p || o ? "invisible" : "visible"}`,
735
- "data-id": n,
736
- ref: R
1386
+ src: h.getPayModalUrl(n, s, t, r),
1387
+ onLoad: q,
1388
+ className: `payment-modal ${d || o ? "invisible" : "visible"}`,
1389
+ "data-id": r,
1390
+ ref: T
737
1391
  })]
738
- }) : /* @__PURE__ */ S(Ue, {});
739
- }
740
- const pt = Symbol(), V = Symbol(), A = "a", Re = "f", oe = "p", be = "c", Ee = "t", J = "h", v = "w", G = "o", X = "k";
741
- let yt = (t, e) => new Proxy(t, e);
742
- const K = Object.getPrototypeOf, $ = /* @__PURE__ */ new WeakMap(), Pe = (t) => t && ($.has(t) ? $.get(t) : K(t) === Object.prototype || K(t) === Array.prototype), q = (t) => typeof t == "object" && t !== null, gt = (t) => Object.values(Object.getOwnPropertyDescriptors(t)).some((e) => !e.configurable && !e.writable), mt = (t) => {
743
- if (Array.isArray(t))
744
- return Array.from(t);
745
- const e = Object.getOwnPropertyDescriptors(t);
746
- return Object.values(e).forEach((s) => {
1392
+ }) : /* @__PURE__ */ U(Bt, {});
1393
+ }
1394
+ function on(e) {
1395
+ return BigInt(e).toString();
1396
+ }
1397
+ function an(e, t) {
1398
+ return Number(e) * Math.pow(10, t);
1399
+ }
1400
+ const cn = Symbol(), be = Symbol(), x = "a", Tt = "f", _e = "p", At = "c", It = "t", Ee = "h", k = "w", Se = "o", Re = "k";
1401
+ let un = (e, t) => new Proxy(e, t);
1402
+ const le = Object.getPrototypeOf, fe = /* @__PURE__ */ new WeakMap(), vt = (e) => e && (fe.has(e) ? fe.get(e) : le(e) === Object.prototype || le(e) === Array.prototype), _ = (e) => typeof e == "object" && e !== null, ln = (e) => Object.values(Object.getOwnPropertyDescriptors(e)).some((t) => !t.configurable && !t.writable), fn = (e) => {
1403
+ if (Array.isArray(e))
1404
+ return Array.from(e);
1405
+ const t = Object.getOwnPropertyDescriptors(e);
1406
+ return Object.values(t).forEach((s) => {
747
1407
  s.configurable = !0;
748
- }), Object.create(K(t), e);
749
- }, wt = (t, e) => {
1408
+ }), Object.create(le(e), t);
1409
+ }, hn = (e, t) => {
750
1410
  const s = {
751
- [Re]: e
1411
+ [Tt]: t
752
1412
  };
753
- let r = !1;
754
- const n = (a, c) => {
755
- if (!r) {
756
- let u = s[A].get(t);
757
- if (u || (u = {}, s[A].set(t, u)), a === v)
758
- u[v] = !0;
1413
+ let n = !1;
1414
+ const r = (a, c) => {
1415
+ if (!n) {
1416
+ let u = s[x].get(e);
1417
+ if (u || (u = {}, s[x].set(e, u)), a === k)
1418
+ u[k] = !0;
759
1419
  else {
760
- let y = u[a];
761
- y || (y = /* @__PURE__ */ new Set(), u[a] = y), y.add(c);
1420
+ let l = u[a];
1421
+ l || (l = /* @__PURE__ */ new Set(), u[a] = l), l.add(c);
762
1422
  }
763
1423
  }
764
1424
  }, i = () => {
765
- r = !0, s[A].delete(t);
1425
+ n = !0, s[x].delete(e);
766
1426
  }, o = {
767
1427
  get(a, c) {
768
- return c === V ? t : (n(X, c), Se(Reflect.get(a, c), s[A], s[be], s[Ee]));
1428
+ return c === be ? e : (r(Re, c), Pt(Reflect.get(a, c), s[x], s[At], s[It]));
769
1429
  },
770
1430
  has(a, c) {
771
- return c === pt ? (i(), !0) : (n(J, c), Reflect.has(a, c));
1431
+ return c === cn ? (i(), !0) : (r(Ee, c), Reflect.has(a, c));
772
1432
  },
773
1433
  getOwnPropertyDescriptor(a, c) {
774
- return n(G, c), Reflect.getOwnPropertyDescriptor(a, c);
1434
+ return r(Se, c), Reflect.getOwnPropertyDescriptor(a, c);
775
1435
  },
776
1436
  ownKeys(a) {
777
- return n(v), Reflect.ownKeys(a);
1437
+ return r(k), Reflect.ownKeys(a);
778
1438
  }
779
1439
  };
780
- return e && (o.set = o.deleteProperty = () => !1), [o, s];
781
- }, Z = (t) => (
1440
+ return t && (o.set = o.deleteProperty = () => !1), [o, s];
1441
+ }, Te = (e) => (
782
1442
  // unwrap proxy
783
- t[V] || // otherwise
784
- t
785
- ), Se = (t, e, s, r) => {
786
- if (!Pe(t))
787
- return t;
788
- let n = r && r.get(t);
789
- if (!n) {
790
- const c = Z(t);
791
- gt(c) ? n = [c, mt(c)] : n = [c], r?.set(t, n);
1443
+ e[be] || // otherwise
1444
+ e
1445
+ ), Pt = (e, t, s, n) => {
1446
+ if (!vt(e))
1447
+ return e;
1448
+ let r = n && n.get(e);
1449
+ if (!r) {
1450
+ const c = Te(e);
1451
+ ln(c) ? r = [c, fn(c)] : r = [c], n?.set(e, r);
792
1452
  }
793
- const [i, o] = n;
1453
+ const [i, o] = r;
794
1454
  let a = s && s.get(i);
795
- return (!a || a[1][Re] !== !!o) && (a = wt(i, !!o), a[1][oe] = yt(o || i, a[0]), s && s.set(i, a)), a[1][A] = e, a[1][be] = s, a[1][Ee] = r, a[1][oe];
796
- }, Tt = (t, e) => {
797
- const s = Reflect.ownKeys(t), r = Reflect.ownKeys(e);
798
- return s.length !== r.length || s.some((n, i) => n !== r[i]);
799
- }, Ae = (t, e, s, r, n = Object.is) => {
800
- if (n(t, e))
1455
+ return (!a || a[1][Tt] !== !!o) && (a = hn(i, !!o), a[1][_e] = un(o || i, a[0]), s && s.set(i, a)), a[1][x] = t, a[1][At] = s, a[1][It] = n, a[1][_e];
1456
+ }, dn = (e, t) => {
1457
+ const s = Reflect.ownKeys(e), n = Reflect.ownKeys(t);
1458
+ return s.length !== n.length || s.some((r, i) => r !== n[i]);
1459
+ }, Ut = (e, t, s, n, r = Object.is) => {
1460
+ if (r(e, t))
801
1461
  return !1;
802
- if (!q(t) || !q(e))
1462
+ if (!_(e) || !_(t))
803
1463
  return !0;
804
- const i = s.get(Z(t));
1464
+ const i = s.get(Te(e));
805
1465
  if (!i)
806
1466
  return !0;
807
- if (r) {
808
- if (r.get(t) === e)
1467
+ if (n) {
1468
+ if (n.get(e) === t)
809
1469
  return !1;
810
- r.set(t, e);
1470
+ n.set(e, t);
811
1471
  }
812
1472
  let o = null;
813
- for (const a of i[J] || [])
814
- if (o = Reflect.has(t, a) !== Reflect.has(e, a), o)
1473
+ for (const a of i[Ee] || [])
1474
+ if (o = Reflect.has(e, a) !== Reflect.has(t, a), o)
815
1475
  return o;
816
- if (i[v] === !0) {
817
- if (o = Tt(t, e), o)
1476
+ if (i[k] === !0) {
1477
+ if (o = dn(e, t), o)
818
1478
  return o;
819
1479
  } else
820
- for (const a of i[G] || []) {
821
- const c = !!Reflect.getOwnPropertyDescriptor(t, a), u = !!Reflect.getOwnPropertyDescriptor(e, a);
1480
+ for (const a of i[Se] || []) {
1481
+ const c = !!Reflect.getOwnPropertyDescriptor(e, a), u = !!Reflect.getOwnPropertyDescriptor(t, a);
822
1482
  if (o = c !== u, o)
823
1483
  return o;
824
1484
  }
825
- for (const a of i[X] || [])
826
- if (o = Ae(t[a], e[a], s, r, n), o)
1485
+ for (const a of i[Re] || [])
1486
+ if (o = Ut(e[a], t[a], s, n, r), o)
827
1487
  return o;
828
1488
  if (o === null)
829
1489
  throw new Error("invalid used");
830
1490
  return o;
831
- }, Rt = (t) => Pe(t) && t[V] || null, ie = (t, e = !0) => {
832
- $.set(t, e);
833
- }, bt = (t, e, s) => {
834
- const r = [], n = /* @__PURE__ */ new WeakSet(), i = (o, a) => {
835
- var c, u, y;
836
- if (n.has(o))
1491
+ }, pn = (e) => vt(e) && e[be] || null, Le = (e, t = !0) => {
1492
+ fe.set(e, t);
1493
+ }, gn = (e, t, s) => {
1494
+ const n = [], r = /* @__PURE__ */ new WeakSet(), i = (o, a) => {
1495
+ var c, u, l;
1496
+ if (r.has(o))
837
1497
  return;
838
- q(o) && n.add(o);
839
- const w = q(o) && e.get(Z(o));
1498
+ _(o) && r.add(o);
1499
+ const w = _(o) && t.get(Te(o));
840
1500
  if (w) {
841
- if ((c = w[J]) === null || c === void 0 || c.forEach((p) => {
842
- const m = `:has(${String(p)})`;
843
- r.push(a ? [...a, m] : [m]);
844
- }), w[v] === !0) {
845
- const p = ":ownKeys";
846
- r.push(a ? [...a, p] : [p]);
1501
+ if ((c = w[Ee]) === null || c === void 0 || c.forEach((d) => {
1502
+ const y = `:has(${String(d)})`;
1503
+ n.push(a ? [...a, y] : [y]);
1504
+ }), w[k] === !0) {
1505
+ const d = ":ownKeys";
1506
+ n.push(a ? [...a, d] : [d]);
847
1507
  } else
848
- (u = w[G]) === null || u === void 0 || u.forEach((p) => {
849
- const m = `:hasOwn(${String(p)})`;
850
- r.push(a ? [...a, m] : [m]);
1508
+ (u = w[Se]) === null || u === void 0 || u.forEach((d) => {
1509
+ const y = `:hasOwn(${String(d)})`;
1510
+ n.push(a ? [...a, y] : [y]);
851
1511
  });
852
- (y = w[X]) === null || y === void 0 || y.forEach((p) => {
853
- "value" in (Object.getOwnPropertyDescriptor(o, p) || {}) && i(o[p], a ? [...a, p] : [p]);
1512
+ (l = w[Re]) === null || l === void 0 || l.forEach((d) => {
1513
+ "value" in (Object.getOwnPropertyDescriptor(o, d) || {}) && i(o[d], a ? [...a, d] : [d]);
854
1514
  });
855
- } else a && r.push(a);
1515
+ } else a && n.push(a);
856
1516
  };
857
- return i(t), r;
858
- }, _ = {}, Q = (t) => typeof t == "object" && t !== null, Et = (t) => Q(t) && !ee.has(t) && (Array.isArray(t) || !(Symbol.iterator in t)) && !(t instanceof WeakMap) && !(t instanceof WeakSet) && !(t instanceof Error) && !(t instanceof Number) && !(t instanceof Date) && !(t instanceof String) && !(t instanceof RegExp) && !(t instanceof ArrayBuffer) && !(t instanceof Promise), ve = (t, e) => {
859
- const s = ae.get(t);
860
- if (s?.[0] === e)
1517
+ return i(e), n;
1518
+ }, L = {}, Ae = (e) => typeof e == "object" && e !== null, mn = (e) => Ae(e) && !Ie.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), Ct = (e, t) => {
1519
+ const s = ze.get(e);
1520
+ if (s?.[0] === t)
861
1521
  return s[1];
862
- const r = Array.isArray(t) ? [] : Object.create(Object.getPrototypeOf(t));
863
- return ie(r, !0), ae.set(t, [e, r]), Reflect.ownKeys(t).forEach((n) => {
864
- if (Object.getOwnPropertyDescriptor(r, n))
1522
+ const n = Array.isArray(e) ? [] : Object.create(Object.getPrototypeOf(e));
1523
+ return Le(n, !0), ze.set(e, [t, n]), Reflect.ownKeys(e).forEach((r) => {
1524
+ if (Object.getOwnPropertyDescriptor(n, r))
865
1525
  return;
866
- const i = Reflect.get(t, n), { enumerable: o } = Reflect.getOwnPropertyDescriptor(
867
- t,
868
- n
1526
+ const i = Reflect.get(e, r), { enumerable: o } = Reflect.getOwnPropertyDescriptor(
1527
+ e,
1528
+ r
869
1529
  ), a = {
870
1530
  value: i,
871
1531
  enumerable: o,
@@ -873,216 +1533,216 @@ const K = Object.getPrototypeOf, $ = /* @__PURE__ */ new WeakMap(), Pe = (t) =>
873
1533
  // It's still non-writable, so it avoids assigning a value.
874
1534
  configurable: !0
875
1535
  };
876
- if (ee.has(i))
877
- ie(i, !1);
1536
+ if (Ie.has(i))
1537
+ Le(i, !1);
878
1538
  else if (P.has(i)) {
879
1539
  const [c, u] = P.get(
880
1540
  i
881
1541
  );
882
- a.value = ve(c, u());
1542
+ a.value = Ct(c, u());
883
1543
  }
884
- Object.defineProperty(r, n, a);
885
- }), Object.preventExtensions(r);
886
- }, Pt = (t, e, s, r) => ({
887
- deleteProperty(n, i) {
888
- const o = Reflect.get(n, i);
1544
+ Object.defineProperty(n, r, a);
1545
+ }), Object.preventExtensions(n);
1546
+ }, yn = (e, t, s, n) => ({
1547
+ deleteProperty(r, i) {
1548
+ const o = Reflect.get(r, i);
889
1549
  s(i);
890
- const a = Reflect.deleteProperty(n, i);
891
- return a && r(["delete", [i], o]), a;
1550
+ const a = Reflect.deleteProperty(r, i);
1551
+ return a && n(["delete", [i], o]), a;
892
1552
  },
893
- set(n, i, o, a) {
894
- const c = !t() && Reflect.has(n, i), u = Reflect.get(n, i, a);
895
- if (c && (ce(u, o) || U.has(o) && ce(u, U.get(o))))
1553
+ set(r, i, o, a) {
1554
+ const c = !e() && Reflect.has(r, i), u = Reflect.get(r, i, a);
1555
+ if (c && (je(u, o) || z.has(o) && je(u, z.get(o))))
896
1556
  return !0;
897
- s(i), Q(o) && (o = Rt(o) || o);
898
- const y = !P.has(o) && At(o) ? Oe(o) : o;
899
- return e(i, y), Reflect.set(n, i, y, a), r(["set", [i], o, u]), !0;
900
- }
901
- }), P = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new WeakSet(), ae = /* @__PURE__ */ new WeakMap(), L = [1], U = /* @__PURE__ */ new WeakMap();
902
- let ce = Object.is, St = (t, e) => new Proxy(t, e), At = Et, vt = ve, Ot = Pt;
903
- function Oe(t = {}) {
904
- if (!Q(t))
1557
+ s(i), Ae(o) && (o = pn(o) || o);
1558
+ const l = !P.has(o) && bn(o) ? xt(o) : o;
1559
+ return t(i, l), Reflect.set(r, i, l, a), n(["set", [i], o, u]), !0;
1560
+ }
1561
+ }), P = /* @__PURE__ */ new WeakMap(), Ie = /* @__PURE__ */ new WeakSet(), ze = /* @__PURE__ */ new WeakMap(), Y = [1], z = /* @__PURE__ */ new WeakMap();
1562
+ let je = Object.is, wn = (e, t) => new Proxy(e, t), bn = mn, En = Ct, Sn = yn;
1563
+ function xt(e = {}) {
1564
+ if (!Ae(e))
905
1565
  throw new Error("object required");
906
- const e = U.get(t);
907
- if (e)
908
- return e;
909
- let s = L[0];
910
- const r = /* @__PURE__ */ new Set(), n = (l, f = ++L[0]) => {
911
- s !== f && (i = s = f, r.forEach((h) => h(l, f)));
1566
+ const t = z.get(e);
1567
+ if (t)
1568
+ return t;
1569
+ let s = Y[0];
1570
+ const n = /* @__PURE__ */ new Set(), r = (f, p = ++Y[0]) => {
1571
+ s !== p && (i = s = p, n.forEach((g) => g(f, p)));
912
1572
  };
913
1573
  let i = s;
914
- const o = (l = L[0]) => (i !== l && (i = l, c.forEach(([f]) => {
915
- const h = f[1](l);
916
- h > s && (s = h);
917
- })), s), a = (l) => (f, h) => {
918
- const T = [...f];
919
- T[1] = [l, ...T[1]], n(T, h);
920
- }, c = /* @__PURE__ */ new Map(), u = (l, f) => {
921
- const h = !ee.has(f) && P.get(f);
922
- if (h) {
923
- if ((_ ? "production" : void 0) !== "production" && c.has(l))
1574
+ const o = (f = Y[0]) => (i !== f && (i = f, c.forEach(([p]) => {
1575
+ const g = p[1](f);
1576
+ g > s && (s = g);
1577
+ })), s), a = (f) => (p, g) => {
1578
+ const b = [...p];
1579
+ b[1] = [f, ...b[1]], r(b, g);
1580
+ }, c = /* @__PURE__ */ new Map(), u = (f, p) => {
1581
+ const g = !Ie.has(p) && P.get(p);
1582
+ if (g) {
1583
+ if ((L ? "production" : void 0) !== "production" && c.has(f))
924
1584
  throw new Error("prop listener already exists");
925
- if (r.size) {
926
- const T = h[2](a(l));
927
- c.set(l, [h, T]);
1585
+ if (n.size) {
1586
+ const b = g[2](a(f));
1587
+ c.set(f, [g, b]);
928
1588
  } else
929
- c.set(l, [h]);
1589
+ c.set(f, [g]);
930
1590
  }
931
- }, y = (l) => {
932
- var f;
933
- const h = c.get(l);
934
- h && (c.delete(l), (f = h[1]) == null || f.call(h));
935
- }, w = (l) => (r.add(l), r.size === 1 && c.forEach(([h, T], C) => {
936
- if ((_ ? "production" : void 0) !== "production" && T)
1591
+ }, l = (f) => {
1592
+ var p;
1593
+ const g = c.get(f);
1594
+ g && (c.delete(f), (p = g[1]) == null || p.call(g));
1595
+ }, w = (f) => (n.add(f), n.size === 1 && c.forEach(([g, b], D) => {
1596
+ if ((L ? "production" : void 0) !== "production" && b)
937
1597
  throw new Error("remove already exists");
938
- const Ce = h[2](a(C));
939
- c.set(C, [h, Ce]);
1598
+ const kt = g[2](a(D));
1599
+ c.set(D, [g, kt]);
940
1600
  }), () => {
941
- r.delete(l), r.size === 0 && c.forEach(([h, T], C) => {
942
- T && (T(), c.set(C, [h]));
1601
+ n.delete(f), n.size === 0 && c.forEach(([g, b], D) => {
1602
+ b && (b(), c.set(D, [g]));
943
1603
  });
944
1604
  });
945
- let p = !0;
946
- const m = Ot(
947
- () => p,
1605
+ let d = !0;
1606
+ const y = Sn(
1607
+ () => d,
948
1608
  u,
949
- y,
950
- n
951
- ), R = St(t, m);
952
- U.set(t, R);
953
- const j = [t, o, w];
954
- return P.set(R, j), Reflect.ownKeys(t).forEach((l) => {
955
- const f = Object.getOwnPropertyDescriptor(
956
- t,
957
- l
1609
+ l,
1610
+ r
1611
+ ), T = wn(e, y);
1612
+ z.set(e, T);
1613
+ const q = [e, o, w];
1614
+ return P.set(T, q), Reflect.ownKeys(e).forEach((f) => {
1615
+ const p = Object.getOwnPropertyDescriptor(
1616
+ e,
1617
+ f
958
1618
  );
959
- "value" in f && f.writable && (R[l] = t[l]);
960
- }), p = !1, R;
961
- }
962
- function Ct(t, e, s) {
963
- const r = P.get(t);
964
- (_ ? "production" : void 0) !== "production" && !r && console.warn("Please use proxy object");
965
- let n;
966
- const i = [], o = r[2];
1619
+ "value" in p && p.writable && (T[f] = e[f]);
1620
+ }), d = !1, T;
1621
+ }
1622
+ function Rn(e, t, s) {
1623
+ const n = P.get(e);
1624
+ (L ? "production" : void 0) !== "production" && !n && console.warn("Please use proxy object");
1625
+ let r;
1626
+ const i = [], o = n[2];
967
1627
  let a = !1;
968
- const u = o((y) => {
969
- i.push(y), n || (n = Promise.resolve().then(() => {
970
- n = void 0, a && e(i.splice(0));
1628
+ const u = o((l) => {
1629
+ i.push(l), r || (r = Promise.resolve().then(() => {
1630
+ r = void 0, a && t(i.splice(0));
971
1631
  }));
972
1632
  });
973
1633
  return a = !0, () => {
974
1634
  a = !1, u();
975
1635
  };
976
1636
  }
977
- function ue(t) {
978
- const e = P.get(t);
979
- (_ ? "production" : void 0) !== "production" && !e && console.warn("Please use proxy object");
980
- const [s, r] = e;
981
- return vt(s, r());
982
- }
983
- const kt = {}, Nt = (t, e) => {
984
- const s = W(void 0);
985
- F(() => {
986
- s.current = bt(t, e);
987
- }), _e(s.current);
988
- }, qt = Nt, _t = /* @__PURE__ */ new WeakMap();
989
- function Ut(t, e) {
990
- const r = te(
991
- () => t && /* @__PURE__ */ new WeakMap(),
992
- [t]
993
- ), n = W(void 0);
1637
+ function qe(e) {
1638
+ const t = P.get(e);
1639
+ (L ? "production" : void 0) !== "production" && !t && console.warn("Please use proxy object");
1640
+ const [s, n] = t;
1641
+ return En(s, n());
1642
+ }
1643
+ const Tn = {}, An = (e, t) => {
1644
+ const s = he(void 0);
1645
+ de(() => {
1646
+ s.current = gn(e, t);
1647
+ }), Mt(s.current);
1648
+ }, In = An, vn = /* @__PURE__ */ new WeakMap();
1649
+ function Pn(e, t) {
1650
+ const n = ve(
1651
+ () => e && /* @__PURE__ */ new WeakMap(),
1652
+ [e]
1653
+ ), r = he(void 0);
994
1654
  let i = !0;
995
- const o = ke(
996
- Ne(
1655
+ const o = Ot(
1656
+ Dt(
997
1657
  (c) => {
998
- const u = Ct(t, c);
1658
+ const u = Rn(e, c);
999
1659
  return c(), u;
1000
1660
  },
1001
- [t, void 0]
1661
+ [e, void 0]
1002
1662
  ),
1003
1663
  () => {
1004
- const c = ue(t);
1664
+ const c = qe(e);
1005
1665
  try {
1006
- if (!i && n.current && !Ae(
1007
- n.current,
1666
+ if (!i && r.current && !Ut(
1667
+ r.current,
1008
1668
  c,
1009
- r,
1669
+ n,
1010
1670
  /* @__PURE__ */ new WeakMap()
1011
1671
  ))
1012
- return n.current;
1672
+ return r.current;
1013
1673
  } catch {
1014
1674
  }
1015
1675
  return c;
1016
1676
  },
1017
- () => ue(t)
1677
+ () => qe(e)
1018
1678
  );
1019
- i = !1, qe(() => {
1020
- n.current = o;
1021
- }), (kt ? "production" : void 0) !== "production" && qt(o, r);
1022
- const a = te(() => /* @__PURE__ */ new WeakMap(), []);
1023
- return Se(o, r, a, _t);
1679
+ i = !1, Nt(() => {
1680
+ r.current = o;
1681
+ }), (Tn ? "production" : void 0) !== "production" && In(o, n);
1682
+ const a = ve(() => /* @__PURE__ */ new WeakMap(), []);
1683
+ return Pt(o, n, a, vn);
1024
1684
  }
1025
- const b = Oe({
1685
+ const I = xt({
1026
1686
  data: null,
1027
1687
  isPending: !1,
1028
1688
  error: null
1029
1689
  });
1030
- function Dt({
1031
- auth_url: t,
1032
- chain: e,
1690
+ function On({
1691
+ auth_url: e,
1692
+ chain: t,
1033
1693
  token: s,
1034
- amount: r,
1035
- to: n,
1694
+ amount: n,
1695
+ to: r,
1036
1696
  onCancel: i,
1037
1697
  onSuccess: o
1038
1698
  }) {
1039
- const a = Ut(b), [c, u] = le(!1);
1040
- function y() {
1699
+ const a = Pn(I), [c, u] = Fe(!1);
1700
+ function l() {
1041
1701
  u(!0);
1042
1702
  }
1043
1703
  function w() {
1044
1704
  u(!1);
1045
1705
  }
1046
- const p = () => {
1047
- b.isPending = !0, b.error = null, fetch(t, {
1706
+ const d = () => {
1707
+ I.isPending = !0, I.error = null, fetch(e, {
1048
1708
  method: "POST",
1049
1709
  headers: {
1050
1710
  "Content-Type": "application/json"
1051
1711
  },
1052
1712
  body: JSON.stringify({
1053
- chain: e,
1713
+ chain: t,
1054
1714
  token: s,
1055
- amount: r,
1056
- to: n
1715
+ amount: n ? on(an(n, Ys(t))) : "0",
1716
+ to: r
1057
1717
  })
1058
- }).then((m) => m.json()).then((m) => {
1059
- b.data = m, d.config({
1060
- api_key: m.sessionToken
1061
- }), b.isPending = !1;
1062
- }).catch((m) => {
1063
- b.error = m?.toString(), b.isPending = !1;
1718
+ }).then((y) => y.json()).then((y) => {
1719
+ I.data = y, h.config({
1720
+ api_key: y.sessionToken
1721
+ }), I.isPending = !1;
1722
+ }).catch((y) => {
1723
+ I.error = y?.toString(), I.isPending = !1;
1064
1724
  });
1065
1725
  };
1066
- return F(() => {
1067
- p();
1068
- }, [e, s, r, n]), {
1726
+ return de(() => {
1727
+ d();
1728
+ }, [t, s, n, r]), {
1069
1729
  ...a,
1070
- chain: e,
1730
+ chain: t,
1071
1731
  token: s,
1072
- to: n,
1732
+ to: r,
1073
1733
  isOpen: c,
1074
- open: y,
1734
+ open: l,
1075
1735
  close: w,
1076
- refetch: p,
1736
+ refetch: d,
1077
1737
  onSuccess: o,
1078
1738
  onCancel: i
1079
1739
  };
1080
1740
  }
1081
1741
  export {
1082
- d as Chainrails,
1083
- Lt as PaymentModal,
1084
- ot as chains,
1085
- xt as crapi,
1086
- it as tokens,
1087
- Dt as usePaymentSession
1742
+ h as Chainrails,
1743
+ kn as PaymentModal,
1744
+ ce as chains,
1745
+ xn as crapi,
1746
+ St as tokens,
1747
+ On as usePaymentSession
1088
1748
  };