@chainrails/react 0.2.17 → 0.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/PaymentModal/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAC;AAE1D,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,KAAK,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG;IAC9D,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eA0FpD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE,UAAU,CAAC;KACxB;CACF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/PaymentModal/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAC;AAE1D,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,KAAK,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG;IAC9D,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eAqFpD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE,UAAU,CAAC;KACxB;CACF"}
@@ -1,4 +1,4 @@
1
- import { useState as I, useRef as re, useEffect as C, useMemo as ye, useSyncExternalStore as Rt, useCallback as At, useLayoutEffect as vt, useDebugValue as Pt } from "react";
1
+ import { useState as I, useRef as re, useEffect as O, useMemo as ye, useSyncExternalStore as Rt, useCallback as At, useLayoutEffect as vt, useDebugValue as Pt } from "react";
2
2
  import { jsxs as we, jsx as B } from "react/jsx-runtime";
3
3
  import './index.css';class G extends Error {
4
4
  response;
@@ -816,12 +816,12 @@ function Ss(e) {
816
816
  const t = (n) => e().update(ot(n)).digest(), s = e();
817
817
  return t.outputLen = s.outputLen, t.blockLen = s.blockLen, t.create = () => e(), t;
818
818
  }
819
- const Ts = BigInt(0), x = BigInt(1), Rs = BigInt(2), As = BigInt(7), vs = BigInt(256), Ps = BigInt(113), it = [], at = [], ct = [];
820
- for (let e = 0, t = x, s = 1, n = 0; e < 24; e++) {
819
+ const Ts = BigInt(0), k = BigInt(1), Rs = BigInt(2), As = BigInt(7), vs = BigInt(256), Ps = BigInt(113), it = [], at = [], ct = [];
820
+ for (let e = 0, t = k, s = 1, n = 0; e < 24; e++) {
821
821
  [s, n] = [n, (2 * s + 3 * n) % 5], it.push(2 * (5 * n + s)), at.push((e + 1) * (e + 2) / 2 % 64);
822
822
  let r = Ts;
823
823
  for (let i = 0; i < 7; i++)
824
- t = (t << x ^ (t >> As) * Ps) % vs, t & Rs && (r ^= x << (x << /* @__PURE__ */ BigInt(i)) - x);
824
+ t = (t << k ^ (t >> As) * Ps) % vs, t & Rs && (r ^= k << (k << /* @__PURE__ */ BigInt(i)) - k);
825
825
  ct.push(r);
826
826
  }
827
827
  const ut = cs(ct, !0), Is = ut[0], Us = ut[1], Ie = (e, t, s) => s > 32 ? fs(e, t, s) : us(e, t, s), Ue = (e, t, s) => s > 32 ? hs(e, t, s) : ls(e, t, s);
@@ -831,9 +831,9 @@ function Cs(e, t = 24) {
831
831
  for (let o = 0; o < 10; o++)
832
832
  s[o] = e[o] ^ e[o + 10] ^ e[o + 20] ^ e[o + 30] ^ e[o + 40];
833
833
  for (let o = 0; o < 10; o += 2) {
834
- const a = (o + 8) % 10, c = (o + 2) % 10, u = s[c], l = s[c + 1], w = Ie(u, l, 1) ^ s[a], p = Ue(u, l, 1) ^ s[a + 1];
834
+ const a = (o + 8) % 10, c = (o + 2) % 10, u = s[c], l = s[c + 1], w = Ie(u, l, 1) ^ s[a], d = Ue(u, l, 1) ^ s[a + 1];
835
835
  for (let y = 0; y < 50; y += 10)
836
- e[o + y] ^= w, e[o + y + 1] ^= p;
836
+ e[o + y] ^= w, e[o + y + 1] ^= d;
837
837
  }
838
838
  let r = e[2], i = e[3];
839
839
  for (let o = 0; o < 24; o++) {
@@ -1132,37 +1132,37 @@ function Vs(e, t) {
1132
1132
  return Ws(e)?.tokens[t]?.address;
1133
1133
  }
1134
1134
  var ue = /* @__PURE__ */ ((e) => (e.PRODUCTION = "production", e.STAGING = "staging", e))(ue || {});
1135
- class h {
1135
+ class f {
1136
1136
  constructor({ api_key: t, env: s, seesion_token: n }) {
1137
1137
  this.api_key = t || "", this.sessionToken = n || "", this.env = s ?? ue.PRODUCTION;
1138
1138
  }
1139
1139
  static async config(t) {
1140
- if (!h.app) {
1140
+ if (!f.app) {
1141
1141
  if (!t)
1142
1142
  throw new Error("Please provide an api_key");
1143
- h.app = new h(t);
1143
+ f.app = new f(t);
1144
1144
  }
1145
- return t && (t.api_key !== void 0 && (h.app.api_key = t.api_key), t.seesion_token !== void 0 && (h.app.sessionToken = t.seesion_token), t.env !== void 0 && (h.app.env = t.env)), h.app;
1145
+ return t && (t.api_key !== void 0 && (f.app.api_key = t.api_key), t.seesion_token !== void 0 && (f.app.sessionToken = t.seesion_token), t.env !== void 0 && (f.app.env = t.env)), f.app;
1146
1146
  }
1147
1147
  static getApiKey() {
1148
- if (!h.app)
1148
+ if (!f.app)
1149
1149
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1150
- return h.app.api_key;
1150
+ return f.app.api_key;
1151
1151
  }
1152
1152
  static getSessionToken() {
1153
- if (!h.app)
1153
+ if (!f.app)
1154
1154
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1155
- return h.app.sessionToken;
1155
+ return f.app.sessionToken;
1156
1156
  }
1157
1157
  static getEnv() {
1158
- if (!h.app)
1158
+ if (!f.app)
1159
1159
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1160
- return h.app.env === "internal" ? "staging" : h.app.env;
1160
+ return f.app.env === "internal" ? "staging" : f.app.env;
1161
1161
  }
1162
1162
  static getBaseUrl() {
1163
- if (!h.app)
1163
+ if (!f.app)
1164
1164
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1165
- switch (h.app.env) {
1165
+ switch (f.app.env) {
1166
1166
  case "production":
1167
1167
  return "https://api.chainrails.io/api/v1";
1168
1168
  case "staging":
@@ -1174,23 +1174,23 @@ class h {
1174
1174
  }
1175
1175
  }
1176
1176
  static getPayModalUrl(t) {
1177
- if (!h.app)
1177
+ if (!f.app)
1178
1178
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1179
- const s = h.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", n = Number(t), r = t && !isNaN(Number(t)) && n > 0 ? "/pay/" : "/deposit/", i = `${t && !isNaN(Number(t)) && n > 0 ? n * 100 : ""}`;
1179
+ const s = f.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", n = Number(t), r = t && !isNaN(Number(t)) && n > 0 ? "/pay/" : "/deposit/", i = `${t && !isNaN(Number(t)) && n > 0 ? n * 100 : ""}`;
1180
1180
  return s + r + i;
1181
1181
  }
1182
1182
  }
1183
1183
  let te = null;
1184
1184
  function Ys() {
1185
1185
  te = Gt.create({
1186
- prefixUrl: h.getBaseUrl(),
1186
+ prefixUrl: f.getBaseUrl(),
1187
1187
  headers: {
1188
1188
  "Content-Type": "application/json"
1189
1189
  },
1190
1190
  hooks: {
1191
1191
  beforeRequest: [
1192
1192
  (e) => {
1193
- const t = h.getSessionToken() || h.getApiKey();
1193
+ const t = f.getSessionToken() || f.getApiKey();
1194
1194
  e.headers.set("Authorization", `Bearer ${t}`);
1195
1195
  }
1196
1196
  ],
@@ -1327,36 +1327,32 @@ function Pn(e) {
1327
1327
  onSuccess: c,
1328
1328
  session_url: u,
1329
1329
  sessionToken: l
1330
- } = e, [w, p] = I(0), [y, b] = I(""), k = re(null);
1331
- C(() => {
1332
- const f = document.body.style.overflow;
1333
- n ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = f || "";
1330
+ } = e, [w, d] = I(0), [y, b] = I(""), C = re(null);
1331
+ f.config({
1332
+ api_key: "",
1333
+ // @ts-expect-error
1334
+ env: e.env === "internal" ? "internal" : "production"
1335
+ }), O(() => {
1336
+ const p = document.body.style.overflow;
1337
+ n ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = p || "";
1334
1338
  const g = (E) => {
1335
1339
  E.data === "closed" && (o(), a?.()), E.data === "completed" && (window.setTimeout(o, 2e3), c?.());
1336
1340
  };
1337
1341
  return window.addEventListener("message", g), () => {
1338
- document.body.style.overflow = f || "", window.removeEventListener("message", g);
1342
+ document.body.style.overflow = p || "", window.removeEventListener("message", g);
1339
1343
  };
1340
- }, [n, a, c]), C(() => {
1341
- h.config({
1342
- api_key: l || "",
1343
- // @ts-expect-error
1344
- env: e.env === "internal" ? "internal" : "production"
1345
- }).then((f) => {
1346
- window.chainrails = f, b(h.getPayModalUrl(t));
1347
- });
1348
- }, [n, t]), C(() => {
1344
+ }, [n, a, c]), O(() => {
1349
1345
  if (!l) return;
1350
- const f = {
1346
+ const p = {
1351
1347
  type: "session",
1352
1348
  session_token: l,
1353
- environment: h.getEnv() || ue.PRODUCTION,
1349
+ environment: f.getEnv() || ue.PRODUCTION,
1354
1350
  styles: s
1355
1351
  };
1356
- k.current?.contentWindow?.postMessage(f, "https://app.chainrails.io"), k.current?.contentWindow?.postMessage(f, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
1352
+ C.current?.contentWindow?.postMessage(p, "https://app.chainrails.io"), C.current?.contentWindow?.postMessage(p, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
1357
1353
  }, [l, w, n, s]);
1358
- function d() {
1359
- p(Math.random());
1354
+ function h() {
1355
+ d(Math.random());
1360
1356
  }
1361
1357
  return /* @__PURE__ */ we("div", {
1362
1358
  className: tn("payment-modal-wrapper", w === 0 || r ? "loading" : "not-loading", n ? "open" : "closed"),
@@ -1379,15 +1375,15 @@ function Pn(e) {
1379
1375
  })
1380
1376
  }), /* @__PURE__ */ B("iframe", {
1381
1377
  allow: "clipboard-read *; clipboard-write *",
1382
- src: y || void 0,
1383
- onLoad: d,
1378
+ src: f.getPayModalUrl(t) || void 0,
1379
+ onLoad: h,
1384
1380
  className: `payment-modal ${w === 0 || r ? "invisible" : "visible"}`,
1385
1381
  "data-id": t,
1386
- ref: k
1382
+ ref: C
1387
1383
  }, l)]
1388
1384
  });
1389
1385
  }
1390
- const sn = Symbol(), le = Symbol(), D = "a", pt = "f", ke = "p", gt = "c", mt = "t", fe = "h", O = "w", he = "o", de = "k";
1386
+ const sn = Symbol(), le = Symbol(), x = "a", pt = "f", ke = "p", gt = "c", mt = "t", fe = "h", D = "w", he = "o", de = "k";
1391
1387
  let nn = (e, t) => new Proxy(e, t);
1392
1388
  const se = Object.getPrototypeOf, ne = /* @__PURE__ */ new WeakMap(), yt = (e) => e && (ne.has(e) ? ne.get(e) : se(e) === Object.prototype || se(e) === Array.prototype), _ = (e) => typeof e == "object" && e !== null, rn = (e) => Object.values(Object.getOwnPropertyDescriptors(e)).some((t) => !t.configurable && !t.writable), on = (e) => {
1393
1389
  if (Array.isArray(e))
@@ -1403,19 +1399,19 @@ const se = Object.getPrototypeOf, ne = /* @__PURE__ */ new WeakMap(), yt = (e) =
1403
1399
  let n = !1;
1404
1400
  const r = (a, c) => {
1405
1401
  if (!n) {
1406
- let u = s[D].get(e);
1407
- if (u || (u = {}, s[D].set(e, u)), a === O)
1408
- u[O] = !0;
1402
+ let u = s[x].get(e);
1403
+ if (u || (u = {}, s[x].set(e, u)), a === D)
1404
+ u[D] = !0;
1409
1405
  else {
1410
1406
  let l = u[a];
1411
1407
  l || (l = /* @__PURE__ */ new Set(), u[a] = l), l.add(c);
1412
1408
  }
1413
1409
  }
1414
1410
  }, i = () => {
1415
- n = !0, s[D].delete(e);
1411
+ n = !0, s[x].delete(e);
1416
1412
  }, o = {
1417
1413
  get(a, c) {
1418
- return c === le ? e : (r(de, c), wt(Reflect.get(a, c), s[D], s[gt], s[mt]));
1414
+ return c === le ? e : (r(de, c), wt(Reflect.get(a, c), s[x], s[gt], s[mt]));
1419
1415
  },
1420
1416
  has(a, c) {
1421
1417
  return c === sn ? (i(), !0) : (r(fe, c), Reflect.has(a, c));
@@ -1424,7 +1420,7 @@ const se = Object.getPrototypeOf, ne = /* @__PURE__ */ new WeakMap(), yt = (e) =
1424
1420
  return r(he, c), Reflect.getOwnPropertyDescriptor(a, c);
1425
1421
  },
1426
1422
  ownKeys(a) {
1427
- return r(O), Reflect.ownKeys(a);
1423
+ return r(D), Reflect.ownKeys(a);
1428
1424
  }
1429
1425
  };
1430
1426
  return t && (o.set = o.deleteProperty = () => !1), [o, s];
@@ -1442,7 +1438,7 @@ const se = Object.getPrototypeOf, ne = /* @__PURE__ */ new WeakMap(), yt = (e) =
1442
1438
  }
1443
1439
  const [i, o] = r;
1444
1440
  let a = s && s.get(i);
1445
- return (!a || a[1][pt] !== !!o) && (a = an(i, !!o), a[1][ke] = nn(o || i, a[0]), s && s.set(i, a)), a[1][D] = t, a[1][gt] = s, a[1][mt] = n, a[1][ke];
1441
+ return (!a || a[1][pt] !== !!o) && (a = an(i, !!o), a[1][ke] = nn(o || i, a[0]), s && s.set(i, a)), a[1][x] = t, a[1][gt] = s, a[1][mt] = n, a[1][ke];
1446
1442
  }, cn = (e, t) => {
1447
1443
  const s = Reflect.ownKeys(e), n = Reflect.ownKeys(t);
1448
1444
  return s.length !== n.length || s.some((r, i) => r !== n[i]);
@@ -1463,7 +1459,7 @@ const se = Object.getPrototypeOf, ne = /* @__PURE__ */ new WeakMap(), yt = (e) =
1463
1459
  for (const a of i[fe] || [])
1464
1460
  if (o = Reflect.has(e, a) !== Reflect.has(t, a), o)
1465
1461
  return o;
1466
- if (i[O] === !0) {
1462
+ if (i[D] === !0) {
1467
1463
  if (o = cn(e, t), o)
1468
1464
  return o;
1469
1465
  } else
@@ -1488,19 +1484,19 @@ const se = Object.getPrototypeOf, ne = /* @__PURE__ */ new WeakMap(), yt = (e) =
1488
1484
  _(o) && r.add(o);
1489
1485
  const w = _(o) && t.get(pe(o));
1490
1486
  if (w) {
1491
- if ((c = w[fe]) === null || c === void 0 || c.forEach((p) => {
1492
- const y = `:has(${String(p)})`;
1487
+ if ((c = w[fe]) === null || c === void 0 || c.forEach((d) => {
1488
+ const y = `:has(${String(d)})`;
1493
1489
  n.push(a ? [...a, y] : [y]);
1494
- }), w[O] === !0) {
1495
- const p = ":ownKeys";
1496
- n.push(a ? [...a, p] : [p]);
1490
+ }), w[D] === !0) {
1491
+ const d = ":ownKeys";
1492
+ n.push(a ? [...a, d] : [d]);
1497
1493
  } else
1498
- (u = w[he]) === null || u === void 0 || u.forEach((p) => {
1499
- const y = `:hasOwn(${String(p)})`;
1494
+ (u = w[he]) === null || u === void 0 || u.forEach((d) => {
1495
+ const y = `:hasOwn(${String(d)})`;
1500
1496
  n.push(a ? [...a, y] : [y]);
1501
1497
  });
1502
- (l = w[de]) === null || l === void 0 || l.forEach((p) => {
1503
- "value" in (Object.getOwnPropertyDescriptor(o, p) || {}) && i(o[p], a ? [...a, p] : [p]);
1498
+ (l = w[de]) === null || l === void 0 || l.forEach((d) => {
1499
+ "value" in (Object.getOwnPropertyDescriptor(o, d) || {}) && i(o[d], a ? [...a, d] : [d]);
1504
1500
  });
1505
1501
  } else a && n.push(a);
1506
1502
  };
@@ -1557,57 +1553,57 @@ function St(e = {}) {
1557
1553
  if (t)
1558
1554
  return t;
1559
1555
  let s = J[0];
1560
- const n = /* @__PURE__ */ new Set(), r = (d, f = ++J[0]) => {
1561
- s !== f && (i = s = f, n.forEach((g) => g(d, f)));
1556
+ const n = /* @__PURE__ */ new Set(), r = (h, p = ++J[0]) => {
1557
+ s !== p && (i = s = p, n.forEach((g) => g(h, p)));
1562
1558
  };
1563
1559
  let i = s;
1564
- const o = (d = J[0]) => (i !== d && (i = d, c.forEach(([f]) => {
1565
- const g = f[1](d);
1560
+ const o = (h = J[0]) => (i !== h && (i = h, c.forEach(([p]) => {
1561
+ const g = p[1](h);
1566
1562
  g > s && (s = g);
1567
- })), s), a = (d) => (f, g) => {
1568
- const E = [...f];
1569
- E[1] = [d, ...E[1]], r(E, g);
1570
- }, c = /* @__PURE__ */ new Map(), u = (d, f) => {
1571
- const g = !me.has(f) && U.get(f);
1563
+ })), s), a = (h) => (p, g) => {
1564
+ const E = [...p];
1565
+ E[1] = [h, ...E[1]], r(E, g);
1566
+ }, c = /* @__PURE__ */ new Map(), u = (h, p) => {
1567
+ const g = !me.has(p) && U.get(p);
1572
1568
  if (g) {
1573
- if ((q ? "production" : void 0) !== "production" && c.has(d))
1569
+ if ((q ? "production" : void 0) !== "production" && c.has(h))
1574
1570
  throw new Error("prop listener already exists");
1575
1571
  if (n.size) {
1576
- const E = g[2](a(d));
1577
- c.set(d, [g, E]);
1572
+ const E = g[2](a(h));
1573
+ c.set(h, [g, E]);
1578
1574
  } else
1579
- c.set(d, [g]);
1575
+ c.set(h, [g]);
1580
1576
  }
1581
- }, l = (d) => {
1582
- var f;
1583
- const g = c.get(d);
1584
- g && (c.delete(d), (f = g[1]) == null || f.call(g));
1585
- }, w = (d) => (n.add(d), n.size === 1 && c.forEach(([g, E], M) => {
1577
+ }, l = (h) => {
1578
+ var p;
1579
+ const g = c.get(h);
1580
+ g && (c.delete(h), (p = g[1]) == null || p.call(g));
1581
+ }, w = (h) => (n.add(h), n.size === 1 && c.forEach(([g, E], M) => {
1586
1582
  if ((q ? "production" : void 0) !== "production" && E)
1587
1583
  throw new Error("remove already exists");
1588
1584
  const Tt = g[2](a(M));
1589
1585
  c.set(M, [g, Tt]);
1590
1586
  }), () => {
1591
- n.delete(d), n.size === 0 && c.forEach(([g, E], M) => {
1587
+ n.delete(h), n.size === 0 && c.forEach(([g, E], M) => {
1592
1588
  E && (E(), c.set(M, [g]));
1593
1589
  });
1594
1590
  });
1595
- let p = !0;
1591
+ let d = !0;
1596
1592
  const y = mn(
1597
- () => p,
1593
+ () => d,
1598
1594
  u,
1599
1595
  l,
1600
1596
  r
1601
1597
  ), b = dn(e, y);
1602
1598
  F.set(e, b);
1603
- const k = [e, o, w];
1604
- return U.set(b, k), Reflect.ownKeys(e).forEach((d) => {
1605
- const f = Object.getOwnPropertyDescriptor(
1599
+ const C = [e, o, w];
1600
+ return U.set(b, C), Reflect.ownKeys(e).forEach((h) => {
1601
+ const p = Object.getOwnPropertyDescriptor(
1606
1602
  e,
1607
- d
1603
+ h
1608
1604
  );
1609
- "value" in f && f.writable && (b[d] = e[d]);
1610
- }), p = !1, b;
1605
+ "value" in p && p.writable && (b[h] = e[h]);
1606
+ }), d = !1, b;
1611
1607
  }
1612
1608
  function yn(e, t, s) {
1613
1609
  const n = U.get(e);
@@ -1632,7 +1628,7 @@ function Ne(e) {
1632
1628
  }
1633
1629
  const wn = {}, bn = (e, t) => {
1634
1630
  const s = re(void 0);
1635
- C(() => {
1631
+ O(() => {
1636
1632
  s.current = ln(e, t);
1637
1633
  }), Pt(s.current);
1638
1634
  }, En = bn, Sn = /* @__PURE__ */ new WeakMap();
@@ -1691,7 +1687,7 @@ function In({
1691
1687
  function w() {
1692
1688
  i(!1);
1693
1689
  }
1694
- const p = () => {
1690
+ const d = () => {
1695
1691
  const y = Date.now();
1696
1692
  A.isPending = !0, A.error = null, A.data = null, fetch(e, {
1697
1693
  headers: {
@@ -1703,8 +1699,8 @@ function In({
1703
1699
  y < o || (A.error = b?.toString(), A.isPending = !1, a(y));
1704
1700
  });
1705
1701
  };
1706
- return C(() => {
1707
- p();
1702
+ return O(() => {
1703
+ d();
1708
1704
  }, [e]), {
1709
1705
  sessionToken: c,
1710
1706
  amount: u,
@@ -1712,7 +1708,7 @@ function In({
1712
1708
  session_url: e,
1713
1709
  open: l,
1714
1710
  close: w,
1715
- refetch: p,
1711
+ refetch: d,
1716
1712
  onSuccess: s,
1717
1713
  onCancel: t
1718
1714
  };
@@ -1730,7 +1726,7 @@ function Un({
1730
1726
  }) {
1731
1727
  a(y), u(b);
1732
1728
  }
1733
- C(() => {
1729
+ O(() => {
1734
1730
  a(e);
1735
1731
  }, [e]);
1736
1732
  function w() {
@@ -1738,7 +1734,7 @@ function Un({
1738
1734
  o && i(!0);
1739
1735
  }, 1e3), i(!0);
1740
1736
  }
1741
- function p() {
1737
+ function d() {
1742
1738
  i(!1);
1743
1739
  }
1744
1740
  return {
@@ -1747,13 +1743,13 @@ function Un({
1747
1743
  amount: c,
1748
1744
  isOpen: r,
1749
1745
  open: w,
1750
- close: p,
1746
+ close: d,
1751
1747
  onSuccess: n,
1752
1748
  onCancel: s
1753
1749
  };
1754
1750
  }
1755
1751
  export {
1756
- h as Chainrails,
1752
+ f as Chainrails,
1757
1753
  Pn as PaymentModal,
1758
1754
  ee as chains,
1759
1755
  vn as crapi,
@@ -1,4 +1,4 @@
1
- import { useState as I, useRef as re, useEffect as C, useMemo as ye, useSyncExternalStore as Rt, useCallback as At, useLayoutEffect as vt, useDebugValue as Pt } from "react";
1
+ import { useState as I, useRef as re, useEffect as O, useMemo as ye, useSyncExternalStore as Rt, useCallback as At, useLayoutEffect as vt, useDebugValue as Pt } from "react";
2
2
  import { jsxs as we, jsx as B } from "react/jsx-runtime";
3
3
  import './index.css';class G extends Error {
4
4
  response;
@@ -816,12 +816,12 @@ function Ss(e) {
816
816
  const t = (n) => e().update(ot(n)).digest(), s = e();
817
817
  return t.outputLen = s.outputLen, t.blockLen = s.blockLen, t.create = () => e(), t;
818
818
  }
819
- const Ts = BigInt(0), x = BigInt(1), Rs = BigInt(2), As = BigInt(7), vs = BigInt(256), Ps = BigInt(113), it = [], at = [], ct = [];
820
- for (let e = 0, t = x, s = 1, n = 0; e < 24; e++) {
819
+ const Ts = BigInt(0), k = BigInt(1), Rs = BigInt(2), As = BigInt(7), vs = BigInt(256), Ps = BigInt(113), it = [], at = [], ct = [];
820
+ for (let e = 0, t = k, s = 1, n = 0; e < 24; e++) {
821
821
  [s, n] = [n, (2 * s + 3 * n) % 5], it.push(2 * (5 * n + s)), at.push((e + 1) * (e + 2) / 2 % 64);
822
822
  let r = Ts;
823
823
  for (let i = 0; i < 7; i++)
824
- t = (t << x ^ (t >> As) * Ps) % vs, t & Rs && (r ^= x << (x << /* @__PURE__ */ BigInt(i)) - x);
824
+ t = (t << k ^ (t >> As) * Ps) % vs, t & Rs && (r ^= k << (k << /* @__PURE__ */ BigInt(i)) - k);
825
825
  ct.push(r);
826
826
  }
827
827
  const ut = cs(ct, !0), Is = ut[0], Us = ut[1], Ie = (e, t, s) => s > 32 ? fs(e, t, s) : us(e, t, s), Ue = (e, t, s) => s > 32 ? hs(e, t, s) : ls(e, t, s);
@@ -831,9 +831,9 @@ function Cs(e, t = 24) {
831
831
  for (let o = 0; o < 10; o++)
832
832
  s[o] = e[o] ^ e[o + 10] ^ e[o + 20] ^ e[o + 30] ^ e[o + 40];
833
833
  for (let o = 0; o < 10; o += 2) {
834
- const a = (o + 8) % 10, c = (o + 2) % 10, u = s[c], l = s[c + 1], w = Ie(u, l, 1) ^ s[a], p = Ue(u, l, 1) ^ s[a + 1];
834
+ const a = (o + 8) % 10, c = (o + 2) % 10, u = s[c], l = s[c + 1], w = Ie(u, l, 1) ^ s[a], d = Ue(u, l, 1) ^ s[a + 1];
835
835
  for (let y = 0; y < 50; y += 10)
836
- e[o + y] ^= w, e[o + y + 1] ^= p;
836
+ e[o + y] ^= w, e[o + y + 1] ^= d;
837
837
  }
838
838
  let r = e[2], i = e[3];
839
839
  for (let o = 0; o < 24; o++) {
@@ -1132,37 +1132,37 @@ function Vs(e, t) {
1132
1132
  return Ws(e)?.tokens[t]?.address;
1133
1133
  }
1134
1134
  var ue = /* @__PURE__ */ ((e) => (e.PRODUCTION = "production", e.STAGING = "staging", e))(ue || {});
1135
- class h {
1135
+ class f {
1136
1136
  constructor({ api_key: t, env: s, seesion_token: n }) {
1137
1137
  this.api_key = t || "", this.sessionToken = n || "", this.env = s ?? ue.PRODUCTION;
1138
1138
  }
1139
1139
  static async config(t) {
1140
- if (!h.app) {
1140
+ if (!f.app) {
1141
1141
  if (!t)
1142
1142
  throw new Error("Please provide an api_key");
1143
- h.app = new h(t);
1143
+ f.app = new f(t);
1144
1144
  }
1145
- return t && (t.api_key !== void 0 && (h.app.api_key = t.api_key), t.seesion_token !== void 0 && (h.app.sessionToken = t.seesion_token), t.env !== void 0 && (h.app.env = t.env)), h.app;
1145
+ return t && (t.api_key !== void 0 && (f.app.api_key = t.api_key), t.seesion_token !== void 0 && (f.app.sessionToken = t.seesion_token), t.env !== void 0 && (f.app.env = t.env)), f.app;
1146
1146
  }
1147
1147
  static getApiKey() {
1148
- if (!h.app)
1148
+ if (!f.app)
1149
1149
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1150
- return h.app.api_key;
1150
+ return f.app.api_key;
1151
1151
  }
1152
1152
  static getSessionToken() {
1153
- if (!h.app)
1153
+ if (!f.app)
1154
1154
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1155
- return h.app.sessionToken;
1155
+ return f.app.sessionToken;
1156
1156
  }
1157
1157
  static getEnv() {
1158
- if (!h.app)
1158
+ if (!f.app)
1159
1159
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1160
- return h.app.env === "internal" ? "staging" : h.app.env;
1160
+ return f.app.env === "internal" ? "staging" : f.app.env;
1161
1161
  }
1162
1162
  static getBaseUrl() {
1163
- if (!h.app)
1163
+ if (!f.app)
1164
1164
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1165
- switch (h.app.env) {
1165
+ switch (f.app.env) {
1166
1166
  case "production":
1167
1167
  return "https://api.chainrails.io/api/v1";
1168
1168
  case "staging":
@@ -1174,23 +1174,23 @@ class h {
1174
1174
  }
1175
1175
  }
1176
1176
  static getPayModalUrl(t) {
1177
- if (!h.app)
1177
+ if (!f.app)
1178
1178
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1179
- const s = h.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", n = Number(t), r = t && !isNaN(Number(t)) && n > 0 ? "/pay/" : "/deposit/", i = `${t && !isNaN(Number(t)) && n > 0 ? n * 100 : ""}`;
1179
+ const s = f.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", n = Number(t), r = t && !isNaN(Number(t)) && n > 0 ? "/pay/" : "/deposit/", i = `${t && !isNaN(Number(t)) && n > 0 ? n * 100 : ""}`;
1180
1180
  return s + r + i;
1181
1181
  }
1182
1182
  }
1183
1183
  let te = null;
1184
1184
  function Ys() {
1185
1185
  te = Gt.create({
1186
- prefixUrl: h.getBaseUrl(),
1186
+ prefixUrl: f.getBaseUrl(),
1187
1187
  headers: {
1188
1188
  "Content-Type": "application/json"
1189
1189
  },
1190
1190
  hooks: {
1191
1191
  beforeRequest: [
1192
1192
  (e) => {
1193
- const t = h.getSessionToken() || h.getApiKey();
1193
+ const t = f.getSessionToken() || f.getApiKey();
1194
1194
  e.headers.set("Authorization", `Bearer ${t}`);
1195
1195
  }
1196
1196
  ],
@@ -1327,36 +1327,32 @@ function Pn(e) {
1327
1327
  onSuccess: c,
1328
1328
  session_url: u,
1329
1329
  sessionToken: l
1330
- } = e, [w, p] = I(0), [y, b] = I(""), k = re(null);
1331
- C(() => {
1332
- const f = document.body.style.overflow;
1333
- n ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = f || "";
1330
+ } = e, [w, d] = I(0), [y, b] = I(""), C = re(null);
1331
+ f.config({
1332
+ api_key: "",
1333
+ // @ts-expect-error
1334
+ env: e.env === "internal" ? "internal" : "production"
1335
+ }), O(() => {
1336
+ const p = document.body.style.overflow;
1337
+ n ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = p || "";
1334
1338
  const g = (E) => {
1335
1339
  E.data === "closed" && (o(), a?.()), E.data === "completed" && (window.setTimeout(o, 2e3), c?.());
1336
1340
  };
1337
1341
  return window.addEventListener("message", g), () => {
1338
- document.body.style.overflow = f || "", window.removeEventListener("message", g);
1342
+ document.body.style.overflow = p || "", window.removeEventListener("message", g);
1339
1343
  };
1340
- }, [n, a, c]), C(() => {
1341
- h.config({
1342
- api_key: l || "",
1343
- // @ts-expect-error
1344
- env: e.env === "internal" ? "internal" : "production"
1345
- }).then((f) => {
1346
- window.chainrails = f, b(h.getPayModalUrl(t));
1347
- });
1348
- }, [n, t]), C(() => {
1344
+ }, [n, a, c]), O(() => {
1349
1345
  if (!l) return;
1350
- const f = {
1346
+ const p = {
1351
1347
  type: "session",
1352
1348
  session_token: l,
1353
- environment: h.getEnv() || ue.PRODUCTION,
1349
+ environment: f.getEnv() || ue.PRODUCTION,
1354
1350
  styles: s
1355
1351
  };
1356
- k.current?.contentWindow?.postMessage(f, "https://app.chainrails.io"), k.current?.contentWindow?.postMessage(f, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
1352
+ C.current?.contentWindow?.postMessage(p, "https://app.chainrails.io"), C.current?.contentWindow?.postMessage(p, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
1357
1353
  }, [l, w, n, s]);
1358
- function d() {
1359
- p(Math.random());
1354
+ function h() {
1355
+ d(Math.random());
1360
1356
  }
1361
1357
  return /* @__PURE__ */ we("div", {
1362
1358
  className: tn("payment-modal-wrapper", w === 0 || r ? "loading" : "not-loading", n ? "open" : "closed"),
@@ -1379,15 +1375,15 @@ function Pn(e) {
1379
1375
  })
1380
1376
  }), /* @__PURE__ */ B("iframe", {
1381
1377
  allow: "clipboard-read *; clipboard-write *",
1382
- src: y || void 0,
1383
- onLoad: d,
1378
+ src: f.getPayModalUrl(t) || void 0,
1379
+ onLoad: h,
1384
1380
  className: `payment-modal ${w === 0 || r ? "invisible" : "visible"}`,
1385
1381
  "data-id": t,
1386
- ref: k
1382
+ ref: C
1387
1383
  }, l)]
1388
1384
  });
1389
1385
  }
1390
- const sn = Symbol(), le = Symbol(), D = "a", pt = "f", ke = "p", gt = "c", mt = "t", fe = "h", O = "w", he = "o", de = "k";
1386
+ const sn = Symbol(), le = Symbol(), x = "a", pt = "f", ke = "p", gt = "c", mt = "t", fe = "h", D = "w", he = "o", de = "k";
1391
1387
  let nn = (e, t) => new Proxy(e, t);
1392
1388
  const se = Object.getPrototypeOf, ne = /* @__PURE__ */ new WeakMap(), yt = (e) => e && (ne.has(e) ? ne.get(e) : se(e) === Object.prototype || se(e) === Array.prototype), _ = (e) => typeof e == "object" && e !== null, rn = (e) => Object.values(Object.getOwnPropertyDescriptors(e)).some((t) => !t.configurable && !t.writable), on = (e) => {
1393
1389
  if (Array.isArray(e))
@@ -1403,19 +1399,19 @@ const se = Object.getPrototypeOf, ne = /* @__PURE__ */ new WeakMap(), yt = (e) =
1403
1399
  let n = !1;
1404
1400
  const r = (a, c) => {
1405
1401
  if (!n) {
1406
- let u = s[D].get(e);
1407
- if (u || (u = {}, s[D].set(e, u)), a === O)
1408
- u[O] = !0;
1402
+ let u = s[x].get(e);
1403
+ if (u || (u = {}, s[x].set(e, u)), a === D)
1404
+ u[D] = !0;
1409
1405
  else {
1410
1406
  let l = u[a];
1411
1407
  l || (l = /* @__PURE__ */ new Set(), u[a] = l), l.add(c);
1412
1408
  }
1413
1409
  }
1414
1410
  }, i = () => {
1415
- n = !0, s[D].delete(e);
1411
+ n = !0, s[x].delete(e);
1416
1412
  }, o = {
1417
1413
  get(a, c) {
1418
- return c === le ? e : (r(de, c), wt(Reflect.get(a, c), s[D], s[gt], s[mt]));
1414
+ return c === le ? e : (r(de, c), wt(Reflect.get(a, c), s[x], s[gt], s[mt]));
1419
1415
  },
1420
1416
  has(a, c) {
1421
1417
  return c === sn ? (i(), !0) : (r(fe, c), Reflect.has(a, c));
@@ -1424,7 +1420,7 @@ const se = Object.getPrototypeOf, ne = /* @__PURE__ */ new WeakMap(), yt = (e) =
1424
1420
  return r(he, c), Reflect.getOwnPropertyDescriptor(a, c);
1425
1421
  },
1426
1422
  ownKeys(a) {
1427
- return r(O), Reflect.ownKeys(a);
1423
+ return r(D), Reflect.ownKeys(a);
1428
1424
  }
1429
1425
  };
1430
1426
  return t && (o.set = o.deleteProperty = () => !1), [o, s];
@@ -1442,7 +1438,7 @@ const se = Object.getPrototypeOf, ne = /* @__PURE__ */ new WeakMap(), yt = (e) =
1442
1438
  }
1443
1439
  const [i, o] = r;
1444
1440
  let a = s && s.get(i);
1445
- return (!a || a[1][pt] !== !!o) && (a = an(i, !!o), a[1][ke] = nn(o || i, a[0]), s && s.set(i, a)), a[1][D] = t, a[1][gt] = s, a[1][mt] = n, a[1][ke];
1441
+ return (!a || a[1][pt] !== !!o) && (a = an(i, !!o), a[1][ke] = nn(o || i, a[0]), s && s.set(i, a)), a[1][x] = t, a[1][gt] = s, a[1][mt] = n, a[1][ke];
1446
1442
  }, cn = (e, t) => {
1447
1443
  const s = Reflect.ownKeys(e), n = Reflect.ownKeys(t);
1448
1444
  return s.length !== n.length || s.some((r, i) => r !== n[i]);
@@ -1463,7 +1459,7 @@ const se = Object.getPrototypeOf, ne = /* @__PURE__ */ new WeakMap(), yt = (e) =
1463
1459
  for (const a of i[fe] || [])
1464
1460
  if (o = Reflect.has(e, a) !== Reflect.has(t, a), o)
1465
1461
  return o;
1466
- if (i[O] === !0) {
1462
+ if (i[D] === !0) {
1467
1463
  if (o = cn(e, t), o)
1468
1464
  return o;
1469
1465
  } else
@@ -1488,19 +1484,19 @@ const se = Object.getPrototypeOf, ne = /* @__PURE__ */ new WeakMap(), yt = (e) =
1488
1484
  _(o) && r.add(o);
1489
1485
  const w = _(o) && t.get(pe(o));
1490
1486
  if (w) {
1491
- if ((c = w[fe]) === null || c === void 0 || c.forEach((p) => {
1492
- const y = `:has(${String(p)})`;
1487
+ if ((c = w[fe]) === null || c === void 0 || c.forEach((d) => {
1488
+ const y = `:has(${String(d)})`;
1493
1489
  n.push(a ? [...a, y] : [y]);
1494
- }), w[O] === !0) {
1495
- const p = ":ownKeys";
1496
- n.push(a ? [...a, p] : [p]);
1490
+ }), w[D] === !0) {
1491
+ const d = ":ownKeys";
1492
+ n.push(a ? [...a, d] : [d]);
1497
1493
  } else
1498
- (u = w[he]) === null || u === void 0 || u.forEach((p) => {
1499
- const y = `:hasOwn(${String(p)})`;
1494
+ (u = w[he]) === null || u === void 0 || u.forEach((d) => {
1495
+ const y = `:hasOwn(${String(d)})`;
1500
1496
  n.push(a ? [...a, y] : [y]);
1501
1497
  });
1502
- (l = w[de]) === null || l === void 0 || l.forEach((p) => {
1503
- "value" in (Object.getOwnPropertyDescriptor(o, p) || {}) && i(o[p], a ? [...a, p] : [p]);
1498
+ (l = w[de]) === null || l === void 0 || l.forEach((d) => {
1499
+ "value" in (Object.getOwnPropertyDescriptor(o, d) || {}) && i(o[d], a ? [...a, d] : [d]);
1504
1500
  });
1505
1501
  } else a && n.push(a);
1506
1502
  };
@@ -1557,57 +1553,57 @@ function St(e = {}) {
1557
1553
  if (t)
1558
1554
  return t;
1559
1555
  let s = J[0];
1560
- const n = /* @__PURE__ */ new Set(), r = (d, f = ++J[0]) => {
1561
- s !== f && (i = s = f, n.forEach((g) => g(d, f)));
1556
+ const n = /* @__PURE__ */ new Set(), r = (h, p = ++J[0]) => {
1557
+ s !== p && (i = s = p, n.forEach((g) => g(h, p)));
1562
1558
  };
1563
1559
  let i = s;
1564
- const o = (d = J[0]) => (i !== d && (i = d, c.forEach(([f]) => {
1565
- const g = f[1](d);
1560
+ const o = (h = J[0]) => (i !== h && (i = h, c.forEach(([p]) => {
1561
+ const g = p[1](h);
1566
1562
  g > s && (s = g);
1567
- })), s), a = (d) => (f, g) => {
1568
- const E = [...f];
1569
- E[1] = [d, ...E[1]], r(E, g);
1570
- }, c = /* @__PURE__ */ new Map(), u = (d, f) => {
1571
- const g = !me.has(f) && U.get(f);
1563
+ })), s), a = (h) => (p, g) => {
1564
+ const E = [...p];
1565
+ E[1] = [h, ...E[1]], r(E, g);
1566
+ }, c = /* @__PURE__ */ new Map(), u = (h, p) => {
1567
+ const g = !me.has(p) && U.get(p);
1572
1568
  if (g) {
1573
- if ((q ? "production" : void 0) !== "production" && c.has(d))
1569
+ if ((q ? "production" : void 0) !== "production" && c.has(h))
1574
1570
  throw new Error("prop listener already exists");
1575
1571
  if (n.size) {
1576
- const E = g[2](a(d));
1577
- c.set(d, [g, E]);
1572
+ const E = g[2](a(h));
1573
+ c.set(h, [g, E]);
1578
1574
  } else
1579
- c.set(d, [g]);
1575
+ c.set(h, [g]);
1580
1576
  }
1581
- }, l = (d) => {
1582
- var f;
1583
- const g = c.get(d);
1584
- g && (c.delete(d), (f = g[1]) == null || f.call(g));
1585
- }, w = (d) => (n.add(d), n.size === 1 && c.forEach(([g, E], M) => {
1577
+ }, l = (h) => {
1578
+ var p;
1579
+ const g = c.get(h);
1580
+ g && (c.delete(h), (p = g[1]) == null || p.call(g));
1581
+ }, w = (h) => (n.add(h), n.size === 1 && c.forEach(([g, E], M) => {
1586
1582
  if ((q ? "production" : void 0) !== "production" && E)
1587
1583
  throw new Error("remove already exists");
1588
1584
  const Tt = g[2](a(M));
1589
1585
  c.set(M, [g, Tt]);
1590
1586
  }), () => {
1591
- n.delete(d), n.size === 0 && c.forEach(([g, E], M) => {
1587
+ n.delete(h), n.size === 0 && c.forEach(([g, E], M) => {
1592
1588
  E && (E(), c.set(M, [g]));
1593
1589
  });
1594
1590
  });
1595
- let p = !0;
1591
+ let d = !0;
1596
1592
  const y = mn(
1597
- () => p,
1593
+ () => d,
1598
1594
  u,
1599
1595
  l,
1600
1596
  r
1601
1597
  ), b = dn(e, y);
1602
1598
  F.set(e, b);
1603
- const k = [e, o, w];
1604
- return U.set(b, k), Reflect.ownKeys(e).forEach((d) => {
1605
- const f = Object.getOwnPropertyDescriptor(
1599
+ const C = [e, o, w];
1600
+ return U.set(b, C), Reflect.ownKeys(e).forEach((h) => {
1601
+ const p = Object.getOwnPropertyDescriptor(
1606
1602
  e,
1607
- d
1603
+ h
1608
1604
  );
1609
- "value" in f && f.writable && (b[d] = e[d]);
1610
- }), p = !1, b;
1605
+ "value" in p && p.writable && (b[h] = e[h]);
1606
+ }), d = !1, b;
1611
1607
  }
1612
1608
  function yn(e, t, s) {
1613
1609
  const n = U.get(e);
@@ -1632,7 +1628,7 @@ function Ne(e) {
1632
1628
  }
1633
1629
  const wn = {}, bn = (e, t) => {
1634
1630
  const s = re(void 0);
1635
- C(() => {
1631
+ O(() => {
1636
1632
  s.current = ln(e, t);
1637
1633
  }), Pt(s.current);
1638
1634
  }, En = bn, Sn = /* @__PURE__ */ new WeakMap();
@@ -1691,7 +1687,7 @@ function In({
1691
1687
  function w() {
1692
1688
  i(!1);
1693
1689
  }
1694
- const p = () => {
1690
+ const d = () => {
1695
1691
  const y = Date.now();
1696
1692
  A.isPending = !0, A.error = null, A.data = null, fetch(e, {
1697
1693
  headers: {
@@ -1703,8 +1699,8 @@ function In({
1703
1699
  y < o || (A.error = b?.toString(), A.isPending = !1, a(y));
1704
1700
  });
1705
1701
  };
1706
- return C(() => {
1707
- p();
1702
+ return O(() => {
1703
+ d();
1708
1704
  }, [e]), {
1709
1705
  sessionToken: c,
1710
1706
  amount: u,
@@ -1712,7 +1708,7 @@ function In({
1712
1708
  session_url: e,
1713
1709
  open: l,
1714
1710
  close: w,
1715
- refetch: p,
1711
+ refetch: d,
1716
1712
  onSuccess: s,
1717
1713
  onCancel: t
1718
1714
  };
@@ -1730,7 +1726,7 @@ function Un({
1730
1726
  }) {
1731
1727
  a(y), u(b);
1732
1728
  }
1733
- C(() => {
1729
+ O(() => {
1734
1730
  a(e);
1735
1731
  }, [e]);
1736
1732
  function w() {
@@ -1738,7 +1734,7 @@ function Un({
1738
1734
  o && i(!0);
1739
1735
  }, 1e3), i(!0);
1740
1736
  }
1741
- function p() {
1737
+ function d() {
1742
1738
  i(!1);
1743
1739
  }
1744
1740
  return {
@@ -1747,13 +1743,13 @@ function Un({
1747
1743
  amount: c,
1748
1744
  isOpen: r,
1749
1745
  open: w,
1750
- close: p,
1746
+ close: d,
1751
1747
  onSuccess: n,
1752
1748
  onCancel: s
1753
1749
  };
1754
1750
  }
1755
1751
  export {
1756
- h as Chainrails,
1752
+ f as Chainrails,
1757
1753
  Pn as PaymentModal,
1758
1754
  ee as chains,
1759
1755
  vn as crapi,
@@ -1,3 +1,3 @@
1
- (function(S,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],f):(S=typeof globalThis<"u"?globalThis:S||self,f(S.Chainrails={},S.React,S.jsxRuntime))})(this,(function(S,f,k){"use strict";var ye=document.createElement("style");ye.textContent=`.payment-modal-wrapper{position:fixed;inset:0;z-index:10000;height:100dvh;width:100vw;transition:all .1s ease-in-out}.payment-modal-wrapper.loading{background-color:#0003;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.payment-modal-wrapper.not-loading{background-color:#0008;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0;pointer-events:none}.payment-modal-wrapper.closed *{pointer-events:none!important}.payment-modal-wrapper.open iframe{transform:translateY(0);transform:scale(1)}.payment-modal-wrapper.closed iframe{transform:translateY(50vh);transform:scale(1)}.payment-modal-loader{position:absolute;inset:0;z-index:10000;display:grid;height:100%;width:100%;place-content:center}.payment-modal-loader .icon{height:48px;width:48px;animation:cr-spin 1s linear infinite;fill:#2563eb;color:#475569}.payment-modal{position:absolute;inset:0;z-index:10000;height:100%;width:100%;transition:all .3s cubic-bezier(.25,1,.5,1)}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@keyframes cr-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
2
- /*$vite$:1*/`,document.head.appendChild(ye);class W extends Error{response;request;options;constructor(t,s,n){const r=t.status||t.status===0?t.status:"",i=t.statusText??"",o=`${r} ${i}`.trim(),a=o?`status code ${o}`:"an unknown error";super(`Request failed with ${a}: ${s.method} ${s.url}`),this.name="HTTPError",this.response=t,this.request=s,this.options=n}}class we extends Error{name="NonError";value;constructor(t){let s="Non-error value was thrown";try{typeof t=="string"?s=t:t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"&&(s=t.message)}catch{}super(s),this.value=t}}class V extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(t){const s=t?.cause?t.cause instanceof Error?t.cause:new we(t.cause):void 0;super(t?.code?`Forced retry: ${t.code}`:"Forced retry",s?{cause:s}:void 0),this.customDelay=t?.delay,this.code=t?.code,this.customRequest=t?.request}}const be=(()=>{let e=!1,t=!1;const s=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(s&&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(r){if(r instanceof Error&&r.message==="unsupported BodyInit type")return!1;throw r}return e&&!t})(),St=typeof globalThis.AbortController=="function",Se=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Et=typeof globalThis.ReadableStream=="function",Tt=typeof globalThis.FormData=="function",Ee=["get","post","put","patch","head","delete"],Rt={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Y=2147483647,At=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Te=Symbol("stop");class Re{options;constructor(t){this.options=t}}const vt=e=>new Re(e),Pt={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},Ct={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},Ut=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(const[s,n]of e)t+=At,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).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},Ae=(e,t,s)=>{let n,r=0;return e.pipeThrough(new TransformStream({transform(i,o){if(o.enqueue(i),n){r+=n.byteLength;let a=t===0?0:r/t;a>=1&&(a=1-Number.EPSILON),s?.({percent:a,totalBytes:Math.max(t,r),transferredBytes:r},n)}n=i},flush(){n&&(r+=n.byteLength,s?.({percent:1,totalBytes:Math.max(t,r),transferredBytes:r},n))}}))},kt=(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 s=Math.max(0,Number(e.headers.get("content-length"))||0);return new Response(Ae(e.body,s,t),{status:e.status,statusText:e.statusText,headers:e.headers})},xt=(e,t,s)=>{if(!e.body)return e;const n=Ut(s??e.body);return new Request(e,{duplex:"half",body:Ae(e.body,n,t)})},C=e=>e!==null&&typeof e=="object",z=(...e)=>{for(const t of e)if((!C(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return X({},...e)},ve=(e={},t={})=>{const s=new globalThis.Headers(e),n=t instanceof globalThis.Headers,r=new globalThis.Headers(t);for(const[i,o]of r.entries())n&&o==="undefined"||o===void 0?s.delete(i):s.set(i,o);return s};function B(e,t,s){return Object.hasOwn(t,s)&&t[s]===void 0?[]:X(e[s]??[],t[s]??[])}const Pe=(e={},t={})=>({beforeRequest:B(e,t,"beforeRequest"),beforeRetry:B(e,t,"beforeRetry"),afterResponse:B(e,t,"afterResponse"),beforeError:B(e,t,"beforeError")}),Dt=(e,t)=>{const s=new URLSearchParams;for(const n of[e,t])if(n!==void 0)if(n instanceof URLSearchParams)for(const[r,i]of n.entries())s.append(r,i);else if(Array.isArray(n))for(const r of n){if(!Array.isArray(r)||r.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");s.append(String(r[0]),String(r[1]))}else if(C(n))for(const[r,i]of Object.entries(n))i!==void 0&&s.append(r,String(i));else{const r=new URLSearchParams(n);for(const[i,o]of r.entries())s.append(i,o)}return s},X=(...e)=>{let t={},s={},n={},r;const i=[];for(const o of e)if(Array.isArray(o))Array.isArray(t)||(t=[]),t=[...t,...o];else if(C(o)){for(let[a,c]of Object.entries(o)){if(a==="signal"&&c instanceof globalThis.AbortSignal){i.push(c);continue}if(a==="context"){if(c!=null&&(!C(c)||Array.isArray(c)))throw new TypeError("The `context` option must be an object");t={...t,context:c==null?{}:{...t.context,...c}};continue}if(a==="searchParams"){c==null?r=void 0:r=r===void 0?c:Dt(r,c);continue}C(c)&&a in t&&(c=X(t[a],c)),t={...t,[a]:c}}C(o.hooks)&&(n=Pe(n,o.hooks),t.hooks=n),C(o.headers)&&(s=ve(s,o.headers),t.headers=s)}return r!==void 0&&(t.searchParams=r),i.length>0&&(i.length===1?t.signal=i[0]:Se?t.signal=AbortSignal.any(i):t.signal=i.at(-1)),t.context===void 0&&(t.context={}),t},Ot=e=>Ee.includes(e)?e.toUpperCase():e,Ie={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},Nt=(e={})=>{if(typeof e=="number")return{...Ie,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{...Ie,...e}};class J extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}}async function Mt(e,t,s,n){return new Promise((r,i)=>{const o=setTimeout(()=>{s&&s.abort(),i(new J(e))},n.timeout);n.fetch(e,t).then(r).catch(i).then(()=>{clearTimeout(o)})})}async function zt(e,{signal:t}){return new Promise((s,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",r,{once:!0}));function r(){clearTimeout(i),n(t.reason)}const i=setTimeout(()=>{t?.removeEventListener("abort",r),s()},e)})}const Bt=(e,t)=>{const s={};for(const n in t)Object.hasOwn(t,n)&&!(n in Ct)&&!(n in Pt)&&(!(n in e)||n in It)&&(s[n]=t[n]);return s},$t=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 jt(e){return e instanceof W||e?.name===W.name}function _t(e){return e instanceof J||e?.name===J.name}class x{static create(t,s){const n=new x(t,s),r=async()=>{if(typeof n.#e.timeout=="number"&&n.#e.timeout>Y)throw new RangeError(`The \`timeout\` option cannot be greater than ${Y}`);await Promise.resolve();let o=await n.#g();for(const a of n.#e.hooks.afterResponse){const c=n.#l(o.clone()),u=await a(n.request,n.#a(),c,{retryCount:n.#s});if(u instanceof globalThis.Response&&(o=u),u instanceof Re)throw await Promise.all([c.body?.cancel(),o.body?.cancel()]),new V(u.options)}if(n.#l(o),!o.ok&&(typeof n.#e.throwHttpErrors=="function"?n.#e.throwHttpErrors(o.status):n.#e.throwHttpErrors)){let a=new W(o,n.request,n.#a());for(const c of n.#e.hooks.beforeError)a=await c(a,{retryCount:n.#s});throw a}if(n.#e.onDownloadProgress){if(typeof n.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Et)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return kt(o.clone(),n.#e.onDownloadProgress)}return o},i=n.#f(r).finally(async()=>{const o=n.#o,a=[];o&&!o.bodyUsed&&a.push(o.body?.cancel()),n.request.bodyUsed||a.push(n.request.body?.cancel()),await Promise.all(a)});for(const[o,a]of Object.entries(Rt))o==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[o]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||a);const c=await i;if(o==="json"){if(c.status===204)return"";const u=await c.text();return u===""?"":s.parseJson?s.parseJson(u):JSON.parse(u)}return c[o]()});return i}static#d(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,s])=>s!==void 0)):t}request;#n;#s=0;#t;#e;#o;#r;#i;constructor(t,s={}){if(this.#t=t,this.#e={...s,headers:ve(this.#t.headers,s.headers),hooks:Pe({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},s.hooks),method:Ot(s.method??this.#t.method??"GET"),prefixUrl:String(s.prefixUrl||""),retry:Nt(s.retry),throwHttpErrors:s.throwHttpErrors??!0,timeout:s.timeout??1e4,fetch:s.fetch??globalThis.fetch.bind(globalThis),context:s.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}St&&Se&&(this.#r=this.#e.signal??this.#t.signal,this.#n=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#n.signal]):this.#n.signal),be&&(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"));const n=s.headers&&new globalThis.Headers(s.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(Tt&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!n&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),$t(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(x.#d(this.#e.searchParams)).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(o,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!be)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#h(this.request,this.#e.body??void 0)}}#c(){const t=this.#e.retry.delay(this.#s);let s=t;return this.#e.retry.jitter===!0?s=Math.random()*t:typeof this.#e.retry.jitter=="function"&&(s=this.#e.retry.jitter(t),(!Number.isFinite(s)||s<0)&&(s=t)),Math.min(this.#e.retry.backoffLimit,s)}async#p(t){if(this.#s++,this.#s>this.#e.retry.limit)throw t;const s=t instanceof Error?t:new we(t);if(s instanceof V)return s.customDelay??this.#c();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw t;if(this.#e.retry.shouldRetry!==void 0){const n=await this.#e.retry.shouldRetry({error:s,retryCount:this.#s});if(n===!1)throw t;if(n===!0)return this.#c()}if(_t(t)&&!this.#e.retry.retryOnTimeout)throw t;if(jt(t)){if(!this.#e.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.#e.retry.afterStatusCodes.includes(t.response.status)){let r=Number(n)*1e3;Number.isNaN(r)?r=Date.parse(n)-Date.now():r>=Date.parse("2024-01-01")&&(r-=Date.now());const i=this.#e.retry.maxRetryAfter??r;return r<i?r:i}if(t.response.status===413)throw t}return this.#c()}#l(t){return this.#e.parseJson&&(t.json=async()=>this.#e.parseJson(await t.text())),t}async#f(t){try{return await t()}catch(s){const n=Math.min(await this.#p(s),Y);if(this.#s<1)throw s;if(await zt(n,this.#r?{signal:this.#r}:{}),s instanceof V&&s.customRequest){const r=this.#e.signal?new globalThis.Request(s.customRequest,{signal:this.#e.signal}):new globalThis.Request(s.customRequest);this.#u(r)}for(const r of this.#e.hooks.beforeRetry){const i=await r({request:this.request,options:this.#a(),error:s,retryCount:this.#s});if(i instanceof globalThis.Request){this.#u(i);break}if(i instanceof globalThis.Response)return i;if(i===Te)return}return this.#f(t)}}async#g(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#n.signal]):this.#n.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const s of this.#e.hooks.beforeRequest){const n=await s(this.request,this.#a(),{retryCount:this.#s});if(n instanceof Response)return n;if(n instanceof globalThis.Request){this.#u(n);break}}const t=Bt(this.request,this.#e);return this.#o=this.request,this.request=this.#o.clone(),this.#e.timeout===!1?this.#e.fetch(this.#o,t):Mt(this.#o,t,this.#n,this.#e)}#a(){if(!this.#i){const{hooks:t,...s}=this.#e;this.#i=Object.freeze(s)}return this.#i}#u(t){this.#i=void 0,this.request=this.#h(t)}#h(t,s){return!this.#e.onUploadProgress||!t.body?t:xt(t,this.#e.onUploadProgress,s??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const G=e=>{const t=(s,n)=>x.create(s,z(e,n));for(const s of Ee)t[s]=(n,r)=>x.create(n,z(e,r,{method:s}));return t.create=s=>G(z(s)),t.extend=s=>(typeof s=="function"&&(s=s(e??{})),G(z(e,s))),t.stop=Te,t.retry=vt,t},Lt=G();var R=(e=>(e.USDC="USDC",e))(R||{});const Ce={type:"evm",chainId:42161,name:"Arbitrum",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},Ue={type:"evm",chainId:421614,name:"Arbitrum Sepolia",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},ke={type:"evm",chainId:8453,name:"Base",cctpDomain:6,logoURI:"/images/chains/base.webp"},xe={type:"evm",chainId:84532,name:"Base Sepolia",cctpDomain:6,logoURI:"/images/chains/base.webp"},De={type:"evm",chainId:56,name:"BNB Chain",cctpDomain:null,logoURI:"/images/chains/bsc.webp"},Oe={type:"evm",chainId:1,name:"Ethereum",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},Ne={type:"evm",chainId:11155111,name:"Ethereum Sepolia",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},Me={type:"evm",chainId:43114,name:"Avalanche",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},ze={type:"evm",chainId:43113,name:"Avalanche Fuji",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},Be={type:"starknet",chainId:"0x534e5f4d41494e",name:"Starknet",cctpDomain:null,logoURI:"/images/chains/starknet.svg"};function Z(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function $e(e){return Z(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const je="2.43.4";let Q={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:s})=>t?`${e??"https://viem.sh"}${t}${s?`#${s}`:""}`:void 0,version:`viem@${je}`};class P extends Error{constructor(t,s={}){const n=s.cause instanceof P?s.cause.details:s.cause?.message?s.cause.message:s.details,r=s.cause instanceof P&&s.cause.docsPath||s.docsPath,i=Q.getDocsUrl?.({...s,docsPath:r}),o=[t||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...n?[`Details: ${n}`]:[],...Q.version?[`Version: ${Q.version}`]:[]].join(`
3
- `);super(o,s.cause?{cause:s.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=r,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=t,this.version=je}walk(t){return _e(this,t)}}function _e(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?_e(e.cause,t):t?null:e}class Le extends P{constructor({size:t,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}function $(e,{dir:t,size:s=32}={}){return typeof e=="string"?qt(e,{dir:t,size:s}):Ft(e,{dir:t,size:s})}function qt(e,{dir:t,size:s=32}={}){if(s===null)return e;const n=e.replace("0x","");if(n.length>s*2)throw new Le({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](s*2,"0")}`}function Ft(e,{dir:t,size:s=32}={}){if(s===null)return e;if(e.length>s)throw new Le({size:e.length,targetSize:s,type:"bytes"});const n=new Uint8Array(s);for(let r=0;r<s;r++){const i=t==="right";n[i?r:s-r-1]=e[i?r:e.length-r-1]}return n}class Ht extends P{constructor({max:t,min:s,signed:n,size:r,value:i}){super(`Number "${i}" is not in safe ${r?`${r*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${s} to ${t})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class Kt extends P{constructor({givenSize:t,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function ee(e,{size:t}){if($e(e)>t)throw new Kt({givenSize:$e(e),maxSize:t})}function Wt(e,t={}){const{signed:s,size:n}=t,r=BigInt(e);let i;n?s?i=(1n<<BigInt(n)*8n-1n)-1n:i=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&s?-i-1n:0;if(i&&r>i||r<o){const c=typeof e=="bigint"?"n":"";throw new Ht({max:i?`${i}${c}`:void 0,min:`${o}${c}`,signed:s,size:n,value:`${e}${c}`})}const a=`0x${(s&&r<0?(1n<<BigInt(n*8))+BigInt(r):r).toString(16)}`;return n?$(a,{size:n}):a}const Vt=new TextEncoder;function Yt(e,t={}){return typeof e=="number"||typeof e=="bigint"?Jt(e,t):typeof e=="boolean"?Xt(e,t):Z(e)?Fe(e,t):He(e,t)}function Xt(e,t={}){const s=new Uint8Array(1);return s[0]=Number(e),typeof t.size=="number"?(ee(s,{size:t.size}),$(s,{size:t.size})):s}const A={zero:48,nine:57,A:65,F:70,a:97,f:102};function qe(e){if(e>=A.zero&&e<=A.nine)return e-A.zero;if(e>=A.A&&e<=A.F)return e-(A.A-10);if(e>=A.a&&e<=A.f)return e-(A.a-10)}function Fe(e,t={}){let s=e;t.size&&(ee(s,{size:t.size}),s=$(s,{dir:"right",size:t.size}));let n=s.slice(2);n.length%2&&(n=`0${n}`);const r=n.length/2,i=new Uint8Array(r);for(let o=0,a=0;o<r;o++){const c=qe(n.charCodeAt(a++)),u=qe(n.charCodeAt(a++));if(c===void 0||u===void 0)throw new P(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);i[o]=c*16+u}return i}function Jt(e,t){const s=Wt(e,t);return Fe(s)}function He(e,t={}){const s=Vt.encode(e);return typeof t.size=="number"?(ee(s,{size:t.size}),$(s,{dir:"right",size:t.size})):s}const j=BigInt(2**32-1),Ke=BigInt(32);function Gt(e,t=!1){return t?{h:Number(e&j),l:Number(e>>Ke&j)}:{h:Number(e>>Ke&j)|0,l:Number(e&j)|0}}function Zt(e,t=!1){const s=e.length;let n=new Uint32Array(s),r=new Uint32Array(s);for(let i=0;i<s;i++){const{h:o,l:a}=Gt(e[i],t);[n[i],r[i]]=[o,a]}return[n,r]}const Qt=(e,t,s)=>e<<s|t>>>32-s,es=(e,t,s)=>t<<s|e>>>32-s,ts=(e,t,s)=>t<<s-32|e>>>64-s,ss=(e,t,s)=>e<<s-32|t>>>64-s;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ns(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function We(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function _(e,...t){if(!ns(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ve(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function rs(e,t){_(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function os(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ye(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const is=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function as(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function cs(e){for(let t=0;t<e.length;t++)e[t]=as(e[t]);return e}const Xe=is?e=>e:cs;function us(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Je(e){return typeof e=="string"&&(e=us(e)),_(e),e}class ls{}function fs(e){const t=n=>e().update(Je(n)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}const hs=BigInt(0),D=BigInt(1),ds=BigInt(2),ps=BigInt(7),gs=BigInt(256),ms=BigInt(113),Ge=[],Ze=[],Qe=[];for(let e=0,t=D,s=1,n=0;e<24;e++){[s,n]=[n,(2*s+3*n)%5],Ge.push(2*(5*n+s)),Ze.push((e+1)*(e+2)/2%64);let r=hs;for(let i=0;i<7;i++)t=(t<<D^(t>>ps)*ms)%gs,t&ds&&(r^=D<<(D<<BigInt(i))-D);Qe.push(r)}const et=Zt(Qe,!0),ys=et[0],ws=et[1],tt=(e,t,s)=>s>32?ts(e,t,s):Qt(e,t,s),st=(e,t,s)=>s>32?ss(e,t,s):es(e,t,s);function bs(e,t=24){const s=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let o=0;o<10;o++)s[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=s[c],l=s[c+1],b=tt(u,l,1)^s[a],m=st(u,l,1)^s[a+1];for(let w=0;w<50;w+=10)e[o+w]^=b,e[o+w+1]^=m}let r=e[2],i=e[3];for(let o=0;o<24;o++){const a=Ze[o],c=tt(r,i,a),u=st(r,i,a),l=Ge[o];r=e[l],i=e[l+1],e[l]=c,e[l+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=e[o+a];for(let a=0;a<10;a++)e[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}e[0]^=ys[n],e[1]^=ws[n]}Ye(s)}class te extends ls{constructor(t,s,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=s,this.outputLen=n,this.enableXOF=r,this.rounds=i,We(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=os(this.state)}clone(){return this._cloneInto()}keccak(){Xe(this.state32),bs(this.state32,this.rounds),Xe(this.state32),this.posOut=0,this.pos=0}update(t){Ve(this),t=Je(t),_(t);const{blockLen:s,state:n}=this,r=t.length;for(let i=0;i<r;){const o=Math.min(s-this.pos,r-i);for(let a=0;a<o;a++)n[this.pos++]^=t[i++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:s,pos:n,blockLen:r}=this;t[n]^=s,(s&128)!==0&&n===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){Ve(this,!1),_(t),this.finish();const s=this.state,{blockLen:n}=this;for(let r=0,i=t.length;r<i;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,i-r);t.set(s.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return We(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(rs(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Ye(this.state)}_cloneInto(t){const{blockLen:s,suffix:n,outputLen:r,rounds:i,enableXOF:o}=this;return t||(t=new te(s,n,r,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=n,t.outputLen=r,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Ss=(e,t,s)=>fs(()=>new te(t,e,s)),Es=Ss(1,136,256/8);function Ts(e,t){return Es(Z(e,{strict:!1})?Yt(e):e)}class Rs extends P{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class nt extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const s=super.get(t);return super.has(t)&&s!==void 0&&(this.delete(t),super.set(t,s)),s}set(t,s){if(super.set(t,s),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const se=new nt(8192);function rt(e,t){if(se.has(`${e}.${t}`))return se.get(`${e}.${t}`);const s=e.substring(2).toLowerCase(),n=Ts(He(s)),r=s.split("");for(let o=0;o<40;o+=2)n[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(n[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const i=`0x${r.join("")}`;return se.set(`${e}.${t}`,i),i}function v(e,t){if(!vs(e,{strict:!1}))throw new Rs({address:e});return rt(e,t)}const As=/^0x[a-fA-F0-9]{40}$/,ne=new nt(8192);function vs(e,t){const{strict:s=!0}=t??{},n=`${e}.${s}`;if(ne.has(n))return ne.get(n);const r=As.test(e)?e.toLowerCase()===e?!0:s?rt(e)===e:!0:!1;return ne.set(n,r),r}const Ps={chainId:Ue.chainId,address:v("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Is={chainId:Ce.chainId,address:v("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:"USDC",name:"USD Coin",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png"},Cs={chainId:ze.chainId,address:v("0x5425890298aed601595a70ab815c96711a31bc65"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Us={chainId:Me.chainId,address:v("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},ks={chainId:xe.chainId,address:v("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},xs={chainId:ke.chainId,address:v("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ds={chainId:De.chainId,address:v("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:"USDC",decimals:18,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Os={chainId:Ne.chainId,address:v("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ns={chainId:Oe.chainId,address:v("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ms={chainId:Be.chainId,address:"0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8",symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},ot={ARBITRUM_MAINNET:{...Ce,tokens:{[R.USDC]:Is},explorer:"https://arbiscan.io"},ARBITRUM_TESTNET:{...Ue,explorer:"https://sepolia.arbiscan.io",tokens:{[R.USDC]:Ps}},AVALANCHE_MAINNET:{...Me,tokens:{[R.USDC]:Us},explorer:"https://snowtrace.io"},AVALANCHE_TESTNET:{...ze,tokens:{[R.USDC]:Cs},explorer:"https://testnet.snowtrace.io"},BASE_MAINNET:{...ke,tokens:{[R.USDC]:xs},explorer:"https://basescan.org"},BASE_TESTNET:{...xe,tokens:{[R.USDC]:ks},explorer:"https://sepolia.basescan.org"},BSC_MAINNET:{...De,tokens:{[R.USDC]:Ds},explorer:"https://bscscan.com"},ETHEREUM_MAINNET:{...Oe,tokens:{[R.USDC]:Ns},explorer:"https://etherscan.io"},ETHEREUM_TESTNET:{...Ne,tokens:{[R.USDC]:Os},explorer:"https://sepolia.etherscan.io"},STARKNET_MAINNET:{...Be,tokens:{[R.USDC]:Ms},explorer:""}};var L=(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))(L||{}),re=(e=>(e.USDC="USDC",e))(re||{});const zs=e=>{const t=e?.trim().toUpperCase();if(ot[t])return ot[t]};function Bs(e,t){return zs(e)?.tokens[t]?.address}var oe=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(oe||{});class h{constructor({api_key:t,env:s,seesion_token:n}){this.api_key=t||"",this.sessionToken=n||"",this.env=s??oe.PRODUCTION}static async config(t){if(!h.app){if(!t)throw new Error("Please provide an api_key");h.app=new h(t)}return t&&(t.api_key!==void 0&&(h.app.api_key=t.api_key),t.seesion_token!==void 0&&(h.app.sessionToken=t.seesion_token),t.env!==void 0&&(h.app.env=t.env)),h.app}static getApiKey(){if(!h.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return h.app.api_key}static getSessionToken(){if(!h.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return h.app.sessionToken}static getEnv(){if(!h.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return h.app.env==="internal"?"staging":h.app.env}static getBaseUrl(){if(!h.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(h.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){if(!h.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const s=h.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",n=Number(t),r=t&&!isNaN(Number(t))&&n>0?"/pay/":"/deposit/",i=`${t&&!isNaN(Number(t))&&n>0?n*100:""}`;return s+r+i}}let ie=null;function $s(){ie=Lt.create({prefixUrl:h.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[e=>{const t=h.getSessionToken()||h.getApiKey();e.headers.set("Authorization",`Bearer ${t}`)}],afterResponse:[(e,t,s)=>s]},retry:{limit:2}})}function g(){return ie||$s(),ie}class js{async getById(t){return await g().get("intents/"+t).json()}async getForSender(t){return await g().get("intents/user/"+t).json()}async getForAddress(t){return await g().get("intents/address/"+t).json()}async getForSession(t){return await g().get("modal/sessions/intents/"+t).json()}async getAll(t){return await g().get("intents",{searchParams:t}).json()}async create(t){return await g().post("intents",{json:t}).json()}async createForSession(t){return await g().post("modal/sessions/intents",{json:t}).json()}async update(t,s){return await g().post("intents",{json:s}).json()}async triggerProcessing(t){return await g().post(`intents/${t}/trigger-processing`).json()}async triggerProcessingForSession(t){return await g().post(`modal/sessions/intents/${t}/process`).json()}}class _s{async getFromSpecificBridge(t){return await g().get("quotes/single",{searchParams:t}).json()}async getFromAllBridges(t){return await g().get("quotes/multiple",{searchParams:t}).json()}async getBestAcrossBridges(t){return await g().get("quotes/best",{searchParams:t}).json()}async getAll(t){return await g().get("quotes/multi-source",{searchParams:t}).json()}async getAllForSession(t){return await g().get("modal/sessions/quotes",{searchParams:t}).json()}}class Ls{async getOptimalRoutes(t){return await g().get("router/optimal-route",{searchParams:t}).json()}async getAllSupportedBridges(){return await g().get("router/supported-bridges/all").json()}async getSupportedBridges(t){return await g().get("router/supported-bridges/route",{searchParams:t}).json()}async getSupportedRoutes(t,s){return await g().get("router/supported-bridges/bridge/"+t,{searchParams:s}).json()}}class qs{async getSupported(t){return await g().get("chains",{searchParams:t}).json()}}class Fs{async getClientInfo(){return await g().get("client/auth/client-info").json()}async getClientInfoForSession(){return await g().get("modal/sessions/client").json()}}class Hs{getSessionToken(t){const s={recipient:t.recipient,tokenOut:Bs(L[t.destinationChain?.replace("_MAINNET","")],re[t.token]),destinationChain:L[t.destinationChain?.replace("_MAINNET","")],amount:t.amount};return g().post("modal/sessions",{json:s}).json().then(n=>({...n,amount:s.amount}))}}const Ks={router:new Ls,quotes:new _s,intents:new js,chains:new qs,client:new Fs,auth:new Hs};function it(e){var t,s,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(s=it(e[t]))&&(n&&(n+=" "),n+=s)}else for(s in e)e[s]&&(n&&(n+=" "),n+=s);return n}function Ws(){for(var e,t,s=0,n="",r=arguments.length;s<r;s++)(e=arguments[s])&&(t=it(e))&&(n&&(n+=" "),n+=t);return n}function Vs(e){const{amount:t,styles:s,isOpen:n,isPending:r,open:i,close:o,onCancel:a,onSuccess:c,session_url:u,sessionToken:l}=e,[b,m]=f.useState(0),[w,E]=f.useState(""),M=f.useRef(null);f.useEffect(()=>{const d=document.body.style.overflow;n?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=d||"";const y=T=>{T.data==="closed"&&(o(),a?.()),T.data==="completed"&&(window.setTimeout(o,2e3),c?.())};return window.addEventListener("message",y),()=>{document.body.style.overflow=d||"",window.removeEventListener("message",y)}},[n,a,c]),f.useEffect(()=>{h.config({api_key:l||"",env:e.env==="internal"?"internal":"production"}).then(d=>{window.chainrails=d,E(h.getPayModalUrl(t))})},[n,t]),f.useEffect(()=>{if(!l)return;const d={type:"session",session_token:l,environment:h.getEnv()||oe.PRODUCTION,styles:s};M.current?.contentWindow?.postMessage(d,"https://app.chainrails.io"),M.current?.contentWindow?.postMessage(d,"https://chainrails-frontend-git-staging-horus-labs.vercel.app")},[l,b,n,s]);function p(){m(Math.random())}return k.jsxs("div",{className:Ws("payment-modal-wrapper",b===0||r?"loading":"not-loading",n?"open":"closed"),children:[(b===0||r)&&k.jsx("div",{role:"status",className:"payment-modal-loader",children:k.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[k.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"}),k.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"})]})}),k.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:w||void 0,onLoad:p,className:`payment-modal ${b===0||r?"invisible":"visible"}`,"data-id":t,ref:M},l)]})}const Ys=Symbol(),ae=Symbol(),O="a",at="f",ct="p",ut="c",lt="t",ce="h",N="w",ue="o",le="k";let Xs=(e,t)=>new Proxy(e,t);const fe=Object.getPrototypeOf,he=new WeakMap,ft=e=>e&&(he.has(e)?he.get(e):fe(e)===Object.prototype||fe(e)===Array.prototype),q=e=>typeof e=="object"&&e!==null,Js=e=>Object.values(Object.getOwnPropertyDescriptors(e)).some(t=>!t.configurable&&!t.writable),Gs=e=>{if(Array.isArray(e))return Array.from(e);const t=Object.getOwnPropertyDescriptors(e);return Object.values(t).forEach(s=>{s.configurable=!0}),Object.create(fe(e),t)},Zs=(e,t)=>{const s={[at]:t};let n=!1;const r=(a,c)=>{if(!n){let u=s[O].get(e);if(u||(u={},s[O].set(e,u)),a===N)u[N]=!0;else{let l=u[a];l||(l=new Set,u[a]=l),l.add(c)}}},i=()=>{n=!0,s[O].delete(e)},o={get(a,c){return c===ae?e:(r(le,c),ht(Reflect.get(a,c),s[O],s[ut],s[lt]))},has(a,c){return c===Ys?(i(),!0):(r(ce,c),Reflect.has(a,c))},getOwnPropertyDescriptor(a,c){return r(ue,c),Reflect.getOwnPropertyDescriptor(a,c)},ownKeys(a){return r(N),Reflect.ownKeys(a)}};return t&&(o.set=o.deleteProperty=()=>!1),[o,s]},de=e=>e[ae]||e,ht=(e,t,s,n)=>{if(!ft(e))return e;let r=n&&n.get(e);if(!r){const c=de(e);Js(c)?r=[c,Gs(c)]:r=[c],n?.set(e,r)}const[i,o]=r;let a=s&&s.get(i);return(!a||a[1][at]!==!!o)&&(a=Zs(i,!!o),a[1][ct]=Xs(o||i,a[0]),s&&s.set(i,a)),a[1][O]=t,a[1][ut]=s,a[1][lt]=n,a[1][ct]},Qs=(e,t)=>{const s=Reflect.ownKeys(e),n=Reflect.ownKeys(t);return s.length!==n.length||s.some((r,i)=>r!==n[i])},dt=(e,t,s,n,r=Object.is)=>{if(r(e,t))return!1;if(!q(e)||!q(t))return!0;const i=s.get(de(e));if(!i)return!0;if(n){if(n.get(e)===t)return!1;n.set(e,t)}let o=null;for(const a of i[ce]||[])if(o=Reflect.has(e,a)!==Reflect.has(t,a),o)return o;if(i[N]===!0){if(o=Qs(e,t),o)return o}else for(const a of i[ue]||[]){const c=!!Reflect.getOwnPropertyDescriptor(e,a),u=!!Reflect.getOwnPropertyDescriptor(t,a);if(o=c!==u,o)return o}for(const a of i[le]||[])if(o=dt(e[a],t[a],s,n,r),o)return o;if(o===null)throw new Error("invalid used");return o},en=e=>ft(e)&&e[ae]||null,pt=(e,t=!0)=>{he.set(e,t)},tn=(e,t,s)=>{const n=[],r=new WeakSet,i=(o,a)=>{var c,u,l;if(r.has(o))return;q(o)&&r.add(o);const b=q(o)&&t.get(de(o));if(b){if((c=b[ce])===null||c===void 0||c.forEach(m=>{const w=`:has(${String(m)})`;n.push(a?[...a,w]:[w])}),b[N]===!0){const m=":ownKeys";n.push(a?[...a,m]:[m])}else(u=b[ue])===null||u===void 0||u.forEach(m=>{const w=`:hasOwn(${String(m)})`;n.push(a?[...a,w]:[w])});(l=b[le])===null||l===void 0||l.forEach(m=>{"value"in(Object.getOwnPropertyDescriptor(o,m)||{})&&i(o[m],a?[...a,m]:[m])})}else a&&n.push(a)};return i(e),n},F={},pe=e=>typeof e=="object"&&e!==null,sn=e=>pe(e)&&!ge.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)&&!(e instanceof Promise),gt=(e,t)=>{const s=mt.get(e);if(s?.[0]===t)return s[1];const n=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return pt(n,!0),mt.set(e,[t,n]),Reflect.ownKeys(e).forEach(r=>{if(Object.getOwnPropertyDescriptor(n,r))return;const i=Reflect.get(e,r),{enumerable:o}=Reflect.getOwnPropertyDescriptor(e,r),a={value:i,enumerable:o,configurable:!0};if(ge.has(i))pt(i,!1);else if(U.has(i)){const[c,u]=U.get(i);a.value=gt(c,u())}Object.defineProperty(n,r,a)}),Object.preventExtensions(n)},nn=(e,t,s,n)=>({deleteProperty(r,i){const o=Reflect.get(r,i);s(i);const a=Reflect.deleteProperty(r,i);return a&&n(["delete",[i],o]),a},set(r,i,o,a){const c=!e()&&Reflect.has(r,i),u=Reflect.get(r,i,a);if(c&&(yt(u,o)||H.has(o)&&yt(u,H.get(o))))return!0;s(i),pe(o)&&(o=en(o)||o);const l=!U.has(o)&&on(o)?wt(o):o;return t(i,l),Reflect.set(r,i,l,a),n(["set",[i],o,u]),!0}}),U=new WeakMap,ge=new WeakSet,mt=new WeakMap,me=[1],H=new WeakMap;let yt=Object.is,rn=(e,t)=>new Proxy(e,t),on=sn,an=gt,cn=nn;function wt(e={}){if(!pe(e))throw new Error("object required");const t=H.get(e);if(t)return t;let s=me[0];const n=new Set,r=(p,d=++me[0])=>{s!==d&&(i=s=d,n.forEach(y=>y(p,d)))};let i=s;const o=(p=me[0])=>(i!==p&&(i=p,c.forEach(([d])=>{const y=d[1](p);y>s&&(s=y)})),s),a=p=>(d,y)=>{const T=[...d];T[1]=[p,...T[1]],r(T,y)},c=new Map,u=(p,d)=>{const y=!ge.has(d)&&U.get(d);if(y){if((F?"production":void 0)!=="production"&&c.has(p))throw new Error("prop listener already exists");if(n.size){const T=y[2](a(p));c.set(p,[y,T])}else c.set(p,[y])}},l=p=>{var d;const y=c.get(p);y&&(c.delete(p),(d=y[1])==null||d.call(y))},b=p=>(n.add(p),n.size===1&&c.forEach(([y,T],K)=>{if((F?"production":void 0)!=="production"&&T)throw new Error("remove already exists");const mn=y[2](a(K));c.set(K,[y,mn])}),()=>{n.delete(p),n.size===0&&c.forEach(([y,T],K)=>{T&&(T(),c.set(K,[y]))})});let m=!0;const w=cn(()=>m,u,l,r),E=rn(e,w);H.set(e,E);const M=[e,o,b];return U.set(E,M),Reflect.ownKeys(e).forEach(p=>{const d=Object.getOwnPropertyDescriptor(e,p);"value"in d&&d.writable&&(E[p]=e[p])}),m=!1,E}function un(e,t,s){const n=U.get(e);(F?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let r;const i=[],o=n[2];let a=!1;const u=o(l=>{i.push(l),r||(r=Promise.resolve().then(()=>{r=void 0,a&&t(i.splice(0))}))});return a=!0,()=>{a=!1,u()}}function bt(e){const t=U.get(e);(F?"production":void 0)!=="production"&&!t&&console.warn("Please use proxy object");const[s,n]=t;return an(s,n())}const ln={},fn=(e,t)=>{const s=f.useRef(void 0);f.useEffect(()=>{s.current=tn(e,t)}),f.useDebugValue(s.current)},hn=new WeakMap;function dn(e,t){const n=f.useMemo(()=>e&&new WeakMap,[e]),r=f.useRef(void 0);let i=!0;const o=f.useSyncExternalStore(f.useCallback(c=>{const u=un(e,c);return c(),u},[e,void 0]),()=>{const c=bt(e);try{if(!i&&r.current&&!dt(r.current,c,n,new WeakMap))return r.current}catch{}return c},()=>bt(e));i=!1,f.useLayoutEffect(()=>{r.current=o}),(ln?"production":void 0)!=="production"&&fn(o,n);const a=f.useMemo(()=>new WeakMap,[]);return ht(o,n,a,hn)}const I=wt({data:null,isPending:!1,error:null});function pn({session_url:e,onCancel:t,onSuccess:s}){const n=dn(I),[r,i]=f.useState(!1),[o,a]=f.useState(Date.now()),c=n?.data?.sessionToken,u=n?.data?.amount;function l(){c||window.setTimeout(()=>{c&&i(!0)},1e3),i(!0)}function b(){i(!1)}const m=()=>{const w=Date.now();I.isPending=!0,I.error=null,I.data=null,fetch(e,{headers:{"Content-Type":"application/json"}}).then(E=>E.json()).then(E=>{w<o||(I.data=E,I.isPending=!1,a(w))}).catch(E=>{w<o||(I.error=E?.toString(),I.isPending=!1,a(w))})};return f.useEffect(()=>{m()},[e]),{sessionToken:c,amount:u,isOpen:r,session_url:e,open:l,close:b,refetch:m,onSuccess:s,onCancel:t}}function gn({sessionToken:e,amount:t,onCancel:s,onSuccess:n}){const[r,i]=f.useState(!1),[o,a]=f.useState(e),[c,u]=f.useState(t);function l({sessionToken:w,amount:E}){a(w),u(E)}f.useEffect(()=>{a(e)},[e]);function b(){o||window.setTimeout(()=>{o&&i(!0)},1e3),i(!0)}function m(){i(!1)}return{sessionToken:o,updateSession:l,amount:c,isOpen:r,open:b,close:m,onSuccess:n,onCancel:s}}S.Chainrails=h,S.PaymentModal=Vs,S.chains=L,S.crapi=Ks,S.tokens=re,S.usePaymentModal=gn,S.usePaymentSession=pn,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(S,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],d):(S=typeof globalThis<"u"?globalThis:S||self,d(S.Chainrails={},S.React,S.jsxRuntime))})(this,(function(S,d,k){"use strict";var ye=document.createElement("style");ye.textContent=`.payment-modal-wrapper{position:fixed;inset:0;z-index:10000;height:100dvh;width:100vw;transition:all .1s ease-in-out}.payment-modal-wrapper.loading{background-color:#0003;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.payment-modal-wrapper.not-loading{background-color:#0008;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0;pointer-events:none}.payment-modal-wrapper.closed *{pointer-events:none!important}.payment-modal-wrapper.open iframe{transform:translateY(0);transform:scale(1)}.payment-modal-wrapper.closed iframe{transform:translateY(50vh);transform:scale(1)}.payment-modal-loader{position:absolute;inset:0;z-index:10000;display:grid;height:100%;width:100%;place-content:center}.payment-modal-loader .icon{height:48px;width:48px;animation:cr-spin 1s linear infinite;fill:#2563eb;color:#475569}.payment-modal{position:absolute;inset:0;z-index:10000;height:100%;width:100%;transition:all .3s cubic-bezier(.25,1,.5,1)}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@keyframes cr-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
2
+ /*$vite$:1*/`,document.head.appendChild(ye);class W extends Error{response;request;options;constructor(t,s,n){const r=t.status||t.status===0?t.status:"",i=t.statusText??"",o=`${r} ${i}`.trim(),a=o?`status code ${o}`:"an unknown error";super(`Request failed with ${a}: ${s.method} ${s.url}`),this.name="HTTPError",this.response=t,this.request=s,this.options=n}}class we extends Error{name="NonError";value;constructor(t){let s="Non-error value was thrown";try{typeof t=="string"?s=t:t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"&&(s=t.message)}catch{}super(s),this.value=t}}class V extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(t){const s=t?.cause?t.cause instanceof Error?t.cause:new we(t.cause):void 0;super(t?.code?`Forced retry: ${t.code}`:"Forced retry",s?{cause:s}:void 0),this.customDelay=t?.delay,this.code=t?.code,this.customRequest=t?.request}}const be=(()=>{let e=!1,t=!1;const s=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(s&&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(r){if(r instanceof Error&&r.message==="unsupported BodyInit type")return!1;throw r}return e&&!t})(),St=typeof globalThis.AbortController=="function",Se=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Et=typeof globalThis.ReadableStream=="function",Tt=typeof globalThis.FormData=="function",Ee=["get","post","put","patch","head","delete"],Rt={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Y=2147483647,At=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Te=Symbol("stop");class Re{options;constructor(t){this.options=t}}const vt=e=>new Re(e),Pt={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},Ct={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},Ut=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(const[s,n]of e)t+=At,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).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},Ae=(e,t,s)=>{let n,r=0;return e.pipeThrough(new TransformStream({transform(i,o){if(o.enqueue(i),n){r+=n.byteLength;let a=t===0?0:r/t;a>=1&&(a=1-Number.EPSILON),s?.({percent:a,totalBytes:Math.max(t,r),transferredBytes:r},n)}n=i},flush(){n&&(r+=n.byteLength,s?.({percent:1,totalBytes:Math.max(t,r),transferredBytes:r},n))}}))},kt=(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 s=Math.max(0,Number(e.headers.get("content-length"))||0);return new Response(Ae(e.body,s,t),{status:e.status,statusText:e.statusText,headers:e.headers})},xt=(e,t,s)=>{if(!e.body)return e;const n=Ut(s??e.body);return new Request(e,{duplex:"half",body:Ae(e.body,n,t)})},C=e=>e!==null&&typeof e=="object",z=(...e)=>{for(const t of e)if((!C(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return X({},...e)},ve=(e={},t={})=>{const s=new globalThis.Headers(e),n=t instanceof globalThis.Headers,r=new globalThis.Headers(t);for(const[i,o]of r.entries())n&&o==="undefined"||o===void 0?s.delete(i):s.set(i,o);return s};function B(e,t,s){return Object.hasOwn(t,s)&&t[s]===void 0?[]:X(e[s]??[],t[s]??[])}const Pe=(e={},t={})=>({beforeRequest:B(e,t,"beforeRequest"),beforeRetry:B(e,t,"beforeRetry"),afterResponse:B(e,t,"afterResponse"),beforeError:B(e,t,"beforeError")}),Dt=(e,t)=>{const s=new URLSearchParams;for(const n of[e,t])if(n!==void 0)if(n instanceof URLSearchParams)for(const[r,i]of n.entries())s.append(r,i);else if(Array.isArray(n))for(const r of n){if(!Array.isArray(r)||r.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");s.append(String(r[0]),String(r[1]))}else if(C(n))for(const[r,i]of Object.entries(n))i!==void 0&&s.append(r,String(i));else{const r=new URLSearchParams(n);for(const[i,o]of r.entries())s.append(i,o)}return s},X=(...e)=>{let t={},s={},n={},r;const i=[];for(const o of e)if(Array.isArray(o))Array.isArray(t)||(t=[]),t=[...t,...o];else if(C(o)){for(let[a,c]of Object.entries(o)){if(a==="signal"&&c instanceof globalThis.AbortSignal){i.push(c);continue}if(a==="context"){if(c!=null&&(!C(c)||Array.isArray(c)))throw new TypeError("The `context` option must be an object");t={...t,context:c==null?{}:{...t.context,...c}};continue}if(a==="searchParams"){c==null?r=void 0:r=r===void 0?c:Dt(r,c);continue}C(c)&&a in t&&(c=X(t[a],c)),t={...t,[a]:c}}C(o.hooks)&&(n=Pe(n,o.hooks),t.hooks=n),C(o.headers)&&(s=ve(s,o.headers),t.headers=s)}return r!==void 0&&(t.searchParams=r),i.length>0&&(i.length===1?t.signal=i[0]:Se?t.signal=AbortSignal.any(i):t.signal=i.at(-1)),t.context===void 0&&(t.context={}),t},Ot=e=>Ee.includes(e)?e.toUpperCase():e,Ie={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},Nt=(e={})=>{if(typeof e=="number")return{...Ie,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{...Ie,...e}};class J extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}}async function Mt(e,t,s,n){return new Promise((r,i)=>{const o=setTimeout(()=>{s&&s.abort(),i(new J(e))},n.timeout);n.fetch(e,t).then(r).catch(i).then(()=>{clearTimeout(o)})})}async function zt(e,{signal:t}){return new Promise((s,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",r,{once:!0}));function r(){clearTimeout(i),n(t.reason)}const i=setTimeout(()=>{t?.removeEventListener("abort",r),s()},e)})}const Bt=(e,t)=>{const s={};for(const n in t)Object.hasOwn(t,n)&&!(n in Ct)&&!(n in Pt)&&(!(n in e)||n in It)&&(s[n]=t[n]);return s},$t=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 jt(e){return e instanceof W||e?.name===W.name}function _t(e){return e instanceof J||e?.name===J.name}class x{static create(t,s){const n=new x(t,s),r=async()=>{if(typeof n.#e.timeout=="number"&&n.#e.timeout>Y)throw new RangeError(`The \`timeout\` option cannot be greater than ${Y}`);await Promise.resolve();let o=await n.#g();for(const a of n.#e.hooks.afterResponse){const c=n.#l(o.clone()),u=await a(n.request,n.#a(),c,{retryCount:n.#s});if(u instanceof globalThis.Response&&(o=u),u instanceof Re)throw await Promise.all([c.body?.cancel(),o.body?.cancel()]),new V(u.options)}if(n.#l(o),!o.ok&&(typeof n.#e.throwHttpErrors=="function"?n.#e.throwHttpErrors(o.status):n.#e.throwHttpErrors)){let a=new W(o,n.request,n.#a());for(const c of n.#e.hooks.beforeError)a=await c(a,{retryCount:n.#s});throw a}if(n.#e.onDownloadProgress){if(typeof n.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Et)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return kt(o.clone(),n.#e.onDownloadProgress)}return o},i=n.#f(r).finally(async()=>{const o=n.#o,a=[];o&&!o.bodyUsed&&a.push(o.body?.cancel()),n.request.bodyUsed||a.push(n.request.body?.cancel()),await Promise.all(a)});for(const[o,a]of Object.entries(Rt))o==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[o]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||a);const c=await i;if(o==="json"){if(c.status===204)return"";const u=await c.text();return u===""?"":s.parseJson?s.parseJson(u):JSON.parse(u)}return c[o]()});return i}static#h(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,s])=>s!==void 0)):t}request;#n;#s=0;#t;#e;#o;#r;#i;constructor(t,s={}){if(this.#t=t,this.#e={...s,headers:ve(this.#t.headers,s.headers),hooks:Pe({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},s.hooks),method:Ot(s.method??this.#t.method??"GET"),prefixUrl:String(s.prefixUrl||""),retry:Nt(s.retry),throwHttpErrors:s.throwHttpErrors??!0,timeout:s.timeout??1e4,fetch:s.fetch??globalThis.fetch.bind(globalThis),context:s.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}St&&Se&&(this.#r=this.#e.signal??this.#t.signal,this.#n=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#n.signal]):this.#n.signal),be&&(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"));const n=s.headers&&new globalThis.Headers(s.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(Tt&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!n&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),$t(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(x.#h(this.#e.searchParams)).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(o,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!be)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#d(this.request,this.#e.body??void 0)}}#c(){const t=this.#e.retry.delay(this.#s);let s=t;return this.#e.retry.jitter===!0?s=Math.random()*t:typeof this.#e.retry.jitter=="function"&&(s=this.#e.retry.jitter(t),(!Number.isFinite(s)||s<0)&&(s=t)),Math.min(this.#e.retry.backoffLimit,s)}async#p(t){if(this.#s++,this.#s>this.#e.retry.limit)throw t;const s=t instanceof Error?t:new we(t);if(s instanceof V)return s.customDelay??this.#c();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw t;if(this.#e.retry.shouldRetry!==void 0){const n=await this.#e.retry.shouldRetry({error:s,retryCount:this.#s});if(n===!1)throw t;if(n===!0)return this.#c()}if(_t(t)&&!this.#e.retry.retryOnTimeout)throw t;if(jt(t)){if(!this.#e.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.#e.retry.afterStatusCodes.includes(t.response.status)){let r=Number(n)*1e3;Number.isNaN(r)?r=Date.parse(n)-Date.now():r>=Date.parse("2024-01-01")&&(r-=Date.now());const i=this.#e.retry.maxRetryAfter??r;return r<i?r:i}if(t.response.status===413)throw t}return this.#c()}#l(t){return this.#e.parseJson&&(t.json=async()=>this.#e.parseJson(await t.text())),t}async#f(t){try{return await t()}catch(s){const n=Math.min(await this.#p(s),Y);if(this.#s<1)throw s;if(await zt(n,this.#r?{signal:this.#r}:{}),s instanceof V&&s.customRequest){const r=this.#e.signal?new globalThis.Request(s.customRequest,{signal:this.#e.signal}):new globalThis.Request(s.customRequest);this.#u(r)}for(const r of this.#e.hooks.beforeRetry){const i=await r({request:this.request,options:this.#a(),error:s,retryCount:this.#s});if(i instanceof globalThis.Request){this.#u(i);break}if(i instanceof globalThis.Response)return i;if(i===Te)return}return this.#f(t)}}async#g(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#n.signal]):this.#n.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const s of this.#e.hooks.beforeRequest){const n=await s(this.request,this.#a(),{retryCount:this.#s});if(n instanceof Response)return n;if(n instanceof globalThis.Request){this.#u(n);break}}const t=Bt(this.request,this.#e);return this.#o=this.request,this.request=this.#o.clone(),this.#e.timeout===!1?this.#e.fetch(this.#o,t):Mt(this.#o,t,this.#n,this.#e)}#a(){if(!this.#i){const{hooks:t,...s}=this.#e;this.#i=Object.freeze(s)}return this.#i}#u(t){this.#i=void 0,this.request=this.#d(t)}#d(t,s){return!this.#e.onUploadProgress||!t.body?t:xt(t,this.#e.onUploadProgress,s??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const G=e=>{const t=(s,n)=>x.create(s,z(e,n));for(const s of Ee)t[s]=(n,r)=>x.create(n,z(e,r,{method:s}));return t.create=s=>G(z(s)),t.extend=s=>(typeof s=="function"&&(s=s(e??{})),G(z(e,s))),t.stop=Te,t.retry=vt,t},Lt=G();var R=(e=>(e.USDC="USDC",e))(R||{});const Ce={type:"evm",chainId:42161,name:"Arbitrum",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},Ue={type:"evm",chainId:421614,name:"Arbitrum Sepolia",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},ke={type:"evm",chainId:8453,name:"Base",cctpDomain:6,logoURI:"/images/chains/base.webp"},xe={type:"evm",chainId:84532,name:"Base Sepolia",cctpDomain:6,logoURI:"/images/chains/base.webp"},De={type:"evm",chainId:56,name:"BNB Chain",cctpDomain:null,logoURI:"/images/chains/bsc.webp"},Oe={type:"evm",chainId:1,name:"Ethereum",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},Ne={type:"evm",chainId:11155111,name:"Ethereum Sepolia",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},Me={type:"evm",chainId:43114,name:"Avalanche",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},ze={type:"evm",chainId:43113,name:"Avalanche Fuji",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},Be={type:"starknet",chainId:"0x534e5f4d41494e",name:"Starknet",cctpDomain:null,logoURI:"/images/chains/starknet.svg"};function Z(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function $e(e){return Z(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const je="2.43.4";let Q={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:s})=>t?`${e??"https://viem.sh"}${t}${s?`#${s}`:""}`:void 0,version:`viem@${je}`};class P extends Error{constructor(t,s={}){const n=s.cause instanceof P?s.cause.details:s.cause?.message?s.cause.message:s.details,r=s.cause instanceof P&&s.cause.docsPath||s.docsPath,i=Q.getDocsUrl?.({...s,docsPath:r}),o=[t||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...n?[`Details: ${n}`]:[],...Q.version?[`Version: ${Q.version}`]:[]].join(`
3
+ `);super(o,s.cause?{cause:s.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=r,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=t,this.version=je}walk(t){return _e(this,t)}}function _e(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?_e(e.cause,t):t?null:e}class Le extends P{constructor({size:t,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}function $(e,{dir:t,size:s=32}={}){return typeof e=="string"?qt(e,{dir:t,size:s}):Ft(e,{dir:t,size:s})}function qt(e,{dir:t,size:s=32}={}){if(s===null)return e;const n=e.replace("0x","");if(n.length>s*2)throw new Le({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](s*2,"0")}`}function Ft(e,{dir:t,size:s=32}={}){if(s===null)return e;if(e.length>s)throw new Le({size:e.length,targetSize:s,type:"bytes"});const n=new Uint8Array(s);for(let r=0;r<s;r++){const i=t==="right";n[i?r:s-r-1]=e[i?r:e.length-r-1]}return n}class Ht extends P{constructor({max:t,min:s,signed:n,size:r,value:i}){super(`Number "${i}" is not in safe ${r?`${r*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${s} to ${t})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class Kt extends P{constructor({givenSize:t,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function ee(e,{size:t}){if($e(e)>t)throw new Kt({givenSize:$e(e),maxSize:t})}function Wt(e,t={}){const{signed:s,size:n}=t,r=BigInt(e);let i;n?s?i=(1n<<BigInt(n)*8n-1n)-1n:i=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&s?-i-1n:0;if(i&&r>i||r<o){const c=typeof e=="bigint"?"n":"";throw new Ht({max:i?`${i}${c}`:void 0,min:`${o}${c}`,signed:s,size:n,value:`${e}${c}`})}const a=`0x${(s&&r<0?(1n<<BigInt(n*8))+BigInt(r):r).toString(16)}`;return n?$(a,{size:n}):a}const Vt=new TextEncoder;function Yt(e,t={}){return typeof e=="number"||typeof e=="bigint"?Jt(e,t):typeof e=="boolean"?Xt(e,t):Z(e)?Fe(e,t):He(e,t)}function Xt(e,t={}){const s=new Uint8Array(1);return s[0]=Number(e),typeof t.size=="number"?(ee(s,{size:t.size}),$(s,{size:t.size})):s}const A={zero:48,nine:57,A:65,F:70,a:97,f:102};function qe(e){if(e>=A.zero&&e<=A.nine)return e-A.zero;if(e>=A.A&&e<=A.F)return e-(A.A-10);if(e>=A.a&&e<=A.f)return e-(A.a-10)}function Fe(e,t={}){let s=e;t.size&&(ee(s,{size:t.size}),s=$(s,{dir:"right",size:t.size}));let n=s.slice(2);n.length%2&&(n=`0${n}`);const r=n.length/2,i=new Uint8Array(r);for(let o=0,a=0;o<r;o++){const c=qe(n.charCodeAt(a++)),u=qe(n.charCodeAt(a++));if(c===void 0||u===void 0)throw new P(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);i[o]=c*16+u}return i}function Jt(e,t){const s=Wt(e,t);return Fe(s)}function He(e,t={}){const s=Vt.encode(e);return typeof t.size=="number"?(ee(s,{size:t.size}),$(s,{dir:"right",size:t.size})):s}const j=BigInt(2**32-1),Ke=BigInt(32);function Gt(e,t=!1){return t?{h:Number(e&j),l:Number(e>>Ke&j)}:{h:Number(e>>Ke&j)|0,l:Number(e&j)|0}}function Zt(e,t=!1){const s=e.length;let n=new Uint32Array(s),r=new Uint32Array(s);for(let i=0;i<s;i++){const{h:o,l:a}=Gt(e[i],t);[n[i],r[i]]=[o,a]}return[n,r]}const Qt=(e,t,s)=>e<<s|t>>>32-s,es=(e,t,s)=>t<<s|e>>>32-s,ts=(e,t,s)=>t<<s-32|e>>>64-s,ss=(e,t,s)=>e<<s-32|t>>>64-s;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ns(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function We(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function _(e,...t){if(!ns(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ve(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function rs(e,t){_(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function os(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ye(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const is=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function as(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function cs(e){for(let t=0;t<e.length;t++)e[t]=as(e[t]);return e}const Xe=is?e=>e:cs;function us(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Je(e){return typeof e=="string"&&(e=us(e)),_(e),e}class ls{}function fs(e){const t=n=>e().update(Je(n)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}const ds=BigInt(0),D=BigInt(1),hs=BigInt(2),ps=BigInt(7),gs=BigInt(256),ms=BigInt(113),Ge=[],Ze=[],Qe=[];for(let e=0,t=D,s=1,n=0;e<24;e++){[s,n]=[n,(2*s+3*n)%5],Ge.push(2*(5*n+s)),Ze.push((e+1)*(e+2)/2%64);let r=ds;for(let i=0;i<7;i++)t=(t<<D^(t>>ps)*ms)%gs,t&hs&&(r^=D<<(D<<BigInt(i))-D);Qe.push(r)}const et=Zt(Qe,!0),ys=et[0],ws=et[1],tt=(e,t,s)=>s>32?ts(e,t,s):Qt(e,t,s),st=(e,t,s)=>s>32?ss(e,t,s):es(e,t,s);function bs(e,t=24){const s=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let o=0;o<10;o++)s[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=s[c],l=s[c+1],b=tt(u,l,1)^s[a],g=st(u,l,1)^s[a+1];for(let w=0;w<50;w+=10)e[o+w]^=b,e[o+w+1]^=g}let r=e[2],i=e[3];for(let o=0;o<24;o++){const a=Ze[o],c=tt(r,i,a),u=st(r,i,a),l=Ge[o];r=e[l],i=e[l+1],e[l]=c,e[l+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=e[o+a];for(let a=0;a<10;a++)e[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}e[0]^=ys[n],e[1]^=ws[n]}Ye(s)}class te extends ls{constructor(t,s,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=s,this.outputLen=n,this.enableXOF=r,this.rounds=i,We(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=os(this.state)}clone(){return this._cloneInto()}keccak(){Xe(this.state32),bs(this.state32,this.rounds),Xe(this.state32),this.posOut=0,this.pos=0}update(t){Ve(this),t=Je(t),_(t);const{blockLen:s,state:n}=this,r=t.length;for(let i=0;i<r;){const o=Math.min(s-this.pos,r-i);for(let a=0;a<o;a++)n[this.pos++]^=t[i++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:s,pos:n,blockLen:r}=this;t[n]^=s,(s&128)!==0&&n===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){Ve(this,!1),_(t),this.finish();const s=this.state,{blockLen:n}=this;for(let r=0,i=t.length;r<i;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,i-r);t.set(s.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return We(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(rs(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Ye(this.state)}_cloneInto(t){const{blockLen:s,suffix:n,outputLen:r,rounds:i,enableXOF:o}=this;return t||(t=new te(s,n,r,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=n,t.outputLen=r,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Ss=(e,t,s)=>fs(()=>new te(t,e,s)),Es=Ss(1,136,256/8);function Ts(e,t){return Es(Z(e,{strict:!1})?Yt(e):e)}class Rs extends P{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class nt extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const s=super.get(t);return super.has(t)&&s!==void 0&&(this.delete(t),super.set(t,s)),s}set(t,s){if(super.set(t,s),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const se=new nt(8192);function rt(e,t){if(se.has(`${e}.${t}`))return se.get(`${e}.${t}`);const s=e.substring(2).toLowerCase(),n=Ts(He(s)),r=s.split("");for(let o=0;o<40;o+=2)n[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(n[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const i=`0x${r.join("")}`;return se.set(`${e}.${t}`,i),i}function v(e,t){if(!vs(e,{strict:!1}))throw new Rs({address:e});return rt(e,t)}const As=/^0x[a-fA-F0-9]{40}$/,ne=new nt(8192);function vs(e,t){const{strict:s=!0}=t??{},n=`${e}.${s}`;if(ne.has(n))return ne.get(n);const r=As.test(e)?e.toLowerCase()===e?!0:s?rt(e)===e:!0:!1;return ne.set(n,r),r}const Ps={chainId:Ue.chainId,address:v("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Is={chainId:Ce.chainId,address:v("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:"USDC",name:"USD Coin",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png"},Cs={chainId:ze.chainId,address:v("0x5425890298aed601595a70ab815c96711a31bc65"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Us={chainId:Me.chainId,address:v("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},ks={chainId:xe.chainId,address:v("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},xs={chainId:ke.chainId,address:v("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ds={chainId:De.chainId,address:v("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:"USDC",decimals:18,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Os={chainId:Ne.chainId,address:v("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ns={chainId:Oe.chainId,address:v("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ms={chainId:Be.chainId,address:"0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8",symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},ot={ARBITRUM_MAINNET:{...Ce,tokens:{[R.USDC]:Is},explorer:"https://arbiscan.io"},ARBITRUM_TESTNET:{...Ue,explorer:"https://sepolia.arbiscan.io",tokens:{[R.USDC]:Ps}},AVALANCHE_MAINNET:{...Me,tokens:{[R.USDC]:Us},explorer:"https://snowtrace.io"},AVALANCHE_TESTNET:{...ze,tokens:{[R.USDC]:Cs},explorer:"https://testnet.snowtrace.io"},BASE_MAINNET:{...ke,tokens:{[R.USDC]:xs},explorer:"https://basescan.org"},BASE_TESTNET:{...xe,tokens:{[R.USDC]:ks},explorer:"https://sepolia.basescan.org"},BSC_MAINNET:{...De,tokens:{[R.USDC]:Ds},explorer:"https://bscscan.com"},ETHEREUM_MAINNET:{...Oe,tokens:{[R.USDC]:Ns},explorer:"https://etherscan.io"},ETHEREUM_TESTNET:{...Ne,tokens:{[R.USDC]:Os},explorer:"https://sepolia.etherscan.io"},STARKNET_MAINNET:{...Be,tokens:{[R.USDC]:Ms},explorer:""}};var L=(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))(L||{}),re=(e=>(e.USDC="USDC",e))(re||{});const zs=e=>{const t=e?.trim().toUpperCase();if(ot[t])return ot[t]};function Bs(e,t){return zs(e)?.tokens[t]?.address}var oe=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(oe||{});class f{constructor({api_key:t,env:s,seesion_token:n}){this.api_key=t||"",this.sessionToken=n||"",this.env=s??oe.PRODUCTION}static async config(t){if(!f.app){if(!t)throw new Error("Please provide an api_key");f.app=new f(t)}return t&&(t.api_key!==void 0&&(f.app.api_key=t.api_key),t.seesion_token!==void 0&&(f.app.sessionToken=t.seesion_token),t.env!==void 0&&(f.app.env=t.env)),f.app}static getApiKey(){if(!f.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return f.app.api_key}static getSessionToken(){if(!f.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return f.app.sessionToken}static getEnv(){if(!f.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return f.app.env==="internal"?"staging":f.app.env}static getBaseUrl(){if(!f.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(f.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){if(!f.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const s=f.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",n=Number(t),r=t&&!isNaN(Number(t))&&n>0?"/pay/":"/deposit/",i=`${t&&!isNaN(Number(t))&&n>0?n*100:""}`;return s+r+i}}let ie=null;function $s(){ie=Lt.create({prefixUrl:f.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[e=>{const t=f.getSessionToken()||f.getApiKey();e.headers.set("Authorization",`Bearer ${t}`)}],afterResponse:[(e,t,s)=>s]},retry:{limit:2}})}function p(){return ie||$s(),ie}class js{async getById(t){return await p().get("intents/"+t).json()}async getForSender(t){return await p().get("intents/user/"+t).json()}async getForAddress(t){return await p().get("intents/address/"+t).json()}async getForSession(t){return await p().get("modal/sessions/intents/"+t).json()}async getAll(t){return await p().get("intents",{searchParams:t}).json()}async create(t){return await p().post("intents",{json:t}).json()}async createForSession(t){return await p().post("modal/sessions/intents",{json:t}).json()}async update(t,s){return await p().post("intents",{json:s}).json()}async triggerProcessing(t){return await p().post(`intents/${t}/trigger-processing`).json()}async triggerProcessingForSession(t){return await p().post(`modal/sessions/intents/${t}/process`).json()}}class _s{async getFromSpecificBridge(t){return await p().get("quotes/single",{searchParams:t}).json()}async getFromAllBridges(t){return await p().get("quotes/multiple",{searchParams:t}).json()}async getBestAcrossBridges(t){return await p().get("quotes/best",{searchParams:t}).json()}async getAll(t){return await p().get("quotes/multi-source",{searchParams:t}).json()}async getAllForSession(t){return await p().get("modal/sessions/quotes",{searchParams:t}).json()}}class Ls{async getOptimalRoutes(t){return await p().get("router/optimal-route",{searchParams:t}).json()}async getAllSupportedBridges(){return await p().get("router/supported-bridges/all").json()}async getSupportedBridges(t){return await p().get("router/supported-bridges/route",{searchParams:t}).json()}async getSupportedRoutes(t,s){return await p().get("router/supported-bridges/bridge/"+t,{searchParams:s}).json()}}class qs{async getSupported(t){return await p().get("chains",{searchParams:t}).json()}}class Fs{async getClientInfo(){return await p().get("client/auth/client-info").json()}async getClientInfoForSession(){return await p().get("modal/sessions/client").json()}}class Hs{getSessionToken(t){const s={recipient:t.recipient,tokenOut:Bs(L[t.destinationChain?.replace("_MAINNET","")],re[t.token]),destinationChain:L[t.destinationChain?.replace("_MAINNET","")],amount:t.amount};return p().post("modal/sessions",{json:s}).json().then(n=>({...n,amount:s.amount}))}}const Ks={router:new Ls,quotes:new _s,intents:new js,chains:new qs,client:new Fs,auth:new Hs};function it(e){var t,s,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(s=it(e[t]))&&(n&&(n+=" "),n+=s)}else for(s in e)e[s]&&(n&&(n+=" "),n+=s);return n}function Ws(){for(var e,t,s=0,n="",r=arguments.length;s<r;s++)(e=arguments[s])&&(t=it(e))&&(n&&(n+=" "),n+=t);return n}function Vs(e){const{amount:t,styles:s,isOpen:n,isPending:r,open:i,close:o,onCancel:a,onSuccess:c,session_url:u,sessionToken:l}=e,[b,g]=d.useState(0),[w,E]=d.useState(""),M=d.useRef(null);f.config({api_key:"",env:e.env==="internal"?"internal":"production"}),d.useEffect(()=>{const m=document.body.style.overflow;n?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=m||"";const y=T=>{T.data==="closed"&&(o(),a?.()),T.data==="completed"&&(window.setTimeout(o,2e3),c?.())};return window.addEventListener("message",y),()=>{document.body.style.overflow=m||"",window.removeEventListener("message",y)}},[n,a,c]),d.useEffect(()=>{if(!l)return;const m={type:"session",session_token:l,environment:f.getEnv()||oe.PRODUCTION,styles:s};M.current?.contentWindow?.postMessage(m,"https://app.chainrails.io"),M.current?.contentWindow?.postMessage(m,"https://chainrails-frontend-git-staging-horus-labs.vercel.app")},[l,b,n,s]);function h(){g(Math.random())}return k.jsxs("div",{className:Ws("payment-modal-wrapper",b===0||r?"loading":"not-loading",n?"open":"closed"),children:[(b===0||r)&&k.jsx("div",{role:"status",className:"payment-modal-loader",children:k.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[k.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"}),k.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"})]})}),k.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:f.getPayModalUrl(t)||void 0,onLoad:h,className:`payment-modal ${b===0||r?"invisible":"visible"}`,"data-id":t,ref:M},l)]})}const Ys=Symbol(),ae=Symbol(),O="a",at="f",ct="p",ut="c",lt="t",ce="h",N="w",ue="o",le="k";let Xs=(e,t)=>new Proxy(e,t);const fe=Object.getPrototypeOf,de=new WeakMap,ft=e=>e&&(de.has(e)?de.get(e):fe(e)===Object.prototype||fe(e)===Array.prototype),q=e=>typeof e=="object"&&e!==null,Js=e=>Object.values(Object.getOwnPropertyDescriptors(e)).some(t=>!t.configurable&&!t.writable),Gs=e=>{if(Array.isArray(e))return Array.from(e);const t=Object.getOwnPropertyDescriptors(e);return Object.values(t).forEach(s=>{s.configurable=!0}),Object.create(fe(e),t)},Zs=(e,t)=>{const s={[at]:t};let n=!1;const r=(a,c)=>{if(!n){let u=s[O].get(e);if(u||(u={},s[O].set(e,u)),a===N)u[N]=!0;else{let l=u[a];l||(l=new Set,u[a]=l),l.add(c)}}},i=()=>{n=!0,s[O].delete(e)},o={get(a,c){return c===ae?e:(r(le,c),dt(Reflect.get(a,c),s[O],s[ut],s[lt]))},has(a,c){return c===Ys?(i(),!0):(r(ce,c),Reflect.has(a,c))},getOwnPropertyDescriptor(a,c){return r(ue,c),Reflect.getOwnPropertyDescriptor(a,c)},ownKeys(a){return r(N),Reflect.ownKeys(a)}};return t&&(o.set=o.deleteProperty=()=>!1),[o,s]},he=e=>e[ae]||e,dt=(e,t,s,n)=>{if(!ft(e))return e;let r=n&&n.get(e);if(!r){const c=he(e);Js(c)?r=[c,Gs(c)]:r=[c],n?.set(e,r)}const[i,o]=r;let a=s&&s.get(i);return(!a||a[1][at]!==!!o)&&(a=Zs(i,!!o),a[1][ct]=Xs(o||i,a[0]),s&&s.set(i,a)),a[1][O]=t,a[1][ut]=s,a[1][lt]=n,a[1][ct]},Qs=(e,t)=>{const s=Reflect.ownKeys(e),n=Reflect.ownKeys(t);return s.length!==n.length||s.some((r,i)=>r!==n[i])},ht=(e,t,s,n,r=Object.is)=>{if(r(e,t))return!1;if(!q(e)||!q(t))return!0;const i=s.get(he(e));if(!i)return!0;if(n){if(n.get(e)===t)return!1;n.set(e,t)}let o=null;for(const a of i[ce]||[])if(o=Reflect.has(e,a)!==Reflect.has(t,a),o)return o;if(i[N]===!0){if(o=Qs(e,t),o)return o}else for(const a of i[ue]||[]){const c=!!Reflect.getOwnPropertyDescriptor(e,a),u=!!Reflect.getOwnPropertyDescriptor(t,a);if(o=c!==u,o)return o}for(const a of i[le]||[])if(o=ht(e[a],t[a],s,n,r),o)return o;if(o===null)throw new Error("invalid used");return o},en=e=>ft(e)&&e[ae]||null,pt=(e,t=!0)=>{de.set(e,t)},tn=(e,t,s)=>{const n=[],r=new WeakSet,i=(o,a)=>{var c,u,l;if(r.has(o))return;q(o)&&r.add(o);const b=q(o)&&t.get(he(o));if(b){if((c=b[ce])===null||c===void 0||c.forEach(g=>{const w=`:has(${String(g)})`;n.push(a?[...a,w]:[w])}),b[N]===!0){const g=":ownKeys";n.push(a?[...a,g]:[g])}else(u=b[ue])===null||u===void 0||u.forEach(g=>{const w=`:hasOwn(${String(g)})`;n.push(a?[...a,w]:[w])});(l=b[le])===null||l===void 0||l.forEach(g=>{"value"in(Object.getOwnPropertyDescriptor(o,g)||{})&&i(o[g],a?[...a,g]:[g])})}else a&&n.push(a)};return i(e),n},F={},pe=e=>typeof e=="object"&&e!==null,sn=e=>pe(e)&&!ge.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)&&!(e instanceof Promise),gt=(e,t)=>{const s=mt.get(e);if(s?.[0]===t)return s[1];const n=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return pt(n,!0),mt.set(e,[t,n]),Reflect.ownKeys(e).forEach(r=>{if(Object.getOwnPropertyDescriptor(n,r))return;const i=Reflect.get(e,r),{enumerable:o}=Reflect.getOwnPropertyDescriptor(e,r),a={value:i,enumerable:o,configurable:!0};if(ge.has(i))pt(i,!1);else if(U.has(i)){const[c,u]=U.get(i);a.value=gt(c,u())}Object.defineProperty(n,r,a)}),Object.preventExtensions(n)},nn=(e,t,s,n)=>({deleteProperty(r,i){const o=Reflect.get(r,i);s(i);const a=Reflect.deleteProperty(r,i);return a&&n(["delete",[i],o]),a},set(r,i,o,a){const c=!e()&&Reflect.has(r,i),u=Reflect.get(r,i,a);if(c&&(yt(u,o)||H.has(o)&&yt(u,H.get(o))))return!0;s(i),pe(o)&&(o=en(o)||o);const l=!U.has(o)&&on(o)?wt(o):o;return t(i,l),Reflect.set(r,i,l,a),n(["set",[i],o,u]),!0}}),U=new WeakMap,ge=new WeakSet,mt=new WeakMap,me=[1],H=new WeakMap;let yt=Object.is,rn=(e,t)=>new Proxy(e,t),on=sn,an=gt,cn=nn;function wt(e={}){if(!pe(e))throw new Error("object required");const t=H.get(e);if(t)return t;let s=me[0];const n=new Set,r=(h,m=++me[0])=>{s!==m&&(i=s=m,n.forEach(y=>y(h,m)))};let i=s;const o=(h=me[0])=>(i!==h&&(i=h,c.forEach(([m])=>{const y=m[1](h);y>s&&(s=y)})),s),a=h=>(m,y)=>{const T=[...m];T[1]=[h,...T[1]],r(T,y)},c=new Map,u=(h,m)=>{const y=!ge.has(m)&&U.get(m);if(y){if((F?"production":void 0)!=="production"&&c.has(h))throw new Error("prop listener already exists");if(n.size){const T=y[2](a(h));c.set(h,[y,T])}else c.set(h,[y])}},l=h=>{var m;const y=c.get(h);y&&(c.delete(h),(m=y[1])==null||m.call(y))},b=h=>(n.add(h),n.size===1&&c.forEach(([y,T],K)=>{if((F?"production":void 0)!=="production"&&T)throw new Error("remove already exists");const mn=y[2](a(K));c.set(K,[y,mn])}),()=>{n.delete(h),n.size===0&&c.forEach(([y,T],K)=>{T&&(T(),c.set(K,[y]))})});let g=!0;const w=cn(()=>g,u,l,r),E=rn(e,w);H.set(e,E);const M=[e,o,b];return U.set(E,M),Reflect.ownKeys(e).forEach(h=>{const m=Object.getOwnPropertyDescriptor(e,h);"value"in m&&m.writable&&(E[h]=e[h])}),g=!1,E}function un(e,t,s){const n=U.get(e);(F?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let r;const i=[],o=n[2];let a=!1;const u=o(l=>{i.push(l),r||(r=Promise.resolve().then(()=>{r=void 0,a&&t(i.splice(0))}))});return a=!0,()=>{a=!1,u()}}function bt(e){const t=U.get(e);(F?"production":void 0)!=="production"&&!t&&console.warn("Please use proxy object");const[s,n]=t;return an(s,n())}const ln={},fn=(e,t)=>{const s=d.useRef(void 0);d.useEffect(()=>{s.current=tn(e,t)}),d.useDebugValue(s.current)},dn=new WeakMap;function hn(e,t){const n=d.useMemo(()=>e&&new WeakMap,[e]),r=d.useRef(void 0);let i=!0;const o=d.useSyncExternalStore(d.useCallback(c=>{const u=un(e,c);return c(),u},[e,void 0]),()=>{const c=bt(e);try{if(!i&&r.current&&!ht(r.current,c,n,new WeakMap))return r.current}catch{}return c},()=>bt(e));i=!1,d.useLayoutEffect(()=>{r.current=o}),(ln?"production":void 0)!=="production"&&fn(o,n);const a=d.useMemo(()=>new WeakMap,[]);return dt(o,n,a,dn)}const I=wt({data:null,isPending:!1,error:null});function pn({session_url:e,onCancel:t,onSuccess:s}){const n=hn(I),[r,i]=d.useState(!1),[o,a]=d.useState(Date.now()),c=n?.data?.sessionToken,u=n?.data?.amount;function l(){c||window.setTimeout(()=>{c&&i(!0)},1e3),i(!0)}function b(){i(!1)}const g=()=>{const w=Date.now();I.isPending=!0,I.error=null,I.data=null,fetch(e,{headers:{"Content-Type":"application/json"}}).then(E=>E.json()).then(E=>{w<o||(I.data=E,I.isPending=!1,a(w))}).catch(E=>{w<o||(I.error=E?.toString(),I.isPending=!1,a(w))})};return d.useEffect(()=>{g()},[e]),{sessionToken:c,amount:u,isOpen:r,session_url:e,open:l,close:b,refetch:g,onSuccess:s,onCancel:t}}function gn({sessionToken:e,amount:t,onCancel:s,onSuccess:n}){const[r,i]=d.useState(!1),[o,a]=d.useState(e),[c,u]=d.useState(t);function l({sessionToken:w,amount:E}){a(w),u(E)}d.useEffect(()=>{a(e)},[e]);function b(){o||window.setTimeout(()=>{o&&i(!0)},1e3),i(!0)}function g(){i(!1)}return{sessionToken:o,updateSession:l,amount:c,isOpen:r,open:b,close:g,onSuccess:n,onCancel:s}}S.Chainrails=f,S.PaymentModal=Vs,S.chains=L,S.crapi=Ks,S.tokens=re,S.usePaymentModal=gn,S.usePaymentSession=pn,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "sideEffects": [
4
4
  "**/*.css"
5
5
  ],
6
- "version": "0.2.17",
6
+ "version": "0.2.18",
7
7
  "description": "",
8
8
  "license": "MIT",
9
9
  "repository": {