@openrails/billing-ui 0.248.1 → 0.249.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.
- package/CHANGELOG.md +20 -0
- package/README.md +32 -27
- package/dist/buy-button.d.ts +9 -15
- package/dist/client/client.d.ts +12 -20
- package/dist/client/generated/error-codes.d.ts +1 -1
- package/dist/client/generated/routes.d.ts +8 -22
- package/dist/client/generated/wire.d.ts +42 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/types.d.ts +7 -3
- package/dist/{client-DoRYitD3.js → client-rFrCMrkn.js} +211 -226
- package/dist/client-rFrCMrkn.js.map +1 -0
- package/dist/client.js +1 -1
- package/dist/embedded-checkout.d.ts +5 -2
- package/dist/{hooks-DCSelDIZ.js → hooks-B1TffejB.js} +7 -20
- package/dist/hooks-B1TffejB.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +247 -235
- package/dist/index.js.map +1 -1
- package/dist/modal.d.ts +10 -1
- package/dist/product-list.d.ts +7 -13
- package/dist/react/hooks.d.ts +2 -15
- package/dist/react/index.d.ts +1 -1
- package/dist/react.js +2 -2
- package/package.json +1 -1
- package/dist/client-DoRYitD3.js.map +0 -1
- package/dist/hooks-DCSelDIZ.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 {
|
|
15
|
-
import {
|
|
14
|
+
import { E as e, O as t, S as n, _ as r, a as i, b as a, d as o, g as s, h as c, l, m as u, p as d, s as f, u as p, v as m, w as h, x as g, y as _ } from "./client-rFrCMrkn.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 j, y as M } from "./hooks-B1TffejB.js";
|
|
16
16
|
import { z as N } from "zod";
|
|
17
17
|
import * as P from "react";
|
|
18
18
|
import { Fragment as F, jsx as I, jsxs as L } from "react/jsx-runtime";
|
|
@@ -30,7 +30,7 @@ import { Radio as H } from "@base-ui/react/radio";
|
|
|
30
30
|
import { RadioGroup as pe } from "@base-ui/react/radio-group";
|
|
31
31
|
//#region src/scope.tsx
|
|
32
32
|
function me({ appearance: e, className: t, style: n, ...r }) {
|
|
33
|
-
let i =
|
|
33
|
+
let i = x(e);
|
|
34
34
|
return /* @__PURE__ */ I("div", {
|
|
35
35
|
"data-orck-theme": i["data-orck-theme"],
|
|
36
36
|
className: R(i.className, t),
|
|
@@ -117,7 +117,7 @@ function W(e, t) {
|
|
|
117
117
|
function G(e, t, n, r) {
|
|
118
118
|
if (!e) return null;
|
|
119
119
|
let i = n[t.toUpperCase()];
|
|
120
|
-
return i === void 0 ? null :
|
|
120
|
+
return i === void 0 ? null : d(e, t, i, r);
|
|
121
121
|
}
|
|
122
122
|
function K(e, t) {
|
|
123
123
|
return e ? e.billing_interval_hours ? _e(e.billing_interval_hours, t) : ve(e.access_duration_hours, t) ?? t.t("interval.once") : null;
|
|
@@ -228,7 +228,7 @@ function J({ className: e, ...t }) {
|
|
|
228
228
|
//#endregion
|
|
229
229
|
//#region src/account/section.tsx
|
|
230
230
|
function Ie({ title: e, description: t, action: n, appearance: r, className: i, children: a, ...o }) {
|
|
231
|
-
let s =
|
|
231
|
+
let s = x(r), c = P.useId();
|
|
232
232
|
return /* @__PURE__ */ I("section", {
|
|
233
233
|
"aria-labelledby": c,
|
|
234
234
|
className: R(s.className, ke, "block", i),
|
|
@@ -290,7 +290,7 @@ function Re({ title: e, description: t, action: n }) {
|
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
292
|
function Y({ error: e, message: t, onRetry: n }) {
|
|
293
|
-
let r =
|
|
293
|
+
let r = S();
|
|
294
294
|
return /* @__PURE__ */ L("div", {
|
|
295
295
|
role: "alert",
|
|
296
296
|
className: "flex flex-wrap items-center justify-between gap-3 rounded-lg bg-destructive/5 px-4 py-3",
|
|
@@ -338,7 +338,7 @@ var Ve = {
|
|
|
338
338
|
neutral: "bg-muted text-muted-foreground"
|
|
339
339
|
};
|
|
340
340
|
function He({ status: e, label: t, className: n }) {
|
|
341
|
-
let { t: r, messages: i } =
|
|
341
|
+
let { t: r, messages: i } = S(), a = e, o = t ?? (a in i.status ? r(`status.${a}`) : e.replace(/_/g, " "));
|
|
342
342
|
return /* @__PURE__ */ I(Be, {
|
|
343
343
|
"data-status": e,
|
|
344
344
|
className: R(Ve[Oe(e)], "font-medium", n),
|
|
@@ -353,7 +353,7 @@ function Ue(e, t) {
|
|
|
353
353
|
return n in t.messages.history.rail ? t.t(`history.rail.${n}`) : n || t.t("common.notAvailable");
|
|
354
354
|
}
|
|
355
355
|
function We({ appearance: e, className: t, ...n }) {
|
|
356
|
-
let r =
|
|
356
|
+
let r = S(), { t: i } = r, { locale: a } = k(), o = D(n), s = O(), c, l = o.payments;
|
|
357
357
|
c = l === null && o.error ? /* @__PURE__ */ I(Y, {
|
|
358
358
|
error: o.error,
|
|
359
359
|
onRetry: o.refetch
|
|
@@ -775,7 +775,7 @@ function pt({ className: e, ...t }) {
|
|
|
775
775
|
//#endregion
|
|
776
776
|
//#region src/components/ui/spinner.tsx
|
|
777
777
|
function X({ className: e, ...t }) {
|
|
778
|
-
let { t: n } =
|
|
778
|
+
let { t: n } = S();
|
|
779
779
|
return /* @__PURE__ */ I(z, {
|
|
780
780
|
icon: de,
|
|
781
781
|
strokeWidth: 2,
|
|
@@ -1689,8 +1689,8 @@ function hn({ tokenizationKey: e, tokenizationURL: t, onTokenized: n, submitLabe
|
|
|
1689
1689
|
};
|
|
1690
1690
|
return /* @__PURE__ */ I("div", {
|
|
1691
1691
|
className: R("orck", s),
|
|
1692
|
-
"data-orck-theme":
|
|
1693
|
-
style:
|
|
1692
|
+
"data-orck-theme": C(o),
|
|
1693
|
+
style: E(o),
|
|
1694
1694
|
children: /* @__PURE__ */ L("form", {
|
|
1695
1695
|
"aria-label": "Secure card setup",
|
|
1696
1696
|
autoComplete: "on",
|
|
@@ -1727,11 +1727,11 @@ function hn({ tokenizationKey: e, tokenizationURL: t, onTokenized: n, submitLabe
|
|
|
1727
1727
|
//#endregion
|
|
1728
1728
|
//#region src/save-payment-method.tsx
|
|
1729
1729
|
function gn(e) {
|
|
1730
|
-
let { t } =
|
|
1730
|
+
let { t } = S(), n = m(e.psp);
|
|
1731
1731
|
return n ? /* @__PURE__ */ L("div", {
|
|
1732
1732
|
className: R("orck grid gap-4", e.className),
|
|
1733
|
-
"data-orck-theme":
|
|
1734
|
-
style:
|
|
1733
|
+
"data-orck-theme": C(e.appearance),
|
|
1734
|
+
style: E(e.appearance),
|
|
1735
1735
|
children: [/* @__PURE__ */ I("p", {
|
|
1736
1736
|
className: "text-sm text-muted-foreground",
|
|
1737
1737
|
children: t("paymentMethods.saveNotice")
|
|
@@ -1742,9 +1742,9 @@ function gn(e) {
|
|
|
1742
1742
|
children: t("paymentMethods.unavailable")
|
|
1743
1743
|
});
|
|
1744
1744
|
}
|
|
1745
|
-
var _n = (e, t) => !
|
|
1745
|
+
var _n = (e, t) => !h(t) && t instanceof Error && t.message ? t.message : e.error(t);
|
|
1746
1746
|
function vn({ psp: e, onSaved: t, submitLabel: n, appearance: r, defaultCountry: i }) {
|
|
1747
|
-
let a =
|
|
1747
|
+
let a = S(), { client: o, notify: s } = T(), [c, l] = P.useState(0), [u, d] = P.useState();
|
|
1748
1748
|
return /* @__PURE__ */ L(F, { children: [u ? /* @__PURE__ */ I("p", {
|
|
1749
1749
|
role: "alert",
|
|
1750
1750
|
className: "text-sm text-destructive",
|
|
@@ -1776,7 +1776,7 @@ function vn({ psp: e, onSaved: t, submitLabel: n, appearance: r, defaultCountry:
|
|
|
1776
1776
|
}, c)] });
|
|
1777
1777
|
}
|
|
1778
1778
|
function yn({ psp: e, onSaved: t, submitLabel: n, defaultCountry: r }) {
|
|
1779
|
-
let i =
|
|
1779
|
+
let i = S(), { client: a, notify: o } = T(), s = P.useId().replace(/[^a-zA-Z0-9-]/g, ""), c = P.useMemo(() => ({
|
|
1780
1780
|
number: `orck-save-${s}-number`,
|
|
1781
1781
|
expiry: `orck-save-${s}-expiry`,
|
|
1782
1782
|
cvv: `orck-save-${s}-cvv`
|
|
@@ -1843,7 +1843,7 @@ function yn({ psp: e, onSaved: t, submitLabel: n, defaultCountry: r }) {
|
|
|
1843
1843
|
});
|
|
1844
1844
|
}
|
|
1845
1845
|
function bn({ psp: e, onSaved: t, submitLabel: n, defaultCountry: r }) {
|
|
1846
|
-
let i =
|
|
1846
|
+
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(() => Ot(r), [r]), g = async (e) => {
|
|
1847
1847
|
if (e.preventDefault(), !(!c.current || d)) {
|
|
1848
1848
|
f(!0), m(void 0);
|
|
1849
1849
|
try {
|
|
@@ -1909,8 +1909,8 @@ function Sn(e, t) {
|
|
|
1909
1909
|
function Cn(e, t) {
|
|
1910
1910
|
return e.status === 409 && e.code === "resource_conflict" ? t.t("paymentMethods.inUse") : t.error(e);
|
|
1911
1911
|
}
|
|
1912
|
-
function wn({ defaultCurrency: e, defaultCountry: t, appearance:
|
|
1913
|
-
let a =
|
|
1912
|
+
function wn({ defaultCurrency: e, defaultCountry: t, appearance: n, className: i }) {
|
|
1913
|
+
let a = S(), { t: o } = a, c = x(n), l = te(), [u, d] = P.useState(null), [f, p] = P.useState(null), [m, h] = P.useState(null), [g, v] = P.useState(!1), y = ee(), b = _(y.config?.payment.psps ?? []), C = b.filter(s), w = C.length > 0 ? null : r(b), { refetch: T } = y;
|
|
1914
1914
|
P.useEffect(() => {
|
|
1915
1915
|
if (w === null) return;
|
|
1916
1916
|
let e = setTimeout(T, w * 1e3);
|
|
@@ -1918,9 +1918,9 @@ function wn({ defaultCurrency: e, defaultCountry: t, appearance: r, className: i
|
|
|
1918
1918
|
}, [
|
|
1919
1919
|
w,
|
|
1920
1920
|
T,
|
|
1921
|
-
|
|
1921
|
+
y.config
|
|
1922
1922
|
]);
|
|
1923
|
-
let [E,
|
|
1923
|
+
let [E, D] = P.useState(), O = C.find((e) => e.psp_id === E) ?? C[0], [k, A] = xn(), ne = e?.toUpperCase(), j = async () => {
|
|
1924
1924
|
if (!u) return;
|
|
1925
1925
|
p(null);
|
|
1926
1926
|
let e = await l.remove(u.id);
|
|
@@ -1928,7 +1928,7 @@ function wn({ defaultCurrency: e, defaultCountry: t, appearance: r, className: i
|
|
|
1928
1928
|
p(Cn(e, a));
|
|
1929
1929
|
return;
|
|
1930
1930
|
}
|
|
1931
|
-
d(null), A(
|
|
1931
|
+
d(null), A(o("paymentMethods.removed"));
|
|
1932
1932
|
}, M = async (e) => {
|
|
1933
1933
|
if (!ne) return;
|
|
1934
1934
|
h(null);
|
|
@@ -1936,18 +1936,18 @@ function wn({ defaultCurrency: e, defaultCountry: t, appearance: r, className: i
|
|
|
1936
1936
|
t ? h({
|
|
1937
1937
|
id: e.id,
|
|
1938
1938
|
message: a.error(t)
|
|
1939
|
-
}) : A(
|
|
1939
|
+
}) : A(o("paymentMethods.defaultUpdated"));
|
|
1940
1940
|
}, N, F = l.methods;
|
|
1941
1941
|
N = F === null && l.error ? /* @__PURE__ */ I(Y, {
|
|
1942
1942
|
error: l.error,
|
|
1943
1943
|
onRetry: l.refetch
|
|
1944
1944
|
}) : F === null ? /* @__PURE__ */ I(Le, {}) : F.length === 0 ? /* @__PURE__ */ I(Re, {
|
|
1945
|
-
title:
|
|
1946
|
-
description:
|
|
1945
|
+
title: o("paymentMethods.empty"),
|
|
1946
|
+
description: o("paymentMethods.emptyDescription")
|
|
1947
1947
|
}) : /* @__PURE__ */ I("ul", {
|
|
1948
1948
|
className: "-my-1 divide-y divide-border",
|
|
1949
1949
|
children: F.map((e) => {
|
|
1950
|
-
let t = Sn(e, a), n = (e.subscriptions ?? []).map((e) => e.display_name).filter(Boolean), r = e.health?.expiry_status, i = e.default_currencies ?? [],
|
|
1950
|
+
let t = Sn(e, a), n = (e.subscriptions ?? []).map((e) => e.display_name).filter(Boolean), r = e.health?.expiry_status, i = e.default_currencies ?? [], s = l.pending[e.id], c = [n.length > 0 && o("paymentMethods.usedBy", { names: n.join(", ") })].filter(Boolean);
|
|
1951
1951
|
return /* @__PURE__ */ L("li", {
|
|
1952
1952
|
"data-testid": "payment-method-row",
|
|
1953
1953
|
"data-payment-method-id": e.id,
|
|
@@ -1970,7 +1970,7 @@ function wn({ defaultCurrency: e, defaultCountry: t, appearance: r, className: i
|
|
|
1970
1970
|
r === "expired" || r === "expiring_soon" ? /* @__PURE__ */ I(He, { status: r }) : e.health?.active === !1 ? /* @__PURE__ */ I(He, { status: "needs_attention" }) : null,
|
|
1971
1971
|
i.length > 0 ? /* @__PURE__ */ I(He, {
|
|
1972
1972
|
status: "default",
|
|
1973
|
-
label:
|
|
1973
|
+
label: o("paymentMethods.defaultFor", { currencies: i.join(", ") })
|
|
1974
1974
|
}) : null
|
|
1975
1975
|
]
|
|
1976
1976
|
}),
|
|
@@ -1991,20 +1991,20 @@ function wn({ defaultCurrency: e, defaultCountry: t, appearance: r, className: i
|
|
|
1991
1991
|
variant: "ghost",
|
|
1992
1992
|
size: "sm",
|
|
1993
1993
|
className: "text-muted-foreground",
|
|
1994
|
-
disabled: !!
|
|
1994
|
+
disabled: !!s,
|
|
1995
1995
|
onClick: () => void M(e),
|
|
1996
|
-
children: [
|
|
1996
|
+
children: [s === "default" ? /* @__PURE__ */ I(X, {}) : null, o("paymentMethods.makeDefault")]
|
|
1997
1997
|
}) : null, /* @__PURE__ */ I(U, {
|
|
1998
1998
|
variant: "ghost",
|
|
1999
1999
|
size: "icon-sm",
|
|
2000
2000
|
className: "text-muted-foreground hover:text-destructive",
|
|
2001
|
-
"aria-label":
|
|
2002
|
-
title:
|
|
2003
|
-
disabled: !!
|
|
2001
|
+
"aria-label": o("paymentMethods.removeLabel", { label: t }),
|
|
2002
|
+
title: o("paymentMethods.remove"),
|
|
2003
|
+
disabled: !!s,
|
|
2004
2004
|
onClick: () => {
|
|
2005
2005
|
p(null), d(e);
|
|
2006
2006
|
},
|
|
2007
|
-
children:
|
|
2007
|
+
children: s === "remove" ? /* @__PURE__ */ I(X, {}) : /* @__PURE__ */ I(z, {
|
|
2008
2008
|
icon: ue,
|
|
2009
2009
|
"aria-hidden": !0
|
|
2010
2010
|
})
|
|
@@ -2016,20 +2016,20 @@ function wn({ defaultCurrency: e, defaultCountry: t, appearance: r, className: i
|
|
|
2016
2016
|
});
|
|
2017
2017
|
let R = u ? l.pending[u.id] === "remove" : !1, re = u ? Sn(u, a) : "";
|
|
2018
2018
|
return /* @__PURE__ */ L(Ie, {
|
|
2019
|
-
title:
|
|
2020
|
-
description:
|
|
2021
|
-
appearance:
|
|
2019
|
+
title: o("paymentMethods.title"),
|
|
2020
|
+
description: o("paymentMethods.description"),
|
|
2021
|
+
appearance: n,
|
|
2022
2022
|
className: i,
|
|
2023
2023
|
"data-testid": "payment-methods-panel",
|
|
2024
2024
|
action: O ? /* @__PURE__ */ L(U, {
|
|
2025
2025
|
variant: "outline",
|
|
2026
2026
|
size: "sm",
|
|
2027
|
-
onClick: () =>
|
|
2027
|
+
onClick: () => v(!0),
|
|
2028
2028
|
children: [/* @__PURE__ */ I(z, {
|
|
2029
2029
|
icon: se,
|
|
2030
2030
|
"aria-hidden": !0,
|
|
2031
2031
|
"data-icon": "inline-start"
|
|
2032
|
-
}),
|
|
2032
|
+
}), o("paymentMethods.add")]
|
|
2033
2033
|
}) : null,
|
|
2034
2034
|
children: [
|
|
2035
2035
|
N,
|
|
@@ -2040,17 +2040,17 @@ function wn({ defaultCurrency: e, defaultCountry: t, appearance: r, className: i
|
|
|
2040
2040
|
onRetry: l.refetch
|
|
2041
2041
|
})
|
|
2042
2042
|
}) : null,
|
|
2043
|
-
|
|
2043
|
+
y.error ? /* @__PURE__ */ I("div", {
|
|
2044
2044
|
className: "pt-3",
|
|
2045
2045
|
children: /* @__PURE__ */ I(Y, {
|
|
2046
|
-
error:
|
|
2047
|
-
message:
|
|
2048
|
-
onRetry:
|
|
2046
|
+
error: y.error,
|
|
2047
|
+
message: o("paymentMethods.addUnavailable"),
|
|
2048
|
+
onRetry: y.refetch
|
|
2049
2049
|
})
|
|
2050
2050
|
}) : w === null ? null : /* @__PURE__ */ I("p", {
|
|
2051
2051
|
role: "status",
|
|
2052
2052
|
className: "pt-3 text-sm text-muted-foreground",
|
|
2053
|
-
children:
|
|
2053
|
+
children: o("paymentMethods.addUnavailable")
|
|
2054
2054
|
}),
|
|
2055
2055
|
k,
|
|
2056
2056
|
/* @__PURE__ */ I(Ze, {
|
|
@@ -2063,7 +2063,7 @@ function wn({ defaultCurrency: e, defaultCountry: t, appearance: r, className: i
|
|
|
2063
2063
|
"data-orck-theme": c["data-orck-theme"],
|
|
2064
2064
|
style: c.style,
|
|
2065
2065
|
children: [
|
|
2066
|
-
/* @__PURE__ */ L(tt, { children: [/* @__PURE__ */ I(rt, { children:
|
|
2066
|
+
/* @__PURE__ */ L(tt, { children: [/* @__PURE__ */ I(rt, { children: o("paymentMethods.removeTitle", { label: re }) }), /* @__PURE__ */ I(it, { children: o("paymentMethods.removeDescription") })] }),
|
|
2067
2067
|
f ? /* @__PURE__ */ I("p", {
|
|
2068
2068
|
role: "alert",
|
|
2069
2069
|
className: "text-sm text-destructive",
|
|
@@ -2071,31 +2071,31 @@ function wn({ defaultCurrency: e, defaultCountry: t, appearance: r, className: i
|
|
|
2071
2071
|
}) : null,
|
|
2072
2072
|
/* @__PURE__ */ L(nt, { children: [/* @__PURE__ */ I(at, {
|
|
2073
2073
|
disabled: R,
|
|
2074
|
-
children:
|
|
2074
|
+
children: o("common.cancel")
|
|
2075
2075
|
}), /* @__PURE__ */ L(U, {
|
|
2076
2076
|
variant: "destructive",
|
|
2077
2077
|
disabled: R,
|
|
2078
2078
|
onClick: () => void j(),
|
|
2079
|
-
children: [R ? /* @__PURE__ */ I(X, {}) : null,
|
|
2079
|
+
children: [R ? /* @__PURE__ */ I(X, {}) : null, o("paymentMethods.removeConfirm")]
|
|
2080
2080
|
})] })
|
|
2081
2081
|
]
|
|
2082
2082
|
})
|
|
2083
2083
|
}),
|
|
2084
2084
|
O ? /* @__PURE__ */ I(ot, {
|
|
2085
|
-
open:
|
|
2086
|
-
onOpenChange:
|
|
2085
|
+
open: g,
|
|
2086
|
+
onOpenChange: v,
|
|
2087
2087
|
children: /* @__PURE__ */ L(lt, {
|
|
2088
2088
|
className: `${c.className} ${ke} max-h-[calc(100dvh-2rem)] overflow-y-auto bg-popover text-popover-foreground`,
|
|
2089
2089
|
"data-orck-theme": c["data-orck-theme"],
|
|
2090
2090
|
style: c.style,
|
|
2091
2091
|
children: [
|
|
2092
|
-
/* @__PURE__ */ L(ut, { children: [/* @__PURE__ */ I(ft, { children:
|
|
2092
|
+
/* @__PURE__ */ L(ut, { children: [/* @__PURE__ */ I(ft, { children: o("paymentMethods.addTitle") }), /* @__PURE__ */ I(pt, { children: o("paymentMethods.addDescription") })] }),
|
|
2093
2093
|
C.length > 1 ? /* @__PURE__ */ L("label", {
|
|
2094
2094
|
className: "grid gap-1.5 text-sm",
|
|
2095
|
-
children: [
|
|
2095
|
+
children: [o("paymentMethods.provider"), /* @__PURE__ */ I("select", {
|
|
2096
2096
|
className: "h-9 rounded-md border border-input bg-transparent px-2",
|
|
2097
2097
|
value: O.psp_id,
|
|
2098
|
-
onChange: (e) =>
|
|
2098
|
+
onChange: (e) => D(e.target.value),
|
|
2099
2099
|
children: C.map((e) => /* @__PURE__ */ I("option", {
|
|
2100
2100
|
value: e.psp_id,
|
|
2101
2101
|
children: e.display_name
|
|
@@ -2105,9 +2105,9 @@ function wn({ defaultCurrency: e, defaultCountry: t, appearance: r, className: i
|
|
|
2105
2105
|
/* @__PURE__ */ I(gn, {
|
|
2106
2106
|
psp: O,
|
|
2107
2107
|
defaultCountry: t,
|
|
2108
|
-
appearance:
|
|
2108
|
+
appearance: n,
|
|
2109
2109
|
onSaved: () => {
|
|
2110
|
-
|
|
2110
|
+
v(!1), A(o("paymentMethods.added"));
|
|
2111
2111
|
}
|
|
2112
2112
|
}, O.psp_id)
|
|
2113
2113
|
]
|
|
@@ -2128,16 +2128,16 @@ function Tn({ className: e, ...t }) {
|
|
|
2128
2128
|
//#endregion
|
|
2129
2129
|
//#region src/account/cancel-dialog.tsx
|
|
2130
2130
|
function En({ open: e, onOpenChange: t, name: n, onChain: r = !1, pending: i, onConfirm: a, appearance: o }) {
|
|
2131
|
-
let s =
|
|
2132
|
-
if (g(!0),
|
|
2133
|
-
|
|
2131
|
+
let s = S(), { t: c } = s, l = x(o), u = P.useId(), d = P.useId(), [p, m] = P.useState(""), [h, g] = P.useState(!1), [_, v] = P.useState(null), y = i !== void 0, b = p.trim().length, C = b < 4, w = async () => {
|
|
2132
|
+
if (g(!0), C || y) return;
|
|
2133
|
+
v(null);
|
|
2134
2134
|
let e = await a(p);
|
|
2135
|
-
e ?
|
|
2136
|
-
},
|
|
2135
|
+
e ? f(e) || v(e) : t(!1);
|
|
2136
|
+
}, T = c(i === "cancel" && r ? "cancel.preparing" : i === "signing" ? "cancel.signing" : i === "confirming" ? "cancel.confirming" : y ? "cancel.working" : r ? "cancel.confirmWallet" : "cancel.confirm");
|
|
2137
2137
|
return /* @__PURE__ */ I(Ze, {
|
|
2138
2138
|
open: e,
|
|
2139
2139
|
onOpenChange: (e) => {
|
|
2140
|
-
!e &&
|
|
2140
|
+
!e && y || t(e);
|
|
2141
2141
|
},
|
|
2142
2142
|
children: /* @__PURE__ */ I(et, {
|
|
2143
2143
|
className: `${l.className} ${ke} bg-popover text-popover-foreground`,
|
|
@@ -2147,7 +2147,7 @@ function En({ open: e, onOpenChange: t, name: n, onChain: r = !1, pending: i, on
|
|
|
2147
2147
|
className: "grid gap-5",
|
|
2148
2148
|
noValidate: !0,
|
|
2149
2149
|
onSubmit: (e) => {
|
|
2150
|
-
e.preventDefault(),
|
|
2150
|
+
e.preventDefault(), w();
|
|
2151
2151
|
},
|
|
2152
2152
|
children: [
|
|
2153
2153
|
/* @__PURE__ */ L(tt, { children: [/* @__PURE__ */ I(rt, { children: c("cancel.title", { name: n }) }), /* @__PURE__ */ I(it, { children: c(r ? "cancel.solanaDescription" : "cancel.description") })] }),
|
|
@@ -2163,21 +2163,21 @@ function En({ open: e, onOpenChange: t, name: n, onChain: r = !1, pending: i, on
|
|
|
2163
2163
|
value: p,
|
|
2164
2164
|
maxLength: 500,
|
|
2165
2165
|
placeholder: c("cancel.reasonPlaceholder"),
|
|
2166
|
-
"aria-describedby":
|
|
2167
|
-
"aria-invalid": h &&
|
|
2168
|
-
disabled:
|
|
2166
|
+
"aria-describedby": d,
|
|
2167
|
+
"aria-invalid": h && C ? !0 : void 0,
|
|
2168
|
+
disabled: y,
|
|
2169
2169
|
required: !0,
|
|
2170
2170
|
rows: 3,
|
|
2171
2171
|
className: "[font:inherit]",
|
|
2172
2172
|
onChange: (e) => m(e.target.value),
|
|
2173
|
-
onBlur: () =>
|
|
2173
|
+
onBlur: () => b > 0 && g(!0)
|
|
2174
2174
|
}),
|
|
2175
2175
|
/* @__PURE__ */ L("div", {
|
|
2176
|
-
id:
|
|
2176
|
+
id: d,
|
|
2177
2177
|
className: "flex justify-between gap-3 text-xs text-muted-foreground",
|
|
2178
2178
|
children: [/* @__PURE__ */ I("span", {
|
|
2179
|
-
className: h &&
|
|
2180
|
-
children: h &&
|
|
2179
|
+
className: h && C ? "text-destructive" : "",
|
|
2180
|
+
children: h && C ? c("cancel.reasonTooShort", { min: 4 }) : ""
|
|
2181
2181
|
}), /* @__PURE__ */ I("span", {
|
|
2182
2182
|
className: "tabular-nums",
|
|
2183
2183
|
children: c("cancel.reasonHint", {
|
|
@@ -2194,13 +2194,13 @@ function En({ open: e, onOpenChange: t, name: n, onChain: r = !1, pending: i, on
|
|
|
2194
2194
|
children: s.error(_)
|
|
2195
2195
|
}) : null,
|
|
2196
2196
|
/* @__PURE__ */ L(nt, { children: [/* @__PURE__ */ I(at, {
|
|
2197
|
-
disabled:
|
|
2197
|
+
disabled: y,
|
|
2198
2198
|
children: c("cancel.keep")
|
|
2199
2199
|
}), /* @__PURE__ */ L(U, {
|
|
2200
2200
|
type: "submit",
|
|
2201
2201
|
variant: "destructive",
|
|
2202
|
-
disabled:
|
|
2203
|
-
children: [
|
|
2202
|
+
disabled: y,
|
|
2203
|
+
children: [y ? /* @__PURE__ */ I(X, {}) : null, T]
|
|
2204
2204
|
})] })
|
|
2205
2205
|
]
|
|
2206
2206
|
})
|
|
@@ -2235,7 +2235,7 @@ function An(e, t) {
|
|
|
2235
2235
|
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));
|
|
2236
2236
|
}
|
|
2237
2237
|
function jn({ subscription: e, name: t, onOpenChange: n, pending: r, onConfirm: i, appearance: a }) {
|
|
2238
|
-
let o =
|
|
2238
|
+
let o = x(a);
|
|
2239
2239
|
return /* @__PURE__ */ I(ot, {
|
|
2240
2240
|
open: e !== null,
|
|
2241
2241
|
onOpenChange: (e) => {
|
|
@@ -2257,19 +2257,19 @@ function jn({ subscription: e, name: t, onOpenChange: n, pending: r, onConfirm:
|
|
|
2257
2257
|
});
|
|
2258
2258
|
}
|
|
2259
2259
|
function Mn({ subscription: e, name: t, pending: n, onCancel: r, onConfirm: i }) {
|
|
2260
|
-
let a =
|
|
2260
|
+
let a = S(), { t: o } = a, s = P.useId(), c = te(), l = e.payment_method_id ?? kn, [u, d] = P.useState(l), [f, p] = P.useState(null), m = c.methods ? An(e, c.methods) : null, h = e.price?.currency?.toUpperCase(), g = h ? m?.find((e) => (e.default_currencies ?? []).includes(h)) : void 0, _ = [...g ? [{
|
|
2261
2261
|
id: kn,
|
|
2262
2262
|
card: g
|
|
2263
2263
|
}] : [], ...(m ?? []).map((e) => ({
|
|
2264
2264
|
id: e.id,
|
|
2265
2265
|
card: e
|
|
2266
|
-
}))],
|
|
2266
|
+
}))], v = _.some((e) => e.id !== l), y = async () => {
|
|
2267
2267
|
if (!u || u === l || n) return;
|
|
2268
2268
|
p(null);
|
|
2269
2269
|
let e = await i(u === kn ? null : u);
|
|
2270
2270
|
e && p(e);
|
|
2271
|
-
},
|
|
2272
|
-
return
|
|
2271
|
+
}, b;
|
|
2272
|
+
return b = m === null && c.error ? /* @__PURE__ */ I(Y, {
|
|
2273
2273
|
error: c.error,
|
|
2274
2274
|
onRetry: c.refetch
|
|
2275
2275
|
}) : m === null ? /* @__PURE__ */ I(Le, { rows: 2 }) : /* @__PURE__ */ I(Dn, {
|
|
@@ -2310,11 +2310,11 @@ function Mn({ subscription: e, name: t, pending: n, onCancel: r, onConfirm: i })
|
|
|
2310
2310
|
className: "grid gap-5",
|
|
2311
2311
|
noValidate: !0,
|
|
2312
2312
|
onSubmit: (e) => {
|
|
2313
|
-
e.preventDefault(),
|
|
2313
|
+
e.preventDefault(), y();
|
|
2314
2314
|
},
|
|
2315
2315
|
children: [
|
|
2316
|
-
/* @__PURE__ */ L(ut, { children: [/* @__PURE__ */ I(ft, { children: o("changeCard.title", { name: t }) }), /* @__PURE__ */ I(pt, { children: o(m !== null && !
|
|
2317
|
-
|
|
2316
|
+
/* @__PURE__ */ L(ut, { children: [/* @__PURE__ */ I(ft, { children: o("changeCard.title", { name: t }) }), /* @__PURE__ */ I(pt, { children: o(m !== null && !v ? "changeCard.none" : "changeCard.description") })] }),
|
|
2317
|
+
b,
|
|
2318
2318
|
f ? /* @__PURE__ */ I("p", {
|
|
2319
2319
|
role: "alert",
|
|
2320
2320
|
className: "text-sm text-destructive",
|
|
@@ -2337,21 +2337,21 @@ function Mn({ subscription: e, name: t, pending: n, onCancel: r, onConfirm: i })
|
|
|
2337
2337
|
//#endregion
|
|
2338
2338
|
//#region src/account/subscriptions-panel.tsx
|
|
2339
2339
|
function Nn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter: n, appearance: r, className: i, ...a }) {
|
|
2340
|
-
let o =
|
|
2340
|
+
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] = xn(), b = P.useMemo(() => {
|
|
2341
2341
|
let e = u.subscriptions ?? [];
|
|
2342
2342
|
return [...e.filter(Te), ...e.filter((e) => !Te(e))];
|
|
2343
|
-
}, [u.subscriptions]),
|
|
2343
|
+
}, [u.subscriptions]), x = async (e) => {
|
|
2344
2344
|
_(null);
|
|
2345
2345
|
let t = await u.resume(e.id);
|
|
2346
2346
|
t ? _({
|
|
2347
2347
|
id: e.id,
|
|
2348
2348
|
message: o.error(t)
|
|
2349
|
-
}) :
|
|
2350
|
-
}, C = f?.rail === "solana",
|
|
2351
|
-
return
|
|
2349
|
+
}) : y(s("subscriptions.resumed"));
|
|
2350
|
+
}, C = f?.rail === "solana", w;
|
|
2351
|
+
return w = u.subscriptions === null && u.error ? /* @__PURE__ */ I(Y, {
|
|
2352
2352
|
error: u.error,
|
|
2353
2353
|
onRetry: u.refetch
|
|
2354
|
-
}) : u.subscriptions === null ? /* @__PURE__ */ I(Le, {}) :
|
|
2354
|
+
}) : u.subscriptions === null ? /* @__PURE__ */ I(Le, {}) : b.length === 0 ? /* @__PURE__ */ I(Re, {
|
|
2355
2355
|
title: s("subscriptions.empty"),
|
|
2356
2356
|
description: s("subscriptions.emptyDescription"),
|
|
2357
2357
|
action: t ? /* @__PURE__ */ I("a", {
|
|
@@ -2367,11 +2367,11 @@ function Nn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter:
|
|
|
2367
2367
|
}) : null
|
|
2368
2368
|
}) : /* @__PURE__ */ I("ul", {
|
|
2369
2369
|
className: "-my-1 divide-y divide-border",
|
|
2370
|
-
children:
|
|
2371
|
-
let r = Te(t), i = u.pending[t.id], a = ye(t, o), l = t.price ? G(t.price.unit_amount, t.price.currency, d, c) : null, f = K(t.price, o), m = W(t.current_period_ends_at, c), v = W(t.access?.ends_at, c), y = W(t.ended_at ?? t.canceled_at ?? t.current_period_ends_at, c), b = Ee(t),
|
|
2370
|
+
children: b.map((t) => {
|
|
2371
|
+
let r = Te(t), i = u.pending[t.id], a = ye(t, o), l = t.price ? G(t.price.unit_amount, t.price.currency, d, c) : null, f = K(t.price, o), m = W(t.current_period_ends_at, c), v = W(t.access?.ends_at, c), y = W(t.ended_at ?? t.canceled_at ?? t.current_period_ends_at, c), b = Ee(t), S = r && !b && !!t.price?.billing_interval_hours, C = r ? S && m ? s("subscriptions.renews", { date: m }) : v ? s("subscriptions.endsOn", { date: v }) : s("subscriptions.noMorePayments") : t.status === "canceled" ? s("subscriptions.noMorePayments") : y && s("subscriptions.endedOn", { date: y }), w = t.rail === "solana" ? s("subscriptions.wallet") : t.card?.last4 ? s("subscriptions.paidWith", {
|
|
2372
2372
|
brand: xe(t.card.brand, s("paymentMethods.fallbackBrand")),
|
|
2373
2373
|
last4: t.card.last4
|
|
2374
|
-
}) : null, T = r && !b ? t.cancel_portal_url : null, E = Ce.has(t.status) && !b && !T && (t.rail !== "solana" || !!e),
|
|
2374
|
+
}) : null, T = r && !b ? t.cancel_portal_url : null, E = Ce.has(t.status) && !b && !T && (t.rail !== "solana" || !!e), D = (t.status === "active" || t.status === "past_due" || t.status === "awaiting_method" || t.status === "unverified") && !b && !T && t.rail !== "solana" && (t.collection_policy === "engine" || t.collection_policy === "nmi_schedule"), O = t.cancel_scheduled ? "cancel_scheduled" : t.status, k = n?.(t);
|
|
2375
2375
|
return /* @__PURE__ */ L("li", {
|
|
2376
2376
|
"data-testid": "subscription-row",
|
|
2377
2377
|
"data-subscription-id": t.id,
|
|
@@ -2385,7 +2385,7 @@ function Nn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter:
|
|
|
2385
2385
|
children: [/* @__PURE__ */ I("span", {
|
|
2386
2386
|
className: R("truncate text-sm font-semibold", !r && "text-muted-foreground"),
|
|
2387
2387
|
children: a
|
|
2388
|
-
}), /* @__PURE__ */ I(He, { status:
|
|
2388
|
+
}), /* @__PURE__ */ I(He, { status: O })]
|
|
2389
2389
|
}),
|
|
2390
2390
|
/* @__PURE__ */ I("p", {
|
|
2391
2391
|
className: "text-sm text-muted-foreground tabular-nums",
|
|
@@ -2419,7 +2419,7 @@ function Nn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter:
|
|
|
2419
2419
|
variant: "outline",
|
|
2420
2420
|
size: "sm",
|
|
2421
2421
|
disabled: !!i,
|
|
2422
|
-
onClick: () => void
|
|
2422
|
+
onClick: () => void x(t),
|
|
2423
2423
|
children: [i === "resume" ? /* @__PURE__ */ I(X, {}) : null, s(i === "resume" ? "subscriptions.updating" : "subscriptions.resume")]
|
|
2424
2424
|
}) : null,
|
|
2425
2425
|
T ? /* @__PURE__ */ L("a", {
|
|
@@ -2435,7 +2435,7 @@ function Nn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter:
|
|
|
2435
2435
|
"aria-hidden": !0
|
|
2436
2436
|
})]
|
|
2437
2437
|
}) : null,
|
|
2438
|
-
|
|
2438
|
+
D ? /* @__PURE__ */ L(U, {
|
|
2439
2439
|
variant: "outline",
|
|
2440
2440
|
size: "sm",
|
|
2441
2441
|
disabled: !!i,
|
|
@@ -2458,10 +2458,10 @@ function Nn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter:
|
|
|
2458
2458
|
}) : null
|
|
2459
2459
|
]
|
|
2460
2460
|
}),
|
|
2461
|
-
|
|
2461
|
+
k ? /* @__PURE__ */ I("div", {
|
|
2462
2462
|
"data-testid": "subscription-footer",
|
|
2463
2463
|
className: "border-t border-border/60 pt-3 @md:col-span-2",
|
|
2464
|
-
children:
|
|
2464
|
+
children: k
|
|
2465
2465
|
}) : null
|
|
2466
2466
|
]
|
|
2467
2467
|
}, t.id);
|
|
@@ -2473,7 +2473,7 @@ function Nn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter:
|
|
|
2473
2473
|
className: i,
|
|
2474
2474
|
"data-testid": "subscriptions-panel",
|
|
2475
2475
|
children: [
|
|
2476
|
-
|
|
2476
|
+
w,
|
|
2477
2477
|
u.subscriptions !== null && u.error ? /* @__PURE__ */ I("div", {
|
|
2478
2478
|
className: "pt-3",
|
|
2479
2479
|
children: /* @__PURE__ */ I(Y, {
|
|
@@ -2481,7 +2481,7 @@ function Nn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter:
|
|
|
2481
2481
|
onRetry: u.refetch
|
|
2482
2482
|
})
|
|
2483
2483
|
}) : null,
|
|
2484
|
-
|
|
2484
|
+
v,
|
|
2485
2485
|
/* @__PURE__ */ I(jn, {
|
|
2486
2486
|
subscription: m,
|
|
2487
2487
|
name: m ? ye(m, o) : "",
|
|
@@ -2491,7 +2491,7 @@ function Nn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter:
|
|
|
2491
2491
|
onConfirm: async (e) => {
|
|
2492
2492
|
if (!m) return null;
|
|
2493
2493
|
let t = await u.setPaymentMethod(m.id, e);
|
|
2494
|
-
return t || (h(null),
|
|
2494
|
+
return t || (h(null), y(s("changeCard.done"))), t;
|
|
2495
2495
|
}
|
|
2496
2496
|
}, `card-${m?.id ?? "closed"}`),
|
|
2497
2497
|
/* @__PURE__ */ I(En, {
|
|
@@ -2504,7 +2504,7 @@ function Nn({ sendSolanaTransaction: e, plansHref: t, renderSubscriptionFooter:
|
|
|
2504
2504
|
onConfirm: async (t) => {
|
|
2505
2505
|
if (!f) return null;
|
|
2506
2506
|
let n = await u.cancel(f.id, t, e);
|
|
2507
|
-
return n ||
|
|
2507
|
+
return n || y(s("cancel.done")), n;
|
|
2508
2508
|
}
|
|
2509
2509
|
}, f?.id ?? "closed")
|
|
2510
2510
|
]
|
|
@@ -2772,25 +2772,25 @@ function Un({ publishableKey: e, amount: t, currency: n, onPaymentMethod: r, onA
|
|
|
2772
2772
|
//#endregion
|
|
2773
2773
|
//#region src/order-checkout.tsx
|
|
2774
2774
|
var Wn = (e) => e.status === "complete" || e.status === "processing", Gn = 3e3;
|
|
2775
|
-
function Kn({ orderId: e, client: t, returnUrl: n, savedPaymentMethods: r = !0, serverCardEntry: i = !0, wallets:
|
|
2776
|
-
let
|
|
2775
|
+
function Kn({ orderId: e, client: t, returnUrl: n, savedPaymentMethods: r = !0, serverCardEntry: i = !0, wallets: a = !1, onSettled: s, appearance: c, className: l }) {
|
|
2776
|
+
let u = S(), f = T(), p = t ?? f.client, { config: g } = y(), { config: _ } = ee(), v = O(), [b, x] = P.useState(), [w, D] = P.useState([]), [k, A] = P.useState("new"), [te, ne] = P.useState(), [j, M] = P.useState(), [N, re] = P.useState(!1), [ie, ae] = P.useState(!1), [oe, z] = P.useState(() => crypto.randomUUID()), se = P.useRef(null), ce = P.useRef(s);
|
|
2777
2777
|
P.useEffect(() => {
|
|
2778
2778
|
ce.current = s;
|
|
2779
2779
|
}), P.useEffect(() => {
|
|
2780
2780
|
let t = new AbortController();
|
|
2781
|
-
return
|
|
2782
|
-
t.signal.aborted || M(
|
|
2781
|
+
return p.getOrder(e, t.signal).then(x, (e) => {
|
|
2782
|
+
t.signal.aborted || M(u.error(e));
|
|
2783
2783
|
}), () => t.abort();
|
|
2784
2784
|
}, [
|
|
2785
|
-
|
|
2785
|
+
p,
|
|
2786
2786
|
e,
|
|
2787
|
-
|
|
2787
|
+
u
|
|
2788
2788
|
]), P.useEffect(() => {
|
|
2789
2789
|
if (!r || b?.collection_owner !== "engine") return;
|
|
2790
2790
|
let e = new AbortController();
|
|
2791
|
-
return
|
|
2791
|
+
return p.listPaymentMethods({ signal: e.signal }).then((e) => D(e.data), () => void 0), () => e.abort();
|
|
2792
2792
|
}, [
|
|
2793
|
-
|
|
2793
|
+
p,
|
|
2794
2794
|
r,
|
|
2795
2795
|
b?.collection_owner
|
|
2796
2796
|
]), P.useEffect(() => {
|
|
@@ -2800,52 +2800,52 @@ function Kn({ orderId: e, client: t, returnUrl: n, savedPaymentMethods: r = !0,
|
|
|
2800
2800
|
P.useEffect(() => {
|
|
2801
2801
|
if (!le || !b) return;
|
|
2802
2802
|
let e = window.setInterval(() => {
|
|
2803
|
-
|
|
2803
|
+
p.confirmOrder(b.id).then((e) => x(e.order), () => void 0);
|
|
2804
2804
|
}, Gn);
|
|
2805
2805
|
return () => window.clearInterval(e);
|
|
2806
2806
|
}, [
|
|
2807
2807
|
le,
|
|
2808
|
-
|
|
2808
|
+
p,
|
|
2809
2809
|
b
|
|
2810
2810
|
]);
|
|
2811
2811
|
let ue = P.useMemo(() => b?.collection_owner === "engine" ? b.payment_options : [], [b]), de = P.useMemo(() => (_?.payment.psps ?? []).filter((e) => ue.some((t) => t.psp_id === e.psp_id)), [_, ue]), B = de.filter((e) => {
|
|
2812
|
-
let t =
|
|
2812
|
+
let t = m(e);
|
|
2813
2813
|
return (t === "collect_js" || t === "stripe_elements") && ue.some((t) => t.psp_id === e.psp_id && t.accepts.includes("new_card"));
|
|
2814
|
-
}), V = de.filter((e) => i ||
|
|
2814
|
+
}), V = de.filter((e) => i || m(e) !== "card"), fe = w.filter((e) => (e.status ?? "active") === "active" && e.reusable !== !1 && e.health?.active !== !1 && V.some((t) => t.psp_id === e.psp_id)).map((e) => ({
|
|
2815
2815
|
id: e.id,
|
|
2816
2816
|
psp_id: e.psp_id ?? "",
|
|
2817
2817
|
rail: e.rail ?? "",
|
|
2818
2818
|
card: e.card ?? void 0
|
|
2819
|
-
})), H = B.find((e) => e.psp_id === te) ?? B[0], pe = ue.find((e) => e.accepts.includes("solana_pay")), me = de.filter((e) =>
|
|
2819
|
+
})), H = B.find((e) => e.psp_id === te) ?? B[0], pe = ue.find((e) => e.accepts.includes("solana_pay")), me = de.filter((e) => m(e) === null && ue.some((t) => t.psp_id === e.psp_id && t.accepts.includes("redirect"))), he = pe ? _?.payment.solana?.tokens ?? [] : [], U = a ? B.find((e) => m(e) === "stripe_elements" && !!e.config?.publishable_key) : void 0;
|
|
2820
2820
|
if (!b) return j ? /* @__PURE__ */ I("p", {
|
|
2821
2821
|
role: "alert",
|
|
2822
2822
|
className: "text-sm text-destructive",
|
|
2823
2823
|
children: j
|
|
2824
2824
|
}) : /* @__PURE__ */ I(Hn, {});
|
|
2825
|
-
let ge =
|
|
2826
|
-
if (
|
|
2825
|
+
let ge = v[b.currency.toUpperCase()] ?? 2, _e = (e) => d(e, b.currency, ge), ve = g?.currencies?.find((e) => e.code.toUpperCase() === b.currency.toUpperCase()), W = U && ve?.minor_decimals != null ? o(b.total, ve.decimals, ve.minor_decimals) : null, G = async (e) => {
|
|
2826
|
+
if (x(e.order), e.error) return M(e.order.payment.last_payment_error?.message ?? e.error.message), z(crypto.randomUUID()), !1;
|
|
2827
2827
|
let t = e.order.payment.next_action;
|
|
2828
2828
|
if (e.order.collection_owner !== "engine" || e.order.payment.status !== "requires_action" || !t) return !0;
|
|
2829
2829
|
if (t.type === "redirect_to_url" && t.url) return window.location.assign(t.url), !0;
|
|
2830
2830
|
let n = t.payload?.client_secret, r = (_?.payment.psps.find((e) => e.psp_id === t.psp_id))?.config?.publishable_key;
|
|
2831
|
-
if (t.type !== "authenticate" || !n || !r) return M(
|
|
2831
|
+
if (t.type !== "authenticate" || !n || !r) return M(u.t("paymentMethods.unavailable")), !1;
|
|
2832
2832
|
if (se.current && t.psp_id === H?.psp_id) await se.current.handleNextAction(n);
|
|
2833
2833
|
else {
|
|
2834
2834
|
let e = await (await Wt(r)).handleNextAction({ clientSecret: n });
|
|
2835
2835
|
if (e.error) throw Error(e.error.message);
|
|
2836
2836
|
}
|
|
2837
|
-
return G(await
|
|
2837
|
+
return G(await p.confirmOrder(b.id));
|
|
2838
2838
|
}, K = async (e) => {
|
|
2839
2839
|
if (N || b.collection_owner !== "engine") return !1;
|
|
2840
2840
|
re(!0), M(void 0);
|
|
2841
2841
|
try {
|
|
2842
|
-
return await G(await
|
|
2842
|
+
return await G(await p.payOrder(b.id, {
|
|
2843
2843
|
payment: await e(),
|
|
2844
2844
|
expectedTotal: b.total,
|
|
2845
2845
|
idempotencyKey: oe
|
|
2846
2846
|
}));
|
|
2847
2847
|
} catch (e) {
|
|
2848
|
-
return M(!
|
|
2848
|
+
return M(!h(e) && e instanceof Error && e.message ? e.message : u.error(e)), z(crypto.randomUUID()), !1;
|
|
2849
2849
|
} finally {
|
|
2850
2850
|
re(!1);
|
|
2851
2851
|
}
|
|
@@ -2855,7 +2855,7 @@ function Kn({ orderId: e, client: t, returnUrl: n, savedPaymentMethods: r = !0,
|
|
|
2855
2855
|
try {
|
|
2856
2856
|
await G({ order: b });
|
|
2857
2857
|
} catch (e) {
|
|
2858
|
-
M(!
|
|
2858
|
+
M(!h(e) && e instanceof Error && e.message ? e.message : u.error(e));
|
|
2859
2859
|
} finally {
|
|
2860
2860
|
re(!1);
|
|
2861
2861
|
}
|
|
@@ -2863,8 +2863,8 @@ function Kn({ orderId: e, client: t, returnUrl: n, savedPaymentMethods: r = !0,
|
|
|
2863
2863
|
}, be = b.collection_owner === "engine" && b.status === "open" && b.payment.status === "requires_action" && b.payment.next_action?.type === "authenticate", xe = `Pay ${_e(b.usage?.amount_due ?? b.total)}`, q = b.collection_owner === "engine" && (b.status === "open" || b.status === "uncollectible" && !!b.usage) && b.payment.status === "requires_payment_method";
|
|
2864
2864
|
return /* @__PURE__ */ L("div", {
|
|
2865
2865
|
className: R("orck grid gap-5", l),
|
|
2866
|
-
"data-orck-theme":
|
|
2867
|
-
style:
|
|
2866
|
+
"data-orck-theme": C(c),
|
|
2867
|
+
style: E(c),
|
|
2868
2868
|
children: [/* @__PURE__ */ L("div", {
|
|
2869
2869
|
className: "grid",
|
|
2870
2870
|
children: [
|
|
@@ -2941,12 +2941,12 @@ function Kn({ orderId: e, client: t, returnUrl: n, savedPaymentMethods: r = !0,
|
|
|
2941
2941
|
}) : null,
|
|
2942
2942
|
fe.length > 0 ? /* @__PURE__ */ I(Vn, {
|
|
2943
2943
|
methods: fe,
|
|
2944
|
-
value:
|
|
2945
|
-
onChange:
|
|
2944
|
+
value: k,
|
|
2945
|
+
onChange: A,
|
|
2946
2946
|
disabled: N || !q,
|
|
2947
2947
|
idPrefix: `orck-order-${b.id}`
|
|
2948
2948
|
}) : null,
|
|
2949
|
-
|
|
2949
|
+
k === "new" ? H ? /* @__PURE__ */ L(F, { children: [B.length > 1 ? /* @__PURE__ */ I("select", {
|
|
2950
2950
|
"aria-label": "Pay with",
|
|
2951
2951
|
className: "h-9 rounded-md border border-border bg-transparent px-2 text-sm",
|
|
2952
2952
|
value: H.psp_id,
|
|
@@ -2955,7 +2955,7 @@ function Kn({ orderId: e, client: t, returnUrl: n, savedPaymentMethods: r = !0,
|
|
|
2955
2955
|
value: e.psp_id,
|
|
2956
2956
|
children: e.display_name
|
|
2957
2957
|
}, e.psp_id))
|
|
2958
|
-
}) : null,
|
|
2958
|
+
}) : null, m(H) === "collect_js" ? /* @__PURE__ */ I(hn, {
|
|
2959
2959
|
tokenizationKey: H.config.tokenization_key,
|
|
2960
2960
|
tokenizationURL: H.config.tokenization_url,
|
|
2961
2961
|
submitLabel: xe,
|
|
@@ -2978,9 +2978,9 @@ function Kn({ orderId: e, client: t, returnUrl: n, savedPaymentMethods: r = !0,
|
|
|
2978
2978
|
/* @__PURE__ */ I(rn, {
|
|
2979
2979
|
ref: se,
|
|
2980
2980
|
psp: H,
|
|
2981
|
-
client:
|
|
2982
|
-
unavailableMessage:
|
|
2983
|
-
verificationPendingMessage:
|
|
2981
|
+
client: p,
|
|
2982
|
+
unavailableMessage: u.t("paymentMethods.unavailable"),
|
|
2983
|
+
verificationPendingMessage: u.t("paymentMethods.verificationPending")
|
|
2984
2984
|
}, H.psp_id),
|
|
2985
2985
|
/* @__PURE__ */ I(Q, {
|
|
2986
2986
|
label: xe,
|
|
@@ -2992,11 +2992,11 @@ function Kn({ orderId: e, client: t, returnUrl: n, savedPaymentMethods: r = !0,
|
|
|
2992
2992
|
})] }) : pe || me.length > 0 ? null : /* @__PURE__ */ I("p", {
|
|
2993
2993
|
role: "alert",
|
|
2994
2994
|
className: "text-sm text-destructive",
|
|
2995
|
-
children:
|
|
2995
|
+
children: u.t("paymentMethods.unavailable")
|
|
2996
2996
|
}) : /* @__PURE__ */ I("form", {
|
|
2997
2997
|
className: "grid gap-4",
|
|
2998
2998
|
onSubmit: (e) => {
|
|
2999
|
-
e.preventDefault(), K(async () => ({ payment_method_id:
|
|
2999
|
+
e.preventDefault(), K(async () => ({ payment_method_id: k }));
|
|
3000
3000
|
},
|
|
3001
3001
|
children: /* @__PURE__ */ I(Q, {
|
|
3002
3002
|
label: xe,
|
|
@@ -3103,14 +3103,14 @@ function Yn({ url: e, onComplete: t, title: n = "Checkout", className: r }) {
|
|
|
3103
3103
|
//#endregion
|
|
3104
3104
|
//#region src/cart.tsx
|
|
3105
3105
|
function Xn({ client: e, onOrder: t, onSettled: n, appearance: r, className: i }) {
|
|
3106
|
-
let a =
|
|
3106
|
+
let a = S(), o = T(), s = e ?? o.client, c = O(), [l, u] = P.useState(), [f, p] = P.useState(), [m, h] = P.useState(), [g, _] = P.useState(!1), [v, y] = P.useState(() => crypto.randomUUID());
|
|
3107
3107
|
P.useEffect(() => {
|
|
3108
3108
|
let e = new AbortController();
|
|
3109
|
-
return s.getCart(e.signal).then(
|
|
3109
|
+
return s.getCart(e.signal).then(u, (t) => {
|
|
3110
3110
|
e.signal.aborted || h(a.error(t));
|
|
3111
3111
|
}), () => e.abort();
|
|
3112
3112
|
}, [s, a]);
|
|
3113
|
-
let
|
|
3113
|
+
let b = async (e) => {
|
|
3114
3114
|
if (!g) {
|
|
3115
3115
|
_(!0), h(void 0);
|
|
3116
3116
|
try {
|
|
@@ -3134,21 +3134,21 @@ function Xn({ client: e, onOrder: t, onSettled: n, appearance: r, className: i }
|
|
|
3134
3134
|
className: "text-sm text-destructive",
|
|
3135
3135
|
children: m
|
|
3136
3136
|
}) : /* @__PURE__ */ I(Hn, {});
|
|
3137
|
-
let
|
|
3138
|
-
|
|
3139
|
-
}),
|
|
3137
|
+
let x = c[l.currency.toUpperCase()] ?? 2, w = (e) => d(e, l.currency, x), D = l.lines.length > 0 && l.lines.every((e) => !e.refusal), k = (e) => b(async () => {
|
|
3138
|
+
u(await s.setCartLine(e, { quantity: 0 })), y(crypto.randomUUID());
|
|
3139
|
+
}), A = () => b(async () => {
|
|
3140
3140
|
let e = await s.createOrder({
|
|
3141
3141
|
cart: !0,
|
|
3142
3142
|
expectedTotal: l.total,
|
|
3143
|
-
idempotencyKey:
|
|
3143
|
+
idempotencyKey: v
|
|
3144
3144
|
});
|
|
3145
3145
|
if (e.error) throw e.error;
|
|
3146
3146
|
p(e.order), t?.(e.order);
|
|
3147
3147
|
});
|
|
3148
3148
|
return /* @__PURE__ */ L("div", {
|
|
3149
3149
|
className: R("orck grid gap-5", i),
|
|
3150
|
-
"data-orck-theme":
|
|
3151
|
-
style:
|
|
3150
|
+
"data-orck-theme": C(r),
|
|
3151
|
+
style: E(r),
|
|
3152
3152
|
children: [
|
|
3153
3153
|
l.lines.length === 0 ? /* @__PURE__ */ I("p", {
|
|
3154
3154
|
role: "status",
|
|
@@ -3163,7 +3163,7 @@ function Xn({ client: e, onOrder: t, onSettled: n, appearance: r, className: i }
|
|
|
3163
3163
|
className: "flex items-start justify-between gap-4",
|
|
3164
3164
|
children: [/* @__PURE__ */ I("span", { children: e.description || e.price_id }), /* @__PURE__ */ I("span", {
|
|
3165
3165
|
className: "whitespace-nowrap tabular-nums",
|
|
3166
|
-
children:
|
|
3166
|
+
children: w(e.amount)
|
|
3167
3167
|
})]
|
|
3168
3168
|
}),
|
|
3169
3169
|
/* @__PURE__ */ L("div", {
|
|
@@ -3175,7 +3175,7 @@ function Xn({ client: e, onOrder: t, onSettled: n, appearance: r, className: i }
|
|
|
3175
3175
|
type: "button",
|
|
3176
3176
|
className: "text-[13px] text-muted-foreground underline",
|
|
3177
3177
|
disabled: g,
|
|
3178
|
-
onClick: () => void
|
|
3178
|
+
onClick: () => void k(e.price_id),
|
|
3179
3179
|
children: "Remove"
|
|
3180
3180
|
})]
|
|
3181
3181
|
}),
|
|
@@ -3188,25 +3188,25 @@ function Xn({ client: e, onOrder: t, onSettled: n, appearance: r, className: i }
|
|
|
3188
3188
|
className: "flex items-start justify-between gap-4 pt-3 text-[13.5px] font-semibold",
|
|
3189
3189
|
children: [/* @__PURE__ */ I("span", { children: "Total" }), /* @__PURE__ */ I("span", {
|
|
3190
3190
|
className: "whitespace-nowrap tabular-nums",
|
|
3191
|
-
children:
|
|
3191
|
+
children: w(l.total)
|
|
3192
3192
|
})]
|
|
3193
3193
|
})]
|
|
3194
3194
|
}),
|
|
3195
3195
|
l.lines.length > 0 ? /* @__PURE__ */ L("form", {
|
|
3196
3196
|
className: "grid gap-2",
|
|
3197
3197
|
onSubmit: (e) => {
|
|
3198
|
-
e.preventDefault(),
|
|
3198
|
+
e.preventDefault(), A();
|
|
3199
3199
|
},
|
|
3200
3200
|
children: [/* @__PURE__ */ I(Q, {
|
|
3201
3201
|
label: "Check out",
|
|
3202
3202
|
processing: g,
|
|
3203
|
-
disabled: !
|
|
3203
|
+
disabled: !D
|
|
3204
3204
|
}), /* @__PURE__ */ I("button", {
|
|
3205
3205
|
type: "button",
|
|
3206
3206
|
className: "text-[13px] text-muted-foreground underline",
|
|
3207
3207
|
disabled: g,
|
|
3208
|
-
onClick: () => void
|
|
3209
|
-
await s.clearCart(),
|
|
3208
|
+
onClick: () => void b(async () => {
|
|
3209
|
+
await s.clearCart(), u(await s.getCart());
|
|
3210
3210
|
}),
|
|
3211
3211
|
children: "Empty cart"
|
|
3212
3212
|
})]
|
|
@@ -3223,7 +3223,7 @@ function Xn({ client: e, onOrder: t, onSettled: n, appearance: r, className: i }
|
|
|
3223
3223
|
//#region src/authenticate.ts
|
|
3224
3224
|
async function Zn(e, t, n, r) {
|
|
3225
3225
|
let i = n.next_action, a = i?.payload?.client_secret;
|
|
3226
|
-
if (n.status !== "requires_action" || i?.type !== "authenticate" || !a || !
|
|
3226
|
+
if (n.status !== "requires_action" || i?.type !== "authenticate" || !a || !c(r)) return n;
|
|
3227
3227
|
let o = await (await Wt(r.config.publishable_key)).handleNextAction({ clientSecret: a });
|
|
3228
3228
|
if (o.error) throw Error(o.error.message ?? "Authentication failed.");
|
|
3229
3229
|
return e.confirmSubscriptionChange(t);
|
|
@@ -3244,14 +3244,14 @@ function Qn(e, t, n, r) {
|
|
|
3244
3244
|
}
|
|
3245
3245
|
//#endregion
|
|
3246
3246
|
//#region src/modal.tsx
|
|
3247
|
-
function $n({ open: e, onOpenChange: t,
|
|
3247
|
+
function $n({ open: e, onOpenChange: t, appearance: n, children: r }) {
|
|
3248
3248
|
return /* @__PURE__ */ I(ot, {
|
|
3249
3249
|
open: e,
|
|
3250
3250
|
onOpenChange: t,
|
|
3251
3251
|
children: /* @__PURE__ */ L(lt, {
|
|
3252
3252
|
className: "orck max-h-[calc(100dvh-2rem)] w-[460px] max-w-[calc(100vw-2rem)] gap-0 overflow-hidden bg-background p-6 text-foreground ring-0 [&>[data-slot=dialog-close]]:top-5 [&>[data-slot=dialog-close]]:right-5 [&>[data-slot=dialog-close]]:text-foreground",
|
|
3253
|
-
"data-orck-theme":
|
|
3254
|
-
style:
|
|
3253
|
+
"data-orck-theme": C(n),
|
|
3254
|
+
style: E(n),
|
|
3255
3255
|
showCloseButton: !0,
|
|
3256
3256
|
children: [
|
|
3257
3257
|
/* @__PURE__ */ I(ft, {
|
|
@@ -3264,139 +3264,151 @@ function $n({ open: e, onOpenChange: t, ...n }) {
|
|
|
3264
3264
|
}),
|
|
3265
3265
|
/* @__PURE__ */ I("div", {
|
|
3266
3266
|
className: "max-h-[calc(100dvh-5rem)] min-h-0 touch-pan-y [scrollbar-width:none] overflow-y-auto overscroll-contain pt-7 pr-6 [-webkit-overflow-scrolling:touch] [&::-webkit-scrollbar]:hidden",
|
|
3267
|
-
children:
|
|
3267
|
+
children: r
|
|
3268
3268
|
})
|
|
3269
3269
|
]
|
|
3270
3270
|
})
|
|
3271
3271
|
});
|
|
3272
3272
|
}
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
})
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3273
|
+
function er({ open: e, onOpenChange: t, ...n }) {
|
|
3274
|
+
return /* @__PURE__ */ I($n, {
|
|
3275
|
+
open: e,
|
|
3276
|
+
onOpenChange: t,
|
|
3277
|
+
appearance: n.appearance,
|
|
3278
|
+
children: /* @__PURE__ */ I(Kn, { ...n })
|
|
3279
|
+
});
|
|
3280
|
+
}
|
|
3281
|
+
function tr({ open: e, onOpenChange: t, appearance: n, ...r }) {
|
|
3282
|
+
return /* @__PURE__ */ I($n, {
|
|
3283
|
+
open: e,
|
|
3284
|
+
onOpenChange: t,
|
|
3285
|
+
appearance: n,
|
|
3286
|
+
children: /* @__PURE__ */ I(Yn, { ...r })
|
|
3284
3287
|
});
|
|
3285
3288
|
}
|
|
3286
|
-
|
|
3287
|
-
|
|
3289
|
+
//#endregion
|
|
3290
|
+
//#region src/buy-button.tsx
|
|
3291
|
+
function nr(e) {
|
|
3292
|
+
if (!h(e) || e.code !== "already_owned") return;
|
|
3288
3293
|
let t = e.metadata.owned_by;
|
|
3289
3294
|
return typeof t == "string" && t.startsWith("ord_") ? t : void 0;
|
|
3290
3295
|
}
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
+
var rr = (e) => typeof window < "u" && e.includes(window.location.origin);
|
|
3297
|
+
function ir({ price: n, label: r, amount: i, returnUrl: a, onPaid: o, onSignInRequired: s, signedIn: c, appearance: l, className: u }) {
|
|
3298
|
+
let d = S(), { locale: f } = k(), p = O(), m = x(l), { client: g } = T(), [_, v] = P.useState(), [y, b] = P.useState(!1), [C, w] = P.useState(), E = (e) => {
|
|
3299
|
+
e.status === "complete" && (v(void 0), o(e));
|
|
3300
|
+
}, D = async () => {
|
|
3301
|
+
if (c === !1) return s();
|
|
3302
|
+
w(void 0), b(!0);
|
|
3303
|
+
try {
|
|
3304
|
+
let { merchant: t } = await g.getCustomerConfig(), r = rr(t.embed_origins), a;
|
|
3296
3305
|
try {
|
|
3297
|
-
|
|
3306
|
+
({order: a} = await g.createOrder({
|
|
3298
3307
|
lines: [{
|
|
3299
|
-
price_id:
|
|
3300
|
-
...
|
|
3308
|
+
price_id: n.id,
|
|
3309
|
+
...i ? { amount: i } : {}
|
|
3301
3310
|
}],
|
|
3302
|
-
|
|
3311
|
+
...r ? { checkout: { ui_mode: "embedded" } } : {}
|
|
3312
|
+
}));
|
|
3313
|
+
} catch (e) {
|
|
3314
|
+
let t = nr(e);
|
|
3315
|
+
if (!t || r) throw e;
|
|
3316
|
+
v({
|
|
3317
|
+
kind: "inline",
|
|
3318
|
+
orderId: t
|
|
3303
3319
|
});
|
|
3304
|
-
|
|
3305
|
-
} catch (t) {
|
|
3306
|
-
let n = tr(t);
|
|
3307
|
-
n ? h(n) : m(t) && t.status === 401 ? o() : b(u.error(e(t)));
|
|
3308
|
-
} finally {
|
|
3309
|
-
_(!1);
|
|
3320
|
+
return;
|
|
3310
3321
|
}
|
|
3322
|
+
if (a.status === "complete") return E(a);
|
|
3323
|
+
if (!r) {
|
|
3324
|
+
v({
|
|
3325
|
+
kind: "inline",
|
|
3326
|
+
orderId: a.id
|
|
3327
|
+
});
|
|
3328
|
+
return;
|
|
3329
|
+
}
|
|
3330
|
+
let o = a.checkout?.url;
|
|
3331
|
+
if (!o) throw e("invalid_response", "the order answered no checkout URL");
|
|
3332
|
+
v({
|
|
3333
|
+
kind: "embedded",
|
|
3334
|
+
orderId: a.id,
|
|
3335
|
+
url: o
|
|
3336
|
+
});
|
|
3337
|
+
} catch (e) {
|
|
3338
|
+
h(e) && e.status === 401 ? s() : w(d.error(t(e)));
|
|
3339
|
+
} finally {
|
|
3340
|
+
b(!1);
|
|
3311
3341
|
}
|
|
3312
|
-
};
|
|
3342
|
+
}, A = (e) => !e && v(void 0);
|
|
3313
3343
|
return /* @__PURE__ */ L("span", {
|
|
3314
|
-
className: R(
|
|
3315
|
-
"data-orck-theme":
|
|
3344
|
+
className: R(m.className, "inline-flex flex-col gap-1", u),
|
|
3345
|
+
"data-orck-theme": m["data-orck-theme"],
|
|
3316
3346
|
style: {
|
|
3317
|
-
...
|
|
3347
|
+
...m.style,
|
|
3318
3348
|
containerType: "normal"
|
|
3319
3349
|
},
|
|
3320
3350
|
children: [
|
|
3321
3351
|
/* @__PURE__ */ I(U, {
|
|
3322
|
-
disabled:
|
|
3323
|
-
onClick: () => void
|
|
3324
|
-
children: n
|
|
3352
|
+
disabled: y,
|
|
3353
|
+
onClick: () => void D(),
|
|
3354
|
+
children: r ?? Qn(n, p, d, f)
|
|
3325
3355
|
}),
|
|
3326
|
-
|
|
3356
|
+
C ? /* @__PURE__ */ I("span", {
|
|
3327
3357
|
role: "alert",
|
|
3328
3358
|
className: "text-sm text-destructive",
|
|
3329
|
-
children:
|
|
3359
|
+
children: C
|
|
3330
3360
|
}) : null,
|
|
3331
|
-
|
|
3361
|
+
_?.kind === "inline" ? /* @__PURE__ */ I(er, {
|
|
3332
3362
|
open: !0,
|
|
3333
|
-
onOpenChange:
|
|
3334
|
-
orderId:
|
|
3335
|
-
returnUrl:
|
|
3336
|
-
appearance:
|
|
3337
|
-
onSettled:
|
|
3338
|
-
|
|
3339
|
-
|
|
3363
|
+
onOpenChange: A,
|
|
3364
|
+
orderId: _.orderId,
|
|
3365
|
+
returnUrl: a,
|
|
3366
|
+
appearance: l,
|
|
3367
|
+
onSettled: E
|
|
3368
|
+
}) : null,
|
|
3369
|
+
_?.kind === "embedded" ? /* @__PURE__ */ I(tr, {
|
|
3370
|
+
open: !0,
|
|
3371
|
+
onOpenChange: A,
|
|
3372
|
+
url: _.url,
|
|
3373
|
+
appearance: l,
|
|
3374
|
+
onComplete: () => void g.getOrder(_.orderId).then(E, () => void 0)
|
|
3340
3375
|
}) : null
|
|
3341
3376
|
]
|
|
3342
3377
|
});
|
|
3343
3378
|
}
|
|
3344
3379
|
//#endregion
|
|
3345
3380
|
//#region src/product-list.tsx
|
|
3346
|
-
function
|
|
3347
|
-
|
|
3348
|
-
...t,
|
|
3349
|
-
state: {
|
|
3350
|
-
products: e,
|
|
3351
|
-
error: null,
|
|
3352
|
-
refetch: () => {}
|
|
3353
|
-
}
|
|
3354
|
-
}) : /* @__PURE__ */ I(ir, { ...t });
|
|
3355
|
-
}
|
|
3356
|
-
function ir(e) {
|
|
3357
|
-
let t = O({
|
|
3358
|
-
merchant: e.merchant ?? "",
|
|
3359
|
-
keys: e.keys ?? []
|
|
3360
|
-
});
|
|
3361
|
-
return /* @__PURE__ */ I(ar, {
|
|
3362
|
-
...e,
|
|
3363
|
-
state: t
|
|
3364
|
-
});
|
|
3365
|
-
}
|
|
3366
|
-
function ar({ onPaid: e, onSignInRequired: t, signedIn: n, appearance: r, className: i, state: a }) {
|
|
3367
|
-
let o = v(), { locale: s } = T(), c = D(r), l = k(), u = (a.products ?? []).filter((e) => !e.archived).map((e) => ({
|
|
3381
|
+
function ar({ products: e, onPaid: t, onSignInRequired: n, signedIn: r, returnUrl: i, appearance: a, className: o }) {
|
|
3382
|
+
let s = S(), c = x(a), l = e.filter((e) => !e.archived).map((e) => ({
|
|
3368
3383
|
product: e,
|
|
3369
3384
|
prices: e.prices.filter((e) => !e.archived && !e.customer_amount)
|
|
3370
|
-
})).filter((e) => e.prices.length > 0),
|
|
3371
|
-
return
|
|
3372
|
-
error: a.error,
|
|
3373
|
-
onRetry: a.refetch
|
|
3374
|
-
}) : a.products === null ? /* @__PURE__ */ I(Le, {}) : u.length === 0 ? /* @__PURE__ */ I(Re, { title: o.t("products.empty") }) : u.map(({ product: i, prices: a }) => /* @__PURE__ */ L(Ae, {
|
|
3385
|
+
})).filter((e) => e.prices.length > 0), u;
|
|
3386
|
+
return u = l.length === 0 ? /* @__PURE__ */ I(Re, { title: s.t("products.empty") }) : l.map(({ product: e, prices: o }) => /* @__PURE__ */ L(Ae, {
|
|
3375
3387
|
className: "gap-4",
|
|
3376
3388
|
"data-testid": "product",
|
|
3377
3389
|
children: [/* @__PURE__ */ L(je, { children: [/* @__PURE__ */ I(Me, {
|
|
3378
3390
|
role: "heading",
|
|
3379
3391
|
"aria-level": 2,
|
|
3380
|
-
children:
|
|
3381
|
-
}),
|
|
3392
|
+
children: e.display_name
|
|
3393
|
+
}), e.description ? /* @__PURE__ */ I(Ne, { children: e.description }) : null] }), /* @__PURE__ */ I(Fe, {
|
|
3382
3394
|
className: "flex flex-wrap gap-2",
|
|
3383
|
-
children:
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
appearance:
|
|
3390
|
-
},
|
|
3395
|
+
children: o.map((e) => /* @__PURE__ */ I(ir, {
|
|
3396
|
+
price: e,
|
|
3397
|
+
onPaid: t,
|
|
3398
|
+
onSignInRequired: n,
|
|
3399
|
+
signedIn: r,
|
|
3400
|
+
returnUrl: i,
|
|
3401
|
+
appearance: a
|
|
3402
|
+
}, e.id))
|
|
3391
3403
|
})]
|
|
3392
|
-
},
|
|
3393
|
-
className: R(c.className, ke, "grid gap-4",
|
|
3404
|
+
}, e.id)), /* @__PURE__ */ I("div", {
|
|
3405
|
+
className: R(c.className, ke, "grid gap-4", o),
|
|
3394
3406
|
"data-orck-theme": c["data-orck-theme"],
|
|
3395
3407
|
style: c.style,
|
|
3396
|
-
children:
|
|
3408
|
+
children: u
|
|
3397
3409
|
});
|
|
3398
3410
|
}
|
|
3399
3411
|
//#endregion
|
|
3400
|
-
export { Pn as AccountBilling,
|
|
3412
|
+
export { Pn as AccountBilling, w as BillingProvider, He as BillingStatusBadge, me as BillingUiRoot, ir as BuyButton, qn as CHECKOUT_COMPLETE_MESSAGE, Jn as CHECKOUT_RESIZE_MESSAGE, En as CancelSubscriptionDialog, Xe as CardBrandPlate, Xn as Cart, Yn as EmbeddedCheckout, Kn as OrderCheckout, We as PaymentHistory, wn as PaymentMethodsPanel, ar as ProductList, gn as SavePaymentMethod, Nn as SubscriptionsPanel, hn as TokenizedCardForm, l as addAmounts, p as amountToDecimal, Zn as authenticateChange, Dt as browserCountry, c as canAuthenticatePayment, s as canSavePaymentMethod, m as cardSetupDriver, _ as checkoutPsps, i as createBillingClient, v as createTranslator, ne as defaultMessages, M as defineMessages, d as formatAmount, Ot as initialCountry, b as interpolate, u as isAmount, a as pspConfigSchema, g as redeemAssertion, Ke as resolveCardBrand, j as resolveMessages, Oe as statusTone, n as tokenSource, S as useMessages };
|
|
3401
3413
|
|
|
3402
3414
|
//# sourceMappingURL=index.js.map
|