@openrails/billing-ui 0.253.0 → 0.254.0

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.
Files changed (42) hide show
  1. package/dist/admin/lib/api/types.d.ts +1 -1
  2. package/dist/admin/messages.d.ts +10 -0
  3. package/dist/{admin-catalog-Bsxo2gyS.js → admin-catalog-rrFZd5N8.js} +2 -2
  4. package/dist/{admin-catalog-Bsxo2gyS.js.map → admin-catalog-rrFZd5N8.js.map} +1 -1
  5. package/dist/{admin-price-detail-ByCmrx_W.js → admin-price-detail-Bwk9PXHP.js} +2 -2
  6. package/dist/{admin-price-detail-ByCmrx_W.js.map → admin-price-detail-Bwk9PXHP.js.map} +1 -1
  7. package/dist/{admin-price-wizard-m7Qjhq6W.js → admin-price-wizard-ByD7j8mB.js} +2 -2
  8. package/dist/admin-price-wizard-ByD7j8mB.js.map +1 -0
  9. package/dist/{admin-settings-BIUgvclv.js → admin-settings-D_8L1Hho.js} +101 -76
  10. package/dist/admin-settings-D_8L1Hho.js.map +1 -0
  11. package/dist/admin.js +15 -5
  12. package/dist/admin.js.map +1 -1
  13. package/dist/client/generated/error-codes.d.ts +1 -1
  14. package/dist/client/generated/wire.d.ts +51 -20
  15. package/dist/{client-Di2a3HGM.js → client-B301IAQD.js} +3 -3
  16. package/dist/client-B301IAQD.js.map +1 -0
  17. package/dist/client.js +1 -1
  18. package/dist/components/platform-card-form.d.ts +3 -1
  19. package/dist/{hooks-Bx0aLyvy.js → hooks-DARbMTwv.js} +69 -59
  20. package/dist/hooks-DARbMTwv.js.map +1 -0
  21. package/dist/index.js +302 -270
  22. package/dist/index.js.map +1 -1
  23. package/dist/locales/de.js +1 -0
  24. package/dist/locales/de.js.map +1 -1
  25. package/dist/locales/en.d.ts +1 -0
  26. package/dist/locales/en.js +1 -0
  27. package/dist/locales/en.js.map +1 -1
  28. package/dist/locales/es.js +1 -0
  29. package/dist/locales/es.js.map +1 -1
  30. package/dist/locales/ja.js +1 -0
  31. package/dist/locales/ja.js.map +1 -1
  32. package/dist/locales/ko.js +1 -0
  33. package/dist/locales/ko.js.map +1 -1
  34. package/dist/locales/zh.js +1 -0
  35. package/dist/locales/zh.js.map +1 -1
  36. package/dist/psp.d.ts +1 -1
  37. package/dist/react.js +1 -1
  38. package/package.json +1 -1
  39. package/dist/admin-price-wizard-m7Qjhq6W.js.map +0 -1
  40. package/dist/admin-settings-BIUgvclv.js.map +0 -1
  41. package/dist/client-Di2a3HGM.js.map +0 -1
  42. package/dist/hooks-Bx0aLyvy.js.map +0 -1
package/dist/index.js CHANGED
@@ -11,8 +11,8 @@ if (typeof document !== "undefined") {
11
11
  if (__orckStyle.textContent !== __orckCss) __orckStyle.textContent = __orckCss;
12
12
  }
13
13
 
14
- import { A as e, C as t, E as n, O as r, S as i, _ as a, a as o, b as s, d as c, f as l, g as u, h as d, p as f, s as p, v as m, w as h, x as g, y as _ } from "./client-Di2a3HGM.js";
15
- import { _ as v, a as y, b, f as x, g as S, h as C, i as w, l as T, m as E, n as D, o as O, p as k, r as A, s as ee, t as te, v as ne, x as re, y as j } from "./hooks-Bx0aLyvy.js";
14
+ import { A as e, C as t, E as n, O as r, S as i, _ as a, a as o, b as s, d as c, f as l, g as u, h as d, p as f, s as p, v as m, w as h, x as g, y as _ } from "./client-B301IAQD.js";
15
+ import { _ as v, a as y, b, f as x, g as S, h as C, i as w, l as T, m as E, n as D, o as O, p as k, r as A, s as ee, t as te, v as ne, x as re, y as j } from "./hooks-DARbMTwv.js";
16
16
  import { t as M } from "./index-rGw83t5v-BE6naeQR.js";
17
17
  import { z as N } from "zod";
18
18
  import * as P from "react";
@@ -1182,19 +1182,112 @@ function Ut() {
1182
1182
  });
1183
1183
  }
1184
1184
  //#endregion
1185
+ //#region src/components/platform-card-form.tsx
1186
+ function Wt({ publicKey: e, submitLabel: t, disabled: n, onTokenized: r, purpose: i = "payment", defaultCountry: a }) {
1187
+ let o = P.useId().replace(/[^a-zA-Z0-9-]/g, ""), s = P.useMemo(() => ({
1188
+ number: `bt-${o}-number`,
1189
+ expiry: `bt-${o}-expiry`,
1190
+ cvv: `bt-${o}-cvv`
1191
+ }), [o]), [c, l] = P.useState(() => ({
1192
+ ...Dt,
1193
+ country: kt(a)
1194
+ })), [u, d] = P.useState(!1), [f, p] = P.useState(!1), [m, h] = P.useState(!1), [g, _] = P.useState(!1), [v, y] = P.useState(), b = P.useRef(void 0), x = P.useRef(void 0), S = P.useRef(!1), C = P.useRef({
1195
+ generation: 0,
1196
+ disabled: n
1197
+ });
1198
+ P.useLayoutEffect(() => {
1199
+ C.current = {
1200
+ generation: C.current.generation + 1,
1201
+ disabled: n
1202
+ };
1203
+ }, [e, n]), P.useEffect(() => {
1204
+ let t = !0, n = M(e), r = n.createElement("cardNumber"), i = n.createElement("expiry"), a = n.createElement("cvv");
1205
+ return Promise.all([
1206
+ r.mount(`#${s.number}`),
1207
+ i.mount(`#${s.expiry}`),
1208
+ a.mount(`#${s.cvv}`)
1209
+ ]).then(() => {
1210
+ t && (x.current = async () => (await n.tokenIntents.create({
1211
+ type: "card",
1212
+ data: {
1213
+ number: r,
1214
+ expiration_month: i,
1215
+ expiration_year: i,
1216
+ cvc: a
1217
+ }
1218
+ })).id, d(!0));
1219
+ }, () => {
1220
+ t && y("Secure card entry could not be loaded.");
1221
+ }), () => {
1222
+ t = !1, C.current.generation++, x.current = void 0, n.destroy();
1223
+ };
1224
+ }, [e, s]);
1225
+ let w = i === "setup" ? "Retry saving card" : "Retry payment", T = i === "setup" ? "The card save is not confirmed. Retry to check the same card." : "The payment result is not confirmed. Retry to check the same payment.", E = async (e) => {
1226
+ if (e.preventDefault(), n || S.current || m || !x.current) return;
1227
+ let t = Tt.safeParse(c);
1228
+ if (!t.success) {
1229
+ y(t.error.issues[0]?.message ?? "Check the billing details");
1230
+ return;
1231
+ }
1232
+ S.current = !0, p(!0), y(void 0);
1233
+ let i = C.current.generation;
1234
+ try {
1235
+ let e = b.current ?? {
1236
+ payment_token: await x.current(),
1237
+ ...t.data
1238
+ };
1239
+ if (C.current.generation !== i || C.current.disabled) return;
1240
+ b.current = e, await r(e) ? h(!0) : b.current = void 0, _(!1);
1241
+ } catch {
1242
+ let e = !!b.current;
1243
+ _(e), y(e ? T : "Check your card details and try again.");
1244
+ } finally {
1245
+ S.current = !1, p(!1);
1246
+ }
1247
+ };
1248
+ return /* @__PURE__ */ L("form", {
1249
+ "aria-label": i === "setup" ? "Secure platform card setup" : "Secure platform card payment",
1250
+ className: "grid gap-4",
1251
+ onSubmit: (e) => void E(e),
1252
+ children: [
1253
+ /* @__PURE__ */ I(It, {
1254
+ idPrefix: `bt-${o}`,
1255
+ value: c,
1256
+ onChange: l,
1257
+ disabled: n || f || g || m
1258
+ }),
1259
+ /* @__PURE__ */ I(Bt, {
1260
+ ids: s,
1261
+ preview: !1
1262
+ }),
1263
+ v ? /* @__PURE__ */ I("p", {
1264
+ role: "alert",
1265
+ className: "text-sm text-destructive",
1266
+ children: v
1267
+ }) : null,
1268
+ /* @__PURE__ */ I(Q, {
1269
+ label: g ? w : t,
1270
+ processing: f,
1271
+ disabled: n || m || !u
1272
+ }),
1273
+ /* @__PURE__ */ I(Ut, {})
1274
+ ]
1275
+ });
1276
+ }
1277
+ //#endregion
1185
1278
  //#region src/lib/stripe.ts
1186
- var Wt = /* @__PURE__ */ new Map();
1187
- function Gt(e) {
1188
- let t = Wt.get(e);
1279
+ var Gt = /* @__PURE__ */ new Map();
1280
+ function Kt(e) {
1281
+ let t = Gt.get(e);
1189
1282
  return t || (t = import("@stripe/stripe-js").then(({ loadStripe: t }) => t(e)).then((e) => {
1190
1283
  if (!e) throw Error("Stripe could not be loaded.");
1191
1284
  return e;
1192
- }), t.catch(() => Wt.delete(e)), Wt.set(e, t)), t;
1285
+ }), t.catch(() => Gt.delete(e)), Gt.set(e, t)), t;
1193
1286
  }
1194
1287
  //#endregion
1195
1288
  //#region src/lib/collect.ts
1196
- var Kt = "openrails-collectjs", qt = 3e4, Jt = /* @__PURE__ */ new WeakMap();
1197
- function Yt(e) {
1289
+ var qt = "openrails-collectjs", Jt = 3e4, Yt = /* @__PURE__ */ new WeakMap();
1290
+ function Xt(e) {
1198
1291
  try {
1199
1292
  let t = new URL(e);
1200
1293
  return t.protocol !== "https:" || t.username || t.password || t.hash ? void 0 : t.toString();
@@ -1202,9 +1295,9 @@ function Yt(e) {
1202
1295
  return;
1203
1296
  }
1204
1297
  }
1205
- function Xt(e) {
1298
+ function Zt(e) {
1206
1299
  if (!e) return "";
1207
- let t = Zt(e);
1300
+ let t = Qt(e);
1208
1301
  if (t) return t;
1209
1302
  try {
1210
1303
  let t = document.createElement("canvas").getContext("2d");
@@ -1216,7 +1309,7 @@ function Xt(e) {
1216
1309
  return "";
1217
1310
  }
1218
1311
  }
1219
- function Zt(e) {
1312
+ function Qt(e) {
1220
1313
  let t = /^oklch\(\s*([\d.]+%?)\s+([\d.]+)\s+([\d.]+)(?:deg)?\s*(?:\/\s*([\d.]+%?)\s*)?\)$/i.exec(e.trim());
1221
1314
  if (!t) return "";
1222
1315
  let n = (e) => e.endsWith("%") ? parseFloat(e) / 100 : parseFloat(e), r = n(t[1]), i = parseFloat(t[2]), a = parseFloat(t[3]) * Math.PI / 180, o = t[4] === void 0 ? 1 : n(t[4]), s = i * Math.cos(a), c = i * Math.sin(a), l = (r + .3963377774 * s + .2158037573 * c) ** 3, u = (r - .1055613458 * s - .0638541728 * c) ** 3, d = (r - .0894841775 * s - 1.291485548 * c) ** 3, f = (e) => {
@@ -1225,23 +1318,23 @@ function Zt(e) {
1225
1318
  }, p = f(4.0767416621 * l - 3.3077115913 * u + .2309699292 * d), m = f(-1.2684380046 * l + 2.6097574011 * u - .3413193965 * d), h = f(-.0041960863 * l - .7034186147 * u + 1.707614701 * d);
1226
1319
  return o >= 1 ? `rgb(${p}, ${m}, ${h})` : `rgba(${p}, ${m}, ${h}, ${o})`;
1227
1320
  }
1228
- function Qt(e) {
1321
+ function $t(e) {
1229
1322
  return e.startsWith("preview_");
1230
1323
  }
1231
- var $t = {
1324
+ var en = {
1232
1325
  ccnumber: "number",
1233
1326
  ccexp: "expiry",
1234
1327
  cvv: "cvv"
1235
- }, en = {
1328
+ }, tn = {
1236
1329
  number: "Enter a valid card number",
1237
1330
  expiry: "Enter a valid expiry date",
1238
1331
  cvv: "Enter a valid security code"
1239
1332
  };
1240
- function tn(e) {
1241
- let t = e.enabled && Qt(e.tokenizationKey), [n, r] = P.useState(!1), [i, a] = P.useState(), [o, s] = P.useState({}), c = P.useRef(void 0), l = P.useRef(void 0), { number: u, expiry: d, cvv: f } = e.selectors;
1333
+ function nn(e) {
1334
+ let t = e.enabled && $t(e.tokenizationKey), [n, r] = P.useState(!1), [i, a] = P.useState(), [o, s] = P.useState({}), c = P.useRef(void 0), l = P.useRef(void 0), { number: u, expiry: d, cvv: f } = e.selectors;
1242
1335
  P.useEffect(() => {
1243
1336
  if (!e.enabled || t || !e.tokenizationKey || !e.scriptURL || typeof document > "u") return;
1244
- let n = Yt(e.scriptURL);
1337
+ let n = Xt(e.scriptURL);
1245
1338
  if (!n) {
1246
1339
  Promise.resolve().then(() => {
1247
1340
  r(!1), a("Card fields failed to load");
@@ -1269,7 +1362,7 @@ function tn(e) {
1269
1362
  p(() => {
1270
1363
  r(!1), a(void 0), s({});
1271
1364
  });
1272
- let t = document.querySelector(u), n = t ? window.getComputedStyle(t) : void 0, i = Xt(n?.backgroundColor), l = i && i !== "transparent" && i !== "rgba(0, 0, 0, 0)" ? i : "#ffffff", m = Xt(n?.color) || "#18181b", h = Xt(n?.getPropertyValue("--muted-foreground").trim()) || m;
1365
+ let t = document.querySelector(u), n = t ? window.getComputedStyle(t) : void 0, i = Zt(n?.backgroundColor), l = i && i !== "transparent" && i !== "rgba(0, 0, 0, 0)" ? i : "#ffffff", m = Zt(n?.color) || "#18181b", h = Zt(n?.getPropertyValue("--muted-foreground").trim()) || m;
1273
1366
  try {
1274
1367
  e.configure({
1275
1368
  variant: "inline",
@@ -1284,7 +1377,7 @@ function tn(e) {
1284
1377
  color: m
1285
1378
  },
1286
1379
  placeholderCss: { color: h },
1287
- invalidCss: { color: Xt(n?.getPropertyValue("--destructive").trim()) || "#dc2626" },
1380
+ invalidCss: { color: Zt(n?.getPropertyValue("--destructive").trim()) || "#dc2626" },
1288
1381
  focusCss: { outline: "none" },
1289
1382
  fields: {
1290
1383
  ccnumber: {
@@ -1305,16 +1398,16 @@ function tn(e) {
1305
1398
  },
1306
1399
  fieldsAvailableCallback: () => p(() => r(!0)),
1307
1400
  validationCallback: (e, t, n) => {
1308
- let r = $t[e];
1401
+ let r = en[e];
1309
1402
  r && p(() => s((e) => ({
1310
1403
  ...e,
1311
1404
  [r]: {
1312
1405
  valid: t,
1313
- message: t ? void 0 : n && n !== "Field is empty" ? `${en[r]}.` : en[r]
1406
+ message: t ? void 0 : n && n !== "Field is empty" ? `${tn[r]}.` : tn[r]
1314
1407
  }
1315
1408
  })));
1316
1409
  },
1317
- timeoutDuration: qt,
1410
+ timeoutDuration: Jt,
1318
1411
  timeoutCallback: () => {
1319
1412
  let e = c.current;
1320
1413
  c.current = void 0, e && (window.clearTimeout(e.timer), e.reject(/* @__PURE__ */ Error("Card entry timed out")));
@@ -1327,12 +1420,12 @@ function tn(e) {
1327
1420
  } catch {
1328
1421
  p(() => a("Card fields failed to load"));
1329
1422
  }
1330
- }, h = document.getElementById(Kt);
1331
- if (h instanceof HTMLScriptElement && (h.src !== n || Jt.get(h) === "failed") && (h.remove(), h.src !== n && Reflect.deleteProperty(window, "CollectJS"), h = null), h instanceof HTMLScriptElement) {
1423
+ }, h = document.getElementById(qt);
1424
+ if (h instanceof HTMLScriptElement && (h.src !== n || Yt.get(h) === "failed") && (h.remove(), h.src !== n && Reflect.deleteProperty(window, "CollectJS"), h = null), h instanceof HTMLScriptElement) {
1332
1425
  if (window.CollectJS) return m(), () => {
1333
1426
  o = !0;
1334
1427
  };
1335
- if (Jt.get(h) === "loaded") return p(() => a("Card fields failed to load")), () => {
1428
+ if (Yt.get(h) === "loaded") return p(() => a("Card fields failed to load")), () => {
1336
1429
  o = !0;
1337
1430
  };
1338
1431
  let e = () => p(() => a("Card fields failed to load"));
@@ -1341,10 +1434,10 @@ function tn(e) {
1341
1434
  };
1342
1435
  }
1343
1436
  let g = document.createElement("script");
1344
- return g.id = Kt, g.src = n, g.async = !0, g.dataset.tokenizationKey = e.tokenizationKey, Jt.set(g, "loading"), g.onload = () => {
1345
- Jt.set(g, "loaded"), m();
1437
+ return g.id = qt, g.src = n, g.async = !0, g.dataset.tokenizationKey = e.tokenizationKey, Yt.set(g, "loading"), g.onload = () => {
1438
+ Yt.set(g, "loaded"), m();
1346
1439
  }, g.onerror = () => {
1347
- Jt.set(g, "failed"), p(() => a("Card fields failed to load"));
1440
+ Yt.set(g, "failed"), p(() => a("Card fields failed to load"));
1348
1441
  }, document.head.appendChild(g), () => {
1349
1442
  o = !0;
1350
1443
  };
@@ -1410,7 +1503,7 @@ function tn(e) {
1410
1503
  tokenize: p
1411
1504
  };
1412
1505
  }
1413
- function nn(e) {
1506
+ function rn(e) {
1414
1507
  let t = (e?.number ?? "").replace(/\D/g, ""), n = (e?.exp ?? "").replace(/\D/g, "");
1415
1508
  return {
1416
1509
  ...t.length >= 4 ? { last_four: t.slice(-4) } : {},
@@ -1420,8 +1513,8 @@ function nn(e) {
1420
1513
  }
1421
1514
  //#endregion
1422
1515
  //#region src/lib/stripe-appearance.ts
1423
- function rn(e) {
1424
- let t = window.getComputedStyle(e), n = (e) => Xt(t.getPropertyValue(e).trim()) || void 0;
1516
+ function an(e) {
1517
+ let t = window.getComputedStyle(e), n = (e) => Zt(t.getPropertyValue(e).trim()) || void 0;
1425
1518
  return {
1426
1519
  theme: e.closest(".dark") ? "night" : "stripe",
1427
1520
  variables: {
@@ -1456,7 +1549,7 @@ function rn(e) {
1456
1549
  }
1457
1550
  //#endregion
1458
1551
  //#region src/components/stripe-card.tsx
1459
- var an = P.forwardRef(function({ psp: e, client: t, defaultCountry: n, onCompleteChange: r, unavailableMessage: i, verificationPendingMessage: a }, o) {
1552
+ var on = P.forwardRef(function({ psp: e, client: t, defaultCountry: n, onCompleteChange: r, unavailableMessage: i, verificationPendingMessage: a }, o) {
1460
1553
  let [s, c] = P.useState(), l = P.useRef(null), u = P.useRef(null), d = P.useRef(r);
1461
1554
  P.useEffect(() => {
1462
1555
  d.current = r;
@@ -1465,13 +1558,13 @@ var an = P.forwardRef(function({ psp: e, client: t, defaultCountry: n, onComplet
1465
1558
  return P.useEffect(() => {
1466
1559
  if (!f || !l.current) return;
1467
1560
  let e = !1, t;
1468
- return Gt(f).then((r) => {
1561
+ return Kt(f).then((r) => {
1469
1562
  if (e || !l.current) return;
1470
1563
  let i = r.elements({
1471
1564
  mode: "setup",
1472
1565
  paymentMethodTypes: ["card"],
1473
1566
  paymentMethodCreation: "manual",
1474
- appearance: rn(l.current)
1567
+ appearance: an(l.current)
1475
1568
  }), a = i.create("payment", {
1476
1569
  wallets: {
1477
1570
  link: "never",
@@ -1539,12 +1632,12 @@ var an = P.forwardRef(function({ psp: e, client: t, defaultCountry: n, onComplet
1539
1632
  children: s
1540
1633
  }) : null]
1541
1634
  });
1542
- }), on = {
1635
+ }), sn = {
1543
1636
  number: "Enter a valid card number",
1544
1637
  expiry: "Enter a valid expiry date",
1545
1638
  cvv: "Enter a valid security code"
1546
1639
  }, $ = (e) => e.replace(/\D/g, "");
1547
- function sn(e) {
1640
+ function cn(e) {
1548
1641
  let t = 0;
1549
1642
  for (let n = 0; n < e.length; n++) {
1550
1643
  let r = e.charCodeAt(e.length - 1 - n) - 48;
@@ -1552,23 +1645,23 @@ function sn(e) {
1552
1645
  }
1553
1646
  return t % 10 == 0;
1554
1647
  }
1555
- function cn(e) {
1648
+ function ln(e) {
1556
1649
  let t = $(e), n = (e) => t.length >= e ? Number(t.slice(0, e)) : -1;
1557
1650
  return n(1) === 4 ? "visa" : n(2) === 34 || n(2) === 37 ? "amex" : n(2) >= 51 && n(2) <= 55 || n(4) >= 2221 && n(4) <= 2720 ? "mastercard" : n(4) === 6011 || n(2) === 65 || n(3) >= 644 && n(3) <= 649 ? "discover" : n(2) === 35 ? "jcb" : n(2) === 36 || n(2) === 38 || n(3) >= 300 && n(3) <= 305 ? "diners" : "";
1558
1651
  }
1559
- function ln(e) {
1652
+ function un(e) {
1560
1653
  let t = $(e).slice(0, 19);
1561
- return cn(t) === "amex" ? [
1654
+ return ln(t) === "amex" ? [
1562
1655
  t.slice(0, 4),
1563
1656
  t.slice(4, 10),
1564
1657
  t.slice(10, 15)
1565
1658
  ].filter(Boolean).join(" ") : t.replace(/(\d{4})(?=\d)/g, "$1 ");
1566
1659
  }
1567
- function un(e) {
1660
+ function dn(e) {
1568
1661
  let t = $(e).slice(0, 4);
1569
1662
  return t.length > 2 ? `${t.slice(0, 2)} / ${t.slice(2)}` : t;
1570
1663
  }
1571
- function dn(e, t) {
1664
+ function fn(e, t) {
1572
1665
  let n = $(e);
1573
1666
  if (n.length !== 4 && n.length !== 6) return null;
1574
1667
  let r = Number(n.slice(0, 2)), i = n.length === 4 ? 2e3 + Number(n.slice(2)) : Number(n.slice(2));
@@ -1577,15 +1670,15 @@ function dn(e, t) {
1577
1670
  year: i
1578
1671
  };
1579
1672
  }
1580
- function fn(e, t = /* @__PURE__ */ new Date()) {
1673
+ function pn(e, t = /* @__PURE__ */ new Date()) {
1581
1674
  let n = {}, r = $(e.number);
1582
- (r.length < 12 || r.length > 19 || !sn(r)) && (n.number = on.number), dn(e.expiry, t) || (n.expiry = on.expiry);
1583
- let i = $(e.cvc), a = cn(r) === "amex" ? 4 : 3;
1584
- return (i !== e.cvc.trim() || i.length !== a && i.length !== 4) && (n.cvv = on.cvv), n;
1675
+ (r.length < 12 || r.length > 19 || !cn(r)) && (n.number = sn.number), fn(e.expiry, t) || (n.expiry = sn.expiry);
1676
+ let i = $(e.cvc), a = ln(r) === "amex" ? 4 : 3;
1677
+ return (i !== e.cvc.trim() || i.length !== a && i.length !== 4) && (n.cvv = sn.cvv), n;
1585
1678
  }
1586
- function pn(e, t = /* @__PURE__ */ new Date()) {
1587
- if (Object.keys(fn(e, t)).length > 0) return null;
1588
- let n = dn(e.expiry, t);
1679
+ function mn(e, t = /* @__PURE__ */ new Date()) {
1680
+ if (Object.keys(pn(e, t)).length > 0) return null;
1681
+ let n = fn(e.expiry, t);
1589
1682
  return {
1590
1683
  number: $(e.number),
1591
1684
  exp_month: n.month,
@@ -1593,16 +1686,16 @@ function pn(e, t = /* @__PURE__ */ new Date()) {
1593
1686
  cvc: $(e.cvc)
1594
1687
  };
1595
1688
  }
1596
- var mn = {
1689
+ var hn = {
1597
1690
  number: "",
1598
1691
  expiry: "",
1599
1692
  cvc: ""
1600
1693
  };
1601
- function hn() {
1602
- let [e, t] = P.useState(mn), [n, r] = P.useState({}), i = fn(e), a = {};
1694
+ function gn() {
1695
+ let [e, t] = P.useState(hn), [n, r] = P.useState({}), i = pn(e), a = {};
1603
1696
  n.number && i.number && (a.number = i.number), n.expiry && i.expiry && (a.expiry = i.expiry), n.cvc && i.cvv && (a.cvv = i.cvv);
1604
1697
  let o = P.useCallback(() => {
1605
- t(mn), r({});
1698
+ t(hn), r({});
1606
1699
  }, []);
1607
1700
  return {
1608
1701
  input: e,
@@ -1610,14 +1703,14 @@ function hn() {
1610
1703
  valid: Object.keys(i).length === 0,
1611
1704
  change: (e, n) => t((t) => ({
1612
1705
  ...t,
1613
- [e]: e === "number" ? ln(n) : e === "expiry" ? un(n) : $(n).slice(0, 4)
1706
+ [e]: e === "number" ? un(n) : e === "expiry" ? dn(n) : $(n).slice(0, 4)
1614
1707
  })),
1615
1708
  leave: (e) => r((t) => ({
1616
1709
  ...t,
1617
1710
  [e]: !0
1618
1711
  })),
1619
1712
  take: () => {
1620
- let t = pn(e);
1713
+ let t = mn(e);
1621
1714
  return t ? (o(), t) : (r({
1622
1715
  number: !0,
1623
1716
  expiry: !0,
@@ -1629,7 +1722,7 @@ function hn() {
1629
1722
  }
1630
1723
  //#endregion
1631
1724
  //#region src/tokenized-card-form.tsx
1632
- function gn({ tokenizationKey: e, tokenizationURL: t, onTokenized: n, submitLabel: r = "Save card", disabled: i = !1, defaultCountry: a, appearance: o, className: s }) {
1725
+ function _n({ tokenizationKey: e, tokenizationURL: t, onTokenized: n, submitLabel: r = "Save card", disabled: i = !1, defaultCountry: a, appearance: o, className: s }) {
1633
1726
  let c = P.useId().replace(/[^a-zA-Z0-9-]/g, ""), l = P.useMemo(() => ({
1634
1727
  number: `orck-save-${c}-number`,
1635
1728
  expiry: `orck-save-${c}-expiry`,
@@ -1655,7 +1748,7 @@ function gn({ tokenizationKey: e, tokenizationURL: t, onTokenized: n, submitLabe
1655
1748
  P.useEffect(() => (y.current = !0, () => {
1656
1749
  y.current = !1;
1657
1750
  }), []);
1658
- let b = tn({
1751
+ let b = nn({
1659
1752
  enabled: !0,
1660
1753
  active: !0,
1661
1754
  tokenizationKey: e,
@@ -1680,7 +1773,7 @@ function gn({ tokenizationKey: e, tokenizationURL: t, onTokenized: n, submitLabe
1680
1773
  a = !0, h(!0), await n({
1681
1774
  payment_token: e.token,
1682
1775
  ...t.data,
1683
- ...nn(e.card)
1776
+ ...rn(e.card)
1684
1777
  }) === !1 && y.current && h(!1);
1685
1778
  } catch (e) {
1686
1779
  y.current && _(a ? "The card-save result is not confirmed. Check your saved cards before starting another attempt." : e instanceof Error ? e.message : "Card entry could not be completed.");
@@ -1727,7 +1820,7 @@ function gn({ tokenizationKey: e, tokenizationURL: t, onTokenized: n, submitLabe
1727
1820
  }
1728
1821
  //#endregion
1729
1822
  //#region src/save-payment-method.tsx
1730
- function _n(e) {
1823
+ function vn(e) {
1731
1824
  let { t } = S(), n = s(e.psp);
1732
1825
  return n ? /* @__PURE__ */ L("div", {
1733
1826
  className: R("orck grid gap-4", e.className),
@@ -1736,21 +1829,21 @@ function _n(e) {
1736
1829
  children: [/* @__PURE__ */ I("p", {
1737
1830
  className: "text-sm text-muted-foreground",
1738
1831
  children: t("paymentMethods.saveNotice")
1739
- }), I(n === "collect_js" ? yn : n === "card" ? bn : xn, { ...e })]
1832
+ }), I(n === "platform" ? Cn : n === "collect_js" ? bn : n === "card" ? xn : Sn, { ...e })]
1740
1833
  }) : /* @__PURE__ */ I("p", {
1741
1834
  role: "alert",
1742
1835
  className: "text-sm text-destructive",
1743
1836
  children: t("paymentMethods.unavailable")
1744
1837
  });
1745
1838
  }
1746
- var vn = (e, t) => !n(t) && t instanceof Error && t.message ? t.message : e.error(t);
1747
- function yn({ psp: e, onSaved: t, submitLabel: n, appearance: r, defaultCountry: i }) {
1839
+ var yn = (e, t) => !n(t) && t instanceof Error && t.message ? t.message : e.error(t);
1840
+ function bn({ psp: e, onSaved: t, submitLabel: n, appearance: r, defaultCountry: i }) {
1748
1841
  let a = S(), { client: o, notify: s } = T(), [c, l] = P.useState(0), [u, d] = P.useState();
1749
1842
  return /* @__PURE__ */ L(F, { children: [u ? /* @__PURE__ */ I("p", {
1750
1843
  role: "alert",
1751
1844
  className: "text-sm text-destructive",
1752
1845
  children: u
1753
- }) : null, /* @__PURE__ */ I(gn, {
1846
+ }) : null, /* @__PURE__ */ I(_n, {
1754
1847
  tokenizationKey: e.config.tokenization_key,
1755
1848
  tokenizationURL: e.config.tokenization_url,
1756
1849
  onTokenized: async (n) => {
@@ -1763,7 +1856,7 @@ function yn({ psp: e, onSaved: t, submitLabel: n, appearance: r, defaultCountry:
1763
1856
  billing_details: Et(n)
1764
1857
  });
1765
1858
  } catch (e) {
1766
- d(vn(a, e)), l((e) => e + 1);
1859
+ d(yn(a, e)), l((e) => e + 1);
1767
1860
  return;
1768
1861
  }
1769
1862
  s({
@@ -1776,12 +1869,12 @@ function yn({ psp: e, onSaved: t, submitLabel: n, appearance: r, defaultCountry:
1776
1869
  appearance: r
1777
1870
  }, c)] });
1778
1871
  }
1779
- function bn({ psp: e, onSaved: t, submitLabel: n, defaultCountry: r }) {
1872
+ function xn({ psp: e, onSaved: t, submitLabel: n, defaultCountry: r }) {
1780
1873
  let i = S(), { client: a, notify: o } = T(), s = P.useId().replace(/[^a-zA-Z0-9-]/g, ""), c = P.useMemo(() => ({
1781
1874
  number: `orck-save-${s}-number`,
1782
1875
  expiry: `orck-save-${s}-expiry`,
1783
1876
  cvv: `orck-save-${s}-cvv`
1784
- }), [s]), l = hn(), [u, d] = P.useState(() => ({
1877
+ }), [s]), l = gn(), [u, d] = P.useState(() => ({
1785
1878
  ...Dt,
1786
1879
  country: kt(r)
1787
1880
  })), [f, p] = P.useState(!1), [m, h] = P.useState(), g = async (n) => {
@@ -1805,7 +1898,7 @@ function bn({ psp: e, onSaved: t, submitLabel: n, defaultCountry: r }) {
1805
1898
  paymentMethodId: n.id
1806
1899
  }), t(n.id);
1807
1900
  } catch (e) {
1808
- h(vn(i, e));
1901
+ h(yn(i, e));
1809
1902
  } finally {
1810
1903
  p(!1);
1811
1904
  }
@@ -1843,7 +1936,7 @@ function bn({ psp: e, onSaved: t, submitLabel: n, defaultCountry: r }) {
1843
1936
  ]
1844
1937
  });
1845
1938
  }
1846
- function xn({ psp: e, onSaved: t, submitLabel: n, defaultCountry: r }) {
1939
+ function Sn({ psp: e, onSaved: t, submitLabel: n, defaultCountry: r }) {
1847
1940
  let i = S(), { t: a } = i, { client: o, notify: s } = T(), c = P.useRef(null), [l, u] = P.useState(!1), [d, f] = P.useState(!1), [p, m] = P.useState(), h = P.useMemo(() => kt(r), [r]), g = async (e) => {
1848
1941
  if (e.preventDefault(), !(!c.current || d)) {
1849
1942
  f(!0), m(void 0);
@@ -1854,7 +1947,7 @@ function xn({ psp: e, onSaved: t, submitLabel: n, defaultCountry: r }) {
1854
1947
  paymentMethodId: e
1855
1948
  }), t(e);
1856
1949
  } catch (e) {
1857
- m(vn(i, e));
1950
+ m(yn(i, e));
1858
1951
  } finally {
1859
1952
  f(!1);
1860
1953
  }
@@ -1864,7 +1957,7 @@ function xn({ psp: e, onSaved: t, submitLabel: n, defaultCountry: r }) {
1864
1957
  className: "grid gap-4",
1865
1958
  onSubmit: (e) => void g(e),
1866
1959
  children: [
1867
- /* @__PURE__ */ I(an, {
1960
+ /* @__PURE__ */ I(on, {
1868
1961
  ref: c,
1869
1962
  psp: e,
1870
1963
  client: o,
@@ -1887,9 +1980,41 @@ function xn({ psp: e, onSaved: t, submitLabel: n, defaultCountry: r }) {
1887
1980
  ]
1888
1981
  });
1889
1982
  }
1983
+ function Cn({ psp: e, onSaved: t, submitLabel: r, defaultCountry: i }) {
1984
+ let a = S(), { client: o, notify: s } = T(), [c, l] = P.useState();
1985
+ return /* @__PURE__ */ L(F, { children: [c ? /* @__PURE__ */ I("p", {
1986
+ role: "alert",
1987
+ className: "text-sm text-destructive",
1988
+ children: c
1989
+ }) : null, /* @__PURE__ */ I(Wt, {
1990
+ publicKey: e.config.public_api_key,
1991
+ purpose: "setup",
1992
+ defaultCountry: i,
1993
+ submitLabel: r ?? a.t("paymentMethods.save"),
1994
+ disabled: !1,
1995
+ onTokenized: async (r) => {
1996
+ l(void 0);
1997
+ let i;
1998
+ try {
1999
+ i = await o.addPaymentMethod({
2000
+ psp_id: e.psp_id,
2001
+ token: r.payment_token,
2002
+ billing_details: Et(r)
2003
+ });
2004
+ } catch (e) {
2005
+ if (l(yn(a, e)), n(e) && (e.status === 400 || e.status === 402)) return !1;
2006
+ throw e;
2007
+ }
2008
+ return s({
2009
+ type: "payment_method.added",
2010
+ paymentMethodId: i.id
2011
+ }), t(i.id), !0;
2012
+ }
2013
+ })] });
2014
+ }
1890
2015
  //#endregion
1891
2016
  //#region src/account/notice.tsx
1892
- function Sn() {
2017
+ function wn() {
1893
2018
  let [e, t] = P.useState(null);
1894
2019
  return P.useEffect(() => {
1895
2020
  if (!e) return;
@@ -1904,13 +2029,13 @@ function Sn() {
1904
2029
  }
1905
2030
  //#endregion
1906
2031
  //#region src/account/payment-methods-panel.tsx
1907
- function Cn(e, t) {
2032
+ function Tn(e, t) {
1908
2033
  return Te(e.card, t);
1909
2034
  }
1910
- function wn(e, t) {
2035
+ function En(e, t) {
1911
2036
  return e.status === 409 && e.code === "resource_conflict" ? t.t("paymentMethods.inUse") : t.error(e);
1912
2037
  }
1913
- function Tn({ defaultCurrency: e, defaultCountry: t, appearance: n, className: r }) {
2038
+ function Dn({ defaultCurrency: e, defaultCountry: t, appearance: n, className: r }) {
1914
2039
  let a = S(), { t: o } = a, s = x(n), c = te(), [l, u] = P.useState(null), [d, f] = P.useState(null), [p, h] = P.useState(null), [g, v] = P.useState(!1), y = ee(), b = i(y.config?.payment.psps ?? []), C = b.filter(m), w = C.length > 0 ? null : _(b), { refetch: T } = y;
1915
2040
  P.useEffect(() => {
1916
2041
  if (w === null) return;
@@ -1921,12 +2046,12 @@ function Tn({ defaultCurrency: e, defaultCountry: t, appearance: n, className: r
1921
2046
  T,
1922
2047
  y.config
1923
2048
  ]);
1924
- let [E, D] = P.useState(), O = C.find((e) => e.psp_id === E) ?? C[0], [k, A] = Sn(), ne = e?.toUpperCase(), re = async () => {
2049
+ let [E, D] = P.useState(), O = C.find((e) => e.psp_id === E) ?? C[0], [k, A] = wn(), ne = e?.toUpperCase(), re = async () => {
1925
2050
  if (!l) return;
1926
2051
  f(null);
1927
2052
  let e = await c.remove(l.id);
1928
2053
  if (e) {
1929
- f(wn(e, a));
2054
+ f(En(e, a));
1930
2055
  return;
1931
2056
  }
1932
2057
  u(null), A(o("paymentMethods.removed"));
@@ -1948,7 +2073,7 @@ function Tn({ defaultCurrency: e, defaultCountry: t, appearance: n, className: r
1948
2073
  }) : /* @__PURE__ */ I("ul", {
1949
2074
  className: "-my-1 divide-y divide-border",
1950
2075
  children: N.map((e) => {
1951
- let t = Cn(e, a), n = (e.subscriptions ?? []).map((e) => e.display_name).filter(Boolean), r = e.health?.expiry_status, i = e.default_currencies ?? [], s = c.pending[e.id], l = [n.length > 0 && o("paymentMethods.usedBy", { names: n.join(", ") })].filter(Boolean);
2076
+ let t = Tn(e, a), n = (e.subscriptions ?? []).map((e) => e.display_name).filter(Boolean), r = e.health?.expiry_status, i = e.default_currencies ?? [], s = c.pending[e.id], l = [n.length > 0 && o("paymentMethods.usedBy", { names: n.join(", ") })].filter(Boolean);
1952
2077
  return /* @__PURE__ */ L("li", {
1953
2078
  "data-testid": "payment-method-row",
1954
2079
  "data-payment-method-id": e.id,
@@ -2015,7 +2140,7 @@ function Tn({ defaultCurrency: e, defaultCountry: t, appearance: n, className: r
2015
2140
  }, e.id);
2016
2141
  })
2017
2142
  });
2018
- let F = l ? c.pending[l.id] === "remove" : !1, R = l ? Cn(l, a) : "";
2143
+ let F = l ? c.pending[l.id] === "remove" : !1, R = l ? Tn(l, a) : "";
2019
2144
  return /* @__PURE__ */ L(Le, {
2020
2145
  title: o("paymentMethods.title"),
2021
2146
  description: o("paymentMethods.description"),
@@ -2103,7 +2228,7 @@ function Tn({ defaultCurrency: e, defaultCountry: t, appearance: n, className: r
2103
2228
  }, e.psp_id))
2104
2229
  })]
2105
2230
  }) : null,
2106
- /* @__PURE__ */ I(_n, {
2231
+ /* @__PURE__ */ I(vn, {
2107
2232
  psp: O,
2108
2233
  defaultCountry: t,
2109
2234
  appearance: n,
@@ -2119,7 +2244,7 @@ function Tn({ defaultCurrency: e, defaultCountry: t, appearance: n, className: r
2119
2244
  }
2120
2245
  //#endregion
2121
2246
  //#region src/components/ui/textarea.tsx
2122
- function En({ className: e, ...t }) {
2247
+ function On({ className: e, ...t }) {
2123
2248
  return /* @__PURE__ */ I("textarea", {
2124
2249
  "data-slot": "textarea",
2125
2250
  className: R("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-2.5 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", e),
@@ -2128,7 +2253,7 @@ function En({ className: e, ...t }) {
2128
2253
  }
2129
2254
  //#endregion
2130
2255
  //#region src/account/cancel-dialog.tsx
2131
- function Dn({ open: e, onOpenChange: t, name: n, onChain: r = !1, pending: i, onConfirm: a, appearance: o }) {
2256
+ function kn({ open: e, onOpenChange: t, name: n, onChain: r = !1, pending: i, onConfirm: a, appearance: o }) {
2132
2257
  let s = S(), { t: c } = s, l = x(o), u = P.useId(), d = P.useId(), [f, m] = P.useState(""), [h, g] = P.useState(!1), [_, v] = P.useState(null), y = i !== void 0, b = f.trim().length, C = b < 4, w = async () => {
2133
2258
  if (g(!0), C || y) return;
2134
2259
  v(null);
@@ -2159,7 +2284,7 @@ function Dn({ open: e, onOpenChange: t, name: n, onChain: r = !1, pending: i, on
2159
2284
  htmlFor: u,
2160
2285
  children: c("cancel.reasonLabel")
2161
2286
  }),
2162
- /* @__PURE__ */ I(En, {
2287
+ /* @__PURE__ */ I(On, {
2163
2288
  id: u,
2164
2289
  value: f,
2165
2290
  maxLength: 500,
@@ -2210,14 +2335,14 @@ function Dn({ open: e, onOpenChange: t, name: n, onChain: r = !1, pending: i, on
2210
2335
  }
2211
2336
  //#endregion
2212
2337
  //#region src/components/ui/radio-group.tsx
2213
- function On({ className: e, ...t }) {
2338
+ function An({ className: e, ...t }) {
2214
2339
  return /* @__PURE__ */ I(me, {
2215
2340
  "data-slot": "radio-group",
2216
2341
  className: R("grid w-full gap-3", e),
2217
2342
  ...t
2218
2343
  });
2219
2344
  }
2220
- function kn({ className: e, ...t }) {
2345
+ function jn({ className: e, ...t }) {
2221
2346
  return /* @__PURE__ */ I(pe.Root, {
2222
2347
  "data-slot": "radio-group-item",
2223
2348
  className: R("group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary", e),
@@ -2231,11 +2356,11 @@ function kn({ className: e, ...t }) {
2231
2356
  }
2232
2357
  //#endregion
2233
2358
  //#region src/account/change-card-dialog.tsx
2234
- var An = "default";
2235
- function jn(e, t) {
2359
+ var Mn = "default";
2360
+ function Nn(e, t) {
2236
2361
  return t.filter((t) => t.health?.expiry_status !== "expired" && (!e.psp_id || !t.psp_id || t.psp_id === e.psp_id) && (!e.rail || !t.rail || t.rail === e.rail));
2237
2362
  }
2238
- function Mn({ subscription: e, name: t, onOpenChange: n, pending: r, onConfirm: i, appearance: a }) {
2363
+ function Pn({ subscription: e, name: t, onOpenChange: n, pending: r, onConfirm: i, appearance: a }) {
2239
2364
  let o = x(a);
2240
2365
  return /* @__PURE__ */ I(st, {
2241
2366
  open: e !== null,
@@ -2247,7 +2372,7 @@ function Mn({ subscription: e, name: t, onOpenChange: n, pending: r, onConfirm:
2247
2372
  className: `${o.className} ${K} bg-popover text-popover-foreground`,
2248
2373
  "data-orck-theme": o["data-orck-theme"],
2249
2374
  style: o.style,
2250
- children: e ? /* @__PURE__ */ I(Nn, {
2375
+ children: e ? /* @__PURE__ */ I(Fn, {
2251
2376
  subscription: e,
2252
2377
  name: t,
2253
2378
  pending: r,
@@ -2257,9 +2382,9 @@ function Mn({ subscription: e, name: t, onOpenChange: n, pending: r, onConfirm:
2257
2382
  })
2258
2383
  });
2259
2384
  }
2260
- function Nn({ subscription: e, name: t, pending: n, onCancel: r, onConfirm: i }) {
2261
- let a = S(), { t: o } = a, s = P.useId(), c = te(), l = e.payment_method_id ?? An, [u, d] = P.useState(l), [f, p] = P.useState(null), m = c.methods ? jn(e, c.methods) : null, h = e.price?.currency?.toUpperCase(), g = h ? m?.find((e) => (e.default_currencies ?? []).includes(h)) : void 0, _ = [...g ? [{
2262
- id: An,
2385
+ function Fn({ subscription: e, name: t, pending: n, onCancel: r, onConfirm: i }) {
2386
+ let a = S(), { t: o } = a, s = P.useId(), c = te(), l = e.payment_method_id ?? Mn, [u, d] = P.useState(l), [f, p] = P.useState(null), m = c.methods ? Nn(e, c.methods) : null, h = e.price?.currency?.toUpperCase(), g = h ? m?.find((e) => (e.default_currencies ?? []).includes(h)) : void 0, _ = [...g ? [{
2387
+ id: Mn,
2263
2388
  card: g
2264
2389
  }] : [], ...(m ?? []).map((e) => ({
2265
2390
  id: e.id,
@@ -2267,13 +2392,13 @@ function Nn({ subscription: e, name: t, pending: n, onCancel: r, onConfirm: i })
2267
2392
  }))], v = _.some((e) => e.id !== l), y = async () => {
2268
2393
  if (!u || u === l || n) return;
2269
2394
  p(null);
2270
- let e = await i(u === An ? null : u);
2395
+ let e = await i(u === Mn ? null : u);
2271
2396
  e && p(e);
2272
2397
  }, b;
2273
2398
  return b = m === null && c.error ? /* @__PURE__ */ I(Y, {
2274
2399
  error: c.error,
2275
2400
  onRetry: c.refetch
2276
- }) : m === null ? /* @__PURE__ */ I(Re, { rows: 2 }) : /* @__PURE__ */ I(On, {
2401
+ }) : m === null ? /* @__PURE__ */ I(Re, { rows: 2 }) : /* @__PURE__ */ I(An, {
2277
2402
  value: u,
2278
2403
  onValueChange: (e) => {
2279
2404
  typeof e == "string" && e && d(e);
@@ -2288,7 +2413,7 @@ function Nn({ subscription: e, name: t, pending: n, onCancel: r, onConfirm: i })
2288
2413
  "data-testid": "change-card-option",
2289
2414
  className: R("flex cursor-pointer items-center gap-3 py-1.5 select-none", n && "cursor-default"),
2290
2415
  children: [
2291
- /* @__PURE__ */ I(kn, {
2416
+ /* @__PURE__ */ I(jn, {
2292
2417
  id: r,
2293
2418
  value: e
2294
2419
  }),
@@ -2298,7 +2423,7 @@ function Nn({ subscription: e, name: t, pending: n, onCancel: r, onConfirm: i })
2298
2423
  }),
2299
2424
  /* @__PURE__ */ I("span", {
2300
2425
  className: "min-w-0 flex-1 truncate text-sm font-medium tabular-nums",
2301
- children: e === An ? o("changeCard.useDefault", { card: i }) : i
2426
+ children: e === Mn ? o("changeCard.useDefault", { card: i }) : i
2302
2427
  }),
2303
2428
  e === l ? /* @__PURE__ */ I("span", {
2304
2429
  className: "shrink-0 text-xs text-muted-foreground",
@@ -2337,8 +2462,8 @@ function Nn({ subscription: e, name: t, pending: n, onCancel: r, onConfirm: i })
2337
2462
  }
2338
2463
  //#endregion
2339
2464
  //#region src/account/subscriptions-panel.tsx
2340
- function Pn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter: n, appearance: r, className: i, ...a }) {
2341
- let o = S(), { t: s } = o, { locale: c, navigate: l } = k(), u = A(a), d = O(), [f, p] = P.useState(null), [m, h] = P.useState(null), [g, _] = P.useState(null), [v, y] = Sn(), b = P.useMemo(() => {
2465
+ function In({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter: n, appearance: r, className: i, ...a }) {
2466
+ let o = S(), { t: s } = o, { locale: c, navigate: l } = k(), u = A(a), d = O(), [f, p] = P.useState(null), [m, h] = P.useState(null), [g, _] = P.useState(null), [v, y] = wn(), b = P.useMemo(() => {
2342
2467
  let e = u.subscriptions ?? [];
2343
2468
  return [...e.filter(G), ...e.filter((e) => !G(e))];
2344
2469
  }, [u.subscriptions]), x = async (e) => {
@@ -2483,7 +2608,7 @@ function Pn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter:
2483
2608
  })
2484
2609
  }) : null,
2485
2610
  v,
2486
- /* @__PURE__ */ I(Mn, {
2611
+ /* @__PURE__ */ I(Pn, {
2487
2612
  subscription: m,
2488
2613
  name: m ? Se(m, o) : "",
2489
2614
  onOpenChange: (e) => !e && h(null),
@@ -2495,7 +2620,7 @@ function Pn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter:
2495
2620
  return t || (h(null), y(s("changeCard.done"))), t;
2496
2621
  }
2497
2622
  }, `card-${m?.id ?? "closed"}`),
2498
- /* @__PURE__ */ I(Dn, {
2623
+ /* @__PURE__ */ I(kn, {
2499
2624
  open: f !== null,
2500
2625
  onOpenChange: (e) => !e && p(null),
2501
2626
  name: f ? Se(f, o) : "",
@@ -2513,19 +2638,19 @@ function Pn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter:
2513
2638
  }
2514
2639
  //#endregion
2515
2640
  //#region src/account/account-billing.tsx
2516
- function Fn({ defaultCurrency: e, defaultCountry: t, sendSolanaTransaction: n, plansHref: r, renderSubscriptionFooter: i, historyPageSize: a, appearance: o, className: s }) {
2641
+ function Ln({ defaultCurrency: e, defaultCountry: t, sendSolanaTransaction: n, plansHref: r, renderSubscriptionFooter: i, historyPageSize: a, appearance: o, className: s }) {
2517
2642
  return /* @__PURE__ */ L(he, {
2518
2643
  appearance: o,
2519
2644
  className: R("grid gap-6", s),
2520
2645
  "data-testid": "account-billing",
2521
2646
  children: [
2522
- /* @__PURE__ */ I(Pn, {
2647
+ /* @__PURE__ */ I(In, {
2523
2648
  sendSolanaTransaction: n,
2524
2649
  plansHref: r,
2525
2650
  renderSubscriptionFooter: i,
2526
2651
  appearance: o
2527
2652
  }),
2528
- /* @__PURE__ */ I(Tn, {
2653
+ /* @__PURE__ */ I(Dn, {
2529
2654
  defaultCurrency: e,
2530
2655
  defaultCountry: t,
2531
2656
  appearance: o
@@ -2539,15 +2664,15 @@ function Fn({ defaultCurrency: e, defaultCountry: t, sendSolanaTransaction: n, p
2539
2664
  }
2540
2665
  //#endregion
2541
2666
  //#region src/components/qr.tsx
2542
- var In = 208;
2543
- function Ln({ amountLabel: e, payload: t, statusLine: n }) {
2667
+ var Rn = 208;
2668
+ function zn({ amountLabel: e, payload: t, statusLine: n }) {
2544
2669
  let r = P.useRef(null), [i, a] = P.useState("loading");
2545
2670
  return P.useEffect(() => {
2546
2671
  let e = r.current;
2547
2672
  if (!e || !t) return;
2548
2673
  let n = !1;
2549
2674
  return e.replaceChildren(), a("loading"), import("./dist-CslWupfi.js").then(({ createQR: r }) => {
2550
- n || (r(t, In, "#ffffff", "#18181b").append(e), a("ready"));
2675
+ n || (r(t, Rn, "#ffffff", "#18181b").append(e), a("ready"));
2551
2676
  }).catch(() => {
2552
2677
  n || a("failed");
2553
2678
  }), () => {
@@ -2563,8 +2688,8 @@ function Ln({ amountLabel: e, payload: t, statusLine: n }) {
2563
2688
  "aria-label": "Solana Pay QR code",
2564
2689
  className: "relative overflow-hidden rounded-lg",
2565
2690
  style: {
2566
- width: In,
2567
- height: In
2691
+ width: Rn,
2692
+ height: Rn
2568
2693
  },
2569
2694
  children: [
2570
2695
  /* @__PURE__ */ I("div", {
@@ -2584,8 +2709,8 @@ function Ln({ amountLabel: e, payload: t, statusLine: n }) {
2584
2709
  "aria-hidden": !0,
2585
2710
  className: "animate-pulse rounded-lg bg-zinc-100",
2586
2711
  style: {
2587
- width: In,
2588
- height: In
2712
+ width: Rn,
2713
+ height: Rn
2589
2714
  }
2590
2715
  })
2591
2716
  }),
@@ -2610,7 +2735,7 @@ function Ln({ amountLabel: e, payload: t, statusLine: n }) {
2610
2735
  ]
2611
2736
  });
2612
2737
  }
2613
- var Rn = {
2738
+ var Bn = {
2614
2739
  visa: "VISA",
2615
2740
  mastercard: "MC",
2616
2741
  amex: "AMEX",
@@ -2618,19 +2743,19 @@ var Rn = {
2618
2743
  jcb: "JCB",
2619
2744
  diners: "DINERS"
2620
2745
  };
2621
- function zn(e) {
2622
- return Rn[e?.trim().toLowerCase() ?? ""] ?? "CARD";
2746
+ function Vn(e) {
2747
+ return Bn[e?.trim().toLowerCase() ?? ""] ?? "CARD";
2623
2748
  }
2624
- function Bn(e) {
2749
+ function Hn(e) {
2625
2750
  let t = e?.trim();
2626
2751
  return t ? t[0].toUpperCase() + t.slice(1) : "Card";
2627
2752
  }
2628
- function Vn(e) {
2753
+ function Un(e) {
2629
2754
  let t = e.card;
2630
2755
  if (!(!t?.exp_month || !t.exp_year)) return `${String(t.exp_month).padStart(2, "0")}/${String(t.exp_year).slice(-2)}`;
2631
2756
  }
2632
- function Hn({ methods: e, value: t, onChange: n, disabled: r, idPrefix: i }) {
2633
- return /* @__PURE__ */ L(On, {
2757
+ function Wn({ methods: e, value: t, onChange: n, disabled: r, idPrefix: i }) {
2758
+ return /* @__PURE__ */ L(An, {
2634
2759
  value: t,
2635
2760
  onValueChange: (e) => {
2636
2761
  typeof e == "string" && e && n(e);
@@ -2639,25 +2764,25 @@ function Hn({ methods: e, value: t, onChange: n, disabled: r, idPrefix: i }) {
2639
2764
  "aria-label": "Saved cards",
2640
2765
  className: "grid gap-0",
2641
2766
  children: [e.map((e) => {
2642
- let n = `${i}-${e.id}`, a = t === e.id, o = Vn(e), s = e.card?.brand, c = e.card?.last4;
2767
+ let n = `${i}-${e.id}`, a = t === e.id, o = Un(e), s = e.card?.brand, c = e.card?.last4;
2643
2768
  return /* @__PURE__ */ L(Z, {
2644
2769
  htmlFor: n,
2645
2770
  className: R("flex cursor-pointer items-center gap-3 py-1.5 select-none", r && "cursor-default"),
2646
2771
  children: [
2647
- /* @__PURE__ */ I(kn, {
2772
+ /* @__PURE__ */ I(jn, {
2648
2773
  id: n,
2649
2774
  value: e.id
2650
2775
  }),
2651
2776
  /* @__PURE__ */ I(Ze, {
2652
2777
  brand: s ?? void 0,
2653
- fallback: zn(s)
2778
+ fallback: Vn(s)
2654
2779
  }),
2655
2780
  /* @__PURE__ */ L("span", {
2656
2781
  className: R("min-w-0 flex-1 truncate text-sm font-medium text-muted-foreground tabular-nums transition-colors", a && "font-semibold text-foreground"),
2657
2782
  children: [/* @__PURE__ */ L("span", {
2658
2783
  className: "sr-only",
2659
2784
  children: [
2660
- Bn(s),
2785
+ Hn(s),
2661
2786
  " card ending ",
2662
2787
  c,
2663
2788
  o ? `, expires ${o}` : ""
@@ -2665,7 +2790,7 @@ function Hn({ methods: e, value: t, onChange: n, disabled: r, idPrefix: i }) {
2665
2790
  }), /* @__PURE__ */ L("span", {
2666
2791
  "aria-hidden": !0,
2667
2792
  children: [
2668
- Bn(s),
2793
+ Hn(s),
2669
2794
  " •••• ",
2670
2795
  c ?? "····",
2671
2796
  o ? /* @__PURE__ */ L("span", {
@@ -2685,7 +2810,7 @@ function Hn({ methods: e, value: t, onChange: n, disabled: r, idPrefix: i }) {
2685
2810
  htmlFor: `${i}-new`,
2686
2811
  className: R("flex cursor-pointer items-center gap-3 py-1.5 text-sm font-medium text-muted-foreground select-none", t === "new" && "font-semibold text-foreground", r && "cursor-default"),
2687
2812
  children: [
2688
- /* @__PURE__ */ I(kn, {
2813
+ /* @__PURE__ */ I(jn, {
2689
2814
  id: `${i}-new`,
2690
2815
  value: "new"
2691
2816
  }),
@@ -2704,7 +2829,7 @@ function Hn({ methods: e, value: t, onChange: n, disabled: r, idPrefix: i }) {
2704
2829
  }
2705
2830
  //#endregion
2706
2831
  //#region src/components/states.tsx
2707
- function Un() {
2832
+ function Gn() {
2708
2833
  return /* @__PURE__ */ L("div", {
2709
2834
  className: "grid gap-4",
2710
2835
  "aria-hidden": !0,
@@ -2720,7 +2845,7 @@ function Un() {
2720
2845
  }
2721
2846
  //#endregion
2722
2847
  //#region src/components/stripe-wallets.tsx
2723
- function Wn({ publishableKey: e, amount: t, currency: n, onPaymentMethod: r, onAvailable: i }) {
2848
+ function Kn({ publishableKey: e, amount: t, currency: n, onPaymentMethod: r, onAvailable: i }) {
2724
2849
  let a = P.useRef(null), o = P.useRef(r), s = P.useRef(i);
2725
2850
  P.useEffect(() => {
2726
2851
  o.current = r, s.current = i;
@@ -2731,7 +2856,7 @@ function Wn({ publishableKey: e, amount: t, currency: n, onPaymentMethod: r, onA
2731
2856
  let r = !1, i, c = (e) => {
2732
2857
  r || (l(e), s.current?.(e));
2733
2858
  };
2734
- return Gt(e).then((e) => {
2859
+ return Kt(e).then((e) => {
2735
2860
  if (r || !a.current) return;
2736
2861
  let s = e.elements({
2737
2862
  mode: "payment",
@@ -2739,7 +2864,7 @@ function Wn({ publishableKey: e, amount: t, currency: n, onPaymentMethod: r, onA
2739
2864
  currency: n.toLowerCase(),
2740
2865
  paymentMethodCreation: "manual",
2741
2866
  paymentMethodTypes: ["card"],
2742
- appearance: rn(a.current)
2867
+ appearance: an(a.current)
2743
2868
  }), l = s.create("expressCheckout", { paymentMethods: {
2744
2869
  applePay: "auto",
2745
2870
  googlePay: "auto",
@@ -2772,7 +2897,7 @@ function Wn({ publishableKey: e, amount: t, currency: n, onPaymentMethod: r, onA
2772
2897
  }
2773
2898
  //#endregion
2774
2899
  //#region src/fallbacks.ts
2775
- function Gn(e, t, n) {
2900
+ function qn(e, t, n) {
2776
2901
  let r = /* @__PURE__ */ new Set();
2777
2902
  if (!e) return r;
2778
2903
  let i = new Map(n.map((e) => [e.psp_id, e.key.toLowerCase()])), a = new Map(Object.entries(e).map(([e, t]) => [e.toLowerCase(), t]));
@@ -2784,25 +2909,25 @@ function Gn(e, t, n) {
2784
2909
  }
2785
2910
  return r;
2786
2911
  }
2787
- var Kn = "fallbacks", qn = 4096, Jn = 1024, Yn = 8, Xn = N.string().regex(/^[a-z0-9][a-z0-9_-]{0,62}$/), Zn = N.record(Xn, N.strictObject({
2788
- for: N.array(Xn).min(1).max(Yn),
2912
+ var Jn = "fallbacks", Yn = 4096, Xn = 1024, Zn = 8, Qn = N.string().regex(/^[a-z0-9][a-z0-9_-]{0,62}$/), $n = N.record(Qn, N.strictObject({
2913
+ for: N.array(Qn).min(1).max(Zn),
2789
2914
  afterFailures: N.number().int().min(1).max(100)
2790
2915
  })).refine((e) => {
2791
2916
  let t = Object.keys(e).length;
2792
- return t >= 1 && t <= Yn;
2917
+ return t >= 1 && t <= Zn;
2793
2918
  });
2794
- function Qn(e, t) {
2919
+ function er(e, t) {
2795
2920
  if (!t || Object.keys(t).length === 0) return e;
2796
- let n = e.indexOf("#"), r = n < 0 ? e : e.slice(0, n), i = n < 0 ? "" : e.slice(n + 1), a = `${Kn}=${encodeURIComponent(JSON.stringify(t))}`;
2921
+ let n = e.indexOf("#"), r = n < 0 ? e : e.slice(0, n), i = n < 0 ? "" : e.slice(n + 1), a = `${Jn}=${encodeURIComponent(JSON.stringify(t))}`;
2797
2922
  return `${r}#${i ? `${i}&` : ""}${a}`;
2798
2923
  }
2799
- function $n(e) {
2924
+ function tr(e) {
2800
2925
  let [t = "", ...n] = e.replace(/^#/, "").split("&"), r = { secret: t.startsWith("pus_") ? t : null };
2801
- if (e.length > qn) return r;
2802
- let i = new URLSearchParams(n.join("&")).get(Kn);
2803
- if (!i || i.length > Jn) return r;
2926
+ if (e.length > Yn) return r;
2927
+ let i = new URLSearchParams(n.join("&")).get(Jn);
2928
+ if (!i || i.length > Xn) return r;
2804
2929
  try {
2805
- let e = Zn.safeParse(JSON.parse(i));
2930
+ let e = $n.safeParse(JSON.parse(i));
2806
2931
  return e.success ? {
2807
2932
  ...r,
2808
2933
  fallbacks: e.data
@@ -2812,102 +2937,9 @@ function $n(e) {
2812
2937
  }
2813
2938
  }
2814
2939
  //#endregion
2815
- //#region src/components/platform-card-form.tsx
2816
- function er({ publicKey: e, submitLabel: t, disabled: n, onTokenized: r }) {
2817
- let i = P.useId().replace(/[^a-zA-Z0-9-]/g, ""), a = P.useMemo(() => ({
2818
- number: `bt-${i}-number`,
2819
- expiry: `bt-${i}-expiry`,
2820
- cvv: `bt-${i}-cvv`
2821
- }), [i]), [o, s] = P.useState(() => ({
2822
- ...Dt,
2823
- country: kt()
2824
- })), [c, l] = P.useState(!1), [u, d] = P.useState(!1), [f, p] = P.useState(!1), [m, h] = P.useState(!1), [g, _] = P.useState(), v = P.useRef(void 0), y = P.useRef(void 0), b = P.useRef(!1), x = P.useRef({
2825
- generation: 0,
2826
- disabled: n
2827
- });
2828
- P.useLayoutEffect(() => {
2829
- x.current = {
2830
- generation: x.current.generation + 1,
2831
- disabled: n
2832
- };
2833
- }, [e, n]), P.useEffect(() => {
2834
- let t = !0, n = M(e), r = n.createElement("cardNumber"), i = n.createElement("expiry"), o = n.createElement("cvv");
2835
- return Promise.all([
2836
- r.mount(`#${a.number}`),
2837
- i.mount(`#${a.expiry}`),
2838
- o.mount(`#${a.cvv}`)
2839
- ]).then(() => {
2840
- t && (y.current = async () => (await n.tokenIntents.create({
2841
- type: "card",
2842
- data: {
2843
- number: r,
2844
- expiration_month: i,
2845
- expiration_year: i,
2846
- cvc: o
2847
- }
2848
- })).id, l(!0));
2849
- }, () => {
2850
- t && _("Secure card entry could not be loaded.");
2851
- }), () => {
2852
- t = !1, x.current.generation++, y.current = void 0, n.destroy();
2853
- };
2854
- }, [e, a]);
2855
- let S = async (e) => {
2856
- if (e.preventDefault(), n || b.current || f || !y.current) return;
2857
- let t = Tt.safeParse(o);
2858
- if (!t.success) {
2859
- _(t.error.issues[0]?.message ?? "Check the billing details");
2860
- return;
2861
- }
2862
- b.current = !0, d(!0), _(void 0);
2863
- let i = x.current.generation;
2864
- try {
2865
- let e = v.current ?? {
2866
- payment_token: await y.current(),
2867
- ...t.data
2868
- };
2869
- if (x.current.generation !== i || x.current.disabled) return;
2870
- v.current = e, await r(e) ? p(!0) : v.current = void 0, h(!1);
2871
- } catch {
2872
- let e = !!v.current;
2873
- h(e), _(e ? "The payment result is not confirmed. Retry to check the same payment." : "Check your card details and try again.");
2874
- } finally {
2875
- b.current = !1, d(!1);
2876
- }
2877
- };
2878
- return /* @__PURE__ */ L("form", {
2879
- "aria-label": "Secure platform card payment",
2880
- className: "grid gap-4",
2881
- onSubmit: (e) => void S(e),
2882
- children: [
2883
- /* @__PURE__ */ I(It, {
2884
- idPrefix: `bt-${i}`,
2885
- value: o,
2886
- onChange: s,
2887
- disabled: n || u || m || f
2888
- }),
2889
- /* @__PURE__ */ I(Bt, {
2890
- ids: a,
2891
- preview: !1
2892
- }),
2893
- g ? /* @__PURE__ */ I("p", {
2894
- role: "alert",
2895
- className: "text-sm text-destructive",
2896
- children: g
2897
- }) : null,
2898
- /* @__PURE__ */ I(Q, {
2899
- label: m ? "Retry payment" : t,
2900
- processing: u,
2901
- disabled: n || f || !c
2902
- }),
2903
- /* @__PURE__ */ I(Ut, {})
2904
- ]
2905
- });
2906
- }
2907
- //#endregion
2908
2940
  //#region src/order-payment.tsx
2909
- var tr = (e) => e.custodian === "platform" && e.rail === "nmi" && e.flow === "tokenize" && !e.status && !!e.config?.public_api_key, nr = (e) => e.status === "complete" || e.status === "processing", rr = 3e3;
2910
- function ir({ orderId: e, client: t, returnUrl: r, savedPaymentMethods: i = !0, serverCardEntry: a = !0, wallets: o = !1, fallbacks: c, onSettled: l, appearance: u, className: p }) {
2941
+ var nr = (e) => e.custodian === "platform" && e.rail === "nmi" && e.flow === "tokenize" && !e.status && !!e.config?.public_api_key, rr = (e) => e.status === "complete" || e.status === "processing", ir = 3e3;
2942
+ function ar({ orderId: e, client: t, returnUrl: r, savedPaymentMethods: i = !0, serverCardEntry: a = !0, wallets: o = !1, fallbacks: c, onSettled: l, appearance: u, className: p }) {
2911
2943
  let m = S(), h = T(), g = t ?? h.client, { config: _ } = y(), { config: v } = ee(), b = O(), [x, w] = P.useState(), [D, k] = P.useState([]), [A, te] = P.useState("new"), [ne, re] = P.useState(), [j, M] = P.useState(), [N, ie] = P.useState(!1), [z, ae] = P.useState(), [oe, B] = P.useState(!1), [se, ce] = P.useState(() => crypto.randomUUID()), le = P.useRef(null), ue = P.useRef(l);
2912
2944
  P.useEffect(() => {
2913
2945
  ue.current = l;
@@ -2929,23 +2961,23 @@ function ir({ orderId: e, client: t, returnUrl: r, savedPaymentMethods: i = !0,
2929
2961
  i,
2930
2962
  x?.collection_owner
2931
2963
  ]), P.useEffect(() => {
2932
- x && nr(x) && ue.current?.(x);
2964
+ x && rr(x) && ue.current?.(x);
2933
2965
  }, [x]);
2934
2966
  let de = x?.collection_owner === "engine" && x?.payment.status === "requires_action" && x.payment.next_action?.type === "solana_pay";
2935
2967
  P.useEffect(() => {
2936
2968
  if (!de || !x) return;
2937
2969
  let e = window.setInterval(() => {
2938
2970
  g.confirmOrder(x.id).then((e) => w(e.order), () => void 0);
2939
- }, rr);
2971
+ }, ir);
2940
2972
  return () => window.clearInterval(e);
2941
2973
  }, [
2942
2974
  de,
2943
2975
  g,
2944
2976
  x
2945
2977
  ]);
2946
- let V = P.useMemo(() => x?.collection_owner === "engine" ? x.payment_options : [], [x]), H = P.useMemo(() => (v?.payment.psps ?? []).filter((e) => V.some((t) => t.psp_id === e.psp_id)), [v, V]), fe = Gn(c, V, H), pe = V.filter((e) => !fe.has(e.psp_id)), me = H.filter((e) => !fe.has(e.psp_id)), he = me.filter((e) => {
2978
+ let V = P.useMemo(() => x?.collection_owner === "engine" ? x.payment_options : [], [x]), H = P.useMemo(() => (v?.payment.psps ?? []).filter((e) => V.some((t) => t.psp_id === e.psp_id)), [v, V]), fe = qn(c, V, H), pe = V.filter((e) => !fe.has(e.psp_id)), me = H.filter((e) => !fe.has(e.psp_id)), he = me.filter((e) => {
2947
2979
  let t = s(e);
2948
- return (t === "collect_js" || t === "stripe_elements" || tr(e)) && pe.some((t) => t.psp_id === e.psp_id && t.accepts.includes("new_card"));
2980
+ return (t === "collect_js" || t === "stripe_elements" || nr(e)) && pe.some((t) => t.psp_id === e.psp_id && t.accepts.includes("new_card"));
2949
2981
  }), ge = me.filter((e) => a || s(e) !== "card"), U = D.filter((e) => (e.status ?? "active") === "active" && e.reusable !== !1 && e.health?.active !== !1 && ge.some((t) => t.psp_id === e.psp_id || pe.some((n) => n.psp_id === t.psp_id && n.saved_payment_method_ids?.includes(e.id)))).map((e) => ({
2950
2982
  id: e.id,
2951
2983
  psp_id: e.psp_id ?? "",
@@ -2956,7 +2988,7 @@ function ir({ orderId: e, client: t, returnUrl: r, savedPaymentMethods: i = !0,
2956
2988
  role: "alert",
2957
2989
  className: "text-sm text-destructive",
2958
2990
  children: j
2959
- }) : /* @__PURE__ */ I(Un, {});
2991
+ }) : /* @__PURE__ */ I(Gn, {});
2960
2992
  let we = b[x.currency.toUpperCase()] ?? 2, Te = (e) => d(e, x.currency, we), Ee = _?.currencies?.find((e) => e.code.toUpperCase() === x.currency.toUpperCase()), De = Ce && Ee?.minor_decimals != null ? f(x.total, Ee.decimals, Ee.minor_decimals) : null, Oe = async (e) => {
2961
2993
  if (w(e.order), e.error) return M(e.order.payment.last_payment_error?.message ?? e.error.message), ce(crypto.randomUUID()), !1;
2962
2994
  let t = e.order.payment.next_action;
@@ -2966,7 +2998,7 @@ function ir({ orderId: e, client: t, returnUrl: r, savedPaymentMethods: i = !0,
2966
2998
  if (t.type !== "authenticate" || !n || !r) return M(m.t("paymentMethods.unavailable")), !1;
2967
2999
  if (le.current && t.psp_id === W?.psp_id) await le.current.handleNextAction(n);
2968
3000
  else {
2969
- let e = await (await Gt(r)).handleNextAction({ clientSecret: n });
3001
+ let e = await (await Kt(r)).handleNextAction({ clientSecret: n });
2970
3002
  if (e.error) throw Error(e.error.message);
2971
3003
  }
2972
3004
  return Oe(await g.confirmOrder(x.id));
@@ -3028,7 +3060,7 @@ function ir({ orderId: e, client: t, returnUrl: r, savedPaymentMethods: i = !0,
3028
3060
  })]
3029
3061
  })
3030
3062
  ]
3031
- }), de ? /* @__PURE__ */ I(Ln, {
3063
+ }), de ? /* @__PURE__ */ I(zn, {
3032
3064
  amountLabel: `${x.payment.next_action?.payload?.token_amount ?? ""} ${x.payment.next_action?.payload?.token_symbol ?? ""}`.trim(),
3033
3065
  payload: x.payment.next_action?.url ?? void 0,
3034
3066
  statusLine: "Waiting for your wallet's payment"
@@ -3080,7 +3112,7 @@ function ir({ orderId: e, client: t, returnUrl: r, savedPaymentMethods: i = !0,
3080
3112
  }) : /* @__PURE__ */ L("div", {
3081
3113
  className: "grid gap-4",
3082
3114
  children: [
3083
- !z && Ce && De ? /* @__PURE__ */ I(Wn, {
3115
+ !z && Ce && De ? /* @__PURE__ */ I(Kn, {
3084
3116
  publishableKey: Ce.config.publishable_key,
3085
3117
  amount: De,
3086
3118
  currency: x.currency,
@@ -3094,7 +3126,7 @@ function ir({ orderId: e, client: t, returnUrl: r, savedPaymentMethods: i = !0,
3094
3126
  className: "text-center text-[13px] text-muted-foreground",
3095
3127
  children: "or pay another way"
3096
3128
  }) : null,
3097
- U.length > 0 ? /* @__PURE__ */ I(Hn, {
3129
+ U.length > 0 ? /* @__PURE__ */ I(Wn, {
3098
3130
  methods: U,
3099
3131
  value: A,
3100
3132
  onChange: te,
@@ -3110,7 +3142,7 @@ function ir({ orderId: e, client: t, returnUrl: r, savedPaymentMethods: i = !0,
3110
3142
  value: e.psp_id,
3111
3143
  children: e.display_name
3112
3144
  }, e.psp_id))
3113
- }) : null, tr(W) ? /* @__PURE__ */ I(er, {
3145
+ }) : null, nr(W) ? /* @__PURE__ */ I(Wt, {
3114
3146
  publicKey: W.config.public_api_key,
3115
3147
  submitLabel: Me,
3116
3148
  disabled: N || !q,
@@ -3119,7 +3151,7 @@ function ir({ orderId: e, client: t, returnUrl: r, savedPaymentMethods: i = !0,
3119
3151
  psp_id: W.psp_id,
3120
3152
  billing_details: Et(e)
3121
3153
  }), !0)
3122
- }, W.psp_id) : s(W) === "collect_js" ? /* @__PURE__ */ I(gn, {
3154
+ }, W.psp_id) : s(W) === "collect_js" ? /* @__PURE__ */ I(_n, {
3123
3155
  tokenizationKey: W.config.tokenization_key,
3124
3156
  tokenizationURL: W.config.tokenization_url,
3125
3157
  submitLabel: Me,
@@ -3139,7 +3171,7 @@ function ir({ orderId: e, client: t, returnUrl: r, savedPaymentMethods: i = !0,
3139
3171
  }));
3140
3172
  },
3141
3173
  children: [
3142
- /* @__PURE__ */ I(an, {
3174
+ /* @__PURE__ */ I(on, {
3143
3175
  ref: le,
3144
3176
  psp: W,
3145
3177
  client: g,
@@ -3235,8 +3267,8 @@ function ir({ orderId: e, client: t, returnUrl: r, savedPaymentMethods: i = !0,
3235
3267
  }
3236
3268
  //#endregion
3237
3269
  //#region src/embedded-payment.tsx
3238
- var ar = "openrails.payment.complete", or = "openrails.payment.resize";
3239
- function sr({ url: e, onComplete: t, fallbacks: n, title: r = "Payment", className: i }) {
3270
+ var or = "openrails.payment.complete", sr = "openrails.payment.resize";
3271
+ function cr({ url: e, onComplete: t, fallbacks: n, title: r = "Payment", className: i }) {
3240
3272
  let a = P.useRef(null), [o, s] = P.useState(), c = P.useRef(t);
3241
3273
  P.useEffect(() => {
3242
3274
  c.current = t;
@@ -3271,7 +3303,7 @@ function sr({ url: e, onComplete: t, fallbacks: n, title: r = "Payment", classNa
3271
3303
  return window.addEventListener("message", t), () => window.removeEventListener("message", t);
3272
3304
  }, [l]), l ? /* @__PURE__ */ I("iframe", {
3273
3305
  ref: a,
3274
- src: Qn(e, n),
3306
+ src: er(e, n),
3275
3307
  title: r,
3276
3308
  className: i,
3277
3309
  allow: "payment *; publickey-credentials-get *; publickey-credentials-create *",
@@ -3284,7 +3316,7 @@ function sr({ url: e, onComplete: t, fallbacks: n, title: r = "Payment", classNa
3284
3316
  }
3285
3317
  //#endregion
3286
3318
  //#region src/cart.tsx
3287
- function cr({ client: e, onOrder: t, onSettled: n, fallbacks: r, appearance: i, className: a }) {
3319
+ function lr({ client: e, onOrder: t, onSettled: n, fallbacks: r, appearance: i, className: a }) {
3288
3320
  let o = S(), s = T(), c = e ?? s.client, l = O(), [u, f] = P.useState(), [p, m] = P.useState(), [h, g] = P.useState(), [_, v] = P.useState(!1), [y, b] = P.useState(() => crypto.randomUUID());
3289
3321
  P.useEffect(() => {
3290
3322
  let e = new AbortController();
@@ -3304,7 +3336,7 @@ function cr({ client: e, onOrder: t, onSettled: n, fallbacks: r, appearance: i,
3304
3336
  }
3305
3337
  }
3306
3338
  };
3307
- if (p && !t) return /* @__PURE__ */ I(ir, {
3339
+ if (p && !t) return /* @__PURE__ */ I(ar, {
3308
3340
  orderId: p.id,
3309
3341
  client: c,
3310
3342
  onSettled: n,
@@ -3316,7 +3348,7 @@ function cr({ client: e, onOrder: t, onSettled: n, fallbacks: r, appearance: i,
3316
3348
  role: "alert",
3317
3349
  className: "text-sm text-destructive",
3318
3350
  children: h
3319
- }) : /* @__PURE__ */ I(Un, {});
3351
+ }) : /* @__PURE__ */ I(Gn, {});
3320
3352
  let w = l[u.currency.toUpperCase()] ?? 2, D = (e) => d(e, u.currency, w), k = u.lines.length > 0 && u.lines.every((e) => !e.refusal), A = (e) => x(async () => {
3321
3353
  f(await c.setCartLine(e, { quantity: 0 })), b(crypto.randomUUID());
3322
3354
  }), ee = () => x(async () => {
@@ -3404,16 +3436,16 @@ function cr({ client: e, onOrder: t, onSettled: n, fallbacks: r, appearance: i,
3404
3436
  }
3405
3437
  //#endregion
3406
3438
  //#region src/authenticate.ts
3407
- async function lr(e, t, n, r) {
3439
+ async function ur(e, t, n, r) {
3408
3440
  let i = n.next_action, o = i?.payload?.client_secret;
3409
3441
  if (n.status !== "requires_action" || i?.type !== "authenticate" || !o || !a(r)) return n;
3410
- let s = await (await Gt(r.config.publishable_key)).handleNextAction({ clientSecret: o });
3442
+ let s = await (await Kt(r.config.publishable_key)).handleNextAction({ clientSecret: o });
3411
3443
  if (s.error) throw Error(s.error.message ?? "Authentication failed.");
3412
3444
  return e.confirmSubscriptionChange(t);
3413
3445
  }
3414
3446
  //#endregion
3415
3447
  //#region src/lib/price-label.ts
3416
- function ur(e, t, n, r) {
3448
+ function dr(e, t, n, r) {
3417
3449
  let i = be(e.unit_amount, e.currency, t, r) ?? `${e.unit_amount} ${e.currency}`, a = W(e.billing_interval_hours);
3418
3450
  if (a) return n.t("products.recurring", {
3419
3451
  amount: i,
@@ -3427,7 +3459,7 @@ function ur(e, t, n, r) {
3427
3459
  }
3428
3460
  //#endregion
3429
3461
  //#region src/modal.tsx
3430
- function dr({ open: e, onOpenChange: t, appearance: n, children: r }) {
3462
+ function fr({ open: e, onOpenChange: t, appearance: n, children: r }) {
3431
3463
  return /* @__PURE__ */ I(st, {
3432
3464
  open: e,
3433
3465
  onOpenChange: t,
@@ -3453,38 +3485,38 @@ function dr({ open: e, onOpenChange: t, appearance: n, children: r }) {
3453
3485
  })
3454
3486
  });
3455
3487
  }
3456
- function fr({ open: e, onOpenChange: t, ...n }) {
3457
- return /* @__PURE__ */ I(dr, {
3488
+ function pr({ open: e, onOpenChange: t, ...n }) {
3489
+ return /* @__PURE__ */ I(fr, {
3458
3490
  open: e,
3459
3491
  onOpenChange: t,
3460
3492
  appearance: n.appearance,
3461
- children: /* @__PURE__ */ I(ir, { ...n })
3493
+ children: /* @__PURE__ */ I(ar, { ...n })
3462
3494
  });
3463
3495
  }
3464
- function pr({ open: e, onOpenChange: t, appearance: n, ...r }) {
3465
- return /* @__PURE__ */ I(dr, {
3496
+ function mr({ open: e, onOpenChange: t, appearance: n, ...r }) {
3497
+ return /* @__PURE__ */ I(fr, {
3466
3498
  open: e,
3467
3499
  onOpenChange: t,
3468
3500
  appearance: n,
3469
- children: /* @__PURE__ */ I(sr, { ...r })
3501
+ children: /* @__PURE__ */ I(cr, { ...r })
3470
3502
  });
3471
3503
  }
3472
3504
  //#endregion
3473
3505
  //#region src/buy-button.tsx
3474
- function mr(e) {
3506
+ function hr(e) {
3475
3507
  if (!n(e) || e.code !== "already_owned") return;
3476
3508
  let t = e.metadata.owned_by;
3477
3509
  return typeof t == "string" && t.startsWith("ord_") ? t : void 0;
3478
3510
  }
3479
- var hr = (e) => typeof window < "u" && e.includes(window.location.origin);
3480
- function gr({ price: t, label: i, amount: a, returnUrl: o, fallbacks: s, onPaid: c, onSignInRequired: l, signedIn: u, appearance: d, className: f }) {
3511
+ var gr = (e) => typeof window < "u" && e.includes(window.location.origin);
3512
+ function _r({ price: t, label: i, amount: a, returnUrl: o, fallbacks: s, onPaid: c, onSignInRequired: l, signedIn: u, appearance: d, className: f }) {
3481
3513
  let p = S(), { locale: m } = k(), h = O(), g = x(d), { client: _ } = T(), [v, y] = P.useState(), [b, C] = P.useState(!1), [w, E] = P.useState(), D = (e) => {
3482
3514
  e.status === "complete" && (y(void 0), c(e));
3483
3515
  }, A = async () => {
3484
3516
  if (u === !1) return l();
3485
3517
  E(void 0), C(!0);
3486
3518
  try {
3487
- let { merchant: e } = await _.getCustomerConfig(), n = hr(e.embed_origins), i;
3519
+ let { merchant: e } = await _.getCustomerConfig(), n = gr(e.embed_origins), i;
3488
3520
  try {
3489
3521
  ({order: i} = await _.createOrder({
3490
3522
  lines: [{
@@ -3494,7 +3526,7 @@ function gr({ price: t, label: i, amount: a, returnUrl: o, fallbacks: s, onPaid:
3494
3526
  ...n ? { payUrl: { embedded: !0 } } : {}
3495
3527
  }));
3496
3528
  } catch (e) {
3497
- let t = mr(e);
3529
+ let t = hr(e);
3498
3530
  if (!t || n) throw e;
3499
3531
  y({
3500
3532
  kind: "inline",
@@ -3534,14 +3566,14 @@ function gr({ price: t, label: i, amount: a, returnUrl: o, fallbacks: s, onPaid:
3534
3566
  /* @__PURE__ */ I(U, {
3535
3567
  disabled: b,
3536
3568
  onClick: () => void A(),
3537
- children: i ?? ur(t, h, p, m)
3569
+ children: i ?? dr(t, h, p, m)
3538
3570
  }),
3539
3571
  w ? /* @__PURE__ */ I("span", {
3540
3572
  role: "alert",
3541
3573
  className: "text-sm text-destructive",
3542
3574
  children: w
3543
3575
  }) : null,
3544
- v?.kind === "inline" ? /* @__PURE__ */ I(fr, {
3576
+ v?.kind === "inline" ? /* @__PURE__ */ I(pr, {
3545
3577
  open: !0,
3546
3578
  onOpenChange: ee,
3547
3579
  orderId: v.orderId,
@@ -3550,7 +3582,7 @@ function gr({ price: t, label: i, amount: a, returnUrl: o, fallbacks: s, onPaid:
3550
3582
  appearance: d,
3551
3583
  onSettled: D
3552
3584
  }) : null,
3553
- v?.kind === "embedded" ? /* @__PURE__ */ I(pr, {
3585
+ v?.kind === "embedded" ? /* @__PURE__ */ I(mr, {
3554
3586
  open: !0,
3555
3587
  onOpenChange: ee,
3556
3588
  url: v.url,
@@ -3563,7 +3595,7 @@ function gr({ price: t, label: i, amount: a, returnUrl: o, fallbacks: s, onPaid:
3563
3595
  }
3564
3596
  //#endregion
3565
3597
  //#region src/product-list.tsx
3566
- function _r({ products: e, onPaid: t, onSignInRequired: n, signedIn: r, returnUrl: i, fallbacks: a, appearance: o, className: s }) {
3598
+ function vr({ products: e, onPaid: t, onSignInRequired: n, signedIn: r, returnUrl: i, fallbacks: a, appearance: o, className: s }) {
3567
3599
  let c = S(), l = x(o), u = e.filter((e) => !e.archived).map((e) => ({
3568
3600
  product: e,
3569
3601
  prices: e.prices.filter((e) => !e.archived && !e.customer_amount)
@@ -3577,7 +3609,7 @@ function _r({ products: e, onPaid: t, onSignInRequired: n, signedIn: r, returnUr
3577
3609
  children: e.display_name
3578
3610
  }), e.description ? /* @__PURE__ */ I(Pe, { children: e.description }) : null] }), /* @__PURE__ */ I(Ie, {
3579
3611
  className: "flex flex-wrap gap-2",
3580
- children: s.map((e) => /* @__PURE__ */ I(gr, {
3612
+ children: s.map((e) => /* @__PURE__ */ I(_r, {
3581
3613
  price: e,
3582
3614
  onPaid: t,
3583
3615
  onSignInRequired: n,
@@ -3595,6 +3627,6 @@ function _r({ products: e, onPaid: t, onSignInRequired: n, signedIn: r, returnUr
3595
3627
  });
3596
3628
  }
3597
3629
  //#endregion
3598
- export { Fn as AccountBilling, w as BillingProvider, Ue as BillingStatusBadge, he as BillingUiRoot, gr as BuyButton, Dn as CancelSubscriptionDialog, Ze as CardBrandPlate, cr as Cart, sr as EmbeddedPayment, ir as OrderPayment, ar as PAYMENT_COMPLETE_MESSAGE, or as PAYMENT_RESIZE_MESSAGE, Ge as PaymentHistory, Tn as PaymentMethodsPanel, _r as ProductList, _n as SavePaymentMethod, Pn as SubscriptionsPanel, gn as TokenizedCardForm, c as addAmounts, l as amountToDecimal, lr as authenticateChange, Ot as browserCountry, a as canAuthenticatePayment, m as canSavePaymentMethod, s as cardSetupDriver, o as createBillingClient, v as createTranslator, ne as defaultMessages, j as defineMessages, d as formatAmount, kt as initialCountry, b as interpolate, u as isAmount, g as pspConfigSchema, $n as readPaymentFragment, t as redeemAssertion, qe as resolveCardBrand, re as resolveMessages, i as routedPsps, je as statusTone, h as tokenSource, S as useMessages, Qn as withPaymentFallbacks };
3630
+ export { Ln as AccountBilling, w as BillingProvider, Ue as BillingStatusBadge, he as BillingUiRoot, _r as BuyButton, kn as CancelSubscriptionDialog, Ze as CardBrandPlate, lr as Cart, cr as EmbeddedPayment, ar as OrderPayment, or as PAYMENT_COMPLETE_MESSAGE, sr as PAYMENT_RESIZE_MESSAGE, Ge as PaymentHistory, Dn as PaymentMethodsPanel, vr as ProductList, vn as SavePaymentMethod, In as SubscriptionsPanel, _n as TokenizedCardForm, c as addAmounts, l as amountToDecimal, ur as authenticateChange, Ot as browserCountry, a as canAuthenticatePayment, m as canSavePaymentMethod, s as cardSetupDriver, o as createBillingClient, v as createTranslator, ne as defaultMessages, j as defineMessages, d as formatAmount, kt as initialCountry, b as interpolate, u as isAmount, g as pspConfigSchema, tr as readPaymentFragment, t as redeemAssertion, qe as resolveCardBrand, re as resolveMessages, i as routedPsps, je as statusTone, h as tokenSource, S as useMessages, er as withPaymentFallbacks };
3599
3631
 
3600
3632
  //# sourceMappingURL=index.js.map