@chainrails/react 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/PaymentModal/index.d.ts +1 -1
- package/dist/PaymentModal/index.d.ts.map +1 -1
- package/dist/chainrails-sdk.es.js +90 -90
- package/dist/chainrails-sdk.es.mjs +90 -90
- package/dist/chainrails-sdk.umd.js +2 -2
- package/dist/hooks/usePaymentModal.d.ts +0 -2
- package/dist/hooks/usePaymentModal.d.ts.map +1 -1
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Chainrails.config({ api_key: <ENTER_API_KEY> })
|
|
|
26
26
|
|
|
27
27
|
function App() {
|
|
28
28
|
const cr = usePaymentModal({
|
|
29
|
-
to: "
|
|
29
|
+
to: "0xb25aa807118aa401896826147a6ecdaae91f2f90",
|
|
30
30
|
amount: 2,
|
|
31
31
|
chain: chains.BASE,
|
|
32
32
|
token: tokens.USDC,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/PaymentModal/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,KAAK,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/PaymentModal/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,KAAK,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eAiFpD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState as L, useRef as
|
|
1
|
+
import { useState as L, useRef as V, useEffect as G } from "react";
|
|
2
2
|
import { jsxs as O, jsx as w } from "react/jsx-runtime";
|
|
3
3
|
import './index.css';function B(t) {
|
|
4
4
|
var e, s, r = "";
|
|
@@ -13,13 +13,13 @@ function X() {
|
|
|
13
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
14
|
return r;
|
|
15
15
|
}
|
|
16
|
-
class
|
|
16
|
+
class P 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(),
|
|
22
|
-
super(`Request failed with ${
|
|
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";
|
|
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
25
|
class D extends Error {
|
|
@@ -34,7 +34,7 @@ class D extends Error {
|
|
|
34
34
|
super(s), this.value = e;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
class
|
|
37
|
+
class A extends Error {
|
|
38
38
|
name = "ForceRetryError";
|
|
39
39
|
customDelay;
|
|
40
40
|
code;
|
|
@@ -44,7 +44,7 @@ class S extends Error {
|
|
|
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
|
|
47
|
+
const M = (() => {
|
|
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)
|
|
@@ -72,7 +72,7 @@ const I = (() => {
|
|
|
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
|
-
},
|
|
75
|
+
}, C = 2147483647, te = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, F = Symbol("stop");
|
|
76
76
|
class _ {
|
|
77
77
|
options;
|
|
78
78
|
constructor(e) {
|
|
@@ -144,8 +144,8 @@ const se = (t) => new _(t), re = {
|
|
|
144
144
|
transform(o, i) {
|
|
145
145
|
if (i.enqueue(o), r) {
|
|
146
146
|
n += r.byteLength;
|
|
147
|
-
let
|
|
148
|
-
|
|
147
|
+
let a = e === 0 ? 0 : n / e;
|
|
148
|
+
a >= 1 && (a = 1 - Number.EPSILON), s?.({ percent: a, totalBytes: Math.max(e, n), transferredBytes: n }, r);
|
|
149
149
|
}
|
|
150
150
|
r = o;
|
|
151
151
|
},
|
|
@@ -181,7 +181,7 @@ const se = (t) => new _(t), re = {
|
|
|
181
181
|
for (const e of t)
|
|
182
182
|
if ((!f(e) || Array.isArray(e)) && e !== void 0)
|
|
183
183
|
throw new TypeError("The `options` argument must be an object");
|
|
184
|
-
return
|
|
184
|
+
return v({}, ...t);
|
|
185
185
|
}, J = (t = {}, e = {}) => {
|
|
186
186
|
const s = new globalThis.Headers(t), r = e instanceof globalThis.Headers, n = new globalThis.Headers(e);
|
|
187
187
|
for (const [o, i] of n.entries())
|
|
@@ -189,7 +189,7 @@ const se = (t) => new _(t), re = {
|
|
|
189
189
|
return s;
|
|
190
190
|
};
|
|
191
191
|
function T(t, e, s) {
|
|
192
|
-
return Object.hasOwn(e, s) && e[s] === void 0 ? [] :
|
|
192
|
+
return Object.hasOwn(e, s) && e[s] === void 0 ? [] : v(t[s] ?? [], e[s] ?? []);
|
|
193
193
|
}
|
|
194
194
|
const K = (t = {}, e = {}) => ({
|
|
195
195
|
beforeRequest: T(t, e, "beforeRequest"),
|
|
@@ -218,37 +218,37 @@ const K = (t = {}, e = {}) => ({
|
|
|
218
218
|
s.append(o, i);
|
|
219
219
|
}
|
|
220
220
|
return s;
|
|
221
|
-
},
|
|
221
|
+
}, v = (...t) => {
|
|
222
222
|
let e = {}, s = {}, r = {}, n;
|
|
223
223
|
const o = [];
|
|
224
224
|
for (const i of t)
|
|
225
225
|
if (Array.isArray(i))
|
|
226
226
|
Array.isArray(e) || (e = []), e = [...e, ...i];
|
|
227
227
|
else if (f(i)) {
|
|
228
|
-
for (let [
|
|
229
|
-
if (
|
|
230
|
-
o.push(
|
|
228
|
+
for (let [a, c] of Object.entries(i)) {
|
|
229
|
+
if (a === "signal" && c instanceof globalThis.AbortSignal) {
|
|
230
|
+
o.push(c);
|
|
231
231
|
continue;
|
|
232
232
|
}
|
|
233
|
-
if (
|
|
234
|
-
if (
|
|
233
|
+
if (a === "context") {
|
|
234
|
+
if (c != null && (!f(c) || Array.isArray(c)))
|
|
235
235
|
throw new TypeError("The `context` option must be an object");
|
|
236
236
|
e = {
|
|
237
237
|
...e,
|
|
238
|
-
context:
|
|
238
|
+
context: c == null ? {} : { ...e.context, ...c }
|
|
239
239
|
};
|
|
240
240
|
continue;
|
|
241
241
|
}
|
|
242
|
-
if (
|
|
243
|
-
|
|
242
|
+
if (a === "searchParams") {
|
|
243
|
+
c == null ? n = void 0 : n = n === void 0 ? c : ue(n, c);
|
|
244
244
|
continue;
|
|
245
245
|
}
|
|
246
|
-
f(
|
|
246
|
+
f(c) && a in e && (c = v(e[a], c)), e = { ...e, [a]: c };
|
|
247
247
|
}
|
|
248
248
|
f(i.hooks) && (r = K(r, i.hooks), e.hooks = r), f(i.headers) && (s = J(s, i.headers), e.headers = s);
|
|
249
249
|
}
|
|
250
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],
|
|
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 = {
|
|
252
252
|
limit: 2,
|
|
253
253
|
methods: he,
|
|
254
254
|
statusCodes: fe,
|
|
@@ -261,7 +261,7 @@ const K = (t = {}, e = {}) => ({
|
|
|
261
261
|
}, pe = (t = {}) => {
|
|
262
262
|
if (typeof t == "number")
|
|
263
263
|
return {
|
|
264
|
-
...
|
|
264
|
+
...I,
|
|
265
265
|
limit: t
|
|
266
266
|
};
|
|
267
267
|
if (t.methods && !Array.isArray(t.methods))
|
|
@@ -269,11 +269,11 @@ 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
|
-
...
|
|
272
|
+
...I,
|
|
273
273
|
...t
|
|
274
274
|
};
|
|
275
275
|
};
|
|
276
|
-
class
|
|
276
|
+
class x 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;
|
|
@@ -282,7 +282,7 @@ class P extends Error {
|
|
|
282
282
|
async function ye(t, e, s, r) {
|
|
283
283
|
return new Promise((n, o) => {
|
|
284
284
|
const i = setTimeout(() => {
|
|
285
|
-
s && s.abort(), o(new
|
|
285
|
+
s && s.abort(), o(new x(t));
|
|
286
286
|
}, r.timeout);
|
|
287
287
|
r.fetch(t, e).then(n).catch(o).then(() => {
|
|
288
288
|
clearTimeout(i);
|
|
@@ -307,31 +307,31 @@ const me = (t, e) => {
|
|
|
307
307
|
return s;
|
|
308
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
309
|
function be(t) {
|
|
310
|
-
return t instanceof
|
|
310
|
+
return t instanceof P || t?.name === P.name;
|
|
311
311
|
}
|
|
312
312
|
function Te(t) {
|
|
313
|
-
return t instanceof
|
|
313
|
+
return t instanceof x || t?.name === x.name;
|
|
314
314
|
}
|
|
315
|
-
class
|
|
315
|
+
class y {
|
|
316
316
|
static create(e, s) {
|
|
317
|
-
const r = new
|
|
318
|
-
if (typeof r.#e.timeout == "number" && r.#e.timeout >
|
|
319
|
-
throw new RangeError(`The \`timeout\` option cannot be greater than ${
|
|
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}`);
|
|
320
320
|
await Promise.resolve();
|
|
321
321
|
let i = await r.#y();
|
|
322
|
-
for (const
|
|
323
|
-
const
|
|
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
324
|
if (h instanceof globalThis.Response && (i = h), h instanceof _)
|
|
325
325
|
throw await Promise.all([
|
|
326
|
-
|
|
326
|
+
c.body?.cancel(),
|
|
327
327
|
i.body?.cancel()
|
|
328
|
-
]), new
|
|
328
|
+
]), new A(h.options);
|
|
329
329
|
}
|
|
330
330
|
if (r.#l(i), !i.ok && (typeof r.#e.throwHttpErrors == "function" ? r.#e.throwHttpErrors(i.status) : r.#e.throwHttpErrors)) {
|
|
331
|
-
let
|
|
332
|
-
for (const
|
|
333
|
-
|
|
334
|
-
throw
|
|
331
|
+
let a = new P(i, r.request, r.#a());
|
|
332
|
+
for (const c of r.#e.hooks.beforeError)
|
|
333
|
+
a = await c(a, { retryCount: r.#s });
|
|
334
|
+
throw a;
|
|
335
335
|
}
|
|
336
336
|
if (r.#e.onDownloadProgress) {
|
|
337
337
|
if (typeof r.#e.onDownloadProgress != "function")
|
|
@@ -342,20 +342,20 @@ class p {
|
|
|
342
342
|
}
|
|
343
343
|
return i;
|
|
344
344
|
}, o = r.#h(n).finally(async () => {
|
|
345
|
-
const i = r.#o,
|
|
346
|
-
i && !i.bodyUsed &&
|
|
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);
|
|
347
347
|
});
|
|
348
|
-
for (const [i,
|
|
348
|
+
for (const [i, a] of Object.entries(ee))
|
|
349
349
|
i === "bytes" && typeof globalThis.Response?.prototype?.bytes != "function" || (o[i] = async () => {
|
|
350
|
-
r.request.headers.set("accept", r.request.headers.get("accept") ||
|
|
351
|
-
const
|
|
350
|
+
r.request.headers.set("accept", r.request.headers.get("accept") || a);
|
|
351
|
+
const c = await o;
|
|
352
352
|
if (i === "json") {
|
|
353
|
-
if (
|
|
353
|
+
if (c.status === 204)
|
|
354
354
|
return "";
|
|
355
|
-
const h = await
|
|
355
|
+
const h = await c.text();
|
|
356
356
|
return h === "" ? "" : s.parseJson ? s.parseJson(h) : JSON.parse(h);
|
|
357
357
|
}
|
|
358
|
-
return
|
|
358
|
+
return c[i]();
|
|
359
359
|
});
|
|
360
360
|
return o;
|
|
361
361
|
}
|
|
@@ -398,16 +398,16 @@ class p {
|
|
|
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),
|
|
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"));
|
|
402
402
|
const r = s.headers && new globalThis.Headers(s.headers).has("content-type");
|
|
403
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(
|
|
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
405
|
this.request = new globalThis.Request(i, 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 (!
|
|
410
|
+
if (!M)
|
|
411
411
|
throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
|
|
412
412
|
this.request = this.#f(this.request, this.#e.body ?? void 0);
|
|
413
413
|
}
|
|
@@ -421,7 +421,7 @@ class p {
|
|
|
421
421
|
if (this.#s++, this.#s > this.#e.retry.limit)
|
|
422
422
|
throw e;
|
|
423
423
|
const s = e instanceof Error ? e : new D(e);
|
|
424
|
-
if (s instanceof
|
|
424
|
+
if (s instanceof A)
|
|
425
425
|
return s.customDelay ?? this.#c();
|
|
426
426
|
if (!this.#e.retry.methods.includes(this.request.method.toLowerCase()))
|
|
427
427
|
throw e;
|
|
@@ -456,10 +456,10 @@ class p {
|
|
|
456
456
|
try {
|
|
457
457
|
return await e();
|
|
458
458
|
} catch (s) {
|
|
459
|
-
const r = Math.min(await this.#p(s),
|
|
459
|
+
const r = Math.min(await this.#p(s), C);
|
|
460
460
|
if (this.#s < 1)
|
|
461
461
|
throw s;
|
|
462
|
-
if (await ge(r, this.#n ? { signal: this.#n } : {}), s instanceof
|
|
462
|
+
if (await ge(r, this.#n ? { signal: this.#n } : {}), s instanceof A && 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
|
}
|
|
@@ -511,24 +511,24 @@ class p {
|
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
/*! MIT License © Sindre Sorhus */
|
|
514
|
-
const
|
|
515
|
-
const e = (s, r) =>
|
|
514
|
+
const q = (t) => {
|
|
515
|
+
const e = (s, r) => y.create(s, b(t, r));
|
|
516
516
|
for (const s of $)
|
|
517
|
-
e[s] = (r, n) =>
|
|
518
|
-
return e.create = (s) =>
|
|
519
|
-
}, Re =
|
|
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 || {}),
|
|
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
521
|
class u {
|
|
522
522
|
constructor({ api_key: e, env: s }) {
|
|
523
|
-
this.api_key = e, this.jwt = "", this.env = s ??
|
|
523
|
+
this.api_key = e, this.jwt = "", this.env = s ?? N.PRODUCTION;
|
|
524
524
|
}
|
|
525
|
-
static config(e) {
|
|
525
|
+
static async config(e) {
|
|
526
526
|
if (!u.app) {
|
|
527
527
|
if (!e)
|
|
528
528
|
throw new Error("Please provide an api_key");
|
|
529
529
|
u.app = new u(e);
|
|
530
530
|
}
|
|
531
|
-
return e && (u.app.api_key = e.api_key, e.env !== void 0 && (u.app.env = e.env), this.updateJWT(), setInterval(this.updateJWT.bind(this), 1500 * 1e3)), u.app;
|
|
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;
|
|
532
532
|
}
|
|
533
533
|
static async updateJWT() {
|
|
534
534
|
try {
|
|
@@ -575,13 +575,13 @@ class u {
|
|
|
575
575
|
static getPayModalUrl(e, s, r, n) {
|
|
576
576
|
if (!u.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
|
|
579
|
-
return o + i;
|
|
578
|
+
const o = u.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", i = n ? "/pay/" : "/deposit/", a = `_chain_/${e}/_token_/${s}/_to_/${r}/_amount_/${n && n * 100}`;
|
|
579
|
+
return o + i + a;
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
|
-
let
|
|
582
|
+
let j = null;
|
|
583
583
|
function Ae() {
|
|
584
|
-
|
|
584
|
+
j = Re.create({
|
|
585
585
|
prefixUrl: u.getBaseUrl(),
|
|
586
586
|
headers: {
|
|
587
587
|
"Content-Type": "application/json"
|
|
@@ -601,7 +601,7 @@ function Ae() {
|
|
|
601
601
|
});
|
|
602
602
|
}
|
|
603
603
|
function l() {
|
|
604
|
-
return
|
|
604
|
+
return j || Ae(), j;
|
|
605
605
|
}
|
|
606
606
|
class Ce {
|
|
607
607
|
async getById(e) {
|
|
@@ -679,33 +679,33 @@ function Ue(t) {
|
|
|
679
679
|
amount: n,
|
|
680
680
|
isOpen: o,
|
|
681
681
|
close: i,
|
|
682
|
-
complete:
|
|
683
|
-
cancel:
|
|
682
|
+
complete: a,
|
|
683
|
+
cancel: c,
|
|
684
684
|
chainSelected: h,
|
|
685
|
-
intentCreated:
|
|
685
|
+
intentCreated: g,
|
|
686
686
|
...R
|
|
687
|
-
} = t, [d, E] = L(!0),
|
|
687
|
+
} = t, [d, E] = L(!0), S = V(null);
|
|
688
688
|
G(() => {
|
|
689
689
|
k();
|
|
690
|
-
const
|
|
691
|
-
o ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow =
|
|
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
692
|
const U = (m) => {
|
|
693
|
-
m.data === "closed" &&
|
|
693
|
+
m.data === "closed" && c(), m.data === "completed" && a(), m.data === "chainSelected" && h(), m.data === "intentCreated" && g();
|
|
694
694
|
};
|
|
695
695
|
return window.addEventListener("message", U), () => {
|
|
696
|
-
document.body.style.overflow =
|
|
696
|
+
document.body.style.overflow = p || "", window.removeEventListener("message", U);
|
|
697
697
|
};
|
|
698
|
-
}, [o,
|
|
699
|
-
function
|
|
698
|
+
}, [o, c, a, h, g]);
|
|
699
|
+
function W() {
|
|
700
700
|
E(!1), k();
|
|
701
701
|
}
|
|
702
702
|
function k() {
|
|
703
|
-
const
|
|
703
|
+
const p = {
|
|
704
704
|
type: "apiKey",
|
|
705
705
|
apiKey: u.getApiKey(),
|
|
706
|
-
environment: u.getEnv() ||
|
|
706
|
+
environment: u.getEnv() || N.PRODUCTION
|
|
707
707
|
};
|
|
708
|
-
|
|
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
709
|
}
|
|
710
710
|
return /* @__PURE__ */ O("div", {
|
|
711
711
|
...R,
|
|
@@ -730,9 +730,9 @@ function Ue(t) {
|
|
|
730
730
|
}), /* @__PURE__ */ w("iframe", {
|
|
731
731
|
allow: "clipboard-read *; clipboard-write *",
|
|
732
732
|
src: u.getPayModalUrl(r, s, e, n),
|
|
733
|
-
onLoad:
|
|
733
|
+
onLoad: W,
|
|
734
734
|
className: `payment-modal ${d ? "invisible" : "visible"}`,
|
|
735
|
-
ref:
|
|
735
|
+
ref: S
|
|
736
736
|
})]
|
|
737
737
|
});
|
|
738
738
|
}
|
|
@@ -743,14 +743,14 @@ function Oe(t) {
|
|
|
743
743
|
onChainSelect: r,
|
|
744
744
|
onIntentCreate: n,
|
|
745
745
|
...o
|
|
746
|
-
} = t, [i,
|
|
747
|
-
function
|
|
748
|
-
|
|
746
|
+
} = t, [i, a] = L(!1);
|
|
747
|
+
function c() {
|
|
748
|
+
a(!0);
|
|
749
749
|
}
|
|
750
750
|
function h() {
|
|
751
|
-
|
|
751
|
+
a(!1);
|
|
752
752
|
}
|
|
753
|
-
function
|
|
753
|
+
function g() {
|
|
754
754
|
h(), e?.();
|
|
755
755
|
}
|
|
756
756
|
function R() {
|
|
@@ -763,10 +763,10 @@ function Oe(t) {
|
|
|
763
763
|
n?.();
|
|
764
764
|
}
|
|
765
765
|
return {
|
|
766
|
-
open:
|
|
766
|
+
open: c,
|
|
767
767
|
close: h,
|
|
768
768
|
complete: R,
|
|
769
|
-
cancel:
|
|
769
|
+
cancel: g,
|
|
770
770
|
chainSelected: d,
|
|
771
771
|
intentCreated: E,
|
|
772
772
|
isOpen: i,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState as L, useRef as
|
|
1
|
+
import { useState as L, useRef as V, useEffect as G } from "react";
|
|
2
2
|
import { jsxs as O, jsx as w } from "react/jsx-runtime";
|
|
3
3
|
import './index.css';function B(t) {
|
|
4
4
|
var e, s, r = "";
|
|
@@ -13,13 +13,13 @@ function X() {
|
|
|
13
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
14
|
return r;
|
|
15
15
|
}
|
|
16
|
-
class
|
|
16
|
+
class P 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(),
|
|
22
|
-
super(`Request failed with ${
|
|
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";
|
|
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
25
|
class D extends Error {
|
|
@@ -34,7 +34,7 @@ class D extends Error {
|
|
|
34
34
|
super(s), this.value = e;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
class
|
|
37
|
+
class A extends Error {
|
|
38
38
|
name = "ForceRetryError";
|
|
39
39
|
customDelay;
|
|
40
40
|
code;
|
|
@@ -44,7 +44,7 @@ class S extends Error {
|
|
|
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
|
|
47
|
+
const M = (() => {
|
|
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)
|
|
@@ -72,7 +72,7 @@ const I = (() => {
|
|
|
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
|
-
},
|
|
75
|
+
}, C = 2147483647, te = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, F = Symbol("stop");
|
|
76
76
|
class _ {
|
|
77
77
|
options;
|
|
78
78
|
constructor(e) {
|
|
@@ -144,8 +144,8 @@ const se = (t) => new _(t), re = {
|
|
|
144
144
|
transform(o, i) {
|
|
145
145
|
if (i.enqueue(o), r) {
|
|
146
146
|
n += r.byteLength;
|
|
147
|
-
let
|
|
148
|
-
|
|
147
|
+
let a = e === 0 ? 0 : n / e;
|
|
148
|
+
a >= 1 && (a = 1 - Number.EPSILON), s?.({ percent: a, totalBytes: Math.max(e, n), transferredBytes: n }, r);
|
|
149
149
|
}
|
|
150
150
|
r = o;
|
|
151
151
|
},
|
|
@@ -181,7 +181,7 @@ const se = (t) => new _(t), re = {
|
|
|
181
181
|
for (const e of t)
|
|
182
182
|
if ((!f(e) || Array.isArray(e)) && e !== void 0)
|
|
183
183
|
throw new TypeError("The `options` argument must be an object");
|
|
184
|
-
return
|
|
184
|
+
return v({}, ...t);
|
|
185
185
|
}, J = (t = {}, e = {}) => {
|
|
186
186
|
const s = new globalThis.Headers(t), r = e instanceof globalThis.Headers, n = new globalThis.Headers(e);
|
|
187
187
|
for (const [o, i] of n.entries())
|
|
@@ -189,7 +189,7 @@ const se = (t) => new _(t), re = {
|
|
|
189
189
|
return s;
|
|
190
190
|
};
|
|
191
191
|
function T(t, e, s) {
|
|
192
|
-
return Object.hasOwn(e, s) && e[s] === void 0 ? [] :
|
|
192
|
+
return Object.hasOwn(e, s) && e[s] === void 0 ? [] : v(t[s] ?? [], e[s] ?? []);
|
|
193
193
|
}
|
|
194
194
|
const K = (t = {}, e = {}) => ({
|
|
195
195
|
beforeRequest: T(t, e, "beforeRequest"),
|
|
@@ -218,37 +218,37 @@ const K = (t = {}, e = {}) => ({
|
|
|
218
218
|
s.append(o, i);
|
|
219
219
|
}
|
|
220
220
|
return s;
|
|
221
|
-
},
|
|
221
|
+
}, v = (...t) => {
|
|
222
222
|
let e = {}, s = {}, r = {}, n;
|
|
223
223
|
const o = [];
|
|
224
224
|
for (const i of t)
|
|
225
225
|
if (Array.isArray(i))
|
|
226
226
|
Array.isArray(e) || (e = []), e = [...e, ...i];
|
|
227
227
|
else if (f(i)) {
|
|
228
|
-
for (let [
|
|
229
|
-
if (
|
|
230
|
-
o.push(
|
|
228
|
+
for (let [a, c] of Object.entries(i)) {
|
|
229
|
+
if (a === "signal" && c instanceof globalThis.AbortSignal) {
|
|
230
|
+
o.push(c);
|
|
231
231
|
continue;
|
|
232
232
|
}
|
|
233
|
-
if (
|
|
234
|
-
if (
|
|
233
|
+
if (a === "context") {
|
|
234
|
+
if (c != null && (!f(c) || Array.isArray(c)))
|
|
235
235
|
throw new TypeError("The `context` option must be an object");
|
|
236
236
|
e = {
|
|
237
237
|
...e,
|
|
238
|
-
context:
|
|
238
|
+
context: c == null ? {} : { ...e.context, ...c }
|
|
239
239
|
};
|
|
240
240
|
continue;
|
|
241
241
|
}
|
|
242
|
-
if (
|
|
243
|
-
|
|
242
|
+
if (a === "searchParams") {
|
|
243
|
+
c == null ? n = void 0 : n = n === void 0 ? c : ue(n, c);
|
|
244
244
|
continue;
|
|
245
245
|
}
|
|
246
|
-
f(
|
|
246
|
+
f(c) && a in e && (c = v(e[a], c)), e = { ...e, [a]: c };
|
|
247
247
|
}
|
|
248
248
|
f(i.hooks) && (r = K(r, i.hooks), e.hooks = r), f(i.headers) && (s = J(s, i.headers), e.headers = s);
|
|
249
249
|
}
|
|
250
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],
|
|
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 = {
|
|
252
252
|
limit: 2,
|
|
253
253
|
methods: he,
|
|
254
254
|
statusCodes: fe,
|
|
@@ -261,7 +261,7 @@ const K = (t = {}, e = {}) => ({
|
|
|
261
261
|
}, pe = (t = {}) => {
|
|
262
262
|
if (typeof t == "number")
|
|
263
263
|
return {
|
|
264
|
-
...
|
|
264
|
+
...I,
|
|
265
265
|
limit: t
|
|
266
266
|
};
|
|
267
267
|
if (t.methods && !Array.isArray(t.methods))
|
|
@@ -269,11 +269,11 @@ 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
|
-
...
|
|
272
|
+
...I,
|
|
273
273
|
...t
|
|
274
274
|
};
|
|
275
275
|
};
|
|
276
|
-
class
|
|
276
|
+
class x 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;
|
|
@@ -282,7 +282,7 @@ class P extends Error {
|
|
|
282
282
|
async function ye(t, e, s, r) {
|
|
283
283
|
return new Promise((n, o) => {
|
|
284
284
|
const i = setTimeout(() => {
|
|
285
|
-
s && s.abort(), o(new
|
|
285
|
+
s && s.abort(), o(new x(t));
|
|
286
286
|
}, r.timeout);
|
|
287
287
|
r.fetch(t, e).then(n).catch(o).then(() => {
|
|
288
288
|
clearTimeout(i);
|
|
@@ -307,31 +307,31 @@ const me = (t, e) => {
|
|
|
307
307
|
return s;
|
|
308
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
309
|
function be(t) {
|
|
310
|
-
return t instanceof
|
|
310
|
+
return t instanceof P || t?.name === P.name;
|
|
311
311
|
}
|
|
312
312
|
function Te(t) {
|
|
313
|
-
return t instanceof
|
|
313
|
+
return t instanceof x || t?.name === x.name;
|
|
314
314
|
}
|
|
315
|
-
class
|
|
315
|
+
class y {
|
|
316
316
|
static create(e, s) {
|
|
317
|
-
const r = new
|
|
318
|
-
if (typeof r.#e.timeout == "number" && r.#e.timeout >
|
|
319
|
-
throw new RangeError(`The \`timeout\` option cannot be greater than ${
|
|
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}`);
|
|
320
320
|
await Promise.resolve();
|
|
321
321
|
let i = await r.#y();
|
|
322
|
-
for (const
|
|
323
|
-
const
|
|
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
324
|
if (h instanceof globalThis.Response && (i = h), h instanceof _)
|
|
325
325
|
throw await Promise.all([
|
|
326
|
-
|
|
326
|
+
c.body?.cancel(),
|
|
327
327
|
i.body?.cancel()
|
|
328
|
-
]), new
|
|
328
|
+
]), new A(h.options);
|
|
329
329
|
}
|
|
330
330
|
if (r.#l(i), !i.ok && (typeof r.#e.throwHttpErrors == "function" ? r.#e.throwHttpErrors(i.status) : r.#e.throwHttpErrors)) {
|
|
331
|
-
let
|
|
332
|
-
for (const
|
|
333
|
-
|
|
334
|
-
throw
|
|
331
|
+
let a = new P(i, r.request, r.#a());
|
|
332
|
+
for (const c of r.#e.hooks.beforeError)
|
|
333
|
+
a = await c(a, { retryCount: r.#s });
|
|
334
|
+
throw a;
|
|
335
335
|
}
|
|
336
336
|
if (r.#e.onDownloadProgress) {
|
|
337
337
|
if (typeof r.#e.onDownloadProgress != "function")
|
|
@@ -342,20 +342,20 @@ class p {
|
|
|
342
342
|
}
|
|
343
343
|
return i;
|
|
344
344
|
}, o = r.#h(n).finally(async () => {
|
|
345
|
-
const i = r.#o,
|
|
346
|
-
i && !i.bodyUsed &&
|
|
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);
|
|
347
347
|
});
|
|
348
|
-
for (const [i,
|
|
348
|
+
for (const [i, a] of Object.entries(ee))
|
|
349
349
|
i === "bytes" && typeof globalThis.Response?.prototype?.bytes != "function" || (o[i] = async () => {
|
|
350
|
-
r.request.headers.set("accept", r.request.headers.get("accept") ||
|
|
351
|
-
const
|
|
350
|
+
r.request.headers.set("accept", r.request.headers.get("accept") || a);
|
|
351
|
+
const c = await o;
|
|
352
352
|
if (i === "json") {
|
|
353
|
-
if (
|
|
353
|
+
if (c.status === 204)
|
|
354
354
|
return "";
|
|
355
|
-
const h = await
|
|
355
|
+
const h = await c.text();
|
|
356
356
|
return h === "" ? "" : s.parseJson ? s.parseJson(h) : JSON.parse(h);
|
|
357
357
|
}
|
|
358
|
-
return
|
|
358
|
+
return c[i]();
|
|
359
359
|
});
|
|
360
360
|
return o;
|
|
361
361
|
}
|
|
@@ -398,16 +398,16 @@ class p {
|
|
|
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),
|
|
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"));
|
|
402
402
|
const r = s.headers && new globalThis.Headers(s.headers).has("content-type");
|
|
403
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(
|
|
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
405
|
this.request = new globalThis.Request(i, 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 (!
|
|
410
|
+
if (!M)
|
|
411
411
|
throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
|
|
412
412
|
this.request = this.#f(this.request, this.#e.body ?? void 0);
|
|
413
413
|
}
|
|
@@ -421,7 +421,7 @@ class p {
|
|
|
421
421
|
if (this.#s++, this.#s > this.#e.retry.limit)
|
|
422
422
|
throw e;
|
|
423
423
|
const s = e instanceof Error ? e : new D(e);
|
|
424
|
-
if (s instanceof
|
|
424
|
+
if (s instanceof A)
|
|
425
425
|
return s.customDelay ?? this.#c();
|
|
426
426
|
if (!this.#e.retry.methods.includes(this.request.method.toLowerCase()))
|
|
427
427
|
throw e;
|
|
@@ -456,10 +456,10 @@ class p {
|
|
|
456
456
|
try {
|
|
457
457
|
return await e();
|
|
458
458
|
} catch (s) {
|
|
459
|
-
const r = Math.min(await this.#p(s),
|
|
459
|
+
const r = Math.min(await this.#p(s), C);
|
|
460
460
|
if (this.#s < 1)
|
|
461
461
|
throw s;
|
|
462
|
-
if (await ge(r, this.#n ? { signal: this.#n } : {}), s instanceof
|
|
462
|
+
if (await ge(r, this.#n ? { signal: this.#n } : {}), s instanceof A && 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
|
}
|
|
@@ -511,24 +511,24 @@ class p {
|
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
/*! MIT License © Sindre Sorhus */
|
|
514
|
-
const
|
|
515
|
-
const e = (s, r) =>
|
|
514
|
+
const q = (t) => {
|
|
515
|
+
const e = (s, r) => y.create(s, b(t, r));
|
|
516
516
|
for (const s of $)
|
|
517
|
-
e[s] = (r, n) =>
|
|
518
|
-
return e.create = (s) =>
|
|
519
|
-
}, Re =
|
|
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 || {}),
|
|
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
521
|
class u {
|
|
522
522
|
constructor({ api_key: e, env: s }) {
|
|
523
|
-
this.api_key = e, this.jwt = "", this.env = s ??
|
|
523
|
+
this.api_key = e, this.jwt = "", this.env = s ?? N.PRODUCTION;
|
|
524
524
|
}
|
|
525
|
-
static config(e) {
|
|
525
|
+
static async config(e) {
|
|
526
526
|
if (!u.app) {
|
|
527
527
|
if (!e)
|
|
528
528
|
throw new Error("Please provide an api_key");
|
|
529
529
|
u.app = new u(e);
|
|
530
530
|
}
|
|
531
|
-
return e && (u.app.api_key = e.api_key, e.env !== void 0 && (u.app.env = e.env), this.updateJWT(), setInterval(this.updateJWT.bind(this), 1500 * 1e3)), u.app;
|
|
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;
|
|
532
532
|
}
|
|
533
533
|
static async updateJWT() {
|
|
534
534
|
try {
|
|
@@ -575,13 +575,13 @@ class u {
|
|
|
575
575
|
static getPayModalUrl(e, s, r, n) {
|
|
576
576
|
if (!u.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
|
|
579
|
-
return o + i;
|
|
578
|
+
const o = u.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", i = n ? "/pay/" : "/deposit/", a = `_chain_/${e}/_token_/${s}/_to_/${r}/_amount_/${n && n * 100}`;
|
|
579
|
+
return o + i + a;
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
|
-
let
|
|
582
|
+
let j = null;
|
|
583
583
|
function Ae() {
|
|
584
|
-
|
|
584
|
+
j = Re.create({
|
|
585
585
|
prefixUrl: u.getBaseUrl(),
|
|
586
586
|
headers: {
|
|
587
587
|
"Content-Type": "application/json"
|
|
@@ -601,7 +601,7 @@ function Ae() {
|
|
|
601
601
|
});
|
|
602
602
|
}
|
|
603
603
|
function l() {
|
|
604
|
-
return
|
|
604
|
+
return j || Ae(), j;
|
|
605
605
|
}
|
|
606
606
|
class Ce {
|
|
607
607
|
async getById(e) {
|
|
@@ -679,33 +679,33 @@ function Ue(t) {
|
|
|
679
679
|
amount: n,
|
|
680
680
|
isOpen: o,
|
|
681
681
|
close: i,
|
|
682
|
-
complete:
|
|
683
|
-
cancel:
|
|
682
|
+
complete: a,
|
|
683
|
+
cancel: c,
|
|
684
684
|
chainSelected: h,
|
|
685
|
-
intentCreated:
|
|
685
|
+
intentCreated: g,
|
|
686
686
|
...R
|
|
687
|
-
} = t, [d, E] = L(!0),
|
|
687
|
+
} = t, [d, E] = L(!0), S = V(null);
|
|
688
688
|
G(() => {
|
|
689
689
|
k();
|
|
690
|
-
const
|
|
691
|
-
o ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow =
|
|
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
692
|
const U = (m) => {
|
|
693
|
-
m.data === "closed" &&
|
|
693
|
+
m.data === "closed" && c(), m.data === "completed" && a(), m.data === "chainSelected" && h(), m.data === "intentCreated" && g();
|
|
694
694
|
};
|
|
695
695
|
return window.addEventListener("message", U), () => {
|
|
696
|
-
document.body.style.overflow =
|
|
696
|
+
document.body.style.overflow = p || "", window.removeEventListener("message", U);
|
|
697
697
|
};
|
|
698
|
-
}, [o,
|
|
699
|
-
function
|
|
698
|
+
}, [o, c, a, h, g]);
|
|
699
|
+
function W() {
|
|
700
700
|
E(!1), k();
|
|
701
701
|
}
|
|
702
702
|
function k() {
|
|
703
|
-
const
|
|
703
|
+
const p = {
|
|
704
704
|
type: "apiKey",
|
|
705
705
|
apiKey: u.getApiKey(),
|
|
706
|
-
environment: u.getEnv() ||
|
|
706
|
+
environment: u.getEnv() || N.PRODUCTION
|
|
707
707
|
};
|
|
708
|
-
|
|
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
709
|
}
|
|
710
710
|
return /* @__PURE__ */ O("div", {
|
|
711
711
|
...R,
|
|
@@ -730,9 +730,9 @@ function Ue(t) {
|
|
|
730
730
|
}), /* @__PURE__ */ w("iframe", {
|
|
731
731
|
allow: "clipboard-read *; clipboard-write *",
|
|
732
732
|
src: u.getPayModalUrl(r, s, e, n),
|
|
733
|
-
onLoad:
|
|
733
|
+
onLoad: W,
|
|
734
734
|
className: `payment-modal ${d ? "invisible" : "visible"}`,
|
|
735
|
-
ref:
|
|
735
|
+
ref: S
|
|
736
736
|
})]
|
|
737
737
|
});
|
|
738
738
|
}
|
|
@@ -743,14 +743,14 @@ function Oe(t) {
|
|
|
743
743
|
onChainSelect: r,
|
|
744
744
|
onIntentCreate: n,
|
|
745
745
|
...o
|
|
746
|
-
} = t, [i,
|
|
747
|
-
function
|
|
748
|
-
|
|
746
|
+
} = t, [i, a] = L(!1);
|
|
747
|
+
function c() {
|
|
748
|
+
a(!0);
|
|
749
749
|
}
|
|
750
750
|
function h() {
|
|
751
|
-
|
|
751
|
+
a(!1);
|
|
752
752
|
}
|
|
753
|
-
function
|
|
753
|
+
function g() {
|
|
754
754
|
h(), e?.();
|
|
755
755
|
}
|
|
756
756
|
function R() {
|
|
@@ -763,10 +763,10 @@ function Oe(t) {
|
|
|
763
763
|
n?.();
|
|
764
764
|
}
|
|
765
765
|
return {
|
|
766
|
-
open:
|
|
766
|
+
open: c,
|
|
767
767
|
close: h,
|
|
768
768
|
complete: R,
|
|
769
|
-
cancel:
|
|
769
|
+
cancel: g,
|
|
770
770
|
chainSelected: d,
|
|
771
771
|
intentCreated: E,
|
|
772
772
|
isOpen: i,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(p,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],h):(p=typeof globalThis<"u"?globalThis:p||self,h(p.Chainrails={},p.React,p.jsxRuntime))})(this,(function(p,h,y){"use strict";var U=document.createElement("style");U.textContent=`/*! tailwindcss v4.1.14 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-duration:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-blue-600:oklch(54.6% .245 262.881);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-600:oklch(44.6% .03 256.802);--color-black:#000;--spacing:.25rem;--animate-spin:spin 1s linear infinite;--blur-xs:4px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.invisible{visibility:hidden}.visible{visibility:visible}.hidden{display:none}}.payment-modal-wrapper{inset:calc(var(--spacing)*0);z-index:10000;width:100vw;height:100dvh;transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration));--tw-duration:.1s;transition-duration:.1s;position:fixed}.payment-modal-wrapper.loading{background-color:#00000026}@supports (color:color-mix(in lab,red,red)){.payment-modal-wrapper.loading{background-color:color-mix(in oklab,var(--color-black)15%,transparent)}}.payment-modal-wrapper.loading{--tw-backdrop-blur:blur(2px);-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.payment-modal-wrapper.not-loading{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.payment-modal-wrapper.not-loading{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.payment-modal-wrapper.not-loading{--tw-backdrop-blur:blur(var(--blur-xs));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0}.payment-modal-wrapper.open iframe{--tw-translate-y:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y);--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x)var(--tw-scale-y)}.payment-modal-wrapper.closed iframe{--tw-translate-y:50vh;translate:var(--tw-translate-x)var(--tw-translate-y);--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x)var(--tw-scale-y)}.payment-modal-loader{inset:calc(var(--spacing)*0);z-index:10000;place-content:center;width:100%;height:100%;display:grid;position:absolute}.payment-modal-loader .icon{height:calc(var(--spacing)*12);width:calc(var(--spacing)*12);animation:var(--animate-spin);fill:var(--color-blue-600);color:var(--color-gray-200)}@media (prefers-color-scheme:dark){.payment-modal-loader .icon{color:var(--color-gray-600)}}.payment-modal{inset:calc(var(--spacing)*0);z-index:10000;width:100%;height:100%;transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration));--tw-duration:.3s;transition-duration:.3s;transition-timing-function:cubic-bezier(.25,1,.5,1);position:absolute}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@property --tw-duration{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@keyframes spin{to{transform:rotate(360deg)}}
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild(U);function M(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=M(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function X(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=M(e))&&(n&&(n+=" "),n+=t);return n}class x extends Error{response;request;options;constructor(t,r,n){const i=t.status||t.status===0?t.status:"",o=t.statusText??"",a=`${i} ${o}`.trim(),l=a?`status code ${a}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}}class O extends Error{name="NonError";value;constructor(t){let r="Non-error value was thrown";try{typeof t=="string"?r=t:t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"&&(r=t.message)}catch{}super(r),this.value=t}}class E extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(t){const r=t?.cause?t.cause instanceof Error?t.cause:new O(t.cause):void 0;super(t?.code?`Forced retry: ${t.code}`:"Forced retry",r?{cause:r}:void 0),this.customDelay=t?.delay,this.code=t?.code,this.customRequest=t?.request}}const z=(()=>{let e=!1,t=!1;const r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),Z=typeof globalThis.AbortController=="function",I=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Y=typeof globalThis.ReadableStream=="function",Q=typeof globalThis.FormData=="function",L=["get","post","put","patch","head","delete"],tt={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},R=2147483647,et=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,B=Symbol("stop");class D{options;constructor(t){this.options=t}}const rt=e=>new D(e),nt={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},it={next:!0},ot={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},at=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(const[r,n]of e)t+=et,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{const t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},H=(e,t,r)=>{let n,i=0;return e.pipeThrough(new TransformStream({transform(o,a){if(a.enqueue(o),n){i+=n.byteLength;let l=t===0?0:i/t;l>=1&&(l=1-Number.EPSILON),r?.({percent:l,totalBytes:Math.max(t,i),transferredBytes:i},n)}n=o},flush(){n&&(i+=n.byteLength,r?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},n))}}))},st=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});const r=Math.max(0,Number(e.headers.get("content-length"))||0);return new Response(H(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},lt=(e,t,r)=>{if(!e.body)return e;const n=at(r??e.body);return new Request(e,{duplex:"half",body:H(e.body,n,t)})},f=e=>e!==null&&typeof e=="object",g=(...e)=>{for(const t of e)if((!f(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return S({},...e)},$=(e={},t={})=>{const r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(const[o,a]of i.entries())n&&a==="undefined"||a===void 0?r.delete(o):r.set(o,a);return r};function w(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:S(e[r]??[],t[r]??[])}const _=(e={},t={})=>({beforeRequest:w(e,t,"beforeRequest"),beforeRetry:w(e,t,"beforeRetry"),afterResponse:w(e,t,"afterResponse"),beforeError:w(e,t,"beforeError")}),ct=(e,t)=>{const r=new URLSearchParams;for(const n of[e,t])if(n!==void 0)if(n instanceof URLSearchParams)for(const[i,o]of n.entries())r.append(i,o);else if(Array.isArray(n))for(const i of n){if(!Array.isArray(i)||i.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");r.append(String(i[0]),String(i[1]))}else if(f(n))for(const[i,o]of Object.entries(n))o!==void 0&&r.append(i,String(o));else{const i=new URLSearchParams(n);for(const[o,a]of i.entries())r.append(o,a)}return r},S=(...e)=>{let t={},r={},n={},i;const o=[];for(const a of e)if(Array.isArray(a))Array.isArray(t)||(t=[]),t=[...t,...a];else if(f(a)){for(let[l,s]of Object.entries(a)){if(l==="signal"&&s instanceof globalThis.AbortSignal){o.push(s);continue}if(l==="context"){if(s!=null&&(!f(s)||Array.isArray(s)))throw new TypeError("The `context` option must be an object");t={...t,context:s==null?{}:{...t.context,...s}};continue}if(l==="searchParams"){s==null?i=void 0:i=i===void 0?s:ct(i,s);continue}f(s)&&l in t&&(s=S(t[l],s)),t={...t,[l]:s}}f(a.hooks)&&(n=_(n,a.hooks),t.hooks=n),f(a.headers)&&(r=$(r,a.headers),t.headers=r)}return i!==void 0&&(t.searchParams=i),o.length>0&&(o.length===1?t.signal=o[0]:I?t.signal=AbortSignal.any(o):t.signal=o.at(-1)),t.context===void 0&&(t.context={}),t},ut=e=>L.includes(e)?e.toUpperCase():e,F={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3,jitter:void 0,retryOnTimeout:!1},dt=(e={})=>{if(typeof e=="number")return{...F,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...F,...e}};class A extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}}async function pt(e,t,r,n){return new Promise((i,o)=>{const a=setTimeout(()=>{r&&r.abort(),o(new A(e))},n.timeout);n.fetch(e,t).then(i).catch(o).then(()=>{clearTimeout(a)})})}async function ht(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(o),n(t.reason)}const o=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}const ft=(e,t)=>{const r={};for(const n in t)Object.hasOwn(t,n)&&!(n in ot)&&!(n in nt)&&(!(n in e)||n in it)&&(r[n]=t[n]);return r},yt=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;function bt(e){return e instanceof x||e?.name===x.name}function mt(e){return e instanceof A||e?.name===A.name}class b{static create(t,r){const n=new b(t,r),i=async()=>{if(typeof n.#t.timeout=="number"&&n.#t.timeout>R)throw new RangeError(`The \`timeout\` option cannot be greater than ${R}`);await Promise.resolve();let a=await n.#y();for(const l of n.#t.hooks.afterResponse){const s=n.#u(a.clone()),d=await l(n.request,n.#s(),s,{retryCount:n.#r});if(d instanceof globalThis.Response&&(a=d),d instanceof D)throw await Promise.all([s.body?.cancel(),a.body?.cancel()]),new E(d.options)}if(n.#u(a),!a.ok&&(typeof n.#t.throwHttpErrors=="function"?n.#t.throwHttpErrors(a.status):n.#t.throwHttpErrors)){let l=new x(a,n.request,n.#s());for(const s of n.#t.hooks.beforeError)l=await s(l,{retryCount:n.#r});throw l}if(n.#t.onDownloadProgress){if(typeof n.#t.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Y)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return st(a.clone(),n.#t.onDownloadProgress)}return a},o=n.#d(i).finally(async()=>{const a=n.#o,l=[];a&&!a.bodyUsed&&l.push(a.body?.cancel()),n.request.bodyUsed||l.push(n.request.body?.cancel()),await Promise.all(l)});for(const[a,l]of Object.entries(tt))a==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[a]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||l);const s=await o;if(a==="json"){if(s.status===204)return"";const d=await s.text();return d===""?"":r.parseJson?r.parseJson(d):JSON.parse(d)}return s[a]()});return o}static#h(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;#n;#r=0;#e;#t;#o;#i;#a;constructor(t,r={}){if(this.#e=t,this.#t={...r,headers:$(this.#e.headers,r.headers),hooks:_({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:ut(r.method??this.#e.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:dt(r.retry),throwHttpErrors:r.throwHttpErrors??!0,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis),context:r.context??{}},typeof this.#e!="string"&&!(this.#e instanceof URL||this.#e instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#t.prefixUrl&&typeof this.#e=="string"){if(this.#e.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#t.prefixUrl.endsWith("/")||(this.#t.prefixUrl+="/"),this.#e=this.#t.prefixUrl+this.#e}Z&&I&&(this.#i=this.#t.signal??this.#e.signal,this.#n=new globalThis.AbortController,this.#t.signal=this.#i?AbortSignal.any([this.#i,this.#n.signal]):this.#n.signal),z&&(this.#t.duplex="half"),this.#t.json!==void 0&&(this.#t.body=this.#t.stringifyJson?.(this.#t.json)??JSON.stringify(this.#t.json),this.#t.headers.set("content-type",this.#t.headers.get("content-type")??"application/json"));const n=r.headers&&new globalThis.Headers(r.headers).has("content-type");if(this.#e instanceof globalThis.Request&&(Q&&this.#t.body instanceof globalThis.FormData||this.#t.body instanceof URLSearchParams)&&!n&&this.#t.headers.delete("content-type"),this.request=new globalThis.Request(this.#e,this.#t),yt(this.#t.searchParams)){const o="?"+(typeof this.#t.searchParams=="string"?this.#t.searchParams.replace(/^\?/,""):new URLSearchParams(b.#h(this.#t.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,o);this.request=new globalThis.Request(a,this.#t)}if(this.#t.onUploadProgress){if(typeof this.#t.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!z)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#p(this.request,this.#t.body??void 0)}}#l(){const t=this.#t.retry.delay(this.#r);let r=t;return this.#t.retry.jitter===!0?r=Math.random()*t:typeof this.#t.retry.jitter=="function"&&(r=this.#t.retry.jitter(t),(!Number.isFinite(r)||r<0)&&(r=t)),Math.min(this.#t.retry.backoffLimit,r)}async#f(t){if(this.#r++,this.#r>this.#t.retry.limit)throw t;const r=t instanceof Error?t:new O(t);if(r instanceof E)return r.customDelay??this.#l();if(!this.#t.retry.methods.includes(this.request.method.toLowerCase()))throw t;if(this.#t.retry.shouldRetry!==void 0){const n=await this.#t.retry.shouldRetry({error:r,retryCount:this.#r});if(n===!1)throw t;if(n===!0)return this.#l()}if(mt(t)&&!this.#t.retry.retryOnTimeout)throw t;if(bt(t)){if(!this.#t.retry.statusCodes.includes(t.response.status))throw t;const n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Retry-After")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this.#t.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());const o=this.#t.retry.maxRetryAfter??i;return i<o?i:o}if(t.response.status===413)throw t}return this.#l()}#u(t){return this.#t.parseJson&&(t.json=async()=>this.#t.parseJson(await t.text())),t}async#d(t){try{return await t()}catch(r){const n=Math.min(await this.#f(r),R);if(this.#r<1)throw r;if(await ht(n,this.#i?{signal:this.#i}:{}),r instanceof E&&r.customRequest){const i=this.#t.signal?new globalThis.Request(r.customRequest,{signal:this.#t.signal}):new globalThis.Request(r.customRequest);this.#c(i)}for(const i of this.#t.hooks.beforeRetry){const o=await i({request:this.request,options:this.#s(),error:r,retryCount:this.#r});if(o instanceof globalThis.Request){this.#c(o);break}if(o instanceof globalThis.Response)return o;if(o===B)return}return this.#d(t)}}async#y(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#t.signal=this.#i?AbortSignal.any([this.#i,this.#n.signal]):this.#n.signal,this.request=new globalThis.Request(this.request,{signal:this.#t.signal}));for(const r of this.#t.hooks.beforeRequest){const n=await r(this.request,this.#s(),{retryCount:this.#r});if(n instanceof Response)return n;if(n instanceof globalThis.Request){this.#c(n);break}}const t=ft(this.request,this.#t);return this.#o=this.request,this.request=this.#o.clone(),this.#t.timeout===!1?this.#t.fetch(this.#o,t):pt(this.#o,t,this.#n,this.#t)}#s(){if(!this.#a){const{hooks:t,...r}=this.#t;this.#a=Object.freeze(r)}return this.#a}#c(t){this.#a=void 0,this.request=this.#p(t)}#p(t,r){return!this.#t.onUploadProgress||!t.body?t:lt(t,this.#t.onUploadProgress,r??this.#t.body??void 0)}}/*! MIT License © Sindre Sorhus */const C=e=>{const t=(r,n)=>b.create(r,g(e,n));for(const r of L)t[r]=(n,i)=>b.create(n,g(e,i,{method:r}));return t.create=r=>C(g(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),C(g(e,r))),t.stop=B,t.retry=rt,t},gt=C();var J=(e=>(e.ARBITRUM="ARBITRUM_MAINNET",e.ARBITRUM_TESTNET="ARBITRUM_TESTNET",e.AVALANCHE="AVALANCHE_MAINNET",e.AVALANCHE_TESTNET="AVALANCHE_TESTNET",e.BASE="BASE_MAINNET",e.BASE_TESTNET="BASE_TESTNET",e.BSC="BSC_MAINNET",e.ETHEREUM="ETHEREUM_MAINNET",e.ETHEREUM_TESTNET="ETHEREUM_TESTNET",e.STARKNET="STARKNET_MAINNET",e))(J||{}),K=(e=>(e.USDC="USDC",e))(K||{}),P=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(P||{});class c{constructor({api_key:t,env:r}){this.api_key=t,this.jwt="",this.env=r??P.PRODUCTION}static config(t){if(!c.app){if(!t)throw new Error("Please provide an api_key");c.app=new c(t)}return t&&(c.app.api_key=t.api_key,t.env!==void 0&&(c.app.env=t.env),this.updateJWT(),setInterval(this.updateJWT.bind(this),1500*1e3)),c.app}static async updateJWT(){try{const t=await(await fetch(this.getBaseUrl()+"/client/api-keys/session-token",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({apiKey:c.app.api_key})})).json();this.app.jwt=t.token}catch{}}static getApiKey(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return c.app.api_key}static getSessionKey(){return c.app.jwt}static getEnv(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return c.app.env==="internal"?"staging":c.app.env}static getBaseUrl(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(c.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(t,r,n,i){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const o=c.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app/pay/":"https://app.chainrails.io/pay/",a=`_chain_/${t}/_token_/${r}/_to_/${n}/_amount_/${i*100}`;return o+a}}let j=null;function wt(){j=gt.create({prefixUrl:c.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[e=>{const t=c.getSessionKey();e.headers.set("Authorization",`Bearer ${t}`)}],afterResponse:[(e,t,r)=>r]},retry:{limit:2}})}function u(){return j||wt(),j}class vt{async getById(t){return await u().get("intents/"+t).json()}async getForSender(t){return await u().get("intents/user/"+t).json()}async getForAddress(t){return await u().get("intents/address/"+t).json()}async getAll(t){return await u().get("intents",{searchParams:t}).json()}async create(t){return await u().post("intents",{json:t}).json()}async update(t,r){return await u().post("intents",{json:r}).json()}async triggerProcessing(t){return await u().post(`intents/${t}/trigger-processing`).json()}}class kt{async getFromSpecificBridge(t){return await u().get("quotes/single",{searchParams:t}).json()}async getFromAllBridges(t){return await u().get("quotes/multiple",{searchParams:t}).json()}async getBestAcrossBridges(t){return await u().get("quotes/best",{searchParams:t}).json()}async getAll(t){return await u().get("quotes/multi-source",{searchParams:t}).json()}}class Tt{async getOptimalRoutes(t){return await u().get("router/optimal-route",{searchParams:t}).json()}async getAllSupportedBridges(){return await u().get("router/supported-bridges/all").json()}async getSupportedBridges(t){return await u().get("router/supported-bridges/route",{searchParams:t}).json()}async getSupportedRoutes(t,r){return await u().get("router/supported-bridges/bridge/"+t,{searchParams:r}).json()}}class xt{async getSupported(t){return await u().get("chains",{searchParams:t}).json()}}class Et{async getClientInfo(){return await u().get("client/auth/client-info").json()}}const Rt={router:new Tt,quotes:new kt,intents:new vt,chains:new xt,client:new Et};function St(e){const{to:t,token:r,chain:n,amount:i,isOpen:o,close:a,complete:l,cancel:s,chainSelected:d,intentCreated:v,...q}=e,[m,N]=h.useState(!0),V=h.useRef(null);h.useEffect(()=>{W();const k=document.body.style.overflow;o?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=k||"";const G=T=>{T.data==="closed"&&s(),T.data==="completed"&&l(),T.data==="chainSelected"&&d(),T.data==="intentCreated"&&v()};return window.addEventListener("message",G),()=>{document.body.style.overflow=k||"",window.removeEventListener("message",G)}},[o,s,l,d,v]);function Ct(){N(!1),W()}function W(){const k={type:"apiKey",apiKey:c.getApiKey(),environment:c.getEnv()||P.PRODUCTION};V.current?.contentWindow?.postMessage(k,"https://app.chainrails.io")}return y.jsxs("div",{...q,className:X("payment-modal-wrapper",m?"loading":"not-loading",o?"open":"closed"),children:[m&&y.jsx("div",{role:"status",className:"payment-modal-loader",children:y.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[y.jsx("path",{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",fill:"currentColor"}),y.jsx("path",{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",fill:"currentFill"})]})}),y.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:c.getPayModalUrl(n,r,t,i),onLoad:Ct,className:`payment-modal ${m?"invisible":"visible"}`,ref:V})]})}function At(e){const{onCancel:t,onSuccess:r,onChainSelect:n,onIntentCreate:i,...o}=e,[a,l]=h.useState(!1);function s(){l(!0)}function d(){l(!1)}function v(){d(),t?.()}function q(){window.setTimeout(d,2e3),r?.()}function m(){n?.()}function N(){i?.()}return{open:s,close:d,complete:q,cancel:v,chainSelected:m,intentCreated:N,isOpen:a,...o}}p.Chainrails=c,p.PaymentModal=St,p.chains=J,p.crapi=Rt,p.tokens=K,p.usePaymentModal=At,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(p,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],h):(p=typeof globalThis<"u"?globalThis:p||self,h(p.Chainrails={},p.React,p.jsxRuntime))})(this,(function(p,h,y){"use strict";var M=document.createElement("style");M.textContent=`/*! tailwindcss v4.1.14 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-duration:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-blue-600:oklch(54.6% .245 262.881);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-600:oklch(44.6% .03 256.802);--color-black:#000;--spacing:.25rem;--animate-spin:spin 1s linear infinite;--blur-xs:4px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.invisible{visibility:hidden}.visible{visibility:visible}.hidden{display:none}}.payment-modal-wrapper{inset:calc(var(--spacing)*0);z-index:10000;width:100vw;height:100dvh;transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration));--tw-duration:.1s;transition-duration:.1s;position:fixed}.payment-modal-wrapper.loading{background-color:#00000026}@supports (color:color-mix(in lab,red,red)){.payment-modal-wrapper.loading{background-color:color-mix(in oklab,var(--color-black)15%,transparent)}}.payment-modal-wrapper.loading{--tw-backdrop-blur:blur(2px);-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.payment-modal-wrapper.not-loading{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.payment-modal-wrapper.not-loading{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.payment-modal-wrapper.not-loading{--tw-backdrop-blur:blur(var(--blur-xs));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0}.payment-modal-wrapper.open iframe{--tw-translate-y:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y);--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x)var(--tw-scale-y)}.payment-modal-wrapper.closed iframe{--tw-translate-y:50vh;translate:var(--tw-translate-x)var(--tw-translate-y);--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x)var(--tw-scale-y)}.payment-modal-loader{inset:calc(var(--spacing)*0);z-index:10000;place-content:center;width:100%;height:100%;display:grid;position:absolute}.payment-modal-loader .icon{height:calc(var(--spacing)*12);width:calc(var(--spacing)*12);animation:var(--animate-spin);fill:var(--color-blue-600);color:var(--color-gray-200)}@media (prefers-color-scheme:dark){.payment-modal-loader .icon{color:var(--color-gray-600)}}.payment-modal{inset:calc(var(--spacing)*0);z-index:10000;width:100%;height:100%;transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration));--tw-duration:.3s;transition-duration:.3s;transition-timing-function:cubic-bezier(.25,1,.5,1);position:absolute}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@property --tw-duration{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@keyframes spin{to{transform:rotate(360deg)}}
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild(M);function O(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=O(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function X(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=O(e))&&(n&&(n+=" "),n+=t);return n}class x extends Error{response;request;options;constructor(t,r,n){const i=t.status||t.status===0?t.status:"",o=t.statusText??"",a=`${i} ${o}`.trim(),s=a?`status code ${a}`:"an unknown error";super(`Request failed with ${s}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}}class z extends Error{name="NonError";value;constructor(t){let r="Non-error value was thrown";try{typeof t=="string"?r=t:t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"&&(r=t.message)}catch{}super(r),this.value=t}}class E extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(t){const r=t?.cause?t.cause instanceof Error?t.cause:new z(t.cause):void 0;super(t?.code?`Forced retry: ${t.code}`:"Forced retry",r?{cause:r}:void 0),this.customDelay=t?.delay,this.code=t?.code,this.customRequest=t?.request}}const I=(()=>{let e=!1,t=!1;const r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),Z=typeof globalThis.AbortController=="function",L=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Y=typeof globalThis.ReadableStream=="function",Q=typeof globalThis.FormData=="function",B=["get","post","put","patch","head","delete"],tt={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},R=2147483647,et=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,D=Symbol("stop");class H{options;constructor(t){this.options=t}}const rt=e=>new H(e),nt={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},it={next:!0},ot={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},at=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(const[r,n]of e)t+=et,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{const t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},_=(e,t,r)=>{let n,i=0;return e.pipeThrough(new TransformStream({transform(o,a){if(a.enqueue(o),n){i+=n.byteLength;let s=t===0?0:i/t;s>=1&&(s=1-Number.EPSILON),r?.({percent:s,totalBytes:Math.max(t,i),transferredBytes:i},n)}n=o},flush(){n&&(i+=n.byteLength,r?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},n))}}))},st=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});const r=Math.max(0,Number(e.headers.get("content-length"))||0);return new Response(_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},lt=(e,t,r)=>{if(!e.body)return e;const n=at(r??e.body);return new Request(e,{duplex:"half",body:_(e.body,n,t)})},f=e=>e!==null&&typeof e=="object",w=(...e)=>{for(const t of e)if((!f(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return S({},...e)},$=(e={},t={})=>{const r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(const[o,a]of i.entries())n&&a==="undefined"||a===void 0?r.delete(o):r.set(o,a);return r};function v(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:S(e[r]??[],t[r]??[])}const F=(e={},t={})=>({beforeRequest:v(e,t,"beforeRequest"),beforeRetry:v(e,t,"beforeRetry"),afterResponse:v(e,t,"afterResponse"),beforeError:v(e,t,"beforeError")}),ct=(e,t)=>{const r=new URLSearchParams;for(const n of[e,t])if(n!==void 0)if(n instanceof URLSearchParams)for(const[i,o]of n.entries())r.append(i,o);else if(Array.isArray(n))for(const i of n){if(!Array.isArray(i)||i.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");r.append(String(i[0]),String(i[1]))}else if(f(n))for(const[i,o]of Object.entries(n))o!==void 0&&r.append(i,String(o));else{const i=new URLSearchParams(n);for(const[o,a]of i.entries())r.append(o,a)}return r},S=(...e)=>{let t={},r={},n={},i;const o=[];for(const a of e)if(Array.isArray(a))Array.isArray(t)||(t=[]),t=[...t,...a];else if(f(a)){for(let[s,l]of Object.entries(a)){if(s==="signal"&&l instanceof globalThis.AbortSignal){o.push(l);continue}if(s==="context"){if(l!=null&&(!f(l)||Array.isArray(l)))throw new TypeError("The `context` option must be an object");t={...t,context:l==null?{}:{...t.context,...l}};continue}if(s==="searchParams"){l==null?i=void 0:i=i===void 0?l:ct(i,l);continue}f(l)&&s in t&&(l=S(t[s],l)),t={...t,[s]:l}}f(a.hooks)&&(n=F(n,a.hooks),t.hooks=n),f(a.headers)&&(r=$(r,a.headers),t.headers=r)}return i!==void 0&&(t.searchParams=i),o.length>0&&(o.length===1?t.signal=o[0]:L?t.signal=AbortSignal.any(o):t.signal=o.at(-1)),t.context===void 0&&(t.context={}),t},ut=e=>B.includes(e)?e.toUpperCase():e,J={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3,jitter:void 0,retryOnTimeout:!1},dt=(e={})=>{if(typeof e=="number")return{...J,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...J,...e}};class A extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}}async function pt(e,t,r,n){return new Promise((i,o)=>{const a=setTimeout(()=>{r&&r.abort(),o(new A(e))},n.timeout);n.fetch(e,t).then(i).catch(o).then(()=>{clearTimeout(a)})})}async function ht(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(o),n(t.reason)}const o=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}const ft=(e,t)=>{const r={};for(const n in t)Object.hasOwn(t,n)&&!(n in ot)&&!(n in nt)&&(!(n in e)||n in it)&&(r[n]=t[n]);return r},yt=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;function bt(e){return e instanceof x||e?.name===x.name}function mt(e){return e instanceof A||e?.name===A.name}class b{static create(t,r){const n=new b(t,r),i=async()=>{if(typeof n.#t.timeout=="number"&&n.#t.timeout>R)throw new RangeError(`The \`timeout\` option cannot be greater than ${R}`);await Promise.resolve();let a=await n.#y();for(const s of n.#t.hooks.afterResponse){const l=n.#u(a.clone()),d=await s(n.request,n.#s(),l,{retryCount:n.#r});if(d instanceof globalThis.Response&&(a=d),d instanceof H)throw await Promise.all([l.body?.cancel(),a.body?.cancel()]),new E(d.options)}if(n.#u(a),!a.ok&&(typeof n.#t.throwHttpErrors=="function"?n.#t.throwHttpErrors(a.status):n.#t.throwHttpErrors)){let s=new x(a,n.request,n.#s());for(const l of n.#t.hooks.beforeError)s=await l(s,{retryCount:n.#r});throw s}if(n.#t.onDownloadProgress){if(typeof n.#t.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Y)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return st(a.clone(),n.#t.onDownloadProgress)}return a},o=n.#d(i).finally(async()=>{const a=n.#o,s=[];a&&!a.bodyUsed&&s.push(a.body?.cancel()),n.request.bodyUsed||s.push(n.request.body?.cancel()),await Promise.all(s)});for(const[a,s]of Object.entries(tt))a==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[a]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||s);const l=await o;if(a==="json"){if(l.status===204)return"";const d=await l.text();return d===""?"":r.parseJson?r.parseJson(d):JSON.parse(d)}return l[a]()});return o}static#h(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;#n;#r=0;#e;#t;#o;#i;#a;constructor(t,r={}){if(this.#e=t,this.#t={...r,headers:$(this.#e.headers,r.headers),hooks:F({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:ut(r.method??this.#e.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:dt(r.retry),throwHttpErrors:r.throwHttpErrors??!0,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis),context:r.context??{}},typeof this.#e!="string"&&!(this.#e instanceof URL||this.#e instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#t.prefixUrl&&typeof this.#e=="string"){if(this.#e.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#t.prefixUrl.endsWith("/")||(this.#t.prefixUrl+="/"),this.#e=this.#t.prefixUrl+this.#e}Z&&L&&(this.#i=this.#t.signal??this.#e.signal,this.#n=new globalThis.AbortController,this.#t.signal=this.#i?AbortSignal.any([this.#i,this.#n.signal]):this.#n.signal),I&&(this.#t.duplex="half"),this.#t.json!==void 0&&(this.#t.body=this.#t.stringifyJson?.(this.#t.json)??JSON.stringify(this.#t.json),this.#t.headers.set("content-type",this.#t.headers.get("content-type")??"application/json"));const n=r.headers&&new globalThis.Headers(r.headers).has("content-type");if(this.#e instanceof globalThis.Request&&(Q&&this.#t.body instanceof globalThis.FormData||this.#t.body instanceof URLSearchParams)&&!n&&this.#t.headers.delete("content-type"),this.request=new globalThis.Request(this.#e,this.#t),yt(this.#t.searchParams)){const o="?"+(typeof this.#t.searchParams=="string"?this.#t.searchParams.replace(/^\?/,""):new URLSearchParams(b.#h(this.#t.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,o);this.request=new globalThis.Request(a,this.#t)}if(this.#t.onUploadProgress){if(typeof this.#t.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!I)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#p(this.request,this.#t.body??void 0)}}#l(){const t=this.#t.retry.delay(this.#r);let r=t;return this.#t.retry.jitter===!0?r=Math.random()*t:typeof this.#t.retry.jitter=="function"&&(r=this.#t.retry.jitter(t),(!Number.isFinite(r)||r<0)&&(r=t)),Math.min(this.#t.retry.backoffLimit,r)}async#f(t){if(this.#r++,this.#r>this.#t.retry.limit)throw t;const r=t instanceof Error?t:new z(t);if(r instanceof E)return r.customDelay??this.#l();if(!this.#t.retry.methods.includes(this.request.method.toLowerCase()))throw t;if(this.#t.retry.shouldRetry!==void 0){const n=await this.#t.retry.shouldRetry({error:r,retryCount:this.#r});if(n===!1)throw t;if(n===!0)return this.#l()}if(mt(t)&&!this.#t.retry.retryOnTimeout)throw t;if(bt(t)){if(!this.#t.retry.statusCodes.includes(t.response.status))throw t;const n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Retry-After")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this.#t.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());const o=this.#t.retry.maxRetryAfter??i;return i<o?i:o}if(t.response.status===413)throw t}return this.#l()}#u(t){return this.#t.parseJson&&(t.json=async()=>this.#t.parseJson(await t.text())),t}async#d(t){try{return await t()}catch(r){const n=Math.min(await this.#f(r),R);if(this.#r<1)throw r;if(await ht(n,this.#i?{signal:this.#i}:{}),r instanceof E&&r.customRequest){const i=this.#t.signal?new globalThis.Request(r.customRequest,{signal:this.#t.signal}):new globalThis.Request(r.customRequest);this.#c(i)}for(const i of this.#t.hooks.beforeRetry){const o=await i({request:this.request,options:this.#s(),error:r,retryCount:this.#r});if(o instanceof globalThis.Request){this.#c(o);break}if(o instanceof globalThis.Response)return o;if(o===D)return}return this.#d(t)}}async#y(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#t.signal=this.#i?AbortSignal.any([this.#i,this.#n.signal]):this.#n.signal,this.request=new globalThis.Request(this.request,{signal:this.#t.signal}));for(const r of this.#t.hooks.beforeRequest){const n=await r(this.request,this.#s(),{retryCount:this.#r});if(n instanceof Response)return n;if(n instanceof globalThis.Request){this.#c(n);break}}const t=ft(this.request,this.#t);return this.#o=this.request,this.request=this.#o.clone(),this.#t.timeout===!1?this.#t.fetch(this.#o,t):pt(this.#o,t,this.#n,this.#t)}#s(){if(!this.#a){const{hooks:t,...r}=this.#t;this.#a=Object.freeze(r)}return this.#a}#c(t){this.#a=void 0,this.request=this.#p(t)}#p(t,r){return!this.#t.onUploadProgress||!t.body?t:lt(t,this.#t.onUploadProgress,r??this.#t.body??void 0)}}/*! MIT License © Sindre Sorhus */const C=e=>{const t=(r,n)=>b.create(r,w(e,n));for(const r of B)t[r]=(n,i)=>b.create(n,w(e,i,{method:r}));return t.create=r=>C(w(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),C(w(e,r))),t.stop=D,t.retry=rt,t},gt=C();var K=(e=>(e.ARBITRUM="ARBITRUM_MAINNET",e.ARBITRUM_TESTNET="ARBITRUM_TESTNET",e.AVALANCHE="AVALANCHE_MAINNET",e.AVALANCHE_TESTNET="AVALANCHE_TESTNET",e.BASE="BASE_MAINNET",e.BASE_TESTNET="BASE_TESTNET",e.BSC="BSC_MAINNET",e.ETHEREUM="ETHEREUM_MAINNET",e.ETHEREUM_TESTNET="ETHEREUM_TESTNET",e.STARKNET="STARKNET_MAINNET",e))(K||{}),W=(e=>(e.USDC="USDC",e))(W||{}),P=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(P||{});class c{constructor({api_key:t,env:r}){this.api_key=t,this.jwt="",this.env=r??P.PRODUCTION}static async config(t){if(!c.app){if(!t)throw new Error("Please provide an api_key");c.app=new c(t)}return t&&(c.app.api_key=t.api_key,t.env!==void 0&&(c.app.env=t.env),await this.updateJWT(),setInterval(this.updateJWT.bind(this),1500*1e3)),c.app}static async updateJWT(){try{const t=await(await fetch(this.getBaseUrl()+"/client/api-keys/session-token",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({apiKey:c.app.api_key})})).json();this.app.jwt=t.token}catch{}}static getApiKey(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return c.app.api_key}static getSessionKey(){return c.app.jwt}static getEnv(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return c.app.env==="internal"?"staging":c.app.env}static getBaseUrl(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(c.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(t,r,n,i){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const o=c.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",a=i?"/pay/":"/deposit/",s=`_chain_/${t}/_token_/${r}/_to_/${n}/_amount_/${i&&i*100}`;return o+a+s}}let j=null;function wt(){j=gt.create({prefixUrl:c.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[e=>{const t=c.getSessionKey();e.headers.set("Authorization",`Bearer ${t}`)}],afterResponse:[(e,t,r)=>r]},retry:{limit:2}})}function u(){return j||wt(),j}class vt{async getById(t){return await u().get("intents/"+t).json()}async getForSender(t){return await u().get("intents/user/"+t).json()}async getForAddress(t){return await u().get("intents/address/"+t).json()}async getAll(t){return await u().get("intents",{searchParams:t}).json()}async create(t){return await u().post("intents",{json:t}).json()}async update(t,r){return await u().post("intents",{json:r}).json()}async triggerProcessing(t){return await u().post(`intents/${t}/trigger-processing`).json()}}class kt{async getFromSpecificBridge(t){return await u().get("quotes/single",{searchParams:t}).json()}async getFromAllBridges(t){return await u().get("quotes/multiple",{searchParams:t}).json()}async getBestAcrossBridges(t){return await u().get("quotes/best",{searchParams:t}).json()}async getAll(t){return await u().get("quotes/multi-source",{searchParams:t}).json()}}class Tt{async getOptimalRoutes(t){return await u().get("router/optimal-route",{searchParams:t}).json()}async getAllSupportedBridges(){return await u().get("router/supported-bridges/all").json()}async getSupportedBridges(t){return await u().get("router/supported-bridges/route",{searchParams:t}).json()}async getSupportedRoutes(t,r){return await u().get("router/supported-bridges/bridge/"+t,{searchParams:r}).json()}}class xt{async getSupported(t){return await u().get("chains",{searchParams:t}).json()}}class Et{async getClientInfo(){return await u().get("client/auth/client-info").json()}}const Rt={router:new Tt,quotes:new kt,intents:new vt,chains:new xt,client:new Et};function St(e){const{to:t,token:r,chain:n,amount:i,isOpen:o,close:a,complete:s,cancel:l,chainSelected:d,intentCreated:k,...q}=e,[m,N]=h.useState(!0),U=h.useRef(null);h.useEffect(()=>{V();const g=document.body.style.overflow;o?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=g||"";const G=T=>{T.data==="closed"&&l(),T.data==="completed"&&s(),T.data==="chainSelected"&&d(),T.data==="intentCreated"&&k()};return window.addEventListener("message",G),()=>{document.body.style.overflow=g||"",window.removeEventListener("message",G)}},[o,l,s,d,k]);function Ct(){N(!1),V()}function V(){const g={type:"apiKey",apiKey:c.getApiKey(),environment:c.getEnv()||P.PRODUCTION};U.current?.contentWindow?.postMessage(g,"https://app.chainrails.io"),U.current?.contentWindow?.postMessage(g,"https://chainrails-frontend-git-staging-horus-labs.vercel.app")}return y.jsxs("div",{...q,className:X("payment-modal-wrapper",m?"loading":"not-loading",o?"open":"closed"),children:[m&&y.jsx("div",{role:"status",className:"payment-modal-loader",children:y.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[y.jsx("path",{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",fill:"currentColor"}),y.jsx("path",{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",fill:"currentFill"})]})}),y.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:c.getPayModalUrl(n,r,t,i),onLoad:Ct,className:`payment-modal ${m?"invisible":"visible"}`,ref:U})]})}function At(e){const{onCancel:t,onSuccess:r,onChainSelect:n,onIntentCreate:i,...o}=e,[a,s]=h.useState(!1);function l(){s(!0)}function d(){s(!1)}function k(){d(),t?.()}function q(){window.setTimeout(d,2e3),r?.()}function m(){n?.()}function N(){i?.()}return{open:l,close:d,complete:q,cancel:k,chainSelected:m,intentCreated:N,isOpen:a,...o}}p.Chainrails=c,p.PaymentModal=St,p.chains=K,p.crapi=Rt,p.tokens=W,p.usePaymentModal=At,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
type usePaymentModalProps = {
|
|
2
2
|
to: string;
|
|
3
|
-
amount: number;
|
|
4
3
|
chain: string;
|
|
5
4
|
token: string;
|
|
6
5
|
onCancel?: () => void;
|
|
@@ -10,7 +9,6 @@ type usePaymentModalProps = {
|
|
|
10
9
|
};
|
|
11
10
|
export declare function usePaymentModal(props: usePaymentModalProps): {
|
|
12
11
|
to: string;
|
|
13
|
-
amount: number;
|
|
14
12
|
chain: string;
|
|
15
13
|
token: string;
|
|
16
14
|
open: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePaymentModal.d.ts","sourceRoot":"","sources":["../../src/hooks/usePaymentModal.tsx"],"names":[],"mappings":"AAEA,KAAK,oBAAoB,GAAG;IAC1B,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"usePaymentModal.d.ts","sourceRoot":"","sources":["../../src/hooks/usePaymentModal.tsx"],"names":[],"mappings":"AAEA,KAAK,oBAAoB,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB;QATrD,MAAM;WACH,MAAM;WACN,MAAM;;;;;;;;EA+Cd"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"sideEffects": [
|
|
4
4
|
"**/*.css"
|
|
5
5
|
],
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.19",
|
|
7
7
|
"description": "",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"source": "./src/index.ts",
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"react": "
|
|
31
|
-
"react-dom": "
|
|
30
|
+
"react": ">=16.8.0",
|
|
31
|
+
"react-dom": ">=16.8.0"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
34
|
"dist"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"vite-plugin-lib-inject-css": "^2.2.2"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@chainrails/sdk": "^0.0.
|
|
57
|
+
"@chainrails/sdk": "^0.0.28",
|
|
58
58
|
"@tailwindcss/vite": "^4.1.14",
|
|
59
59
|
"clsx": "^2.1.1",
|
|
60
60
|
"dotenv": "^17.2.3",
|
|
@@ -64,5 +64,9 @@
|
|
|
64
64
|
"tailwindcss": "^4.1.14",
|
|
65
65
|
"valtio": "^2.1.8",
|
|
66
66
|
"vite": "^7.1.9"
|
|
67
|
+
},
|
|
68
|
+
"externals": {
|
|
69
|
+
"react": "commonjs react",
|
|
70
|
+
"react-dom": "commonjs react-dom"
|
|
67
71
|
}
|
|
68
72
|
}
|