@loczer/storefront-sdk 0.191.0 → 0.192.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/StorefrontProvider.d.ts +9 -0
  2. package/dist/StorefrontProvider.d.ts.map +1 -1
  3. package/dist/chunks/pkg/booking-engine/dist/models/{Product.shared-IYOeC3N7.js → Product.shared-cjcvMCMa.js} +4 -2
  4. package/dist/chunks/pkg/booking-engine/dist/schemas/{base-asset-zsUj5_3O.js → base-asset-CsOe0vXi.js} +1 -1
  5. package/dist/chunks/pkg/booking-engine/dist/schemas/{base-booking-TzCge_mR.js → base-booking-Sjsqh31e.js} +28 -23
  6. package/dist/chunks/pkg/booking-engine/dist/schemas/{base-product-DvFFzAcg.js → base-product-C_ATjuc6.js} +1 -1
  7. package/dist/chunks/pkg/booking-engine/dist/schemas/{cart-inputs-B0HpcFe5.js → cart-inputs-D1_Wmkca.js} +11 -0
  8. package/dist/chunks/pkg/booking-engine/dist/schemas/insurance-B01h642r.js +67 -0
  9. package/dist/chunks/pkg/booking-engine/dist/schemas-D_yUBLa0.js +14 -0
  10. package/dist/components/ContractSaleDocument/Invoice.d.ts.map +1 -1
  11. package/dist/components/ContractSaleDocument/Invoice.js +106 -106
  12. package/dist/components/ContractSaleDocument/InvoiceDetails.d.ts.map +1 -1
  13. package/dist/components/ContractSaleDocument/InvoiceDetails.js +33 -24
  14. package/dist/i18n/en.d.ts +11 -0
  15. package/dist/i18n/en.d.ts.map +1 -1
  16. package/dist/i18n/en.js +11 -0
  17. package/dist/i18n/fr.d.ts +11 -0
  18. package/dist/i18n/fr.d.ts.map +1 -1
  19. package/dist/i18n/fr.js +11 -0
  20. package/dist/index.d.ts +193 -3
  21. package/dist/index.js +66 -65
  22. package/dist/lib/booking.js +2 -2
  23. package/dist/lib/checkoutSubmit.d.ts +8 -2
  24. package/dist/lib/checkoutSubmit.d.ts.map +1 -1
  25. package/dist/lib/checkoutSubmit.js +13 -4
  26. package/dist/lib/checkoutVerifyCoupon.d.ts +3 -0
  27. package/dist/lib/checkoutVerifyCoupon.d.ts.map +1 -1
  28. package/dist/lib/checkoutVerifyCoupon.js +4 -1
  29. package/dist/lib/contractSaleDocument.d.ts +4 -0
  30. package/dist/lib/contractSaleDocument.d.ts.map +1 -1
  31. package/dist/lib/contractSaleDocument.js +3 -1
  32. package/dist/lib/contractSaleDocumentApi.d.ts +6 -0
  33. package/dist/lib/contractSaleDocumentApi.d.ts.map +1 -1
  34. package/dist/lib/storefrontProducts.d.ts +3 -0
  35. package/dist/lib/storefrontProducts.d.ts.map +1 -1
  36. package/dist/lib/storefrontProducts.js +2 -1
  37. package/dist/pages/CheckoutPage.d.ts.map +1 -1
  38. package/dist/pages/CheckoutPage.js +264 -237
  39. package/dist/pages/ContractSaleDocumentPage.d.ts +2 -0
  40. package/dist/pages/ContractSaleDocumentPage.d.ts.map +1 -1
  41. package/dist/pages/checkout/components/CheckoutDetailsCard.d.ts.map +1 -1
  42. package/dist/pages/checkout/components/CheckoutDetailsCard.js +17 -3
  43. package/dist/pages/checkout/components/CheckoutInsuranceCard.d.ts +12 -0
  44. package/dist/pages/checkout/components/CheckoutInsuranceCard.d.ts.map +1 -0
  45. package/dist/pages/checkout/components/CheckoutInsuranceCard.js +53 -0
  46. package/dist/pages/checkout/components/CheckoutPaymentSummaryCard.d.ts +2 -1
  47. package/dist/pages/checkout/components/CheckoutPaymentSummaryCard.d.ts.map +1 -1
  48. package/dist/pages/checkout/components/CheckoutPaymentSummaryCard.js +47 -30
  49. package/dist/pages/checkout/types.d.ts +2 -1
  50. package/dist/pages/checkout/types.d.ts.map +1 -1
  51. package/dist/pages/checkout/types.js +2 -1
  52. package/dist/storefront.css +1 -1
  53. package/dist/storefrontSchemas.d.ts +6 -0
  54. package/dist/storefrontSchemas.d.ts.map +1 -1
  55. package/dist/storefrontSchemas.js +5 -2
  56. package/package.json +1 -1
  57. package/dist/chunks/pkg/booking-engine/dist/schemas-BNUzqsci.js +0 -13
@@ -1,28 +1,29 @@
1
- import { applyBookingParamsToSearch as e, getBookingDurationLabel as t, getBookingDurationMinutes as n, getBookingParamsFromSearch as r, resolveBookingSearchParamsFromSessionStorage as i, writeBookingSearchParamsToSessionStorage as a } from "../lib/booking.js";
2
- import { useStorefrontCart as ee } from "../lib/cart.js";
3
- import { buildStorefrontCartSummary as te } from "../lib/cartSummary.js";
4
- import { ROUTE as ne, responseSchema as re } from "../lib/checkoutPaymentDecision.js";
5
- import { ROUTE as ie, responseSchema as ae } from "../lib/checkoutSubmit.js";
6
- import { ROUTE as oe, buildStorefrontAvailabilityKey as se, getStorefrontAvailabilityIssue as ce, getValidStorefrontAvailabilitySchedule as le, responseSchema as ue } from "../lib/storefrontAvailability.js";
7
- import { Button as de } from "../ui/button.js";
8
- import { BookingFlowSteps as fe } from "../components/BookingFlowSteps/index.js";
9
- import { useStorefront as pe, useStorefrontProducts as me } from "../StorefrontProvider.js";
10
- import { apiPost as o } from "../lib/apiCall.js";
11
- import { FulfillmentSection as he } from "../components/FulfillmentSection/index.js";
12
- import { ROUTE as ge, responseSchema as _e } from "../lib/checkoutVerifyCoupon.js";
13
- import { CheckoutDetailsCard as ve } from "./checkout/components/CheckoutDetailsCard.js";
14
- import { CheckoutPaymentSummaryCard as ye } from "./checkout/components/CheckoutPaymentSummaryCard.js";
15
- import { CheckoutSummaryColumn as be } from "./checkout/components/CheckoutSummaryColumn.js";
16
- import { checkoutFormSchema as xe } from "./checkout/types.js";
17
- import { useEffect as s, useMemo as c, useState as l } from "react";
18
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
19
- import { toast as f } from "@rpcbase/client";
20
- import { Link as Se, useNavigate as Ce, useParams as we, useSearchParams as Te } from "@rpcbase/router";
21
- import { useTranslation as Ee } from "react-i18next";
22
- import { ArrowLeft as De } from "lucide-react";
23
- import { useForm as Oe, zodResolver as ke } from "@rpcbase/form";
1
+ import { applyBookingParamsToSearch as e, getBookingDurationLabel as t, getBookingDurationMinutes as n, getBookingParamsFromSearch as r, resolveBookingSearchParamsFromSessionStorage as i, writeBookingSearchParamsToSessionStorage as ee } from "../lib/booking.js";
2
+ import { useStorefrontCart as te } from "../lib/cart.js";
3
+ import { buildStorefrontCartSummary as ne } from "../lib/cartSummary.js";
4
+ import { ROUTE as re, responseSchema as ie } from "../lib/checkoutPaymentDecision.js";
5
+ import { ROUTE as ae, responseSchema as oe } from "../lib/checkoutSubmit.js";
6
+ import { ROUTE as se, buildStorefrontAvailabilityKey as ce, getStorefrontAvailabilityIssue as le, getValidStorefrontAvailabilitySchedule as ue, responseSchema as de } from "../lib/storefrontAvailability.js";
7
+ import { Button as fe } from "../ui/button.js";
8
+ import { BookingFlowSteps as pe } from "../components/BookingFlowSteps/index.js";
9
+ import { useStorefront as me, useStorefrontProducts as he } from "../StorefrontProvider.js";
10
+ import { apiPost as a } from "../lib/apiCall.js";
11
+ import { FulfillmentSection as ge } from "../components/FulfillmentSection/index.js";
12
+ import { ROUTE as _e, responseSchema as ve } from "../lib/checkoutVerifyCoupon.js";
13
+ import { CheckoutDetailsCard as ye } from "./checkout/components/CheckoutDetailsCard.js";
14
+ import { CheckoutPaymentSummaryCard as be } from "./checkout/components/CheckoutPaymentSummaryCard.js";
15
+ import { CheckoutInsuranceCard as xe } from "./checkout/components/CheckoutInsuranceCard.js";
16
+ import { CheckoutSummaryColumn as Se } from "./checkout/components/CheckoutSummaryColumn.js";
17
+ import { checkoutFormSchema as Ce } from "./checkout/types.js";
18
+ import { useEffect as o, useMemo as s, useState as c } from "react";
19
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
20
+ import { toast as we } from "@rpcbase/client";
21
+ import { Link as Te, useNavigate as Ee, useParams as De, useSearchParams as Oe } from "@rpcbase/router";
22
+ import { useTranslation as ke } from "react-i18next";
23
+ import { ArrowLeft as Ae } from "lucide-react";
24
+ import { useForm as je, zodResolver as Me } from "@rpcbase/form";
24
25
  //#region src/pages/CheckoutPage.tsx
25
- var Ae = .2, je = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), p = (e, t, n) => {
26
+ var Ne = .2, Pe = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), d = (e, t, n) => {
26
27
  try {
27
28
  return new Intl.NumberFormat(n, {
28
29
  style: "currency",
@@ -31,7 +32,7 @@ var Ae = .2, je = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), p = (e,
31
32
  } catch {
32
33
  return `${(e / 100).toFixed(2)} ${t.toUpperCase()}`;
33
34
  }
34
- }, Me = (e, t) => {
35
+ }, Fe = (e, t) => {
35
36
  try {
36
37
  return new Intl.NumberFormat(t, {
37
38
  style: "percent",
@@ -41,7 +42,7 @@ var Ae = .2, je = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), p = (e,
41
42
  } catch {
42
43
  return `${Math.round(e * 100)}%`;
43
44
  }
44
- }, Ne = (e, t, n) => {
45
+ }, Ie = (e, t, n) => {
45
46
  let r = {
46
47
  dateStyle: "medium",
47
48
  timeStyle: "short"
@@ -54,390 +55,416 @@ var Ae = .2, je = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), p = (e,
54
55
  } catch {}
55
56
  return new Intl.DateTimeFormat(t, r).format(e);
56
57
  };
57
- function m() {
58
- let { t: m, i18n: h } = Ee(), { storefrontConfiguration: g } = pe(), Pe = g.workspace?.workspaceLanguage, { bikes: Fe, accessories: Ie } = me(), { storeSlug: _ } = we(), [v, Le] = Te(), Re = Ce(), { items: ze, itemCount: Be, setQuantity: Ve, removeItem: He, clear: Ue } = ee(), [y, We] = l(!1), [b, x] = l(null), [Ge, S] = l(!1), [Ke, C] = l(null), qe = v.get("coupon") ?? v.get("code") ?? "", [Je, w] = l(qe), [Ye, Xe] = l(qe.trim()), [T, E] = l(null), [Ze, D] = l(null), [Qe, O] = l(!1), [$e, k] = l(null), [et, A] = l(null), [j, tt] = l(!1), M = c(() => i(v, _), [v, _]), N = g.settings.fulfillmentModes.includes("delivery"), P = g.settings.deliveryDisabledReason.trim(), nt = N || P.length > 0, rt = g.shop.address?.trim() ?? "", F = c(() => {
59
- let e = r(M, {
58
+ function f() {
59
+ let { t: f, i18n: p } = ke(), { storefrontConfiguration: m } = me(), Le = m.workspace?.workspaceLanguage, { bikes: Re, accessories: ze } = he(), { storeSlug: h } = De(), [g, Be] = Oe(), Ve = Ee(), { items: He, itemCount: Ue, setQuantity: We, removeItem: Ge, clear: Ke } = te(), [_, qe] = c(!1), [v, y] = c(null), [Je, b] = c(!1), [Ye, x] = c(null), Xe = g.get("coupon") ?? g.get("code") ?? "", [Ze, S] = c(Xe), [Qe, $e] = c(Xe.trim()), [C, w] = c(null), [T, E] = c(null), [et, tt] = c(!1), [nt, D] = c(null), [rt, O] = c(null), [k, it] = c(!1), [A, at] = c(!1), ot = s(() => i(g, h), [g, h]), j = m.settings.fulfillmentModes.includes("delivery"), st = m.settings.deliveryDisabledReason.trim(), ct = j || st.length > 0, lt = m.shop.address?.trim() ?? "", M = s(() => {
60
+ let e = r(ot, {
60
61
  start_time: "",
61
62
  end_time: ""
62
63
  });
63
- return e.fulfillment === "delivery" && !N ? {
64
+ return e.fulfillment === "delivery" && !j ? {
64
65
  ...e,
65
66
  fulfillment: "pickup"
66
67
  } : e;
67
- }, [M, N]), I = c(() => le(F), [F]), it = c(() => t(F), [F]), at = c(() => n(F), [F]), ot = c(() => je(at), [at]), L = c(() => te({
68
- items: ze,
69
- language: h.language,
70
- fallbackLanguage: Pe,
68
+ }, [ot, j]), N = s(() => ue(M), [M]), ut = s(() => t(M), [M]), dt = s(() => n(M), [M]), ft = s(() => Pe(dt), [dt]), P = s(() => ne({
69
+ items: He,
70
+ language: p.language,
71
+ fallbackLanguage: Le,
71
72
  products: {
72
- bikes: Fe,
73
- accessories: Ie
73
+ bikes: Re,
74
+ accessories: ze
74
75
  },
75
- estimatedDays: ot
76
+ estimatedDays: ft
76
77
  }), [
77
- Ie,
78
- Fe,
79
- ot,
80
- h.language,
81
78
  ze,
82
- Pe
83
- ]), R = c(() => L.lines.map((e) => ({
79
+ Re,
80
+ ft,
81
+ p.language,
82
+ He,
83
+ Le
84
+ ]), F = s(() => P.lines.map((e) => ({
84
85
  productId: e.checkoutProductId,
85
86
  productVariantId: e.productVariantId,
86
87
  quantity: e.quantity
87
- })), [L.lines]), [st, z] = l([]), [B, V] = l(!1);
88
- s(() => {
89
- if (!_ || R.length === 0) {
90
- z([]), V(!1);
88
+ })), [P.lines]), [pt, I] = c([]), [L, R] = c(!1);
89
+ o(() => {
90
+ if (!h || F.length === 0) {
91
+ I([]), R(!1);
91
92
  return;
92
93
  }
93
- if (!I) {
94
- z([]), V(!1);
94
+ if (!N) {
95
+ I([]), R(!1);
95
96
  return;
96
97
  }
97
98
  let e = !1;
98
- return V(!0), z([]), (async () => {
99
+ return R(!0), I([]), (async () => {
99
100
  try {
100
- let t = await o(oe, {
101
- storeSlug: _,
102
- schedule: I,
103
- products: R
104
- }), n = ue.parse(t);
101
+ let t = await a(se, {
102
+ storeSlug: h,
103
+ schedule: N,
104
+ products: F
105
+ }), n = de.parse(t);
105
106
  if (e) return;
106
- z(n.success ? n.availability ?? [] : []);
107
+ I(n.success ? n.availability ?? [] : []);
107
108
  } catch (t) {
108
109
  if (e) return;
109
- console.error("Failed to load checkout cart availability", t), z([]);
110
+ console.error("Failed to load checkout cart availability", t), I([]);
110
111
  } finally {
111
- e || V(!1);
112
+ e || R(!1);
112
113
  }
113
114
  })(), () => {
114
115
  e = !0;
115
116
  };
116
117
  }, [
117
- F.end_date,
118
- F.end_time,
119
- F.start_date,
120
- F.start_time,
121
- I,
122
- R,
123
- _
118
+ M.end_date,
119
+ M.end_time,
120
+ M.start_date,
121
+ M.start_time,
122
+ N,
123
+ F,
124
+ h
124
125
  ]);
125
- let ct = c(() => new Map(st.map((e) => [se(e.productId, e.productVariantId), e])), [st]), H = c(() => ({
126
- ...L,
127
- lines: L.lines.map((e) => {
128
- let t = ct.get(se(e.checkoutProductId, e.productVariantId)), n = t ? ce(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
126
+ let mt = s(() => new Map(pt.map((e) => [ce(e.productId, e.productVariantId), e])), [pt]), z = s(() => ({
127
+ ...P,
128
+ lines: P.lines.map((e) => {
129
+ let t = mt.get(ce(e.checkoutProductId, e.productVariantId)), n = t ? le(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
129
130
  return {
130
131
  ...e,
131
- insufficientCapacity: !B && n !== void 0,
132
- availabilityIssue: B ? void 0 : n
132
+ insufficientCapacity: !L && n !== void 0,
133
+ availabilityIssue: L ? void 0 : n
133
134
  };
134
135
  })
135
136
  }), [
136
- ct,
137
- B,
138
- L
139
- ]), U = c(() => L.lines.map((e) => ({
137
+ mt,
138
+ L,
139
+ P
140
+ ]), B = s(() => P.lines.map((e) => ({
140
141
  kind: e.kind,
141
142
  productId: e.checkoutProductId,
142
143
  productVariantId: e.productVariantId,
143
144
  quantity: e.quantity
144
- })), [L.lines]), lt = L.estimatedTotalMinor ?? L.totalPerDayMinor, W = Ze?.totalMinor ?? lt, G = T?.discountAmountMinor ?? 0, K = e(new URLSearchParams(), F).toString(), q = `/${_ ?? ""}/booking${K ? `?${K}` : ""}`, ut = `/${_ ?? ""}/checkout${K ? `?${K}` : ""}`, dt = Oe({
145
- resolver: ke(xe),
145
+ })), [P.lines]), ht = new Map(Re.map((e) => [e.checkoutProductId?.trim() || e.id, e])), V = P.lines.flatMap((e) => {
146
+ let t = ht.get(e.checkoutProductId);
147
+ return t?.insurance?.enabled ? [{
148
+ quantity: e.quantity,
149
+ pricePerDayMinor: t.insurance.pricePerDayMinor,
150
+ deductibleAmountMinor: t.insurance.deductibleAmountMinor
151
+ }] : [];
152
+ }), H = m.modules?.insurance?.enabled === !0 && V.length > 0, U = H && A, gt = V.reduce((e, t) => e + t.pricePerDayMinor * t.quantity, 0), _t = V.reduce((e, t) => Math.max(e, t.deductibleAmountMinor), 0), vt = P.estimatedTotalMinor ?? P.totalPerDayMinor, W = T?.totalMinor ?? vt, G = C?.discountAmountMinor ?? 0, K = e(new URLSearchParams(), M).toString(), q = `/${h ?? ""}/booking${K ? `?${K}` : ""}`, yt = `/${h ?? ""}/checkout${K ? `?${K}` : ""}`, bt = je({
153
+ resolver: Me(Ce),
146
154
  defaultValues: {
147
- full_name: "",
155
+ first_name: "",
156
+ last_name: "",
148
157
  email: "",
149
158
  phone: "",
150
159
  notes: ""
151
160
  }
152
161
  });
153
- s(() => {
154
- a(_, F);
155
- }, [F, _]);
162
+ o(() => {
163
+ ee(h, M);
164
+ }, [M, h]), o(() => {
165
+ !H && A && at(!1);
166
+ }, [A, H]);
156
167
  let J = (t) => {
157
168
  let n = {
158
- ...F,
169
+ ...M,
159
170
  ...t
160
- }, r = e(v, n);
161
- Le(r, { replace: !0 }), a(_, r);
171
+ }, r = e(g, n);
172
+ Be(r, { replace: !0 }), ee(h, r);
162
173
  };
163
- s(() => {
164
- if (!_ || U.length === 0 || !I) {
165
- E(null), D(null), O(!1), k(null), A(null);
174
+ o(() => {
175
+ if (!h || B.length === 0 || !N) {
176
+ w(null), E(null), tt(!1), D(null), O(null);
166
177
  return;
167
178
  }
168
- let e = Ye.trim(), t = e.length === 0 && !j, n = !1;
169
- return O(!0), A(null), k(null), (async () => {
179
+ let e = Qe.trim(), t = e.length === 0 && !k, n = !1;
180
+ return tt(!0), O(null), D(null), (async () => {
170
181
  try {
171
- let r = await o(ge, {
172
- storeSlug: _,
173
- schedule: I,
174
- items: U,
182
+ let r = await a(_e, {
183
+ storeSlug: h,
184
+ schedule: N,
185
+ items: B,
175
186
  couponCode: e || void 0,
176
- includeAutoApply: t
177
- }), i = _e.parse(r);
187
+ includeAutoApply: t,
188
+ insuranceAccepted: U
189
+ }), i = ve.parse(r);
178
190
  if (n) return;
179
- if (D(typeof i.subtotalMinor == "number" && typeof i.totalMinor == "number" ? {
191
+ if (E(typeof i.subtotalMinor == "number" && typeof i.totalMinor == "number" ? {
180
192
  subtotalMinor: i.subtotalMinor,
181
193
  totalMinor: i.totalMinor,
182
- lateReturnSurchargeMinor: i.lateReturnSurchargeMinor
194
+ lateReturnSurchargeMinor: i.lateReturnSurchargeMinor,
195
+ insuranceSubtotalMinor: i.insuranceSubtotalMinor,
196
+ insuranceBillableDays: i.insuranceBillableDays
183
197
  } : null), !i.success) {
184
- E(null), A(i.message || m("checkout_coupon_invalid"));
198
+ w(null), O(i.message || f("checkout_coupon_invalid"));
185
199
  return;
186
200
  }
187
- E(i.coupon ?? null), i.coupon && (i.coupon.autoApplied && e.length === 0 ? (w(i.coupon.code), k(m("checkout_coupon_auto_applied", { code: i.coupon.code }))) : k(m("checkout_coupon_manual_applied")));
201
+ w(i.coupon ?? null), i.coupon && (i.coupon.autoApplied && e.length === 0 ? (S(i.coupon.code), D(f("checkout_coupon_auto_applied", { code: i.coupon.code }))) : D(f("checkout_coupon_manual_applied")));
188
202
  } catch (e) {
189
203
  if (n) return;
190
- console.error("Failed to verify checkout coupon", e), E(null), D(null), A(m("checkout_coupon_error"));
204
+ console.error("Failed to verify checkout coupon", e), w(null), E(null), O(f("checkout_coupon_error"));
191
205
  } finally {
192
- n || O(!1);
206
+ n || tt(!1);
193
207
  }
194
208
  })(), () => {
195
209
  n = !0;
196
210
  };
197
211
  }, [
198
- j,
199
- F.end_date,
200
- F.end_time,
201
- F.start_date,
202
- F.start_time,
203
- I,
212
+ k,
213
+ M.end_date,
214
+ M.end_time,
215
+ M.start_date,
216
+ M.start_time,
217
+ N,
218
+ B,
204
219
  U,
205
- _,
206
- Ye,
207
- m
208
- ]), s(() => {
209
- if (!_ || L.lines.length === 0 || !I) {
210
- x(null), C(null), S(!1);
220
+ h,
221
+ Qe,
222
+ f
223
+ ]), o(() => {
224
+ if (!h || P.lines.length === 0 || !N) {
225
+ y(null), x(null), b(!1);
211
226
  return;
212
227
  }
213
228
  let e = !1;
214
- return S(!0), C(null), (async () => {
229
+ return b(!0), x(null), (async () => {
215
230
  try {
216
- let t = await o(ne, {
217
- storeSlug: _,
218
- schedule: I,
231
+ let t = await a(re, {
232
+ storeSlug: h,
233
+ schedule: N,
219
234
  estimatedTotalMinor: W
220
- }), n = re.parse(t);
235
+ }), n = ie.parse(t);
221
236
  if (e) return;
222
237
  if (!n.success || !n.decision) {
223
- x(null), C(n.errorCode === "online_payment_provider_missing" ? m("checkout_payment_error") : n.message || m("checkout_payment_error"));
238
+ y(null), x(n.errorCode === "online_payment_provider_missing" ? f("checkout_payment_error") : n.message || f("checkout_payment_error"));
224
239
  return;
225
240
  }
226
- x(n.decision);
241
+ y(n.decision);
227
242
  } catch (t) {
228
243
  if (e) return;
229
- console.error("Failed to load checkout payment decision", t), x(null), C(m("checkout_payment_error"));
244
+ console.error("Failed to load checkout payment decision", t), y(null), x(f("checkout_payment_error"));
230
245
  } finally {
231
- e || S(!1);
246
+ e || b(!1);
232
247
  }
233
248
  })(), () => {
234
249
  e = !0;
235
250
  };
236
251
  }, [
237
- F.end_date,
238
- F.end_time,
239
- F.start_date,
240
- F.start_time,
241
- I,
252
+ M.end_date,
253
+ M.end_time,
254
+ M.start_date,
255
+ M.start_time,
256
+ N,
242
257
  W,
243
- L.lines.length,
244
- _,
245
- m
258
+ P.lines.length,
259
+ h,
260
+ f
246
261
  ]);
247
- let Y = b?.currency ?? "EUR", ft = p(W, Y, h.language), pt = G > 0 ? `-${p(G, Y, h.language)}` : null, mt = Math.round(W / 1.2), ht = Math.max(0, W - mt), gt = p(mt, Y, h.language), _t = p(ht, Y, h.language), vt = Me(Ae, h.language), X = b?.amountToCollectMinor ?? 0, yt = p(X, Y, h.language), bt = b?.paymentMode === "deposit" && X > 0 ? p(X, Y, h.language) : null, xt = b?.shouldCollectOnlinePayment === !0 && X > 0, Z = g.shop.timeZone?.trim() || void 0, Q = c(() => b ? Me(Math.max(0, Math.min(1, b.bookingDepositPercentage)), h.language) : null, [h.language, b]), $ = c(() => {
248
- if (!b?.depositRefundableUntilIso) return null;
249
- let e = new Date(b.depositRefundableUntilIso);
250
- return Number.isNaN(e.getTime()) ? null : Ne(e, h.language, Z);
262
+ let Y = v?.currency ?? "EUR", xt = d(W, Y, p.language), St = G > 0 ? `-${d(G, Y, p.language)}` : null, X = T?.insuranceSubtotalMinor ?? 0, Ct = Math.max(0, W - X), wt = Math.round(Ct / 1.2), Tt = wt + X, Et = Math.max(0, Ct - wt), Dt = d(Tt, Y, p.language), Ot = d(Et, Y, p.language), kt = Fe(Ne, p.language), At = X > 0 ? d(X, Y, p.language) : void 0, Z = v?.amountToCollectMinor ?? 0, jt = d(Z, Y, p.language), Mt = v?.paymentMode === "deposit" && Z > 0 ? d(Z, Y, p.language) : null, Nt = v?.shouldCollectOnlinePayment === !0 && Z > 0, Pt = m.shop.timeZone?.trim() || void 0, Q = s(() => v ? Fe(Math.max(0, Math.min(1, v.bookingDepositPercentage)), p.language) : null, [p.language, v]), $ = s(() => {
263
+ if (!v?.depositRefundableUntilIso) return null;
264
+ let e = new Date(v.depositRefundableUntilIso);
265
+ return Number.isNaN(e.getTime()) ? null : Ie(e, p.language, Pt);
251
266
  }, [
252
- h.language,
253
- b?.depositRefundableUntilIso,
254
- Z
255
- ]), St = c(() => b ? b.paymentMode === "deposit" && X > 0 && Q ? $ ? m("checkout_payment_due_now_helper_deposit_refundable_until", {
267
+ p.language,
268
+ v?.depositRefundableUntilIso,
269
+ Pt
270
+ ]), Ft = s(() => v ? v.paymentMode === "deposit" && Z > 0 && Q ? $ ? f("checkout_payment_due_now_helper_deposit_refundable_until", {
256
271
  percent: Q,
257
272
  date: $
258
- }) : m("checkout_payment_due_now_helper_deposit", { percent: Q }) : b.paymentMode === "none" || X <= 0 ? m("checkout_payment_due_now_helper_none") : null : null, [
259
- X,
273
+ }) : f("checkout_payment_due_now_helper_deposit", { percent: Q }) : v.paymentMode === "none" || Z <= 0 ? f("checkout_payment_due_now_helper_none") : null : null, [
274
+ Z,
260
275
  Q,
261
276
  $,
262
- b,
263
- m
264
- ]), Ct = dt.handleSubmit(async (e) => {
265
- if (!(!_ || U.length === 0 || !I)) {
266
- We(!0);
277
+ v,
278
+ f
279
+ ]), It = bt.handleSubmit(async (e) => {
280
+ if (!(!h || B.length === 0 || !N)) {
281
+ qe(!0);
267
282
  try {
268
- let t = await o(ie, {
269
- storeSlug: _,
270
- schedule: I,
271
- fulfillment: F.fulfillment,
272
- startAddress: F.fulfillment === "delivery" ? F.start_address : void 0,
273
- endAddress: F.fulfillment === "delivery" ? F.end_address : void 0,
274
- couponCode: T?.code,
275
- couponAutoApplied: !j && T?.autoApplied,
283
+ let t = await a(ae, {
284
+ storeSlug: h,
285
+ schedule: N,
286
+ fulfillment: M.fulfillment,
287
+ startAddress: M.fulfillment === "delivery" ? M.start_address : void 0,
288
+ endAddress: M.fulfillment === "delivery" ? M.end_address : void 0,
289
+ couponCode: C?.code,
290
+ couponAutoApplied: !k && C?.autoApplied,
291
+ insuranceAccepted: U,
276
292
  customer: {
277
- fullName: e.full_name,
293
+ firstName: e.first_name,
294
+ lastName: e.last_name,
278
295
  email: e.email,
279
296
  phone: e.phone,
280
297
  notes: e.notes
281
298
  },
282
- items: U
283
- }), n = ae.parse(t);
299
+ items: B
300
+ }), n = oe.parse(t);
284
301
  if (!n.success || !n.checkout) {
285
- f.error(n.errorCode === "online_payment_provider_missing" ? m("checkout_payment_error") : n.message || m("checkout_payment_error"));
302
+ we.error(n.errorCode === "online_payment_provider_missing" ? f("checkout_payment_error") : n.message || f("checkout_payment_error"));
286
303
  return;
287
304
  }
288
- n.checkout.requiresPayment || f.success(m("checkout_success_toast")), await Re(n.checkout.nextPath), Ue();
305
+ n.checkout.requiresPayment || we.success(f("checkout_success_toast")), await Ve(n.checkout.nextPath), Ke();
289
306
  } catch (e) {
290
- console.error("Failed to submit storefront checkout", e), f.error(m("checkout_payment_error"));
307
+ console.error("Failed to submit storefront checkout", e), we.error(f("checkout_payment_error"));
291
308
  } finally {
292
- We(!1);
309
+ qe(!1);
293
310
  }
294
311
  }
295
- }), wt = m(xt ? "checkout_continue_to_payment" : "checkout_submit"), Tt = F.fulfillment === "delivery" && F.start_address.trim().length === 0, Et = !y && !Ge && !Ke && !Qe && !et && !!b && !!I && !Tt && U.length > 0;
296
- return L.lines.length === 0 ? /* @__PURE__ */ u("div", {
312
+ }), Lt = f(Nt ? "checkout_continue_to_payment" : "checkout_submit"), Rt = M.fulfillment === "delivery" && M.start_address.trim().length === 0, zt = !_ && !Je && !Ye && !et && !rt && !!v && !!N && !Rt && B.length > 0;
313
+ return P.lines.length === 0 ? /* @__PURE__ */ l("div", {
297
314
  className: "mx-auto max-w-3xl px-4 py-10 sm:px-6",
298
- children: /* @__PURE__ */ d("div", {
315
+ children: /* @__PURE__ */ u("div", {
299
316
  className: "rounded-xl border border-slate-200 bg-white p-4 shadow-sm",
300
317
  children: [
301
- /* @__PURE__ */ u("h1", {
318
+ /* @__PURE__ */ l("h1", {
302
319
  className: "text-xl font-semibold tracking-tight text-slate-950",
303
- children: /* @__PURE__ */ u("span", { children: m("cart_empty_title") })
320
+ children: /* @__PURE__ */ l("span", { children: f("cart_empty_title") })
304
321
  }),
305
- /* @__PURE__ */ u("p", {
322
+ /* @__PURE__ */ l("p", {
306
323
  className: "mt-2 text-sm text-slate-600",
307
- children: /* @__PURE__ */ u("span", { children: m("cart_empty_description") })
324
+ children: /* @__PURE__ */ l("span", { children: f("cart_empty_description") })
308
325
  }),
309
- /* @__PURE__ */ u("div", {
326
+ /* @__PURE__ */ l("div", {
310
327
  className: "mt-6",
311
- children: /* @__PURE__ */ u(Se, {
328
+ children: /* @__PURE__ */ l(Te, {
312
329
  to: q,
313
- children: /* @__PURE__ */ d(de, {
330
+ children: /* @__PURE__ */ u(fe, {
314
331
  className: "gap-2",
315
- children: [/* @__PURE__ */ u(De, {
332
+ children: [/* @__PURE__ */ l(Ae, {
316
333
  className: "h-4 w-4",
317
334
  "aria-hidden": "true"
318
- }), /* @__PURE__ */ u("span", { children: m("back_to_booking") })]
335
+ }), /* @__PURE__ */ l("span", { children: f("back_to_booking") })]
319
336
  })
320
337
  })
321
338
  })
322
339
  ]
323
340
  })
324
- }) : /* @__PURE__ */ u("div", {
341
+ }) : /* @__PURE__ */ l("div", {
325
342
  className: "mx-auto max-w-7xl px-4 py-8 sm:px-6",
326
- children: /* @__PURE__ */ d("div", {
343
+ children: /* @__PURE__ */ u("div", {
327
344
  className: "flex flex-col gap-6",
328
345
  children: [
329
- /* @__PURE__ */ u(fe, {
346
+ /* @__PURE__ */ l(pe, {
330
347
  currentStep: "checkout",
331
348
  bookingPath: q,
332
- checkoutPath: ut
349
+ checkoutPath: yt
333
350
  }),
334
- /* @__PURE__ */ d(Se, {
351
+ /* @__PURE__ */ u(Te, {
335
352
  to: q,
336
353
  className: "inline-flex items-center gap-2 text-sm font-medium text-slate-700 hover:text-slate-950",
337
- children: [/* @__PURE__ */ u(De, {
354
+ children: [/* @__PURE__ */ l(Ae, {
338
355
  className: "h-4 w-4",
339
356
  "aria-hidden": "true"
340
- }), /* @__PURE__ */ u("span", { children: m("back_to_booking") })]
357
+ }), /* @__PURE__ */ l("span", { children: f("back_to_booking") })]
341
358
  }),
342
- /* @__PURE__ */ d("div", {
359
+ /* @__PURE__ */ u("div", {
343
360
  className: "grid gap-6 lg:grid-cols-12",
344
- children: [/* @__PURE__ */ d("div", {
361
+ children: [/* @__PURE__ */ u("div", {
345
362
  className: "lg:col-span-7",
346
363
  children: [
347
- /* @__PURE__ */ u("h1", {
364
+ /* @__PURE__ */ l("h1", {
348
365
  className: "text-xl font-semibold tracking-tight text-slate-950",
349
- children: /* @__PURE__ */ u("span", { children: m("checkout_title") })
366
+ children: /* @__PURE__ */ l("span", { children: f("checkout_title") })
350
367
  }),
351
- I ? null : /* @__PURE__ */ u("p", {
368
+ N ? null : /* @__PURE__ */ l("p", {
352
369
  role: "alert",
353
370
  className: "mt-3 text-sm text-destructive",
354
- children: /* @__PURE__ */ u("span", { children: m("booking_time_slots_required") })
371
+ children: /* @__PURE__ */ l("span", { children: f("booking_time_slots_required") })
355
372
  }),
356
- /* @__PURE__ */ d("div", {
373
+ /* @__PURE__ */ u("div", {
357
374
  className: "mt-5 grid gap-4",
358
375
  children: [
359
- nt ? /* @__PURE__ */ u("div", {
376
+ ct ? /* @__PURE__ */ l("div", {
360
377
  className: "rounded-xl border border-slate-200 bg-white p-3 shadow-sm",
361
- children: /* @__PURE__ */ u(he, {
362
- value: F.fulfillment,
378
+ children: /* @__PURE__ */ l(ge, {
379
+ value: M.fulfillment,
363
380
  onValueChange: (e) => J({ fulfillment: e }),
364
- pickupAddress: rt,
365
- deliveryEnabled: N,
366
- deliveryDisabledReason: P,
367
- startAddress: F.start_address,
381
+ pickupAddress: lt,
382
+ deliveryEnabled: j,
383
+ deliveryDisabledReason: st,
384
+ startAddress: M.start_address,
368
385
  onStartAddressChange: (e) => J({ start_address: e }),
369
- endAddress: F.end_address,
386
+ endAddress: M.end_address,
370
387
  onEndAddressChange: (e) => J({ end_address: e }),
371
388
  showPickupAddressWhenPickupOnly: !1,
372
389
  testIdPrefix: "storefront-checkout-fulfillment"
373
390
  })
374
391
  }) : null,
375
- /* @__PURE__ */ u(ve, { form: dt }),
376
- /* @__PURE__ */ u(ye, {
377
- estimatedTotalLabel: ft,
378
- couponCode: T?.code,
379
- discountAmountLabel: pt,
380
- totalExcludingTaxLabel: gt,
381
- vatAmountLabel: _t,
382
- vatRateLabel: vt,
383
- depositAmountLabel: bt,
384
- amountToCollectMinor: X,
385
- amountToCollectLabel: yt,
386
- paymentSummaryHelper: St,
387
- paymentDecisionLoading: Ge,
388
- paymentDecisionError: Ke,
392
+ /* @__PURE__ */ l(ye, { form: bt }),
393
+ H ? /* @__PURE__ */ l(xe, {
394
+ accepted: U,
395
+ disabled: _ || et,
396
+ dailyAmountLabel: d(gt, Y, p.language),
397
+ totalAmountLabel: At,
398
+ billableDays: T?.insuranceBillableDays,
399
+ deductibleLabel: _t > 0 ? d(_t, Y, p.language) : void 0,
400
+ onAcceptedChange: at
401
+ }) : null,
402
+ /* @__PURE__ */ l(be, {
403
+ estimatedTotalLabel: xt,
404
+ couponCode: C?.code,
405
+ discountAmountLabel: St,
406
+ totalExcludingTaxLabel: Dt,
407
+ vatAmountLabel: Ot,
408
+ vatRateLabel: kt,
409
+ insuranceAmountLabel: At,
410
+ depositAmountLabel: Mt,
411
+ amountToCollectMinor: Z,
412
+ amountToCollectLabel: jt,
413
+ paymentSummaryHelper: Ft,
414
+ paymentDecisionLoading: Je,
415
+ paymentDecisionError: Ye,
389
416
  canChoosePaymentMethod: !1,
390
417
  showAmountDueNowRow: !0,
391
418
  selectedPaymentMethod: "card",
392
- submitting: y,
419
+ submitting: _,
393
420
  onSelectPaymentMethod: () => {}
394
421
  }),
395
- /* @__PURE__ */ u(de, {
422
+ /* @__PURE__ */ l(fe, {
396
423
  type: "button",
397
424
  size: "lg",
398
425
  onClick: () => {
399
- Ct();
426
+ It();
400
427
  },
401
- disabled: !Et,
428
+ disabled: !zt,
402
429
  className: "mt-4 w-fit",
403
- children: /* @__PURE__ */ u("span", { children: wt })
430
+ children: /* @__PURE__ */ l("span", { children: Lt })
404
431
  }),
405
- Tt ? /* @__PURE__ */ u("p", {
432
+ Rt ? /* @__PURE__ */ l("p", {
406
433
  className: "text-sm text-slate-600",
407
- children: /* @__PURE__ */ u("span", { children: m("checkout_delivery_address_required") })
434
+ children: /* @__PURE__ */ l("span", { children: f("checkout_delivery_address_required") })
408
435
  }) : null
409
436
  ]
410
437
  })
411
438
  ]
412
- }), /* @__PURE__ */ u(be, {
413
- lines: H.lines,
414
- itemCount: Be,
415
- totalPerDayMinor: H.totalPerDayMinor,
416
- estimatedDays: H.estimatedDays,
417
- estimatedTotalMinor: H.estimatedTotalMinor,
439
+ }), /* @__PURE__ */ l(Se, {
440
+ lines: z.lines,
441
+ itemCount: Ue,
442
+ totalPerDayMinor: z.totalPerDayMinor,
443
+ estimatedDays: z.estimatedDays,
444
+ estimatedTotalMinor: z.estimatedTotalMinor,
418
445
  discountedEstimatedTotalMinor: W,
419
446
  discountAmountMinor: G,
420
- lateReturnSurchargeMinor: Ze?.lateReturnSurchargeMinor,
421
- couponCode: T?.code,
422
- durationLabel: it.label,
423
- onQuantityChange: Ve,
424
- onRemove: He,
447
+ lateReturnSurchargeMinor: T?.lateReturnSurchargeMinor,
448
+ couponCode: C?.code,
449
+ durationLabel: ut.label,
450
+ onQuantityChange: We,
451
+ onRemove: Ge,
425
452
  coupon: {
426
- code: Je,
427
- appliedCode: T?.code,
428
- discountLabel: T && G > 0 ? p(G, Y, h.language) : null,
429
- message: $e,
430
- error: et,
431
- loading: Qe,
432
- disabled: y,
453
+ code: Ze,
454
+ appliedCode: C?.code,
455
+ discountLabel: C && G > 0 ? d(G, Y, p.language) : null,
456
+ message: nt,
457
+ error: rt,
458
+ loading: et,
459
+ disabled: _,
433
460
  onCodeChange: (e) => {
434
- w(e), A(null), k(null);
461
+ S(e), O(null), D(null);
435
462
  },
436
463
  onApply: () => {
437
- tt(!1), Xe(Je.trim());
464
+ it(!1), $e(Ze.trim());
438
465
  },
439
466
  onRemove: () => {
440
- w(""), Xe(""), E(null), D(null), A(null), k(null), tt(!0);
467
+ S(""), $e(""), w(null), E(null), O(null), D(null), it(!0);
441
468
  }
442
469
  }
443
470
  })]
@@ -447,4 +474,4 @@ function m() {
447
474
  });
448
475
  }
449
476
  //#endregion
450
- export { m as default };
477
+ export { f as default };