@nextblock-cms/ecom 0.8.1 → 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
package/index.es.js
CHANGED
|
@@ -1,2463 +1,424 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
function xs(t) {
|
|
57
|
-
const { currencies: n, storedCurrencyCode: s, hasHydrated: a, initialCurrencyCode: l, locale: c } = t, o = new Set(
|
|
58
|
-
n.map((p) => Fe(p.code))
|
|
59
|
-
), m = Wt(n), _ = l ? Fe(l) : null, y = s ? Fe(s) : null;
|
|
60
|
-
if (a && y && o.has(y))
|
|
61
|
-
return y;
|
|
62
|
-
if (_ && o.has(_))
|
|
63
|
-
return _;
|
|
64
|
-
const h = Yr(c, n);
|
|
65
|
-
return o.has(h) ? h : m.code;
|
|
66
|
-
}
|
|
67
|
-
function ha({
|
|
68
|
-
children: t,
|
|
69
|
-
initialCurrencies: n,
|
|
70
|
-
initialCurrencyCode: s,
|
|
71
|
-
locale: a
|
|
72
|
-
}) {
|
|
73
|
-
const [l, c] = k(
|
|
74
|
-
() => tt(n)
|
|
75
|
-
), o = Oe(
|
|
76
|
-
(b) => b.activeCurrencyCode
|
|
77
|
-
), m = Oe((b) => b.hasHydrated), _ = Oe(
|
|
78
|
-
(b) => b.setActiveCurrencyCode
|
|
79
|
-
);
|
|
80
|
-
G(() => {
|
|
81
|
-
Oe.persist.rehydrate();
|
|
82
|
-
}, []), G(() => {
|
|
83
|
-
n.length > 0 && c(tt(n));
|
|
84
|
-
}, [n]), G(() => {
|
|
85
|
-
if (n.length > 0)
|
|
86
|
-
return;
|
|
87
|
-
async function b() {
|
|
88
|
-
const { fetchActiveCurrenciesFromRest: d } = await import("./currency-rest-client-CwoqdgAP.js"), E = await d();
|
|
89
|
-
E.length > 0 && c(
|
|
90
|
-
tt(E.map((v) => Xr(v)))
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
b();
|
|
94
|
-
}, [n.length]);
|
|
95
|
-
const y = H(
|
|
96
|
-
() => xs({
|
|
97
|
-
currencies: l,
|
|
98
|
-
storedCurrencyCode: o,
|
|
99
|
-
hasHydrated: m,
|
|
100
|
-
initialCurrencyCode: s,
|
|
101
|
-
locale: a
|
|
102
|
-
}),
|
|
103
|
-
[l, o, m, s, a]
|
|
104
|
-
);
|
|
105
|
-
G(() => {
|
|
106
|
-
y && o !== y && _(y);
|
|
107
|
-
}, [y, _, o]), G(() => {
|
|
108
|
-
!y || typeof document > "u" || (document.cookie = `${Wr}=${y}; Path=/; Max-Age=31536000; SameSite=Lax`);
|
|
109
|
-
}, [y]);
|
|
110
|
-
const h = H(
|
|
111
|
-
() => Wt(l),
|
|
112
|
-
[l]
|
|
113
|
-
), p = H(
|
|
114
|
-
() => l.find((b) => b.code === y) ?? h,
|
|
115
|
-
[l, h, y]
|
|
116
|
-
), f = H(
|
|
117
|
-
() => ({
|
|
118
|
-
currencies: l,
|
|
119
|
-
defaultCurrency: h,
|
|
120
|
-
activeCurrency: p,
|
|
121
|
-
activeCurrencyCode: p.code,
|
|
122
|
-
isHydrated: m,
|
|
123
|
-
setActiveCurrencyCode: (b) => {
|
|
124
|
-
const d = Fe(b);
|
|
125
|
-
l.some((v) => v.code === d) && _(d);
|
|
126
|
-
}
|
|
127
|
-
}),
|
|
128
|
-
[p, l, h, m, _]
|
|
129
|
-
);
|
|
130
|
-
return /* @__PURE__ */ e(dr.Provider, { value: f, children: t });
|
|
131
|
-
}
|
|
132
|
-
function le() {
|
|
133
|
-
const t = rr(dr);
|
|
134
|
-
if (!t)
|
|
135
|
-
throw new Error("useCurrency must be used inside a CurrencyProvider");
|
|
136
|
-
return t;
|
|
137
|
-
}
|
|
138
|
-
function rt(t, n, s) {
|
|
139
|
-
return t.reduce((a, l) => Y(l) || l.sku !== n || s && l.id === s ? a : a + l.quantity, 0);
|
|
140
|
-
}
|
|
141
|
-
const Te = Kt()(
|
|
142
|
-
Gt(
|
|
143
|
-
(t, n) => ({
|
|
144
|
-
items: [],
|
|
145
|
-
appliedCoupon: null,
|
|
146
|
-
isOpen: !1,
|
|
147
|
-
addItem: (s) => {
|
|
148
|
-
const { items: a } = n(), l = s.quantity ?? 1, c = typeof s.stock == "number" ? s.stock : null, o = c !== null ? rt(a, s.sku) : 0;
|
|
149
|
-
if (Y(s))
|
|
150
|
-
return a.find(
|
|
151
|
-
(y) => y.product_id === s.product_id && Y(y)
|
|
152
|
-
) ? {
|
|
153
|
-
success: !1,
|
|
154
|
-
error: "This software license is already in your cart."
|
|
155
|
-
} : (t({
|
|
156
|
-
items: [...a, { ...s, quantity: 1 }],
|
|
157
|
-
isOpen: !0
|
|
158
|
-
}), { success: !0 });
|
|
159
|
-
const m = a.find((_) => _.id === s.id);
|
|
160
|
-
return c !== null && c <= 0 ? {
|
|
161
|
-
success: !1,
|
|
162
|
-
error: "This item is out of stock."
|
|
163
|
-
} : c !== null && o + l > c ? {
|
|
164
|
-
success: !1,
|
|
165
|
-
error: `Only ${c} available for this SKU.`
|
|
166
|
-
} : (t(m ? {
|
|
167
|
-
items: a.map(
|
|
168
|
-
(_) => _.id === s.id ? {
|
|
169
|
-
..._,
|
|
170
|
-
...s,
|
|
171
|
-
quantity: _.quantity + l
|
|
172
|
-
} : _
|
|
173
|
-
),
|
|
174
|
-
isOpen: !0
|
|
175
|
-
} : {
|
|
176
|
-
items: [...a, { ...s, quantity: l }],
|
|
177
|
-
isOpen: !0
|
|
178
|
-
}), { success: !0 });
|
|
179
|
-
},
|
|
180
|
-
removeItem: (s) => {
|
|
181
|
-
const { items: a } = n();
|
|
182
|
-
t({
|
|
183
|
-
items: a.filter((l) => l.id !== s)
|
|
184
|
-
});
|
|
185
|
-
},
|
|
186
|
-
updateQuantity: (s, a) => {
|
|
187
|
-
const { items: l } = n(), c = l.find((o) => o.id === s);
|
|
188
|
-
c && Y(c) || (c && typeof c.stock == "number" && a + rt(l, c.sku, s) > c.stock && (a = Math.max(
|
|
189
|
-
c.stock - rt(l, c.sku, s),
|
|
190
|
-
0
|
|
191
|
-
)), a <= 0 ? t({
|
|
192
|
-
items: l.filter((o) => o.id !== s)
|
|
193
|
-
}) : t({
|
|
194
|
-
items: l.map(
|
|
195
|
-
(o) => o.id === s ? { ...o, quantity: a } : o
|
|
196
|
-
)
|
|
197
|
-
}));
|
|
198
|
-
},
|
|
199
|
-
setAppliedCoupon: (s) => {
|
|
200
|
-
const a = n().appliedCoupon;
|
|
201
|
-
a?.code === s?.code && a?.couponId === s?.couponId || t({ appliedCoupon: s });
|
|
202
|
-
},
|
|
203
|
-
removeCoupon: () => {
|
|
204
|
-
n().appliedCoupon && t({ appliedCoupon: null });
|
|
205
|
-
},
|
|
206
|
-
clearCart: () => t({ items: [], appliedCoupon: null }),
|
|
207
|
-
toggleCart: () => t((s) => ({ isOpen: !s.isOpen })),
|
|
208
|
-
setIsOpen: (s) => t({ isOpen: s }),
|
|
209
|
-
setItems: (s) => t({ items: s })
|
|
210
|
-
}),
|
|
211
|
-
{
|
|
212
|
-
name: "cart-storage",
|
|
213
|
-
storage: Jt(() => localStorage),
|
|
214
|
-
skipHydration: !0
|
|
215
|
-
}
|
|
216
|
-
)
|
|
217
|
-
), vs = () => Te((n) => n.items).reduce((n, s) => n + s.quantity, 0);
|
|
218
|
-
function Ce(t, n) {
|
|
219
|
-
return ke({
|
|
220
|
-
prices: t.prices,
|
|
221
|
-
salePrices: t.sale_prices,
|
|
222
|
-
fallbackPrice: t.price,
|
|
223
|
-
fallbackSalePrice: t.sale_price,
|
|
224
|
-
saleStartAt: t.sale_start_at,
|
|
225
|
-
saleEndAt: t.sale_end_at,
|
|
226
|
-
scheduledPrice: t.scheduled_price,
|
|
227
|
-
scheduledPrices: t.scheduled_prices,
|
|
228
|
-
scheduledPriceAt: t.scheduled_price_at,
|
|
229
|
-
currencyCode: n.currencyCode,
|
|
230
|
-
currencies: n.currencies
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
const ur = () => {
|
|
234
|
-
const t = Te((a) => a.items), { activeCurrencyCode: n, currencies: s } = le();
|
|
235
|
-
return t.reduce((a, l) => {
|
|
236
|
-
const { price: c, sale_price: o } = Ce(l, {
|
|
237
|
-
currencyCode: n,
|
|
238
|
-
currencies: s
|
|
239
|
-
});
|
|
240
|
-
return a + (o ?? c) * l.quantity;
|
|
241
|
-
}, 0);
|
|
242
|
-
};
|
|
243
|
-
let qe = null;
|
|
244
|
-
function Ge() {
|
|
245
|
-
return Te.persist;
|
|
246
|
-
}
|
|
247
|
-
function ct() {
|
|
248
|
-
return Ge()?.hasHydrated?.() ?? !1;
|
|
249
|
-
}
|
|
250
|
-
function mr() {
|
|
251
|
-
if (typeof window > "u")
|
|
252
|
-
return Promise.resolve();
|
|
253
|
-
const t = Ge();
|
|
254
|
-
return !t || t.hasHydrated() ? Promise.resolve() : (qe || (qe = Promise.resolve().then(() => t.rehydrate()).finally(() => {
|
|
255
|
-
qe = null;
|
|
256
|
-
})), qe);
|
|
257
|
-
}
|
|
258
|
-
const ue = (t) => {
|
|
259
|
-
const n = Te(t), [s, a] = k(!1);
|
|
260
|
-
return G(() => {
|
|
261
|
-
const l = Ge();
|
|
262
|
-
if (ct()) {
|
|
263
|
-
a(!0);
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
const c = l?.onFinishHydration(() => a(!0));
|
|
267
|
-
return mr(), () => {
|
|
268
|
-
c?.();
|
|
269
|
-
};
|
|
270
|
-
}, []), s ? n : void 0;
|
|
271
|
-
}, fa = () => {
|
|
272
|
-
const [t, n] = k(!1);
|
|
273
|
-
return G(() => {
|
|
274
|
-
const a = Ge()?.onFinishHydration(() => n(!0));
|
|
275
|
-
return n(ct()), ct() || mr(), () => {
|
|
276
|
-
a?.();
|
|
277
|
-
};
|
|
278
|
-
}, []), t;
|
|
279
|
-
};
|
|
280
|
-
function it(t) {
|
|
281
|
-
const n = Number(t?.trial_period_days ?? 0);
|
|
282
|
-
return !Number.isFinite(n) || n <= 0 ? 0 : Math.round(n);
|
|
283
|
-
}
|
|
284
|
-
function Ns(t) {
|
|
285
|
-
return it(t) === 0 ? null : t?.trial_requires_payment_method ? "paid" : "free";
|
|
286
|
-
}
|
|
287
|
-
function Cs(t) {
|
|
288
|
-
const n = it(typeof t == "number" ? { trial_period_days: t } : t);
|
|
289
|
-
return n > 0 ? `${n}-day free trial` : null;
|
|
290
|
-
}
|
|
291
|
-
function ws(t) {
|
|
292
|
-
return t?.trial_requires_payment_method ? "Payment method required" : "No credit card required";
|
|
293
|
-
}
|
|
294
|
-
function pe(t) {
|
|
295
|
-
const n = Cs(t);
|
|
296
|
-
return n ? {
|
|
297
|
-
label: n,
|
|
298
|
-
paymentRequirementLabel: ws(t),
|
|
299
|
-
checkoutMode: Ns(t)
|
|
300
|
-
} : null;
|
|
301
|
-
}
|
|
302
|
-
async function ks(t) {
|
|
303
|
-
try {
|
|
304
|
-
const n = sr();
|
|
305
|
-
return await Qt({
|
|
306
|
-
client: n,
|
|
307
|
-
code: t.code,
|
|
308
|
-
items: Array.isArray(t.items) ? t.items : [],
|
|
309
|
-
currencyCode: t.currencyCode
|
|
310
|
-
});
|
|
311
|
-
} catch (n) {
|
|
312
|
-
return console.error("Failed to validate coupon:", n), {
|
|
313
|
-
success: !1,
|
|
314
|
-
error: n.message || "Failed to validate coupon.",
|
|
315
|
-
errorKey: "ecommerce.coupon_validation_failed"
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
function pt({
|
|
320
|
-
items: t,
|
|
321
|
-
currencyCode: n,
|
|
322
|
-
onQuoteChange: s,
|
|
323
|
-
compact: a = !1
|
|
1
|
+
import { CartDrawer as ar } from "./components/CartDrawer.es.js";
|
|
2
|
+
import { Cart as sr } from "./components/Cart.es.js";
|
|
3
|
+
import { Checkout as ir } from "./components/Checkout.es.js";
|
|
4
|
+
import { CartIcon as or } from "./components/CartIcon.es.js";
|
|
5
|
+
import { C as dr } from "./CouponForm-BI_5SBHQ.js";
|
|
6
|
+
import { CurrencySwitcher as ur } from "./components/CurrencySwitcher.es.js";
|
|
7
|
+
import { A as hr } from "./AddToCartButton-ffE0DhHu.js";
|
|
8
|
+
import { P as _r, a as fr } from "./ProductGrid-D3AWM8sr.js";
|
|
9
|
+
import { P as yr, a as vr, b as Nr, S as xr, u as Cr } from "./ProductDetailsLayout-Dg8dRTYp.js";
|
|
10
|
+
import { FeaturedProduct as Sr } from "./components/FeaturedProduct.es.js";
|
|
11
|
+
import { jsxs as a, jsx as r } from "react/jsx-runtime";
|
|
12
|
+
import E, { useState as C } from "react";
|
|
13
|
+
import { useForm as te } from "react-hook-form";
|
|
14
|
+
import se from "next/link";
|
|
15
|
+
import { usePathname as le } from "next/navigation";
|
|
16
|
+
import { KeyRound as ie, Package2 as ne, User as V, Upload as oe, Github as F, Phone as ce, Globe as de, Mail as me } from "lucide-react";
|
|
17
|
+
import { useTranslations as T, cn as z } from "@nextblock-cms/utils";
|
|
18
|
+
import { Avatar as ue, AvatarImage as pe, AvatarFallback as he } from "@nextblock-cms/ui/avatar";
|
|
19
|
+
import { Badge as ge } from "@nextblock-cms/ui/badge";
|
|
20
|
+
import { Button as G } from "@nextblock-cms/ui/button";
|
|
21
|
+
import { Card as B, CardHeader as M, CardTitle as j, CardContent as D, CardFooter as _e } from "@nextblock-cms/ui/card";
|
|
22
|
+
import { Checkbox as fe } from "@nextblock-cms/ui/checkbox";
|
|
23
|
+
import { Input as m } from "@nextblock-cms/ui/input";
|
|
24
|
+
import { Label as c } from "@nextblock-cms/ui/label";
|
|
25
|
+
import { Select as be, SelectTrigger as ye, SelectValue as ve, SelectContent as Ne, SelectItem as I } from "@nextblock-cms/ui/select";
|
|
26
|
+
import { Separator as xe } from "@nextblock-cms/ui/separator";
|
|
27
|
+
import { createClient as Ce } from "@nextblock-cms/db/server";
|
|
28
|
+
import { revalidatePath as H } from "next/cache";
|
|
29
|
+
import { n as S, a as K, e as we } from "./customer-C3xccjUg.js";
|
|
30
|
+
import { i as Er, b as Fr } from "./customer-C3xccjUg.js";
|
|
31
|
+
import { u as Se } from "./actions-j5fuSZX-.js";
|
|
32
|
+
import { createClient as W } from "@nextblock-cms/db";
|
|
33
|
+
import { n as Pe, c as Ee } from "./states-DlHJezQ1.js";
|
|
34
|
+
import { D as Tr, I as Ar, a as Rr, b as $r, P as Lr, c as Ur, d as kr, e as Or, f as Vr, g as zr, h as Gr, i as Br, j as Mr, k as jr, l as Dr, m as Hr, n as Kr, o as Wr, p as qr, q as Xr, r as Yr, s as Jr, t as Qr, u as Zr } from "./invoice-ui-DtpbTJE1.js";
|
|
35
|
+
import { SimpleTiptapRenderer as ra } from "./components/SimpleTiptapRenderer.es.js";
|
|
36
|
+
import { getCartItemActivePrice as ta, useCartStore as sa, useCartSubtotal as la, useCartTotalItems as ia } from "./cart-store.es.js";
|
|
37
|
+
import { e as oa, g as ca, n as da } from "./coupon-server-DUKVtyYs.js";
|
|
38
|
+
import { C as ua, u as pa, a as ha } from "./CurrencyProvider-OzlRN96V.js";
|
|
39
|
+
import { CURRENCY_ROUNDING_MODES as _a, applyCurrencyRounding as fa, convertMinorUnitAmount as ba, describeCurrencyRoundingRule as ya, getCurrencyLookup as va, getDefaultCurrency as Na, getExchangeRateForCurrency as xa, inferCurrencyCodeFromLocale as Ca, isSaleWindowActive as wa, isScheduledPriceDue as Sa, normalizeCurrencyRecord as Pa, normalizeCurrencyRoundingMode as Ea, normalizePriceMap as Fa, normalizeSalePriceMap as Ia, resolveEffectivePriceForCurrency as Ta, resolvePriceForCurrency as Aa, resolvePriceRangeForCurrency as Ra, sortCurrencies as $a } from "./currency.es.js";
|
|
40
|
+
import { useCart as Ua, useIsCartHydrated as ka } from "./use-cart.es.js";
|
|
41
|
+
import { DEFAULT_ENABLED_PAYMENT_PROVIDERS as Va, derivePaymentProviderFromProductType as za, getProductPaymentProvider as Ga, isDigitalItem as Ba, isDigitalProduct as Ma, normalizeEnabledPaymentProviders as ja } from "./types.es.js";
|
|
42
|
+
import { g as Ha, a as Ka, b as Wa, c as qa, d as Xa } from "./trials-RDcRAZKx.js";
|
|
43
|
+
import { buildCombinationKey as Ja, buildVariantLabel as Qa, chooseInitialVariantSelections as Za, extractSelectedTermsByAttribute as et, findMatchingVariant as rt, generateVariantDrafts as at, getAvailableTermIdsForAttribute as tt, getVariantEffectivePriceRange as st, mapRawVariantRelations as lt, normalizeSelectionsToAvailableVariants as it, resolveAttributeName as nt, resolveTermValue as ot, resolveTranslatedText as ct } from "./variation-utils.es.js";
|
|
44
|
+
function q(e, d, l) {
|
|
45
|
+
const s = e(d);
|
|
46
|
+
return s === d ? l : s;
|
|
47
|
+
}
|
|
48
|
+
function Fe(e) {
|
|
49
|
+
return e === "password" ? ie : ne;
|
|
50
|
+
}
|
|
51
|
+
function Ie({
|
|
52
|
+
links: e,
|
|
53
|
+
title: d,
|
|
54
|
+
className: l
|
|
324
55
|
}) {
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
(i) => `${wt(i)}:${n}:${F}`,
|
|
333
|
-
[F, n]
|
|
334
|
-
), L = et(async (i, $) => {
|
|
335
|
-
const q = wt(i);
|
|
336
|
-
if (!q) {
|
|
337
|
-
b(j("ecommerce.coupon_code_required", "Enter a coupon code."));
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
E(!0), b("");
|
|
341
|
-
try {
|
|
342
|
-
const P = await ks({
|
|
343
|
-
code: q,
|
|
344
|
-
items: t,
|
|
345
|
-
currencyCode: n
|
|
346
|
-
});
|
|
347
|
-
if (!P.success) {
|
|
348
|
-
p(null), s?.(null), o?.(), b(P.errorKey ? j(P.errorKey, P.error) : P.error);
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
v.current = R(P.quote.code), p(P.quote), s?.(P.quote), $?.silent || (c?.({
|
|
352
|
-
code: P.quote.code,
|
|
353
|
-
couponId: P.quote.couponId
|
|
354
|
-
}), y("")), $?.silent || b("");
|
|
355
|
-
} catch (P) {
|
|
356
|
-
console.error("Failed to validate coupon:", P), p(null), s?.(null), b(
|
|
357
|
-
j("ecommerce.coupon_validation_failed", "Failed to validate coupon.")
|
|
358
|
-
);
|
|
359
|
-
} finally {
|
|
360
|
-
E(!1);
|
|
361
|
-
}
|
|
362
|
-
}, [
|
|
363
|
-
o,
|
|
364
|
-
n,
|
|
365
|
-
R,
|
|
366
|
-
t,
|
|
367
|
-
s,
|
|
368
|
-
c,
|
|
369
|
-
j
|
|
370
|
-
]);
|
|
371
|
-
if (G(() => {
|
|
372
|
-
if (!c || !o)
|
|
373
|
-
return;
|
|
374
|
-
if (!l || t.length === 0) {
|
|
375
|
-
v.current = null, p(null), s?.(null);
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
const i = R(l.code);
|
|
379
|
-
v.current !== i && (v.current = i, L(l.code, { silent: !0 }));
|
|
380
|
-
}, [
|
|
381
|
-
l?.code,
|
|
382
|
-
L,
|
|
383
|
-
o,
|
|
384
|
-
R,
|
|
385
|
-
t.length,
|
|
386
|
-
s,
|
|
387
|
-
c
|
|
388
|
-
]), !c || !o)
|
|
389
|
-
return null;
|
|
390
|
-
const S = () => {
|
|
391
|
-
o(), p(null), s?.(null), b("");
|
|
392
|
-
};
|
|
393
|
-
return /* @__PURE__ */ r("div", { className: a ? "space-y-2" : "rounded-lg border bg-muted/10 p-4 space-y-3", children: [
|
|
394
|
-
/* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-3", children: [
|
|
395
|
-
/* @__PURE__ */ r(A, { htmlFor: a ? "coupon-code-compact" : "coupon-code", className: "flex items-center gap-2 text-sm font-medium", children: [
|
|
396
|
-
/* @__PURE__ */ e(jr, { className: "h-4 w-4" }),
|
|
397
|
-
j("ecommerce.coupon", "Coupon")
|
|
398
|
-
] }),
|
|
399
|
-
h ? /* @__PURE__ */ r(ie, { variant: "secondary", className: "gap-1", children: [
|
|
400
|
-
h.code,
|
|
401
|
-
/* @__PURE__ */ e("button", { type: "button", onClick: S, "aria-label": `Remove coupon ${h.code}`, children: /* @__PURE__ */ e(Mt, { className: "h-3 w-3" }) })
|
|
402
|
-
] }) : null
|
|
403
|
-
] }),
|
|
404
|
-
h ? /* @__PURE__ */ r("div", { className: "flex items-center justify-between text-sm", children: [
|
|
405
|
-
/* @__PURE__ */ e("span", { className: "text-muted-foreground", children: h.name }),
|
|
406
|
-
/* @__PURE__ */ r("span", { className: "font-medium text-emerald-600", children: [
|
|
407
|
-
"-",
|
|
408
|
-
w(h.discountTotal, n)
|
|
409
|
-
] })
|
|
410
|
-
] }) : /* @__PURE__ */ r("div", { className: "flex gap-2", children: [
|
|
411
|
-
/* @__PURE__ */ e(
|
|
412
|
-
U,
|
|
413
|
-
{
|
|
414
|
-
id: a ? "coupon-code-compact" : "coupon-code",
|
|
415
|
-
value: _,
|
|
416
|
-
onChange: (i) => y(i.target.value.toUpperCase()),
|
|
417
|
-
placeholder: j("ecommerce.coupon_placeholder", "Code"),
|
|
418
|
-
className: "uppercase",
|
|
419
|
-
onKeyDown: (i) => {
|
|
420
|
-
i.key === "Enter" && (i.preventDefault(), L(_));
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
),
|
|
424
|
-
/* @__PURE__ */ e(
|
|
425
|
-
D,
|
|
56
|
+
const s = le(), { t: h } = T();
|
|
57
|
+
return e.length ? /* @__PURE__ */ a("div", { className: z("w-full space-y-3", l), children: [
|
|
58
|
+
/* @__PURE__ */ r("div", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wider", children: d || q(h, "account_navigation", "Account") }),
|
|
59
|
+
/* @__PURE__ */ r("div", { className: "space-y-2", children: e.map((i) => {
|
|
60
|
+
const u = Fe(i.icon), t = s === i.href || s.startsWith(`${i.href}/`);
|
|
61
|
+
return /* @__PURE__ */ a(
|
|
62
|
+
se,
|
|
426
63
|
{
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
disabled: d || t.length === 0,
|
|
430
|
-
onClick: () => {
|
|
431
|
-
L(_);
|
|
432
|
-
},
|
|
433
|
-
children: d ? j("ecommerce.applying", "Applying...") : j("ecommerce.apply", "Apply")
|
|
434
|
-
}
|
|
435
|
-
)
|
|
436
|
-
] }),
|
|
437
|
-
f ? /* @__PURE__ */ e("p", { className: "text-xs text-destructive", children: f }) : null
|
|
438
|
-
] });
|
|
439
|
-
}
|
|
440
|
-
const ga = () => {
|
|
441
|
-
const t = zt(), n = ue((d) => d), s = ur(), { t: a } = Z(), { activeCurrencyCode: l, currencies: c } = le();
|
|
442
|
-
if (!n) return null;
|
|
443
|
-
const { isOpen: o, setIsOpen: m, items: _, updateQuantity: y, removeItem: h } = n, p = (d) => _.reduce((E, v) => Y(v) || v.sku !== d ? E : E + v.quantity, 0), f = () => {
|
|
444
|
-
m(!1), t.push("/cart");
|
|
445
|
-
}, b = () => {
|
|
446
|
-
m(!1), t.push("/checkout");
|
|
447
|
-
};
|
|
448
|
-
return /* @__PURE__ */ e(Fr, { open: o, onOpenChange: m, children: /* @__PURE__ */ r(Tr, { className: "flex w-full flex-col pr-0 sm:max-w-lg", children: [
|
|
449
|
-
/* @__PURE__ */ r(Rr, { className: "px-1 text-left", children: [
|
|
450
|
-
/* @__PURE__ */ r($r, { children: [
|
|
451
|
-
a("ecommerce.shopping_cart"),
|
|
452
|
-
" (",
|
|
453
|
-
_.length,
|
|
454
|
-
")"
|
|
455
|
-
] }),
|
|
456
|
-
/* @__PURE__ */ e(Lr, { className: "sr-only", children: a("ecommerce.shopping_cart") })
|
|
457
|
-
] }),
|
|
458
|
-
_.length > 0 ? /* @__PURE__ */ e("div", { className: "flex flex-1 flex-col gap-5 overflow-y-auto p-1 pr-6 pt-4", children: _.map((d) => {
|
|
459
|
-
const E = p(d.sku);
|
|
460
|
-
return /* @__PURE__ */ e("div", { className: "flex gap-4", children: (() => {
|
|
461
|
-
const v = Ce(d, {
|
|
462
|
-
currencyCode: l,
|
|
463
|
-
currencies: c
|
|
464
|
-
}), F = pe(d);
|
|
465
|
-
return /* @__PURE__ */ r(ot, { children: [
|
|
466
|
-
d.image_url ? /* @__PURE__ */ e("div", { className: "relative aspect-square h-20 w-20 min-w-fit overflow-hidden rounded border bg-neutral-100", children: /* @__PURE__ */ e(
|
|
467
|
-
"img",
|
|
468
|
-
{
|
|
469
|
-
src: d.image_url,
|
|
470
|
-
alt: d.title,
|
|
471
|
-
className: "h-full w-full object-cover"
|
|
472
|
-
}
|
|
473
|
-
) }) : /* @__PURE__ */ e("div", { className: "flex h-20 w-20 items-center justify-center rounded bg-secondary", children: /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground", children: a("ecommerce.no_image") }) }),
|
|
474
|
-
/* @__PURE__ */ r("div", { className: "flex flex-1 flex-col justify-between", children: [
|
|
475
|
-
/* @__PURE__ */ r("div", { className: "flex justify-between gap-2", children: [
|
|
476
|
-
/* @__PURE__ */ r("div", { children: [
|
|
477
|
-
/* @__PURE__ */ e("span", { className: "line-clamp-2 text-sm font-medium leading-tight", children: d.title }),
|
|
478
|
-
d.variant_label && /* @__PURE__ */ e("div", { className: "mt-1 text-xs text-muted-foreground", children: d.variant_label }),
|
|
479
|
-
F && /* @__PURE__ */ r("div", { className: "mt-1 text-xs font-medium text-emerald-700", children: [
|
|
480
|
-
F.label,
|
|
481
|
-
" - ",
|
|
482
|
-
F.paymentRequirementLabel
|
|
483
|
-
] })
|
|
484
|
-
] }),
|
|
485
|
-
/* @__PURE__ */ r("span", { className: "text-sm font-semibold", children: [
|
|
486
|
-
v.sale_price && /* @__PURE__ */ e("span", { className: "mr-1.5 text-xs font-normal text-muted-foreground line-through", children: w(v.price, l) }),
|
|
487
|
-
w(v.sale_price ?? v.price, l)
|
|
488
|
-
] })
|
|
489
|
-
] }),
|
|
490
|
-
/* @__PURE__ */ r("div", { className: "flex items-center justify-between text-sm", children: [
|
|
491
|
-
Y(d) ? /* @__PURE__ */ e(ie, { variant: "secondary", className: "font-normal text-xs", children: "1 (License)" }) : /* @__PURE__ */ r("div", { className: "flex items-center rounded-md border text-xs", children: [
|
|
492
|
-
/* @__PURE__ */ e(
|
|
493
|
-
"button",
|
|
494
|
-
{
|
|
495
|
-
onClick: () => y(d.id, d.quantity - 1),
|
|
496
|
-
className: "flex h-7 w-7 items-center justify-center border-r",
|
|
497
|
-
type: "button",
|
|
498
|
-
children: /* @__PURE__ */ e(Ut, { className: "h-3 w-3" })
|
|
499
|
-
}
|
|
500
|
-
),
|
|
501
|
-
/* @__PURE__ */ e("span", { className: "flex h-7 w-8 items-center justify-center", children: d.quantity }),
|
|
502
|
-
/* @__PURE__ */ e(
|
|
503
|
-
"button",
|
|
504
|
-
{
|
|
505
|
-
onClick: () => y(d.id, d.quantity + 1),
|
|
506
|
-
className: "flex h-7 w-7 items-center justify-center border-l",
|
|
507
|
-
type: "button",
|
|
508
|
-
disabled: typeof d.stock == "number" && E >= d.stock,
|
|
509
|
-
children: /* @__PURE__ */ e(Vt, { className: "h-3 w-3" })
|
|
510
|
-
}
|
|
511
|
-
)
|
|
512
|
-
] }),
|
|
513
|
-
/* @__PURE__ */ e(
|
|
514
|
-
"button",
|
|
515
|
-
{
|
|
516
|
-
onClick: () => h(d.id),
|
|
517
|
-
className: "text-muted-foreground hover:text-destructive",
|
|
518
|
-
type: "button",
|
|
519
|
-
children: /* @__PURE__ */ e(Dt, { className: "h-4 w-4" })
|
|
520
|
-
}
|
|
521
|
-
)
|
|
522
|
-
] })
|
|
523
|
-
] })
|
|
524
|
-
] });
|
|
525
|
-
})() }, d.id);
|
|
526
|
-
}) }) : /* @__PURE__ */ r("div", { className: "flex h-full flex-col items-center justify-center space-y-2", children: [
|
|
527
|
-
/* @__PURE__ */ e("span", { className: "text-muted-foreground", children: a("ecommerce.cart_empty") }),
|
|
528
|
-
/* @__PURE__ */ e(D, { variant: "outline", onClick: () => m(!1), children: a("ecommerce.continue_shopping") })
|
|
529
|
-
] }),
|
|
530
|
-
_.length > 0 && /* @__PURE__ */ r("div", { className: "border-t pr-6 pt-4", children: [
|
|
531
|
-
/* @__PURE__ */ r("div", { className: "flex items-center justify-between text-base font-medium", children: [
|
|
532
|
-
/* @__PURE__ */ e("span", { children: a("ecommerce.subtotal") }),
|
|
533
|
-
/* @__PURE__ */ e("span", { children: w(s, l) })
|
|
534
|
-
] }),
|
|
535
|
-
/* @__PURE__ */ e("p", { className: "mb-4 mt-1 text-xs text-muted-foreground", children: a("ecommerce.shipping_taxes_calculated") }),
|
|
536
|
-
/* @__PURE__ */ e("div", { className: "mb-4", children: /* @__PURE__ */ e(pt, { items: _, currencyCode: l, compact: !0 }) }),
|
|
537
|
-
/* @__PURE__ */ e(D, { variant: "outline", className: "w-full mb-3", onClick: f, children: a("ecommerce.view_full_cart") }),
|
|
538
|
-
/* @__PURE__ */ e(D, { className: "w-full", onClick: b, children: a("ecommerce.ready_to_checkout") })
|
|
539
|
-
] })
|
|
540
|
-
] }) });
|
|
541
|
-
};
|
|
542
|
-
async function pr(t, n, s, a) {
|
|
543
|
-
try {
|
|
544
|
-
const l = dt(n.country);
|
|
545
|
-
return l ? { success: !0, methods: await Zr(t, {
|
|
546
|
-
...n,
|
|
547
|
-
country: l,
|
|
548
|
-
state: es(l, n.state) || void 0
|
|
549
|
-
}, s, a) } : {
|
|
550
|
-
success: !1,
|
|
551
|
-
error: "Country is required for shipping calculation",
|
|
552
|
-
errorKey: "ecommerce.shipping_country_required"
|
|
553
|
-
};
|
|
554
|
-
} catch (l) {
|
|
555
|
-
return console.error("Failed to resolve shipping options:", l), {
|
|
556
|
-
success: !1,
|
|
557
|
-
error: l.message || "Failed to calculate shipping",
|
|
558
|
-
errorKey: "ecommerce.shipping_calculation_failed"
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
const Ss = ({ physicalSubtotal: t }) => {
|
|
563
|
-
const [n, s] = k("CA"), [a, l] = k(""), [c, o] = k(""), [m, _] = k(!1), [y, h] = k(null), [p, f] = k(null), { t: b, lang: d } = Z(), { activeCurrencyCode: E } = le(), v = (i, $) => {
|
|
564
|
-
const q = b(i);
|
|
565
|
-
return q === i ? $ : q;
|
|
566
|
-
}, F = Be(n), j = Ke(n), R = v("select_an_option", "Select an option"), L = v("state_province", "State / Province"), S = async () => {
|
|
567
|
-
_(!0), f(null), h(null);
|
|
568
|
-
const i = await pr(
|
|
569
|
-
t,
|
|
570
|
-
{
|
|
571
|
-
country: n,
|
|
572
|
-
state: a || void 0,
|
|
573
|
-
postal_code: c
|
|
574
|
-
},
|
|
575
|
-
d,
|
|
576
|
-
E
|
|
577
|
-
);
|
|
578
|
-
i.success && i.methods ? h(i.methods) : f(
|
|
579
|
-
i.errorKey ? v(
|
|
580
|
-
i.errorKey,
|
|
581
|
-
i.error || b("ecommerce.no_rates_found")
|
|
582
|
-
) : i.error || b("ecommerce.no_rates_found")
|
|
583
|
-
), _(!1);
|
|
584
|
-
};
|
|
585
|
-
return /* @__PURE__ */ r("div", { className: "space-y-4 rounded-lg border bg-muted/30 p-4 mt-6", children: [
|
|
586
|
-
/* @__PURE__ */ r("div", { className: "flex items-center gap-2 font-semibold text-sm", children: [
|
|
587
|
-
/* @__PURE__ */ e(vt, { className: "h-4 w-4" }),
|
|
588
|
-
/* @__PURE__ */ e("span", { children: b("ecommerce.estimate_shipping") })
|
|
589
|
-
] }),
|
|
590
|
-
/* @__PURE__ */ r("div", { className: "grid gap-3", children: [
|
|
591
|
-
/* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
592
|
-
/* @__PURE__ */ e(A, { htmlFor: "estimate-country", className: "text-xs uppercase tracking-wider text-muted-foreground", children: b("ecommerce.country") }),
|
|
593
|
-
/* @__PURE__ */ e(
|
|
594
|
-
"select",
|
|
595
|
-
{
|
|
596
|
-
id: "estimate-country",
|
|
597
|
-
value: n,
|
|
598
|
-
onChange: (i) => {
|
|
599
|
-
const $ = i.target.value, q = Be($);
|
|
600
|
-
s($), l(
|
|
601
|
-
q.some((P) => P.code === a) ? a : ""
|
|
602
|
-
);
|
|
603
|
-
},
|
|
604
|
-
className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
605
|
-
children: ut.map((i) => /* @__PURE__ */ e("option", { value: i.code, children: i.name }, i.code))
|
|
606
|
-
}
|
|
607
|
-
)
|
|
608
|
-
] }),
|
|
609
|
-
j && /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
610
|
-
/* @__PURE__ */ e(A, { htmlFor: "estimate-state", className: "text-xs uppercase tracking-wider text-muted-foreground", children: b("state_province") }),
|
|
611
|
-
/* @__PURE__ */ r(
|
|
612
|
-
"select",
|
|
613
|
-
{
|
|
614
|
-
id: "estimate-state",
|
|
615
|
-
value: a,
|
|
616
|
-
onChange: (i) => l(i.target.value),
|
|
617
|
-
className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
618
|
-
children: [
|
|
619
|
-
/* @__PURE__ */ e("option", { value: "", children: `${R}: ${L}` }),
|
|
620
|
-
F.map((i) => /* @__PURE__ */ e("option", { value: i.code, children: i.name }, i.code))
|
|
621
|
-
]
|
|
622
|
-
}
|
|
623
|
-
)
|
|
624
|
-
] }),
|
|
625
|
-
/* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
626
|
-
/* @__PURE__ */ e(A, { htmlFor: "estimate-postal", className: "text-xs uppercase tracking-wider text-muted-foreground", children: b("ecommerce.postal_code") }),
|
|
627
|
-
/* @__PURE__ */ r("div", { className: "flex gap-2", children: [
|
|
628
|
-
/* @__PURE__ */ e(
|
|
629
|
-
U,
|
|
630
|
-
{
|
|
631
|
-
id: "estimate-postal",
|
|
632
|
-
placeholder: "A1A 1A1",
|
|
633
|
-
value: c,
|
|
634
|
-
onChange: (i) => o(i.target.value),
|
|
635
|
-
className: "h-9 text-sm bg-background"
|
|
636
|
-
}
|
|
637
|
-
),
|
|
638
|
-
/* @__PURE__ */ r(
|
|
639
|
-
D,
|
|
640
|
-
{
|
|
641
|
-
size: "sm",
|
|
642
|
-
variant: "secondary",
|
|
643
|
-
onClick: S,
|
|
644
|
-
disabled: m,
|
|
645
|
-
className: "shrink-0",
|
|
646
|
-
children: [
|
|
647
|
-
m ? /* @__PURE__ */ e(Ve, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(Or, { className: "h-4 w-4 mr-1.5" }),
|
|
648
|
-
b("ecommerce.calculate")
|
|
649
|
-
]
|
|
650
|
-
}
|
|
651
|
-
)
|
|
652
|
-
] })
|
|
653
|
-
] })
|
|
654
|
-
] }),
|
|
655
|
-
p && /* @__PURE__ */ e("p", { className: "text-xs text-destructive mt-2", children: p }),
|
|
656
|
-
y && y.length > 0 && /* @__PURE__ */ r("div", { className: "mt-4 space-y-2 border-t pt-3", children: [
|
|
657
|
-
/* @__PURE__ */ r("p", { className: "text-xs font-medium text-muted-foreground uppercase", children: [
|
|
658
|
-
b("ecommerce.available_rates"),
|
|
659
|
-
":"
|
|
660
|
-
] }),
|
|
661
|
-
y.map((i) => /* @__PURE__ */ r("div", { className: "flex justify-between items-center p-3 border rounded-lg bg-muted/30", children: [
|
|
662
|
-
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
663
|
-
/* @__PURE__ */ e(vt, { className: "h-4 w-4 text-muted-foreground" }),
|
|
664
|
-
/* @__PURE__ */ e("span", { className: "text-sm font-medium", children: i.name })
|
|
665
|
-
] }),
|
|
666
|
-
/* @__PURE__ */ e("span", { className: "text-sm font-bold", children: i.amount === 0 ? b("ecommerce.free") : w(i.amount, E) })
|
|
667
|
-
] }, i.id))
|
|
668
|
-
] }),
|
|
669
|
-
y && y.length === 0 && !p && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground mt-2 italic", children: b("ecommerce.no_rates_found") })
|
|
670
|
-
] });
|
|
671
|
-
}, _a = () => {
|
|
672
|
-
const t = zt(), n = ue((f) => f), s = ur(), { t: a } = Z(), { activeCurrencyCode: l, currencies: c } = le(), o = n?.items ?? [], m = H(
|
|
673
|
-
() => o.reduce((f, b) => {
|
|
674
|
-
if (Y(b))
|
|
675
|
-
return f;
|
|
676
|
-
const d = Ce(b, {
|
|
677
|
-
currencyCode: l,
|
|
678
|
-
currencies: c
|
|
679
|
-
});
|
|
680
|
-
return f + (d.sale_price ?? d.price) * b.quantity;
|
|
681
|
-
}, 0),
|
|
682
|
-
[l, c, o]
|
|
683
|
-
);
|
|
684
|
-
if (!n) return null;
|
|
685
|
-
const { updateQuantity: _, removeItem: y } = n, h = (f) => o.reduce((b, d) => Y(d) || d.sku !== f ? b : b + d.quantity, 0), p = () => {
|
|
686
|
-
t.push("/checkout");
|
|
687
|
-
};
|
|
688
|
-
return o.length === 0 ? /* @__PURE__ */ r("div", { className: "flex flex-col items-center justify-center space-y-4 py-12", children: [
|
|
689
|
-
/* @__PURE__ */ e("h2", { className: "text-2xl font-bold", children: a("ecommerce.cart_empty") }),
|
|
690
|
-
/* @__PURE__ */ e("p", { className: "text-muted-foreground", children: a("ecommerce.cart_empty_description") }),
|
|
691
|
-
/* @__PURE__ */ e(D, { asChild: !0, children: /* @__PURE__ */ e("a", { href: "/shop", children: a("ecommerce.continue_shopping") }) })
|
|
692
|
-
] }) : /* @__PURE__ */ r("div", { className: "container mx-auto py-12", children: [
|
|
693
|
-
/* @__PURE__ */ e("h1", { className: "mb-8 text-3xl font-bold", children: a("ecommerce.shopping_cart") }),
|
|
694
|
-
/* @__PURE__ */ r("div", { className: "grid gap-12 lg:grid-cols-12 lg:items-start", children: [
|
|
695
|
-
/* @__PURE__ */ e("div", { className: "lg:col-span-8", children: /* @__PURE__ */ e("div", { className: "rounded-lg border overflow-hidden", children: /* @__PURE__ */ r(ds, { children: [
|
|
696
|
-
/* @__PURE__ */ e(us, { children: /* @__PURE__ */ r(Et, { children: [
|
|
697
|
-
/* @__PURE__ */ e(Ae, { children: a("ecommerce.product") }),
|
|
698
|
-
/* @__PURE__ */ e(Ae, { children: a("ecommerce.quantity") }),
|
|
699
|
-
/* @__PURE__ */ e(Ae, { className: "text-right", children: a("ecommerce.price") }),
|
|
700
|
-
/* @__PURE__ */ e(Ae, { className: "text-right", children: a("ecommerce.total") }),
|
|
701
|
-
/* @__PURE__ */ e(Ae, { className: "w-[50px]" })
|
|
702
|
-
] }) }),
|
|
703
|
-
/* @__PURE__ */ e(ms, { children: o.map((f) => {
|
|
704
|
-
const b = h(f.sku), d = Ce(f, {
|
|
705
|
-
currencyCode: l,
|
|
706
|
-
currencies: c
|
|
707
|
-
}), E = pe(f);
|
|
708
|
-
return /* @__PURE__ */ r(Et, { children: [
|
|
709
|
-
/* @__PURE__ */ e(Ee, { children: /* @__PURE__ */ r("div", { className: "flex items-center gap-4", children: [
|
|
710
|
-
f.image_url ? /* @__PURE__ */ e("div", { className: "h-16 w-16 overflow-hidden rounded border bg-neutral-100", children: /* @__PURE__ */ e(
|
|
711
|
-
"img",
|
|
712
|
-
{
|
|
713
|
-
src: f.image_url,
|
|
714
|
-
alt: f.title,
|
|
715
|
-
className: "h-full w-full object-cover"
|
|
716
|
-
}
|
|
717
|
-
) }) : /* @__PURE__ */ e("div", { className: "flex h-16 w-16 items-center justify-center rounded bg-secondary", children: /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground", children: a("ecommerce.no_image") }) }),
|
|
718
|
-
/* @__PURE__ */ r("div", { children: [
|
|
719
|
-
/* @__PURE__ */ e("div", { className: "font-medium", children: f.title }),
|
|
720
|
-
f.variant_label && /* @__PURE__ */ e("div", { className: "mt-1 text-xs text-muted-foreground", children: f.variant_label }),
|
|
721
|
-
Y(f) && f.billing_cycle && /* @__PURE__ */ r("div", { className: "mt-1 text-xs capitalize text-muted-foreground", children: [
|
|
722
|
-
f.billing_cycle,
|
|
723
|
-
" Subscription"
|
|
724
|
-
] }),
|
|
725
|
-
E && /* @__PURE__ */ r("div", { className: "mt-1 text-xs font-medium text-emerald-700", children: [
|
|
726
|
-
E.label,
|
|
727
|
-
" - ",
|
|
728
|
-
E.paymentRequirementLabel
|
|
729
|
-
] })
|
|
730
|
-
] })
|
|
731
|
-
] }) }),
|
|
732
|
-
/* @__PURE__ */ e(Ee, { children: Y(f) ? /* @__PURE__ */ e(ie, { variant: "secondary", className: "font-normal text-xs", children: "1 (License)" }) : /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
733
|
-
/* @__PURE__ */ e(
|
|
734
|
-
D,
|
|
735
|
-
{
|
|
736
|
-
variant: "outline",
|
|
737
|
-
size: "icon",
|
|
738
|
-
className: "h-8 w-8",
|
|
739
|
-
onClick: () => _(f.id, f.quantity - 1),
|
|
740
|
-
children: /* @__PURE__ */ e(Ut, { className: "h-4 w-4" })
|
|
741
|
-
}
|
|
742
|
-
),
|
|
743
|
-
/* @__PURE__ */ e("span", { className: "w-8 text-center", children: f.quantity }),
|
|
744
|
-
/* @__PURE__ */ e(
|
|
745
|
-
D,
|
|
746
|
-
{
|
|
747
|
-
variant: "outline",
|
|
748
|
-
size: "icon",
|
|
749
|
-
className: "h-8 w-8",
|
|
750
|
-
onClick: () => _(f.id, f.quantity + 1),
|
|
751
|
-
disabled: typeof f.stock == "number" && b >= f.stock,
|
|
752
|
-
children: /* @__PURE__ */ e(Vt, { className: "h-4 w-4" })
|
|
753
|
-
}
|
|
754
|
-
)
|
|
755
|
-
] }) }),
|
|
756
|
-
/* @__PURE__ */ e(Ee, { className: "text-right", children: /* @__PURE__ */ r("div", { className: "flex flex-col items-end", children: [
|
|
757
|
-
/* @__PURE__ */ e("span", { className: "font-medium", children: w(d.sale_price ?? d.price, l) }),
|
|
758
|
-
d.sale_price && /* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground line-through", children: w(d.price, l) })
|
|
759
|
-
] }) }),
|
|
760
|
-
/* @__PURE__ */ e(Ee, { className: "text-right font-medium", children: w(
|
|
761
|
-
(d.sale_price ?? d.price) * f.quantity,
|
|
762
|
-
l
|
|
763
|
-
) }),
|
|
764
|
-
/* @__PURE__ */ e(Ee, { children: /* @__PURE__ */ e(
|
|
765
|
-
D,
|
|
766
|
-
{
|
|
767
|
-
variant: "ghost",
|
|
768
|
-
size: "icon",
|
|
769
|
-
onClick: () => y(f.id),
|
|
770
|
-
className: "text-muted-foreground hover:text-destructive",
|
|
771
|
-
children: /* @__PURE__ */ e(Dt, { className: "h-4 w-4" })
|
|
772
|
-
}
|
|
773
|
-
) })
|
|
774
|
-
] }, f.id);
|
|
775
|
-
}) })
|
|
776
|
-
] }) }) }),
|
|
777
|
-
/* @__PURE__ */ e("div", { className: "lg:col-span-4", children: /* @__PURE__ */ r("div", { className: "rounded-lg border bg-card p-6 shadow-sm", children: [
|
|
778
|
-
/* @__PURE__ */ e("h2", { className: "mb-4 text-lg font-semibold", children: a("ecommerce.order_summary") }),
|
|
779
|
-
/* @__PURE__ */ r("div", { className: "flex justify-between border-b pb-4", children: [
|
|
780
|
-
/* @__PURE__ */ e("span", { children: a("ecommerce.subtotal") }),
|
|
781
|
-
/* @__PURE__ */ e("span", { className: "font-medium", children: w(s, l) })
|
|
782
|
-
] }),
|
|
783
|
-
/* @__PURE__ */ r("div", { className: "mt-4 flex flex-col gap-4", children: [
|
|
784
|
-
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: a("ecommerce.shipping_taxes_calculated") }),
|
|
785
|
-
o.some((f) => !Y(f)) && /* @__PURE__ */ e(Ss, { physicalSubtotal: m }),
|
|
786
|
-
/* @__PURE__ */ e(
|
|
787
|
-
pt,
|
|
788
|
-
{
|
|
789
|
-
items: o,
|
|
790
|
-
currencyCode: l,
|
|
791
|
-
compact: !0
|
|
792
|
-
}
|
|
793
|
-
),
|
|
794
|
-
/* @__PURE__ */ e(D, { className: "w-full mt-4", size: "lg", onClick: p, children: a("ecommerce.proceed_to_checkout") })
|
|
795
|
-
] })
|
|
796
|
-
] }) })
|
|
797
|
-
] })
|
|
798
|
-
] });
|
|
799
|
-
};
|
|
800
|
-
async function Ps(t, n, s = "USD", a, l) {
|
|
801
|
-
try {
|
|
802
|
-
const c = ar(), o = sr(), { data: m } = await c.from("currencies").select(
|
|
803
|
-
"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"
|
|
804
|
-
).eq("is_active", !0).order("code", { ascending: !0 }), _ = m ?? [];
|
|
805
|
-
let y;
|
|
806
|
-
if (a) {
|
|
807
|
-
const f = await Qt({
|
|
808
|
-
client: o,
|
|
809
|
-
code: a,
|
|
810
|
-
items: l && l.length > 0 ? l : t,
|
|
811
|
-
currencyCode: s
|
|
812
|
-
});
|
|
813
|
-
f.success && (y = ts(f.quote));
|
|
814
|
-
}
|
|
815
|
-
const h = await rs(
|
|
816
|
-
c,
|
|
817
|
-
t,
|
|
818
|
-
s,
|
|
819
|
-
_,
|
|
820
|
-
y
|
|
821
|
-
);
|
|
822
|
-
return { success: !0, tax: await ss(c, {
|
|
823
|
-
items: h,
|
|
824
|
-
destination: n
|
|
825
|
-
}) };
|
|
826
|
-
} catch (c) {
|
|
827
|
-
return console.error("Failed to estimate taxes:", c), {
|
|
828
|
-
success: !1,
|
|
829
|
-
error: c.message || "Failed to calculate taxes"
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
const As = process.env.NEXT_PUBLIC_IS_SANDBOX === "true", ze = "nextblock-checkout-draft-v1";
|
|
834
|
-
function Me(t, n) {
|
|
835
|
-
return {
|
|
836
|
-
...Xt(),
|
|
837
|
-
company_name: t?.company_name || "",
|
|
838
|
-
recipient_name: t?.recipient_name || n || "",
|
|
839
|
-
line1: t?.line1 || "",
|
|
840
|
-
line2: t?.line2 || "",
|
|
841
|
-
city: t?.city || "",
|
|
842
|
-
state: t?.state || "",
|
|
843
|
-
postal_code: t?.postal_code || "",
|
|
844
|
-
country_code: dt(t?.country_code) || "CA"
|
|
845
|
-
};
|
|
846
|
-
}
|
|
847
|
-
function Es(t) {
|
|
848
|
-
const n = Ne(t);
|
|
849
|
-
return !(!n?.country_code || !n.postal_code || Ke(n.country_code) && !n.state);
|
|
850
|
-
}
|
|
851
|
-
function st(t, n, s) {
|
|
852
|
-
return t.reduce((a, l) => {
|
|
853
|
-
const { price: c, sale_price: o } = Ce(l, {
|
|
854
|
-
currencyCode: n,
|
|
855
|
-
currencies: s
|
|
856
|
-
});
|
|
857
|
-
return a + (o ?? c) * l.quantity;
|
|
858
|
-
}, 0);
|
|
859
|
-
}
|
|
860
|
-
function Lt({
|
|
861
|
-
idPrefix: t,
|
|
862
|
-
title: n,
|
|
863
|
-
description: s,
|
|
864
|
-
value: a,
|
|
865
|
-
onChange: l
|
|
866
|
-
}) {
|
|
867
|
-
const { t: c } = Z(), o = c("company_name") === "company_name" ? "Company name" : c("company_name"), m = c("select_an_option") === "select_an_option" ? "Select an option" : c("select_an_option"), _ = c("state_province") === "state_province" ? "State / Province" : c("state_province"), y = Be(a.country_code), h = Ke(a.country_code);
|
|
868
|
-
return /* @__PURE__ */ r(ye, { children: [
|
|
869
|
-
/* @__PURE__ */ r(be, { children: [
|
|
870
|
-
/* @__PURE__ */ r(xe, { className: "flex items-center gap-2", children: [
|
|
871
|
-
/* @__PURE__ */ e(Ur, { className: "w-5 h-5" }),
|
|
872
|
-
n
|
|
873
|
-
] }),
|
|
874
|
-
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: s })
|
|
875
|
-
] }),
|
|
876
|
-
/* @__PURE__ */ r(ve, { className: "space-y-4", children: [
|
|
877
|
-
/* @__PURE__ */ r("div", { className: "grid gap-4 sm:grid-cols-3", children: [
|
|
878
|
-
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
879
|
-
/* @__PURE__ */ e(A, { htmlFor: `${t}-company`, children: o }),
|
|
880
|
-
/* @__PURE__ */ e(
|
|
881
|
-
U,
|
|
882
|
-
{
|
|
883
|
-
id: `${t}-company`,
|
|
884
|
-
value: a.company_name,
|
|
885
|
-
onChange: (p) => l({ ...a, company_name: p.target.value })
|
|
886
|
-
}
|
|
887
|
-
)
|
|
888
|
-
] }),
|
|
889
|
-
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
890
|
-
/* @__PURE__ */ e(A, { htmlFor: `${t}-name`, children: c("full_name") }),
|
|
891
|
-
/* @__PURE__ */ e(
|
|
892
|
-
U,
|
|
893
|
-
{
|
|
894
|
-
id: `${t}-name`,
|
|
895
|
-
value: a.recipient_name,
|
|
896
|
-
onChange: (p) => l({ ...a, recipient_name: p.target.value })
|
|
897
|
-
}
|
|
898
|
-
)
|
|
899
|
-
] }),
|
|
900
|
-
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
901
|
-
/* @__PURE__ */ e(A, { htmlFor: `${t}-country`, children: c("country") }),
|
|
902
|
-
/* @__PURE__ */ e(
|
|
903
|
-
"select",
|
|
904
|
-
{
|
|
905
|
-
id: `${t}-country`,
|
|
906
|
-
className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
907
|
-
value: a.country_code,
|
|
908
|
-
onChange: (p) => {
|
|
909
|
-
const f = p.target.value, b = Be(f);
|
|
910
|
-
l({
|
|
911
|
-
...a,
|
|
912
|
-
country_code: f,
|
|
913
|
-
state: b.some((d) => d.code === a.state) ? a.state : ""
|
|
914
|
-
});
|
|
915
|
-
},
|
|
916
|
-
children: ut.map((p) => /* @__PURE__ */ e("option", { value: p.code, children: p.name }, p.code))
|
|
917
|
-
}
|
|
918
|
-
)
|
|
919
|
-
] })
|
|
920
|
-
] }),
|
|
921
|
-
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
922
|
-
/* @__PURE__ */ e(A, { htmlFor: `${t}-line1`, children: c("address_line_1") }),
|
|
923
|
-
/* @__PURE__ */ e(
|
|
924
|
-
U,
|
|
925
|
-
{
|
|
926
|
-
id: `${t}-line1`,
|
|
927
|
-
value: a.line1,
|
|
928
|
-
onChange: (p) => l({ ...a, line1: p.target.value })
|
|
929
|
-
}
|
|
930
|
-
)
|
|
931
|
-
] }),
|
|
932
|
-
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
933
|
-
/* @__PURE__ */ e(A, { htmlFor: `${t}-line2`, children: c("address_line_2") }),
|
|
934
|
-
/* @__PURE__ */ e(
|
|
935
|
-
U,
|
|
936
|
-
{
|
|
937
|
-
id: `${t}-line2`,
|
|
938
|
-
value: a.line2,
|
|
939
|
-
onChange: (p) => l({ ...a, line2: p.target.value })
|
|
940
|
-
}
|
|
941
|
-
)
|
|
942
|
-
] }),
|
|
943
|
-
/* @__PURE__ */ r("div", { className: "grid gap-4 sm:grid-cols-3", children: [
|
|
944
|
-
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
945
|
-
/* @__PURE__ */ e(A, { htmlFor: `${t}-city`, children: c("city") }),
|
|
946
|
-
/* @__PURE__ */ e(
|
|
947
|
-
U,
|
|
948
|
-
{
|
|
949
|
-
id: `${t}-city`,
|
|
950
|
-
value: a.city,
|
|
951
|
-
onChange: (p) => l({ ...a, city: p.target.value })
|
|
952
|
-
}
|
|
953
|
-
)
|
|
954
|
-
] }),
|
|
955
|
-
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
956
|
-
/* @__PURE__ */ e(A, { htmlFor: `${t}-state`, children: c("state_province") }),
|
|
957
|
-
h ? /* @__PURE__ */ r(
|
|
958
|
-
"select",
|
|
959
|
-
{
|
|
960
|
-
id: `${t}-state`,
|
|
961
|
-
className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
962
|
-
value: a.state,
|
|
963
|
-
onChange: (p) => l({ ...a, state: p.target.value }),
|
|
964
|
-
children: [
|
|
965
|
-
/* @__PURE__ */ e("option", { value: "", children: `${m}: ${_}` }),
|
|
966
|
-
y.map((p) => /* @__PURE__ */ e("option", { value: p.code, children: p.name }, p.code))
|
|
967
|
-
]
|
|
968
|
-
}
|
|
969
|
-
) : /* @__PURE__ */ e(
|
|
970
|
-
U,
|
|
971
|
-
{
|
|
972
|
-
id: `${t}-state`,
|
|
973
|
-
value: a.state,
|
|
974
|
-
onChange: (p) => l({ ...a, state: p.target.value })
|
|
975
|
-
}
|
|
976
|
-
)
|
|
977
|
-
] }),
|
|
978
|
-
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
979
|
-
/* @__PURE__ */ e(A, { htmlFor: `${t}-postal`, children: c("postal_zip_code") }),
|
|
980
|
-
/* @__PURE__ */ e(
|
|
981
|
-
U,
|
|
982
|
-
{
|
|
983
|
-
id: `${t}-postal`,
|
|
984
|
-
value: a.postal_code,
|
|
985
|
-
onChange: (p) => l({ ...a, postal_code: p.target.value })
|
|
986
|
-
}
|
|
987
|
-
)
|
|
988
|
-
] })
|
|
989
|
-
] })
|
|
990
|
-
] })
|
|
991
|
-
] });
|
|
992
|
-
}
|
|
993
|
-
function It({
|
|
994
|
-
title: t,
|
|
995
|
-
description: n,
|
|
996
|
-
badgeLabel: s,
|
|
997
|
-
children: a
|
|
998
|
-
}) {
|
|
999
|
-
return /* @__PURE__ */ r(ye, { children: [
|
|
1000
|
-
/* @__PURE__ */ e(be, { children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-3 flex-wrap", children: [
|
|
1001
|
-
/* @__PURE__ */ r("div", { children: [
|
|
1002
|
-
/* @__PURE__ */ e(xe, { children: t }),
|
|
1003
|
-
/* @__PURE__ */ e("p", { className: "mt-1 text-sm text-muted-foreground", children: n })
|
|
1004
|
-
] }),
|
|
1005
|
-
s ? /* @__PURE__ */ e(ie, { variant: "secondary", children: s }) : null
|
|
1006
|
-
] }) }),
|
|
1007
|
-
/* @__PURE__ */ e(ve, { className: "space-y-4", children: a })
|
|
1008
|
-
] });
|
|
1009
|
-
}
|
|
1010
|
-
const ya = ({ initialCustomer: t }) => {
|
|
1011
|
-
const [n, s] = k({}), [a, l] = k(null), [c, o] = k({}), [m, _] = k(t?.email || ""), [y, h] = k(""), [p, f] = k(t?.phone || ""), [b, d] = k(!1), [E, v] = k(null), [F, j] = k(!1), [R, L] = k(!1), [S, i] = k([]), [$, q] = k(null), [P, W] = k(null), [C, X] = k(null), [V, B] = k(
|
|
1012
|
-
() => Me(t?.billingAddress, t?.fullName)
|
|
1013
|
-
), [Q, he] = k(
|
|
1014
|
-
() => Me(
|
|
1015
|
-
t?.shippingAddress ?? t?.billingAddress,
|
|
1016
|
-
t?.fullName
|
|
1017
|
-
)
|
|
1018
|
-
), [J, Re] = k(
|
|
1019
|
-
!t?.shippingAddress || lt(t?.billingAddress, t?.shippingAddress)
|
|
1020
|
-
), fe = ue((u) => u), { t: g, lang: ee } = Z(), { activeCurrencyCode: x, currencies: ne } = le(), te = fe?.items ?? [], re = H(
|
|
1021
|
-
() => te.filter((u) => !Y(u)),
|
|
1022
|
-
[te]
|
|
1023
|
-
), se = H(
|
|
1024
|
-
() => te.filter((u) => Y(u)),
|
|
1025
|
-
[te]
|
|
1026
|
-
), ge = t?.isAuthenticated ?? !1, N = (u, T, z) => {
|
|
1027
|
-
const O = g(u, z);
|
|
1028
|
-
if (O !== u)
|
|
1029
|
-
return O;
|
|
1030
|
-
if (!z)
|
|
1031
|
-
return T;
|
|
1032
|
-
let K = T;
|
|
1033
|
-
return Object.entries(z).forEach(([M, I]) => {
|
|
1034
|
-
K = K.replace(
|
|
1035
|
-
new RegExp(`\\{${M}\\}`, "g"),
|
|
1036
|
-
String(I)
|
|
1037
|
-
);
|
|
1038
|
-
}), K;
|
|
1039
|
-
}, ae = re.length > 0, _r = H(
|
|
1040
|
-
() => st(te, x, ne),
|
|
1041
|
-
[x, ne, te]
|
|
1042
|
-
), Je = H(
|
|
1043
|
-
() => st(re, x, ne),
|
|
1044
|
-
[x, ne, re]
|
|
1045
|
-
), We = H(
|
|
1046
|
-
() => st(se, x, ne),
|
|
1047
|
-
[x, ne, se]
|
|
1048
|
-
), Qe = C?.providerDiscounts.stripe ?? 0, Xe = C?.providerDiscounts.freemius ?? 0, $e = Math.max(0, Je - Qe), yr = Math.max(0, We - Xe), ce = H(
|
|
1049
|
-
() => J ? V : Q,
|
|
1050
|
-
[V, Q, J]
|
|
1051
|
-
), _e = H(
|
|
1052
|
-
() => ae ? ce : V,
|
|
1053
|
-
[V, ae, ce]
|
|
1054
|
-
), Le = !ae || Es(ce), Ie = H(
|
|
1055
|
-
() => S.find((u) => u.id === $),
|
|
1056
|
-
[S, $]
|
|
1057
|
-
), ft = H(
|
|
1058
|
-
() => $e + (Ie?.amount ?? 0) + (P && !P.isPendingExternalCalculation ? P.amount : 0),
|
|
1059
|
-
[$e, Ie, P]
|
|
1060
|
-
), br = ft + yr;
|
|
1061
|
-
if (G(() => {
|
|
1062
|
-
if (!(ge || typeof window > "u"))
|
|
1063
|
-
try {
|
|
1064
|
-
const u = window.localStorage.getItem(ze);
|
|
1065
|
-
if (!u)
|
|
1066
|
-
return;
|
|
1067
|
-
const T = JSON.parse(u);
|
|
1068
|
-
T.email && _(T.email), T.phone && f(T.phone), T.billingAddress && B(Me(T.billingAddress)), T.shippingAddress && he(Me(T.shippingAddress)), typeof T.useBillingForShipping == "boolean" && Re(T.useBillingForShipping), (typeof T.selectedMethodId == "string" || T.selectedMethodId === null) && q(T.selectedMethodId);
|
|
1069
|
-
} catch (u) {
|
|
1070
|
-
console.error("[Checkout] Failed to restore checkout draft:", u);
|
|
1071
|
-
}
|
|
1072
|
-
}, [ge]), G(() => {
|
|
1073
|
-
if (!(typeof window > "u")) {
|
|
1074
|
-
if (ge) {
|
|
1075
|
-
window.localStorage.removeItem(ze);
|
|
1076
|
-
return;
|
|
1077
|
-
}
|
|
1078
|
-
window.localStorage.setItem(
|
|
1079
|
-
ze,
|
|
1080
|
-
JSON.stringify({
|
|
1081
|
-
email: m,
|
|
1082
|
-
phone: p,
|
|
1083
|
-
billingAddress: V,
|
|
1084
|
-
shippingAddress: Q,
|
|
1085
|
-
useBillingForShipping: J,
|
|
1086
|
-
selectedMethodId: $
|
|
1087
|
-
})
|
|
1088
|
-
);
|
|
1089
|
-
}
|
|
1090
|
-
}, [
|
|
1091
|
-
V,
|
|
1092
|
-
m,
|
|
1093
|
-
ge,
|
|
1094
|
-
p,
|
|
1095
|
-
$,
|
|
1096
|
-
Q,
|
|
1097
|
-
J
|
|
1098
|
-
]), G(() => {
|
|
1099
|
-
if (!ae) {
|
|
1100
|
-
i([]), q(null), j(!1);
|
|
1101
|
-
return;
|
|
1102
|
-
}
|
|
1103
|
-
if (!Le) {
|
|
1104
|
-
i([]), q(null), j(!1);
|
|
1105
|
-
return;
|
|
1106
|
-
}
|
|
1107
|
-
let u = !1;
|
|
1108
|
-
const z = setTimeout(async () => {
|
|
1109
|
-
if (!ce.country_code)
|
|
1110
|
-
return;
|
|
1111
|
-
j(!0);
|
|
1112
|
-
const O = await pr(
|
|
1113
|
-
$e,
|
|
1114
|
-
{
|
|
1115
|
-
country: ce.country_code,
|
|
1116
|
-
state: ce.state,
|
|
1117
|
-
postal_code: ce.postal_code
|
|
1118
|
-
},
|
|
1119
|
-
ee,
|
|
1120
|
-
x
|
|
1121
|
-
);
|
|
1122
|
-
u || (O.success && O.methods ? (i(O.methods), O.methods.length > 0 && (!$ || !O.methods.find((K) => K.id === $)) && q(O.methods[0].id)) : (i([]), q(null)), j(!1));
|
|
1123
|
-
}, 400);
|
|
1124
|
-
return () => {
|
|
1125
|
-
u = !0, clearTimeout(z);
|
|
1126
|
-
};
|
|
1127
|
-
}, [
|
|
1128
|
-
x,
|
|
1129
|
-
ae,
|
|
1130
|
-
Le,
|
|
1131
|
-
ee,
|
|
1132
|
-
$,
|
|
1133
|
-
ce.country_code,
|
|
1134
|
-
ce.postal_code,
|
|
1135
|
-
ce.state,
|
|
1136
|
-
$e
|
|
1137
|
-
]), G(() => {
|
|
1138
|
-
const T = setTimeout(async () => {
|
|
1139
|
-
if (!ae || !_e.country_code) {
|
|
1140
|
-
L(!1), W(null);
|
|
1141
|
-
return;
|
|
1142
|
-
}
|
|
1143
|
-
if (Ke(_e.country_code) && !_e.state) {
|
|
1144
|
-
L(!1), W(null);
|
|
1145
|
-
return;
|
|
1146
|
-
}
|
|
1147
|
-
L(!0);
|
|
1148
|
-
const z = await Ps(
|
|
1149
|
-
re,
|
|
1150
|
-
{
|
|
1151
|
-
country_code: _e.country_code,
|
|
1152
|
-
state: _e.state
|
|
1153
|
-
},
|
|
1154
|
-
x,
|
|
1155
|
-
C?.code ?? null,
|
|
1156
|
-
te
|
|
1157
|
-
);
|
|
1158
|
-
z.success && z.tax ? W(z.tax) : W(null), L(!1);
|
|
1159
|
-
}, 300);
|
|
1160
|
-
return () => clearTimeout(T);
|
|
1161
|
-
}, [
|
|
1162
|
-
x,
|
|
1163
|
-
ae,
|
|
1164
|
-
re,
|
|
1165
|
-
_e.country_code,
|
|
1166
|
-
_e.state,
|
|
1167
|
-
C?.code,
|
|
1168
|
-
te
|
|
1169
|
-
]), !fe)
|
|
1170
|
-
return null;
|
|
1171
|
-
const gt = () => {
|
|
1172
|
-
d(!1), v(null);
|
|
1173
|
-
}, _t = b ? /* @__PURE__ */ e(
|
|
1174
|
-
"div",
|
|
1175
|
-
{
|
|
1176
|
-
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",
|
|
1177
|
-
onClick: gt,
|
|
1178
|
-
children: /* @__PURE__ */ r(
|
|
1179
|
-
"div",
|
|
1180
|
-
{
|
|
1181
|
-
className: "relative bg-background border rounded-xl shadow-2xl p-8 max-w-md mx-4",
|
|
1182
|
-
onClick: (u) => u.stopPropagation(),
|
|
1183
|
-
children: [
|
|
1184
|
-
/* @__PURE__ */ e(
|
|
1185
|
-
"button",
|
|
1186
|
-
{
|
|
1187
|
-
onClick: gt,
|
|
1188
|
-
className: "absolute top-4 right-4 text-muted-foreground hover:text-foreground transition-colors",
|
|
1189
|
-
children: /* @__PURE__ */ e(Mt, { className: "w-5 h-5" })
|
|
1190
|
-
}
|
|
1191
|
-
),
|
|
1192
|
-
/* @__PURE__ */ r("div", { className: "flex items-center gap-3 mb-4", children: [
|
|
1193
|
-
/* @__PURE__ */ e("div", { className: "p-2 rounded-full bg-amber-100 dark:bg-amber-900/20", children: /* @__PURE__ */ e(qr, { className: "h-6 w-6 text-amber-600 dark:text-amber-400" }) }),
|
|
1194
|
-
/* @__PURE__ */ e("h2", { className: "text-xl font-semibold", children: g("ecommerce.checkout_successful") })
|
|
1195
|
-
] }),
|
|
1196
|
-
/* @__PURE__ */ e("p", { className: "text-muted-foreground mb-2", children: g("ecommerce.sandbox_notice") }),
|
|
1197
|
-
/* @__PURE__ */ e("p", { className: "text-muted-foreground mb-2", children: E === "stripe" ? N(
|
|
1198
|
-
"ecommerce.sandbox_checkout_stripe_description",
|
|
1199
|
-
"This simulated step represents the Stripe checkout for physical products."
|
|
1200
|
-
) : N(
|
|
1201
|
-
"ecommerce.sandbox_checkout_freemius_description",
|
|
1202
|
-
"This simulated step represents the Freemius checkout for digital products."
|
|
1203
|
-
) }),
|
|
1204
|
-
/* @__PURE__ */ e("p", { className: "text-muted-foreground mb-6", children: g("ecommerce.license_notice") }),
|
|
1205
|
-
/* @__PURE__ */ e(
|
|
1206
|
-
"a",
|
|
1207
|
-
{
|
|
1208
|
-
href: "https://nextblock.ca",
|
|
1209
|
-
target: "_blank",
|
|
1210
|
-
rel: "noopener noreferrer",
|
|
1211
|
-
className: "block w-full text-center py-3 px-4 rounded-lg bg-primary text-primary-foreground font-semibold hover:opacity-90 transition-opacity",
|
|
1212
|
-
children: g("ecommerce.purchase_at")
|
|
1213
|
-
}
|
|
1214
|
-
)
|
|
1215
|
-
]
|
|
1216
|
-
}
|
|
1217
|
-
)
|
|
1218
|
-
}
|
|
1219
|
-
) : null, xr = (u) => {
|
|
1220
|
-
if (!ge && (!m || !/^\S+@\S+\.\S+$/.test(m)))
|
|
1221
|
-
return h(g("ecommerce.invalid_email")), null;
|
|
1222
|
-
const T = Ne(V);
|
|
1223
|
-
if (!kt(T))
|
|
1224
|
-
return alert(g("checkout_complete_billing_address")), null;
|
|
1225
|
-
const z = ae ? Ne(J ? V : Q) : null;
|
|
1226
|
-
if (u === "stripe") {
|
|
1227
|
-
if (!kt(z))
|
|
1228
|
-
return alert(g("checkout_complete_shipping_address")), null;
|
|
1229
|
-
if (!$)
|
|
1230
|
-
return alert(
|
|
1231
|
-
N(
|
|
1232
|
-
"ecommerce.shipping_method_required",
|
|
1233
|
-
"Please select a shipping method before continuing."
|
|
1234
|
-
)
|
|
1235
|
-
), null;
|
|
1236
|
-
}
|
|
1237
|
-
return h(""), {
|
|
1238
|
-
normalizedBillingAddress: T,
|
|
1239
|
-
normalizedShippingAddress: z
|
|
1240
|
-
};
|
|
1241
|
-
}, yt = async (u, T, z) => {
|
|
1242
|
-
o((K) => ({
|
|
1243
|
-
...K,
|
|
1244
|
-
[u]: ""
|
|
1245
|
-
}));
|
|
1246
|
-
const O = xr(u);
|
|
1247
|
-
if (O) {
|
|
1248
|
-
if (As) {
|
|
1249
|
-
const K = new Set(T.map((I) => I.id)), M = te.filter((I) => !K.has(I.id));
|
|
1250
|
-
fe.setItems(M), M.length === 0 && fe.removeCoupon(), v(u), d(!0), typeof window < "u" && M.length === 0 && window.localStorage.removeItem(ze);
|
|
1251
|
-
return;
|
|
1252
|
-
}
|
|
1253
|
-
l(z);
|
|
1254
|
-
try {
|
|
1255
|
-
const K = await fetch("/api/checkout", {
|
|
1256
|
-
method: "POST",
|
|
1257
|
-
headers: { "Content-Type": "application/json" },
|
|
1258
|
-
body: JSON.stringify({
|
|
1259
|
-
items: T,
|
|
1260
|
-
customerEmail: ge ? void 0 : m,
|
|
1261
|
-
customerPhone: p || null,
|
|
1262
|
-
billingAddress: O.normalizedBillingAddress,
|
|
1263
|
-
shippingAddress: u === "stripe" ? O.normalizedShippingAddress : null,
|
|
1264
|
-
shippingMethodId: u === "stripe" ? $ : null,
|
|
1265
|
-
locale: ee,
|
|
1266
|
-
currencyCode: x,
|
|
1267
|
-
couponCode: C?.code ?? fe.appliedCoupon?.code ?? null,
|
|
1268
|
-
couponContextItems: te
|
|
1269
|
-
})
|
|
1270
|
-
}), M = await K.json();
|
|
1271
|
-
if (!K.ok) {
|
|
1272
|
-
const I = M?.errorKey && typeof M.errorKey == "string" ? N(
|
|
1273
|
-
M.errorKey,
|
|
1274
|
-
M?.error || N("ecommerce.generic_error", "Something went wrong."),
|
|
1275
|
-
M.errorParams
|
|
1276
|
-
) : M?.error || g("ecommerce.generic_error");
|
|
1277
|
-
o((Pe) => ({
|
|
1278
|
-
...Pe,
|
|
1279
|
-
[u]: I
|
|
1280
|
-
})), l(null);
|
|
1281
|
-
return;
|
|
1282
|
-
}
|
|
1283
|
-
if (M.customProps && M.customProps.provider === "freemius") {
|
|
1284
|
-
const I = M.customProps;
|
|
1285
|
-
let Pe = null;
|
|
1286
|
-
const Sr = () => {
|
|
1287
|
-
window.location.href = `/checkout/success?session_id=${I.order_id}`;
|
|
1288
|
-
}, bt = (de) => (Pe || (Pe = fetch("/api/checkout/freemius/sync", {
|
|
1289
|
-
method: "POST",
|
|
1290
|
-
headers: { "Content-Type": "application/json" },
|
|
1291
|
-
body: JSON.stringify({
|
|
1292
|
-
orderId: I.order_id,
|
|
1293
|
-
checkoutResponse: de
|
|
1294
|
-
})
|
|
1295
|
-
}).then(async (xt) => {
|
|
1296
|
-
if (!xt.ok) {
|
|
1297
|
-
const Er = await xt.json().catch(() => null);
|
|
1298
|
-
console.error("Freemius checkout sync failed:", Er);
|
|
1299
|
-
}
|
|
1300
|
-
})), Pe), Pr = {
|
|
1301
|
-
product_id: I.plugin_id,
|
|
1302
|
-
public_key: I.public_key,
|
|
1303
|
-
sandbox: I.sandbox
|
|
1304
|
-
}, Ar = {
|
|
1305
|
-
name: g("ecommerce.checkout_overlay_title"),
|
|
1306
|
-
plan_id: I.plan_id,
|
|
1307
|
-
...I.billing_cycle ? { billing_cycle: I.billing_cycle } : {},
|
|
1308
|
-
...I.trial ? { trial: I.trial } : {},
|
|
1309
|
-
...I.coupon ? { coupon: I.coupon } : {},
|
|
1310
|
-
user_email: I.user_email,
|
|
1311
|
-
user_firstname: I.user_firstname,
|
|
1312
|
-
user_lastname: I.user_lastname,
|
|
1313
|
-
sandbox: I.sandbox,
|
|
1314
|
-
purchaseCompleted: function(de) {
|
|
1315
|
-
bt(de);
|
|
1316
|
-
},
|
|
1317
|
-
success: function(de) {
|
|
1318
|
-
(async () => {
|
|
1319
|
-
try {
|
|
1320
|
-
await bt(de);
|
|
1321
|
-
} finally {
|
|
1322
|
-
Sr();
|
|
1323
|
-
}
|
|
1324
|
-
})();
|
|
1325
|
-
}
|
|
1326
|
-
};
|
|
1327
|
-
try {
|
|
1328
|
-
new fs(Pr).open(Ar), l(null);
|
|
1329
|
-
} catch (de) {
|
|
1330
|
-
alert(
|
|
1331
|
-
g("ecommerce.checkout_popup_blocked") + " " + (de.message || String(de))
|
|
1332
|
-
), M.url && (window.location.href = M.url), l(null);
|
|
1333
|
-
}
|
|
1334
|
-
} else M.url ? window.location.href = M.url : (o((I) => ({
|
|
1335
|
-
...I,
|
|
1336
|
-
[u]: g("ecommerce.checkout_failed") + (M.error || N("ecommerce.unknown_error", "Unknown error"))
|
|
1337
|
-
})), l(null));
|
|
1338
|
-
} catch (K) {
|
|
1339
|
-
console.error(K), o((M) => ({
|
|
1340
|
-
...M,
|
|
1341
|
-
[u]: g("ecommerce.generic_error")
|
|
1342
|
-
})), l(null);
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
};
|
|
1346
|
-
if (te.length === 0)
|
|
1347
|
-
return /* @__PURE__ */ r(ot, { children: [
|
|
1348
|
-
_t,
|
|
1349
|
-
/* @__PURE__ */ r("div", { className: "container mx-auto flex min-h-[50vh] flex-col items-center justify-center p-8 text-center", children: [
|
|
1350
|
-
/* @__PURE__ */ e("h1", { className: "mb-4 text-2xl font-bold", children: g("ecommerce.cart_empty") }),
|
|
1351
|
-
/* @__PURE__ */ e("p", { className: "mb-8 text-muted-foreground", children: g("ecommerce.cart_empty_description") }),
|
|
1352
|
-
/* @__PURE__ */ e(D, { asChild: !0, children: /* @__PURE__ */ e("a", { href: "/shop", children: g("ecommerce.go_to_shop") }) })
|
|
1353
|
-
] })
|
|
1354
|
-
] });
|
|
1355
|
-
const Ye = ae ? Le ? F ? N(
|
|
1356
|
-
"ecommerce.calculating_shipping",
|
|
1357
|
-
"Calculating shipping..."
|
|
1358
|
-
) : $ ? null : S.length > 0 ? g("ecommerce.select_rate") : g("ecommerce.no_rates_for_region") : N(
|
|
1359
|
-
"ecommerce.waiting_on_address_info",
|
|
1360
|
-
"Complete your shipping address to view available shipping options."
|
|
1361
|
-
) : null, vr = a !== null || Ye !== null, Nr = re.length === 1 ? N("ecommerce.item_count_one", "{count} item", {
|
|
1362
|
-
count: re.length
|
|
1363
|
-
}) : N("ecommerce.item_count_other", "{count} items", {
|
|
1364
|
-
count: re.length
|
|
1365
|
-
}), Cr = se.length === 1 ? N("ecommerce.license_count_one", "{count} license", {
|
|
1366
|
-
count: se.length
|
|
1367
|
-
}) : N("ecommerce.license_count_other", "{count} licenses", {
|
|
1368
|
-
count: se.length
|
|
1369
|
-
}), wr = (u) => Y(u) ? N("ecommerce.digital_label", "Digital") : N("ecommerce.physical_label", "Physical"), kr = (u) => u === "monthly" ? N(
|
|
1370
|
-
"ecommerce.checkout_billing_cycle_monthly",
|
|
1371
|
-
"Monthly subscription"
|
|
1372
|
-
) : u === "annual" ? N(
|
|
1373
|
-
"ecommerce.checkout_billing_cycle_annual",
|
|
1374
|
-
"Annual subscription"
|
|
1375
|
-
) : u === "lifetime" ? N(
|
|
1376
|
-
"ecommerce.checkout_billing_cycle_lifetime",
|
|
1377
|
-
"Lifetime subscription"
|
|
1378
|
-
) : null;
|
|
1379
|
-
return /* @__PURE__ */ r("div", { className: "container mx-auto px-4 py-12 md:px-6", children: [
|
|
1380
|
-
_t,
|
|
1381
|
-
/* @__PURE__ */ r("div", { className: "mx-auto max-w-6xl", children: [
|
|
1382
|
-
/* @__PURE__ */ e("h1", { className: "mb-8 text-3xl font-bold", children: g("ecommerce.checkout") }),
|
|
1383
|
-
/* @__PURE__ */ r("div", { className: "grid gap-8 lg:grid-cols-12 lg:items-start", children: [
|
|
1384
|
-
/* @__PURE__ */ r("div", { className: "lg:col-span-8 space-y-6", children: [
|
|
1385
|
-
/* @__PURE__ */ r(ye, { children: [
|
|
1386
|
-
/* @__PURE__ */ e(be, { children: /* @__PURE__ */ r(xe, { className: "flex items-center gap-2", children: [
|
|
1387
|
-
/* @__PURE__ */ e(zr, { className: "w-5 h-5" }),
|
|
1388
|
-
g("ecommerce.contact_information")
|
|
1389
|
-
] }) }),
|
|
1390
|
-
/* @__PURE__ */ r(ve, { className: "space-y-4", children: [
|
|
1391
|
-
ge ? /* @__PURE__ */ e("div", { className: "rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground", children: g("checkout_prefill_notice", { email: t?.email || "" }) }) : /* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
1392
|
-
/* @__PURE__ */ r(A, { htmlFor: "checkout-email", children: [
|
|
1393
|
-
g("ecommerce.email_address"),
|
|
1394
|
-
" ",
|
|
1395
|
-
/* @__PURE__ */ e("span", { className: "text-destructive", children: "*" })
|
|
1396
|
-
] }),
|
|
1397
|
-
/* @__PURE__ */ e(
|
|
1398
|
-
U,
|
|
1399
|
-
{
|
|
1400
|
-
id: "checkout-email",
|
|
1401
|
-
type: "email",
|
|
1402
|
-
placeholder: g("ecommerce.email_placeholder"),
|
|
1403
|
-
value: m,
|
|
1404
|
-
onChange: (u) => {
|
|
1405
|
-
_(u.target.value), y && h("");
|
|
1406
|
-
},
|
|
1407
|
-
required: !0
|
|
1408
|
-
}
|
|
1409
|
-
),
|
|
1410
|
-
y ? /* @__PURE__ */ e("p", { className: "text-xs text-destructive mt-1", children: y }) : null
|
|
1411
|
-
] }),
|
|
1412
|
-
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
1413
|
-
/* @__PURE__ */ e(A, { htmlFor: "checkout-phone", children: g("phone_number") }),
|
|
1414
|
-
/* @__PURE__ */ e(
|
|
1415
|
-
U,
|
|
1416
|
-
{
|
|
1417
|
-
id: "checkout-phone",
|
|
1418
|
-
placeholder: g("optional"),
|
|
1419
|
-
value: p,
|
|
1420
|
-
onChange: (u) => f(u.target.value)
|
|
1421
|
-
}
|
|
1422
|
-
)
|
|
1423
|
-
] })
|
|
1424
|
-
] })
|
|
1425
|
-
] }),
|
|
1426
|
-
/* @__PURE__ */ e(
|
|
1427
|
-
Lt,
|
|
1428
|
-
{
|
|
1429
|
-
idPrefix: "billing",
|
|
1430
|
-
title: g("billing_address"),
|
|
1431
|
-
description: g("checkout_billing_address_help"),
|
|
1432
|
-
value: V,
|
|
1433
|
-
onChange: B
|
|
1434
|
-
}
|
|
1435
|
-
),
|
|
1436
|
-
ae ? /* @__PURE__ */ r("div", { className: "flex items-center space-x-3 rounded-xl border bg-muted/20 p-4", children: [
|
|
1437
|
-
/* @__PURE__ */ e(
|
|
1438
|
-
nr,
|
|
1439
|
-
{
|
|
1440
|
-
id: "use-billing-for-shipping",
|
|
1441
|
-
checked: J,
|
|
1442
|
-
onCheckedChange: (u) => Re(!!u)
|
|
1443
|
-
}
|
|
1444
|
-
),
|
|
1445
|
-
/* @__PURE__ */ r("div", { className: "space-y-1", children: [
|
|
1446
|
-
/* @__PURE__ */ e(A, { htmlFor: "use-billing-for-shipping", className: "cursor-pointer", children: g("use_billing_for_shipping") }),
|
|
1447
|
-
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: g("checkout_use_billing_for_shipping_help") })
|
|
1448
|
-
] })
|
|
1449
|
-
] }) : null,
|
|
1450
|
-
ae && !J ? /* @__PURE__ */ e(
|
|
1451
|
-
Lt,
|
|
1452
|
-
{
|
|
1453
|
-
idPrefix: "shipping",
|
|
1454
|
-
title: g("shipping_address"),
|
|
1455
|
-
description: g("checkout_shipping_address_help"),
|
|
1456
|
-
value: Q,
|
|
1457
|
-
onChange: he
|
|
1458
|
-
}
|
|
1459
|
-
) : null,
|
|
1460
|
-
ae ? /* @__PURE__ */ r(ye, { children: [
|
|
1461
|
-
/* @__PURE__ */ e(be, { children: /* @__PURE__ */ r(xe, { className: "flex items-center gap-2", children: [
|
|
1462
|
-
/* @__PURE__ */ e(Mr, { className: "w-5 h-5 text-primary" }),
|
|
1463
|
-
g("ecommerce.shipping_method")
|
|
1464
|
-
] }) }),
|
|
1465
|
-
/* @__PURE__ */ e(ve, { children: F ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ e(Ve, { className: "w-6 h-6 animate-spin text-muted-foreground" }) }) : S.length > 0 ? /* @__PURE__ */ e("div", { className: "space-y-3", children: S.map((u) => /* @__PURE__ */ r(
|
|
1466
|
-
"div",
|
|
1467
|
-
{
|
|
1468
|
-
onClick: () => q(u.id),
|
|
1469
|
-
className: `flex items-center justify-between p-4 rounded-lg border-2 cursor-pointer transition-all ${$ === u.id ? "border-primary bg-primary/5" : "border-neutral-100 hover:border-neutral-200"}`,
|
|
1470
|
-
children: [
|
|
1471
|
-
/* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
|
|
1472
|
-
/* @__PURE__ */ e(
|
|
1473
|
-
"div",
|
|
1474
|
-
{
|
|
1475
|
-
className: `w-4 h-4 rounded-full border flex items-center justify-center ${$ === u.id ? "border-primary" : "border-neutral-300"}`,
|
|
1476
|
-
children: $ === u.id ? /* @__PURE__ */ e("div", { className: "w-2 h-2 rounded-full bg-primary" }) : null
|
|
1477
|
-
}
|
|
1478
|
-
),
|
|
1479
|
-
/* @__PURE__ */ e("span", { className: "font-medium", children: u.name })
|
|
1480
|
-
] }),
|
|
1481
|
-
/* @__PURE__ */ e("span", { className: "font-bold", children: w(u.amount, x) })
|
|
1482
|
-
]
|
|
1483
|
-
},
|
|
1484
|
-
u.id
|
|
1485
|
-
)) }) : /* @__PURE__ */ e("div", { className: "py-4 text-center text-muted-foreground bg-muted/30 rounded-lg italic", children: Le ? g("ecommerce.no_rates_for_region") : N(
|
|
1486
|
-
"ecommerce.waiting_on_address_info",
|
|
1487
|
-
"Complete your shipping address to view available shipping options."
|
|
1488
|
-
) }) })
|
|
1489
|
-
] }) : null
|
|
1490
|
-
] }),
|
|
1491
|
-
/* @__PURE__ */ r("div", { className: "lg:col-span-4 space-y-6", children: [
|
|
1492
|
-
/* @__PURE__ */ r(ye, { className: "top-6", children: [
|
|
1493
|
-
/* @__PURE__ */ e(be, { children: /* @__PURE__ */ e(xe, { children: g("ecommerce.order_summary") }) }),
|
|
1494
|
-
/* @__PURE__ */ r(ve, { className: "space-y-4", children: [
|
|
1495
|
-
/* @__PURE__ */ e("div", { className: "space-y-3 max-h-[260px] overflow-y-auto pr-2", children: te.map((u) => {
|
|
1496
|
-
const T = Ce(u, {
|
|
1497
|
-
currencyCode: x,
|
|
1498
|
-
currencies: ne
|
|
1499
|
-
}), z = pe(u);
|
|
1500
|
-
return /* @__PURE__ */ r("div", { className: "flex items-start justify-between gap-4", children: [
|
|
1501
|
-
/* @__PURE__ */ r("div", { className: "flex gap-3", children: [
|
|
1502
|
-
u.image_url ? /* @__PURE__ */ e("div", { className: "h-10 w-10 shrink-0 overflow-hidden rounded border bg-neutral-100", children: /* @__PURE__ */ e("img", { src: u.image_url, alt: u.title, className: "h-full w-full object-cover" }) }) : null,
|
|
1503
|
-
/* @__PURE__ */ r("div", { className: "grid gap-0.5", children: [
|
|
1504
|
-
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
1505
|
-
/* @__PURE__ */ e("span", { className: "font-medium text-xs line-clamp-1", children: u.title }),
|
|
1506
|
-
/* @__PURE__ */ e(ie, { variant: "outline", className: "text-[9px] uppercase", children: wr(u) })
|
|
1507
|
-
] }),
|
|
1508
|
-
u.variant_label ? /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground line-clamp-1", children: u.variant_label }) : null,
|
|
1509
|
-
/* @__PURE__ */ r("span", { className: "text-[10px] text-muted-foreground", children: [
|
|
1510
|
-
g("ecommerce.qty"),
|
|
1511
|
-
": ",
|
|
1512
|
-
u.quantity
|
|
1513
|
-
] }),
|
|
1514
|
-
z ? /* @__PURE__ */ r("span", { className: "text-[10px] font-medium text-emerald-700", children: [
|
|
1515
|
-
z.label,
|
|
1516
|
-
" - ",
|
|
1517
|
-
z.paymentRequirementLabel
|
|
1518
|
-
] }) : null
|
|
1519
|
-
] })
|
|
1520
|
-
] }),
|
|
1521
|
-
/* @__PURE__ */ r("div", { className: "flex flex-col items-end gap-0.5 shrink-0", children: [
|
|
1522
|
-
/* @__PURE__ */ e("span", { className: "font-medium text-xs", children: w(
|
|
1523
|
-
(T.sale_price ?? T.price) * u.quantity,
|
|
1524
|
-
x
|
|
1525
|
-
) }),
|
|
1526
|
-
T.sale_price ? /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground line-through", children: w(T.price * u.quantity, x) }) : null
|
|
1527
|
-
] })
|
|
1528
|
-
] }, `${u.id}-${u.variant_id || "base"}`);
|
|
1529
|
-
}) }),
|
|
1530
|
-
/* @__PURE__ */ e(mt, {}),
|
|
1531
|
-
/* @__PURE__ */ e(
|
|
1532
|
-
pt,
|
|
1533
|
-
{
|
|
1534
|
-
items: te,
|
|
1535
|
-
currencyCode: x,
|
|
1536
|
-
onQuoteChange: X
|
|
1537
|
-
}
|
|
1538
|
-
),
|
|
1539
|
-
/* @__PURE__ */ r("div", { className: "space-y-2 text-sm", children: [
|
|
1540
|
-
/* @__PURE__ */ r("div", { className: "flex justify-between", children: [
|
|
1541
|
-
/* @__PURE__ */ e("span", { children: g("ecommerce.subtotal") }),
|
|
1542
|
-
/* @__PURE__ */ e("span", { children: w(_r, x) })
|
|
1543
|
-
] }),
|
|
1544
|
-
re.length > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-muted-foreground", children: [
|
|
1545
|
-
/* @__PURE__ */ e("span", { children: N(
|
|
1546
|
-
"ecommerce.physical_products",
|
|
1547
|
-
"Physical products"
|
|
1548
|
-
) }),
|
|
1549
|
-
/* @__PURE__ */ e("span", { children: w(Je, x) })
|
|
1550
|
-
] }) : null,
|
|
1551
|
-
se.length > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-muted-foreground", children: [
|
|
1552
|
-
/* @__PURE__ */ e("span", { children: N(
|
|
1553
|
-
"ecommerce.digital_products",
|
|
1554
|
-
"Digital products"
|
|
1555
|
-
) }),
|
|
1556
|
-
/* @__PURE__ */ e("span", { children: w(We, x) })
|
|
1557
|
-
] }) : null,
|
|
1558
|
-
C ? /* @__PURE__ */ r("div", { className: "flex justify-between text-emerald-600", children: [
|
|
1559
|
-
/* @__PURE__ */ r("span", { children: [
|
|
1560
|
-
N("ecommerce.discount", "Discount"),
|
|
1561
|
-
" (",
|
|
1562
|
-
C.code,
|
|
1563
|
-
")"
|
|
1564
|
-
] }),
|
|
1565
|
-
/* @__PURE__ */ r("span", { children: [
|
|
1566
|
-
"-",
|
|
1567
|
-
w(C.discountTotal, x)
|
|
1568
|
-
] })
|
|
1569
|
-
] }) : null,
|
|
1570
|
-
(re.length > 0 || se.length > 0) && /* @__PURE__ */ r("div", { className: "flex justify-between font-bold text-lg pt-2 border-t mt-2", children: [
|
|
1571
|
-
/* @__PURE__ */ e("span", { children: N(
|
|
1572
|
-
"ecommerce.estimated_total",
|
|
1573
|
-
"Estimated total"
|
|
1574
|
-
) }),
|
|
1575
|
-
/* @__PURE__ */ e("span", { className: "text-primary", children: w(br, x) })
|
|
1576
|
-
] })
|
|
1577
|
-
] })
|
|
1578
|
-
] })
|
|
1579
|
-
] }),
|
|
1580
|
-
re.length > 0 ? /* @__PURE__ */ r(
|
|
1581
|
-
It,
|
|
1582
|
-
{
|
|
1583
|
-
title: N(
|
|
1584
|
-
"ecommerce.stripe_checkout_title",
|
|
1585
|
-
"Stripe Checkout"
|
|
1586
|
-
),
|
|
1587
|
-
description: N(
|
|
1588
|
-
"ecommerce.stripe_checkout_description",
|
|
1589
|
-
"Pay for physical products in one Stripe checkout session."
|
|
1590
|
-
),
|
|
1591
|
-
badgeLabel: Nr,
|
|
1592
|
-
children: [
|
|
1593
|
-
/* @__PURE__ */ r("div", { className: "space-y-2 text-sm", children: [
|
|
1594
|
-
/* @__PURE__ */ r("div", { className: "flex justify-between", children: [
|
|
1595
|
-
/* @__PURE__ */ e("span", { children: N(
|
|
1596
|
-
"ecommerce.physical_subtotal",
|
|
1597
|
-
"Physical subtotal"
|
|
1598
|
-
) }),
|
|
1599
|
-
/* @__PURE__ */ e("span", { children: w(Je, x) })
|
|
1600
|
-
] }),
|
|
1601
|
-
Qe > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-emerald-600", children: [
|
|
1602
|
-
/* @__PURE__ */ e("span", { children: N("ecommerce.discount", "Discount") }),
|
|
1603
|
-
/* @__PURE__ */ r("span", { children: [
|
|
1604
|
-
"-",
|
|
1605
|
-
w(Qe, x)
|
|
1606
|
-
] })
|
|
1607
|
-
] }) : null,
|
|
1608
|
-
/* @__PURE__ */ r("div", { className: "flex justify-between", children: [
|
|
1609
|
-
/* @__PURE__ */ e("span", { children: g("ecommerce.shipping") }),
|
|
1610
|
-
/* @__PURE__ */ e("span", { children: Ie ? w(Ie.amount, x) : "-" })
|
|
1611
|
-
] }),
|
|
1612
|
-
/* @__PURE__ */ r("div", { className: "flex justify-between", children: [
|
|
1613
|
-
/* @__PURE__ */ e("span", { children: N("ecommerce.tax", "Tax") }),
|
|
1614
|
-
/* @__PURE__ */ e("span", { children: R ? "..." : P?.isPendingExternalCalculation ? N(
|
|
1615
|
-
"ecommerce.tax_calculated_on_stripe",
|
|
1616
|
-
"Calculated on Stripe"
|
|
1617
|
-
) : P ? w(P.amount, x) : "-" })
|
|
1618
|
-
] }),
|
|
1619
|
-
P && P.lines.length > 0 ? /* @__PURE__ */ e("div", { className: "rounded-lg bg-muted/20 px-3 py-2 text-xs text-muted-foreground", children: P.lines.map((u) => /* @__PURE__ */ r("div", { className: "flex justify-between gap-3", children: [
|
|
1620
|
-
/* @__PURE__ */ r("span", { children: [
|
|
1621
|
-
u.name,
|
|
1622
|
-
" (",
|
|
1623
|
-
u.rate.toFixed(4),
|
|
1624
|
-
"%)"
|
|
1625
|
-
] }),
|
|
1626
|
-
/* @__PURE__ */ e("span", { children: w(u.amount, x) })
|
|
1627
|
-
] }, u.id || `${u.name}-${u.rate}`)) }) : null,
|
|
1628
|
-
/* @__PURE__ */ r("div", { className: "flex justify-between font-semibold pt-2 border-t", children: [
|
|
1629
|
-
/* @__PURE__ */ e("span", { children: N(
|
|
1630
|
-
"ecommerce.total_on_stripe",
|
|
1631
|
-
"Total on Stripe"
|
|
1632
|
-
) }),
|
|
1633
|
-
/* @__PURE__ */ e("span", { children: w(ft, x) })
|
|
1634
|
-
] })
|
|
1635
|
-
] }),
|
|
1636
|
-
/* @__PURE__ */ r(
|
|
1637
|
-
D,
|
|
1638
|
-
{
|
|
1639
|
-
className: "w-full",
|
|
1640
|
-
size: "lg",
|
|
1641
|
-
onClick: () => yt("stripe", re, "stripe"),
|
|
1642
|
-
disabled: vr,
|
|
1643
|
-
children: [
|
|
1644
|
-
a === "stripe" ? /* @__PURE__ */ e(Ve, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(Bt, { className: "mr-2 h-4 w-4" }),
|
|
1645
|
-
a === "stripe" ? g("ecommerce.processing") : N(
|
|
1646
|
-
"ecommerce.checkout_physical_products",
|
|
1647
|
-
"Checkout Physical Products"
|
|
1648
|
-
)
|
|
1649
|
-
]
|
|
1650
|
-
}
|
|
1651
|
-
),
|
|
1652
|
-
Ye && a === null ? /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground", children: Ye }) : null,
|
|
1653
|
-
c.stripe ? /* @__PURE__ */ e("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: c.stripe }) : null,
|
|
1654
|
-
/* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground", children: P?.isPendingExternalCalculation ? N(
|
|
1655
|
-
"checkout_stripe_tax_finalized_notice",
|
|
1656
|
-
"Tax will be finalized by Stripe Tax on the payment step."
|
|
1657
|
-
) : N(
|
|
1658
|
-
"ecommerce.shipping_taxes_collected_on_stripe",
|
|
1659
|
-
"Shipping and taxes are only collected during the Stripe step for physical products."
|
|
1660
|
-
) })
|
|
1661
|
-
]
|
|
1662
|
-
}
|
|
1663
|
-
) : null,
|
|
1664
|
-
se.length > 0 ? /* @__PURE__ */ r(
|
|
1665
|
-
It,
|
|
1666
|
-
{
|
|
1667
|
-
title: N(
|
|
1668
|
-
"ecommerce.freemius_checkout_title",
|
|
1669
|
-
"Freemius Checkout"
|
|
1670
|
-
),
|
|
1671
|
-
description: N(
|
|
1672
|
-
"ecommerce.freemius_checkout_description",
|
|
1673
|
-
"Digital products use the Freemius checkout flow."
|
|
1674
|
-
),
|
|
1675
|
-
badgeLabel: Cr,
|
|
1676
|
-
children: [
|
|
1677
|
-
/* @__PURE__ */ e("div", { className: "space-y-3", children: se.map((u) => {
|
|
1678
|
-
const T = Ce(u, {
|
|
1679
|
-
currencyCode: x,
|
|
1680
|
-
currencies: ne
|
|
1681
|
-
}), z = pe(u), O = `freemius:${u.id}`, K = z ? n[O] || "paid" : void 0;
|
|
1682
|
-
return /* @__PURE__ */ r("div", { className: "rounded-lg border p-3 space-y-3", children: [
|
|
1683
|
-
/* @__PURE__ */ r("div", { className: "flex items-start justify-between gap-3", children: [
|
|
1684
|
-
/* @__PURE__ */ r("div", { children: [
|
|
1685
|
-
/* @__PURE__ */ e("p", { className: "font-medium", children: u.title }),
|
|
1686
|
-
u.billing_cycle ? /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground capitalize", children: kr(u.billing_cycle) }) : null,
|
|
1687
|
-
z ? /* @__PURE__ */ r("p", { className: "text-xs font-medium text-emerald-700", children: [
|
|
1688
|
-
z.label,
|
|
1689
|
-
" - ",
|
|
1690
|
-
z.paymentRequirementLabel
|
|
1691
|
-
] }) : null
|
|
1692
|
-
] }),
|
|
1693
|
-
/* @__PURE__ */ e("span", { className: "font-medium", children: w(T.sale_price ?? T.price, x) })
|
|
1694
|
-
] }),
|
|
1695
|
-
z && !u.trial_requires_payment_method && /* @__PURE__ */ r("div", { className: "bg-muted/30 p-3 rounded-md border text-sm mt-2 mb-3", children: [
|
|
1696
|
-
/* @__PURE__ */ e("p", { className: "font-medium mb-3", children: N(
|
|
1697
|
-
"ecommerce.freemius_trial_preference_title",
|
|
1698
|
-
"How would you like to start your trial?"
|
|
1699
|
-
) }),
|
|
1700
|
-
/* @__PURE__ */ r(
|
|
1701
|
-
hs,
|
|
1702
|
-
{
|
|
1703
|
-
value: n[O] || "paid",
|
|
1704
|
-
onValueChange: (M) => s((I) => ({ ...I, [O]: M })),
|
|
1705
|
-
className: "gap-3",
|
|
1706
|
-
children: [
|
|
1707
|
-
/* @__PURE__ */ r("div", { className: "flex items-start space-x-3", children: [
|
|
1708
|
-
/* @__PURE__ */ e(Ft, { value: "paid", id: `${O}-paid`, className: "mt-1" }),
|
|
1709
|
-
/* @__PURE__ */ r("div", { className: "grid gap-1.5", children: [
|
|
1710
|
-
/* @__PURE__ */ e(A, { htmlFor: `${O}-paid`, className: "font-medium leading-none cursor-pointer", children: N(
|
|
1711
|
-
"ecommerce.freemius_trial_with_card",
|
|
1712
|
-
"Enter Payment Details Now (Still get full trial length free)"
|
|
1713
|
-
) }),
|
|
1714
|
-
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: N(
|
|
1715
|
-
"ecommerce.freemius_trial_with_card_help",
|
|
1716
|
-
"You will not be billed until the trial ends. Cancel anytime."
|
|
1717
|
-
) })
|
|
1718
|
-
] })
|
|
1719
|
-
] }),
|
|
1720
|
-
/* @__PURE__ */ r("div", { className: "flex items-start space-x-3", children: [
|
|
1721
|
-
/* @__PURE__ */ e(Ft, { value: "free", id: `${O}-free`, className: "mt-1" }),
|
|
1722
|
-
/* @__PURE__ */ e("div", { className: "grid gap-1.5", children: /* @__PURE__ */ e(A, { htmlFor: `${O}-free`, className: "font-medium leading-none cursor-pointer", children: N(
|
|
1723
|
-
"ecommerce.freemius_trial_no_card",
|
|
1724
|
-
"Start Free Trial (No card required)"
|
|
1725
|
-
) }) })
|
|
1726
|
-
] })
|
|
1727
|
-
]
|
|
1728
|
-
}
|
|
1729
|
-
)
|
|
1730
|
-
] }),
|
|
1731
|
-
/* @__PURE__ */ r(
|
|
1732
|
-
D,
|
|
1733
|
-
{
|
|
1734
|
-
className: "w-full h-auto min-h-[2.75rem] py-2",
|
|
1735
|
-
variant: se.length > 1 ? "outline" : "default",
|
|
1736
|
-
onClick: () => yt(
|
|
1737
|
-
"freemius",
|
|
1738
|
-
[
|
|
1739
|
-
{
|
|
1740
|
-
...u,
|
|
1741
|
-
...K ? { trial_preference: K } : {}
|
|
1742
|
-
}
|
|
1743
|
-
],
|
|
1744
|
-
O
|
|
1745
|
-
),
|
|
1746
|
-
disabled: a !== null,
|
|
1747
|
-
children: [
|
|
1748
|
-
a === O ? /* @__PURE__ */ e(Ve, { className: "mr-2 h-4 w-4 shrink-0 animate-spin" }) : /* @__PURE__ */ e(Ht, { className: "mr-2 h-4 w-4 shrink-0" }),
|
|
1749
|
-
/* @__PURE__ */ e("span", { className: "whitespace-normal text-left", children: a === O ? g("ecommerce.processing") : se.length > 1 ? N(
|
|
1750
|
-
"ecommerce.checkout_product",
|
|
1751
|
-
"Checkout {title}",
|
|
1752
|
-
{ title: u.title }
|
|
1753
|
-
) : N(
|
|
1754
|
-
"ecommerce.checkout_digital_product",
|
|
1755
|
-
"Checkout Digital Product"
|
|
1756
|
-
) })
|
|
1757
|
-
]
|
|
1758
|
-
}
|
|
1759
|
-
)
|
|
1760
|
-
] }, O);
|
|
1761
|
-
}) }),
|
|
1762
|
-
/* @__PURE__ */ r("div", { className: "flex justify-between text-sm font-semibold border-t pt-3", children: [
|
|
1763
|
-
/* @__PURE__ */ e("span", { children: N(
|
|
1764
|
-
"ecommerce.digital_subtotal",
|
|
1765
|
-
"Digital subtotal"
|
|
1766
|
-
) }),
|
|
1767
|
-
/* @__PURE__ */ e("span", { children: w(We, x) })
|
|
1768
|
-
] }),
|
|
1769
|
-
Xe > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-sm font-semibold text-emerald-600", children: [
|
|
1770
|
-
/* @__PURE__ */ e("span", { children: N("ecommerce.discount", "Discount") }),
|
|
1771
|
-
/* @__PURE__ */ r("span", { children: [
|
|
1772
|
-
"-",
|
|
1773
|
-
w(Xe, x)
|
|
1774
|
-
] })
|
|
1775
|
-
] }) : null,
|
|
1776
|
-
c.freemius ? /* @__PURE__ */ e("div", { className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: c.freemius }) : null,
|
|
1777
|
-
/* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground", children: se.length > 1 ? N(
|
|
1778
|
-
"ecommerce.freemius_multi_checkout_notice",
|
|
1779
|
-
"Freemius licenses are completed one at a time, so each digital product gets its own checkout action."
|
|
1780
|
-
) : N(
|
|
1781
|
-
"ecommerce.freemius_tax_notice",
|
|
1782
|
-
"Taxes and compliance for digital products are handled inside the Freemius checkout."
|
|
1783
|
-
) })
|
|
1784
|
-
]
|
|
1785
|
-
}
|
|
1786
|
-
) : null
|
|
1787
|
-
] })
|
|
1788
|
-
] })
|
|
1789
|
-
] })
|
|
1790
|
-
] });
|
|
1791
|
-
}, ba = () => {
|
|
1792
|
-
const t = Te((a) => a.toggleCart), n = vs();
|
|
1793
|
-
return ue((a) => a.isOpen) !== void 0 ? /* @__PURE__ */ r(
|
|
1794
|
-
D,
|
|
1795
|
-
{
|
|
1796
|
-
variant: "ghost",
|
|
1797
|
-
size: "icon",
|
|
1798
|
-
className: "relative",
|
|
1799
|
-
onClick: t,
|
|
1800
|
-
"aria-label": "Open cart",
|
|
1801
|
-
children: [
|
|
1802
|
-
/* @__PURE__ */ e(Nt, { className: "h-5 w-5" }),
|
|
1803
|
-
n > 0 && /* @__PURE__ */ e(
|
|
1804
|
-
ie,
|
|
1805
|
-
{
|
|
1806
|
-
variant: "destructive",
|
|
1807
|
-
className: "absolute -right-1 -top-1 h-4 w-4 items-center justify-center p-0 text-[10px]",
|
|
1808
|
-
children: n
|
|
1809
|
-
}
|
|
1810
|
-
)
|
|
1811
|
-
]
|
|
1812
|
-
}
|
|
1813
|
-
) : /* @__PURE__ */ e(D, { variant: "ghost", size: "icon", className: "relative", "aria-label": "Open cart", children: /* @__PURE__ */ e(Nt, { className: "h-5 w-5" }) });
|
|
1814
|
-
};
|
|
1815
|
-
function xa() {
|
|
1816
|
-
const {
|
|
1817
|
-
activeCurrencyCode: t,
|
|
1818
|
-
currencies: n,
|
|
1819
|
-
setActiveCurrencyCode: s
|
|
1820
|
-
} = le();
|
|
1821
|
-
return n.length <= 1 ? null : /* @__PURE__ */ r(lr, { value: t, onValueChange: s, children: [
|
|
1822
|
-
/* @__PURE__ */ e(cr, { className: "h-9 w-[88px] text-xs font-semibold", children: /* @__PURE__ */ e(ir, { placeholder: t }) }),
|
|
1823
|
-
/* @__PURE__ */ e(or, { children: n.map((a) => /* @__PURE__ */ e(De, { value: a.code, children: a.code }, a.code)) })
|
|
1824
|
-
] });
|
|
1825
|
-
}
|
|
1826
|
-
const ht = ({ product: t, className: n, quantity: s }) => {
|
|
1827
|
-
const a = ue((y) => y), { t: l } = Z(), { activeCurrencyCode: c } = le();
|
|
1828
|
-
if (!!t.has_variants && !t.variant_id && !Yt(t))
|
|
1829
|
-
return /* @__PURE__ */ e(D, { asChild: !0, className: n, children: /* @__PURE__ */ e(Se, { href: `/product/${t.slug}`, children: "Select Options" }) });
|
|
1830
|
-
if (!a)
|
|
1831
|
-
return /* @__PURE__ */ r(D, { disabled: !0, className: n, children: [
|
|
1832
|
-
/* @__PURE__ */ e(nt, { className: "mr-2 h-4 w-4" }),
|
|
1833
|
-
l("ecommerce.add_to_cart")
|
|
1834
|
-
] });
|
|
1835
|
-
const { addItem: m } = a;
|
|
1836
|
-
return /* @__PURE__ */ r(D, { onClick: () => {
|
|
1837
|
-
const y = as(t) ?? "stripe", { success: h, error: p } = m({
|
|
1838
|
-
id: t.variant_id || t.id,
|
|
1839
|
-
product_id: t.id,
|
|
1840
|
-
title: t.title,
|
|
1841
|
-
price: t.price,
|
|
1842
|
-
prices: t.prices,
|
|
1843
|
-
sale_price: t.sale_price,
|
|
1844
|
-
sale_prices: t.sale_prices,
|
|
1845
|
-
is_taxable: t.is_taxable,
|
|
1846
|
-
image_url: t.image_url,
|
|
1847
|
-
slug: t.slug,
|
|
1848
|
-
sku: t.sku,
|
|
1849
|
-
stock: t.stock,
|
|
1850
|
-
language_id: t.language_id,
|
|
1851
|
-
translation_group_id: t.translation_group_id,
|
|
1852
|
-
product_type: t.product_type,
|
|
1853
|
-
payment_provider: t.payment_provider ?? y,
|
|
1854
|
-
provider: y,
|
|
1855
|
-
freemius_product_id: t.freemius_product_id,
|
|
1856
|
-
// include just in case it wasn't intercepted
|
|
1857
|
-
freemius_plan_id: t.freemius_plan_id,
|
|
1858
|
-
trial_period_days: t.trial_period_days ?? 0,
|
|
1859
|
-
trial_requires_payment_method: t.trial_requires_payment_method ?? !1,
|
|
1860
|
-
has_variants: t.has_variants,
|
|
1861
|
-
variant_id: t.variant_id,
|
|
1862
|
-
variant_label: t.variant_label,
|
|
1863
|
-
selected_options: t.selected_options,
|
|
1864
|
-
currency_code: c,
|
|
1865
|
-
quantity: s
|
|
1866
|
-
});
|
|
1867
|
-
h ? He.success(l("ecommerce.added_to_cart_success", { item: t.title })) : He.error(p || l("ecommerce.added_to_cart_error"));
|
|
1868
|
-
}, className: n, children: [
|
|
1869
|
-
/* @__PURE__ */ e(nt, { className: "mr-2 h-4 w-4" }),
|
|
1870
|
-
l("ecommerce.add_to_cart")
|
|
1871
|
-
] });
|
|
1872
|
-
}, Fs = ({ product: t, className: n }) => {
|
|
1873
|
-
const { activeCurrencyCode: s, currencies: a } = le(), l = Zt({
|
|
1874
|
-
entries: t.variants?.length ? t.variants : t.product_variants?.length ? t.product_variants : [],
|
|
1875
|
-
currencyCode: s,
|
|
1876
|
-
currencies: a
|
|
1877
|
-
}), c = !!(t.has_variants && l), o = ke({
|
|
1878
|
-
prices: t.prices,
|
|
1879
|
-
salePrices: t.sale_prices,
|
|
1880
|
-
fallbackPrice: t.price,
|
|
1881
|
-
fallbackSalePrice: t.sale_price,
|
|
1882
|
-
saleStartAt: t.sale_start_at,
|
|
1883
|
-
saleEndAt: t.sale_end_at,
|
|
1884
|
-
scheduledPrice: t.scheduled_price,
|
|
1885
|
-
scheduledPrices: t.scheduled_prices,
|
|
1886
|
-
scheduledPriceAt: t.scheduled_price_at,
|
|
1887
|
-
currencyCode: s,
|
|
1888
|
-
currencies: a
|
|
1889
|
-
}), m = c && l ? l.min === l.max ? w(l.min, s) : `${w(l.min, s)} - ${w(
|
|
1890
|
-
l.max,
|
|
1891
|
-
s
|
|
1892
|
-
)}` : w(o.sale_price ?? o.price, s), _ = t.variants?.length ? t.variants : t.product_variants?.length ? t.product_variants : [], y = c ? _.some(
|
|
1893
|
-
(i) => ke({
|
|
1894
|
-
prices: i.prices,
|
|
1895
|
-
salePrices: i.sale_prices,
|
|
1896
|
-
fallbackPrice: i.price,
|
|
1897
|
-
fallbackSalePrice: i.sale_price,
|
|
1898
|
-
saleStartAt: i.sale_start_at,
|
|
1899
|
-
saleEndAt: i.sale_end_at,
|
|
1900
|
-
scheduledPrice: i.scheduled_price,
|
|
1901
|
-
scheduledPrices: i.scheduled_prices,
|
|
1902
|
-
scheduledPriceAt: i.scheduled_price_at,
|
|
1903
|
-
currencyCode: s,
|
|
1904
|
-
currencies: a
|
|
1905
|
-
}).sale_price != null
|
|
1906
|
-
) : o.sale_price != null, { t: h, lang: p } = Z(), f = h("ecommerce.on_sale"), b = f === "ecommerce.on_sale" ? "On Sale" : f, d = pe(t), v = t.freemius_plans?.[0]?.freemius_pricing?.[0], F = a.find((i) => i.is_default)?.code || "USD", j = v?.override_monthly_price ?? v?.api_monthly_price, R = v?.override_annual_price ?? v?.api_annual_price, L = typeof j == "number" ? St({
|
|
1907
|
-
prices: {
|
|
1908
|
-
[F]: me(
|
|
1909
|
-
j,
|
|
1910
|
-
F
|
|
1911
|
-
)
|
|
1912
|
-
},
|
|
1913
|
-
currencyCode: s,
|
|
1914
|
-
currencies: a
|
|
1915
|
-
}) : null, S = typeof R == "number" ? St({
|
|
1916
|
-
prices: {
|
|
1917
|
-
[F]: me(
|
|
1918
|
-
R,
|
|
1919
|
-
F
|
|
1920
|
-
)
|
|
1921
|
-
},
|
|
1922
|
-
currencyCode: s,
|
|
1923
|
-
currencies: a
|
|
1924
|
-
}) : null;
|
|
1925
|
-
return /* @__PURE__ */ r("div", { className: oe("group relative flex flex-col overflow-hidden rounded-lg border bg-card text-card-foreground shadow-sm transition-all hover:shadow-md", n), children: [
|
|
1926
|
-
/* @__PURE__ */ r(Se, { href: `/product/${t.slug}`, className: "relative aspect-square overflow-hidden bg-muted", children: [
|
|
1927
|
-
y && /* @__PURE__ */ e("span", { className: "absolute left-3 top-3 z-10 rounded-full bg-destructive px-2.5 py-1 text-[10px] font-bold uppercase tracking-wider text-destructive-foreground shadow-sm", children: b }),
|
|
1928
|
-
t.image_url ? /* @__PURE__ */ e(
|
|
1929
|
-
"img",
|
|
1930
|
-
{
|
|
1931
|
-
src: t.image_url,
|
|
1932
|
-
alt: t.title,
|
|
1933
|
-
className: "h-full w-full object-cover object-center transition-transform duration-300 group-hover:scale-105"
|
|
1934
|
-
}
|
|
1935
|
-
) : /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center text-muted-foreground", children: "No Image" })
|
|
1936
|
-
] }),
|
|
1937
|
-
/* @__PURE__ */ r("div", { className: "flex flex-1 flex-col p-4", children: [
|
|
1938
|
-
t.categories && t.categories.length > 0 && /* @__PURE__ */ e("div", { className: "text-[10px] font-bold uppercase tracking-widest text-amber-600 dark:text-amber-400 mb-1", children: t.categories.map((i) => er(i.name, i.name_translations, p)).join(" • ") }),
|
|
1939
|
-
/* @__PURE__ */ e(Se, { href: `/product/${t.slug}`, className: "mb-2", children: /* @__PURE__ */ e("h3", { className: "line-clamp-1 text-lg font-medium text-foreground group-hover:underline", children: t.title }) }),
|
|
1940
|
-
/* @__PURE__ */ e("div", { className: "mb-4", children: t.product_type === "digital" && (L || S) ? /* @__PURE__ */ r("div", { className: "flex flex-wrap items-baseline gap-x-3 gap-y-1", children: [
|
|
1941
|
-
L && /* @__PURE__ */ r("div", { className: "flex items-baseline gap-0.5", children: [
|
|
1942
|
-
/* @__PURE__ */ e("span", { className: "text-xl font-bold text-primary", children: w(L.price, s) }),
|
|
1943
|
-
/* @__PURE__ */ r("span", { className: "text-xs font-medium text-muted-foreground lowercase", children: [
|
|
1944
|
-
"/ ",
|
|
1945
|
-
h("ecommerce.month")
|
|
1946
|
-
] })
|
|
1947
|
-
] }),
|
|
1948
|
-
S && /* @__PURE__ */ r("div", { className: "flex items-baseline gap-0.5", children: [
|
|
1949
|
-
/* @__PURE__ */ e("span", { className: oe("font-bold text-primary", L ? "text-lg" : "text-xl"), children: w(S.price, s) }),
|
|
1950
|
-
/* @__PURE__ */ r("span", { className: "text-xs font-medium text-muted-foreground lowercase", children: [
|
|
1951
|
-
"/ ",
|
|
1952
|
-
h("ecommerce.year")
|
|
1953
|
-
] })
|
|
1954
|
-
] })
|
|
1955
|
-
] }) : /* @__PURE__ */ r("div", { className: "flex items-baseline gap-2", children: [
|
|
1956
|
-
/* @__PURE__ */ e("span", { className: "text-xl font-bold text-primary", children: m }),
|
|
1957
|
-
!c && o.sale_price && /* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground line-through", children: w(o.price, s) })
|
|
1958
|
-
] }) }),
|
|
1959
|
-
d && /* @__PURE__ */ r("div", { className: "mb-4 rounded-md border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900", children: [
|
|
1960
|
-
/* @__PURE__ */ e("div", { className: "font-semibold", children: d.label }),
|
|
1961
|
-
/* @__PURE__ */ e("div", { className: "text-emerald-700", children: d.paymentRequirementLabel })
|
|
1962
|
-
] }),
|
|
1963
|
-
/* @__PURE__ */ e("div", { className: "mt-auto", children: /* @__PURE__ */ e(
|
|
1964
|
-
ht,
|
|
1965
|
-
{
|
|
1966
|
-
product: {
|
|
1967
|
-
...t,
|
|
1968
|
-
price: t.price,
|
|
1969
|
-
prices: t.prices,
|
|
1970
|
-
sale_price: t.sale_price,
|
|
1971
|
-
sale_prices: t.sale_prices
|
|
1972
|
-
},
|
|
1973
|
-
className: "w-full"
|
|
1974
|
-
}
|
|
1975
|
-
) })
|
|
1976
|
-
] })
|
|
1977
|
-
] });
|
|
1978
|
-
}, va = ({ products: t, columns: n = 3, className: s }) => t.length ? /* @__PURE__ */ e(
|
|
1979
|
-
"div",
|
|
1980
|
-
{
|
|
1981
|
-
className: oe(
|
|
1982
|
-
"grid gap-6 sm:grid-cols-2",
|
|
1983
|
-
n === 3 && "lg:grid-cols-3",
|
|
1984
|
-
n === 4 && "lg:grid-cols-4",
|
|
1985
|
-
s
|
|
1986
|
-
),
|
|
1987
|
-
children: t.map((a) => /* @__PURE__ */ e(Fs, { product: a }, a.id))
|
|
1988
|
-
}
|
|
1989
|
-
) : /* @__PURE__ */ e("div", { className: "py-12 text-center text-muted-foreground", children: "No products found." }), Ts = ({ images: t = [], className: n }) => {
|
|
1990
|
-
const [s, a] = k(0);
|
|
1991
|
-
return G(() => {
|
|
1992
|
-
a(0);
|
|
1993
|
-
}, [t]), t.length ? /* @__PURE__ */ r("div", { className: oe("flex flex-col gap-4", n), children: [
|
|
1994
|
-
/* @__PURE__ */ e("div", { className: "relative aspect-square w-full overflow-hidden rounded-lg border bg-white", children: /* @__PURE__ */ e(
|
|
1995
|
-
"img",
|
|
1996
|
-
{
|
|
1997
|
-
src: t[s].url,
|
|
1998
|
-
alt: t[s].alt,
|
|
1999
|
-
className: "h-full w-full object-cover object-center"
|
|
2000
|
-
}
|
|
2001
|
-
) }),
|
|
2002
|
-
t.length > 1 && /* @__PURE__ */ e("div", { className: "flex gap-4 overflow-x-auto pb-2", children: t.map((l, c) => /* @__PURE__ */ e(
|
|
2003
|
-
"button",
|
|
2004
|
-
{
|
|
2005
|
-
onClick: () => a(c),
|
|
2006
|
-
className: oe(
|
|
2007
|
-
"relative aspect-square w-20 flex-shrink-0 overflow-hidden rounded-md border",
|
|
2008
|
-
s === c ? "ring-2 ring-primary" : "ring-1 ring-transparent hover:ring-primary/50"
|
|
2009
|
-
),
|
|
2010
|
-
children: /* @__PURE__ */ e(
|
|
2011
|
-
"img",
|
|
2012
|
-
{
|
|
2013
|
-
src: l.url,
|
|
2014
|
-
alt: l.alt,
|
|
2015
|
-
className: "h-full w-full object-cover object-center"
|
|
2016
|
-
}
|
|
2017
|
-
)
|
|
2018
|
-
},
|
|
2019
|
-
c
|
|
2020
|
-
)) })
|
|
2021
|
-
] }) : /* @__PURE__ */ e("div", { className: oe("relative aspect-square w-full overflow-hidden rounded-lg bg-secondary", n), children: /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center text-muted-foreground", children: "No Image" }) });
|
|
2022
|
-
}, Na = ({ product: t, className: n, imagePosition: s = "left" }) => {
|
|
2023
|
-
const { t: a } = Z(), { activeCurrencyCode: l, currencies: c } = le(), o = Zt({
|
|
2024
|
-
entries: t.variants?.length ? t.variants : t.product_variants?.length ? t.product_variants : [],
|
|
2025
|
-
currencyCode: l,
|
|
2026
|
-
currencies: c
|
|
2027
|
-
}), m = !!(t.has_variants && o), _ = ke({
|
|
2028
|
-
prices: t.prices,
|
|
2029
|
-
salePrices: t.sale_prices,
|
|
2030
|
-
fallbackPrice: t.price,
|
|
2031
|
-
fallbackSalePrice: t.sale_price,
|
|
2032
|
-
saleStartAt: t.sale_start_at,
|
|
2033
|
-
saleEndAt: t.sale_end_at,
|
|
2034
|
-
scheduledPrice: t.scheduled_price,
|
|
2035
|
-
scheduledPrices: t.scheduled_prices,
|
|
2036
|
-
scheduledPriceAt: t.scheduled_price_at,
|
|
2037
|
-
currencyCode: l,
|
|
2038
|
-
currencies: c
|
|
2039
|
-
}), y = m && o ? o.min === o.max ? w(o.min, l) : `${w(o.min, l)} - ${w(
|
|
2040
|
-
o.max,
|
|
2041
|
-
l
|
|
2042
|
-
)}` : w(_.sale_price ?? _.price, l), h = pe(t);
|
|
2043
|
-
return /* @__PURE__ */ e("div", { className: oe("overflow-hidden rounded-xl border bg-card shadow-sm", n), children: /* @__PURE__ */ r("div", { className: oe("flex flex-col gap-8 md:flex-row", s === "right" && "md:flex-row-reverse"), children: [
|
|
2044
|
-
/* @__PURE__ */ e("div", { className: "relative aspect-square w-full md:w-1/2", children: t.image_url ? /* @__PURE__ */ e(
|
|
2045
|
-
"img",
|
|
2046
|
-
{
|
|
2047
|
-
src: t.image_url,
|
|
2048
|
-
alt: t.title,
|
|
2049
|
-
className: "h-full w-full object-cover"
|
|
2050
|
-
}
|
|
2051
|
-
) : /* @__PURE__ */ e("div", { className: "flex h-full w-full items-center justify-center bg-secondary text-muted-foreground", children: a("ecommerce.no_image") }) }),
|
|
2052
|
-
/* @__PURE__ */ r("div", { className: "flex flex-1 flex-col justify-center p-6 md:p-12", children: [
|
|
2053
|
-
/* @__PURE__ */ e(Se, { href: `/product/${t.slug}`, children: /* @__PURE__ */ e("h2", { className: "mb-4 text-3xl font-bold tracking-tight hover:underline md:text-4xl", children: t.title }) }),
|
|
2054
|
-
/* @__PURE__ */ r("div", { className: "mb-6 flex items-baseline gap-3", children: [
|
|
2055
|
-
/* @__PURE__ */ e("span", { className: "text-3xl font-bold text-primary", children: y }),
|
|
2056
|
-
!m && _.sale_price && /* @__PURE__ */ e("span", { className: "text-lg text-muted-foreground line-through", children: w(_.price, l) })
|
|
2057
|
-
] }),
|
|
2058
|
-
h && /* @__PURE__ */ r("div", { className: "mb-6 inline-flex w-fit flex-col rounded-md border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm text-emerald-900", children: [
|
|
2059
|
-
/* @__PURE__ */ e("span", { className: "font-semibold", children: h.label }),
|
|
2060
|
-
/* @__PURE__ */ e("span", { className: "text-emerald-700", children: h.paymentRequirementLabel })
|
|
2061
|
-
] }),
|
|
2062
|
-
t.short_description && /* @__PURE__ */ e("p", { className: "mb-8 text-lg text-muted-foreground", children: t.short_description }),
|
|
2063
|
-
/* @__PURE__ */ r("div", { className: "flex flex-col gap-4 sm:flex-row", children: [
|
|
2064
|
-
/* @__PURE__ */ e(
|
|
2065
|
-
ht,
|
|
2066
|
-
{
|
|
2067
|
-
product: t,
|
|
2068
|
-
className: "h-12 w-full px-8 text-lg sm:w-auto"
|
|
2069
|
-
}
|
|
2070
|
-
),
|
|
2071
|
-
/* @__PURE__ */ e(
|
|
2072
|
-
Se,
|
|
2073
|
-
{
|
|
2074
|
-
href: `/product/${t.slug}`,
|
|
2075
|
-
className: "inline-flex h-12 items-center justify-center rounded-md border border-input bg-background px-8 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground",
|
|
2076
|
-
children: a("ecommerce.view_details")
|
|
2077
|
-
}
|
|
2078
|
-
)
|
|
2079
|
-
] })
|
|
2080
|
-
] })
|
|
2081
|
-
] }) });
|
|
2082
|
-
};
|
|
2083
|
-
function jt(t, n, s) {
|
|
2084
|
-
const a = t(n);
|
|
2085
|
-
return a === n ? s : a;
|
|
2086
|
-
}
|
|
2087
|
-
function Rs(t) {
|
|
2088
|
-
return t === "password" ? Vr : Dr;
|
|
2089
|
-
}
|
|
2090
|
-
function $s({
|
|
2091
|
-
links: t,
|
|
2092
|
-
title: n,
|
|
2093
|
-
className: s
|
|
2094
|
-
}) {
|
|
2095
|
-
const a = Ir(), { t: l } = Z();
|
|
2096
|
-
return t.length ? /* @__PURE__ */ r("div", { className: oe("w-full space-y-3", s), children: [
|
|
2097
|
-
/* @__PURE__ */ e("div", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wider", children: n || jt(l, "account_navigation", "Account") }),
|
|
2098
|
-
/* @__PURE__ */ e("div", { className: "space-y-2", children: t.map((c) => {
|
|
2099
|
-
const o = Rs(c.icon), m = a === c.href || a.startsWith(`${c.href}/`);
|
|
2100
|
-
return /* @__PURE__ */ r(
|
|
2101
|
-
Se,
|
|
2102
|
-
{
|
|
2103
|
-
href: c.href,
|
|
2104
|
-
className: oe(
|
|
64
|
+
href: i.href,
|
|
65
|
+
className: z(
|
|
2105
66
|
"flex items-center gap-3 rounded-xl border px-3 py-2.5 text-sm font-medium transition-colors",
|
|
2106
|
-
|
|
67
|
+
t ? "border-slate-900 bg-slate-900 text-white" : "border-border bg-background hover:bg-muted/40"
|
|
2107
68
|
),
|
|
2108
69
|
children: [
|
|
2109
|
-
/* @__PURE__ */
|
|
2110
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ r(u, { className: "h-4 w-4 shrink-0" }),
|
|
71
|
+
/* @__PURE__ */ r("span", { children: q(h, i.labelKey, i.fallbackLabel) })
|
|
2111
72
|
]
|
|
2112
73
|
},
|
|
2113
|
-
|
|
74
|
+
i.href
|
|
2114
75
|
);
|
|
2115
76
|
}) })
|
|
2116
77
|
] }) : null;
|
|
2117
78
|
}
|
|
2118
|
-
async function
|
|
2119
|
-
const
|
|
2120
|
-
if (
|
|
79
|
+
async function Te(e) {
|
|
80
|
+
const d = Ce(), { data: { user: l }, error: s } = await d.auth.getUser();
|
|
81
|
+
if (s || !l)
|
|
2121
82
|
throw new Error("Unauthorized");
|
|
2122
|
-
const
|
|
2123
|
-
full_name:
|
|
2124
|
-
avatar_url:
|
|
2125
|
-
website:
|
|
2126
|
-
github_username:
|
|
2127
|
-
phone:
|
|
83
|
+
const h = {
|
|
84
|
+
full_name: e.full_name || null,
|
|
85
|
+
avatar_url: e.avatar_url || null,
|
|
86
|
+
website: e.website || null,
|
|
87
|
+
github_username: e.github_username || null,
|
|
88
|
+
phone: e.phone || null,
|
|
2128
89
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2129
|
-
}, { error:
|
|
2130
|
-
if (
|
|
2131
|
-
throw console.error("Error updating profile:",
|
|
2132
|
-
const
|
|
2133
|
-
return await
|
|
2134
|
-
userId:
|
|
2135
|
-
billingAddress:
|
|
2136
|
-
shippingAddress:
|
|
2137
|
-
client:
|
|
2138
|
-
}),
|
|
2139
|
-
}
|
|
2140
|
-
function
|
|
90
|
+
}, { error: i } = await d.from("profiles").update(h).eq("id", l.id);
|
|
91
|
+
if (i)
|
|
92
|
+
throw console.error("Error updating profile:", i), new Error("Failed to update profile");
|
|
93
|
+
const u = S(e.billing_address), t = e.use_billing_for_shipping ? u : S(e.shipping_address);
|
|
94
|
+
return await Se({
|
|
95
|
+
userId: l.id,
|
|
96
|
+
billingAddress: u,
|
|
97
|
+
shippingAddress: t,
|
|
98
|
+
client: d
|
|
99
|
+
}), H("/profile"), H("/checkout"), { success: !0 };
|
|
100
|
+
}
|
|
101
|
+
function w(e) {
|
|
2141
102
|
return {
|
|
2142
|
-
company_name:
|
|
2143
|
-
recipient_name:
|
|
2144
|
-
line1:
|
|
2145
|
-
line2:
|
|
2146
|
-
city:
|
|
2147
|
-
state:
|
|
2148
|
-
postal_code:
|
|
2149
|
-
country_code:
|
|
103
|
+
company_name: e?.company_name || "",
|
|
104
|
+
recipient_name: e?.recipient_name || "",
|
|
105
|
+
line1: e?.line1 || "",
|
|
106
|
+
line2: e?.line2 || "",
|
|
107
|
+
city: e?.city || "",
|
|
108
|
+
state: e?.state || "",
|
|
109
|
+
postal_code: e?.postal_code || "",
|
|
110
|
+
country_code: Pe(e?.country_code) || "CA"
|
|
2150
111
|
};
|
|
2151
112
|
}
|
|
2152
|
-
function
|
|
2153
|
-
prefix:
|
|
2154
|
-
title:
|
|
2155
|
-
register:
|
|
113
|
+
function X({
|
|
114
|
+
prefix: e,
|
|
115
|
+
title: d,
|
|
116
|
+
register: l
|
|
2156
117
|
}) {
|
|
2157
|
-
const { t:
|
|
2158
|
-
return /* @__PURE__ */
|
|
2159
|
-
/* @__PURE__ */
|
|
2160
|
-
/* @__PURE__ */
|
|
2161
|
-
/* @__PURE__ */
|
|
118
|
+
const { t: s } = T(), h = s("company_name") === "company_name" ? "Company name" : s("company_name");
|
|
119
|
+
return /* @__PURE__ */ a("div", { className: "space-y-4 rounded-xl border p-4", children: [
|
|
120
|
+
/* @__PURE__ */ a("div", { children: [
|
|
121
|
+
/* @__PURE__ */ r("h3", { className: "text-lg font-medium", children: d }),
|
|
122
|
+
/* @__PURE__ */ r("p", { className: "text-sm text-muted-foreground", children: s("profile_address_defaults_help") })
|
|
2162
123
|
] }),
|
|
2163
|
-
/* @__PURE__ */
|
|
2164
|
-
/* @__PURE__ */
|
|
2165
|
-
/* @__PURE__ */
|
|
2166
|
-
/* @__PURE__ */
|
|
124
|
+
/* @__PURE__ */ a("div", { className: "grid gap-4 md:grid-cols-3", children: [
|
|
125
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
126
|
+
/* @__PURE__ */ r(c, { htmlFor: `${e}-company_name`, children: h }),
|
|
127
|
+
/* @__PURE__ */ r(m, { id: `${e}-company_name`, ...l(`${e}.company_name`) })
|
|
2167
128
|
] }),
|
|
2168
|
-
/* @__PURE__ */
|
|
2169
|
-
/* @__PURE__ */
|
|
2170
|
-
/* @__PURE__ */
|
|
129
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
130
|
+
/* @__PURE__ */ r(c, { htmlFor: `${e}-recipient_name`, children: s("full_name") }),
|
|
131
|
+
/* @__PURE__ */ r(m, { id: `${e}-recipient_name`, ...l(`${e}.recipient_name`) })
|
|
2171
132
|
] }),
|
|
2172
|
-
/* @__PURE__ */
|
|
2173
|
-
/* @__PURE__ */
|
|
2174
|
-
/* @__PURE__ */
|
|
133
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
134
|
+
/* @__PURE__ */ r(c, { htmlFor: `${e}-country_code`, children: s("country") }),
|
|
135
|
+
/* @__PURE__ */ r(
|
|
2175
136
|
"select",
|
|
2176
137
|
{
|
|
2177
|
-
id: `${
|
|
138
|
+
id: `${e}-country_code`,
|
|
2178
139
|
className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
2179
|
-
...
|
|
2180
|
-
children:
|
|
140
|
+
...l(`${e}.country_code`),
|
|
141
|
+
children: Ee.map((i) => /* @__PURE__ */ r("option", { value: i.code, children: i.name }, i.code))
|
|
2181
142
|
}
|
|
2182
143
|
)
|
|
2183
144
|
] })
|
|
2184
145
|
] }),
|
|
2185
|
-
/* @__PURE__ */
|
|
2186
|
-
/* @__PURE__ */
|
|
2187
|
-
/* @__PURE__ */
|
|
146
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
147
|
+
/* @__PURE__ */ r(c, { htmlFor: `${e}-line1`, children: s("address_line_1") }),
|
|
148
|
+
/* @__PURE__ */ r(m, { id: `${e}-line1`, ...l(`${e}.line1`) })
|
|
2188
149
|
] }),
|
|
2189
|
-
/* @__PURE__ */
|
|
2190
|
-
/* @__PURE__ */
|
|
2191
|
-
/* @__PURE__ */
|
|
150
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
151
|
+
/* @__PURE__ */ r(c, { htmlFor: `${e}-line2`, children: s("address_line_2") }),
|
|
152
|
+
/* @__PURE__ */ r(m, { id: `${e}-line2`, ...l(`${e}.line2`) })
|
|
2192
153
|
] }),
|
|
2193
|
-
/* @__PURE__ */
|
|
2194
|
-
/* @__PURE__ */
|
|
2195
|
-
/* @__PURE__ */
|
|
2196
|
-
/* @__PURE__ */
|
|
154
|
+
/* @__PURE__ */ a("div", { className: "grid gap-4 md:grid-cols-3", children: [
|
|
155
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
156
|
+
/* @__PURE__ */ r(c, { htmlFor: `${e}-city`, children: s("city") }),
|
|
157
|
+
/* @__PURE__ */ r(m, { id: `${e}-city`, ...l(`${e}.city`) })
|
|
2197
158
|
] }),
|
|
2198
|
-
/* @__PURE__ */
|
|
2199
|
-
/* @__PURE__ */
|
|
2200
|
-
/* @__PURE__ */
|
|
159
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
160
|
+
/* @__PURE__ */ r(c, { htmlFor: `${e}-state`, children: s("state_province") }),
|
|
161
|
+
/* @__PURE__ */ r(m, { id: `${e}-state`, ...l(`${e}.state`) })
|
|
2201
162
|
] }),
|
|
2202
|
-
/* @__PURE__ */
|
|
2203
|
-
/* @__PURE__ */
|
|
2204
|
-
/* @__PURE__ */
|
|
163
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
164
|
+
/* @__PURE__ */ r(c, { htmlFor: `${e}-postal_code`, children: s("postal_zip_code") }),
|
|
165
|
+
/* @__PURE__ */ r(m, { id: `${e}-postal_code`, ...l(`${e}.postal_code`) })
|
|
2205
166
|
] })
|
|
2206
167
|
] })
|
|
2207
168
|
] });
|
|
2208
169
|
}
|
|
2209
|
-
function
|
|
2210
|
-
initialData:
|
|
2211
|
-
MediaPickerComponent:
|
|
2212
|
-
isAdmin:
|
|
2213
|
-
email:
|
|
2214
|
-
accountLinks:
|
|
2215
|
-
onAction:
|
|
2216
|
-
initialSuccessMessage:
|
|
170
|
+
function Ze({
|
|
171
|
+
initialData: e,
|
|
172
|
+
MediaPickerComponent: d,
|
|
173
|
+
isAdmin: l,
|
|
174
|
+
email: s,
|
|
175
|
+
accountLinks: h,
|
|
176
|
+
onAction: i,
|
|
177
|
+
initialSuccessMessage: u
|
|
2217
178
|
}) {
|
|
2218
|
-
const { t
|
|
2219
|
-
|
|
2220
|
-
), [
|
|
2221
|
-
register:
|
|
2222
|
-
handleSubmit:
|
|
2223
|
-
setValue:
|
|
2224
|
-
getValues:
|
|
2225
|
-
watch:
|
|
2226
|
-
reset:
|
|
2227
|
-
} =
|
|
179
|
+
const { t } = T(), [A, R] = C(!1), [P, y] = C(
|
|
180
|
+
u ? { type: "success", text: u } : null
|
|
181
|
+
), [$, Y] = C(!1), [L, J] = C(null), Q = e?.use_billing_for_shipping ?? (!e?.shipping_address || K(e?.billing_address, e?.shipping_address)), {
|
|
182
|
+
register: _,
|
|
183
|
+
handleSubmit: Z,
|
|
184
|
+
setValue: g,
|
|
185
|
+
getValues: x,
|
|
186
|
+
watch: v,
|
|
187
|
+
reset: U
|
|
188
|
+
} = te({
|
|
2228
189
|
defaultValues: {
|
|
2229
|
-
full_name:
|
|
2230
|
-
avatar_url:
|
|
2231
|
-
website:
|
|
2232
|
-
github_username:
|
|
2233
|
-
phone:
|
|
2234
|
-
role:
|
|
2235
|
-
use_billing_for_shipping:
|
|
2236
|
-
billing_address:
|
|
2237
|
-
shipping_address:
|
|
190
|
+
full_name: e?.full_name || "",
|
|
191
|
+
avatar_url: e?.avatar_url || "",
|
|
192
|
+
website: e?.website || "",
|
|
193
|
+
github_username: e?.github_username || "",
|
|
194
|
+
phone: e?.phone || "",
|
|
195
|
+
role: e?.role,
|
|
196
|
+
use_billing_for_shipping: Q,
|
|
197
|
+
billing_address: w(e?.billing_address),
|
|
198
|
+
shipping_address: w(e?.shipping_address)
|
|
2238
199
|
}
|
|
2239
200
|
});
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
full_name:
|
|
2243
|
-
avatar_url:
|
|
2244
|
-
website:
|
|
2245
|
-
github_username:
|
|
2246
|
-
phone:
|
|
2247
|
-
role:
|
|
2248
|
-
use_billing_for_shipping:
|
|
2249
|
-
billing_address:
|
|
2250
|
-
shipping_address:
|
|
201
|
+
E.useEffect(() => {
|
|
202
|
+
e && U({
|
|
203
|
+
full_name: e.full_name || "",
|
|
204
|
+
avatar_url: e.avatar_url || "",
|
|
205
|
+
website: e.website || "",
|
|
206
|
+
github_username: e.github_username || "",
|
|
207
|
+
phone: e.phone || "",
|
|
208
|
+
role: e.role,
|
|
209
|
+
use_billing_for_shipping: e.use_billing_for_shipping ?? (!e.shipping_address || K(e.billing_address, e.shipping_address)),
|
|
210
|
+
billing_address: w(e.billing_address),
|
|
211
|
+
shipping_address: w(e.shipping_address)
|
|
2251
212
|
});
|
|
2252
|
-
}, [
|
|
2253
|
-
|
|
2254
|
-
}, [
|
|
2255
|
-
const
|
|
213
|
+
}, [e, U]), E.useEffect(() => {
|
|
214
|
+
u && y({ type: "success", text: u });
|
|
215
|
+
}, [u]), E.useEffect(() => {
|
|
216
|
+
const n = W();
|
|
2256
217
|
(async () => {
|
|
2257
218
|
const {
|
|
2258
|
-
data: { user:
|
|
2259
|
-
} = await
|
|
2260
|
-
if (!
|
|
219
|
+
data: { user: p }
|
|
220
|
+
} = await n.auth.getUser();
|
|
221
|
+
if (!p)
|
|
2261
222
|
return;
|
|
2262
|
-
const
|
|
2263
|
-
if (
|
|
2264
|
-
|
|
2265
|
-
const
|
|
2266
|
-
if (
|
|
2267
|
-
const
|
|
2268
|
-
|
|
223
|
+
const o = p.identities?.find((b) => b.provider === "github");
|
|
224
|
+
if (o) {
|
|
225
|
+
Y(!0);
|
|
226
|
+
const b = o.identity_data?.email || (p.app_metadata.provider === "github" ? p.email : null);
|
|
227
|
+
if (J(b), !x("website")) {
|
|
228
|
+
const N = o.identity_data?.custom_claims?.blog || o.identity_data?.blog || o.identity_data?.html_url;
|
|
229
|
+
N && g("website", N);
|
|
2269
230
|
}
|
|
2270
|
-
if (!
|
|
2271
|
-
const
|
|
2272
|
-
|
|
231
|
+
if (!x("avatar_url")) {
|
|
232
|
+
const N = o.identity_data?.avatar_url;
|
|
233
|
+
N && g("avatar_url", N);
|
|
2273
234
|
}
|
|
2274
|
-
const
|
|
2275
|
-
|
|
235
|
+
const O = o.identity_data?.user_name || o.identity_data?.preferred_username;
|
|
236
|
+
O && g("github_username", O);
|
|
2276
237
|
}
|
|
2277
|
-
!
|
|
238
|
+
!x("full_name") && p.user_metadata?.full_name && g("full_name", p.user_metadata.full_name);
|
|
2278
239
|
})();
|
|
2279
|
-
}, [
|
|
2280
|
-
const
|
|
2281
|
-
const
|
|
2282
|
-
|
|
240
|
+
}, [x, g]);
|
|
241
|
+
const ee = async () => {
|
|
242
|
+
const n = W(), { error: f } = await n.auth.linkIdentity({ provider: "github" });
|
|
243
|
+
f && (console.error("Error linking GitHub:", f), y({
|
|
2283
244
|
type: "error",
|
|
2284
|
-
text:
|
|
245
|
+
text: t("github_link_failed") || "Failed to link GitHub account"
|
|
2285
246
|
}));
|
|
2286
|
-
},
|
|
2287
|
-
const
|
|
2288
|
-
|
|
2289
|
-
},
|
|
2290
|
-
|
|
2291
|
-
const
|
|
247
|
+
}, re = (n) => {
|
|
248
|
+
const p = `${process.env.NEXT_PUBLIC_R2_BASE_URL || "https://assets.nextblock.com"}/${n.object_key}`;
|
|
249
|
+
g("avatar_url", p);
|
|
250
|
+
}, ae = async (n) => {
|
|
251
|
+
R(!0), y(null);
|
|
252
|
+
const f = S(n.billing_address) ?? we(), p = n.use_billing_for_shipping ? f : S(n.shipping_address);
|
|
2292
253
|
try {
|
|
2293
|
-
const
|
|
2294
|
-
...
|
|
2295
|
-
billing_address:
|
|
2296
|
-
shipping_address:
|
|
254
|
+
const o = {
|
|
255
|
+
...n,
|
|
256
|
+
billing_address: f,
|
|
257
|
+
shipping_address: p
|
|
2297
258
|
};
|
|
2298
|
-
if (
|
|
2299
|
-
const
|
|
2300
|
-
if (
|
|
2301
|
-
throw new Error(
|
|
259
|
+
if (i) {
|
|
260
|
+
const b = await i(o);
|
|
261
|
+
if (b?.error)
|
|
262
|
+
throw new Error(b.error);
|
|
2302
263
|
} else
|
|
2303
|
-
await
|
|
2304
|
-
|
|
2305
|
-
} catch (
|
|
2306
|
-
if (
|
|
264
|
+
await Te(o);
|
|
265
|
+
y({ type: "success", text: t("profile_updated_success") });
|
|
266
|
+
} catch (o) {
|
|
267
|
+
if (o.message === "NEXT_REDIRECT" || o.message?.includes("NEXT_REDIRECT"))
|
|
2307
268
|
return;
|
|
2308
|
-
console.error(
|
|
269
|
+
console.error(o), y({ type: "error", text: o.message || t("profile_update_failed") });
|
|
2309
270
|
} finally {
|
|
2310
|
-
|
|
271
|
+
R(!1);
|
|
2311
272
|
}
|
|
2312
|
-
},
|
|
2313
|
-
return /* @__PURE__ */
|
|
2314
|
-
/* @__PURE__ */
|
|
2315
|
-
/* @__PURE__ */
|
|
2316
|
-
/* @__PURE__ */
|
|
2317
|
-
/* @__PURE__ */
|
|
2318
|
-
/* @__PURE__ */
|
|
2319
|
-
/* @__PURE__ */
|
|
2320
|
-
/* @__PURE__ */
|
|
273
|
+
}, k = v("use_billing_for_shipping");
|
|
274
|
+
return /* @__PURE__ */ a("div", { className: "grid gap-6 md:grid-cols-12 max-w-5xl mx-auto", children: [
|
|
275
|
+
/* @__PURE__ */ a(B, { className: "md:col-span-4 h-fit", children: [
|
|
276
|
+
/* @__PURE__ */ r(M, { children: /* @__PURE__ */ r(j, { className: "text-xl", children: t("public_profile") }) }),
|
|
277
|
+
/* @__PURE__ */ a(D, { className: "flex flex-col items-center text-center space-y-4", children: [
|
|
278
|
+
/* @__PURE__ */ a("div", { className: "relative group", children: [
|
|
279
|
+
/* @__PURE__ */ a(ue, { className: "h-32 w-32 border-4 border-muted", children: [
|
|
280
|
+
/* @__PURE__ */ r(pe, { src: v("avatar_url") || void 0, className: "object-cover" }),
|
|
281
|
+
/* @__PURE__ */ r(he, { className: "text-4xl bg-secondary", children: v("full_name")?.charAt(0)?.toUpperCase() || /* @__PURE__ */ r(V, { className: "h-12 w-12" }) })
|
|
2321
282
|
] }),
|
|
2322
|
-
|
|
2323
|
-
|
|
283
|
+
d && /* @__PURE__ */ r("div", { className: "absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/40 rounded-full cursor-pointer", children: /* @__PURE__ */ r(
|
|
284
|
+
d,
|
|
2324
285
|
{
|
|
2325
|
-
triggerLabel: /* @__PURE__ */
|
|
286
|
+
triggerLabel: /* @__PURE__ */ r(oe, { className: "h-6 w-6 text-white" }),
|
|
2326
287
|
triggerVariant: "ghost",
|
|
2327
|
-
title:
|
|
2328
|
-
onSelect:
|
|
2329
|
-
accept: (
|
|
288
|
+
title: t("customer_profile"),
|
|
289
|
+
onSelect: re,
|
|
290
|
+
accept: (n) => n.file_type.startsWith("image/"),
|
|
2330
291
|
hideTrigger: !1
|
|
2331
292
|
}
|
|
2332
293
|
) })
|
|
2333
294
|
] }),
|
|
2334
|
-
!
|
|
2335
|
-
/* @__PURE__ */
|
|
2336
|
-
/* @__PURE__ */
|
|
295
|
+
!d && /* @__PURE__ */ a("div", { className: "w-full", children: [
|
|
296
|
+
/* @__PURE__ */ r(c, { htmlFor: "avatar_url", className: "sr-only", children: t("avatar_url") }),
|
|
297
|
+
/* @__PURE__ */ r(m, { id: "avatar_url", ..._("avatar_url"), placeholder: "https://...", className: "mt-2" })
|
|
2337
298
|
] }),
|
|
2338
|
-
/* @__PURE__ */
|
|
2339
|
-
/* @__PURE__ */
|
|
2340
|
-
/* @__PURE__ */
|
|
2341
|
-
|
|
2342
|
-
/* @__PURE__ */
|
|
299
|
+
/* @__PURE__ */ a("div", { className: "w-full space-y-1 text-left mt-4", children: [
|
|
300
|
+
/* @__PURE__ */ r("div", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wider", children: t("identity") }),
|
|
301
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ r("span", { className: "font-semibold text-lg", children: v("full_name") || t("full_name") }) }),
|
|
302
|
+
$ && /* @__PURE__ */ a(ge, { variant: "secondary", className: "mt-2 w-fit gap-1", children: [
|
|
303
|
+
/* @__PURE__ */ r(F, { className: "h-3 w-3" }),
|
|
2343
304
|
" ",
|
|
2344
|
-
|
|
305
|
+
t("github_connected") || "GitHub Connected"
|
|
2345
306
|
] })
|
|
2346
307
|
] }),
|
|
2347
|
-
|
|
2348
|
-
|
|
308
|
+
h?.length ? /* @__PURE__ */ r(
|
|
309
|
+
Ie,
|
|
2349
310
|
{
|
|
2350
|
-
links:
|
|
311
|
+
links: h,
|
|
2351
312
|
className: "mt-2 text-left"
|
|
2352
313
|
}
|
|
2353
314
|
) : null
|
|
2354
315
|
] })
|
|
2355
316
|
] }),
|
|
2356
|
-
/* @__PURE__ */
|
|
2357
|
-
/* @__PURE__ */
|
|
2358
|
-
/* @__PURE__ */
|
|
2359
|
-
|
|
2360
|
-
/* @__PURE__ */
|
|
2361
|
-
|
|
317
|
+
/* @__PURE__ */ r(B, { className: "md:col-span-8", children: /* @__PURE__ */ a("form", { onSubmit: Z(ae), children: [
|
|
318
|
+
/* @__PURE__ */ r(M, { children: /* @__PURE__ */ r(j, { children: t("details") }) }),
|
|
319
|
+
/* @__PURE__ */ a(D, { className: "space-y-6", children: [
|
|
320
|
+
s && /* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
321
|
+
/* @__PURE__ */ a(c, { htmlFor: "email", children: [
|
|
322
|
+
t("email") || "Email",
|
|
2362
323
|
" (Read-only)"
|
|
2363
324
|
] }),
|
|
2364
|
-
/* @__PURE__ */
|
|
325
|
+
/* @__PURE__ */ r(m, { id: "email", value: s, readOnly: !0, disabled: !0, className: "bg-muted/50" })
|
|
2365
326
|
] }),
|
|
2366
|
-
/* @__PURE__ */
|
|
2367
|
-
/* @__PURE__ */
|
|
2368
|
-
/* @__PURE__ */
|
|
2369
|
-
/* @__PURE__ */
|
|
2370
|
-
/* @__PURE__ */
|
|
327
|
+
/* @__PURE__ */ r("div", { className: "rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground", children: t("profile_basic_info_help") }),
|
|
328
|
+
/* @__PURE__ */ a("div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
329
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
330
|
+
/* @__PURE__ */ a(c, { htmlFor: "full_name", className: "flex items-center gap-2", children: [
|
|
331
|
+
/* @__PURE__ */ r(V, { className: "h-4 w-4" }),
|
|
2371
332
|
" ",
|
|
2372
|
-
|
|
333
|
+
t("full_name")
|
|
2373
334
|
] }),
|
|
2374
|
-
/* @__PURE__ */
|
|
335
|
+
/* @__PURE__ */ r(m, { id: "full_name", ..._("full_name") })
|
|
2375
336
|
] }),
|
|
2376
|
-
/* @__PURE__ */
|
|
2377
|
-
/* @__PURE__ */
|
|
2378
|
-
/* @__PURE__ */
|
|
337
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
338
|
+
/* @__PURE__ */ a(c, { htmlFor: "phone", className: "flex items-center gap-2", children: [
|
|
339
|
+
/* @__PURE__ */ r(ce, { className: "h-4 w-4" }),
|
|
2379
340
|
" ",
|
|
2380
|
-
|
|
341
|
+
t("phone_number")
|
|
2381
342
|
] }),
|
|
2382
|
-
/* @__PURE__ */
|
|
343
|
+
/* @__PURE__ */ r(m, { id: "phone", ..._("phone") })
|
|
2383
344
|
] })
|
|
2384
345
|
] }),
|
|
2385
|
-
/* @__PURE__ */
|
|
2386
|
-
/* @__PURE__ */
|
|
2387
|
-
/* @__PURE__ */
|
|
2388
|
-
/* @__PURE__ */
|
|
346
|
+
/* @__PURE__ */ a("div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
347
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
348
|
+
/* @__PURE__ */ a(c, { htmlFor: "website", className: "flex items-center gap-2", children: [
|
|
349
|
+
/* @__PURE__ */ r(de, { className: "h-4 w-4" }),
|
|
2389
350
|
" ",
|
|
2390
|
-
|
|
351
|
+
t("website")
|
|
2391
352
|
] }),
|
|
2392
|
-
/* @__PURE__ */
|
|
353
|
+
/* @__PURE__ */ r(m, { id: "website", ..._("website"), placeholder: "https://example.com" })
|
|
2393
354
|
] }),
|
|
2394
|
-
/* @__PURE__ */
|
|
2395
|
-
/* @__PURE__ */
|
|
2396
|
-
/* @__PURE__ */
|
|
355
|
+
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
356
|
+
/* @__PURE__ */ a(c, { htmlFor: "github_username", className: "flex items-center gap-2", children: [
|
|
357
|
+
/* @__PURE__ */ r(F, { className: "h-4 w-4" }),
|
|
2397
358
|
" ",
|
|
2398
|
-
|
|
359
|
+
t("github_username")
|
|
2399
360
|
] }),
|
|
2400
|
-
|
|
2401
|
-
/* @__PURE__ */
|
|
2402
|
-
|
|
2403
|
-
/* @__PURE__ */
|
|
361
|
+
$ ? /* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
362
|
+
/* @__PURE__ */ r(m, { id: "github_username", ..._("github_username"), disabled: !0, className: "bg-muted" }),
|
|
363
|
+
L && /* @__PURE__ */ a("p", { className: "text-xs text-muted-foreground flex items-center gap-1", children: [
|
|
364
|
+
/* @__PURE__ */ r(me, { className: "h-3 w-3" }),
|
|
2404
365
|
" ",
|
|
2405
|
-
|
|
366
|
+
t("linked_to") || "Linked to",
|
|
2406
367
|
" ",
|
|
2407
|
-
|
|
368
|
+
L
|
|
2408
369
|
] })
|
|
2409
|
-
] }) : /* @__PURE__ */
|
|
2410
|
-
/* @__PURE__ */
|
|
2411
|
-
|
|
370
|
+
] }) : /* @__PURE__ */ a(G, { type: "button", variant: "outline", className: "w-full", onClick: ee, children: [
|
|
371
|
+
/* @__PURE__ */ r(F, { className: "mr-2 h-4 w-4" }),
|
|
372
|
+
t("connect_github")
|
|
2412
373
|
] })
|
|
2413
374
|
] })
|
|
2414
375
|
] }),
|
|
2415
|
-
/* @__PURE__ */
|
|
2416
|
-
/* @__PURE__ */
|
|
2417
|
-
/* @__PURE__ */
|
|
2418
|
-
/* @__PURE__ */
|
|
2419
|
-
|
|
376
|
+
/* @__PURE__ */ r(xe, { className: "my-2" }),
|
|
377
|
+
/* @__PURE__ */ r(X, { prefix: "billing_address", title: t("billing_address"), register: _ }),
|
|
378
|
+
/* @__PURE__ */ a("div", { className: "flex items-center space-x-3 rounded-lg border p-4", children: [
|
|
379
|
+
/* @__PURE__ */ r(
|
|
380
|
+
fe,
|
|
2420
381
|
{
|
|
2421
382
|
id: "use_billing_for_shipping",
|
|
2422
|
-
checked: !!
|
|
2423
|
-
onCheckedChange: (
|
|
383
|
+
checked: !!k,
|
|
384
|
+
onCheckedChange: (n) => g("use_billing_for_shipping", !!n, { shouldDirty: !0 })
|
|
2424
385
|
}
|
|
2425
386
|
),
|
|
2426
|
-
/* @__PURE__ */
|
|
2427
|
-
/* @__PURE__ */
|
|
2428
|
-
/* @__PURE__ */
|
|
387
|
+
/* @__PURE__ */ a("div", { className: "space-y-1", children: [
|
|
388
|
+
/* @__PURE__ */ r(c, { htmlFor: "use_billing_for_shipping", className: "cursor-pointer", children: t("use_billing_for_shipping") }),
|
|
389
|
+
/* @__PURE__ */ r("p", { className: "text-sm text-muted-foreground", children: t("profile_use_billing_for_shipping_help") })
|
|
2429
390
|
] })
|
|
2430
391
|
] }),
|
|
2431
|
-
!
|
|
2432
|
-
|
|
392
|
+
!k && /* @__PURE__ */ r(
|
|
393
|
+
X,
|
|
2433
394
|
{
|
|
2434
395
|
prefix: "shipping_address",
|
|
2435
|
-
title:
|
|
2436
|
-
register:
|
|
396
|
+
title: t("shipping_address"),
|
|
397
|
+
register: _
|
|
2437
398
|
}
|
|
2438
399
|
),
|
|
2439
|
-
|
|
400
|
+
P && /* @__PURE__ */ r(
|
|
2440
401
|
"div",
|
|
2441
402
|
{
|
|
2442
|
-
className: `mt-4 rounded-xl border p-4 text-sm ${
|
|
2443
|
-
children:
|
|
403
|
+
className: `mt-4 rounded-xl border p-4 text-sm ${P.type === "success" ? "border-emerald-200 bg-emerald-50 text-emerald-700" : "border-red-200 bg-red-50 text-red-700"}`,
|
|
404
|
+
children: P.text
|
|
2444
405
|
}
|
|
2445
406
|
),
|
|
2446
|
-
|
|
2447
|
-
/* @__PURE__ */
|
|
2448
|
-
/* @__PURE__ */
|
|
2449
|
-
/* @__PURE__ */
|
|
2450
|
-
/* @__PURE__ */
|
|
2451
|
-
|
|
407
|
+
l && /* @__PURE__ */ a("div", { className: "border-t pt-4 mt-4", children: [
|
|
408
|
+
/* @__PURE__ */ r("h3", { className: "text-sm font-medium mb-3", children: "Admin Settings" }),
|
|
409
|
+
/* @__PURE__ */ a("div", { className: "grid gap-2", children: [
|
|
410
|
+
/* @__PURE__ */ r(c, { htmlFor: "role", children: "Role" }),
|
|
411
|
+
/* @__PURE__ */ a(
|
|
412
|
+
be,
|
|
2452
413
|
{
|
|
2453
|
-
value:
|
|
2454
|
-
onValueChange: (
|
|
414
|
+
value: v("role") || "USER",
|
|
415
|
+
onValueChange: (n) => g("role", n),
|
|
2455
416
|
children: [
|
|
2456
|
-
/* @__PURE__ */
|
|
2457
|
-
/* @__PURE__ */
|
|
2458
|
-
/* @__PURE__ */
|
|
2459
|
-
/* @__PURE__ */
|
|
2460
|
-
/* @__PURE__ */
|
|
417
|
+
/* @__PURE__ */ r(ye, { children: /* @__PURE__ */ r(ve, { placeholder: "Select role" }) }),
|
|
418
|
+
/* @__PURE__ */ a(Ne, { children: [
|
|
419
|
+
/* @__PURE__ */ r(I, { value: "USER", children: "User" }),
|
|
420
|
+
/* @__PURE__ */ r(I, { value: "WRITER", children: "Writer" }),
|
|
421
|
+
/* @__PURE__ */ r(I, { value: "ADMIN", children: "Admin" })
|
|
2461
422
|
] })
|
|
2462
423
|
]
|
|
2463
424
|
}
|
|
@@ -2465,762 +426,110 @@ function Ca({
|
|
|
2465
426
|
] })
|
|
2466
427
|
] })
|
|
2467
428
|
] }),
|
|
2468
|
-
/* @__PURE__ */
|
|
429
|
+
/* @__PURE__ */ r(_e, { className: "flex justify-end", children: /* @__PURE__ */ r(G, { type: "submit", disabled: A, size: "lg", children: t(A ? "saving" : "save_changes") }) })
|
|
2469
430
|
] }) })
|
|
2470
431
|
] });
|
|
2471
432
|
}
|
|
2472
|
-
const Is = ({ product: t }) => {
|
|
2473
|
-
const n = ue((S) => S), { t: s } = Z(), { activeCurrencyCode: a, currencies: l, defaultCurrency: c } = le(), [o, m] = k([]), [_, y] = k(!0), [h, p] = k("annual");
|
|
2474
|
-
if (G(() => {
|
|
2475
|
-
async function S() {
|
|
2476
|
-
try {
|
|
2477
|
-
if (!t.id) return;
|
|
2478
|
-
const i = await ls(t.id);
|
|
2479
|
-
m(i);
|
|
2480
|
-
} catch (i) {
|
|
2481
|
-
console.error("Failed to load pricing:", i);
|
|
2482
|
-
} finally {
|
|
2483
|
-
y(!1);
|
|
2484
|
-
}
|
|
2485
|
-
}
|
|
2486
|
-
S();
|
|
2487
|
-
}, [t.id]), !n)
|
|
2488
|
-
return /* @__PURE__ */ e($t, { className: "h-14 w-full" });
|
|
2489
|
-
const { addItem: f } = n, b = o[0], d = b?.pricing?.[0], E = () => {
|
|
2490
|
-
let S = t.price, i = t.freemius_plan_id;
|
|
2491
|
-
d && (h === "monthly" && d.monthly_price != null && (S = me(d.monthly_price, c.code)), h === "annual" && d.annual_price != null && (S = me(d.annual_price, c.code)), h === "lifetime" && d.lifetime_price != null && (S = me(d.lifetime_price, c.code)));
|
|
2492
|
-
const $ = l.reduce((C, X) => (C[X.code] = je({
|
|
2493
|
-
amount: S,
|
|
2494
|
-
fromCurrencyCode: c.code,
|
|
2495
|
-
toCurrencyCode: X.code,
|
|
2496
|
-
currencies: l,
|
|
2497
|
-
applyRounding: !0
|
|
2498
|
-
}), C), {}), q = $[a] ?? S;
|
|
2499
|
-
b && b.id && (i = b.id);
|
|
2500
|
-
const { success: P, error: W } = f({
|
|
2501
|
-
id: t.id,
|
|
2502
|
-
product_id: t.id,
|
|
2503
|
-
title: t.title,
|
|
2504
|
-
price: q,
|
|
2505
|
-
prices: $,
|
|
2506
|
-
image_url: t.image_url,
|
|
2507
|
-
slug: t.slug,
|
|
2508
|
-
sku: t.sku,
|
|
2509
|
-
language_id: t.language_id,
|
|
2510
|
-
translation_group_id: t.translation_group_id,
|
|
2511
|
-
product_type: "digital",
|
|
2512
|
-
payment_provider: "freemius",
|
|
2513
|
-
provider: "freemius",
|
|
2514
|
-
billing_cycle: h,
|
|
2515
|
-
freemius_product_id: t.freemius_product_id,
|
|
2516
|
-
freemius_plan_id: i,
|
|
2517
|
-
// Overwrite if we got a real plan id
|
|
2518
|
-
trial_period_days: t.trial_period_days ?? 0,
|
|
2519
|
-
trial_requires_payment_method: t.trial_requires_payment_method ?? !1,
|
|
2520
|
-
is_taxable: t.is_taxable,
|
|
2521
|
-
currency_code: a
|
|
2522
|
-
});
|
|
2523
|
-
P ? He.success(s("ecommerce.added_to_cart_success", { item: t.title })) : He.error(W || s("ecommerce.added_to_cart_error"));
|
|
2524
|
-
};
|
|
2525
|
-
if (_)
|
|
2526
|
-
return /* @__PURE__ */ e($t, { className: "h-32 w-full" });
|
|
2527
|
-
if (!b || !d)
|
|
2528
|
-
return /* @__PURE__ */ e("div", { className: "p-4 border border-dashed rounded-lg text-center text-muted-foreground", children: s("ecommerce.pricing_unavailable") });
|
|
2529
|
-
const v = d.monthly_price != null, F = d.annual_price != null, j = d.lifetime_price != null;
|
|
2530
|
-
h === "annual" && !F && (v ? p("monthly") : j && p("lifetime"));
|
|
2531
|
-
const R = pe(t);
|
|
2532
|
-
let L = t.price;
|
|
2533
|
-
return h === "monthly" && d.monthly_price != null && (L = je({
|
|
2534
|
-
amount: me(d.monthly_price, c.code),
|
|
2535
|
-
fromCurrencyCode: c.code,
|
|
2536
|
-
toCurrencyCode: a,
|
|
2537
|
-
currencies: l,
|
|
2538
|
-
applyRounding: !0
|
|
2539
|
-
})), h === "annual" && d.annual_price != null && (L = je({
|
|
2540
|
-
amount: me(d.annual_price, c.code),
|
|
2541
|
-
fromCurrencyCode: c.code,
|
|
2542
|
-
toCurrencyCode: a,
|
|
2543
|
-
currencies: l,
|
|
2544
|
-
applyRounding: !0
|
|
2545
|
-
})), h === "lifetime" && d.lifetime_price != null && (L = je({
|
|
2546
|
-
amount: me(d.lifetime_price, c.code),
|
|
2547
|
-
fromCurrencyCode: c.code,
|
|
2548
|
-
toCurrencyCode: a,
|
|
2549
|
-
currencies: l,
|
|
2550
|
-
applyRounding: !0
|
|
2551
|
-
})), /* @__PURE__ */ r("div", { className: "flex flex-col gap-4", children: [
|
|
2552
|
-
/* @__PURE__ */ r("div", { className: "flex bg-secondary/35 p-1 rounded-lg w-full max-w-sm mx-auto shadow-inner", children: [
|
|
2553
|
-
v && /* @__PURE__ */ e(
|
|
2554
|
-
"button",
|
|
2555
|
-
{
|
|
2556
|
-
onClick: () => p("monthly"),
|
|
2557
|
-
className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${h === "monthly" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
|
|
2558
|
-
children: s("ecommerce.monthly")
|
|
2559
|
-
}
|
|
2560
|
-
),
|
|
2561
|
-
F && /* @__PURE__ */ e(
|
|
2562
|
-
"button",
|
|
2563
|
-
{
|
|
2564
|
-
onClick: () => p("annual"),
|
|
2565
|
-
className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${h === "annual" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
|
|
2566
|
-
children: s("ecommerce.annual")
|
|
2567
|
-
}
|
|
2568
|
-
),
|
|
2569
|
-
j && /* @__PURE__ */ e(
|
|
2570
|
-
"button",
|
|
2571
|
-
{
|
|
2572
|
-
onClick: () => p("lifetime"),
|
|
2573
|
-
className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${h === "lifetime" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
|
|
2574
|
-
children: s("ecommerce.lifetime")
|
|
2575
|
-
}
|
|
2576
|
-
)
|
|
2577
|
-
] }),
|
|
2578
|
-
/* @__PURE__ */ r("div", { className: "text-center", children: [
|
|
2579
|
-
/* @__PURE__ */ e("span", { className: "text-3xl font-extrabold text-foreground", children: w(L, a) }),
|
|
2580
|
-
h !== "lifetime" && /* @__PURE__ */ r("span", { className: "text-muted-foreground text-sm ml-1.5", children: [
|
|
2581
|
-
"/ ",
|
|
2582
|
-
s(h === "annual" ? "ecommerce.year" : "ecommerce.month")
|
|
2583
|
-
] }),
|
|
2584
|
-
R && /* @__PURE__ */ r("div", { className: "mt-1 text-xs font-medium text-emerald-600 dark:text-emerald-400", children: [
|
|
2585
|
-
R.label,
|
|
2586
|
-
/* @__PURE__ */ e("span", { className: "mx-2 text-muted-foreground/50", children: "|" }),
|
|
2587
|
-
/* @__PURE__ */ e("span", { className: "text-muted-foreground", children: R.paymentRequirementLabel })
|
|
2588
|
-
] })
|
|
2589
|
-
] }),
|
|
2590
|
-
/* @__PURE__ */ r(D, { onClick: E, className: "w-full h-12 text-md font-bold shadow-md transition-all hover:shadow-lg active:scale-[0.98]", children: [
|
|
2591
|
-
/* @__PURE__ */ e(nt, { className: "mr-2 h-4 w-4" }),
|
|
2592
|
-
R?.label ? `Start ${R.label}` : s("ecommerce.get_license")
|
|
2593
|
-
] })
|
|
2594
|
-
] });
|
|
2595
|
-
}, js = (t, n) => n.reduce((s, a) => {
|
|
2596
|
-
switch (a.type) {
|
|
2597
|
-
case "bold":
|
|
2598
|
-
return /* @__PURE__ */ e("strong", { children: s });
|
|
2599
|
-
case "italic":
|
|
2600
|
-
return /* @__PURE__ */ e("em", { children: s });
|
|
2601
|
-
case "underline":
|
|
2602
|
-
case "u":
|
|
2603
|
-
return /* @__PURE__ */ e("u", { children: s });
|
|
2604
|
-
case "strike":
|
|
2605
|
-
return /* @__PURE__ */ e("s", { children: s });
|
|
2606
|
-
case "code":
|
|
2607
|
-
return /* @__PURE__ */ e("code", { className: "bg-muted px-1.5 py-0.5 rounded text-[0.875em] font-mono", children: s });
|
|
2608
|
-
case "link": {
|
|
2609
|
-
const l = a.attrs?.href || "#", c = a.attrs?.target || "_blank";
|
|
2610
|
-
return /* @__PURE__ */ e("a", { href: l, target: c, rel: "noopener noreferrer", className: "underline text-primary hover:text-primary/80", children: s });
|
|
2611
|
-
}
|
|
2612
|
-
case "highlight": {
|
|
2613
|
-
const l = a.attrs?.color;
|
|
2614
|
-
return /* @__PURE__ */ e("mark", { style: l ? { backgroundColor: l } : {}, className: l ? void 0 : "bg-yellow-200 dark:bg-yellow-800/50", children: s });
|
|
2615
|
-
}
|
|
2616
|
-
case "subscript":
|
|
2617
|
-
return /* @__PURE__ */ e("sub", { children: s });
|
|
2618
|
-
case "superscript":
|
|
2619
|
-
return /* @__PURE__ */ e("sup", { children: s });
|
|
2620
|
-
case "textStyle": {
|
|
2621
|
-
const l = {};
|
|
2622
|
-
return a.attrs?.color && (l.color = a.attrs.color), a.attrs?.fontSize && (l.fontSize = a.attrs.fontSize), a.attrs?.fontFamily && (l.fontFamily = a.attrs.fontFamily), Object.keys(l).length > 0 ? /* @__PURE__ */ e("span", { style: l, children: s }) : /* @__PURE__ */ e(ot, { children: s });
|
|
2623
|
-
}
|
|
2624
|
-
default:
|
|
2625
|
-
return s;
|
|
2626
|
-
}
|
|
2627
|
-
}, t), Os = ["h1", "h2", "h3", "h4", "h5", "h6"], qs = (t, n, s, a) => {
|
|
2628
|
-
const l = Math.max(1, Math.min(6, t)), c = Os[l - 1], o = a?.id;
|
|
2629
|
-
return we.createElement(c, { key: s, className: "font-bold my-4", id: o }, n);
|
|
2630
|
-
}, qt = (t) => {
|
|
2631
|
-
const n = {}, s = {}, a = t?.colspan, l = t?.rowspan, c = t?.colwidth;
|
|
2632
|
-
return a && a > 1 && (n.colSpan = a), l && l > 1 && (n.rowSpan = l), c && Array.isArray(c) && c[0] && (s.minWidth = c[0]), Object.keys(s).length > 0 && (n.style = s), n;
|
|
2633
|
-
}, hr = (t, n) => {
|
|
2634
|
-
if (t.type === "text") {
|
|
2635
|
-
const a = t.text ?? "";
|
|
2636
|
-
return /* @__PURE__ */ e(we.Fragment, { children: t.marks?.length ? js(a, t.marks) : a }, n);
|
|
2637
|
-
}
|
|
2638
|
-
const s = t.content?.map((a, l) => hr(a, l)) ?? null;
|
|
2639
|
-
switch (t.type) {
|
|
2640
|
-
// ── Document ────────────────────────────────────────────────
|
|
2641
|
-
case "doc":
|
|
2642
|
-
return /* @__PURE__ */ e("div", { children: s }, n);
|
|
2643
|
-
// ── Block-level text ────────────────────────────────────────
|
|
2644
|
-
case "paragraph": {
|
|
2645
|
-
if (!t.content?.length || t.content.every(
|
|
2646
|
-
(o) => o.type === "text" && (!o.text || !o.text.trim())
|
|
2647
|
-
)) return null;
|
|
2648
|
-
const l = t.attrs?.textAlign, c = l ? { textAlign: l } : {};
|
|
2649
|
-
return /* @__PURE__ */ e("p", { className: "mb-4", style: Object.keys(c).length ? c : void 0, children: s }, n);
|
|
2650
|
-
}
|
|
2651
|
-
case "heading":
|
|
2652
|
-
return qs(
|
|
2653
|
-
t.attrs?.level || 1,
|
|
2654
|
-
s,
|
|
2655
|
-
n,
|
|
2656
|
-
t.attrs ?? void 0
|
|
2657
|
-
);
|
|
2658
|
-
// ── Lists ───────────────────────────────────────────────────
|
|
2659
|
-
case "bulletList":
|
|
2660
|
-
return /* @__PURE__ */ e("ul", { className: "list-disc pl-5 mb-4", children: s }, n);
|
|
2661
|
-
case "orderedList": {
|
|
2662
|
-
const a = t.attrs?.start ?? 1;
|
|
2663
|
-
return /* @__PURE__ */ e("ol", { className: "list-decimal pl-5 mb-4", start: a !== 1 ? a : void 0, children: s }, n);
|
|
2664
|
-
}
|
|
2665
|
-
case "listItem":
|
|
2666
|
-
return /* @__PURE__ */ e("li", { children: s }, n);
|
|
2667
|
-
case "taskList":
|
|
2668
|
-
return /* @__PURE__ */ e("ul", { className: "list-none pl-0 mb-4 space-y-1", children: s }, n);
|
|
2669
|
-
case "taskItem": {
|
|
2670
|
-
const a = !!t.attrs?.checked;
|
|
2671
|
-
return /* @__PURE__ */ r("li", { className: "flex items-start gap-2", children: [
|
|
2672
|
-
/* @__PURE__ */ e("input", { type: "checkbox", checked: a, readOnly: !0, className: "mt-1.5 rounded" }),
|
|
2673
|
-
/* @__PURE__ */ e("div", { className: a ? "line-through text-muted-foreground" : "", children: s })
|
|
2674
|
-
] }, n);
|
|
2675
|
-
}
|
|
2676
|
-
// ── Quotes & code ───────────────────────────────────────────
|
|
2677
|
-
case "blockquote":
|
|
2678
|
-
return /* @__PURE__ */ e("blockquote", { className: "border-l-4 border-border pl-4 italic my-4", children: s }, n);
|
|
2679
|
-
case "codeBlock": {
|
|
2680
|
-
const a = t.attrs?.language;
|
|
2681
|
-
return /* @__PURE__ */ e("pre", { className: "bg-muted rounded-lg p-4 mb-4 overflow-x-auto", "data-language": a || void 0, children: /* @__PURE__ */ e("code", { className: "text-sm font-mono", children: s }) }, n);
|
|
2682
|
-
}
|
|
2683
|
-
// ── Inline / void ───────────────────────────────────────────
|
|
2684
|
-
case "horizontalRule":
|
|
2685
|
-
return /* @__PURE__ */ e("hr", { className: "my-6 border-border" }, n);
|
|
2686
|
-
case "hardBreak":
|
|
2687
|
-
return /* @__PURE__ */ e("br", {}, n);
|
|
2688
|
-
case "image": {
|
|
2689
|
-
const a = t.attrs?.src, l = t.attrs?.alt || "", c = t.attrs?.title, o = t.attrs?.width, m = t.attrs?.height, _ = {};
|
|
2690
|
-
return o && (_.width = typeof o == "number" ? `${o}px` : o), m && (_.height = typeof m == "number" ? `${m}px` : m), /* @__PURE__ */ e(
|
|
2691
|
-
"img",
|
|
2692
|
-
{
|
|
2693
|
-
src: a,
|
|
2694
|
-
alt: l,
|
|
2695
|
-
title: c,
|
|
2696
|
-
style: Object.keys(_).length ? _ : void 0,
|
|
2697
|
-
className: "max-w-full h-auto rounded my-4"
|
|
2698
|
-
},
|
|
2699
|
-
n
|
|
2700
|
-
);
|
|
2701
|
-
}
|
|
2702
|
-
// ── Table ───────────────────────────────────────────────────
|
|
2703
|
-
case "table":
|
|
2704
|
-
return /* @__PURE__ */ e("div", { className: "overflow-x-auto my-4", children: /* @__PURE__ */ e("table", { className: "w-full border-collapse border border-gray-300 dark:border-gray-700", style: { minWidth: 500 }, children: /* @__PURE__ */ e("tbody", { children: s }) }) }, n);
|
|
2705
|
-
case "tableRow":
|
|
2706
|
-
return /* @__PURE__ */ e("tr", { className: "border-b border-gray-300 dark:border-gray-700", children: s }, n);
|
|
2707
|
-
case "tableHeader":
|
|
2708
|
-
return /* @__PURE__ */ e(
|
|
2709
|
-
"th",
|
|
2710
|
-
{
|
|
2711
|
-
...qt(t.attrs ?? void 0),
|
|
2712
|
-
className: "bg-gray-100 dark:bg-gray-800 font-bold p-3 text-left border border-gray-300 dark:border-gray-700",
|
|
2713
|
-
children: s
|
|
2714
|
-
},
|
|
2715
|
-
n
|
|
2716
|
-
);
|
|
2717
|
-
case "tableCell":
|
|
2718
|
-
return /* @__PURE__ */ e(
|
|
2719
|
-
"td",
|
|
2720
|
-
{
|
|
2721
|
-
...qt(t.attrs ?? void 0),
|
|
2722
|
-
className: "p-3 border border-gray-300 dark:border-gray-700",
|
|
2723
|
-
children: s
|
|
2724
|
-
},
|
|
2725
|
-
n
|
|
2726
|
-
);
|
|
2727
|
-
// ── Details / collapsible ───────────────────────────────────
|
|
2728
|
-
case "details":
|
|
2729
|
-
return /* @__PURE__ */ e("details", { className: "my-4 border rounded-lg overflow-hidden", children: s }, n);
|
|
2730
|
-
case "detailsSummary":
|
|
2731
|
-
return /* @__PURE__ */ e("summary", { className: "cursor-pointer p-3 font-semibold bg-muted/30 hover:bg-muted/50", children: s }, n);
|
|
2732
|
-
case "detailsContent":
|
|
2733
|
-
return /* @__PURE__ */ e("div", { className: "p-3 border-t", children: s }, n);
|
|
2734
|
-
// ── Embeds ──────────────────────────────────────────────────
|
|
2735
|
-
case "youtube": {
|
|
2736
|
-
const a = t.attrs?.src, l = t.attrs?.width || 640, c = t.attrs?.height || 480;
|
|
2737
|
-
return /* @__PURE__ */ e("div", { className: "relative my-4 overflow-hidden rounded-lg", style: { aspectRatio: `${l}/${c}`, maxWidth: l }, children: /* @__PURE__ */ e(
|
|
2738
|
-
"iframe",
|
|
2739
|
-
{
|
|
2740
|
-
src: a,
|
|
2741
|
-
allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
|
|
2742
|
-
allowFullScreen: !0,
|
|
2743
|
-
className: "absolute inset-0 w-full h-full"
|
|
2744
|
-
}
|
|
2745
|
-
) }, n);
|
|
2746
|
-
}
|
|
2747
|
-
case "iframe": {
|
|
2748
|
-
const a = t.attrs?.src;
|
|
2749
|
-
return /* @__PURE__ */ e("div", { className: "my-4 overflow-hidden rounded-lg", style: { aspectRatio: "16/9" }, children: /* @__PURE__ */ e("iframe", { src: a, allowFullScreen: !0, className: "w-full h-full border-0" }) }, n);
|
|
2750
|
-
}
|
|
2751
|
-
// ── Mention ─────────────────────────────────────────────────
|
|
2752
|
-
case "mention": {
|
|
2753
|
-
const a = t.attrs?.label || t.attrs?.id || "";
|
|
2754
|
-
return /* @__PURE__ */ r("span", { className: "text-primary font-medium", children: [
|
|
2755
|
-
"@",
|
|
2756
|
-
a
|
|
2757
|
-
] }, n);
|
|
2758
|
-
}
|
|
2759
|
-
// ── Fallback ────────────────────────────────────────────────
|
|
2760
|
-
default:
|
|
2761
|
-
return /* @__PURE__ */ e("div", { children: s }, n);
|
|
2762
|
-
}
|
|
2763
|
-
}, fr = ({ content: t, className: n }) => {
|
|
2764
|
-
if (!t) return null;
|
|
2765
|
-
if (typeof t == "string") {
|
|
2766
|
-
if (t.trim().startsWith("{") || t.trim().startsWith("["))
|
|
2767
|
-
try {
|
|
2768
|
-
const a = JSON.parse(t);
|
|
2769
|
-
return /* @__PURE__ */ e(fr, { content: a, className: n });
|
|
2770
|
-
} catch {
|
|
2771
|
-
}
|
|
2772
|
-
return /* @__PURE__ */ e("div", { className: n, dangerouslySetInnerHTML: { __html: t } });
|
|
2773
|
-
}
|
|
2774
|
-
const s = t;
|
|
2775
|
-
return !s.content || !Array.isArray(s.content) ? null : /* @__PURE__ */ e("div", { className: n, children: s.content.map((a, l) => hr(a, l)) });
|
|
2776
|
-
}, gr = tr(void 0), wa = ({
|
|
2777
|
-
product: t,
|
|
2778
|
-
children: n
|
|
2779
|
-
}) => /* @__PURE__ */ e(gr.Provider, { value: { product: t }, children: n }), zs = () => {
|
|
2780
|
-
const t = rr(gr);
|
|
2781
|
-
if (!t)
|
|
2782
|
-
throw new Error("useProduct must be used within a ProductProvider. Ensure the component is wrapped in a ProductProvider.");
|
|
2783
|
-
return t.product;
|
|
2784
|
-
};
|
|
2785
|
-
function at(t, n, s, a) {
|
|
2786
|
-
const l = {
|
|
2787
|
-
kind: "product-field",
|
|
2788
|
-
field: n,
|
|
2789
|
-
input: s,
|
|
2790
|
-
label: a
|
|
2791
|
-
}, c = typeof window < "u" ? window.location.origin : process.env.NEXT_PUBLIC_URL || process.env.TARGET_URL || (process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : "") || "http://localhost:3000";
|
|
2792
|
-
let m = (typeof window < "u" ? window.location.origin : process.env.NEXT_PUBLIC_URL || process.env.TARGET_URL || (process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : "") || "http://localhost:3000").replace(/\/+$/, "");
|
|
2793
|
-
try {
|
|
2794
|
-
(m.startsWith("http://") || m.startsWith("https://")) && (m = new URL(m).hostname);
|
|
2795
|
-
} catch {
|
|
2796
|
-
}
|
|
2797
|
-
const _ = process.env.NEXTBLOCK_VERCEL_PROJECT_ID || process.env.VERCEL_PROJECT_ID, y = process.env.NEXTBLOCK_VERCEL_WORKSPACE_ID || process.env.VERCEL_ORG_ID, h = {
|
|
2798
|
-
origin: m,
|
|
2799
|
-
editUrl: `${c}/cms/products/${t.id}/edit`,
|
|
2800
|
-
data: {
|
|
2801
|
-
parentType: "product",
|
|
2802
|
-
parentId: t.id,
|
|
2803
|
-
slug: t.slug,
|
|
2804
|
-
languageId: t.language_id,
|
|
2805
|
-
draftId: null,
|
|
2806
|
-
target: l
|
|
2807
|
-
}
|
|
2808
|
-
};
|
|
2809
|
-
return _ && (h.projectId = _), y && (h.workspaceId = y), {
|
|
2810
|
-
"data-vercel-edit-info": JSON.stringify(h),
|
|
2811
|
-
"data-vercel-edit-target": JSON.stringify(l),
|
|
2812
|
-
"data-nextblock-visual-edit": `product:${n}`
|
|
2813
|
-
};
|
|
2814
|
-
}
|
|
2815
|
-
const ka = ({
|
|
2816
|
-
visualEditingEnabled: t = !1,
|
|
2817
|
-
descriptionNode: n
|
|
2818
|
-
}) => {
|
|
2819
|
-
const s = zs(), { t: a, lang: l } = Z(), { activeCurrencyCode: c, currencies: o } = le(), m = t ? at(
|
|
2820
|
-
s,
|
|
2821
|
-
"title",
|
|
2822
|
-
"plain-text",
|
|
2823
|
-
"Product title"
|
|
2824
|
-
) : void 0, _ = t ? at(
|
|
2825
|
-
s,
|
|
2826
|
-
"short_description",
|
|
2827
|
-
"plain-text",
|
|
2828
|
-
"Short description"
|
|
2829
|
-
) : void 0, y = t ? at(
|
|
2830
|
-
s,
|
|
2831
|
-
"description_json",
|
|
2832
|
-
"tiptap",
|
|
2833
|
-
"Product description"
|
|
2834
|
-
) : void 0, h = (g, ee, x) => {
|
|
2835
|
-
const ne = a(g, x);
|
|
2836
|
-
return ne === g ? ee : ne;
|
|
2837
|
-
}, p = s.images && s.images.length > 0 ? s.images : s.image_url ? [{ url: s.image_url, alt: s.title }] : [], f = s.custom_props?.provider === "freemius" || Yt(s), b = pe(s), d = !f && !!(s.has_variants && s.attributes?.length && s.variants?.length), E = s.attributes || [], v = s.variants || [], [F, j] = k(() => Pt(E, v)), [R, L] = k(1);
|
|
2838
|
-
G(() => {
|
|
2839
|
-
L(1);
|
|
2840
|
-
}, [s.id]), G(() => {
|
|
2841
|
-
d && j(Pt(E, v));
|
|
2842
|
-
}, [E, d, s.id, v]);
|
|
2843
|
-
const S = H(() => d ? At(
|
|
2844
|
-
E,
|
|
2845
|
-
v,
|
|
2846
|
-
F
|
|
2847
|
-
) : F, [E, d, F, v]);
|
|
2848
|
-
G(() => {
|
|
2849
|
-
JSON.stringify(S) !== JSON.stringify(F) && j(S);
|
|
2850
|
-
}, [S, F]);
|
|
2851
|
-
const i = H(() => d ? cs(v, S) : null, [d, S, v]), $ = ke({
|
|
2852
|
-
prices: s.prices,
|
|
2853
|
-
salePrices: s.sale_prices,
|
|
2854
|
-
fallbackPrice: s.price,
|
|
2855
|
-
fallbackSalePrice: s.sale_price,
|
|
2856
|
-
saleStartAt: s.sale_start_at,
|
|
2857
|
-
saleEndAt: s.sale_end_at,
|
|
2858
|
-
scheduledPrice: s.scheduled_price,
|
|
2859
|
-
scheduledPrices: s.scheduled_prices,
|
|
2860
|
-
scheduledPriceAt: s.scheduled_price_at,
|
|
2861
|
-
currencyCode: c,
|
|
2862
|
-
currencies: o
|
|
2863
|
-
}), q = d && i ? ke({
|
|
2864
|
-
prices: i.prices,
|
|
2865
|
-
salePrices: i.sale_prices,
|
|
2866
|
-
fallbackPrice: i.price,
|
|
2867
|
-
fallbackSalePrice: i.sale_price,
|
|
2868
|
-
saleStartAt: i.sale_start_at,
|
|
2869
|
-
saleEndAt: i.sale_end_at,
|
|
2870
|
-
scheduledPrice: i.scheduled_price,
|
|
2871
|
-
scheduledPrices: i.scheduled_prices,
|
|
2872
|
-
scheduledPriceAt: i.scheduled_price_at,
|
|
2873
|
-
currencyCode: c,
|
|
2874
|
-
currencies: o
|
|
2875
|
-
}) : null, P = q?.price ?? $.price, W = q?.sale_price ?? $.sale_price, C = d ? i?.stock_quantity ?? 0 : s.stock ?? 0, X = H(() => {
|
|
2876
|
-
if (!i?.image_url)
|
|
2877
|
-
return p;
|
|
2878
|
-
const g = {
|
|
2879
|
-
url: i.image_url,
|
|
2880
|
-
alt: `${s.title} ${i.label}`
|
|
2881
|
-
}, ee = p.filter(
|
|
2882
|
-
(x) => x.url !== i.image_url
|
|
2883
|
-
);
|
|
2884
|
-
return [g, ...ee];
|
|
2885
|
-
}, [p, s.title, i]), V = typeof W == "number" && P > 0 ? Math.round(
|
|
2886
|
-
(P - W) / P * 100
|
|
2887
|
-
) : 0, B = d && i ? {
|
|
2888
|
-
...s,
|
|
2889
|
-
sku: i.sku,
|
|
2890
|
-
price: i.price,
|
|
2891
|
-
prices: i.prices,
|
|
2892
|
-
sale_price: typeof i.sale_price == "number" ? i.sale_price : null,
|
|
2893
|
-
sale_prices: i.sale_prices,
|
|
2894
|
-
image_url: i.image_url || s.image_url,
|
|
2895
|
-
stock: i.stock_quantity,
|
|
2896
|
-
variant_id: i.id,
|
|
2897
|
-
variant_label: i.label,
|
|
2898
|
-
selected_options: i.selected_options,
|
|
2899
|
-
currency_code: c
|
|
2900
|
-
} : {
|
|
2901
|
-
...s,
|
|
2902
|
-
currency_code: c
|
|
2903
|
-
}, Q = (g, ee) => {
|
|
2904
|
-
j(
|
|
2905
|
-
(x) => At(E, v, {
|
|
2906
|
-
...x,
|
|
2907
|
-
[g]: ee
|
|
2908
|
-
})
|
|
2909
|
-
);
|
|
2910
|
-
}, he = h(
|
|
2911
|
-
"ecommerce.in_stock",
|
|
2912
|
-
`${C} in stock`,
|
|
2913
|
-
{ count: String(C) }
|
|
2914
|
-
), J = h(
|
|
2915
|
-
"ecommerce.out_of_stock",
|
|
2916
|
-
"Out of stock"
|
|
2917
|
-
), Re = h(
|
|
2918
|
-
"ecommerce.select_options",
|
|
2919
|
-
"Select Options"
|
|
2920
|
-
), fe = h(
|
|
2921
|
-
"ecommerce.variant_selection_required",
|
|
2922
|
-
"Select one term from every dropdown to resolve a variation."
|
|
2923
|
-
);
|
|
2924
|
-
return /* @__PURE__ */ r("div", { className: "w-full animate-in fade-in slide-in-from-bottom-4 duration-700 ease-out", children: [
|
|
2925
|
-
/* @__PURE__ */ e("div", { className: "container mx-auto px-4 md:px-6 py-12", children: /* @__PURE__ */ r("div", { className: "grid gap-12 lg:grid-cols-[2fr_3fr] items-start", children: [
|
|
2926
|
-
/* @__PURE__ */ e("div", { className: "w-full max-w-2xl mx-auto lg:max-w-none", children: /* @__PURE__ */ e(Ts, { images: X, className: "w-full" }) }),
|
|
2927
|
-
/* @__PURE__ */ r("div", { className: "flex flex-col gap-4 pb-2 max-w-xl mx-auto lg:mx-0 lg:max-w-none", children: [
|
|
2928
|
-
/* @__PURE__ */ e("div", { className: "space-y-6", children: /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
2929
|
-
/* @__PURE__ */ e(
|
|
2930
|
-
"h1",
|
|
2931
|
-
{
|
|
2932
|
-
className: "text-3xl sm:text-4xl lg:text-5xl font-extrabold tracking-tight text-foreground leading-[1.1] lg:mt-0",
|
|
2933
|
-
...m,
|
|
2934
|
-
children: s.title
|
|
2935
|
-
}
|
|
2936
|
-
),
|
|
2937
|
-
s.categories && s.categories.length > 0 && /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-1.5 text-xs font-bold uppercase tracking-widest text-amber-600 dark:text-amber-400", children: s.categories.map((g, ee) => {
|
|
2938
|
-
const x = er(
|
|
2939
|
-
g.name,
|
|
2940
|
-
g.name_translations,
|
|
2941
|
-
l
|
|
2942
|
-
);
|
|
2943
|
-
return /* @__PURE__ */ r(we.Fragment, { children: [
|
|
2944
|
-
ee > 0 && /* @__PURE__ */ e("span", { className: "text-muted-foreground/30", children: "•" }),
|
|
2945
|
-
/* @__PURE__ */ e("span", { children: x })
|
|
2946
|
-
] }, g.id);
|
|
2947
|
-
}) }),
|
|
2948
|
-
/* @__PURE__ */ e(
|
|
2949
|
-
"div",
|
|
2950
|
-
{
|
|
2951
|
-
className: "prose prose-neutral dark:prose-invert max-w-none text-muted-foreground leading-relaxed text-left",
|
|
2952
|
-
..._,
|
|
2953
|
-
children: s.short_description ? /* @__PURE__ */ e(
|
|
2954
|
-
"div",
|
|
2955
|
-
{
|
|
2956
|
-
className: "text-lg mb-4 leading-relaxed",
|
|
2957
|
-
dangerouslySetInnerHTML: {
|
|
2958
|
-
__html: s.short_description
|
|
2959
|
-
}
|
|
2960
|
-
}
|
|
2961
|
-
) : t ? /* @__PURE__ */ e("p", { className: "text-lg mb-4 italic text-muted-foreground", children: "Add a short product description." }) : null
|
|
2962
|
-
}
|
|
2963
|
-
),
|
|
2964
|
-
/* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
|
|
2965
|
-
typeof W == "number" && /* @__PURE__ */ e(
|
|
2966
|
-
ie,
|
|
2967
|
-
{
|
|
2968
|
-
variant: "destructive",
|
|
2969
|
-
className: "px-2.5 py-1 text-xs font-bold uppercase tracking-wide animate-pulse shadow-sm",
|
|
2970
|
-
children: a("ecommerce.sale_badge", {
|
|
2971
|
-
percent: String(V)
|
|
2972
|
-
})
|
|
2973
|
-
}
|
|
2974
|
-
),
|
|
2975
|
-
!f && C > 0 && C < 10 && /* @__PURE__ */ e(
|
|
2976
|
-
ie,
|
|
2977
|
-
{
|
|
2978
|
-
variant: "outline",
|
|
2979
|
-
className: "text-amber-600 border-amber-200 bg-amber-50",
|
|
2980
|
-
children: a("ecommerce.low_stock", {
|
|
2981
|
-
count: String(C)
|
|
2982
|
-
})
|
|
2983
|
-
}
|
|
2984
|
-
),
|
|
2985
|
-
b && /* @__PURE__ */ e(
|
|
2986
|
-
ie,
|
|
2987
|
-
{
|
|
2988
|
-
variant: "secondary",
|
|
2989
|
-
className: "border border-emerald-200 bg-emerald-50 text-emerald-800",
|
|
2990
|
-
children: b.label
|
|
2991
|
-
}
|
|
2992
|
-
)
|
|
2993
|
-
] })
|
|
2994
|
-
] }) }),
|
|
2995
|
-
/* @__PURE__ */ r("div", { className: "p-5 rounded-2xl bg-card/60 border border-border/80 shadow-md backdrop-blur-md space-y-4", children: [
|
|
2996
|
-
f ? /* @__PURE__ */ e(Is, { product: s }) : /* @__PURE__ */ r("div", { className: "space-y-3.5", children: [
|
|
2997
|
-
/* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-4", children: [
|
|
2998
|
-
/* @__PURE__ */ r("div", { className: "space-y-1", children: [
|
|
2999
|
-
/* @__PURE__ */ e("span", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-widest", children: h("ecommerce.price", "Price") }),
|
|
3000
|
-
/* @__PURE__ */ r("div", { className: "flex items-baseline gap-2.5", children: [
|
|
3001
|
-
/* @__PURE__ */ e("span", { className: "text-3xl font-extrabold text-foreground", children: w(
|
|
3002
|
-
W ?? P,
|
|
3003
|
-
c
|
|
3004
|
-
) }),
|
|
3005
|
-
typeof W == "number" && /* @__PURE__ */ e("span", { className: "text-lg text-muted-foreground line-through decoration-destructive/20 decoration-1", children: w(P, c) })
|
|
3006
|
-
] })
|
|
3007
|
-
] }),
|
|
3008
|
-
!f && (i || !d) && /* @__PURE__ */ r("div", { className: "text-right space-y-1", children: [
|
|
3009
|
-
/* @__PURE__ */ r("span", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-widest block", children: [
|
|
3010
|
-
!d && s.sku && /* @__PURE__ */ r("span", { className: "mr-2 font-normal lowercase normal-case text-muted-foreground/70", children: [
|
|
3011
|
-
"SKU: ",
|
|
3012
|
-
s.sku
|
|
3013
|
-
] }),
|
|
3014
|
-
h("ecommerce.status", "Status")
|
|
3015
|
-
] }),
|
|
3016
|
-
/* @__PURE__ */ e("div", { className: (C ?? 0) > 0 ? "text-emerald-600 dark:text-emerald-400 font-semibold text-sm" : "text-destructive font-semibold text-sm", children: (C ?? 0) > 0 ? he : J })
|
|
3017
|
-
] })
|
|
3018
|
-
] }),
|
|
3019
|
-
d && /* @__PURE__ */ e("div", { className: "space-y-3", children: /* @__PURE__ */ e("div", { className: "grid gap-3 sm:grid-cols-2", children: E.map((g) => {
|
|
3020
|
-
const ee = is(
|
|
3021
|
-
v,
|
|
3022
|
-
g.id,
|
|
3023
|
-
S
|
|
3024
|
-
);
|
|
3025
|
-
return /* @__PURE__ */ r("div", { className: "space-y-1", children: [
|
|
3026
|
-
/* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
|
|
3027
|
-
/* @__PURE__ */ e(
|
|
3028
|
-
A,
|
|
3029
|
-
{
|
|
3030
|
-
htmlFor: `attribute-${g.id}`,
|
|
3031
|
-
className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",
|
|
3032
|
-
children: g.name
|
|
3033
|
-
}
|
|
3034
|
-
),
|
|
3035
|
-
i?.sku && /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground font-mono", children: i.sku })
|
|
3036
|
-
] }),
|
|
3037
|
-
/* @__PURE__ */ e(
|
|
3038
|
-
"select",
|
|
3039
|
-
{
|
|
3040
|
-
id: `attribute-${g.id}`,
|
|
3041
|
-
className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
3042
|
-
value: S[g.id] || "",
|
|
3043
|
-
onChange: (x) => Q(
|
|
3044
|
-
g.id,
|
|
3045
|
-
x.target.value
|
|
3046
|
-
),
|
|
3047
|
-
children: g.terms.map((x) => /* @__PURE__ */ e(
|
|
3048
|
-
"option",
|
|
3049
|
-
{
|
|
3050
|
-
value: x.id,
|
|
3051
|
-
disabled: !ee.has(x.id),
|
|
3052
|
-
children: x.value
|
|
3053
|
-
},
|
|
3054
|
-
x.id
|
|
3055
|
-
))
|
|
3056
|
-
}
|
|
3057
|
-
)
|
|
3058
|
-
] }, g.id);
|
|
3059
|
-
}) }) }),
|
|
3060
|
-
d && !i && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground italic pt-1", children: fe }),
|
|
3061
|
-
/* @__PURE__ */ r("div", { className: "flex items-center gap-3 pt-1", children: [
|
|
3062
|
-
!f && (C ?? 0) > 0 && /* @__PURE__ */ r("div", { className: "flex items-center border rounded-lg h-12 bg-background border-input select-none", children: [
|
|
3063
|
-
/* @__PURE__ */ e(
|
|
3064
|
-
"button",
|
|
3065
|
-
{
|
|
3066
|
-
type: "button",
|
|
3067
|
-
onClick: () => L((g) => Math.max(1, g - 1)),
|
|
3068
|
-
className: "px-3 h-full flex items-center justify-center text-muted-foreground hover:text-foreground active:scale-95 transition-all text-lg font-medium",
|
|
3069
|
-
disabled: R <= 1,
|
|
3070
|
-
children: "-"
|
|
3071
|
-
}
|
|
3072
|
-
),
|
|
3073
|
-
/* @__PURE__ */ e("span", { className: "w-8 text-center text-sm font-semibold", children: R }),
|
|
3074
|
-
/* @__PURE__ */ e(
|
|
3075
|
-
"button",
|
|
3076
|
-
{
|
|
3077
|
-
type: "button",
|
|
3078
|
-
onClick: () => L(
|
|
3079
|
-
(g) => C !== null && g >= C ? g : g + 1
|
|
3080
|
-
),
|
|
3081
|
-
className: "px-3 h-full flex items-center justify-center text-muted-foreground hover:text-foreground active:scale-95 transition-all text-lg font-medium",
|
|
3082
|
-
disabled: C !== null && R >= C,
|
|
3083
|
-
children: "+"
|
|
3084
|
-
}
|
|
3085
|
-
)
|
|
3086
|
-
] }),
|
|
3087
|
-
d && (!i || (C ?? 0) <= 0) ? /* @__PURE__ */ e(
|
|
3088
|
-
D,
|
|
3089
|
-
{
|
|
3090
|
-
disabled: !0,
|
|
3091
|
-
className: "flex-1 h-12 text-md font-bold shadow-md",
|
|
3092
|
-
children: i ? J : Re
|
|
3093
|
-
}
|
|
3094
|
-
) : /* @__PURE__ */ e(
|
|
3095
|
-
ht,
|
|
3096
|
-
{
|
|
3097
|
-
product: B,
|
|
3098
|
-
quantity: R,
|
|
3099
|
-
className: "flex-1 h-12 text-md font-bold shadow-md transition-all hover:shadow-lg active:scale-[0.98]"
|
|
3100
|
-
}
|
|
3101
|
-
)
|
|
3102
|
-
] })
|
|
3103
|
-
] }),
|
|
3104
|
-
/* @__PURE__ */ e(mt, { className: "opacity-60 my-0.5" }),
|
|
3105
|
-
/* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4 text-center text-[11px] font-medium text-muted-foreground pt-1", children: [
|
|
3106
|
-
/* @__PURE__ */ e("div", { className: "flex items-center justify-center gap-2", children: f ? /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
3107
|
-
/* @__PURE__ */ e(Ht, { className: "h-3.5 w-3.5" }),
|
|
3108
|
-
a("ecommerce.instant_digital_delivery")
|
|
3109
|
-
] }) : /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
3110
|
-
/* @__PURE__ */ e(Bt, { className: "h-3.5 w-3.5" }),
|
|
3111
|
-
a("ecommerce.free_shipping")
|
|
3112
|
-
] }) }),
|
|
3113
|
-
/* @__PURE__ */ e("div", { className: "flex items-center justify-center gap-2", children: /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
3114
|
-
/* @__PURE__ */ e(Jr, { className: "h-3.5 w-3.5" }),
|
|
3115
|
-
a("ecommerce.secure_checkout")
|
|
3116
|
-
] }) })
|
|
3117
|
-
] })
|
|
3118
|
-
] })
|
|
3119
|
-
] })
|
|
3120
|
-
] }) }),
|
|
3121
|
-
/* @__PURE__ */ e("div", { className: "min-w-0 w-full", ...n ? void 0 : y, children: n || (s.description_json ? /* @__PURE__ */ e("div", { className: "container mx-auto px-4 md:px-6 pb-12 prose prose-neutral dark:prose-invert max-w-none leading-relaxed", children: /* @__PURE__ */ e(fr, { content: s.description_json }) }) : /* @__PURE__ */ e("div", { className: "container mx-auto px-4 md:px-6 pb-12", children: /* @__PURE__ */ e("p", { className: "italic text-sm text-muted-foreground", children: a("ecommerce.no_description") }) })) })
|
|
3122
|
-
] });
|
|
3123
|
-
};
|
|
3124
433
|
export {
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
$
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
434
|
+
Ie as AccountNavigationMenu,
|
|
435
|
+
hr as AddToCartButton,
|
|
436
|
+
_a as CURRENCY_ROUNDING_MODES,
|
|
437
|
+
sr as Cart,
|
|
438
|
+
ar as CartDrawer,
|
|
439
|
+
or as CartIcon,
|
|
440
|
+
ir as Checkout,
|
|
441
|
+
dr as CouponForm,
|
|
442
|
+
ua as CurrencyProvider,
|
|
443
|
+
ur as CurrencySwitcher,
|
|
444
|
+
Ze as CustomerProfileForm,
|
|
445
|
+
Va as DEFAULT_ENABLED_PAYMENT_PROVIDERS,
|
|
446
|
+
Tr as DEFAULT_INVOICE_SETTINGS,
|
|
447
|
+
Sr as FeaturedProduct,
|
|
448
|
+
Ar as INVOICE_SETTINGS_KEY,
|
|
449
|
+
Rr as InvoiceDocument,
|
|
450
|
+
$r as InvoiceViewerShell,
|
|
451
|
+
_r as ProductCard,
|
|
452
|
+
Lr as ProductCategorySelector,
|
|
453
|
+
yr as ProductDetailsLayout,
|
|
454
|
+
Ur as ProductForm,
|
|
455
|
+
vr as ProductGallery,
|
|
456
|
+
fr as ProductGrid,
|
|
457
|
+
Nr as ProductProvider,
|
|
458
|
+
ra as SimpleTiptapRenderer,
|
|
459
|
+
xr as SubscriptionSelector,
|
|
460
|
+
K as addressesMatch,
|
|
461
|
+
kr as aggregateOrderTaxLines,
|
|
462
|
+
fa as applyCurrencyRounding,
|
|
463
|
+
Ja as buildCombinationKey,
|
|
464
|
+
Or as buildInvoiceDocumentLabels,
|
|
465
|
+
Vr as buildOrderTaxDetailsFromCalculation,
|
|
466
|
+
zr as buildOrderTaxDetailsFromStripeSession,
|
|
467
|
+
Qa as buildVariantLabel,
|
|
468
|
+
Za as chooseInitialVariantSelections,
|
|
469
|
+
ba as convertMinorUnitAmount,
|
|
470
|
+
za as derivePaymentProviderFromProductType,
|
|
471
|
+
ya as describeCurrencyRoundingRule,
|
|
472
|
+
we as emptyCustomerAddress,
|
|
473
|
+
oa as emptyProviderDiscounts,
|
|
474
|
+
et as extractSelectedTermsByAttribute,
|
|
475
|
+
rt as findMatchingVariant,
|
|
476
|
+
Gr as formatInvoiceCurrency,
|
|
477
|
+
Br as formatInvoiceDate,
|
|
478
|
+
at as generateVariantDrafts,
|
|
479
|
+
tt as getAvailableTermIdsForAttribute,
|
|
480
|
+
ta as getCartItemActivePrice,
|
|
481
|
+
ca as getCartLineCouponKey,
|
|
482
|
+
va as getCurrencyLookup,
|
|
483
|
+
Na as getDefaultCurrency,
|
|
484
|
+
xa as getExchangeRateForCurrency,
|
|
485
|
+
Mr as getInvoiceAddressLines,
|
|
486
|
+
jr as getInvoiceLocale,
|
|
487
|
+
Dr as getOrderTaxRateJurisdiction,
|
|
488
|
+
Hr as getOrderTaxRateLabel,
|
|
489
|
+
Kr as getOrderTaxRatePercentage,
|
|
490
|
+
Ga as getProductPaymentProvider,
|
|
491
|
+
Ha as getTrialCheckoutMode,
|
|
492
|
+
Ka as getTrialLabel,
|
|
493
|
+
Wa as getTrialPaymentRequirementLabel,
|
|
494
|
+
qa as getTrialPeriodDays,
|
|
495
|
+
Xa as getTrialSummary,
|
|
496
|
+
st as getVariantEffectivePriceRange,
|
|
497
|
+
Ca as inferCurrencyCodeFromLocale,
|
|
498
|
+
Er as isCustomerAddressComplete,
|
|
499
|
+
Ba as isDigitalItem,
|
|
500
|
+
Ma as isDigitalProduct,
|
|
501
|
+
wa as isSaleWindowActive,
|
|
502
|
+
Sa as isScheduledPriceDue,
|
|
503
|
+
Wr as localizeInvoicePresentationData,
|
|
504
|
+
lt as mapRawVariantRelations,
|
|
505
|
+
da as normalizeCouponCode,
|
|
506
|
+
Pa as normalizeCurrencyRecord,
|
|
507
|
+
Ea as normalizeCurrencyRoundingMode,
|
|
508
|
+
S as normalizeCustomerAddress,
|
|
509
|
+
ja as normalizeEnabledPaymentProviders,
|
|
510
|
+
qr as normalizeInvoiceSettings,
|
|
511
|
+
Fr as normalizeOrderCustomerDetails,
|
|
512
|
+
Xr as normalizeOrderTaxDetails,
|
|
513
|
+
Fa as normalizePriceMap,
|
|
514
|
+
Ia as normalizeSalePriceMap,
|
|
515
|
+
it as normalizeSelectionsToAvailableVariants,
|
|
516
|
+
Yr as productSchema,
|
|
517
|
+
nt as resolveAttributeName,
|
|
518
|
+
Ta as resolveEffectivePriceForCurrency,
|
|
519
|
+
Aa as resolvePriceForCurrency,
|
|
520
|
+
Ra as resolvePriceRangeForCurrency,
|
|
521
|
+
ot as resolveTermValue,
|
|
522
|
+
ct as resolveTranslatedText,
|
|
523
|
+
Jr as serializeInvoiceSettings,
|
|
524
|
+
$a as sortCurrencies,
|
|
525
|
+
Qr as translateOrFallback,
|
|
526
|
+
Zr as translateOrderStatus,
|
|
527
|
+
Ua as useCart,
|
|
528
|
+
sa as useCartStore,
|
|
529
|
+
la as useCartSubtotal,
|
|
530
|
+
ia as useCartTotalItems,
|
|
531
|
+
pa as useCurrency,
|
|
532
|
+
ha as useCurrencyPreferenceStore,
|
|
533
|
+
ka as useIsCartHydrated,
|
|
534
|
+
Cr as useProduct
|
|
3226
535
|
};
|