@msm-platform/customer-react 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,15 +4,55 @@ import { createCustomerClient as l, isCustomerApiError as u } from "@msm-platfor
4
4
  import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
5
5
  import { Metadata as m, getCountries as h, getCountryCallingCode as g, parsePhoneNumberFromString as _, validatePhoneNumberLength as v } from "libphonenumber-js";
6
6
  import y from "libphonenumber-js/min/metadata";
7
+ // src/client.ts
8
+ var b = ["x-msm-session", "x-msm-registration"], x = /* @__PURE__ */ new Map();
9
+ function S(e, t) {
10
+ t.headers.set("X-MSM-BFF", "1");
11
+ for (let [n, r] of x.get(e) ?? []) t.headers.set(n, r);
12
+ return t;
13
+ }
14
+ function C(e) {
15
+ return x.get(e)?.has("x-msm-session") ?? !1;
16
+ }
17
+ function w(e, t) {
18
+ for (let n of b) {
19
+ let r = t.headers.get(n);
20
+ if (r === null) continue;
21
+ let i = x.get(e) ?? /* @__PURE__ */ new Map();
22
+ x.set(e, i), r ? i.set(n, r) : i.delete(n);
23
+ }
24
+ }
25
+ async function T(e, t, n) {
26
+ let r = await fetch(S(e, new Request(`${e}${t}`, n)));
27
+ return w(e, r), r;
28
+ }
29
+ function E(e, t, n) {
30
+ return T(e, t, {
31
+ method: "POST",
32
+ headers: { "content-type": "application/json" },
33
+ body: JSON.stringify(n ?? {})
34
+ });
35
+ }
36
+ function D(e, t) {
37
+ let n = l({ baseUrl: `${e}/engine` });
38
+ return n.use({
39
+ onRequest({ request: t }) {
40
+ return S(e, t);
41
+ },
42
+ onResponse({ response: n }) {
43
+ w(e, n), n.status === 401 && t();
44
+ }
45
+ }), n;
46
+ }
7
47
  // src/context.ts
8
- var b = e(null);
9
- function x() {
10
- let e = n(b);
48
+ var O = e(null);
49
+ function k() {
50
+ let e = n(O);
11
51
  if (!e) throw Error("usePortal needs a customer screen component.");
12
52
  return e;
13
53
  }
14
54
  // src/i18n.ts
15
- var S = {
55
+ var A = {
16
56
  "app.loading": "Loading…",
17
57
  "app.loadFailed": "Something went wrong loading this page. Try again.",
18
58
  "app.retry": "Try again",
@@ -107,9 +147,6 @@ var S = {
107
147
  "business.full": "Full",
108
148
  "business.openTime": "Open time",
109
149
  "business.with": "With {resource}",
110
- "business.instructor": "Instructor: {names}",
111
- "business.room": "Room: {names}",
112
- "business.guests": "Guest instructors: {names}",
113
150
  "business.book": "Book",
114
151
  "book.heading": "Your booking",
115
152
  "book.signInFirst": "Sign in with your phone to book this time.",
@@ -129,6 +166,7 @@ var S = {
129
166
  "book.anyResource": "Anyone",
130
167
  "book.anyResourceHint": "The first free times with anyone who offers it",
131
168
  "book.toTypes": "Back to services",
169
+ "book.toStep": "Back",
132
170
  "book.otherResource": "Choose someone else",
133
171
  "book.reserveAgain": "Hold this time again",
134
172
  "book.full": "This class is full now. Choose another time.",
@@ -137,8 +175,29 @@ var S = {
137
175
  "book.expired": "We held this time for as long as we could, and it has lapsed. Hold it again if it's still free.",
138
176
  "book.notAllowed": "Booking this needs a membership or pass that covers it. Ask the business.",
139
177
  "book.unavailable": "This time can no longer be booked. Choose another.",
178
+ "book.banned": "You can't book online until {date} because of bookings you didn't show up to. Contact the business if you think this is a mistake.",
179
+ "book.banned.undated": "You can't book online right now because of bookings you didn't show up to. Contact the business if you think this is a mistake.",
140
180
  "book.refused": "This business can't take your booking. Contact them.",
141
181
  "book.failed": "The booking could not be made. Try again.",
182
+ "pay.price": "Price: {price}",
183
+ "pay.advance": "Pay {advance} now to book. The rest, {rest}, is paid later.",
184
+ "pay.whole": "Pay {advance} now to book.",
185
+ "pay.later": "Nothing to pay now; you pay {price} later.",
186
+ "pay.with": "Pay with {provider}",
187
+ "pay.none": "This business doesn't take payments online yet. Contact them to book.",
188
+ "pay.redirecting": "Taking you to the payment page…",
189
+ "pay.checking": "Checking your payment…",
190
+ "pay.away": "Finish paying in the new tab. You'll see your booking here as soon as the payment arrives.",
191
+ "pay.awayBlocked": "Open the payment page to pay. You'll see the result here as soon as the payment arrives.",
192
+ "pay.open": "Open the payment page",
193
+ "pay.tabDone": "You can close this tab. The page you came from shows whether your payment went through.",
194
+ "pay.notFinished": "You haven't finished paying. We're holding this time for you until {time}.",
195
+ "pay.again": "Go back to payment",
196
+ "pay.released": "Your payment didn't go through, so the time was released. Hold it again if it's still free.",
197
+ "pay.paidUnbooked": "We received your payment, but the time was taken before it arrived, so you're not booked. The business will contact you about your payment.",
198
+ "pay.slow": "Your payment is still being confirmed. Check your bookings in a few minutes.",
199
+ "pay.unavailable": "The payment page couldn't be opened. Try again in a moment.",
200
+ "pay.notOffered": "This way of paying isn't available. Choose another.",
142
201
  "passes.heading": "Memberships and passes",
143
202
  "passes.empty": "You have no memberships or passes.",
144
203
  "passes.unlimited": "Unlimited",
@@ -146,6 +205,15 @@ var S = {
146
205
  "passes.validFrom": "Valid from {date}",
147
206
  "passes.validRange": "Valid {from} – {until}",
148
207
  "passes.expired": "Expired",
208
+ "shop.heading": "Buy a membership or pass",
209
+ "shop.buy": "Buy with {provider}",
210
+ "shop.paid": "Thank you, your payment is received. The receipt comes from the payment provider, and your purchase shows here once it's ready.",
211
+ "shop.notPaid": "Your payment didn't go through, so nothing was bought.",
212
+ "shop.notFinished": "You haven't finished paying, so nothing was bought yet.",
213
+ "shop.away": "Finish paying in the new tab. You'll see here as soon as the payment arrives.",
214
+ "shop.slow": "Your payment is still being confirmed. Check back here in a few minutes.",
215
+ "shop.outside": "You can buy from {business} online once you're its customer. Book with them first, or ask them.",
216
+ "shop.gone": "This is no longer sold. Choose something else.",
149
217
  "details.heading": "My details",
150
218
  "details.name": "Name",
151
219
  "details.phone": "Phone",
@@ -159,73 +227,107 @@ var S = {
159
227
  "details.signOutEverywhere": "Sign out everywhere",
160
228
  "details.signOutEverywhereHint": "Ends your sessions on every phone and computer, including this one.",
161
229
  "details.signOutEverywhereFailed": "Could not sign out everywhere. Try again."
162
- }, C = "en-GB", w = S;
163
- function T(e, t = {}) {
164
- return w[e].replace(/\{(\w+)\}/g, (e, n) => {
230
+ }, j = "en-GB", M = A;
231
+ function N(e, t = {}) {
232
+ return M[e].replace(/\{(\w+)\}/g, (e, n) => {
165
233
  let r = t[n];
166
- return r === void 0 ? e : typeof r == "number" ? O(r) : r;
234
+ return r === void 0 ? e : typeof r == "number" ? ee(r) : r;
167
235
  });
168
236
  }
169
- var E = new Intl.PluralRules(C);
170
- function D(e, t, n = {}) {
171
- let r = `${e}.${E.select(t)}`;
172
- return T(r in w ? r : `${e}.other`, {
237
+ var P = new Intl.PluralRules(j);
238
+ function F(e, t, n = {}) {
239
+ let r = `${e}.${P.select(t)}`;
240
+ return N(r in M ? r : `${e}.other`, {
173
241
  count: t,
174
242
  ...n
175
243
  });
176
244
  }
177
- function O(e) {
178
- return new Intl.NumberFormat(C).format(e);
245
+ function I(e, t) {
246
+ let n = new Intl.NumberFormat(j, {
247
+ style: "currency",
248
+ currency: t
249
+ }), r = n.resolvedOptions().maximumFractionDigits ?? 0;
250
+ return n.format(e / 10 ** r);
179
251
  }
180
- function k(e, t) {
181
- return new Intl.DateTimeFormat(C, {
252
+ function ee(e) {
253
+ return new Intl.NumberFormat(j).format(e);
254
+ }
255
+ function L(e, t) {
256
+ return new Intl.DateTimeFormat(j, {
182
257
  dateStyle: "medium",
183
258
  timeStyle: "short",
184
259
  ...t && { timeZone: t }
185
260
  }).format(new Date(e));
186
261
  }
187
- function A(e, t) {
188
- return new Intl.DateTimeFormat(C, {
262
+ function R(e, t) {
263
+ return new Intl.DateTimeFormat(j, {
189
264
  timeStyle: "short",
190
265
  ...t && { timeZone: t }
191
266
  }).format(new Date(e));
192
267
  }
193
- function j(e, t) {
194
- return new Intl.DateTimeFormat(C, {
268
+ function z(e, t) {
269
+ return new Intl.DateTimeFormat(j, {
195
270
  dateStyle: "medium",
196
271
  ...t && { timeZone: t }
197
272
  }).format(new Date(e));
198
273
  }
199
- function M(e, t) {
200
- return new Intl.DateTimeFormat(C, {
274
+ function te(e, t) {
275
+ return new Intl.DateTimeFormat(j, {
201
276
  weekday: "long",
202
277
  day: "numeric",
203
278
  month: "long",
204
279
  ...t && { timeZone: t }
205
280
  }).format(new Date(e));
206
281
  }
207
- function N(e, t, n) {
208
- let r = j(e, n) === j(t, n);
209
- return T("bookings.when", {
210
- start: k(e, n),
211
- end: r ? A(t, n) : k(t, n)
282
+ function ne(e, t, n) {
283
+ let r = z(e, n) === z(t, n);
284
+ return N("bookings.when", {
285
+ start: L(e, n),
286
+ end: r ? R(t, n) : L(t, n)
212
287
  });
213
288
  }
214
- function ee(e) {
215
- if (e < 60) return D("wait.seconds", e);
289
+ function re(e) {
290
+ if (e < 60) return F("wait.seconds", e);
216
291
  let t = Math.round(e / 60);
217
- return t < 60 ? D("wait.minutes", t) : D("wait.hours", Math.round(e / 3600));
292
+ return t < 60 ? F("wait.minutes", t) : F("wait.hours", Math.round(e / 3600));
293
+ }
294
+ // src/payment-tab.ts
295
+ var ie = "msmTab";
296
+ function ae(e) {
297
+ if (C(e)) return { window: window.open("", "_blank") };
298
+ }
299
+ function oe(e, t) {
300
+ if (!e) return window.location.assign(t);
301
+ e.window && (e.window.opener = null, e.window.location.replace(t));
302
+ }
303
+ function B(e) {
304
+ e?.window?.close();
305
+ }
306
+ function V(e, t, n) {
307
+ let r = new URL(window.location.href);
308
+ return r.searchParams.set(e, t), n && r.searchParams.set(ie, ""), r.toString();
309
+ }
310
+ function se() {
311
+ return new URL(window.location.href).searchParams.has(ie);
312
+ }
313
+ function H(e) {
314
+ return new Promise((t) => {
315
+ let n = () => {
316
+ clearTimeout(r), document.removeEventListener("visibilitychange", n), t();
317
+ }, r = setTimeout(n, e);
318
+ document.addEventListener("visibilitychange", n);
319
+ });
218
320
  }
219
321
  // src/cancellation.ts
220
- function te(e, t) {
322
+ function ce(e, t) {
221
323
  if (e.status === "cancelled") return "cancelled";
222
324
  let n = t.getTime();
223
325
  return !e.cancellableUntil || n >= Date.parse(e.cancellableUntil) ? "closed" : e.lateCancellationFrom && n >= Date.parse(e.lateCancellationFrom) ? "late" : "open";
224
326
  }
225
327
  // src/screens/bookings.tsx
226
- var ne = "/web/businesses/{businessId}/bookings/{bookingId}/cancel";
227
- function P() {
228
- let { client: e } = x(), [n, i] = s("upcoming"), [a, o] = s(), [c, l] = s(null), [u, d] = s(!1), [m, h] = s(), g = t(async (t) => {
328
+ var le = "/web/businesses/{businessId}/bookings/{bookingId}/cancel";
329
+ function ue() {
330
+ let { client: e } = k(), [n, i] = s("upcoming"), [a, o] = s(), [c, l] = s(null), [u, d] = s(!1), [m, h] = s(), g = t(async (t) => {
229
331
  d(!1);
230
332
  try {
231
333
  let { data: r } = await e.GET("/web/me/bookings", { params: { query: {
@@ -243,28 +345,28 @@ function P() {
243
345
  }, [g]), /* @__PURE__ */ p("section", {
244
346
  className: "cp-screen",
245
347
  children: [
246
- /* @__PURE__ */ f("h1", { children: T("bookings.heading") }),
348
+ /* @__PURE__ */ f("h1", { children: N("bookings.heading") }),
247
349
  /* @__PURE__ */ f("fieldset", {
248
350
  className: "cp-tabs",
249
- "aria-label": T("bookings.period"),
351
+ "aria-label": N("bookings.period"),
250
352
  children: ["upcoming", "past"].map((e) => /* @__PURE__ */ f("button", {
251
353
  type: "button",
252
354
  "aria-pressed": n === e,
253
355
  onClick: () => i(e),
254
- children: T(e === "upcoming" ? "bookings.upcoming" : "bookings.past")
356
+ children: N(e === "upcoming" ? "bookings.upcoming" : "bookings.past")
255
357
  }, e))
256
358
  }),
257
359
  m && /* @__PURE__ */ f("p", {
258
360
  role: "status",
259
361
  className: "cp-notice",
260
- children: T(m)
362
+ children: N(m)
261
363
  }),
262
- u ? /* @__PURE__ */ f(F, { onRetry: () => g() }) : a ? a.length === 0 ? /* @__PURE__ */ f("p", {
364
+ u ? /* @__PURE__ */ f(U, { onRetry: () => g() }) : a ? a.length === 0 ? /* @__PURE__ */ f("p", {
263
365
  className: "cp-empty",
264
- children: T(n === "upcoming" ? "bookings.emptyUpcoming" : "bookings.emptyPast")
366
+ children: N(n === "upcoming" ? "bookings.emptyUpcoming" : "bookings.emptyPast")
265
367
  }) : /* @__PURE__ */ f("ul", {
266
368
  className: "cp-list",
267
- children: a.map((e) => /* @__PURE__ */ f(re, {
369
+ children: a.map((e) => /* @__PURE__ */ f(de, {
268
370
  booking: e,
269
371
  onCancelled: (e, t) => {
270
372
  o((t) => t?.map((t) => t.id === e.id ? e : t)), h(t ? "bookings.doneLate" : "bookings.doneOnTime");
@@ -272,35 +374,35 @@ function P() {
272
374
  }, e.id))
273
375
  }) : /* @__PURE__ */ f("p", {
274
376
  role: "status",
275
- children: T("app.loading")
377
+ children: N("app.loading")
276
378
  }),
277
379
  a && c && !u && /* @__PURE__ */ f("button", {
278
380
  type: "button",
279
381
  className: "cp-secondary",
280
382
  onClick: () => g(c),
281
- children: T("bookings.more")
383
+ children: N("bookings.more")
282
384
  })
283
385
  ]
284
386
  });
285
387
  }
286
- function F({ onRetry: e }) {
388
+ function U({ onRetry: e }) {
287
389
  return /* @__PURE__ */ p("div", {
288
390
  role: "alert",
289
391
  className: "cp-error",
290
- children: [/* @__PURE__ */ f("p", { children: T("app.loadFailed") }), /* @__PURE__ */ f("button", {
392
+ children: [/* @__PURE__ */ f("p", { children: N("app.loadFailed") }), /* @__PURE__ */ f("button", {
291
393
  type: "button",
292
394
  className: "cp-secondary",
293
395
  onClick: e,
294
- children: T("app.retry")
396
+ children: N("app.retry")
295
397
  })]
296
398
  });
297
399
  }
298
- function re(e) {
299
- let { client: t, businesses: n } = x(), { booking: r } = e, i = n.get(r.businessId)?.timezone, [a, o] = s(!1), [c, l] = s(!1), [d, m] = s(), [h, g] = s(!1), _ = h ? "closed" : te(r, /* @__PURE__ */ new Date()), v = r.creditMembershipId !== null && r.creditRestoredAt === null;
400
+ function de(e) {
401
+ let { client: t, businesses: n } = k(), { booking: r } = e, i = n.get(r.businessId)?.timezone, [a, o] = s(!1), [c, l] = s(!1), [d, m] = s(), [h, g] = s(!1), _ = h ? "closed" : ce(r, /* @__PURE__ */ new Date()), v = r.creditMembershipId !== null && r.creditRestoredAt === null;
300
402
  async function y() {
301
403
  l(!0), m(void 0);
302
404
  try {
303
- let { data: n } = await t.POST(ne, { params: { path: {
405
+ let { data: n } = await t.POST(le, { params: { path: {
304
406
  businessId: r.businessId,
305
407
  bookingId: r.id
306
408
  } } });
@@ -311,7 +413,7 @@ function re(e) {
311
413
  lateCancellationFrom: null
312
414
  }, n.cancelledLate === !0));
313
415
  } catch (e) {
314
- if (u(e, "post", ne)) {
416
+ if (u(e, "post", le)) {
315
417
  if (e.code === "EventStarted") {
316
418
  g(!0), o(!1);
317
419
  return;
@@ -334,37 +436,37 @@ function re(e) {
334
436
  className: "cp-card-head",
335
437
  children: [/* @__PURE__ */ f("h2", { children: r.event.eventTypeName }), r.status === "cancelled" ? /* @__PURE__ */ f("span", {
336
438
  className: "cp-badge",
337
- children: T(r.cancelledLate ? "bookings.cancelledLate" : "bookings.cancelled")
439
+ children: N(r.cancelledLate ? "bookings.cancelledLate" : "bookings.cancelled")
338
440
  }) : r.attendance ? /* @__PURE__ */ f("span", {
339
441
  className: "cp-badge",
340
- children: T(r.attendance === "attended" ? "bookings.attended" : "bookings.noShow")
442
+ children: N(r.attendance === "attended" ? "bookings.attended" : "bookings.noShow")
341
443
  }) : null]
342
444
  }),
343
445
  /* @__PURE__ */ f("p", { children: r.businessName }),
344
- /* @__PURE__ */ f("p", { children: N(r.event.startsAt, r.event.endsAt, i) }),
446
+ /* @__PURE__ */ f("p", { children: ne(r.event.startsAt, r.event.endsAt, i) }),
345
447
  (_ === "open" || _ === "late") && r.lateCancellationFrom && /* @__PURE__ */ f("p", {
346
448
  className: "cp-hint",
347
- children: T("bookings.lateFrom", { time: k(r.lateCancellationFrom, i) })
449
+ children: N("bookings.lateFrom", { time: L(r.lateCancellationFrom, i) })
348
450
  }),
349
451
  _ === "closed" && r.status === "confirmed" && !r.attendance && /* @__PURE__ */ f("p", {
350
452
  className: "cp-hint",
351
- children: T("bookings.started")
453
+ children: N("bookings.started")
352
454
  }),
353
455
  d && /* @__PURE__ */ f("p", {
354
456
  role: "alert",
355
- children: T(d)
457
+ children: N(d)
356
458
  }),
357
459
  (_ === "open" || _ === "late") && (a ? /* @__PURE__ */ p("fieldset", {
358
460
  className: "cp-confirm",
359
461
  children: [
360
- /* @__PURE__ */ f("legend", { children: T("bookings.confirmHeading") }),
462
+ /* @__PURE__ */ f("legend", { children: N("bookings.confirmHeading") }),
361
463
  _ === "late" && /* @__PURE__ */ f("p", {
362
464
  className: "cp-warning",
363
- children: T("bookings.confirmLate")
465
+ children: N("bookings.confirmLate")
364
466
  }),
365
467
  _ === "late" && v && /* @__PURE__ */ f("p", {
366
468
  className: "cp-warning",
367
- children: T("bookings.confirmCredit")
469
+ children: N("bookings.confirmCredit")
368
470
  }),
369
471
  /* @__PURE__ */ p("div", {
370
472
  className: "cp-actions",
@@ -372,13 +474,13 @@ function re(e) {
372
474
  type: "button",
373
475
  disabled: c,
374
476
  onClick: y,
375
- children: T(c ? "bookings.cancelling" : "bookings.confirm")
477
+ children: N(c ? "bookings.cancelling" : "bookings.confirm")
376
478
  }), /* @__PURE__ */ f("button", {
377
479
  type: "button",
378
480
  className: "cp-secondary",
379
481
  disabled: c,
380
482
  onClick: () => o(!1),
381
- children: T("bookings.keep")
483
+ children: N("bookings.keep")
382
484
  })]
383
485
  })
384
486
  ]
@@ -386,13 +488,13 @@ function re(e) {
386
488
  type: "button",
387
489
  className: "cp-secondary",
388
490
  onClick: () => o(!0),
389
- children: T("bookings.cancel")
491
+ children: N("bookings.cancel")
390
492
  }))
391
493
  ]
392
494
  });
393
495
  }
394
496
  // src/image.tsx
395
- function I(e) {
497
+ function W(e) {
396
498
  let { image: t, alt: n, className: r } = e;
397
499
  if (!t) return null;
398
500
  let { small: i } = t;
@@ -425,12 +527,12 @@ function I(e) {
425
527
  });
426
528
  }
427
529
  // src/screens/business.tsx
428
- var ie = "/web/businesses/{businessId}", ae = /* @__PURE__ */ new Set([
530
+ var fe = "/web/businesses/{businessId}", pe = /* @__PURE__ */ new Set([
429
531
  "BusinessNotFound",
430
532
  "OutsideClientScope",
431
533
  "ValidationFailed"
432
- ]), oe = 7;
433
- function se(e, t = /* @__PURE__ */ new Date()) {
534
+ ]), me = 7;
535
+ function he(e, t = /* @__PURE__ */ new Date()) {
434
536
  return new Intl.DateTimeFormat("en-CA", {
435
537
  timeZone: e,
436
538
  year: "numeric",
@@ -438,18 +540,18 @@ function se(e, t = /* @__PURE__ */ new Date()) {
438
540
  day: "2-digit"
439
541
  }).format(t);
440
542
  }
441
- function L(e, t) {
543
+ function G(e, t) {
442
544
  let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
443
545
  return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
444
546
  }
445
- function ce(e) {
446
- let { client: n } = x(), [i, a] = s(), [o, c] = s(), [l, d] = s(!1), f = t(async () => {
547
+ function ge(e) {
548
+ let { client: n } = k(), [i, a] = s(), [o, c] = s(), [l, d] = s(!1), f = t(async () => {
447
549
  d(!1), a(void 0);
448
550
  try {
449
- let [t, r] = await Promise.all([n.GET(ie, { params: { path: { businessId: e } } }), n.GET("/web/businesses/{businessId}/event-types", { params: { path: { businessId: e } } })]);
551
+ let [t, r] = await Promise.all([n.GET(fe, { params: { path: { businessId: e } } }), n.GET("/web/businesses/{businessId}/event-types", { params: { path: { businessId: e } } })]);
450
552
  a(t.data ?? null), c(r.data?.items ?? []);
451
553
  } catch (e) {
452
- u(e) && ae.has(e.code ?? "") ? a(null) : d(!0);
554
+ u(e) && pe.has(e.code ?? "") ? a(null) : d(!0);
453
555
  }
454
556
  }, [n, e]);
455
557
  return r(() => {
@@ -461,45 +563,45 @@ function ce(e) {
461
563
  reload: f
462
564
  };
463
565
  }
464
- function le(e, t) {
566
+ function _e(e, t) {
465
567
  if (e.failed) return /* @__PURE__ */ p("section", {
466
568
  className: "cp-screen",
467
- children: [t, /* @__PURE__ */ f(F, { onRetry: e.reload })]
569
+ children: [t, /* @__PURE__ */ f(U, { onRetry: e.reload })]
468
570
  });
469
571
  if (e.business === null) return /* @__PURE__ */ p("section", {
470
572
  className: "cp-screen",
471
573
  children: [t, /* @__PURE__ */ f("p", {
472
574
  className: "cp-empty",
473
- children: T("business.notFound")
575
+ children: N("business.notFound")
474
576
  })]
475
577
  });
476
578
  if (e.business === void 0 || !e.types) return /* @__PURE__ */ p("section", {
477
579
  className: "cp-screen",
478
580
  children: [t, /* @__PURE__ */ f("p", {
479
581
  role: "status",
480
- children: T("app.loading")
582
+ children: N("app.loading")
481
583
  })]
482
584
  });
483
585
  }
484
- function ue(e) {
586
+ function ve(e) {
485
587
  let t = /* @__PURE__ */ new Map();
486
588
  for (let n of e) for (let e of n.resources) t.has(e.id) || t.set(e.id, e);
487
589
  return [...t.values()];
488
590
  }
489
- function de(e) {
490
- let { navigate: t, accountNavigation: n } = x(), { businessId: r, eventTypeId: i, onFilter: a } = e, o = ce(r), s = n && /* @__PURE__ */ f("button", {
591
+ function ye(e) {
592
+ let { navigate: t, accountNavigation: n } = k(), { businessId: r, eventTypeId: i, onFilter: a } = e, o = ge(r), s = n && /* @__PURE__ */ f("button", {
491
593
  type: "button",
492
594
  className: "cp-link cp-back",
493
595
  onClick: () => t("businesses"),
494
- children: T("business.all")
495
- }), c = le(o, s), { business: l, types: u } = o;
596
+ children: N("business.all")
597
+ }), c = _e(o, s), { business: l, types: u } = o;
496
598
  if (c || !l || !u) return c;
497
- let m = u.find((e) => e.id === i), h = a ? ue(m ? [m] : u) : [], g = h.some((t) => t.id === e.resourceId) ? e.resourceId : void 0, _ = (e) => {
599
+ let m = u.find((e) => e.id === i), h = a ? ve(m ? [m] : u) : [], g = h.some((t) => t.id === e.resourceId) ? e.resourceId : void 0, _ = (e) => {
498
600
  if (!a) return t(e ? {
499
601
  businessId: r,
500
602
  eventTypeId: e
501
603
  } : { businessId: r });
502
- let n = u.find((t) => t.id === e), i = g && ue(n ? [n] : u).some((e) => e.id === g);
604
+ let n = u.find((t) => t.id === e), i = g && ve(n ? [n] : u).some((e) => e.id === g);
503
605
  a({
504
606
  ...e && { eventTypeId: e },
505
607
  ...i && { resourceId: g }
@@ -509,15 +611,15 @@ function de(e) {
509
611
  className: "cp-screen",
510
612
  children: [
511
613
  s,
512
- /* @__PURE__ */ f(fe, { business: l }),
614
+ /* @__PURE__ */ f(be, { business: l }),
513
615
  u.length > 0 && /* @__PURE__ */ p("fieldset", {
514
616
  className: "cp-chips",
515
- "aria-label": T("business.types"),
617
+ "aria-label": N("business.types"),
516
618
  children: [/* @__PURE__ */ f("button", {
517
619
  type: "button",
518
620
  "aria-pressed": !i,
519
621
  onClick: () => _(void 0),
520
- children: T("business.allTypes")
622
+ children: N("business.allTypes")
521
623
  }), u.map((e) => /* @__PURE__ */ f("button", {
522
624
  type: "button",
523
625
  "aria-pressed": e.id === i,
@@ -528,12 +630,12 @@ function de(e) {
528
630
  a && h.length > 1 && /* @__PURE__ */ p("fieldset", {
529
631
  className: "cp-chips",
530
632
  children: [
531
- /* @__PURE__ */ f("legend", { children: T("business.resources") }),
633
+ /* @__PURE__ */ f("legend", { children: N("business.resources") }),
532
634
  /* @__PURE__ */ f("button", {
533
635
  type: "button",
534
636
  "aria-pressed": !g,
535
637
  onClick: () => a({ ...i && { eventTypeId: i } }),
536
- children: T("business.anyResource")
638
+ children: N("business.anyResource")
537
639
  }),
538
640
  h.map((e) => /* @__PURE__ */ f("button", {
539
641
  type: "button",
@@ -548,8 +650,8 @@ function de(e) {
548
650
  }),
549
651
  i && !m ? /* @__PURE__ */ f("p", {
550
652
  className: "cp-empty",
551
- children: T("business.typeMissing")
552
- }) : /* @__PURE__ */ p(d, { children: [m && /* @__PURE__ */ f(R, { type: m }), /* @__PURE__ */ f(z, {
653
+ children: N("business.typeMissing")
654
+ }) : /* @__PURE__ */ p(d, { children: [m && /* @__PURE__ */ f(xe, { type: m }), /* @__PURE__ */ f(Se, {
553
655
  business: l,
554
656
  eventTypeId: i,
555
657
  resourceId: g,
@@ -558,12 +660,12 @@ function de(e) {
558
660
  ]
559
661
  });
560
662
  }
561
- function fe({ business: e }) {
663
+ function be({ business: e }) {
562
664
  return /* @__PURE__ */ p("header", {
563
665
  className: "cp-business-head",
564
- children: [/* @__PURE__ */ f(I, {
666
+ children: [/* @__PURE__ */ f(W, {
565
667
  image: e.logo,
566
- alt: T("image.logo", { name: e.displayName }),
668
+ alt: N("image.logo", { name: e.displayName }),
567
669
  size: "small",
568
670
  className: "cp-logo"
569
671
  }), /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("h1", { children: e.displayName }), e.address && /* @__PURE__ */ f("p", {
@@ -572,11 +674,11 @@ function fe({ business: e }) {
572
674
  })] })]
573
675
  });
574
676
  }
575
- function R({ type: e }) {
677
+ function xe({ type: e }) {
576
678
  return /* @__PURE__ */ p("div", {
577
679
  className: "cp-type",
578
680
  children: [
579
- /* @__PURE__ */ f(I, {
681
+ /* @__PURE__ */ f(W, {
580
682
  image: e.image,
581
683
  alt: e.displayName,
582
684
  size: "full",
@@ -586,13 +688,13 @@ function R({ type: e }) {
586
688
  e.description && /* @__PURE__ */ f("p", { children: e.description }),
587
689
  /* @__PURE__ */ f("p", {
588
690
  className: "cp-hint",
589
- children: T("business.minutes", { minutes: e.durationMinutes })
691
+ children: N("business.minutes", { minutes: e.durationMinutes })
590
692
  })
591
693
  ]
592
694
  });
593
695
  }
594
- function z(e) {
595
- let { client: n } = x(), { business: i, eventTypeId: a, resourceId: o } = e, c = i.timezone, [l, u] = s(0), [m, h] = s(), [g, _] = s(!1), v = L(se(c), l * oe), y = L(v, oe), b = t(async () => {
696
+ function Se(e) {
697
+ let { client: n } = k(), { business: i, eventTypeId: a, resourceId: o } = e, c = i.timezone, [l, u] = s(0), [m, h] = s(), [g, _] = s(!1), v = G(he(c), l * me), y = G(v, me), b = t(async () => {
596
698
  _(!1), h(void 0);
597
699
  try {
598
700
  let { data: e } = await n.GET("/web/businesses/{businessId}/availability", { params: {
@@ -619,70 +721,77 @@ function z(e) {
619
721
  r(() => {
620
722
  b();
621
723
  }, [b]);
622
- let S = Date.now(), C = /* @__PURE__ */ new Map();
724
+ let x = Date.now(), S = /* @__PURE__ */ new Map();
623
725
  for (let e of m ?? []) {
624
- if (Date.parse(e.startsAt) <= S) continue;
625
- let t = M(e.startsAt, e.timezone);
626
- C.set(t, [...C.get(t) ?? [], e]);
726
+ if (Date.parse(e.startsAt) <= x) continue;
727
+ let t = te(e.startsAt, e.timezone);
728
+ S.set(t, [...S.get(t) ?? [], e]);
627
729
  }
628
- let w = T("business.weekOf", {
629
- from: j(`${v}T12:00:00Z`, "UTC"),
630
- to: j(`${L(y, -1)}T12:00:00Z`, "UTC")
730
+ let C = N("business.weekOf", {
731
+ from: z(`${v}T12:00:00Z`, "UTC"),
732
+ to: z(`${G(y, -1)}T12:00:00Z`, "UTC")
631
733
  });
632
734
  return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("fieldset", {
633
735
  className: "cp-week",
634
- "aria-label": T("business.week"),
736
+ "aria-label": N("business.week"),
635
737
  children: [
636
738
  /* @__PURE__ */ f("button", {
637
739
  type: "button",
638
740
  className: "cp-secondary",
639
741
  disabled: l === 0,
640
742
  onClick: () => u((e) => e - 1),
641
- "aria-label": T("business.previousWeek"),
743
+ "aria-label": N("business.previousWeek"),
642
744
  children: "‹"
643
745
  }),
644
- /* @__PURE__ */ f("span", { children: w }),
746
+ /* @__PURE__ */ f("span", { children: C }),
645
747
  /* @__PURE__ */ f("button", {
646
748
  type: "button",
647
749
  className: "cp-secondary",
648
750
  onClick: () => u((e) => e + 1),
649
- "aria-label": T("business.nextWeek"),
751
+ "aria-label": N("business.nextWeek"),
650
752
  children: "›"
651
753
  })
652
754
  ]
653
- }), g ? /* @__PURE__ */ f(F, { onRetry: b }) : m ? C.size === 0 ? /* @__PURE__ */ f("p", {
755
+ }), g ? /* @__PURE__ */ f(U, { onRetry: b }) : m ? S.size === 0 ? /* @__PURE__ */ f("p", {
654
756
  className: "cp-empty",
655
- children: T("business.empty")
656
- }) : [...C].map(([t, n]) => /* @__PURE__ */ p("div", {
757
+ children: N("business.empty")
758
+ }) : [...S].map(([t, n]) => /* @__PURE__ */ p("div", {
657
759
  className: "cp-day",
658
760
  children: [/* @__PURE__ */ f("h2", { children: t }), /* @__PURE__ */ f("ul", {
659
761
  className: "cp-list",
660
- children: n.map((t) => /* @__PURE__ */ f(pe, {
762
+ children: n.map((t) => /* @__PURE__ */ f(we, {
661
763
  candidate: t,
662
764
  onChoose: () => e.onChoose(t)
663
765
  }, `${t.eventId ?? t.eventTypeId}-${t.resource?.id ?? ""}-${t.startsAt}`))
664
766
  })]
665
767
  }, t)) : /* @__PURE__ */ f("p", {
666
768
  role: "status",
667
- children: T("app.loading")
769
+ children: N("app.loading")
668
770
  })] });
669
771
  }
670
- function B({ candidate: e }) {
772
+ function Ce({ candidate: e }) {
671
773
  if (e.kind === "slot") return e.resource ? /* @__PURE__ */ f("p", {
672
774
  className: "cp-hint",
673
- children: T("business.with", { resource: e.resource.displayName })
775
+ children: N("business.with", { resource: e.resources?.[0]?.presentedAs?.name ?? e.resource.displayName })
674
776
  }) : null;
675
- let t = (e) => e.map((e) => e.displayName).join(", "), n = e.resources ?? [], [r, ...i] = n.filter((e) => e.person), a = n.filter((e) => !e.person), o = [
676
- r && T("business.instructor", { names: r.displayName }),
677
- a.length > 0 && T("business.room", { names: t(a) }),
678
- i.length > 0 && T("business.guests", { names: t(i) })
679
- ].filter((e) => typeof e == "string");
680
- return o.length > 0 ? /* @__PURE__ */ f("p", {
777
+ let t = [];
778
+ for (let n of e.resources ?? []) {
779
+ let { label: e, name: r } = n.presentedAs ?? {
780
+ label: null,
781
+ name: n.displayName
782
+ }, i = t.at(-1);
783
+ i && e !== null && i.label === e ? i.names.push(r) : t.push({
784
+ label: e,
785
+ names: [r]
786
+ });
787
+ }
788
+ let n = t.map(({ label: e, names: t }) => e === null ? t.join(", ") : `${e}: ${t.join(", ")}`);
789
+ return n.length > 0 ? /* @__PURE__ */ f("p", {
681
790
  className: "cp-hint cp-resources",
682
- children: o.join(" · ")
791
+ children: n.join(" · ")
683
792
  }) : null;
684
793
  }
685
- function pe(e) {
794
+ function we(e) {
686
795
  let { candidate: t } = e, n = t.kind === "slot";
687
796
  return /* @__PURE__ */ p("li", {
688
797
  className: "cp-card cp-candidate",
@@ -691,181 +800,421 @@ function pe(e) {
691
800
  /* @__PURE__ */ p("p", {
692
801
  className: "cp-time",
693
802
  children: [
694
- A(t.startsAt, t.timezone),
803
+ R(t.startsAt, t.timezone),
695
804
  " – ",
696
- A(t.endsAt, t.timezone)
805
+ R(t.endsAt, t.timezone)
697
806
  ]
698
807
  }),
699
808
  /* @__PURE__ */ p("div", {
700
809
  className: "cp-candidate-body",
701
810
  children: [
702
811
  /* @__PURE__ */ f("h3", { children: t.title }),
703
- /* @__PURE__ */ f(B, { candidate: t }),
812
+ /* @__PURE__ */ f(Ce, { candidate: t }),
704
813
  /* @__PURE__ */ f("p", {
705
814
  className: "cp-hint",
706
- children: n ? T("business.openTime") : t.full ? T("business.full") : D("business.seatsLeft", t.seatsLeft)
815
+ children: n ? N("business.openTime") : t.full ? N("business.full") : F("business.seatsLeft", t.seatsLeft)
707
816
  })
708
817
  ]
709
818
  }),
710
819
  !t.full && /* @__PURE__ */ f("button", {
711
820
  type: "button",
712
821
  onClick: e.onChoose,
713
- children: T("business.book")
822
+ children: N("business.book")
714
823
  })
715
824
  ]
716
825
  });
717
826
  }
718
827
  // src/booking.tsx
719
- var V = "/web/businesses/{businessId}/reservations", H = "/web/businesses/{businessId}/reservations/{reservationId}/confirm";
720
- function U({ choice: e }) {
828
+ var Te = "/web/businesses/{businessId}/reservations", Ee = "/web/businesses/{businessId}/reservations/{reservationId}/confirm", De = "/web/businesses/{businessId}/reservations/{reservationId}/checkout", K = "msmCheckout", Oe = (e) => `msm-checkout:${e.business.id}|${e.candidate.eventId ?? e.candidate.eventTypeId}|${Date.parse(e.candidate.startsAt)}`;
829
+ function ke(e) {
830
+ try {
831
+ return window.sessionStorage.getItem(Oe(e));
832
+ } catch {
833
+ return null;
834
+ }
835
+ }
836
+ function q(e, t) {
837
+ try {
838
+ t ? window.sessionStorage.setItem(Oe(e), t) : window.sessionStorage.removeItem(Oe(e));
839
+ } catch {}
840
+ }
841
+ var Ae = "msm-checkout-selection";
842
+ function je(e) {
843
+ try {
844
+ window.sessionStorage.setItem(Ae, JSON.stringify(e));
845
+ } catch {}
846
+ }
847
+ function Me() {
848
+ let e = new URL(window.location.href), t = e.searchParams.get(K);
849
+ if (t !== "paid" && t !== "back") return null;
850
+ e.searchParams.delete(K), window.history.replaceState(window.history.state, "", e.toString());
851
+ let n = null;
852
+ try {
853
+ let e = window.sessionStorage.getItem(Ae);
854
+ window.sessionStorage.removeItem(Ae), n = e ? JSON.parse(e) : null;
855
+ } catch {
856
+ n = null;
857
+ }
858
+ return {
859
+ outcome: t,
860
+ selection: n
861
+ };
862
+ }
863
+ function J({ choice: e }) {
721
864
  let { business: t, candidate: n } = e;
722
865
  return /* @__PURE__ */ p("div", {
723
866
  className: "cp-summary",
724
867
  children: [
725
868
  /* @__PURE__ */ f("h2", { children: n.title }),
726
869
  /* @__PURE__ */ f("p", { children: t.displayName }),
727
- /* @__PURE__ */ f("p", { children: N(n.startsAt, n.endsAt, n.timezone) }),
728
- /* @__PURE__ */ f(B, { candidate: n })
870
+ /* @__PURE__ */ f("p", { children: ne(n.startsAt, n.endsAt, n.timezone) }),
871
+ /* @__PURE__ */ f(Ce, { candidate: n })
729
872
  ]
730
873
  });
731
874
  }
732
- function me(e) {
733
- let { client: n, navigate: i, accountNavigation: a } = x(), { business: c, candidate: l } = e.choice, [m, h] = s({ step: "reserving" }), [g, _] = s(), v = t(async () => {
734
- h({ step: "reserving" });
875
+ function Ne(e) {
876
+ let { client: n, basePath: i, navigate: a, accountNavigation: c } = k(), { business: l, candidate: m } = e.choice, [h, g] = s({ step: "reserving" }), [_, v] = s(), y = t(async () => {
877
+ g({ step: "reserving" });
735
878
  try {
736
- let { data: e } = await n.POST(V, {
737
- params: { path: { businessId: c.id } },
738
- body: l.eventId ? { eventId: l.eventId } : {
739
- eventTypeId: l.eventTypeId,
740
- startsAt: l.startsAt,
741
- ...l.resource && { resourceId: l.resource.id }
879
+ let { data: e } = await n.POST(Te, {
880
+ params: { path: { businessId: l.id } },
881
+ body: m.eventId ? { eventId: m.eventId } : {
882
+ eventTypeId: m.eventTypeId,
883
+ startsAt: m.startsAt,
884
+ ...m.resource && { resourceId: m.resource.id }
742
885
  }
743
886
  });
744
- e && h({
745
- step: "held",
887
+ if (!e) return;
888
+ let t = (await n.GET("/web/businesses/{businessId}/event-types", { params: { path: { businessId: l.id } } }).then(({ data: e }) => e?.items ?? []).catch(() => [])).find((e) => e.id === m.eventTypeId)?.price;
889
+ if (!t) {
890
+ g({
891
+ step: "held",
892
+ reservationId: e.id,
893
+ expiresAt: e.expiresAt
894
+ });
895
+ return;
896
+ }
897
+ let r = await n.GET("/web/businesses/{businessId}/payment-methods", { params: { path: { businessId: l.id } } }).then(({ data: e }) => e?.items ?? []).catch(() => []);
898
+ g({
899
+ step: "pay",
746
900
  reservationId: e.id,
747
- expiresAt: e.expiresAt
901
+ expiresAt: e.expiresAt,
902
+ price: t,
903
+ methods: r
748
904
  });
749
905
  } catch (e) {
750
- let t = u(e, "post", V) ? e.code : void 0;
751
- h({
906
+ let t = u(e, "post", Te) ? e : void 0;
907
+ g({
752
908
  step: "refused",
753
- message: he(t),
909
+ ...Pe(t, Fe, m.timezone),
754
910
  again: !1
755
911
  });
756
912
  }
757
913
  }, [
758
914
  n,
759
- c.id,
760
- l
761
- ]), y = o(!1);
915
+ l.id,
916
+ m
917
+ ]), b = t(async (t) => {
918
+ let r = await n.GET("/web/businesses/{businessId}/bookings/{bookingId}", { params: { path: {
919
+ businessId: l.id,
920
+ bookingId: t
921
+ } } }).then(({ data: e }) => e ?? null).catch(() => null);
922
+ r && e.onBooked?.(r), g({
923
+ step: "booked",
924
+ booking: r
925
+ });
926
+ }, [
927
+ n,
928
+ l.id,
929
+ e.onBooked
930
+ ]), x = o(!0);
931
+ r(() => (x.current = !0, () => {
932
+ x.current = !1;
933
+ }), []);
934
+ let S = t(async (t, r, i) => {
935
+ g(i ? {
936
+ step: "away",
937
+ reservationId: t,
938
+ ...i
939
+ } : {
940
+ step: "checking",
941
+ reservationId: t
942
+ });
943
+ let a = i && Date.parse(i.expiresAt) + 3e5;
944
+ for (let o = 0; x.current; o++) {
945
+ let s = await n.GET(De, { params: { path: {
946
+ businessId: l.id,
947
+ reservationId: t
948
+ } } }).then(({ data: e }) => e).catch(() => void 0);
949
+ if (!x.current) return;
950
+ if (!s && a && Date.now() <= a) {
951
+ await H(3e3);
952
+ continue;
953
+ }
954
+ if (!s) {
955
+ q(e.choice, null), y();
956
+ return;
957
+ }
958
+ if (s.status === "confirmed" && s.bookingId) {
959
+ q(e.choice, null), b(s.bookingId);
960
+ return;
961
+ }
962
+ let c = r && s.status === "released" && (s.payment?.status === "PENDING" || s.payment?.status === "SUCCEEDED");
963
+ if (!c && (s.status === "released" || s.status === "unconfirmed_paid")) return q(e.choice, null), g({
964
+ step: "refused",
965
+ message: s.status === "released" ? "pay.released" : "pay.paidUnbooked",
966
+ again: s.status === "released"
967
+ });
968
+ if (!c && (!r || s.payment?.status === "FAILED")) return g({
969
+ step: "unfinished",
970
+ reservationId: t,
971
+ expiresAt: s.holdUntil,
972
+ redirectUrl: s.payment?.redirectUrl ?? null
973
+ });
974
+ if (a ? Date.now() > a : o >= 15) return g({
975
+ step: "refused",
976
+ message: "pay.slow",
977
+ again: !1
978
+ });
979
+ await H(i ? 3e3 : 2e3);
980
+ }
981
+ }, [
982
+ n,
983
+ l.id,
984
+ e.choice,
985
+ y,
986
+ b
987
+ ]), w = o(!1);
762
988
  r(() => {
763
- y.current || (y.current = !0, v());
764
- }, [v]);
765
- async function b(t, r) {
766
- h({
989
+ if (w.current) return;
990
+ w.current = !0;
991
+ let t = ke(e.choice);
992
+ t ? S(t, e.returned === "paid") : y();
993
+ }, [
994
+ y,
995
+ S,
996
+ e.choice,
997
+ e.returned
998
+ ]);
999
+ async function T(t, r) {
1000
+ let a = r ? ae(i) : void 0;
1001
+ g({
1002
+ ...t,
1003
+ paying: !0,
1004
+ notice: void 0
1005
+ });
1006
+ try {
1007
+ let { data: i } = await n.POST(De, {
1008
+ params: { path: {
1009
+ businessId: l.id,
1010
+ reservationId: t.reservationId
1011
+ } },
1012
+ body: {
1013
+ ...r && { paymentMethodId: r.id },
1014
+ successUrl: V(K, "paid", a),
1015
+ cancelUrl: V(K, "back", a)
1016
+ }
1017
+ }), o = i?.payment?.redirectUrl;
1018
+ if (i?.status === "pending" && o || B(a), !i) return;
1019
+ if (i.status === "confirmed" && i.bookingId) return void b(i.bookingId);
1020
+ if (i.status !== "pending" || !o) return g({
1021
+ ...t,
1022
+ paying: !1,
1023
+ notice: "pay.unavailable"
1024
+ });
1025
+ a || (q(e.choice, t.reservationId), e.onLeave?.()), oe(a, o), a && S(t.reservationId, !0, {
1026
+ expiresAt: t.expiresAt,
1027
+ redirectUrl: o,
1028
+ opened: !!a.window
1029
+ });
1030
+ } catch (e) {
1031
+ B(a);
1032
+ let n = u(e, "post", De) ? e : void 0;
1033
+ if (n?.code === "ReservationExpired") return g({
1034
+ step: "refused",
1035
+ message: "book.expired",
1036
+ again: !0
1037
+ });
1038
+ if (n?.code === "PaymentProviderNotOffered" || n?.code === "PaymentProviderNotConnected") return g({
1039
+ ...t,
1040
+ paying: !1,
1041
+ notice: "pay.notOffered"
1042
+ });
1043
+ if (n?.code === "PaymentProviderUnavailable" || n?.code === "PaymentProviderRejected" || n?.code === "PaymentCredentialsUnavailable") return g({
1044
+ ...t,
1045
+ paying: !1,
1046
+ notice: "pay.unavailable"
1047
+ });
1048
+ g({
1049
+ step: "refused",
1050
+ ...Pe(n, Ie, m.timezone),
1051
+ again: !1
1052
+ });
1053
+ }
1054
+ }
1055
+ async function E(t, r) {
1056
+ g({
767
1057
  step: "confirming",
768
1058
  reservationId: t,
769
1059
  expiresAt: r
770
1060
  });
771
1061
  try {
772
- let { data: r } = await n.POST(H, { params: { path: {
773
- businessId: c.id,
1062
+ let { data: r } = await n.POST(Ee, { params: { path: {
1063
+ businessId: l.id,
774
1064
  reservationId: t
775
1065
  } } });
776
1066
  if (!r) return;
777
1067
  e.onBooked?.(r);
778
1068
  let i = await n.GET("/web/businesses/{businessId}/bookings/{bookingId}", { params: { path: {
779
- businessId: c.id,
1069
+ businessId: l.id,
780
1070
  bookingId: r.id
781
1071
  } } }).then(({ data: e }) => e ?? null).catch(() => null);
782
- h({
1072
+ g({
783
1073
  step: "booked",
784
1074
  booking: i
785
1075
  });
786
1076
  } catch (e) {
787
- let t = u(e, "post", H) ? e.code : void 0;
788
- h(t === "ReservationExpired" || t === "ReservationNotFound" ? {
1077
+ let t = u(e, "post", Ee) ? e : void 0;
1078
+ t?.code === "ReservationExpired" || t?.code === "ReservationNotFound" ? g({
789
1079
  step: "refused",
790
1080
  message: "book.expired",
791
1081
  again: !0
792
- } : {
1082
+ }) : g({
793
1083
  step: "refused",
794
- message: ge(t),
1084
+ ...Pe(t, Ie, m.timezone),
795
1085
  again: !1
796
1086
  });
797
1087
  }
798
1088
  }
799
- let S = /* @__PURE__ */ f("button", {
1089
+ let D = /* @__PURE__ */ f("button", {
800
1090
  type: "button",
801
1091
  className: "cp-secondary",
802
1092
  onClick: e.onBack,
803
- children: T("book.back")
1093
+ children: N("book.back")
804
1094
  });
805
1095
  return /* @__PURE__ */ p("section", {
806
1096
  className: "cp-screen",
807
- children: [/* @__PURE__ */ f("h1", { children: T("book.heading") }), m.step === "booked" ? /* @__PURE__ */ p(d, { children: [
1097
+ children: [/* @__PURE__ */ f("h1", { children: N("book.heading") }), h.step === "booked" ? /* @__PURE__ */ p(d, { children: [
808
1098
  /* @__PURE__ */ f("p", {
809
1099
  role: "status",
810
1100
  className: "cp-notice",
811
- children: T(g ?? "book.booked")
1101
+ children: N(_ ?? "book.booked")
812
1102
  }),
813
- m.booking ? /* @__PURE__ */ f("ul", {
1103
+ h.booking ? /* @__PURE__ */ f("ul", {
814
1104
  className: "cp-list",
815
- children: /* @__PURE__ */ f(re, {
816
- booking: m.booking,
1105
+ children: /* @__PURE__ */ f(de, {
1106
+ booking: h.booking,
817
1107
  onCancelled: (e, t) => {
818
- h({
1108
+ g({
819
1109
  step: "booked",
820
1110
  booking: e
821
- }), _(t ? "bookings.doneLate" : "bookings.doneOnTime");
1111
+ }), v(t ? "bookings.doneLate" : "bookings.doneOnTime");
822
1112
  }
823
1113
  })
824
- }) : /* @__PURE__ */ f(U, { choice: e.choice }),
825
- a ? /* @__PURE__ */ f("button", {
1114
+ }) : /* @__PURE__ */ f(J, { choice: e.choice }),
1115
+ c ? /* @__PURE__ */ f("button", {
826
1116
  type: "button",
827
1117
  className: "cp-secondary",
828
- onClick: () => i("bookings"),
829
- children: T("book.toBookings")
1118
+ onClick: () => a("bookings"),
1119
+ children: N("book.toBookings")
830
1120
  }) : e.onDone && /* @__PURE__ */ f("button", {
831
1121
  type: "button",
832
1122
  className: "cp-secondary",
833
1123
  onClick: e.onDone,
834
- children: T("book.done")
1124
+ children: N("book.done")
835
1125
  })
836
1126
  ] }) : /* @__PURE__ */ p(d, { children: [
837
- /* @__PURE__ */ f(U, { choice: e.choice }),
838
- m.step === "reserving" && /* @__PURE__ */ f("p", {
1127
+ /* @__PURE__ */ f(J, { choice: e.choice }),
1128
+ h.step === "reserving" && /* @__PURE__ */ f("p", {
839
1129
  role: "status",
840
- children: T("book.reserving")
1130
+ children: N("book.reserving")
841
1131
  }),
842
- (m.step === "held" || m.step === "confirming") && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", {
1132
+ (h.step === "held" || h.step === "confirming") && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", {
843
1133
  className: "cp-hint",
844
- children: T("book.heldUntil", { time: A(m.expiresAt, l.timezone) })
1134
+ children: N("book.heldUntil", { time: R(h.expiresAt, m.timezone) })
845
1135
  }), /* @__PURE__ */ p("div", {
846
1136
  className: "cp-actions",
847
1137
  children: [/* @__PURE__ */ f("button", {
848
1138
  type: "button",
849
- disabled: m.step === "confirming",
850
- onClick: () => b(m.reservationId, m.expiresAt),
851
- children: m.step === "confirming" ? T("book.confirming") : T("book.confirm")
852
- }), S]
1139
+ disabled: h.step === "confirming",
1140
+ onClick: () => E(h.reservationId, h.expiresAt),
1141
+ children: h.step === "confirming" ? N("book.confirming") : N("book.confirm")
1142
+ }), D]
853
1143
  })] }),
854
- m.step === "refused" && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", {
1144
+ h.step === "pay" && /* @__PURE__ */ f(Le, {
1145
+ state: h,
1146
+ timeZone: m.timezone,
1147
+ onPay: (e) => T(h, e),
1148
+ back: D
1149
+ }),
1150
+ h.step === "checking" && /* @__PURE__ */ f("p", {
1151
+ role: "status",
1152
+ children: N("pay.checking")
1153
+ }),
1154
+ h.step === "away" && /* @__PURE__ */ p(d, { children: [
1155
+ /* @__PURE__ */ f("p", {
1156
+ role: "status",
1157
+ className: "cp-notice",
1158
+ children: N(h.opened ? "pay.away" : "pay.awayBlocked")
1159
+ }),
1160
+ /* @__PURE__ */ f("p", {
1161
+ className: "cp-hint",
1162
+ children: N("book.heldUntil", { time: R(h.expiresAt, m.timezone) })
1163
+ }),
1164
+ /* @__PURE__ */ p("div", {
1165
+ className: "cp-actions",
1166
+ children: [/* @__PURE__ */ f("a", {
1167
+ className: "cp-button",
1168
+ href: h.redirectUrl,
1169
+ target: "_blank",
1170
+ rel: "noopener",
1171
+ children: N("pay.open")
1172
+ }), D]
1173
+ })
1174
+ ] }),
1175
+ h.step === "unfinished" && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", {
1176
+ className: "cp-hint",
1177
+ children: N("pay.notFinished", { time: R(h.expiresAt, m.timezone) })
1178
+ }), /* @__PURE__ */ p("div", {
1179
+ className: "cp-actions",
1180
+ children: [h.redirectUrl && /* @__PURE__ */ f("a", {
1181
+ className: "cp-button",
1182
+ href: h.redirectUrl,
1183
+ ...C(i) ? {
1184
+ target: "_blank",
1185
+ rel: "noopener",
1186
+ onClick: () => void S(h.reservationId, !0, {
1187
+ expiresAt: h.expiresAt,
1188
+ redirectUrl: h.redirectUrl,
1189
+ opened: !0
1190
+ })
1191
+ } : { onClick: e.onLeave },
1192
+ children: N("pay.again")
1193
+ }), D]
1194
+ })] }),
1195
+ h.step === "refused" && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", {
855
1196
  role: "alert",
856
- children: T(m.message)
1197
+ children: N(h.message, h.date ? { date: h.date } : {})
857
1198
  }), /* @__PURE__ */ p("div", {
858
1199
  className: "cp-actions",
859
- children: [m.again && /* @__PURE__ */ f("button", {
1200
+ children: [h.again && /* @__PURE__ */ f("button", {
860
1201
  type: "button",
861
- onClick: v,
862
- children: T("book.reserveAgain")
863
- }), S]
1202
+ onClick: y,
1203
+ children: N("book.reserveAgain")
1204
+ }), D]
864
1205
  })] })
865
1206
  ] })]
866
1207
  });
867
1208
  }
868
- function he(e) {
1209
+ function Pe(e, t, n) {
1210
+ if (e?.code !== "BookingBanned") return { message: t(e?.code) };
1211
+ let { bannedUntil: r } = e.body ?? {};
1212
+ return r ? {
1213
+ message: "book.banned",
1214
+ date: z(r, n)
1215
+ } : { message: "book.banned.undated" };
1216
+ }
1217
+ function Fe(e) {
869
1218
  switch (e) {
870
1219
  case "EventFull": return "book.full";
871
1220
  case "SlotTaken": return "book.slotTaken";
@@ -880,7 +1229,7 @@ function he(e) {
880
1229
  default: return "book.failed";
881
1230
  }
882
1231
  }
883
- function ge(e) {
1232
+ function Ie(e) {
884
1233
  switch (e) {
885
1234
  case "NotAuthorized": return "book.notAllowed";
886
1235
  case "EventStarted":
@@ -890,8 +1239,54 @@ function ge(e) {
890
1239
  default: return "book.failed";
891
1240
  }
892
1241
  }
1242
+ function Le(e) {
1243
+ let { price: t, methods: n, paying: r, notice: i, expiresAt: a } = e.state, o = (e) => I(e, t.currency), s = t.advanceAmount;
1244
+ return /* @__PURE__ */ p(d, { children: [
1245
+ /* @__PURE__ */ f("p", {
1246
+ className: "cp-price",
1247
+ children: N("pay.price", { price: o(t.amount) })
1248
+ }),
1249
+ /* @__PURE__ */ f("p", {
1250
+ className: "cp-hint",
1251
+ children: s === 0 ? N("pay.later", { price: o(t.amount) }) : s === t.amount ? N("pay.whole", { advance: o(s) }) : N("pay.advance", {
1252
+ advance: o(s),
1253
+ rest: o(t.amount - s)
1254
+ })
1255
+ }),
1256
+ /* @__PURE__ */ f("p", {
1257
+ className: "cp-hint",
1258
+ children: N("book.heldUntil", { time: R(a, e.timeZone) })
1259
+ }),
1260
+ i && /* @__PURE__ */ f("p", {
1261
+ role: "alert",
1262
+ children: N(i)
1263
+ }),
1264
+ r && /* @__PURE__ */ f("p", {
1265
+ role: "status",
1266
+ children: N("pay.redirecting")
1267
+ }),
1268
+ s > 0 && n.length === 0 && /* @__PURE__ */ f("p", {
1269
+ role: "alert",
1270
+ children: N("pay.none")
1271
+ }),
1272
+ /* @__PURE__ */ p("div", {
1273
+ className: "cp-actions",
1274
+ children: [s === 0 ? /* @__PURE__ */ f("button", {
1275
+ type: "button",
1276
+ disabled: r,
1277
+ onClick: () => e.onPay(void 0),
1278
+ children: N("book.confirm")
1279
+ }) : n.map((t) => /* @__PURE__ */ f("button", {
1280
+ type: "button",
1281
+ disabled: r,
1282
+ onClick: () => e.onPay(t),
1283
+ children: N("pay.with", { provider: t.label })
1284
+ }, t.id)), e.back]
1285
+ })
1286
+ ] });
1287
+ }
893
1288
  // src/layout.tsx
894
- function _e({ brand: e }) {
1289
+ function Re({ brand: e }) {
895
1290
  return e ? /* @__PURE__ */ p("div", {
896
1291
  className: "cp-brand",
897
1292
  children: [e.logo && /* @__PURE__ */ f("img", {
@@ -900,38 +1295,38 @@ function _e({ brand: e }) {
900
1295
  }), /* @__PURE__ */ f("span", { children: e.name })]
901
1296
  }) : null;
902
1297
  }
903
- var ve = [["businesses", "nav.book"]], ye = [
1298
+ var ze = [["businesses", "nav.book"]], Be = [
904
1299
  ["bookings", "nav.bookings"],
905
1300
  ["passes", "nav.passes"],
906
1301
  ["details", "nav.details"]
907
- ], be = [...ve, ...ye];
908
- function xe(e) {
1302
+ ], Ve = [...ze, ...Be];
1303
+ function He(e) {
909
1304
  let t = typeof e.screen == "string" ? e.screen : "businesses";
910
1305
  return /* @__PURE__ */ p("div", {
911
1306
  className: "cp-shell",
912
1307
  children: [
913
1308
  /* @__PURE__ */ p("header", {
914
1309
  className: "cp-header",
915
- children: [/* @__PURE__ */ f(_e, { brand: e.brand }), e.signedIn ? /* @__PURE__ */ f("button", {
1310
+ children: [/* @__PURE__ */ f(Re, { brand: e.brand }), e.signedIn ? /* @__PURE__ */ f("button", {
916
1311
  type: "button",
917
1312
  className: "cp-link",
918
1313
  onClick: e.onSignOut,
919
- children: T("nav.signOut")
1314
+ children: N("nav.signOut")
920
1315
  }) : !e.signingIn && /* @__PURE__ */ f("button", {
921
1316
  type: "button",
922
1317
  className: "cp-link",
923
1318
  onClick: () => e.onNavigate("bookings"),
924
- children: T("nav.signIn")
1319
+ children: N("nav.signIn")
925
1320
  })]
926
1321
  }),
927
1322
  /* @__PURE__ */ f("nav", {
928
1323
  className: "cp-nav",
929
- "aria-label": T("nav.label"),
1324
+ "aria-label": N("nav.label"),
930
1325
  children: e.tabs.map(([n, r]) => /* @__PURE__ */ f("button", {
931
1326
  type: "button",
932
1327
  "aria-current": t === n ? "page" : void 0,
933
1328
  onClick: () => e.onNavigate(n),
934
- children: T(r)
1329
+ children: N(r)
935
1330
  }, n))
936
1331
  }),
937
1332
  /* @__PURE__ */ f("main", {
@@ -941,62 +1336,39 @@ function xe(e) {
941
1336
  ]
942
1337
  });
943
1338
  }
944
- // src/client.ts
945
- var Se = (e, t) => {
946
- let n = new Request(e, t);
947
- return n.headers.set("X-MSM-BFF", "1"), fetch(n);
948
- };
949
- function W(e, t, n) {
950
- return Se(`${e}${t}`, {
951
- method: "POST",
952
- headers: { "content-type": "application/json" },
953
- body: JSON.stringify(n ?? {})
954
- });
955
- }
956
- function Ce(e, t) {
957
- let n = l({ baseUrl: `${e}/engine` });
958
- return n.use({
959
- onRequest({ request: e }) {
960
- return e.headers.set("X-MSM-BFF", "1"), e;
961
- },
962
- onResponse({ response: e }) {
963
- e.status === 401 && t();
964
- }
965
- }), n;
966
- }
967
1339
  // src/session.ts
968
- var we = /* @__PURE__ */ new Map();
969
- function G(e) {
970
- let t = we.get(e);
1340
+ var Ue = /* @__PURE__ */ new Map();
1341
+ function We(e) {
1342
+ let t = Ue.get(e);
971
1343
  return t || (t = {
972
1344
  value: void 0,
973
1345
  listeners: /* @__PURE__ */ new Set(),
974
1346
  generation: 0
975
- }, we.set(e, t)), t;
1347
+ }, Ue.set(e, t)), t;
976
1348
  }
977
- function K(e, t) {
978
- let n = G(e);
1349
+ function Y(e, t) {
1350
+ let n = We(e);
979
1351
  if (n.value !== t) {
980
1352
  n.value = t;
981
1353
  for (let e of n.listeners) e();
982
1354
  }
983
1355
  }
984
- function Te(e, t) {
1356
+ function Ge(e, t) {
985
1357
  let { generation: n } = t, r = (r) => {
986
- t.generation === n && t.value === void 0 && K(e, r);
1358
+ t.generation === n && t.value === void 0 && Y(e, r);
987
1359
  };
988
- Se(`${e}/auth/session`).then(async (e) => r(e.ok ? (await e.json()).sessionKey : null)).catch(() => r(null));
1360
+ T(e, "/auth/session").then(async (e) => r(e.ok ? (await e.json()).sessionKey : null)).catch(() => r(null));
989
1361
  }
990
- function Ee(e, t) {
991
- let n = G(e);
992
- return n.listeners.size === 0 && n.value === void 0 && Te(e, n), n.listeners.add(t), () => {
1362
+ function Ke(e, t) {
1363
+ let n = We(e);
1364
+ return n.listeners.size === 0 && n.value === void 0 && Ge(e, n), n.listeners.add(t), () => {
993
1365
  n.listeners.delete(t), n.listeners.size === 0 && queueMicrotask(() => {
994
1366
  n.listeners.size > 0 || (n.value = void 0, n.generation++);
995
1367
  });
996
1368
  };
997
1369
  }
998
- function De(e, t) {
999
- let n = c((t) => Ee(e, t), () => G(e).value, () => void 0), i = o(void 0), a = o(t);
1370
+ function qe(e, t) {
1371
+ let n = c((t) => Ke(e, t), () => We(e).value, () => void 0), i = o(void 0), a = o(t);
1000
1372
  return a.current = t, r(() => {
1001
1373
  if (n === void 0) return;
1002
1374
  let e = n !== null;
@@ -1004,11 +1376,11 @@ function De(e, t) {
1004
1376
  }, [n]), n;
1005
1377
  }
1006
1378
  // src/portal.tsx
1007
- function q(e) {
1008
- let { navigate: n, accountNavigation: i } = e, c = e.basePath.replace(/\/$/, ""), l = De(c, e.onSessionChange), u = o(!1);
1379
+ function Je(e) {
1380
+ let { navigate: n, accountNavigation: i } = e, c = e.basePath.replace(/\/$/, ""), l = qe(c, e.onSessionChange), u = o(!1);
1009
1381
  u.current = !!l;
1010
- let [d, f] = s(), [p, m] = s(/* @__PURE__ */ new Map()), [h, g] = s("loading"), _ = a(() => Ce(c, () => {
1011
- u.current && f("app.signedOut"), K(c, null);
1382
+ let [d, f] = s(), [p, m] = s(/* @__PURE__ */ new Map()), [h, g] = s("loading"), _ = a(() => D(c, () => {
1383
+ u.current && f("app.signedOut"), Y(c, null);
1012
1384
  }), [c]), v = t(async () => {
1013
1385
  g("loading");
1014
1386
  try {
@@ -1034,13 +1406,14 @@ function q(e) {
1034
1406
  notice: d,
1035
1407
  portal: a(() => ({
1036
1408
  client: _,
1409
+ basePath: c,
1037
1410
  businesses: p,
1038
1411
  businessesStatus: h,
1039
1412
  reloadBusinesses: () => void v(),
1040
1413
  navigate: n,
1041
1414
  accountNavigation: i,
1042
1415
  signOut: async (e) => {
1043
- await W(c, "/auth/logout").catch(() => {}), f(e), K(c, null);
1416
+ await E(c, "/auth/logout").catch(() => {}), f(e), Y(c, null);
1044
1417
  }
1045
1418
  }), [
1046
1419
  _,
@@ -1052,43 +1425,50 @@ function q(e) {
1052
1425
  c
1053
1426
  ]),
1054
1427
  signedInAs: t((e) => {
1055
- f(void 0), K(c, e);
1428
+ f(void 0), Y(c, e);
1056
1429
  }, [c])
1057
1430
  };
1058
1431
  }
1059
- function J(e) {
1060
- return /* @__PURE__ */ f("div", {
1432
+ function Ye(e) {
1433
+ let [t, n] = s(!1);
1434
+ return r(() => {
1435
+ se() && (n(!0), window.close());
1436
+ }, []), /* @__PURE__ */ f("div", {
1061
1437
  className: "msm-customer",
1062
- children: e.loading ? /* @__PURE__ */ f("p", {
1438
+ children: t ? /* @__PURE__ */ f("p", {
1439
+ className: "cp-status",
1440
+ role: "status",
1441
+ children: N("pay.tabDone")
1442
+ }) : e.loading ? /* @__PURE__ */ f("p", {
1063
1443
  className: "cp-status",
1064
1444
  role: "status",
1065
- children: T("app.loading")
1066
- }) : /* @__PURE__ */ f(b.Provider, {
1445
+ children: N("app.loading")
1446
+ }) : /* @__PURE__ */ f(O.Provider, {
1067
1447
  value: e.portal,
1068
1448
  children: e.children
1069
1449
  })
1070
1450
  });
1071
1451
  }
1072
1452
  // src/screens/businesses.tsx
1073
- function Oe() {
1074
- let { businesses: e, businessesStatus: t, reloadBusinesses: n, navigate: r } = x(), i = [...e.values()];
1453
+ function Xe() {
1454
+ let { businesses: e, businessesStatus: t, reloadBusinesses: n, navigate: r } = k(), i = [...e.values()];
1075
1455
  return /* @__PURE__ */ p("section", {
1076
1456
  className: "cp-screen",
1077
- children: [/* @__PURE__ */ f("h1", { children: T("businesses.heading") }), t === "failed" ? /* @__PURE__ */ f(F, { onRetry: n }) : t === "loading" ? /* @__PURE__ */ f("p", {
1457
+ children: [/* @__PURE__ */ f("h1", { children: N("businesses.heading") }), t === "failed" ? /* @__PURE__ */ f(U, { onRetry: n }) : t === "loading" ? /* @__PURE__ */ f("p", {
1078
1458
  role: "status",
1079
- children: T("app.loading")
1459
+ children: N("app.loading")
1080
1460
  }) : i.length === 0 ? /* @__PURE__ */ f("p", {
1081
1461
  className: "cp-empty",
1082
- children: T("businesses.empty")
1462
+ children: N("businesses.empty")
1083
1463
  }) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", {
1084
1464
  className: "cp-hint",
1085
- children: T("businesses.intro")
1465
+ children: N("businesses.intro")
1086
1466
  }), /* @__PURE__ */ f("ul", {
1087
1467
  className: "cp-list",
1088
1468
  children: i.map((e) => /* @__PURE__ */ p("li", {
1089
1469
  className: "cp-card cp-business",
1090
1470
  children: [
1091
- /* @__PURE__ */ f(I, {
1471
+ /* @__PURE__ */ f(W, {
1092
1472
  image: e.logo,
1093
1473
  alt: "",
1094
1474
  size: "small",
@@ -1099,7 +1479,7 @@ function Oe() {
1099
1479
  /* @__PURE__ */ f("button", {
1100
1480
  type: "button",
1101
1481
  onClick: () => r({ businessId: e.id }),
1102
- children: T("businesses.open")
1482
+ children: N("businesses.open")
1103
1483
  })
1104
1484
  ]
1105
1485
  }, e.id))
@@ -1107,8 +1487,8 @@ function Oe() {
1107
1487
  });
1108
1488
  }
1109
1489
  // src/screens/details.tsx
1110
- function ke() {
1111
- let { client: e, signOut: n } = x(), [i, a] = s(), [o, c] = s(""), [l, u] = s(!1), [m, h] = s(!1), [g, _] = s(), v = t(async () => {
1490
+ function Ze() {
1491
+ let { client: e, signOut: n } = k(), [i, a] = s(), [o, c] = s(""), [l, u] = s(!1), [m, h] = s(!1), [g, _] = s(), v = t(async () => {
1112
1492
  u(!1);
1113
1493
  try {
1114
1494
  let { data: t } = await e.GET("/web/me");
@@ -1152,12 +1532,12 @@ function ke() {
1152
1532
  }
1153
1533
  return /* @__PURE__ */ p("section", {
1154
1534
  className: "cp-screen",
1155
- children: [/* @__PURE__ */ f("h1", { children: T("details.heading") }), l ? /* @__PURE__ */ f(F, { onRetry: v }) : i ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("form", {
1535
+ children: [/* @__PURE__ */ f("h1", { children: N("details.heading") }), l ? /* @__PURE__ */ f(U, { onRetry: v }) : i ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("form", {
1156
1536
  className: "cp-card cp-form",
1157
1537
  onSubmit: y,
1158
1538
  "aria-busy": m,
1159
1539
  children: [
1160
- /* @__PURE__ */ p("label", { children: [T("details.name"), /* @__PURE__ */ f("input", {
1540
+ /* @__PURE__ */ p("label", { children: [N("details.name"), /* @__PURE__ */ f("input", {
1161
1541
  value: o,
1162
1542
  onChange: (e) => c(e.target.value),
1163
1543
  autoComplete: "name",
@@ -1165,46 +1545,229 @@ function ke() {
1165
1545
  required: !0
1166
1546
  })] }),
1167
1547
  /* @__PURE__ */ p("dl", { children: [
1168
- /* @__PURE__ */ f("dt", { children: T("details.phone") }),
1169
- /* @__PURE__ */ f("dd", { children: i.phone ?? T("details.none") }),
1170
- /* @__PURE__ */ f("dt", { children: T("details.email") }),
1171
- /* @__PURE__ */ f("dd", { children: i.email ?? T("details.none") })
1548
+ /* @__PURE__ */ f("dt", { children: N("details.phone") }),
1549
+ /* @__PURE__ */ f("dd", { children: i.phone ?? N("details.none") }),
1550
+ /* @__PURE__ */ f("dt", { children: N("details.email") }),
1551
+ /* @__PURE__ */ f("dd", { children: i.email ?? N("details.none") })
1172
1552
  ] }),
1173
1553
  /* @__PURE__ */ f("p", {
1174
1554
  className: "cp-hint",
1175
- children: T("details.readOnly")
1555
+ children: N("details.readOnly")
1176
1556
  }),
1177
1557
  g && /* @__PURE__ */ f("p", {
1178
1558
  role: g.alert ? "alert" : "status",
1179
- children: T(g.key)
1559
+ children: N(g.key)
1180
1560
  }),
1181
1561
  /* @__PURE__ */ f("button", {
1182
1562
  type: "submit",
1183
1563
  disabled: m || !o.trim() || o.trim() === i.name,
1184
- children: T(m ? "details.saving" : "details.save")
1564
+ children: N(m ? "details.saving" : "details.save")
1185
1565
  })
1186
1566
  ]
1187
1567
  }), /* @__PURE__ */ p("div", {
1188
1568
  className: "cp-card cp-form",
1189
1569
  children: [/* @__PURE__ */ f("p", {
1190
1570
  className: "cp-hint",
1191
- children: T("details.signOutEverywhereHint")
1571
+ children: N("details.signOutEverywhereHint")
1192
1572
  }), /* @__PURE__ */ f("button", {
1193
1573
  type: "button",
1194
1574
  className: "cp-secondary",
1195
1575
  disabled: m,
1196
1576
  onClick: b,
1197
- children: T("details.signOutEverywhere")
1577
+ children: N("details.signOutEverywhere")
1198
1578
  })]
1199
1579
  })] }) : /* @__PURE__ */ f("p", {
1200
1580
  role: "status",
1201
- children: T("app.loading")
1581
+ children: N("app.loading")
1202
1582
  })]
1203
1583
  });
1204
1584
  }
1585
+ // src/screens/shop.tsx
1586
+ var Qe = "/web/businesses/{businessId}/products/{productId}/checkout", X = "msmPurchase", $e = "msm-purchase";
1587
+ function et() {
1588
+ let e = new URL(window.location.href), t = e.searchParams.get(X);
1589
+ if (t !== "paid" && t !== "back") return null;
1590
+ e.searchParams.delete(X), window.history.replaceState(window.history.state, "", e.toString());
1591
+ try {
1592
+ let e = window.sessionStorage.getItem($e);
1593
+ return window.sessionStorage.removeItem($e), e ? {
1594
+ outcome: t,
1595
+ purchase: JSON.parse(e)
1596
+ } : null;
1597
+ } catch {
1598
+ return null;
1599
+ }
1600
+ }
1601
+ function tt(e, t) {
1602
+ let n = o(!1);
1603
+ r(() => {
1604
+ n.current || (n.current = !0, e !== "passes" && !se() && new URL(window.location.href).searchParams.has(X) && t("passes"));
1605
+ }, [e, t]);
1606
+ }
1607
+ function nt() {
1608
+ let { client: e, basePath: n, businesses: i, businessesStatus: a } = k(), [c, l] = s([]), [m, h] = s(!1), [g, _] = s();
1609
+ r(() => {
1610
+ if (a !== "ready") return;
1611
+ let t = !0;
1612
+ return Promise.all([...i.values()].map(async (t) => {
1613
+ let n = { params: { path: { businessId: t.id } } }, [r, i] = await Promise.all([e.GET("/web/businesses/{businessId}/products", n), e.GET("/web/businesses/{businessId}/payment-methods", n)]).catch(() => [void 0, void 0]), a = i?.data?.items ?? [];
1614
+ return a.length ? (r?.data?.items ?? []).map((e) => ({
1615
+ business: t,
1616
+ product: e,
1617
+ methods: a
1618
+ })) : [];
1619
+ })).then((e) => {
1620
+ t && l(e.flat());
1621
+ }), () => {
1622
+ t = !1;
1623
+ };
1624
+ }, [
1625
+ e,
1626
+ i,
1627
+ a
1628
+ ]);
1629
+ let v = o(!0), y = o(0);
1630
+ r(() => (v.current = !0, () => {
1631
+ v.current = !1;
1632
+ }), []);
1633
+ let b = t(async (t, n, r) => {
1634
+ _(r ? {
1635
+ message: r.opened ? "shop.away" : "pay.awayBlocked",
1636
+ link: r.redirectUrl
1637
+ } : { message: "pay.checking" });
1638
+ let i = r && Date.now() + 9e5, a = ++y.current, o = () => v.current && y.current === a;
1639
+ for (let a = 0; o(); a++) {
1640
+ let { data: s } = await e.GET(Qe, { params: { path: n } }).catch(() => ({ data: void 0 }));
1641
+ if (!o()) return;
1642
+ if (!s && i && Date.now() <= i) {
1643
+ await H(3e3);
1644
+ continue;
1645
+ }
1646
+ if (s?.status === "paid") return _({ message: "shop.paid" });
1647
+ let c = s?.payment?.status === "FAILED" || s?.payment?.status === "EXPIRED";
1648
+ if (!s || c) return _({
1649
+ message: "shop.notPaid",
1650
+ alert: !0
1651
+ });
1652
+ if (t === "back") return _({ message: "shop.notFinished" });
1653
+ if (i ? Date.now() > i : a >= 15) return _({ message: "shop.slow" });
1654
+ await H(r ? 3e3 : 2e3);
1655
+ }
1656
+ }, [e]), x = o(!1);
1657
+ r(() => {
1658
+ if (x.current) return;
1659
+ x.current = !0;
1660
+ let e = et();
1661
+ e && b(e.outcome, e.purchase);
1662
+ }, [b]);
1663
+ async function S(t, r) {
1664
+ let i = ae(n);
1665
+ y.current++, h(!0), _(void 0);
1666
+ let a = {
1667
+ businessId: t.business.id,
1668
+ productId: t.product.id
1669
+ };
1670
+ try {
1671
+ let { data: t } = await e.POST(Qe, {
1672
+ params: { path: a },
1673
+ body: {
1674
+ paymentMethodId: r.id,
1675
+ successUrl: V(X, "paid", i),
1676
+ cancelUrl: V(X, "back", i)
1677
+ }
1678
+ }), n = t?.payment?.redirectUrl;
1679
+ if (t?.status !== "paid" && n || B(i), t?.status === "paid") return _({ message: "shop.paid" });
1680
+ if (!n) return _({
1681
+ message: "pay.unavailable",
1682
+ alert: !0
1683
+ });
1684
+ if (i) {
1685
+ oe(i, n), b("paid", a, {
1686
+ redirectUrl: n,
1687
+ opened: !!i.window
1688
+ });
1689
+ return;
1690
+ }
1691
+ try {
1692
+ window.sessionStorage.setItem($e, JSON.stringify(a));
1693
+ } catch {}
1694
+ _({ message: "pay.redirecting" }), oe(i, n);
1695
+ } catch (e) {
1696
+ B(i);
1697
+ let n = u(e, "post", Qe) ? e.code : void 0;
1698
+ _(n === "CustomerOutsideBusiness" ? {
1699
+ message: "shop.outside",
1700
+ business: t.business.displayName,
1701
+ alert: !0
1702
+ } : n === "ProductInactive" || n === "ProductNotFound" ? {
1703
+ message: "shop.gone",
1704
+ alert: !0
1705
+ } : n === "PaymentProviderNotOffered" || n === "PaymentProviderNotConnected" ? {
1706
+ message: "pay.notOffered",
1707
+ alert: !0
1708
+ } : {
1709
+ message: "pay.unavailable",
1710
+ alert: !0
1711
+ });
1712
+ } finally {
1713
+ h(!1);
1714
+ }
1715
+ }
1716
+ return !c.length && !g ? null : /* @__PURE__ */ p(d, { children: [
1717
+ /* @__PURE__ */ f("h2", {
1718
+ className: "cp-section",
1719
+ children: N("shop.heading")
1720
+ }),
1721
+ g && /* @__PURE__ */ f("p", {
1722
+ role: g.alert ? "alert" : "status",
1723
+ className: g.alert ? void 0 : "cp-notice",
1724
+ children: N(g.message, { business: g.business ?? "" })
1725
+ }),
1726
+ g?.link && /* @__PURE__ */ f("div", {
1727
+ className: "cp-actions",
1728
+ children: /* @__PURE__ */ f("a", {
1729
+ className: "cp-button",
1730
+ href: g.link,
1731
+ target: "_blank",
1732
+ rel: "noopener",
1733
+ children: N("pay.open")
1734
+ })
1735
+ }),
1736
+ /* @__PURE__ */ f("ul", {
1737
+ className: "cp-list",
1738
+ children: c.map((e) => /* @__PURE__ */ p("li", {
1739
+ className: "cp-card",
1740
+ children: [
1741
+ /* @__PURE__ */ p("div", {
1742
+ className: "cp-card-head",
1743
+ children: [/* @__PURE__ */ f("h2", { children: e.product.title }), /* @__PURE__ */ f("span", {
1744
+ className: "cp-price",
1745
+ children: I(e.product.price, e.product.currency)
1746
+ })]
1747
+ }),
1748
+ i.size > 1 && /* @__PURE__ */ f("p", { children: e.business.displayName }),
1749
+ e.product.description && /* @__PURE__ */ f("p", { children: e.product.description }),
1750
+ e.product.terms && /* @__PURE__ */ f("p", {
1751
+ className: "cp-hint",
1752
+ children: e.product.terms
1753
+ }),
1754
+ /* @__PURE__ */ f("div", {
1755
+ className: "cp-actions",
1756
+ children: e.methods.map((t) => /* @__PURE__ */ f("button", {
1757
+ type: "button",
1758
+ disabled: m,
1759
+ onClick: () => S(e, t),
1760
+ children: N("shop.buy", { provider: t.label })
1761
+ }, t.id))
1762
+ })
1763
+ ]
1764
+ }, e.product.id))
1765
+ })
1766
+ ] });
1767
+ }
1205
1768
  // src/screens/passes.tsx
1206
- function Ae() {
1207
- let { client: e, businesses: n } = x(), [i, a] = s(), [o, c] = s(!1), l = t(async () => {
1769
+ function rt() {
1770
+ let { client: e, businesses: n } = k(), [i, a] = s(), [o, c] = s(!1), l = t(async () => {
1208
1771
  c(!1);
1209
1772
  try {
1210
1773
  let { data: t } = await e.GET("/web/me/memberships");
@@ -1217,55 +1780,59 @@ function Ae() {
1217
1780
  l();
1218
1781
  }, [l]), /* @__PURE__ */ p("section", {
1219
1782
  className: "cp-screen",
1220
- children: [/* @__PURE__ */ f("h1", { children: T("passes.heading") }), o ? /* @__PURE__ */ f(F, { onRetry: l }) : i ? i.length === 0 ? /* @__PURE__ */ f("p", {
1221
- className: "cp-empty",
1222
- children: T("passes.empty")
1223
- }) : /* @__PURE__ */ f("ul", {
1224
- className: "cp-list",
1225
- children: i.map((e) => {
1226
- let t = n.get(e.businessId), r = t?.timezone, i = e.validUntil !== null && Date.parse(e.validUntil) <= Date.now();
1227
- return /* @__PURE__ */ p("li", {
1228
- className: "cp-card",
1229
- children: [
1230
- /* @__PURE__ */ p("div", {
1231
- className: "cp-card-head",
1232
- children: [/* @__PURE__ */ f("h2", { children: e.displayName }), i && /* @__PURE__ */ f("span", {
1233
- className: "cp-badge",
1234
- children: T("passes.expired")
1235
- })]
1236
- }),
1237
- t && /* @__PURE__ */ f("p", { children: t.displayName }),
1238
- /* @__PURE__ */ f("p", {
1239
- className: "cp-credits",
1240
- children: e.creditsRemaining === null || e.creditsTotal === null ? T("passes.unlimited") : T("passes.credits", {
1241
- remaining: e.creditsRemaining,
1242
- total: e.creditsTotal
1783
+ children: [
1784
+ /* @__PURE__ */ f("h1", { children: N("passes.heading") }),
1785
+ o ? /* @__PURE__ */ f(U, { onRetry: l }) : i ? i.length === 0 ? /* @__PURE__ */ f("p", {
1786
+ className: "cp-empty",
1787
+ children: N("passes.empty")
1788
+ }) : /* @__PURE__ */ f("ul", {
1789
+ className: "cp-list",
1790
+ children: i.map((e) => {
1791
+ let t = n.get(e.businessId), r = t?.timezone, i = e.validUntil !== null && Date.parse(e.validUntil) <= Date.now();
1792
+ return /* @__PURE__ */ p("li", {
1793
+ className: "cp-card",
1794
+ children: [
1795
+ /* @__PURE__ */ p("div", {
1796
+ className: "cp-card-head",
1797
+ children: [/* @__PURE__ */ f("h2", { children: e.displayName }), i && /* @__PURE__ */ f("span", {
1798
+ className: "cp-badge",
1799
+ children: N("passes.expired")
1800
+ })]
1801
+ }),
1802
+ t && /* @__PURE__ */ f("p", { children: t.displayName }),
1803
+ /* @__PURE__ */ f("p", {
1804
+ className: "cp-credits",
1805
+ children: e.creditsRemaining === null || e.creditsTotal === null ? N("passes.unlimited") : N("passes.credits", {
1806
+ remaining: e.creditsRemaining,
1807
+ total: e.creditsTotal
1808
+ })
1809
+ }),
1810
+ /* @__PURE__ */ f("p", {
1811
+ className: "cp-hint",
1812
+ children: e.validUntil ? N("passes.validRange", {
1813
+ from: z(e.validFrom, r),
1814
+ until: z(e.validUntil, r)
1815
+ }) : N("passes.validFrom", { date: z(e.validFrom, r) })
1243
1816
  })
1244
- }),
1245
- /* @__PURE__ */ f("p", {
1246
- className: "cp-hint",
1247
- children: e.validUntil ? T("passes.validRange", {
1248
- from: j(e.validFrom, r),
1249
- until: j(e.validUntil, r)
1250
- }) : T("passes.validFrom", { date: j(e.validFrom, r) })
1251
- })
1252
- ]
1253
- }, e.id);
1254
- })
1255
- }) : /* @__PURE__ */ f("p", {
1256
- role: "status",
1257
- children: T("app.loading")
1258
- })]
1817
+ ]
1818
+ }, e.id);
1819
+ })
1820
+ }) : /* @__PURE__ */ f("p", {
1821
+ role: "status",
1822
+ children: N("app.loading")
1823
+ }),
1824
+ /* @__PURE__ */ f(nt, {})
1825
+ ]
1259
1826
  });
1260
1827
  }
1261
1828
  // ../ui/dist/index.js
1262
- var je = new Intl.DisplayNames(["en"], { type: "region" }), Me = (e) => e.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().trim(), Y = h().map((e) => ({
1829
+ var it = new Intl.DisplayNames(["en"], { type: "region" }), at = (e) => e.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().trim(), Z = h().map((e) => ({
1263
1830
  code: e,
1264
- name: je.of(e) ?? e,
1831
+ name: it.of(e) ?? e,
1265
1832
  callingCode: g(e),
1266
1833
  flag: String.fromCodePoint(...[...e].map((e) => 127397 + e.charCodeAt(0)))
1267
- })).sort((e, t) => e.name.localeCompare(t.name)), Ne = new Map(Y.map((e) => [e.code, e])), Pe = (e) => Ne.get(e);
1268
- function Fe(e) {
1834
+ })).sort((e, t) => e.name.localeCompare(t.name)), ot = new Map(Z.map((e) => [e.code, e])), st = (e) => ot.get(e);
1835
+ function ct(e) {
1269
1836
  let t = i(), n = o(null), a = o(null), c = o(null), [l, u] = s(""), d = e.search(l), m = () => n.current?.close(), h = (t) => {
1270
1837
  m(), e.onPick(t);
1271
1838
  };
@@ -1339,10 +1906,10 @@ function Fe(e) {
1339
1906
  ]
1340
1907
  });
1341
1908
  }
1342
- var Ie = new m(), X = (e) => Pe(e);
1343
- function Le(e) {
1909
+ var lt = new m(), ut = (e) => st(e);
1910
+ function dt(e) {
1344
1911
  for (let t = 1; t <= 3 && t <= e.length; t++) {
1345
- let n = e.slice(0, t), r = (y.country_calling_codes[n] ?? []).filter((e) => Pe(e) !== void 0), [i] = r;
1912
+ let n = e.slice(0, t), r = (y.country_calling_codes[n] ?? []).filter((e) => st(e) !== void 0), [i] = r;
1346
1913
  if (i) return {
1347
1914
  code: n,
1348
1915
  first: i,
@@ -1351,10 +1918,10 @@ function Le(e) {
1351
1918
  }
1352
1919
  return null;
1353
1920
  }
1354
- function Re(e, t) {
1921
+ function ft(e, t) {
1355
1922
  let n = /^\s*(\+|00)/.exec(e);
1356
1923
  if (!n) return null;
1357
- let r = e.slice(n[0].length), i = r.replace(/\D/g, ""), a = Le(i);
1924
+ let r = e.slice(n[0].length), i = r.replace(/\D/g, ""), a = dt(i);
1358
1925
  if (!a) return null;
1359
1926
  let o = _(`+${i}`), s = a.countries.includes(t) ? t : o?.country ?? a.first, c = 0;
1360
1927
  for (let e = 0; e < a.code.length; c++) /\d/.test(r.charAt(c)) && e++;
@@ -1363,45 +1930,45 @@ function Re(e, t) {
1363
1930
  text: o?.isValid() ? o.formatNational() : r.slice(c).replace(/^[\s\-().]+/, "")
1364
1931
  };
1365
1932
  }
1366
- function ze(e, t) {
1933
+ function pt(e, t) {
1367
1934
  let n = t.replace(/\D/g, "");
1368
- return n === "" ? "" : t.trim().startsWith("+") ? `+${n}` : _(t, e)?.number ?? `+${X(e).callingCode}${n}`;
1935
+ return n === "" ? "" : t.trim().startsWith("+") ? `+${n}` : _(t, e)?.number ?? `+${ut(e).callingCode}${n}`;
1369
1936
  }
1370
- function Be(e) {
1371
- return Ie.selectNumberingPlan(e), Ie.numberingPlan?.possibleLengths() ?? [];
1937
+ function mt(e) {
1938
+ return lt.selectNumberingPlan(e), lt.numberingPlan?.possibleLengths() ?? [];
1372
1939
  }
1373
- function Ve(e, t, n) {
1940
+ function ht(e, t, n) {
1374
1941
  if (e === "") return t ? "Enter a phone number." : "";
1375
1942
  let r = _(e);
1376
1943
  if (r?.isValid()) return "";
1377
- let i = e.replace(/\D/g, ""), a = Le(i);
1944
+ let i = e.replace(/\D/g, ""), a = dt(i);
1378
1945
  if (!a) return "Unknown country code. Choose the country from the list.";
1379
- let o = n && a.countries.includes(n) ? n : r?.country ?? a.first, s = X(o).name, c = v(i.slice(a.code.length), o);
1946
+ let o = n && a.countries.includes(n) ? n : r?.country ?? a.first, s = ut(o).name, c = v(i.slice(a.code.length), o);
1380
1947
  if (c && c !== "NOT_A_NUMBER") {
1381
- let e = Be(o), t = e[0] ?? 0, n = e[e.length - 1] ?? 0;
1948
+ let e = mt(o), t = e[0] ?? 0, n = e[e.length - 1] ?? 0;
1382
1949
  return e.length === 1 ? `Enter a ${t}-digit number for ${s}.` : e.length > 2 && n - t === e.length - 1 ? `Enter ${t} to ${n} digits for ${s}.` : `Enter ${e.slice(0, -1).join(", ")} or ${n} digits for ${s}.`;
1383
1950
  }
1384
1951
  return `This is not a valid number for ${s}.`;
1385
1952
  }
1386
- function He(e, t = !1) {
1387
- return Ve(e, t);
1953
+ function gt(e, t = !1) {
1954
+ return ht(e, t);
1388
1955
  }
1389
- function Ue(e, t) {
1390
- return Re(e, t) ?? {
1956
+ function _t(e, t) {
1957
+ return ft(e, t) ?? {
1391
1958
  country: t,
1392
1959
  text: e
1393
1960
  };
1394
1961
  }
1395
- function We(e) {
1962
+ function vt(e) {
1396
1963
  let t = i(), n = o(null), [a, c] = s(() => ({
1397
1964
  value: e.value,
1398
- ...Ue(e.value, "IS")
1965
+ ..._t(e.value, "IS")
1399
1966
  })), l = a;
1400
1967
  e.value !== a.value && (l = {
1401
1968
  value: e.value,
1402
- ...Ue(e.value, a.country)
1969
+ ..._t(e.value, a.country)
1403
1970
  }, c(l));
1404
- let [u, d] = s(!1), [m, h] = s(!1), g = X(l.country), _ = Ve(l.value, e.required ?? !1, l.country), v = u && _ !== "" ? _ : e.error ?? "", y = v !== "";
1971
+ let [u, d] = s(!1), [m, h] = s(!1), g = ut(l.country), _ = ht(l.value, e.required ?? !1, l.country), v = u && _ !== "" ? _ : e.error ?? "", y = v !== "";
1405
1972
  r(() => {
1406
1973
  let e = n.current?.form;
1407
1974
  if (!e) return;
@@ -1411,7 +1978,7 @@ function We(e) {
1411
1978
  return e.addEventListener("submit", t), () => e.removeEventListener("submit", t);
1412
1979
  }, []);
1413
1980
  let b = (t, n) => {
1414
- let r = ze(t, n);
1981
+ let r = pt(t, n);
1415
1982
  c({
1416
1983
  value: r,
1417
1984
  country: t,
@@ -1454,7 +2021,7 @@ function We(e) {
1454
2021
  "aria-invalid": y || void 0,
1455
2022
  "aria-describedby": y ? `${t}-problem` : void 0,
1456
2023
  onChange: (e) => {
1457
- let t = e.target.value.replace(/[^\d\s\-().+]/g, ""), n = Re(t, l.country);
2024
+ let t = e.target.value.replace(/[^\d\s\-().+]/g, ""), n = ft(t, l.country);
1458
2025
  b(n?.country ?? l.country, n?.text ?? t);
1459
2026
  },
1460
2027
  onBlur: () => {
@@ -1468,12 +2035,12 @@ function We(e) {
1468
2035
  role: "alert",
1469
2036
  children: v
1470
2037
  }),
1471
- m && /* @__PURE__ */ f(Fe, {
2038
+ m && /* @__PURE__ */ f(ct, {
1472
2039
  title: "Country code",
1473
2040
  searchLabel: "Search by country or code",
1474
2041
  listLabel: "Countries",
1475
2042
  empty: (e) => `No country matches “${e}”.`,
1476
- search: Ge,
2043
+ search: yt,
1477
2044
  selected: l.country,
1478
2045
  onClose: () => h(!1),
1479
2046
  onPick: (e) => {
@@ -1483,41 +2050,95 @@ function We(e) {
1483
2050
  ]
1484
2051
  });
1485
2052
  }
1486
- function Ge(e) {
1487
- let t = Me(e).replace(/^(\+|00)/, "");
1488
- return (t === "" ? Y : /^\d+$/.test(t) ? Y.filter((e) => e.callingCode.startsWith(t)) : Y.filter((e) => Me(e.name).includes(t) || e.code.toLowerCase() === t)).map((e) => ({
2053
+ function yt(e) {
2054
+ let t = at(e).replace(/^(\+|00)/, "");
2055
+ return (t === "" ? Z : /^\d+$/.test(t) ? Z.filter((e) => e.callingCode.startsWith(t)) : Z.filter((e) => at(e.name).includes(t) || e.code.toLowerCase() === t)).map((e) => ({
1489
2056
  value: e.code,
1490
2057
  label: e.name,
1491
2058
  hint: `+${e.callingCode}`,
1492
2059
  flag: e.flag
1493
2060
  }));
1494
2061
  }
2062
+ var bt = {
2063
+ red: {
2064
+ light: "#d14b4b",
2065
+ dark: "#f07a7a"
2066
+ },
2067
+ orange: {
2068
+ light: "#d9773a",
2069
+ dark: "#f29a62"
2070
+ },
2071
+ amber: {
2072
+ light: "#b8891a",
2073
+ dark: "#e3b847"
2074
+ },
2075
+ lime: {
2076
+ light: "#6f9a1f",
2077
+ dark: "#a5cf4f"
2078
+ },
2079
+ green: {
2080
+ light: "#2f9a69",
2081
+ dark: "#5cc194"
2082
+ },
2083
+ teal: {
2084
+ light: "#24918f",
2085
+ dark: "#4fc0bd"
2086
+ },
2087
+ cyan: {
2088
+ light: "#1d8fb3",
2089
+ dark: "#5bc0e0"
2090
+ },
2091
+ blue: {
2092
+ light: "#4a7fe0",
2093
+ dark: "#7ea6f5"
2094
+ },
2095
+ indigo: {
2096
+ light: "#6366d8",
2097
+ dark: "#9a9cf2"
2098
+ },
2099
+ purple: {
2100
+ light: "#9666cf",
2101
+ dark: "#bb9be6"
2102
+ },
2103
+ pink: {
2104
+ light: "#cf5c94",
2105
+ dark: "#ea8cba"
2106
+ },
2107
+ slate: {
2108
+ light: "#6c778a",
2109
+ dark: "#9aa5b5"
2110
+ }
2111
+ };
2112
+ function xt(e) {
2113
+ let { light: t, dark: n } = bt[e in bt ? e : "slate"];
2114
+ return `light-dark(${t}, ${n})`;
2115
+ }
1495
2116
  // src/bot-check.tsx
1496
- var Ke = () => window.turnstile, qe = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit", Z;
1497
- function Je() {
1498
- let e = Ke();
1499
- return e ? Promise.resolve(e) : (Z ??= new Promise((e, t) => {
2117
+ var St = () => window.turnstile, Ct = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit", wt;
2118
+ function Tt() {
2119
+ let e = St();
2120
+ return e ? Promise.resolve(e) : (wt ??= new Promise((e, t) => {
1500
2121
  let n = document.createElement("script");
1501
- n.src = qe, n.async = !0;
2122
+ n.src = Ct, n.async = !0;
1502
2123
  let r = () => {
1503
- Z = void 0, n.remove(), t(/* @__PURE__ */ Error("Turnstile did not load."));
2124
+ wt = void 0, n.remove(), t(/* @__PURE__ */ Error("Turnstile did not load."));
1504
2125
  };
1505
2126
  n.onload = () => {
1506
- let t = Ke();
2127
+ let t = St();
1507
2128
  t ? e(t) : r();
1508
2129
  }, n.onerror = r, document.head.append(n);
1509
- }), Z);
2130
+ }), wt);
1510
2131
  }
1511
- function Ye(e) {
2132
+ function Et(e) {
1512
2133
  return e?.provider === "turnstile" && typeof e.siteKey == "string" && e.siteKey.trim() !== "";
1513
2134
  }
1514
- function Xe(e) {
2135
+ function Dt(e) {
1515
2136
  let t = o(null), n = o(void 0), i = o(e);
1516
2137
  i.current = e;
1517
2138
  let { siteKey: a } = e.botCheck;
1518
2139
  r(() => {
1519
2140
  let e = !0;
1520
- return Je().then((r) => {
2141
+ return Tt().then((r) => {
1521
2142
  let o = t.current;
1522
2143
  if (!e || !o) return;
1523
2144
  let s = r.render(o, {
@@ -1554,7 +2175,7 @@ function Q(e) {
1554
2175
  r(() => {
1555
2176
  n && t.current?.querySelector("input")?.focus();
1556
2177
  }, [n]);
1557
- let [i, a] = s("phone"), [c, l] = s(""), [u, m] = s(""), [h, g] = s(""), [_, v] = s(), [y, b] = s(), [x, S] = s(!1), [C, w] = s(), [E, D] = s(0), O = Ye(e.botCheck) ? e.botCheck : void 0, [k, A] = s();
2178
+ let [i, a] = s("phone"), [c, l] = s(""), [u, m] = s(""), [h, g] = s(""), [_, v] = s(), [y, b] = s(), [x, S] = s(!1), [C, w] = s(), [T, D] = s(0), O = Et(e.botCheck) ? e.botCheck : void 0, [k, A] = s();
1558
2179
  r(() => {
1559
2180
  if (!k) return;
1560
2181
  let e = setTimeout(() => {
@@ -1566,16 +2187,16 @@ function Q(e) {
1566
2187
  a("phone"), v(void 0), g(""), l(""), b(e);
1567
2188
  }
1568
2189
  async function M(t) {
1569
- if (t.preventDefault(), (i !== "phone" || !He(u, !0) && O && C) && (i !== "name" || c.trim())) {
2190
+ if (t.preventDefault(), (i !== "phone" || !gt(u, !0) && O && C) && (i !== "name" || c.trim())) {
1570
2191
  S(!0), b(void 0);
1571
2192
  try {
1572
- let t = i === "phone" ? await W(e.basePath, "/auth/initiate", {
2193
+ let t = i === "phone" ? await E(e.basePath, "/auth/initiate", {
1573
2194
  phone: u,
1574
2195
  botCheckToken: C
1575
- }) : i === "code" ? await W(e.basePath, "/auth/login", {
2196
+ }) : i === "code" ? await E(e.basePath, "/auth/login", {
1576
2197
  challenge: _,
1577
2198
  code: h
1578
- }) : await W(e.basePath, "/auth/register", { name: c.trim() });
2199
+ }) : await E(e.basePath, "/auth/register", { name: c.trim() });
1579
2200
  if (t.ok) {
1580
2201
  let n = await t.json();
1581
2202
  i === "phone" ? (v(n.challenge), a("code")) : n.result === "nameRequired" ? a("name") : e.onSignedIn(n.sessionKey);
@@ -1583,17 +2204,17 @@ function Q(e) {
1583
2204
  }
1584
2205
  let n = await t.json().catch(() => void 0);
1585
2206
  if (i === "name" && t.status === 401) {
1586
- j(T("register.error.expired"));
2207
+ j(N("register.error.expired"));
1587
2208
  return;
1588
2209
  }
1589
- let r = Number(t.headers.get("retry-after")), o = Number.isInteger(r) && r > 0 ? r : void 0, s = Ze(t.status, n?.code, o, i);
2210
+ let r = Number(t.headers.get("retry-after")), o = Number.isInteger(r) && r > 0 ? r : void 0, s = Ot(t.status, n?.code, o, i);
1590
2211
  t.status === 429 && o && i === "phone" && A({
1591
2212
  phone: u,
1592
2213
  seconds: o,
1593
2214
  message: s
1594
2215
  }), b(s);
1595
2216
  } catch {
1596
- b(T("signIn.error.unreachable"));
2217
+ b(N("signIn.error.unreachable"));
1597
2218
  } finally {
1598
2219
  S(!1), i === "phone" && D((e) => e + 1);
1599
2220
  }
@@ -1606,22 +2227,22 @@ function Q(e) {
1606
2227
  onSubmit: M,
1607
2228
  "aria-busy": x,
1608
2229
  children: [
1609
- /* @__PURE__ */ f(_e, { brand: e.brand }),
1610
- /* @__PURE__ */ f("h1", { children: T("signIn.heading") }),
2230
+ /* @__PURE__ */ f(Re, { brand: e.brand }),
2231
+ /* @__PURE__ */ f("h1", { children: N("signIn.heading") }),
1611
2232
  e.children,
1612
2233
  e.notice && i === "phone" && /* @__PURE__ */ f("p", {
1613
2234
  role: "status",
1614
2235
  className: "cp-notice",
1615
- children: T(e.notice)
2236
+ children: N(e.notice)
1616
2237
  }),
1617
- i === "name" ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", { children: T("register.intro") }), /* @__PURE__ */ p("label", { children: [T("register.name"), /* @__PURE__ */ f("input", {
2238
+ i === "name" ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", { children: N("register.intro") }), /* @__PURE__ */ p("label", { children: [N("register.name"), /* @__PURE__ */ f("input", {
1618
2239
  value: c,
1619
2240
  onChange: (e) => l(e.target.value),
1620
2241
  autoComplete: "name",
1621
2242
  maxLength: 200,
1622
2243
  required: !0,
1623
2244
  autoFocus: !0
1624
- })] })] }) : i === "code" ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", { children: T("signIn.codeSent", { phone: u }) }), /* @__PURE__ */ p("label", { children: [T("signIn.code"), /* @__PURE__ */ f("input", {
2245
+ })] })] }) : i === "code" ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", { children: N("signIn.codeSent", { phone: u }) }), /* @__PURE__ */ p("label", { children: [N("signIn.code"), /* @__PURE__ */ f("input", {
1625
2246
  value: h,
1626
2247
  onChange: (e) => g(e.target.value),
1627
2248
  inputMode: "numeric",
@@ -1629,23 +2250,23 @@ function Q(e) {
1629
2250
  required: !0,
1630
2251
  autoFocus: !0
1631
2252
  })] })] }) : /* @__PURE__ */ p(d, { children: [
1632
- /* @__PURE__ */ f("p", { children: T("signIn.intro") }),
1633
- /* @__PURE__ */ f(We, {
1634
- label: T("signIn.phone"),
2253
+ /* @__PURE__ */ f("p", { children: N("signIn.intro") }),
2254
+ /* @__PURE__ */ f(vt, {
2255
+ label: N("signIn.phone"),
1635
2256
  value: u,
1636
2257
  onChange: m,
1637
2258
  required: !0
1638
2259
  }),
1639
- O && /* @__PURE__ */ f(Xe, {
2260
+ O && /* @__PURE__ */ f(Dt, {
1640
2261
  botCheck: O,
1641
- attempt: E,
2262
+ attempt: T,
1642
2263
  onToken: w,
1643
- onUnavailable: () => b(T("signIn.error.botCheckUnavailable"))
2264
+ onUnavailable: () => b(N("signIn.error.botCheckUnavailable"))
1644
2265
  })
1645
2266
  ] }),
1646
2267
  i === "phone" && !O && /* @__PURE__ */ f("p", {
1647
2268
  role: "alert",
1648
- children: T("signIn.error.notConfigured")
2269
+ children: N("signIn.error.notConfigured")
1649
2270
  }),
1650
2271
  y && /* @__PURE__ */ f("p", {
1651
2272
  role: "alert",
@@ -1654,58 +2275,58 @@ function Q(e) {
1654
2275
  /* @__PURE__ */ f("button", {
1655
2276
  type: "submit",
1656
2277
  disabled: x || i === "phone" && (!O || !C || k?.phone === u),
1657
- children: T(x ? "signIn.wait" : i === "phone" ? "signIn.sendCode" : i === "code" ? "signIn.submit" : "register.submit")
2278
+ children: N(x ? "signIn.wait" : i === "phone" ? "signIn.sendCode" : i === "code" ? "signIn.submit" : "register.submit")
1658
2279
  }),
1659
2280
  i !== "phone" && /* @__PURE__ */ f("button", {
1660
2281
  type: "button",
1661
2282
  className: "cp-secondary",
1662
2283
  onClick: () => j(),
1663
- children: T("signIn.differentNumber")
2284
+ children: N("signIn.differentNumber")
1664
2285
  }),
1665
2286
  e.onCancel && /* @__PURE__ */ f("button", {
1666
2287
  type: "button",
1667
2288
  className: "cp-secondary",
1668
2289
  onClick: e.onCancel,
1669
- children: T("signIn.cancel")
2290
+ children: N("signIn.cancel")
1670
2291
  })
1671
2292
  ]
1672
2293
  })
1673
2294
  });
1674
2295
  }
1675
- function Ze(e, t, n, r) {
1676
- if (e === 429) return n ? T("signIn.error.tooMany", { wait: ee(n) }) : T("signIn.error.tooManyLater");
1677
- if (r === "name" && (e === 400 || e === 422)) return T("register.error.name");
2296
+ function Ot(e, t, n, r) {
2297
+ if (e === 429) return n ? N("signIn.error.tooMany", { wait: re(n) }) : N("signIn.error.tooManyLater");
2298
+ if (r === "name" && (e === 400 || e === 422)) return N("register.error.name");
1678
2299
  let i = r === "phone";
1679
- return i && e === 403 && t === "BotCheckFailed" ? T("signIn.error.botCheck") : i && e === 503 && t === "BotCheckUnavailable" ? T("signIn.error.botCheckUnavailable") : i && e === 503 && (t === "LimiterUnavailable" || t === "ClientIpUnavailable") ? T("signIn.error.failed") : i && e === 503 ? n ? T("signIn.error.paused", { wait: ee(n) }) : T("signIn.error.pausedLater") : i && e === 422 && t === "PhoneDestinationNotAllowed" ? T("signIn.error.destination") : r === "code" && [
2300
+ return i && e === 403 && t === "BotCheckFailed" ? N("signIn.error.botCheck") : i && e === 503 && t === "BotCheckUnavailable" ? N("signIn.error.botCheckUnavailable") : i && e === 503 && (t === "LimiterUnavailable" || t === "ClientIpUnavailable") ? N("signIn.error.failed") : i && e === 503 ? n ? N("signIn.error.paused", { wait: re(n) }) : N("signIn.error.pausedLater") : i && e === 422 && t === "PhoneDestinationNotAllowed" ? N("signIn.error.destination") : r === "code" && [
1680
2301
  400,
1681
2302
  401,
1682
2303
  403,
1683
2304
  404,
1684
2305
  409
1685
- ].includes(e) ? T("signIn.error.badCode") : T(e === 400 ? "signIn.error.invalid" : e === 403 ? "signIn.error.refused" : "signIn.error.failed");
2306
+ ].includes(e) ? N("signIn.error.badCode") : N(e === 400 ? "signIn.error.invalid" : e === 403 ? "signIn.error.refused" : "signIn.error.failed");
1686
2307
  }
1687
2308
  // src/account.tsx
1688
- function Qe(e) {
2309
+ function kt(e) {
1689
2310
  let [n, r] = s("bookings"), i = e.screen ?? n, a = e.onNavigate ?? r, o = t((e) => {
1690
2311
  (e === "bookings" || e === "passes" || e === "details") && a(e);
1691
- }, [a]), { basePath: c, sessionKey: l, notice: u, portal: d, signedInAs: p } = q({
2312
+ }, [a]), { basePath: c, sessionKey: l, notice: u, portal: d, signedInAs: p } = Je({
1692
2313
  basePath: e.basePath,
1693
2314
  navigate: o,
1694
2315
  accountNavigation: !0,
1695
2316
  onSessionChange: e.onSessionChange
1696
2317
  });
1697
- return /* @__PURE__ */ f(J, {
2318
+ return tt(i, o), /* @__PURE__ */ f(Ye, {
1698
2319
  portal: d,
1699
2320
  loading: l === void 0,
1700
- children: /* @__PURE__ */ f(xe, {
2321
+ children: /* @__PURE__ */ f(He, {
1701
2322
  brand: e.brand,
1702
- tabs: ye,
2323
+ tabs: Be,
1703
2324
  screen: i,
1704
2325
  signedIn: !!l,
1705
2326
  signingIn: !l,
1706
2327
  onNavigate: o,
1707
2328
  onSignOut: () => d.signOut(),
1708
- children: l ? f(i === "passes" ? Ae : i === "details" ? ke : P, {}) : /* @__PURE__ */ f(Q, {
2329
+ children: l ? f(i === "passes" ? rt : i === "details" ? Ze : ue, {}) : /* @__PURE__ */ f(Q, {
1709
2330
  basePath: c,
1710
2331
  brand: void 0,
1711
2332
  botCheck: e.botCheck,
@@ -1717,7 +2338,7 @@ function Qe(e) {
1717
2338
  });
1718
2339
  }
1719
2340
  // src/booking-flow.tsx
1720
- function $e(e) {
2341
+ function At(e) {
1721
2342
  return {
1722
2343
  startsAt: e.startsAt,
1723
2344
  eventTypeId: e.eventTypeId,
@@ -1733,105 +2354,122 @@ function $(e) {
1733
2354
  e.resourceId ?? ""
1734
2355
  ].join("|") : "";
1735
2356
  }
1736
- function et(e, t) {
2357
+ function jt(e, t) {
1737
2358
  return t.eventId ? e.eventId === t.eventId : e.eventTypeId === t.eventTypeId && Date.parse(e.startsAt) === Date.parse(t.startsAt) && (!t.resourceId || e.resource?.id === t.resourceId);
1738
2359
  }
1739
- function tt(e) {
1740
- let n = e.onChange !== void 0, r = {
2360
+ function Mt(e) {
2361
+ let n = e.onChange !== void 0, i = {
1741
2362
  businessId: e.businessId,
1742
2363
  ...e.eventTypeId && { eventTypeId: e.eventTypeId },
1743
2364
  ...e.resourceId && { resourceId: e.resourceId },
1744
2365
  ...e.all && { all: !0 },
2366
+ ...e.all && e.allFrom && { allFrom: e.allFrom },
1745
2367
  ...e.time && { time: e.time }
1746
- }, i = [
2368
+ }, a = [
1747
2369
  e.businessId,
1748
2370
  e.eventTypeId ?? "",
1749
2371
  e.resourceId ?? "",
1750
2372
  e.all ? "all" : "",
2373
+ e.allFrom ? `${e.allFrom.eventTypeId}~${e.allFrom.resourceId ?? ""}` : "",
1751
2374
  $(e.time)
1752
- ].join("/"), [a, o] = s(r), [c, l] = s(i);
1753
- !n && c !== i && (l(i), o(r));
1754
- let u = n ? r : a, m = e.onChange, h = t((e) => (m ?? o)(e), [m]), g = t((e) => {
1755
- typeof e == "object" && h({
2375
+ ].join("/"), [o, c] = s(i), [l, u] = s(a);
2376
+ !n && l !== a && (u(a), c(i));
2377
+ let m = n ? i : o, h = e.onChange, g = t((e) => (h ?? c)(e), [h]), _ = t((e) => {
2378
+ typeof e == "object" && g({
1756
2379
  businessId: e.businessId,
1757
2380
  ...e.eventTypeId && { eventTypeId: e.eventTypeId }
1758
2381
  });
1759
- }, [h]), { basePath: _, sessionKey: v, notice: y, portal: b, signedInAs: x } = q({
2382
+ }, [g]), { basePath: v, sessionKey: y, notice: b, portal: x, signedInAs: S } = Je({
1760
2383
  basePath: e.basePath,
1761
- navigate: g,
2384
+ navigate: _,
1762
2385
  accountNavigation: !1,
1763
2386
  onSessionChange: e.onSessionChange
1764
- }), [S, C] = s(), [w, E] = s(), D = u.time, O = $(D), k = S && D && S.business.id === u.businessId && $($e(S.candidate)) === O ? S : void 0, A = () => {
1765
- C(void 0);
1766
- let { time: e, ...t } = u;
1767
- h(t);
1768
- }, j = (e, t) => {
1769
- C({
2387
+ }), [C, w] = s();
2388
+ r(() => {
2389
+ let t = Me();
2390
+ t && (w(t.outcome), t.selection?.businessId === e.businessId && t.selection.time && g(t.selection));
2391
+ }, [g, e.businessId]);
2392
+ let [T, E] = s(), [D, O] = s(), k = m.time, A = $(k), j = T && k && T.business.id === m.businessId && $(At(T.candidate)) === A ? T : void 0, M = () => {
2393
+ E(void 0);
2394
+ let { time: e, ...t } = m;
2395
+ g(t);
2396
+ }, P = (e, t) => {
2397
+ E({
1770
2398
  business: e,
1771
2399
  candidate: t
1772
- }), h({
1773
- ...u,
1774
- time: $e(t)
2400
+ }), g({
2401
+ ...m,
2402
+ time: At(t)
1775
2403
  });
1776
- }, M;
1777
- M = k ? v ? /* @__PURE__ */ f(me, {
1778
- choice: k,
1779
- onBack: A,
2404
+ }, F;
2405
+ F = j ? y ? /* @__PURE__ */ f(Ne, {
2406
+ choice: j,
2407
+ onBack: M,
1780
2408
  onBooked: e.onBooked,
1781
- onDone: e.onClose
1782
- }, `${k.candidate.startsAt}-${k.candidate.eventId ?? k.candidate.eventTypeId}`) : /* @__PURE__ */ p(Q, {
1783
- basePath: _,
2409
+ onDone: e.onClose,
2410
+ onLeave: () => je(m),
2411
+ returned: C
2412
+ }, `${j.candidate.startsAt}-${j.candidate.eventId ?? j.candidate.eventTypeId}`) : /* @__PURE__ */ p(Q, {
2413
+ basePath: v,
1784
2414
  brand: e.brand,
1785
2415
  botCheck: e.botCheck,
1786
- notice: y,
1787
- onSignedIn: x,
1788
- autoFocus: !0,
2416
+ notice: b,
2417
+ onSignedIn: S,
2418
+ autoFocus: e.autoFocus !== !1,
1789
2419
  children: [
1790
- /* @__PURE__ */ f("p", { children: T("book.signInFirst") }),
1791
- /* @__PURE__ */ f(U, { choice: k }),
2420
+ /* @__PURE__ */ f("p", { children: N("book.signInFirst") }),
2421
+ /* @__PURE__ */ f(J, { choice: j }),
1792
2422
  /* @__PURE__ */ f("button", {
1793
2423
  type: "button",
1794
2424
  className: "cp-link",
1795
- onClick: A,
1796
- children: T("book.back")
2425
+ onClick: M,
2426
+ children: N("book.back")
1797
2427
  })
1798
2428
  ]
1799
- }) : D && w !== O ? /* @__PURE__ */ f(rt, {
1800
- businessId: u.businessId,
1801
- time: D,
1802
- onFound: C,
1803
- onMissing: () => E(O)
1804
- }) : u.all ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("button", {
2429
+ }) : k && D !== A ? /* @__PURE__ */ f(Pt, {
2430
+ businessId: m.businessId,
2431
+ time: k,
2432
+ onFound: E,
2433
+ onMissing: () => O(A)
2434
+ }) : m.all ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("button", {
1805
2435
  type: "button",
1806
2436
  className: "cp-link cp-back",
1807
- onClick: () => h({ businessId: u.businessId }),
1808
- children: T("book.toTypes")
1809
- }), /* @__PURE__ */ f(de, {
1810
- businessId: u.businessId,
1811
- eventTypeId: u.eventTypeId,
1812
- resourceId: u.resourceId,
1813
- onFilter: (e) => h({
1814
- businessId: u.businessId,
2437
+ onClick: () => g({
2438
+ businessId: m.businessId,
2439
+ ...m.allFrom && {
2440
+ eventTypeId: m.allFrom.eventTypeId,
2441
+ ...m.allFrom.resourceId && { resourceId: m.allFrom.resourceId }
2442
+ }
2443
+ }),
2444
+ children: N(m.allFrom ? "book.toStep" : "book.toTypes")
2445
+ }), /* @__PURE__ */ f(ye, {
2446
+ businessId: m.businessId,
2447
+ eventTypeId: m.eventTypeId,
2448
+ resourceId: m.resourceId,
2449
+ onFilter: (e) => g({
2450
+ businessId: m.businessId,
1815
2451
  all: !0,
2452
+ ...m.allFrom && { allFrom: m.allFrom },
1816
2453
  ...e
1817
2454
  }),
1818
- onChoose: j
1819
- })] }) : /* @__PURE__ */ f(nt, {
1820
- selection: u,
1821
- change: h,
1822
- onChoose: j
2455
+ onChoose: P
2456
+ })] }) : /* @__PURE__ */ f(Nt, {
2457
+ selection: m,
2458
+ change: g,
2459
+ onChoose: P
1823
2460
  });
1824
- let N = k ? v ? "booking" : "sign-in" : [
1825
- u.all ? "all" : "",
1826
- u.eventTypeId ?? "",
1827
- u.resourceId ?? "",
1828
- D && w !== O ? "time" : ""
2461
+ let I = j ? y ? "booking" : "sign-in" : [
2462
+ m.all ? "all" : "",
2463
+ m.eventTypeId ?? "",
2464
+ m.resourceId ?? "",
2465
+ k && D !== A ? "time" : ""
1829
2466
  ].join("/");
1830
- return /* @__PURE__ */ f(J, {
1831
- portal: b,
1832
- loading: v === void 0,
1833
- children: /* @__PURE__ */ p(at, {
1834
- step: N,
2467
+ return /* @__PURE__ */ f(Ye, {
2468
+ portal: x,
2469
+ loading: y === void 0,
2470
+ children: /* @__PURE__ */ p(It, {
2471
+ step: I,
2472
+ initial: e.autoFocus !== !1,
1835
2473
  children: [
1836
2474
  e.onClose && /* @__PURE__ */ f("div", {
1837
2475
  className: "cp-flow-head",
@@ -1839,27 +2477,27 @@ function tt(e) {
1839
2477
  type: "button",
1840
2478
  className: "cp-secondary",
1841
2479
  onClick: e.onClose,
1842
- children: T("book.close")
2480
+ children: N("book.close")
1843
2481
  })
1844
2482
  }),
1845
- D && w === O && /* @__PURE__ */ f("p", {
2483
+ k && D === A && /* @__PURE__ */ f("p", {
1846
2484
  role: "alert",
1847
2485
  className: "cp-notice",
1848
- children: T("book.unavailable")
2486
+ children: N("book.unavailable")
1849
2487
  }),
1850
- M
2488
+ F
1851
2489
  ]
1852
2490
  })
1853
2491
  });
1854
2492
  }
1855
- function nt(e) {
1856
- let { selection: t, change: n } = e, { businessId: r, eventTypeId: i } = t, a = ce(r), o = le(a, null), { business: s, types: c } = a;
2493
+ function Nt(e) {
2494
+ let { selection: t, change: n } = e, { businessId: r, eventTypeId: i } = t, a = ge(r), o = _e(a, null), { business: s, types: c } = a;
1857
2495
  if (o || !s || !c) return o;
1858
- let l = /* @__PURE__ */ f(fe, { business: s }), u = /* @__PURE__ */ f("button", {
2496
+ let l = /* @__PURE__ */ f(be, { business: s }), u = /* @__PURE__ */ f("button", {
1859
2497
  type: "button",
1860
2498
  className: "cp-link cp-back",
1861
2499
  onClick: () => n({ businessId: r }),
1862
- children: T("book.toTypes")
2500
+ children: N("book.toTypes")
1863
2501
  }), d = c.find((e) => e.id === i);
1864
2502
  if (!d) return /* @__PURE__ */ p("section", {
1865
2503
  className: "cp-screen",
@@ -1867,12 +2505,12 @@ function nt(e) {
1867
2505
  l,
1868
2506
  i && /* @__PURE__ */ f("p", {
1869
2507
  className: "cp-empty",
1870
- children: T("business.typeMissing")
2508
+ children: N("business.typeMissing")
1871
2509
  }),
1872
- /* @__PURE__ */ f("h2", { children: T("book.chooseType") }),
2510
+ /* @__PURE__ */ f("h2", { children: N("book.chooseType") }),
1873
2511
  c.length === 0 ? /* @__PURE__ */ f("p", {
1874
2512
  className: "cp-empty",
1875
- children: T("book.noTypes")
2513
+ children: N("book.noTypes")
1876
2514
  }) : /* @__PURE__ */ f("ul", {
1877
2515
  className: "cp-list",
1878
2516
  children: c.map((e) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ p("button", {
@@ -1883,7 +2521,7 @@ function nt(e) {
1883
2521
  eventTypeId: e.id
1884
2522
  }),
1885
2523
  children: [
1886
- /* @__PURE__ */ f(I, {
2524
+ /* @__PURE__ */ f(W, {
1887
2525
  image: e.image,
1888
2526
  alt: "",
1889
2527
  size: "small",
@@ -1891,7 +2529,15 @@ function nt(e) {
1891
2529
  }),
1892
2530
  /* @__PURE__ */ f("strong", { children: e.displayName }),
1893
2531
  e.description && /* @__PURE__ */ f("span", { children: e.description }),
1894
- /* @__PURE__ */ f("span", { children: T("business.minutes", { minutes: e.durationMinutes }) })
2532
+ /* @__PURE__ */ f("span", { children: N("business.minutes", { minutes: e.durationMinutes }) }),
2533
+ e.tags.length > 0 && /* @__PURE__ */ f("span", {
2534
+ className: "cp-tags",
2535
+ children: e.tags.slice(0, 3).map((e) => /* @__PURE__ */ f("span", {
2536
+ className: "cp-tag",
2537
+ style: { "--cp-tag": xt(e.colour) },
2538
+ children: e.name
2539
+ }, e.id))
2540
+ })
1895
2541
  ]
1896
2542
  }) }, e.id))
1897
2543
  }),
@@ -1902,7 +2548,7 @@ function nt(e) {
1902
2548
  businessId: r,
1903
2549
  all: !0
1904
2550
  }),
1905
- children: T("book.seeAll")
2551
+ children: N("book.seeAll")
1906
2552
  })
1907
2553
  ]
1908
2554
  });
@@ -1912,14 +2558,14 @@ function nt(e) {
1912
2558
  children: [
1913
2559
  u,
1914
2560
  l,
1915
- /* @__PURE__ */ f(R, { type: d }),
1916
- /* @__PURE__ */ f("h2", { children: T("book.chooseResource") }),
2561
+ /* @__PURE__ */ f(xe, { type: d }),
2562
+ /* @__PURE__ */ f("h2", { children: N("book.chooseResource") }),
1917
2563
  /* @__PURE__ */ f("ul", {
1918
2564
  className: "cp-list",
1919
2565
  children: [{
1920
2566
  id: "any",
1921
- displayName: T("book.anyResource"),
1922
- description: T("book.anyResourceHint"),
2567
+ displayName: N("book.anyResource"),
2568
+ description: N("book.anyResourceHint"),
1923
2569
  image: null
1924
2570
  }, ...d.resources].map((e) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ p("button", {
1925
2571
  type: "button",
@@ -1930,7 +2576,7 @@ function nt(e) {
1930
2576
  resourceId: e.id
1931
2577
  }),
1932
2578
  children: [
1933
- /* @__PURE__ */ f(I, {
2579
+ /* @__PURE__ */ f(W, {
1934
2580
  image: e.image,
1935
2581
  alt: "",
1936
2582
  size: "small",
@@ -1940,6 +2586,17 @@ function nt(e) {
1940
2586
  e.description && /* @__PURE__ */ f("span", { children: e.description })
1941
2587
  ]
1942
2588
  }) }, e.id))
2589
+ }),
2590
+ /* @__PURE__ */ f("button", {
2591
+ type: "button",
2592
+ className: "cp-secondary",
2593
+ onClick: () => n({
2594
+ businessId: r,
2595
+ all: !0,
2596
+ eventTypeId: d.id,
2597
+ allFrom: { eventTypeId: d.id }
2598
+ }),
2599
+ children: N("book.seeAll")
1943
2600
  })
1944
2601
  ]
1945
2602
  }) : /* @__PURE__ */ p("section", {
@@ -1952,25 +2609,40 @@ function nt(e) {
1952
2609
  businessId: r,
1953
2610
  eventTypeId: d.id
1954
2611
  }),
1955
- children: T("book.otherResource")
2612
+ children: N("book.otherResource")
1956
2613
  }) : u,
1957
2614
  l,
1958
- /* @__PURE__ */ f(R, { type: d }),
2615
+ /* @__PURE__ */ f(xe, { type: d }),
1959
2616
  m && h && /* @__PURE__ */ f("p", {
1960
2617
  className: "cp-hint",
1961
- children: T("business.with", { resource: h.displayName })
2618
+ children: N("business.with", { resource: h.displayName })
1962
2619
  }),
1963
- /* @__PURE__ */ f(z, {
2620
+ /* @__PURE__ */ f(Se, {
1964
2621
  business: s,
1965
2622
  eventTypeId: d.id,
1966
2623
  resourceId: m ? h?.id : void 0,
1967
2624
  onChoose: (t) => e.onChoose(s, t)
2625
+ }),
2626
+ /* @__PURE__ */ f("button", {
2627
+ type: "button",
2628
+ className: "cp-secondary",
2629
+ onClick: () => n({
2630
+ businessId: r,
2631
+ all: !0,
2632
+ eventTypeId: d.id,
2633
+ ...m && h && { resourceId: h.id },
2634
+ allFrom: {
2635
+ eventTypeId: d.id,
2636
+ ...m && t.resourceId ? { resourceId: t.resourceId } : {}
2637
+ }
2638
+ }),
2639
+ children: N("book.seeAll")
1968
2640
  })
1969
2641
  ]
1970
2642
  });
1971
2643
  }
1972
- function rt(e) {
1973
- let { client: t } = x(), { businessId: n, time: i } = e, a = o(e);
2644
+ function Pt(e) {
2645
+ let { client: t } = k(), { businessId: n, time: i } = e, a = o(e);
1974
2646
  a.current = e;
1975
2647
  let s = $(i);
1976
2648
  return r(() => {
@@ -1978,15 +2650,15 @@ function rt(e) {
1978
2650
  return (async () => {
1979
2651
  let { data: r } = await t.GET("/web/businesses/{businessId}", { params: { path: { businessId: n } } });
1980
2652
  if (!r) throw Error("no business");
1981
- let o = se(r.timezone, new Date(i.startsAt)), { data: s } = await t.GET("/web/businesses/{businessId}/availability", { params: {
2653
+ let o = he(r.timezone, new Date(i.startsAt)), { data: s } = await t.GET("/web/businesses/{businessId}/availability", { params: {
1982
2654
  path: { businessId: n },
1983
2655
  query: {
1984
2656
  from: `${o}T00:00`,
1985
- to: `${L(o, 1)}T00:00`,
2657
+ to: `${G(o, 1)}T00:00`,
1986
2658
  eventTypeId: i.eventTypeId,
1987
2659
  ...!i.eventId && i.resourceId && { resourceId: i.resourceId }
1988
2660
  }
1989
- } }), c = s?.items.find((e) => et(e, i));
2661
+ } }), c = s?.items.find((e) => jt(e, i));
1990
2662
  e && (c ? a.current.onFound({
1991
2663
  business: r,
1992
2664
  candidate: c
@@ -2004,33 +2676,33 @@ function rt(e) {
2004
2676
  className: "cp-screen",
2005
2677
  children: /* @__PURE__ */ f("p", {
2006
2678
  role: "status",
2007
- children: T("app.loading")
2679
+ children: N("app.loading")
2008
2680
  })
2009
2681
  });
2010
2682
  }
2011
- var it = "input, .cp-option, .cp-chips button, .cp-candidate button, .cp-actions button:not(:disabled)";
2012
- function at(e) {
2683
+ var Ft = "input, .cp-option, .cp-chips button, .cp-candidate button, .cp-actions button:not(:disabled)";
2684
+ function It(e) {
2013
2685
  let t = o(null), n = o(!1), { step: i } = e;
2014
2686
  return r(() => {
2015
- let e = t.current;
2016
- if (!e) return;
2017
- let r = n.current;
2018
- if (n.current = !0, r && e.contains(document.activeElement)) return;
2019
- let i = () => {
2020
- let t = e.querySelector(it);
2021
- return t?.focus(), !!t;
2687
+ let r = t.current;
2688
+ if (!r) return;
2689
+ let i = n.current;
2690
+ if (n.current = !0, i ? r.contains(document.activeElement) : !e.initial) return;
2691
+ let a = () => {
2692
+ let e = r.querySelector(Ft);
2693
+ return e?.focus(), !!e;
2022
2694
  };
2023
- if (i()) return;
2024
- let a = new MutationObserver(() => {
2025
- i() && a.disconnect();
2695
+ if (a()) return;
2696
+ let o = new MutationObserver(() => {
2697
+ a() && o.disconnect();
2026
2698
  });
2027
- a.observe(e, {
2699
+ o.observe(r, {
2028
2700
  childList: !0,
2029
2701
  subtree: !0
2030
2702
  });
2031
- let o = () => a.disconnect();
2032
- return e.addEventListener("focusin", o), () => {
2033
- a.disconnect(), e.removeEventListener("focusin", o);
2703
+ let s = () => o.disconnect();
2704
+ return r.addEventListener("focusin", s), () => {
2705
+ o.disconnect(), r.removeEventListener("focusin", s);
2034
2706
  };
2035
2707
  }, [i]), /* @__PURE__ */ f("div", {
2036
2708
  ref: t,
@@ -2039,8 +2711,8 @@ function at(e) {
2039
2711
  });
2040
2712
  }
2041
2713
  // src/sign-in-standalone.tsx
2042
- function ot(e) {
2043
- let t = e.basePath.replace(/\/$/, ""), n = De(t, e.onSessionChange), i = o(e.onSignedIn);
2714
+ function Lt(e) {
2715
+ let t = e.basePath.replace(/\/$/, ""), n = qe(t, e.onSessionChange), i = o(e.onSignedIn);
2044
2716
  i.current = e.onSignedIn;
2045
2717
  let a = o(!1);
2046
2718
  return r(() => {
@@ -2050,67 +2722,76 @@ function ot(e) {
2050
2722
  children: n === void 0 ? /* @__PURE__ */ f("p", {
2051
2723
  className: "cp-status",
2052
2724
  role: "status",
2053
- children: T("app.loading")
2725
+ children: N("app.loading")
2054
2726
  }) : n === null && /* @__PURE__ */ f(Q, {
2055
2727
  basePath: t,
2056
2728
  brand: e.brand,
2057
2729
  botCheck: e.botCheck,
2058
2730
  notice: void 0,
2059
- onSignedIn: (e) => K(t, e),
2731
+ onSignedIn: (e) => Y(t, e),
2060
2732
  onCancel: e.onCancel,
2061
2733
  autoFocus: !0
2062
2734
  })
2063
2735
  });
2064
2736
  }
2065
2737
  // src/index.tsx
2066
- function st(e) {
2067
- let [t, n] = s("businesses"), r = e.screen ?? t, i = e.onNavigate ?? n, { basePath: a, sessionKey: o, notice: c, portal: l, signedInAs: u } = q({
2738
+ function Rt(e) {
2739
+ let [t, n] = s("businesses"), i = e.screen ?? t, a = e.onNavigate ?? n, { basePath: o, sessionKey: c, notice: l, portal: u, signedInAs: m } = Je({
2068
2740
  basePath: e.basePath,
2069
- navigate: i,
2741
+ navigate: a,
2070
2742
  accountNavigation: !0,
2071
2743
  onSessionChange: void 0
2072
- }), [m, h] = s(), g = typeof r == "string" ? r : `${r.businessId}/${r.eventTypeId ?? ""}`, [_, v] = s(g);
2073
- _ !== g && (v(g), h(void 0));
2074
- let y = (t) => /* @__PURE__ */ f(Q, {
2075
- basePath: a,
2744
+ });
2745
+ tt(i, a);
2746
+ let [h, g] = s(), _ = typeof i == "string" ? i : `${i.businessId}/${i.eventTypeId ?? ""}`, [v, y] = s(_);
2747
+ v !== _ && (y(_), g(void 0));
2748
+ let [b, x] = s();
2749
+ r(() => {
2750
+ let e = Me();
2751
+ e && (x(e.outcome), e.selection?.business && e.selection.candidate && g(e.selection));
2752
+ }, []);
2753
+ let S = (t) => /* @__PURE__ */ f(Q, {
2754
+ basePath: o,
2076
2755
  brand: void 0,
2077
2756
  botCheck: e.botCheck,
2078
- notice: c,
2079
- onSignedIn: u,
2757
+ notice: l,
2758
+ onSignedIn: m,
2080
2759
  children: t
2081
2760
  });
2082
- return /* @__PURE__ */ f(J, {
2083
- portal: l,
2084
- loading: o === void 0,
2085
- children: /* @__PURE__ */ f(xe, {
2761
+ return /* @__PURE__ */ f(Ye, {
2762
+ portal: u,
2763
+ loading: c === void 0,
2764
+ children: /* @__PURE__ */ f(He, {
2086
2765
  brand: e.brand,
2087
- tabs: be,
2088
- screen: r,
2089
- signedIn: !!o,
2090
- signingIn: !o && (!!m || typeof r == "string" && r !== "businesses"),
2091
- onNavigate: i,
2092
- onSignOut: () => l.signOut(),
2093
- children: m ? o ? /* @__PURE__ */ f(me, {
2094
- choice: m,
2095
- onBack: () => h(void 0)
2096
- }, `${m.candidate.startsAt}-${m.candidate.eventId ?? m.candidate.eventTypeId}`) : y(/* @__PURE__ */ p(d, { children: [
2097
- /* @__PURE__ */ f("p", { children: T("book.signInFirst") }),
2098
- /* @__PURE__ */ f(U, { choice: m }),
2766
+ tabs: Ve,
2767
+ screen: i,
2768
+ signedIn: !!c,
2769
+ signingIn: !c && (!!h || typeof i == "string" && i !== "businesses"),
2770
+ onNavigate: a,
2771
+ onSignOut: () => u.signOut(),
2772
+ children: h ? c ? /* @__PURE__ */ f(Ne, {
2773
+ choice: h,
2774
+ onBack: () => g(void 0),
2775
+ onLeave: () => je(h),
2776
+ returned: b
2777
+ }, `${h.candidate.startsAt}-${h.candidate.eventId ?? h.candidate.eventTypeId}`) : S(/* @__PURE__ */ p(d, { children: [
2778
+ /* @__PURE__ */ f("p", { children: N("book.signInFirst") }),
2779
+ /* @__PURE__ */ f(J, { choice: h }),
2099
2780
  /* @__PURE__ */ f("button", {
2100
2781
  type: "button",
2101
2782
  className: "cp-link",
2102
- onClick: () => h(void 0),
2103
- children: T("book.back")
2783
+ onClick: () => g(void 0),
2784
+ children: N("book.back")
2104
2785
  })
2105
- ] })) : typeof r == "object" ? /* @__PURE__ */ f(de, {
2106
- businessId: r.businessId,
2107
- eventTypeId: r.eventTypeId,
2108
- onChoose: (e, t) => h({
2786
+ ] })) : typeof i == "object" ? /* @__PURE__ */ f(ye, {
2787
+ businessId: i.businessId,
2788
+ eventTypeId: i.eventTypeId,
2789
+ onChoose: (e, t) => g({
2109
2790
  business: e,
2110
2791
  candidate: t
2111
2792
  })
2112
- }) : r === "businesses" ? /* @__PURE__ */ f(Oe, {}) : o ? f(r === "passes" ? Ae : r === "details" ? ke : P, {}) : y()
2793
+ }) : i === "businesses" ? /* @__PURE__ */ f(Xe, {}) : c ? f(i === "passes" ? rt : i === "details" ? Ze : ue, {}) : S()
2113
2794
  })
2114
2795
  });
2115
2796
  }
2116
- export { Qe as MsmAccount, tt as MsmBooking, st as MsmCustomer, ot as MsmSignIn, te as cancellationState, j as formatDate, k as formatDateTime, O as formatNumber, C as locale, T as t };
2797
+ export { kt as MsmAccount, Mt as MsmBooking, Rt as MsmCustomer, Lt as MsmSignIn, ce as cancellationState, z as formatDate, L as formatDateTime, ee as formatNumber, j as locale, N as t };