@msm-platform/customer-react 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +62 -12
- package/dist/account.d.ts +28 -0
- package/dist/booking-flow.d.ts +61 -0
- package/dist/booking.d.ts +5 -1
- package/dist/client.d.ts +4 -0
- package/dist/context.d.ts +5 -0
- package/dist/i18n.d.ts +19 -7
- package/dist/image.d.ts +14 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +1196 -636
- package/dist/layout.d.ts +8 -0
- package/dist/portal.d.ts +26 -0
- package/dist/screens/business.d.ts +125 -2
- package/dist/server/index.d.ts +10 -6
- package/dist/server/session.d.ts +19 -5
- package/dist/server.js +157 -131
- package/dist/session.d.ts +10 -0
- package/dist/sign-in-standalone.d.ts +26 -0
- package/dist/sign-in.d.ts +8 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createContext as e, useCallback as t, useContext as n, useEffect as r, useId as i, useMemo as a, useRef as o, useState as s } from "react";
|
|
3
|
-
import { createCustomerClient as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { Metadata as
|
|
6
|
-
import
|
|
2
|
+
import { createContext as e, useCallback as t, useContext as n, useEffect as r, useId as i, useMemo as a, useRef as o, useState as s, useSyncExternalStore as c } from "react";
|
|
3
|
+
import { createCustomerClient as l, isCustomerApiError as u } from "@msm-platform/customer-sdk";
|
|
4
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
5
|
+
import { Metadata as m, getCountries as h, getCountryCallingCode as g, parsePhoneNumberFromString as _, validatePhoneNumberLength as v } from "libphonenumber-js";
|
|
6
|
+
import y from "libphonenumber-js/min/metadata";
|
|
7
7
|
// src/context.ts
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
let e = n(
|
|
11
|
-
if (!e) throw Error("usePortal needs
|
|
8
|
+
var b = e(null);
|
|
9
|
+
function x() {
|
|
10
|
+
let e = n(b);
|
|
11
|
+
if (!e) throw Error("usePortal needs a customer screen component.");
|
|
12
12
|
return e;
|
|
13
13
|
}
|
|
14
14
|
// src/i18n.ts
|
|
15
|
-
var
|
|
15
|
+
var S = {
|
|
16
16
|
"app.loading": "Loading…",
|
|
17
17
|
"app.loadFailed": "Something went wrong loading this page. Try again.",
|
|
18
18
|
"app.retry": "Try again",
|
|
19
19
|
"app.signedOut": "You were signed out because your session ended. Sign in again.",
|
|
20
20
|
"app.signedOutEverywhere": "You were signed out on every device.",
|
|
21
|
+
"image.logo": "{name} logo",
|
|
21
22
|
"nav.label": "Booking and my account",
|
|
22
23
|
"nav.book": "Book",
|
|
23
24
|
"nav.signIn": "Sign in",
|
|
@@ -27,11 +28,8 @@ var x = {
|
|
|
27
28
|
"nav.signOut": "Sign out",
|
|
28
29
|
"signIn.heading": "Sign in",
|
|
29
30
|
"signIn.intro": "We'll text a one-time code to your phone.",
|
|
30
|
-
"
|
|
31
|
-
"register.heading": "Create an account",
|
|
32
|
-
"register.intro": "Enter your name and phone. We'll text you a code.",
|
|
31
|
+
"register.intro": "One more step: what's your name?",
|
|
33
32
|
"register.name": "Your name",
|
|
34
|
-
"register.toSignIn": "Already have an account? Sign in",
|
|
35
33
|
"signIn.phone": "Phone number",
|
|
36
34
|
"signIn.codeSent": "Enter the code we sent to {phone}.",
|
|
37
35
|
"signIn.code": "Verification code",
|
|
@@ -40,13 +38,15 @@ var x = {
|
|
|
40
38
|
"register.submit": "Create account",
|
|
41
39
|
"signIn.wait": "Please wait…",
|
|
42
40
|
"signIn.differentNumber": "Use a different number",
|
|
41
|
+
"signIn.cancel": "Cancel",
|
|
43
42
|
"signIn.error.tooMany": "Too many codes requested. Try again in about {wait}.",
|
|
44
43
|
"signIn.error.tooManyLater": "Too many codes requested. Try again later.",
|
|
45
44
|
"signIn.error.paused": "Sign-in codes are paused for now. Try again in about {wait}.",
|
|
46
45
|
"signIn.error.pausedLater": "Sign-in codes are paused for now. Try again later.",
|
|
47
46
|
"signIn.error.destination": "This number can't receive sign-in codes.",
|
|
48
|
-
"signIn.error.badCode": "That code is incorrect or has expired
|
|
49
|
-
"register.error.
|
|
47
|
+
"signIn.error.badCode": "That code is incorrect or has expired.",
|
|
48
|
+
"register.error.expired": "That took too long. Request a new code.",
|
|
49
|
+
"register.error.name": "Check your name and try again.",
|
|
50
50
|
"signIn.error.invalid": "Check the phone number and try again.",
|
|
51
51
|
"signIn.error.refused": "This number can't sign in here.",
|
|
52
52
|
"signIn.error.unreachable": "The sign-in service is unreachable. Try again shortly.",
|
|
@@ -93,6 +93,8 @@ var x = {
|
|
|
93
93
|
"business.notFound": "This business isn't taking bookings here.",
|
|
94
94
|
"business.types": "Services",
|
|
95
95
|
"business.allTypes": "Everything",
|
|
96
|
+
"business.resources": "With",
|
|
97
|
+
"business.anyResource": "Anyone",
|
|
96
98
|
"business.typeMissing": "This service can't be booked here.",
|
|
97
99
|
"business.minutes": "{minutes} min",
|
|
98
100
|
"business.week": "Which week",
|
|
@@ -107,7 +109,7 @@ var x = {
|
|
|
107
109
|
"business.with": "With {resource}",
|
|
108
110
|
"business.book": "Book",
|
|
109
111
|
"book.heading": "Your booking",
|
|
110
|
-
"book.signInFirst": "Sign in
|
|
112
|
+
"book.signInFirst": "Sign in with your phone to book this time.",
|
|
111
113
|
"book.back": "Choose another time",
|
|
112
114
|
"book.reserving": "Holding this time for you…",
|
|
113
115
|
"book.heldUntil": "We're holding this time for you until {time}.",
|
|
@@ -115,6 +117,16 @@ var x = {
|
|
|
115
117
|
"book.confirming": "Confirming…",
|
|
116
118
|
"book.booked": "You're booked.",
|
|
117
119
|
"book.toBookings": "See all my bookings",
|
|
120
|
+
"book.done": "Done",
|
|
121
|
+
"book.close": "Close",
|
|
122
|
+
"book.chooseType": "What would you like to book?",
|
|
123
|
+
"book.noTypes": "There is nothing to book here yet.",
|
|
124
|
+
"book.seeAll": "See all times",
|
|
125
|
+
"book.chooseResource": "Who would you like to book with?",
|
|
126
|
+
"book.anyResource": "Anyone",
|
|
127
|
+
"book.anyResourceHint": "The first free times with anyone who offers it",
|
|
128
|
+
"book.toTypes": "Back to services",
|
|
129
|
+
"book.otherResource": "Choose someone else",
|
|
118
130
|
"book.reserveAgain": "Hold this time again",
|
|
119
131
|
"book.full": "This class is full now. Choose another time.",
|
|
120
132
|
"book.slotTaken": "Someone has just taken this time. Choose another.",
|
|
@@ -144,74 +156,74 @@ var x = {
|
|
|
144
156
|
"details.signOutEverywhere": "Sign out everywhere",
|
|
145
157
|
"details.signOutEverywhereHint": "Ends your sessions on every phone and computer, including this one.",
|
|
146
158
|
"details.signOutEverywhereFailed": "Could not sign out everywhere. Try again."
|
|
147
|
-
},
|
|
148
|
-
function
|
|
149
|
-
return
|
|
159
|
+
}, C = "en-GB", w = S;
|
|
160
|
+
function T(e, t = {}) {
|
|
161
|
+
return w[e].replace(/\{(\w+)\}/g, (e, n) => {
|
|
150
162
|
let r = t[n];
|
|
151
|
-
return r === void 0 ? e : typeof r == "number" ?
|
|
163
|
+
return r === void 0 ? e : typeof r == "number" ? O(r) : r;
|
|
152
164
|
});
|
|
153
165
|
}
|
|
154
|
-
var
|
|
155
|
-
function
|
|
156
|
-
let r = `${e}.${
|
|
157
|
-
return
|
|
166
|
+
var E = new Intl.PluralRules(C);
|
|
167
|
+
function D(e, t, n = {}) {
|
|
168
|
+
let r = `${e}.${E.select(t)}`;
|
|
169
|
+
return T(r in w ? r : `${e}.other`, {
|
|
158
170
|
count: t,
|
|
159
171
|
...n
|
|
160
172
|
});
|
|
161
173
|
}
|
|
162
|
-
function
|
|
163
|
-
return new Intl.NumberFormat(
|
|
174
|
+
function O(e) {
|
|
175
|
+
return new Intl.NumberFormat(C).format(e);
|
|
164
176
|
}
|
|
165
|
-
function
|
|
166
|
-
return new Intl.DateTimeFormat(
|
|
177
|
+
function k(e, t) {
|
|
178
|
+
return new Intl.DateTimeFormat(C, {
|
|
167
179
|
dateStyle: "medium",
|
|
168
180
|
timeStyle: "short",
|
|
169
181
|
...t && { timeZone: t }
|
|
170
182
|
}).format(new Date(e));
|
|
171
183
|
}
|
|
172
|
-
function
|
|
173
|
-
return new Intl.DateTimeFormat(
|
|
184
|
+
function A(e, t) {
|
|
185
|
+
return new Intl.DateTimeFormat(C, {
|
|
174
186
|
timeStyle: "short",
|
|
175
187
|
...t && { timeZone: t }
|
|
176
188
|
}).format(new Date(e));
|
|
177
189
|
}
|
|
178
|
-
function
|
|
179
|
-
return new Intl.DateTimeFormat(
|
|
190
|
+
function j(e, t) {
|
|
191
|
+
return new Intl.DateTimeFormat(C, {
|
|
180
192
|
dateStyle: "medium",
|
|
181
193
|
...t && { timeZone: t }
|
|
182
194
|
}).format(new Date(e));
|
|
183
195
|
}
|
|
184
|
-
function
|
|
185
|
-
return new Intl.DateTimeFormat(
|
|
196
|
+
function M(e, t) {
|
|
197
|
+
return new Intl.DateTimeFormat(C, {
|
|
186
198
|
weekday: "long",
|
|
187
199
|
day: "numeric",
|
|
188
200
|
month: "long",
|
|
189
201
|
...t && { timeZone: t }
|
|
190
202
|
}).format(new Date(e));
|
|
191
203
|
}
|
|
192
|
-
function
|
|
193
|
-
let r =
|
|
194
|
-
return
|
|
195
|
-
start:
|
|
196
|
-
end: r ?
|
|
204
|
+
function N(e, t, n) {
|
|
205
|
+
let r = j(e, n) === j(t, n);
|
|
206
|
+
return T("bookings.when", {
|
|
207
|
+
start: k(e, n),
|
|
208
|
+
end: r ? A(t, n) : k(t, n)
|
|
197
209
|
});
|
|
198
210
|
}
|
|
199
|
-
function
|
|
200
|
-
if (e < 60) return
|
|
211
|
+
function P(e) {
|
|
212
|
+
if (e < 60) return D("wait.seconds", e);
|
|
201
213
|
let t = Math.round(e / 60);
|
|
202
|
-
return t < 60 ?
|
|
214
|
+
return t < 60 ? D("wait.minutes", t) : D("wait.hours", Math.round(e / 3600));
|
|
203
215
|
}
|
|
204
216
|
// src/cancellation.ts
|
|
205
|
-
function
|
|
217
|
+
function F(e, t) {
|
|
206
218
|
if (e.status === "cancelled") return "cancelled";
|
|
207
219
|
let n = t.getTime();
|
|
208
220
|
return !e.cancellableUntil || n >= Date.parse(e.cancellableUntil) ? "closed" : e.lateCancellationFrom && n >= Date.parse(e.lateCancellationFrom) ? "late" : "open";
|
|
209
221
|
}
|
|
210
222
|
// src/screens/bookings.tsx
|
|
211
|
-
var
|
|
212
|
-
function
|
|
213
|
-
let { client: e } =
|
|
214
|
-
|
|
223
|
+
var ee = "/web/businesses/{businessId}/bookings/{bookingId}/cancel";
|
|
224
|
+
function te() {
|
|
225
|
+
let { client: e } = x(), [n, i] = s("upcoming"), [a, o] = s(), [c, l] = s(null), [u, d] = s(!1), [m, h] = s(), g = t(async (t) => {
|
|
226
|
+
d(!1);
|
|
215
227
|
try {
|
|
216
228
|
let { data: r } = await e.GET("/web/me/bookings", { params: { query: {
|
|
217
229
|
period: n,
|
|
@@ -220,72 +232,72 @@ function ee() {
|
|
|
220
232
|
if (!r) return;
|
|
221
233
|
o((e) => t ? [...e ?? [], ...r.items] : r.items), l(r.nextCursor);
|
|
222
234
|
} catch {
|
|
223
|
-
|
|
235
|
+
d(!0);
|
|
224
236
|
}
|
|
225
237
|
}, [e, n]);
|
|
226
238
|
return r(() => {
|
|
227
239
|
o(void 0), h(void 0), g();
|
|
228
|
-
}, [g]), /* @__PURE__ */
|
|
240
|
+
}, [g]), /* @__PURE__ */ p("section", {
|
|
229
241
|
className: "cp-screen",
|
|
230
242
|
children: [
|
|
231
|
-
/* @__PURE__ */
|
|
232
|
-
/* @__PURE__ */
|
|
243
|
+
/* @__PURE__ */ f("h1", { children: T("bookings.heading") }),
|
|
244
|
+
/* @__PURE__ */ f("fieldset", {
|
|
233
245
|
className: "cp-tabs",
|
|
234
|
-
"aria-label":
|
|
235
|
-
children: ["upcoming", "past"].map((e) => /* @__PURE__ */
|
|
246
|
+
"aria-label": T("bookings.period"),
|
|
247
|
+
children: ["upcoming", "past"].map((e) => /* @__PURE__ */ f("button", {
|
|
236
248
|
type: "button",
|
|
237
249
|
"aria-pressed": n === e,
|
|
238
250
|
onClick: () => i(e),
|
|
239
|
-
children:
|
|
251
|
+
children: T(e === "upcoming" ? "bookings.upcoming" : "bookings.past")
|
|
240
252
|
}, e))
|
|
241
253
|
}),
|
|
242
|
-
m && /* @__PURE__ */
|
|
254
|
+
m && /* @__PURE__ */ f("p", {
|
|
243
255
|
role: "status",
|
|
244
256
|
className: "cp-notice",
|
|
245
|
-
children:
|
|
257
|
+
children: T(m)
|
|
246
258
|
}),
|
|
247
|
-
u ? /* @__PURE__ */
|
|
259
|
+
u ? /* @__PURE__ */ f(I, { onRetry: () => g() }) : a ? a.length === 0 ? /* @__PURE__ */ f("p", {
|
|
248
260
|
className: "cp-empty",
|
|
249
|
-
children:
|
|
250
|
-
}) : /* @__PURE__ */
|
|
261
|
+
children: T(n === "upcoming" ? "bookings.emptyUpcoming" : "bookings.emptyPast")
|
|
262
|
+
}) : /* @__PURE__ */ f("ul", {
|
|
251
263
|
className: "cp-list",
|
|
252
|
-
children: a.map((e) => /* @__PURE__ */
|
|
264
|
+
children: a.map((e) => /* @__PURE__ */ f(ne, {
|
|
253
265
|
booking: e,
|
|
254
266
|
onCancelled: (e, t) => {
|
|
255
267
|
o((t) => t?.map((t) => t.id === e.id ? e : t)), h(t ? "bookings.doneLate" : "bookings.doneOnTime");
|
|
256
268
|
}
|
|
257
269
|
}, e.id))
|
|
258
|
-
}) : /* @__PURE__ */
|
|
270
|
+
}) : /* @__PURE__ */ f("p", {
|
|
259
271
|
role: "status",
|
|
260
|
-
children:
|
|
272
|
+
children: T("app.loading")
|
|
261
273
|
}),
|
|
262
|
-
a && c && !u && /* @__PURE__ */
|
|
274
|
+
a && c && !u && /* @__PURE__ */ f("button", {
|
|
263
275
|
type: "button",
|
|
264
276
|
className: "cp-secondary",
|
|
265
277
|
onClick: () => g(c),
|
|
266
|
-
children:
|
|
278
|
+
children: T("bookings.more")
|
|
267
279
|
})
|
|
268
280
|
]
|
|
269
281
|
});
|
|
270
282
|
}
|
|
271
283
|
function I({ onRetry: e }) {
|
|
272
|
-
return /* @__PURE__ */
|
|
284
|
+
return /* @__PURE__ */ p("div", {
|
|
273
285
|
role: "alert",
|
|
274
286
|
className: "cp-error",
|
|
275
|
-
children: [/* @__PURE__ */
|
|
287
|
+
children: [/* @__PURE__ */ f("p", { children: T("app.loadFailed") }), /* @__PURE__ */ f("button", {
|
|
276
288
|
type: "button",
|
|
277
289
|
className: "cp-secondary",
|
|
278
290
|
onClick: e,
|
|
279
|
-
children:
|
|
291
|
+
children: T("app.retry")
|
|
280
292
|
})]
|
|
281
293
|
});
|
|
282
294
|
}
|
|
283
|
-
function
|
|
284
|
-
let { client: t, businesses: n } =
|
|
295
|
+
function ne(e) {
|
|
296
|
+
let { client: t, businesses: n } = x(), { booking: r } = e, i = n.get(r.businessId)?.timezone, [a, o] = s(!1), [c, l] = s(!1), [d, m] = s(), [h, g] = s(!1), _ = h ? "closed" : F(r, /* @__PURE__ */ new Date()), v = r.creditMembershipId !== null && r.creditRestoredAt === null;
|
|
285
297
|
async function y() {
|
|
286
|
-
|
|
298
|
+
l(!0), m(void 0);
|
|
287
299
|
try {
|
|
288
|
-
let { data: n } = await t.POST(
|
|
300
|
+
let { data: n } = await t.POST(ee, { params: { path: {
|
|
289
301
|
businessId: r.businessId,
|
|
290
302
|
bookingId: r.id
|
|
291
303
|
} } });
|
|
@@ -296,7 +308,7 @@ function L(e) {
|
|
|
296
308
|
lateCancellationFrom: null
|
|
297
309
|
}, n.cancelledLate === !0));
|
|
298
310
|
} catch (e) {
|
|
299
|
-
if (
|
|
311
|
+
if (u(e, "post", ee)) {
|
|
300
312
|
if (e.code === "EventStarted") {
|
|
301
313
|
g(!0), o(!1);
|
|
302
314
|
return;
|
|
@@ -308,222 +320,228 @@ function L(e) {
|
|
|
308
320
|
}
|
|
309
321
|
m("bookings.cancelFailed");
|
|
310
322
|
} finally {
|
|
311
|
-
|
|
323
|
+
l(!1);
|
|
312
324
|
}
|
|
313
325
|
}
|
|
314
|
-
return /* @__PURE__ */
|
|
326
|
+
return /* @__PURE__ */ p("li", {
|
|
315
327
|
className: "cp-card",
|
|
316
328
|
"data-state": _,
|
|
317
329
|
children: [
|
|
318
|
-
/* @__PURE__ */
|
|
330
|
+
/* @__PURE__ */ p("div", {
|
|
319
331
|
className: "cp-card-head",
|
|
320
|
-
children: [/* @__PURE__ */
|
|
332
|
+
children: [/* @__PURE__ */ f("h2", { children: r.event.eventTypeName }), r.status === "cancelled" ? /* @__PURE__ */ f("span", {
|
|
321
333
|
className: "cp-badge",
|
|
322
|
-
children:
|
|
323
|
-
}) : r.attendance ? /* @__PURE__ */
|
|
334
|
+
children: T(r.cancelledLate ? "bookings.cancelledLate" : "bookings.cancelled")
|
|
335
|
+
}) : r.attendance ? /* @__PURE__ */ f("span", {
|
|
324
336
|
className: "cp-badge",
|
|
325
|
-
children:
|
|
337
|
+
children: T(r.attendance === "attended" ? "bookings.attended" : "bookings.noShow")
|
|
326
338
|
}) : null]
|
|
327
339
|
}),
|
|
328
|
-
/* @__PURE__ */
|
|
329
|
-
/* @__PURE__ */
|
|
330
|
-
(_ === "open" || _ === "late") && r.lateCancellationFrom && /* @__PURE__ */
|
|
340
|
+
/* @__PURE__ */ f("p", { children: r.businessName }),
|
|
341
|
+
/* @__PURE__ */ f("p", { children: N(r.event.startsAt, r.event.endsAt, i) }),
|
|
342
|
+
(_ === "open" || _ === "late") && r.lateCancellationFrom && /* @__PURE__ */ f("p", {
|
|
331
343
|
className: "cp-hint",
|
|
332
|
-
children:
|
|
344
|
+
children: T("bookings.lateFrom", { time: k(r.lateCancellationFrom, i) })
|
|
333
345
|
}),
|
|
334
|
-
_ === "closed" && r.status === "confirmed" && !r.attendance && /* @__PURE__ */
|
|
346
|
+
_ === "closed" && r.status === "confirmed" && !r.attendance && /* @__PURE__ */ f("p", {
|
|
335
347
|
className: "cp-hint",
|
|
336
|
-
children:
|
|
348
|
+
children: T("bookings.started")
|
|
337
349
|
}),
|
|
338
|
-
|
|
350
|
+
d && /* @__PURE__ */ f("p", {
|
|
339
351
|
role: "alert",
|
|
340
|
-
children:
|
|
352
|
+
children: T(d)
|
|
341
353
|
}),
|
|
342
|
-
(_ === "open" || _ === "late") && (a ? /* @__PURE__ */
|
|
354
|
+
(_ === "open" || _ === "late") && (a ? /* @__PURE__ */ p("fieldset", {
|
|
343
355
|
className: "cp-confirm",
|
|
344
356
|
children: [
|
|
345
|
-
/* @__PURE__ */
|
|
346
|
-
_ === "late" && /* @__PURE__ */
|
|
357
|
+
/* @__PURE__ */ f("legend", { children: T("bookings.confirmHeading") }),
|
|
358
|
+
_ === "late" && /* @__PURE__ */ f("p", {
|
|
347
359
|
className: "cp-warning",
|
|
348
|
-
children:
|
|
360
|
+
children: T("bookings.confirmLate")
|
|
349
361
|
}),
|
|
350
|
-
_ === "late" && v && /* @__PURE__ */
|
|
362
|
+
_ === "late" && v && /* @__PURE__ */ f("p", {
|
|
351
363
|
className: "cp-warning",
|
|
352
|
-
children:
|
|
364
|
+
children: T("bookings.confirmCredit")
|
|
353
365
|
}),
|
|
354
|
-
/* @__PURE__ */
|
|
366
|
+
/* @__PURE__ */ p("div", {
|
|
355
367
|
className: "cp-actions",
|
|
356
|
-
children: [/* @__PURE__ */
|
|
368
|
+
children: [/* @__PURE__ */ f("button", {
|
|
357
369
|
type: "button",
|
|
358
370
|
disabled: c,
|
|
359
371
|
onClick: y,
|
|
360
|
-
children:
|
|
361
|
-
}), /* @__PURE__ */
|
|
372
|
+
children: T(c ? "bookings.cancelling" : "bookings.confirm")
|
|
373
|
+
}), /* @__PURE__ */ f("button", {
|
|
362
374
|
type: "button",
|
|
363
375
|
className: "cp-secondary",
|
|
364
376
|
disabled: c,
|
|
365
377
|
onClick: () => o(!1),
|
|
366
|
-
children:
|
|
378
|
+
children: T("bookings.keep")
|
|
367
379
|
})]
|
|
368
380
|
})
|
|
369
381
|
]
|
|
370
|
-
}) : /* @__PURE__ */
|
|
382
|
+
}) : /* @__PURE__ */ f("button", {
|
|
371
383
|
type: "button",
|
|
372
384
|
className: "cp-secondary",
|
|
373
385
|
onClick: () => o(!0),
|
|
374
|
-
children:
|
|
386
|
+
children: T("bookings.cancel")
|
|
375
387
|
}))
|
|
376
388
|
]
|
|
377
389
|
});
|
|
378
390
|
}
|
|
379
391
|
// src/booking.tsx
|
|
380
|
-
var
|
|
381
|
-
function
|
|
392
|
+
var re = "/web/businesses/{businessId}/reservations", ie = "/web/businesses/{businessId}/reservations/{reservationId}/confirm";
|
|
393
|
+
function L({ choice: e }) {
|
|
382
394
|
let { business: t, candidate: n } = e;
|
|
383
|
-
return /* @__PURE__ */
|
|
395
|
+
return /* @__PURE__ */ p("div", {
|
|
384
396
|
className: "cp-summary",
|
|
385
397
|
children: [
|
|
386
|
-
/* @__PURE__ */
|
|
387
|
-
/* @__PURE__ */
|
|
388
|
-
/* @__PURE__ */
|
|
389
|
-
n.resource && /* @__PURE__ */
|
|
398
|
+
/* @__PURE__ */ f("h2", { children: n.title }),
|
|
399
|
+
/* @__PURE__ */ f("p", { children: t.displayName }),
|
|
400
|
+
/* @__PURE__ */ f("p", { children: N(n.startsAt, n.endsAt, n.timezone) }),
|
|
401
|
+
n.resource && /* @__PURE__ */ f("p", {
|
|
390
402
|
className: "cp-hint",
|
|
391
|
-
children:
|
|
403
|
+
children: T("business.with", { resource: n.resource.displayName })
|
|
392
404
|
})
|
|
393
405
|
]
|
|
394
406
|
});
|
|
395
407
|
}
|
|
396
|
-
function
|
|
397
|
-
let { client: n, navigate: i } =
|
|
398
|
-
|
|
408
|
+
function ae(e) {
|
|
409
|
+
let { client: n, navigate: i, accountNavigation: a } = x(), { business: c, candidate: l } = e.choice, [m, h] = s({ step: "reserving" }), [g, _] = s(), v = t(async () => {
|
|
410
|
+
h({ step: "reserving" });
|
|
399
411
|
try {
|
|
400
|
-
let { data: e } = await n.POST(
|
|
401
|
-
params: { path: { businessId:
|
|
402
|
-
body:
|
|
403
|
-
eventTypeId:
|
|
404
|
-
startsAt:
|
|
405
|
-
...
|
|
412
|
+
let { data: e } = await n.POST(re, {
|
|
413
|
+
params: { path: { businessId: c.id } },
|
|
414
|
+
body: l.eventId ? { eventId: l.eventId } : {
|
|
415
|
+
eventTypeId: l.eventTypeId,
|
|
416
|
+
startsAt: l.startsAt,
|
|
417
|
+
...l.resource && { resourceId: l.resource.id }
|
|
406
418
|
}
|
|
407
419
|
});
|
|
408
|
-
e &&
|
|
420
|
+
e && h({
|
|
409
421
|
step: "held",
|
|
410
422
|
reservationId: e.id,
|
|
411
423
|
expiresAt: e.expiresAt
|
|
412
424
|
});
|
|
413
425
|
} catch (e) {
|
|
414
|
-
let t =
|
|
415
|
-
|
|
426
|
+
let t = u(e, "post", re) ? e.code : void 0;
|
|
427
|
+
h({
|
|
416
428
|
step: "refused",
|
|
417
|
-
message:
|
|
429
|
+
message: oe(t),
|
|
418
430
|
again: !1
|
|
419
431
|
});
|
|
420
432
|
}
|
|
421
433
|
}, [
|
|
422
434
|
n,
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
]),
|
|
435
|
+
c.id,
|
|
436
|
+
l
|
|
437
|
+
]), y = o(!1);
|
|
426
438
|
r(() => {
|
|
427
|
-
|
|
428
|
-
}, [
|
|
429
|
-
async function
|
|
430
|
-
|
|
439
|
+
y.current || (y.current = !0, v());
|
|
440
|
+
}, [v]);
|
|
441
|
+
async function b(t, r) {
|
|
442
|
+
h({
|
|
431
443
|
step: "confirming",
|
|
432
|
-
reservationId:
|
|
433
|
-
expiresAt:
|
|
444
|
+
reservationId: t,
|
|
445
|
+
expiresAt: r
|
|
434
446
|
});
|
|
435
447
|
try {
|
|
436
|
-
let { data:
|
|
437
|
-
businessId:
|
|
438
|
-
reservationId:
|
|
448
|
+
let { data: r } = await n.POST(ie, { params: { path: {
|
|
449
|
+
businessId: c.id,
|
|
450
|
+
reservationId: t
|
|
439
451
|
} } });
|
|
440
|
-
if (!
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
452
|
+
if (!r) return;
|
|
453
|
+
e.onBooked?.(r);
|
|
454
|
+
let i = await n.GET("/web/businesses/{businessId}/bookings/{bookingId}", { params: { path: {
|
|
455
|
+
businessId: c.id,
|
|
456
|
+
bookingId: r.id
|
|
444
457
|
} } }).then(({ data: e }) => e ?? null).catch(() => null);
|
|
445
|
-
|
|
458
|
+
h({
|
|
446
459
|
step: "booked",
|
|
447
|
-
booking:
|
|
460
|
+
booking: i
|
|
448
461
|
});
|
|
449
462
|
} catch (e) {
|
|
450
|
-
let t =
|
|
451
|
-
|
|
463
|
+
let t = u(e, "post", ie) ? e.code : void 0;
|
|
464
|
+
h(t === "ReservationExpired" || t === "ReservationNotFound" ? {
|
|
452
465
|
step: "refused",
|
|
453
466
|
message: "book.expired",
|
|
454
467
|
again: !0
|
|
455
468
|
} : {
|
|
456
469
|
step: "refused",
|
|
457
|
-
message:
|
|
470
|
+
message: se(t),
|
|
458
471
|
again: !1
|
|
459
472
|
});
|
|
460
473
|
}
|
|
461
474
|
}
|
|
462
|
-
let
|
|
475
|
+
let S = /* @__PURE__ */ f("button", {
|
|
463
476
|
type: "button",
|
|
464
477
|
className: "cp-secondary",
|
|
465
478
|
onClick: e.onBack,
|
|
466
|
-
children:
|
|
479
|
+
children: T("book.back")
|
|
467
480
|
});
|
|
468
|
-
return /* @__PURE__ */
|
|
481
|
+
return /* @__PURE__ */ p("section", {
|
|
469
482
|
className: "cp-screen",
|
|
470
|
-
children: [/* @__PURE__ */
|
|
471
|
-
/* @__PURE__ */
|
|
483
|
+
children: [/* @__PURE__ */ f("h1", { children: T("book.heading") }), m.step === "booked" ? /* @__PURE__ */ p(d, { children: [
|
|
484
|
+
/* @__PURE__ */ f("p", {
|
|
472
485
|
role: "status",
|
|
473
486
|
className: "cp-notice",
|
|
474
|
-
children:
|
|
487
|
+
children: T(g ?? "book.booked")
|
|
475
488
|
}),
|
|
476
|
-
|
|
489
|
+
m.booking ? /* @__PURE__ */ f("ul", {
|
|
477
490
|
className: "cp-list",
|
|
478
|
-
children: /* @__PURE__ */
|
|
479
|
-
booking:
|
|
491
|
+
children: /* @__PURE__ */ f(ne, {
|
|
492
|
+
booking: m.booking,
|
|
480
493
|
onCancelled: (e, t) => {
|
|
481
|
-
|
|
494
|
+
h({
|
|
482
495
|
step: "booked",
|
|
483
496
|
booking: e
|
|
484
|
-
}),
|
|
497
|
+
}), _(t ? "bookings.doneLate" : "bookings.doneOnTime");
|
|
485
498
|
}
|
|
486
499
|
})
|
|
487
|
-
}) : /* @__PURE__ */
|
|
488
|
-
/* @__PURE__ */
|
|
500
|
+
}) : /* @__PURE__ */ f(L, { choice: e.choice }),
|
|
501
|
+
a ? /* @__PURE__ */ f("button", {
|
|
489
502
|
type: "button",
|
|
490
503
|
className: "cp-secondary",
|
|
491
504
|
onClick: () => i("bookings"),
|
|
492
|
-
children:
|
|
505
|
+
children: T("book.toBookings")
|
|
506
|
+
}) : e.onDone && /* @__PURE__ */ f("button", {
|
|
507
|
+
type: "button",
|
|
508
|
+
className: "cp-secondary",
|
|
509
|
+
onClick: e.onDone,
|
|
510
|
+
children: T("book.done")
|
|
493
511
|
})
|
|
494
|
-
] }) : /* @__PURE__ */
|
|
495
|
-
/* @__PURE__ */
|
|
496
|
-
|
|
512
|
+
] }) : /* @__PURE__ */ p(d, { children: [
|
|
513
|
+
/* @__PURE__ */ f(L, { choice: e.choice }),
|
|
514
|
+
m.step === "reserving" && /* @__PURE__ */ f("p", {
|
|
497
515
|
role: "status",
|
|
498
|
-
children:
|
|
516
|
+
children: T("book.reserving")
|
|
499
517
|
}),
|
|
500
|
-
(
|
|
518
|
+
(m.step === "held" || m.step === "confirming") && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", {
|
|
501
519
|
className: "cp-hint",
|
|
502
|
-
children:
|
|
503
|
-
}), /* @__PURE__ */
|
|
520
|
+
children: T("book.heldUntil", { time: A(m.expiresAt, l.timezone) })
|
|
521
|
+
}), /* @__PURE__ */ p("div", {
|
|
504
522
|
className: "cp-actions",
|
|
505
|
-
children: [/* @__PURE__ */
|
|
523
|
+
children: [/* @__PURE__ */ f("button", {
|
|
506
524
|
type: "button",
|
|
507
|
-
disabled:
|
|
508
|
-
onClick: () =>
|
|
509
|
-
children:
|
|
510
|
-
}),
|
|
525
|
+
disabled: m.step === "confirming",
|
|
526
|
+
onClick: () => b(m.reservationId, m.expiresAt),
|
|
527
|
+
children: m.step === "confirming" ? T("book.confirming") : T("book.confirm")
|
|
528
|
+
}), S]
|
|
511
529
|
})] }),
|
|
512
|
-
|
|
530
|
+
m.step === "refused" && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", {
|
|
513
531
|
role: "alert",
|
|
514
|
-
children:
|
|
515
|
-
}), /* @__PURE__ */
|
|
532
|
+
children: T(m.message)
|
|
533
|
+
}), /* @__PURE__ */ p("div", {
|
|
516
534
|
className: "cp-actions",
|
|
517
|
-
children: [
|
|
535
|
+
children: [m.again && /* @__PURE__ */ f("button", {
|
|
518
536
|
type: "button",
|
|
519
|
-
onClick:
|
|
520
|
-
children:
|
|
521
|
-
}),
|
|
537
|
+
onClick: v,
|
|
538
|
+
children: T("book.reserveAgain")
|
|
539
|
+
}), S]
|
|
522
540
|
})] })
|
|
523
541
|
] })]
|
|
524
542
|
});
|
|
525
543
|
}
|
|
526
|
-
function
|
|
544
|
+
function oe(e) {
|
|
527
545
|
switch (e) {
|
|
528
546
|
case "EventFull": return "book.full";
|
|
529
547
|
case "SlotTaken": return "book.slotTaken";
|
|
@@ -538,7 +556,7 @@ function ne(e) {
|
|
|
538
556
|
default: return "book.failed";
|
|
539
557
|
}
|
|
540
558
|
}
|
|
541
|
-
function
|
|
559
|
+
function se(e) {
|
|
542
560
|
switch (e) {
|
|
543
561
|
case "NotAuthorized": return "book.notAllowed";
|
|
544
562
|
case "EventStarted":
|
|
@@ -548,322 +566,528 @@ function re(e) {
|
|
|
548
566
|
default: return "book.failed";
|
|
549
567
|
}
|
|
550
568
|
}
|
|
551
|
-
// src/client.ts
|
|
552
|
-
var V = (e, t) => {
|
|
553
|
-
let n = new Request(e, t);
|
|
554
|
-
return n.headers.set("X-MSM-BFF", "1"), fetch(n);
|
|
555
|
-
};
|
|
556
|
-
function H(e, t, n) {
|
|
557
|
-
return V(`${e}${t}`, {
|
|
558
|
-
method: "POST",
|
|
559
|
-
headers: { "content-type": "application/json" },
|
|
560
|
-
body: JSON.stringify(n ?? {})
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
function ie(e, t) {
|
|
564
|
-
let n = c({ baseUrl: `${e}/engine` });
|
|
565
|
-
return n.use({
|
|
566
|
-
onRequest({ request: e }) {
|
|
567
|
-
return e.headers.set("X-MSM-BFF", "1"), e;
|
|
568
|
-
},
|
|
569
|
-
onResponse({ response: e }) {
|
|
570
|
-
e.status === 401 && t();
|
|
571
|
-
}
|
|
572
|
-
}), n;
|
|
573
|
-
}
|
|
574
569
|
// src/layout.tsx
|
|
575
|
-
function
|
|
576
|
-
return e ? /* @__PURE__ */
|
|
570
|
+
function R({ brand: e }) {
|
|
571
|
+
return e ? /* @__PURE__ */ p("div", {
|
|
577
572
|
className: "cp-brand",
|
|
578
|
-
children: [e.logo && /* @__PURE__ */
|
|
573
|
+
children: [e.logo && /* @__PURE__ */ f("img", {
|
|
579
574
|
src: e.logo,
|
|
580
575
|
alt: ""
|
|
581
|
-
}), /* @__PURE__ */
|
|
576
|
+
}), /* @__PURE__ */ f("span", { children: e.name })]
|
|
582
577
|
}) : null;
|
|
583
578
|
}
|
|
584
|
-
var
|
|
585
|
-
["businesses", "nav.book"],
|
|
579
|
+
var ce = [["businesses", "nav.book"]], le = [
|
|
586
580
|
["bookings", "nav.bookings"],
|
|
587
581
|
["passes", "nav.passes"],
|
|
588
582
|
["details", "nav.details"]
|
|
589
|
-
];
|
|
590
|
-
function
|
|
583
|
+
], ue = [...ce, ...le];
|
|
584
|
+
function de(e) {
|
|
591
585
|
let t = typeof e.screen == "string" ? e.screen : "businesses";
|
|
592
|
-
return /* @__PURE__ */
|
|
586
|
+
return /* @__PURE__ */ p("div", {
|
|
593
587
|
className: "cp-shell",
|
|
594
588
|
children: [
|
|
595
|
-
/* @__PURE__ */
|
|
589
|
+
/* @__PURE__ */ p("header", {
|
|
596
590
|
className: "cp-header",
|
|
597
|
-
children: [/* @__PURE__ */
|
|
591
|
+
children: [/* @__PURE__ */ f(R, { brand: e.brand }), e.signedIn ? /* @__PURE__ */ f("button", {
|
|
598
592
|
type: "button",
|
|
599
593
|
className: "cp-link",
|
|
600
594
|
onClick: e.onSignOut,
|
|
601
|
-
children:
|
|
602
|
-
}) : !e.signingIn && /* @__PURE__ */
|
|
595
|
+
children: T("nav.signOut")
|
|
596
|
+
}) : !e.signingIn && /* @__PURE__ */ f("button", {
|
|
603
597
|
type: "button",
|
|
604
598
|
className: "cp-link",
|
|
605
599
|
onClick: () => e.onNavigate("bookings"),
|
|
606
|
-
children:
|
|
600
|
+
children: T("nav.signIn")
|
|
607
601
|
})]
|
|
608
602
|
}),
|
|
609
|
-
/* @__PURE__ */
|
|
603
|
+
/* @__PURE__ */ f("nav", {
|
|
610
604
|
className: "cp-nav",
|
|
611
|
-
"aria-label":
|
|
612
|
-
children:
|
|
605
|
+
"aria-label": T("nav.label"),
|
|
606
|
+
children: e.tabs.map(([n, r]) => /* @__PURE__ */ f("button", {
|
|
613
607
|
type: "button",
|
|
614
608
|
"aria-current": t === n ? "page" : void 0,
|
|
615
609
|
onClick: () => e.onNavigate(n),
|
|
616
|
-
children:
|
|
610
|
+
children: T(r)
|
|
617
611
|
}, n))
|
|
618
612
|
}),
|
|
619
|
-
/* @__PURE__ */
|
|
613
|
+
/* @__PURE__ */ f("main", {
|
|
620
614
|
className: "cp-main",
|
|
621
615
|
children: e.children
|
|
622
616
|
})
|
|
623
617
|
]
|
|
624
618
|
});
|
|
625
619
|
}
|
|
620
|
+
// src/client.ts
|
|
621
|
+
var z = (e, t) => {
|
|
622
|
+
let n = new Request(e, t);
|
|
623
|
+
return n.headers.set("X-MSM-BFF", "1"), fetch(n);
|
|
624
|
+
};
|
|
625
|
+
function B(e, t, n) {
|
|
626
|
+
return z(`${e}${t}`, {
|
|
627
|
+
method: "POST",
|
|
628
|
+
headers: { "content-type": "application/json" },
|
|
629
|
+
body: JSON.stringify(n ?? {})
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
function fe(e, t) {
|
|
633
|
+
let n = l({ baseUrl: `${e}/engine` });
|
|
634
|
+
return n.use({
|
|
635
|
+
onRequest({ request: e }) {
|
|
636
|
+
return e.headers.set("X-MSM-BFF", "1"), e;
|
|
637
|
+
},
|
|
638
|
+
onResponse({ response: e }) {
|
|
639
|
+
e.status === 401 && t();
|
|
640
|
+
}
|
|
641
|
+
}), n;
|
|
642
|
+
}
|
|
643
|
+
// src/session.ts
|
|
644
|
+
var V = /* @__PURE__ */ new Map();
|
|
645
|
+
function H(e) {
|
|
646
|
+
let t = V.get(e);
|
|
647
|
+
return t || (t = {
|
|
648
|
+
value: void 0,
|
|
649
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
650
|
+
generation: 0
|
|
651
|
+
}, V.set(e, t)), t;
|
|
652
|
+
}
|
|
653
|
+
function U(e, t) {
|
|
654
|
+
let n = H(e);
|
|
655
|
+
if (n.value !== t) {
|
|
656
|
+
n.value = t;
|
|
657
|
+
for (let e of n.listeners) e();
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
function pe(e, t) {
|
|
661
|
+
let { generation: n } = t, r = (r) => {
|
|
662
|
+
t.generation === n && t.value === void 0 && U(e, r);
|
|
663
|
+
};
|
|
664
|
+
z(`${e}/auth/session`).then(async (e) => r(e.ok ? (await e.json()).sessionKey : null)).catch(() => r(null));
|
|
665
|
+
}
|
|
666
|
+
function me(e, t) {
|
|
667
|
+
let n = H(e);
|
|
668
|
+
return n.listeners.size === 0 && n.value === void 0 && pe(e, n), n.listeners.add(t), () => {
|
|
669
|
+
n.listeners.delete(t), n.listeners.size === 0 && queueMicrotask(() => {
|
|
670
|
+
n.listeners.size > 0 || (n.value = void 0, n.generation++);
|
|
671
|
+
});
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
function he(e, t) {
|
|
675
|
+
let n = c((t) => me(e, t), () => H(e).value, () => void 0), i = o(void 0), a = o(t);
|
|
676
|
+
return a.current = t, r(() => {
|
|
677
|
+
if (n === void 0) return;
|
|
678
|
+
let e = n !== null;
|
|
679
|
+
i.current !== void 0 && i.current !== e && a.current?.(e), i.current = e;
|
|
680
|
+
}, [n]), n;
|
|
681
|
+
}
|
|
682
|
+
// src/portal.tsx
|
|
683
|
+
function W(e) {
|
|
684
|
+
let { navigate: n, accountNavigation: i } = e, c = e.basePath.replace(/\/$/, ""), l = he(c, e.onSessionChange), u = o(!1);
|
|
685
|
+
u.current = !!l;
|
|
686
|
+
let [d, f] = s(), [p, m] = s(/* @__PURE__ */ new Map()), [h, g] = s("loading"), _ = a(() => fe(c, () => {
|
|
687
|
+
u.current && f("app.signedOut"), U(c, null);
|
|
688
|
+
}), [c]), v = t(async () => {
|
|
689
|
+
g("loading");
|
|
690
|
+
try {
|
|
691
|
+
let e = /* @__PURE__ */ new Map(), t;
|
|
692
|
+
do {
|
|
693
|
+
let { data: n } = await _.GET("/web/businesses", { params: { query: {
|
|
694
|
+
limit: 100,
|
|
695
|
+
...t && { cursor: t }
|
|
696
|
+
} } });
|
|
697
|
+
for (let t of n?.items ?? []) e.set(t.id, t);
|
|
698
|
+
t = n?.nextCursor ?? void 0;
|
|
699
|
+
} while (t);
|
|
700
|
+
m(e), g("ready");
|
|
701
|
+
} catch {
|
|
702
|
+
g("failed");
|
|
703
|
+
}
|
|
704
|
+
}, [_]);
|
|
705
|
+
return r(() => {
|
|
706
|
+
v();
|
|
707
|
+
}, [v]), {
|
|
708
|
+
basePath: c,
|
|
709
|
+
sessionKey: l,
|
|
710
|
+
notice: d,
|
|
711
|
+
portal: a(() => ({
|
|
712
|
+
client: _,
|
|
713
|
+
businesses: p,
|
|
714
|
+
businessesStatus: h,
|
|
715
|
+
reloadBusinesses: () => void v(),
|
|
716
|
+
navigate: n,
|
|
717
|
+
accountNavigation: i,
|
|
718
|
+
signOut: async (e) => {
|
|
719
|
+
await B(c, "/auth/logout").catch(() => {}), f(e), U(c, null);
|
|
720
|
+
}
|
|
721
|
+
}), [
|
|
722
|
+
_,
|
|
723
|
+
p,
|
|
724
|
+
h,
|
|
725
|
+
v,
|
|
726
|
+
n,
|
|
727
|
+
i,
|
|
728
|
+
c
|
|
729
|
+
]),
|
|
730
|
+
signedInAs: t((e) => {
|
|
731
|
+
f(void 0), U(c, e);
|
|
732
|
+
}, [c])
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
function G(e) {
|
|
736
|
+
return /* @__PURE__ */ f("div", {
|
|
737
|
+
className: "msm-customer",
|
|
738
|
+
children: e.loading ? /* @__PURE__ */ f("p", {
|
|
739
|
+
className: "cp-status",
|
|
740
|
+
role: "status",
|
|
741
|
+
children: T("app.loading")
|
|
742
|
+
}) : /* @__PURE__ */ f(b.Provider, {
|
|
743
|
+
value: e.portal,
|
|
744
|
+
children: e.children
|
|
745
|
+
})
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
// src/image.tsx
|
|
749
|
+
function K(e) {
|
|
750
|
+
let { image: t, alt: n, className: r } = e;
|
|
751
|
+
if (!t) return null;
|
|
752
|
+
let { small: i } = t;
|
|
753
|
+
return e.size === "small" ? /* @__PURE__ */ f("img", {
|
|
754
|
+
className: r,
|
|
755
|
+
src: i.url,
|
|
756
|
+
width: i.width,
|
|
757
|
+
height: i.height,
|
|
758
|
+
alt: n,
|
|
759
|
+
loading: "lazy",
|
|
760
|
+
decoding: "async"
|
|
761
|
+
}) : i.url === t.url ? /* @__PURE__ */ f("img", {
|
|
762
|
+
className: r,
|
|
763
|
+
src: t.url,
|
|
764
|
+
width: t.width,
|
|
765
|
+
height: t.height,
|
|
766
|
+
alt: n,
|
|
767
|
+
loading: "lazy",
|
|
768
|
+
decoding: "async"
|
|
769
|
+
}) : /* @__PURE__ */ f("img", {
|
|
770
|
+
className: r,
|
|
771
|
+
src: t.url,
|
|
772
|
+
srcSet: `${i.url} ${i.width}w, ${t.url} ${t.width}w`,
|
|
773
|
+
sizes: "(min-width: 640px) 608px, calc(100vw - 32px)",
|
|
774
|
+
width: t.width,
|
|
775
|
+
height: t.height,
|
|
776
|
+
alt: n,
|
|
777
|
+
loading: "lazy",
|
|
778
|
+
decoding: "async"
|
|
779
|
+
});
|
|
780
|
+
}
|
|
626
781
|
// src/screens/business.tsx
|
|
627
|
-
var
|
|
782
|
+
var ge = "/web/businesses/{businessId}", _e = /* @__PURE__ */ new Set([
|
|
628
783
|
"BusinessNotFound",
|
|
629
784
|
"OutsideClientScope",
|
|
630
785
|
"ValidationFailed"
|
|
631
|
-
]),
|
|
632
|
-
function
|
|
786
|
+
]), ve = 7;
|
|
787
|
+
function ye(e, t = /* @__PURE__ */ new Date()) {
|
|
633
788
|
return new Intl.DateTimeFormat("en-CA", {
|
|
634
789
|
timeZone: e,
|
|
635
790
|
year: "numeric",
|
|
636
791
|
month: "2-digit",
|
|
637
792
|
day: "2-digit"
|
|
638
|
-
}).format(
|
|
793
|
+
}).format(t);
|
|
639
794
|
}
|
|
640
|
-
function
|
|
795
|
+
function q(e, t) {
|
|
641
796
|
let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
642
797
|
return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
|
|
643
798
|
}
|
|
644
|
-
function
|
|
645
|
-
let { client: n
|
|
646
|
-
|
|
799
|
+
function be(e) {
|
|
800
|
+
let { client: n } = x(), [i, a] = s(), [o, c] = s(), [l, d] = s(!1), f = t(async () => {
|
|
801
|
+
d(!1), a(void 0);
|
|
647
802
|
try {
|
|
648
|
-
let [
|
|
649
|
-
|
|
803
|
+
let [t, r] = await Promise.all([n.GET(ge, { params: { path: { businessId: e } } }), n.GET("/web/businesses/{businessId}/event-types", { params: { path: { businessId: e } } })]);
|
|
804
|
+
a(t.data ?? null), c(r.data?.items ?? []);
|
|
650
805
|
} catch (e) {
|
|
651
|
-
|
|
806
|
+
u(e) && _e.has(e.code ?? "") ? a(null) : d(!0);
|
|
652
807
|
}
|
|
653
|
-
}, [n,
|
|
654
|
-
r(() => {
|
|
655
|
-
|
|
656
|
-
}, [
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
808
|
+
}, [n, e]);
|
|
809
|
+
return r(() => {
|
|
810
|
+
f();
|
|
811
|
+
}, [f]), {
|
|
812
|
+
business: i,
|
|
813
|
+
types: o,
|
|
814
|
+
failed: l,
|
|
815
|
+
reload: f
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
function xe(e, t) {
|
|
819
|
+
if (e.failed) return /* @__PURE__ */ p("section", {
|
|
664
820
|
className: "cp-screen",
|
|
665
|
-
children: [
|
|
821
|
+
children: [t, /* @__PURE__ */ f(I, { onRetry: e.reload })]
|
|
666
822
|
});
|
|
667
|
-
if (
|
|
823
|
+
if (e.business === null) return /* @__PURE__ */ p("section", {
|
|
668
824
|
className: "cp-screen",
|
|
669
|
-
children: [
|
|
825
|
+
children: [t, /* @__PURE__ */ f("p", {
|
|
670
826
|
className: "cp-empty",
|
|
671
|
-
children:
|
|
827
|
+
children: T("business.notFound")
|
|
672
828
|
})]
|
|
673
829
|
});
|
|
674
|
-
if (
|
|
830
|
+
if (e.business === void 0 || !e.types) return /* @__PURE__ */ p("section", {
|
|
675
831
|
className: "cp-screen",
|
|
676
|
-
children: [
|
|
832
|
+
children: [t, /* @__PURE__ */ f("p", {
|
|
677
833
|
role: "status",
|
|
678
|
-
children:
|
|
834
|
+
children: T("app.loading")
|
|
679
835
|
})]
|
|
680
836
|
});
|
|
681
|
-
|
|
682
|
-
|
|
837
|
+
}
|
|
838
|
+
function Se(e) {
|
|
839
|
+
let t = /* @__PURE__ */ new Map();
|
|
840
|
+
for (let n of e) for (let e of n.resources) t.has(e.id) || t.set(e.id, e);
|
|
841
|
+
return [...t.values()];
|
|
842
|
+
}
|
|
843
|
+
function Ce(e) {
|
|
844
|
+
let { navigate: t, accountNavigation: n } = x(), { businessId: r, eventTypeId: i, onFilter: a } = e, o = be(r), s = n && /* @__PURE__ */ f("button", {
|
|
845
|
+
type: "button",
|
|
846
|
+
className: "cp-link cp-back",
|
|
847
|
+
onClick: () => t("businesses"),
|
|
848
|
+
children: T("business.all")
|
|
849
|
+
}), c = xe(o, s), { business: l, types: u } = o;
|
|
850
|
+
if (c || !l || !u) return c;
|
|
851
|
+
let m = u.find((e) => e.id === i), h = a ? Se(m ? [m] : u) : [], g = h.some((t) => t.id === e.resourceId) ? e.resourceId : void 0, _ = (e) => {
|
|
852
|
+
if (!a) return t(e ? {
|
|
853
|
+
businessId: r,
|
|
854
|
+
eventTypeId: e
|
|
855
|
+
} : { businessId: r });
|
|
856
|
+
let n = u.find((t) => t.id === e), i = g && Se(n ? [n] : u).some((e) => e.id === g);
|
|
857
|
+
a({
|
|
858
|
+
...e && { eventTypeId: e },
|
|
859
|
+
...i && { resourceId: g }
|
|
860
|
+
});
|
|
861
|
+
};
|
|
862
|
+
return /* @__PURE__ */ p("section", {
|
|
683
863
|
className: "cp-screen",
|
|
684
864
|
children: [
|
|
685
|
-
|
|
686
|
-
/* @__PURE__ */ f(
|
|
687
|
-
|
|
688
|
-
children: [/* @__PURE__ */ d("h1", { children: c.displayName }), c.address && /* @__PURE__ */ d("p", {
|
|
689
|
-
className: "cp-hint",
|
|
690
|
-
children: c.address
|
|
691
|
-
})]
|
|
692
|
-
}),
|
|
693
|
-
m.length > 0 && /* @__PURE__ */ f("fieldset", {
|
|
865
|
+
s,
|
|
866
|
+
/* @__PURE__ */ f(we, { business: l }),
|
|
867
|
+
u.length > 0 && /* @__PURE__ */ p("fieldset", {
|
|
694
868
|
className: "cp-chips",
|
|
695
|
-
"aria-label":
|
|
696
|
-
children: [/* @__PURE__ */
|
|
869
|
+
"aria-label": T("business.types"),
|
|
870
|
+
children: [/* @__PURE__ */ f("button", {
|
|
697
871
|
type: "button",
|
|
698
|
-
"aria-pressed": !
|
|
699
|
-
onClick: () =>
|
|
700
|
-
children:
|
|
701
|
-
}),
|
|
872
|
+
"aria-pressed": !i,
|
|
873
|
+
onClick: () => _(void 0),
|
|
874
|
+
children: T("business.allTypes")
|
|
875
|
+
}), u.map((e) => /* @__PURE__ */ f("button", {
|
|
702
876
|
type: "button",
|
|
703
|
-
"aria-pressed": e.id ===
|
|
704
|
-
onClick: () =>
|
|
705
|
-
businessId: a,
|
|
706
|
-
eventTypeId: e.id
|
|
707
|
-
}),
|
|
877
|
+
"aria-pressed": e.id === i,
|
|
878
|
+
onClick: () => _(e.id),
|
|
708
879
|
children: e.displayName
|
|
709
880
|
}, e.id))]
|
|
710
881
|
}),
|
|
711
|
-
|
|
712
|
-
className: "cp-
|
|
713
|
-
children: w("business.typeMissing")
|
|
714
|
-
}) : /* @__PURE__ */ f(u, { children: [x && /* @__PURE__ */ f("div", {
|
|
715
|
-
className: "cp-type",
|
|
882
|
+
a && h.length > 1 && /* @__PURE__ */ p("fieldset", {
|
|
883
|
+
className: "cp-chips",
|
|
716
884
|
children: [
|
|
717
|
-
/* @__PURE__ */
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
885
|
+
/* @__PURE__ */ f("legend", { children: T("business.resources") }),
|
|
886
|
+
/* @__PURE__ */ f("button", {
|
|
887
|
+
type: "button",
|
|
888
|
+
"aria-pressed": !g,
|
|
889
|
+
onClick: () => a({ ...i && { eventTypeId: i } }),
|
|
890
|
+
children: T("business.anyResource")
|
|
891
|
+
}),
|
|
892
|
+
h.map((e) => /* @__PURE__ */ f("button", {
|
|
893
|
+
type: "button",
|
|
894
|
+
"aria-pressed": e.id === g,
|
|
895
|
+
onClick: () => a({
|
|
896
|
+
...i && { eventTypeId: i },
|
|
897
|
+
resourceId: e.id
|
|
898
|
+
}),
|
|
899
|
+
children: e.displayName
|
|
900
|
+
}, e.id))
|
|
723
901
|
]
|
|
724
|
-
}),
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
902
|
+
}),
|
|
903
|
+
i && !m ? /* @__PURE__ */ f("p", {
|
|
904
|
+
className: "cp-empty",
|
|
905
|
+
children: T("business.typeMissing")
|
|
906
|
+
}) : /* @__PURE__ */ p(d, { children: [m && /* @__PURE__ */ f(J, { type: m }), /* @__PURE__ */ f(Te, {
|
|
907
|
+
business: l,
|
|
908
|
+
eventTypeId: i,
|
|
909
|
+
resourceId: g,
|
|
910
|
+
onChoose: (t) => e.onChoose(l, t)
|
|
728
911
|
})] })
|
|
729
912
|
]
|
|
730
913
|
});
|
|
731
914
|
}
|
|
732
|
-
function
|
|
733
|
-
|
|
734
|
-
|
|
915
|
+
function we({ business: e }) {
|
|
916
|
+
return /* @__PURE__ */ p("header", {
|
|
917
|
+
className: "cp-business-head",
|
|
918
|
+
children: [/* @__PURE__ */ f(K, {
|
|
919
|
+
image: e.logo,
|
|
920
|
+
alt: T("image.logo", { name: e.displayName }),
|
|
921
|
+
size: "small",
|
|
922
|
+
className: "cp-logo"
|
|
923
|
+
}), /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("h1", { children: e.displayName }), e.address && /* @__PURE__ */ f("p", {
|
|
924
|
+
className: "cp-hint",
|
|
925
|
+
children: e.address
|
|
926
|
+
})] })]
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
function J({ type: e }) {
|
|
930
|
+
return /* @__PURE__ */ p("div", {
|
|
931
|
+
className: "cp-type",
|
|
932
|
+
children: [
|
|
933
|
+
/* @__PURE__ */ f(K, {
|
|
934
|
+
image: e.image,
|
|
935
|
+
alt: e.displayName,
|
|
936
|
+
size: "full",
|
|
937
|
+
className: "cp-detail-image"
|
|
938
|
+
}),
|
|
939
|
+
/* @__PURE__ */ f("h2", { children: e.displayName }),
|
|
940
|
+
e.description && /* @__PURE__ */ f("p", { children: e.description }),
|
|
941
|
+
/* @__PURE__ */ f("p", {
|
|
942
|
+
className: "cp-hint",
|
|
943
|
+
children: T("business.minutes", { minutes: e.durationMinutes })
|
|
944
|
+
})
|
|
945
|
+
]
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
function Te(e) {
|
|
949
|
+
let { client: n } = x(), { business: i, eventTypeId: a, resourceId: o } = e, c = i.timezone, [l, u] = s(0), [m, h] = s(), [g, _] = s(!1), v = q(ye(c), l * ve), y = q(v, ve), b = t(async () => {
|
|
950
|
+
_(!1), h(void 0);
|
|
735
951
|
try {
|
|
736
952
|
let { data: e } = await n.GET("/web/businesses/{businessId}/availability", { params: {
|
|
737
953
|
path: { businessId: i.id },
|
|
738
954
|
query: {
|
|
739
|
-
from: `${
|
|
740
|
-
to: `${
|
|
741
|
-
...a && { eventTypeId: a }
|
|
955
|
+
from: `${v}T00:00`,
|
|
956
|
+
to: `${y}T00:00`,
|
|
957
|
+
...a && { eventTypeId: a },
|
|
958
|
+
...o && { resourceId: o }
|
|
742
959
|
}
|
|
743
960
|
} });
|
|
744
|
-
|
|
961
|
+
h(e?.items ?? []);
|
|
745
962
|
} catch {
|
|
746
|
-
|
|
963
|
+
_(!0);
|
|
747
964
|
}
|
|
748
965
|
}, [
|
|
749
966
|
n,
|
|
750
967
|
i.id,
|
|
751
968
|
a,
|
|
752
|
-
|
|
753
|
-
v
|
|
969
|
+
o,
|
|
970
|
+
v,
|
|
971
|
+
y
|
|
754
972
|
]);
|
|
755
973
|
r(() => {
|
|
756
|
-
|
|
757
|
-
}, [
|
|
758
|
-
let
|
|
759
|
-
for (let e of
|
|
760
|
-
if (Date.parse(e.startsAt) <=
|
|
761
|
-
let t =
|
|
762
|
-
|
|
974
|
+
b();
|
|
975
|
+
}, [b]);
|
|
976
|
+
let S = Date.now(), C = /* @__PURE__ */ new Map();
|
|
977
|
+
for (let e of m ?? []) {
|
|
978
|
+
if (Date.parse(e.startsAt) <= S) continue;
|
|
979
|
+
let t = M(e.startsAt, e.timezone);
|
|
980
|
+
C.set(t, [...C.get(t) ?? [], e]);
|
|
763
981
|
}
|
|
764
|
-
let
|
|
765
|
-
from:
|
|
766
|
-
to:
|
|
982
|
+
let w = T("business.weekOf", {
|
|
983
|
+
from: j(`${v}T12:00:00Z`, "UTC"),
|
|
984
|
+
to: j(`${q(y, -1)}T12:00:00Z`, "UTC")
|
|
767
985
|
});
|
|
768
|
-
return /* @__PURE__ */
|
|
986
|
+
return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("fieldset", {
|
|
769
987
|
className: "cp-week",
|
|
770
|
-
"aria-label":
|
|
988
|
+
"aria-label": T("business.week"),
|
|
771
989
|
children: [
|
|
772
|
-
/* @__PURE__ */
|
|
990
|
+
/* @__PURE__ */ f("button", {
|
|
773
991
|
type: "button",
|
|
774
992
|
className: "cp-secondary",
|
|
775
|
-
disabled:
|
|
776
|
-
onClick: () =>
|
|
777
|
-
"aria-label":
|
|
993
|
+
disabled: l === 0,
|
|
994
|
+
onClick: () => u((e) => e - 1),
|
|
995
|
+
"aria-label": T("business.previousWeek"),
|
|
778
996
|
children: "‹"
|
|
779
997
|
}),
|
|
780
|
-
/* @__PURE__ */
|
|
781
|
-
/* @__PURE__ */
|
|
998
|
+
/* @__PURE__ */ f("span", { children: w }),
|
|
999
|
+
/* @__PURE__ */ f("button", {
|
|
782
1000
|
type: "button",
|
|
783
1001
|
className: "cp-secondary",
|
|
784
|
-
onClick: () =>
|
|
785
|
-
"aria-label":
|
|
1002
|
+
onClick: () => u((e) => e + 1),
|
|
1003
|
+
"aria-label": T("business.nextWeek"),
|
|
786
1004
|
children: "›"
|
|
787
1005
|
})
|
|
788
1006
|
]
|
|
789
|
-
}),
|
|
1007
|
+
}), g ? /* @__PURE__ */ f(I, { onRetry: b }) : m ? C.size === 0 ? /* @__PURE__ */ f("p", {
|
|
790
1008
|
className: "cp-empty",
|
|
791
|
-
children:
|
|
792
|
-
}) : [...
|
|
1009
|
+
children: T("business.empty")
|
|
1010
|
+
}) : [...C].map(([t, n]) => /* @__PURE__ */ p("div", {
|
|
793
1011
|
className: "cp-day",
|
|
794
|
-
children: [/* @__PURE__ */
|
|
1012
|
+
children: [/* @__PURE__ */ f("h2", { children: t }), /* @__PURE__ */ f("ul", {
|
|
795
1013
|
className: "cp-list",
|
|
796
|
-
children: n.map((t) => /* @__PURE__ */
|
|
1014
|
+
children: n.map((t) => /* @__PURE__ */ f(Ee, {
|
|
797
1015
|
candidate: t,
|
|
798
1016
|
onChoose: () => e.onChoose(t)
|
|
799
1017
|
}, `${t.eventId ?? t.eventTypeId}-${t.resource?.id ?? ""}-${t.startsAt}`))
|
|
800
1018
|
})]
|
|
801
|
-
}, t)) : /* @__PURE__ */
|
|
1019
|
+
}, t)) : /* @__PURE__ */ f("p", {
|
|
802
1020
|
role: "status",
|
|
803
|
-
children:
|
|
1021
|
+
children: T("app.loading")
|
|
804
1022
|
})] });
|
|
805
1023
|
}
|
|
806
|
-
function
|
|
1024
|
+
function Ee(e) {
|
|
807
1025
|
let { candidate: t } = e, n = t.kind === "slot";
|
|
808
|
-
return /* @__PURE__ */
|
|
1026
|
+
return /* @__PURE__ */ p("li", {
|
|
809
1027
|
className: "cp-card cp-candidate",
|
|
810
1028
|
"data-kind": t.kind,
|
|
811
1029
|
children: [
|
|
812
|
-
/* @__PURE__ */
|
|
1030
|
+
/* @__PURE__ */ p("p", {
|
|
813
1031
|
className: "cp-time",
|
|
814
1032
|
children: [
|
|
815
|
-
|
|
1033
|
+
A(t.startsAt, t.timezone),
|
|
816
1034
|
" – ",
|
|
817
|
-
|
|
1035
|
+
A(t.endsAt, t.timezone)
|
|
818
1036
|
]
|
|
819
1037
|
}),
|
|
820
|
-
/* @__PURE__ */
|
|
1038
|
+
/* @__PURE__ */ p("div", {
|
|
821
1039
|
className: "cp-candidate-body",
|
|
822
1040
|
children: [
|
|
823
|
-
/* @__PURE__ */
|
|
824
|
-
t.resource && /* @__PURE__ */
|
|
1041
|
+
/* @__PURE__ */ f("h3", { children: t.title }),
|
|
1042
|
+
t.resource && /* @__PURE__ */ f("p", {
|
|
825
1043
|
className: "cp-hint",
|
|
826
|
-
children:
|
|
1044
|
+
children: T("business.with", { resource: t.resource.displayName })
|
|
827
1045
|
}),
|
|
828
|
-
/* @__PURE__ */
|
|
1046
|
+
/* @__PURE__ */ f("p", {
|
|
829
1047
|
className: "cp-hint",
|
|
830
|
-
children: n ?
|
|
1048
|
+
children: n ? T("business.openTime") : t.full ? T("business.full") : D("business.seatsLeft", t.seatsLeft)
|
|
831
1049
|
})
|
|
832
1050
|
]
|
|
833
1051
|
}),
|
|
834
|
-
!t.full && /* @__PURE__ */
|
|
1052
|
+
!t.full && /* @__PURE__ */ f("button", {
|
|
835
1053
|
type: "button",
|
|
836
1054
|
onClick: e.onChoose,
|
|
837
|
-
children:
|
|
1055
|
+
children: T("business.book")
|
|
838
1056
|
})
|
|
839
1057
|
]
|
|
840
1058
|
});
|
|
841
1059
|
}
|
|
842
1060
|
// src/screens/businesses.tsx
|
|
843
|
-
function
|
|
844
|
-
let { businesses: e, businessesStatus: t, reloadBusinesses: n, navigate: r } =
|
|
845
|
-
return /* @__PURE__ */
|
|
1061
|
+
function De() {
|
|
1062
|
+
let { businesses: e, businessesStatus: t, reloadBusinesses: n, navigate: r } = x(), i = [...e.values()];
|
|
1063
|
+
return /* @__PURE__ */ p("section", {
|
|
846
1064
|
className: "cp-screen",
|
|
847
|
-
children: [/* @__PURE__ */
|
|
1065
|
+
children: [/* @__PURE__ */ f("h1", { children: T("businesses.heading") }), t === "failed" ? /* @__PURE__ */ f(I, { onRetry: n }) : t === "loading" ? /* @__PURE__ */ f("p", {
|
|
848
1066
|
role: "status",
|
|
849
|
-
children:
|
|
850
|
-
}) : i.length === 0 ? /* @__PURE__ */
|
|
1067
|
+
children: T("app.loading")
|
|
1068
|
+
}) : i.length === 0 ? /* @__PURE__ */ f("p", {
|
|
851
1069
|
className: "cp-empty",
|
|
852
|
-
children:
|
|
853
|
-
}) : /* @__PURE__ */
|
|
1070
|
+
children: T("businesses.empty")
|
|
1071
|
+
}) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", {
|
|
854
1072
|
className: "cp-hint",
|
|
855
|
-
children:
|
|
856
|
-
}), /* @__PURE__ */
|
|
1073
|
+
children: T("businesses.intro")
|
|
1074
|
+
}), /* @__PURE__ */ f("ul", {
|
|
857
1075
|
className: "cp-list",
|
|
858
|
-
children: i.map((e) => /* @__PURE__ */
|
|
1076
|
+
children: i.map((e) => /* @__PURE__ */ p("li", {
|
|
859
1077
|
className: "cp-card cp-business",
|
|
860
1078
|
children: [
|
|
861
|
-
/* @__PURE__ */
|
|
862
|
-
|
|
863
|
-
|
|
1079
|
+
/* @__PURE__ */ f(K, {
|
|
1080
|
+
image: e.logo,
|
|
1081
|
+
alt: "",
|
|
1082
|
+
size: "small",
|
|
1083
|
+
className: "cp-logo"
|
|
1084
|
+
}),
|
|
1085
|
+
/* @__PURE__ */ f("h2", { children: e.displayName }),
|
|
1086
|
+
e.address && /* @__PURE__ */ f("p", { children: e.address }),
|
|
1087
|
+
/* @__PURE__ */ f("button", {
|
|
864
1088
|
type: "button",
|
|
865
1089
|
onClick: () => r({ businessId: e.id }),
|
|
866
|
-
children:
|
|
1090
|
+
children: T("businesses.open")
|
|
867
1091
|
})
|
|
868
1092
|
]
|
|
869
1093
|
}, e.id))
|
|
@@ -871,14 +1095,14 @@ function pe() {
|
|
|
871
1095
|
});
|
|
872
1096
|
}
|
|
873
1097
|
// src/screens/details.tsx
|
|
874
|
-
function
|
|
875
|
-
let { client: e, signOut: n } =
|
|
876
|
-
|
|
1098
|
+
function Oe() {
|
|
1099
|
+
let { client: e, signOut: n } = x(), [i, a] = s(), [o, c] = s(""), [l, u] = s(!1), [m, h] = s(!1), [g, _] = s(), v = t(async () => {
|
|
1100
|
+
u(!1);
|
|
877
1101
|
try {
|
|
878
1102
|
let { data: t } = await e.GET("/web/me");
|
|
879
1103
|
t && (a(t), c(t.name));
|
|
880
1104
|
} catch {
|
|
881
|
-
|
|
1105
|
+
u(!0);
|
|
882
1106
|
}
|
|
883
1107
|
}, [e]);
|
|
884
1108
|
r(() => {
|
|
@@ -903,7 +1127,7 @@ function me() {
|
|
|
903
1127
|
h(!1);
|
|
904
1128
|
}
|
|
905
1129
|
}
|
|
906
|
-
async function
|
|
1130
|
+
async function b() {
|
|
907
1131
|
h(!0), _(void 0);
|
|
908
1132
|
try {
|
|
909
1133
|
await e.DELETE("/web/me/sessions"), await n("app.signedOutEverywhere");
|
|
@@ -914,61 +1138,61 @@ function me() {
|
|
|
914
1138
|
}), h(!1);
|
|
915
1139
|
}
|
|
916
1140
|
}
|
|
917
|
-
return /* @__PURE__ */
|
|
1141
|
+
return /* @__PURE__ */ p("section", {
|
|
918
1142
|
className: "cp-screen",
|
|
919
|
-
children: [/* @__PURE__ */
|
|
1143
|
+
children: [/* @__PURE__ */ f("h1", { children: T("details.heading") }), l ? /* @__PURE__ */ f(I, { onRetry: v }) : i ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("form", {
|
|
920
1144
|
className: "cp-card cp-form",
|
|
921
1145
|
onSubmit: y,
|
|
922
1146
|
"aria-busy": m,
|
|
923
1147
|
children: [
|
|
924
|
-
/* @__PURE__ */
|
|
1148
|
+
/* @__PURE__ */ p("label", { children: [T("details.name"), /* @__PURE__ */ f("input", {
|
|
925
1149
|
value: o,
|
|
926
1150
|
onChange: (e) => c(e.target.value),
|
|
927
1151
|
autoComplete: "name",
|
|
928
1152
|
maxLength: 200,
|
|
929
1153
|
required: !0
|
|
930
1154
|
})] }),
|
|
931
|
-
/* @__PURE__ */
|
|
932
|
-
/* @__PURE__ */
|
|
933
|
-
/* @__PURE__ */
|
|
934
|
-
/* @__PURE__ */
|
|
935
|
-
/* @__PURE__ */
|
|
1155
|
+
/* @__PURE__ */ p("dl", { children: [
|
|
1156
|
+
/* @__PURE__ */ f("dt", { children: T("details.phone") }),
|
|
1157
|
+
/* @__PURE__ */ f("dd", { children: i.phone ?? T("details.none") }),
|
|
1158
|
+
/* @__PURE__ */ f("dt", { children: T("details.email") }),
|
|
1159
|
+
/* @__PURE__ */ f("dd", { children: i.email ?? T("details.none") })
|
|
936
1160
|
] }),
|
|
937
|
-
/* @__PURE__ */
|
|
1161
|
+
/* @__PURE__ */ f("p", {
|
|
938
1162
|
className: "cp-hint",
|
|
939
|
-
children:
|
|
1163
|
+
children: T("details.readOnly")
|
|
940
1164
|
}),
|
|
941
|
-
g && /* @__PURE__ */
|
|
1165
|
+
g && /* @__PURE__ */ f("p", {
|
|
942
1166
|
role: g.alert ? "alert" : "status",
|
|
943
|
-
children:
|
|
1167
|
+
children: T(g.key)
|
|
944
1168
|
}),
|
|
945
|
-
/* @__PURE__ */
|
|
1169
|
+
/* @__PURE__ */ f("button", {
|
|
946
1170
|
type: "submit",
|
|
947
1171
|
disabled: m || !o.trim() || o.trim() === i.name,
|
|
948
|
-
children:
|
|
1172
|
+
children: T(m ? "details.saving" : "details.save")
|
|
949
1173
|
})
|
|
950
1174
|
]
|
|
951
|
-
}), /* @__PURE__ */
|
|
1175
|
+
}), /* @__PURE__ */ p("div", {
|
|
952
1176
|
className: "cp-card cp-form",
|
|
953
|
-
children: [/* @__PURE__ */
|
|
1177
|
+
children: [/* @__PURE__ */ f("p", {
|
|
954
1178
|
className: "cp-hint",
|
|
955
|
-
children:
|
|
956
|
-
}), /* @__PURE__ */
|
|
1179
|
+
children: T("details.signOutEverywhereHint")
|
|
1180
|
+
}), /* @__PURE__ */ f("button", {
|
|
957
1181
|
type: "button",
|
|
958
1182
|
className: "cp-secondary",
|
|
959
1183
|
disabled: m,
|
|
960
|
-
onClick:
|
|
961
|
-
children:
|
|
1184
|
+
onClick: b,
|
|
1185
|
+
children: T("details.signOutEverywhere")
|
|
962
1186
|
})]
|
|
963
|
-
})] }) : /* @__PURE__ */
|
|
1187
|
+
})] }) : /* @__PURE__ */ f("p", {
|
|
964
1188
|
role: "status",
|
|
965
|
-
children:
|
|
1189
|
+
children: T("app.loading")
|
|
966
1190
|
})]
|
|
967
1191
|
});
|
|
968
1192
|
}
|
|
969
1193
|
// src/screens/passes.tsx
|
|
970
|
-
function
|
|
971
|
-
let { client: e, businesses: n } =
|
|
1194
|
+
function ke() {
|
|
1195
|
+
let { client: e, businesses: n } = x(), [i, a] = s(), [o, c] = s(!1), l = t(async () => {
|
|
972
1196
|
c(!1);
|
|
973
1197
|
try {
|
|
974
1198
|
let { data: t } = await e.GET("/web/me/memberships");
|
|
@@ -979,63 +1203,63 @@ function he() {
|
|
|
979
1203
|
}, [e]);
|
|
980
1204
|
return r(() => {
|
|
981
1205
|
l();
|
|
982
|
-
}, [l]), /* @__PURE__ */
|
|
1206
|
+
}, [l]), /* @__PURE__ */ p("section", {
|
|
983
1207
|
className: "cp-screen",
|
|
984
|
-
children: [/* @__PURE__ */
|
|
1208
|
+
children: [/* @__PURE__ */ f("h1", { children: T("passes.heading") }), o ? /* @__PURE__ */ f(I, { onRetry: l }) : i ? i.length === 0 ? /* @__PURE__ */ f("p", {
|
|
985
1209
|
className: "cp-empty",
|
|
986
|
-
children:
|
|
987
|
-
}) : /* @__PURE__ */
|
|
1210
|
+
children: T("passes.empty")
|
|
1211
|
+
}) : /* @__PURE__ */ f("ul", {
|
|
988
1212
|
className: "cp-list",
|
|
989
1213
|
children: i.map((e) => {
|
|
990
1214
|
let t = n.get(e.businessId), r = t?.timezone, i = e.validUntil !== null && Date.parse(e.validUntil) <= Date.now();
|
|
991
|
-
return /* @__PURE__ */
|
|
1215
|
+
return /* @__PURE__ */ p("li", {
|
|
992
1216
|
className: "cp-card",
|
|
993
1217
|
children: [
|
|
994
|
-
/* @__PURE__ */
|
|
1218
|
+
/* @__PURE__ */ p("div", {
|
|
995
1219
|
className: "cp-card-head",
|
|
996
|
-
children: [/* @__PURE__ */
|
|
1220
|
+
children: [/* @__PURE__ */ f("h2", { children: e.displayName }), i && /* @__PURE__ */ f("span", {
|
|
997
1221
|
className: "cp-badge",
|
|
998
|
-
children:
|
|
1222
|
+
children: T("passes.expired")
|
|
999
1223
|
})]
|
|
1000
1224
|
}),
|
|
1001
|
-
t && /* @__PURE__ */
|
|
1002
|
-
/* @__PURE__ */
|
|
1225
|
+
t && /* @__PURE__ */ f("p", { children: t.displayName }),
|
|
1226
|
+
/* @__PURE__ */ f("p", {
|
|
1003
1227
|
className: "cp-credits",
|
|
1004
|
-
children: e.creditsRemaining === null || e.creditsTotal === null ?
|
|
1228
|
+
children: e.creditsRemaining === null || e.creditsTotal === null ? T("passes.unlimited") : T("passes.credits", {
|
|
1005
1229
|
remaining: e.creditsRemaining,
|
|
1006
1230
|
total: e.creditsTotal
|
|
1007
1231
|
})
|
|
1008
1232
|
}),
|
|
1009
|
-
/* @__PURE__ */
|
|
1233
|
+
/* @__PURE__ */ f("p", {
|
|
1010
1234
|
className: "cp-hint",
|
|
1011
|
-
children: e.validUntil ?
|
|
1012
|
-
from:
|
|
1013
|
-
until:
|
|
1014
|
-
}) :
|
|
1235
|
+
children: e.validUntil ? T("passes.validRange", {
|
|
1236
|
+
from: j(e.validFrom, r),
|
|
1237
|
+
until: j(e.validUntil, r)
|
|
1238
|
+
}) : T("passes.validFrom", { date: j(e.validFrom, r) })
|
|
1015
1239
|
})
|
|
1016
1240
|
]
|
|
1017
1241
|
}, e.id);
|
|
1018
1242
|
})
|
|
1019
|
-
}) : /* @__PURE__ */
|
|
1243
|
+
}) : /* @__PURE__ */ f("p", {
|
|
1020
1244
|
role: "status",
|
|
1021
|
-
children:
|
|
1245
|
+
children: T("app.loading")
|
|
1022
1246
|
})]
|
|
1023
1247
|
});
|
|
1024
1248
|
}
|
|
1025
1249
|
// ../ui/dist/index.js
|
|
1026
|
-
var
|
|
1250
|
+
var Ae = new Intl.DisplayNames(["en"], { type: "region" }), je = (e) => e.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().trim(), Y = h().map((e) => ({
|
|
1027
1251
|
code: e,
|
|
1028
|
-
name:
|
|
1029
|
-
callingCode:
|
|
1252
|
+
name: Ae.of(e) ?? e,
|
|
1253
|
+
callingCode: g(e),
|
|
1030
1254
|
flag: String.fromCodePoint(...[...e].map((e) => 127397 + e.charCodeAt(0)))
|
|
1031
|
-
})).sort((e, t) => e.name.localeCompare(t.name)),
|
|
1032
|
-
function
|
|
1033
|
-
let t = i(), n = o(null), a = o(null), c = o(null), [l, u] = s(""),
|
|
1255
|
+
})).sort((e, t) => e.name.localeCompare(t.name)), Me = new Map(Y.map((e) => [e.code, e])), Ne = (e) => Me.get(e);
|
|
1256
|
+
function Pe(e) {
|
|
1257
|
+
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) => {
|
|
1034
1258
|
m(), e.onPick(t);
|
|
1035
1259
|
};
|
|
1036
1260
|
return r(() => {
|
|
1037
1261
|
n.current?.showModal(), a.current?.focus(), document.getElementById(`${t}-${e.selected}`)?.scrollIntoView({ block: "center" });
|
|
1038
|
-
}, [t, e.selected]), /* @__PURE__ */
|
|
1262
|
+
}, [t, e.selected]), /* @__PURE__ */ p("dialog", {
|
|
1039
1263
|
ref: n,
|
|
1040
1264
|
className: "msm-picker-dialog",
|
|
1041
1265
|
"aria-labelledby": `${t}-title`,
|
|
@@ -1044,18 +1268,18 @@ function ve(e) {
|
|
|
1044
1268
|
e.target === n.current && m();
|
|
1045
1269
|
},
|
|
1046
1270
|
children: [
|
|
1047
|
-
/* @__PURE__ */
|
|
1271
|
+
/* @__PURE__ */ p("div", {
|
|
1048
1272
|
className: "msm-picker-head",
|
|
1049
|
-
children: [/* @__PURE__ */
|
|
1273
|
+
children: [/* @__PURE__ */ f("h2", {
|
|
1050
1274
|
id: `${t}-title`,
|
|
1051
1275
|
children: e.title
|
|
1052
|
-
}), /* @__PURE__ */
|
|
1276
|
+
}), /* @__PURE__ */ f("button", {
|
|
1053
1277
|
type: "button",
|
|
1054
1278
|
onClick: m,
|
|
1055
1279
|
children: "Close"
|
|
1056
1280
|
})]
|
|
1057
1281
|
}),
|
|
1058
|
-
/* @__PURE__ */
|
|
1282
|
+
/* @__PURE__ */ f("input", {
|
|
1059
1283
|
ref: a,
|
|
1060
1284
|
className: "msm-picker-search",
|
|
1061
1285
|
type: "search",
|
|
@@ -1068,45 +1292,45 @@ function ve(e) {
|
|
|
1068
1292
|
u(e.target.value), c.current && (c.current.scrollTop = 0);
|
|
1069
1293
|
},
|
|
1070
1294
|
onKeyDown: (e) => {
|
|
1071
|
-
e.key === "Enter" && (e.preventDefault(), l.trim() !== "" &&
|
|
1295
|
+
e.key === "Enter" && (e.preventDefault(), l.trim() !== "" && d[0] && h(d[0].value));
|
|
1072
1296
|
}
|
|
1073
1297
|
}),
|
|
1074
|
-
/* @__PURE__ */
|
|
1298
|
+
/* @__PURE__ */ f("ul", {
|
|
1075
1299
|
ref: c,
|
|
1076
1300
|
"aria-label": e.listLabel,
|
|
1077
|
-
children:
|
|
1301
|
+
children: d.map((n, r) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ p("button", {
|
|
1078
1302
|
type: "button",
|
|
1079
1303
|
id: `${t}-${n.value}`,
|
|
1080
1304
|
"aria-current": n.value === e.selected || void 0,
|
|
1081
1305
|
className: r === 0 && l.trim() !== "" ? "msm-picker-first" : void 0,
|
|
1082
1306
|
onClick: () => h(n.value),
|
|
1083
1307
|
children: [
|
|
1084
|
-
n.flag && /* @__PURE__ */
|
|
1308
|
+
n.flag && /* @__PURE__ */ f("span", {
|
|
1085
1309
|
"aria-hidden": "true",
|
|
1086
1310
|
children: n.flag
|
|
1087
1311
|
}),
|
|
1088
|
-
/* @__PURE__ */
|
|
1312
|
+
/* @__PURE__ */ f("span", {
|
|
1089
1313
|
className: "msm-picker-label",
|
|
1090
1314
|
children: n.label
|
|
1091
1315
|
}),
|
|
1092
|
-
n.hint && /* @__PURE__ */
|
|
1316
|
+
n.hint && /* @__PURE__ */ f("span", {
|
|
1093
1317
|
className: "msm-picker-hint",
|
|
1094
1318
|
children: n.hint
|
|
1095
1319
|
})
|
|
1096
1320
|
]
|
|
1097
1321
|
}) }, n.value))
|
|
1098
1322
|
}),
|
|
1099
|
-
|
|
1323
|
+
d.length === 0 && /* @__PURE__ */ f("p", {
|
|
1100
1324
|
className: "msm-picker-empty",
|
|
1101
1325
|
children: e.empty(l)
|
|
1102
1326
|
})
|
|
1103
1327
|
]
|
|
1104
1328
|
});
|
|
1105
1329
|
}
|
|
1106
|
-
var
|
|
1107
|
-
function
|
|
1330
|
+
var Fe = new m(), X = (e) => Ne(e);
|
|
1331
|
+
function Ie(e) {
|
|
1108
1332
|
for (let t = 1; t <= 3 && t <= e.length; t++) {
|
|
1109
|
-
let n = e.slice(0, t), r = (
|
|
1333
|
+
let n = e.slice(0, t), r = (y.country_calling_codes[n] ?? []).filter((e) => Ne(e) !== void 0), [i] = r;
|
|
1110
1334
|
if (i) return {
|
|
1111
1335
|
code: n,
|
|
1112
1336
|
first: i,
|
|
@@ -1115,97 +1339,97 @@ function Z(e) {
|
|
|
1115
1339
|
}
|
|
1116
1340
|
return null;
|
|
1117
1341
|
}
|
|
1118
|
-
function
|
|
1342
|
+
function Le(e, t) {
|
|
1119
1343
|
let n = /^\s*(\+|00)/.exec(e);
|
|
1120
1344
|
if (!n) return null;
|
|
1121
|
-
let r = e.slice(n[0].length), i = r.replace(/\D/g, ""), a =
|
|
1345
|
+
let r = e.slice(n[0].length), i = r.replace(/\D/g, ""), a = Ie(i);
|
|
1122
1346
|
if (!a) return null;
|
|
1123
|
-
let o =
|
|
1347
|
+
let o = _(`+${i}`), s = a.countries.includes(t) ? t : o?.country ?? a.first, c = 0;
|
|
1124
1348
|
for (let e = 0; e < a.code.length; c++) /\d/.test(r.charAt(c)) && e++;
|
|
1125
1349
|
return {
|
|
1126
1350
|
country: s,
|
|
1127
1351
|
text: o?.isValid() ? o.formatNational() : r.slice(c).replace(/^[\s\-().]+/, "")
|
|
1128
1352
|
};
|
|
1129
1353
|
}
|
|
1130
|
-
function
|
|
1354
|
+
function Re(e, t) {
|
|
1131
1355
|
let n = t.replace(/\D/g, "");
|
|
1132
|
-
return n === "" ? "" : t.trim().startsWith("+") ? `+${n}` :
|
|
1356
|
+
return n === "" ? "" : t.trim().startsWith("+") ? `+${n}` : _(t, e)?.number ?? `+${X(e).callingCode}${n}`;
|
|
1133
1357
|
}
|
|
1134
|
-
function
|
|
1135
|
-
return
|
|
1358
|
+
function ze(e) {
|
|
1359
|
+
return Fe.selectNumberingPlan(e), Fe.numberingPlan?.possibleLengths() ?? [];
|
|
1136
1360
|
}
|
|
1137
|
-
function
|
|
1361
|
+
function Be(e, t, n) {
|
|
1138
1362
|
if (e === "") return t ? "Enter a phone number." : "";
|
|
1139
|
-
let r =
|
|
1363
|
+
let r = _(e);
|
|
1140
1364
|
if (r?.isValid()) return "";
|
|
1141
|
-
let i = e.replace(/\D/g, ""), a =
|
|
1365
|
+
let i = e.replace(/\D/g, ""), a = Ie(i);
|
|
1142
1366
|
if (!a) return "Unknown country code. Choose the country from the list.";
|
|
1143
|
-
let o = n && a.countries.includes(n) ? n : r?.country ?? a.first, s = X(o).name, c =
|
|
1367
|
+
let o = n && a.countries.includes(n) ? n : r?.country ?? a.first, s = X(o).name, c = v(i.slice(a.code.length), o);
|
|
1144
1368
|
if (c && c !== "NOT_A_NUMBER") {
|
|
1145
|
-
let e =
|
|
1369
|
+
let e = ze(o), t = e[0] ?? 0, n = e[e.length - 1] ?? 0;
|
|
1146
1370
|
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}.`;
|
|
1147
1371
|
}
|
|
1148
1372
|
return `This is not a valid number for ${s}.`;
|
|
1149
1373
|
}
|
|
1150
|
-
function
|
|
1151
|
-
return
|
|
1374
|
+
function Ve(e, t = !1) {
|
|
1375
|
+
return Be(e, t);
|
|
1152
1376
|
}
|
|
1153
|
-
function
|
|
1154
|
-
return
|
|
1377
|
+
function He(e, t) {
|
|
1378
|
+
return Le(e, t) ?? {
|
|
1155
1379
|
country: t,
|
|
1156
1380
|
text: e
|
|
1157
1381
|
};
|
|
1158
1382
|
}
|
|
1159
|
-
function
|
|
1383
|
+
function Ue(e) {
|
|
1160
1384
|
let t = i(), n = o(null), [a, c] = s(() => ({
|
|
1161
1385
|
value: e.value,
|
|
1162
|
-
...
|
|
1386
|
+
...He(e.value, "IS")
|
|
1163
1387
|
})), l = a;
|
|
1164
1388
|
e.value !== a.value && (l = {
|
|
1165
1389
|
value: e.value,
|
|
1166
|
-
...
|
|
1390
|
+
...He(e.value, a.country)
|
|
1167
1391
|
}, c(l));
|
|
1168
|
-
let [u,
|
|
1392
|
+
let [u, d] = s(!1), [m, h] = s(!1), g = X(l.country), _ = Be(l.value, e.required ?? !1, l.country), v = u && _ !== "" ? _ : e.error ?? "", y = v !== "";
|
|
1169
1393
|
r(() => {
|
|
1170
1394
|
let e = n.current?.form;
|
|
1171
1395
|
if (!e) return;
|
|
1172
1396
|
let t = () => {
|
|
1173
|
-
|
|
1397
|
+
d(!0), e.querySelector("[data-msm-phone-problem]") === n.current && n.current?.focus();
|
|
1174
1398
|
};
|
|
1175
1399
|
return e.addEventListener("submit", t), () => e.removeEventListener("submit", t);
|
|
1176
1400
|
}, []);
|
|
1177
1401
|
let b = (t, n) => {
|
|
1178
|
-
let r =
|
|
1402
|
+
let r = Re(t, n);
|
|
1179
1403
|
c({
|
|
1180
1404
|
value: r,
|
|
1181
1405
|
country: t,
|
|
1182
1406
|
text: n
|
|
1183
1407
|
}), r !== e.value && e.onChange(r);
|
|
1184
1408
|
};
|
|
1185
|
-
return /* @__PURE__ */
|
|
1409
|
+
return /* @__PURE__ */ p("div", {
|
|
1186
1410
|
className: "msm-phone",
|
|
1187
1411
|
children: [
|
|
1188
|
-
/* @__PURE__ */
|
|
1412
|
+
/* @__PURE__ */ f("label", {
|
|
1189
1413
|
htmlFor: `${t}-number`,
|
|
1190
1414
|
children: e.label
|
|
1191
1415
|
}),
|
|
1192
|
-
/* @__PURE__ */
|
|
1416
|
+
/* @__PURE__ */ p("div", {
|
|
1193
1417
|
className: "msm-phone-row",
|
|
1194
|
-
children: [/* @__PURE__ */
|
|
1418
|
+
children: [/* @__PURE__ */ p("button", {
|
|
1195
1419
|
type: "button",
|
|
1196
1420
|
className: "msm-phone-country",
|
|
1197
1421
|
"aria-label": `Country code: ${g.name} +${g.callingCode}`,
|
|
1198
1422
|
"aria-haspopup": "dialog",
|
|
1199
1423
|
onClick: () => h(!0),
|
|
1200
1424
|
children: [
|
|
1201
|
-
/* @__PURE__ */
|
|
1425
|
+
/* @__PURE__ */ f("span", {
|
|
1202
1426
|
"aria-hidden": "true",
|
|
1203
1427
|
children: g.flag
|
|
1204
1428
|
}),
|
|
1205
1429
|
"+",
|
|
1206
1430
|
g.callingCode
|
|
1207
1431
|
]
|
|
1208
|
-
}), /* @__PURE__ */
|
|
1432
|
+
}), /* @__PURE__ */ f("input", {
|
|
1209
1433
|
ref: n,
|
|
1210
1434
|
id: `${t}-number`,
|
|
1211
1435
|
className: "msm-phone-number",
|
|
@@ -1218,26 +1442,26 @@ function we(e) {
|
|
|
1218
1442
|
"aria-invalid": y || void 0,
|
|
1219
1443
|
"aria-describedby": y ? `${t}-problem` : void 0,
|
|
1220
1444
|
onChange: (e) => {
|
|
1221
|
-
let t = e.target.value.replace(/[^\d\s\-().+]/g, ""), n =
|
|
1445
|
+
let t = e.target.value.replace(/[^\d\s\-().+]/g, ""), n = Le(t, l.country);
|
|
1222
1446
|
b(n?.country ?? l.country, n?.text ?? t);
|
|
1223
1447
|
},
|
|
1224
1448
|
onBlur: () => {
|
|
1225
|
-
l.text.trim() !== "" &&
|
|
1449
|
+
l.text.trim() !== "" && d(!0);
|
|
1226
1450
|
}
|
|
1227
1451
|
})]
|
|
1228
1452
|
}),
|
|
1229
|
-
y && /* @__PURE__ */
|
|
1453
|
+
y && /* @__PURE__ */ f("p", {
|
|
1230
1454
|
id: `${t}-problem`,
|
|
1231
1455
|
className: "msm-phone-problem",
|
|
1232
1456
|
role: "alert",
|
|
1233
1457
|
children: v
|
|
1234
1458
|
}),
|
|
1235
|
-
m && /* @__PURE__ */
|
|
1459
|
+
m && /* @__PURE__ */ f(Pe, {
|
|
1236
1460
|
title: "Country code",
|
|
1237
1461
|
searchLabel: "Search by country or code",
|
|
1238
1462
|
listLabel: "Countries",
|
|
1239
1463
|
empty: (e) => `No country matches “${e}”.`,
|
|
1240
|
-
search:
|
|
1464
|
+
search: We,
|
|
1241
1465
|
selected: l.country,
|
|
1242
1466
|
onClose: () => h(!1),
|
|
1243
1467
|
onPick: (e) => {
|
|
@@ -1247,9 +1471,9 @@ function we(e) {
|
|
|
1247
1471
|
]
|
|
1248
1472
|
});
|
|
1249
1473
|
}
|
|
1250
|
-
function
|
|
1251
|
-
let t =
|
|
1252
|
-
return (t === "" ?
|
|
1474
|
+
function We(e) {
|
|
1475
|
+
let t = je(e).replace(/^(\+|00)/, "");
|
|
1476
|
+
return (t === "" ? Y : /^\d+$/.test(t) ? Y.filter((e) => e.callingCode.startsWith(t)) : Y.filter((e) => je(e.name).includes(t) || e.code.toLowerCase() === t)).map((e) => ({
|
|
1253
1477
|
value: e.code,
|
|
1254
1478
|
label: e.name,
|
|
1255
1479
|
hint: `+${e.callingCode}`,
|
|
@@ -1257,31 +1481,31 @@ function Te(e) {
|
|
|
1257
1481
|
}));
|
|
1258
1482
|
}
|
|
1259
1483
|
// src/bot-check.tsx
|
|
1260
|
-
var
|
|
1261
|
-
function
|
|
1262
|
-
let e =
|
|
1263
|
-
return e ? Promise.resolve(e) : (
|
|
1484
|
+
var Ge = () => window.turnstile, Ke = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit", Z;
|
|
1485
|
+
function qe() {
|
|
1486
|
+
let e = Ge();
|
|
1487
|
+
return e ? Promise.resolve(e) : (Z ??= new Promise((e, t) => {
|
|
1264
1488
|
let n = document.createElement("script");
|
|
1265
|
-
n.src =
|
|
1489
|
+
n.src = Ke, n.async = !0;
|
|
1266
1490
|
let r = () => {
|
|
1267
|
-
|
|
1491
|
+
Z = void 0, n.remove(), t(/* @__PURE__ */ Error("Turnstile did not load."));
|
|
1268
1492
|
};
|
|
1269
1493
|
n.onload = () => {
|
|
1270
|
-
let t =
|
|
1494
|
+
let t = Ge();
|
|
1271
1495
|
t ? e(t) : r();
|
|
1272
1496
|
}, n.onerror = r, document.head.append(n);
|
|
1273
|
-
}),
|
|
1497
|
+
}), Z);
|
|
1274
1498
|
}
|
|
1275
|
-
function
|
|
1499
|
+
function Je(e) {
|
|
1276
1500
|
return e?.provider === "turnstile" && typeof e.siteKey == "string" && e.siteKey.trim() !== "";
|
|
1277
1501
|
}
|
|
1278
|
-
function
|
|
1502
|
+
function Ye(e) {
|
|
1279
1503
|
let t = o(null), n = o(void 0), i = o(e);
|
|
1280
1504
|
i.current = e;
|
|
1281
1505
|
let { siteKey: a } = e.botCheck;
|
|
1282
1506
|
r(() => {
|
|
1283
1507
|
let e = !0;
|
|
1284
|
-
return
|
|
1508
|
+
return qe().then((r) => {
|
|
1285
1509
|
let o = t.current;
|
|
1286
1510
|
if (!e || !o) return;
|
|
1287
1511
|
let s = r.render(o, {
|
|
@@ -1307,238 +1531,574 @@ function Ae(e) {
|
|
|
1307
1531
|
if (s === 0) return;
|
|
1308
1532
|
let e = n.current;
|
|
1309
1533
|
i.current.onToken(void 0), e?.api.reset(e.id);
|
|
1310
|
-
}, [s]), /* @__PURE__ */
|
|
1534
|
+
}, [s]), /* @__PURE__ */ f("div", {
|
|
1311
1535
|
className: "cp-bot-check",
|
|
1312
1536
|
ref: t
|
|
1313
1537
|
});
|
|
1314
1538
|
}
|
|
1315
1539
|
// src/sign-in.tsx
|
|
1316
|
-
function
|
|
1317
|
-
let
|
|
1540
|
+
function Q(e) {
|
|
1541
|
+
let t = o(null), n = e.autoFocus;
|
|
1318
1542
|
r(() => {
|
|
1319
|
-
|
|
1543
|
+
n && t.current?.querySelector("input")?.focus();
|
|
1544
|
+
}, [n]);
|
|
1545
|
+
let [i, a] = s("phone"), [c, l] = s(""), [u, m] = s(""), [h, g] = s(""), [_, v] = s(), [y, b] = s(), [x, S] = s(!1), [C, w] = s(), [E, D] = s(0), O = Je(e.botCheck) ? e.botCheck : void 0, [k, A] = s();
|
|
1546
|
+
r(() => {
|
|
1547
|
+
if (!k) return;
|
|
1320
1548
|
let e = setTimeout(() => {
|
|
1321
|
-
|
|
1322
|
-
},
|
|
1549
|
+
A(void 0), b((e) => e === k.message ? void 0 : e);
|
|
1550
|
+
}, k.seconds * 1e3);
|
|
1323
1551
|
return () => clearTimeout(e);
|
|
1324
|
-
}, [
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1552
|
+
}, [k]);
|
|
1553
|
+
function j(e) {
|
|
1554
|
+
a("phone"), v(void 0), g(""), l(""), b(e);
|
|
1555
|
+
}
|
|
1556
|
+
async function M(t) {
|
|
1557
|
+
if (t.preventDefault(), (i !== "phone" || !Ve(u, !0) && O && C) && (i !== "name" || c.trim())) {
|
|
1558
|
+
S(!0), b(void 0);
|
|
1329
1559
|
try {
|
|
1330
|
-
let t =
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
}) :
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
}) : await H(e.basePath, "/auth/initiate", {
|
|
1338
|
-
phone: o,
|
|
1339
|
-
botCheckToken: b
|
|
1340
|
-
});
|
|
1560
|
+
let t = i === "phone" ? await B(e.basePath, "/auth/initiate", {
|
|
1561
|
+
phone: u,
|
|
1562
|
+
botCheckToken: C
|
|
1563
|
+
}) : i === "code" ? await B(e.basePath, "/auth/login", {
|
|
1564
|
+
challenge: _,
|
|
1565
|
+
code: h
|
|
1566
|
+
}) : await B(e.basePath, "/auth/register", { name: c.trim() });
|
|
1341
1567
|
if (t.ok) {
|
|
1342
1568
|
let n = await t.json();
|
|
1343
|
-
|
|
1569
|
+
i === "phone" ? (v(n.challenge), a("code")) : n.result === "nameRequired" ? a("name") : e.onSignedIn(n.sessionKey);
|
|
1570
|
+
return;
|
|
1571
|
+
}
|
|
1572
|
+
let n = await t.json().catch(() => void 0);
|
|
1573
|
+
if (i === "name" && t.status === 401) {
|
|
1574
|
+
j(T("register.error.expired"));
|
|
1344
1575
|
return;
|
|
1345
1576
|
}
|
|
1346
|
-
let
|
|
1347
|
-
t.status === 429 &&
|
|
1348
|
-
phone:
|
|
1349
|
-
seconds:
|
|
1577
|
+
let r = Number(t.headers.get("retry-after")), o = Number.isInteger(r) && r > 0 ? r : void 0, s = Xe(t.status, n?.code, o, i);
|
|
1578
|
+
t.status === 429 && o && i === "phone" && A({
|
|
1579
|
+
phone: u,
|
|
1580
|
+
seconds: o,
|
|
1350
1581
|
message: s
|
|
1351
|
-
}),
|
|
1582
|
+
}), b(s);
|
|
1352
1583
|
} catch {
|
|
1353
|
-
|
|
1584
|
+
b(T("signIn.error.unreachable"));
|
|
1354
1585
|
} finally {
|
|
1355
|
-
|
|
1586
|
+
S(!1), i === "phone" && D((e) => e + 1);
|
|
1356
1587
|
}
|
|
1357
1588
|
}
|
|
1358
1589
|
}
|
|
1359
|
-
|
|
1360
|
-
n(e), h(void 0), p(""), _(void 0);
|
|
1361
|
-
}
|
|
1362
|
-
return /* @__PURE__ */ d("div", {
|
|
1590
|
+
return /* @__PURE__ */ f("div", {
|
|
1363
1591
|
className: "cp-sign-in",
|
|
1364
|
-
children: /* @__PURE__ */
|
|
1365
|
-
|
|
1366
|
-
|
|
1592
|
+
children: /* @__PURE__ */ p("form", {
|
|
1593
|
+
ref: t,
|
|
1594
|
+
onSubmit: M,
|
|
1595
|
+
"aria-busy": x,
|
|
1367
1596
|
children: [
|
|
1368
|
-
/* @__PURE__ */
|
|
1369
|
-
/* @__PURE__ */
|
|
1597
|
+
/* @__PURE__ */ f(R, { brand: e.brand }),
|
|
1598
|
+
/* @__PURE__ */ f("h1", { children: T("signIn.heading") }),
|
|
1370
1599
|
e.children,
|
|
1371
|
-
e.notice &&
|
|
1600
|
+
e.notice && i === "phone" && /* @__PURE__ */ f("p", {
|
|
1372
1601
|
role: "status",
|
|
1373
1602
|
className: "cp-notice",
|
|
1374
|
-
children:
|
|
1603
|
+
children: T(e.notice)
|
|
1375
1604
|
}),
|
|
1376
|
-
|
|
1377
|
-
value:
|
|
1378
|
-
onChange: (e) =>
|
|
1605
|
+
i === "name" ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", { children: T("register.intro") }), /* @__PURE__ */ p("label", { children: [T("register.name"), /* @__PURE__ */ f("input", {
|
|
1606
|
+
value: c,
|
|
1607
|
+
onChange: (e) => l(e.target.value),
|
|
1608
|
+
autoComplete: "name",
|
|
1609
|
+
maxLength: 200,
|
|
1610
|
+
required: !0,
|
|
1611
|
+
autoFocus: !0
|
|
1612
|
+
})] })] }) : i === "code" ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("p", { children: T("signIn.codeSent", { phone: u }) }), /* @__PURE__ */ p("label", { children: [T("signIn.code"), /* @__PURE__ */ f("input", {
|
|
1613
|
+
value: h,
|
|
1614
|
+
onChange: (e) => g(e.target.value),
|
|
1379
1615
|
inputMode: "numeric",
|
|
1380
1616
|
autoComplete: "one-time-code",
|
|
1381
1617
|
required: !0,
|
|
1382
1618
|
autoFocus: !0
|
|
1383
|
-
})] })] }) : /* @__PURE__ */
|
|
1384
|
-
/* @__PURE__ */
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
maxLength: 200,
|
|
1390
|
-
required: !0
|
|
1391
|
-
})] }),
|
|
1392
|
-
/* @__PURE__ */ d(we, {
|
|
1393
|
-
label: w("signIn.phone"),
|
|
1394
|
-
value: o,
|
|
1395
|
-
onChange: c,
|
|
1619
|
+
})] })] }) : /* @__PURE__ */ p(d, { children: [
|
|
1620
|
+
/* @__PURE__ */ f("p", { children: T("signIn.intro") }),
|
|
1621
|
+
/* @__PURE__ */ f(Ue, {
|
|
1622
|
+
label: T("signIn.phone"),
|
|
1623
|
+
value: u,
|
|
1624
|
+
onChange: m,
|
|
1396
1625
|
required: !0
|
|
1397
1626
|
}),
|
|
1398
|
-
|
|
1399
|
-
botCheck:
|
|
1400
|
-
attempt:
|
|
1401
|
-
onToken:
|
|
1402
|
-
onUnavailable: () =>
|
|
1627
|
+
O && /* @__PURE__ */ f(Ye, {
|
|
1628
|
+
botCheck: O,
|
|
1629
|
+
attempt: E,
|
|
1630
|
+
onToken: w,
|
|
1631
|
+
onUnavailable: () => b(T("signIn.error.botCheckUnavailable"))
|
|
1403
1632
|
})
|
|
1404
1633
|
] }),
|
|
1405
|
-
|
|
1634
|
+
i === "phone" && !O && /* @__PURE__ */ f("p", {
|
|
1406
1635
|
role: "alert",
|
|
1407
|
-
children:
|
|
1636
|
+
children: T("signIn.error.notConfigured")
|
|
1408
1637
|
}),
|
|
1409
|
-
|
|
1638
|
+
y && /* @__PURE__ */ f("p", {
|
|
1410
1639
|
role: "alert",
|
|
1411
|
-
children:
|
|
1640
|
+
children: y
|
|
1412
1641
|
}),
|
|
1413
|
-
/* @__PURE__ */
|
|
1642
|
+
/* @__PURE__ */ f("button", {
|
|
1414
1643
|
type: "submit",
|
|
1415
|
-
disabled:
|
|
1416
|
-
children:
|
|
1644
|
+
disabled: x || i === "phone" && (!O || !C || k?.phone === u),
|
|
1645
|
+
children: T(x ? "signIn.wait" : i === "phone" ? "signIn.sendCode" : i === "code" ? "signIn.submit" : "register.submit")
|
|
1417
1646
|
}),
|
|
1418
|
-
|
|
1647
|
+
i !== "phone" && /* @__PURE__ */ f("button", {
|
|
1419
1648
|
type: "button",
|
|
1420
1649
|
className: "cp-secondary",
|
|
1421
|
-
onClick: () =>
|
|
1422
|
-
children:
|
|
1423
|
-
})
|
|
1650
|
+
onClick: () => j(),
|
|
1651
|
+
children: T("signIn.differentNumber")
|
|
1652
|
+
}),
|
|
1653
|
+
e.onCancel && /* @__PURE__ */ f("button", {
|
|
1424
1654
|
type: "button",
|
|
1425
|
-
className: "cp-
|
|
1426
|
-
onClick:
|
|
1427
|
-
children:
|
|
1655
|
+
className: "cp-secondary",
|
|
1656
|
+
onClick: e.onCancel,
|
|
1657
|
+
children: T("signIn.cancel")
|
|
1428
1658
|
})
|
|
1429
1659
|
]
|
|
1430
1660
|
})
|
|
1431
1661
|
});
|
|
1432
1662
|
}
|
|
1433
|
-
function
|
|
1434
|
-
|
|
1663
|
+
function Xe(e, t, n, r) {
|
|
1664
|
+
if (e === 429) return n ? T("signIn.error.tooMany", { wait: P(n) }) : T("signIn.error.tooManyLater");
|
|
1665
|
+
if (r === "name" && (e === 400 || e === 422)) return T("register.error.name");
|
|
1666
|
+
let i = r === "phone";
|
|
1667
|
+
return i && e === 403 && t === "BotCheckFailed" ? T("signIn.error.botCheck") : i && e === 503 && t === "BotCheckUnavailable" ? T("signIn.error.botCheckUnavailable") : i && e === 503 && (t === "LimiterUnavailable" || t === "ClientIpUnavailable") ? T("signIn.error.failed") : i && e === 503 ? n ? T("signIn.error.paused", { wait: P(n) }) : T("signIn.error.pausedLater") : i && e === 422 && t === "PhoneDestinationNotAllowed" ? T("signIn.error.destination") : r === "code" && [
|
|
1435
1668
|
400,
|
|
1436
1669
|
401,
|
|
1437
1670
|
403,
|
|
1438
1671
|
404,
|
|
1439
1672
|
409
|
|
1440
|
-
].includes(e) ?
|
|
1673
|
+
].includes(e) ? T("signIn.error.badCode") : T(e === 400 ? "signIn.error.invalid" : e === 403 ? "signIn.error.refused" : "signIn.error.failed");
|
|
1441
1674
|
}
|
|
1442
|
-
// src/
|
|
1443
|
-
function
|
|
1444
|
-
let n =
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1675
|
+
// src/account.tsx
|
|
1676
|
+
function Ze(e) {
|
|
1677
|
+
let [n, r] = s("bookings"), i = e.screen ?? n, a = e.onNavigate ?? r, o = t((e) => {
|
|
1678
|
+
(e === "bookings" || e === "passes" || e === "details") && a(e);
|
|
1679
|
+
}, [a]), { basePath: c, sessionKey: l, notice: u, portal: d, signedInAs: p } = W({
|
|
1680
|
+
basePath: e.basePath,
|
|
1681
|
+
navigate: o,
|
|
1682
|
+
accountNavigation: !0,
|
|
1683
|
+
onSessionChange: e.onSessionChange
|
|
1684
|
+
});
|
|
1685
|
+
return /* @__PURE__ */ f(G, {
|
|
1686
|
+
portal: d,
|
|
1687
|
+
loading: l === void 0,
|
|
1688
|
+
children: /* @__PURE__ */ f(de, {
|
|
1689
|
+
brand: e.brand,
|
|
1690
|
+
tabs: le,
|
|
1691
|
+
screen: i,
|
|
1692
|
+
signedIn: !!l,
|
|
1693
|
+
signingIn: !l,
|
|
1694
|
+
onNavigate: o,
|
|
1695
|
+
onSignOut: () => d.signOut(),
|
|
1696
|
+
children: l ? f(i === "passes" ? ke : i === "details" ? Oe : te, {}) : /* @__PURE__ */ f(Q, {
|
|
1697
|
+
basePath: c,
|
|
1698
|
+
brand: void 0,
|
|
1699
|
+
botCheck: e.botCheck,
|
|
1700
|
+
notice: u,
|
|
1701
|
+
onSignedIn: p,
|
|
1702
|
+
autoFocus: !0
|
|
1703
|
+
})
|
|
1704
|
+
})
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
// src/booking-flow.tsx
|
|
1708
|
+
function Qe(e) {
|
|
1709
|
+
return {
|
|
1710
|
+
startsAt: e.startsAt,
|
|
1711
|
+
eventTypeId: e.eventTypeId,
|
|
1712
|
+
...e.eventId && { eventId: e.eventId },
|
|
1713
|
+
...e.resource && { resourceId: e.resource.id }
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
function $(e) {
|
|
1717
|
+
return e ? [
|
|
1718
|
+
e.eventId ?? "",
|
|
1719
|
+
e.eventTypeId,
|
|
1720
|
+
Date.parse(e.startsAt),
|
|
1721
|
+
e.resourceId ?? ""
|
|
1722
|
+
].join("|") : "";
|
|
1723
|
+
}
|
|
1724
|
+
function $e(e, t) {
|
|
1725
|
+
return t.eventId ? e.eventId === t.eventId : e.eventTypeId === t.eventTypeId && Date.parse(e.startsAt) === Date.parse(t.startsAt) && (!t.resourceId || e.resource?.id === t.resourceId);
|
|
1726
|
+
}
|
|
1727
|
+
function et(e) {
|
|
1728
|
+
let n = e.onChange !== void 0, r = {
|
|
1729
|
+
businessId: e.businessId,
|
|
1730
|
+
...e.eventTypeId && { eventTypeId: e.eventTypeId },
|
|
1731
|
+
...e.resourceId && { resourceId: e.resourceId },
|
|
1732
|
+
...e.all && { all: !0 },
|
|
1733
|
+
...e.time && { time: e.time }
|
|
1734
|
+
}, i = [
|
|
1735
|
+
e.businessId,
|
|
1736
|
+
e.eventTypeId ?? "",
|
|
1737
|
+
e.resourceId ?? "",
|
|
1738
|
+
e.all ? "all" : "",
|
|
1739
|
+
$(e.time)
|
|
1740
|
+
].join("/"), [a, o] = s(r), [c, l] = s(i);
|
|
1741
|
+
!n && c !== i && (l(i), o(r));
|
|
1742
|
+
let u = n ? r : a, m = e.onChange, h = t((e) => (m ?? o)(e), [m]), g = t((e) => {
|
|
1743
|
+
typeof e == "object" && h({
|
|
1744
|
+
businessId: e.businessId,
|
|
1745
|
+
...e.eventTypeId && { eventTypeId: e.eventTypeId }
|
|
1746
|
+
});
|
|
1747
|
+
}, [h]), { basePath: _, sessionKey: v, notice: y, portal: b, signedInAs: x } = W({
|
|
1748
|
+
basePath: e.basePath,
|
|
1749
|
+
navigate: g,
|
|
1750
|
+
accountNavigation: !1,
|
|
1751
|
+
onSessionChange: e.onSessionChange
|
|
1752
|
+
}), [S, C] = s(), [w, E] = s(), D = u.time, O = $(D), k = S && D && S.business.id === u.businessId && $(Qe(S.candidate)) === O ? S : void 0, A = () => {
|
|
1753
|
+
C(void 0);
|
|
1754
|
+
let { time: e, ...t } = u;
|
|
1755
|
+
h(t);
|
|
1756
|
+
}, j = (e, t) => {
|
|
1757
|
+
C({
|
|
1758
|
+
business: e,
|
|
1759
|
+
candidate: t
|
|
1760
|
+
}), h({
|
|
1761
|
+
...u,
|
|
1762
|
+
time: Qe(t)
|
|
1763
|
+
});
|
|
1764
|
+
}, M;
|
|
1765
|
+
M = k ? v ? /* @__PURE__ */ f(ae, {
|
|
1766
|
+
choice: k,
|
|
1767
|
+
onBack: A,
|
|
1768
|
+
onBooked: e.onBooked,
|
|
1769
|
+
onDone: e.onClose
|
|
1770
|
+
}, `${k.candidate.startsAt}-${k.candidate.eventId ?? k.candidate.eventTypeId}`) : /* @__PURE__ */ p(Q, {
|
|
1771
|
+
basePath: _,
|
|
1772
|
+
brand: e.brand,
|
|
1773
|
+
botCheck: e.botCheck,
|
|
1774
|
+
notice: y,
|
|
1775
|
+
onSignedIn: x,
|
|
1776
|
+
autoFocus: !0,
|
|
1777
|
+
children: [
|
|
1778
|
+
/* @__PURE__ */ f("p", { children: T("book.signInFirst") }),
|
|
1779
|
+
/* @__PURE__ */ f(L, { choice: k }),
|
|
1780
|
+
/* @__PURE__ */ f("button", {
|
|
1781
|
+
type: "button",
|
|
1782
|
+
className: "cp-link",
|
|
1783
|
+
onClick: A,
|
|
1784
|
+
children: T("book.back")
|
|
1785
|
+
})
|
|
1786
|
+
]
|
|
1787
|
+
}) : D && w !== O ? /* @__PURE__ */ f(nt, {
|
|
1788
|
+
businessId: u.businessId,
|
|
1789
|
+
time: D,
|
|
1790
|
+
onFound: C,
|
|
1791
|
+
onMissing: () => E(O)
|
|
1792
|
+
}) : u.all ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("button", {
|
|
1793
|
+
type: "button",
|
|
1794
|
+
className: "cp-link cp-back",
|
|
1795
|
+
onClick: () => h({ businessId: u.businessId }),
|
|
1796
|
+
children: T("book.toTypes")
|
|
1797
|
+
}), /* @__PURE__ */ f(Ce, {
|
|
1798
|
+
businessId: u.businessId,
|
|
1799
|
+
eventTypeId: u.eventTypeId,
|
|
1800
|
+
resourceId: u.resourceId,
|
|
1801
|
+
onFilter: (e) => h({
|
|
1802
|
+
businessId: u.businessId,
|
|
1803
|
+
all: !0,
|
|
1804
|
+
...e
|
|
1805
|
+
}),
|
|
1806
|
+
onChoose: j
|
|
1807
|
+
})] }) : /* @__PURE__ */ f(tt, {
|
|
1808
|
+
selection: u,
|
|
1809
|
+
change: h,
|
|
1810
|
+
onChoose: j
|
|
1811
|
+
});
|
|
1812
|
+
let N = k ? v ? "booking" : "sign-in" : [
|
|
1813
|
+
u.all ? "all" : "",
|
|
1814
|
+
u.eventTypeId ?? "",
|
|
1815
|
+
u.resourceId ?? "",
|
|
1816
|
+
D && w !== O ? "time" : ""
|
|
1817
|
+
].join("/");
|
|
1818
|
+
return /* @__PURE__ */ f(G, {
|
|
1819
|
+
portal: b,
|
|
1820
|
+
loading: v === void 0,
|
|
1821
|
+
children: /* @__PURE__ */ p(it, {
|
|
1822
|
+
step: N,
|
|
1823
|
+
children: [
|
|
1824
|
+
e.onClose && /* @__PURE__ */ f("div", {
|
|
1825
|
+
className: "cp-flow-head",
|
|
1826
|
+
children: /* @__PURE__ */ f("button", {
|
|
1827
|
+
type: "button",
|
|
1828
|
+
className: "cp-secondary",
|
|
1829
|
+
onClick: e.onClose,
|
|
1830
|
+
children: T("book.close")
|
|
1831
|
+
})
|
|
1832
|
+
}),
|
|
1833
|
+
D && w === O && /* @__PURE__ */ f("p", {
|
|
1834
|
+
role: "alert",
|
|
1835
|
+
className: "cp-notice",
|
|
1836
|
+
children: T("book.unavailable")
|
|
1837
|
+
}),
|
|
1838
|
+
M
|
|
1839
|
+
]
|
|
1840
|
+
})
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
function tt(e) {
|
|
1844
|
+
let { selection: t, change: n } = e, { businessId: r, eventTypeId: i } = t, a = be(r), o = xe(a, null), { business: s, types: c } = a;
|
|
1845
|
+
if (o || !s || !c) return o;
|
|
1846
|
+
let l = /* @__PURE__ */ f(we, { business: s }), u = /* @__PURE__ */ f("button", {
|
|
1847
|
+
type: "button",
|
|
1848
|
+
className: "cp-link cp-back",
|
|
1849
|
+
onClick: () => n({ businessId: r }),
|
|
1850
|
+
children: T("book.toTypes")
|
|
1851
|
+
}), d = c.find((e) => e.id === i);
|
|
1852
|
+
if (!d) return /* @__PURE__ */ p("section", {
|
|
1853
|
+
className: "cp-screen",
|
|
1854
|
+
children: [
|
|
1855
|
+
l,
|
|
1856
|
+
i && /* @__PURE__ */ f("p", {
|
|
1857
|
+
className: "cp-empty",
|
|
1858
|
+
children: T("business.typeMissing")
|
|
1859
|
+
}),
|
|
1860
|
+
/* @__PURE__ */ f("h2", { children: T("book.chooseType") }),
|
|
1861
|
+
c.length === 0 ? /* @__PURE__ */ f("p", {
|
|
1862
|
+
className: "cp-empty",
|
|
1863
|
+
children: T("book.noTypes")
|
|
1864
|
+
}) : /* @__PURE__ */ f("ul", {
|
|
1865
|
+
className: "cp-list",
|
|
1866
|
+
children: c.map((e) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ p("button", {
|
|
1867
|
+
type: "button",
|
|
1868
|
+
className: "cp-option",
|
|
1869
|
+
onClick: () => n({
|
|
1870
|
+
businessId: r,
|
|
1871
|
+
eventTypeId: e.id
|
|
1872
|
+
}),
|
|
1873
|
+
children: [
|
|
1874
|
+
/* @__PURE__ */ f(K, {
|
|
1875
|
+
image: e.image,
|
|
1876
|
+
alt: "",
|
|
1877
|
+
size: "small",
|
|
1878
|
+
className: "cp-thumb"
|
|
1879
|
+
}),
|
|
1880
|
+
/* @__PURE__ */ f("strong", { children: e.displayName }),
|
|
1881
|
+
e.description && /* @__PURE__ */ f("span", { children: e.description }),
|
|
1882
|
+
/* @__PURE__ */ f("span", { children: T("business.minutes", { minutes: e.durationMinutes }) })
|
|
1883
|
+
]
|
|
1884
|
+
}) }, e.id))
|
|
1885
|
+
}),
|
|
1886
|
+
/* @__PURE__ */ f("button", {
|
|
1887
|
+
type: "button",
|
|
1888
|
+
className: "cp-secondary",
|
|
1889
|
+
onClick: () => n({
|
|
1890
|
+
businessId: r,
|
|
1891
|
+
all: !0
|
|
1892
|
+
}),
|
|
1893
|
+
children: T("book.seeAll")
|
|
1894
|
+
})
|
|
1895
|
+
]
|
|
1896
|
+
});
|
|
1897
|
+
let m = d.resources.length > 1, h = d.resources.find((e) => e.id === t.resourceId);
|
|
1898
|
+
return m && !h && t.resourceId !== "any" ? /* @__PURE__ */ p("section", {
|
|
1899
|
+
className: "cp-screen",
|
|
1900
|
+
children: [
|
|
1901
|
+
u,
|
|
1902
|
+
l,
|
|
1903
|
+
/* @__PURE__ */ f(J, { type: d }),
|
|
1904
|
+
/* @__PURE__ */ f("h2", { children: T("book.chooseResource") }),
|
|
1905
|
+
/* @__PURE__ */ f("ul", {
|
|
1906
|
+
className: "cp-list",
|
|
1907
|
+
children: [{
|
|
1908
|
+
id: "any",
|
|
1909
|
+
displayName: T("book.anyResource"),
|
|
1910
|
+
description: T("book.anyResourceHint"),
|
|
1911
|
+
image: null
|
|
1912
|
+
}, ...d.resources].map((e) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ p("button", {
|
|
1913
|
+
type: "button",
|
|
1914
|
+
className: "cp-option",
|
|
1915
|
+
onClick: () => n({
|
|
1916
|
+
businessId: r,
|
|
1917
|
+
eventTypeId: d.id,
|
|
1918
|
+
resourceId: e.id
|
|
1919
|
+
}),
|
|
1920
|
+
children: [
|
|
1921
|
+
/* @__PURE__ */ f(K, {
|
|
1922
|
+
image: e.image,
|
|
1923
|
+
alt: "",
|
|
1924
|
+
size: "small",
|
|
1925
|
+
className: "cp-thumb"
|
|
1926
|
+
}),
|
|
1927
|
+
/* @__PURE__ */ f("strong", { children: e.displayName }),
|
|
1928
|
+
e.description && /* @__PURE__ */ f("span", { children: e.description })
|
|
1929
|
+
]
|
|
1930
|
+
}) }, e.id))
|
|
1931
|
+
})
|
|
1932
|
+
]
|
|
1933
|
+
}) : /* @__PURE__ */ p("section", {
|
|
1934
|
+
className: "cp-screen",
|
|
1935
|
+
children: [
|
|
1936
|
+
m ? /* @__PURE__ */ f("button", {
|
|
1937
|
+
type: "button",
|
|
1938
|
+
className: "cp-link cp-back",
|
|
1939
|
+
onClick: () => n({
|
|
1940
|
+
businessId: r,
|
|
1941
|
+
eventTypeId: d.id
|
|
1942
|
+
}),
|
|
1943
|
+
children: T("book.otherResource")
|
|
1944
|
+
}) : u,
|
|
1945
|
+
l,
|
|
1946
|
+
/* @__PURE__ */ f(J, { type: d }),
|
|
1947
|
+
m && h && /* @__PURE__ */ f("p", {
|
|
1948
|
+
className: "cp-hint",
|
|
1949
|
+
children: T("business.with", { resource: h.displayName })
|
|
1950
|
+
}),
|
|
1951
|
+
/* @__PURE__ */ f(Te, {
|
|
1952
|
+
business: s,
|
|
1953
|
+
eventTypeId: d.id,
|
|
1954
|
+
resourceId: m ? h?.id : void 0,
|
|
1955
|
+
onChoose: (t) => e.onChoose(s, t)
|
|
1956
|
+
})
|
|
1957
|
+
]
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
function nt(e) {
|
|
1961
|
+
let { client: t } = x(), { businessId: n, time: i } = e, a = o(e);
|
|
1962
|
+
a.current = e;
|
|
1963
|
+
let s = $(i);
|
|
1964
|
+
return r(() => {
|
|
1965
|
+
let e = !0;
|
|
1966
|
+
return (async () => {
|
|
1967
|
+
let { data: r } = await t.GET("/web/businesses/{businessId}", { params: { path: { businessId: n } } });
|
|
1968
|
+
if (!r) throw Error("no business");
|
|
1969
|
+
let o = ye(r.timezone, new Date(i.startsAt)), { data: s } = await t.GET("/web/businesses/{businessId}/availability", { params: {
|
|
1970
|
+
path: { businessId: n },
|
|
1971
|
+
query: {
|
|
1972
|
+
from: `${o}T00:00`,
|
|
1973
|
+
to: `${q(o, 1)}T00:00`,
|
|
1974
|
+
eventTypeId: i.eventTypeId,
|
|
1975
|
+
...!i.eventId && i.resourceId && { resourceId: i.resourceId }
|
|
1976
|
+
}
|
|
1977
|
+
} }), c = s?.items.find((e) => $e(e, i));
|
|
1978
|
+
e && (c ? a.current.onFound({
|
|
1979
|
+
business: r,
|
|
1980
|
+
candidate: c
|
|
1981
|
+
}) : a.current.onMissing());
|
|
1982
|
+
})().catch(() => {
|
|
1983
|
+
e && a.current.onMissing();
|
|
1984
|
+
}), () => {
|
|
1985
|
+
e = !1;
|
|
1986
|
+
};
|
|
1987
|
+
}, [
|
|
1988
|
+
t,
|
|
1989
|
+
n,
|
|
1990
|
+
s
|
|
1991
|
+
]), /* @__PURE__ */ f("section", {
|
|
1992
|
+
className: "cp-screen",
|
|
1993
|
+
children: /* @__PURE__ */ f("p", {
|
|
1994
|
+
role: "status",
|
|
1995
|
+
children: T("app.loading")
|
|
1996
|
+
})
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
var rt = "input, .cp-option, .cp-chips button, .cp-candidate button, .cp-actions button:not(:disabled)";
|
|
2000
|
+
function it(e) {
|
|
2001
|
+
let t = o(null), n = o(!1), { step: i } = e;
|
|
2002
|
+
return r(() => {
|
|
2003
|
+
let e = t.current;
|
|
2004
|
+
if (!e) return;
|
|
2005
|
+
let r = n.current;
|
|
2006
|
+
if (n.current = !0, r && e.contains(document.activeElement)) return;
|
|
2007
|
+
let i = () => {
|
|
2008
|
+
let t = e.querySelector(rt);
|
|
2009
|
+
return t?.focus(), !!t;
|
|
2010
|
+
};
|
|
2011
|
+
if (i()) return;
|
|
2012
|
+
let a = new MutationObserver(() => {
|
|
2013
|
+
i() && a.disconnect();
|
|
2014
|
+
});
|
|
2015
|
+
a.observe(e, {
|
|
2016
|
+
childList: !0,
|
|
2017
|
+
subtree: !0
|
|
2018
|
+
});
|
|
2019
|
+
let o = () => a.disconnect();
|
|
2020
|
+
return e.addEventListener("focusin", o), () => {
|
|
2021
|
+
a.disconnect(), e.removeEventListener("focusin", o);
|
|
2022
|
+
};
|
|
2023
|
+
}, [i]), /* @__PURE__ */ f("div", {
|
|
2024
|
+
ref: t,
|
|
2025
|
+
className: "cp-shell cp-flow",
|
|
2026
|
+
children: e.children
|
|
2027
|
+
});
|
|
2028
|
+
}
|
|
2029
|
+
// src/sign-in-standalone.tsx
|
|
2030
|
+
function at(e) {
|
|
2031
|
+
let t = e.basePath.replace(/\/$/, ""), n = he(t, e.onSessionChange), i = o(e.onSignedIn);
|
|
2032
|
+
i.current = e.onSignedIn;
|
|
2033
|
+
let a = o(!1);
|
|
2034
|
+
return r(() => {
|
|
2035
|
+
n ? a.current || (a.current = !0, i.current?.()) : a.current = !1;
|
|
2036
|
+
}, [n]), /* @__PURE__ */ f("div", {
|
|
1492
2037
|
className: "msm-customer",
|
|
1493
|
-
children: /* @__PURE__ */
|
|
2038
|
+
children: n === void 0 ? /* @__PURE__ */ f("p", {
|
|
1494
2039
|
className: "cp-status",
|
|
1495
2040
|
role: "status",
|
|
1496
|
-
children:
|
|
2041
|
+
children: T("app.loading")
|
|
2042
|
+
}) : n === null && /* @__PURE__ */ f(Q, {
|
|
2043
|
+
basePath: t,
|
|
2044
|
+
brand: e.brand,
|
|
2045
|
+
botCheck: e.botCheck,
|
|
2046
|
+
notice: void 0,
|
|
2047
|
+
onSignedIn: (e) => U(t, e),
|
|
2048
|
+
onCancel: e.onCancel,
|
|
2049
|
+
autoFocus: !0
|
|
1497
2050
|
})
|
|
1498
2051
|
});
|
|
1499
|
-
|
|
1500
|
-
|
|
2052
|
+
}
|
|
2053
|
+
// src/index.tsx
|
|
2054
|
+
function ot(e) {
|
|
2055
|
+
let [t, n] = s("businesses"), r = e.screen ?? t, i = e.onNavigate ?? n, { basePath: a, sessionKey: o, notice: c, portal: l, signedInAs: u } = W({
|
|
2056
|
+
basePath: e.basePath,
|
|
2057
|
+
navigate: i,
|
|
2058
|
+
accountNavigation: !0,
|
|
2059
|
+
onSessionChange: void 0
|
|
2060
|
+
}), [m, h] = s(), g = typeof r == "string" ? r : `${r.businessId}/${r.eventTypeId ?? ""}`, [_, v] = s(g);
|
|
2061
|
+
_ !== g && (v(g), h(void 0));
|
|
2062
|
+
let y = (t) => /* @__PURE__ */ f(Q, {
|
|
2063
|
+
basePath: a,
|
|
1501
2064
|
brand: void 0,
|
|
1502
2065
|
botCheck: e.botCheck,
|
|
1503
|
-
notice:
|
|
1504
|
-
onSignedIn:
|
|
1505
|
-
m(void 0), c(e);
|
|
1506
|
-
},
|
|
2066
|
+
notice: c,
|
|
2067
|
+
onSignedIn: u,
|
|
1507
2068
|
children: t
|
|
1508
2069
|
});
|
|
1509
|
-
return /* @__PURE__ */
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
})
|
|
2070
|
+
return /* @__PURE__ */ f(G, {
|
|
2071
|
+
portal: l,
|
|
2072
|
+
loading: o === void 0,
|
|
2073
|
+
children: /* @__PURE__ */ f(de, {
|
|
2074
|
+
brand: e.brand,
|
|
2075
|
+
tabs: ue,
|
|
2076
|
+
screen: r,
|
|
2077
|
+
signedIn: !!o,
|
|
2078
|
+
signingIn: !o && (!!m || typeof r == "string" && r !== "businesses"),
|
|
2079
|
+
onNavigate: i,
|
|
2080
|
+
onSignOut: () => l.signOut(),
|
|
2081
|
+
children: m ? o ? /* @__PURE__ */ f(ae, {
|
|
2082
|
+
choice: m,
|
|
2083
|
+
onBack: () => h(void 0)
|
|
2084
|
+
}, `${m.candidate.startsAt}-${m.candidate.eventId ?? m.candidate.eventTypeId}`) : y(/* @__PURE__ */ p(d, { children: [
|
|
2085
|
+
/* @__PURE__ */ f("p", { children: T("book.signInFirst") }),
|
|
2086
|
+
/* @__PURE__ */ f(L, { choice: m }),
|
|
2087
|
+
/* @__PURE__ */ f("button", {
|
|
2088
|
+
type: "button",
|
|
2089
|
+
className: "cp-link",
|
|
2090
|
+
onClick: () => h(void 0),
|
|
2091
|
+
children: T("book.back")
|
|
2092
|
+
})
|
|
2093
|
+
] })) : typeof r == "object" ? /* @__PURE__ */ f(Ce, {
|
|
2094
|
+
businessId: r.businessId,
|
|
2095
|
+
eventTypeId: r.eventTypeId,
|
|
2096
|
+
onChoose: (e, t) => h({
|
|
2097
|
+
business: e,
|
|
2098
|
+
candidate: t
|
|
2099
|
+
})
|
|
2100
|
+
}) : r === "businesses" ? /* @__PURE__ */ f(De, {}) : o ? f(r === "passes" ? ke : r === "details" ? Oe : te, {}) : y()
|
|
1541
2101
|
})
|
|
1542
2102
|
});
|
|
1543
2103
|
}
|
|
1544
|
-
export {
|
|
2104
|
+
export { Ze as MsmAccount, et as MsmBooking, ot as MsmCustomer, at as MsmSignIn, F as cancellationState, j as formatDate, k as formatDateTime, O as formatNumber, C as locale, T as t };
|