@chainrails/react 0.0.27 → 0.0.29

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