@chainrails/react 0.0.28 → 0.0.30

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,28 +1,15 @@
1
- import { useState as L, useRef as V, useEffect as G } from "react";
2
- import { jsxs as O, jsx as w } from "react/jsx-runtime";
3
- import './index.css';function B(t) {
4
- var e, s, r = "";
5
- if (typeof t == "string" || typeof t == "number") r += t;
6
- else if (typeof t == "object") if (Array.isArray(t)) {
7
- var n = t.length;
8
- for (e = 0; e < n; e++) t[e] && (s = B(t[e])) && (r && (r += " "), r += s);
9
- } else for (s in t) t[s] && (r && (r += " "), r += s);
10
- return r;
11
- }
12
- function X() {
13
- for (var t, e, s = 0, r = "", n = arguments.length; s < n; s++) (t = arguments[s]) && (e = B(t)) && (r && (r += " "), r += e);
14
- return r;
15
- }
16
- class P extends Error {
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 { jsxs as se, jsx as k } from "react/jsx-runtime";
3
+ import './index.css';class D extends Error {
17
4
  response;
18
5
  request;
19
6
  options;
20
7
  constructor(e, s, r) {
21
- const n = e.status || e.status === 0 ? e.status : "", o = e.statusText ?? "", i = `${n} ${o}`.trim(), a = i ? `status code ${i}` : "an unknown error";
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";
22
9
  super(`Request failed with ${a}: ${s.method} ${s.url}`), this.name = "HTTPError", this.response = e, this.request = s, this.options = r;
23
10
  }
24
11
  }
25
- class D extends Error {
12
+ class fe extends Error {
26
13
  name = "NonError";
27
14
  value;
28
15
  constructor(e) {
@@ -34,17 +21,17 @@ class D extends Error {
34
21
  super(s), this.value = e;
35
22
  }
36
23
  }
37
- class A extends Error {
24
+ class M extends Error {
38
25
  name = "ForceRetryError";
39
26
  customDelay;
40
27
  code;
41
28
  customRequest;
42
29
  constructor(e) {
43
- const s = e?.cause ? e.cause instanceof Error ? e.cause : new D(e.cause) : void 0;
30
+ const s = e?.cause ? e.cause instanceof Error ? e.cause : new fe(e.cause) : void 0;
44
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;
45
32
  }
46
33
  }
47
- const M = (() => {
34
+ const re = (() => {
48
35
  let t = !1, e = !1;
49
36
  const s = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function";
50
37
  if (s && r)
@@ -63,7 +50,7 @@ const M = (() => {
63
50
  throw n;
64
51
  }
65
52
  return t && !e;
66
- })(), Z = typeof globalThis.AbortController == "function", H = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", Y = typeof globalThis.ReadableStream == "function", Q = typeof globalThis.FormData == "function", $ = ["get", "post", "put", "patch", "head", "delete"], ee = {
53
+ })(), Ue = typeof globalThis.AbortController == "function", he = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", je = typeof globalThis.ReadableStream == "function", Me = typeof globalThis.FormData == "function", de = ["get", "post", "put", "patch", "head", "delete"], xe = {
67
54
  json: "application/json",
68
55
  text: "text/*",
69
56
  formData: "multipart/form-data",
@@ -72,14 +59,14 @@ const M = (() => {
72
59
  // Supported in modern Fetch implementations (for example, browsers and recent Node.js/undici).
73
60
  // We still feature-check at runtime before exposing the shortcut.
74
61
  bytes: "*/*"
75
- }, C = 2147483647, te = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, F = Symbol("stop");
76
- class _ {
62
+ }, x = 2147483647, Le = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, pe = Symbol("stop");
63
+ class ye {
77
64
  options;
78
65
  constructor(e) {
79
66
  this.options = e;
80
67
  }
81
68
  }
82
- const se = (t) => new _(t), re = {
69
+ const De = (t) => new ye(t), Ie = {
83
70
  json: !0,
84
71
  parseJson: !0,
85
72
  stringifyJson: !0,
@@ -93,10 +80,10 @@ const se = (t) => new _(t), re = {
93
80
  onUploadProgress: !0,
94
81
  fetch: !0,
95
82
  context: !0
96
- }, ne = {
83
+ }, Be = {
97
84
  next: !0
98
85
  // Next.js cache revalidation (revalidate, tags)
99
- }, oe = {
86
+ }, He = {
100
87
  method: !0,
101
88
  headers: !0,
102
89
  body: !0,
@@ -111,13 +98,13 @@ const se = (t) => new _(t), re = {
111
98
  signal: !0,
112
99
  window: !0,
113
100
  duplex: !0
114
- }, ie = (t) => {
101
+ }, Ke = (t) => {
115
102
  if (!t)
116
103
  return 0;
117
104
  if (t instanceof FormData) {
118
105
  let e = 0;
119
106
  for (const [s, r] of t)
120
- e += te, e += new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).length, e += typeof r == "string" ? new TextEncoder().encode(r).length : r.size;
107
+ e += Le, e += new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).length, e += typeof r == "string" ? new TextEncoder().encode(r).length : r.size;
121
108
  return e;
122
109
  }
123
110
  if (t instanceof Blob)
@@ -138,22 +125,22 @@ const se = (t) => new _(t), re = {
138
125
  return 0;
139
126
  }
140
127
  return 0;
141
- }, z = (t, e, s) => {
128
+ }, ge = (t, e, s) => {
142
129
  let r, n = 0;
143
130
  return t.pipeThrough(new TransformStream({
144
- transform(o, i) {
145
- if (i.enqueue(o), r) {
131
+ transform(i, o) {
132
+ if (o.enqueue(i), r) {
146
133
  n += r.byteLength;
147
134
  let a = e === 0 ? 0 : n / e;
148
135
  a >= 1 && (a = 1 - Number.EPSILON), s?.({ percent: a, totalBytes: Math.max(e, n), transferredBytes: n }, r);
149
136
  }
150
- r = o;
137
+ r = i;
151
138
  },
152
139
  flush() {
153
140
  r && (n += r.byteLength, s?.({ percent: 1, totalBytes: Math.max(e, n), transferredBytes: n }, r));
154
141
  }
155
142
  }));
156
- }, ae = (t, e) => {
143
+ }, $e = (t, e) => {
157
144
  if (!t.body)
158
145
  return t;
159
146
  if (t.status === 204)
@@ -163,75 +150,75 @@ const se = (t) => new _(t), re = {
163
150
  headers: t.headers
164
151
  });
165
152
  const s = Math.max(0, Number(t.headers.get("content-length")) || 0);
166
- return new Response(z(t.body, s, e), {
153
+ return new Response(ge(t.body, s, e), {
167
154
  status: t.status,
168
155
  statusText: t.statusText,
169
156
  headers: t.headers
170
157
  });
171
- }, ce = (t, e, s) => {
158
+ }, We = (t, e, s) => {
172
159
  if (!t.body)
173
160
  return t;
174
- const r = ie(s ?? t.body);
161
+ const r = Ke(s ?? t.body);
175
162
  return new Request(t, {
176
163
  // @ts-expect-error - Types are outdated.
177
164
  duplex: "half",
178
- body: z(t.body, r, e)
165
+ body: ge(t.body, r, e)
179
166
  });
180
- }, f = (t) => t !== null && typeof t == "object", b = (...t) => {
167
+ }, b = (t) => t !== null && typeof t == "object", N = (...t) => {
181
168
  for (const e of t)
182
- if ((!f(e) || Array.isArray(e)) && e !== void 0)
169
+ if ((!b(e) || Array.isArray(e)) && e !== void 0)
183
170
  throw new TypeError("The `options` argument must be an object");
184
- return v({}, ...t);
185
- }, J = (t = {}, e = {}) => {
171
+ return Y({}, ...t);
172
+ }, me = (t = {}, e = {}) => {
186
173
  const s = new globalThis.Headers(t), r = e instanceof globalThis.Headers, n = new globalThis.Headers(e);
187
- for (const [o, i] of n.entries())
188
- r && i === "undefined" || i === void 0 ? s.delete(o) : s.set(o, i);
174
+ for (const [i, o] of n.entries())
175
+ r && o === "undefined" || o === void 0 ? s.delete(i) : s.set(i, o);
189
176
  return s;
190
177
  };
191
- function T(t, e, s) {
192
- return Object.hasOwn(e, s) && e[s] === void 0 ? [] : v(t[s] ?? [], e[s] ?? []);
178
+ function q(t, e, s) {
179
+ return Object.hasOwn(e, s) && e[s] === void 0 ? [] : Y(t[s] ?? [], e[s] ?? []);
193
180
  }
194
- const K = (t = {}, e = {}) => ({
195
- beforeRequest: T(t, e, "beforeRequest"),
196
- beforeRetry: T(t, e, "beforeRetry"),
197
- afterResponse: T(t, e, "afterResponse"),
198
- beforeError: T(t, e, "beforeError")
199
- }), ue = (t, e) => {
181
+ const we = (t = {}, e = {}) => ({
182
+ beforeRequest: q(t, e, "beforeRequest"),
183
+ beforeRetry: q(t, e, "beforeRetry"),
184
+ afterResponse: q(t, e, "afterResponse"),
185
+ beforeError: q(t, e, "beforeError")
186
+ }), Fe = (t, e) => {
200
187
  const s = new URLSearchParams();
201
188
  for (const r of [t, e])
202
189
  if (r !== void 0)
203
190
  if (r instanceof URLSearchParams)
204
- for (const [n, o] of r.entries())
205
- s.append(n, o);
191
+ for (const [n, i] of r.entries())
192
+ s.append(n, i);
206
193
  else if (Array.isArray(r))
207
194
  for (const n of r) {
208
195
  if (!Array.isArray(n) || n.length !== 2)
209
196
  throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
210
197
  s.append(String(n[0]), String(n[1]));
211
198
  }
212
- else if (f(r))
213
- for (const [n, o] of Object.entries(r))
214
- o !== void 0 && s.append(n, String(o));
199
+ else if (b(r))
200
+ for (const [n, i] of Object.entries(r))
201
+ i !== void 0 && s.append(n, String(i));
215
202
  else {
216
203
  const n = new URLSearchParams(r);
217
- for (const [o, i] of n.entries())
218
- s.append(o, i);
204
+ for (const [i, o] of n.entries())
205
+ s.append(i, o);
219
206
  }
220
207
  return s;
221
- }, v = (...t) => {
208
+ }, Y = (...t) => {
222
209
  let e = {}, s = {}, r = {}, n;
223
- const o = [];
224
- for (const i of t)
225
- if (Array.isArray(i))
226
- Array.isArray(e) || (e = []), e = [...e, ...i];
227
- else if (f(i)) {
228
- for (let [a, c] of Object.entries(i)) {
210
+ const i = [];
211
+ for (const o of t)
212
+ if (Array.isArray(o))
213
+ Array.isArray(e) || (e = []), e = [...e, ...o];
214
+ else if (b(o)) {
215
+ for (let [a, c] of Object.entries(o)) {
229
216
  if (a === "signal" && c instanceof globalThis.AbortSignal) {
230
- o.push(c);
217
+ i.push(c);
231
218
  continue;
232
219
  }
233
220
  if (a === "context") {
234
- if (c != null && (!f(c) || Array.isArray(c)))
221
+ if (c != null && (!b(c) || Array.isArray(c)))
235
222
  throw new TypeError("The `context` option must be an object");
236
223
  e = {
237
224
  ...e,
@@ -240,28 +227,28 @@ const K = (t = {}, e = {}) => ({
240
227
  continue;
241
228
  }
242
229
  if (a === "searchParams") {
243
- c == null ? n = void 0 : n = n === void 0 ? c : ue(n, c);
230
+ c == null ? n = void 0 : n = n === void 0 ? c : Fe(n, c);
244
231
  continue;
245
232
  }
246
- f(c) && a in e && (c = v(e[a], c)), e = { ...e, [a]: c };
233
+ b(c) && a in e && (c = Y(e[a], c)), e = { ...e, [a]: c };
247
234
  }
248
- f(i.hooks) && (r = K(r, i.hooks), e.hooks = r), f(i.headers) && (s = J(s, i.headers), e.headers = s);
235
+ b(o.hooks) && (r = we(r, o.hooks), e.hooks = r), b(o.headers) && (s = me(s, o.headers), e.headers = s);
249
236
  }
250
- return n !== void 0 && (e.searchParams = n), o.length > 0 && (o.length === 1 ? e.signal = o[0] : H ? e.signal = AbortSignal.any(o) : e.signal = o.at(-1)), e.context === void 0 && (e.context = {}), e;
251
- }, le = (t) => $.includes(t) ? t.toUpperCase() : t, he = ["get", "put", "head", "delete", "options", "trace"], fe = [408, 413, 429, 500, 502, 503, 504], de = [413, 429, 503], I = {
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
+ }, Ye = (t) => de.includes(t) ? t.toUpperCase() : t, ze = ["get", "put", "head", "delete", "options", "trace"], Ve = [408, 413, 429, 500, 502, 503, 504], Je = [413, 429, 503], ne = {
252
239
  limit: 2,
253
- methods: he,
254
- statusCodes: fe,
255
- afterStatusCodes: de,
240
+ methods: ze,
241
+ statusCodes: Ve,
242
+ afterStatusCodes: Je,
256
243
  maxRetryAfter: Number.POSITIVE_INFINITY,
257
244
  backoffLimit: Number.POSITIVE_INFINITY,
258
245
  delay: (t) => 0.3 * 2 ** (t - 1) * 1e3,
259
246
  jitter: void 0,
260
247
  retryOnTimeout: !1
261
- }, pe = (t = {}) => {
248
+ }, Ge = (t = {}) => {
262
249
  if (typeof t == "number")
263
250
  return {
264
- ...I,
251
+ ...ne,
265
252
  limit: t
266
253
  };
267
254
  if (t.methods && !Array.isArray(t.methods))
@@ -269,66 +256,66 @@ const K = (t = {}, e = {}) => ({
269
256
  if (t.statusCodes && !Array.isArray(t.statusCodes))
270
257
  throw new Error("retry.statusCodes must be an array");
271
258
  return {
272
- ...I,
259
+ ...ne,
273
260
  ...t
274
261
  };
275
262
  };
276
- class x extends Error {
263
+ class I extends Error {
277
264
  request;
278
265
  constructor(e) {
279
266
  super(`Request timed out: ${e.method} ${e.url}`), this.name = "TimeoutError", this.request = e;
280
267
  }
281
268
  }
282
- async function ye(t, e, s, r) {
283
- return new Promise((n, o) => {
284
- const i = setTimeout(() => {
285
- s && s.abort(), o(new x(t));
269
+ async function Xe(t, e, s, r) {
270
+ return new Promise((n, i) => {
271
+ const o = setTimeout(() => {
272
+ s && s.abort(), i(new I(t));
286
273
  }, r.timeout);
287
- r.fetch(t, e).then(n).catch(o).then(() => {
288
- clearTimeout(i);
274
+ r.fetch(t, e).then(n).catch(i).then(() => {
275
+ clearTimeout(o);
289
276
  });
290
277
  });
291
278
  }
292
- async function ge(t, { signal: e }) {
279
+ async function Ze(t, { signal: e }) {
293
280
  return new Promise((s, r) => {
294
281
  e && (e.throwIfAborted(), e.addEventListener("abort", n, { once: !0 }));
295
282
  function n() {
296
- clearTimeout(o), r(e.reason);
283
+ clearTimeout(i), r(e.reason);
297
284
  }
298
- const o = setTimeout(() => {
285
+ const i = setTimeout(() => {
299
286
  e?.removeEventListener("abort", n), s();
300
287
  }, t);
301
288
  });
302
289
  }
303
- const me = (t, e) => {
290
+ const Qe = (t, e) => {
304
291
  const s = {};
305
292
  for (const r in e)
306
- Object.hasOwn(e, r) && !(r in oe) && !(r in re) && (!(r in t) || r in ne) && (s[r] = e[r]);
293
+ Object.hasOwn(e, r) && !(r in He) && !(r in Ie) && (!(r in t) || r in Be) && (s[r] = e[r]);
307
294
  return s;
308
- }, we = (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;
309
- function be(t) {
310
- return t instanceof P || t?.name === P.name;
295
+ }, et = (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 tt(t) {
297
+ return t instanceof D || t?.name === D.name;
311
298
  }
312
- function Te(t) {
313
- return t instanceof x || t?.name === x.name;
299
+ function st(t) {
300
+ return t instanceof I || t?.name === I.name;
314
301
  }
315
- class y {
302
+ class v {
316
303
  static create(e, s) {
317
- const r = new y(e, s), n = async () => {
318
- if (typeof r.#e.timeout == "number" && r.#e.timeout > C)
319
- throw new RangeError(`The \`timeout\` option cannot be greater than ${C}`);
304
+ const r = new v(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}`);
320
307
  await Promise.resolve();
321
- let i = await r.#y();
308
+ let o = await r.#y();
322
309
  for (const a of r.#e.hooks.afterResponse) {
323
- const c = r.#l(i.clone()), h = await a(r.request, r.#a(), c, { retryCount: r.#s });
324
- if (h instanceof globalThis.Response && (i = h), h instanceof _)
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)
325
312
  throw await Promise.all([
326
313
  c.body?.cancel(),
327
- i.body?.cancel()
328
- ]), new A(h.options);
314
+ o.body?.cancel()
315
+ ]), new M(u.options);
329
316
  }
330
- if (r.#l(i), !i.ok && (typeof r.#e.throwHttpErrors == "function" ? r.#e.throwHttpErrors(i.status) : r.#e.throwHttpErrors)) {
331
- let a = new P(i, r.request, r.#a());
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());
332
319
  for (const c of r.#e.hooks.beforeError)
333
320
  a = await c(a, { retryCount: r.#s });
334
321
  throw a;
@@ -336,28 +323,28 @@ class y {
336
323
  if (r.#e.onDownloadProgress) {
337
324
  if (typeof r.#e.onDownloadProgress != "function")
338
325
  throw new TypeError("The `onDownloadProgress` option must be a function");
339
- if (!Y)
326
+ if (!je)
340
327
  throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
341
- return ae(i.clone(), r.#e.onDownloadProgress);
328
+ return $e(o.clone(), r.#e.onDownloadProgress);
342
329
  }
343
- return i;
344
- }, o = r.#h(n).finally(async () => {
345
- const i = r.#o, a = [];
346
- i && !i.bodyUsed && a.push(i.body?.cancel()), r.request.bodyUsed || a.push(r.request.body?.cancel()), await Promise.all(a);
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);
347
334
  });
348
- for (const [i, a] of Object.entries(ee))
349
- i === "bytes" && typeof globalThis.Response?.prototype?.bytes != "function" || (o[i] = async () => {
335
+ for (const [o, a] of Object.entries(xe))
336
+ o === "bytes" && typeof globalThis.Response?.prototype?.bytes != "function" || (i[o] = async () => {
350
337
  r.request.headers.set("accept", r.request.headers.get("accept") || a);
351
- const c = await o;
352
- if (i === "json") {
338
+ const c = await i;
339
+ if (o === "json") {
353
340
  if (c.status === 204)
354
341
  return "";
355
- const h = await c.text();
356
- return h === "" ? "" : s.parseJson ? s.parseJson(h) : JSON.parse(h);
342
+ const u = await c.text();
343
+ return u === "" ? "" : s.parseJson ? s.parseJson(u) : JSON.parse(u);
357
344
  }
358
- return c[i]();
345
+ return c[o]();
359
346
  });
360
- return o;
347
+ return i;
361
348
  }
362
349
  // eslint-disable-next-line unicorn/prevent-abbreviations
363
350
  static #d(e) {
@@ -376,17 +363,17 @@ class y {
376
363
  constructor(e, s = {}) {
377
364
  if (this.#t = e, this.#e = {
378
365
  ...s,
379
- headers: J(this.#t.headers, s.headers),
380
- hooks: K({
366
+ headers: me(this.#t.headers, s.headers),
367
+ hooks: we({
381
368
  beforeRequest: [],
382
369
  beforeRetry: [],
383
370
  beforeError: [],
384
371
  afterResponse: []
385
372
  }, s.hooks),
386
- method: le(s.method ?? this.#t.method ?? "GET"),
373
+ method: Ye(s.method ?? this.#t.method ?? "GET"),
387
374
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
388
375
  prefixUrl: String(s.prefixUrl || ""),
389
- retry: pe(s.retry),
376
+ retry: Ge(s.retry),
390
377
  throwHttpErrors: s.throwHttpErrors ?? !0,
391
378
  timeout: s.timeout ?? 1e4,
392
379
  fetch: s.fetch ?? globalThis.fetch.bind(globalThis),
@@ -398,18 +385,18 @@ class y {
398
385
  throw new Error("`input` must not begin with a slash when using `prefixUrl`");
399
386
  this.#e.prefixUrl.endsWith("/") || (this.#e.prefixUrl += "/"), this.#t = this.#e.prefixUrl + this.#t;
400
387
  }
401
- Z && H && (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), M && (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"));
388
+ Ue && 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"));
402
389
  const r = s.headers && new globalThis.Headers(s.headers).has("content-type");
403
- if (this.#t instanceof globalThis.Request && (Q && 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), we(this.#e.searchParams)) {
404
- const o = "?" + (typeof this.#e.searchParams == "string" ? this.#e.searchParams.replace(/^\?/, "") : new URLSearchParams(y.#d(this.#e.searchParams)).toString()), i = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, o);
405
- this.request = new globalThis.Request(i, this.#e);
390
+ if (this.#t instanceof globalThis.Request && (Me && 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), et(this.#e.searchParams)) {
391
+ const i = "?" + (typeof this.#e.searchParams == "string" ? this.#e.searchParams.replace(/^\?/, "") : new URLSearchParams(v.#d(this.#e.searchParams)).toString()), o = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, i);
392
+ this.request = new globalThis.Request(o, this.#e);
406
393
  }
407
394
  if (this.#e.onUploadProgress) {
408
395
  if (typeof this.#e.onUploadProgress != "function")
409
396
  throw new TypeError("The `onUploadProgress` option must be a function");
410
- if (!M)
397
+ if (!re)
411
398
  throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
412
- this.request = this.#f(this.request, this.#e.body ?? void 0);
399
+ this.request = this.#h(this.request, this.#e.body ?? void 0);
413
400
  }
414
401
  }
415
402
  #c() {
@@ -420,8 +407,8 @@ class y {
420
407
  async #p(e) {
421
408
  if (this.#s++, this.#s > this.#e.retry.limit)
422
409
  throw e;
423
- const s = e instanceof Error ? e : new D(e);
424
- if (s instanceof A)
410
+ const s = e instanceof Error ? e : new fe(e);
411
+ if (s instanceof M)
425
412
  return s.customDelay ?? this.#c();
426
413
  if (!this.#e.retry.methods.includes(this.request.method.toLowerCase()))
427
414
  throw e;
@@ -432,17 +419,17 @@ class y {
432
419
  if (r === !0)
433
420
  return this.#c();
434
421
  }
435
- if (Te(e) && !this.#e.retry.retryOnTimeout)
422
+ if (st(e) && !this.#e.retry.retryOnTimeout)
436
423
  throw e;
437
- if (be(e)) {
424
+ if (tt(e)) {
438
425
  if (!this.#e.retry.statusCodes.includes(e.response.status))
439
426
  throw e;
440
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");
441
428
  if (r && this.#e.retry.afterStatusCodes.includes(e.response.status)) {
442
429
  let n = Number(r) * 1e3;
443
430
  Number.isNaN(n) ? n = Date.parse(r) - Date.now() : n >= Date.parse("2024-01-01") && (n -= Date.now());
444
- const o = this.#e.retry.maxRetryAfter ?? n;
445
- return n < o ? n : o;
431
+ const i = this.#e.retry.maxRetryAfter ?? n;
432
+ return n < i ? n : i;
446
433
  }
447
434
  if (e.response.status === 413)
448
435
  throw e;
@@ -452,34 +439,34 @@ class y {
452
439
  #l(e) {
453
440
  return this.#e.parseJson && (e.json = async () => this.#e.parseJson(await e.text())), e;
454
441
  }
455
- async #h(e) {
442
+ async #f(e) {
456
443
  try {
457
444
  return await e();
458
445
  } catch (s) {
459
- const r = Math.min(await this.#p(s), C);
446
+ const r = Math.min(await this.#p(s), x);
460
447
  if (this.#s < 1)
461
448
  throw s;
462
- if (await ge(r, this.#n ? { signal: this.#n } : {}), s instanceof A && s.customRequest) {
449
+ if (await Ze(r, this.#n ? { signal: this.#n } : {}), s instanceof M && s.customRequest) {
463
450
  const n = this.#e.signal ? new globalThis.Request(s.customRequest, { signal: this.#e.signal }) : new globalThis.Request(s.customRequest);
464
451
  this.#u(n);
465
452
  }
466
453
  for (const n of this.#e.hooks.beforeRetry) {
467
- const o = await n({
454
+ const i = await n({
468
455
  request: this.request,
469
456
  options: this.#a(),
470
457
  error: s,
471
458
  retryCount: this.#s
472
459
  });
473
- if (o instanceof globalThis.Request) {
474
- this.#u(o);
460
+ if (i instanceof globalThis.Request) {
461
+ this.#u(i);
475
462
  break;
476
463
  }
477
- if (o instanceof globalThis.Response)
478
- return o;
479
- if (o === F)
464
+ if (i instanceof globalThis.Response)
465
+ return i;
466
+ if (i === pe)
480
467
  return;
481
468
  }
482
- return this.#h(e);
469
+ return this.#f(e);
483
470
  }
484
471
  }
485
472
  async #y() {
@@ -493,8 +480,8 @@ class y {
493
480
  break;
494
481
  }
495
482
  }
496
- const e = me(this.request, this.#e);
497
- return this.#o = this.request, this.request = this.#o.clone(), this.#e.timeout === !1 ? this.#e.fetch(this.#o, e) : ye(this.#o, e, this.#r, this.#e);
483
+ const e = Qe(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) : Xe(this.#o, e, this.#r, this.#e);
498
485
  }
499
486
  #a() {
500
487
  if (!this.#i) {
@@ -504,31 +491,31 @@ class y {
504
491
  return this.#i;
505
492
  }
506
493
  #u(e) {
507
- this.#i = void 0, this.request = this.#f(e);
494
+ this.#i = void 0, this.request = this.#h(e);
508
495
  }
509
- #f(e, s) {
510
- return !this.#e.onUploadProgress || !e.body ? e : ce(e, this.#e.onUploadProgress, s ?? this.#e.body ?? void 0);
496
+ #h(e, s) {
497
+ return !this.#e.onUploadProgress || !e.body ? e : We(e, this.#e.onUploadProgress, s ?? this.#e.body ?? void 0);
511
498
  }
512
499
  }
513
500
  /*! MIT License © Sindre Sorhus */
514
- const q = (t) => {
515
- const e = (s, r) => y.create(s, b(t, r));
516
- for (const s of $)
517
- e[s] = (r, n) => y.create(r, b(t, n, { method: s }));
518
- return e.create = (s) => q(b(s)), e.extend = (s) => (typeof s == "function" && (s = s(t ?? {})), q(b(t, s))), e.stop = F, e.retry = se, e;
519
- }, Re = q();
520
- var Ee = /* @__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))(Ee || {}), Se = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(Se || {}), N = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(N || {});
521
- class u {
501
+ const B = (t) => {
502
+ const e = (s, r) => v.create(s, N(t, r));
503
+ for (const s of de)
504
+ e[s] = (r, n) => v.create(r, N(t, n, { method: s }));
505
+ return e.create = (s) => B(N(s)), e.extend = (s) => (typeof s == "function" && (s = s(t ?? {})), B(N(t, s))), e.stop = pe, e.retry = De, e;
506
+ }, rt = B();
507
+ var nt = /* @__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))(nt || {}), ot = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(ot || {}), z = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(z || {});
508
+ class h {
522
509
  constructor({ api_key: e, env: s }) {
523
- this.api_key = e, this.jwt = "", this.env = s ?? N.PRODUCTION;
510
+ this.api_key = e, this.jwt = "", this.env = s ?? z.PRODUCTION;
524
511
  }
525
512
  static async config(e) {
526
- if (!u.app) {
513
+ if (!h.app) {
527
514
  if (!e)
528
515
  throw new Error("Please provide an api_key");
529
- u.app = new u(e);
516
+ h.app = new h(e);
530
517
  }
531
- return e && (u.app.api_key = e.api_key, e.env !== void 0 && (u.app.env = e.env), await this.updateJWT(), setInterval(this.updateJWT.bind(this), 1500 * 1e3)), u.app;
518
+ return e && (h.app.api_key = e.api_key, e.env !== void 0 && (h.app.env = e.env), await this.updateJWT(), setInterval(this.updateJWT.bind(this), 1500 * 1e3)), h.app;
532
519
  }
533
520
  static async updateJWT() {
534
521
  try {
@@ -538,7 +525,7 @@ class u {
538
525
  "content-type": "application/json"
539
526
  },
540
527
  body: JSON.stringify({
541
- apiKey: u.app.api_key
528
+ apiKey: h.app.api_key
542
529
  })
543
530
  })).json();
544
531
  this.app.jwt = e.token;
@@ -546,22 +533,22 @@ class u {
546
533
  }
547
534
  }
548
535
  static getApiKey() {
549
- if (!u.app)
536
+ if (!h.app)
550
537
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
551
- return u.app.api_key;
538
+ return h.app.api_key;
552
539
  }
553
540
  static getSessionKey() {
554
- return u.app.jwt;
541
+ return h.app.jwt;
555
542
  }
556
543
  static getEnv() {
557
- if (!u.app)
544
+ if (!h.app)
558
545
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
559
- return u.app.env === "internal" ? "staging" : u.app.env;
546
+ return h.app.env === "internal" ? "staging" : h.app.env;
560
547
  }
561
548
  static getBaseUrl() {
562
- if (!u.app)
549
+ if (!h.app)
563
550
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
564
- switch (u.app.env) {
551
+ switch (h.app.env) {
565
552
  case "production":
566
553
  return "https://api.chainrails.io/api/v1";
567
554
  case "staging":
@@ -573,23 +560,23 @@ class u {
573
560
  }
574
561
  }
575
562
  static getPayModalUrl(e, s, r, n) {
576
- if (!u.app)
563
+ if (!h.app)
577
564
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
578
- const o = u.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", i = n && n > 0 ? "/pay/" : "/deposit/", a = `_chain_/${e}/_token_/${s}/_to_/${r}${n ? "/_amount_/" + n * 100 : ""}`;
579
- return o + i + a;
565
+ const i = h.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 : ""}`;
566
+ return i + o + a;
580
567
  }
581
568
  }
582
- let j = null;
583
- function Ae() {
584
- j = Re.create({
585
- prefixUrl: u.getBaseUrl(),
569
+ let H = null;
570
+ function it() {
571
+ H = rt.create({
572
+ prefixUrl: h.getBaseUrl(),
586
573
  headers: {
587
574
  "Content-Type": "application/json"
588
575
  },
589
576
  hooks: {
590
577
  beforeRequest: [
591
578
  (t) => {
592
- const e = u.getSessionKey();
579
+ const e = h.getSessionKey();
593
580
  t.headers.set("Authorization", `Bearer ${e}`);
594
581
  }
595
582
  ],
@@ -600,185 +587,486 @@ function Ae() {
600
587
  }
601
588
  });
602
589
  }
603
- function l() {
604
- return j || Ae(), j;
590
+ function y() {
591
+ return H || it(), H;
605
592
  }
606
- class Ce {
593
+ class at {
607
594
  async getById(e) {
608
- return await l().get("intents/" + e).json();
595
+ return await y().get("intents/" + e).json();
609
596
  }
610
597
  async getForSender(e) {
611
- return await l().get("intents/user/" + e).json();
598
+ return await y().get("intents/user/" + e).json();
612
599
  }
613
600
  async getForAddress(e) {
614
- return await l().get("intents/address/" + e).json();
601
+ return await y().get("intents/address/" + e).json();
615
602
  }
616
603
  async getAll(e) {
617
- return await l().get("intents", { searchParams: e }).json();
604
+ return await y().get("intents", { searchParams: e }).json();
618
605
  }
619
606
  async create(e) {
620
- return await l().post("intents", { json: e }).json();
607
+ return await y().post("intents", { json: e }).json();
621
608
  }
622
609
  async update(e, s) {
623
- return await l().post("intents", { json: s }).json();
610
+ return await y().post("intents", { json: s }).json();
624
611
  }
625
612
  async triggerProcessing(e) {
626
- return await l().post(`intents/${e}/trigger-processing`).json();
613
+ return await y().post(`intents/${e}/trigger-processing`).json();
627
614
  }
628
615
  }
629
- class Pe {
616
+ class ct {
630
617
  async getFromSpecificBridge(e) {
631
- return await l().get("quotes/single", { searchParams: e }).json();
618
+ return await y().get("quotes/single", { searchParams: e }).json();
632
619
  }
633
620
  async getFromAllBridges(e) {
634
- return await l().get("quotes/multiple", { searchParams: e }).json();
621
+ return await y().get("quotes/multiple", { searchParams: e }).json();
635
622
  }
636
623
  async getBestAcrossBridges(e) {
637
- return await l().get("quotes/best", { searchParams: e }).json();
624
+ return await y().get("quotes/best", { searchParams: e }).json();
638
625
  }
639
626
  async getAll(e) {
640
- return await l().get("quotes/multi-source", { searchParams: e }).json();
627
+ return await y().get("quotes/multi-source", { searchParams: e }).json();
641
628
  }
642
629
  }
643
- class xe {
630
+ class ut {
644
631
  async getOptimalRoutes(e) {
645
- return await l().get("router/optimal-route", { searchParams: e }).json();
632
+ return await y().get("router/optimal-route", { searchParams: e }).json();
646
633
  }
647
634
  async getAllSupportedBridges() {
648
- return await l().get("router/supported-bridges/all").json();
635
+ return await y().get("router/supported-bridges/all").json();
649
636
  }
650
637
  async getSupportedBridges(e) {
651
- return await l().get("router/supported-bridges/route", { searchParams: e }).json();
638
+ return await y().get("router/supported-bridges/route", { searchParams: e }).json();
652
639
  }
653
640
  async getSupportedRoutes(e, s) {
654
- return await l().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
641
+ return await y().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
655
642
  }
656
643
  }
657
- class qe {
644
+ class lt {
658
645
  async getSupported(e) {
659
- return await l().get("chains", { searchParams: e }).json();
646
+ return await y().get("chains", { searchParams: e }).json();
660
647
  }
661
648
  }
662
- class je {
649
+ class ft {
663
650
  async getClientInfo() {
664
- return await l().get("client/auth/client-info").json();
651
+ return await y().get("client/auth/client-info").json();
665
652
  }
666
653
  }
667
- const ke = {
668
- router: new xe(),
669
- quotes: new Pe(),
670
- intents: new Ce(),
671
- chains: new qe(),
672
- client: new je()
654
+ const Mt = {
655
+ router: new ut(),
656
+ quotes: new ct(),
657
+ intents: new at(),
658
+ chains: new lt(),
659
+ client: new ft()
673
660
  };
674
- function Ue(t) {
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 ht() {
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 xt(t) {
675
675
  const {
676
676
  to: e,
677
677
  token: s,
678
678
  chain: r,
679
679
  amount: n,
680
- isOpen: o,
681
- close: i,
682
- complete: a,
683
- cancel: c,
684
- chainSelected: h,
685
- intentCreated: g,
686
- ...R
687
- } = t, [d, E] = L(!0), S = V(null);
688
- G(() => {
689
- k();
690
- const p = document.body.style.overflow;
691
- o ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = p || "";
692
- const U = (m) => {
693
- m.data === "closed" && c(), m.data === "completed" && a(), m.data === "chainSelected" && h(), m.data === "intentCreated" && g();
680
+ isOpen: i,
681
+ open: o,
682
+ close: a,
683
+ onCancel: c,
684
+ onSuccess: u,
685
+ session_token: p
686
+ } = t, [m, g] = le(!0), w = W(null);
687
+ F(() => {
688
+ O();
689
+ const l = document.body.style.overflow;
690
+ i ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = l || "";
691
+ const d = (f) => {
692
+ f.data === "closed" && (a(), c?.()), f.data === "completed" && (window.setTimeout(a, 2e3), u?.());
694
693
  };
695
- return window.addEventListener("message", U), () => {
696
- document.body.style.overflow = p || "", window.removeEventListener("message", U);
694
+ return window.addEventListener("message", d), () => {
695
+ document.body.style.overflow = l || "", window.removeEventListener("message", d);
697
696
  };
698
- }, [o, c, a, h, g]);
699
- function W() {
700
- E(!1), k();
701
- }
702
- function k() {
703
- const p = {
704
- type: "apiKey",
705
- apiKey: u.getApiKey(),
706
- environment: u.getEnv() || N.PRODUCTION
697
+ }, [i, c, u]);
698
+ function P() {
699
+ g(!1), O();
700
+ }
701
+ function O() {
702
+ if (!p) return;
703
+ const l = {
704
+ type: "session",
705
+ session_token: p,
706
+ environment: h.getEnv() || z.PRODUCTION
707
707
  };
708
- S.current?.contentWindow?.postMessage(p, "https://app.chainrails.io"), S.current?.contentWindow?.postMessage(p, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
709
- }
710
- return /* @__PURE__ */ O("div", {
711
- ...R,
712
- className: X("payment-modal-wrapper", d ? "loading" : "not-loading", o ? "open" : "closed"),
713
- children: [d && /* @__PURE__ */ w("div", {
714
- role: "status",
715
- className: "payment-modal-loader",
716
- children: /* @__PURE__ */ O("svg", {
717
- "aria-hidden": "true",
718
- className: "icon",
719
- viewBox: "0 0 100 101",
720
- fill: "none",
721
- xmlns: "http://www.w3.org/2000/svg",
722
- children: [/* @__PURE__ */ w("path", {
723
- 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
- fill: "currentColor"
725
- }), /* @__PURE__ */ w("path", {
726
- 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
- fill: "currentFill"
728
- })]
729
- })
730
- }), /* @__PURE__ */ w("iframe", {
731
- allow: "clipboard-read *; clipboard-write *",
732
- src: u.getPayModalUrl(r, s, e, n),
733
- onLoad: W,
734
- className: `payment-modal ${d ? "invisible" : "visible"}`,
735
- "data-id": n,
736
- ref: S
737
- })]
738
- });
739
- }
740
- function Oe(t) {
741
- const {
742
- onCancel: e,
743
- onSuccess: s,
744
- onChainSelect: r,
745
- onIntentCreate: n,
746
- ...o
747
- } = t, [i, a] = L(!1);
748
- function c() {
749
- a(!0);
708
+ w.current?.contentWindow?.postMessage(l, "https://app.chainrails.io"), w.current?.contentWindow?.postMessage(l, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
750
709
  }
751
- function h() {
752
- a(!1);
710
+ if (p)
711
+ return /* @__PURE__ */ se("div", {
712
+ className: ht("payment-modal-wrapper", m ? "loading" : "not-loading", i ? "open" : "closed"),
713
+ children: [m && /* @__PURE__ */ k("div", {
714
+ role: "status",
715
+ className: "payment-modal-loader",
716
+ children: /* @__PURE__ */ se("svg", {
717
+ "aria-hidden": "true",
718
+ className: "icon",
719
+ viewBox: "0 0 100 101",
720
+ fill: "none",
721
+ xmlns: "http://www.w3.org/2000/svg",
722
+ children: [/* @__PURE__ */ k("path", {
723
+ 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
+ fill: "currentColor"
725
+ }), /* @__PURE__ */ k("path", {
726
+ 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
+ fill: "currentFill"
728
+ })]
729
+ })
730
+ }), /* @__PURE__ */ k("iframe", {
731
+ allow: "clipboard-read *; clipboard-write *",
732
+ src: h.getPayModalUrl(r, s, e, n),
733
+ onLoad: P,
734
+ className: `payment-modal ${m ? "invisible" : "visible"}`,
735
+ "data-id": n,
736
+ ref: w
737
+ })]
738
+ });
739
+ }
740
+ const dt = Symbol(), V = Symbol(), S = "a", Re = "f", oe = "p", be = "c", Ee = "t", J = "h", A = "w", G = "o", X = "k";
741
+ let pt = (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), _ = (t) => typeof t == "object" && t !== null, yt = (t) => Object.values(Object.getOwnPropertyDescriptors(t)).some((e) => !e.configurable && !e.writable), gt = (t) => {
743
+ if (Array.isArray(t))
744
+ return Array.from(t);
745
+ const e = Object.getOwnPropertyDescriptors(t);
746
+ return Object.values(e).forEach((s) => {
747
+ s.configurable = !0;
748
+ }), Object.create(K(t), e);
749
+ }, mt = (t, e) => {
750
+ const s = {
751
+ [Re]: e
752
+ };
753
+ let r = !1;
754
+ const n = (a, c) => {
755
+ if (!r) {
756
+ let u = s[S].get(t);
757
+ if (u || (u = {}, s[S].set(t, u)), a === A)
758
+ u[A] = !0;
759
+ else {
760
+ let p = u[a];
761
+ p || (p = /* @__PURE__ */ new Set(), u[a] = p), p.add(c);
762
+ }
763
+ }
764
+ }, i = () => {
765
+ r = !0, s[S].delete(t);
766
+ }, o = {
767
+ get(a, c) {
768
+ return c === V ? t : (n(X, c), Se(Reflect.get(a, c), s[S], s[be], s[Ee]));
769
+ },
770
+ has(a, c) {
771
+ return c === dt ? (i(), !0) : (n(J, c), Reflect.has(a, c));
772
+ },
773
+ getOwnPropertyDescriptor(a, c) {
774
+ return n(G, c), Reflect.getOwnPropertyDescriptor(a, c);
775
+ },
776
+ ownKeys(a) {
777
+ return n(A), Reflect.ownKeys(a);
778
+ }
779
+ };
780
+ return e && (o.set = o.deleteProperty = () => !1), [o, s];
781
+ }, Z = (t) => (
782
+ // 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
+ yt(c) ? n = [c, gt(c)] : n = [c], r?.set(t, n);
753
792
  }
754
- function g() {
755
- h(), e?.();
793
+ const [i, o] = n;
794
+ let a = s && s.get(i);
795
+ return (!a || a[1][Re] !== !!o) && (a = mt(i, !!o), a[1][oe] = pt(o || i, a[0]), s && s.set(i, a)), a[1][S] = e, a[1][be] = s, a[1][Ee] = r, a[1][oe];
796
+ }, wt = (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))
801
+ return !1;
802
+ if (!_(t) || !_(e))
803
+ return !0;
804
+ const i = s.get(Z(t));
805
+ if (!i)
806
+ return !0;
807
+ if (r) {
808
+ if (r.get(t) === e)
809
+ return !1;
810
+ r.set(t, e);
756
811
  }
757
- function R() {
758
- window.setTimeout(h, 2e3), s?.();
812
+ let o = null;
813
+ for (const a of i[J] || [])
814
+ if (o = Reflect.has(t, a) !== Reflect.has(e, a), o)
815
+ return o;
816
+ if (i[A] === !0) {
817
+ if (o = wt(t, e), o)
818
+ return o;
819
+ } else
820
+ for (const a of i[G] || []) {
821
+ const c = !!Reflect.getOwnPropertyDescriptor(t, a), u = !!Reflect.getOwnPropertyDescriptor(e, a);
822
+ if (o = c !== u, o)
823
+ return o;
824
+ }
825
+ for (const a of i[X] || [])
826
+ if (o = Ae(t[a], e[a], s, r, n), o)
827
+ return o;
828
+ if (o === null)
829
+ throw new Error("invalid used");
830
+ return o;
831
+ }, Tt = (t) => Pe(t) && t[V] || null, ie = (t, e = !0) => {
832
+ $.set(t, e);
833
+ }, Rt = (t, e, s) => {
834
+ const r = [], n = /* @__PURE__ */ new WeakSet(), i = (o, a) => {
835
+ var c, u, p;
836
+ if (n.has(o))
837
+ return;
838
+ _(o) && n.add(o);
839
+ const m = _(o) && e.get(Z(o));
840
+ if (m) {
841
+ if ((c = m[J]) === null || c === void 0 || c.forEach((g) => {
842
+ const w = `:has(${String(g)})`;
843
+ r.push(a ? [...a, w] : [w]);
844
+ }), m[A] === !0) {
845
+ const g = ":ownKeys";
846
+ r.push(a ? [...a, g] : [g]);
847
+ } else
848
+ (u = m[G]) === null || u === void 0 || u.forEach((g) => {
849
+ const w = `:hasOwn(${String(g)})`;
850
+ r.push(a ? [...a, w] : [w]);
851
+ });
852
+ (p = m[X]) === null || p === void 0 || p.forEach((g) => {
853
+ "value" in (Object.getOwnPropertyDescriptor(o, g) || {}) && i(o[g], a ? [...a, g] : [g]);
854
+ });
855
+ } else a && r.push(a);
856
+ };
857
+ return i(t), r;
858
+ }, U = {}, Q = (t) => typeof t == "object" && t !== null, bt = (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)
861
+ 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))
865
+ return;
866
+ const i = Reflect.get(t, n), { enumerable: o } = Reflect.getOwnPropertyDescriptor(
867
+ t,
868
+ n
869
+ ), a = {
870
+ value: i,
871
+ enumerable: o,
872
+ // This is intentional to avoid copying with proxy-compare.
873
+ // It's still non-writable, so it avoids assigning a value.
874
+ configurable: !0
875
+ };
876
+ if (ee.has(i))
877
+ ie(i, !1);
878
+ else if (E.has(i)) {
879
+ const [c, u] = E.get(
880
+ i
881
+ );
882
+ a.value = ve(c, u());
883
+ }
884
+ Object.defineProperty(r, n, a);
885
+ }), Object.preventExtensions(r);
886
+ }, Et = (t, e, s, r) => ({
887
+ deleteProperty(n, i) {
888
+ const o = Reflect.get(n, i);
889
+ s(i);
890
+ const a = Reflect.deleteProperty(n, i);
891
+ return a && r(["delete", [i], o]), a;
892
+ },
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) || j.has(o) && ce(u, j.get(o))))
896
+ return !0;
897
+ s(i), Q(o) && (o = Tt(o) || o);
898
+ const p = !E.has(o) && St(o) ? Oe(o) : o;
899
+ return e(i, p), Reflect.set(n, i, p, a), r(["set", [i], o, u]), !0;
759
900
  }
760
- function d() {
761
- r?.();
901
+ }), E = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new WeakSet(), ae = /* @__PURE__ */ new WeakMap(), L = [1], j = /* @__PURE__ */ new WeakMap();
902
+ let ce = Object.is, Pt = (t, e) => new Proxy(t, e), St = bt, At = ve, vt = Et;
903
+ function Oe(t = {}) {
904
+ if (!Q(t))
905
+ throw new Error("object required");
906
+ const e = j.get(t);
907
+ if (e)
908
+ return e;
909
+ let s = L[0];
910
+ const r = /* @__PURE__ */ new Set(), n = (l, d = ++L[0]) => {
911
+ s !== d && (i = s = d, r.forEach((f) => f(l, d)));
912
+ };
913
+ let i = s;
914
+ const o = (l = L[0]) => (i !== l && (i = l, c.forEach(([d]) => {
915
+ const f = d[1](l);
916
+ f > s && (s = f);
917
+ })), s), a = (l) => (d, f) => {
918
+ const T = [...d];
919
+ T[1] = [l, ...T[1]], n(T, f);
920
+ }, c = /* @__PURE__ */ new Map(), u = (l, d) => {
921
+ const f = !ee.has(d) && E.get(d);
922
+ if (f) {
923
+ if ((U ? "production" : void 0) !== "production" && c.has(l))
924
+ throw new Error("prop listener already exists");
925
+ if (r.size) {
926
+ const T = f[2](a(l));
927
+ c.set(l, [f, T]);
928
+ } else
929
+ c.set(l, [f]);
930
+ }
931
+ }, p = (l) => {
932
+ var d;
933
+ const f = c.get(l);
934
+ f && (c.delete(l), (d = f[1]) == null || d.call(f));
935
+ }, m = (l) => (r.add(l), r.size === 1 && c.forEach(([f, T], C) => {
936
+ if ((U ? "production" : void 0) !== "production" && T)
937
+ throw new Error("remove already exists");
938
+ const Ce = f[2](a(C));
939
+ c.set(C, [f, Ce]);
940
+ }), () => {
941
+ r.delete(l), r.size === 0 && c.forEach(([f, T], C) => {
942
+ T && (T(), c.set(C, [f]));
943
+ });
944
+ });
945
+ let g = !0;
946
+ const w = vt(
947
+ () => g,
948
+ u,
949
+ p,
950
+ n
951
+ ), P = Pt(t, w);
952
+ j.set(t, P);
953
+ const O = [t, o, m];
954
+ return E.set(P, O), Reflect.ownKeys(t).forEach((l) => {
955
+ const d = Object.getOwnPropertyDescriptor(
956
+ t,
957
+ l
958
+ );
959
+ "value" in d && d.writable && (P[l] = t[l]);
960
+ }), g = !1, P;
961
+ }
962
+ function Ot(t, e, s) {
963
+ const r = E.get(t);
964
+ (U ? "production" : void 0) !== "production" && !r && console.warn("Please use proxy object");
965
+ let n;
966
+ const i = [], o = r[2];
967
+ let a = !1;
968
+ const u = o((p) => {
969
+ i.push(p), n || (n = Promise.resolve().then(() => {
970
+ n = void 0, a && e(i.splice(0));
971
+ }));
972
+ });
973
+ return a = !0, () => {
974
+ a = !1, u();
975
+ };
976
+ }
977
+ function ue(t) {
978
+ const e = E.get(t);
979
+ (U ? "production" : void 0) !== "production" && !e && console.warn("Please use proxy object");
980
+ const [s, r] = e;
981
+ return At(s, r());
982
+ }
983
+ const Ct = {}, kt = (t, e) => {
984
+ const s = W(void 0);
985
+ F(() => {
986
+ s.current = Rt(t, e);
987
+ }), _e(s.current);
988
+ }, Nt = kt, qt = /* @__PURE__ */ new WeakMap();
989
+ function _t(t, e) {
990
+ const r = te(
991
+ () => t && /* @__PURE__ */ new WeakMap(),
992
+ [t]
993
+ ), n = W(void 0);
994
+ let i = !0;
995
+ const o = ke(
996
+ Ne(
997
+ (c) => {
998
+ const u = Ot(t, c);
999
+ return c(), u;
1000
+ },
1001
+ [t, void 0]
1002
+ ),
1003
+ () => {
1004
+ const c = ue(t);
1005
+ try {
1006
+ if (!i && n.current && !Ae(
1007
+ n.current,
1008
+ c,
1009
+ r,
1010
+ /* @__PURE__ */ new WeakMap()
1011
+ ))
1012
+ return n.current;
1013
+ } catch {
1014
+ }
1015
+ return c;
1016
+ },
1017
+ () => ue(t)
1018
+ );
1019
+ i = !1, qe(() => {
1020
+ n.current = o;
1021
+ }), (Ct ? "production" : void 0) !== "production" && Nt(o, r);
1022
+ const a = te(() => /* @__PURE__ */ new WeakMap(), []);
1023
+ return Se(o, r, a, qt);
1024
+ }
1025
+ const R = Oe({
1026
+ data: null,
1027
+ isPending: !1,
1028
+ error: null
1029
+ });
1030
+ function Lt({
1031
+ url: t,
1032
+ params: e,
1033
+ callbacks: s
1034
+ }) {
1035
+ const r = _t(R), [n, i] = le(!1);
1036
+ function o() {
1037
+ i(!0);
762
1038
  }
763
- function E() {
764
- n?.();
1039
+ function a() {
1040
+ i(!1);
765
1041
  }
766
- return {
767
- open: c,
768
- close: h,
769
- complete: R,
770
- cancel: g,
771
- chainSelected: d,
772
- intentCreated: E,
773
- isOpen: i,
774
- ...o
1042
+ const c = () => {
1043
+ R.isPending = !0, R.error = null, fetch(t, {
1044
+ method: "POST",
1045
+ headers: {
1046
+ "Content-Type": "application/json"
1047
+ },
1048
+ body: JSON.stringify({
1049
+ amount: e?.amount
1050
+ })
1051
+ }).then((u) => u.json()).then((u) => {
1052
+ R.data = u, s?.onSuccess?.(), R.isPending = !1;
1053
+ }).catch((u) => {
1054
+ R.error = u?.toString(), s?.onError?.(), R.isPending = !1;
1055
+ });
1056
+ };
1057
+ return F(c, []), {
1058
+ ...r,
1059
+ isOpen: n,
1060
+ open: o,
1061
+ close: a,
1062
+ refetch: c
775
1063
  };
776
1064
  }
777
1065
  export {
778
- u as Chainrails,
779
- Ue as PaymentModal,
780
- Ee as chains,
781
- ke as crapi,
782
- Se as tokens,
783
- Oe as usePaymentModal
1066
+ h as Chainrails,
1067
+ xt as PaymentModal,
1068
+ nt as chains,
1069
+ Mt as crapi,
1070
+ ot as tokens,
1071
+ Lt as useGetSessionToken
784
1072
  };