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