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