Build a React 19 + TypeScript component called BookingCalendar: a dark meeting scheduler with a host card, a month calendar and the chosen day's free times, then a details form and a "You're booked." card.
Constraints
- One .tsx file, "use client", imports from react only, icons inlined as SVG, no date library. All CSS in a template string rendered as <style href="play-booking-calendar" precedence="play">, every class prefixed "sb-". Default export, no required props; optional host name (default "Alex Rivera"), title ("Intro call"), description, duration, location, avatar and logo URLs (both empty by default), accent ("r, g, b", default "139, 92, 246"), the availability rules below, and onBook(booking).
- The root fills its parent (width/height 100%, overflow hidden, isolation isolate, background #0b0d12) and scrolls inside an inner wrapper if its frame is short. Respond to its own width with container queries, never the window. Render the inner content only on the client (useSyncExternalStore), since it depends on the clock and the visitor's time zone.
- Font: var(--font-google-sans-flex, "Google Sans Flex"), system-ui, sans-serif. Tokens: card #0D1219, border #1E2125, muted well #191E24, muted text #989EA4, hover #1D232B, page #0A0E12, focus #60A5FA.
Availability
- Host in America/Los_Angeles, Monday–Friday 09:00–17:00, 15-minute meetings starting every 15 minutes, at least 240 minutes' notice, up to 60 days ahead. Convert each host day to UTC with Intl.DateTimeFormat.formatToParts (correct across DST), then group the instants by date in the visitor's zone.
- Open on the current month, or the next one if the current month has no free days left.
Layout
- Page: max-width 896px, padding 40px 16px. One column below 680px; from 680px a 300px host column beside the rest; from 840px the rest splits into the calendar and a 232px times column. Gaps 24px, items aligned to the top.
Host card (radius 12, 1px border, padding 20)
- 40px round avatar (the host's initial, 16px semibold white, on the accent when there's no photo) with an optional 20px round logo badge at its bottom-right (1px white/10 border). Beside it the host name (12px muted) over the title (16px semibold, line-height 1.25). Then the description (14px muted), and rows with 16px icons, gap 8, 6px apart: "15 min" (clock), the location (video), and the visitor's zone as an unstyled select of every IANA zone with underscores shown as spaces. On the details step the select becomes plain text and a row with the chosen date and time (calendar icon) folds open above it.
Calendar card (padding 16)
- Header: "November 2026" (16px semibold) and two 36px round ghost buttons with 16px chevrons; previous is disabled at 50% on the current month.
- Weekday letters S M T W T F S (12px muted), then always six rows of seven square days, gap 4. Unavailable days are plain text at 40% muted (30% outside the month). Available days are buttons, 14px medium, radius 10; the selected one fills with the accent (radius 6, fade 0.22s) and its number turns white.
Times
- Before a date: "Select a date to see times." 14px muted, 24px from the top.
- After: a card headed "Mon, Nov 23" (14px semibold) with a 12h/24h segmented toggle (11px medium, muted well, the active half an accent pill that slides). Times are 36px pills, 14px medium, background #0A0E12, ring 0 0 0 1px white/8, 6px apart: one column of 200px pills scrolling at 420px when beside the calendar, two columns otherwise. Picking one fills it with the accent.
- Next (36px accent pill): when the frame is 980px or wider, the card widens from 232px to 312px past its column and Next pops in beside the chosen pill (scale .9 → 1). Narrower, Next fills a sticky bar under the times that folds open.
- Days and pills share a hover glow: a 1px conic border in the accent (accent at 0°, clear 90°–270°) whose start angle sweeps 0 → 360° over 1s ease-out-cubic (a registered @property), plus a radial wash of the accent at 10% under the pointer. Fade both out over .3s on leave.
Details and confirmation
- Replaces the calendar and times: "Confirm your details" (18px semibold), then floating-label fields in 52px wells (radius 16, #191E24 at 60%) with a white light under the pointer and a 2px rainbow conic ring on focus: "Your name *", "Email *", and a 96px "Anything else? (optional)" textarea whose placeholder reads "Share anything that will help prepare for the meeting." Back (ghost; hover tints with the accent at 12%) and "Confirm booking" (accent, spinner while submitting).
- Booking never calls a server: after a 0.9s pause it calls onBook and shows the confirmation. Missing name or email shows a white toast at the bottom: "Name and email are required", with a pink gradient swatch and a close button, gone after 4s.
- Then a centred 512px card: a green (#22C55E) circle and tick that draw themselves, "You're booked." (24px bold), "This is a demo, so nothing was booked and no email went to {email}.", rows for the title "with {host}" and the full date and time with the zone, and Reschedule, Cancel and Add to calendar (downloads an .ics) as 12px muted links.
Motion
- Transforms spring (0.3s, bounce 0.18, as a CSS linear() curve); opacity fades over 0.22s cubic-bezier(.22,1,.36,1). Swaps wait for the old piece to leave: the month sweeps 16px the way you paged (its title 10px), the times card and the panels rise 10px in and lift 10px out. Columns arrive 14px up, 0.13s apart; times stagger in 20ms apart.
- prefers-reduced-motion: fades only, no sweeps, no glow rotation, the tick already drawn.
Behaviour
- Real buttons with aria-pressed for days, times and the toggle, labelled month arrows, visible focus rings; hover effects only where (hover: hover). Clear every timer on unmount.1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373"use client";
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
import type { CSSProperties, PointerEvent as ReactPointerEvent, ReactNode, RefObject } from "react";
export type Booking = {
startUtc: string;
endUtc: string;
name: string;
email: string;
notes: string;
timeZone: string;
};
export type BookingCalendarProps = {
hostName?: string;
title?: string;
description?: string;
durationMinutes?: number;
location?: string;
avatarUrl?: string;
logoUrl?: string;
accent?: string;
hostTimeZone?: string;
workdays?: number[];
dayStart?: string;
dayEnd?: string;
intervalMinutes?: number;
minNoticeMinutes?: number;
futureLimitDays?: number;
onBook?: (booking: Booking) => void;
};
const DEFAULTS = {
hostName: "Alex Rivera",
title: "Intro call",
description: "A quick 15-minute call to get to know each other, talk through what you're working on, and see whether we're a good fit.",
durationMinutes: 15,
location: "Google Meet",
avatarUrl: "",
logoUrl: "",
accent: "139, 92, 246",
hostTimeZone: "America/Los_Angeles",
workdays: [1, 2, 3, 4, 5],
dayStart: "09:00",
dayEnd: "17:00",
intervalMinutes: 15,
minNoticeMinutes: 240,
futureLimitDays: 60,
};
type Settings = typeof DEFAULTS & { onBook?: (booking: Booking) => void };
const THREE_COLUMNS = 840;
const OVERHANG = 980;
const SLOT_CARD_WIDTH = 232;
const SLOT_CARD_WIDTH_OPEN = 312;
const MOVE_MS = 300;
const FADE_MS = 220;
const SPRING = (() => {
const zeta = 0.82;
const omega = Math.log(1000) / (zeta * 0.3);
const damped = omega * Math.sqrt(1 - zeta * zeta);
const points: string[] = [];
for (let i = 0; i <= 40; i++) {
const t = (i / 40) * 0.3;
const x = 1 - Math.exp(-zeta * omega * t) * (Math.cos(damped * t) + ((zeta * omega) / damped) * Math.sin(damped * t));
points.push(i === 40 ? "1" : x.toFixed(4));
}
return `linear(${points.join(", ")})`;
})();
const pad = (n: number) => String(n).padStart(2, "0");
const localKey = (d: Date) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
const parseKey = (key: string) => {
const [y, m, d] = key.split("-").map(Number);
return new Date(y, m - 1, d || 1);
};
const toMinutes = (hhmm: string) => {
const [h, m] = hhmm.split(":").map(Number);
return h * 60 + (m || 0);
};
const formatters = new Map<string, Intl.DateTimeFormat>();
function zoned(ms: number, timeZone: string) {
let f = formatters.get(timeZone);
if (!f) {
f = new Intl.DateTimeFormat("en-US", {
timeZone,
hourCycle: "h23",
year: "numeric",
month: "numeric",
day: "numeric",
hour: "numeric",
minute: "numeric",
});
formatters.set(timeZone, f);
}
const p: Record<string, number> = {};
for (const { type, value } of f.formatToParts(ms)) p[type] = Number(value);
return { y: p.year, m: p.month, d: p.day, h: p.hour % 24, min: p.minute };
}
function zonedToUtc(y: number, m: number, d: number, minutes: number, timeZone: string) {
const wall = Date.UTC(y, m - 1, d, 0, minutes);
const offset = (ms: number) => {
const p = zoned(ms, timeZone);
return Date.UTC(p.y, p.m - 1, p.d, p.h, p.min) - Math.floor(ms / 60000) * 60000;
};
return wall - offset(wall - offset(wall));
}
type Rules = Pick<Settings, "hostTimeZone" | "workdays" | "dayStart" | "dayEnd" | "durationMinutes" | "intervalMinutes" | "minNoticeMinutes" | "futureLimitDays">;
function buildSlots(now: number, viewerZone: string, s: Rules) {
const byDay = new Map<string, number[]>();
const earliest = now + s.minNoticeMinutes * 60_000;
const latest = now + s.futureLimitDays * 86_400_000;
const start = toMinutes(s.dayStart);
const end = toMinutes(s.dayEnd);
const today = zoned(now, s.hostTimeZone);
for (let i = 0; i <= s.futureLimitDays + 1; i++) {
const day = new Date(Date.UTC(today.y, today.m - 1, today.d + i));
if (!s.workdays.includes(day.getUTCDay())) continue;
const opens = zonedToUtc(day.getUTCFullYear(), day.getUTCMonth() + 1, day.getUTCDate(), start, s.hostTimeZone);
for (let t = start; t + s.durationMinutes <= end; t += s.intervalMinutes) {
const at = opens + (t - start) * 60_000;
if (at < earliest || at > latest) continue;
const p = zoned(at, viewerZone);
const key = `${p.y}-${pad(p.m)}-${pad(p.d)}`;
const list = byDay.get(key);
if (list) list.push(at);
else byDay.set(key, [at]);
}
}
return byDay;
}
function monthGrid(month: Date) {
const lead = month.getDay();
return Array.from({ length: 42 }, (_, i) => new Date(month.getFullYear(), month.getMonth(), 1 - lead + i));
}
function monthHasTimes(slots: Map<string, number[]>, month: Date, today: Date) {
for (const d of monthGrid(month)) {
if (d.getMonth() === month.getMonth() && d >= today && slots.get(localKey(d))?.length) return true;
}
return false;
}
const monthTitle = (month: Date) => month.toLocaleDateString("en-US", { month: "long", year: "numeric" });
const formatZone = (zone: string) => zone.replace(/_/g, " ");
const noopSubscribe = () => () => {};
function useWidth(ref: RefObject<HTMLDivElement | null>) {
const subscribe = useCallback(
(onChange: () => void) => {
const el = ref.current;
if (!el) return () => {};
const observer = new ResizeObserver(onChange);
observer.observe(el);
return () => observer.disconnect();
},
[ref],
);
return useSyncExternalStore(subscribe, () => ref.current?.clientWidth ?? 0, () => 0);
}
function useSwap(key: string, exitMs: (leaving: string) => number) {
const [shown, setShown] = useState(key);
const [swapped, setSwapped] = useState(false);
const leaving = key !== shown;
const ms = leaving ? exitMs(shown) : 0;
useEffect(() => {
if (!leaving) return;
const timer = setTimeout(() => {
setShown(key);
setSwapped(true);
}, ms);
return () => clearTimeout(timer);
}, [leaving, key, ms]);
return { shown, leaving, entering: swapped && !leaving };
}
function trackPointer(e: ReactPointerEvent<HTMLElement>) {
const r = e.currentTarget.getBoundingClientRect();
e.currentTarget.style.setProperty("--mx", `${((e.clientX - r.left) / r.width) * 100}%`);
e.currentTarget.style.setProperty("--my", `${((e.clientY - r.top) / r.height) * 100}%`);
}
function trackField(e: ReactPointerEvent<HTMLElement>) {
const r = e.currentTarget.getBoundingClientRect();
e.currentTarget.style.setProperty("--gx", `${e.clientX - r.left}px`);
e.currentTarget.style.setProperty("--gy", `${e.clientY - r.top}px`);
}
const vars = (v: Record<string, string | number>) => v as CSSProperties;
export default function BookingCalendar(props: BookingCalendarProps) {
const rootRef = useRef<HTMLDivElement>(null);
const mounted = useSyncExternalStore(noopSubscribe, () => true, () => false);
return (
<div ref={rootRef} className="sb" style={vars({ "--sb-accent": props.accent ?? DEFAULTS.accent })}>
<style href="play-booking-calendar" precedence="play">
{css}
</style>
{mounted && <Scheduler settings={{ ...DEFAULTS, ...stripUndefined(props) }} rootRef={rootRef} />}
</div>
);
}
function stripUndefined<T extends object>(o: T): Partial<T> {
return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined)) as Partial<T>;
}
type Panel = "pick" | "form" | "done";
type Toast = { id: number; text: string };
function Scheduler({ settings: s, rootRef }: { settings: Settings; rootRef: RefObject<HTMLDivElement | null> }) {
const width = useWidth(rootRef);
const threeColumns = width >= THREE_COLUMNS;
const overhang = width >= OVERHANG;
const [now] = useState(() => Date.now());
const [tz, setTz] = useState(() => Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC");
const [zones] = useState<string[]>(() =>
typeof Intl.supportedValuesOf === "function" ? Intl.supportedValuesOf("timeZone") : [],
);
const [hour12, setHour12] = useState(
() => new Intl.DateTimeFormat(undefined, { hour: "numeric" }).resolvedOptions().hour12 ?? true,
);
const rules = JSON.stringify([s.hostTimeZone, s.workdays, s.dayStart, s.dayEnd, s.durationMinutes, s.intervalMinutes, s.minNoticeMinutes, s.futureLimitDays]);
const slots = useMemo(() => {
const [hostTimeZone, workdays, dayStart, dayEnd, durationMinutes, intervalMinutes, minNoticeMinutes, futureLimitDays] = JSON.parse(rules);
return buildSlots(now, tz, { hostTimeZone, workdays, dayStart, dayEnd, durationMinutes, intervalMinutes, minNoticeMinutes, futureLimitDays });
}, [now, tz, rules]);
const today = useMemo(() => {
const d = new Date(now);
d.setHours(0, 0, 0, 0);
return d;
}, [now]);
const [view, setView] = useState(() => {
const first = new Date(today.getFullYear(), today.getMonth(), 1);
return monthHasTimes(slots, first, today) ? first : new Date(today.getFullYear(), today.getMonth() + 1, 1);
});
const [monthDir, setMonthDir] = useState(1);
const goToMonth = (delta: number) => {
setMonthDir(delta);
setView(new Date(view.getFullYear(), view.getMonth() + delta, 1));
};
const [dateKey, setDateKey] = useState<string | null>(null);
const [slot, setSlot] = useState<number | null>(null);
const [leavingSlot, setLeavingSlot] = useState<number | null>(null);
const [panel, setPanel] = useState<Panel>("pick");
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [notes, setNotes] = useState("");
const [submitting, setSubmitting] = useState(false);
const [booked, setBooked] = useState<Booking | null>(null);
const [toast, setToast] = useState<Toast | null>(null);
useEffect(() => {
if (leavingSlot === null) return;
const timer = setTimeout(() => setLeavingSlot(null), MOVE_MS);
return () => clearTimeout(timer);
}, [leavingSlot]);
useEffect(() => {
if (!toast) return;
const timer = setTimeout(() => setToast(null), 4000);
return () => clearTimeout(timer);
}, [toast]);
useEffect(() => {
if (!submitting) return;
const timer = setTimeout(() => {
if (slot === null) return;
const booking: Booking = {
startUtc: new Date(slot).toISOString(),
endUtc: new Date(slot + s.durationMinutes * 60_000).toISOString(),
name: name.trim(),
email: email.trim(),
notes: notes.trim(),
timeZone: tz,
};
s.onBook?.(booking);
setBooked(booking);
setSubmitting(false);
setPanel("done");
}, 900);
return () => clearTimeout(timer);
}, [submitting, slot, name, email, notes, tz, s]);
const pickDate = (key: string) => {
setDateKey(key);
setSlot(null);
setLeavingSlot(null);
};
const pickSlot = (at: number) => {
if (slot !== null && slot !== at) setLeavingSlot(slot);
setSlot(at);
};
const submit = () => {
if (slot === null || submitting) return;
if (!name.trim() || !email.trim()) {
setToast({ id: Date.now(), text: "Name and email are required" });
return;
}
setToast(null);
setSubmitting(true);
};
const startOver = (clearForm: boolean) => {
setPanel("pick");
setDateKey(null);
setSlot(null);
if (clearForm) {
setName("");
setEmail("");
setNotes("");
}
};
const top = useSwap(panel === "done" ? "done" : "book", () => MOVE_MS);
const onForm = panel !== "pick" && slot !== null;
return (
<>
<div className="sb-scroll">
<div className="sb-page">
{top.shown === "done" && booked ? (
<div
key="done"
className={top.leaving ? "sb-out" : "sb-in"}
style={vars({ "--sb-dy": "10px", "--sb-oy": "-10px" })}
>
<Confirmed booking={booked} settings={s} hour12={hour12} onReschedule={() => startOver(false)} onCancel={() => startOver(true)} />
</div>
) : (
<div
key="book"
className={`sb-grid${top.leaving ? " sb-out" : ""}`}
style={vars({ "--sb-oy": "-10px" })}
>
<div className="sb-in" style={vars({ "--sb-dy": "14px" })}>
<HostCard
settings={s}
slotDate={onForm ? slot : null}
tz={tz}
hour12={hour12}
zones={zones}
onTzChange={onForm ? undefined : setTz}
/>
</div>
<BookPanels
panelKey={panel === "pick" ? "pick" : "form"}
pick={
<>
<div className="sb-in" style={vars({ "--sb-dy": "14px", "--sb-delay": "0.13s" })}>
<CalendarCard
view={view}
monthDir={monthDir}
today={today}
slots={slots}
selected={dateKey}
onMonth={goToMonth}
onPick={pickDate}
/>
</div>
<div className="sb-times-col sb-in" style={vars({ "--sb-dy": "14px", "--sb-delay": "0.26s" })}>
<TimesColumn
dateKey={dateKey}
slots={slots}
slot={slot}
leavingSlot={leavingSlot}
tz={tz}
hour12={hour12}
onHour12={setHour12}
threeColumns={threeColumns}
overhang={overhang}
onPick={pickSlot}
onNext={() => setPanel("form")}
/>
</div>
</>
}
form={
<ConfirmForm
name={name}
email={email}
notes={notes}
onName={setName}
onEmail={setEmail}
onNotes={setNotes}
submitting={submitting}
onBack={() => setPanel("pick")}
onSubmit={submit}
/>
}
/>
</div>
)}
</div>
</div>
{toast && (
<div key={toast.id} className="sb-toast" role="status">
<span className="sb-swatch" aria-hidden />
<span className="sb-toast-title">{toast.text}</span>
<button type="button" className="sb-toast-close" aria-label="Dismiss notification" onClick={() => setToast(null)}>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" aria-hidden>
<path d="M18 6 6 18M6 6l12 12" />
</svg>
</button>
</div>
)}
</>
);
}
function BookPanels({ panelKey, pick, form }: { panelKey: "pick" | "form"; pick: ReactNode; form: ReactNode }) {
const swap = useSwap(panelKey, () => MOVE_MS);
if (swap.shown === "form") {
return (
<div
key="form"
className={swap.leaving ? "sb-out" : swap.entering ? "sb-in" : undefined}
style={vars({ "--sb-dy": "10px", "--sb-oy": "-10px" })}
>
{form}
</div>
);
}
return (
<div key="pick" className={`sb-pick${swap.leaving ? " sb-out" : ""}`} style={vars({ "--sb-oy": "-10px" })}>
{pick}
</div>
);
}
function HostCard({
settings: s,
slotDate,
tz,
hour12,
zones,
onTzChange,
}: {
settings: Settings;
slotDate: number | null;
tz: string;
hour12: boolean;
zones: string[];
onTzChange?: (zone: string) => void;
}) {
const [avatarFailed, setAvatarFailed] = useState(false);
const options = zones.includes(tz) ? zones : [tz, ...zones];
const [shownSlot, setShownSlot] = useState(slotDate);
if (slotDate !== null && slotDate !== shownSlot) setShownSlot(slotDate);
return (
<div className="sb-host">
<div className="sb-host-head">
<span className="sb-avatar-wrap">
<span className="sb-avatar">
{s.avatarUrl && !avatarFailed ? (
<img src={s.avatarUrl} alt="" onError={() => setAvatarFailed(true)} />
) : (
<span>{(s.hostName || "?")[0].toUpperCase()}</span>
)}
</span>
{s.logoUrl && (
<span className="sb-badge">
<img src={s.logoUrl} alt="" />
</span>
)}
</span>
<div>
<p className="sb-host-name">{s.hostName}</p>
<h2 className="sb-host-title">{s.title}</h2>
</div>
</div>
{s.description && <p className="sb-host-desc">{s.description}</p>}
<div className="sb-host-row">
<ClockIcon /> {s.durationMinutes} min
</div>
{s.location && (
<div className="sb-host-row">
<VideoIcon /> {s.location}
</div>
)}
<div className="sb-reveal" data-open={slotDate !== null ? "" : undefined}>
<div>
<span className="sb-host-row">
<CalendarIcon />
{shownSlot !== null &&
new Date(shownSlot).toLocaleString("en-US", {
weekday: "long",
month: "long",
day: "numeric",
hour: "numeric",
minute: "2-digit",
hour12,
timeZone: tz,
})}
</span>
</div>
</div>
<div className="sb-host-row sb-host-tz">
<EarthIcon />
{onTzChange ? (
<select value={tz} onChange={(e) => onTzChange(e.target.value)} aria-label="Time zone">
{options.map((zone) => (
<option key={zone} value={zone}>
{formatZone(zone)}
</option>
))}
</select>
) : (
<span>{formatZone(tz)}</span>
)}
</div>
</div>
);
}
function CalendarCard({
view,
monthDir,
today,
slots,
selected,
onMonth,
onPick,
}: {
view: Date;
monthDir: number;
today: Date;
slots: Map<string, number[]>;
selected: string | null;
onMonth: (delta: number) => void;
onPick: (key: string) => void;
}) {
const swap = useSwap(localKey(view), () => MOVE_MS);
const month = parseKey(swap.shown);
const days = monthGrid(month);
const motionClass = swap.leaving ? "sb-out" : swap.entering ? "sb-in" : undefined;
const isCurrentMonth = view.getFullYear() === today.getFullYear() && view.getMonth() === today.getMonth();
return (
<div className="sb-card sb-cal">
<div className="sb-cal-head">
<div className="sb-month" aria-live="polite">
{}
<span className="sb-month-size" aria-hidden>
{monthTitle(view)}
</span>
<h3
key={swap.shown}
className={`sb-month-title${motionClass ? ` ${motionClass}` : ""}`}
style={vars({ "--sb-dx": `${monthDir * 10}px`, "--sb-ox": `${monthDir * -10}px` })}
>
{monthTitle(month)}
</h3>
</div>
<div className="sb-nav">
<button type="button" className="sb-icon-btn" onClick={() => onMonth(-1)} disabled={isCurrentMonth} aria-label="Previous month">
<ChevronLeftIcon />
</button>
<button type="button" className="sb-icon-btn" onClick={() => onMonth(1)} aria-label="Next month">
<ChevronRightIcon />
</button>
</div>
</div>
<div className="sb-dow" aria-hidden>
{["S", "M", "T", "W", "T", "F", "S"].map((d, i) => (
<div key={i}>{d}</div>
))}
</div>
<div
key={swap.shown}
className={`sb-days${motionClass ? ` ${motionClass}` : ""}`}
style={vars({ "--sb-dx": `${monthDir * 16}px`, "--sb-ox": `${monthDir * -16}px` })}
>
{days.map((d) => {
const key = localKey(d);
const inMonth = d.getMonth() === month.getMonth();
const available = inMonth && d >= today && (slots.get(key)?.length ?? 0) > 0;
if (!available) {
return (
<div key={key} className={`sb-day${inMonth ? "" : " sb-day-out"}`}>
{d.getDate()}
</div>
);
}
const isSelected = selected === key;
return (
<button
key={key}
type="button"
className="sb-day sb-glow"
aria-pressed={isSelected}
aria-label={d.toLocaleDateString("en-US", { weekday: "long", month: "long", day: "numeric" })}
onPointerMove={trackPointer}
onClick={() => onPick(key)}
>
<Glow />
<span className="sb-fill" aria-hidden />
<span className="sb-lbl">{d.getDate()}</span>
</button>
);
})}
</div>
</div>
);
}
function Glow() {
return (
<>
<span className="sb-ring" aria-hidden />
<span className="sb-wash" aria-hidden />
</>
);
}
function TimesColumn({
dateKey,
slots,
slot,
leavingSlot,
tz,
hour12,
onHour12,
threeColumns,
overhang,
onPick,
onNext,
}: {
dateKey: string | null;
slots: Map<string, number[]>;
slot: number | null;
leavingSlot: number | null;
tz: string;
hour12: boolean;
onHour12: (hour12: boolean) => void;
threeColumns: boolean;
overhang: boolean;
onPick: (at: number) => void;
onNext: () => void;
}) {
const swap = useSwap(dateKey ?? "empty", (leaving) => (leaving === "empty" ? FADE_MS : MOVE_MS));
if (swap.shown === "empty") {
return (
<div key="empty" className={`sb-empty${swap.leaving ? " sb-fade-out" : ""}`}>
Select a date to see times.
</div>
);
}
const times = slots.get(swap.shown) ?? [];
const chosen = swap.leaving ? null : slot;
const inlineNext = threeColumns && overhang;
const label = (at: number) => new Date(at).toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit", hour12, timeZone: tz });
return (
<div
key={swap.shown}
className={swap.leaving ? "sb-out" : "sb-in"}
style={vars({ "--sb-dy": "10px", "--sb-oy": "-10px" })}
>
{}
<div
className="sb-times"
style={{ width: inlineNext ? (chosen !== null ? SLOT_CARD_WIDTH_OPEN : SLOT_CARD_WIDTH) : "100%" }}
>
<div className="sb-card sb-times-card">
<div className="sb-times-head">
<h3>{parseKey(swap.shown).toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric" })}</h3>
<TimeFormatToggle hour12={hour12} onChange={onHour12} />
</div>
<div className="sb-slots" role="group" aria-label="Available times">
{times.map((at, i) => {
const selected = chosen === at;
const next = inlineNext && (selected || leavingSlot === at);
return (
<div key={at} className="sb-slot-row sb-in" style={vars({ "--sb-dy": "6px", "--sb-delay": `${i * 0.02}s` })}>
<button
type="button"
className="sb-slot sb-glow"
aria-pressed={selected}
onPointerMove={trackPointer}
onClick={() => onPick(at)}
>
<Glow />
<span className="sb-fill" aria-hidden />
<span className="sb-lbl">{label(at)}</span>
</button>
{next && (
<div className={selected ? "sb-pop-in" : "sb-pop-out"}>
<button type="button" className="sb-btn sb-btn-accent" onClick={onNext} tabIndex={selected ? 0 : -1}>
Next
</button>
</div>
)}
</div>
);
})}
</div>
{!inlineNext && (
<div className="sb-bar" data-open={chosen !== null ? "" : undefined} inert={chosen === null}>
<div>
<div className="sb-bar-pad">
<button type="button" className="sb-btn sb-btn-accent sb-btn-block" onClick={onNext}>
Next
</button>
</div>
</div>
</div>
)}
</div>
</div>
</div>
);
}
function TimeFormatToggle({ hour12, onChange }: { hour12: boolean; onChange: (hour12: boolean) => void }) {
const refs = useRef<(HTMLButtonElement | null)[]>([]);
const [pill, setPill] = useState<{ x: number; w: number; ready: boolean } | null>(null);
useLayoutEffect(() => {
const el = refs.current[hour12 ? 0 : 1];
if (!el) return;
setPill((prev) => ({ x: el.offsetLeft, w: el.offsetWidth, ready: prev !== null }));
}, [hour12]);
return (
<div role="group" aria-label="Time format" className="sb-fmt">
{pill && (
<span
className="sb-fmt-pill"
data-ready={pill.ready ? "" : undefined}
style={{ transform: `translateX(${pill.x}px)`, width: pill.w }}
aria-hidden
/>
)}
{([true, false] as const).map((is12, i) => (
<button
key={String(is12)}
ref={(el) => {
refs.current[i] = el;
}}
type="button"
aria-pressed={hour12 === is12}
onClick={() => onChange(is12)}
>
{is12 ? "12h" : "24h"}
</button>
))}
</div>
);
}
function ConfirmForm({
name,
email,
notes,
onName,
onEmail,
onNotes,
submitting,
onBack,
onSubmit,
}: {
name: string;
email: string;
notes: string;
onName: (v: string) => void;
onEmail: (v: string) => void;
onNotes: (v: string) => void;
submitting: boolean;
onBack: () => void;
onSubmit: () => void;
}) {
return (
<form
className="sb-card sb-form"
noValidate
onSubmit={(e) => {
e.preventDefault();
onSubmit();
}}
>
<h2>Confirm your details</h2>
<div className="sb-fields">
<Field label="Your name *" value={name} onChange={onName} disabled={submitting} autoComplete="name" />
<Field label="Email *" type="email" value={email} onChange={onEmail} disabled={submitting} autoComplete="email" />
<Field
label="Anything else? (optional)"
multiline
value={notes}
onChange={onNotes}
disabled={submitting}
placeholder="Share anything that will help prepare for the meeting."
/>
</div>
<div className="sb-actions">
<button type="button" className="sb-btn sb-btn-ghost" onClick={onBack} disabled={submitting}>
Back
</button>
<button type="submit" className="sb-btn sb-btn-accent" disabled={submitting}>
{submitting && <Spinner />}
Confirm booking
</button>
</div>
</form>
);
}
function Field({
label,
value,
onChange,
multiline,
...rest
}: {
label: string;
value: string;
onChange: (v: string) => void;
multiline?: boolean;
type?: string;
disabled?: boolean;
autoComplete?: string;
placeholder?: string;
}) {
const id = `sb-${label.replace(/\W+/g, "-").toLowerCase()}`;
const control = multiline ? (
<textarea id={id} rows={2} value={value} onChange={(e) => onChange(e.target.value)} placeholder={rest.placeholder ?? " "} disabled={rest.disabled} />
) : (
<input id={id} value={value} onChange={(e) => onChange(e.target.value)} placeholder=" " {...rest} />
);
return (
<div className={`sb-field${multiline ? " sb-field-multi" : ""}`} onPointerMove={trackField}>
<span className="sb-field-light" aria-hidden />
<span className="sb-field-ring" aria-hidden />
{control}
<label htmlFor={id}>{label}</label>
</div>
);
}
function Confirmed({
booking,
settings: s,
hour12,
onReschedule,
onCancel,
}: {
booking: Booking;
settings: Settings;
hour12: boolean;
onReschedule: () => void;
onCancel: () => void;
}) {
const when = new Date(booking.startUtc).toLocaleString("en-US", {
weekday: "long",
month: "long",
day: "numeric",
year: "numeric",
hour: "numeric",
minute: "2-digit",
hour12,
timeZone: booking.timeZone,
});
const addToCalendar = () => {
const stamp = (iso: string) => iso.replace(/[-:]/g, "").replace(/\.\d{3}/, "");
const text = (v: string) => v.replace(/[\\;,]/g, (c) => `\\${c}`).replace(/\n/g, "\\n");
const ics = [
"BEGIN:VCALENDAR",
"VERSION:2.0",
"PRODID:-//Booking calendar//EN",
"METHOD:PUBLISH",
"BEGIN:VEVENT",
`UID:${stamp(booking.startUtc)}-${Math.random().toString(36).slice(2)}@booking-calendar`,
`DTSTAMP:${stamp(new Date().toISOString())}`,
`DTSTART:${stamp(booking.startUtc)}`,
`DTEND:${stamp(booking.endUtc)}`,
`SUMMARY:${text(`${s.title} with ${s.hostName}`)}`,
`LOCATION:${text(s.location)}`,
"END:VEVENT",
"END:VCALENDAR",
].join("\r\n");
const url = URL.createObjectURL(new Blob([ics], { type: "text/calendar" }));
const a = document.createElement("a");
a.href = url;
a.download = `${s.title.toLowerCase().replace(/\W+/g, "-")}.ics`;
a.click();
setTimeout(() => URL.revokeObjectURL(url), 1000);
};
return (
<div className="sb-card sb-done">
<div className="sb-check">
<svg viewBox="0 0 80 80" fill="none" aria-hidden>
<circle cx="40" cy="40" r="34" pathLength={1} />
<path d="M26.5 41.5 35.5 50.5 54 31" pathLength={1} />
</svg>
</div>
<h2>You're booked.</h2>
<p className="sb-done-sub">This is a demo, so nothing was booked and no email went to {booking.email}.</p>
<div className="sb-done-rows">
<div className="sb-done-row">
<CalendarDaysIcon />
<div>
<p>{s.title}</p>
<p>with {s.hostName}</p>
</div>
</div>
<div className="sb-done-row">
<ClockIcon />
<div>
<p>{when}</p>
<p>{booking.timeZone}</p>
</div>
</div>
</div>
<div className="sb-done-links">
<button type="button" onClick={onReschedule}>
<FlipBackwardIcon />
Reschedule
</button>
<button type="button" onClick={onCancel}>
<RemoveCircleIcon />
Cancel
</button>
<button type="button" onClick={addToCalendar}>
<CalendarAddIcon />
Add to calendar
</button>
</div>
</div>
);
}
const stroke = { stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" } as const;
function Icon({ children }: { children: ReactNode }) {
return (
<svg viewBox="0 0 24 24" fill="none" aria-hidden>
{children}
</svg>
);
}
function ClockIcon() {
return (
<Icon>
<path
fill="currentColor"
fillRule="evenodd"
clipRule="evenodd"
d="M12 3.75C7.44329 3.75 3.75 7.44329 3.75 12C3.75 16.5558 7.44335 20.25 12 20.25C16.5567 20.25 20.25 16.5558 20.25 12C20.25 7.44329 16.5567 3.75 12 3.75ZM2.25 12C2.25 6.61487 6.61487 2.25 12 2.25C17.3851 2.25 21.75 6.61487 21.75 12C21.75 17.3841 17.3852 21.75 12 21.75C6.61481 21.75 2.25 17.3841 2.25 12Z"
/>
<path
fill="currentColor"
fillRule="evenodd"
clipRule="evenodd"
d="M11.6719 7.82617C12.0861 7.82617 12.4219 8.16196 12.4219 8.57617V12.2488L15.2314 13.9278C15.587 14.1403 15.703 14.6008 15.4905 14.9564C15.278 15.3119 14.8175 15.4279 14.4619 15.2154L11.2871 13.3181C11.0606 13.1827 10.9219 12.9383 10.9219 12.6743V8.57617C10.9219 8.16196 11.2577 7.82617 11.6719 7.82617Z"
/>
</Icon>
);
}
function VideoIcon() {
return (
<Icon>
<path {...stroke} d="M16.1515 9.67278C17.9896 8.21564 20.4563 6.80611 20.9229 7.31087C21.6943 8.13945 21.6277 16.0252 20.9229 16.7775C20.4943 17.2442 18.0086 15.8347 16.1515 14.3871" />
<path {...stroke} fillRule="evenodd" clipRule="evenodd" d="M2.5144 12.037C2.5144 6.84461 4.23917 5.11414 9.41536 5.11414C14.5906 5.11414 16.3154 6.84461 16.3154 12.037C16.3154 17.2284 14.5906 18.9599 9.41536 18.9599C4.23917 18.9599 2.5144 17.2284 2.5144 12.037Z" />
</Icon>
);
}
function EarthIcon() {
return (
<Icon>
<path {...stroke} fillRule="evenodd" clipRule="evenodd" d="M12 21C7.02908 21 3 16.9709 3 12C3 7.02908 7.02908 3 12 3C16.9709 3 21 7.02908 21 12C21 16.9709 16.9709 21 12 21Z" />
<path {...stroke} d="M17.3835 19.0977C17.3835 19.0977 15.2059 13.0954 21 11.9998" />
<path {...stroke} d="M20.1123 8.08805C19.1763 8.02286 17.4717 8.30308 14.9711 10.1011C11.9938 12.2456 11.3098 7.71346 12.2555 3.01302" />
<path {...stroke} d="M11.5945 21C11.5945 21 12.2075 18.4635 10.4532 17.0916C8.69895 15.7206 7.38835 15.8209 7.17041 14.0773C6.95246 12.3337 9.10468 12.0409 7.53041 9.44595C6.49127 7.73254 5.31787 6.66032 5.36165 5.95103" />
</Icon>
);
}
function CalendarIcon() {
return (
<Icon>
<path {...stroke} fillRule="evenodd" clipRule="evenodd" d="M2.74976 12.7756C2.74976 5.81959 5.06876 3.50159 12.0238 3.50159C18.9798 3.50159 21.2988 5.81959 21.2988 12.7756C21.2988 19.7316 18.9798 22.0496 12.0238 22.0496C5.06876 22.0496 2.74976 19.7316 2.74976 12.7756Z" />
<path {...stroke} d="M3.02515 9.32397H21.0331M16.4285 13.261H16.4375M12.0291 13.261H12.0381M7.62135 13.261H7.63035M16.4285 17.1129H16.4375M12.0291 17.1129H12.0381M7.62135 17.1129H7.63035M16.033 2.05005V5.31205M8.02466 2.05005V5.31205" />
</Icon>
);
}
function CalendarDaysIcon() {
return (
<Icon>
<g transform="translate(3, 2)" {...stroke}>
<path d="M0.09264 7.40426H17.91659M13.44207 11.30969H13.45134M9.00461 11.30969H9.01388M4.55789 11.30969H4.56716M13.44207 15.19622H13.45134M9.00461 15.19622H9.01388M4.55789 15.19622H4.56716M13.04372 0V3.29078M4.96551 0V3.29078" />
<path d="M13.2382655,1.57919622 L4.77096342,1.57919622 C1.83427331,1.57919622 0,3.21513002 0,6.22222222 L0,15.2718676 C0,18.3262411 1.83427331,20 4.77096342,20 L13.2290015,20 C16.1749556,20 18,18.3546099 18,15.3475177 L18,6.22222222 C18.0092289,3.21513002 16.1842196,1.57919622 13.2382655,1.57919622 Z" />
</g>
</Icon>
);
}
function FlipBackwardIcon() {
return (
<Icon>
<path {...stroke} d="M7.49049 13.0022C6.12748 11.6392 5.36301 10.8745 4 9.51145C5.36301 8.14844 6.12748 7.38449 7.49049 6.02148" />
<path {...stroke} d="M4 9.51099H15.7664C18.1046 9.51099 19.9997 11.4061 19.9997 13.7443C19.9997 16.0826 18.1046 17.9784 15.7664 17.9784H12.2824" />
</Icon>
);
}
function RemoveCircleIcon() {
return (
<Icon>
<path {...stroke} d="M21 12C21 7.02908 16.9709 3 12 3C7.02908 3 3 7.02908 3 12C3 16.9699 7.02908 21 12 21C16.9709 21 21 16.9699 21 12Z" />
<path {...stroke} d="M14.3304 9.66646L9.66792 14.329M14.3363 14.3353L9.66602 9.66504" />
</Icon>
);
}
function CalendarAddIcon() {
return (
<Icon>
<path {...stroke} d="M5.14567 8.28468C4.94095 6.9535 5.92558 5.74707 7.21675 5.74707H17.3368C18.3669 5.74707 19.2446 6.52808 19.4079 7.59009L20.9728 17.7657C21.1776 19.0969 20.1929 20.3033 18.9017 20.3033H8.78169C7.7516 20.3033 6.87394 19.5223 6.71061 18.4603L5.14567 8.28468Z" />
<path {...stroke} d="M10.2006 5.74707H6.66304C5.63295 5.74707 4.75529 6.52808 4.59196 7.59009L3.02702 17.7657C2.82229 19.0969 3.80693 20.3033 5.0981 20.3033H8.36228" />
<path {...stroke} d="M13.0593 10.8833V16.2578M15.7466 13.5706H10.3721" />
<path {...stroke} d="M9.02471 7.5044C9.21547 7.73453 9.34107 7.69894 9.59094 7.69894C10.2426 7.69894 10.7709 6.78153 10.7709 5.64985C10.7709 4.51817 10.2426 3.60076 9.59094 3.60076C9.2432 3.60076 9.03968 3.64146 8.82373 4.0571" />
<path {...stroke} d="M14.9334 7.5044C15.1242 7.73453 15.2498 7.69894 15.4996 7.69894C16.1513 7.69894 16.6795 6.78153 16.6795 5.64985C16.6795 4.51817 16.1513 3.60076 15.4996 3.60076C15.1519 3.60076 14.9484 3.64146 14.7324 4.0571" />
</Icon>
);
}
function ChevronLeftIcon() {
return (
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden>
<path fillRule="evenodd" clipRule="evenodd" d="M7.72 12.53a.75.75 0 0 1 0-1.06l7.5-7.5a.75.75 0 1 1 1.06 1.06L9.31 12l6.97 6.97a.75.75 0 1 1-1.06 1.06l-7.5-7.5Z" />
</svg>
);
}
function ChevronRightIcon() {
return (
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden>
<path fillRule="evenodd" clipRule="evenodd" d="M16.28 11.47a.75.75 0 0 1 0 1.06l-7.5 7.5a.75.75 0 0 1-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 0 1 1.06-1.06l7.5 7.5Z" />
</svg>
);
}
function Spinner() {
return (
<svg className="sb-spin" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" role="status" aria-label="Loading">
<path d="M21 12a9 9 0 1 1-6.219-8.56" />
</svg>
);
}
const css = `
@property --sb-a{syntax:"<angle>";inherits:false;initial-value:0deg}
.sb{--sb-card:#0d1219;--sb-border:#1e2125;--sb-muted:#191e24;--sb-muted-fg:#989ea4;--sb-hover:#1d232b;--sb-page:#0a0e12;--sb-ring:#60a5fa;--sb-spring:${SPRING};--sb-fade:cubic-bezier(.22,1,.36,1);--sb-colors:cubic-bezier(.4,0,.2,1);position:relative;width:100%;height:100%;overflow:hidden;isolation:isolate;container:sb/inline-size;background:#0b0d12;color:#fff;color-scheme:dark;font-family:var(--font-google-sans-flex,"Google Sans Flex"),system-ui,sans-serif;font-size:16px;line-height:1.5;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-rendering:optimizeLegibility;-webkit-tap-highlight-color:transparent}
/* Resets carry no specificity (:where), so every sb- class below wins over them. */
:where(.sb) *,:where(.sb) *::before,:where(.sb) *::after{box-sizing:border-box}
:where(.sb) :where(h2,h3,p){margin:0;font:inherit}
:where(.sb) :where(button,input,textarea,select){font:inherit;color:inherit;letter-spacing:inherit;margin:0}
:where(.sb) :where(button){background:none;border:0;padding:0;cursor:pointer;text-align:inherit}
:where(.sb) :where(button:disabled){cursor:default}
:where(.sb) :where(svg){display:block;flex-shrink:0}
:where(.sb) :where(img){display:block}
:where(.sb) :where(a){color:inherit}
:where(.sb) :focus-visible{outline:1.5px solid var(--sb-ring);outline-offset:1px}
.sb-scroll{height:100%;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:var(--sb-border) transparent}
.sb-page{max-width:896px;margin:0 auto;padding:40px 16px}
.sb-grid,.sb-pick{display:grid;gap:24px;align-items:start}
@container sb (min-width:680px){.sb-grid{grid-template-columns:300px minmax(0,1fr)}}
@container sb (min-width:840px){.sb-pick{grid-template-columns:minmax(0,1fr) 232px}}
.sb-card{border-radius:12px;border:1px solid var(--sb-border);background:var(--sb-card);color:#fafafa}
/* host */
.sb-host{position:relative;padding:20px;color:#fafafa}
.sb-host::before{content:"";position:absolute;inset:0;border-radius:12px;border:1px solid var(--sb-border);background:var(--sb-card);z-index:-1}
.sb-host-head{display:flex;align-items:center;gap:12px;margin-bottom:12px}
.sb-avatar-wrap{position:relative;flex-shrink:0}
.sb-avatar{display:flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:9999px;overflow:hidden;background:rgb(var(--sb-accent));color:#fff;font-size:16px;font-weight:600}
.sb-avatar img{width:100%;height:100%;object-fit:cover}
.sb-badge{position:absolute;right:-2px;bottom:-2px;display:flex;align-items:center;justify-content:center;width:20px;height:20px;overflow:hidden;border-radius:9999px;border:1px solid rgba(255,255,255,.1);background:var(--sb-page)}
.sb-badge img{width:100%;height:100%;border-radius:9999px;object-fit:contain}
.sb-host-name{font-size:12px;line-height:16px;color:var(--sb-muted-fg)}
.sb-host-title{font-weight:600;line-height:1.25}
.sb-host-desc{font-size:14px;line-height:20px;color:var(--sb-muted-fg);margin-bottom:12px}
.sb-host-row{display:flex;align-items:center;gap:8px;margin-bottom:6px;font-size:14px;line-height:20px;color:var(--sb-muted-fg)}
.sb-host-row svg{width:16px;height:16px}
.sb-host-tz{align-items:flex-start;margin-bottom:0}
.sb-host-tz svg{margin-top:2px}
.sb-host-tz select{width:100%;min-width:0;padding:0;border:0;border-bottom:1px solid transparent;border-radius:0;background:transparent;font-size:14px;line-height:20px;cursor:pointer;-webkit-appearance:none;appearance:none;outline:none}
.sb-host-tz select:focus-visible{border-bottom-color:var(--sb-muted-fg)}
.sb-host-tz option{background:var(--sb-card);color:#fafafa}
.sb-reveal{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows .22s var(--sb-fade),opacity .22s var(--sb-fade)}
.sb-reveal[data-open]{grid-template-rows:1fr;opacity:1}
.sb-reveal>div{min-height:0;overflow:hidden}
/* calendar */
.sb-cal{padding:16px}
.sb-cal-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px}
.sb-month{position:relative;height:24px;overflow:hidden;flex-shrink:0;font-weight:600;line-height:24px;white-space:nowrap}
.sb-month-size{visibility:hidden}
.sb-month-title{position:absolute;inset:0}
.sb-nav{display:flex;align-items:center;gap:4px}
.sb-icon-btn{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:9999px;transition:color .15s var(--sb-colors),background-color .15s var(--sb-colors)}
.sb-icon-btn svg{width:16px;height:16px}
.sb-icon-btn:disabled{opacity:.5;pointer-events:none}
@media (hover:hover){.sb-icon-btn:hover{background:var(--sb-hover);color:#f2f2f2}}
.sb-dow{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));margin-bottom:8px;font-size:12px;line-height:16px;color:var(--sb-muted-fg)}
.sb-dow div{padding:4px 0;text-align:center}
.sb-days{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px}
.sb-day{aspect-ratio:1;display:flex;align-items:center;justify-content:center;font-size:14px;line-height:20px;color:rgba(152,158,164,.4)}
.sb-day.sb-day-out{color:rgba(152,158,164,.3)}
button.sb-day{position:relative;overflow:hidden;border-radius:10px;font-weight:500;color:#fafafa}
/* card glow, shared by days and time pills */
.sb-ring{position:absolute;inset:0;z-index:1;padding:1px;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity .3s ease-out,--sb-a 0s;background:conic-gradient(from var(--sb-a),rgb(var(--sb-accent)) 0deg,transparent 90deg,transparent 270deg,rgb(var(--sb-accent)) 360deg);-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0)}
.sb-wash{position:absolute;inset:0;z-index:0;pointer-events:none;opacity:0;transition:opacity .3s ease-out;background:radial-gradient(circle at var(--mx,50%) var(--my,50%),rgba(var(--sb-accent),.1) 0%,rgba(255,255,255,0) 90%)}
@media (hover:hover){
.sb-glow:hover>.sb-ring{opacity:1;--sb-a:360deg;transition:opacity 0s,--sb-a 1s cubic-bezier(.33,1,.68,1)}
.sb-glow:hover>.sb-wash{opacity:1}
}
.sb-fill{position:absolute;inset:0;z-index:2;border-radius:6px;background:rgb(var(--sb-accent));opacity:0;transition:opacity .22s var(--sb-fade)}
.sb-slot .sb-fill{border-radius:9999px}
.sb-glow[aria-pressed=true]>.sb-fill{opacity:1}
.sb-lbl{position:relative;z-index:10;transition:color .2s var(--sb-colors)}
.sb-glow[aria-pressed=true]>.sb-lbl{color:#fff}
/* times */
.sb-times-col{min-width:0}
.sb-empty{padding-top:24px;font-size:14px;line-height:20px;color:var(--sb-muted-fg)}
.sb-times{transition:width .3s var(--sb-spring)}
.sb-times-card{padding:16px}
.sb-times-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:12px}
.sb-times-head h3{font-size:14px;line-height:20px;font-weight:600}
.sb-slots{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;padding:4px;margin:-4px}
@container sb (min-width:840px){.sb-slots{grid-template-columns:minmax(0,1fr);max-height:420px;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--sb-border) transparent}}
.sb-slot-row{display:flex;align-items:center;gap:8px;min-width:0}
.sb-slot{position:relative;overflow:hidden;width:100%;height:36px;padding:0 16px;border-radius:9999px;font-size:14px;line-height:20px;font-weight:500;text-align:center;background:var(--sb-page);box-shadow:0 0 0 1px rgba(255,255,255,.08)}
@container sb (min-width:840px){.sb-slot{width:200px;flex-shrink:0}}
.sb-fmt{position:relative;display:flex;flex-shrink:0;align-items:center;padding:2px;border-radius:9999px;background:rgba(25,30,36,.6);font-size:11px;font-weight:500}
.sb-fmt button{position:relative;z-index:1;padding:2px 8px;border-radius:9999px;color:var(--sb-muted-fg);transition:color .15s var(--sb-colors)}
.sb-fmt button[aria-pressed=true]{color:#fff}
@media (hover:hover){.sb-fmt button[aria-pressed=false]:hover{color:#fff}}
.sb-fmt-pill{position:absolute;top:2px;bottom:2px;left:0;border-radius:9999px;background:rgb(var(--sb-accent))}
.sb-fmt-pill[data-ready]{transition:transform .3s var(--sb-spring),width .3s var(--sb-spring)}
.sb-bar{position:sticky;bottom:0;z-index:20;display:grid;grid-template-rows:0fr;margin:0 -16px;border-radius:0 0 11px 11px;background:var(--sb-card);opacity:0;transition:grid-template-rows .22s var(--sb-fade),opacity .22s var(--sb-fade),margin-bottom .22s var(--sb-fade)}
.sb-bar[data-open]{grid-template-rows:1fr;margin-bottom:-16px;opacity:1}
.sb-bar>div{min-height:0;overflow:hidden}
.sb-bar-pad{padding:12px 16px 16px}
/* buttons */
.sb-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:36px;padding:8px 16px;border-radius:9999px;white-space:nowrap;font-size:14px;line-height:20px;font-weight:500}
.sb-btn:disabled{opacity:.5;pointer-events:none}
.sb-btn-block{width:100%}
.sb-btn-accent{background:rgb(var(--sb-accent));color:#fff;box-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);transition:filter .15s var(--sb-colors),opacity .15s var(--sb-colors)}
.sb-btn-ghost{transition:color .15s var(--sb-colors),background-color .15s var(--sb-colors)}
@media (hover:hover){
.sb-btn-accent:hover{filter:brightness(.95)}
.sb-btn-ghost:hover{background:rgba(var(--sb-accent),.12);color:rgb(var(--sb-accent))}
}
.sb-spin{width:16px;height:16px;margin-right:8px;animation:sb-spin 1s linear infinite}
@keyframes sb-spin{to{rotate:360deg}}
/* details form */
.sb-form{padding:24px}
.sb-form h2{margin-bottom:16px;font-size:18px;line-height:28px;font-weight:600}
.sb-fields{display:flex;flex-direction:column;gap:16px}
.sb-field{position:relative;isolation:isolate;height:52px;border:1px solid transparent;border-radius:16px;background:rgba(25,30,36,.6)}
.sb-field:has(:disabled){opacity:.5;cursor:not-allowed}
.sb-field-light{position:absolute;inset:0;z-index:1;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity .2s ease-out;background-image:radial-gradient(140px at var(--gx,50%) var(--gy,50%),rgba(255,255,255,.1) 0%,transparent 60%),radial-gradient(168px at var(--gx,50%) var(--gy,50%),rgba(255,255,255,.05),transparent 70%)}
@media (hover:hover){.sb-field:hover>.sb-field-light{opacity:1}}
.sb-field-ring{position:absolute;inset:0;z-index:3;padding:2px;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity .15s ease-out;background-image:conic-gradient(#f28a00,#f6b300,#f4d21a,#6fd34a,#16c7d9,#1a9dff,#1f5bff,#6b2bd9,#d834b7,#f04a9b,#f28a00);-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0)}
.sb-field:focus-within>.sb-field-ring{opacity:1}
.sb-field input,.sb-field textarea{position:relative;z-index:2;display:block;width:100%;border:0;border-radius:inherit;background:transparent;font-size:16px;line-height:20px;outline:none}
.sb-field input{height:100%;padding:18px 20px 4px}
.sb-field :is(input,textarea)::placeholder{color:transparent}
.sb-field :is(input,textarea):focus::placeholder{color:var(--sb-muted-fg)}
.sb-field label{position:absolute;left:20px;top:50%;z-index:3;translate:0 -50%;font-size:14px;line-height:20px;color:var(--sb-muted-fg);pointer-events:none;transition:all .15s var(--sb-colors)}
.sb-field input:is(:focus,:not(:placeholder-shown),:autofill)+label{top:.85rem;font-size:11px}
.sb-field-multi{display:flex;height:auto;min-height:96px;overflow:hidden;padding-top:24px;cursor:text}
.sb-field-multi textarea{flex:1;min-height:0;padding:0 16px 8px;border-radius:0;resize:none}
.sb-field-multi label{left:16px;top:16px;translate:none}
.sb-field-multi textarea:is(:focus,:not(:placeholder-shown))+label{top:6px;font-size:11px}
@container sb (min-width:680px){.sb-field :is(input,textarea){font-size:14px}}
.sb-actions{display:flex;justify-content:space-between;margin-top:24px}
/* confirmation */
.sb-done{max-width:512px;margin:0 auto;padding:32px;text-align:center}
.sb-check{display:flex;justify-content:center;margin-bottom:16px}
.sb-check svg{width:80px;height:80px;stroke:#22c55e;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;animation:sb-fade-in .22s var(--sb-fade) .12s both,sb-pop .3s var(--sb-spring) .12s both}
.sb-check circle{stroke-dasharray:1;stroke-dashoffset:1;rotate:-90deg;transform-origin:center;animation:sb-draw .6s cubic-bezier(.65,0,.35,1) .2s forwards}
.sb-check path{stroke-dasharray:1;stroke-dashoffset:1;animation:sb-draw .35s cubic-bezier(.65,0,.35,1) .7s forwards}
@keyframes sb-draw{to{stroke-dashoffset:0}}
@keyframes sb-pop{from{scale:.7}}
.sb-done h2{margin-bottom:8px;font-size:24px;line-height:32px;font-weight:700}
.sb-done-sub{margin-bottom:24px;font-size:14px;line-height:20px;color:var(--sb-muted-fg);overflow-wrap:anywhere}
.sb-done-rows{display:flex;flex-direction:column;gap:12px;padding-top:24px;border-top:1px solid rgba(30,33,37,.6);text-align:left}
.sb-done-row{display:flex;align-items:flex-start;gap:12px}
.sb-done-row svg{width:20px;height:20px;margin-top:2px;color:var(--sb-muted-fg)}
.sb-done-row p:first-child{font-weight:500}
.sb-done-row p+p{font-size:14px;line-height:20px;color:var(--sb-muted-fg)}
.sb-done-links{display:flex;flex-wrap:wrap;justify-content:center;gap:16px;margin-top:24px;padding-top:24px;border-top:1px solid rgba(30,33,37,.6);font-size:12px;line-height:16px;color:var(--sb-muted-fg)}
.sb-done-links button{display:inline-flex;align-items:center;gap:6px;transition:color .15s var(--sb-colors)}
.sb-done-links svg{width:16px;height:16px}
@media (hover:hover){.sb-done-links button:hover{color:#fff}}
/* footer */
/* toast */
.sb-toast{position:absolute;left:50%;bottom:24px;z-index:50;display:flex;align-items:center;gap:12px;width:min(400px,calc(100% - 32px));padding:12px;translate:-50% 0;border:1px solid hsl(0 0% 91%);border-radius:20px;background:#fff;color:#020817;font-size:13px;box-shadow:0 1px 2px rgb(17 17 34/.04),0 4px 10px -2px rgb(17 17 34/.06),0 14px 28px -8px rgb(17 17 34/.1),0 30px 56px -16px rgb(17 17 34/.14);animation:sb-fade-in .4s ease both,sb-toast .4s cubic-bezier(.21,1.02,.73,1) both}
@keyframes sb-toast{from{translate:-50% calc(100% + 24px)}}
.sb-swatch{flex-shrink:0;align-self:stretch;width:56px;min-height:40px;margin:-10px 0 -10px -10px;border-radius:18px;box-shadow:inset 0 0 0 1px rgb(0 0 0/.04);background-image:linear-gradient(135deg,hsl(2 85% 91%) 0%,hsl(350 78% 89%) 34%,hsl(336 72% 88%) 68%,hsl(20 85% 90%) 100%)}
.sb-toast-title{flex:1;min-width:0;font-size:14px;line-height:1.35;font-weight:600}
.sb-toast-close{display:flex;flex-shrink:0;align-items:center;justify-content:center;width:28px;height:28px;border:1px solid hsl(0 0% 91%)!important;border-radius:999px;background:hsl(0 0% 97%)!important;color:hsl(0 0% 46%)!important}
@media (hover:hover){.sb-toast-close:hover{background:hsl(0 0% 93.5%)!important;border-color:hsl(0 0% 84%)!important;color:hsl(0 0% 16%)!important}}
/* enter and leave: transforms spring, opacity fades */
@keyframes sb-fade-in{from{opacity:0}}
@keyframes sb-fade-out{to{opacity:0}}
@keyframes sb-move-in{from{translate:var(--sb-dx,0px) var(--sb-dy,0px)}}
@keyframes sb-move-out{to{translate:var(--sb-ox,0px) var(--sb-oy,0px)}}
@keyframes sb-scale-in{from{scale:.9}}
@keyframes sb-scale-out{to{scale:.9}}
.sb-in{animation:sb-fade-in .22s var(--sb-fade) var(--sb-delay,0s) both,sb-move-in .3s var(--sb-spring) var(--sb-delay,0s) both}
.sb-out{animation:sb-fade-out .22s var(--sb-fade) both,sb-move-out .3s var(--sb-spring) both;pointer-events:none}
.sb-fade-out{animation:sb-fade-out .22s var(--sb-fade) both;pointer-events:none}
.sb-pop-in{animation:sb-fade-in .22s var(--sb-fade) both,sb-scale-in .3s var(--sb-spring) both}
.sb-pop-out{animation:sb-fade-out .22s var(--sb-fade) both,sb-scale-out .3s var(--sb-spring) both;pointer-events:none}
@media (prefers-reduced-motion:reduce){
.sb-in{animation:sb-fade-in .22s var(--sb-fade) var(--sb-delay,0s) both}
.sb-out{animation:sb-fade-out .22s var(--sb-fade) both}
.sb-pop-in{animation:sb-fade-in .22s var(--sb-fade) both}
.sb-pop-out{animation:sb-fade-out .22s var(--sb-fade) both}
.sb-times,.sb-fmt-pill[data-ready]{transition:none}
.sb-glow:hover>.sb-ring{transition:opacity 0s}
.sb-check svg{animation:sb-fade-in .22s var(--sb-fade) both}
.sb-check circle,.sb-check path{animation:none;stroke-dashoffset:0}
.sb-toast{animation:sb-fade-in .22s ease both}
}
`;