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