@nextblock-cms/ecom 0.8.0 → 0.8.6
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/AddToCartButton-DsSEH9yp.cjs +1 -0
- package/AddToCartButton-ffE0DhHu.js +59 -0
- package/CouponForm-BI_5SBHQ.js +152 -0
- package/CouponForm-D_uu2bLP.cjs +1 -0
- package/CurrencyProvider-Cg-Q6ucj.cjs +1 -0
- package/CurrencyProvider-OzlRN96V.js +120 -0
- package/CurrencyProvider.cjs.js +1 -0
- package/CurrencyProvider.es.js +10 -0
- package/ProductDetailsLayout-BxJH_BxR.cjs +1 -0
- package/ProductDetailsLayout-Dg8dRTYp.js +530 -0
- package/ProductGrid-BdL7iglO.cjs +1 -0
- package/ProductGrid-D3AWM8sr.js +130 -0
- package/actions-AHmBrS5e.cjs +48 -0
- package/actions-j5fuSZX-.js +820 -0
- package/cart-store.cjs.js +1 -0
- package/cart-store.es.js +116 -0
- package/components/Cart.cjs.js +1 -0
- package/components/Cart.es.js +259 -0
- package/components/CartDrawer.cjs.js +1 -0
- package/components/CartDrawer.es.js +118 -0
- package/components/CartIcon.cjs.js +1 -0
- package/components/CartIcon.es.js +33 -0
- package/components/Checkout.cjs.js +1 -0
- package/components/Checkout.es.js +1020 -0
- package/components/CurrencySwitcher.cjs.js +1 -0
- package/components/CurrencySwitcher.es.js +17 -0
- package/components/FeaturedProduct.cjs.js +1 -0
- package/components/FeaturedProduct.es.js +71 -0
- package/components/ProductDetailsLayout.cjs.js +1 -0
- package/components/ProductDetailsLayout.es.js +19 -0
- package/components/ProductGrid.cjs.js +1 -0
- package/components/ProductGrid.es.js +6 -0
- package/components/SimpleTiptapRenderer.cjs.js +1 -0
- package/components/SimpleTiptapRenderer.es.js +187 -0
- package/coupon-server-C9ySm3I5.cjs +1 -0
- package/coupon-server-DUKVtyYs.js +248 -0
- package/currency-constants.cjs.js +1 -0
- package/currency-constants.es.js +4 -0
- package/currency.cjs.js +1 -0
- package/currency.es.js +312 -0
- package/customer-C-UPvrYN.cjs +1 -0
- package/customer-C3xccjUg.js +57 -0
- package/index.cjs.js +1 -1
- package/index.es.js +414 -3105
- package/invoice-ui-CAnJPu6n.cjs +29 -0
- package/invoice-ui-DtpbTJE1.js +2886 -0
- package/package.json +10 -5
- package/product-actions-CONBF8i6.cjs +251 -0
- package/product-actions-DjlIWCMH.js +691 -0
- package/resolver-Fz_FKsfX.cjs +7 -0
- package/resolver-cfrCaHpE.js +128 -0
- package/server-actions/product-actions.cjs.js +1 -0
- package/server-actions/product-actions.es.js +15 -0
- package/server.cjs.js +27 -27
- package/server.es.js +478 -463
- package/shipping-actions-BnHjlo2q.js +25 -0
- package/shipping-actions-D6zt20gg.cjs +1 -0
- package/states-CWYRxV4B.cjs +1 -0
- package/states-DlHJezQ1.js +200 -0
- package/tax-calculation-Dab89aHd.js +181 -0
- package/tax-calculation-MkDKOEkL.cjs +1 -0
- package/trials-DvZaOtNy.cjs +1 -0
- package/trials-RDcRAZKx.js +29 -0
- package/types.cjs.js +1 -0
- package/types.es.js +33 -0
- package/use-cart.cjs.js +1 -0
- package/use-cart.es.js +43 -0
- package/variation-utils.cjs.js +1 -0
- package/variation-utils.es.js +246 -0
- package/invoice-ui-BJZfedDd.cjs +0 -332
- package/invoice-ui-GJ1ADAjn.js +0 -5759
|
@@ -0,0 +1,1020 @@
|
|
|
1
|
+
import { jsx as e, jsxs as r, Fragment as st } from "react/jsx-runtime";
|
|
2
|
+
import { Badge as Be } from "@nextblock-cms/ui/badge";
|
|
3
|
+
import { Button as _e } from "@nextblock-cms/ui/button";
|
|
4
|
+
import { Card as X, CardHeader as Y, CardTitle as V, CardContent as W } from "@nextblock-cms/ui/card";
|
|
5
|
+
import { Checkbox as it } from "@nextblock-cms/ui/checkbox";
|
|
6
|
+
import { Input as I } from "@nextblock-cms/ui/input";
|
|
7
|
+
import { Label as v } from "@nextblock-cms/ui/label";
|
|
8
|
+
import { Separator as lt } from "@nextblock-cms/ui/separator";
|
|
9
|
+
import { RadioGroup as at, RadioGroupItem as De } from "@nextblock-cms/ui/radio-group";
|
|
10
|
+
import { Checkout as ot } from "@freemius/checkout";
|
|
11
|
+
import { getCartItemActivePrice as Ne } from "../cart-store.es.js";
|
|
12
|
+
import { useCart as dt } from "../use-cart.es.js";
|
|
13
|
+
import { useState as y, useMemo as E, useEffect as le } from "react";
|
|
14
|
+
import { X as mt, FlaskConical as ut, CreditCard as pt, ChevronRight as ht, Loader2 as ye, Package as ft, Download as gt, MapPin as _t } from "lucide-react";
|
|
15
|
+
import { useTranslations as Oe, formatPrice as x } from "@nextblock-cms/utils";
|
|
16
|
+
import { n as yt, a as we, g as Me, c as xt } from "../states-DlHJezQ1.js";
|
|
17
|
+
import { g as bt } from "../shipping-actions-BnHjlo2q.js";
|
|
18
|
+
import { createClient as Nt, getServiceRoleSupabaseClient as vt } from "@nextblock-cms/db/server";
|
|
19
|
+
import { b as wt, c as kt } from "../tax-calculation-Dab89aHd.js";
|
|
20
|
+
import { a as St, b as Ct } from "../coupon-server-DUKVtyYs.js";
|
|
21
|
+
import { isDigitalItem as xe } from "../types.es.js";
|
|
22
|
+
import { a as Ft, e as Tt, n as ve, i as Le } from "../customer-C3xccjUg.js";
|
|
23
|
+
import { u as At } from "../CurrencyProvider-OzlRN96V.js";
|
|
24
|
+
import { d as Re } from "../trials-RDcRAZKx.js";
|
|
25
|
+
import { C as $t } from "../CouponForm-BI_5SBHQ.js";
|
|
26
|
+
async function jt(c, g, C = "USD", i, f) {
|
|
27
|
+
try {
|
|
28
|
+
const m = Nt(), T = vt(), { data: A } = await m.from("currencies").select(
|
|
29
|
+
"code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount"
|
|
30
|
+
).eq("is_active", !0).order("code", { ascending: !0 }), K = A ?? [];
|
|
31
|
+
let D;
|
|
32
|
+
if (i) {
|
|
33
|
+
const M = await St({
|
|
34
|
+
client: T,
|
|
35
|
+
code: i,
|
|
36
|
+
items: f && f.length > 0 ? f : c,
|
|
37
|
+
currencyCode: C
|
|
38
|
+
});
|
|
39
|
+
M.success && (D = Ct(M.quote));
|
|
40
|
+
}
|
|
41
|
+
const q = await wt(
|
|
42
|
+
m,
|
|
43
|
+
c,
|
|
44
|
+
C,
|
|
45
|
+
K,
|
|
46
|
+
D
|
|
47
|
+
);
|
|
48
|
+
return { success: !0, tax: await kt(m, {
|
|
49
|
+
items: q,
|
|
50
|
+
destination: g
|
|
51
|
+
}) };
|
|
52
|
+
} catch (m) {
|
|
53
|
+
return console.error("Failed to estimate taxes:", m), {
|
|
54
|
+
success: !1,
|
|
55
|
+
error: m.message || "Failed to calculate taxes"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const Pt = process.env.NEXT_PUBLIC_IS_SANDBOX === "true", ae = "nextblock-checkout-draft-v1";
|
|
60
|
+
function oe(c, g) {
|
|
61
|
+
return {
|
|
62
|
+
...Tt(),
|
|
63
|
+
company_name: c?.company_name || "",
|
|
64
|
+
recipient_name: c?.recipient_name || g || "",
|
|
65
|
+
line1: c?.line1 || "",
|
|
66
|
+
line2: c?.line2 || "",
|
|
67
|
+
city: c?.city || "",
|
|
68
|
+
state: c?.state || "",
|
|
69
|
+
postal_code: c?.postal_code || "",
|
|
70
|
+
country_code: yt(c?.country_code) || "CA"
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function Et(c) {
|
|
74
|
+
const g = ve(c);
|
|
75
|
+
return !(!g?.country_code || !g.postal_code || we(g.country_code) && !g.state);
|
|
76
|
+
}
|
|
77
|
+
function be(c, g, C) {
|
|
78
|
+
return c.reduce((i, f) => {
|
|
79
|
+
const { price: m, sale_price: T } = Ne(f, {
|
|
80
|
+
currencyCode: g,
|
|
81
|
+
currencies: C
|
|
82
|
+
});
|
|
83
|
+
return i + (T ?? m) * f.quantity;
|
|
84
|
+
}, 0);
|
|
85
|
+
}
|
|
86
|
+
function qe({
|
|
87
|
+
idPrefix: c,
|
|
88
|
+
title: g,
|
|
89
|
+
description: C,
|
|
90
|
+
value: i,
|
|
91
|
+
onChange: f
|
|
92
|
+
}) {
|
|
93
|
+
const { t: m } = Oe(), T = m("company_name") === "company_name" ? "Company name" : m("company_name"), A = m("select_an_option") === "select_an_option" ? "Select an option" : m("select_an_option"), K = m("state_province") === "state_province" ? "State / Province" : m("state_province"), D = Me(i.country_code), q = we(i.country_code);
|
|
94
|
+
return /* @__PURE__ */ r(X, { children: [
|
|
95
|
+
/* @__PURE__ */ r(Y, { children: [
|
|
96
|
+
/* @__PURE__ */ r(V, { className: "flex items-center gap-2", children: [
|
|
97
|
+
/* @__PURE__ */ e(_t, { className: "w-5 h-5" }),
|
|
98
|
+
g
|
|
99
|
+
] }),
|
|
100
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: C })
|
|
101
|
+
] }),
|
|
102
|
+
/* @__PURE__ */ r(W, { className: "space-y-4", children: [
|
|
103
|
+
/* @__PURE__ */ r("div", { className: "grid gap-4 sm:grid-cols-3", children: [
|
|
104
|
+
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
105
|
+
/* @__PURE__ */ e(v, { htmlFor: `${c}-company`, children: T }),
|
|
106
|
+
/* @__PURE__ */ e(
|
|
107
|
+
I,
|
|
108
|
+
{
|
|
109
|
+
id: `${c}-company`,
|
|
110
|
+
value: i.company_name,
|
|
111
|
+
onChange: (a) => f({ ...i, company_name: a.target.value })
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
] }),
|
|
115
|
+
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
116
|
+
/* @__PURE__ */ e(v, { htmlFor: `${c}-name`, children: m("full_name") }),
|
|
117
|
+
/* @__PURE__ */ e(
|
|
118
|
+
I,
|
|
119
|
+
{
|
|
120
|
+
id: `${c}-name`,
|
|
121
|
+
value: i.recipient_name,
|
|
122
|
+
onChange: (a) => f({ ...i, recipient_name: a.target.value })
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
] }),
|
|
126
|
+
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
127
|
+
/* @__PURE__ */ e(v, { htmlFor: `${c}-country`, children: m("country") }),
|
|
128
|
+
/* @__PURE__ */ e(
|
|
129
|
+
"select",
|
|
130
|
+
{
|
|
131
|
+
id: `${c}-country`,
|
|
132
|
+
className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
133
|
+
value: i.country_code,
|
|
134
|
+
onChange: (a) => {
|
|
135
|
+
const M = a.target.value, de = Me(M);
|
|
136
|
+
f({
|
|
137
|
+
...i,
|
|
138
|
+
country_code: M,
|
|
139
|
+
state: de.some((Z) => Z.code === i.state) ? i.state : ""
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
children: xt.map((a) => /* @__PURE__ */ e("option", { value: a.code, children: a.name }, a.code))
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
] })
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
148
|
+
/* @__PURE__ */ e(v, { htmlFor: `${c}-line1`, children: m("address_line_1") }),
|
|
149
|
+
/* @__PURE__ */ e(
|
|
150
|
+
I,
|
|
151
|
+
{
|
|
152
|
+
id: `${c}-line1`,
|
|
153
|
+
value: i.line1,
|
|
154
|
+
onChange: (a) => f({ ...i, line1: a.target.value })
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
] }),
|
|
158
|
+
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
159
|
+
/* @__PURE__ */ e(v, { htmlFor: `${c}-line2`, children: m("address_line_2") }),
|
|
160
|
+
/* @__PURE__ */ e(
|
|
161
|
+
I,
|
|
162
|
+
{
|
|
163
|
+
id: `${c}-line2`,
|
|
164
|
+
value: i.line2,
|
|
165
|
+
onChange: (a) => f({ ...i, line2: a.target.value })
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
] }),
|
|
169
|
+
/* @__PURE__ */ r("div", { className: "grid gap-4 sm:grid-cols-3", children: [
|
|
170
|
+
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
171
|
+
/* @__PURE__ */ e(v, { htmlFor: `${c}-city`, children: m("city") }),
|
|
172
|
+
/* @__PURE__ */ e(
|
|
173
|
+
I,
|
|
174
|
+
{
|
|
175
|
+
id: `${c}-city`,
|
|
176
|
+
value: i.city,
|
|
177
|
+
onChange: (a) => f({ ...i, city: a.target.value })
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
] }),
|
|
181
|
+
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
182
|
+
/* @__PURE__ */ e(v, { htmlFor: `${c}-state`, children: m("state_province") }),
|
|
183
|
+
q ? /* @__PURE__ */ r(
|
|
184
|
+
"select",
|
|
185
|
+
{
|
|
186
|
+
id: `${c}-state`,
|
|
187
|
+
className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
188
|
+
value: i.state,
|
|
189
|
+
onChange: (a) => f({ ...i, state: a.target.value }),
|
|
190
|
+
children: [
|
|
191
|
+
/* @__PURE__ */ e("option", { value: "", children: `${A}: ${K}` }),
|
|
192
|
+
D.map((a) => /* @__PURE__ */ e("option", { value: a.code, children: a.name }, a.code))
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
) : /* @__PURE__ */ e(
|
|
196
|
+
I,
|
|
197
|
+
{
|
|
198
|
+
id: `${c}-state`,
|
|
199
|
+
value: i.state,
|
|
200
|
+
onChange: (a) => f({ ...i, state: a.target.value })
|
|
201
|
+
}
|
|
202
|
+
)
|
|
203
|
+
] }),
|
|
204
|
+
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
205
|
+
/* @__PURE__ */ e(v, { htmlFor: `${c}-postal`, children: m("postal_zip_code") }),
|
|
206
|
+
/* @__PURE__ */ e(
|
|
207
|
+
I,
|
|
208
|
+
{
|
|
209
|
+
id: `${c}-postal`,
|
|
210
|
+
value: i.postal_code,
|
|
211
|
+
onChange: (a) => f({ ...i, postal_code: a.target.value })
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
] })
|
|
215
|
+
] })
|
|
216
|
+
] })
|
|
217
|
+
] });
|
|
218
|
+
}
|
|
219
|
+
function ze({
|
|
220
|
+
title: c,
|
|
221
|
+
description: g,
|
|
222
|
+
badgeLabel: C,
|
|
223
|
+
children: i
|
|
224
|
+
}) {
|
|
225
|
+
return /* @__PURE__ */ r(X, { children: [
|
|
226
|
+
/* @__PURE__ */ e(Y, { children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-3 flex-wrap", children: [
|
|
227
|
+
/* @__PURE__ */ r("div", { children: [
|
|
228
|
+
/* @__PURE__ */ e(V, { children: c }),
|
|
229
|
+
/* @__PURE__ */ e("p", { className: "mt-1 text-sm text-muted-foreground", children: g })
|
|
230
|
+
] }),
|
|
231
|
+
C ? /* @__PURE__ */ e(Be, { variant: "secondary", children: C }) : null
|
|
232
|
+
] }) }),
|
|
233
|
+
/* @__PURE__ */ e(W, { className: "space-y-4", children: i })
|
|
234
|
+
] });
|
|
235
|
+
}
|
|
236
|
+
const sr = ({ initialCustomer: c }) => {
|
|
237
|
+
const [g, C] = y({}), [i, f] = y(null), [m, T] = y({}), [A, K] = y(c?.email || ""), [D, q] = y(""), [a, M] = y(c?.phone || ""), [de, Z] = y(!1), [Ke, ke] = y(null), [Se, ee] = y(!1), [Ue, te] = y(!1), [J, re] = y([]), [b, U] = y(null), [F, ce] = y(null), [L, Qe] = y(null), [j, Ce] = y(
|
|
238
|
+
() => oe(c?.billingAddress, c?.fullName)
|
|
239
|
+
), [Q, Fe] = y(
|
|
240
|
+
() => oe(
|
|
241
|
+
c?.shippingAddress ?? c?.billingAddress,
|
|
242
|
+
c?.fullName
|
|
243
|
+
)
|
|
244
|
+
), [z, Te] = y(
|
|
245
|
+
!c?.shippingAddress || Ft(c?.billingAddress, c?.shippingAddress)
|
|
246
|
+
), G = dt((t) => t), { t: s, lang: me } = Oe(), { activeCurrencyCode: o, currencies: R } = At(), N = G?.items ?? [], w = E(
|
|
247
|
+
() => N.filter((t) => !xe(t)),
|
|
248
|
+
[N]
|
|
249
|
+
), k = E(
|
|
250
|
+
() => N.filter((t) => xe(t)),
|
|
251
|
+
[N]
|
|
252
|
+
), B = c?.isAuthenticated ?? !1, n = (t, l, p) => {
|
|
253
|
+
const u = s(t, p);
|
|
254
|
+
if (u !== t)
|
|
255
|
+
return u;
|
|
256
|
+
if (!p)
|
|
257
|
+
return l;
|
|
258
|
+
let _ = l;
|
|
259
|
+
return Object.entries(p).forEach(([h, d]) => {
|
|
260
|
+
_ = _.replace(
|
|
261
|
+
new RegExp(`\\{${h}\\}`, "g"),
|
|
262
|
+
String(d)
|
|
263
|
+
);
|
|
264
|
+
}), _;
|
|
265
|
+
}, S = w.length > 0, Je = E(
|
|
266
|
+
() => be(N, o, R),
|
|
267
|
+
[o, R, N]
|
|
268
|
+
), ue = E(
|
|
269
|
+
() => be(w, o, R),
|
|
270
|
+
[o, R, w]
|
|
271
|
+
), pe = E(
|
|
272
|
+
() => be(k, o, R),
|
|
273
|
+
[o, R, k]
|
|
274
|
+
), he = L?.providerDiscounts.stripe ?? 0, fe = L?.providerDiscounts.freemius ?? 0, ne = Math.max(0, ue - he), Ge = Math.max(0, pe - fe), $ = E(
|
|
275
|
+
() => z ? j : Q,
|
|
276
|
+
[j, Q, z]
|
|
277
|
+
), O = E(
|
|
278
|
+
() => S ? $ : j,
|
|
279
|
+
[j, S, $]
|
|
280
|
+
), se = !S || Et($), ie = E(
|
|
281
|
+
() => J.find((t) => t.id === b),
|
|
282
|
+
[J, b]
|
|
283
|
+
), Ae = E(
|
|
284
|
+
() => ne + (ie?.amount ?? 0) + (F && !F.isPendingExternalCalculation ? F.amount : 0),
|
|
285
|
+
[ne, ie, F]
|
|
286
|
+
), He = Ae + Ge;
|
|
287
|
+
if (le(() => {
|
|
288
|
+
if (!(B || typeof window > "u"))
|
|
289
|
+
try {
|
|
290
|
+
const t = window.localStorage.getItem(ae);
|
|
291
|
+
if (!t)
|
|
292
|
+
return;
|
|
293
|
+
const l = JSON.parse(t);
|
|
294
|
+
l.email && K(l.email), l.phone && M(l.phone), l.billingAddress && Ce(oe(l.billingAddress)), l.shippingAddress && Fe(oe(l.shippingAddress)), typeof l.useBillingForShipping == "boolean" && Te(l.useBillingForShipping), (typeof l.selectedMethodId == "string" || l.selectedMethodId === null) && U(l.selectedMethodId);
|
|
295
|
+
} catch (t) {
|
|
296
|
+
console.error("[Checkout] Failed to restore checkout draft:", t);
|
|
297
|
+
}
|
|
298
|
+
}, [B]), le(() => {
|
|
299
|
+
if (!(typeof window > "u")) {
|
|
300
|
+
if (B) {
|
|
301
|
+
window.localStorage.removeItem(ae);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
window.localStorage.setItem(
|
|
305
|
+
ae,
|
|
306
|
+
JSON.stringify({
|
|
307
|
+
email: A,
|
|
308
|
+
phone: a,
|
|
309
|
+
billingAddress: j,
|
|
310
|
+
shippingAddress: Q,
|
|
311
|
+
useBillingForShipping: z,
|
|
312
|
+
selectedMethodId: b
|
|
313
|
+
})
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
}, [
|
|
317
|
+
j,
|
|
318
|
+
A,
|
|
319
|
+
B,
|
|
320
|
+
a,
|
|
321
|
+
b,
|
|
322
|
+
Q,
|
|
323
|
+
z
|
|
324
|
+
]), le(() => {
|
|
325
|
+
if (!S) {
|
|
326
|
+
re([]), U(null), ee(!1);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (!se) {
|
|
330
|
+
re([]), U(null), ee(!1);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
let t = !1;
|
|
334
|
+
const p = setTimeout(async () => {
|
|
335
|
+
if (!$.country_code)
|
|
336
|
+
return;
|
|
337
|
+
ee(!0);
|
|
338
|
+
const u = await bt(
|
|
339
|
+
ne,
|
|
340
|
+
{
|
|
341
|
+
country: $.country_code,
|
|
342
|
+
state: $.state,
|
|
343
|
+
postal_code: $.postal_code
|
|
344
|
+
},
|
|
345
|
+
me,
|
|
346
|
+
o
|
|
347
|
+
);
|
|
348
|
+
t || (u.success && u.methods ? (re(u.methods), u.methods.length > 0 && (!b || !u.methods.find((_) => _.id === b)) && U(u.methods[0].id)) : (re([]), U(null)), ee(!1));
|
|
349
|
+
}, 400);
|
|
350
|
+
return () => {
|
|
351
|
+
t = !0, clearTimeout(p);
|
|
352
|
+
};
|
|
353
|
+
}, [
|
|
354
|
+
o,
|
|
355
|
+
S,
|
|
356
|
+
se,
|
|
357
|
+
me,
|
|
358
|
+
b,
|
|
359
|
+
$.country_code,
|
|
360
|
+
$.postal_code,
|
|
361
|
+
$.state,
|
|
362
|
+
ne
|
|
363
|
+
]), le(() => {
|
|
364
|
+
const l = setTimeout(async () => {
|
|
365
|
+
if (!S || !O.country_code) {
|
|
366
|
+
te(!1), ce(null);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (we(O.country_code) && !O.state) {
|
|
370
|
+
te(!1), ce(null);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
te(!0);
|
|
374
|
+
const p = await jt(
|
|
375
|
+
w,
|
|
376
|
+
{
|
|
377
|
+
country_code: O.country_code,
|
|
378
|
+
state: O.state
|
|
379
|
+
},
|
|
380
|
+
o,
|
|
381
|
+
L?.code ?? null,
|
|
382
|
+
N
|
|
383
|
+
);
|
|
384
|
+
p.success && p.tax ? ce(p.tax) : ce(null), te(!1);
|
|
385
|
+
}, 300);
|
|
386
|
+
return () => clearTimeout(l);
|
|
387
|
+
}, [
|
|
388
|
+
o,
|
|
389
|
+
S,
|
|
390
|
+
w,
|
|
391
|
+
O.country_code,
|
|
392
|
+
O.state,
|
|
393
|
+
L?.code,
|
|
394
|
+
N
|
|
395
|
+
]), !G)
|
|
396
|
+
return null;
|
|
397
|
+
const $e = () => {
|
|
398
|
+
Z(!1), ke(null);
|
|
399
|
+
}, je = de ? /* @__PURE__ */ e(
|
|
400
|
+
"div",
|
|
401
|
+
{
|
|
402
|
+
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",
|
|
403
|
+
onClick: $e,
|
|
404
|
+
children: /* @__PURE__ */ r(
|
|
405
|
+
"div",
|
|
406
|
+
{
|
|
407
|
+
className: "relative bg-background border rounded-xl shadow-2xl p-8 max-w-md mx-4",
|
|
408
|
+
onClick: (t) => t.stopPropagation(),
|
|
409
|
+
children: [
|
|
410
|
+
/* @__PURE__ */ e(
|
|
411
|
+
"button",
|
|
412
|
+
{
|
|
413
|
+
onClick: $e,
|
|
414
|
+
className: "absolute top-4 right-4 text-muted-foreground hover:text-foreground transition-colors",
|
|
415
|
+
children: /* @__PURE__ */ e(mt, { className: "w-5 h-5" })
|
|
416
|
+
}
|
|
417
|
+
),
|
|
418
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-3 mb-4", children: [
|
|
419
|
+
/* @__PURE__ */ e("div", { className: "p-2 rounded-full bg-amber-100 dark:bg-amber-900/20", children: /* @__PURE__ */ e(ut, { className: "h-6 w-6 text-amber-600 dark:text-amber-400" }) }),
|
|
420
|
+
/* @__PURE__ */ e("h2", { className: "text-xl font-semibold", children: s("ecommerce.checkout_successful") })
|
|
421
|
+
] }),
|
|
422
|
+
/* @__PURE__ */ e("p", { className: "text-muted-foreground mb-2", children: s("ecommerce.sandbox_notice") }),
|
|
423
|
+
/* @__PURE__ */ e("p", { className: "text-muted-foreground mb-2", children: Ke === "stripe" ? n(
|
|
424
|
+
"ecommerce.sandbox_checkout_stripe_description",
|
|
425
|
+
"This simulated step represents the Stripe checkout for physical products."
|
|
426
|
+
) : n(
|
|
427
|
+
"ecommerce.sandbox_checkout_freemius_description",
|
|
428
|
+
"This simulated step represents the Freemius checkout for digital products."
|
|
429
|
+
) }),
|
|
430
|
+
/* @__PURE__ */ e("p", { className: "text-muted-foreground mb-6", children: s("ecommerce.license_notice") }),
|
|
431
|
+
/* @__PURE__ */ e(
|
|
432
|
+
"a",
|
|
433
|
+
{
|
|
434
|
+
href: "https://nextblock.ca",
|
|
435
|
+
target: "_blank",
|
|
436
|
+
rel: "noopener noreferrer",
|
|
437
|
+
className: "block w-full text-center py-3 px-4 rounded-lg bg-primary text-primary-foreground font-semibold hover:opacity-90 transition-opacity",
|
|
438
|
+
children: s("ecommerce.purchase_at")
|
|
439
|
+
}
|
|
440
|
+
)
|
|
441
|
+
]
|
|
442
|
+
}
|
|
443
|
+
)
|
|
444
|
+
}
|
|
445
|
+
) : null, Xe = (t) => {
|
|
446
|
+
if (!B && (!A || !/^\S+@\S+\.\S+$/.test(A)))
|
|
447
|
+
return q(s("ecommerce.invalid_email")), null;
|
|
448
|
+
const l = ve(j);
|
|
449
|
+
if (!Le(l))
|
|
450
|
+
return alert(s("checkout_complete_billing_address")), null;
|
|
451
|
+
const p = S ? ve(z ? j : Q) : null;
|
|
452
|
+
if (t === "stripe") {
|
|
453
|
+
if (!Le(p))
|
|
454
|
+
return alert(s("checkout_complete_shipping_address")), null;
|
|
455
|
+
if (!b)
|
|
456
|
+
return alert(
|
|
457
|
+
n(
|
|
458
|
+
"ecommerce.shipping_method_required",
|
|
459
|
+
"Please select a shipping method before continuing."
|
|
460
|
+
)
|
|
461
|
+
), null;
|
|
462
|
+
}
|
|
463
|
+
return q(""), {
|
|
464
|
+
normalizedBillingAddress: l,
|
|
465
|
+
normalizedShippingAddress: p
|
|
466
|
+
};
|
|
467
|
+
}, Pe = async (t, l, p) => {
|
|
468
|
+
T((_) => ({
|
|
469
|
+
..._,
|
|
470
|
+
[t]: ""
|
|
471
|
+
}));
|
|
472
|
+
const u = Xe(t);
|
|
473
|
+
if (u) {
|
|
474
|
+
if (Pt) {
|
|
475
|
+
const _ = new Set(l.map((d) => d.id)), h = N.filter((d) => !_.has(d.id));
|
|
476
|
+
G.setItems(h), h.length === 0 && G.removeCoupon(), ke(t), Z(!0), typeof window < "u" && h.length === 0 && window.localStorage.removeItem(ae);
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
f(p);
|
|
480
|
+
try {
|
|
481
|
+
const _ = await fetch("/api/checkout", {
|
|
482
|
+
method: "POST",
|
|
483
|
+
headers: { "Content-Type": "application/json" },
|
|
484
|
+
body: JSON.stringify({
|
|
485
|
+
items: l,
|
|
486
|
+
customerEmail: B ? void 0 : A,
|
|
487
|
+
customerPhone: a || null,
|
|
488
|
+
billingAddress: u.normalizedBillingAddress,
|
|
489
|
+
shippingAddress: t === "stripe" ? u.normalizedShippingAddress : null,
|
|
490
|
+
shippingMethodId: t === "stripe" ? b : null,
|
|
491
|
+
locale: me,
|
|
492
|
+
currencyCode: o,
|
|
493
|
+
couponCode: L?.code ?? G.appliedCoupon?.code ?? null,
|
|
494
|
+
couponContextItems: N
|
|
495
|
+
})
|
|
496
|
+
}), h = await _.json();
|
|
497
|
+
if (!_.ok) {
|
|
498
|
+
const d = h?.errorKey && typeof h.errorKey == "string" ? n(
|
|
499
|
+
h.errorKey,
|
|
500
|
+
h?.error || n("ecommerce.generic_error", "Something went wrong."),
|
|
501
|
+
h.errorParams
|
|
502
|
+
) : h?.error || s("ecommerce.generic_error");
|
|
503
|
+
T((H) => ({
|
|
504
|
+
...H,
|
|
505
|
+
[t]: d
|
|
506
|
+
})), f(null);
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
if (h.customProps && h.customProps.provider === "freemius") {
|
|
510
|
+
const d = h.customProps;
|
|
511
|
+
let H = null;
|
|
512
|
+
const tt = () => {
|
|
513
|
+
window.location.href = `/checkout/success?session_id=${d.order_id}`;
|
|
514
|
+
}, Ee = (P) => (H || (H = fetch("/api/checkout/freemius/sync", {
|
|
515
|
+
method: "POST",
|
|
516
|
+
headers: { "Content-Type": "application/json" },
|
|
517
|
+
body: JSON.stringify({
|
|
518
|
+
orderId: d.order_id,
|
|
519
|
+
checkoutResponse: P
|
|
520
|
+
})
|
|
521
|
+
}).then(async (Ie) => {
|
|
522
|
+
if (!Ie.ok) {
|
|
523
|
+
const nt = await Ie.json().catch(() => null);
|
|
524
|
+
console.error("Freemius checkout sync failed:", nt);
|
|
525
|
+
}
|
|
526
|
+
})), H), rt = {
|
|
527
|
+
product_id: d.plugin_id,
|
|
528
|
+
public_key: d.public_key,
|
|
529
|
+
sandbox: d.sandbox
|
|
530
|
+
}, ct = {
|
|
531
|
+
name: s("ecommerce.checkout_overlay_title"),
|
|
532
|
+
plan_id: d.plan_id,
|
|
533
|
+
...d.billing_cycle ? { billing_cycle: d.billing_cycle } : {},
|
|
534
|
+
...d.trial ? { trial: d.trial } : {},
|
|
535
|
+
...d.coupon ? { coupon: d.coupon } : {},
|
|
536
|
+
user_email: d.user_email,
|
|
537
|
+
user_firstname: d.user_firstname,
|
|
538
|
+
user_lastname: d.user_lastname,
|
|
539
|
+
sandbox: d.sandbox,
|
|
540
|
+
purchaseCompleted: function(P) {
|
|
541
|
+
Ee(P);
|
|
542
|
+
},
|
|
543
|
+
success: function(P) {
|
|
544
|
+
(async () => {
|
|
545
|
+
try {
|
|
546
|
+
await Ee(P);
|
|
547
|
+
} finally {
|
|
548
|
+
tt();
|
|
549
|
+
}
|
|
550
|
+
})();
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
try {
|
|
554
|
+
new ot(rt).open(ct), f(null);
|
|
555
|
+
} catch (P) {
|
|
556
|
+
alert(
|
|
557
|
+
s("ecommerce.checkout_popup_blocked") + " " + (P.message || String(P))
|
|
558
|
+
), h.url && (window.location.href = h.url), f(null);
|
|
559
|
+
}
|
|
560
|
+
} else h.url ? window.location.href = h.url : (T((d) => ({
|
|
561
|
+
...d,
|
|
562
|
+
[t]: s("ecommerce.checkout_failed") + (h.error || n("ecommerce.unknown_error", "Unknown error"))
|
|
563
|
+
})), f(null));
|
|
564
|
+
} catch (_) {
|
|
565
|
+
console.error(_), T((h) => ({
|
|
566
|
+
...h,
|
|
567
|
+
[t]: s("ecommerce.generic_error")
|
|
568
|
+
})), f(null);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
if (N.length === 0)
|
|
573
|
+
return /* @__PURE__ */ r(st, { children: [
|
|
574
|
+
je,
|
|
575
|
+
/* @__PURE__ */ r("div", { className: "container mx-auto flex min-h-[50vh] flex-col items-center justify-center p-8 text-center", children: [
|
|
576
|
+
/* @__PURE__ */ e("h1", { className: "mb-4 text-2xl font-bold", children: s("ecommerce.cart_empty") }),
|
|
577
|
+
/* @__PURE__ */ e("p", { className: "mb-8 text-muted-foreground", children: s("ecommerce.cart_empty_description") }),
|
|
578
|
+
/* @__PURE__ */ e(_e, { asChild: !0, children: /* @__PURE__ */ e("a", { href: "/shop", children: s("ecommerce.go_to_shop") }) })
|
|
579
|
+
] })
|
|
580
|
+
] });
|
|
581
|
+
const ge = S ? se ? Se ? n(
|
|
582
|
+
"ecommerce.calculating_shipping",
|
|
583
|
+
"Calculating shipping..."
|
|
584
|
+
) : b ? null : J.length > 0 ? s("ecommerce.select_rate") : s("ecommerce.no_rates_for_region") : n(
|
|
585
|
+
"ecommerce.waiting_on_address_info",
|
|
586
|
+
"Complete your shipping address to view available shipping options."
|
|
587
|
+
) : null, Ye = i !== null || ge !== null, Ve = w.length === 1 ? n("ecommerce.item_count_one", "{count} item", {
|
|
588
|
+
count: w.length
|
|
589
|
+
}) : n("ecommerce.item_count_other", "{count} items", {
|
|
590
|
+
count: w.length
|
|
591
|
+
}), We = k.length === 1 ? n("ecommerce.license_count_one", "{count} license", {
|
|
592
|
+
count: k.length
|
|
593
|
+
}) : n("ecommerce.license_count_other", "{count} licenses", {
|
|
594
|
+
count: k.length
|
|
595
|
+
}), Ze = (t) => xe(t) ? n("ecommerce.digital_label", "Digital") : n("ecommerce.physical_label", "Physical"), et = (t) => t === "monthly" ? n(
|
|
596
|
+
"ecommerce.checkout_billing_cycle_monthly",
|
|
597
|
+
"Monthly subscription"
|
|
598
|
+
) : t === "annual" ? n(
|
|
599
|
+
"ecommerce.checkout_billing_cycle_annual",
|
|
600
|
+
"Annual subscription"
|
|
601
|
+
) : t === "lifetime" ? n(
|
|
602
|
+
"ecommerce.checkout_billing_cycle_lifetime",
|
|
603
|
+
"Lifetime subscription"
|
|
604
|
+
) : null;
|
|
605
|
+
return /* @__PURE__ */ r("div", { className: "container mx-auto px-4 py-12 md:px-6", children: [
|
|
606
|
+
je,
|
|
607
|
+
/* @__PURE__ */ r("div", { className: "mx-auto max-w-6xl", children: [
|
|
608
|
+
/* @__PURE__ */ e("h1", { className: "mb-8 text-3xl font-bold", children: s("ecommerce.checkout") }),
|
|
609
|
+
/* @__PURE__ */ r("div", { className: "grid gap-8 lg:grid-cols-12 lg:items-start", children: [
|
|
610
|
+
/* @__PURE__ */ r("div", { className: "lg:col-span-8 space-y-6", children: [
|
|
611
|
+
/* @__PURE__ */ r(X, { children: [
|
|
612
|
+
/* @__PURE__ */ e(Y, { children: /* @__PURE__ */ r(V, { className: "flex items-center gap-2", children: [
|
|
613
|
+
/* @__PURE__ */ e(pt, { className: "w-5 h-5" }),
|
|
614
|
+
s("ecommerce.contact_information")
|
|
615
|
+
] }) }),
|
|
616
|
+
/* @__PURE__ */ r(W, { className: "space-y-4", children: [
|
|
617
|
+
B ? /* @__PURE__ */ e("div", { className: "rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground", children: s("checkout_prefill_notice", { email: c?.email || "" }) }) : /* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
618
|
+
/* @__PURE__ */ r(v, { htmlFor: "checkout-email", children: [
|
|
619
|
+
s("ecommerce.email_address"),
|
|
620
|
+
" ",
|
|
621
|
+
/* @__PURE__ */ e("span", { className: "text-destructive", children: "*" })
|
|
622
|
+
] }),
|
|
623
|
+
/* @__PURE__ */ e(
|
|
624
|
+
I,
|
|
625
|
+
{
|
|
626
|
+
id: "checkout-email",
|
|
627
|
+
type: "email",
|
|
628
|
+
placeholder: s("ecommerce.email_placeholder"),
|
|
629
|
+
value: A,
|
|
630
|
+
onChange: (t) => {
|
|
631
|
+
K(t.target.value), D && q("");
|
|
632
|
+
},
|
|
633
|
+
required: !0
|
|
634
|
+
}
|
|
635
|
+
),
|
|
636
|
+
D ? /* @__PURE__ */ e("p", { className: "text-xs text-destructive mt-1", children: D }) : null
|
|
637
|
+
] }),
|
|
638
|
+
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
639
|
+
/* @__PURE__ */ e(v, { htmlFor: "checkout-phone", children: s("phone_number") }),
|
|
640
|
+
/* @__PURE__ */ e(
|
|
641
|
+
I,
|
|
642
|
+
{
|
|
643
|
+
id: "checkout-phone",
|
|
644
|
+
placeholder: s("optional"),
|
|
645
|
+
value: a,
|
|
646
|
+
onChange: (t) => M(t.target.value)
|
|
647
|
+
}
|
|
648
|
+
)
|
|
649
|
+
] })
|
|
650
|
+
] })
|
|
651
|
+
] }),
|
|
652
|
+
/* @__PURE__ */ e(
|
|
653
|
+
qe,
|
|
654
|
+
{
|
|
655
|
+
idPrefix: "billing",
|
|
656
|
+
title: s("billing_address"),
|
|
657
|
+
description: s("checkout_billing_address_help"),
|
|
658
|
+
value: j,
|
|
659
|
+
onChange: Ce
|
|
660
|
+
}
|
|
661
|
+
),
|
|
662
|
+
S ? /* @__PURE__ */ r("div", { className: "flex items-center space-x-3 rounded-xl border bg-muted/20 p-4", children: [
|
|
663
|
+
/* @__PURE__ */ e(
|
|
664
|
+
it,
|
|
665
|
+
{
|
|
666
|
+
id: "use-billing-for-shipping",
|
|
667
|
+
checked: z,
|
|
668
|
+
onCheckedChange: (t) => Te(!!t)
|
|
669
|
+
}
|
|
670
|
+
),
|
|
671
|
+
/* @__PURE__ */ r("div", { className: "space-y-1", children: [
|
|
672
|
+
/* @__PURE__ */ e(v, { htmlFor: "use-billing-for-shipping", className: "cursor-pointer", children: s("use_billing_for_shipping") }),
|
|
673
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: s("checkout_use_billing_for_shipping_help") })
|
|
674
|
+
] })
|
|
675
|
+
] }) : null,
|
|
676
|
+
S && !z ? /* @__PURE__ */ e(
|
|
677
|
+
qe,
|
|
678
|
+
{
|
|
679
|
+
idPrefix: "shipping",
|
|
680
|
+
title: s("shipping_address"),
|
|
681
|
+
description: s("checkout_shipping_address_help"),
|
|
682
|
+
value: Q,
|
|
683
|
+
onChange: Fe
|
|
684
|
+
}
|
|
685
|
+
) : null,
|
|
686
|
+
S ? /* @__PURE__ */ r(X, { children: [
|
|
687
|
+
/* @__PURE__ */ e(Y, { children: /* @__PURE__ */ r(V, { className: "flex items-center gap-2", children: [
|
|
688
|
+
/* @__PURE__ */ e(ht, { className: "w-5 h-5 text-primary" }),
|
|
689
|
+
s("ecommerce.shipping_method")
|
|
690
|
+
] }) }),
|
|
691
|
+
/* @__PURE__ */ e(W, { children: Se ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ e(ye, { className: "w-6 h-6 animate-spin text-muted-foreground" }) }) : J.length > 0 ? /* @__PURE__ */ e("div", { className: "space-y-3", children: J.map((t) => /* @__PURE__ */ r(
|
|
692
|
+
"div",
|
|
693
|
+
{
|
|
694
|
+
onClick: () => U(t.id),
|
|
695
|
+
className: `flex items-center justify-between p-4 rounded-lg border-2 cursor-pointer transition-all ${b === t.id ? "border-primary bg-primary/5" : "border-neutral-100 hover:border-neutral-200"}`,
|
|
696
|
+
children: [
|
|
697
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
|
|
698
|
+
/* @__PURE__ */ e(
|
|
699
|
+
"div",
|
|
700
|
+
{
|
|
701
|
+
className: `w-4 h-4 rounded-full border flex items-center justify-center ${b === t.id ? "border-primary" : "border-neutral-300"}`,
|
|
702
|
+
children: b === t.id ? /* @__PURE__ */ e("div", { className: "w-2 h-2 rounded-full bg-primary" }) : null
|
|
703
|
+
}
|
|
704
|
+
),
|
|
705
|
+
/* @__PURE__ */ e("span", { className: "font-medium", children: t.name })
|
|
706
|
+
] }),
|
|
707
|
+
/* @__PURE__ */ e("span", { className: "font-bold", children: x(t.amount, o) })
|
|
708
|
+
]
|
|
709
|
+
},
|
|
710
|
+
t.id
|
|
711
|
+
)) }) : /* @__PURE__ */ e("div", { className: "py-4 text-center text-muted-foreground bg-muted/30 rounded-lg italic", children: se ? s("ecommerce.no_rates_for_region") : n(
|
|
712
|
+
"ecommerce.waiting_on_address_info",
|
|
713
|
+
"Complete your shipping address to view available shipping options."
|
|
714
|
+
) }) })
|
|
715
|
+
] }) : null
|
|
716
|
+
] }),
|
|
717
|
+
/* @__PURE__ */ r("div", { className: "lg:col-span-4 space-y-6", children: [
|
|
718
|
+
/* @__PURE__ */ r(X, { className: "top-6", children: [
|
|
719
|
+
/* @__PURE__ */ e(Y, { children: /* @__PURE__ */ e(V, { children: s("ecommerce.order_summary") }) }),
|
|
720
|
+
/* @__PURE__ */ r(W, { className: "space-y-4", children: [
|
|
721
|
+
/* @__PURE__ */ e("div", { className: "space-y-3 max-h-[260px] overflow-y-auto pr-2", children: N.map((t) => {
|
|
722
|
+
const l = Ne(t, {
|
|
723
|
+
currencyCode: o,
|
|
724
|
+
currencies: R
|
|
725
|
+
}), p = Re(t);
|
|
726
|
+
return /* @__PURE__ */ r("div", { className: "flex items-start justify-between gap-4", children: [
|
|
727
|
+
/* @__PURE__ */ r("div", { className: "flex gap-3", children: [
|
|
728
|
+
t.image_url ? /* @__PURE__ */ e("div", { className: "h-10 w-10 shrink-0 overflow-hidden rounded border bg-neutral-100", children: /* @__PURE__ */ e("img", { src: t.image_url, alt: t.title, className: "h-full w-full object-cover" }) }) : null,
|
|
729
|
+
/* @__PURE__ */ r("div", { className: "grid gap-0.5", children: [
|
|
730
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
731
|
+
/* @__PURE__ */ e("span", { className: "font-medium text-xs line-clamp-1", children: t.title }),
|
|
732
|
+
/* @__PURE__ */ e(Be, { variant: "outline", className: "text-[9px] uppercase", children: Ze(t) })
|
|
733
|
+
] }),
|
|
734
|
+
t.variant_label ? /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground line-clamp-1", children: t.variant_label }) : null,
|
|
735
|
+
/* @__PURE__ */ r("span", { className: "text-[10px] text-muted-foreground", children: [
|
|
736
|
+
s("ecommerce.qty"),
|
|
737
|
+
": ",
|
|
738
|
+
t.quantity
|
|
739
|
+
] }),
|
|
740
|
+
p ? /* @__PURE__ */ r("span", { className: "text-[10px] font-medium text-emerald-700", children: [
|
|
741
|
+
p.label,
|
|
742
|
+
" - ",
|
|
743
|
+
p.paymentRequirementLabel
|
|
744
|
+
] }) : null
|
|
745
|
+
] })
|
|
746
|
+
] }),
|
|
747
|
+
/* @__PURE__ */ r("div", { className: "flex flex-col items-end gap-0.5 shrink-0", children: [
|
|
748
|
+
/* @__PURE__ */ e("span", { className: "font-medium text-xs", children: x(
|
|
749
|
+
(l.sale_price ?? l.price) * t.quantity,
|
|
750
|
+
o
|
|
751
|
+
) }),
|
|
752
|
+
l.sale_price ? /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground line-through", children: x(l.price * t.quantity, o) }) : null
|
|
753
|
+
] })
|
|
754
|
+
] }, `${t.id}-${t.variant_id || "base"}`);
|
|
755
|
+
}) }),
|
|
756
|
+
/* @__PURE__ */ e(lt, {}),
|
|
757
|
+
/* @__PURE__ */ e(
|
|
758
|
+
$t,
|
|
759
|
+
{
|
|
760
|
+
items: N,
|
|
761
|
+
currencyCode: o,
|
|
762
|
+
onQuoteChange: Qe
|
|
763
|
+
}
|
|
764
|
+
),
|
|
765
|
+
/* @__PURE__ */ r("div", { className: "space-y-2 text-sm", children: [
|
|
766
|
+
/* @__PURE__ */ r("div", { className: "flex justify-between", children: [
|
|
767
|
+
/* @__PURE__ */ e("span", { children: s("ecommerce.subtotal") }),
|
|
768
|
+
/* @__PURE__ */ e("span", { children: x(Je, o) })
|
|
769
|
+
] }),
|
|
770
|
+
w.length > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-muted-foreground", children: [
|
|
771
|
+
/* @__PURE__ */ e("span", { children: n(
|
|
772
|
+
"ecommerce.physical_products",
|
|
773
|
+
"Physical products"
|
|
774
|
+
) }),
|
|
775
|
+
/* @__PURE__ */ e("span", { children: x(ue, o) })
|
|
776
|
+
] }) : null,
|
|
777
|
+
k.length > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-muted-foreground", children: [
|
|
778
|
+
/* @__PURE__ */ e("span", { children: n(
|
|
779
|
+
"ecommerce.digital_products",
|
|
780
|
+
"Digital products"
|
|
781
|
+
) }),
|
|
782
|
+
/* @__PURE__ */ e("span", { children: x(pe, o) })
|
|
783
|
+
] }) : null,
|
|
784
|
+
L ? /* @__PURE__ */ r("div", { className: "flex justify-between text-emerald-600", children: [
|
|
785
|
+
/* @__PURE__ */ r("span", { children: [
|
|
786
|
+
n("ecommerce.discount", "Discount"),
|
|
787
|
+
" (",
|
|
788
|
+
L.code,
|
|
789
|
+
")"
|
|
790
|
+
] }),
|
|
791
|
+
/* @__PURE__ */ r("span", { children: [
|
|
792
|
+
"-",
|
|
793
|
+
x(L.discountTotal, o)
|
|
794
|
+
] })
|
|
795
|
+
] }) : null,
|
|
796
|
+
(w.length > 0 || k.length > 0) && /* @__PURE__ */ r("div", { className: "flex justify-between font-bold text-lg pt-2 border-t mt-2", children: [
|
|
797
|
+
/* @__PURE__ */ e("span", { children: n(
|
|
798
|
+
"ecommerce.estimated_total",
|
|
799
|
+
"Estimated total"
|
|
800
|
+
) }),
|
|
801
|
+
/* @__PURE__ */ e("span", { className: "text-primary", children: x(He, o) })
|
|
802
|
+
] })
|
|
803
|
+
] })
|
|
804
|
+
] })
|
|
805
|
+
] }),
|
|
806
|
+
w.length > 0 ? /* @__PURE__ */ r(
|
|
807
|
+
ze,
|
|
808
|
+
{
|
|
809
|
+
title: n(
|
|
810
|
+
"ecommerce.stripe_checkout_title",
|
|
811
|
+
"Stripe Checkout"
|
|
812
|
+
),
|
|
813
|
+
description: n(
|
|
814
|
+
"ecommerce.stripe_checkout_description",
|
|
815
|
+
"Pay for physical products in one Stripe checkout session."
|
|
816
|
+
),
|
|
817
|
+
badgeLabel: Ve,
|
|
818
|
+
children: [
|
|
819
|
+
/* @__PURE__ */ r("div", { className: "space-y-2 text-sm", children: [
|
|
820
|
+
/* @__PURE__ */ r("div", { className: "flex justify-between", children: [
|
|
821
|
+
/* @__PURE__ */ e("span", { children: n(
|
|
822
|
+
"ecommerce.physical_subtotal",
|
|
823
|
+
"Physical subtotal"
|
|
824
|
+
) }),
|
|
825
|
+
/* @__PURE__ */ e("span", { children: x(ue, o) })
|
|
826
|
+
] }),
|
|
827
|
+
he > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-emerald-600", children: [
|
|
828
|
+
/* @__PURE__ */ e("span", { children: n("ecommerce.discount", "Discount") }),
|
|
829
|
+
/* @__PURE__ */ r("span", { children: [
|
|
830
|
+
"-",
|
|
831
|
+
x(he, o)
|
|
832
|
+
] })
|
|
833
|
+
] }) : null,
|
|
834
|
+
/* @__PURE__ */ r("div", { className: "flex justify-between", children: [
|
|
835
|
+
/* @__PURE__ */ e("span", { children: s("ecommerce.shipping") }),
|
|
836
|
+
/* @__PURE__ */ e("span", { children: ie ? x(ie.amount, o) : "-" })
|
|
837
|
+
] }),
|
|
838
|
+
/* @__PURE__ */ r("div", { className: "flex justify-between", children: [
|
|
839
|
+
/* @__PURE__ */ e("span", { children: n("ecommerce.tax", "Tax") }),
|
|
840
|
+
/* @__PURE__ */ e("span", { children: Ue ? "..." : F?.isPendingExternalCalculation ? n(
|
|
841
|
+
"ecommerce.tax_calculated_on_stripe",
|
|
842
|
+
"Calculated on Stripe"
|
|
843
|
+
) : F ? x(F.amount, o) : "-" })
|
|
844
|
+
] }),
|
|
845
|
+
F && F.lines.length > 0 ? /* @__PURE__ */ e("div", { className: "rounded-lg bg-muted/20 px-3 py-2 text-xs text-muted-foreground", children: F.lines.map((t) => /* @__PURE__ */ r("div", { className: "flex justify-between gap-3", children: [
|
|
846
|
+
/* @__PURE__ */ r("span", { children: [
|
|
847
|
+
t.name,
|
|
848
|
+
" (",
|
|
849
|
+
t.rate.toFixed(4),
|
|
850
|
+
"%)"
|
|
851
|
+
] }),
|
|
852
|
+
/* @__PURE__ */ e("span", { children: x(t.amount, o) })
|
|
853
|
+
] }, t.id || `${t.name}-${t.rate}`)) }) : null,
|
|
854
|
+
/* @__PURE__ */ r("div", { className: "flex justify-between font-semibold pt-2 border-t", children: [
|
|
855
|
+
/* @__PURE__ */ e("span", { children: n(
|
|
856
|
+
"ecommerce.total_on_stripe",
|
|
857
|
+
"Total on Stripe"
|
|
858
|
+
) }),
|
|
859
|
+
/* @__PURE__ */ e("span", { children: x(Ae, o) })
|
|
860
|
+
] })
|
|
861
|
+
] }),
|
|
862
|
+
/* @__PURE__ */ r(
|
|
863
|
+
_e,
|
|
864
|
+
{
|
|
865
|
+
className: "w-full",
|
|
866
|
+
size: "lg",
|
|
867
|
+
onClick: () => Pe("stripe", w, "stripe"),
|
|
868
|
+
disabled: Ye,
|
|
869
|
+
children: [
|
|
870
|
+
i === "stripe" ? /* @__PURE__ */ e(ye, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(ft, { className: "mr-2 h-4 w-4" }),
|
|
871
|
+
i === "stripe" ? s("ecommerce.processing") : n(
|
|
872
|
+
"ecommerce.checkout_physical_products",
|
|
873
|
+
"Checkout Physical Products"
|
|
874
|
+
)
|
|
875
|
+
]
|
|
876
|
+
}
|
|
877
|
+
),
|
|
878
|
+
ge && i === null ? /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground", children: ge }) : null,
|
|
879
|
+
m.stripe ? /* @__PURE__ */ e("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: m.stripe }) : null,
|
|
880
|
+
/* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground", children: F?.isPendingExternalCalculation ? n(
|
|
881
|
+
"checkout_stripe_tax_finalized_notice",
|
|
882
|
+
"Tax will be finalized by Stripe Tax on the payment step."
|
|
883
|
+
) : n(
|
|
884
|
+
"ecommerce.shipping_taxes_collected_on_stripe",
|
|
885
|
+
"Shipping and taxes are only collected during the Stripe step for physical products."
|
|
886
|
+
) })
|
|
887
|
+
]
|
|
888
|
+
}
|
|
889
|
+
) : null,
|
|
890
|
+
k.length > 0 ? /* @__PURE__ */ r(
|
|
891
|
+
ze,
|
|
892
|
+
{
|
|
893
|
+
title: n(
|
|
894
|
+
"ecommerce.freemius_checkout_title",
|
|
895
|
+
"Freemius Checkout"
|
|
896
|
+
),
|
|
897
|
+
description: n(
|
|
898
|
+
"ecommerce.freemius_checkout_description",
|
|
899
|
+
"Digital products use the Freemius checkout flow."
|
|
900
|
+
),
|
|
901
|
+
badgeLabel: We,
|
|
902
|
+
children: [
|
|
903
|
+
/* @__PURE__ */ e("div", { className: "space-y-3", children: k.map((t) => {
|
|
904
|
+
const l = Ne(t, {
|
|
905
|
+
currencyCode: o,
|
|
906
|
+
currencies: R
|
|
907
|
+
}), p = Re(t), u = `freemius:${t.id}`, _ = p ? g[u] || "paid" : void 0;
|
|
908
|
+
return /* @__PURE__ */ r("div", { className: "rounded-lg border p-3 space-y-3", children: [
|
|
909
|
+
/* @__PURE__ */ r("div", { className: "flex items-start justify-between gap-3", children: [
|
|
910
|
+
/* @__PURE__ */ r("div", { children: [
|
|
911
|
+
/* @__PURE__ */ e("p", { className: "font-medium", children: t.title }),
|
|
912
|
+
t.billing_cycle ? /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground capitalize", children: et(t.billing_cycle) }) : null,
|
|
913
|
+
p ? /* @__PURE__ */ r("p", { className: "text-xs font-medium text-emerald-700", children: [
|
|
914
|
+
p.label,
|
|
915
|
+
" - ",
|
|
916
|
+
p.paymentRequirementLabel
|
|
917
|
+
] }) : null
|
|
918
|
+
] }),
|
|
919
|
+
/* @__PURE__ */ e("span", { className: "font-medium", children: x(l.sale_price ?? l.price, o) })
|
|
920
|
+
] }),
|
|
921
|
+
p && !t.trial_requires_payment_method && /* @__PURE__ */ r("div", { className: "bg-muted/30 p-3 rounded-md border text-sm mt-2 mb-3", children: [
|
|
922
|
+
/* @__PURE__ */ e("p", { className: "font-medium mb-3", children: n(
|
|
923
|
+
"ecommerce.freemius_trial_preference_title",
|
|
924
|
+
"How would you like to start your trial?"
|
|
925
|
+
) }),
|
|
926
|
+
/* @__PURE__ */ r(
|
|
927
|
+
at,
|
|
928
|
+
{
|
|
929
|
+
value: g[u] || "paid",
|
|
930
|
+
onValueChange: (h) => C((d) => ({ ...d, [u]: h })),
|
|
931
|
+
className: "gap-3",
|
|
932
|
+
children: [
|
|
933
|
+
/* @__PURE__ */ r("div", { className: "flex items-start space-x-3", children: [
|
|
934
|
+
/* @__PURE__ */ e(De, { value: "paid", id: `${u}-paid`, className: "mt-1" }),
|
|
935
|
+
/* @__PURE__ */ r("div", { className: "grid gap-1.5", children: [
|
|
936
|
+
/* @__PURE__ */ e(v, { htmlFor: `${u}-paid`, className: "font-medium leading-none cursor-pointer", children: n(
|
|
937
|
+
"ecommerce.freemius_trial_with_card",
|
|
938
|
+
"Enter Payment Details Now (Still get full trial length free)"
|
|
939
|
+
) }),
|
|
940
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: n(
|
|
941
|
+
"ecommerce.freemius_trial_with_card_help",
|
|
942
|
+
"You will not be billed until the trial ends. Cancel anytime."
|
|
943
|
+
) })
|
|
944
|
+
] })
|
|
945
|
+
] }),
|
|
946
|
+
/* @__PURE__ */ r("div", { className: "flex items-start space-x-3", children: [
|
|
947
|
+
/* @__PURE__ */ e(De, { value: "free", id: `${u}-free`, className: "mt-1" }),
|
|
948
|
+
/* @__PURE__ */ e("div", { className: "grid gap-1.5", children: /* @__PURE__ */ e(v, { htmlFor: `${u}-free`, className: "font-medium leading-none cursor-pointer", children: n(
|
|
949
|
+
"ecommerce.freemius_trial_no_card",
|
|
950
|
+
"Start Free Trial (No card required)"
|
|
951
|
+
) }) })
|
|
952
|
+
] })
|
|
953
|
+
]
|
|
954
|
+
}
|
|
955
|
+
)
|
|
956
|
+
] }),
|
|
957
|
+
/* @__PURE__ */ r(
|
|
958
|
+
_e,
|
|
959
|
+
{
|
|
960
|
+
className: "w-full h-auto min-h-[2.75rem] py-2",
|
|
961
|
+
variant: k.length > 1 ? "outline" : "default",
|
|
962
|
+
onClick: () => Pe(
|
|
963
|
+
"freemius",
|
|
964
|
+
[
|
|
965
|
+
{
|
|
966
|
+
...t,
|
|
967
|
+
..._ ? { trial_preference: _ } : {}
|
|
968
|
+
}
|
|
969
|
+
],
|
|
970
|
+
u
|
|
971
|
+
),
|
|
972
|
+
disabled: i !== null,
|
|
973
|
+
children: [
|
|
974
|
+
i === u ? /* @__PURE__ */ e(ye, { className: "mr-2 h-4 w-4 shrink-0 animate-spin" }) : /* @__PURE__ */ e(gt, { className: "mr-2 h-4 w-4 shrink-0" }),
|
|
975
|
+
/* @__PURE__ */ e("span", { className: "whitespace-normal text-left", children: i === u ? s("ecommerce.processing") : k.length > 1 ? n(
|
|
976
|
+
"ecommerce.checkout_product",
|
|
977
|
+
"Checkout {title}",
|
|
978
|
+
{ title: t.title }
|
|
979
|
+
) : n(
|
|
980
|
+
"ecommerce.checkout_digital_product",
|
|
981
|
+
"Checkout Digital Product"
|
|
982
|
+
) })
|
|
983
|
+
]
|
|
984
|
+
}
|
|
985
|
+
)
|
|
986
|
+
] }, u);
|
|
987
|
+
}) }),
|
|
988
|
+
/* @__PURE__ */ r("div", { className: "flex justify-between text-sm font-semibold border-t pt-3", children: [
|
|
989
|
+
/* @__PURE__ */ e("span", { children: n(
|
|
990
|
+
"ecommerce.digital_subtotal",
|
|
991
|
+
"Digital subtotal"
|
|
992
|
+
) }),
|
|
993
|
+
/* @__PURE__ */ e("span", { children: x(pe, o) })
|
|
994
|
+
] }),
|
|
995
|
+
fe > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-sm font-semibold text-emerald-600", children: [
|
|
996
|
+
/* @__PURE__ */ e("span", { children: n("ecommerce.discount", "Discount") }),
|
|
997
|
+
/* @__PURE__ */ r("span", { children: [
|
|
998
|
+
"-",
|
|
999
|
+
x(fe, o)
|
|
1000
|
+
] })
|
|
1001
|
+
] }) : null,
|
|
1002
|
+
m.freemius ? /* @__PURE__ */ e("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: m.freemius }) : null,
|
|
1003
|
+
/* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground", children: k.length > 1 ? n(
|
|
1004
|
+
"ecommerce.freemius_multi_checkout_notice",
|
|
1005
|
+
"Freemius licenses are completed one at a time, so each digital product gets its own checkout action."
|
|
1006
|
+
) : n(
|
|
1007
|
+
"ecommerce.freemius_tax_notice",
|
|
1008
|
+
"Taxes and compliance for digital products are handled inside the Freemius checkout."
|
|
1009
|
+
) })
|
|
1010
|
+
]
|
|
1011
|
+
}
|
|
1012
|
+
) : null
|
|
1013
|
+
] })
|
|
1014
|
+
] })
|
|
1015
|
+
] })
|
|
1016
|
+
] });
|
|
1017
|
+
};
|
|
1018
|
+
export {
|
|
1019
|
+
sr as Checkout
|
|
1020
|
+
};
|