@scopetickets/checkout 0.6.2 → 0.6.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.cjs CHANGED
@@ -299,13 +299,14 @@ function CardAction({ action, tapped = false }) {
299
299
  type: "button",
300
300
  className: `scopetickets-island-button scopetickets-island-button--${action.role} scopetickets-island-button--block${action.mark === void 0 ? "" : ` scopetickets-island-button--marked-${action.mark.spacing ?? "separate"}`}${action.disabled ? " scopetickets-island-button--disabled" : ""}`,
301
301
  "aria-disabled": action.disabled === true ? true : void 0,
302
- "aria-label": alone && typeof action.label === "string" ? action.label : void 0,
303
- onClick: action.disabled === true ? void 0 : action.onPress,
302
+ "aria-busy": action.busy === true ? "true" : void 0,
303
+ "aria-label": (alone || action.busy === true) && typeof action.label === "string" ? action.label : void 0,
304
+ onClick: action.disabled === true || action.busy === true ? void 0 : action.onPress,
304
305
  ...press,
305
306
  "data-pressed": held ? "" : void 0,
306
307
  children: [
307
308
  action.mark?.side === "leading" ? mark : null,
308
- alone ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "scopetickets-island-button__mark--alone", "aria-hidden": "true", children: action.mark?.node }) : action.label,
309
+ action.busy === true ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "scopetickets-island-spinner", "aria-hidden": "true" }) : alone ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "scopetickets-island-button__mark--alone", "aria-hidden": "true", children: action.mark?.node }) : action.label,
309
310
  action.mark?.side === "trailing" ? mark : null
310
311
  ]
311
312
  }
@@ -3290,6 +3291,9 @@ var FUNNEL_COPY = {
3290
3291
  refused: "That email and password did not match. Please try again.",
3291
3292
  working: "Checking your details\u2026"
3292
3293
  };
3294
+ var FREE_ORDER_COPY = {
3295
+ processing: { title: "Booking", subtitle: "This may take a moment." }
3296
+ };
3293
3297
  var PROMO_COPY = {
3294
3298
  /** The trailing half of the commit pill. */
3295
3299
  open: "Promo Code",
@@ -3298,6 +3302,10 @@ var PROMO_COPY = {
3298
3302
  field: "Promo Code",
3299
3303
  apply: "Apply",
3300
3304
  remove: "Remove",
3305
+ /** Once a code is on the order: back to Review, where the price it took off is paid. */
3306
+ continue: "Continue",
3307
+ /** The card's own way out — the header draws none on this card. */
3308
+ back: "Back",
3301
3309
  /** What the card says once a code is on the order. `saved` is already written money. */
3302
3310
  saved: (saved) => `${saved} Saved`,
3303
3311
  /** The mark on an accepted field, for anyone who cannot see it. */
@@ -3366,6 +3374,7 @@ var JOURNEY_COPY = {
3366
3374
  };
3367
3375
  var PASSKEY_BUTTON_LABEL = "Add Passkey";
3368
3376
  var COMPOSE_FUNNEL_LABEL = "Your ticket selection";
3377
+ var HOLDING_TICKETS = "Holding your tickets\u2026";
3369
3378
  var POWERED_BY = [
3370
3379
  { kind: "TEXT", text: "Powered by" },
3371
3380
  { kind: "MARK", mark: "SCOPE_TICKETS_WORDMARK" }
@@ -5014,17 +5023,19 @@ function IslandCommitPill({
5014
5023
  children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "scopetickets-island-glyph-slot", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons3.ShoppingCartIcon, { fill: true, color: "currentColor" }) })
5015
5024
  }
5016
5025
  ),
5017
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "scopetickets-island-commit__rule", "aria-hidden": "true" }),
5018
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
5019
- "button",
5020
- {
5021
- type: "button",
5022
- className: "scopetickets-island-commit__target scopetickets-island-commit__promo",
5023
- onClick: onOpenPromo,
5024
- ...promoPress,
5025
- children: promoLabel
5026
- }
5027
- )
5026
+ promoLabel === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
5027
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "scopetickets-island-commit__rule", "aria-hidden": "true" }),
5028
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
5029
+ "button",
5030
+ {
5031
+ type: "button",
5032
+ className: "scopetickets-island-commit__target scopetickets-island-commit__promo",
5033
+ onClick: onOpenPromo,
5034
+ ...promoPress,
5035
+ children: promoLabel
5036
+ }
5037
+ )
5038
+ ] })
5028
5039
  ] });
5029
5040
  }
5030
5041
 
@@ -5080,6 +5091,9 @@ function toQuote(cart, currency) {
5080
5091
  if (currency === void 0) return void 0;
5081
5092
  return { kind: "TOTAL", minorUnits: cart.TotalAmount, currency };
5082
5093
  }
5094
+ function nothingToPay(cart, itemCount) {
5095
+ return cart !== null && itemCount > 0 && cart.TotalAmount <= 0;
5096
+ }
5083
5097
  var ESCROW_WINDOW_SECONDS = 5 * 60;
5084
5098
  function withExpiry(cart, heldFrom) {
5085
5099
  return {
@@ -5345,7 +5359,8 @@ var IDLE_ORDER = {
5345
5359
  answers: { status: "IDLE" },
5346
5360
  answersLanded: null,
5347
5361
  eventQuestions: { status: "IDLE" },
5348
- promo: { status: "IDLE" }
5362
+ promo: { status: "IDLE" },
5363
+ acceptedPromo: null
5349
5364
  };
5350
5365
  var NOTHING = [];
5351
5366
  var UNEXPLAINED_FAILURE = "Your payment could not be completed.";
@@ -5413,6 +5428,7 @@ var EMPTIED = {
5413
5428
  eventQuestions: { status: "IDLE" },
5414
5429
  answers: { status: "IDLE" },
5415
5430
  promo: { status: "IDLE" },
5431
+ acceptedPromo: null,
5416
5432
  sheet: { status: "IDLE" },
5417
5433
  completedPreviously: false
5418
5434
  };
@@ -5480,7 +5496,9 @@ function reduceOrder(state, event) {
5480
5496
  reservation,
5481
5497
  /* The old cart is gone from here the moment we ask for another. */
5482
5498
  ...giveBack ? EMPTIED : {},
5483
- opening: { kind: "ASKING", mark: event.mark, ask: event.ask }
5499
+ opening: { kind: "ASKING", mark: event.mark, ask: event.ask },
5500
+ /* Unknown from this press, so nothing reads the wait as a run that asks nothing. */
5501
+ ...event.adopt ? {} : { eventQuestions: { status: "LOADING" } }
5484
5502
  },
5485
5503
  effects: [
5486
5504
  ...giveBack && state.cart !== null ? [
@@ -5544,6 +5562,8 @@ function reduceOrder(state, event) {
5544
5562
  state: {
5545
5563
  ...state,
5546
5564
  opening: state.opening === null ? null : { ...state.opening, kind: "REFUSED" },
5565
+ /* No cart, so no questions to wait on: the refusal is the whole of the card. */
5566
+ eventQuestions: { status: "IDLE" },
5547
5567
  fill: event.fill
5548
5568
  },
5549
5569
  effects: NOTHING
@@ -5564,6 +5584,18 @@ function reduceOrder(state, event) {
5564
5584
  effects: [{ kind: "READ_QUESTIONS", reservation: state.reservation, cart: state.cart }]
5565
5585
  };
5566
5586
  }
5587
+ /*
5588
+ * ONLY WHILE THE CART IS STILL COMING — once it lands, it carried this same read. A failure
5589
+ * waits for it too: Try Again reads against the cart, so a notice raised before there was
5590
+ * one would offer a button that could do nothing.
5591
+ */
5592
+ case "QUESTIONS_AHEAD_OF_CART": {
5593
+ if (!isCurrent(state.reservation, event.reservation)) return { state, effects: NOTHING };
5594
+ if (state.opening?.kind !== "ASKING" || event.load.status === "FAILED") {
5595
+ return { state, effects: NOTHING };
5596
+ }
5597
+ return { state: { ...state, eventQuestions: event.load }, effects: NOTHING };
5598
+ }
5567
5599
  case "QUESTIONS_READ": {
5568
5600
  if (!isCurrent(state.reservation, event.reservation)) return { state, effects: NOTHING };
5569
5601
  if (state.cart?.Key !== event.cartKey) return { state, effects: NOTHING };
@@ -5615,6 +5647,22 @@ function reduceOrder(state, event) {
5615
5647
  }
5616
5648
  case "CHARGE_ATTEMPTED":
5617
5649
  return arm(state, "CHARGED", event.finalizes === true, void 0, event.method);
5650
+ /*
5651
+ * A FREE ORDER IS CONVERTED, NOT WATCHED. There is no payment for a status poll to
5652
+ * follow — the platform answers `409 InvalidPayment` for the status of a zero cart — so
5653
+ * this goes straight to `landed`, whose `FINALIZE` is the same `FromCart` a paid order
5654
+ * ends on, with the same retry and the same `PROVIDER_SETTLED` at the end.
5655
+ *
5656
+ * THE GUARD IS THE REDUCER'S, NOT THE CALLER'S: a cart with money on it must never be
5657
+ * converted by this road, whatever pressed it. Nor twice — a second press while one is
5658
+ * finalizing, or after the order is placed, is nothing.
5659
+ */
5660
+ case "NOTHING_TO_PAY":
5661
+ if (!nothingToPay(state.cart, state.items.length)) return { state, effects: NOTHING };
5662
+ if (state.watch.kind === "FINALIZING" || moneyMoved(state.payment)) {
5663
+ return { state, effects: NOTHING };
5664
+ }
5665
+ return landed(state, true);
5618
5666
  case "SHEET_OPENING":
5619
5667
  return {
5620
5668
  state: {
@@ -5726,7 +5774,8 @@ function reduceOrder(state, event) {
5726
5774
  ...event.cart,
5727
5775
  ExpirationTime: state.cart?.ExpirationTime ?? event.cart.ExpirationTime
5728
5776
  },
5729
- promo: { status: "IDLE" }
5777
+ promo: { status: "IDLE" },
5778
+ acceptedPromo: event.code === void 0 ? state.acceptedPromo : event.code
5730
5779
  },
5731
5780
  effects: NOTHING
5732
5781
  };
@@ -5907,9 +5956,9 @@ function mergeQuestions(eventQuestions, ticketQuestions) {
5907
5956
  return merged;
5908
5957
  }
5909
5958
  function questionsInHand(ticketQuestions, load, hasCart) {
5910
- if (!hasCart) return { status: "READY", questions: guardQuestions(ticketQuestions) };
5911
5959
  switch (load.status) {
5912
5960
  case "IDLE":
5961
+ return hasCart ? { status: "PENDING" } : { status: "READY", questions: guardQuestions(ticketQuestions) };
5913
5962
  case "LOADING":
5914
5963
  return { status: "PENDING" };
5915
5964
  case "LOADED":
@@ -5942,8 +5991,24 @@ function questionPages(questions, host) {
5942
5991
  (question) => !questionAnswered(questionKind(question), host[String(question.QuestionId)])
5943
5992
  );
5944
5993
  }
5945
- function questionOnPage(pages, at) {
5946
- return pages.find((question) => question.QuestionId === at) ?? pages[0] ?? null;
5994
+ function questionCards(questions, host, grouping = "question") {
5995
+ const pages = questionPages(questions, host);
5996
+ switch (grouping) {
5997
+ case "question":
5998
+ return pages.map((question) => [question]);
5999
+ case "all":
6000
+ return pages.length === 0 ? [] : [pages];
6001
+ default: {
6002
+ const exhaustive = grouping;
6003
+ return exhaustive;
6004
+ }
6005
+ }
6006
+ }
6007
+ function questionCardIds(cards) {
6008
+ return cards.flatMap((card2) => card2.slice(0, 1).map((question) => question.QuestionId));
6009
+ }
6010
+ function questionCardOnPage(cards, at) {
6011
+ return cards.find((card2) => card2[0]?.QuestionId === at) ?? cards[0] ?? [];
5947
6012
  }
5948
6013
 
5949
6014
  // ../checkout-core/src/machine/save-for-charge.ts
@@ -8524,7 +8589,7 @@ function param(value) {
8524
8589
  }
8525
8590
 
8526
8591
  // src/version.ts
8527
- var CHECKOUT_VERSION = "0.6.2";
8592
+ var CHECKOUT_VERSION = "0.6.3";
8528
8593
 
8529
8594
  // src/data/useCheckoutEvents.ts
8530
8595
  function useCheckoutEvents(observed, { applicationKey, inventories, onEvent, logger = browserLogger }) {
@@ -9696,7 +9761,15 @@ function createOrderStore(parts, seed = IDLE_ORDER) {
9696
9761
  case "OPEN_CART": {
9697
9762
  const { reservation, mark, ask } = effect;
9698
9763
  const asked = intentHeadcount(ask.composition);
9699
- loading(parts.gateway.open(mark, ask), reservation, asked);
9764
+ loading(
9765
+ parts.gateway.open(
9766
+ mark,
9767
+ ask,
9768
+ (load) => dispatch({ kind: "QUESTIONS_AHEAD_OF_CART", reservation, load })
9769
+ ),
9770
+ reservation,
9771
+ asked
9772
+ );
9700
9773
  return;
9701
9774
  }
9702
9775
  case "READ_CART": {
@@ -9837,7 +9910,7 @@ function createOrderStore(parts, seed = IDLE_ORDER) {
9837
9910
  });
9838
9911
  return refusal === null;
9839
9912
  };
9840
- const writePromo = async (write) => {
9913
+ const writePromo = async (write, code) => {
9841
9914
  const taken = state.reservation;
9842
9915
  const cartKey = state.cart?.Key;
9843
9916
  if (cartKey === void 0) return false;
@@ -9848,12 +9921,34 @@ function createOrderStore(parts, seed = IDLE_ORDER) {
9848
9921
  return false;
9849
9922
  }
9850
9923
  if (!written.ok) {
9924
+ const reread = await rereadAfterRefusal(cartKey);
9925
+ if (!stillOurs(taken)) {
9926
+ dispatch({ kind: "PROMO_SETTLED" });
9927
+ return false;
9928
+ }
9929
+ if (reread !== null) {
9930
+ dispatch({ kind: "PROMO_WRITTEN", cart: reread, code });
9931
+ return true;
9932
+ }
9851
9933
  dispatch({ kind: "PROMO_REFUSED", reason: written.reason });
9852
9934
  return false;
9853
9935
  }
9854
- dispatch({ kind: "PROMO_WRITTEN", cart: written.cart });
9936
+ dispatch({ kind: "PROMO_WRITTEN", cart: written.cart, code });
9855
9937
  return true;
9856
9938
  };
9939
+ const rereadAfterRefusal = async (cartKey) => {
9940
+ const before = state.cart;
9941
+ if (before === null) return null;
9942
+ try {
9943
+ const load = await parts.gateway.adopt(cartKey);
9944
+ if (!load.ok) return null;
9945
+ const after2 = load.opening.cart;
9946
+ const moved = after2.TotalAmount !== before.TotalAmount || (after2.PromoCode ?? null) !== (before.PromoCode ?? null);
9947
+ return moved ? after2 : null;
9948
+ } catch {
9949
+ return null;
9950
+ }
9951
+ };
9857
9952
  const charge = async (method, email) => {
9858
9953
  const taken = state.reservation;
9859
9954
  const cartKey = state.cart?.Key;
@@ -9988,13 +10083,13 @@ function createOrderStore(parts, seed = IDLE_ORDER) {
9988
10083
  if (state.cart === null) return false;
9989
10084
  const typed = code.trim();
9990
10085
  try {
9991
- return await writePromo((cartKey) => parts.gateway.writePromo(cartKey, typed));
10086
+ return await writePromo((cartKey) => parts.gateway.writePromo(cartKey, typed), typed);
9992
10087
  } catch (cause) {
9993
10088
  dispatch({ kind: "PROMO_SETTLED" });
9994
10089
  throw cause;
9995
10090
  }
9996
10091
  },
9997
- removePromo: () => writePromo((cartKey) => parts.gateway.clearPromo(cartKey)),
10092
+ removePromo: () => writePromo((cartKey) => parts.gateway.clearPromo(cartKey), null),
9998
10093
  /*
9999
10094
  * Not a kill switch: a host in StrictMode mounts, unmounts and mounts again over the
10000
10095
  * same store, and a permanently dead one would never open a cart. Answers still in
@@ -10540,8 +10635,13 @@ function promoSaved(cart, currency) {
10540
10635
  if (typeof saved !== "number" || !Number.isFinite(saved) || saved <= 0) return null;
10541
10636
  return formatMoney(saved, currency);
10542
10637
  }
10543
- function promoApplied(cart) {
10544
- return cart === null ? null : bounded(cart.PromoCode, WIRE_LIMITS.promoCode);
10638
+ function promoApplied(cart, accepted = null) {
10639
+ if (cart === null) return null;
10640
+ const named = bounded(cart.PromoCode, WIRE_LIMITS.promoCode);
10641
+ if (named !== null) return named;
10642
+ const saved = cart.PromoSavingAmount;
10643
+ if (typeof saved !== "number" || !Number.isFinite(saved) || saved <= 0) return null;
10644
+ return bounded(accepted, WIRE_LIMITS.promoCode);
10545
10645
  }
10546
10646
  var PROMO_REFUSED = "That code cannot be used on this order.";
10547
10647
  function promoRefusal(reason, fallback) {
@@ -10579,11 +10679,13 @@ async function writtenAnyway(client, cartKey) {
10579
10679
  }
10580
10680
  function orderGateway(client, clock) {
10581
10681
  return {
10582
- async open(mark, ask) {
10682
+ async open(mark, ask, questionsAhead) {
10583
10683
  let asking = `opening a cart on '${mark}'`;
10584
10684
  try {
10585
10685
  const at = clock.now();
10586
10686
  const cart = withExpiry(await client.createCart(mark), at);
10687
+ const questions = readQuestions(client, cart);
10688
+ if (questionsAhead !== void 0) void questions.then(questionsAhead);
10587
10689
  asking = `reading the tickets on '${mark}'`;
10588
10690
  const tickets = await readDayTickets(client, mark, ask.inventories, {
10589
10691
  timeslots: true,
@@ -10596,11 +10698,11 @@ function orderGateway(client, clock) {
10596
10698
  throw new Error(
10597
10699
  `no product on '${mark}' sells the ${session.LocalStartTime}\u2013${session.LocalEndTime} session the buyer was offered`
10598
10700
  );
10599
- return empty(client, cart, at, void 0, void 0);
10701
+ return empty(cart, at, void 0, void 0, questions);
10600
10702
  }
10601
10703
  const money = product.Currency ?? void 0;
10602
10704
  const requested = itemsFor({ composition: ask.composition, timeslot: session }, product);
10603
- if (requested.length === 0) return empty(client, cart, at, money, product.Name);
10705
+ if (requested.length === 0) return empty(cart, at, money, product.Name, questions);
10604
10706
  const sold = sessionOn(product, session);
10605
10707
  asking = `filling cart '${cart.Key}' on '${mark}' with ${requested.length} \xD7 '${product.Key}' (Available: ${product.Available})` + (session === void 0 ? "" : ` at ${session.LocalStartTime}\u2013${session.LocalEndTime}`) + (sold === void 0 ? "" : ` (session Total: ${sold.Total}, Remaining: ${sold.Remaining})`);
10606
10708
  const filled = await client.addItemsBulk(cart.Key, requested, { allowPartial: true });
@@ -10621,7 +10723,7 @@ function orderGateway(client, clock) {
10621
10723
  /* The product it was filled WITH — the cart's items do not reliably name it. */
10622
10724
  productName: product.Name,
10623
10725
  heldFrom: at,
10624
- eventQuestions: await readQuestions(client, filled.Cart)
10726
+ eventQuestions: await questions
10625
10727
  }
10626
10728
  };
10627
10729
  } catch (cause) {
@@ -10748,7 +10850,7 @@ async function promoWrite(write) {
10748
10850
  function said4(cause) {
10749
10851
  return cause instanceof Error ? cause.message : String(cause);
10750
10852
  }
10751
- async function empty(client, cart, heldFrom, currency, productName) {
10853
+ async function empty(cart, heldFrom, currency, productName, questions) {
10752
10854
  return {
10753
10855
  ok: true,
10754
10856
  opening: {
@@ -10758,7 +10860,7 @@ async function empty(client, cart, heldFrom, currency, productName) {
10758
10860
  currency,
10759
10861
  productName,
10760
10862
  heldFrom,
10761
- eventQuestions: await readQuestions(client, cart)
10863
+ eventQuestions: await questions
10762
10864
  }
10763
10865
  };
10764
10866
  }
@@ -11337,13 +11439,11 @@ function commitBlocks(id, facts) {
11337
11439
  }
11338
11440
  /*
11339
11441
  * THE EVENT'S OWN QUESTIONS, which come from the tickets and the event's questionnaire
11340
- * and arrive with the cart — so they are in hand by the time this card is asked. One
11341
- * per card: the card is the question the flow stands on.
11442
+ * and arrive with the cart — so they are in hand by the time this card is asked. As
11443
+ * many per card as `questionGrouping` deals it, and the card is the one the flow stands on.
11342
11444
  */
11343
- case "DETAILS": {
11344
- const page = pageOf(facts);
11345
- return page === null ? [] : chainFields([questionBlock(page, facts)]);
11346
- }
11445
+ case "DETAILS":
11446
+ return chainFields(cardOf(facts).map((question) => questionBlock(question, facts)));
11347
11447
  case "PROMO":
11348
11448
  return [promoBlock(facts.collected.promoCode, facts.promo)];
11349
11449
  default:
@@ -11400,15 +11500,14 @@ function commitAnswered(id, facts) {
11400
11500
  case "PHONE":
11401
11501
  return e164(collected.phone.dialCode, collected.phone.national) !== null;
11402
11502
  /*
11403
- * THE QUESTION ON THIS CARD, and not the rest: each has a card of its own, and a gate
11503
+ * THE QUESTIONS ON THIS CARD, and not the rest: where each has a card of its own, a gate
11404
11504
  * over all of them would hold the first card shut until the last was answered. Not
11405
11505
  * answered while the questions are still on their way — see `questions`.
11406
11506
  */
11407
- case "DETAILS": {
11408
- if (facts.questions.status !== "READY") return false;
11409
- const page = pageOf(facts);
11410
- return page === null || questionAnswered(questionKind(page), collected.answers[String(page.QuestionId)]);
11411
- }
11507
+ case "DETAILS":
11508
+ return facts.questions.status === "READY" && cardOf(facts).every(
11509
+ (question) => questionAnswered(questionKind(question), collected.answers[String(question.QuestionId)])
11510
+ );
11412
11511
  /*
11413
11512
  * THE CARD FORM OPENS ON NO METHOD, so its Confirm waits for the tap that picks one: a
11414
11513
  * row mounts the form beneath it, and a step confirmed without one would be a buyer
@@ -11432,8 +11531,11 @@ function commitAnswered(id, facts) {
11432
11531
  return true;
11433
11532
  }
11434
11533
  }
11435
- function pageOf(facts) {
11436
- return questionOnPage(questionPages(facts.questions, facts.hostAnswers), facts.question);
11534
+ function cardOf(facts) {
11535
+ return questionCardOnPage(
11536
+ questionCards(facts.questions, facts.hostAnswers, facts.questionGrouping),
11537
+ facts.question
11538
+ );
11437
11539
  }
11438
11540
  function questionBlock(question, facts) {
11439
11541
  const id = String(question.QuestionId);
@@ -11767,6 +11869,7 @@ function useCheckoutOrder(store, request, currency, open, adopt, userTypeNames2
11767
11869
  (method) => store?.dispatch({ kind: "CHARGE_ATTEMPTED", method }),
11768
11870
  [store]
11769
11871
  );
11872
+ const bookFree = (0, import_react22.useCallback)(() => store?.dispatch({ kind: "NOTHING_TO_PAY" }), [store]);
11770
11873
  const restart = (0, import_react22.useCallback)(() => store?.dispatch({ kind: "RESTARTED" }), [store]);
11771
11874
  const retryEventQuestions = (0, import_react22.useCallback)(
11772
11875
  () => store?.dispatch({ kind: "QUESTIONS_WANTED_AGAIN" }),
@@ -11786,6 +11889,7 @@ function useCheckoutOrder(store, request, currency, open, adopt, userTypeNames2
11786
11889
  answers: state.answers,
11787
11890
  saveAnswers,
11788
11891
  promo: state.promo,
11892
+ acceptedPromo: state.acceptedPromo,
11789
11893
  applyPromo,
11790
11894
  removePromo,
11791
11895
  settledFromFrame,
@@ -11793,6 +11897,7 @@ function useCheckoutOrder(store, request, currency, open, adopt, userTypeNames2
11793
11897
  paidWithoutFinalizing,
11794
11898
  retryPayment,
11795
11899
  chargeAttempted,
11900
+ bookFree,
11796
11901
  restart,
11797
11902
  eventQuestions: state.eventQuestions,
11798
11903
  retryEventQuestions
@@ -14787,6 +14892,12 @@ var STEP_ACCESSORY = Object.fromEntries(
14787
14892
  Object.entries(STEP_BADGES).map(([step2, badge]) => [step2, { ...badge, id: `step:${step2}` }])
14788
14893
  );
14789
14894
  var UNCLOSABLE_STEPS = /* @__PURE__ */ new Set([
14895
+ /*
14896
+ * NOT FOR THE MONEY, unlike the rest: the promo card's way out is its own Back button
14897
+ * (or Continue, once a code is on), so the header's would be a second one. Conall,
14898
+ * 2026-11-12.
14899
+ */
14900
+ "PROMO",
14790
14901
  "PROCESSING",
14791
14902
  "PAYMENT_SUCCESS",
14792
14903
  "FEEDBACK",
@@ -15398,10 +15509,13 @@ var SHEET_PRESS = {
15398
15509
  },
15399
15510
  card: { role: payButtonRole("CARD"), pays: true, picks: "card", label: "Pay with Card" }
15400
15511
  };
15512
+ var FREE_PRESS = { role: "primary", pays: true, label: "Book Now" };
15401
15513
  function reviewActions(reach) {
15402
15514
  switch (reach.entry) {
15403
15515
  case "BAY":
15404
15516
  return STEP_CARD_ACTIONS.REVIEW;
15517
+ case "FREE":
15518
+ return [FREE_PRESS];
15405
15519
  case "SHEET":
15406
15520
  return reach.methods.map((method) => SHEET_PRESS[method]);
15407
15521
  default: {
@@ -15826,7 +15940,12 @@ function trailingSlot(id, facts) {
15826
15940
  return {
15827
15941
  kind: "ORDER",
15828
15942
  cartLabel: CART_VIEW.label(facts.summary.total),
15829
- ...facts.can.redeemPromo ? { promoLabel: PROMO_COPY.open } : {}
15943
+ /*
15944
+ * THE PROMO HALF ON THE PAY SCREEN ONLY — Conall, 2026-11-12. A code is a question
15945
+ * about the price, and Review is where the price is paid; offered earlier, it opened
15946
+ * over steps that had nothing to do with it.
15947
+ */
15948
+ ...facts.can.redeemPromo && id === "REVIEW" ? { promoLabel: PROMO_COPY.open } : {}
15830
15949
  };
15831
15950
  }
15832
15951
  const stops = composeFunnel(facts.stops ?? [], facts.answers, id);
@@ -15980,6 +16099,7 @@ function stepSubtitle(facts) {
15980
16099
  if (facts.stepId === "PAYMENT_FAILED" && facts.failureReason !== null) return facts.failureReason;
15981
16100
  if (facts.stepId === "PAYMENT_SUCCESS") return paymentSuccessSubtitle(facts.buyerFirstName);
15982
16101
  if (facts.stepId === "REVIEW" || facts.stepId === "PAYMENT") {
16102
+ if (facts.orderComing === true) return HOLDING_TICKETS;
15983
16103
  return facts.holdRemaining === null ? POWERED_BY : holdSentence(facts.holdRemaining);
15984
16104
  }
15985
16105
  if (facts.stepId === "DETAILS" && facts.answersSaved) return DETAILS_SAVED_SUBTITLE;
@@ -15994,12 +16114,13 @@ function stepCardOf(facts) {
15994
16114
  const names = greeted(facts);
15995
16115
  const heading = {
15996
16116
  stepId,
15997
- copy: card2?.copy ?? STEP_CARD_COPY[stepId],
16117
+ copy: card2?.copy ?? (stepId === "PROCESSING" && facts.payment.entry === "FREE" ? FREE_ORDER_COPY.processing : STEP_CARD_COPY[stepId]),
15998
16118
  outcome: facts.outcome,
15999
16119
  failureReason: facts.failureReason,
16000
16120
  buyerFirstName: names.thanks,
16001
16121
  accountFirstName: names.welcome,
16002
16122
  holdRemaining: facts.summary.kind === "HELD" ? facts.summary.hold : null,
16123
+ orderComing: facts.orderComing === true,
16003
16124
  quoteHeadline: facts.quoteHeadline,
16004
16125
  promoSaving: facts.promoSaving,
16005
16126
  answersSaved: facts.answersSaved
@@ -16056,7 +16177,10 @@ function cardActions(facts, checkpoint) {
16056
16177
  if (stepId === "PROCESSING" && journey?.kind === "PROCESSING") {
16057
16178
  return [{ role: "secondary", label: ACTION_COPY.cancel, cancels: true }];
16058
16179
  }
16059
- const base = checkpoint ?? (stepId === "REVIEW" ? shutUnlessChargeable(reviewActions(facts.payment), facts.chargeReady !== false) : STEP_CARD_ACTIONS[stepId]);
16180
+ const base = checkpoint ?? (stepId === "REVIEW" ? shutUnlessChargeable(
16181
+ reviewActions(facts.payment),
16182
+ facts.chargeReady !== false && facts.orderComing !== true
16183
+ ) : STEP_CARD_ACTIONS[stepId]);
16060
16184
  if (pressCreatesOrder(stepId, facts.next)) {
16061
16185
  return base.map(
16062
16186
  (action) => action.role === "primary" ? { ...action, label: CREATE_ORDER_LABEL } : action
@@ -16064,7 +16188,7 @@ function cardActions(facts, checkpoint) {
16064
16188
  }
16065
16189
  switch (stepId) {
16066
16190
  case "PROMO":
16067
- return facts.promo === void 0 ? base : [promoAction(facts.promo)];
16191
+ return facts.promo === void 0 ? base : promoActions(facts.promo);
16068
16192
  /*
16069
16193
  * THE PASSKEY CARD KEEPS ONLY ITS SKIP. Its primary is the ceremony document drawn as
16070
16194
  * the card's own content — a credential can only be made by a page under the RP id —
@@ -16131,13 +16255,23 @@ function shutUnlessChargeable(actions, chargeable) {
16131
16255
  (action) => action.pays === true || action.picks !== void 0 ? { ...action, disabled: true } : action
16132
16256
  );
16133
16257
  }
16134
- function promoAction(promo) {
16135
- return promoSendable(promo.typed, promo.applied) ? { role: "primary", label: PROMO_COPY.apply, disabled: promo.saving, promo: "APPLY" } : {
16136
- role: "primary",
16137
- label: PROMO_COPY.remove,
16138
- disabled: promo.saving || promo.applied === null,
16139
- promo: "REMOVE"
16140
- };
16258
+ function promoActions(promo) {
16259
+ const applied = promo.applied;
16260
+ if (applied !== null && !promoSendable(promo.typed, applied)) {
16261
+ return [
16262
+ { role: "primary", label: PROMO_COPY.continue, disabled: promo.saving, promo: "CONTINUE" },
16263
+ { role: "secondary", label: PROMO_COPY.remove, disabled: promo.saving, promo: "REMOVE" }
16264
+ ];
16265
+ }
16266
+ return [
16267
+ {
16268
+ role: "primary",
16269
+ label: PROMO_COPY.apply,
16270
+ disabled: promo.saving || !promoSendable(promo.typed, applied),
16271
+ promo: "APPLY"
16272
+ },
16273
+ { role: "secondary", label: PROMO_COPY.back }
16274
+ ];
16141
16275
  }
16142
16276
  function pillView(facts) {
16143
16277
  const lines = facts.quote === void 0 ? null : quoteLines(facts.quote);
@@ -16312,6 +16446,12 @@ function islandStep(state, facts, stepId) {
16312
16446
  answersSaved: answersLocked(state.order.answers),
16313
16447
  payment: facts.payment,
16314
16448
  ...facts.chargeReady === void 0 ? {} : { chargeReady: facts.chargeReady },
16449
+ /*
16450
+ * READ OFF THE ORDER, SO NO RENDERER HAS TO REMEMBER IT. Review can be reached before the
16451
+ * fill lands, and a press there went on to Pay with no cart behind it and stayed there
16452
+ * when the event's questions arrived (measured 2026-11-05).
16453
+ */
16454
+ orderComing: state.order.cart === null && state.order.opening?.kind === "ASKING",
16315
16455
  detour: facts.detour,
16316
16456
  first: facts.first,
16317
16457
  next: facts.next,
@@ -16381,6 +16521,11 @@ function restingEffect(card2, id) {
16381
16521
  }
16382
16522
 
16383
16523
  // ../checkout-core/src/view/island-flow.ts
16524
+ var PROMO_EFFECT = {
16525
+ APPLY: "PROMO_APPLIED",
16526
+ REMOVE: "PROMO_REMOVED",
16527
+ CONTINUE: "PROMO_CONTINUED"
16528
+ };
16384
16529
  function openingFlow(expanded) {
16385
16530
  return {
16386
16531
  at: null,
@@ -16467,7 +16612,7 @@ function pressed(state, action, facts) {
16467
16612
  return forward(state, facts, [{ kind: "GUEST_CHOSEN" }]);
16468
16613
  }
16469
16614
  if (action.promo !== void 0) {
16470
- return still6(state, [{ kind: action.promo === "APPLY" ? "PROMO_APPLIED" : "PROMO_REMOVED" }]);
16615
+ return still6(state, [{ kind: PROMO_EFFECT[action.promo] }]);
16471
16616
  }
16472
16617
  if (action.reveals === true) {
16473
16618
  return still6({ ...state, passwordRevealed: !state.passwordRevealed });
@@ -18745,6 +18890,8 @@ var WEB_CAN = {
18745
18890
  redeemPromo: true
18746
18891
  };
18747
18892
  var WEB_PAYMENT = { entry: "BAY" };
18893
+ var CONTINUE_WAIT_MS = 3e3;
18894
+ var FREE_ORDER = { entry: "FREE" };
18748
18895
  var sendEnvelope = (url, body) => {
18749
18896
  if (typeof fetch !== "function") return;
18750
18897
  void fetch(url, { method: "POST", body, keepalive: true }).catch(() => void 0);
@@ -18830,6 +18977,7 @@ function PurchaseIsland({
18830
18977
  inventories,
18831
18978
  inventoryFilter = "checkbox",
18832
18979
  timeslotGrouping,
18980
+ questionGrouping,
18833
18981
  mode = "system",
18834
18982
  align = "bottom",
18835
18983
  placement = "page",
@@ -19090,8 +19238,8 @@ function PurchaseIsland({
19090
19238
  );
19091
19239
  const answeredByHost = (0, import_react43.useMemo)(() => hostAnswers(intent.answers), [intent.answers]);
19092
19240
  const questionIds = (0, import_react43.useMemo)(
19093
- () => questionPages(questionnaire, answeredByHost).map((question) => question.QuestionId),
19094
- [questionnaire, answeredByHost]
19241
+ () => questionCardIds(questionCards(questionnaire, answeredByHost, questionGrouping)),
19242
+ [questionnaire, answeredByHost, questionGrouping]
19095
19243
  );
19096
19244
  const answersReady = questionnaire.status === "READY" && questionsAnswered(questionnaire.questions, answersInHand);
19097
19245
  const answersSaved = answersLocked(order.answers);
@@ -19309,7 +19457,7 @@ function PurchaseIsland({
19309
19457
  () => dispatch({ kind: "DETOUR_OPENED", step: "PROMO" }),
19310
19458
  [dispatch]
19311
19459
  );
19312
- const appliedPromo = promoApplied(order.cart);
19460
+ const appliedPromo = promoApplied(order.cart, order.acceptedPromo);
19313
19461
  (0, import_react43.useEffect)(() => {
19314
19462
  setCollected((was) => ({ ...was, promoCode: appliedPromo ?? "" }));
19315
19463
  }, [appliedPromo]);
@@ -19384,6 +19532,8 @@ function PurchaseIsland({
19384
19532
  });
19385
19533
  const [reviewCartKey, setReviewCartKey] = (0, import_react43.useState)(null);
19386
19534
  const [frameHeight, setFrameHeight] = (0, import_react43.useState)(null);
19535
+ const [revolutReadyAt, setRevolutReadyAt] = (0, import_react43.useState)(null);
19536
+ const [continuing, setContinuing] = (0, import_react43.useState)(false);
19387
19537
  (0, import_react43.useEffect)(() => {
19388
19538
  if (expanded && order.cart !== null) {
19389
19539
  setReviewCartKey(order.cart.Key);
@@ -19454,7 +19604,28 @@ function PurchaseIsland({
19454
19604
  }
19455
19605
  };
19456
19606
  const cardChosen = collected.paymentMethodKey === "card";
19457
- const frameMounted = order.cart !== null && reviewCartKey === order.cart.Key;
19607
+ const free = nothingToPay(order.cart, order.items.length);
19608
+ const frameMounted = !free && order.cart !== null && reviewCartKey === order.cart.Key;
19609
+ const price2 = order.cart?.TotalAmount ?? null;
19610
+ (0, import_react43.useEffect)(() => {
19611
+ setFrameHeight(null);
19612
+ }, [price2]);
19613
+ const revolutStanding = revolutCart !== order.cart?.Key || revolutReadyAt === price2;
19614
+ const cardStanding = !cardChosen || frameHeight !== null;
19615
+ const entriesStanding = !frameMounted || cardStanding && revolutStanding;
19616
+ (0, import_react43.useEffect)(() => {
19617
+ if (!continuing) return;
19618
+ const finish = () => {
19619
+ setContinuing(false);
19620
+ dispatch({ kind: "DETOUR_CLOSED" });
19621
+ };
19622
+ if (entriesStanding) {
19623
+ finish();
19624
+ return;
19625
+ }
19626
+ const timer = window.setTimeout(finish, CONTINUE_WAIT_MS);
19627
+ return () => window.clearTimeout(timer);
19628
+ }, [continuing, entriesStanding, dispatch]);
19458
19629
  const terminalPayment = moneyMoved(reported);
19459
19630
  const {
19460
19631
  revolutActive,
@@ -19521,6 +19692,7 @@ function PurchaseIsland({
19521
19692
  (0, import_react43.useEffect)(() => {
19522
19693
  const key = order.cart?.Key;
19523
19694
  if (stepId !== "REVIEW" || key === void 0 || revolutCart === key || !answersReady) return;
19695
+ if (free) return;
19524
19696
  setRevolutCart(key);
19525
19697
  setWalletCart(key);
19526
19698
  const request = ++selectionRequest.current;
@@ -19529,7 +19701,7 @@ function PurchaseIsland({
19529
19701
  setSavedRevolutCart(key);
19530
19702
  setSavedWalletCart(key);
19531
19703
  });
19532
- }, [stepId, order.cart?.Key, revolutCart, answersReady]);
19704
+ }, [stepId, order.cart?.Key, revolutCart, answersReady, free]);
19533
19705
  const [cardStatus, setCardStatus] = (0, import_react43.useState)(null);
19534
19706
  const checkoutSessionId = (0, import_react43.useMemo)(() => crypto.randomUUID(), [order.cart?.Key]);
19535
19707
  const payEntries = frameMounted ? /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
@@ -19560,7 +19732,7 @@ function PurchaseIsland({
19560
19732
  },
19561
19733
  theme: frameTheme
19562
19734
  },
19563
- order.cart.Key
19735
+ `${order.cart.Key}:${order.cart.TotalAmount}`
19564
19736
  ) }),
19565
19737
  walletCart === order.cart.Key && /*
19566
19738
  * THE WALLET STANDS ABOVE REVOLUT PAY, which is the order the design draws and the
@@ -19603,7 +19775,7 @@ function PurchaseIsland({
19603
19775
  onSuccess: order.settledFromFrame,
19604
19776
  onError: providerFailed
19605
19777
  },
19606
- `wallet:${order.cart.Key}`
19778
+ `wallet:${order.cart.Key}:${order.cart.TotalAmount}`
19607
19779
  ) }),
19608
19780
  revolutCart === order.cart.Key && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
19609
19781
  "div",
@@ -19623,7 +19795,10 @@ function PurchaseIsland({
19623
19795
  retry: revolutFrameEpoch > 0,
19624
19796
  heightOverride: journeyInline && journeyFullscreen ? "100%" : journeyRoom?.height ?? PROVIDER_BUTTON_HEIGHT,
19625
19797
  onSubmitRequested: chargingWith("revolut_pay"),
19626
- onReady: recoveryReady,
19798
+ onReady: () => {
19799
+ recoveryReady();
19800
+ setRevolutReadyAt(order.cart?.TotalAmount ?? null);
19801
+ },
19627
19802
  onHeight: recoveryReady,
19628
19803
  theme: frameTheme,
19629
19804
  onStatusChange: (status) => {
@@ -19634,7 +19809,7 @@ function PurchaseIsland({
19634
19809
  onSuccess: order.settledFromFrame,
19635
19810
  onError: providerFailed
19636
19811
  },
19637
- `revolut:${revolutFrameEpoch}:${order.cart.Key}`
19812
+ `revolut:${revolutFrameEpoch}:${order.cart.Key}:${order.cart.TotalAmount}`
19638
19813
  )
19639
19814
  }
19640
19815
  )
@@ -19673,7 +19848,7 @@ function PurchaseIsland({
19673
19848
  collected,
19674
19849
  lines: cartLines2
19675
19850
  }) : null,
19676
- payment: WEB_PAYMENT,
19851
+ payment: free ? FREE_ORDER : WEB_PAYMENT,
19677
19852
  orderFirstName: orderedBuyer.firstName ?? null,
19678
19853
  next: walk.stops[index + 1]?.step,
19679
19854
  quote: drawnQuote,
@@ -19766,6 +19941,15 @@ function PurchaseIsland({
19766
19941
  * accepting it is what moves the flow on, not this press.
19767
19942
  */
19768
19943
  case "PAY_PRESSED":
19944
+ if (free) {
19945
+ void saveForCharge().then((saved) => {
19946
+ if (!saved) return;
19947
+ order.bookFree();
19948
+ dispatch({ kind: "DETOUR_CLOSED" });
19949
+ forward2();
19950
+ });
19951
+ return;
19952
+ }
19769
19953
  void saveForCharge().then((saved) => {
19770
19954
  if (!saved) return;
19771
19955
  setSubmitSignal((was) => was + 1);
@@ -19805,6 +19989,9 @@ function PurchaseIsland({
19805
19989
  case "PROMO_REMOVED":
19806
19990
  void order.removePromo();
19807
19991
  return;
19992
+ case "PROMO_CONTINUED":
19993
+ setContinuing(true);
19994
+ return;
19808
19995
  case "PAYMENT_CANCELLED":
19809
19996
  setCancelSignal((value) => value + 1);
19810
19997
  return;
@@ -19979,6 +20166,7 @@ function PurchaseIsland({
19979
20166
  answersLocked: answersSaved,
19980
20167
  hostAnswers: answeredByHost,
19981
20168
  question: flow.question,
20169
+ ...questionGrouping === void 0 ? {} : { questionGrouping },
19982
20170
  promo: {
19983
20171
  applied: appliedPromo,
19984
20172
  refusal: order.promo.status === "REFUSED" ? order.promo.reason : null
@@ -20041,6 +20229,7 @@ function PurchaseIsland({
20041
20229
  mark: action.mark === void 0 ? void 0 : buttonMark(action.mark),
20042
20230
  label: action.label,
20043
20231
  disabled: action.state !== "ENABLED",
20232
+ busy: continuing && pressed2?.promo === "CONTINUE",
20044
20233
  onPress: pressed2 === null ? () => void 0 : pressFor(pressed2)
20045
20234
  };
20046
20235
  });
@@ -20105,7 +20294,7 @@ function PurchaseIsland({
20105
20294
  onOpenCart: openCart,
20106
20295
  cartLabel: view.trailing.cartLabel,
20107
20296
  onOpenPromo: openPromo,
20108
- promoLabel: view.trailing.promoLabel ?? PROMO_COPY.open
20297
+ promoLabel: view.trailing.promoLabel
20109
20298
  }
20110
20299
  )
20111
20300
  ),