@semics-tech/emdash-events 1.0.0-rc.1 → 1.0.0-rc.10

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.
@@ -0,0 +1,80 @@
1
+ ---
2
+ // <CancelBooking>: the quiet "Cancel booking" action at the foot of the booking page (T157). The button only
3
+ // opens a confirmation (a `<details>`, no JavaScript needed); the form posts `intent=cancel` back to the page.
4
+ import { around, pickLocale, translator } from "../i18n/index";
5
+ import { zonedAt } from "./lib/list";
6
+
7
+ interface Props {
8
+ /** Where the cancel form posts. */
9
+ action: string;
10
+ /** The last moment to cancel, when there is one. */
11
+ cancelBy?: string | undefined;
12
+ /** The event's zone, for `cancelBy`. */
13
+ zone?: string | null | undefined;
14
+ locale?: string;
15
+ }
16
+
17
+ const { action, cancelBy, zone } = Astro.props;
18
+ const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
19
+ const { t, lang, dir } = translator(locale);
20
+ const [cancelBefore, cancelAfter] = around(t("booking.cancelUntil"), "time");
21
+ ---
22
+ <details class="semics-events semics-cancel" lang={lang} dir={dir} data-testid="booking-cancel">
23
+ <summary>{t("booking.cancel")}</summary>
24
+ <form method="post" action={action}>
25
+ <input type="hidden" name="intent" value="cancel" />
26
+ {cancelBy && (
27
+ <p>
28
+ {cancelBefore}<time datetime={cancelBy}>{zonedAt(cancelBy, zone, locale)}</time>{cancelAfter}
29
+ </p>
30
+ )}
31
+ <p>{t("booking.cancelConfirm")}</p>
32
+ <button type="submit">{t("booking.cancelYes")}</button>
33
+ </form>
34
+ </details>
35
+
36
+ <style>
37
+ .semics-cancel {
38
+ margin-block: 1.5rem 0;
39
+ color: var(--events-fg, #1a1a1a);
40
+ }
41
+ .semics-cancel summary {
42
+ display: inline-flex;
43
+ align-items: center;
44
+ min-block-size: 2.75rem;
45
+ color: var(--events-muted, #4a4a4a);
46
+ text-decoration: underline;
47
+ text-underline-offset: 0.2em;
48
+ cursor: pointer;
49
+ }
50
+ .semics-cancel form {
51
+ margin-block-start: 0.5rem;
52
+ padding: 1rem 1.25rem;
53
+ border: 1px solid var(--events-error, #b3261e);
54
+ border-radius: var(--events-radius, 6px);
55
+ background: var(--events-bg, #ffffff);
56
+ }
57
+ .semics-cancel p {
58
+ margin: 0 0 0.75rem;
59
+ }
60
+ .semics-cancel button {
61
+ font: inherit;
62
+ min-block-size: 2.75rem;
63
+ padding: 0.5rem 1.25rem;
64
+ border: 1px solid var(--events-error, #b3261e);
65
+ border-radius: var(--events-radius, 6px);
66
+ background: var(--events-bg, #ffffff);
67
+ color: var(--events-error, #b3261e);
68
+ font-weight: 600;
69
+ cursor: pointer;
70
+ }
71
+ .semics-cancel :focus-visible {
72
+ outline: 3px solid var(--events-accent, #0b57d0);
73
+ outline-offset: 2px;
74
+ }
75
+ @media print {
76
+ .semics-cancel {
77
+ display: none;
78
+ }
79
+ }
80
+ </style>
@@ -0,0 +1,18 @@
1
+ ---
2
+ // The site's name or logo at the top of the plugins' own pages (`/booking`, `/_events/waiver`), linking
3
+ // home: those pages run outside the site's layout (`eventsIntegration({ page: { brand } })`).
4
+ import type { PageBrand } from "./lib/page";
5
+
6
+ interface Props {
7
+ brand?: PageBrand | undefined;
8
+ }
9
+
10
+ const { brand } = Astro.props;
11
+ ---
12
+ {
13
+ brand && (
14
+ <header class="semics-page-brand">
15
+ <a href={brand.href ?? "/"}>{brand.logo ? <img src={brand.logo} alt={brand.name} /> : brand.name}</a>
16
+ </header>
17
+ )
18
+ }
@@ -0,0 +1,22 @@
1
+ ---
2
+ // The organiser at the foot of the plugins' own pages (T157): the site's name and, when the site gives one,
3
+ // its address (`page.brand.address`). It stays on a printed booking, where the brand bar is hidden.
4
+ import { pickLocale, translator } from "../i18n/index";
5
+ import type { PageBrand } from "./lib/page";
6
+
7
+ interface Props {
8
+ brand?: PageBrand | undefined;
9
+ locale?: string;
10
+ }
11
+
12
+ const { brand } = Astro.props;
13
+ const { t } = translator(pickLocale(Astro.props.locale, Astro.currentLocale));
14
+ ---
15
+ {
16
+ brand && (
17
+ <footer class="semics-page-organiser" data-testid="page-organiser">
18
+ <p>{t("booking.organiser", { name: brand.name })}</p>
19
+ {brand.address && <address>{brand.address}</address>}
20
+ </footer>
21
+ )
22
+ }
@@ -1,10 +1,12 @@
1
1
  ---
2
- // <TicketPass>: one attendee's ticket with the check-in code as text (EU-FR-07). With Events Pro the
3
- // core also sends the code's QR matrix (`qr`, T082), drawn here as an SVG for the door's camera; the
4
- // text code stays for typing it in. The code is grouped in fours for reading aloud; screen readers
5
- // get it character by character.
2
+ // <TicketPass>: one attendee's ticket with the check-in code (EU-FR-07). With Events Pro the core also sends the
3
+ // code's QR matrix (`qr`, T082), drawn here as an SVG for the door's camera. The code is the core's 43-character
4
+ // value, which door check-in matches exactly, so it is never shortened, only shown smaller (T158): with a QR the face
5
+ // of the pass shows none (the QR carries it) and "Show the code to type in" reveals it on screen, and a printed pass
6
+ // carries it on one small line under the QR; without a QR (Free) it is the way in and shows in full. The code is
7
+ // grouped in fours by spacing (the text stays the exact value); screen readers get it character by character.
6
8
  import { pickLocale, translator } from "../i18n/index";
7
- import { qrPath } from "./lib/pass";
9
+ import { codeGroups, qrPath } from "./lib/pass";
8
10
 
9
11
  interface Props {
10
12
  name: string;
@@ -22,38 +24,63 @@ const { t, lang, dir } = translator(pickLocale(Astro.props.locale, Astro.current
22
24
  const statusText =
23
25
  status === "pending" ? t("pass.status.pending") : status === "cancelled" ? t("pass.status.cancelled") : status;
24
26
  const spoken = code.replace(/[^A-Za-z0-9]/g, "").split("").join(" ");
27
+ const groups = codeGroups(code);
25
28
  const matrix = qrPath(qr);
26
29
  const box = matrix ? matrix.size + 8 : 0;
27
30
  ---
28
- <article class="semics-events semics-ticket-pass" lang={lang} dir={dir} data-testid="ticket-pass" data-status={status}>
29
- {event && <p class="semics-pass-event">{event}</p>}
30
- <h3 class="semics-pass-name">{name}</h3>
31
- {ticket && <p class="semics-pass-ticket">{ticket}</p>}
31
+ <article class="semics-events semics-ticket-pass" lang={lang} dir={dir} data-testid="ticket-pass" data-status={status} data-qr={matrix ? "" : undefined}>
32
32
  {matrix && (
33
- <svg
34
- class="semics-pass-qr"
35
- data-testid="ticket-qr"
36
- role="img"
37
- aria-label={t("pass.qr")}
38
- viewBox={`-4 -4 ${box} ${box}`}
39
- shape-rendering="crispEdges"
40
- >
41
- <rect x="-4" y="-4" width={box} height={box} fill="#ffffff" />
42
- <path d={matrix.d} fill="#000000" />
43
- </svg>
33
+ <div class="semics-pass-qr-box">
34
+ <svg
35
+ class="semics-pass-qr"
36
+ data-testid="ticket-qr"
37
+ role="img"
38
+ aria-label={t("pass.qr")}
39
+ viewBox={`-4 -4 ${box} ${box}`}
40
+ shape-rendering="crispEdges"
41
+ >
42
+ <rect x="-4" y="-4" width={box} height={box} fill="#ffffff" />
43
+ <path d={matrix.d} fill="#000000" />
44
+ </svg>
45
+ <p class="semics-pass-code-print" aria-hidden="true" data-testid="ticket-code-print">{groups.map((g) => <span>{g}</span>)}</p>
46
+ </div>
47
+ )}
48
+ <div class="semics-pass-text">
49
+ {event && <p class="semics-pass-event">{event}</p>}
50
+ <h3 class="semics-pass-name">{name}</h3>
51
+ {ticket && <p class="semics-pass-ticket">{ticket}</p>}
52
+ {!matrix && (
53
+ <>
54
+ <p class="semics-pass-code-label">{t("pass.code")}</p>
55
+ <p class="semics-pass-code">
56
+ <span aria-hidden="true" data-testid="ticket-code">{groups.map((g) => <span>{g}</span>)}</span>
57
+ <span class="semics-visually-hidden">{spoken}</span>
58
+ </p>
59
+ </>
60
+ )}
61
+ {status && status !== "valid" && <p class="semics-pass-status">{statusText}</p>}
62
+ </div>
63
+ {matrix && (
64
+ <details class="semics-pass-more">
65
+ <summary>{t("pass.codeShow")}</summary>
66
+ <p class="semics-pass-code">
67
+ <span aria-hidden="true" data-testid="ticket-code">{groups.map((g) => <span>{g}</span>)}</span>
68
+ <span class="semics-visually-hidden">{spoken}</span>
69
+ </p>
70
+ </details>
44
71
  )}
45
- <p class="semics-pass-code-label">{t("pass.code")}</p>
46
- <p class="semics-pass-code">
47
- <span aria-hidden="true" data-testid="ticket-code">{code}</span>
48
- <span class="semics-visually-hidden">{spoken}</span>
49
- </p>
50
- {status && status !== "valid" && <p class="semics-pass-status">{statusText}</p>}
51
72
  </article>
52
73
 
53
74
  <style>
75
+ /* The QR beside the attendee and the code (T157); stacked on a narrow screen. */
54
76
  .semics-ticket-pass {
55
77
  box-sizing: border-box;
56
- max-inline-size: 24rem;
78
+ display: flex;
79
+ flex-wrap: wrap;
80
+ align-items: center;
81
+ gap: 0.75rem 1.25rem;
82
+ max-inline-size: 32rem;
83
+ margin-block: 0 0.75rem;
57
84
  padding: 1rem;
58
85
  border: 2px dashed var(--events-border, #6b6b6b);
59
86
  border-radius: var(--events-radius, 6px);
@@ -61,6 +88,10 @@ const box = matrix ? matrix.size + 8 : 0;
61
88
  color: var(--events-fg, #1a1a1a);
62
89
  overflow-wrap: anywhere;
63
90
  }
91
+ .semics-pass-text {
92
+ flex: 1 1 12rem;
93
+ min-inline-size: 0;
94
+ }
64
95
  .semics-ticket-pass p,
65
96
  .semics-ticket-pass h3 {
66
97
  margin: 0 0 0.25rem;
@@ -70,19 +101,58 @@ const box = matrix ? matrix.size + 8 : 0;
70
101
  .semics-pass-code-label {
71
102
  color: var(--events-muted, #4a4a4a);
72
103
  }
104
+ .semics-pass-code-label {
105
+ font-size: 0.875rem;
106
+ }
107
+ .semics-pass-qr-box {
108
+ flex: none;
109
+ inline-size: min(100%, 10rem);
110
+ }
73
111
  /* Black on white in every theme: phone cameras read dark modules on a light ground. */
74
112
  .semics-pass-qr {
75
113
  display: block;
76
- inline-size: min(100%, 14rem);
114
+ inline-size: 100%;
77
115
  block-size: auto;
78
116
  aspect-ratio: 1;
79
- margin: 0.5rem 0;
80
117
  }
81
- .semics-pass-code {
118
+ /* Groups of four, spaced rather than separated, so the text is the exact code; a line breaks only between groups. */
119
+ .semics-pass-code,
120
+ .semics-pass-code-print {
82
121
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
83
- font-size: 1.75rem;
84
- letter-spacing: 0.1em;
85
- font-weight: 700;
122
+ overflow-wrap: normal;
123
+ }
124
+ .semics-pass-code {
125
+ font-size: 0.875rem;
126
+ line-height: 1.5;
127
+ letter-spacing: 0.02em;
128
+ font-weight: 600;
129
+ }
130
+ .semics-pass-code > [data-testid] {
131
+ display: block;
132
+ }
133
+ .semics-pass-code > [data-testid] > span,
134
+ .semics-pass-code-print > span {
135
+ display: inline-block;
136
+ margin-inline-end: 0.35em;
137
+ }
138
+ /* Without a QR the code is what the door types in: a little larger. */
139
+ .semics-ticket-pass:not([data-qr]) .semics-pass-code {
140
+ font-size: 0.9375rem;
141
+ }
142
+ /* The pass's full width, under the QR and the name, so the code fits one line on a desktop. */
143
+ .semics-pass-more {
144
+ flex: 1 1 100%;
145
+ }
146
+ .semics-pass-more summary {
147
+ color: var(--events-accent, #0b57d0);
148
+ font-size: 0.875rem;
149
+ cursor: pointer;
150
+ }
151
+ .semics-pass-more .semics-pass-code {
152
+ margin-block: 0.375rem 0;
153
+ }
154
+ .semics-pass-code-print {
155
+ display: none;
86
156
  }
87
157
  .semics-visually-hidden {
88
158
  position: absolute;
@@ -92,4 +162,32 @@ const box = matrix ? matrix.size + 8 : 0;
92
162
  clip-path: inset(50%);
93
163
  white-space: nowrap;
94
164
  }
165
+ @media print {
166
+ .semics-ticket-pass {
167
+ break-inside: avoid;
168
+ border-color: #000000;
169
+ color: #000000;
170
+ }
171
+ .semics-pass-qr-box {
172
+ inline-size: auto;
173
+ }
174
+ .semics-pass-qr {
175
+ inline-size: 35mm;
176
+ }
177
+ /* The QR's fallback for the door: the full code, one small line under it. */
178
+ .semics-pass-code-print {
179
+ display: block;
180
+ margin: 1.5mm 0 0;
181
+ font-size: 6.5pt;
182
+ line-height: 1.3;
183
+ white-space: nowrap;
184
+ }
185
+ .semics-pass-code-print > span {
186
+ margin-inline-end: 0.25em;
187
+ }
188
+ .semics-ticket-pass:not([data-qr]) .semics-pass-code {
189
+ font-size: 9pt;
190
+ white-space: nowrap;
191
+ }
192
+ }
95
193
  </style>
@@ -52,14 +52,32 @@ export interface AttendeeEdit {
52
52
  email?: string;
53
53
  }
54
54
 
55
- /** Statuses in which a waiver can still be signed: the hold's, and a confirmed booking's pending seats. */
56
- const OPEN = ["awaiting_signature", "awaiting_payment", "confirmed"];
55
+ /** Statuses in which a waiver can still be signed: the holds', and a confirmed booking's pending seats. */
56
+ const OPEN = ["awaiting_signature", "awaiting_payment", "awaiting_approval", "confirmed"];
57
57
  const SEAT = /^[0-9]{1,3}$/;
58
58
  const CODE = /^[A-Z_]{1,40}$/;
59
59
  const MAX_TEXT = 254;
60
60
  /** Issue codes of a refused save the page explains itself; any other issue is an invalid entry. */
61
61
  const ISSUE_CODES = ["ATTENDEE_SIGNED", "WAIVER_EMAIL_REQUIRED", "WAIVER_TOO_MANY_EMAILS", "RATE_LIMITED"];
62
62
 
63
+ /** Where the after-payment waiver step shows (T160): a paid booking confirmed, or waiting for the organiser. */
64
+ const AFTER_PAYMENT = ["confirmed", "awaiting_approval"];
65
+
66
+ /**
67
+ * The booking page's signing step for a waiver that comes after payment (Events Pro's `waiverAfter`, T160): `sign`
68
+ * when a seat signed on this device (the buyer, or a minor with the buyer as guardian) still waits, `invite` when an
69
+ * emailed adult does. Null for any other booking, so nothing changes for a waiver signed before payment.
70
+ */
71
+ export function waiverStep(booking: BookingView): { sign: boolean; invite: boolean } | null {
72
+ if (booking.waiverAfter !== true || !AFTER_PAYMENT.includes(booking.status)) return null;
73
+ const rows = signingRows(booking);
74
+ const waiting = (booking.attendees as SigningAttendee[]).filter(
75
+ (a) => a.signing === "waiting" && rows?.some((r) => r.seat === a.seat),
76
+ );
77
+ if (waiting.length === 0) return null;
78
+ return { sign: waiting.some((a) => a.signs !== "email"), invite: waiting.some((a) => a.signs === "email") };
79
+ }
80
+
63
81
  /** The list's rows, or null when the answer has no signing list (Free, or not a waiver booking). */
64
82
  export function signingRows(booking: BookingView): SigningRow[] | null {
65
83
  const list = booking.signingList;
@@ -112,7 +130,7 @@ function back(ref: string, key: "error" | "attendees", value: string): { locatio
112
130
  interface Minted {
113
131
  intent?: unknown;
114
132
  lookup?: unknown;
115
- intents?: Array<{ token?: unknown }>;
133
+ intents?: Array<{ token?: unknown; delivery?: unknown }>;
116
134
  }
117
135
 
118
136
  /**
@@ -127,12 +145,14 @@ export async function handleAttendeeAction(
127
145
  booking: BookingView,
128
146
  ): Promise<{ location: string } | null> {
129
147
  const intent = form.get("intent");
130
- if (intent !== "sign-now" && intent !== "resend" && intent !== "attendees") return null;
148
+ if (intent !== "sign-now" && intent !== "resend" && intent !== "attendees" && intent !== "sign-waiver") return null;
131
149
  const { ref } = access;
132
150
  if (!options.esignPluginId) return back(ref, "error", "ESIGN_NOT_CONFIGURED");
133
151
  const rows = signingRows(booking) ?? [];
134
152
  const auth = { bookingRef: ref, accessToken: access.token };
135
153
 
154
+ if (intent === "sign-waiver") return signWaiver(ctx, auth, options, booking);
155
+
136
156
  if (intent === "attendees") {
137
157
  const attendees = readAttendeeEdits(form, rows);
138
158
  if (attendees.length === 0) return back(ref, "error", "ATTENDEES_LOCKED");
@@ -168,3 +188,31 @@ export async function handleAttendeeAction(
168
188
  if ("signed" in started) return { location: `${BOOKING_PATH}?ref=${ref}&waiver=signed` };
169
189
  return back(ref, "error", started.error);
170
190
  }
191
+
192
+ /**
193
+ * "Sign the waiver" after payment (T160): Events Pro's `public/booking/attendees/sign` with no seat mints an intent for every seat not
194
+ * signed. The emailed adults' are redeemed first (e-sign invites each once: a second press finds the envelope and
195
+ * sends nothing), then the first seat signed on this device opens e-sign's signing page; the next press signs the next.
196
+ */
197
+ async function signWaiver(
198
+ ctx: PublicRouteContext,
199
+ auth: { bookingRef: string; accessToken: string },
200
+ options: ReceiptOptions,
201
+ booking: BookingView,
202
+ ): Promise<{ location: string }> {
203
+ const ref = auth.bookingRef;
204
+ if (!waiverStep(booking) || !options.esignPluginId) return back(ref, "error", "BAD_REQUEST");
205
+ const minted = await post<Minted>(ctx, options.pluginId, "public/booking/attendees/sign", auth);
206
+ if (!minted.ok) return back(ref, "error", minted.error.code);
207
+ const intents = minted.data.intents ?? [];
208
+ for (const email of intents.filter((i) => i.delivery === "email")) {
209
+ const sent = await post(ctx, options.esignPluginId, "public/envelopes/from-intent", { intent: email.token });
210
+ if (!sent.ok) return back(ref, "error", "ATTENDEES_UNSENT");
211
+ }
212
+ const inline = intents.find((i) => i.delivery !== "email");
213
+ if (!inline) return back(ref, "attendees", "invited");
214
+ const started = await startDoorSigning(ctx, inline.token, options);
215
+ if ("location" in started) return started;
216
+ if ("signed" in started) return { location: `${BOOKING_PATH}?ref=${ref}&waiver=signed` };
217
+ return back(ref, "error", started.error);
218
+ }
@@ -62,6 +62,28 @@ const WHEN: Intl.DateTimeFormatOptions = {
62
62
  timeZoneName: "short",
63
63
  };
64
64
 
65
+ /** The booking widget's and the waiver page's date format: full date, short time. */
66
+ const AT: Intl.DateTimeFormatOptions = { dateStyle: "full", timeStyle: "short" };
67
+
68
+ /**
69
+ * A time on a customer page (a deadline, a hold, the booked session): local time in the event's own zone, as the
70
+ * session's time line reads ("Monday 9 November 2026 at 15:09", T157), without the zone's name. A missing or
71
+ * unknown zone shows UTC and says so; a value that is not a date is shown as it is.
72
+ */
73
+ export function zonedAt(iso: string, timezone: string | null | undefined, locale: string): string {
74
+ const ms = Date.parse(iso);
75
+ if (!Number.isFinite(ms)) return iso;
76
+ const known = Boolean(timezone && isValidTimeZone(timezone));
77
+ const zone = known ? (timezone as string) : "UTC";
78
+ let time: string;
79
+ try {
80
+ time = formatInZone(ms, zone, locale, AT);
81
+ } catch {
82
+ time = formatInZone(ms, zone, "en-GB", AT); // A locale `Intl` refuses, such as `en_GB`.
83
+ }
84
+ return known ? time : `${time} (${zone})`;
85
+ }
86
+
65
87
  const BADGES = { cancelled: "list.badge.cancelled", closed: "list.badge.closed", paused: "list.badge.paused" } as const;
66
88
 
67
89
  /** The start in the event's own zone; a missing or unknown zone shows UTC rather than failing. */
@@ -0,0 +1,142 @@
1
+ // i18n-ignore-file: a stylesheet and its option names, no text for people.
2
+ /**
3
+ * The look of the plugins' own full pages (`/booking`, the suite's `/_events/waiver`), which run outside the
4
+ * site's layout: a default stylesheet built only on the `--events-*` properties, and what a site sets through
5
+ * `eventsIntegration({ page })` / `eventsSuite({ page })`. It is one exact string so the signing page can allow
6
+ * it by hash (its CSP allows nothing else inline, `ceremonyCsp`). Web APIs only (R35).
7
+ *
8
+ * The site's own layout is deliberately not wrapped around these pages: an emailed link's one-time code is in the
9
+ * URL here, and a signing page's CSP would block the layout's scripts and styles anyway.
10
+ */
11
+
12
+ /** A theme value by property: `accent` sets `--events-accent` (the signing form follows, see `PAGE_CSS`). */
13
+ export const THEME_PROPERTIES = [
14
+ "fg",
15
+ "muted",
16
+ "bg",
17
+ "border",
18
+ "accent",
19
+ "accent-fg",
20
+ "error",
21
+ "success",
22
+ "radius",
23
+ "font",
24
+ "page-bg",
25
+ "heading-font",
26
+ "heading-fg",
27
+ ] as const;
28
+ export type ThemeProperty = (typeof THEME_PROPERTIES)[number];
29
+ export interface PageBrand {
30
+ /** The site's name: the link's text, or the logo's alternative text. Also the organiser at the page's foot. */
31
+ name: string;
32
+ /** Where it links, a path on this site (default `/`). */
33
+ href?: string;
34
+ /** A logo, a path on this site. */
35
+ logo?: string;
36
+ /** The organiser's postal address, one line, at the page's foot and on a printed booking (T157). */
37
+ address?: string;
38
+ }
39
+
40
+ /** One line of text for people: 1 to 300 characters, no control characters (line breaks included). */
41
+ function oneLine(value: unknown): boolean {
42
+ if (typeof value !== "string" || !value.trim() || value.length > 300) return false;
43
+ for (let i = 0; i < value.length; i++) {
44
+ const unit = value.charCodeAt(i);
45
+ if (unit <= 0x1f || unit === 0x7f) return false;
46
+ }
47
+ return true;
48
+ }
49
+
50
+ export interface PageOptions {
51
+ /** Values for the pages' custom properties, for example `{ accent: "#1f3a2e", "page-bg": "#f6f1ea" }`. */
52
+ theme?: Partial<Record<ThemeProperty, string>>;
53
+ /** A stylesheet on this site, loaded after the defaults: for `@font-face`, or any further rules. */
54
+ stylesheet?: string;
55
+ /** The site's name or logo at the top of each page. */
56
+ brand?: PageBrand;
57
+ /** The event's page, where "Book again" goes: a path with `{slug}` (default `/events/{slug}`). */
58
+ eventPath?: string;
59
+ }
60
+
61
+ /** One line of CSS, nothing that could end the declaration, the rule or the `<style>` element. */
62
+ const THEME_VALUE = /^[^;{}<>\\@]{1,200}$/;
63
+ /** A path on this site; `;` and `,` would end a source in the signing page's CSP header. */
64
+ const SITE_PATH = /^\/(?!\/)[^\s"'<>\\;,]*$/;
65
+
66
+ /** Checks a site's page options when the site's config loads; a bad value stops the build with its name. */
67
+ export function checkPageOptions(page: PageOptions = {}): PageOptions {
68
+ const refuse = (what: string) => {
69
+ throw new Error(`page.${what} is not valid`); // i18n-ignore
70
+ };
71
+ for (const [name, value] of Object.entries(page.theme ?? {})) {
72
+ const known = (THEME_PROPERTIES as readonly string[]).includes(name);
73
+ if (!known || typeof value !== "string" || !THEME_VALUE.test(value) || /url\(/i.test(value))
74
+ refuse(`theme.${name}`);
75
+ }
76
+ const { brand, stylesheet, eventPath } = page;
77
+ if (stylesheet !== undefined && !SITE_PATH.test(stylesheet)) refuse("stylesheet");
78
+ if (eventPath !== undefined && !(SITE_PATH.test(eventPath) && eventPath.includes("{slug}"))) refuse("eventPath");
79
+ if (brand) {
80
+ if (typeof brand.name !== "string" || !brand.name.trim()) refuse("brand.name");
81
+ if (brand.href !== undefined && !SITE_PATH.test(brand.href)) refuse("brand.href");
82
+ if (brand.logo !== undefined && !SITE_PATH.test(brand.logo)) refuse("brand.logo");
83
+ if (brand.address !== undefined && !oneLine(brand.address)) refuse("brand.address");
84
+ }
85
+ return page;
86
+ }
87
+
88
+ /** The event's page for "Book again"; undefined when the booking does not know its slug. */
89
+ export function eventPageHref(slug: string | null | undefined, eventPath?: string): string | undefined {
90
+ return slug ? (eventPath ?? "/events/{slug}").replace("{slug}", encodeURIComponent(slug)) : undefined;
91
+ }
92
+
93
+ /**
94
+ * Works with no site theme at all. Zero specificity on elements, so the components' own rules win; except the card
95
+ * rule for `main`'s sections, which outranks a component's own box (`.semics-payment`, `.semics-attendee-list`) so
96
+ * every card has the same edges, width and look (T158).
97
+ */
98
+ export const PAGE_CSS = `*,*::before,*::after{box-sizing:border-box}
99
+ html{color-scheme:light;-webkit-text-size-adjust:100%}
100
+ body.semics-page{margin:0;min-block-size:100vh;background:var(--events-page-bg, #f5f4f0);color:var(--events-fg, #1a1a1a);font-family:var(--events-font, system-ui, sans-serif);font-size:1.0625rem;line-height:1.55;overflow-wrap:anywhere;
101
+ --esign-fg:var(--events-fg, #1a1a1a);--esign-muted:var(--events-muted, #4a4a4a);--esign-bg:var(--events-bg, #ffffff);--esign-border:var(--events-border, #6b6b6b);--esign-accent:var(--events-accent, #0b57d0);--esign-accent-fg:var(--events-accent-fg, #ffffff);--esign-error:var(--events-error, #b3261e);--esign-radius:var(--events-radius, 6px);--esign-font:var(--events-font, system-ui, sans-serif)}
102
+ .semics-page-brand{max-inline-size:40rem;margin-inline:auto;padding:1.25rem 1rem 0;font-family:var(--events-heading-font, inherit);font-weight:600}
103
+ .semics-page-brand a{color:var(--events-heading-fg, inherit);text-decoration:none}
104
+ .semics-page-brand img{display:block;block-size:2.5rem;inline-size:auto;max-inline-size:100%}
105
+ .semics-page-main{max-inline-size:40rem;margin-inline:auto;padding:1.5rem 1rem 2rem}
106
+ :where(.semics-page) :is(h1,h2,h3){margin:0 0 .75rem;font-family:var(--events-heading-font, inherit);color:var(--events-heading-fg, inherit);line-height:1.2}
107
+ :where(.semics-page) h1{margin-block-end:1.25rem;font-size:clamp(1.75rem,1.5rem + 1.5vw,2.25rem)}
108
+ :where(.semics-page) h2{font-size:1.25rem}
109
+ :where(.semics-page) h3{font-size:1.0625rem}
110
+ :where(.semics-page) p{margin:0 0 .75rem}
111
+ :where(.semics-page) a{color:var(--events-accent, #0b57d0);text-underline-offset:.2em}
112
+ :where(.semics-page) :focus-visible{outline:3px solid var(--events-accent, #0b57d0);outline-offset:2px}
113
+ .semics-page-main > :is(section,form:not([hidden]),.semics-ceremony){margin-block:0 1.25rem;padding:clamp(1.25rem,.9rem + 1.8vw,1.75rem);background:var(--events-bg, #ffffff);border:1px solid color-mix(in srgb,var(--events-border, #6b6b6b) 30%,transparent);border-radius:calc(var(--events-radius, 6px) + 6px);box-shadow:0 1px 2px rgb(0 0 0 / .04),0 6px 24px rgb(0 0 0 / .05);max-inline-size:none}
114
+ :where(.semics-page-main > section,.semics-page-main > form,.semics-page-main > .semics-ceremony) > :last-child{margin-block-end:0}
115
+ :where(.semics-page) [role="alert"]{padding:.75rem 1rem;border:1px solid var(--events-error, #b3261e);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-error, #b3261e)}
116
+ :where(.semics-page) :is(input:not([type="checkbox"],[type="radio"],[type="hidden"]),select,textarea){font:inherit;inline-size:100%;min-block-size:2.75rem;padding:.5rem .75rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-fg, #1a1a1a)}
117
+ :where(.semics-page) label{display:block}
118
+ :where(.semics-page) fieldset{min-inline-size:0;margin:0 0 1rem;padding:0;border:0}
119
+ :where(.semics-page) legend{padding:0;margin-block-end:.5rem;font-weight:600}
120
+ :where(.semics-page) button{font:inherit;font-weight:600;min-block-size:2.75rem;padding:.625rem 1.25rem;border:1px solid var(--events-accent, #0b57d0);border-radius:var(--events-radius, 6px);background:var(--events-accent, #0b57d0);color:var(--events-accent-fg, #ffffff);cursor:pointer}
121
+ .semics-page-actions{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem 1.25rem;margin-block:0 1.25rem}
122
+ .semics-page-actions .semics-print{background:transparent;color:var(--events-accent, #0b57d0)}
123
+ .semics-page-organiser{max-inline-size:40rem;margin-inline:auto;padding:0 1rem 3rem;color:var(--events-muted, #4a4a4a);font-size:.9375rem}
124
+ .semics-page-organiser p{margin:0}
125
+ .semics-page-organiser address{font-style:normal}
126
+ @media print{
127
+ @page{margin:15mm}
128
+ body.semics-page{min-block-size:0;background:#ffffff;color:#000000;font-size:11pt}
129
+ .semics-page-brand,.semics-page-actions,.semics-page-main form,.semics-page-main button,.semics-page-main details,.semics-add-to-calendar,[data-semics-payment-live]{display:none !important}
130
+ .semics-page-main{max-inline-size:none;padding:0}
131
+ .semics-page-main > :is(section,form:not([hidden]),.semics-ceremony){box-shadow:none;border-color:#999999;break-inside:avoid}
132
+ .semics-ticket-pass{break-inside:avoid}
133
+ .semics-page-organiser{max-inline-size:none;padding:1rem 0 0;color:#000000}
134
+ }
135
+ `;
136
+
137
+ /** The stylesheet for a page: the defaults, then the site's theme. Exact: the signing page hashes this text. */
138
+ export function pageCss(page: PageOptions = {}): string {
139
+ const set = Object.entries(page.theme ?? {}) as Array<[ThemeProperty, string]>;
140
+ if (set.length === 0) return PAGE_CSS;
141
+ return `${PAGE_CSS}:root{${set.map(([name, value]) => `--events-${name}:${value}`).join(";")}}\n`;
142
+ }
@@ -33,3 +33,12 @@ export function qrPath(qr: unknown): QrPath | null {
33
33
  }
34
34
  return { size, d };
35
35
  }
36
+
37
+ /**
38
+ * A check-in code in groups of four for reading (T158): the pass draws each group as its own span, spaced by CSS, so
39
+ * the text (and a copy of it) stays the exact value door check-in takes. A short code (12 or fewer) stays whole.
40
+ */
41
+ export function codeGroups(code: string): string[] {
42
+ if (code.length <= 12) return code ? [code] : [];
43
+ return code.match(/.{1,4}/gsu) ?? [];
44
+ }
@@ -5,6 +5,7 @@
5
5
  * way" are told apart by asking the core, never by a query parameter.
6
6
  */
7
7
  import { type MessageKey, t } from "../../i18n/index";
8
+ import { zonedAt } from "./list";
8
9
  import type { BookingView } from "./widget";
9
10
 
10
11
  export type PaymentState = "confirmed" | "pending" | "expired" | "cancelled" | "refunded" | "refunded_unavailable";
@@ -19,15 +20,6 @@ export interface PaymentView {
19
20
  resume: boolean;
20
21
  }
21
22
 
22
- const utc = (iso: string, locale: string) => {
23
- try {
24
- const at = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" });
25
- return t(locale, "time.utc", { time: at.format(new Date(iso)) });
26
- } catch {
27
- return iso;
28
- }
29
- };
30
-
31
23
  /** The provider's payment page is followed only when it is an `https:` URL (never `javascript:` or `//host`). */
32
24
  export function isPayUrl(value: unknown): value is string {
33
25
  if (typeof value !== "string" || !value.startsWith("https://")) return false;
@@ -49,13 +41,17 @@ const final = (state: PaymentState, locale: string): PaymentView => ({
49
41
  /** The payment section for a booking, or `null` when there is nothing to say about money. */
50
42
  export function paymentView(booking: BookingView, locale = "en-GB"): PaymentView | null {
51
43
  const paid = booking.totals.totalMinor > 0;
44
+ // Ran out waiting for the organiser: not about a payment (`endedNotes` says what happened).
45
+ if (booking.status === "expired" && booking.undecided) return null;
52
46
  switch (booking.status) {
53
47
  case "awaiting_payment":
54
48
  return {
55
49
  state: "pending",
56
50
  heading: t(locale, "payment.pending.heading"),
57
51
  body: booking.holdExpiresAt
58
- ? t(locale, "payment.pending.bodyUntil", { time: utc(booking.holdExpiresAt, locale) })
52
+ ? t(locale, "payment.pending.bodyUntil", {
53
+ time: zonedAt(booking.holdExpiresAt, booking.event?.timezone, locale),
54
+ })
59
55
  : t(locale, "payment.pending.body"),
60
56
  poll: true,
61
57
  resume: true,