@scopetickets/checkout 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -54,7 +54,7 @@ import {
54
54
  userTypeNames,
55
55
  withSelectedDay,
56
56
  withSelectedTime
57
- } from "./chunk-4BOPQURW.js";
57
+ } from "./chunk-GJZKPJB5.js";
58
58
 
59
59
  // src/island/CarrySlot.tsx
60
60
  import { createContext, useContext, useLayoutEffect, useRef } from "react";
@@ -1466,6 +1466,30 @@ var ScopeClient = class {
1466
1466
  signal
1467
1467
  });
1468
1468
  }
1469
+ /**
1470
+ * Tickets for any number of events or whole series in one request, each row naming the
1471
+ * events it sells for in `EventKeys`.
1472
+ *
1473
+ * THE ROUTE TO READ TICKETS FROM. `Events/{key}/Tickets` omits a timeslot at
1474
+ * `Remaining: 0` rather than reporting it sold out, so a sold-out session never reaches
1475
+ * the picker at all.
1476
+ *
1477
+ * A MISSPELT PARAMETER IS NOT REFUSED: the platform answers `200 {"Tickets":[]}`, which
1478
+ * reads exactly like an event that sells nothing.
1479
+ */
1480
+ async getTicketInformation(query, signal) {
1481
+ const params = new URLSearchParams();
1482
+ for (const key of query.events ?? []) params.append("events", key);
1483
+ for (const key of query.series ?? []) params.append("series", key);
1484
+ if (query.includeTimeslots) params.set("include_timeslots", "true");
1485
+ if (query.includeQuestions) params.set("include_questions", "true");
1486
+ const response = await this.fetch(
1487
+ `/api/v2/TicketInformation?${params}`,
1488
+ { signal }
1489
+ );
1490
+ return response.Tickets ?? [];
1491
+ }
1492
+ /** @deprecated Use getTicketInformation(), which also reports sold-out timeslots */
1469
1493
  async getEventTickets(eventKey, signal) {
1470
1494
  const response = await this.fetch(
1471
1495
  `/api/v2/Events/${eventKey}/Tickets?include_timeslots=true`,
@@ -2538,8 +2562,8 @@ function e164(dialCode, phone) {
2538
2562
  if (country === null) return null;
2539
2563
  const national = nationalDigits(phone, country);
2540
2564
  if (!isValidPhone(phone, country)) return null;
2541
- const composed = `${country.dialCode}${national}`;
2542
- return isE164(composed) ? composed : null;
2565
+ const composed2 = `${country.dialCode}${national}`;
2566
+ return isE164(composed2) ? composed2 : null;
2543
2567
  }
2544
2568
  function normalizeE164(value) {
2545
2569
  const { dialCode, national } = splitPhoneNumber(value);
@@ -3251,8 +3275,8 @@ var PURCHASE_STEPS = [
3251
3275
  name: "More Information",
3252
3276
  islandState: "details",
3253
3277
  preflightStepId: "questionnaire",
3254
- blurb: "The event\u2019s own questions \u2014 the last thing the order can still be missing. Needs the cart, which is the only source of the integer EventId the questions endpoint takes, and by here the cart is four steps old.",
3255
- excusedWhen: "The event asks nothing. A failed LOOKUP is NOT this \u2014 it resolves to a notice, because proceeding would let the buyer reach payment and be rejected server-side with nothing on screen to fix.",
3278
+ blurb: "The event\u2019s own questions \u2014 the last thing the order can still be missing. They come from the tickets and from the event\u2019s questionnaire, or its series\u2019, which is read with the cart; the answers go to every cart item once, before any charge.",
3279
+ excusedWhen: "Nothing asks \u2014 not the ticket, the event or its series. A failed LOOKUP is NOT this \u2014 it resolves to a notice, because proceeding would let the buyer reach payment and be rejected server-side with nothing on screen to fix.",
3256
3280
  collapsed: pill("Add Details")
3257
3281
  },
3258
3282
  {
@@ -4296,136 +4320,182 @@ function useCheckoutClient(appKey, source) {
4296
4320
  });
4297
4321
  }, [appKey, orgKey, environment]);
4298
4322
  }
4323
+ function readRun(info, environment) {
4324
+ const eventKeyByDay = {};
4325
+ for (const event of info.Events) eventKeyByDay[dayOf(event.Date)] = event.Key;
4326
+ const theme = info.Series?.Theme ?? info.Events[0]?.Theme;
4327
+ const artwork = runArtwork(info.Series, info.Events, ENVIRONMENT_URLS[environment].artworkUrl);
4328
+ if (artwork === void 0 && theme !== void 0 && typeof console !== "undefined") {
4329
+ console.warn(
4330
+ "[ScopeTicketsCheckout] no cart artwork resolved from this run\u2019s Theme. Expected a url in `Theme.Backgrounds[0]`. The Theme as it arrived:",
4331
+ theme
4332
+ );
4333
+ }
4334
+ return {
4335
+ info,
4336
+ events: info.Events.map((event) => ({
4337
+ eventKey: event.Key,
4338
+ name: event.Name,
4339
+ day: dayOf(event.Date)
4340
+ })),
4341
+ eventKeyByDay,
4342
+ /*
4343
+ * THE VENUE'S CLOCK, from the venue. `Venue.TimeZone` is an IANA zone and every event
4344
+ * carries its venue — `nowTime` was `00:00` for a turn, which is not a clock at all:
4345
+ * it says every slot today is still to come, which is exactly the question the time
4346
+ * picker asks it.
4347
+ */
4348
+ timeZone: info.Events[0]?.Venue?.TimeZone ?? null,
4349
+ artwork
4350
+ };
4351
+ }
4352
+ function composed({ run, wanted, today, nowTime, tickets, error }, loading) {
4353
+ const { info } = run;
4354
+ const slots = tickets.flatMap((ticket) => ticket.HasTimeslot ? ticket.Timeslots ?? [] : []);
4355
+ const slotsByDay = wanted !== null && slots.length > 0 ? { [wanted]: slots.map(toTimeslot) } : {};
4356
+ const questions = tickets.flatMap((ticket) => ticket.Questions ?? []);
4357
+ const productCurrency = tickets.map((ticket) => ticket.Currency).find((currency) => currency !== null && currency !== void 0);
4358
+ const assignments = [
4359
+ ...info.UserTypes ?? [],
4360
+ ...info.Events.flatMap((event) => event.UserTypes ?? []),
4361
+ ...tickets.flatMap((ticket) => ticket.UserTypes ?? [])
4362
+ ];
4363
+ const organisation = info.Events[0]?.Organisation;
4364
+ return {
4365
+ schedule: {
4366
+ series: { events: [...run.events] },
4367
+ today,
4368
+ nowTime,
4369
+ slotsByDay
4370
+ },
4371
+ userTypes: groupUserTypes(assignments),
4372
+ userTypeNames: userTypeNames(assignments),
4373
+ /*
4374
+ * THE QUESTIONS RIDE ON THE TICKETS, so they arrive with the slots and cost no
4375
+ * request of their own. `getQuestionnaireQuestions` wants a cart's event id, which
4376
+ * does not exist yet at the step that has to know whether to ask.
4377
+ */
4378
+ questions: [...new Map(questions.map((q) => [q.QuestionId, q])).values()],
4379
+ /*
4380
+ * WHOSE EVENT IT IS. There is no follow endpoint and there does not need to be:
4381
+ * the organisation is on every event, and it is who a buyer would want to hear
4382
+ * from again.
4383
+ *
4384
+ * NOT THE VENUE, though the event names one. A venue hosts whatever is booked
4385
+ * into it — following one subscribes a buyer to every unrelated thing that happens
4386
+ * in a building, which is not what "stay up to date" offered them. The organiser
4387
+ * is the party whose next event resembles this one.
4388
+ */
4389
+ follow: [
4390
+ organisation === void 0 ? null : { key: organisation.Key, name: organisation.Name, kind: "Organiser" }
4391
+ ].filter((entity) => entity !== null),
4392
+ /*
4393
+ * `Backgrounds[0]`, made absolute against the CDN, the run's before a night's — see
4394
+ * `runArtwork`. The platform answers with site-root paths, so the origin is the
4395
+ * whole of the work: without it every thumbnail points at the customer's own domain.
4396
+ */
4397
+ artwork: run.artwork,
4398
+ eventKeyByDay: run.eventKeyByDay,
4399
+ hasTimeslots: tickets.some((ticket) => ticket.HasTimeslot),
4400
+ limits: ticketLimits(tickets),
4401
+ /* Most specific first — a product's own, then its event's, then the run's. */
4402
+ currency: productCurrency ?? info.Events[0]?.Currency ?? info.Series?.Currency ?? void 0,
4403
+ loading,
4404
+ error: loading ? null : error
4405
+ };
4406
+ }
4299
4407
  function useCheckoutData(subjectKey, isSeries, client, enabled, day, environment = "production") {
4300
- const [data, setData] = useState5(NOTHING);
4408
+ const [run, setRun] = useState5({ status: "IDLE" });
4409
+ const [sessions, setSessions] = useState5({ status: "IDLE" });
4301
4410
  useEffect4(() => {
4302
4411
  if (!enabled || client === null) return;
4303
4412
  const abort = new AbortController();
4304
- setData((was) => ({ ...was, loading: true, error: null }));
4305
- const load = async () => {
4306
- const info = isSeries ? await client.getSeriesInfo(subjectKey, abort.signal) : await client.getEventInfo(subjectKey, abort.signal);
4307
- const eventKeyByDay = {};
4308
- for (const event of info.Events) eventKeyByDay[dayOf(event.Date)] = event.Key;
4309
- const events = info.Events.map((event) => ({
4310
- eventKey: event.Key,
4311
- name: event.Name,
4312
- day: dayOf(event.Date)
4313
- }));
4314
- const timeZone = info.Events[0]?.Venue?.TimeZone ?? null;
4315
- const now = /* @__PURE__ */ new Date();
4316
- const today = dayInZone(now, timeZone);
4317
- const wanted = day !== void 0 && day in eventKeyByDay ? day : soonestRelevantDay({ events }, today);
4318
- const forDay = wanted === null ? void 0 : eventKeyByDay[wanted];
4319
- const slotsByDay = {};
4320
- const questions = [];
4321
- let list = [];
4322
- let ticketsError = null;
4323
- if (forDay !== void 0) {
4324
- try {
4325
- list = await client.getEventTickets(forDay, abort.signal);
4326
- } catch (cause) {
4327
- ticketsError = cause instanceof Error ? cause : new Error(String(cause));
4328
- }
4329
- }
4330
- const tickets = wanted === null ? [] : [[wanted, list]];
4331
- let hasTimeslots = false;
4332
- let productCurrency;
4333
- for (const [on, forThatDay] of tickets) {
4334
- const slots = forThatDay.flatMap(
4335
- (ticket) => ticket.HasTimeslot ? ticket.Timeslots ?? [] : []
4336
- );
4337
- if (forThatDay.some((ticket) => ticket.HasTimeslot)) hasTimeslots = true;
4338
- if (slots.length > 0) slotsByDay[on] = slots.map(toTimeslot);
4339
- for (const ticket of forThatDay) {
4340
- questions.push(...ticket.Questions ?? []);
4341
- productCurrency ??= ticket.Currency ?? void 0;
4342
- }
4343
- }
4344
- const assignments = [
4345
- ...info.UserTypes ?? [],
4346
- ...info.Events.flatMap((event) => event.UserTypes ?? []),
4347
- ...list.flatMap((ticket) => ticket.UserTypes ?? [])
4348
- ];
4349
- const organisation = info.Events[0]?.Organisation;
4350
- const theme = info.Series?.Theme ?? info.Events[0]?.Theme;
4351
- const artwork = runArtwork(
4352
- info.Series,
4353
- info.Events,
4354
- ENVIRONMENT_URLS[environment].artworkUrl
4355
- );
4356
- if (artwork === void 0 && theme !== void 0 && typeof console !== "undefined") {
4413
+ setRun({ status: "LOADING" });
4414
+ const load = async () => readRun(
4415
+ isSeries ? await client.getSeriesInfo(subjectKey, abort.signal) : await client.getEventInfo(subjectKey, abort.signal),
4416
+ environment
4417
+ );
4418
+ load().then((loaded2) => {
4419
+ if (!abort.signal.aborted) setRun({ status: "LOADED", run: loaded2 });
4420
+ }).catch((cause) => {
4421
+ if (abort.signal.aborted) return;
4422
+ if (typeof console !== "undefined") {
4357
4423
  console.warn(
4358
- "[ScopeTicketsCheckout] no cart artwork resolved from this run\u2019s Theme. Expected a url in `Theme.Backgrounds[0]`. The Theme as it arrived:",
4359
- theme
4424
+ `[ScopeTicketsCheckout] could not load ${isSeries ? "series" : "event"} '${subjectKey}' from ${environment} (${ENVIRONMENT_URLS[environment].apiUrl}). If the key is right, check \`source.environment\` \u2014 it defaults to production.`,
4425
+ cause
4360
4426
  );
4361
4427
  }
4362
- return {
4363
- schedule: {
4364
- series: { events },
4365
- today,
4366
- nowTime: timeOfDayInZone(now, timeZone),
4367
- slotsByDay
4368
- },
4369
- userTypes: groupUserTypes(assignments),
4370
- userTypeNames: userTypeNames(assignments),
4371
- /*
4372
- * THE QUESTIONS RIDE ON THE TICKETS, so they arrive with the slots and cost no
4373
- * request of their own. `getQuestionnaireQuestions` wants a cart's event id, which
4374
- * does not exist yet at the step that has to know whether to ask.
4375
- */
4376
- questions: [...new Map(questions.map((q) => [q.QuestionId, q])).values()],
4377
- /*
4378
- * WHOSE EVENT IT IS. There is no follow endpoint and there does not need to be:
4379
- * the organisation is on every event, and it is who a buyer would want to hear
4380
- * from again.
4381
- *
4382
- * NOT THE VENUE, though the event names one. A venue hosts whatever is booked
4383
- * into it — following one subscribes a buyer to every unrelated thing that happens
4384
- * in a building, which is not what "stay up to date" offered them. The organiser
4385
- * is the party whose next event resembles this one.
4386
- */
4387
- follow: [
4388
- organisation === void 0 ? null : { key: organisation.Key, name: organisation.Name, kind: "Organiser" }
4389
- ].filter((entity) => entity !== null),
4390
- /*
4391
- * `Backgrounds[0]`, made absolute against the CDN, the run's before a night's — see
4392
- * `runArtwork`. The platform answers with site-root paths, so the origin is the
4393
- * whole of the work: without it every thumbnail points at the customer's own domain.
4394
- */
4395
- artwork,
4396
- eventKeyByDay,
4397
- hasTimeslots,
4398
- limits: ticketLimits(list),
4399
- ticketsError,
4400
- /* Most specific first — a product's own, then its event's, then the run's. */
4401
- currency: productCurrency ?? info.Events[0]?.Currency ?? info.Series?.Currency ?? void 0
4402
- };
4428
+ setRun({
4429
+ status: "ERROR",
4430
+ error: cause instanceof Error ? cause : new Error(String(cause))
4431
+ });
4432
+ });
4433
+ return () => abort.abort();
4434
+ }, [client, subjectKey, isSeries, enabled, environment]);
4435
+ const loaded = run.status === "LOADED" ? run.run : void 0;
4436
+ const wanted = useMemo3(() => {
4437
+ if (loaded === void 0) return null;
4438
+ if (day !== void 0 && day in loaded.eventKeyByDay) return day;
4439
+ return soonestRelevantDay({ events: loaded.events }, dayInZone(/* @__PURE__ */ new Date(), loaded.timeZone));
4440
+ }, [loaded, day]);
4441
+ useEffect4(() => {
4442
+ if (!enabled || client === null || loaded === void 0) return;
4443
+ const abort = new AbortController();
4444
+ const now = /* @__PURE__ */ new Date();
4445
+ const asked = {
4446
+ run: loaded,
4447
+ wanted,
4448
+ today: dayInZone(now, loaded.timeZone),
4449
+ nowTime: timeOfDayInZone(now, loaded.timeZone)
4403
4450
  };
4404
- load().then(({ ticketsError, ...loaded }) => {
4451
+ const eventKey = wanted === null ? void 0 : loaded.eventKeyByDay[wanted];
4452
+ if (eventKey === void 0) {
4453
+ setSessions({ status: "SETTLED", day: { ...asked, tickets: [], error: null } });
4454
+ return;
4455
+ }
4456
+ setSessions((was) => ({
4457
+ status: "LOADING",
4458
+ previous: was.status === "SETTLED" ? was.day : was.status === "LOADING" ? was.previous : void 0
4459
+ }));
4460
+ client.getTicketInformation(
4461
+ { events: [eventKey], includeTimeslots: true, includeQuestions: true },
4462
+ abort.signal
4463
+ ).then((tickets) => {
4405
4464
  if (abort.signal.aborted) return;
4406
- if (ticketsError !== null && typeof console !== "undefined") {
4407
- console.warn(
4408
- "[ScopeTicketsCheckout] could not load tickets for this day; sessions, questions and user types will be missing.",
4409
- ticketsError
4410
- );
4411
- }
4412
- setData({ ...loaded, loading: false, error: ticketsError });
4465
+ setSessions({ status: "SETTLED", day: { ...asked, tickets, error: null } });
4413
4466
  }).catch((cause) => {
4414
4467
  if (abort.signal.aborted) return;
4468
+ const error = cause instanceof Error ? cause : new Error(String(cause));
4415
4469
  if (typeof console !== "undefined") {
4416
4470
  console.warn(
4417
- `[ScopeTicketsCheckout] could not load ${isSeries ? "series" : "event"} '${subjectKey}' from ${environment} (${ENVIRONMENT_URLS[environment].apiUrl}). If the key is right, check \`source.environment\` \u2014 it defaults to production.`,
4418
- cause
4471
+ "[ScopeTicketsCheckout] could not load tickets for this day; sessions, questions and user types will be missing.",
4472
+ error
4419
4473
  );
4420
4474
  }
4421
- setData({
4422
- ...NOTHING,
4423
- error: cause instanceof Error ? cause : new Error(String(cause))
4424
- });
4475
+ setSessions({ status: "SETTLED", day: { ...asked, tickets: [], error } });
4425
4476
  });
4426
4477
  return () => abort.abort();
4427
- }, [client, subjectKey, isSeries, enabled, day, environment]);
4428
- return enabled ? data : NOTHING;
4478
+ }, [client, enabled, loaded, wanted]);
4479
+ return useMemo3(() => {
4480
+ if (!enabled) return NOTHING;
4481
+ switch (run.status) {
4482
+ case "IDLE":
4483
+ return NOTHING;
4484
+ case "LOADING":
4485
+ return { ...NOTHING, loading: true };
4486
+ case "ERROR":
4487
+ return { ...NOTHING, error: run.error };
4488
+ case "LOADED": {
4489
+ const shown = sessions.status === "SETTLED" ? sessions.day : sessions.status === "LOADING" ? sessions.previous : void 0;
4490
+ if (shown === void 0 || shown.run !== run.run) return { ...NOTHING, loading: true };
4491
+ return composed(shown, sessions.status === "LOADING");
4492
+ }
4493
+ default: {
4494
+ const exhaustive = run;
4495
+ return exhaustive;
4496
+ }
4497
+ }
4498
+ }, [enabled, run, sessions]);
4429
4499
  }
4430
4500
 
4431
4501
  // src/data/useAccountGateway.ts
@@ -5626,6 +5696,171 @@ function productForSession(tickets, session) {
5626
5696
  return sells.find((ticket) => ticket.Available) ?? sells[0];
5627
5697
  }
5628
5698
 
5699
+ // src/domain/questionnaire.ts
5700
+ var AGREED = "true";
5701
+ var NOT_AGREED = "false";
5702
+ function questionType(type) {
5703
+ switch (type.trim().toLowerCase()) {
5704
+ case "text":
5705
+ return "TEXT";
5706
+ case "boolean":
5707
+ return "AGREEMENT";
5708
+ case "integer":
5709
+ return "INTEGER";
5710
+ default:
5711
+ return null;
5712
+ }
5713
+ }
5714
+ function questionKind(question) {
5715
+ const type = questionType(question.Type);
5716
+ switch (type) {
5717
+ case "TEXT":
5718
+ return "TEXT";
5719
+ case "AGREEMENT":
5720
+ return "AGREEMENT";
5721
+ case "INTEGER":
5722
+ return "INTEGER";
5723
+ // Unknown types are asked as text rather than dropped.
5724
+ case null:
5725
+ return "TEXT";
5726
+ default: {
5727
+ const exhaustive = type;
5728
+ return exhaustive;
5729
+ }
5730
+ }
5731
+ }
5732
+ function questionAnswered(kind, value) {
5733
+ switch (kind) {
5734
+ case "TEXT":
5735
+ return (value ?? "").trim().length > 0;
5736
+ case "AGREEMENT":
5737
+ return value === AGREED;
5738
+ case "INTEGER":
5739
+ return wholeNumber(value) !== null;
5740
+ default: {
5741
+ const exhaustive = kind;
5742
+ return exhaustive;
5743
+ }
5744
+ }
5745
+ }
5746
+ function wholeNumber(value) {
5747
+ const text = (value ?? "").trim();
5748
+ if (!/^[+-]?\d{1,10}$/.test(text)) return null;
5749
+ const parsed = Number(text);
5750
+ return parsed >= -2147483648 && parsed <= 2147483647 ? text : null;
5751
+ }
5752
+ function questionsAnswered(questions, answers) {
5753
+ return questions.every(
5754
+ (question) => questionAnswered(questionKind(question), answers[String(question.QuestionId)])
5755
+ );
5756
+ }
5757
+ var MAX_ANSWER_LENGTH = 200;
5758
+ var QUESTION_KEY = /^\d{1,12}$/;
5759
+ function hostAnswers(raw) {
5760
+ if (raw === null || typeof raw !== "object") return {};
5761
+ const kept = {};
5762
+ for (const [key, value] of Object.entries(raw)) {
5763
+ if (!QUESTION_KEY.test(key) || typeof value !== "string") continue;
5764
+ const answer = value.trim();
5765
+ if (answer.length > MAX_ANSWER_LENGTH) continue;
5766
+ kept[key] = answer;
5767
+ }
5768
+ return kept;
5769
+ }
5770
+ function responsesFor(items, questions, answers) {
5771
+ const values = [];
5772
+ for (const question of questions) {
5773
+ const value = answers[String(question.QuestionId)];
5774
+ const kind = questionKind(question);
5775
+ switch (kind) {
5776
+ case "TEXT": {
5777
+ const text = (value ?? "").trim();
5778
+ if (text.length > 0 && text.length <= MAX_ANSWER_LENGTH) {
5779
+ values.push({ QuestionId: question.QuestionId, Value: text });
5780
+ }
5781
+ break;
5782
+ }
5783
+ case "AGREEMENT":
5784
+ if (value === AGREED || value === NOT_AGREED) {
5785
+ values.push({ QuestionId: question.QuestionId, Value: value });
5786
+ }
5787
+ break;
5788
+ case "INTEGER": {
5789
+ const number = wholeNumber(value);
5790
+ if (number !== null) values.push({ QuestionId: question.QuestionId, Value: number });
5791
+ break;
5792
+ }
5793
+ default: {
5794
+ const exhaustive = kind;
5795
+ return exhaustive;
5796
+ }
5797
+ }
5798
+ }
5799
+ if (values.length === 0) return [];
5800
+ return items.map((item) => ({
5801
+ ItemKey: item.Key,
5802
+ Values: values.map((entry) => ({ ...entry }))
5803
+ }));
5804
+ }
5805
+ function answersLocked(save) {
5806
+ switch (save.status) {
5807
+ case "IDLE":
5808
+ return false;
5809
+ case "SAVING":
5810
+ case "SAVED":
5811
+ return true;
5812
+ case "FAILED":
5813
+ return save.partly;
5814
+ default: {
5815
+ const exhaustive = save;
5816
+ return exhaustive;
5817
+ }
5818
+ }
5819
+ }
5820
+ var MAX_QUESTION_TEXT = 1e3;
5821
+ var MAX_QUESTION_TYPE = 40;
5822
+ function guardQuestions(raw) {
5823
+ if (!Array.isArray(raw)) return [];
5824
+ return raw.flatMap((entry) => {
5825
+ if (entry === null || typeof entry !== "object") return [];
5826
+ const { QuestionId, Question, Type } = entry;
5827
+ if (typeof QuestionId !== "number" || !Number.isSafeInteger(QuestionId)) return [];
5828
+ if (typeof Question !== "string" || Question.trim() === "") return [];
5829
+ if (Question.length > MAX_QUESTION_TEXT) return [];
5830
+ if (typeof Type !== "string" || Type.length > MAX_QUESTION_TYPE) return [];
5831
+ return [{ QuestionId, Question, Type }];
5832
+ });
5833
+ }
5834
+ function mergeQuestions(eventQuestions, ticketQuestions) {
5835
+ const seen = /* @__PURE__ */ new Set();
5836
+ const merged = [];
5837
+ for (const question of [...eventQuestions, ...ticketQuestions]) {
5838
+ if (seen.has(question.QuestionId)) continue;
5839
+ seen.add(question.QuestionId);
5840
+ merged.push(question);
5841
+ }
5842
+ return merged;
5843
+ }
5844
+ function questionsInHand(ticketQuestions, load, hasCart) {
5845
+ if (!hasCart) return { status: "READY", questions: guardQuestions(ticketQuestions) };
5846
+ switch (load.status) {
5847
+ case "IDLE":
5848
+ case "LOADING":
5849
+ return { status: "PENDING" };
5850
+ case "LOADED":
5851
+ return {
5852
+ status: "READY",
5853
+ questions: mergeQuestions(load.questions, guardQuestions(ticketQuestions))
5854
+ };
5855
+ case "FAILED":
5856
+ return { status: "FAILED" };
5857
+ default: {
5858
+ const exhaustive = load;
5859
+ return exhaustive;
5860
+ }
5861
+ }
5862
+ }
5863
+
5629
5864
  // src/domain/promo.ts
5630
5865
  function promoSaved(cart, currency) {
5631
5866
  if (currency === void 0) return null;
@@ -5653,8 +5888,23 @@ var IDLE = {
5653
5888
  items: [],
5654
5889
  currency: void 0,
5655
5890
  productName: void 0,
5656
- payment: void 0
5891
+ payment: void 0,
5892
+ answers: { status: "IDLE" },
5893
+ eventQuestions: { status: "IDLE" }
5657
5894
  };
5895
+ async function eventQuestionsFor(client, cart) {
5896
+ if (client === null) return { status: "IDLE" };
5897
+ if (typeof cart.EventId !== "number")
5898
+ return { status: "FAILED", reason: "The cart names no event" };
5899
+ try {
5900
+ return {
5901
+ status: "LOADED",
5902
+ questions: guardQuestions(await client.getQuestionnaireQuestions(cart.EventId))
5903
+ };
5904
+ } catch (cause) {
5905
+ return { status: "FAILED", reason: cause instanceof Error ? cause.message : String(cause) };
5906
+ }
5907
+ }
5658
5908
  var POLL_MS = 2e3;
5659
5909
  function toQuote(cart, currency) {
5660
5910
  if (currency === void 0) return void 0;
@@ -5737,7 +5987,7 @@ function useCheckoutOrder(client, request, currency, open, adopt, userTypeNames2
5737
5987
  const cart = withExpiry(await client.createCart(mark), opening);
5738
5988
  held.current = opening;
5739
5989
  asking = `reading the tickets on '${mark}'`;
5740
- const tickets = await client.getEventTickets(mark);
5990
+ const tickets = await client.getTicketInformation({ events: [mark], includeTimeslots: true });
5741
5991
  const asked = safeParse(timeslot, null) ?? void 0;
5742
5992
  const session = sessionFor(tickets, asked);
5743
5993
  const product = productForSession(tickets, session);
@@ -5787,9 +6037,18 @@ function useCheckoutOrder(client, request, currency, open, adopt, userTypeNames2
5787
6037
  productName: product.Name
5788
6038
  };
5789
6039
  };
5790
- load().then(({ cart, items, fill, currency: filled2, productName }) => {
6040
+ load().then(async ({ cart, items, fill, currency: filled2, productName }) => {
6041
+ const eventQuestions = await eventQuestionsFor(client, cart);
5791
6042
  if (!live) return;
5792
- setState((was) => ({ ...was, cart, items, fill, currency: filled2, productName }));
6043
+ setState((was) => ({
6044
+ ...was,
6045
+ cart,
6046
+ items,
6047
+ fill,
6048
+ currency: filled2,
6049
+ productName,
6050
+ eventQuestions
6051
+ }));
5793
6052
  }).catch((cause) => {
5794
6053
  if (!live) return;
5795
6054
  opened.current = null;
@@ -5862,6 +6121,44 @@ function useCheckoutOrder(client, request, currency, open, adopt, userTypeNames2
5862
6121
  },
5863
6122
  [client, state.cart?.Key]
5864
6123
  );
6124
+ const savedAnswers = useRef12(null);
6125
+ const saveAnswers = useCallback11(
6126
+ async (questions, answers) => {
6127
+ const cartKey = state.cart?.Key;
6128
+ if (client === null || cartKey === void 0) return false;
6129
+ const was = savedAnswers.current;
6130
+ const landed = was !== null && was.cartKey === cartKey && was.items.size > 0 ? was : null;
6131
+ const requests = landed === null ? responsesFor(state.items, questions, answers) : state.items.map((item) => ({
6132
+ ItemKey: item.Key,
6133
+ Values: landed.values.map((value) => ({ ...value }))
6134
+ }));
6135
+ if (requests.length === 0) return true;
6136
+ const saved = landed?.items ?? /* @__PURE__ */ new Set();
6137
+ savedAnswers.current = { cartKey, values: requests[0]?.Values ?? [], items: saved };
6138
+ const unsent = requests.filter((request2) => !saved.has(request2.ItemKey));
6139
+ if (unsent.length === 0) return true;
6140
+ setState((held2) => ({ ...held2, answers: { status: "SAVING" } }));
6141
+ for (const request2 of unsent) {
6142
+ try {
6143
+ await client.submitQuestionnaireResponses(cartKey, request2);
6144
+ saved.add(request2.ItemKey);
6145
+ } catch (cause) {
6146
+ setState((held2) => ({
6147
+ ...held2,
6148
+ answers: {
6149
+ status: "FAILED",
6150
+ reason: cause instanceof Error ? cause.message : String(cause),
6151
+ partly: saved.size > 0
6152
+ }
6153
+ }));
6154
+ return false;
6155
+ }
6156
+ }
6157
+ setState((held2) => ({ ...held2, answers: { status: "SAVED" } }));
6158
+ return true;
6159
+ },
6160
+ [client, state.cart?.Key, state.items]
6161
+ );
5865
6162
  const [promo, setPromo] = useState13({ status: "IDLE" });
5866
6163
  const writePromo = useCallback11(
5867
6164
  async (write) => {
@@ -5943,6 +6240,14 @@ function useCheckoutOrder(client, request, currency, open, adopt, userTypeNames2
5943
6240
  setWatching(false);
5944
6241
  setState((was) => was.payment === void 0 ? was : { ...was, payment: void 0 });
5945
6242
  }, []);
6243
+ const retryEventQuestions = useCallback11(() => {
6244
+ const cart = state.cart;
6245
+ if (cart === null) return;
6246
+ setState((was) => ({ ...was, eventQuestions: { status: "LOADING" } }));
6247
+ void eventQuestionsFor(client, cart).then(
6248
+ (eventQuestions) => setState((was) => was.cart?.Key === cart.Key ? { ...was, eventQuestions } : was)
6249
+ );
6250
+ }, [client, state.cart]);
5946
6251
  const restart = useCallback11(() => {
5947
6252
  opened.current = null;
5948
6253
  held.current = null;
@@ -5960,6 +6265,7 @@ function useCheckoutOrder(client, request, currency, open, adopt, userTypeNames2
5960
6265
  quote: state.cart === null ? void 0 : toQuote(state.cart, filled ?? currency),
5961
6266
  hold: state.cart === null ? void 0 : toHold(state.cart, Date.now(), held.current),
5962
6267
  saveBuyer,
6268
+ saveAnswers,
5963
6269
  promo,
5964
6270
  applyPromo,
5965
6271
  removePromo,
@@ -5968,7 +6274,8 @@ function useCheckoutOrder(client, request, currency, open, adopt, userTypeNames2
5968
6274
  paidWithoutFinalizing,
5969
6275
  retryPayment,
5970
6276
  chargeAttempted,
5971
- restart
6277
+ restart,
6278
+ retryEventQuestions
5972
6279
  };
5973
6280
  }
5974
6281
 
@@ -6168,6 +6475,7 @@ function TextField({
6168
6475
  placeholder,
6169
6476
  maxLength,
6170
6477
  autoFocus = false,
6478
+ readOnly = false,
6171
6479
  id,
6172
6480
  name
6173
6481
  }) {
@@ -6216,6 +6524,7 @@ function TextField({
6216
6524
  value,
6217
6525
  placeholder,
6218
6526
  maxLength,
6527
+ readOnly,
6219
6528
  onChange: (event) => {
6220
6529
  const typed = event.target.value;
6221
6530
  const before = typed.slice(0, event.target.selectionStart ?? typed.length);
@@ -6820,6 +7129,21 @@ var NOTICES = {
6820
7129
  */
6821
7130
  actions: [secondary("CLOSE", "Close")]
6822
7131
  },
7132
+ QUESTIONS_NOT_LOADED: {
7133
+ id: "QUESTIONS_NOT_LOADED",
7134
+ severity: "FAILURE",
7135
+ title: "We Could Not Load the Questions",
7136
+ subtitle: "This event asks a few questions before checkout, and they did not reach us just now.",
7137
+ actions: [confirm("RETRY", "Try Again"), secondary("CLOSE", "Close")]
7138
+ },
7139
+ ANSWERS_NOT_SAVED: {
7140
+ id: "ANSWERS_NOT_SAVED",
7141
+ severity: "FAILURE",
7142
+ title: "We Could Not Save Your Answers",
7143
+ // Every path to a charge saves the answers first, so nothing has been charged.
7144
+ subtitle: "Your answers did not reach us just now. Nothing has been charged.",
7145
+ actions: [confirm("RETRY", "Try Again"), secondary("CLOSE", "Close")]
7146
+ },
6823
7147
  /*
6824
7148
  * THE COUNTERPART OF THE CHARGE PROMISE, and the reason both of these say it. Before a
6825
7149
  * payment the reassurance a buyer needs is that no money moved; after one it is the
@@ -6986,6 +7310,12 @@ function raiseForSignIn(signIn2, funnel) {
6986
7310
  function raiseForFeedback(submission) {
6987
7311
  return submission.status === "FAILED" ? NOTICES.FEEDBACK_NOT_SENT : null;
6988
7312
  }
7313
+ function raiseForQuestions(load) {
7314
+ return load.status === "FAILED" ? NOTICES.QUESTIONS_NOT_LOADED : null;
7315
+ }
7316
+ function raiseForAnswers(answers) {
7317
+ return answers.status === "FAILED" ? NOTICES.ANSWERS_NOT_SAVED : null;
7318
+ }
6989
7319
  function noticeTelemetry(severity) {
6990
7320
  return severity === "WARNING" ? "BREADCRUMB" : "EXCEPTION";
6991
7321
  }
@@ -8133,6 +8463,7 @@ var SIGN_IN_FUNNEL_CARD = {
8133
8463
  * still running, unlike the design.
8134
8464
  */
8135
8465
  };
8466
+ var DETAILS_SAVED_SUBTITLE = "Your answers are saved with this order and can no longer be changed.";
8136
8467
 
8137
8468
  // src/island/island-hero.tsx
8138
8469
  var HERO_TRANSITION_KEY = "checkout:hero";
@@ -8274,7 +8605,7 @@ async function read(client, subject, day) {
8274
8605
  if (client === null || subject === void 0) return NOTHING2;
8275
8606
  const eventKey = await eventKeyFor(client, subject, day);
8276
8607
  if (eventKey === null) return NOTHING2;
8277
- const tickets = await client.getEventTickets(eventKey);
8608
+ const tickets = await client.getTicketInformation({ events: [eventKey], includeQuestions: true });
8278
8609
  return {
8279
8610
  sellsSessions: tickets.some((ticket) => ticket.HasTimeslot),
8280
8611
  asksQuestions: tickets.some((ticket) => (ticket.Questions ?? []).length > 0)
@@ -10118,7 +10449,16 @@ function PurchaseIsland({
10118
10449
  [userTypes, fetched.userTypes, partyAsking]
10119
10450
  );
10120
10451
  const standing = useMemo11(() => foldIntent(intent, collected), [intent, collected]);
10452
+ const [walkQuestionnaire, setWalkQuestionnaire] = useState23({ hasCart: false, load: { status: "IDLE" } });
10453
+ const walkQuestions = useMemo11(
10454
+ () => questionsInHand(fetched.questions, walkQuestionnaire.load, walkQuestionnaire.hasCart),
10455
+ [fetched.questions, walkQuestionnaire]
10456
+ );
10121
10457
  const orderedBuyer = useMemo11(() => orderBuyer(standing, session.auth), [standing, session.auth]);
10458
+ const answersInHand = useMemo11(
10459
+ () => ({ ...hostAnswers(intent?.answers), ...collected.answers }),
10460
+ [intent?.answers, collected.answers]
10461
+ );
10122
10462
  const situation = useMemo11(
10123
10463
  () => ({
10124
10464
  name: "The host composes what it holds",
@@ -10139,12 +10479,13 @@ function PurchaseIsland({
10139
10479
  */
10140
10480
  excused: [
10141
10481
  ...excusedByIntent(
10142
- /*
10143
- * WHAT THE EVENT ACTUALLY ASKS, where the platform said. `asksQuestions` is a
10144
- * host's claim; the tickets carry the questions, so a run that asks none excuses
10145
- * the step without anybody having to remember to say so.
10146
- */
10147
- fetched.questions.length > 0 ? { ...intent, asksQuestions: true } : intent
10482
+ // Unknown or failed questions keep the step.
10483
+ walkQuestions.status !== "READY" || walkQuestions.questions.length > 0 ? {
10484
+ ...intent,
10485
+ asksQuestions: true,
10486
+ // Host answers skip the step only if they cover every question.
10487
+ answers: walkQuestions.status === "READY" && !questionsAnswered(walkQuestions.questions, hostAnswers(intent.answers)) ? void 0 : intent.answers
10488
+ } : intent
10148
10489
  ),
10149
10490
  /*
10150
10491
  * AND A RUN THAT SELLS NO SESSIONS IS NOT ASKED FOR ONE. `HasTimeslot` is the
@@ -10165,7 +10506,7 @@ function PurchaseIsland({
10165
10506
  savedPaymentMethod: intent.paymentMethodKey !== void 0,
10166
10507
  devicePasskey: false
10167
10508
  }),
10168
- [intent, fetched.questions.length, fetched.hasTimeslots, photos.length]
10509
+ [intent, walkQuestions, fetched.hasTimeslots, photos.length]
10169
10510
  );
10170
10511
  const [accountChosen, setAccountChosen] = useState23(false);
10171
10512
  const [passwordRevealed, setPasswordRevealed] = useState23(false);
@@ -10271,6 +10612,19 @@ function PurchaseIsland({
10271
10612
  */
10272
10613
  userTypeNames2
10273
10614
  );
10615
+ const questionnaire = useMemo11(
10616
+ () => questionsInHand(fetched.questions, order.eventQuestions, order.cart !== null),
10617
+ [fetched.questions, order.eventQuestions, order.cart]
10618
+ );
10619
+ const answersReady = questionnaire.status === "READY" && questionsAnswered(questionnaire.questions, answersInHand);
10620
+ const answersSaved = answersLocked(order.answers);
10621
+ useEffect18(() => {
10622
+ setWalkQuestionnaire({ hasCart: order.cart !== null, load: order.eventQuestions });
10623
+ }, [order.cart, order.eventQuestions]);
10624
+ const saveForCharge = useCallback18(
10625
+ () => questionnaire.status !== "READY" || !answersReady ? Promise.resolve(false) : order.saveAnswers(questionnaire.questions, answersInHand).then((saved) => saved && order.saveBuyer(buyerDetails(orderedBuyer))),
10626
+ [order, questionnaire, answersReady, answersInHand, orderedBuyer]
10627
+ );
10274
10628
  useEffect18(() => {
10275
10629
  if (order.fill.status !== "FAILED" || typeof console === "undefined") return;
10276
10630
  console.warn(
@@ -10344,6 +10698,11 @@ function PurchaseIsland({
10344
10698
  const index = Math.min(Math.max(from, floor), last);
10345
10699
  const walked = walk.stops[index]?.step ?? "REVIEW";
10346
10700
  const stepId = detour ?? (outcome?.kind === "FAILED" ? "PAYMENT_FAILED" : walked);
10701
+ useEffect18(() => {
10702
+ if (questionnaire.status !== "READY" || answersReady || floor > 0) return;
10703
+ const details = walk.stops.findIndex((stop) => stop.step === "DETAILS");
10704
+ if (details !== -1 && from > details) setAt("DETAILS");
10705
+ }, [questionnaire.status, answersReady, floor, walk.stops, from]);
10347
10706
  const passkeyRegistration = usePasskeyRegistration(accounts, stepId === "PASSKEY");
10348
10707
  const step = purchaseStep(stepId);
10349
10708
  const ratedTicket = outcome?.kind === "PLACED" ? outcome.attendeeTicketKey : void 0;
@@ -10405,7 +10764,7 @@ function PurchaseIsland({
10405
10764
  setRevolutCart(key);
10406
10765
  setSavedRevolutCart(null);
10407
10766
  }
10408
- void order.saveBuyer(buyerDetails(orderedBuyer)).then((saved) => {
10767
+ void saveForCharge().then((saved) => {
10409
10768
  if (!saved || selectionRequest.current !== request) return;
10410
10769
  if (wallet) setSavedWalletCart(key);
10411
10770
  else setSavedRevolutCart(key);
@@ -10424,7 +10783,7 @@ function PurchaseIsland({
10424
10783
  const funnel = useAuthFunnel(signIns, auth);
10425
10784
  useSessionGuard(client, auth);
10426
10785
  const raised = useMemo11(
10427
- () => raiseFor(order.fill) ?? raiseForAccount(accountFlow.progress, accountFlow.outcome) ?? raiseForSignIn(signIn2.state, funnel.state) ?? /*
10786
+ () => raiseFor(order.fill) ?? raiseForQuestions(order.eventQuestions) ?? raiseForAnswers(order.answers) ?? raiseForAccount(accountFlow.progress, accountFlow.outcome) ?? raiseForSignIn(signIn2.state, funnel.state) ?? /*
10428
10787
  * THE RATING LAST, because it is the least of them. Everything above is about the
10429
10788
  * order or the way into an account; a rating that did not send is news about a
10430
10789
  * courtesy, and a buyer holding both should be told about the one that matters.
@@ -10432,6 +10791,8 @@ function PurchaseIsland({
10432
10791
  raiseForFeedback(feedback.submission),
10433
10792
  [
10434
10793
  order.fill,
10794
+ order.eventQuestions,
10795
+ order.answers,
10435
10796
  accountFlow.progress,
10436
10797
  accountFlow.outcome,
10437
10798
  signIn2.state,
@@ -10451,6 +10812,15 @@ function PurchaseIsland({
10451
10812
  if (raised?.id === "SIGN_IN_NOT_COMPLETED") signIn2.retry();
10452
10813
  if (raised?.id === "SIGN_IN_UNREACHABLE") funnel.open(standing.buyer?.email ?? "");
10453
10814
  if (raised?.id === "FEEDBACK_NOT_SENT") feedback.retry();
10815
+ if (raised?.id === "QUESTIONS_NOT_LOADED") order.retryEventQuestions();
10816
+ if (raised?.id === "ANSWERS_NOT_SAVED") {
10817
+ const key = order.cart?.Key;
10818
+ void saveForCharge().then((saved) => {
10819
+ if (!saved || key === void 0) return;
10820
+ setSavedRevolutCart(key);
10821
+ setSavedWalletCart(key);
10822
+ });
10823
+ }
10454
10824
  if (raised?.id === "ACCOUNT_NOT_CREATED") {
10455
10825
  accountFlow.create(
10456
10826
  {
@@ -10474,7 +10844,9 @@ function PurchaseIsland({
10474
10844
  collected.firstName,
10475
10845
  collected.lastName,
10476
10846
  collected.phone,
10477
- walk.stops
10847
+ walk.stops,
10848
+ saveForCharge,
10849
+ order
10478
10850
  ]
10479
10851
  );
10480
10852
  const forward = useCallback18(() => {
@@ -10650,7 +11022,7 @@ function PurchaseIsland({
10650
11022
  }
10651
11023
  if (action.pays === true) {
10652
11024
  return () => {
10653
- void order.saveBuyer(buyerDetails(orderedBuyer)).then((saved) => {
11025
+ void saveForCharge().then((saved) => {
10654
11026
  if (!saved) return;
10655
11027
  setSubmitSignal((was) => was + 1);
10656
11028
  });
@@ -10670,7 +11042,7 @@ function PurchaseIsland({
10670
11042
  detour,
10671
11043
  forward,
10672
11044
  order,
10673
- orderedBuyer,
11045
+ saveForCharge,
10674
11046
  walletCharging,
10675
11047
  /* The funnel's prefill is the address TYPED, not the order's — see its press below. */
10676
11048
  standing.buyer?.email,
@@ -10910,16 +11282,16 @@ function PurchaseIsland({
10910
11282
  };
10911
11283
  useEffect18(() => {
10912
11284
  const key = order.cart?.Key;
10913
- if (stepId !== "REVIEW" || key === void 0 || revolutCart === key) return;
11285
+ if (stepId !== "REVIEW" || key === void 0 || revolutCart === key || !answersReady) return;
10914
11286
  setRevolutCart(key);
10915
11287
  setWalletCart(key);
10916
11288
  const request = ++selectionRequest.current;
10917
- void order.saveBuyer(buyerDetails(orderedBuyer)).then((saved) => {
11289
+ void saveForCharge().then((saved) => {
10918
11290
  if (!saved || selectionRequest.current !== request) return;
10919
11291
  setSavedRevolutCart(key);
10920
11292
  setSavedWalletCart(key);
10921
11293
  });
10922
- }, [stepId, order.cart?.Key, revolutCart]);
11294
+ }, [stepId, order.cart?.Key, revolutCart, answersReady]);
10923
11295
  const [cardStatus, setCardStatus] = useState23(null);
10924
11296
  const checkoutSessionId = useMemo11(() => crypto.randomUUID(), [order.cart?.Key]);
10925
11297
  const payEntries = frameMounted ? /* @__PURE__ */ jsxs25(Fragment3, { children: [
@@ -11196,7 +11568,8 @@ function PurchaseIsland({
11196
11568
  schedule: drawnSchedule,
11197
11569
  onPartyRefused: setPartyRefused,
11198
11570
  partyRefused,
11199
- questions: fetched.questions,
11571
+ questions: questionnaire.status === "READY" ? questionnaire.questions : [],
11572
+ answersLocked: answersSaved,
11200
11573
  follow: fetched.follow,
11201
11574
  buyerEmail: standing.buyer?.email,
11202
11575
  scheduleDay: chosenDay,
@@ -11276,7 +11649,7 @@ function PurchaseIsland({
11276
11649
  stepId === "NAME" ? isCompleteName(
11277
11650
  standing.buyer?.firstName ?? "",
11278
11651
  standing.buyer?.lastName ?? ""
11279
- ) : stepId === "EMAIL" ? isValidEmail(collected.email) : stepId === "PHONE" ? e164(collected.phone.dialCode, collected.phone.national) !== null : input === null || answered
11652
+ ) : stepId === "EMAIL" ? isValidEmail(collected.email) : stepId === "PHONE" ? e164(collected.phone.dialCode, collected.phone.national) !== null : stepId === "DETAILS" ? questionnaire.status === "READY" && questionsAnswered(questionnaire.questions, collected.answers) : input === null || answered
11280
11653
  )
11281
11654
  )
11282
11655
  )
@@ -11307,7 +11680,7 @@ function PurchaseIsland({
11307
11680
  * checkout this is. A card with no hold has the room for it; one with a hold has
11308
11681
  * something more useful to say in the only line it has.
11309
11682
  */
11310
- stepId === "REVIEW" || stepId === "PAYMENT" ? drawnHold === void 0 ? POWERED_BY : CART_VIEW.remaining(formatHold(drawnHold)) : copy?.subtitle
11683
+ stepId === "REVIEW" || stepId === "PAYMENT" ? drawnHold === void 0 ? POWERED_BY : CART_VIEW.remaining(formatHold(drawnHold)) : stepId === "DETAILS" && answersSaved ? DETAILS_SAVED_SUBTITLE : copy?.subtitle
11311
11684
  );
11312
11685
  const lines = drawnQuote === void 0 ? null : quoteLines(drawnQuote);
11313
11686
  const title = paidRecovery ? "Payment Received" : stepId === "ACCOUNT_CREATED" ? accountCreatedTitle(accountFirstName) : stepId === "REVIEW" && lines !== null ? `Pay ${lines.headline}` : (
@@ -11525,6 +11898,7 @@ function stepInput(stepId, context) {
11525
11898
  onPartyRefused,
11526
11899
  partyRefused,
11527
11900
  questions,
11901
+ answersLocked: answersLocked2,
11528
11902
  follow,
11529
11903
  buyerEmail,
11530
11904
  buyerName: buyerName2,
@@ -11593,23 +11967,62 @@ function stepInput(stepId, context) {
11593
11967
  /*
11594
11968
  * THE EVENT'S OWN QUESTIONS. The card was a gate onto nothing: `DETAILS` had no case
11595
11969
  * here, so it drew a sentence about needing details and no way to give any. The
11596
- * questions ride on the tickets, so they are already in hand by the time this is asked.
11970
+ * questions come from the tickets and the event's questionnaire, which arrives with the
11971
+ * cart, so they are in hand by the time this is asked.
11597
11972
  */
11598
11973
  case "DETAILS":
11599
- return questions.length === 0 ? null : /* @__PURE__ */ jsx35("div", { className: "scopetickets-island-card__fields", children: questions.map((question) => /* @__PURE__ */ jsx35(
11600
- TextField,
11601
- {
11602
- label: question.Question,
11603
- value: collected.answers[String(question.QuestionId)] ?? "",
11604
- onChange: (value) => setCollected((was) => ({
11605
- ...was,
11606
- answers: { ...was.answers, [String(question.QuestionId)]: value }
11607
- })),
11608
- type: question.Type === "date" ? "text" : "text",
11609
- enterKeyHint: "done"
11610
- },
11611
- question.QuestionId
11612
- )) });
11974
+ return questions.length === 0 ? null : /* @__PURE__ */ jsx35("div", { className: "scopetickets-island-card__fields", children: questions.map((question) => {
11975
+ const key = String(question.QuestionId);
11976
+ const value = collected.answers[key];
11977
+ const answer = answersLocked2 ? void 0 : (next) => setCollected((was) => ({ ...was, answers: { ...was.answers, [key]: next } }));
11978
+ const kind = questionKind(question);
11979
+ switch (kind) {
11980
+ case "AGREEMENT":
11981
+ return /* @__PURE__ */ jsxs25("div", { className: "scopetickets-island-card__agreement", children: [
11982
+ /* @__PURE__ */ jsx35("span", { className: "scopetickets-island-card__agreement-label", children: question.Question }),
11983
+ /* @__PURE__ */ jsx35(
11984
+ Switch,
11985
+ {
11986
+ checked: value === AGREED,
11987
+ label: question.Question,
11988
+ onChange: (on) => answer?.(on ? AGREED : NOT_AGREED),
11989
+ disabled: answersLocked2
11990
+ }
11991
+ )
11992
+ ] }, question.QuestionId);
11993
+ case "INTEGER":
11994
+ return /* @__PURE__ */ jsx35(
11995
+ TextField,
11996
+ {
11997
+ label: question.Question,
11998
+ value: value ?? "",
11999
+ onChange: answer,
12000
+ inputMode: "numeric",
12001
+ maxLength: 11,
12002
+ readOnly: answersLocked2,
12003
+ enterKeyHint: "done"
12004
+ },
12005
+ question.QuestionId
12006
+ );
12007
+ case "TEXT":
12008
+ return /* @__PURE__ */ jsx35(
12009
+ TextField,
12010
+ {
12011
+ label: question.Question,
12012
+ value: value ?? "",
12013
+ onChange: answer,
12014
+ maxLength: MAX_ANSWER_LENGTH,
12015
+ readOnly: answersLocked2,
12016
+ enterKeyHint: "done"
12017
+ },
12018
+ question.QuestionId
12019
+ );
12020
+ default: {
12021
+ const exhaustive = kind;
12022
+ return exhaustive;
12023
+ }
12024
+ }
12025
+ }) });
11613
12026
  /*
11614
12027
  * WHO TO HEAR FROM AGAIN. `FollowList` was built and tested and mounted by nothing —
11615
12028
  * the organiser and the venue are on every event, and they are who a buyer would