@msm-platform/customer-react 0.4.0 → 0.4.1

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
@@ -107,6 +107,9 @@ var S = {
107
107
  "business.full": "Full",
108
108
  "business.openTime": "Open time",
109
109
  "business.with": "With {resource}",
110
+ "business.instructor": "Instructor: {names}",
111
+ "business.room": "Room: {names}",
112
+ "business.guests": "Guest instructors: {names}",
110
113
  "business.book": "Book",
111
114
  "book.heading": "Your booking",
112
115
  "book.signInFirst": "Sign in with your phone to book this time.",
@@ -208,20 +211,20 @@ function N(e, t, n) {
208
211
  end: r ? A(t, n) : k(t, n)
209
212
  });
210
213
  }
211
- function P(e) {
214
+ function ee(e) {
212
215
  if (e < 60) return D("wait.seconds", e);
213
216
  let t = Math.round(e / 60);
214
217
  return t < 60 ? D("wait.minutes", t) : D("wait.hours", Math.round(e / 3600));
215
218
  }
216
219
  // src/cancellation.ts
217
- function F(e, t) {
220
+ function te(e, t) {
218
221
  if (e.status === "cancelled") return "cancelled";
219
222
  let n = t.getTime();
220
223
  return !e.cancellableUntil || n >= Date.parse(e.cancellableUntil) ? "closed" : e.lateCancellationFrom && n >= Date.parse(e.lateCancellationFrom) ? "late" : "open";
221
224
  }
222
225
  // src/screens/bookings.tsx
223
- var ee = "/web/businesses/{businessId}/bookings/{bookingId}/cancel";
224
- function te() {
226
+ var ne = "/web/businesses/{businessId}/bookings/{bookingId}/cancel";
227
+ function P() {
225
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) => {
226
229
  d(!1);
227
230
  try {
@@ -256,12 +259,12 @@ function te() {
256
259
  className: "cp-notice",
257
260
  children: T(m)
258
261
  }),
259
- u ? /* @__PURE__ */ f(I, { onRetry: () => g() }) : a ? a.length === 0 ? /* @__PURE__ */ f("p", {
262
+ u ? /* @__PURE__ */ f(F, { onRetry: () => g() }) : a ? a.length === 0 ? /* @__PURE__ */ f("p", {
260
263
  className: "cp-empty",
261
264
  children: T(n === "upcoming" ? "bookings.emptyUpcoming" : "bookings.emptyPast")
262
265
  }) : /* @__PURE__ */ f("ul", {
263
266
  className: "cp-list",
264
- children: a.map((e) => /* @__PURE__ */ f(ne, {
267
+ children: a.map((e) => /* @__PURE__ */ f(re, {
265
268
  booking: e,
266
269
  onCancelled: (e, t) => {
267
270
  o((t) => t?.map((t) => t.id === e.id ? e : t)), h(t ? "bookings.doneLate" : "bookings.doneOnTime");
@@ -280,7 +283,7 @@ function te() {
280
283
  ]
281
284
  });
282
285
  }
283
- function I({ onRetry: e }) {
286
+ function F({ onRetry: e }) {
284
287
  return /* @__PURE__ */ p("div", {
285
288
  role: "alert",
286
289
  className: "cp-error",
@@ -292,12 +295,12 @@ function I({ onRetry: e }) {
292
295
  })]
293
296
  });
294
297
  }
295
- function ne(e) {
296
- 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" : F(r, /* @__PURE__ */ new Date()), v = r.creditMembershipId !== null && r.creditRestoredAt === null;
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;
297
300
  async function y() {
298
301
  l(!0), m(void 0);
299
302
  try {
300
- let { data: n } = await t.POST(ee, { params: { path: {
303
+ let { data: n } = await t.POST(ne, { params: { path: {
301
304
  businessId: r.businessId,
302
305
  bookingId: r.id
303
306
  } } });
@@ -308,7 +311,7 @@ function ne(e) {
308
311
  lateCancellationFrom: null
309
312
  }, n.cancelledLate === !0));
310
313
  } catch (e) {
311
- if (u(e, "post", ee)) {
314
+ if (u(e, "post", ne)) {
312
315
  if (e.code === "EventStarted") {
313
316
  g(!0), o(!1);
314
317
  return;
@@ -388,89 +391,410 @@ function ne(e) {
388
391
  ]
389
392
  });
390
393
  }
391
- // src/booking.tsx
392
- var re = "/web/businesses/{businessId}/reservations", ie = "/web/businesses/{businessId}/reservations/{reservationId}/confirm";
393
- function L({ choice: e }) {
394
- let { business: t, candidate: n } = e;
394
+ // src/image.tsx
395
+ function I(e) {
396
+ let { image: t, alt: n, className: r } = e;
397
+ if (!t) return null;
398
+ let { small: i } = t;
399
+ return e.size === "small" ? /* @__PURE__ */ f("img", {
400
+ className: r,
401
+ src: i.url,
402
+ width: i.width,
403
+ height: i.height,
404
+ alt: n,
405
+ loading: "lazy",
406
+ decoding: "async"
407
+ }) : i.url === t.url ? /* @__PURE__ */ f("img", {
408
+ className: r,
409
+ src: t.url,
410
+ width: t.width,
411
+ height: t.height,
412
+ alt: n,
413
+ loading: "lazy",
414
+ decoding: "async"
415
+ }) : /* @__PURE__ */ f("img", {
416
+ className: r,
417
+ src: t.url,
418
+ srcSet: `${i.url} ${i.width}w, ${t.url} ${t.width}w`,
419
+ sizes: "(min-width: 640px) 608px, calc(100vw - 32px)",
420
+ width: t.width,
421
+ height: t.height,
422
+ alt: n,
423
+ loading: "lazy",
424
+ decoding: "async"
425
+ });
426
+ }
427
+ // src/screens/business.tsx
428
+ var ie = "/web/businesses/{businessId}", ae = /* @__PURE__ */ new Set([
429
+ "BusinessNotFound",
430
+ "OutsideClientScope",
431
+ "ValidationFailed"
432
+ ]), oe = 7;
433
+ function se(e, t = /* @__PURE__ */ new Date()) {
434
+ return new Intl.DateTimeFormat("en-CA", {
435
+ timeZone: e,
436
+ year: "numeric",
437
+ month: "2-digit",
438
+ day: "2-digit"
439
+ }).format(t);
440
+ }
441
+ function L(e, t) {
442
+ let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
443
+ return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
444
+ }
445
+ function ce(e) {
446
+ let { client: n } = x(), [i, a] = s(), [o, c] = s(), [l, d] = s(!1), f = t(async () => {
447
+ d(!1), a(void 0);
448
+ 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 } } })]);
450
+ a(t.data ?? null), c(r.data?.items ?? []);
451
+ } catch (e) {
452
+ u(e) && ae.has(e.code ?? "") ? a(null) : d(!0);
453
+ }
454
+ }, [n, e]);
455
+ return r(() => {
456
+ f();
457
+ }, [f]), {
458
+ business: i,
459
+ types: o,
460
+ failed: l,
461
+ reload: f
462
+ };
463
+ }
464
+ function le(e, t) {
465
+ if (e.failed) return /* @__PURE__ */ p("section", {
466
+ className: "cp-screen",
467
+ children: [t, /* @__PURE__ */ f(F, { onRetry: e.reload })]
468
+ });
469
+ if (e.business === null) return /* @__PURE__ */ p("section", {
470
+ className: "cp-screen",
471
+ children: [t, /* @__PURE__ */ f("p", {
472
+ className: "cp-empty",
473
+ children: T("business.notFound")
474
+ })]
475
+ });
476
+ if (e.business === void 0 || !e.types) return /* @__PURE__ */ p("section", {
477
+ className: "cp-screen",
478
+ children: [t, /* @__PURE__ */ f("p", {
479
+ role: "status",
480
+ children: T("app.loading")
481
+ })]
482
+ });
483
+ }
484
+ function ue(e) {
485
+ let t = /* @__PURE__ */ new Map();
486
+ for (let n of e) for (let e of n.resources) t.has(e.id) || t.set(e.id, e);
487
+ return [...t.values()];
488
+ }
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", {
491
+ type: "button",
492
+ className: "cp-link cp-back",
493
+ onClick: () => t("businesses"),
494
+ children: T("business.all")
495
+ }), c = le(o, s), { business: l, types: u } = o;
496
+ 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) => {
498
+ if (!a) return t(e ? {
499
+ businessId: r,
500
+ eventTypeId: e
501
+ } : { businessId: r });
502
+ let n = u.find((t) => t.id === e), i = g && ue(n ? [n] : u).some((e) => e.id === g);
503
+ a({
504
+ ...e && { eventTypeId: e },
505
+ ...i && { resourceId: g }
506
+ });
507
+ };
508
+ return /* @__PURE__ */ p("section", {
509
+ className: "cp-screen",
510
+ children: [
511
+ s,
512
+ /* @__PURE__ */ f(fe, { business: l }),
513
+ u.length > 0 && /* @__PURE__ */ p("fieldset", {
514
+ className: "cp-chips",
515
+ "aria-label": T("business.types"),
516
+ children: [/* @__PURE__ */ f("button", {
517
+ type: "button",
518
+ "aria-pressed": !i,
519
+ onClick: () => _(void 0),
520
+ children: T("business.allTypes")
521
+ }), u.map((e) => /* @__PURE__ */ f("button", {
522
+ type: "button",
523
+ "aria-pressed": e.id === i,
524
+ onClick: () => _(e.id),
525
+ children: e.displayName
526
+ }, e.id))]
527
+ }),
528
+ a && h.length > 1 && /* @__PURE__ */ p("fieldset", {
529
+ className: "cp-chips",
530
+ children: [
531
+ /* @__PURE__ */ f("legend", { children: T("business.resources") }),
532
+ /* @__PURE__ */ f("button", {
533
+ type: "button",
534
+ "aria-pressed": !g,
535
+ onClick: () => a({ ...i && { eventTypeId: i } }),
536
+ children: T("business.anyResource")
537
+ }),
538
+ h.map((e) => /* @__PURE__ */ f("button", {
539
+ type: "button",
540
+ "aria-pressed": e.id === g,
541
+ onClick: () => a({
542
+ ...i && { eventTypeId: i },
543
+ resourceId: e.id
544
+ }),
545
+ children: e.displayName
546
+ }, e.id))
547
+ ]
548
+ }),
549
+ i && !m ? /* @__PURE__ */ f("p", {
550
+ className: "cp-empty",
551
+ children: T("business.typeMissing")
552
+ }) : /* @__PURE__ */ p(d, { children: [m && /* @__PURE__ */ f(R, { type: m }), /* @__PURE__ */ f(z, {
553
+ business: l,
554
+ eventTypeId: i,
555
+ resourceId: g,
556
+ onChoose: (t) => e.onChoose(l, t)
557
+ })] })
558
+ ]
559
+ });
560
+ }
561
+ function fe({ business: e }) {
562
+ return /* @__PURE__ */ p("header", {
563
+ className: "cp-business-head",
564
+ children: [/* @__PURE__ */ f(I, {
565
+ image: e.logo,
566
+ alt: T("image.logo", { name: e.displayName }),
567
+ size: "small",
568
+ className: "cp-logo"
569
+ }), /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("h1", { children: e.displayName }), e.address && /* @__PURE__ */ f("p", {
570
+ className: "cp-hint",
571
+ children: e.address
572
+ })] })]
573
+ });
574
+ }
575
+ function R({ type: e }) {
395
576
  return /* @__PURE__ */ p("div", {
396
- className: "cp-summary",
577
+ className: "cp-type",
397
578
  children: [
398
- /* @__PURE__ */ f("h2", { children: n.title }),
399
- /* @__PURE__ */ f("p", { children: t.displayName }),
400
- /* @__PURE__ */ f("p", { children: N(n.startsAt, n.endsAt, n.timezone) }),
401
- n.resource && /* @__PURE__ */ f("p", {
579
+ /* @__PURE__ */ f(I, {
580
+ image: e.image,
581
+ alt: e.displayName,
582
+ size: "full",
583
+ className: "cp-detail-image"
584
+ }),
585
+ /* @__PURE__ */ f("h2", { children: e.displayName }),
586
+ e.description && /* @__PURE__ */ f("p", { children: e.description }),
587
+ /* @__PURE__ */ f("p", {
402
588
  className: "cp-hint",
403
- children: T("business.with", { resource: n.resource.displayName })
589
+ children: T("business.minutes", { minutes: e.durationMinutes })
404
590
  })
405
591
  ]
406
592
  });
407
593
  }
408
- function ae(e) {
409
- let { client: n, navigate: i, accountNavigation: a } = x(), { business: c, candidate: l } = e.choice, [m, h] = s({ step: "reserving" }), [g, _] = s(), v = t(async () => {
410
- h({ step: "reserving" });
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 () => {
596
+ _(!1), h(void 0);
411
597
  try {
412
- let { data: e } = await n.POST(re, {
413
- params: { path: { businessId: c.id } },
414
- body: l.eventId ? { eventId: l.eventId } : {
415
- eventTypeId: l.eventTypeId,
416
- startsAt: l.startsAt,
417
- ...l.resource && { resourceId: l.resource.id }
598
+ let { data: e } = await n.GET("/web/businesses/{businessId}/availability", { params: {
599
+ path: { businessId: i.id },
600
+ query: {
601
+ from: `${v}T00:00`,
602
+ to: `${y}T00:00`,
603
+ ...a && { eventTypeId: a },
604
+ ...o && { resourceId: o }
418
605
  }
419
- });
420
- e && h({
421
- step: "held",
422
- reservationId: e.id,
423
- expiresAt: e.expiresAt
424
- });
425
- } catch (e) {
426
- let t = u(e, "post", re) ? e.code : void 0;
427
- h({
428
- step: "refused",
429
- message: oe(t),
430
- again: !1
431
- });
606
+ } });
607
+ h(e?.items ?? []);
608
+ } catch {
609
+ _(!0);
432
610
  }
433
611
  }, [
434
612
  n,
435
- c.id,
436
- l
437
- ]), y = o(!1);
613
+ i.id,
614
+ a,
615
+ o,
616
+ v,
617
+ y
618
+ ]);
438
619
  r(() => {
439
- y.current || (y.current = !0, v());
440
- }, [v]);
441
- async function b(t, r) {
442
- h({
443
- step: "confirming",
444
- reservationId: t,
445
- expiresAt: r
446
- });
447
- try {
448
- let { data: r } = await n.POST(ie, { params: { path: {
449
- businessId: c.id,
450
- reservationId: t
451
- } } });
452
- if (!r) return;
453
- e.onBooked?.(r);
454
- let i = await n.GET("/web/businesses/{businessId}/bookings/{bookingId}", { params: { path: {
455
- businessId: c.id,
456
- bookingId: r.id
457
- } } }).then(({ data: e }) => e ?? null).catch(() => null);
458
- h({
459
- step: "booked",
460
- booking: i
461
- });
462
- } catch (e) {
463
- let t = u(e, "post", ie) ? e.code : void 0;
464
- h(t === "ReservationExpired" || t === "ReservationNotFound" ? {
465
- step: "refused",
466
- message: "book.expired",
467
- again: !0
468
- } : {
469
- step: "refused",
470
- message: se(t),
471
- again: !1
472
- });
473
- }
620
+ b();
621
+ }, [b]);
622
+ let S = Date.now(), C = /* @__PURE__ */ new Map();
623
+ 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]);
627
+ }
628
+ let w = T("business.weekOf", {
629
+ from: j(`${v}T12:00:00Z`, "UTC"),
630
+ to: j(`${L(y, -1)}T12:00:00Z`, "UTC")
631
+ });
632
+ return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("fieldset", {
633
+ className: "cp-week",
634
+ "aria-label": T("business.week"),
635
+ children: [
636
+ /* @__PURE__ */ f("button", {
637
+ type: "button",
638
+ className: "cp-secondary",
639
+ disabled: l === 0,
640
+ onClick: () => u((e) => e - 1),
641
+ "aria-label": T("business.previousWeek"),
642
+ children: "‹"
643
+ }),
644
+ /* @__PURE__ */ f("span", { children: w }),
645
+ /* @__PURE__ */ f("button", {
646
+ type: "button",
647
+ className: "cp-secondary",
648
+ onClick: () => u((e) => e + 1),
649
+ "aria-label": T("business.nextWeek"),
650
+ children: "›"
651
+ })
652
+ ]
653
+ }), g ? /* @__PURE__ */ f(F, { onRetry: b }) : m ? C.size === 0 ? /* @__PURE__ */ f("p", {
654
+ className: "cp-empty",
655
+ children: T("business.empty")
656
+ }) : [...C].map(([t, n]) => /* @__PURE__ */ p("div", {
657
+ className: "cp-day",
658
+ children: [/* @__PURE__ */ f("h2", { children: t }), /* @__PURE__ */ f("ul", {
659
+ className: "cp-list",
660
+ children: n.map((t) => /* @__PURE__ */ f(pe, {
661
+ candidate: t,
662
+ onChoose: () => e.onChoose(t)
663
+ }, `${t.eventId ?? t.eventTypeId}-${t.resource?.id ?? ""}-${t.startsAt}`))
664
+ })]
665
+ }, t)) : /* @__PURE__ */ f("p", {
666
+ role: "status",
667
+ children: T("app.loading")
668
+ })] });
669
+ }
670
+ function B({ candidate: e }) {
671
+ if (e.kind === "slot") return e.resource ? /* @__PURE__ */ f("p", {
672
+ className: "cp-hint",
673
+ children: T("business.with", { resource: e.resource.displayName })
674
+ }) : 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", {
681
+ className: "cp-hint cp-resources",
682
+ children: o.join(" · ")
683
+ }) : null;
684
+ }
685
+ function pe(e) {
686
+ let { candidate: t } = e, n = t.kind === "slot";
687
+ return /* @__PURE__ */ p("li", {
688
+ className: "cp-card cp-candidate",
689
+ "data-kind": t.kind,
690
+ children: [
691
+ /* @__PURE__ */ p("p", {
692
+ className: "cp-time",
693
+ children: [
694
+ A(t.startsAt, t.timezone),
695
+ " – ",
696
+ A(t.endsAt, t.timezone)
697
+ ]
698
+ }),
699
+ /* @__PURE__ */ p("div", {
700
+ className: "cp-candidate-body",
701
+ children: [
702
+ /* @__PURE__ */ f("h3", { children: t.title }),
703
+ /* @__PURE__ */ f(B, { candidate: t }),
704
+ /* @__PURE__ */ f("p", {
705
+ className: "cp-hint",
706
+ children: n ? T("business.openTime") : t.full ? T("business.full") : D("business.seatsLeft", t.seatsLeft)
707
+ })
708
+ ]
709
+ }),
710
+ !t.full && /* @__PURE__ */ f("button", {
711
+ type: "button",
712
+ onClick: e.onChoose,
713
+ children: T("business.book")
714
+ })
715
+ ]
716
+ });
717
+ }
718
+ // src/booking.tsx
719
+ var V = "/web/businesses/{businessId}/reservations", H = "/web/businesses/{businessId}/reservations/{reservationId}/confirm";
720
+ function U({ choice: e }) {
721
+ let { business: t, candidate: n } = e;
722
+ return /* @__PURE__ */ p("div", {
723
+ className: "cp-summary",
724
+ children: [
725
+ /* @__PURE__ */ f("h2", { children: n.title }),
726
+ /* @__PURE__ */ f("p", { children: t.displayName }),
727
+ /* @__PURE__ */ f("p", { children: N(n.startsAt, n.endsAt, n.timezone) }),
728
+ /* @__PURE__ */ f(B, { candidate: n })
729
+ ]
730
+ });
731
+ }
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" });
735
+ 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 }
742
+ }
743
+ });
744
+ e && h({
745
+ step: "held",
746
+ reservationId: e.id,
747
+ expiresAt: e.expiresAt
748
+ });
749
+ } catch (e) {
750
+ let t = u(e, "post", V) ? e.code : void 0;
751
+ h({
752
+ step: "refused",
753
+ message: he(t),
754
+ again: !1
755
+ });
756
+ }
757
+ }, [
758
+ n,
759
+ c.id,
760
+ l
761
+ ]), y = o(!1);
762
+ r(() => {
763
+ y.current || (y.current = !0, v());
764
+ }, [v]);
765
+ async function b(t, r) {
766
+ h({
767
+ step: "confirming",
768
+ reservationId: t,
769
+ expiresAt: r
770
+ });
771
+ try {
772
+ let { data: r } = await n.POST(H, { params: { path: {
773
+ businessId: c.id,
774
+ reservationId: t
775
+ } } });
776
+ if (!r) return;
777
+ e.onBooked?.(r);
778
+ let i = await n.GET("/web/businesses/{businessId}/bookings/{bookingId}", { params: { path: {
779
+ businessId: c.id,
780
+ bookingId: r.id
781
+ } } }).then(({ data: e }) => e ?? null).catch(() => null);
782
+ h({
783
+ step: "booked",
784
+ booking: i
785
+ });
786
+ } catch (e) {
787
+ let t = u(e, "post", H) ? e.code : void 0;
788
+ h(t === "ReservationExpired" || t === "ReservationNotFound" ? {
789
+ step: "refused",
790
+ message: "book.expired",
791
+ again: !0
792
+ } : {
793
+ step: "refused",
794
+ message: ge(t),
795
+ again: !1
796
+ });
797
+ }
474
798
  }
475
799
  let S = /* @__PURE__ */ f("button", {
476
800
  type: "button",
@@ -488,7 +812,7 @@ function ae(e) {
488
812
  }),
489
813
  m.booking ? /* @__PURE__ */ f("ul", {
490
814
  className: "cp-list",
491
- children: /* @__PURE__ */ f(ne, {
815
+ children: /* @__PURE__ */ f(re, {
492
816
  booking: m.booking,
493
817
  onCancelled: (e, t) => {
494
818
  h({
@@ -497,7 +821,7 @@ function ae(e) {
497
821
  }), _(t ? "bookings.doneLate" : "bookings.doneOnTime");
498
822
  }
499
823
  })
500
- }) : /* @__PURE__ */ f(L, { choice: e.choice }),
824
+ }) : /* @__PURE__ */ f(U, { choice: e.choice }),
501
825
  a ? /* @__PURE__ */ f("button", {
502
826
  type: "button",
503
827
  className: "cp-secondary",
@@ -510,7 +834,7 @@ function ae(e) {
510
834
  children: T("book.done")
511
835
  })
512
836
  ] }) : /* @__PURE__ */ p(d, { children: [
513
- /* @__PURE__ */ f(L, { choice: e.choice }),
837
+ /* @__PURE__ */ f(U, { choice: e.choice }),
514
838
  m.step === "reserving" && /* @__PURE__ */ f("p", {
515
839
  role: "status",
516
840
  children: T("book.reserving")
@@ -541,7 +865,7 @@ function ae(e) {
541
865
  ] })]
542
866
  });
543
867
  }
544
- function oe(e) {
868
+ function he(e) {
545
869
  switch (e) {
546
870
  case "EventFull": return "book.full";
547
871
  case "SlotTaken": return "book.slotTaken";
@@ -556,7 +880,7 @@ function oe(e) {
556
880
  default: return "book.failed";
557
881
  }
558
882
  }
559
- function se(e) {
883
+ function ge(e) {
560
884
  switch (e) {
561
885
  case "NotAuthorized": return "book.notAllowed";
562
886
  case "EventStarted":
@@ -567,7 +891,7 @@ function se(e) {
567
891
  }
568
892
  }
569
893
  // src/layout.tsx
570
- function R({ brand: e }) {
894
+ function _e({ brand: e }) {
571
895
  return e ? /* @__PURE__ */ p("div", {
572
896
  className: "cp-brand",
573
897
  children: [e.logo && /* @__PURE__ */ f("img", {
@@ -576,493 +900,181 @@ function R({ brand: e }) {
576
900
  }), /* @__PURE__ */ f("span", { children: e.name })]
577
901
  }) : null;
578
902
  }
579
- var ce = [["businesses", "nav.book"]], le = [
580
- ["bookings", "nav.bookings"],
581
- ["passes", "nav.passes"],
582
- ["details", "nav.details"]
583
- ], ue = [...ce, ...le];
584
- function de(e) {
585
- let t = typeof e.screen == "string" ? e.screen : "businesses";
586
- return /* @__PURE__ */ p("div", {
587
- className: "cp-shell",
588
- children: [
589
- /* @__PURE__ */ p("header", {
590
- className: "cp-header",
591
- children: [/* @__PURE__ */ f(R, { brand: e.brand }), e.signedIn ? /* @__PURE__ */ f("button", {
592
- type: "button",
593
- className: "cp-link",
594
- onClick: e.onSignOut,
595
- children: T("nav.signOut")
596
- }) : !e.signingIn && /* @__PURE__ */ f("button", {
597
- type: "button",
598
- className: "cp-link",
599
- onClick: () => e.onNavigate("bookings"),
600
- children: T("nav.signIn")
601
- })]
602
- }),
603
- /* @__PURE__ */ f("nav", {
604
- className: "cp-nav",
605
- "aria-label": T("nav.label"),
606
- children: e.tabs.map(([n, r]) => /* @__PURE__ */ f("button", {
607
- type: "button",
608
- "aria-current": t === n ? "page" : void 0,
609
- onClick: () => e.onNavigate(n),
610
- children: T(r)
611
- }, n))
612
- }),
613
- /* @__PURE__ */ f("main", {
614
- className: "cp-main",
615
- children: e.children
616
- })
617
- ]
618
- });
619
- }
620
- // src/client.ts
621
- var z = (e, t) => {
622
- let n = new Request(e, t);
623
- return n.headers.set("X-MSM-BFF", "1"), fetch(n);
624
- };
625
- function B(e, t, n) {
626
- return z(`${e}${t}`, {
627
- method: "POST",
628
- headers: { "content-type": "application/json" },
629
- body: JSON.stringify(n ?? {})
630
- });
631
- }
632
- function fe(e, t) {
633
- let n = l({ baseUrl: `${e}/engine` });
634
- return n.use({
635
- onRequest({ request: e }) {
636
- return e.headers.set("X-MSM-BFF", "1"), e;
637
- },
638
- onResponse({ response: e }) {
639
- e.status === 401 && t();
640
- }
641
- }), n;
642
- }
643
- // src/session.ts
644
- var V = /* @__PURE__ */ new Map();
645
- function H(e) {
646
- let t = V.get(e);
647
- return t || (t = {
648
- value: void 0,
649
- listeners: /* @__PURE__ */ new Set(),
650
- generation: 0
651
- }, V.set(e, t)), t;
652
- }
653
- function U(e, t) {
654
- let n = H(e);
655
- if (n.value !== t) {
656
- n.value = t;
657
- for (let e of n.listeners) e();
658
- }
659
- }
660
- function pe(e, t) {
661
- let { generation: n } = t, r = (r) => {
662
- t.generation === n && t.value === void 0 && U(e, r);
663
- };
664
- z(`${e}/auth/session`).then(async (e) => r(e.ok ? (await e.json()).sessionKey : null)).catch(() => r(null));
665
- }
666
- function me(e, t) {
667
- let n = H(e);
668
- return n.listeners.size === 0 && n.value === void 0 && pe(e, n), n.listeners.add(t), () => {
669
- n.listeners.delete(t), n.listeners.size === 0 && queueMicrotask(() => {
670
- n.listeners.size > 0 || (n.value = void 0, n.generation++);
671
- });
672
- };
673
- }
674
- function he(e, t) {
675
- let n = c((t) => me(e, t), () => H(e).value, () => void 0), i = o(void 0), a = o(t);
676
- return a.current = t, r(() => {
677
- if (n === void 0) return;
678
- let e = n !== null;
679
- i.current !== void 0 && i.current !== e && a.current?.(e), i.current = e;
680
- }, [n]), n;
681
- }
682
- // src/portal.tsx
683
- function W(e) {
684
- let { navigate: n, accountNavigation: i } = e, c = e.basePath.replace(/\/$/, ""), l = he(c, e.onSessionChange), u = o(!1);
685
- u.current = !!l;
686
- let [d, f] = s(), [p, m] = s(/* @__PURE__ */ new Map()), [h, g] = s("loading"), _ = a(() => fe(c, () => {
687
- u.current && f("app.signedOut"), U(c, null);
688
- }), [c]), v = t(async () => {
689
- g("loading");
690
- try {
691
- let e = /* @__PURE__ */ new Map(), t;
692
- do {
693
- let { data: n } = await _.GET("/web/businesses", { params: { query: {
694
- limit: 100,
695
- ...t && { cursor: t }
696
- } } });
697
- for (let t of n?.items ?? []) e.set(t.id, t);
698
- t = n?.nextCursor ?? void 0;
699
- } while (t);
700
- m(e), g("ready");
701
- } catch {
702
- g("failed");
703
- }
704
- }, [_]);
705
- return r(() => {
706
- v();
707
- }, [v]), {
708
- basePath: c,
709
- sessionKey: l,
710
- notice: d,
711
- portal: a(() => ({
712
- client: _,
713
- businesses: p,
714
- businessesStatus: h,
715
- reloadBusinesses: () => void v(),
716
- navigate: n,
717
- accountNavigation: i,
718
- signOut: async (e) => {
719
- await B(c, "/auth/logout").catch(() => {}), f(e), U(c, null);
720
- }
721
- }), [
722
- _,
723
- p,
724
- h,
725
- v,
726
- n,
727
- i,
728
- c
729
- ]),
730
- signedInAs: t((e) => {
731
- f(void 0), U(c, e);
732
- }, [c])
733
- };
734
- }
735
- function G(e) {
736
- return /* @__PURE__ */ f("div", {
737
- className: "msm-customer",
738
- children: e.loading ? /* @__PURE__ */ f("p", {
739
- className: "cp-status",
740
- role: "status",
741
- children: T("app.loading")
742
- }) : /* @__PURE__ */ f(b.Provider, {
743
- value: e.portal,
744
- children: e.children
745
- })
746
- });
747
- }
748
- // src/image.tsx
749
- function K(e) {
750
- let { image: t, alt: n, className: r } = e;
751
- if (!t) return null;
752
- let { small: i } = t;
753
- return e.size === "small" ? /* @__PURE__ */ f("img", {
754
- className: r,
755
- src: i.url,
756
- width: i.width,
757
- height: i.height,
758
- alt: n,
759
- loading: "lazy",
760
- decoding: "async"
761
- }) : i.url === t.url ? /* @__PURE__ */ f("img", {
762
- className: r,
763
- src: t.url,
764
- width: t.width,
765
- height: t.height,
766
- alt: n,
767
- loading: "lazy",
768
- decoding: "async"
769
- }) : /* @__PURE__ */ f("img", {
770
- className: r,
771
- src: t.url,
772
- srcSet: `${i.url} ${i.width}w, ${t.url} ${t.width}w`,
773
- sizes: "(min-width: 640px) 608px, calc(100vw - 32px)",
774
- width: t.width,
775
- height: t.height,
776
- alt: n,
777
- loading: "lazy",
778
- decoding: "async"
779
- });
780
- }
781
- // src/screens/business.tsx
782
- var ge = "/web/businesses/{businessId}", _e = /* @__PURE__ */ new Set([
783
- "BusinessNotFound",
784
- "OutsideClientScope",
785
- "ValidationFailed"
786
- ]), ve = 7;
787
- function ye(e, t = /* @__PURE__ */ new Date()) {
788
- return new Intl.DateTimeFormat("en-CA", {
789
- timeZone: e,
790
- year: "numeric",
791
- month: "2-digit",
792
- day: "2-digit"
793
- }).format(t);
794
- }
795
- function q(e, t) {
796
- let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
797
- return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
798
- }
799
- function be(e) {
800
- let { client: n } = x(), [i, a] = s(), [o, c] = s(), [l, d] = s(!1), f = t(async () => {
801
- d(!1), a(void 0);
802
- try {
803
- let [t, r] = await Promise.all([n.GET(ge, { params: { path: { businessId: e } } }), n.GET("/web/businesses/{businessId}/event-types", { params: { path: { businessId: e } } })]);
804
- a(t.data ?? null), c(r.data?.items ?? []);
805
- } catch (e) {
806
- u(e) && _e.has(e.code ?? "") ? a(null) : d(!0);
807
- }
808
- }, [n, e]);
809
- return r(() => {
810
- f();
811
- }, [f]), {
812
- business: i,
813
- types: o,
814
- failed: l,
815
- reload: f
816
- };
817
- }
818
- function xe(e, t) {
819
- if (e.failed) return /* @__PURE__ */ p("section", {
820
- className: "cp-screen",
821
- children: [t, /* @__PURE__ */ f(I, { onRetry: e.reload })]
822
- });
823
- if (e.business === null) return /* @__PURE__ */ p("section", {
824
- className: "cp-screen",
825
- children: [t, /* @__PURE__ */ f("p", {
826
- className: "cp-empty",
827
- children: T("business.notFound")
828
- })]
829
- });
830
- if (e.business === void 0 || !e.types) return /* @__PURE__ */ p("section", {
831
- className: "cp-screen",
832
- children: [t, /* @__PURE__ */ f("p", {
833
- role: "status",
834
- children: T("app.loading")
835
- })]
836
- });
837
- }
838
- function Se(e) {
839
- let t = /* @__PURE__ */ new Map();
840
- for (let n of e) for (let e of n.resources) t.has(e.id) || t.set(e.id, e);
841
- return [...t.values()];
842
- }
843
- function Ce(e) {
844
- let { navigate: t, accountNavigation: n } = x(), { businessId: r, eventTypeId: i, onFilter: a } = e, o = be(r), s = n && /* @__PURE__ */ f("button", {
845
- type: "button",
846
- className: "cp-link cp-back",
847
- onClick: () => t("businesses"),
848
- children: T("business.all")
849
- }), c = xe(o, s), { business: l, types: u } = o;
850
- if (c || !l || !u) return c;
851
- let m = u.find((e) => e.id === i), h = a ? Se(m ? [m] : u) : [], g = h.some((t) => t.id === e.resourceId) ? e.resourceId : void 0, _ = (e) => {
852
- if (!a) return t(e ? {
853
- businessId: r,
854
- eventTypeId: e
855
- } : { businessId: r });
856
- let n = u.find((t) => t.id === e), i = g && Se(n ? [n] : u).some((e) => e.id === g);
857
- a({
858
- ...e && { eventTypeId: e },
859
- ...i && { resourceId: g }
860
- });
861
- };
862
- return /* @__PURE__ */ p("section", {
863
- className: "cp-screen",
864
- children: [
865
- s,
866
- /* @__PURE__ */ f(we, { business: l }),
867
- u.length > 0 && /* @__PURE__ */ p("fieldset", {
868
- className: "cp-chips",
869
- "aria-label": T("business.types"),
870
- children: [/* @__PURE__ */ f("button", {
871
- type: "button",
872
- "aria-pressed": !i,
873
- onClick: () => _(void 0),
874
- children: T("business.allTypes")
875
- }), u.map((e) => /* @__PURE__ */ f("button", {
876
- type: "button",
877
- "aria-pressed": e.id === i,
878
- onClick: () => _(e.id),
879
- children: e.displayName
880
- }, e.id))]
881
- }),
882
- a && h.length > 1 && /* @__PURE__ */ p("fieldset", {
883
- className: "cp-chips",
884
- children: [
885
- /* @__PURE__ */ f("legend", { children: T("business.resources") }),
886
- /* @__PURE__ */ f("button", {
887
- type: "button",
888
- "aria-pressed": !g,
889
- onClick: () => a({ ...i && { eventTypeId: i } }),
890
- children: T("business.anyResource")
891
- }),
892
- h.map((e) => /* @__PURE__ */ f("button", {
893
- type: "button",
894
- "aria-pressed": e.id === g,
895
- onClick: () => a({
896
- ...i && { eventTypeId: i },
897
- resourceId: e.id
898
- }),
899
- children: e.displayName
900
- }, e.id))
901
- ]
902
- }),
903
- i && !m ? /* @__PURE__ */ f("p", {
904
- className: "cp-empty",
905
- children: T("business.typeMissing")
906
- }) : /* @__PURE__ */ p(d, { children: [m && /* @__PURE__ */ f(J, { type: m }), /* @__PURE__ */ f(Te, {
907
- business: l,
908
- eventTypeId: i,
909
- resourceId: g,
910
- onChoose: (t) => e.onChoose(l, t)
911
- })] })
912
- ]
913
- });
914
- }
915
- function we({ business: e }) {
916
- return /* @__PURE__ */ p("header", {
917
- className: "cp-business-head",
918
- children: [/* @__PURE__ */ f(K, {
919
- image: e.logo,
920
- alt: T("image.logo", { name: e.displayName }),
921
- size: "small",
922
- className: "cp-logo"
923
- }), /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("h1", { children: e.displayName }), e.address && /* @__PURE__ */ f("p", {
924
- className: "cp-hint",
925
- children: e.address
926
- })] })]
927
- });
928
- }
929
- function J({ type: e }) {
903
+ var ve = [["businesses", "nav.book"]], ye = [
904
+ ["bookings", "nav.bookings"],
905
+ ["passes", "nav.passes"],
906
+ ["details", "nav.details"]
907
+ ], be = [...ve, ...ye];
908
+ function xe(e) {
909
+ let t = typeof e.screen == "string" ? e.screen : "businesses";
930
910
  return /* @__PURE__ */ p("div", {
931
- className: "cp-type",
911
+ className: "cp-shell",
932
912
  children: [
933
- /* @__PURE__ */ f(K, {
934
- image: e.image,
935
- alt: e.displayName,
936
- size: "full",
937
- className: "cp-detail-image"
913
+ /* @__PURE__ */ p("header", {
914
+ className: "cp-header",
915
+ children: [/* @__PURE__ */ f(_e, { brand: e.brand }), e.signedIn ? /* @__PURE__ */ f("button", {
916
+ type: "button",
917
+ className: "cp-link",
918
+ onClick: e.onSignOut,
919
+ children: T("nav.signOut")
920
+ }) : !e.signingIn && /* @__PURE__ */ f("button", {
921
+ type: "button",
922
+ className: "cp-link",
923
+ onClick: () => e.onNavigate("bookings"),
924
+ children: T("nav.signIn")
925
+ })]
938
926
  }),
939
- /* @__PURE__ */ f("h2", { children: e.displayName }),
940
- e.description && /* @__PURE__ */ f("p", { children: e.description }),
941
- /* @__PURE__ */ f("p", {
942
- className: "cp-hint",
943
- children: T("business.minutes", { minutes: e.durationMinutes })
927
+ /* @__PURE__ */ f("nav", {
928
+ className: "cp-nav",
929
+ "aria-label": T("nav.label"),
930
+ children: e.tabs.map(([n, r]) => /* @__PURE__ */ f("button", {
931
+ type: "button",
932
+ "aria-current": t === n ? "page" : void 0,
933
+ onClick: () => e.onNavigate(n),
934
+ children: T(r)
935
+ }, n))
936
+ }),
937
+ /* @__PURE__ */ f("main", {
938
+ className: "cp-main",
939
+ children: e.children
944
940
  })
945
941
  ]
946
942
  });
947
943
  }
948
- function Te(e) {
949
- 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 = q(ye(c), l * ve), y = q(v, ve), b = t(async () => {
950
- _(!1), h(void 0);
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
+ // src/session.ts
968
+ var we = /* @__PURE__ */ new Map();
969
+ function G(e) {
970
+ let t = we.get(e);
971
+ return t || (t = {
972
+ value: void 0,
973
+ listeners: /* @__PURE__ */ new Set(),
974
+ generation: 0
975
+ }, we.set(e, t)), t;
976
+ }
977
+ function K(e, t) {
978
+ let n = G(e);
979
+ if (n.value !== t) {
980
+ n.value = t;
981
+ for (let e of n.listeners) e();
982
+ }
983
+ }
984
+ function Te(e, t) {
985
+ let { generation: n } = t, r = (r) => {
986
+ t.generation === n && t.value === void 0 && K(e, r);
987
+ };
988
+ Se(`${e}/auth/session`).then(async (e) => r(e.ok ? (await e.json()).sessionKey : null)).catch(() => r(null));
989
+ }
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), () => {
993
+ n.listeners.delete(t), n.listeners.size === 0 && queueMicrotask(() => {
994
+ n.listeners.size > 0 || (n.value = void 0, n.generation++);
995
+ });
996
+ };
997
+ }
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);
1000
+ return a.current = t, r(() => {
1001
+ if (n === void 0) return;
1002
+ let e = n !== null;
1003
+ i.current !== void 0 && i.current !== e && a.current?.(e), i.current = e;
1004
+ }, [n]), n;
1005
+ }
1006
+ // 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);
1009
+ 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);
1012
+ }), [c]), v = t(async () => {
1013
+ g("loading");
951
1014
  try {
952
- let { data: e } = await n.GET("/web/businesses/{businessId}/availability", { params: {
953
- path: { businessId: i.id },
954
- query: {
955
- from: `${v}T00:00`,
956
- to: `${y}T00:00`,
957
- ...a && { eventTypeId: a },
958
- ...o && { resourceId: o }
959
- }
960
- } });
961
- h(e?.items ?? []);
1015
+ let e = /* @__PURE__ */ new Map(), t;
1016
+ do {
1017
+ let { data: n } = await _.GET("/web/businesses", { params: { query: {
1018
+ limit: 100,
1019
+ ...t && { cursor: t }
1020
+ } } });
1021
+ for (let t of n?.items ?? []) e.set(t.id, t);
1022
+ t = n?.nextCursor ?? void 0;
1023
+ } while (t);
1024
+ m(e), g("ready");
962
1025
  } catch {
963
- _(!0);
1026
+ g("failed");
964
1027
  }
965
- }, [
966
- n,
967
- i.id,
968
- a,
969
- o,
970
- v,
971
- y
972
- ]);
973
- r(() => {
974
- b();
975
- }, [b]);
976
- let S = Date.now(), C = /* @__PURE__ */ new Map();
977
- for (let e of m ?? []) {
978
- if (Date.parse(e.startsAt) <= S) continue;
979
- let t = M(e.startsAt, e.timezone);
980
- C.set(t, [...C.get(t) ?? [], e]);
981
- }
982
- let w = T("business.weekOf", {
983
- from: j(`${v}T12:00:00Z`, "UTC"),
984
- to: j(`${q(y, -1)}T12:00:00Z`, "UTC")
985
- });
986
- return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("fieldset", {
987
- className: "cp-week",
988
- "aria-label": T("business.week"),
989
- children: [
990
- /* @__PURE__ */ f("button", {
991
- type: "button",
992
- className: "cp-secondary",
993
- disabled: l === 0,
994
- onClick: () => u((e) => e - 1),
995
- "aria-label": T("business.previousWeek"),
996
- children: "‹"
997
- }),
998
- /* @__PURE__ */ f("span", { children: w }),
999
- /* @__PURE__ */ f("button", {
1000
- type: "button",
1001
- className: "cp-secondary",
1002
- onClick: () => u((e) => e + 1),
1003
- "aria-label": T("business.nextWeek"),
1004
- children: "›"
1005
- })
1006
- ]
1007
- }), g ? /* @__PURE__ */ f(I, { onRetry: b }) : m ? C.size === 0 ? /* @__PURE__ */ f("p", {
1008
- className: "cp-empty",
1009
- children: T("business.empty")
1010
- }) : [...C].map(([t, n]) => /* @__PURE__ */ p("div", {
1011
- className: "cp-day",
1012
- children: [/* @__PURE__ */ f("h2", { children: t }), /* @__PURE__ */ f("ul", {
1013
- className: "cp-list",
1014
- children: n.map((t) => /* @__PURE__ */ f(Ee, {
1015
- candidate: t,
1016
- onChoose: () => e.onChoose(t)
1017
- }, `${t.eventId ?? t.eventTypeId}-${t.resource?.id ?? ""}-${t.startsAt}`))
1018
- })]
1019
- }, t)) : /* @__PURE__ */ f("p", {
1020
- role: "status",
1021
- children: T("app.loading")
1022
- })] });
1028
+ }, [_]);
1029
+ return r(() => {
1030
+ v();
1031
+ }, [v]), {
1032
+ basePath: c,
1033
+ sessionKey: l,
1034
+ notice: d,
1035
+ portal: a(() => ({
1036
+ client: _,
1037
+ businesses: p,
1038
+ businessesStatus: h,
1039
+ reloadBusinesses: () => void v(),
1040
+ navigate: n,
1041
+ accountNavigation: i,
1042
+ signOut: async (e) => {
1043
+ await W(c, "/auth/logout").catch(() => {}), f(e), K(c, null);
1044
+ }
1045
+ }), [
1046
+ _,
1047
+ p,
1048
+ h,
1049
+ v,
1050
+ n,
1051
+ i,
1052
+ c
1053
+ ]),
1054
+ signedInAs: t((e) => {
1055
+ f(void 0), K(c, e);
1056
+ }, [c])
1057
+ };
1023
1058
  }
1024
- function Ee(e) {
1025
- let { candidate: t } = e, n = t.kind === "slot";
1026
- return /* @__PURE__ */ p("li", {
1027
- className: "cp-card cp-candidate",
1028
- "data-kind": t.kind,
1029
- children: [
1030
- /* @__PURE__ */ p("p", {
1031
- className: "cp-time",
1032
- children: [
1033
- A(t.startsAt, t.timezone),
1034
- " – ",
1035
- A(t.endsAt, t.timezone)
1036
- ]
1037
- }),
1038
- /* @__PURE__ */ p("div", {
1039
- className: "cp-candidate-body",
1040
- children: [
1041
- /* @__PURE__ */ f("h3", { children: t.title }),
1042
- t.resource && /* @__PURE__ */ f("p", {
1043
- className: "cp-hint",
1044
- children: T("business.with", { resource: t.resource.displayName })
1045
- }),
1046
- /* @__PURE__ */ f("p", {
1047
- className: "cp-hint",
1048
- children: n ? T("business.openTime") : t.full ? T("business.full") : D("business.seatsLeft", t.seatsLeft)
1049
- })
1050
- ]
1051
- }),
1052
- !t.full && /* @__PURE__ */ f("button", {
1053
- type: "button",
1054
- onClick: e.onChoose,
1055
- children: T("business.book")
1056
- })
1057
- ]
1059
+ function J(e) {
1060
+ return /* @__PURE__ */ f("div", {
1061
+ className: "msm-customer",
1062
+ children: e.loading ? /* @__PURE__ */ f("p", {
1063
+ className: "cp-status",
1064
+ role: "status",
1065
+ children: T("app.loading")
1066
+ }) : /* @__PURE__ */ f(b.Provider, {
1067
+ value: e.portal,
1068
+ children: e.children
1069
+ })
1058
1070
  });
1059
1071
  }
1060
1072
  // src/screens/businesses.tsx
1061
- function De() {
1073
+ function Oe() {
1062
1074
  let { businesses: e, businessesStatus: t, reloadBusinesses: n, navigate: r } = x(), i = [...e.values()];
1063
1075
  return /* @__PURE__ */ p("section", {
1064
1076
  className: "cp-screen",
1065
- children: [/* @__PURE__ */ f("h1", { children: T("businesses.heading") }), t === "failed" ? /* @__PURE__ */ f(I, { onRetry: n }) : t === "loading" ? /* @__PURE__ */ f("p", {
1077
+ children: [/* @__PURE__ */ f("h1", { children: T("businesses.heading") }), t === "failed" ? /* @__PURE__ */ f(F, { onRetry: n }) : t === "loading" ? /* @__PURE__ */ f("p", {
1066
1078
  role: "status",
1067
1079
  children: T("app.loading")
1068
1080
  }) : i.length === 0 ? /* @__PURE__ */ f("p", {
@@ -1076,7 +1088,7 @@ function De() {
1076
1088
  children: i.map((e) => /* @__PURE__ */ p("li", {
1077
1089
  className: "cp-card cp-business",
1078
1090
  children: [
1079
- /* @__PURE__ */ f(K, {
1091
+ /* @__PURE__ */ f(I, {
1080
1092
  image: e.logo,
1081
1093
  alt: "",
1082
1094
  size: "small",
@@ -1095,7 +1107,7 @@ function De() {
1095
1107
  });
1096
1108
  }
1097
1109
  // src/screens/details.tsx
1098
- function Oe() {
1110
+ function ke() {
1099
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 () => {
1100
1112
  u(!1);
1101
1113
  try {
@@ -1140,7 +1152,7 @@ function Oe() {
1140
1152
  }
1141
1153
  return /* @__PURE__ */ p("section", {
1142
1154
  className: "cp-screen",
1143
- children: [/* @__PURE__ */ f("h1", { children: T("details.heading") }), l ? /* @__PURE__ */ f(I, { onRetry: v }) : i ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("form", {
1155
+ children: [/* @__PURE__ */ f("h1", { children: T("details.heading") }), l ? /* @__PURE__ */ f(F, { onRetry: v }) : i ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("form", {
1144
1156
  className: "cp-card cp-form",
1145
1157
  onSubmit: y,
1146
1158
  "aria-busy": m,
@@ -1191,7 +1203,7 @@ function Oe() {
1191
1203
  });
1192
1204
  }
1193
1205
  // src/screens/passes.tsx
1194
- function ke() {
1206
+ function Ae() {
1195
1207
  let { client: e, businesses: n } = x(), [i, a] = s(), [o, c] = s(!1), l = t(async () => {
1196
1208
  c(!1);
1197
1209
  try {
@@ -1205,7 +1217,7 @@ function ke() {
1205
1217
  l();
1206
1218
  }, [l]), /* @__PURE__ */ p("section", {
1207
1219
  className: "cp-screen",
1208
- children: [/* @__PURE__ */ f("h1", { children: T("passes.heading") }), o ? /* @__PURE__ */ f(I, { onRetry: l }) : i ? i.length === 0 ? /* @__PURE__ */ f("p", {
1220
+ children: [/* @__PURE__ */ f("h1", { children: T("passes.heading") }), o ? /* @__PURE__ */ f(F, { onRetry: l }) : i ? i.length === 0 ? /* @__PURE__ */ f("p", {
1209
1221
  className: "cp-empty",
1210
1222
  children: T("passes.empty")
1211
1223
  }) : /* @__PURE__ */ f("ul", {
@@ -1247,13 +1259,13 @@ function ke() {
1247
1259
  });
1248
1260
  }
1249
1261
  // ../ui/dist/index.js
1250
- var Ae = new Intl.DisplayNames(["en"], { type: "region" }), je = (e) => e.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().trim(), Y = h().map((e) => ({
1262
+ var je = new Intl.DisplayNames(["en"], { type: "region" }), Me = (e) => e.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().trim(), Y = h().map((e) => ({
1251
1263
  code: e,
1252
- name: Ae.of(e) ?? e,
1264
+ name: je.of(e) ?? e,
1253
1265
  callingCode: g(e),
1254
1266
  flag: String.fromCodePoint(...[...e].map((e) => 127397 + e.charCodeAt(0)))
1255
- })).sort((e, t) => e.name.localeCompare(t.name)), Me = new Map(Y.map((e) => [e.code, e])), Ne = (e) => Me.get(e);
1256
- function Pe(e) {
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) {
1257
1269
  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) => {
1258
1270
  m(), e.onPick(t);
1259
1271
  };
@@ -1327,10 +1339,10 @@ function Pe(e) {
1327
1339
  ]
1328
1340
  });
1329
1341
  }
1330
- var Fe = new m(), X = (e) => Ne(e);
1331
- function Ie(e) {
1342
+ var Ie = new m(), X = (e) => Pe(e);
1343
+ function Le(e) {
1332
1344
  for (let t = 1; t <= 3 && t <= e.length; t++) {
1333
- let n = e.slice(0, t), r = (y.country_calling_codes[n] ?? []).filter((e) => Ne(e) !== void 0), [i] = r;
1345
+ let n = e.slice(0, t), r = (y.country_calling_codes[n] ?? []).filter((e) => Pe(e) !== void 0), [i] = r;
1334
1346
  if (i) return {
1335
1347
  code: n,
1336
1348
  first: i,
@@ -1339,10 +1351,10 @@ function Ie(e) {
1339
1351
  }
1340
1352
  return null;
1341
1353
  }
1342
- function Le(e, t) {
1354
+ function Re(e, t) {
1343
1355
  let n = /^\s*(\+|00)/.exec(e);
1344
1356
  if (!n) return null;
1345
- let r = e.slice(n[0].length), i = r.replace(/\D/g, ""), a = Ie(i);
1357
+ let r = e.slice(n[0].length), i = r.replace(/\D/g, ""), a = Le(i);
1346
1358
  if (!a) return null;
1347
1359
  let o = _(`+${i}`), s = a.countries.includes(t) ? t : o?.country ?? a.first, c = 0;
1348
1360
  for (let e = 0; e < a.code.length; c++) /\d/.test(r.charAt(c)) && e++;
@@ -1351,45 +1363,45 @@ function Le(e, t) {
1351
1363
  text: o?.isValid() ? o.formatNational() : r.slice(c).replace(/^[\s\-().]+/, "")
1352
1364
  };
1353
1365
  }
1354
- function Re(e, t) {
1366
+ function ze(e, t) {
1355
1367
  let n = t.replace(/\D/g, "");
1356
1368
  return n === "" ? "" : t.trim().startsWith("+") ? `+${n}` : _(t, e)?.number ?? `+${X(e).callingCode}${n}`;
1357
1369
  }
1358
- function ze(e) {
1359
- return Fe.selectNumberingPlan(e), Fe.numberingPlan?.possibleLengths() ?? [];
1370
+ function Be(e) {
1371
+ return Ie.selectNumberingPlan(e), Ie.numberingPlan?.possibleLengths() ?? [];
1360
1372
  }
1361
- function Be(e, t, n) {
1373
+ function Ve(e, t, n) {
1362
1374
  if (e === "") return t ? "Enter a phone number." : "";
1363
1375
  let r = _(e);
1364
1376
  if (r?.isValid()) return "";
1365
- let i = e.replace(/\D/g, ""), a = Ie(i);
1377
+ let i = e.replace(/\D/g, ""), a = Le(i);
1366
1378
  if (!a) return "Unknown country code. Choose the country from the list.";
1367
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);
1368
1380
  if (c && c !== "NOT_A_NUMBER") {
1369
- let e = ze(o), t = e[0] ?? 0, n = e[e.length - 1] ?? 0;
1381
+ let e = Be(o), t = e[0] ?? 0, n = e[e.length - 1] ?? 0;
1370
1382
  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}.`;
1371
1383
  }
1372
1384
  return `This is not a valid number for ${s}.`;
1373
1385
  }
1374
- function Ve(e, t = !1) {
1375
- return Be(e, t);
1386
+ function He(e, t = !1) {
1387
+ return Ve(e, t);
1376
1388
  }
1377
- function He(e, t) {
1378
- return Le(e, t) ?? {
1389
+ function Ue(e, t) {
1390
+ return Re(e, t) ?? {
1379
1391
  country: t,
1380
1392
  text: e
1381
1393
  };
1382
1394
  }
1383
- function Ue(e) {
1395
+ function We(e) {
1384
1396
  let t = i(), n = o(null), [a, c] = s(() => ({
1385
1397
  value: e.value,
1386
- ...He(e.value, "IS")
1398
+ ...Ue(e.value, "IS")
1387
1399
  })), l = a;
1388
1400
  e.value !== a.value && (l = {
1389
1401
  value: e.value,
1390
- ...He(e.value, a.country)
1402
+ ...Ue(e.value, a.country)
1391
1403
  }, c(l));
1392
- let [u, d] = s(!1), [m, h] = s(!1), g = X(l.country), _ = Be(l.value, e.required ?? !1, l.country), v = u && _ !== "" ? _ : e.error ?? "", y = v !== "";
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 !== "";
1393
1405
  r(() => {
1394
1406
  let e = n.current?.form;
1395
1407
  if (!e) return;
@@ -1399,7 +1411,7 @@ function Ue(e) {
1399
1411
  return e.addEventListener("submit", t), () => e.removeEventListener("submit", t);
1400
1412
  }, []);
1401
1413
  let b = (t, n) => {
1402
- let r = Re(t, n);
1414
+ let r = ze(t, n);
1403
1415
  c({
1404
1416
  value: r,
1405
1417
  country: t,
@@ -1442,7 +1454,7 @@ function Ue(e) {
1442
1454
  "aria-invalid": y || void 0,
1443
1455
  "aria-describedby": y ? `${t}-problem` : void 0,
1444
1456
  onChange: (e) => {
1445
- let t = e.target.value.replace(/[^\d\s\-().+]/g, ""), n = Le(t, l.country);
1457
+ let t = e.target.value.replace(/[^\d\s\-().+]/g, ""), n = Re(t, l.country);
1446
1458
  b(n?.country ?? l.country, n?.text ?? t);
1447
1459
  },
1448
1460
  onBlur: () => {
@@ -1456,12 +1468,12 @@ function Ue(e) {
1456
1468
  role: "alert",
1457
1469
  children: v
1458
1470
  }),
1459
- m && /* @__PURE__ */ f(Pe, {
1471
+ m && /* @__PURE__ */ f(Fe, {
1460
1472
  title: "Country code",
1461
1473
  searchLabel: "Search by country or code",
1462
1474
  listLabel: "Countries",
1463
1475
  empty: (e) => `No country matches “${e}”.`,
1464
- search: We,
1476
+ search: Ge,
1465
1477
  selected: l.country,
1466
1478
  onClose: () => h(!1),
1467
1479
  onPick: (e) => {
@@ -1471,9 +1483,9 @@ function Ue(e) {
1471
1483
  ]
1472
1484
  });
1473
1485
  }
1474
- function We(e) {
1475
- let t = je(e).replace(/^(\+|00)/, "");
1476
- return (t === "" ? Y : /^\d+$/.test(t) ? Y.filter((e) => e.callingCode.startsWith(t)) : Y.filter((e) => je(e.name).includes(t) || e.code.toLowerCase() === t)).map((e) => ({
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) => ({
1477
1489
  value: e.code,
1478
1490
  label: e.name,
1479
1491
  hint: `+${e.callingCode}`,
@@ -1481,31 +1493,31 @@ function We(e) {
1481
1493
  }));
1482
1494
  }
1483
1495
  // src/bot-check.tsx
1484
- var Ge = () => window.turnstile, Ke = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit", Z;
1485
- function qe() {
1486
- let e = Ge();
1496
+ var Ke = () => window.turnstile, qe = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit", Z;
1497
+ function Je() {
1498
+ let e = Ke();
1487
1499
  return e ? Promise.resolve(e) : (Z ??= new Promise((e, t) => {
1488
1500
  let n = document.createElement("script");
1489
- n.src = Ke, n.async = !0;
1501
+ n.src = qe, n.async = !0;
1490
1502
  let r = () => {
1491
1503
  Z = void 0, n.remove(), t(/* @__PURE__ */ Error("Turnstile did not load."));
1492
1504
  };
1493
1505
  n.onload = () => {
1494
- let t = Ge();
1506
+ let t = Ke();
1495
1507
  t ? e(t) : r();
1496
1508
  }, n.onerror = r, document.head.append(n);
1497
1509
  }), Z);
1498
1510
  }
1499
- function Je(e) {
1511
+ function Ye(e) {
1500
1512
  return e?.provider === "turnstile" && typeof e.siteKey == "string" && e.siteKey.trim() !== "";
1501
1513
  }
1502
- function Ye(e) {
1514
+ function Xe(e) {
1503
1515
  let t = o(null), n = o(void 0), i = o(e);
1504
1516
  i.current = e;
1505
1517
  let { siteKey: a } = e.botCheck;
1506
1518
  r(() => {
1507
1519
  let e = !0;
1508
- return qe().then((r) => {
1520
+ return Je().then((r) => {
1509
1521
  let o = t.current;
1510
1522
  if (!e || !o) return;
1511
1523
  let s = r.render(o, {
@@ -1542,7 +1554,7 @@ function Q(e) {
1542
1554
  r(() => {
1543
1555
  n && t.current?.querySelector("input")?.focus();
1544
1556
  }, [n]);
1545
- 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 = Je(e.botCheck) ? e.botCheck : void 0, [k, A] = s();
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();
1546
1558
  r(() => {
1547
1559
  if (!k) return;
1548
1560
  let e = setTimeout(() => {
@@ -1554,16 +1566,16 @@ function Q(e) {
1554
1566
  a("phone"), v(void 0), g(""), l(""), b(e);
1555
1567
  }
1556
1568
  async function M(t) {
1557
- if (t.preventDefault(), (i !== "phone" || !Ve(u, !0) && O && C) && (i !== "name" || c.trim())) {
1569
+ if (t.preventDefault(), (i !== "phone" || !He(u, !0) && O && C) && (i !== "name" || c.trim())) {
1558
1570
  S(!0), b(void 0);
1559
1571
  try {
1560
- let t = i === "phone" ? await B(e.basePath, "/auth/initiate", {
1572
+ let t = i === "phone" ? await W(e.basePath, "/auth/initiate", {
1561
1573
  phone: u,
1562
1574
  botCheckToken: C
1563
- }) : i === "code" ? await B(e.basePath, "/auth/login", {
1575
+ }) : i === "code" ? await W(e.basePath, "/auth/login", {
1564
1576
  challenge: _,
1565
1577
  code: h
1566
- }) : await B(e.basePath, "/auth/register", { name: c.trim() });
1578
+ }) : await W(e.basePath, "/auth/register", { name: c.trim() });
1567
1579
  if (t.ok) {
1568
1580
  let n = await t.json();
1569
1581
  i === "phone" ? (v(n.challenge), a("code")) : n.result === "nameRequired" ? a("name") : e.onSignedIn(n.sessionKey);
@@ -1574,7 +1586,7 @@ function Q(e) {
1574
1586
  j(T("register.error.expired"));
1575
1587
  return;
1576
1588
  }
1577
- let r = Number(t.headers.get("retry-after")), o = Number.isInteger(r) && r > 0 ? r : void 0, s = Xe(t.status, n?.code, o, i);
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);
1578
1590
  t.status === 429 && o && i === "phone" && A({
1579
1591
  phone: u,
1580
1592
  seconds: o,
@@ -1594,7 +1606,7 @@ function Q(e) {
1594
1606
  onSubmit: M,
1595
1607
  "aria-busy": x,
1596
1608
  children: [
1597
- /* @__PURE__ */ f(R, { brand: e.brand }),
1609
+ /* @__PURE__ */ f(_e, { brand: e.brand }),
1598
1610
  /* @__PURE__ */ f("h1", { children: T("signIn.heading") }),
1599
1611
  e.children,
1600
1612
  e.notice && i === "phone" && /* @__PURE__ */ f("p", {
@@ -1618,13 +1630,13 @@ function Q(e) {
1618
1630
  autoFocus: !0
1619
1631
  })] })] }) : /* @__PURE__ */ p(d, { children: [
1620
1632
  /* @__PURE__ */ f("p", { children: T("signIn.intro") }),
1621
- /* @__PURE__ */ f(Ue, {
1633
+ /* @__PURE__ */ f(We, {
1622
1634
  label: T("signIn.phone"),
1623
1635
  value: u,
1624
1636
  onChange: m,
1625
1637
  required: !0
1626
1638
  }),
1627
- O && /* @__PURE__ */ f(Ye, {
1639
+ O && /* @__PURE__ */ f(Xe, {
1628
1640
  botCheck: O,
1629
1641
  attempt: E,
1630
1642
  onToken: w,
@@ -1660,11 +1672,11 @@ function Q(e) {
1660
1672
  })
1661
1673
  });
1662
1674
  }
1663
- function Xe(e, t, n, r) {
1664
- if (e === 429) return n ? T("signIn.error.tooMany", { wait: P(n) }) : T("signIn.error.tooManyLater");
1675
+ function Ze(e, t, n, r) {
1676
+ if (e === 429) return n ? T("signIn.error.tooMany", { wait: ee(n) }) : T("signIn.error.tooManyLater");
1665
1677
  if (r === "name" && (e === 400 || e === 422)) return T("register.error.name");
1666
1678
  let i = r === "phone";
1667
- 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: P(n) }) : T("signIn.error.pausedLater") : i && e === 422 && t === "PhoneDestinationNotAllowed" ? T("signIn.error.destination") : r === "code" && [
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" && [
1668
1680
  400,
1669
1681
  401,
1670
1682
  403,
@@ -1673,27 +1685,27 @@ function Xe(e, t, n, r) {
1673
1685
  ].includes(e) ? T("signIn.error.badCode") : T(e === 400 ? "signIn.error.invalid" : e === 403 ? "signIn.error.refused" : "signIn.error.failed");
1674
1686
  }
1675
1687
  // src/account.tsx
1676
- function Ze(e) {
1688
+ function Qe(e) {
1677
1689
  let [n, r] = s("bookings"), i = e.screen ?? n, a = e.onNavigate ?? r, o = t((e) => {
1678
1690
  (e === "bookings" || e === "passes" || e === "details") && a(e);
1679
- }, [a]), { basePath: c, sessionKey: l, notice: u, portal: d, signedInAs: p } = W({
1691
+ }, [a]), { basePath: c, sessionKey: l, notice: u, portal: d, signedInAs: p } = q({
1680
1692
  basePath: e.basePath,
1681
1693
  navigate: o,
1682
1694
  accountNavigation: !0,
1683
1695
  onSessionChange: e.onSessionChange
1684
1696
  });
1685
- return /* @__PURE__ */ f(G, {
1697
+ return /* @__PURE__ */ f(J, {
1686
1698
  portal: d,
1687
1699
  loading: l === void 0,
1688
- children: /* @__PURE__ */ f(de, {
1700
+ children: /* @__PURE__ */ f(xe, {
1689
1701
  brand: e.brand,
1690
- tabs: le,
1702
+ tabs: ye,
1691
1703
  screen: i,
1692
1704
  signedIn: !!l,
1693
1705
  signingIn: !l,
1694
1706
  onNavigate: o,
1695
1707
  onSignOut: () => d.signOut(),
1696
- children: l ? f(i === "passes" ? ke : i === "details" ? Oe : te, {}) : /* @__PURE__ */ f(Q, {
1708
+ children: l ? f(i === "passes" ? Ae : i === "details" ? ke : P, {}) : /* @__PURE__ */ f(Q, {
1697
1709
  basePath: c,
1698
1710
  brand: void 0,
1699
1711
  botCheck: e.botCheck,
@@ -1705,12 +1717,12 @@ function Ze(e) {
1705
1717
  });
1706
1718
  }
1707
1719
  // src/booking-flow.tsx
1708
- function Qe(e) {
1720
+ function $e(e) {
1709
1721
  return {
1710
1722
  startsAt: e.startsAt,
1711
1723
  eventTypeId: e.eventTypeId,
1712
1724
  ...e.eventId && { eventId: e.eventId },
1713
- ...e.resource && { resourceId: e.resource.id }
1725
+ ...!e.eventId && e.resource && { resourceId: e.resource.id }
1714
1726
  };
1715
1727
  }
1716
1728
  function $(e) {
@@ -1721,10 +1733,10 @@ function $(e) {
1721
1733
  e.resourceId ?? ""
1722
1734
  ].join("|") : "";
1723
1735
  }
1724
- function $e(e, t) {
1736
+ function et(e, t) {
1725
1737
  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);
1726
1738
  }
1727
- function et(e) {
1739
+ function tt(e) {
1728
1740
  let n = e.onChange !== void 0, r = {
1729
1741
  businessId: e.businessId,
1730
1742
  ...e.eventTypeId && { eventTypeId: e.eventTypeId },
@@ -1744,12 +1756,12 @@ function et(e) {
1744
1756
  businessId: e.businessId,
1745
1757
  ...e.eventTypeId && { eventTypeId: e.eventTypeId }
1746
1758
  });
1747
- }, [h]), { basePath: _, sessionKey: v, notice: y, portal: b, signedInAs: x } = W({
1759
+ }, [h]), { basePath: _, sessionKey: v, notice: y, portal: b, signedInAs: x } = q({
1748
1760
  basePath: e.basePath,
1749
1761
  navigate: g,
1750
1762
  accountNavigation: !1,
1751
1763
  onSessionChange: e.onSessionChange
1752
- }), [S, C] = s(), [w, E] = s(), D = u.time, O = $(D), k = S && D && S.business.id === u.businessId && $(Qe(S.candidate)) === O ? S : void 0, A = () => {
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 = () => {
1753
1765
  C(void 0);
1754
1766
  let { time: e, ...t } = u;
1755
1767
  h(t);
@@ -1759,10 +1771,10 @@ function et(e) {
1759
1771
  candidate: t
1760
1772
  }), h({
1761
1773
  ...u,
1762
- time: Qe(t)
1774
+ time: $e(t)
1763
1775
  });
1764
1776
  }, M;
1765
- M = k ? v ? /* @__PURE__ */ f(ae, {
1777
+ M = k ? v ? /* @__PURE__ */ f(me, {
1766
1778
  choice: k,
1767
1779
  onBack: A,
1768
1780
  onBooked: e.onBooked,
@@ -1776,7 +1788,7 @@ function et(e) {
1776
1788
  autoFocus: !0,
1777
1789
  children: [
1778
1790
  /* @__PURE__ */ f("p", { children: T("book.signInFirst") }),
1779
- /* @__PURE__ */ f(L, { choice: k }),
1791
+ /* @__PURE__ */ f(U, { choice: k }),
1780
1792
  /* @__PURE__ */ f("button", {
1781
1793
  type: "button",
1782
1794
  className: "cp-link",
@@ -1784,7 +1796,7 @@ function et(e) {
1784
1796
  children: T("book.back")
1785
1797
  })
1786
1798
  ]
1787
- }) : D && w !== O ? /* @__PURE__ */ f(nt, {
1799
+ }) : D && w !== O ? /* @__PURE__ */ f(rt, {
1788
1800
  businessId: u.businessId,
1789
1801
  time: D,
1790
1802
  onFound: C,
@@ -1794,7 +1806,7 @@ function et(e) {
1794
1806
  className: "cp-link cp-back",
1795
1807
  onClick: () => h({ businessId: u.businessId }),
1796
1808
  children: T("book.toTypes")
1797
- }), /* @__PURE__ */ f(Ce, {
1809
+ }), /* @__PURE__ */ f(de, {
1798
1810
  businessId: u.businessId,
1799
1811
  eventTypeId: u.eventTypeId,
1800
1812
  resourceId: u.resourceId,
@@ -1804,7 +1816,7 @@ function et(e) {
1804
1816
  ...e
1805
1817
  }),
1806
1818
  onChoose: j
1807
- })] }) : /* @__PURE__ */ f(tt, {
1819
+ })] }) : /* @__PURE__ */ f(nt, {
1808
1820
  selection: u,
1809
1821
  change: h,
1810
1822
  onChoose: j
@@ -1815,10 +1827,10 @@ function et(e) {
1815
1827
  u.resourceId ?? "",
1816
1828
  D && w !== O ? "time" : ""
1817
1829
  ].join("/");
1818
- return /* @__PURE__ */ f(G, {
1830
+ return /* @__PURE__ */ f(J, {
1819
1831
  portal: b,
1820
1832
  loading: v === void 0,
1821
- children: /* @__PURE__ */ p(it, {
1833
+ children: /* @__PURE__ */ p(at, {
1822
1834
  step: N,
1823
1835
  children: [
1824
1836
  e.onClose && /* @__PURE__ */ f("div", {
@@ -1840,10 +1852,10 @@ function et(e) {
1840
1852
  })
1841
1853
  });
1842
1854
  }
1843
- function tt(e) {
1844
- let { selection: t, change: n } = e, { businessId: r, eventTypeId: i } = t, a = be(r), o = xe(a, null), { business: s, types: c } = a;
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;
1845
1857
  if (o || !s || !c) return o;
1846
- let l = /* @__PURE__ */ f(we, { business: s }), u = /* @__PURE__ */ f("button", {
1858
+ let l = /* @__PURE__ */ f(fe, { business: s }), u = /* @__PURE__ */ f("button", {
1847
1859
  type: "button",
1848
1860
  className: "cp-link cp-back",
1849
1861
  onClick: () => n({ businessId: r }),
@@ -1871,7 +1883,7 @@ function tt(e) {
1871
1883
  eventTypeId: e.id
1872
1884
  }),
1873
1885
  children: [
1874
- /* @__PURE__ */ f(K, {
1886
+ /* @__PURE__ */ f(I, {
1875
1887
  image: e.image,
1876
1888
  alt: "",
1877
1889
  size: "small",
@@ -1900,7 +1912,7 @@ function tt(e) {
1900
1912
  children: [
1901
1913
  u,
1902
1914
  l,
1903
- /* @__PURE__ */ f(J, { type: d }),
1915
+ /* @__PURE__ */ f(R, { type: d }),
1904
1916
  /* @__PURE__ */ f("h2", { children: T("book.chooseResource") }),
1905
1917
  /* @__PURE__ */ f("ul", {
1906
1918
  className: "cp-list",
@@ -1918,7 +1930,7 @@ function tt(e) {
1918
1930
  resourceId: e.id
1919
1931
  }),
1920
1932
  children: [
1921
- /* @__PURE__ */ f(K, {
1933
+ /* @__PURE__ */ f(I, {
1922
1934
  image: e.image,
1923
1935
  alt: "",
1924
1936
  size: "small",
@@ -1943,12 +1955,12 @@ function tt(e) {
1943
1955
  children: T("book.otherResource")
1944
1956
  }) : u,
1945
1957
  l,
1946
- /* @__PURE__ */ f(J, { type: d }),
1958
+ /* @__PURE__ */ f(R, { type: d }),
1947
1959
  m && h && /* @__PURE__ */ f("p", {
1948
1960
  className: "cp-hint",
1949
1961
  children: T("business.with", { resource: h.displayName })
1950
1962
  }),
1951
- /* @__PURE__ */ f(Te, {
1963
+ /* @__PURE__ */ f(z, {
1952
1964
  business: s,
1953
1965
  eventTypeId: d.id,
1954
1966
  resourceId: m ? h?.id : void 0,
@@ -1957,7 +1969,7 @@ function tt(e) {
1957
1969
  ]
1958
1970
  });
1959
1971
  }
1960
- function nt(e) {
1972
+ function rt(e) {
1961
1973
  let { client: t } = x(), { businessId: n, time: i } = e, a = o(e);
1962
1974
  a.current = e;
1963
1975
  let s = $(i);
@@ -1966,15 +1978,15 @@ function nt(e) {
1966
1978
  return (async () => {
1967
1979
  let { data: r } = await t.GET("/web/businesses/{businessId}", { params: { path: { businessId: n } } });
1968
1980
  if (!r) throw Error("no business");
1969
- let o = ye(r.timezone, new Date(i.startsAt)), { data: s } = await t.GET("/web/businesses/{businessId}/availability", { params: {
1981
+ let o = se(r.timezone, new Date(i.startsAt)), { data: s } = await t.GET("/web/businesses/{businessId}/availability", { params: {
1970
1982
  path: { businessId: n },
1971
1983
  query: {
1972
1984
  from: `${o}T00:00`,
1973
- to: `${q(o, 1)}T00:00`,
1985
+ to: `${L(o, 1)}T00:00`,
1974
1986
  eventTypeId: i.eventTypeId,
1975
1987
  ...!i.eventId && i.resourceId && { resourceId: i.resourceId }
1976
1988
  }
1977
- } }), c = s?.items.find((e) => $e(e, i));
1989
+ } }), c = s?.items.find((e) => et(e, i));
1978
1990
  e && (c ? a.current.onFound({
1979
1991
  business: r,
1980
1992
  candidate: c
@@ -1996,8 +2008,8 @@ function nt(e) {
1996
2008
  })
1997
2009
  });
1998
2010
  }
1999
- var rt = "input, .cp-option, .cp-chips button, .cp-candidate button, .cp-actions button:not(:disabled)";
2000
- function it(e) {
2011
+ var it = "input, .cp-option, .cp-chips button, .cp-candidate button, .cp-actions button:not(:disabled)";
2012
+ function at(e) {
2001
2013
  let t = o(null), n = o(!1), { step: i } = e;
2002
2014
  return r(() => {
2003
2015
  let e = t.current;
@@ -2005,7 +2017,7 @@ function it(e) {
2005
2017
  let r = n.current;
2006
2018
  if (n.current = !0, r && e.contains(document.activeElement)) return;
2007
2019
  let i = () => {
2008
- let t = e.querySelector(rt);
2020
+ let t = e.querySelector(it);
2009
2021
  return t?.focus(), !!t;
2010
2022
  };
2011
2023
  if (i()) return;
@@ -2027,8 +2039,8 @@ function it(e) {
2027
2039
  });
2028
2040
  }
2029
2041
  // src/sign-in-standalone.tsx
2030
- function at(e) {
2031
- let t = e.basePath.replace(/\/$/, ""), n = he(t, e.onSessionChange), i = o(e.onSignedIn);
2042
+ function ot(e) {
2043
+ let t = e.basePath.replace(/\/$/, ""), n = De(t, e.onSessionChange), i = o(e.onSignedIn);
2032
2044
  i.current = e.onSignedIn;
2033
2045
  let a = o(!1);
2034
2046
  return r(() => {
@@ -2044,15 +2056,15 @@ function at(e) {
2044
2056
  brand: e.brand,
2045
2057
  botCheck: e.botCheck,
2046
2058
  notice: void 0,
2047
- onSignedIn: (e) => U(t, e),
2059
+ onSignedIn: (e) => K(t, e),
2048
2060
  onCancel: e.onCancel,
2049
2061
  autoFocus: !0
2050
2062
  })
2051
2063
  });
2052
2064
  }
2053
2065
  // src/index.tsx
2054
- function ot(e) {
2055
- let [t, n] = s("businesses"), r = e.screen ?? t, i = e.onNavigate ?? n, { basePath: a, sessionKey: o, notice: c, portal: l, signedInAs: u } = W({
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({
2056
2068
  basePath: e.basePath,
2057
2069
  navigate: i,
2058
2070
  accountNavigation: !0,
@@ -2067,38 +2079,38 @@ function ot(e) {
2067
2079
  onSignedIn: u,
2068
2080
  children: t
2069
2081
  });
2070
- return /* @__PURE__ */ f(G, {
2082
+ return /* @__PURE__ */ f(J, {
2071
2083
  portal: l,
2072
2084
  loading: o === void 0,
2073
- children: /* @__PURE__ */ f(de, {
2085
+ children: /* @__PURE__ */ f(xe, {
2074
2086
  brand: e.brand,
2075
- tabs: ue,
2087
+ tabs: be,
2076
2088
  screen: r,
2077
2089
  signedIn: !!o,
2078
2090
  signingIn: !o && (!!m || typeof r == "string" && r !== "businesses"),
2079
2091
  onNavigate: i,
2080
2092
  onSignOut: () => l.signOut(),
2081
- children: m ? o ? /* @__PURE__ */ f(ae, {
2093
+ children: m ? o ? /* @__PURE__ */ f(me, {
2082
2094
  choice: m,
2083
2095
  onBack: () => h(void 0)
2084
2096
  }, `${m.candidate.startsAt}-${m.candidate.eventId ?? m.candidate.eventTypeId}`) : y(/* @__PURE__ */ p(d, { children: [
2085
2097
  /* @__PURE__ */ f("p", { children: T("book.signInFirst") }),
2086
- /* @__PURE__ */ f(L, { choice: m }),
2098
+ /* @__PURE__ */ f(U, { choice: m }),
2087
2099
  /* @__PURE__ */ f("button", {
2088
2100
  type: "button",
2089
2101
  className: "cp-link",
2090
2102
  onClick: () => h(void 0),
2091
2103
  children: T("book.back")
2092
2104
  })
2093
- ] })) : typeof r == "object" ? /* @__PURE__ */ f(Ce, {
2105
+ ] })) : typeof r == "object" ? /* @__PURE__ */ f(de, {
2094
2106
  businessId: r.businessId,
2095
2107
  eventTypeId: r.eventTypeId,
2096
2108
  onChoose: (e, t) => h({
2097
2109
  business: e,
2098
2110
  candidate: t
2099
2111
  })
2100
- }) : r === "businesses" ? /* @__PURE__ */ f(De, {}) : o ? f(r === "passes" ? ke : r === "details" ? Oe : te, {}) : y()
2112
+ }) : r === "businesses" ? /* @__PURE__ */ f(Oe, {}) : o ? f(r === "passes" ? Ae : r === "details" ? ke : P, {}) : y()
2101
2113
  })
2102
2114
  });
2103
2115
  }
2104
- export { Ze as MsmAccount, et as MsmBooking, ot as MsmCustomer, at as MsmSignIn, F as cancellationState, j as formatDate, k as formatDateTime, O as formatNumber, C as locale, T as t };
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 };