@loczer/storefront-sdk 0.230.0 → 0.232.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 (68) hide show
  1. package/dist/StorefrontContext.d.ts +0 -2
  2. package/dist/StorefrontContext.d.ts.map +1 -1
  3. package/dist/StorefrontProvider.d.ts +0 -1
  4. package/dist/StorefrontProvider.d.ts.map +1 -1
  5. package/dist/chunks/pkg/booking-engine/dist/schemas/{base-booking-C9kJFMIu.js → base-booking-BJXFzDM5.js} +0 -2
  6. package/dist/chunks/pkg/booking-engine/dist/schemas/{cart-inputs-epi7FXIk.js → cart-inputs-3lBblkB0.js} +0 -10
  7. package/dist/chunks/pkg/booking-engine/dist/{schemas-DW5gdDYz.js → schemas-JjiUWFIv.js} +2 -2
  8. package/dist/chunks/pkg/ui/dist/LanguagePicker/index-D7_3voTe.js +83 -0
  9. package/dist/components/BookingBikeQuickAddCard/index.d.ts +3 -1
  10. package/dist/components/BookingBikeQuickAddCard/index.d.ts.map +1 -1
  11. package/dist/components/BookingBikeQuickAddCard/index.js +94 -85
  12. package/dist/components/BookingPeriodSelector/components/BookingEndDateField.js +1 -1
  13. package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.js +1 -1
  14. package/dist/components/BookingPeriodSelector/components/BookingStartDateField.js +1 -1
  15. package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.js +1 -1
  16. package/dist/components/ContractSaleDocument/InvoiceDetails.d.ts.map +1 -1
  17. package/dist/components/ContractSaleDocument/InvoiceDetails.js +62 -56
  18. package/dist/components/Footer/businessHoursStatus.js +1 -1
  19. package/dist/components/Header/index.d.ts.map +1 -1
  20. package/dist/components/Header/index.js +56 -56
  21. package/dist/components/LanguageSelector/index.d.ts.map +1 -1
  22. package/dist/components/LanguageSelector/index.js +19 -64
  23. package/dist/components/StorefrontCartPanel/index.js +1 -1
  24. package/dist/i18n/en.d.ts +2 -4
  25. package/dist/i18n/en.d.ts.map +1 -1
  26. package/dist/i18n/en.js +3 -5
  27. package/dist/i18n/fr.d.ts +2 -4
  28. package/dist/i18n/fr.d.ts.map +1 -1
  29. package/dist/i18n/fr.js +4 -6
  30. package/dist/index.d.ts +17 -35
  31. package/dist/index.js +3 -3
  32. package/dist/lib/booking-period.js +1 -1
  33. package/dist/lib/booking.d.ts +6 -6
  34. package/dist/lib/booking.d.ts.map +1 -1
  35. package/dist/lib/booking.js +21 -21
  36. package/dist/lib/cart.d.ts +1 -0
  37. package/dist/lib/cart.d.ts.map +1 -1
  38. package/dist/lib/cart.js +2 -0
  39. package/dist/lib/checkoutSubmit.d.ts +2 -6
  40. package/dist/lib/checkoutSubmit.d.ts.map +1 -1
  41. package/dist/lib/checkoutSubmit.js +3 -11
  42. package/dist/lib/pricing.js +1 -1
  43. package/dist/lib/storefrontAvailability.d.ts +12 -8
  44. package/dist/lib/storefrontAvailability.d.ts.map +1 -1
  45. package/dist/lib/storefrontAvailability.js +17 -7
  46. package/dist/pages/BookingPage.d.ts.map +1 -1
  47. package/dist/pages/BookingPage.js +236 -238
  48. package/dist/pages/CheckoutPage.d.ts.map +1 -1
  49. package/dist/pages/CheckoutPage.js +127 -125
  50. package/dist/pages/ContractSaleDocumentPage.d.ts.map +1 -1
  51. package/dist/pages/ContractSaleDocumentPage.js +117 -171
  52. package/dist/pages/HomePage.js +8 -8
  53. package/dist/pages/ProductPage.d.ts.map +1 -1
  54. package/dist/pages/ProductPage.js +187 -181
  55. package/dist/pages/checkout/components/CheckoutDetailsCard.d.ts.map +1 -1
  56. package/dist/pages/checkout/components/CheckoutDetailsCard.js +4 -17
  57. package/dist/pages/checkout/components/CheckoutLoadingSkeleton.d.ts +7 -0
  58. package/dist/pages/checkout/components/CheckoutLoadingSkeleton.d.ts.map +1 -0
  59. package/dist/pages/checkout/components/CheckoutLoadingSkeleton.js +105 -0
  60. package/dist/pages/checkout/types.d.ts +1 -2
  61. package/dist/pages/checkout/types.d.ts.map +1 -1
  62. package/dist/pages/checkout/types.js +1 -2
  63. package/dist/storefront.css +1 -1
  64. package/dist/storefrontSchemas.d.ts +0 -2
  65. package/dist/storefrontSchemas.d.ts.map +1 -1
  66. package/dist/storefrontSchemas.js +1 -2
  67. package/package.json +1 -1
  68. package/dist/chunks/pkg/ui/dist/{MorphingModalWizard-j1CgFGLe.js → MorphingModalWizard-Q8O5Rjfq.js} +1 -1
@@ -4,58 +4,60 @@ import { getStorefrontCheckoutProductId as s, getStorefrontProductSelectionDispl
4
4
  import { useStorefrontCart as ne } from "../lib/cart.js";
5
5
  import { calculateBookingRentalUnitSummary as re, getPricingUnitLabel as ie } from "../lib/pricing.js";
6
6
  import { buildStorefrontCartSummary as ae } from "../lib/cartSummary.js";
7
- import { ROUTE as oe, buildStorefrontAvailabilityKey as c, getStorefrontAvailabilityIssue as se, getStorefrontAvailabilityStatus as l, getValidStorefrontAvailabilitySchedule as u, isStorefrontAvailabilityInsufficient as ce, responseSchema as le } from "../lib/storefrontAvailability.js";
8
- import { Badge as ue } from "../ui/badge.js";
9
- import { Button as de } from "../ui/button.js";
10
- import { useStorefront as fe, useStorefrontBookingProducts as pe, useStorefrontProducts as me } from "../StorefrontContext.js";
11
- import { toast as he } from "../lib/toast.js";
12
- import { BookingPeriodSelector as ge } from "../components/BookingPeriodSelector/index.js";
7
+ import { ROUTE as oe, buildStorefrontAvailabilityKey as c, getStorefrontAvailabilityIssue as se, getStorefrontAvailabilityStatus as ce, getStorefrontProductAvailabilityStatus as l, getValidStorefrontAvailabilitySchedule as u, isStorefrontAvailabilityInsufficient as le, responseSchema as ue } from "../lib/storefrontAvailability.js";
8
+ import { Badge as de } from "../ui/badge.js";
9
+ import { Button as fe } from "../ui/button.js";
10
+ import { useStorefront as pe, useStorefrontBookingProducts as me, useStorefrontProducts as he } from "../StorefrontContext.js";
11
+ import { toast as ge } from "../lib/toast.js";
12
+ import { BookingPeriodSelector as _e } from "../components/BookingPeriodSelector/index.js";
13
13
  import { StepSectionTitle as d } from "../components/StepSectionTitle/index.js";
14
- import { Card as _e } from "../ui/card.js";
15
- import { ProductWarningNotice as ve } from "../components/ProductWarningNotice/index.js";
16
- import { StorefrontCartPanel as ye } from "../components/StorefrontCartPanel/index.js";
17
- import { ProductPriceBadge as be } from "../components/ProductPriceBadge/index.js";
18
- import { resolveProductImageContainerStyle as xe } from "../lib/productImageStyles.js";
19
- import { apiPost as Se } from "../lib/apiCall.js";
20
- import { createStorefrontTimeSlotsFetcher as Ce } from "../lib/fetchStorefrontTimeSlots.js";
21
- import { FulfillmentSection as we } from "../components/FulfillmentSection/index.js";
22
- import { BookingFlowPageLayout as Te } from "../components/BookingFlowPageLayout/index.js";
23
- import { BookingBikeQuickAddCard as Ee } from "../components/BookingBikeQuickAddCard/index.js";
24
- import { BookingBikeVariantDialog as De } from "../components/BookingBikeVariantDialog/index.js";
25
- import { useEffect as f, useLayoutEffect as Oe, useMemo as p, useRef as m, useState as h } from "react";
26
- import { Fragment as ke, jsx as g, jsxs as _ } from "react/jsx-runtime";
27
- import { Link as Ae, useLocation as je, useParams as Me, useSearchParams as Ne } from "@rpcbase/router";
28
- import { useTranslation as Pe } from "react-i18next";
29
- import { cn as Fe } from "@rpcbase/ui";
30
- import { Bike as Ie, Plus as Le } from "lucide-react";
14
+ import { Card as ve } from "../ui/card.js";
15
+ import { ProductWarningNotice as ye } from "../components/ProductWarningNotice/index.js";
16
+ import { StorefrontCartPanel as be } from "../components/StorefrontCartPanel/index.js";
17
+ import { ProductPriceBadge as xe } from "../components/ProductPriceBadge/index.js";
18
+ import { resolveProductImageContainerStyle as Se } from "../lib/productImageStyles.js";
19
+ import { apiPost as Ce } from "../lib/apiCall.js";
20
+ import { createStorefrontTimeSlotsFetcher as we } from "../lib/fetchStorefrontTimeSlots.js";
21
+ import { FulfillmentSection as Te } from "../components/FulfillmentSection/index.js";
22
+ import { BookingFlowPageLayout as Ee } from "../components/BookingFlowPageLayout/index.js";
23
+ import { BookingBikeQuickAddCard as De } from "../components/BookingBikeQuickAddCard/index.js";
24
+ import { BookingBikeVariantDialog as Oe } from "../components/BookingBikeVariantDialog/index.js";
25
+ import { useEffect as f, useLayoutEffect as ke, useMemo as p, useRef as m, useState as h } from "react";
26
+ import { Fragment as Ae, jsx as g, jsxs as _ } from "react/jsx-runtime";
27
+ import { Link as je, useLocation as Me, useParams as Ne, useSearchParams as Pe } from "@rpcbase/router";
28
+ import { useTranslation as Fe } from "react-i18next";
29
+ import { cn as Ie } from "@rpcbase/ui";
30
+ import { Bike as Le, Plus as Re } from "lucide-react";
31
31
  //#region src/pages/BookingPage.tsx
32
- var v = (e) => String(e).padStart(2, "0"), y = "product_modal", Re = (e, t) => {
32
+ var v = (e) => String(e).padStart(2, "0"), y = "product_modal", ze = (e, t) => {
33
33
  let n = t - e;
34
34
  return e >= 0 && (n === 1 || n === 2) ? n : null;
35
- }, ze = (e) => `${e.getFullYear()}-${v(e.getMonth() + 1)}-${v(e.getDate())}`, Be = (e) => {
35
+ }, Be = (e) => `${e.getFullYear()}-${v(e.getMonth() + 1)}-${v(e.getDate())}`, Ve = (e) => {
36
36
  if (!e) return;
37
37
  let t = e.match(/^(\d{4})-(\d{2})-(\d{2})$/);
38
38
  if (!t) return;
39
39
  let n = Number(t[1]), r = Number(t[2]), i = Number(t[3]), a = new Date(n, r - 1, i);
40
40
  if (!(Number.isNaN(a.getTime()) || a.getFullYear() !== n || a.getMonth() !== r - 1 || a.getDate() !== i)) return a;
41
- }, b = (e, t) => e.fulfillment === t.fulfillment && e.start_date === t.start_date && e.start_time === t.start_time && e.end_date === t.end_date && e.end_time === t.end_time && e.start_address === t.start_address && e.end_address === t.end_address, x = (e, t = () => !0) => {
41
+ }, b = (e, t) => e.fulfillment === t.fulfillment && e.startDate === t.startDate && e.startTime === t.startTime && e.endDate === t.endDate && e.endTime === t.endTime && e.startAddress === t.startAddress && e.endAddress === t.endAddress, x = (e, t = () => !0) => {
42
42
  if (e.representedVariantId?.trim()) return e.representedVariantId.trim();
43
43
  let n = e.productVariants ?? [], r = n.find((e) => t(e.id))?.id ?? n[0]?.id;
44
44
  return typeof r == "string" && r.trim().length > 0 ? r : null;
45
- }, Ve = (e, t) => e.fulfillment === "delivery" && !t ? {
45
+ }, He = (e, t) => e.fulfillment === "delivery" && !t ? {
46
46
  ...e,
47
47
  fulfillment: "pickup"
48
- } : e, He = (e, t) => {
49
- let n = s(e), r = e.representedVariantId?.trim();
50
- if (r) {
51
- let e = t.get(c(n, r));
52
- if (e) return e;
53
- }
54
- return t.get(c(n));
55
- }, Ue = (e, t, n) => n.get(c(s(e), t)), We = (e, t, n) => {
48
+ } : e, Ue = (e, t) => {
49
+ let n = s(e);
50
+ return l({
51
+ availabilityByKey: t,
52
+ fallbackStatus: e.availabilityStatus ?? "AVAILABLE",
53
+ productId: n,
54
+ productVariantIds: (e.productVariants ?? []).map((e) => e.id),
55
+ representedVariantId: e.representedVariantId
56
+ });
57
+ }, We = (e, t, n) => n.get(c(s(e), t)), Ge = (e, t, n) => {
56
58
  let r = se(t);
57
- return r === "quantity_unavailable" ? e("availability_quantity_unavailable") : r === "unavailable" || n === "OUT_OF_STOCK" ? e("availability_out_of_stock") : t?.remaining === void 0 ? t?.fewRemaining || n === "LOW_STOCK" ? e("availability_low_stock") : e("availability_in_stock") : e("availability_remaining_count", { count: t.remaining });
58
- }, Ge = (e) => {
59
+ return r === "quantityUnavailable" ? e("availability_quantity_unavailable") : r === "unavailable" || n === "OUT_OF_STOCK" ? e("availability_out_of_stock") : t?.remaining === void 0 ? t?.fewRemaining || n === "LOW_STOCK" ? e("availability_low_stock") : e("availability_in_stock") : e("availability_remaining_count", { count: t.remaining });
60
+ }, Ke = (e) => {
59
61
  let t = /* @__PURE__ */ new Map();
60
62
  for (let n of e) {
61
63
  let e = s(n);
@@ -73,93 +75,93 @@ var v = (e) => String(e).padStart(2, "0"), y = "product_modal", Re = (e, t) => {
73
75
  return Array.from(t.values());
74
76
  };
75
77
  function S() {
76
- let { t: v, i18n: S } = Pe(), { storeSlug: C } = Me(), w = je(), Ke = m(null), { storefrontConfiguration: T } = fe(), E = T.workspace?.workspaceLanguage, { bikes: qe, accessories: Je } = me(), { bikes: D, accessories: O } = pe(), [k, A] = Ne(), { items: Ye, itemCount: Xe, addItem: Ze, removeItem: Qe, setQuantity: $e } = ne();
77
- Oe(() => {
78
- w.hash === "#booking-products" && Ke.current?.scrollIntoView({ block: "start" });
79
- }, [w.hash]);
80
- let et = p(() => t(T), [T]), j = p(() => r(T), [T]), M = T.settings.fulfillmentModes.includes("delivery"), tt = T.settings.deliveryDisabledReason.trim(), nt = T.shop.address?.trim() ?? "", N = T.bookingEngine.pricing.baseUnit, rt = ie(N, v), it = i(k).toString(), P = p(() => a(new URLSearchParams(it), C), [it, C]), [F, I] = h(() => ({
81
- booking: Ve(n(P, j), M),
78
+ let { t: l, i18n: v } = Fe(), { storeSlug: S } = Ne(), C = Me(), qe = m(null), { storefrontConfiguration: w } = pe(), T = w.workspace?.workspaceLanguage, { bikes: Je, accessories: Ye } = he(), { bikes: E, accessories: D } = me(), [O, k] = Pe(), { items: Xe, itemCount: Ze, addItem: Qe, removeItem: $e, setQuantity: et } = ne();
79
+ ke(() => {
80
+ C.hash === "#booking-products" && qe.current?.scrollIntoView({ block: "start" });
81
+ }, [C.hash]);
82
+ let tt = p(() => t(w), [w]), A = p(() => r(w), [w]), j = w.settings.fulfillmentModes.includes("delivery"), nt = w.settings.deliveryDisabledReason.trim(), rt = w.shop.address?.trim() ?? "", M = w.bookingEngine.pricing.baseUnit, it = ie(M, l), at = i(O).toString(), N = p(() => a(new URLSearchParams(at), S), [at, S]), [P, F] = h(() => ({
83
+ booking: He(n(N, A), j),
82
84
  shouldWriteToUrl: !0
83
- })), L = F.booking, R = p(() => Be(L.start_date), [L.start_date]), at = p(() => Be(L.end_date) ?? R, [L.end_date, R]), [ot, st] = h(void 0), ct = m(void 0), lt = m(""), ut = [
84
- L.start_date,
85
- L.start_time,
86
- L.end_date,
87
- L.end_time
85
+ })), I = P.booking, L = p(() => Ve(I.startDate), [I.startDate]), ot = p(() => Ve(I.endDate) ?? L, [I.endDate, L]), [st, ct] = h(void 0), lt = m(void 0), ut = m(""), dt = [
86
+ I.startDate,
87
+ I.startTime,
88
+ I.endDate,
89
+ I.endTime
88
90
  ].join(":");
89
- lt.current = ut;
90
- let z = ot === ut, B = z ? L.start_time : "", V = z ? L.end_time : "", H = !z && k.get("start_date") === L.start_date && k.get("start_time") === L.start_time && k.get("end_date") === L.end_date && k.get("end_time") === L.end_time;
91
+ ut.current = dt;
92
+ let R = st === dt, z = R ? I.startTime : "", B = R ? I.endTime : "", V = !R && O.get("start_date") === I.startDate && O.get("start_time") === I.startTime && O.get("end_date") === I.endDate && O.get("end_time") === I.endTime;
91
93
  f(() => {
92
- I((e) => {
94
+ F((e) => {
93
95
  if (e.shouldWriteToUrl) return e;
94
96
  let t = {
95
- ...j,
97
+ ...A,
96
98
  ...e.booking
97
- }, r = Ve(n(P, t), M);
99
+ }, r = He(n(N, t), j);
98
100
  return {
99
101
  booking: b(e.booking, r) ? e.booking : r,
100
102
  shouldWriteToUrl: !0
101
103
  };
102
104
  });
103
105
  }, [
104
- P,
105
- j,
106
- M
106
+ N,
107
+ A,
108
+ j
107
109
  ]), f(() => {
108
- if (!F.shouldWriteToUrl) return;
109
- let t = e(k, {
110
- ...L,
111
- start_time: H ? L.start_time : B,
112
- end_time: H ? L.end_time : V
110
+ if (!P.shouldWriteToUrl) return;
111
+ let t = e(O, {
112
+ ...I,
113
+ startTime: V ? I.startTime : z,
114
+ endTime: V ? I.endTime : B
113
115
  });
114
- if (t.toString() === k.toString()) {
115
- I((e) => e.shouldWriteToUrl ? {
116
+ if (t.toString() === O.toString()) {
117
+ F((e) => e.shouldWriteToUrl ? {
116
118
  ...e,
117
119
  shouldWriteToUrl: !1
118
120
  } : e);
119
121
  return;
120
122
  }
121
- A(t, { replace: !0 });
123
+ k(t, { replace: !0 });
122
124
  }, [
123
- L,
124
- F.shouldWriteToUrl,
125
- H,
125
+ I,
126
+ P.shouldWriteToUrl,
126
127
  V,
127
128
  B,
128
- k,
129
- A
129
+ z,
130
+ O,
131
+ k
130
132
  ]), f(() => {
131
- ee(C, {
132
- ...L,
133
- start_time: B,
134
- end_time: V
133
+ ee(S, {
134
+ ...I,
135
+ startTime: z,
136
+ endTime: B
135
137
  });
136
138
  }, [
137
- L,
138
- V,
139
+ I,
139
140
  B,
140
- C
141
+ z,
142
+ S
141
143
  ]);
142
- let U = p(() => Ge([...D, ...O]), [O, D]), [dt, W] = h([]);
144
+ let H = p(() => Ke([...E, ...D]), [D, E]), [ft, U] = h([]);
143
145
  f(() => {
144
- if (!C || U.length === 0) {
145
- W([]);
146
+ if (!S || H.length === 0) {
147
+ U([]);
146
148
  return;
147
149
  }
148
- let e = z ? u(L) : null;
150
+ let e = R ? u(I) : null;
149
151
  if (!e) {
150
- W([]);
152
+ U([]);
151
153
  return;
152
154
  }
153
155
  let t = !1;
154
156
  return (async () => {
155
157
  try {
156
- let n = await Se(oe, {
157
- storeSlug: C,
158
+ let n = await Ce(oe, {
159
+ storeSlug: S,
158
160
  schedule: e,
159
- products: U
160
- }), r = le.parse(n);
161
+ products: H
162
+ }), r = ue.parse(n);
161
163
  if (t) return;
162
- W(r.success ? r.availability ?? [] : []);
164
+ U(r.success ? r.availability ?? [] : []);
163
165
  } catch (e) {
164
166
  if (t) return;
165
167
  console.error("Failed to load storefront availability", e);
@@ -168,53 +170,47 @@ function S() {
168
170
  t = !0;
169
171
  };
170
172
  }, [
171
- U,
172
- L.end_date,
173
- L.end_time,
174
- L.start_date,
175
- L.start_time,
176
- z,
177
- C
173
+ H,
174
+ I.endDate,
175
+ I.endTime,
176
+ I.startDate,
177
+ I.startTime,
178
+ R,
179
+ S
178
180
  ]);
179
- let G = p(() => new Map(dt.map((e) => [c(e.productId, e.productVariantId), e])), [dt]), K = p(() => D.map((e) => {
180
- let t = He(e, G);
181
- return {
182
- ...e,
183
- availabilityStatus: t ? l(t) : e.availabilityStatus ?? "AVAILABLE"
184
- };
185
- }), [G, D]), ft = p(() => O.map((e) => {
186
- let t = He(e, G);
187
- return {
188
- ...e,
189
- availabilityStatus: t ? l(t) : "AVAILABLE"
190
- };
191
- }), [O, G]), pt = (e, t) => {
192
- let n = Ue(e, t, G);
193
- return n ? ce(n) : e.availabilityStatus === "OUT_OF_STOCK";
194
- }, mt = (e) => (e.productVariants ?? []).length > 0, ht = (e, t) => {
195
- let n = Ue(e, t, G);
196
- return n ? We(v, n, l(n)) : e.availabilityStatus === "OUT_OF_STOCK" ? v("availability_out_of_stock") : null;
197
- }, gt = Ce(C), _t = p(() => ({
198
- startDate: v("booking_start_date"),
199
- pickStartDate: v("booking_start_date"),
200
- startTime: v("booking_start_time"),
201
- endDate: v("booking_end_date"),
202
- pickEndDate: v("booking_end_date"),
203
- endTime: v("booking_end_time"),
204
- selectedDaysTooltip: ({ count: e }) => v("booking_selected_days_tooltip", { count: e }),
205
- rentalPeriod: v("booking_rental_period"),
206
- dateDrawerNext: v("booking_date_drawer_continue"),
207
- closeDrawer: v("booking_date_drawer_close"),
208
- timeSlotsLoading: v("booking_time_slots_loading"),
209
- timeSlotsUnavailable: v("booking_time_slots_unavailable"),
210
- timeSlotsLoadError: v("booking_time_slots_load_error"),
211
- retryTimeSlots: v("booking_time_slots_retry")
212
- }), [S.language, v]), q = (e) => {
181
+ let W = p(() => new Map(ft.map((e) => [c(e.productId, e.productVariantId), e])), [ft]), G = p(() => E.map((e) => ({
182
+ ...e,
183
+ availabilityStatus: Ue(e, W)
184
+ })), [W, E]), pt = p(() => D.map((e) => ({
185
+ ...e,
186
+ availabilityStatus: Ue(e, W)
187
+ })), [D, W]), mt = (e, t) => {
188
+ let n = We(e, t, W);
189
+ return n ? le(n) : e.availabilityStatus === "OUT_OF_STOCK";
190
+ }, ht = (e) => (e.productVariants ?? []).length > 0, gt = (e, t) => {
191
+ let n = We(e, t, W);
192
+ return n ? Ge(l, n, ce(n)) : e.availabilityStatus === "OUT_OF_STOCK" ? l("availability_out_of_stock") : null;
193
+ }, _t = we(S), vt = p(() => ({
194
+ startDate: l("booking_start_date"),
195
+ pickStartDate: l("booking_start_date"),
196
+ startTime: l("booking_start_time"),
197
+ endDate: l("booking_end_date"),
198
+ pickEndDate: l("booking_end_date"),
199
+ endTime: l("booking_end_time"),
200
+ selectedDaysTooltip: ({ count: e }) => l("booking_selected_days_tooltip", { count: e }),
201
+ rentalPeriod: l("booking_rental_period"),
202
+ dateDrawerNext: l("booking_date_drawer_continue"),
203
+ closeDrawer: l("booking_date_drawer_close"),
204
+ timeSlotsLoading: l("booking_time_slots_loading"),
205
+ timeSlotsUnavailable: l("booking_time_slots_unavailable"),
206
+ timeSlotsLoadError: l("booking_time_slots_load_error"),
207
+ retryTimeSlots: l("booking_time_slots_retry")
208
+ }), [v.language, l]), K = (e) => {
213
209
  let t = {
214
- ...L,
210
+ ...I,
215
211
  ...e
216
212
  };
217
- b(L, t) || I((t) => {
213
+ b(I, t) || F((t) => {
218
214
  let n = {
219
215
  ...t.booking,
220
216
  ...e
@@ -224,74 +220,74 @@ function S() {
224
220
  shouldWriteToUrl: !0
225
221
  };
226
222
  });
227
- }, vt = {
228
- startDate: R,
223
+ }, yt = {
224
+ startDate: L,
229
225
  onStartDateChange: (e) => {
230
- e && q({ start_date: ze(e) });
226
+ e && K({ startDate: Be(e) });
231
227
  },
232
- startTime: L.start_time,
233
- onStartTimeChange: (e) => q({ start_time: e }),
234
- endDate: at,
228
+ startTime: I.startTime,
229
+ onStartTimeChange: (e) => K({ startTime: e }),
230
+ endDate: ot,
235
231
  onEndDateChange: (e) => {
236
- e && q({ end_date: ze(e) });
232
+ e && K({ endDate: Be(e) });
237
233
  },
238
- endTime: L.end_time,
239
- onEndTimeChange: (e) => q({ end_time: e }),
240
- bookingPeriodConfig: et,
234
+ endTime: I.endTime,
235
+ onEndTimeChange: (e) => K({ endTime: e }),
236
+ bookingPeriodConfig: tt,
241
237
  withMobileDateDrawer: !0,
242
- fetchTimeSlots: gt,
238
+ fetchTimeSlots: _t,
243
239
  onTimeSlotsConfirmationChange: (e) => {
244
- let t = e ? lt.current : void 0;
245
- ct.current !== t && (ct.current = t, I((e) => e.shouldWriteToUrl ? e : {
240
+ let t = e ? ut.current : void 0;
241
+ lt.current !== t && (lt.current = t, F((e) => e.shouldWriteToUrl ? e : {
246
242
  ...e,
247
243
  shouldWriteToUrl: !0
248
- }), st(t));
244
+ }), ct(t));
249
245
  },
250
- labels: _t,
251
- localeCode: S.language
252
- }, yt = re(L, T.bookingEngine.pricing, T.bookingEngine.shop.timeZone)?.billableUnitCount, J = p(() => ae({
253
- items: Ye,
254
- language: S.language,
255
- fallbackLanguage: E,
246
+ labels: vt,
247
+ localeCode: v.language
248
+ }, bt = re(I, w.bookingEngine.pricing, w.bookingEngine.shop.timeZone)?.billableUnitCount, q = p(() => ae({
249
+ items: Xe,
250
+ language: v.language,
251
+ fallbackLanguage: T,
256
252
  products: {
257
- bikes: qe,
258
- accessories: Je
253
+ bikes: Je,
254
+ accessories: Ye
259
255
  },
260
- priceUnit: N,
261
- billableUnitCount: yt
256
+ priceUnit: M,
257
+ billableUnitCount: bt
262
258
  }), [
263
- yt,
264
- Je,
265
- qe,
266
- S.language,
259
+ bt,
267
260
  Ye,
268
- N,
269
- E
270
- ]), Y = p(() => J.lines.map((e) => ({
261
+ Je,
262
+ v.language,
263
+ Xe,
264
+ M,
265
+ T
266
+ ]), J = p(() => q.lines.map((e) => ({
271
267
  productId: e.checkoutProductId,
272
268
  productVariantId: e.productVariantId,
273
269
  quantity: e.quantity
274
- })), [J.lines]), [bt, xt] = h([]);
270
+ })), [q.lines]), [xt, Y] = h([]);
275
271
  f(() => {
276
- if (!C || Y.length === 0) {
277
- xt([]);
272
+ if (!S || J.length === 0) {
273
+ Y([]);
278
274
  return;
279
275
  }
280
- let e = z ? u(L) : null;
276
+ let e = R ? u(I) : null;
281
277
  if (!e) {
282
- xt([]);
278
+ Y([]);
283
279
  return;
284
280
  }
285
281
  let t = !1;
286
282
  return (async () => {
287
283
  try {
288
- let n = await Se(oe, {
289
- storeSlug: C,
284
+ let n = await Ce(oe, {
285
+ storeSlug: S,
290
286
  schedule: e,
291
- products: Y
292
- }), r = le.parse(n);
287
+ products: J
288
+ }), r = ue.parse(n);
293
289
  if (t) return;
294
- xt(r.success ? r.availability ?? [] : []);
290
+ Y(r.success ? r.availability ?? [] : []);
295
291
  } catch (e) {
296
292
  if (t) return;
297
293
  console.error("Failed to load storefront cart availability", e);
@@ -300,17 +296,17 @@ function S() {
300
296
  t = !0;
301
297
  };
302
298
  }, [
303
- L.end_date,
304
- L.end_time,
305
- L.start_date,
306
- L.start_time,
307
- z,
308
- Y,
309
- C
299
+ I.endDate,
300
+ I.endTime,
301
+ I.startDate,
302
+ I.startTime,
303
+ R,
304
+ J,
305
+ S
310
306
  ]);
311
- let St = p(() => new Map(bt.map((e) => [c(e.productId, e.productVariantId), e])), [bt]), Ct = p(() => ({
312
- ...J,
313
- lines: J.lines.map((e) => {
307
+ let St = p(() => new Map(xt.map((e) => [c(e.productId, e.productVariantId), e])), [xt]), Ct = p(() => ({
308
+ ...q,
309
+ lines: q.lines.map((e) => {
314
310
  let t = St.get(c(e.checkoutProductId, e.productVariantId)), n = t ? se(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
315
311
  return {
316
312
  ...e,
@@ -318,30 +314,30 @@ function S() {
318
314
  availabilityIssue: n
319
315
  };
320
316
  })
321
- }), [St, J]), X = e(new URLSearchParams(), {
322
- ...L,
323
- start_time: B,
324
- end_time: V
325
- }).toString(), Z = z && u(L) !== null, wt = `/${C ?? ""}${X ? `?${X}` : ""}`, Tt = `/${C ?? ""}/booking${X ? `?${X}` : ""}`, Et = `/${C ?? ""}/checkout${X ? `?${X}` : ""}`, Dt = { backTo: `${w.pathname}${w.search}${w.hash}` }, [Ot, kt] = h(null), At = K.findIndex((e) => e.id === Ot), jt = k.get(y)?.trim() ?? "", Q = jt ? K.find((e) => e.id === jt) ?? ft.find((e) => e.id === jt) ?? null : null, $ = (e) => {
326
- let t = new URLSearchParams(k);
327
- e?.trim() ? t.set(y, e) : t.delete(y), A(t, { replace: !0 });
317
+ }), [St, q]), X = e(new URLSearchParams(), {
318
+ ...I,
319
+ startTime: z,
320
+ endTime: B
321
+ }).toString(), Z = R && u(I) !== null, wt = `/${S ?? ""}${X ? `?${X}` : ""}`, Tt = `/${S ?? ""}/booking${X ? `?${X}` : ""}`, Et = `/${S ?? ""}/checkout${X ? `?${X}` : ""}`, Dt = { backTo: `${C.pathname}${C.search}${C.hash}` }, [Ot, kt] = h(null), At = G.findIndex((e) => e.id === Ot), jt = O.get(y)?.trim() ?? "", Q = jt ? G.find((e) => e.id === jt) ?? pt.find((e) => e.id === jt) ?? null : null, $ = (e) => {
322
+ let t = new URLSearchParams(O);
323
+ e?.trim() ? t.set(y, e) : t.delete(y), k(t, { replace: !0 });
328
324
  }, Mt = (e) => {
329
325
  x(e) && $(e.id);
330
326
  }, Nt = (e, t, n = 1) => {
331
327
  if (!Z) return;
332
328
  let r = Math.max(1, Math.floor(n));
333
- Ze({
329
+ Qe({
334
330
  kind: e.kind,
335
331
  productId: s(e),
336
332
  ...t ? { productVariantId: t } : {},
337
333
  quantity: r
338
- }), he.success(v("product_added_to_cart_successfully", {
334
+ }), ge.success(l("product_added_to_cart_successfully", {
339
335
  quantity: r,
340
336
  productName: te({
341
337
  product: e,
342
338
  productVariantId: t,
343
- language: S.language,
344
- fallbackLanguage: E
339
+ language: v.language,
340
+ fallbackLanguage: T
345
341
  })
346
342
  }));
347
343
  }, Pt = (e) => {
@@ -356,13 +352,13 @@ function S() {
356
352
  Nt(e, n);
357
353
  }
358
354
  };
359
- return /* @__PURE__ */ _(ke, { children: [/* @__PURE__ */ g(Te, {
355
+ return /* @__PURE__ */ _(Ae, { children: [/* @__PURE__ */ g(Ee, {
360
356
  currentStep: "booking",
361
357
  bookingPath: Tt,
362
358
  checkoutPath: Et,
363
- checkoutEnabled: Xe > 0 && Z,
359
+ checkoutEnabled: Ze > 0 && Z,
364
360
  backPath: wt,
365
- backLabel: v("back_to_home"),
361
+ backLabel: l("back_to_home"),
366
362
  children: /* @__PURE__ */ _("div", {
367
363
  className: "grid gap-6 lg:grid-cols-12",
368
364
  children: [/* @__PURE__ */ g("div", {
@@ -375,53 +371,55 @@ function S() {
375
371
  children: [
376
372
  /* @__PURE__ */ g(d, {
377
373
  stepNumber: 1,
378
- title: v("booking_summary_title")
374
+ title: l("booking_summary_title")
379
375
  }),
380
- /* @__PURE__ */ g(ge, {
381
- ...vt,
376
+ /* @__PURE__ */ g(_e, {
377
+ ...yt,
382
378
  className: "gap-3",
383
379
  labelClassName: "text-xs font-medium text-slate-700",
384
380
  inputClassName: "h-10"
385
381
  }),
386
- /* @__PURE__ */ g(we, {
387
- value: L.fulfillment,
388
- onValueChange: (e) => q({ fulfillment: e }),
389
- pickupAddress: nt,
390
- deliveryEnabled: M,
391
- deliveryDisabledReason: tt,
392
- startAddress: L.start_address,
393
- onStartAddressChange: (e) => q({ start_address: e }),
394
- endAddress: L.end_address,
395
- onEndAddressChange: (e) => q({ end_address: e }),
382
+ /* @__PURE__ */ g(Te, {
383
+ value: I.fulfillment,
384
+ onValueChange: (e) => K({ fulfillment: e }),
385
+ pickupAddress: rt,
386
+ deliveryEnabled: j,
387
+ deliveryDisabledReason: nt,
388
+ startAddress: I.startAddress,
389
+ onStartAddressChange: (e) => K({ startAddress: e }),
390
+ endAddress: I.endAddress,
391
+ onEndAddressChange: (e) => K({ endAddress: e }),
396
392
  showPickupAddressWhenPickupOnly: !1,
397
393
  testIdPrefix: "storefront-booking-fulfillment"
398
394
  })
399
395
  ]
400
396
  }),
401
397
  /* @__PURE__ */ _("div", {
402
- ref: Ke,
398
+ ref: qe,
403
399
  id: "booking-products",
404
400
  className: "space-y-2 scroll-mt-32",
405
401
  children: [/* @__PURE__ */ g(d, {
406
402
  stepNumber: 2,
407
- title: v("products_title")
403
+ title: l("products_title")
408
404
  }), /* @__PURE__ */ g("p", {
409
405
  className: "text-sm text-slate-600",
410
- children: /* @__PURE__ */ g("span", { children: v("products_description") })
406
+ children: /* @__PURE__ */ g("span", { children: l("products_description") })
411
407
  })]
412
408
  }),
413
409
  /* @__PURE__ */ g("div", {
414
410
  className: "grid gap-4 md:grid-cols-2",
415
- children: K.map((e, t) => {
416
- let n = `/${C ?? ""}/products/${e.slug}`, r = !!x(e) || mt(e);
417
- return /* @__PURE__ */ g(Ee, {
411
+ children: G.map((e, t) => {
412
+ let n = `/${S ?? ""}/products/${e.slug}`, r = !!x(e) || ht(e);
413
+ return /* @__PURE__ */ g(De, {
418
414
  bike: e,
419
415
  detailsPath: n,
420
416
  productDetailsLinkState: Dt,
421
417
  onAction: () => Pt(e),
422
418
  actionDisabled: !r || !Z,
423
- fallbackLanguage: E,
424
- dimOnColumnCount: Re(At, t),
419
+ fallbackLanguage: T,
420
+ getVariantAvailabilityLabel: (t) => gt(e, t),
421
+ isVariantOutOfCapacity: (t) => mt(e, t),
422
+ dimOnColumnCount: ze(At, t),
425
423
  onQuickAdd: (t, n) => Nt(e, t, n),
426
424
  onHoverStart: () => kt(e.id),
427
425
  onHoverEnd: () => {
@@ -435,24 +433,24 @@ function S() {
435
433
  className: "space-y-2 pt-4",
436
434
  children: [/* @__PURE__ */ g(d, {
437
435
  stepNumber: 3,
438
- title: v("accessories_title")
436
+ title: l("accessories_title")
439
437
  }), /* @__PURE__ */ g("p", {
440
438
  className: "text-sm text-slate-600",
441
- children: /* @__PURE__ */ g("span", { children: v("accessories_description") })
439
+ children: /* @__PURE__ */ g("span", { children: l("accessories_description") })
442
440
  })]
443
441
  }),
444
442
  /* @__PURE__ */ g("div", {
445
443
  className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
446
- children: ft.map((e) => {
447
- let t = o(e.name, S.language, E), n = o(e.description, S.language, E), r = o(e.warning, S.language, E), i = typeof e.images?.[0] == "string" ? e.images[0].trim() : "", a = xe(e.primaryImageStyle), ee = `/${C ?? ""}/products/${e.slug}`, s = x(e), te = e.availabilityStatus === "OUT_OF_STOCK", ne = !!s || mt(e);
448
- return /* @__PURE__ */ g(_e, {
444
+ children: pt.map((e) => {
445
+ let t = o(e.name, v.language, T), n = o(e.description, v.language, T), r = o(e.warning, v.language, T), i = typeof e.images?.[0] == "string" ? e.images[0].trim() : "", a = Se(e.primaryImageStyle), ee = `/${S ?? ""}/products/${e.slug}`, s = x(e), te = e.availabilityStatus === "OUT_OF_STOCK", ne = !!s || ht(e);
446
+ return /* @__PURE__ */ g(ve, {
449
447
  "data-testid": `storefront-booking-accessory-card-${e.id}`.toLowerCase(),
450
448
  className: "h-full border-slate-200 bg-white shadow-sm transition-[border-color,box-shadow] duration-200 hover:border-primary/20 hover:shadow-md",
451
449
  children: /* @__PURE__ */ _("div", {
452
450
  className: "flex h-full flex-col gap-2 p-3",
453
451
  children: [
454
452
  /* @__PURE__ */ _("div", {
455
- className: Fe("relative aspect-[1618/1000] overflow-hidden rounded-xl", a.className),
453
+ className: Ie("relative aspect-[1618/1000] overflow-hidden rounded-xl", a.className),
456
454
  style: a.style,
457
455
  children: [i ? /* @__PURE__ */ g("img", {
458
456
  src: i,
@@ -461,14 +459,14 @@ function S() {
461
459
  loading: "lazy"
462
460
  }) : /* @__PURE__ */ g("div", {
463
461
  className: "absolute inset-0 flex items-center justify-center text-slate-400",
464
- children: /* @__PURE__ */ g(Ie, {
462
+ children: /* @__PURE__ */ g(Le, {
465
463
  className: "h-8 w-8",
466
464
  "aria-hidden": "true"
467
465
  })
468
- }), te ? /* @__PURE__ */ g(ue, {
466
+ }), te ? /* @__PURE__ */ g(de, {
469
467
  variant: "destructive",
470
468
  className: "pointer-events-none absolute right-2 top-2 shadow-sm",
471
- children: /* @__PURE__ */ g("span", { children: v("availability_out_of_stock") })
469
+ children: /* @__PURE__ */ g("span", { children: l("availability_out_of_stock") })
472
470
  }) : null]
473
471
  }),
474
472
  /* @__PURE__ */ _("div", {
@@ -479,7 +477,7 @@ function S() {
479
477
  children: [/* @__PURE__ */ g("p", {
480
478
  className: "min-w-0 text-sm font-semibold text-slate-950",
481
479
  children: /* @__PURE__ */ g("span", { children: t })
482
- }), /* @__PURE__ */ g(be, {
480
+ }), /* @__PURE__ */ g(xe, {
483
481
  prices: e.prices,
484
482
  className: "shrink-0",
485
483
  openOnHover: !1
@@ -489,7 +487,7 @@ function S() {
489
487
  className: "line-clamp-2 text-xs text-slate-600",
490
488
  children: /* @__PURE__ */ g("span", { children: n })
491
489
  }),
492
- /* @__PURE__ */ g(ve, {
490
+ /* @__PURE__ */ g(ye, {
493
491
  warning: r,
494
492
  className: "mt-1"
495
493
  })
@@ -497,18 +495,18 @@ function S() {
497
495
  }),
498
496
  /* @__PURE__ */ _("div", {
499
497
  className: "mt-auto flex items-center gap-2",
500
- children: [/* @__PURE__ */ g(Ae, {
498
+ children: [/* @__PURE__ */ g(je, {
501
499
  to: ee,
502
500
  state: Dt,
503
501
  className: "text-xs font-medium text-slate-700 hover:text-slate-950",
504
- children: /* @__PURE__ */ g("span", { children: v("product_details_link") })
505
- }), /* @__PURE__ */ _(de, {
502
+ children: /* @__PURE__ */ g("span", { children: l("product_details_link") })
503
+ }), /* @__PURE__ */ _(fe, {
506
504
  type: "button",
507
505
  size: "sm",
508
506
  className: "ml-auto gap-2",
509
507
  onClick: () => Ft(e),
510
508
  disabled: !ne || !Z,
511
- children: [/* @__PURE__ */ g("span", { children: v("add_to_cart") }), /* @__PURE__ */ g(Le, {
509
+ children: [/* @__PURE__ */ g("span", { children: l("add_to_cart") }), /* @__PURE__ */ g(Re, {
512
510
  className: "h-4 w-4",
513
511
  "aria-hidden": "true"
514
512
  })]
@@ -523,28 +521,28 @@ function S() {
523
521
  })
524
522
  }), /* @__PURE__ */ g("div", {
525
523
  className: "min-w-0 lg:col-span-4",
526
- children: /* @__PURE__ */ g(ye, {
524
+ children: /* @__PURE__ */ g(be, {
527
525
  lines: Ct.lines,
528
- itemCount: Xe,
529
- baseUnitLabel: rt,
526
+ itemCount: Ze,
527
+ baseUnitLabel: it,
530
528
  totalMinor: Ct.totalMinor,
531
529
  checkoutPath: Et,
532
530
  showCheckoutAction: Z,
533
531
  editable: !0,
534
532
  stickyTopClassName: "top-32",
535
- onQuantityChange: $e,
536
- onRemove: Qe
533
+ onQuantityChange: et,
534
+ onRemove: $e
537
535
  })
538
536
  })]
539
537
  })
540
- }), /* @__PURE__ */ g(De, {
538
+ }), /* @__PURE__ */ g(Oe, {
541
539
  open: !!Q,
542
540
  product: Q,
543
541
  onOpenChange: (e) => {
544
542
  e || $(null);
545
543
  },
546
- getVariantAvailabilityLabel: (e) => Q ? ht(Q, e) : null,
547
- isVariantOutOfCapacity: (e) => Q ? pt(Q, e) : !1,
544
+ getVariantAvailabilityLabel: (e) => Q ? gt(Q, e) : null,
545
+ isVariantOutOfCapacity: (e) => Q ? mt(Q, e) : !1,
548
546
  addDisabled: !Z,
549
547
  onAddVariant: (e, t) => {
550
548
  Q && (Nt(Q, e, t), $(null));