@riverbankcms/sdk 0.178.0 → 0.180.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/README.md +15 -8
  2. package/dist/_dts/{BlocksIslandsHydrator-CrKsXtpD.d.ts → BlocksIslandsHydrator-DC_AvZwy.d.ts} +1 -1
  3. package/dist/_dts/{Page-C9i27wZA.d.ts → Page-DQOxVtp3.d.ts} +7 -7
  4. package/dist/_dts/{SdkPreviewMode-DzGSR3jh.d.ts → SdkPreviewMode-DrLgY9_f.d.ts} +3 -2
  5. package/dist/_dts/{client-BnYN6XsH.d.ts → client-BP7VBRvs.d.ts} +281 -72
  6. package/dist/_dts/{content-types-CXj6lp3d.d.ts → content-types-1-K2qi__.d.ts} +2 -2
  7. package/dist/_dts/{contracts-BZLwkTwL.d.ts → contracts-Dfqz0Tcu.d.ts} +6 -116
  8. package/dist/_dts/{generatePageMetadata-ByEWwe9j.d.ts → generatePageMetadata-CSfAqmry.d.ts} +2 -2
  9. package/dist/_dts/{index-BE9dWIsr.d.ts → index-B0_2-65A.d.ts} +3 -3
  10. package/dist/_dts/{index-0HFgCnGz.d.ts → index-BeM5Ylwf.d.ts} +5 -3
  11. package/dist/_dts/{index-D9-N1d9v.d.ts → index-Blrw2oVk.d.ts} +1 -1
  12. package/dist/_dts/{index-cTpvQg_Q.d.ts → index-CB5Csefo.d.ts} +2 -2
  13. package/dist/_dts/{index-nnEdgc3Z.d.ts → index-DCcxLa8p.d.ts} +4 -2
  14. package/dist/_dts/{index-DCa-8TEY.d.ts → index-DQBGwBPx.d.ts} +1 -1
  15. package/dist/_dts/{index-CKDRr54L.d.ts → index-DQr358-m.d.ts} +4 -4
  16. package/dist/_dts/{loadContent-DYkVV6w4.d.ts → loadContent-BG2tLGXj.d.ts} +15 -13
  17. package/dist/_dts/{request-B20VRWHH.d.ts → request-P08l6mkr.d.ts} +3641 -994
  18. package/dist/_dts/{resolveBlockData-C_aK5GIS.d.ts → resolveBlockData-BDHc8lFs.d.ts} +8 -5
  19. package/dist/_dts/resolvePageContent-Y3IZBbtL.d.ts +61 -0
  20. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  21. package/dist/_dts/sdk/src/client/types.d.ts +3 -3
  22. package/dist/_dts/sdk/src/client.d.ts +7 -7
  23. package/dist/_dts/sdk/src/config/index.d.ts +6 -6
  24. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  25. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  26. package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +2 -2
  27. package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
  28. package/dist/_dts/sdk/src/data/types.d.ts +7 -2
  29. package/dist/_dts/sdk/src/gifting/client.d.ts +1 -1
  30. package/dist/_dts/sdk/src/index.d.ts +8 -8
  31. package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
  32. package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
  33. package/dist/_dts/sdk/src/navigation/index.d.ts +3 -3
  34. package/dist/_dts/sdk/src/next/index.d.ts +16 -8
  35. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  36. package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
  37. package/dist/_dts/sdk/src/portal/client.d.ts +3 -3
  38. package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
  39. package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
  40. package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
  41. package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
  42. package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
  43. package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +1 -1
  44. package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +1 -1
  45. package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +4 -4
  46. package/dist/_dts/sdk/src/rendering/index.d.ts +7 -7
  47. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  48. package/dist/_dts/sdk/src/rendering/server.d.ts +3 -3
  49. package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
  50. package/dist/_dts/sdk/src/routing/index.d.ts +19 -6
  51. package/dist/_dts/sdk/src/server.d.ts +5 -5
  52. package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
  53. package/dist/_dts/sdk/src/theme/index.d.ts +1 -1
  54. package/dist/_dts/serviceBookingOutline-BvtNagjw.d.ts +583 -0
  55. package/dist/_dts/{types-CYcd15BQ.d.ts → types-BrK6SS5c.d.ts} +9 -7
  56. package/dist/_dts/{types-CMZ5mkpv.d.ts → types-DpEAnP4F.d.ts} +10 -39
  57. package/dist/_dts/{types-rm2M4LGx.d.ts → types-HAy1-Jjo.d.ts} +3 -3
  58. package/dist/_dts/{validation-BSxnRhyy.d.ts → validation-D6q3tOBA.d.ts} +4 -4
  59. package/dist/client/{BlocksIslandsHydrator-D1n09bu-.mjs → BlocksIslandsHydrator-DJSmdNUJ.mjs} +17 -18
  60. package/dist/client/{BookingMailingListNote-DSD4gS96.mjs → BookingMailingListNote-CGxg37zx.mjs} +92 -60
  61. package/dist/client/{BookingQuestionFields-B57oGPcj.mjs → BookingQuestionFields-DXegGSnS.mjs} +26 -5
  62. package/dist/client/{CalendarNavigationChevron-qXvsFYOg.mjs → CalendarNavigationChevron-VfP50sYm.mjs} +42 -9
  63. package/dist/client/{CheckboxChoice-b-PJLEXe.mjs → CheckboxChoice-BZPLCgTU.mjs} +1 -1
  64. package/dist/client/{DemoBookingPortalAccess-Olvrwi3Z.mjs → DemoBookingPortalAccess-0Ua44F1j.mjs} +13 -8
  65. package/dist/client/{EventCalendar.client-DwFNFb-0.mjs → EventCalendar.client-CrpiyDSP.mjs} +10 -10
  66. package/dist/client/{EventCombined.client-Ffu-aVOb.mjs → EventCombined.client-D0me9wnz.mjs} +10 -10
  67. package/dist/client/{EventEmbeddedCheckoutStep-B18VbNS_.mjs → EventEmbeddedCheckoutStep-BDnicDM6.mjs} +1 -1
  68. package/dist/client/{EventItem-b8tVkNHA.mjs → EventItem-CJITrGkF.mjs} +249 -8
  69. package/dist/client/{EventListWeekNavigation-BxnJW_Gf.mjs → EventListWeekNavigation-BlEm_xjq.mjs} +1 -1
  70. package/dist/client/{EventListing.client-ViCnrNg4.mjs → EventListing.client-BNM_HuS0.mjs} +3 -3
  71. package/dist/client/{EventListing.view-CdjiepMf.mjs → EventListing.view-CXfb7RRy.mjs} +7 -16
  72. package/dist/client/{EventRegistrationPayment-BVd70XkH.mjs → EventRegistrationPayment-DiD9uYs6.mjs} +1439 -293
  73. package/dist/client/{Page-DqETUt-U.mjs → Page-bX7iy_MK.mjs} +24299 -20103
  74. package/dist/client/{ProtectedSubmitButton-C-ql101B.mjs → ProtectedSubmitButton-De6AzhE6.mjs} +1 -1
  75. package/dist/client/{SiteTermsAgreementField-DkFnbzf_.mjs → SiteTermsAgreementField-BAdW5DvE.mjs} +23 -16
  76. package/dist/client/{BookingPanelArrangement--EkA1ZQd.mjs → StepIndicator-DCfdcb7s.mjs} +12 -12
  77. package/dist/client/{StepIndicator-JO2PS03n.mjs → StepIndicator-DCqorVne.mjs} +7 -7
  78. package/dist/client/{TabBarFragment-BqfRLojo.mjs → TabBarFragment-DlKQRhP4.mjs} +1 -1
  79. package/dist/client/{ThemedButton-DuaYtnvG.mjs → ThemedButton-CnSa7o-I.mjs} +66 -66
  80. package/dist/client/{accessibleSurfaces-DN8it_Cx.mjs → accessibleSurfaces-Wl8-_OVJ.mjs} +1 -1
  81. package/dist/client/{accordion-XgNxl0Wg.mjs → accordion-wofJY8xY.mjs} +1 -1
  82. package/dist/client/{booking-form.client-ljJoDwuI.mjs → booking-form.client-CYl9NrqS.mjs} +412 -79
  83. package/dist/client/{bookingForm-DtEHwY4W.mjs → bookingForm-kgVWtuMe.mjs} +4 -4
  84. package/dist/client/bookings.mjs +40 -10
  85. package/dist/client/{boxStyleClassNames-BHoMAcun.mjs → boxStyleClassNames-CQHWz5gJ.mjs} +19 -19
  86. package/dist/client/{carousel-B3UhbFu7.mjs → carousel-BE1dEFsD.mjs} +2 -2
  87. package/dist/client/{carousel.client-h65clfUO.mjs → carousel.client-DMtGYTTM.mjs} +1 -1
  88. package/dist/client/{cart-DzOJfYOR.mjs → cart-BsjsdGZE.mjs} +3 -3
  89. package/dist/client/{cart.client-DBG77v-5.mjs → cart.client-DylGUWXY.mjs} +1 -1
  90. package/dist/client/{checkout-LmePoEgM.mjs → checkout-B5KxEUDr.mjs} +3 -3
  91. package/dist/client/{checkout.client-DmgZuLBT.mjs → checkout.client-C98fhch3.mjs} +1 -1
  92. package/dist/client/{checkoutUrls-CMZI8o_V.mjs → checkoutUrls-BMLYTf38.mjs} +1 -1
  93. package/dist/client/client.mjs +502 -341
  94. package/dist/client/constants-PfYJsEZF.mjs +101 -0
  95. package/dist/client/{context-CJIz4FdL.mjs → context-DtKdUdkO.mjs} +200 -27
  96. package/dist/client/{dateFormatting-UoXqBh10.mjs → dateFormatting-BaGPvQS3.mjs} +1 -1
  97. package/dist/client/{demoPortalMagicLink-6CgFZNvu.mjs → demoPortalMagicLink-B8eDjhuG.mjs} +1 -1
  98. package/dist/client/{enhanceHeaderSection-DaMo6len.mjs → enhanceHeaderSection-DvhD-8eE.mjs} +4 -4
  99. package/dist/client/{event-registration.client-b6APrFQe.mjs → event-registration.client-Du9a_xAN.mjs} +1982 -1519
  100. package/dist/client/{eventCalendar-DJYz7yZf.mjs → eventCalendar-Di9wDfzl.mjs} +4 -4
  101. package/dist/client/{eventCombined-j9VCVgMW.mjs → eventCombined-CNW6nBsB.mjs} +4 -4
  102. package/dist/client/{eventListing-DWgpGuFM.mjs → eventListing-CQMxQ8By.mjs} +4 -4
  103. package/dist/client/{eventRegistration-DCinRot3.mjs → eventRegistration-CprS9k1D.mjs} +4 -4
  104. package/dist/client/events-9LPvwbWp.mjs +28 -0
  105. package/dist/client/{form-BBBtRwvy.mjs → form-Zl1_8RJ6.mjs} +3 -3
  106. package/dist/client/{form.client-CZeRQLGF.mjs → form.client-TaMUys6I.mjs} +5 -5
  107. package/dist/client/{form.parts-DhGGv4_L.mjs → form.parts-CpNPbPPM.mjs} +3 -3
  108. package/dist/client/{formatDate-DVFVDcDW.mjs → formatDate-hhI1-tzt.mjs} +1 -1
  109. package/dist/client/gifting/client.mjs +6 -6
  110. package/dist/client/{gifting-Di9-SpwW.mjs → gifting-DNVa7-Wj.mjs} +4 -4
  111. package/dist/client/{gifting.client-CjT5PrAZ.mjs → gifting.client-CFUq3GVx.mjs} +5 -5
  112. package/dist/client/{gifting.parts-ffP6mjMd.mjs → gifting.parts-CDQvxA4A.mjs} +2 -2
  113. package/dist/client/{headerSection-jjAvtSZk.mjs → headerSection-Cg6083rn.mjs} +2 -2
  114. package/dist/client/{lookSurfaces-C2VzJfyG.mjs → lookSurfaces-gJ3OqPf9.mjs} +258 -86
  115. package/dist/client/{newsletter-form.client-D45frHoa.mjs → newsletter-form.client-VuL9I96G.mjs} +6 -6
  116. package/dist/client/{shop.interactive-D7wky1GL.mjs → newsletter-form.interactive-7Of3eYn0.mjs} +4023 -4029
  117. package/dist/client/{newsletter-form.parts-CHdg82ct.mjs → newsletter-form.parts-OBqsfT24.mjs} +2 -2
  118. package/dist/client/{newsletterForm-tS465_vl.mjs → newsletterForm-BkJe_RTv.mjs} +3 -3
  119. package/dist/client/portal/client.mjs +301 -117
  120. package/dist/client/{product-detail.client-DIWSeW7P.mjs → product-detail.client-B2hdxqJN.mjs} +1 -1
  121. package/dist/client/{product-list.client-BRf14h_e.mjs → product-list.client-CCEgu9rx.mjs} +1 -1
  122. package/dist/client/{productDetail-gxF5whea.mjs → productDetail-CRX_ZRfS.mjs} +3 -3
  123. package/dist/client/{productList-B9t0XJrN.mjs → productList-BAdJ6z5S.mjs} +3 -3
  124. package/dist/client/{propsDecoder-Db8wAmgr.mjs → propsDecoder-BLKAmX0S.mjs} +2 -48
  125. package/dist/client/{registry.server-Bn0gE0uP.mjs → registry.server-Bj9cmHHF.mjs} +10464 -9113
  126. package/dist/client/rendering/client.mjs +41 -27
  127. package/dist/client/rendering/islands.mjs +1 -1
  128. package/dist/client/rendering.mjs +23 -2836
  129. package/dist/client/{richText-coerce-COnKrLO7.mjs → richText-coerce-Z45OLLEX.mjs} +1 -1
  130. package/dist/client/{routeIslandApiConfig-Bok1Oy50.mjs → routeIslandApiConfig-DHpTTK77.mjs} +1 -1
  131. package/dist/client/runtimeResponse-D2j2-mOk.mjs +3 -0
  132. package/dist/client/{runtimeResponse-9v8q2NBc.mjs → runtimeResponse-DtWSfWSZ.mjs} +1 -1
  133. package/dist/client/{shop-D1oTPDxm.mjs → shop-BKsgxm_-.mjs} +3 -3
  134. package/dist/client/{shop-commerce-DyMZLC0a.mjs → shop-commerce-Cbtk_kUW.mjs} +14 -14
  135. package/dist/client/{shop-commerce-store-FODNS63D.mjs → shop-commerce-store-B-rv2p5h.mjs} +1 -1
  136. package/dist/client/{shop-discount-apply.state-C4xcmFzZ.mjs → shop-discount-apply.state-CiCDLNh7.mjs} +2 -2
  137. package/dist/client/{shop.client-CRgRulfI.mjs → shop.client-Rnqa74Tk.mjs} +14 -14
  138. package/dist/client/{shopShared-Bd_hy9ZO.mjs → shopShared-BaBfhjCq.mjs} +2 -2
  139. package/dist/client/spam-protection.mjs +1 -1
  140. package/dist/client/{noop-D11X-B6n.mjs → src-o7WEvbK1.mjs} +398 -308
  141. package/dist/client/{timetableModel-UlWfP1gh.mjs → timetableModel-BOff1Kk5.mjs} +259 -11
  142. package/dist/client/{types-DjWUR_O6.mjs → types-BEaKfam_.mjs} +65 -65
  143. package/dist/client/{useAvailableSlots-D-qoooLy.mjs → useAvailableSlots-DQJNh10g.mjs} +3 -23
  144. package/dist/client/useDiscountCodeUi-BcFQRI_7.mjs +196 -0
  145. package/dist/client/{useEventPagination-CQH2e9sQ.mjs → useEventPagination-BvdcexDC.mjs} +8 -8
  146. package/dist/client/{view-bGU1ws-m.mjs → view-CTBwSpKv.mjs} +4 -4
  147. package/dist/client/{display-D1oVR5Eh.mjs → wizardSteps-CWIQyRIw.mjs} +10263 -9078
  148. package/dist/preview-next/before-render.mjs +5 -3
  149. package/dist/preview-next/client/{LocationPickerEnvironment-BHAT81Wx.mjs → LocationPickerEnvironment-BW3dRFIv.mjs} +1 -1
  150. package/dist/preview-next/client/{MapLibreEditMap-B52hkdIZ.mjs → MapLibreEditMap-Db9BHyXh.mjs} +2 -2
  151. package/dist/preview-next/client/{PageSectionToolbar-D-Le7O3o.mjs → PageSectionToolbar-CG6KwITA.mjs} +4 -4
  152. package/dist/preview-next/client/{PreviewEditorSidebar-DNy5j_ce.mjs → PreviewEditorSidebar-BGBqrC9m.mjs} +8 -7
  153. package/dist/preview-next/client/{PreviewEditorUI-CzJvgbqt.mjs → PreviewEditorUI-Bwkyx28x.mjs} +5 -5
  154. package/dist/preview-next/client/{PreviewShell-xhJ6ca1i.mjs → PreviewShell-DB1l6JNU.mjs} +7 -7
  155. package/dist/preview-next/client/{SdkPreviewModeRuntime-BmYO1TdT.mjs → SdkPreviewModeRuntime-Bs6Cwzr3.mjs} +15 -7
  156. package/dist/preview-next/client/{lucide-react-McYZeSMb.mjs → lucide-react-00FF_oar.mjs} +13 -1
  157. package/dist/preview-next/client/{previewAssistantSlot-BN93X9o1.mjs → previewAssistantSlot-T-oDD_Dd.mjs} +6252 -2461
  158. package/dist/preview-next/client/{previewChromeRoot-C51RQseo.mjs → previewChromeRoot-BeukcDRy.mjs} +1 -1
  159. package/dist/preview-next/client/runtime.mjs +3 -3
  160. package/dist/preview-next/client/{sdk-runtime-oeGquJM-.mjs → sdk-runtime-ceDW_9q2.mjs} +2 -2
  161. package/dist/preview-next/client/{siteStyleAccess-BGTAcPud.mjs → siteStyleAccess-CCB9bScO.mjs} +35 -23
  162. package/dist/preview-next/client/{useAutosaveStatus-BMGXjGZq.mjs → useAutosaveStatus-D4o0CKq7.mjs} +1 -1
  163. package/dist/preview-next/client/{useOpenBlockForSetup-CTDoR_gQ.mjs → useOpenBlockForSetup-Seccrvwu.mjs} +2 -2
  164. package/dist/preview-next/container-responsive.css +103 -10
  165. package/dist/preview-next/keepAlive.mjs +1 -1
  166. package/dist/preview-next/middleware.mjs +1 -1
  167. package/dist/preview-next/{route-contract-BtdzkSUg.mjs → route-contract-FwFj8zGL.mjs} +71 -10
  168. package/dist/server/{Block.shared-Bp3OlOjj.mjs → Block.shared-D6WrRCxX.mjs} +4 -4
  169. package/dist/server/{ThemeScopeCore-DFEM1a85.mjs → ThemeScopeCore-BQzjDQ2q.mjs} +8 -1
  170. package/dist/server/{bindings-DrbJuftt.mjs → bindings-CS6ih1Yc.mjs} +37 -6
  171. package/dist/server/{client-Bf06n9oj.mjs → client-m0ylCj_f.mjs} +436 -526
  172. package/dist/server/config-validation.mjs +1 -1
  173. package/dist/server/config.mjs +2 -2
  174. package/dist/server/contentTypeResolver-B9vy8BrF.mjs +19 -0
  175. package/dist/server/data/dataLoaderContext.mjs +1 -1
  176. package/dist/server/data/resolveBlockData.mjs +1 -1
  177. package/dist/server/{dataLoaderContext-B3fXA54R.mjs → dataLoaderContext-lMRTfG5Z.mjs} +1 -0
  178. package/dist/server/error-f4g44bKx.mjs +387 -0
  179. package/dist/server/index.mjs +3 -2
  180. package/dist/server/loadContent-vgWMz1uD.mjs +694 -0
  181. package/dist/server/{loadPage-5iZefzDd.mjs → loadPage-CIOL3-9t.mjs} +22 -4
  182. package/dist/server/{lookMediaFrame-CaH018pK.mjs → lookMediaFrame-m-91jGGn.mjs} +36 -0
  183. package/dist/server/next.mjs +67 -94
  184. package/dist/server/{overrideResolution-CUHtm7tW.mjs → overrideResolution-BiHmsvTZ.mjs} +1 -1
  185. package/dist/server/page-converter.mjs +1 -1
  186. package/dist/server/{pageRenderPlan-GmPXForc.mjs → pageRenderPlan-DJo_obpi.mjs} +15 -8
  187. package/dist/server/{pageRuntimeSupport-Dd8LFzfa.mjs → pageRuntimeSupport-BnSuoHON.mjs} +54 -2
  188. package/dist/server/{pageShared-tz-GVWft.mjs → pageShared-BJuOzxzn.mjs} +554 -304
  189. package/dist/server/{prebuild-JmsuYCIH.mjs → prebuild-Cr8p8T7V.mjs} +5 -4
  190. package/dist/server/prebuild.mjs +1 -1
  191. package/dist/server/{prefetchBlockData-Ce9DDwON.mjs → prefetchBlockData-BZh57-ua.mjs} +5 -3
  192. package/dist/server/{registry-D12XF_h1.mjs → registry-CvhFwbXJ.mjs} +358 -95
  193. package/dist/server/rendering/components/pageShared.mjs +1 -1
  194. package/dist/server/rendering/helpers/loadPage.mjs +1 -1
  195. package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
  196. package/dist/server/rendering/server.mjs +5 -4
  197. package/dist/server/rendering.mjs +9 -8
  198. package/dist/server/{resolveBlockData-D9yZIN3V.mjs → resolveBlockData-Cv_W1LVB.mjs} +61 -34
  199. package/dist/server/resolvePageContent-BWKUZUIn.mjs +89 -0
  200. package/dist/server/{responseMedia-F-ElH2Rd.mjs → responseMedia-KRKguBC5.mjs} +56 -1
  201. package/dist/server/routing.mjs +271 -57
  202. package/dist/server/server.mjs +3 -3
  203. package/dist/server/{loadContent-eaTY7RPg.mjs → servicePageContent-CRKbTm_7.mjs} +719 -459
  204. package/dist/server/theme-bridge.mjs +1 -1
  205. package/dist/server/{validation-CLq5cw6M.mjs → validation-DCl-FCk_.mjs} +4 -4
  206. package/dist/server/{version-oPbhAx8E.mjs → version-DT_R5JAR.mjs} +1 -1
  207. package/dist/styles/index.css +504 -27
  208. package/package.json +1 -1
  209. package/dist/_dts/footerPageOutline-D_XbQW_o.d.ts +0 -256
  210. package/dist/_dts/resolvePageContent-YT6ndha1.d.ts +0 -162
  211. package/dist/client/LocationMapActions-CiMtl1Ha.mjs +0 -62
  212. package/dist/client/MapDrawingSvg-BCZa3dpf.mjs +0 -200
  213. package/dist/client/constants-4o4_hl34.mjs +0 -6
  214. package/dist/client/course-DBEU9IA9.mjs +0 -244
  215. package/dist/client/duration-Q6_QNgiv.mjs +0 -37
  216. package/dist/client/event-details.client-BwASwKIq.mjs +0 -53
  217. package/dist/client/eventDetails-BzGOVDI-.mjs +0 -13
  218. package/dist/client/runtimeResponse-CVkM0dHy.mjs +0 -3
  219. package/dist/client/useDiscountCodeUi-B9DODAkj.mjs +0 -237
  220. package/dist/client/view-DNX59QwM.mjs +0 -1372
  221. package/dist/server/resolvePageContent-CAELMBEJ.mjs +0 -438
@@ -1,20 +1,46 @@
1
1
  "use client";
2
- import { $ as resolveEventRegistrationSubmitPlan, $n as getTicketSelectionRemainingPlaces, $t as incompleteRunChoiceMessage, An as selectionPreviewLines, At as toRegistrationEvents, B as getTicketSelectionPurpose, Bo as eventRegistrationErrors, Bt as decideSelectionRequirementsLayout, Cn as combinationHintCopy, Ct as registrationQuestionsMessage, D as registrationRoute, Dn as selectionCombinationHint, Dr as closedDateCopy, E as registrationPresentation, En as combinationWorking, Eo as groupPublicEventsByRun, Er as closedRunCopy, Et as toWaitlistClaimResolveFailure, F as registrationFlowReducer, Ft as eventSignInEnds, G as resolveRegistrationAdmission, Gt as toRunRequirementsSnapshots, H as planRegistrationDetailsCheck, Hn as getPortalSubjectEmail, Ht as nextRunToRead, I as buildEventRegistrationPaymentOptionsViewModel, It as eventSignInRestoration, Ja as requestSignIn, Jn as getCurrentTicketSelection, Ka as leavePage, Kn as transformRegistrationOptionsResponse, Ko as orderedLiveRunSessions, Kt as withoutKeptAnswers, L as decideEventRegistrationPayment, Lt as toEventSignInDraft, M as decideEventChoice, Mt as toWholeSeriesRegistrationEvents, N as getDeclinedPass, Nt as EVENT_SIGN_IN_FORM_ID, P as isRegistrationLocked, Pn as findSelectedTicketType, Pt as eventSignInDraftStore, Qn as getSlidingScaleSelectionMessage, Qt as effectiveSelection, Ro as decideSelectionAttendance, Rt as buildSelectionRequirementsSubmission, Sn as toggleSelectionItem, St as invitationSubmission, T as registrationPaymentRoute, Tn as combinationOffersOf, Tr as closedDatesCopy, Tt as isSameWaitlistClaim, U as planRegistrationDetailsContinuation, Ut as runFieldErrors, Vn as getImplicitSingleTicketType, Vo as parseEventRegistrationErrorReason, Vt as deriveRunRequirements, W as resolveGuestNextStepCheck, Wa as PAGE_NAVIGATION, Wn as getVisibleTicketTypes, Wt as runsKeepingAnswers, Xn as getRegistrationOccurrenceId, Xo as resolveBookingSignupOffer, Xt as canToggleSelectionItem, Y as visitorHoldsOwnPlace, Yn as getEligibilityFlowFlags, Zn as getSlidingScaleForEvent, Zt as decideSelectionPayment, _n as selectionTicketInputs, _t as resolveRegistrationTarget, aa as deriveBookingQuestions, ar as getSingleSelectedPricingOptionId, bn as severalRunsChoiceMessage, bt as beginWaitlistInvitation, c as formatCommercePrice, dn as selectionIncludes, dt as restorableBrowserDraftCode, en as planSelectionPrice, er as parseCurrencyInputToCents, fn as selectionItemPrice, ft as withOfferedEvent, gt as resolveEventRequiresPayment, ht as resolveDiscountContext, it as calculateEventRegistrationPreviewTotal, j as createInitialRegistrationFlowState, jn as serverPricedTotalCents, kn as selectionPreviewKey, kt as getRegistrationStartAt, la as toBookingQuestionsPaymentSnapshot, lr as hasValidPricingOptionSelection, ls as publicEventPricingCurrency, lt as registrationBrowserDraft, mt as findPreSelectedEvent, nn as registrationSelectionMode, no as resolveEventRegistrationScopedEvents, nr as shouldLoadRegistrationOptions, oa as needsBookingQuestionsRefresh, pt as buildRegistrationSelectionRequest, q as resolveRegistrationTicketContinuation, qi as formatCentsAsCurrencyInput, qo as resolveWholeSeriesBookingPhase, qt as paymentReturnRestoration, rr as withRegistrationAvailability, t as appliedDiscountHint, tn as primarySelectionItem, to as resolveEventRegistrationChoices, tr as resolveHeldTicketPlaces, ur as normalizeTicketSelectionLines, ut as registrationBrowserDraftSchema, vt as resolveRouteRequiresPayment, wt as validateFormData, xn as summariseSelectionPayment, xt as createRegistrationDraftData, yn as severalItemsOf, yt as toRegistrationRequestSubject, zo as eventRegistrationErrorEndsCommand, zt as checkRunRequirements } from "./display-D1oVR5Eh.mjs";
3
- import { gn as resolveBookingBusinessTimeZone, n as assertNever, rn as inferSiteDateLocale } from "./noop-D11X-B6n.mjs";
2
+ import { f as err, p as ok } from "./renderableMediaAssetAdmission-BlfqYLJW.mjs";
3
+ import { $ as withOfferedEvent, $o as decideSelectionAttendance, A as visitorHoldsOwnPlace, At as eventSignInRestoration, B as calculateEventRegistrationPreviewTotal, Bi as toBookingQuestionsPaymentSnapshot, Bt as withoutKeptAnswers, Cn as selectionCombinationHint, Cr as formatCommercePrice, Ct as getRegistrationStartAt, D as resolveRegistrationTicketContinuation, Da as leavePage, Dn as findSelectedTicketType, Dt as EVENT_SIGN_IN_FORM_ID, En as serverPricedTotalCents, Et as toWholeSeriesRegistrationEvents, Ft as deriveRunRequirements, Gn as getTicketSelectionRemainingPlaces, Gt as decideSelectionPayment, Hi as formatPrice, Hn as getRegistrationOccurrenceId, Hr as resolveEventRegistrationChoices, Ii as deriveBookingQuestions, In as getVisibleTicketTypes, It as nextRunToRead, J as restorableBrowserDraftCode, Jn as shouldLoadRegistrationOptions, Jt as planSelectionPrice, K as registrationBrowserDraft, Kn as parseCurrencyInputToCents, Kt as effectiveSelection, Li as needsBookingQuestionsRefresh, Lr as closedDatesCopy, Lt as runFieldErrors, Mt as buildSelectionRequirementsSubmission, Nn as getImplicitSingleTicketType, Nt as checkRunRequirements, On as formatBookingWhen, Ot as eventSignInDraftStore, P as resolveEventRegistrationSubmitPlan, Pn as getPortalSubjectEmail, Pt as decideSelectionRequirementsLayout, Q as invitationBooking, Rn as transformRegistrationOptionsResponse, Rr as closedRunCopy, Rt as runsKeepingAnswers, S as planRegistrationDetailsContinuation, Sn as paymentCaption, T as resolveRegistrationAdmission, Ta as PAGE_NAVIGATION, Tn as selectionPreviewLines, U as paymentChoiceDetails, Un as getSlidingScaleForEvent, Ur as resolveEventRegistrationScopedEvents, Vi as formatCentsAsCurrencyInput, Vn as getCurrentTicketSelection, Vt as paymentReturnRestoration, W as paymentChoicePrice, Wn as getSlidingScaleSelectionMessage, Wt as canToggleSelectionItem, X as createRegistrationDraftData, Xt as quoteReductions, Y as beginWaitlistInvitation, Yn as withRegistrationAvailability, Yt as primarySelectionItem, Z as invitationSubmission, Zn as getSingleSelectedPricingOptionId, Zt as registrationSelectionMode, _n as toggleSelectionItem, _t as roomSubmission, a as registrationPresentation, at as resolveRouteRequiresPayment, bn as combinationOffersOf, bt as toWaitlistClaimResolveFailure, cs as getStripeMinimumChargeRequirement, ct as validateFormData, d as decideEventChoice, ds as orderedLiveRunSessions, dt as dayOptionsOf, et as buildRegistrationSelectionRequest, f as isRegistrationLocked, fn as selectionTicketInputs, fs as resolveWholeSeriesBookingPhase, ft as decideRoomStay, gn as summariseSelectionPayment, gr as appliedDiscountHint, gs as resolveBookingSignupOffer, gt as roomChoiceMessage, h as decideEventRegistrationPayment, hn as severalRunsChoiceMessage, ht as presentRoomChooser, i as registrationPaymentRoute, is as planCheckoutPaymentFlow, it as resolveRegistrationTarget, jt as toEventSignInDraft, k as severalRunsNeedCard, ka as requestSignIn, ks as publicEventPricingCurrency, kt as eventSignInEnds, m as buildEventRegistrationPaymentOptionsViewModel, mn as severalItemsOf, mt as isRoomChoiceRefusal, nr as normalizeTicketSelectionLines, ns as eventRegistrationErrors, nt as resolveDiscountContext, o as registrationRoute, on as selectionIncludes, ot as toRegistrationRequestSubject, p as registrationFlowReducer, pt as defaultTicketOptions, q as registrationBrowserDraftSchema, qn as resolveHeldTicketPlaces, qt as incompleteRunChoiceMessage, rs as parseEventRegistrationErrorReason, rt as resolveEventRequiresPayment, sn as selectionItemPrice, st as registrationQuestionsMessage, ti as groupPublicEventsByRun, tr as hasValidPricingOptionSelection, ts as eventRegistrationErrorEndsCommand, tt as findPreSelectedEvent, u as createInitialRegistrationFlowState, ut as bookingLines, vn as combinationHintCopy, vt as selectRoomOffer, w as resolveGuestNextStepCheck, wt as toRegistrationEvents, x as planRegistrationDetailsCheck, xn as combinationWorking, y as getTicketSelectionPurpose, yt as isSameWaitlistClaim, zr as closedDateCopy, zt as toRunRequirementsSnapshots } from "./wizardSteps-CWIQyRIw.mjs";
4
+ import { Tn as formatCurrencyAmount, _t as roomChoicesSchema, gt as reviewedRoomsSchema, on as inferSiteDateLocale, t as assertNever, yn as resolveBookingBusinessTimeZone } from "./src-o7WEvbK1.mjs";
4
5
  import { o as checkBookingQuestionsAnswered } from "./creditProducts-BQ1t1erI.mjs";
5
- import { a as eventSiteTermsSurface, i as useSiteTermsAgreement, r as siteTermsFailureKind } from "./SiteTermsAgreementField-DkFnbzf_.mjs";
6
+ import { i as useSiteTermsAgreement, r as siteTermsFailureKind } from "./SiteTermsAgreementField-BAdW5DvE.mjs";
6
7
  import { t as generateUuidV4 } from "./uuid-BETKW8rS.mjs";
7
- import { i as BlockApiError, n as useBlockApi } from "./context-CJIz4FdL.mjs";
8
+ import { i as useBookingNowIso, r as parseBookingSubmissionFailure, s as indefiniteArticle } from "./BookingQuestionFields-DXegGSnS.mjs";
9
+ import { i as BlockApiError, n as useBlockApi } from "./context-DtKdUdkO.mjs";
10
+ import { n as EVENT_REGISTRATION_CHECKOUT_ATTEMPT_PARAM, r as paidInFullNote, t as EVENT_REGISTRATION_ANCHOR_ID } from "./constants-PfYJsEZF.mjs";
8
11
  import { t as resolveDedicatedBookingHref } from "./bookingRoute-D6DlxYx6.mjs";
9
- import { r as DISCOUNT_APPLY_MESSAGES } from "./DemoBookingPortalAccess-Olvrwi3Z.mjs";
10
- import { i as useBookingNowIso, r as parseBookingSubmissionFailure } from "./BookingQuestionFields-B57oGPcj.mjs";
11
- import { t as useDiscountCodeUi } from "./useDiscountCodeUi-B9DODAkj.mjs";
12
- import { a as usePolling, c as useBookingQuestionsRefresh, o as portalSessionIdentity, s as useSignInReturn } from "./BookingMailingListNote-DSD4gS96.mjs";
13
- import { n as EVENT_REGISTRATION_CHECKOUT_ATTEMPT_PARAM, t as EVENT_REGISTRATION_ANCHOR_ID } from "./constants-4o4_hl34.mjs";
14
- import { s as storeDemoBookingPass, t as CUSTOMER_PORTAL_PATH } from "./demoPortalMagicLink-6CgFZNvu.mjs";
12
+ import { i as discountEmailProblem } from "./DemoBookingPortalAccess-0Ua44F1j.mjs";
13
+ import { t as useDiscountCodeUi } from "./useDiscountCodeUi-BcFQRI_7.mjs";
14
+ import { c as portalSessionIdentity, l as useSignInReturn, s as usePolling, u as useBookingQuestionsRefresh } from "./BookingMailingListNote-CGxg37zx.mjs";
15
+ import { s as storeDemoBookingPass, t as CUSTOMER_PORTAL_PATH } from "./demoPortalMagicLink-B8eDjhuG.mjs";
15
16
  import { Suspense, lazy, useCallback, useEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
16
17
  import { jsx } from "react/jsx-runtime";
17
18
  import { z } from "zod";
19
+ //#region ../core/src/participants.ts
20
+ function unsafeAsParticipantEmail(value) {
21
+ return value;
22
+ }
23
+ /**
24
+ * Canonicalizes an optional participant email for equality checks.
25
+ *
26
+ * This intentionally does not validate email shape; call parseParticipantEmail at
27
+ * API/DB boundaries that require a syntactically usable address.
28
+ */
29
+ function normalizeParticipantEmail(value) {
30
+ const normalized = value?.trim().normalize("NFC").toLowerCase() ?? "";
31
+ return normalized.length > 0 ? unsafeAsParticipantEmail(normalized) : null;
32
+ }
33
+ function parseParticipantEmail(value) {
34
+ const normalized = normalizeParticipantEmail(value);
35
+ if (normalized === null) return err({ kind: "empty_email" });
36
+ if (!isEmailLike(normalized)) return err({ kind: "invalid_email_shape" });
37
+ return ok(normalized);
38
+ }
39
+ function isEmailLike(value) {
40
+ const atIndex = value.indexOf("@");
41
+ return atIndex > 0 && atIndex === value.lastIndexOf("@") && atIndex < value.length - 1;
42
+ }
43
+ //#endregion
18
44
  //#region ../blocks/src/system/runtime/shared/utils/portalLogout.ts
19
45
  /**
20
46
  * Portal Logout Utility
@@ -218,6 +244,238 @@ function planEventRegistrationSurface(input) {
218
244
  } : { kind: "unavailableWholeSeries" };
219
245
  }
220
246
  //#endregion
247
+ //#region ../blocks/src/system/runtime/nodes/event-registration/useSelectionFunding.state.ts
248
+ /**
249
+ * How the dates are paid, one date or several (issue 1767, sets 6 and 7). The server
250
+ * plans every option, its order and the one to select; the block keeps which one
251
+ * the visitor picked and sends that option back with the split it showed.
252
+ */
253
+ /** The pass or membership an entitlement option uses, as the server names it on submit. */
254
+ function entitlementSource(entitlement) {
255
+ switch (entitlement.kind) {
256
+ case "ownedPass": return {
257
+ kind: "ownedPass",
258
+ passId: entitlement.passId
259
+ };
260
+ case "ownedMembership": return {
261
+ kind: "ownedMembership",
262
+ membershipId: entitlement.membershipId
263
+ };
264
+ case "buyPass": return {
265
+ kind: "buyPass",
266
+ productId: entitlement.productId
267
+ };
268
+ case "buyMembership": return {
269
+ kind: "buyMembership",
270
+ productId: entitlement.productId
271
+ };
272
+ default: return assertNever(entitlement);
273
+ }
274
+ }
275
+ function sourceKey(source) {
276
+ switch (source.kind) {
277
+ case "ownedPass": return `ownedPass:${source.passId}`;
278
+ case "ownedMembership": return `ownedMembership:${source.membershipId}`;
279
+ case "buyPass": return `buyPass:${source.productId}`;
280
+ case "buyMembership": return `buyMembership:${source.productId}`;
281
+ default: return assertNever(source);
282
+ }
283
+ }
284
+ /** One key per option, so a pick survives a refetch that still offers it. */
285
+ function fundingPickKey(pick) {
286
+ switch (pick.kind) {
287
+ case "money": return "money";
288
+ case "entitlement": return sourceKey(pick.source);
289
+ default: return assertNever(pick);
290
+ }
291
+ }
292
+ function fundingOptionPick(option) {
293
+ switch (option.kind) {
294
+ case "money": return { kind: "money" };
295
+ case "entitlement": return {
296
+ kind: "entitlement",
297
+ source: entitlementSource(option.entitlement)
298
+ };
299
+ default: return assertNever(option);
300
+ }
301
+ }
302
+ function fundingOptionKey(option) {
303
+ return fundingPickKey(fundingOptionPick(option));
304
+ }
305
+ function findOption(funding, pick) {
306
+ const key = fundingPickKey(pick);
307
+ return funding.options.find((option) => fundingOptionKey(option) === key);
308
+ }
309
+ /** The picked option, or the server's own selection when the pick isn't offered. */
310
+ function chosenFundingOption(funding, pick) {
311
+ return findOption(funding, pick) ?? findOption(funding, funding.selected) ?? funding.options[0];
312
+ }
313
+ /** The dates the option charges money for, earliest first. */
314
+ function fundingMoneyDates(option) {
315
+ switch (option.kind) {
316
+ case "money": return option.moneyDates;
317
+ case "entitlement": return option.uncovered.map((date) => date.occurrenceId);
318
+ default: return assertNever(option);
319
+ }
320
+ }
321
+ /** What submit sends: the option's source and the split the visitor saw. */
322
+ function fundingChoice(option) {
323
+ switch (option.kind) {
324
+ case "money": return { kind: "money" };
325
+ case "entitlement": return {
326
+ kind: "entitlement",
327
+ source: entitlementSource(option.entitlement),
328
+ expected: {
329
+ covered: [...option.covered],
330
+ moneyDates: [...fundingMoneyDates(option)]
331
+ }
332
+ };
333
+ default: return assertNever(option);
334
+ }
335
+ }
336
+ /**
337
+ * The options request for the dates of one event, one date or several; null
338
+ * for anything else, which keeps its own payment step. A waitlist claim asks the
339
+ * same way: the claim admits the held place, and the funding pays for it.
340
+ */
341
+ function selectionFundingRequest(input) {
342
+ const selection = input.target?.selection;
343
+ if (selection?.kind !== "dates") return null;
344
+ const eventSeriesId = datesSeries(selection, input.eventSeriesId);
345
+ const lines = normalizeTicketSelectionLines(input.ticketSelections);
346
+ if (!eventSeriesId || lines.length === 0) return null;
347
+ return {
348
+ subject: {
349
+ kind: "dates",
350
+ eventSeriesId,
351
+ occurrenceIds: selection.occurrenceIds,
352
+ ...input.attendanceMode ? { attendanceMode: input.attendanceMode } : {}
353
+ },
354
+ selections: lines.map(({ pricingOptionId, quantity }) => ({
355
+ pricingOptionId,
356
+ quantity
357
+ })),
358
+ ...input.selectedSlidingAmount !== null ? { selectedSlidingAmount: input.selectedSlidingAmount } : {}
359
+ };
360
+ }
361
+ /** Several dates name their series; one date's comes from the event being booked. */
362
+ function datesSeries(selection, eventSeriesId) {
363
+ return selection.eventSeriesId ?? (selection.occurrenceIds.length === 1 ? eventSeriesId : null);
364
+ }
365
+ /**
366
+ * What the quote prices for the dates: nothing while the ways to pay are on their way or when the
367
+ * visitor's own pass or membership covers every date, and otherwise the chosen option's whole order,
368
+ * which the server funds and prices itself. Null for anything that isn't dates. One date paid with
369
+ * money keeps its own booking's quote, so its card options, deposits and automatic discount stay
370
+ * as they are, and it waits for nothing.
371
+ */
372
+ function selectionDatesQuote(lookup, request) {
373
+ if (request === null) return null;
374
+ const oneDate = request.subject.occurrenceIds.length === 1;
375
+ switch (lookup.tag) {
376
+ case "idle": return null;
377
+ case "loading":
378
+ case "failed": return oneDate ? null : { kind: "waiting" };
379
+ case "loaded": {
380
+ const option = chosenFundingOption(lookup.funding, lookup.pick);
381
+ if (oneDate && option.kind === "money") return null;
382
+ return ownCoverPaysEveryDate(option) ? { kind: "nothingToPay" } : {
383
+ kind: "order",
384
+ selection: {
385
+ ...request,
386
+ funding: fundingChoice(option)
387
+ }
388
+ };
389
+ }
390
+ default: return assertNever(lookup);
391
+ }
392
+ }
393
+ /** A pass or membership the visitor already has, covering every date: submit books them with no order. */
394
+ function ownCoverPaysEveryDate(option) {
395
+ if (option.kind === "money" || option.uncovered.length > 0) return false;
396
+ switch (option.entitlement.kind) {
397
+ case "ownedPass":
398
+ case "ownedMembership": return true;
399
+ case "buyPass":
400
+ case "buyMembership": return false;
401
+ default: return assertNever(option.entitlement);
402
+ }
403
+ }
404
+ /**
405
+ * One date with nothing but money to offer, no note and no change to explain keeps
406
+ * the card step it always had; anything else shows the ways to pay.
407
+ */
408
+ function cardStepServesDates(lookup, dateCount) {
409
+ if (dateCount !== 1 || lookup.tag !== "loaded" || lookup.notice !== null) return false;
410
+ const { options, entitlementNote } = lookup.funding;
411
+ return options.length === 1 && options[0].kind === "money" && entitlementNote === "none";
412
+ }
413
+ /** The option the visitor has chosen, once the options are in. */
414
+ function lookupChosenOption(lookup) {
415
+ return lookup.tag === "loaded" ? chosenFundingOption(lookup.funding, lookup.pick) : null;
416
+ }
417
+ /** What the visitor is looking at now, for a quote or submit to say which options it was about. */
418
+ function selectionFundingBasis(lookup) {
419
+ return lookup.tag === "loaded" ? {
420
+ requestKey: lookup.requestKey,
421
+ pickKey: fundingPickKey(lookup.pick)
422
+ } : null;
423
+ }
424
+ const initialSelectionFundingLookup = { tag: "idle" };
425
+ function settles(state, requestKey) {
426
+ return state.tag === "loading" && state.requestKey === requestKey;
427
+ }
428
+ function stillCurrent(state, basis) {
429
+ const now = selectionFundingBasis(state);
430
+ return now !== null && basis !== null && now.requestKey === basis.requestKey && now.pickKey === basis.pickKey;
431
+ }
432
+ function selectionFundingReducer(state, action) {
433
+ switch (action.type) {
434
+ case "loading": return {
435
+ tag: "loading",
436
+ requestKey: action.requestKey
437
+ };
438
+ case "loaded": return settles(state, action.requestKey) ? {
439
+ tag: "loaded",
440
+ requestKey: action.requestKey,
441
+ funding: action.funding,
442
+ pick: action.funding.selected,
443
+ notice: null
444
+ } : state;
445
+ case "failed": return settles(state, action.requestKey) ? {
446
+ tag: "failed",
447
+ requestKey: action.requestKey
448
+ } : state;
449
+ case "picked": return state.tag === "loaded" && findOption(state.funding, action.pick) ? {
450
+ ...state,
451
+ pick: action.pick,
452
+ notice: null
453
+ } : state;
454
+ case "changed": return stillCurrent(state, action.basis) ? {
455
+ tag: "loaded",
456
+ requestKey: state.requestKey,
457
+ funding: action.funding,
458
+ pick: action.funding.selected,
459
+ notice: action.message
460
+ } : state;
461
+ case "reset": return initialSelectionFundingLookup;
462
+ default: return assertNever(action);
463
+ }
464
+ }
465
+ /** The lookup for this request: another request's answer, or none yet, is still loading. */
466
+ function currentSelectionFundingLookup(state, requestKey) {
467
+ if (requestKey === null) return initialSelectionFundingLookup;
468
+ if (state.tag !== "idle" && state.requestKey === requestKey) return state;
469
+ return {
470
+ tag: "loading",
471
+ requestKey
472
+ };
473
+ }
474
+ /** Whether the hook should ask the server now. */
475
+ function selectionFundingFetchWanted(state, requestKey, enabled) {
476
+ return enabled && requestKey !== null && (state.tag === "idle" || state.requestKey !== requestKey);
477
+ }
478
+ //#endregion
221
479
  //#region ../blocks/src/system/runtime/nodes/event-registration/registrationDiscountView.state.ts
222
480
  /** The quote owns the code for one booking or several; one booking still finds out what's on offer from availability. */
223
481
  function registrationDiscountView(input) {
@@ -245,47 +503,41 @@ function registrationDiscountView(input) {
245
503
  }
246
504
  /** A draft code must remain editable while its price is unresolved and payment choices are disabled. */
247
505
  function registrationDiscountEntryVisible(view, method) {
248
- return (view.manualCodeEntryAllowed || view.editingCode) && (view.several || method === "stripe" || method === "pass_bundle" || method === "membership_bundle");
506
+ return method === "membership" || view.manualCodeEntryAllowed || view.editingCode;
507
+ }
508
+ /** Typed codes belong to the money choice, including when a pass leaves a card remainder. */
509
+ function registrationDiscountCardOnly(method, funding) {
510
+ return method === "membership" || funding.tag === "loaded" && chosenFundingOption(funding.funding, funding.pick).kind === "entitlement";
249
511
  }
250
512
  //#endregion
251
513
  //#region ../blocks/src/system/runtime/nodes/event-registration/registrationDiscountCode.state.ts
252
514
  const NO_REDUCTION = {
253
515
  bookingTotalCents: null,
254
- automaticDiscount: null,
255
- passTotalCents: null,
256
- membershipFirstPaymentCents: null
516
+ automaticDiscount: null
257
517
  };
258
518
  function decideSingleBookingPrices(input) {
259
519
  const { context, quote } = input;
260
520
  if (input.several || !context) return NO_REDUCTION;
261
- if (context.type === "event") return eventPrices(input, quote);
262
- if (!quote) return NO_REDUCTION;
263
- if (context.type === "pass") return {
264
- ...NO_REDUCTION,
265
- passTotalCents: reducedTotal(quote)
266
- };
267
- return context.type === "membership" ? {
268
- ...NO_REDUCTION,
269
- membershipFirstPaymentCents: reducedTotal(quote)
270
- } : NO_REDUCTION;
521
+ return context.type === "event" || context.type === "whole_series" ? eventPrices(input, quote) : NO_REDUCTION;
271
522
  }
272
523
  function eventPrices(input, quote) {
273
524
  if (!quote) return input.typedCode.trim() || input.lookupFailed ? NO_REDUCTION : {
274
525
  ...NO_REDUCTION,
275
526
  automaticDiscount: input.advertisedAutomatic
276
527
  };
277
- if (quote.preview.type !== "applied") return NO_REDUCTION;
528
+ if (quote.preview.type !== "applied") return {
529
+ ...NO_REDUCTION,
530
+ bookingTotalCents: quote.preview.totalAfterDiscountCents
531
+ };
278
532
  return quote.source === "typed" ? {
279
533
  ...NO_REDUCTION,
280
534
  bookingTotalCents: quote.preview.totalAfterDiscountCents
281
535
  } : {
282
536
  ...NO_REDUCTION,
537
+ bookingTotalCents: quote.preview.totalAfterDiscountCents + quote.preview.discountCents,
283
538
  automaticDiscount: automaticFromQuote(quote.preview, input.advertisedAutomatic)
284
539
  };
285
540
  }
286
- function reducedTotal(quote) {
287
- return quote.preview.type === "applied" ? quote.preview.totalAfterDiscountCents : null;
288
- }
289
541
  /** The discount the server chose for this customer, which may not be the one advertised to everyone. */
290
542
  function automaticFromQuote(preview, advertised) {
291
543
  const shared = {
@@ -306,21 +558,11 @@ function automaticFromQuote(preview, advertised) {
306
558
  };
307
559
  }
308
560
  /** What an applied code does to this purchase, said beside the code. */
309
- function appliedCodeHint(selection, discount) {
310
- if (!discount) return "";
311
- if (selection.method !== "membership_bundle") return appliedDiscountHint({
561
+ function appliedCodeHint(discount) {
562
+ return discount ? appliedDiscountHint({
312
563
  ...discount,
313
564
  membership: null
314
- }) ?? "";
315
- const { productPrice, productInterval } = selection;
316
- if (!productPrice || productInterval !== "month" && productInterval !== "year") return "";
317
- return appliedDiscountHint({
318
- ...discount,
319
- membership: {
320
- priceCents: productPrice,
321
- billingInterval: productInterval
322
- }
323
- }) ?? "";
565
+ }) ?? "" : "";
324
566
  }
325
567
  /** Holds Pay for a code awaiting Apply, and says whether that's the only thing holding it. */
326
568
  function holdPaymentForCode(state, awaitingApply) {
@@ -459,7 +701,7 @@ function getRegistrationBrowserDraft(scope) {
459
701
  try {
460
702
  const stored = sessionStorage.getItem(`riverbank:event-draft:${scope}`);
461
703
  const entry = browserDraftEntry.safeParse(stored ? JSON.parse(stored) : null);
462
- if (entry.success && Date.now() - entry.data.timestamp <= STALE_THRESHOLD_MS) return entry.data.draft;
704
+ if (entry.success && Date.now() - entry.data.timestamp <= 108e5) return entry.data.draft;
463
705
  clearRegistrationBrowserDraft(scope);
464
706
  } catch {}
465
707
  return null;
@@ -480,32 +722,10 @@ const paymentSelection = z.discriminatedUnion("method", [
480
722
  "flexible_balance"
481
723
  ])
482
724
  }),
483
- z.object({
484
- method: z.literal("pass"),
485
- passId: z.string(),
486
- productName: z.string().optional()
487
- }),
488
725
  z.object({
489
726
  method: z.literal("membership"),
490
727
  membershipId: z.string(),
491
728
  productName: z.string().optional()
492
- }),
493
- z.object({
494
- method: z.literal("pass_bundle"),
495
- bundlePassId: z.string(),
496
- productName: z.string().optional(),
497
- productDescription: z.string().optional(),
498
- productPrice: z.number().optional(),
499
- productCurrency: z.string().optional()
500
- }),
501
- z.object({
502
- method: z.literal("membership_bundle"),
503
- bundleMembershipId: z.string(),
504
- productName: z.string().optional(),
505
- productDescription: z.string().optional(),
506
- productPrice: z.number().optional(),
507
- productCurrency: z.string().optional(),
508
- productInterval: z.string().optional()
509
729
  })
510
730
  ]);
511
731
  const reference = z.discriminatedUnion("scope", [z.object({
@@ -544,7 +764,15 @@ const currentSchema = z.object({
544
764
  runChoices: z.record(z.string(), z.object({
545
765
  pricingOptionId: z.string().nullable(),
546
766
  slidingAmountInput: z.string()
547
- })).optional()
767
+ })).optional(),
768
+ rooms: z.object({
769
+ choices: roomChoicesSchema,
770
+ reviewed: reviewedRoomsSchema.default([]),
771
+ dayLines: z.array(z.object({
772
+ pricingOptionId: z.string().nullable(),
773
+ quantity: z.number().int().positive()
774
+ }))
775
+ }).optional()
548
776
  });
549
777
  /** Saved before booking several existed: one reference and one event. */
550
778
  const version6Schema = z.object({
@@ -621,7 +849,7 @@ function hasRegistrationReturn(flow) {
621
849
  const params = new URLSearchParams(window.location.search);
622
850
  return flow.invitation.kind !== "none" || params.has("registration") || params.has("rb_booking_sign_in");
623
851
  }
624
- /** Only the allowlisted contact, ticket and code draft survives a reload in this tab. */
852
+ /** Only the allowlisted draft (`registrationBrowserDraftSchema`) survives a reload in this tab. */
625
853
  function useRegistrationBrowserDraft(input) {
626
854
  const [ready, setReady] = useState(false);
627
855
  const restored = useRef(false);
@@ -633,7 +861,8 @@ function useRegistrationBrowserDraft(input) {
633
861
  input.dispatch({
634
862
  type: "browser-draft-restored",
635
863
  draft: saved,
636
- events: input.events
864
+ events: input.events,
865
+ identity: input.identity
637
866
  });
638
867
  const code = restorableBrowserDraftCode(saved, input.events);
639
868
  if (code.trim()) input.onDiscountCodeRestored(code);
@@ -652,7 +881,7 @@ function useSaveRegistrationBrowserDraft(input) {
652
881
  return;
653
882
  }
654
883
  if (hasRegistrationReturn(input.flow)) return;
655
- const draft = registrationBrowserDraft(input.flow, input.discountCode);
884
+ const draft = registrationBrowserDraft(input.flow, input.discountCode, input.identity);
656
885
  if (draft) saveRegistrationBrowserDraft(input.scope, draft);
657
886
  }, [input, ready]);
658
887
  }
@@ -1046,7 +1275,7 @@ function useRunQuestionsRefresh(input) {
1046
1275
  }
1047
1276
  //#endregion
1048
1277
  //#region ../blocks/src/system/runtime/nodes/event-registration/useTicketSelectionInitialization.ts
1049
- /** Pick the single default once; removing or refreshing a line never picks it again. */
1278
+ /** Pick the single default once; removing or refreshing a line never picks it again. An event with rooms passes no options: its guests choose. */
1050
1279
  function useTicketSelectionInitialization(input) {
1051
1280
  const initializedSelection = useRef(null);
1052
1281
  useEffect(() => {
@@ -1196,7 +1425,13 @@ function useEligibility(params) {
1196
1425
  function eligibilityRequest(params) {
1197
1426
  const selections = normalizeTicketSelectionLines(params.ticketSelections);
1198
1427
  if (!params.enabled || !params.subject || selections.length === 0) return null;
1428
+ const email = parseParticipantEmail(params.buyerEmail);
1199
1429
  return {
1430
+ buyer: email.ok ? {
1431
+ kind: "email",
1432
+ email: email.value
1433
+ } : { kind: "unknown" },
1434
+ purchaseTarget: params.purchaseTarget ?? "eventTickets",
1200
1435
  subject: toRegistrationRequestSubject(params.subject, params.attendanceMode),
1201
1436
  selections: selections.map(({ pricingOptionId, quantity }) => ({
1202
1437
  pricingOptionId,
@@ -1228,18 +1463,31 @@ async function loadEligibility(input) {
1228
1463
  input.dispatch({
1229
1464
  type: "failed",
1230
1465
  requestKey: input.requestKey,
1231
- message: "We couldn’t load the booking options for this event. Please refresh this page and try again. If this keeps happening, contact the organiser for help."
1466
+ message: "We couldn’t load the booking options for this event. Try again, or contact the organiser if this keeps happening."
1232
1467
  });
1233
1468
  }
1234
1469
  }
1235
1470
  function useEligibilityWithDeps(params, deps) {
1236
1471
  const api = deps.useBlockApi();
1237
1472
  const request = eligibilityRequest(params);
1473
+ const scope = useRef({
1474
+ api,
1475
+ version: 0
1476
+ });
1477
+ if (scope.current.api !== api) scope.current = {
1478
+ api,
1479
+ version: scope.current.version + 1
1480
+ };
1238
1481
  const requestKey = JSON.stringify({
1482
+ scope: scope.current.version,
1483
+ subjectEmail: params.subjectEmail,
1484
+ purchaseKey: params.purchaseKey,
1239
1485
  refreshKey: params.refreshKey ?? 0,
1240
1486
  request
1241
1487
  });
1242
1488
  const [state, dispatch] = useReducer(eligibilityLookupReducer, initialEligibilityLookupState);
1489
+ const activeKey = useRef(requestKey);
1490
+ activeKey.current = requestKey;
1243
1491
  useEffect(() => {
1244
1492
  const lifetime = { current: true };
1245
1493
  const timeoutId = window.setTimeout(() => {
@@ -1249,7 +1497,7 @@ function useEligibilityWithDeps(params, deps) {
1249
1497
  request,
1250
1498
  requestKey,
1251
1499
  dispatch,
1252
- isCurrent: () => lifetime.current
1500
+ isCurrent: () => lifetime.current && activeKey.current === requestKey
1253
1501
  });
1254
1502
  }, REGISTRATION_OPTIONS_DEBOUNCE_MS);
1255
1503
  return () => {
@@ -1541,6 +1789,23 @@ function registrationErrorPresentation(failure, bookings = "one") {
1541
1789
  };
1542
1790
  }
1543
1791
  //#endregion
1792
+ //#region ../blocks/src/system/runtime/nodes/event-registration/eventRegistrationFunding.ts
1793
+ /**
1794
+ * How a whole run is paid on the wire. Dates send the server's funding option
1795
+ * instead (issue 1767), so a run is the only booking that names a method.
1796
+ */
1797
+ function toEventRunPayment(choice) {
1798
+ switch (choice.method) {
1799
+ case "free":
1800
+ case "stripe": return { paymentMethod: choice.method };
1801
+ case "membership": return {
1802
+ paymentMethod: "membership",
1803
+ customerMembershipId: choice.membershipId
1804
+ };
1805
+ default: return assertNever(choice.method);
1806
+ }
1807
+ }
1808
+ //#endregion
1544
1809
  //#region ../blocks/src/system/runtime/nodes/event-registration/useEventRegistrationSubmit.ts
1545
1810
  function wantsMailingListSignup(options) {
1546
1811
  return options.mailingListSignup !== null && options.formData.mailingListOptIn === true;
@@ -1598,20 +1863,20 @@ function useEventRegistrationSubmitWithDeps(options, deps) {
1598
1863
  */
1599
1864
  const { commandRef } = options;
1600
1865
  const inFlightRef = useRef(null);
1601
- const submit = async (method, passId, membershipId, selection) => {
1866
+ const submit = async (method, membershipId, selection) => {
1602
1867
  const start = resolveSubmissionStart(options);
1603
1868
  if (start.kind === "blocked") return start.result;
1604
1869
  const { invitation, target } = start;
1605
1870
  options.setStep("submitting");
1606
1871
  const registrationCommandId = commandRef.current?.id ?? deps.createClientCommandId();
1607
1872
  try {
1608
- const initialPrepared = prepareSubmitContext(options, registrationCommandId, target, method, passId, membershipId, selection);
1609
- const intentKey = registrationRequestIntentKey(buildRegistrationRequest(options, initialPrepared, invitation, method, passId, membershipId));
1873
+ const initialPrepared = prepareSubmitContext(options, registrationCommandId, target, method, membershipId, selection);
1874
+ const intentKey = registrationRequestIntentKey(buildRegistrationRequest(options, initialPrepared, invitation, method, membershipId));
1610
1875
  const prepared = commandRef.current !== null && commandRef.current.intentKey !== intentKey ? {
1611
1876
  ...initialPrepared,
1612
1877
  registrationCommandId: deps.createClientCommandId()
1613
1878
  } : initialPrepared;
1614
- const request = buildRegistrationRequest(options, prepared, invitation, method, passId, membershipId);
1879
+ const request = buildRegistrationRequest(options, prepared, invitation, method, membershipId);
1615
1880
  commandRef.current = {
1616
1881
  id: prepared.registrationCommandId,
1617
1882
  intentKey
@@ -1622,7 +1887,7 @@ function useEventRegistrationSubmitWithDeps(options, deps) {
1622
1887
  }));
1623
1888
  } catch (error) {
1624
1889
  if (error instanceof BlockApiError && (eventRegistrationErrorEndsCommand(error.tag) || error.fieldErrors.some((field) => field.field === "discountCode"))) commandRef.current = null;
1625
- return reportFailedRegistration(options, error, method);
1890
+ return reportFailedRegistration(options, error);
1626
1891
  }
1627
1892
  };
1628
1893
  return (...args) => {
@@ -1677,15 +1942,20 @@ async function completeRegistrationSubmission(options, deps, prepared, result) {
1677
1942
  mailingListSignupNote: result.mailingListSignupNote
1678
1943
  });
1679
1944
  break;
1945
+ case "fundingChanged":
1946
+ options.commandRef.current = null;
1947
+ if (options.onFundingChanged) options.onFundingChanged(result.funding, result.message);
1948
+ else options.setErrorMessage(result.message);
1949
+ options.setStep("select-payment");
1950
+ return {
1951
+ ok: false,
1952
+ reason: "blocked",
1953
+ message: result.message
1954
+ };
1680
1955
  case "bookingComplete":
1681
- options.complete({
1682
- status: "confirmed",
1683
- outcome: result.outcome,
1684
- ...result.outcomes ? { outcomes: result.outcomes } : {},
1685
- message: result.summary.passCreditsRemaining !== void 0 ? result.summary.message : void 0,
1686
- mailingListSignupNote: result.mailingListSignupNote
1687
- });
1956
+ options.complete(confirmedRegistration(result));
1688
1957
  break;
1958
+ default: return assertNever(result);
1689
1959
  }
1690
1960
  options.commandRef.current = null;
1691
1961
  return {
@@ -1693,6 +1963,21 @@ async function completeRegistrationSubmission(options, deps, prepared, result) {
1693
1963
  outcome: { kind: "completed" }
1694
1964
  };
1695
1965
  }
1966
+ /**
1967
+ * A completed booking as the finished screen reads it. One booking says its pass balance in the
1968
+ * summary's message; several list it with how each date was paid, so the message would repeat it.
1969
+ */
1970
+ function confirmedRegistration(result) {
1971
+ const { passCreditsRemaining } = result.summary;
1972
+ return {
1973
+ status: "confirmed",
1974
+ submissionPayment: result.submissionPayment,
1975
+ outcome: result.outcome,
1976
+ mailingListSignupNote: result.mailingListSignupNote,
1977
+ ...result.outcomes ? { outcomes: result.outcomes } : { message: passCreditsRemaining !== void 0 ? result.summary.message : void 0 },
1978
+ ...passCreditsRemaining !== void 0 ? { passCreditsRemaining } : {}
1979
+ };
1980
+ }
1696
1981
  function toTicketSelectionRequests(lines) {
1697
1982
  return lines.map((line) => ({
1698
1983
  pricingOptionId: line.pricingOptionId,
@@ -1703,15 +1988,13 @@ function toTicketSelectionRequests(lines) {
1703
1988
  * Freeze everything this submission is about to send, including the command
1704
1989
  * identity the server keys the commit on.
1705
1990
  */
1706
- function prepareSubmitContext(options, registrationCommandId, target, method, passId, membershipId, selection) {
1991
+ function prepareSubmitContext(options, registrationCommandId, target, method, membershipId, selection) {
1707
1992
  const ticketSelections = normalizeTicketSelectionLines(options.ticketSelections);
1708
1993
  if (ticketSelections.length === 0) throw new Error("Choose at least one ticket to continue.");
1709
- const bundleProductId = method === "pass_bundle" || method === "membership_bundle" ? passId || membershipId : void 0;
1710
1994
  return {
1711
1995
  registrationCommandId,
1712
1996
  ticketSelections,
1713
- bundleProductId,
1714
- selectionSnapshot: resolveSelectionSnapshot(method, passId, membershipId, bundleProductId, selection),
1997
+ selectionSnapshot: resolveSelectionSnapshot(method, membershipId, selection),
1715
1998
  guestsPayload: options.requireGuestDetails && options.guests.length > 0 ? options.guests.map((guest) => ({
1716
1999
  name: guest.name.trim(),
1717
2000
  email: guest.email?.trim().toLowerCase() || void 0,
@@ -1726,24 +2009,12 @@ function prepareSubmitContext(options, registrationCommandId, target, method, pa
1726
2009
  })
1727
2010
  };
1728
2011
  }
1729
- function resolveSelectionSnapshot(method, passId, membershipId, bundleProductId, selection) {
2012
+ function resolveSelectionSnapshot(method, membershipId, selection) {
1730
2013
  if (selection?.method) return selection;
1731
- if (method === "pass" && passId) return {
1732
- method,
1733
- passId
1734
- };
1735
2014
  if (method === "membership" && membershipId) return {
1736
2015
  method,
1737
2016
  membershipId
1738
2017
  };
1739
- if (method === "pass_bundle" && bundleProductId) return {
1740
- method,
1741
- bundlePassId: bundleProductId
1742
- };
1743
- if (method === "membership_bundle" && bundleProductId) return {
1744
- method,
1745
- bundleMembershipId: bundleProductId
1746
- };
1747
2018
  if (method === "free") return { method };
1748
2019
  throw new Error("Choose an available payment option.");
1749
2020
  }
@@ -1760,7 +2031,12 @@ function savePendingCheckout(options, deps, prepared, checkoutAttemptId, mailing
1760
2031
  guests: options.guests,
1761
2032
  selectedSlidingAmount: options.selectedSlidingAmount,
1762
2033
  discountCode: options.discountCode,
1763
- mailingListSignupNote
2034
+ mailingListSignupNote,
2035
+ ...options.rooms ? { rooms: {
2036
+ choices: options.rooms.request.choices,
2037
+ reviewed: options.rooms.request.reviewed,
2038
+ dayLines: options.rooms.dayLines
2039
+ } } : {}
1764
2040
  });
1765
2041
  }
1766
2042
  function registrationRequestIntentKey(request) {
@@ -1773,15 +2049,14 @@ function registrationRequestIntentKey(request) {
1773
2049
  } : void 0
1774
2050
  });
1775
2051
  }
1776
- function buildRegistrationRequest(options, prepared, invitation, method, passId, membershipId) {
1777
- return {
2052
+ function buildRegistrationRequest(options, prepared, invitation, method, membershipId) {
2053
+ const common = {
1778
2054
  registrationCommandId: prepared.registrationCommandId,
1779
2055
  checkout: {
1780
2056
  returnUrl: eventPaymentReturnUrl(prepared.registrationCommandId),
1781
2057
  discountCode: options.discountCode.trim() || void 0,
1782
2058
  collectionOptionKind: prepared.selectionSnapshot.method === "stripe" ? prepared.selectionSnapshot.collectionOptionKind : void 0
1783
2059
  },
1784
- selection: prepared.selection,
1785
2060
  ticketSelections: toTicketSelectionRequests(prepared.ticketSelections),
1786
2061
  selectedSlidingAmount: options.selectedSlidingAmount ?? void 0,
1787
2062
  email: options.formData.email.trim().toLowerCase(),
@@ -1790,12 +2065,22 @@ function buildRegistrationRequest(options, prepared, invitation, method, passId,
1790
2065
  notes: options.formData.notes.trim() || void 0,
1791
2066
  ...singleBookingRequirements(options, prepared),
1792
2067
  mailingListOptIn: wantsMailingListSignup(options),
1793
- paymentMethod: method,
1794
- customerPassId: method === "pass" ? passId : void 0,
1795
- customerMembershipId: method === "membership" ? membershipId : void 0,
1796
- bundleProductId: prepared.bundleProductId,
1797
2068
  ...invitationRequestCredential(invitation.credential),
1798
- guests: prepared.guestsPayload
2069
+ guests: prepared.guestsPayload,
2070
+ ...options.rooms ? { rooms: options.rooms.request } : {}
2071
+ };
2072
+ const selection = prepared.selection;
2073
+ return selection.kind === "dates" ? {
2074
+ ...common,
2075
+ selection,
2076
+ funding: options.selectionFunding ?? { kind: "money" }
2077
+ } : {
2078
+ ...common,
2079
+ selection,
2080
+ ...toEventRunPayment({
2081
+ method,
2082
+ membershipId
2083
+ })
1799
2084
  };
1800
2085
  }
1801
2086
  /**
@@ -1816,19 +2101,30 @@ function invitationRequestCredential(credential) {
1816
2101
  }
1817
2102
  }
1818
2103
  /** Legal rejection returns to the intact draft, before any payment effect. */
1819
- function failedRegistrationStep(failure, method) {
2104
+ function failedRegistrationStep(failure, funding) {
2105
+ if (isRoomChoiceRefusal(failure.reason)) return "select-tickets";
1820
2106
  if (failure.discountRefused) return "select-payment";
1821
2107
  if (failure.reason === "paymentContextMismatch") return "select-payment";
1822
2108
  if (failure.reason === "invalidAnswers") return "enter-details";
1823
2109
  if (!failure.siteTermsFailure) return "error";
1824
- return method === "pass_bundle" || method === "membership_bundle" ? "select-payment" : "enter-details";
2110
+ return buysWithBooking(funding) ? "select-payment" : "enter-details";
2111
+ }
2112
+ function buysWithBooking(funding) {
2113
+ if (!funding || funding.kind === "money") return false;
2114
+ switch (funding.source.kind) {
2115
+ case "buyPass":
2116
+ case "buyMembership": return true;
2117
+ case "ownedPass":
2118
+ case "ownedMembership": return false;
2119
+ default: return assertNever(funding.source);
2120
+ }
1825
2121
  }
1826
2122
  function bookingCount(target) {
1827
2123
  const selection = target?.selection;
1828
2124
  return (selection?.kind === "runs" ? selection.eventSeriesIds.length : selection?.occurrenceIds.length ?? 1) > 1 ? "several" : "one";
1829
2125
  }
1830
2126
  /** Keep feedback, field errors and navigation together when a submission fails. */
1831
- function reportFailedRegistration(options, error, method) {
2127
+ function reportFailedRegistration(options, error) {
1832
2128
  const parsed = parseEventRegistrationFailure(error);
1833
2129
  const { message, action } = registrationErrorPresentation(parsed, bookingCount(options.registrationTarget));
1834
2130
  const failure = {
@@ -1840,7 +2136,8 @@ function reportFailedRegistration(options, error, method) {
1840
2136
  options.setErrorAction?.(action);
1841
2137
  options.setErrorMessage(message);
1842
2138
  options.setSubmissionFailure(failure);
1843
- options.setStep(failedRegistrationStep(parsed, method));
2139
+ if (isRoomChoiceRefusal(parsed.reason)) options.refreshOptions?.();
2140
+ options.setStep(failedRegistrationStep(parsed, options.selectionFunding));
1844
2141
  return {
1845
2142
  ok: false,
1846
2143
  reason: "submission-failed",
@@ -1869,9 +2166,24 @@ function quoteFeedback(state) {
1869
2166
  message: state.preview.type === "applied" ? `${state.preview.publicLabel} applied. You'll pay ${formatCommercePrice(state.preview.totalAfterDiscountCents, state.preview.currency)}.` : ""
1870
2167
  } : null;
1871
2168
  }
2169
+ /** The request for this input, or null while there's nothing to price yet. */
2170
+ function selectionQuoteRequest(input) {
2171
+ if (input.dates !== null) switch (input.dates.kind) {
2172
+ case "order": return { selection: input.dates.selection };
2173
+ case "waiting":
2174
+ case "nothingToPay": return null;
2175
+ default: return assertNever(input.dates);
2176
+ }
2177
+ const lines = input.several !== null ? selectionPreviewLines(input) : input.singleLines.length > 0 ? input.singleLines : null;
2178
+ return lines ? { lines } : null;
2179
+ }
1872
2180
  /** A quote belongs to the complete priced input and the customer, never just the draft code. */
1873
- function selectionQuoteKey(lines, email) {
1874
- return lines ? JSON.stringify([selectionPreviewKey(null, lines), email.trim().toLowerCase()]) : null;
2181
+ function selectionQuoteKey(request, email, scope) {
2182
+ return request ? JSON.stringify([
2183
+ request,
2184
+ email.trim().toLowerCase(),
2185
+ ...scope ? [scope] : []
2186
+ ]) : null;
1875
2187
  }
1876
2188
  function currentSelectionQuote(state, key) {
1877
2189
  return state.key === key ? state : emptyQuoteDraft(key, state.draftCode);
@@ -1884,16 +2196,20 @@ function editedSelectionCode(state, key, draftCode) {
1884
2196
  ...same && state.uncoded ? { uncoded: state.uncoded } : {}
1885
2197
  };
1886
2198
  }
2199
+ /**
2200
+ * What one quote answer means for the selection. A changed pass or membership isn't a price at all: the
2201
+ * options go back to the server's revised ones, as when submit refuses the split, and the new option is
2202
+ * priced from there. Its state stays unpriced, so nothing is charged on the old split meanwhile.
2203
+ */
2204
+ function decideSelectionQuoteAnswer(pending, result) {
2205
+ return {
2206
+ state: decideSelectionQuoteResponse(pending, result),
2207
+ fundingChanged: result.type === "fundingChanged" ? result : null
2208
+ };
2209
+ }
1887
2210
  function decideSelectionQuoteResponse(pending, result) {
1888
2211
  const typed = Boolean(pending.draftCode.trim());
1889
- if (result.type === "rejected") return typed && result.reason === "invalid_or_not_applicable" ? {
1890
- ...pending,
1891
- status: "refused",
1892
- message: result.message
1893
- } : {
1894
- ...pending,
1895
- status: "failed"
1896
- };
2212
+ if (result.type === "rejected" || result.type === "fundingChanged") return unpricedQuote(pending, typed, result);
1897
2213
  if (typed && result.type !== "applied") return {
1898
2214
  ...pending,
1899
2215
  status: "failed"
@@ -1907,41 +2223,67 @@ function decideSelectionQuoteResponse(pending, result) {
1907
2223
  decidedCode: typed && result.type === "applied" ? result.code : void 0
1908
2224
  };
1909
2225
  }
2226
+ /** No price: a typed code the server refused shows why; anything else, a changed pass included, is unresolved. */
2227
+ function unpricedQuote(pending, typed, result) {
2228
+ return typed && result.type === "rejected" && result.reason === "invalid_or_not_applicable" ? {
2229
+ ...pending,
2230
+ status: "refused",
2231
+ message: result.message
2232
+ } : {
2233
+ ...pending,
2234
+ status: "failed"
2235
+ };
2236
+ }
1910
2237
  /**
1911
2238
  * Whether to ask the server now, without the visitor pressing Apply: for the
1912
2239
  * automatic code, or for a code the visitor typed before (in one item's box,
1913
2240
  * or before going to Stripe and coming back), which they've already applied
1914
2241
  * as far as they know. A code typed here waits for Apply.
1915
2242
  */
1916
- function automaticSelectionQuoteWanted(state, input, carried = false) {
2243
+ function explicitSelectionQuoteWanted(state, input, carried = false) {
2244
+ if (!serverPricesTotal(input) && input.combinedPending) return false;
1917
2245
  return input.automaticWanted && state.status === "draft" && (carried || uncodedQuoteWanted(input) && !state.draftCode.trim());
1918
2246
  }
1919
- /** Several items have no total until the server prices them; one booking has a price already. */
2247
+ /**
2248
+ * Several items, and dates paid with a pass or membership, have no total until the server
2249
+ * prices their order; one booking paid by card has a price already.
2250
+ */
2251
+ function serverPricesTotal(input) {
2252
+ return input.several !== null || input.dates !== null;
2253
+ }
1920
2254
  function uncodedQuoteWanted(input) {
1921
- return input.several !== null || input.automaticOffered;
2255
+ return serverPricesTotal(input) || input.productAutomaticOffered;
1922
2256
  }
1923
- /** Nothing to price: no code or automatic discount can change a free selection. */
2257
+ /** Nothing to price: no code or automatic discount can change a free selection, or dates the visitor's own cover pays for. */
1924
2258
  function freeSelection(input) {
1925
- return input.several !== null && input.price.listTotalCents === 0;
2259
+ return serverPricesTotal(input) && (input.price.listTotalCents === 0 || input.dates?.kind === "nothingToPay");
1926
2260
  }
1927
2261
  function selectionPayable(input, state) {
1928
- if (input.several === null || freeSelection(input)) return input.price.totalCents;
2262
+ if (!serverPricesTotal(input)) return input.price.totalCents;
2263
+ if (freeSelection(input)) return input.dates?.kind === "nothingToPay" ? 0 : input.price.totalCents;
1929
2264
  if (input.payment.kind === "payment") return serverPricedTotalCents({
1930
- listTotalCents: input.price.listTotalCents,
2265
+ listTotalCents: paymentListCents(input, state),
1931
2266
  reductions: input.payment.checkout.priceReductions ?? []
1932
2267
  });
1933
2268
  return pricedPreview(state)?.totalAfterDiscountCents ?? null;
1934
2269
  }
2270
+ /** A dates order can hold a bought pass besides the dates, so its list price is the one the server priced. */
2271
+ function paymentListCents(input, state) {
2272
+ return (input.dates?.kind === "order" ? pricedPreview(state)?.subtotalCents ?? null : null) ?? input.price.listTotalCents;
2273
+ }
1935
2274
  /** The price to show and charge: the decided quote, or after a refused code, the price without it. */
1936
2275
  function pricedPreview(state) {
1937
2276
  if (state.status === "priced") return state.preview;
1938
2277
  return state.status === "refused" ? state.uncoded ?? null : null;
1939
2278
  }
2279
+ function selectionPriceSettled(input, state) {
2280
+ return !(!serverPricesTotal(input) && state.key !== null && Boolean(state.draftCode.trim()) && state.status !== "priced") && (pricedPreview(state) !== null || freeSelection(input) || singleBookingNeedsNoAnswer(input, state));
2281
+ }
1940
2282
  /** The only projection that can expose a selection's payable total and submitted code. */
1941
2283
  function decidedSelectionPricing(input, state, apply) {
1942
2284
  const priced = state.status === "priced" ? state : null;
1943
2285
  const fallback = priced === null ? pricedPreview(state) : null;
1944
- const settled = priced !== null || fallback !== null || freeSelection(input) || singleBookingNeedsNoAnswer(input, state);
2286
+ const settled = selectionPriceSettled(input, state);
1945
2287
  const waiting = quoteWaiting(input, state, settled);
1946
2288
  return {
1947
2289
  state,
@@ -1968,7 +2310,7 @@ function decidedSelectionPricing(input, state, apply) {
1968
2310
  * price anyway, so a preview that failed never stops a booking. A typed code always waits.
1969
2311
  */
1970
2312
  function singleBookingNeedsNoAnswer(input, state) {
1971
- if (input.several !== null) return false;
2313
+ if (serverPricesTotal(input) || input.combinedPending) return false;
1972
2314
  if (state.key === null) return true;
1973
2315
  if (state.draftCode.trim()) return false;
1974
2316
  if (state.status === "failed") return true;
@@ -1981,7 +2323,7 @@ function quoteWaiting(input, state, settled) {
1981
2323
  awaitingVisitor: false,
1982
2324
  codeHoldingOne: false
1983
2325
  };
1984
- const typedOnOne = input.several === null && Boolean(state.draftCode.trim());
2326
+ const typedOnOne = !serverPricesTotal(input) && Boolean(state.draftCode.trim());
1985
2327
  const deciding = serverDeciding(state);
1986
2328
  return {
1987
2329
  quoting: deciding && !typedOnOne,
@@ -2008,6 +2350,31 @@ function codeFieldFor(state, apply, settled) {
2008
2350
  hint: state.status === "priced" && state.preview.totalAfterDiscountCents === 0 ? "There's nothing to pay. You won't need to enter card details." : ""
2009
2351
  };
2010
2352
  }
2353
+ /** A combined response may settle only an uncoded draft. Explicit code requests own their result. */
2354
+ function seedRegistrationQuote(state, preview) {
2355
+ if (state.status !== "draft" || state.draftCode.trim() || !preview) return state;
2356
+ if (preview.kind === "incomplete_selection") return state;
2357
+ if (preview.kind === "lookup_failure") return {
2358
+ ...state,
2359
+ status: "failed"
2360
+ };
2361
+ const [first, ...rest] = preview.price.priceReductions;
2362
+ const fields = {
2363
+ subtotalCents: preview.price.subtotalCents,
2364
+ totalAfterDiscountCents: preview.price.totalCents,
2365
+ currency: preview.price.currency,
2366
+ manualCodeEntryAllowed: preview.manualCodeEntryAllowed,
2367
+ ...first ? { priceReductions: [first, ...rest] } : {}
2368
+ };
2369
+ return decideSelectionQuoteResponse(state, preview.automaticCode ? {
2370
+ type: "applied",
2371
+ ...fields,
2372
+ ...preview.automaticCode
2373
+ } : {
2374
+ type: "priced",
2375
+ ...fields
2376
+ });
2377
+ }
2011
2378
  //#endregion
2012
2379
  //#region ../blocks/src/system/runtime/nodes/event-registration/useSelectionCombinationPricing.ts
2013
2380
  const NOTHING = {
@@ -2044,17 +2411,20 @@ function presentSelectionCombination(input) {
2044
2411
  /** The checkout and quote both consume the code decided by this response. */
2045
2412
  async function requestSelectionQuote(input) {
2046
2413
  try {
2047
- const code = input.pending.draftCode.trim();
2414
+ const code = "selection" in input.request && input.request.selection.funding.kind === "entitlement" ? "" : input.pending.draftCode.trim();
2048
2415
  const result = await input.api.applyDiscountCode({
2049
2416
  customerEmail: input.email.trim(),
2050
- lines: input.lines,
2417
+ ...input.request,
2051
2418
  ...code ? { discountCode: code } : {}
2052
2419
  });
2053
- return decideSelectionQuoteResponse(input.pending, result);
2420
+ return decideSelectionQuoteAnswer(input.pending, result);
2054
2421
  } catch {
2055
2422
  return {
2056
- ...input.pending,
2057
- status: "failed"
2423
+ state: {
2424
+ ...input.pending,
2425
+ status: "failed"
2426
+ },
2427
+ fundingChanged: null
2058
2428
  };
2059
2429
  }
2060
2430
  }
@@ -2065,18 +2435,24 @@ async function requestSelectionQuote(input) {
2065
2435
  * request remains unresolved and can be retried explicitly.
2066
2436
  */
2067
2437
  function useSelectionCombinationPricing(input) {
2068
- const lines = input.several !== null ? selectionPreviewLines(input) : input.singleLines.length > 0 ? input.singleLines : null;
2069
- const key = selectionQuoteKey(lines, input.email);
2438
+ const request = selectionQuoteRequest(input);
2439
+ const seededFromOptions = input.several === null && input.dates === null;
2440
+ const key = selectionQuoteKey(request, input.email, seededFromOptions ? input.registrationRequestKey : void 0);
2070
2441
  const [state, setState] = useState(() => emptyQuoteDraft(key));
2071
2442
  const [carried, setCarried] = useState(false);
2072
- const current = currentSelectionQuote(state, key);
2443
+ const latestPending = useRef(null);
2444
+ const latestKey = useRef(key);
2445
+ latestKey.current = key;
2446
+ const registrationPreview = seededFromOptions ? input.registrationPreview : null;
2447
+ const current = seedRegistrationQuote(currentSelectionQuote(state, key), registrationPreview);
2073
2448
  const apply = async () => {
2074
- if (key === null || lines === null) return;
2075
- if (current.draftCode.trim() && !input.email.trim()) {
2449
+ if (key === null || request === null) return;
2450
+ const emailProblem = current.draftCode.trim() ? discountEmailProblem(input.email) : null;
2451
+ if (emailProblem) {
2076
2452
  setState({
2077
2453
  ...current,
2078
2454
  status: "refused",
2079
- message: DISCOUNT_APPLY_MESSAGES.emailRequired
2455
+ message: emailProblem
2080
2456
  });
2081
2457
  return;
2082
2458
  }
@@ -2086,35 +2462,41 @@ function useSelectionCombinationPricing(input) {
2086
2462
  };
2087
2463
  setCarried(false);
2088
2464
  setState(pending);
2089
- const next = await requestSelectionQuote({
2465
+ latestPending.current = pending;
2466
+ const answer = await requestSelectionQuote({
2090
2467
  api: input.api,
2091
2468
  email: input.email,
2092
- lines,
2469
+ request,
2093
2470
  pending
2094
2471
  });
2095
- setState((previous) => previous === pending ? next : previous);
2472
+ setState((previous) => latestKey.current === pending.key && previous === pending ? answer.state : previous);
2473
+ if (latestPending.current !== pending || latestKey.current !== pending.key || answer.fundingChanged === null) return;
2474
+ setCarried(Boolean(pending.draftCode.trim()));
2475
+ input.onFundingChanged(answer.fundingChanged.funding, answer.fundingChanged.message);
2096
2476
  };
2097
2477
  useEffect(() => {
2098
- if (automaticSelectionQuoteWanted(current, input, carried)) apply();
2478
+ if (explicitSelectionQuoteWanted(current, input, carried)) apply();
2099
2479
  }, [
2100
2480
  key,
2101
2481
  input.automaticWanted,
2102
- input.automaticOffered,
2482
+ input.productAutomaticOffered,
2483
+ input.combinedPending,
2103
2484
  current.status,
2104
2485
  current.draftCode,
2105
2486
  carried
2106
2487
  ]);
2107
2488
  const editCode = (draftCode) => {
2108
2489
  setCarried(false);
2109
- setState((previous) => editedSelectionCode(previous, key, draftCode));
2490
+ setState((previous) => editedSelectionCode(seedRegistrationQuote(currentSelectionQuote(previous, key), registrationPreview), key, draftCode));
2110
2491
  };
2111
2492
  /** A code typed in one item's box, or restored after Stripe: priced as soon as payment wants a price. */
2112
2493
  const carryCode = (draftCode) => {
2113
2494
  setCarried(Boolean(draftCode.trim()));
2114
- setState((previous) => editedSelectionCode(previous, key, draftCode));
2495
+ setState((previous) => editedSelectionCode(seedRegistrationQuote(currentSelectionQuote(previous, key), registrationPreview), key, draftCode));
2115
2496
  };
2116
2497
  /** A new booking starts with no code and no earlier price. */
2117
2498
  const reset = () => {
2499
+ latestPending.current = null;
2118
2500
  setCarried(false);
2119
2501
  setState(emptyQuoteDraft(key));
2120
2502
  };
@@ -2142,67 +2524,465 @@ function useEventRegistrationRecoveryRequest() {
2142
2524
  return arrival;
2143
2525
  }
2144
2526
  //#endregion
2145
- //#region ../blocks/src/system/runtime/nodes/event-registration/useSettledCommerceView.ts
2146
- function buildCandidate(input) {
2147
- if (!input.eligibilityIsSettled || !input.eligibility || !input.currentEvent) return null;
2527
+ //#region ../blocks/src/system/runtime/nodes/event-registration/useSelectionFunding.ts
2528
+ const SELECTION_FUNDING_LOAD_FAILED = "We couldn’t load the ways to pay for these dates. Try again, or refresh the page.";
2529
+ const ONE_DATE_FUNDING_LOAD_FAILED = "We couldn’t load the ways to pay for this date. Try again, or refresh the page.";
2530
+ /**
2531
+ * The server's ways to pay for the dates, one or several, fetched when the
2532
+ * payment step wants them. The key carries the dates, places and who's signed in, so any
2533
+ * change asks again and the pick goes back to the server's default.
2534
+ */
2535
+ function useSelectionFunding(input) {
2536
+ const requestKey = input.request ? JSON.stringify([input.request, input.identity]) : null;
2537
+ const [state, dispatch] = useReducer(selectionFundingReducer, initialSelectionFundingLookup);
2538
+ const wanted = selectionFundingFetchWanted(state, requestKey, input.enabled);
2539
+ useEffect(() => {
2540
+ if (!wanted || requestKey === null || input.request === null) return;
2541
+ dispatch({
2542
+ type: "loading",
2543
+ requestKey
2544
+ });
2545
+ input.api.getSelectionFunding(input.request).then((response) => dispatch({
2546
+ type: "loaded",
2547
+ requestKey,
2548
+ funding: response.funding
2549
+ }), () => dispatch({
2550
+ type: "failed",
2551
+ requestKey
2552
+ }));
2553
+ }, [wanted, requestKey]);
2554
+ const lookup = input.enabled || state.tag !== "idle" ? currentSelectionFundingLookup(state, requestKey) : initialSelectionFundingLookup;
2555
+ const basis = selectionFundingBasis(lookup);
2148
2556
  return {
2149
- eventSelectionId: input.currentEvent.selectionId,
2150
- discountContext: resolveDiscountContext({
2151
- paymentSelection: input.paymentSelection,
2152
- event: input.currentEvent,
2153
- eventRequiresPayment: input.eventRequiresPayment,
2154
- ticketsCount: input.ticketsCount
2557
+ lookup,
2558
+ choose: (pick) => dispatch({
2559
+ type: "picked",
2560
+ pick
2155
2561
  }),
2156
- subtotalCents: input.eligibility.price,
2157
- summaryLines: input.eligibility.ticketLines.map((line) => ({
2158
- pricingOptionId: line.pricingOptionId,
2159
- label: line.label,
2160
- quantity: line.quantity,
2161
- unitPriceCents: line.unitPriceCents,
2162
- subtotalCents: line.subtotalCents
2163
- }))
2562
+ revise: (funding, message) => dispatch({
2563
+ type: "changed",
2564
+ funding,
2565
+ message,
2566
+ basis
2567
+ }),
2568
+ reset: () => dispatch({ type: "reset" })
2569
+ };
2570
+ }
2571
+ //#endregion
2572
+ //#region ../blocks/src/system/runtime/nodes/event-registration/selectionFundingView.ts
2573
+ const SEVERAL_PLACES_ENTITLEMENT_NOTE = "Class passes and memberships can be used when you book one place on each date.";
2574
+ const ONE_DATE_SEVERAL_PLACES_ENTITLEMENT_NOTE = "Class passes and memberships can be used when you book one place.";
2575
+ /** The chosen option at the quote's price once it's in; every other option at the funding read's. */
2576
+ function orderPrice(option, chosen, input) {
2577
+ return chosen && input.chosenOrder !== null ? input.chosenOrder : {
2578
+ totalCents: option.money.totalCents,
2579
+ discountCents: 0
2164
2580
  };
2165
2581
  }
2166
- function eligibilityIsSettled(result) {
2167
- return result.settledRequestKey === result.requestKey;
2582
+ /** The server's price for the option's order, with account credit taken off the whole of it, as checkout takes it. */
2583
+ function decideCharge(option, order, input) {
2584
+ const moneyDateCount = fundingMoneyDates(option).length;
2585
+ const creditCents = planCheckoutPaymentFlow({
2586
+ amountDueCents: order.totalCents,
2587
+ discountCents: order.discountCents,
2588
+ availableCreditCents: input.availableCreditCents,
2589
+ creditCurrencyMatches: true,
2590
+ minimumStripeChargeCents: input.minimumCardChargeCents
2591
+ }).reserveCreditCents;
2592
+ const cardCents = order.totalCents - creditCents;
2593
+ const remainder = moneyDateCount === 0 ? "none" : order.totalCents === 0 ? "free" : cardCents === 0 ? "credit" : "card";
2594
+ return {
2595
+ moneyDateCount,
2596
+ boughtCents: boughtPriceCents(option),
2597
+ creditCents,
2598
+ cardCents,
2599
+ remainder
2600
+ };
2168
2601
  }
2169
- function viewIsStale(view, currentEvent, eligibilityState) {
2170
- return view.eventSelectionId !== currentEvent?.selectionId || eligibilityState?.tag === "failed" || eligibilityState?.tag === "idle";
2602
+ function boughtPriceCents(option) {
2603
+ if (option.kind === "money") return 0;
2604
+ switch (option.entitlement.kind) {
2605
+ case "buyPass":
2606
+ case "buyMembership": return option.entitlement.priceCents;
2607
+ case "ownedPass":
2608
+ case "ownedMembership": return 0;
2609
+ default: return assertNever(option.entitlement);
2610
+ }
2171
2611
  }
2172
- function requestIsSettled(discountUi) {
2173
- return discountUi.discountAvailabilityRequestKey === "disabled" || discountUi.settledDiscountAvailabilityRequestKey === discountUi.discountAvailabilityRequestKey;
2612
+ function plural(count, singular, pluralForm = `${singular}s`) {
2613
+ return `${count} ${count === 1 ? singular : pluralForm}`;
2614
+ }
2615
+ const credits = (count) => plural(count, "credit");
2616
+ const datesCount = (count) => plural(count, "date");
2617
+ /** "Fri 13 Nov", "Fri 13 Nov and Fri 20 Nov", "A, B and C". */
2618
+ function joinDays(days) {
2619
+ const last = days[days.length - 1] ?? "";
2620
+ return days.length < 2 ? last : `${days.slice(0, -1).join(", ")} and ${last}`;
2621
+ }
2622
+ /** "the other 2", or "the other date" for one. */
2623
+ function theOther(count) {
2624
+ return count === 1 ? "the other date" : `the other ${count}`;
2625
+ }
2626
+ /** Card wording only when a card is really charged. */
2627
+ function payer(charge) {
2628
+ return charge.remainder === "card" ? "Card pays for" : "You pay for";
2629
+ }
2630
+ /** Why a date isn't covered, under the date. */
2631
+ const UNCOVERED_REASON_COPY = {
2632
+ ends_before: "After your pass ends",
2633
+ not_started: "Before your membership starts",
2634
+ membership_ended: "After your membership ends",
2635
+ already_used_on_date: "Already used for this date",
2636
+ no_credits_left: "No credits left for this date"
2637
+ };
2638
+ function partTitle(facts) {
2639
+ switch (facts.charge.remainder) {
2640
+ case "none":
2641
+ case "free": return facts.name;
2642
+ case "card": return `${facts.name} and card`;
2643
+ case "credit": return `${facts.name} and account credit`;
2644
+ default: return assertNever(facts.charge.remainder);
2645
+ }
2646
+ }
2647
+ function ownedPassShortfall(facts) {
2648
+ switch (facts.shortfall) {
2649
+ case "credits": return facts.covered === 1 ? `Your last credit covers the first date. ${payer(facts.charge)} ${theOther(facts.moneyDates)}.` : `Your last ${facts.covered} credits cover the first ${facts.covered} dates. ${payer(facts.charge)} ${theOther(facts.moneyDates)}.`;
2650
+ case "ends": return `Your pass ends on ${facts.endsOn ?? ""}, so it covers ${datesCount(facts.covered)}. ${payer(facts.charge)} ${facts.moneyDays}.`;
2651
+ case "other": return `Your pass covers ${facts.coveredDays}. ${payer(facts.charge)} ${theOther(facts.moneyDates)}.`;
2652
+ default: return assertNever(facts.shortfall);
2653
+ }
2174
2654
  }
2175
- function discountRequest(view, several = false) {
2176
- const discountContext = several ? null : view?.discountContext ?? null;
2655
+ function boughtPassShortfall(facts) {
2656
+ switch (facts.shortfall) {
2657
+ case "ends": return `It ends on ${facts.endsOn ?? ""}, so it covers ${datesCount(facts.covered)}. You pay for ${facts.moneyDays}.`;
2658
+ case "credits": return `${credits(facts.creditsBefore ?? facts.covered)}, so it covers the first ${datesCount(facts.covered)}. You pay for ${theOther(facts.moneyDates)}.`;
2659
+ case "other": return `It covers ${facts.coveredDays}. You pay for ${facts.moneyDays}.`;
2660
+ default: return assertNever(facts.shortfall);
2661
+ }
2662
+ }
2663
+ const membershipRenewal = (facts) => `${facts.boughtPrice ?? ""} a ${facts.interval ?? "month"}, renews ${facts.interval === "year" ? "yearly" : "monthly"}.`;
2664
+ const passCredits = (facts) => `${facts.covered} pass ${facts.covered === 1 ? "credit" : "credits"}`;
2665
+ /** Each kind's words. A new kind of pass or membership won't compile until it has its own. */
2666
+ const ENTITLEMENT_COPY = {
2667
+ ownedPass: {
2668
+ coveredValue: credits(1),
2669
+ countsCredits: true,
2670
+ title: partTitle,
2671
+ detail: (facts) => facts.moneyDates === 0 ? `${credits(facts.creditsBefore ?? 0)} left, ${facts.creditsLeftAfter ?? 0} after this booking` : ownedPassShortfall(facts),
2672
+ price: (facts) => facts.charge.remainder === "card" ? facts.toPay : credits(facts.covered),
2673
+ button: (facts) => {
2674
+ switch (facts.charge.remainder) {
2675
+ case "none": return `Book using ${passCredits(facts)}`;
2676
+ case "card": return `Use ${passCredits(facts)} and pay ${facts.toPay}`;
2677
+ case "credit":
2678
+ case "free": return `Use ${passCredits(facts)} and book`;
2679
+ default: return assertNever(facts.charge.remainder);
2680
+ }
2681
+ },
2682
+ boughtLine: () => null
2683
+ },
2684
+ ownedMembership: {
2685
+ coveredValue: "Included",
2686
+ countsCredits: false,
2687
+ title: partTitle,
2688
+ detail: (facts) => facts.moneyDates === 0 ? facts.dateCount === 1 ? "Your membership covers this date" : `Your membership covers all ${facts.dateCount} dates` : `Your membership covers ${facts.covered} of these dates. ${payer(facts.charge)} ${theOther(facts.moneyDates)}.`,
2689
+ price: (facts) => facts.charge.remainder === "card" ? facts.toPay : "Included",
2690
+ button: (facts) => facts.charge.remainder === "card" ? `Pay ${facts.toPay}` : facts.dateCount === 1 ? "Book your place" : "Book your places",
2691
+ boughtLine: () => null
2692
+ },
2693
+ buyPass: {
2694
+ coveredValue: credits(1),
2695
+ countsCredits: false,
2696
+ title: (facts) => facts.moneyDates === 0 ? `Buy ${indefiniteArticle(facts.name)} ${facts.name}` : `Buy ${indefiniteArticle(facts.name)} ${facts.name} and pay for the rest`,
2697
+ detail: (facts) => facts.moneyDates === 0 ? `${credits(facts.creditsBefore ?? 0)}. ${facts.dateCount === 1 ? "This date uses" : "These dates use"} ${facts.covered}, leaving ${facts.creditsLeftAfter ?? 0}.` : boughtPassShortfall(facts),
2698
+ price: (facts) => facts.toPay,
2699
+ button: (facts) => facts.moneyDates === 0 || facts.charge.cardCents === 0 ? "Buy pass and book" : `Buy pass and pay ${facts.toPay}`,
2700
+ boughtLine: (facts) => ({ note: facts.creditsBefore === 1 ? "Uses its 1 class" : `Uses ${facts.covered} of its ${facts.creditsBefore ?? facts.covered} classes, ${facts.creditsLeftAfter ?? 0} left for later` })
2701
+ },
2702
+ buyMembership: {
2703
+ coveredValue: "Covered",
2704
+ countsCredits: false,
2705
+ title: (facts) => `Buy ${indefiniteArticle(facts.name)} ${facts.name}`,
2706
+ detail: (facts) => facts.dateCount === 1 ? `${membershipRenewal(facts)} It covers this date. You can cancel from your account.` : `${facts.boughtPrice ?? ""} a ${facts.interval ?? "month"}. It covers all ${datesCount(facts.covered)}.`,
2707
+ price: (facts) => facts.toPay,
2708
+ button: (facts) => facts.moneyDates === 0 || facts.charge.cardCents === 0 ? "Buy membership and book" : `Buy membership and pay ${facts.toPay}`,
2709
+ boughtLine: (facts) => ({ note: `${membershipRenewal(facts)} You can cancel from your account.` })
2710
+ }
2711
+ };
2712
+ function entitlementFacts(entitlement, currency) {
2713
+ switch (entitlement.kind) {
2714
+ case "ownedPass": return {
2715
+ creditsBefore: entitlement.credits.used + entitlement.credits.leftAfter,
2716
+ creditsLeftAfter: entitlement.credits.leftAfter,
2717
+ ends: entitlement.expiresAt,
2718
+ boughtPrice: null,
2719
+ interval: null
2720
+ };
2721
+ case "ownedMembership": return {
2722
+ creditsBefore: null,
2723
+ creditsLeftAfter: null,
2724
+ ends: entitlement.endsAt,
2725
+ boughtPrice: null,
2726
+ interval: null
2727
+ };
2728
+ case "buyPass": return {
2729
+ creditsBefore: entitlement.credits.total,
2730
+ creditsLeftAfter: entitlement.credits.leftAfter,
2731
+ ends: entitlement.expiresAt,
2732
+ boughtPrice: formatPrice(entitlement.priceCents, currency),
2733
+ interval: null
2734
+ };
2735
+ case "buyMembership": return {
2736
+ creditsBefore: null,
2737
+ creditsLeftAfter: null,
2738
+ ends: null,
2739
+ boughtPrice: formatPrice(entitlement.priceCents, currency),
2740
+ interval: entitlement.interval
2741
+ };
2742
+ default: return assertNever(entitlement);
2743
+ }
2744
+ }
2745
+ /**
2746
+ * Credits ran out when every skipped date ran out and the covered ones are
2747
+ * the earliest; the pass ended when every skipped date is after its end.
2748
+ * Anything else names the dates it covers.
2749
+ */
2750
+ function decideShortfall(option, dates, ends) {
2751
+ const reasons = option.uncovered.map((date) => date.reason);
2752
+ const firstCovered = dates.slice(0, option.covered.length).every((date) => option.covered.includes(date.occurrenceId));
2753
+ if (reasons.every((reason) => reason === "no_credits_left") && firstCovered) return "credits";
2754
+ if (ends !== null && reasons.every((reason) => reason === "ends_before")) return "ends";
2755
+ return "other";
2756
+ }
2757
+ function daysOf(ids, dates) {
2758
+ return joinDays(dates.filter((date) => ids.includes(date.occurrenceId)).map((date) => date.day));
2759
+ }
2760
+ function optionFacts(option, charge, input) {
2761
+ const facts = entitlementFacts(option.entitlement, input.currency);
2177
2762
  return {
2178
- discountContext,
2179
- subtotalCents: discountContext?.type === "event" && view?.subtotalCents !== null ? view?.subtotalCents : void 0
2763
+ name: option.entitlement.name,
2764
+ dateCount: input.dates.length,
2765
+ covered: option.covered.length,
2766
+ moneyDates: charge.moneyDateCount,
2767
+ creditsBefore: facts.creditsBefore,
2768
+ creditsLeftAfter: facts.creditsLeftAfter,
2769
+ endsOn: facts.ends === null ? null : input.formatDay(facts.ends),
2770
+ boughtPrice: facts.boughtPrice,
2771
+ interval: facts.interval,
2772
+ shortfall: decideShortfall(option, input.dates, facts.ends),
2773
+ coveredDays: daysOf(option.covered, input.dates),
2774
+ moneyDays: daysOf(fundingMoneyDates(option), input.dates),
2775
+ toPay: formatPrice(charge.cardCents, input.currency),
2776
+ charge
2180
2777
  };
2181
2778
  }
2182
- function useSettledCommerceView(input) {
2183
- const candidate = buildCandidate({
2184
- eligibilityIsSettled: eligibilityIsSettled(input.eligibilityResult),
2185
- eligibility: input.eligibility,
2186
- currentEvent: input.currentEvent,
2187
- paymentSelection: input.paymentSelection,
2188
- eventRequiresPayment: input.eventRequiresPayment,
2189
- ticketsCount: input.ticketsCount
2190
- });
2191
- const settledRef = useRef(candidate);
2192
- if (settledRef.current && viewIsStale(settledRef.current, input.currentEvent, input.eligibilityResult.state)) settledRef.current = null;
2193
- const requestView = candidate ?? settledRef.current;
2194
- const discountUi = input.useDiscountCodeUi({
2195
- api: input.api,
2196
- ...discountRequest(requestView, input.several)
2779
+ function optionRows(option, chosenKey, input) {
2780
+ const key = fundingOptionKey(option);
2781
+ const selected = key === chosenKey;
2782
+ const pick = fundingOptionPick(option);
2783
+ switch (option.kind) {
2784
+ case "money": {
2785
+ const price = formatPrice(orderPrice(option, selected, input).totalCents, input.currency);
2786
+ return input.moneyRows.map((row) => ({
2787
+ key: input.moneyRows.length === 1 ? key : `${key}:${row.key}`,
2788
+ pick,
2789
+ card: row.card,
2790
+ label: row.label,
2791
+ details: row.details,
2792
+ price: row.price ?? price,
2793
+ selected: selected && row.current
2794
+ }));
2795
+ }
2796
+ case "entitlement": {
2797
+ const facts = optionFacts(option, decideCharge(option, orderPrice(option, selected, input), input), input);
2798
+ const copy = ENTITLEMENT_COPY[option.entitlement.kind];
2799
+ return [{
2800
+ key,
2801
+ pick,
2802
+ card: null,
2803
+ selected,
2804
+ label: copy.title(facts),
2805
+ details: [copy.detail(facts)],
2806
+ price: copy.price(facts)
2807
+ }];
2808
+ }
2809
+ default: return assertNever(option);
2810
+ }
2811
+ }
2812
+ function dateLines(option, copy, charge, input) {
2813
+ const money = (cents) => formatCurrencyAmount(cents, input.currency);
2814
+ return input.dates.map((date) => {
2815
+ if (option.covered.includes(date.occurrenceId)) return {
2816
+ key: date.occurrenceId,
2817
+ label: date.label,
2818
+ note: null,
2819
+ value: copy.coveredValue
2820
+ };
2821
+ const uncovered = option.uncovered.find((entry) => entry.occurrenceId === date.occurrenceId);
2822
+ const value = charge.remainder === "free" ? "Free" : date.priceCents === null ? "" : money(date.priceCents);
2823
+ return {
2824
+ key: date.occurrenceId,
2825
+ label: date.label,
2826
+ note: uncovered ? UNCOVERED_REASON_COPY[uncovered.reason] : null,
2827
+ value
2828
+ };
2197
2829
  });
2198
- if (candidate && requestIsSettled(discountUi)) settledRef.current = candidate;
2830
+ }
2831
+ function fundedSummary(option, input) {
2832
+ const charge = decideCharge(option, orderPrice(option, true, input), input);
2833
+ const facts = optionFacts(option, charge, input);
2834
+ const copy = ENTITLEMENT_COPY[option.entitlement.kind];
2835
+ const money = (cents) => formatCurrencyAmount(cents, input.currency);
2836
+ const bought = copy.boughtLine(facts);
2837
+ const lines = [...dateLines(option, copy, charge, input), ...bought ? [{
2838
+ key: "bought",
2839
+ label: `${facts.name} (buying now)`,
2840
+ note: bought.note,
2841
+ value: money(charge.boughtCents)
2842
+ }] : []];
2843
+ const owesMoney = charge.moneyDateCount > 0 || charge.boughtCents > 0;
2844
+ const totals = [
2845
+ ...copy.countsCredits && facts.covered > 0 && owesMoney ? [{
2846
+ key: "credits",
2847
+ label: "From your pass",
2848
+ value: credits(facts.covered),
2849
+ total: false
2850
+ }] : [],
2851
+ ...owesMoney ? input.reductions.map((row) => ({
2852
+ key: row.key,
2853
+ label: row.label,
2854
+ value: `−${money(row.amountCents)}`,
2855
+ total: false
2856
+ })) : [],
2857
+ ...charge.creditCents > 0 ? [{
2858
+ key: "account-credit",
2859
+ label: "Account credit",
2860
+ value: `−${money(charge.creditCents)}`,
2861
+ total: false
2862
+ }] : [],
2863
+ ...owesMoney ? [{
2864
+ key: "to-pay",
2865
+ label: "To pay",
2866
+ value: money(charge.cardCents),
2867
+ total: true
2868
+ }] : copy.countsCredits ? [{
2869
+ key: "credits",
2870
+ label: "From your pass",
2871
+ value: credits(facts.covered),
2872
+ total: true
2873
+ }] : []
2874
+ ];
2199
2875
  return {
2200
- discountUi,
2201
- discountContext: settledRef.current?.discountContext ?? null,
2202
- ticketSelectionSubtotalCents: settledRef.current?.subtotalCents ?? null,
2203
- ticketSelectionSummaryLines: settledRef.current?.summaryLines ?? []
2876
+ summary: {
2877
+ caption: paymentCaption("dates", input.dates.length, input.places),
2878
+ lines,
2879
+ totals
2880
+ },
2881
+ facts,
2882
+ copy
2204
2883
  };
2205
2884
  }
2885
+ /**
2886
+ * Whether the breakdown says something the chosen option's row and button don't:
2887
+ * a code, a combination price or account credit coming off. One date shows it
2888
+ * only then.
2889
+ */
2890
+ function summaryExplainsMoreThanTheOption(summary) {
2891
+ return summary.totals.some((row) => row.key !== "credits" && row.key !== "to-pay");
2892
+ }
2893
+ function entitlementNote(funding, dateCount) {
2894
+ switch (funding.entitlementNote) {
2895
+ case "none": return null;
2896
+ case "severalPlaces": return dateCount === 1 ? ONE_DATE_SEVERAL_PLACES_ENTITLEMENT_NOTE : SEVERAL_PLACES_ENTITLEMENT_NOTE;
2897
+ default: return assertNever(funding.entitlementNote);
2898
+ }
2899
+ }
2900
+ function termsSurfaceOf(option) {
2901
+ if (option.kind === "money") return "primary";
2902
+ switch (option.entitlement.kind) {
2903
+ case "buyPass":
2904
+ case "buyMembership": return "commerce";
2905
+ case "ownedPass":
2906
+ case "ownedMembership": return "primary";
2907
+ default: return assertNever(option.entitlement);
2908
+ }
2909
+ }
2910
+ function presentSelectionFunding(input) {
2911
+ const option = chosenFundingOption(input.funding, input.pick);
2912
+ const chosenKey = fundingOptionKey(option);
2913
+ const common = {
2914
+ option,
2915
+ rows: (ownCoverPaysEveryDate(option) ? input.funding.options.filter((candidate) => candidate.kind === "money" || ownCoverPaysEveryDate(candidate)) : input.funding.options).flatMap((candidate) => optionRows(candidate, chosenKey, input)),
2916
+ termsSurface: termsSurfaceOf(option),
2917
+ note: entitlementNote(input.funding, input.dates.length)
2918
+ };
2919
+ switch (option.kind) {
2920
+ case "money": return {
2921
+ ...common,
2922
+ summary: null,
2923
+ buttonText: null,
2924
+ cardCents: null,
2925
+ takesPayment: orderPrice(option, true, input).totalCents > 0
2926
+ };
2927
+ case "entitlement": {
2928
+ const { summary, facts, copy } = fundedSummary(option, input);
2929
+ return {
2930
+ ...common,
2931
+ summary,
2932
+ buttonText: copy.button(facts),
2933
+ cardCents: facts.charge.cardCents,
2934
+ takesPayment: facts.charge.cardCents > 0
2935
+ };
2936
+ }
2937
+ default: return assertNever(option);
2938
+ }
2939
+ }
2940
+ /** The chosen dates as the summary lists them, each at its own price for every place. */
2941
+ function fundingDatesOf(selection, itemPrice) {
2942
+ return selection.flatMap((event) => event.registrationSubject.kind === "occurrence" ? [{
2943
+ occurrenceId: event.registrationSubject.occurrenceId,
2944
+ label: formatBookingWhen(event, "short"),
2945
+ day: formatBookingWhen(event, "day"),
2946
+ priceCents: itemPrice(event)?.subtotalCents ?? null
2947
+ }] : []);
2948
+ }
2949
+ /** "31 Jan", where the event is. */
2950
+ function fundingDayFormatter(event) {
2951
+ return (iso) => formatBookingWhen({
2952
+ startsAt: iso,
2953
+ timeZone: event?.timeZone ?? null,
2954
+ siteTimeZone: event?.siteTimeZone ?? null,
2955
+ deliveryMode: event?.deliveryMode ?? null
2956
+ }, "dayMonth");
2957
+ }
2958
+ /**
2959
+ * The payment step's status and button for several dates. The money option
2960
+ * keeps the card step's own; a pass or membership option waits for the
2961
+ * server to price its order.
2962
+ */
2963
+ function fundingPaymentStepState(base, lookup, view, priced) {
2964
+ switch (lookup.tag) {
2965
+ case "idle": return base;
2966
+ case "loading": return {
2967
+ ...base,
2968
+ status: base.status === "ready" ? "loading" : base.status,
2969
+ canContinue: false
2970
+ };
2971
+ case "failed": return {
2972
+ ...base,
2973
+ status: base.status === "ready" ? "error" : base.status,
2974
+ canContinue: false
2975
+ };
2976
+ case "loaded":
2977
+ if (!view || view.buttonText === null) return base;
2978
+ return {
2979
+ ...base,
2980
+ canContinue: base.status === "ready" && priced,
2981
+ buttonText: view.buttonText
2982
+ };
2983
+ default: return assertNever(lookup);
2984
+ }
2985
+ }
2206
2986
  //#endregion
2207
2987
  //#region ../blocks/src/system/runtime/nodes/event-registration/useGuestDetailsCheck.ts
2208
2988
  /** When a guest completes details on a full event with a waitlist, asks the
@@ -2239,11 +3019,17 @@ async function checkGuestNextStep(input, request, setCheckingNextStep) {
2239
3019
  }
2240
3020
  }
2241
3021
  function guestNextStepRequest(input) {
3022
+ const buyer = parseParticipantEmail(input.formData.email);
2242
3023
  return input.registrationTarget ? {
2243
3024
  subject: toRegistrationRequestSubject(input.registrationTarget.subject, input.selectedAttendanceMode),
2244
3025
  selections: input.ticketSelections,
2245
3026
  selectedSlidingAmount: input.selectedSlidingAmount ?? void 0,
2246
- email: input.formData.email
3027
+ email: input.formData.email,
3028
+ buyer: buyer.ok ? {
3029
+ kind: "email",
3030
+ email: buyer.value
3031
+ } : { kind: "unknown" },
3032
+ purchaseTarget: "eventTickets"
2247
3033
  } : null;
2248
3034
  }
2249
3035
  //#endregion
@@ -2274,6 +3060,7 @@ function planCheckoutOutcome({ outcome, subject }, intent) {
2274
3060
  switch (outcome.kind) {
2275
3061
  case "resolved": return {
2276
3062
  kind: "confirmed",
3063
+ submissionPayment: outcome.submissionPayment,
2277
3064
  outcome: outcome.outcome,
2278
3065
  ...outcome.outcomes ? { outcomes: outcome.outcomes } : {}
2279
3066
  };
@@ -2459,6 +3246,7 @@ function usePaymentTransitions(options, runtime) {
2459
3246
  case "confirmed":
2460
3247
  options.complete({
2461
3248
  status: "confirmed",
3249
+ submissionPayment: transition.submissionPayment,
2462
3250
  outcome: transition.outcome,
2463
3251
  ...transition.outcomes ? { outcomes: transition.outcomes } : {},
2464
3252
  mailingListSignupNote: note.current
@@ -2845,11 +3633,52 @@ function useVerifiedFormData(draft, authState, profile) {
2845
3633
  email: verifiedEmail
2846
3634
  }, [draft, verifiedEmail]);
2847
3635
  }
3636
+ function registrationQuoteInputs(eligibility) {
3637
+ return {
3638
+ primarySubtotalCents: eligibility?.price ?? null,
3639
+ ticketSelectionSummaryLines: eligibility?.ticketLines ?? []
3640
+ };
3641
+ }
3642
+ function registrationDiscountPreview(state) {
3643
+ return state.tag === "resolved" ? state.eligibility.discountPreview : null;
3644
+ }
3645
+ function registrationPurchaseTarget(payment) {
3646
+ return registrationPurchaseIdentity(payment) === "eventTickets" ? "eventTickets" : "other";
3647
+ }
3648
+ function registrationPurchaseIdentity(payment) {
3649
+ return payment.method === null || payment.method === "stripe" || payment.method === "free" ? "eventTickets" : payment;
3650
+ }
3651
+ function registrationDiscountContext(input) {
3652
+ const { several, currentEvent, paymentIntent, eventRequiresPayment, ticketsCount } = input;
3653
+ const selectedDiscountContext = several !== null || !currentEvent ? null : resolveDiscountContext({
3654
+ paymentSelection: paymentIntent,
3655
+ event: currentEvent,
3656
+ eventRequiresPayment,
3657
+ ticketsCount
3658
+ });
3659
+ return selectedDiscountContext?.type === "event" && currentEvent?.registrationSubject.kind === "wholeSeries" ? {
3660
+ type: "whole_series",
3661
+ eventSeriesId: selectedDiscountContext.eventSeriesId
3662
+ } : selectedDiscountContext;
3663
+ }
3664
+ function registrationClaimRequest(claim) {
3665
+ return claim.kind === "none" ? null : claim.request;
3666
+ }
3667
+ function registrationClaimError(claim, message, action) {
3668
+ return claim.kind === "error" ? {
3669
+ message: claim.message,
3670
+ action: claim.action
3671
+ } : {
3672
+ message,
3673
+ action
3674
+ };
3675
+ }
2848
3676
  function useEventRegistrationWizardWithDeps(options, deps) {
2849
3677
  const api = useBlockApi();
2850
3678
  const arrivalCredential = deps.useWaitlistClaimCredential();
2851
3679
  const nowIso = deps.useBookingNowIso(options.now);
2852
- const { events, registrationEvents, recoveryEvents, scopedEvents, claimEventSource } = useRegistrationEventSource(options, deps.useBookingNowIso(options.now, CHOOSER_CLOCK));
3680
+ const choiceNowIso = deps.useBookingNowIso(options.now, CHOOSER_CLOCK);
3681
+ const { events, registrationEvents, recoveryEvents, scopedEvents, claimEventSource } = useRegistrationEventSource(options, choiceNowIso);
2853
3682
  const preSelectedEvent = useMemo(() => findPreSelectedEvent({
2854
3683
  scopedEvents,
2855
3684
  occurrenceContext: options.occurrenceContext
@@ -2867,12 +3696,13 @@ function useEventRegistrationWizardWithDeps(options, deps) {
2867
3696
  flow: flowState,
2868
3697
  dispatch: dispatchFlow,
2869
3698
  events: scopedEvents,
3699
+ identity: portalSessionIdentity(api.config),
2870
3700
  eventsReady: options.eventSource.kind === "ready",
2871
3701
  onDiscountCodeRestored: restoreDiscountCode
2872
3702
  });
2873
3703
  const step = flowState.step;
2874
3704
  const paymentIntent = flowState.paymentSelection;
2875
- const { selection, runChoices, formData: draftFormData, guests, selectedAttendanceMode, selectedTicketLines, selectedSlidingAmountInput: draftSlidingAmountInput } = flowState.draft;
3705
+ const { selection, runChoices, formData: draftFormData, guests, selectedAttendanceMode, selectedTicketLines, roomChoices, selectedSlidingAmountInput: draftSlidingAmountInput } = flowState.draft;
2876
3706
  const selectedEvent = primarySelectionItem(selection);
2877
3707
  const selectionMode = registrationSelectionMode({
2878
3708
  events: scopedEvents,
@@ -2921,6 +3751,13 @@ function useEventRegistrationWizardWithDeps(options, deps) {
2921
3751
  value
2922
3752
  }
2923
3753
  }), []);
3754
+ const setRoomChoices = useCallback((value) => dispatchFlow({
3755
+ type: "draft-edited",
3756
+ edit: {
3757
+ field: "roomChoices",
3758
+ value
3759
+ }
3760
+ }), []);
2924
3761
  const setSelectedSlidingAmountInput = useCallback((value) => dispatchFlow({
2925
3762
  type: "draft-edited",
2926
3763
  edit: {
@@ -2948,7 +3785,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
2948
3785
  const formData = useVerifiedFormData(draftFormData, portalAuthState, portalProfile);
2949
3786
  const portalIdentity = portalSessionIdentity(api.config);
2950
3787
  const waitlistClaim = flowState.invitation;
2951
- const claimLookup = deps.useWaitlistClaim(waitlistClaim.kind === "none" ? null : waitlistClaim.request);
3788
+ const claimLookup = deps.useWaitlistClaim(registrationClaimRequest(waitlistClaim));
2952
3789
  useEffect(() => {
2953
3790
  dispatchFlow({
2954
3791
  type: "claim-arrived",
@@ -2968,8 +3805,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
2968
3805
  claimEventSource,
2969
3806
  options.occurrenceContext?.id
2970
3807
  ]);
2971
- const errorMessage = waitlistClaim.kind === "error" ? waitlistClaim.message : submissionErrorMessage;
2972
- const errorAction = waitlistClaim.kind === "error" ? waitlistClaim.action : submissionErrorAction;
3808
+ const { message: errorMessage, action: errorAction } = registrationClaimError(waitlistClaim, submissionErrorMessage, submissionErrorAction);
2973
3809
  const selectionLocked = isRegistrationLocked(step);
2974
3810
  useEffect(() => {
2975
3811
  if (selectionLocked || portalAuthState !== "authenticated" || !portalProfile) return;
@@ -2993,7 +3829,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
2993
3829
  });
2994
3830
  const { showMagicLinkModal, changeSignInVisibility: setShowMagicLinkModal, interceptPaymentSelection } = registrationNavigation;
2995
3831
  const currentEvent = selectedEvent ?? preSelectedEvent;
2996
- const attendance = useMemo(() => decideSelectionAttendance(effectiveSelection(selection, preSelectedEvent ?? null)), [selection, preSelectedEvent]);
3832
+ const activeSelection = useMemo(() => effectiveSelection(selection, preSelectedEvent ?? null), [selection, preSelectedEvent]);
3833
+ const attendance = useMemo(() => decideSelectionAttendance(activeSelection), [activeSelection]);
2997
3834
  const commandRef = useRef(null);
2998
3835
  const setStep = useCallback((nextStep) => {
2999
3836
  dispatchFlow({
@@ -3001,10 +3838,13 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3001
3838
  step: nextStep
3002
3839
  });
3003
3840
  }, []);
3841
+ const roomOffer = selectRoomOffer(activeSelection, flowState.roomFacts);
3842
+ const roomStay = useMemo(() => decideRoomStay(roomOffer, roomChoices), [roomOffer, roomChoices]);
3843
+ const bookedTicketLines = useMemo(() => bookingLines(selectedTicketLines, roomStay), [selectedTicketLines, roomStay]);
3004
3844
  const ticketInputs = useMemo(() => selectionTicketInputs({
3005
3845
  several,
3006
3846
  primary: currentEvent,
3007
- lines: selectedTicketLines,
3847
+ lines: bookedTicketLines,
3008
3848
  slidingAmountInput: draftSlidingAmountInput,
3009
3849
  placeCount: flowState.placeCount,
3010
3850
  runChoices,
@@ -3012,7 +3852,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3012
3852
  }), [
3013
3853
  several,
3014
3854
  currentEvent,
3015
- selectedTicketLines,
3855
+ bookedTicketLines,
3016
3856
  draftSlidingAmountInput,
3017
3857
  flowState.placeCount,
3018
3858
  runChoices,
@@ -3020,10 +3860,15 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3020
3860
  ]);
3021
3861
  const usesTicketTypeSelections = ticketInputs.usesTicketLines;
3022
3862
  const selectedSlidingAmountInput = ticketInputs.slidingAmountInput;
3023
- const normalizedSelectedTicketLines = useMemo(() => normalizeTicketSelectionLines(selectedTicketLines), [selectedTicketLines]);
3863
+ const normalizedSelectedTicketLines = useMemo(() => normalizeTicketSelectionLines(bookedTicketLines), [bookedTicketLines]);
3864
+ const roomlessTicketLines = useMemo(() => normalizeTicketSelectionLines(selectedTicketLines), [selectedTicketLines]);
3024
3865
  const primaryLines = useMemo(() => normalizeTicketSelectionLines(ticketInputs.lines), [ticketInputs.lines]);
3025
3866
  const ticketsCount = ticketInputs.ticketsCount;
3026
- const ticketSelections = useMemo(() => waitlistClaim.kind === "ready" ? [...waitlistClaim.restoration.ticketSelections] : primaryLines, [waitlistClaim, primaryLines]);
3867
+ const { ticketSelections, quoteSelections, maxTicketsNum } = useMemo(() => invitationBooking(waitlistClaim, primaryLines, options.maxTicketsNum), [
3868
+ waitlistClaim,
3869
+ primaryLines,
3870
+ options.maxTicketsNum
3871
+ ]);
3027
3872
  const currentTicketSelection = getCurrentTicketSelection(currentEvent, selectedAttendanceMode, ticketSelections);
3028
3873
  const paymentController = usePaymentStatusRecovery({
3029
3874
  api,
@@ -3041,10 +3886,18 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3041
3886
  const bookingClosure = useFreshBookingClosure(deps, options, events, step, holdsPlace(waitlistClaim, paymentController));
3042
3887
  const eligibilityResult = deps.useEligibility({
3043
3888
  refreshKey: optionsRefreshKey,
3889
+ buyerEmail: formData.email,
3890
+ purchaseTarget: registrationPurchaseTarget(paymentIntent),
3891
+ purchaseKey: JSON.stringify([
3892
+ registrationPurchaseIdentity(paymentIntent),
3893
+ several,
3894
+ api.config.siteId,
3895
+ portalIdentity
3896
+ ]),
3044
3897
  enabled: bookingClosureAllowsQuote(bookingClosure, shouldRefreshAfterRegistrationError(step, errorAction, shouldLoadRegistrationOptions(portalAuthState, step))),
3045
3898
  subject: registrationTarget?.subject ?? null,
3046
3899
  attendanceMode: selectedAttendanceMode,
3047
- ticketSelections,
3900
+ ticketSelections: quoteSelections,
3048
3901
  selectedSlidingAmount: parseCurrencyInputToCents(selectedSlidingAmountInput),
3049
3902
  subjectEmail: getPortalSubjectEmail(portalProfile),
3050
3903
  waitlistClaim: waitlistClaimCredential(waitlistClaim)
@@ -3054,6 +3907,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3054
3907
  occurrenceId: registrationOccurrenceId
3055
3908
  });
3056
3909
  const existingRegistrations = useMemo(() => existingRegistrationResult.registrations.filter((registration) => registration.occurrenceId === registrationOccurrenceId), [existingRegistrationResult.registrations, registrationOccurrenceId]);
3910
+ const registrationOptionsState = eligibilityResult.state;
3057
3911
  const eligibility = eligibilityResult.eligibility;
3058
3912
  const eligibilityLoading = eligibilityResult.isLoading;
3059
3913
  const eligibilityError = eligibilityResult.error;
@@ -3140,15 +3994,18 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3140
3994
  maxTickets: options.maxTicketsNum,
3141
3995
  attendanceMode: selectedAttendanceMode
3142
3996
  };
3143
- const { slidingScaleSelectionMessage, selectionChoiceMessage } = resolveSelectionChoiceMessages({
3997
+ const choiceMessages = resolveSelectionChoiceMessages({
3144
3998
  several,
3145
3999
  attendance,
3146
4000
  selection,
3147
4001
  runChoices,
3148
4002
  facts: runChoiceFacts,
3149
4003
  slidingScale: selectedEventSlidingScale,
3150
- selectedAmount: selectedSlidingAmount
4004
+ selectedAmount: selectedSlidingAmount,
4005
+ roomMessage: roomChoiceMessage(roomStay, roomlessTicketLines)
3151
4006
  });
4007
+ const { slidingScaleSelectionMessage } = choiceMessages;
4008
+ const selectionChoiceMessage = choiceMessages.selectionChoiceMessage;
3152
4009
  const ticketTypeSelectionRequired = useMemo(() => {
3153
4010
  const event = currentEvent;
3154
4011
  if (!event || !usesTicketTypeSelections) return false;
@@ -3159,6 +4016,11 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3159
4016
  selectedAttendanceMode,
3160
4017
  usesTicketTypeSelections
3161
4018
  ]);
4019
+ const selectionPayment = decideSelectionPayment({
4020
+ selection,
4021
+ runChoices,
4022
+ eligibility
4023
+ });
3162
4024
  const admission = resolveRegistrationAdmission({
3163
4025
  eligibility,
3164
4026
  eligibilityError,
@@ -3167,7 +4029,9 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3167
4029
  hasWaitlistClaim: waitlistClaim.kind === "ready",
3168
4030
  retryingHeldPlace: paymentController.retryingHeldPlace
3169
4031
  }),
3170
- isAuthenticated: portalAuthState === "authenticated"
4032
+ isAuthenticated: portalAuthState === "authenticated",
4033
+ businessName: options.siteName,
4034
+ severalRunsNeedCard: severalRunsNeedCard(several, selectionPayment)
3171
4035
  });
3172
4036
  const ticketSelectionPurpose = getTicketSelectionPurpose({
3173
4037
  admission,
@@ -3185,7 +4049,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3185
4049
  purpose: ticketSelectionPurpose,
3186
4050
  lines: normalizedSelectedTicketLines,
3187
4051
  visibleOptions: visibleTicketTypes,
3188
- maxTickets: options.maxTicketsNum,
4052
+ maxTickets: maxTicketsNum,
3189
4053
  overallRemainingPlaces,
3190
4054
  heldPlacesBySelection
3191
4055
  });
@@ -3195,8 +4059,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3195
4059
  locked: selectionLocked,
3196
4060
  restoring: !browserDraftReady,
3197
4061
  usesTicketTypes: usesTicketTypeSelections,
3198
- lines: normalizedSelectedTicketLines,
3199
- visibleOptions: visibleTicketTypes,
4062
+ lines: roomlessTicketLines,
4063
+ visibleOptions: defaultTicketOptions(roomOffer, visibleTicketTypes),
3200
4064
  purpose: ticketSelectionPurpose,
3201
4065
  setLines: setSelectedTicketLines
3202
4066
  });
@@ -3225,11 +4089,6 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3225
4089
  const handleGuestShakeEnd = () => {
3226
4090
  setGuestSectionShake(false);
3227
4091
  };
3228
- const selectionPayment = decideSelectionPayment({
3229
- selection,
3230
- runChoices,
3231
- eligibility
3232
- });
3233
4092
  const eventRequiresPayment = useMemo(() => {
3234
4093
  if (selectionPayment.kind === "several") return selectionPayment.due === "card";
3235
4094
  if (selectedEventSlidingScale) return (selectedSlidingAmount ?? 0) > 0;
@@ -3330,8 +4189,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3330
4189
  outcome: "payment-step"
3331
4190
  };
3332
4191
  case "submit": {
3333
- const { method, passId, membershipId, selection } = continuation.args;
3334
- const result = await handleSubmit(method, passId, membershipId, selection);
4192
+ const { method, membershipId, selection } = continuation.args;
4193
+ const result = await handleSubmit(method, membershipId, selection);
3335
4194
  return result.ok ? {
3336
4195
  ok: true,
3337
4196
  outcome: "submitted"
@@ -3343,9 +4202,18 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3343
4202
  }
3344
4203
  }
3345
4204
  };
4205
+ /** The payment step's button, for the block and the headless flow alike. */
3346
4206
  const handlePaymentSelect = async () => {
3347
- const surface = eventSiteTermsSurface(paymentSelection.method);
3348
- if (surface === "commerce" && !siteTerms.requireAgreement(surface)) return;
4207
+ const surface = paymentTermsSurface;
4208
+ if (surface === "commerce" && !siteTerms.requireAgreement(surface)) return {
4209
+ ok: false,
4210
+ reason: "blocked",
4211
+ message: "Agree to the terms of sale to continue."
4212
+ };
4213
+ if (fundingView?.option.kind === "entitlement") return handleSubmit("stripe", void 0, {
4214
+ method: "stripe",
4215
+ collectionOptionKind: "upfront"
4216
+ });
3349
4217
  const submitPlan = resolveEventRegistrationSubmitPlan({
3350
4218
  paymentSelection,
3351
4219
  eventRequiresPayment,
@@ -3354,15 +4222,13 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3354
4222
  if (!submitPlan.ok) {
3355
4223
  setErrorMessage(submitPlan.message);
3356
4224
  setStep("error");
3357
- return;
4225
+ return {
4226
+ ok: false,
4227
+ reason: "blocked",
4228
+ message: submitPlan.message
4229
+ };
3358
4230
  }
3359
- await handleSubmit(submitPlan.args.method, submitPlan.args.passId, submitPlan.args.membershipId, submitPlan.args.selection);
3360
- };
3361
- const handleUseCardInsteadOfPass = () => {
3362
- dispatchFlow({ type: "use-card-instead-of-pass" });
3363
- };
3364
- const handleUsePassInstead = () => {
3365
- dispatchFlow({ type: "use-pass" });
4231
+ return handleSubmit(submitPlan.args.method, submitPlan.args.membershipId, submitPlan.args.selection);
3366
4232
  };
3367
4233
  const handleBookForSomeoneElse = () => {
3368
4234
  if (portalAuthState === "authenticated") {
@@ -3371,16 +4237,21 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3371
4237
  }
3372
4238
  setStep("select-tickets");
3373
4239
  };
3374
- const { discountUi, discountContext, ticketSelectionSubtotalCents: primarySubtotalCents, ticketSelectionSummaryLines } = useSettledCommerceView({
3375
- api,
3376
- useDiscountCodeUi: deps.useDiscountCodeUi,
3377
- eligibilityResult,
3378
- eligibility,
4240
+ const currentPreview = registrationDiscountPreview(eligibilityResult.state);
4241
+ const discountContext = registrationDiscountContext({
4242
+ several,
3379
4243
  currentEvent,
4244
+ paymentIntent,
3380
4245
  eventRequiresPayment,
3381
- paymentSelection: paymentIntent,
3382
- ticketsCount,
3383
- several: several !== null
4246
+ ticketsCount
4247
+ });
4248
+ const { primarySubtotalCents, ticketSelectionSummaryLines } = registrationQuoteInputs(eligibility);
4249
+ const discountUi = deps.useDiscountCodeUi({
4250
+ api,
4251
+ discountContext,
4252
+ preview: currentPreview,
4253
+ loading: eligibilityLoading,
4254
+ scopeKey: eligibilityResult.requestKey
3384
4255
  });
3385
4256
  const selectionPrice = planSelectionPrice({
3386
4257
  several,
@@ -3396,6 +4267,22 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3396
4267
  runChoices,
3397
4268
  primaryTicketUnits: ticketSelectionSummaryLines
3398
4269
  });
4270
+ const { selectionFunding, datesQuote } = useWizardSelectionFunding({
4271
+ api,
4272
+ target: registrationTarget,
4273
+ event: currentEvent,
4274
+ attendanceMode: selectedAttendanceMode,
4275
+ ticketSelections,
4276
+ selectedSlidingAmount,
4277
+ identity: getPortalSubjectEmail(portalProfile),
4278
+ step,
4279
+ portalAuthState
4280
+ });
4281
+ const pricedAsOrder = pricedAsWholeOrder(several, datesQuote);
4282
+ const reviseFunding = (revised, message) => {
4283
+ setErrorMessage("");
4284
+ selectionFunding.revise(revised, message);
4285
+ };
3399
4286
  const combinationPricing = useSelectionCombinationPricing({
3400
4287
  api,
3401
4288
  selection,
@@ -3403,6 +4290,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3403
4290
  places: ticketsCount,
3404
4291
  price: selectionPrice,
3405
4292
  itemPrice,
4293
+ dates: datesQuote,
4294
+ onFundingChanged: reviseFunding,
3406
4295
  email: formData.email,
3407
4296
  payment: paymentController.state,
3408
4297
  automaticWanted: step === "select-payment",
@@ -3414,15 +4303,26 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3414
4303
  ticketLines: ticketSelectionSummaryLines,
3415
4304
  currentEvent
3416
4305
  }),
3417
- automaticOffered: automaticQuoteOffered(discountUi.autoAppliedDiscount, discountContext)
4306
+ registrationPreview: currentPreview,
4307
+ registrationRequestKey: eligibilityResult.requestKey,
4308
+ combinedPending: eligibilityLoading,
4309
+ productAutomaticOffered: discountUi.autoAppliedDiscount !== null && discountContext?.type === "pass"
3418
4310
  });
3419
4311
  const discountView = registrationDiscountView({
3420
- several: several !== null,
4312
+ several: pricedAsOrder,
3421
4313
  single: discountUi,
3422
4314
  selection: combinationPricing,
3423
4315
  context: discountContext
3424
4316
  });
3425
4317
  const { code: discountCode, editCode: setDiscountCode } = discountView;
4318
+ const discountCardOnly = registrationDiscountCardOnly(paymentIntent.method, selectionFunding.lookup);
4319
+ useEffect(() => {
4320
+ if (discountCardOnly && discountCode) setDiscountCode("");
4321
+ }, [
4322
+ discountCardOnly,
4323
+ discountCode,
4324
+ setDiscountCode
4325
+ ]);
3426
4326
  useEffect(() => {
3427
4327
  if (restoredCode === null || paymentReturn) return;
3428
4328
  restoreDiscountCode(null);
@@ -3433,10 +4333,11 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3433
4333
  scope: browserScope,
3434
4334
  ready: browserDraftReady,
3435
4335
  flow: flowState,
3436
- discountCode
4336
+ discountCode,
4337
+ identity: portalSessionIdentity(api.config)
3437
4338
  });
3438
4339
  const singlePrices = decideSingleBookingPrices({
3439
- several: !(several === null),
4340
+ several: pricedAsOrder,
3440
4341
  context: discountContext,
3441
4342
  quote: combinationPricing.quote,
3442
4343
  typedCode: discountCode,
@@ -3445,15 +4346,22 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3445
4346
  });
3446
4347
  const codeAwaitingApply = combinationPricing.codeHoldingOne;
3447
4348
  const ticketSelectionSubtotalCents = singlePrices.bookingTotalCents ?? combinationPricing.payableCents;
3448
- const directPaymentOptions = resolveWizardDirectPaymentOptions({
4349
+ const directPaymentInput = {
3449
4350
  eligibility,
3450
4351
  currentEvent,
3451
4352
  occurrenceContext: options.occurrenceContext,
3452
- ticketSelectionSubtotalCents,
4353
+ ticketSelectionSubtotalCents: cardOptionsSubtotal({
4354
+ several,
4355
+ datesQuote,
4356
+ primarySubtotalCents,
4357
+ ticketSelectionSubtotalCents
4358
+ }),
3453
4359
  automaticDiscount: singlePrices.automaticDiscount,
3454
4360
  nowIso,
3455
4361
  selectionPayment
3456
- });
4362
+ };
4363
+ const directPaymentOptions = resolveWizardDirectPaymentOptions(directPaymentInput);
4364
+ const paymentInFullNote = decidePaidInFullNote(directPaymentInput, directPaymentOptions, choiceNowIso);
3457
4365
  const { paymentDecision, paymentSelection, paymentStepState: quotedPaymentStepState } = resolveWizardPaymentView({
3458
4366
  directPaymentOptions,
3459
4367
  paymentIntent,
@@ -3469,7 +4377,21 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3469
4377
  discountCode: codeAwaitingApply ? discountCode : "",
3470
4378
  step
3471
4379
  });
3472
- const { state: paymentStepState, heldForCode: paymentHeldForCode } = holdPaymentForCode(quotedPaymentStepState, codeAwaitingApply);
4380
+ const { state: cardPaymentStepState, heldForCode: paymentHeldForCode } = holdPaymentForCode(quotedPaymentStepState, codeAwaitingApply);
4381
+ const funding = decideWizardSelectionFunding({
4382
+ lookup: selectionFunding.lookup,
4383
+ selection,
4384
+ itemPrice,
4385
+ places: ticketsCount,
4386
+ eligibility,
4387
+ event: currentEvent,
4388
+ directPaymentOptions,
4389
+ paymentDecision,
4390
+ pricing: combinationPricing,
4391
+ creditState: portalCreditState,
4392
+ cardStepState: cardPaymentStepState
4393
+ });
4394
+ const { view: fundingView, paymentStepState, termsSurface: paymentTermsSurface } = funding;
3473
4395
  const siteTerms = useSiteTermsAgreement({
3474
4396
  terms: options.siteTerms,
3475
4397
  context: {
@@ -3520,6 +4442,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3520
4442
  registrationTarget,
3521
4443
  selectedAttendanceMode,
3522
4444
  ticketSelections,
4445
+ rooms: roomSubmission(roomOffer, roomChoices, roomlessTicketLines, flowState.draft.reviewedRooms),
4446
+ refreshOptions: () => setOptionsRefreshKey((value) => value + 1),
3523
4447
  selectedSlidingAmount,
3524
4448
  runChoices,
3525
4449
  formData,
@@ -3534,6 +4458,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3534
4458
  combinationPricing.refuse(message);
3535
4459
  },
3536
4460
  quoteReady: combinationPricing.ready,
4461
+ selectionFunding: funding.choice,
4462
+ onFundingChanged: reviseFunding,
3537
4463
  invitation: invitationSubmission(waitlistClaim),
3538
4464
  setStep,
3539
4465
  complete,
@@ -3564,6 +4490,16 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3564
4490
  event
3565
4491
  });
3566
4492
  };
4493
+ /**
4494
+ * Several dates: back to the dates with the same ones ticked. The way to pay
4495
+ * and the code's price are dropped; coming back plans them again.
4496
+ */
4497
+ const handleChangeDates = () => {
4498
+ if (selectionLocked) return;
4499
+ selectionFunding.reset();
4500
+ combinationPricing.carryCode(discountCode);
4501
+ setStep("select-event");
4502
+ };
3567
4503
  /** Booking several: Continue moves on with whatever is ticked. */
3568
4504
  const handleSelectionContinue = () => {
3569
4505
  if (selection.length > 0) dispatchFlow({
@@ -3604,10 +4540,12 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3604
4540
  setErrorMessage
3605
4541
  });
3606
4542
  setSelectedSlidingAmountInput(initialSlidingAmountInput(preSelectedEvent ?? null));
4543
+ setRoomChoices([]);
3607
4544
  setSelection(preSelectedEvent ? [preSelectedEvent] : []);
3608
4545
  setGuests([]);
3609
4546
  setGuestErrors({});
3610
4547
  combinationPricing.reset();
4548
+ selectionFunding.reset();
3611
4549
  commandRef.current = null;
3612
4550
  setOptionsRefreshKey((value) => value + 1);
3613
4551
  };
@@ -3627,6 +4565,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3627
4565
  setSelectedAttendanceMode,
3628
4566
  setErrorMessage
3629
4567
  });
4568
+ setRoomChoices([]);
3630
4569
  }
3631
4570
  });
3632
4571
  const handlePaymentSelectionChange = useCallback((selection) => {
@@ -3658,27 +4597,45 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3658
4597
  navigate: setStep,
3659
4598
  payment: paymentController
3660
4599
  });
3661
- const { hasEligibility, hasMembershipEligibility, isMembershipFastTrack } = getEligibilityFlowFlags({
3662
- eligibility,
3663
- portalAuthState,
3664
- ticketsCount,
3665
- paymentMethod: paymentSelection.method
3666
- });
3667
4600
  const displayEvent = withRegistrationAvailability(currentEvent, eligibilityLoading ? null : eligibility, selectedAttendanceMode);
3668
4601
  return {
3669
4602
  ...registrationNavigation.presentation,
4603
+ /** The rooms step, on an event with rooms; null otherwise. */
4604
+ roomChooser: roomChooserStep({
4605
+ step,
4606
+ offer: roomOffer,
4607
+ choices: roomChoices,
4608
+ stay: roomStay,
4609
+ dayLines: roomlessTicketLines,
4610
+ options: visibleTicketTypes,
4611
+ maxTickets: options.maxTicketsNum,
4612
+ refusal: submissionErrorMessage,
4613
+ event: currentEvent,
4614
+ setRoomChoices: (choices) => {
4615
+ setErrorMessage("");
4616
+ setRoomChoices(choices);
4617
+ },
4618
+ setDayLines: (lines) => {
4619
+ setErrorMessage("");
4620
+ setSelectedTicketLines(normalizeTicketSelectionLines(lines));
4621
+ }
4622
+ }),
4623
+ /** What can be listed as a ticket: an event's room prices can only be chosen through its rooms. */
4624
+ listableTicketTypes: dayOptionsOf(visibleTicketTypes, roomOffer),
3670
4625
  api,
3671
4626
  nowIso,
3672
4627
  /** Whether the clock has stopped this visitor starting a booking on this page. */
3673
4628
  bookingClosure,
3674
4629
  directPaymentOptions,
3675
4630
  paymentDecision,
4631
+ /** Why one booking's card payment is the whole price although its terms offer a deposit; null otherwise. */
4632
+ paymentInFullNote,
3676
4633
  anchorId: options.anchorId,
3677
4634
  occurrenceContext: options.occurrenceContext,
3678
4635
  registrationTarget,
3679
4636
  subject: options.subject,
3680
4637
  events,
3681
- maxTicketsNum: waitlistClaim.kind === "ready" ? waitlistClaim.restoration.ticketsCount : options.maxTicketsNum,
4638
+ maxTicketsNum,
3682
4639
  /** The new-booking choices, plus the run or date an invitation holds a place on. */
3683
4640
  scopedEvents: withOfferedEvent(scopedEvents, waitlistClaim),
3684
4641
  /** Everything on this page a booking could be for, whether or not it's still a choice. */
@@ -3693,7 +4650,10 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3693
4650
  },
3694
4651
  admission,
3695
4652
  ticketContinuation,
3696
- handleTicketsComplete,
4653
+ handleTicketsComplete: () => {
4654
+ setErrorMessage("");
4655
+ return handleTicketsComplete();
4656
+ },
3697
4657
  selectedEvent: selectedEvent ? displayEvent : null,
3698
4658
  /** Every chosen item, in date order; the first is `selectedEvent`. */
3699
4659
  selection,
@@ -3718,8 +4678,26 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3718
4678
  itemPrice
3719
4679
  }),
3720
4680
  /** The code field shares the booking's server quote. */
3721
- combinationCodeField: registrationCodeField(combinationPricing.codeField, combinationPricing.quote, paymentIntent),
4681
+ combinationCodeField: registrationCodeField(combinationPricing.codeField, combinationPricing.quote),
3722
4682
  combinationAwaitingVisitor: combinationPricing.awaitingVisitor,
4683
+ /**
4684
+ * The dates' ways to pay from the server and the visitor's pick; null for anything else, and
4685
+ * for one date the card alone pays for, which keeps the card step.
4686
+ */
4687
+ selectionFunding: selectionFundingStepModel({
4688
+ funding: selectionFunding,
4689
+ view: fundingView,
4690
+ locked: selectionLocked,
4691
+ dateCount: fundingDateCount(registrationTarget),
4692
+ chooseCard: (card) => {
4693
+ if (!selectionLocked) handlePaymentSelectionChange({
4694
+ method: "stripe",
4695
+ collectionOptionKind: card
4696
+ });
4697
+ }
4698
+ }),
4699
+ handleChangeDates,
4700
+ paymentTermsSurface,
3723
4701
  /** The payment step's list of what several items cost; null for one item. */
3724
4702
  selectionPaymentSummary: summariseSelectionPayment({
3725
4703
  ready: combinationPricing.ready,
@@ -3747,7 +4725,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3747
4725
  ticketSelections,
3748
4726
  selectedTicketLines: normalizedSelectedTicketLines,
3749
4727
  setSelectedTicketLines: (lines) => {
3750
- if (selectionLocked || waitlistClaim.kind === "ready") return;
4728
+ if (selectionLocked) return;
3751
4729
  setSelectedTicketLines(normalizeTicketSelectionLines(lines));
3752
4730
  },
3753
4731
  selectedSlidingAmountInput,
@@ -3802,27 +4780,21 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3802
4780
  paymentStepState,
3803
4781
  /** Pay is off only because a typed code hasn't been applied yet, which the customer needs telling. */
3804
4782
  paymentHeldForCode: paymentHeldForCode && combinationPricing.awaitingVisitor,
3805
- /** What the pass costs once an applied code is taken off; null when no code applies. */
3806
- passPriceAfterCodeCents: singlePrices.passTotalCents,
3807
- /** A membership's first payment after its discount; it renews at the regular price. */
3808
- membershipFirstPaymentCents: singlePrices.membershipFirstPaymentCents,
3809
4783
  handlePaymentSelectionChange: (value) => {
3810
4784
  if (!selectionLocked) handlePaymentSelectionChange(value);
3811
4785
  },
3812
4786
  paymentSelection,
3813
- declinedPass: getDeclinedPass(flowState),
3814
- isMembershipFastTrack,
3815
4787
  waitlistClaim,
3816
4788
  eligibility,
3817
- registrationOptionsState: eligibilityResult.state,
4789
+ registrationOptionsState,
3818
4790
  eligibilityLoading: anyLoading(eligibilityLoading, checkingNextStep, combinationPricing.quoting),
3819
4791
  eligibilityError,
4792
+ /** Asks for the booking options again, after they failed to load. */
4793
+ reloadOptions: () => setOptionsRefreshKey((value) => value + 1),
3820
4794
  existingRegistrations,
3821
4795
  existingRegistrationLoading: existingRegistrationResult.isLoading || portalAuthState === "authenticated" && eligibilityLoading,
3822
4796
  existingRegistrationState: existingRegistrationResult.state,
3823
4797
  registrationState,
3824
- hasEligibility,
3825
- hasMembershipEligibility,
3826
4798
  requireGuestDetails,
3827
4799
  discountCode,
3828
4800
  setDiscountCode: (value) => {
@@ -3836,6 +4808,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3836
4808
  discountsAvailableLoading: discountView.discountsAvailableLoading,
3837
4809
  discountContext,
3838
4810
  shouldShowDiscountToggle,
4811
+ discountCardOnly,
3839
4812
  verification,
3840
4813
  paymentController,
3841
4814
  paymentStatusRecovery,
@@ -3846,8 +4819,6 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3846
4819
  checkingNextStep,
3847
4820
  handleDetailsComplete,
3848
4821
  handlePaymentSelect,
3849
- handleUseCardInsteadOfPass,
3850
- handleUsePassInstead,
3851
4822
  handleBookForSomeoneElse,
3852
4823
  handleBookAnother,
3853
4824
  handleSubmit: (...args) => selectionLocked ? Promise.resolve({
@@ -3865,6 +4836,25 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3865
4836
  ...registrationCompletionState(flowState)
3866
4837
  };
3867
4838
  }
4839
+ /** The rooms step, while the guest is on it. */
4840
+ function roomChooserStep(input) {
4841
+ const { offer, options } = input;
4842
+ if (!offer || input.step !== "select-tickets") return null;
4843
+ const dayOptions = dayOptionsOf(options, offer);
4844
+ const dayIds = new Set(dayOptions.map((option) => option.pricingOptionId));
4845
+ return {
4846
+ view: presentRoomChooser({
4847
+ ...input,
4848
+ offer,
4849
+ timeZone: resolveBookingBusinessTimeZone(input.event?.siteTimeZone)
4850
+ }),
4851
+ choices: input.choices,
4852
+ /** The places without a room. */
4853
+ dayOptions,
4854
+ setRoomChoices: input.setRoomChoices,
4855
+ setDayLines: (lines) => input.setDayLines(lines.filter((line) => line.pricingOptionId !== null && dayIds.has(line.pricingOptionId)))
4856
+ };
4857
+ }
3868
4858
  /**
3869
4859
  * What still needs choosing. Several runs need one way of attending and a
3870
4860
  * usable ticket or amount for each run before the tickets step goes on; one
@@ -3873,7 +4863,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3873
4863
  function resolveSelectionChoiceMessages(input) {
3874
4864
  if (input.several !== "runs") return {
3875
4865
  slidingScaleSelectionMessage: getSlidingScaleSelectionMessage(input),
3876
- selectionChoiceMessage: null
4866
+ selectionChoiceMessage: input.roomMessage
3877
4867
  };
3878
4868
  return {
3879
4869
  slidingScaleSelectionMessage: incompleteRunChoiceMessage(input),
@@ -3913,51 +4903,40 @@ function registrationCompletionState(state) {
3913
4903
  function preSelectedDisplayEvent(preSelected, current, display) {
3914
4904
  return preSelected?.selectionId === current?.selectionId ? display : preSelected;
3915
4905
  }
3916
- /** What a single booking's typed code is checked against. Several items have their own quote. */
4906
+ /** What a single booking's typed code is checked against. Several items, and dates bought with a pass, have their own quote. */
3917
4907
  function singleBookingDiscountLines(input) {
3918
4908
  const { discountContext, eligibility } = input;
3919
4909
  if (!discountContext || !eligibility) return [];
3920
- const product = bundleProductPrice(discountContext, eligibility);
3921
4910
  return [{
3922
4911
  context: discountContext,
3923
- subtotalCents: product ? product.price : input.primarySubtotalCents ?? 0,
3924
- currency: product ? product.currency : eligibility.currency,
3925
- ...singleBookingTicketDetails(discountContext.type, input)
4912
+ subtotalCents: input.primarySubtotalCents ?? 0,
4913
+ currency: eligibility.currency,
4914
+ ...singleBookingTicketDetails(discountContext, input)
3926
4915
  }];
3927
4916
  }
3928
- /** What the pass or membership being bought costs, from the server's options, so a caller only has to name it. */
3929
- function bundleProductPrice(context, eligibility) {
3930
- if (context.type === "pass") return eligibility.availablePasses.find((pass) => pass.id === context.passId) ?? null;
3931
- if (context.type === "membership") return eligibility.availableMemberships.find((membership) => membership.id === context.membershipId) ?? null;
3932
- return null;
3933
- }
3934
- function singleBookingTicketDetails(contextType, input) {
4917
+ function singleBookingTicketDetails(context, input) {
3935
4918
  const ticketUnits = input.ticketLines.map((line) => ({
3936
4919
  unitPriceCents: line.unitPriceCents,
3937
4920
  quantity: line.quantity
3938
4921
  }));
3939
- if (contextType === "whole_series") return {
4922
+ if (context.type === "whole_series") return {
3940
4923
  quantity: input.ticketsCount,
3941
4924
  ticketUnits
3942
4925
  };
3943
- if (contextType !== "event") return {};
4926
+ if (context.type !== "event") return {};
3944
4927
  const subject = input.currentEvent?.registrationSubject;
3945
4928
  return {
3946
4929
  occurrenceId: subject?.kind === "occurrence" ? subject.occurrenceId : void 0,
3947
4930
  ticketUnits
3948
4931
  };
3949
4932
  }
3950
- /** The server can't yet preview an automatic discount on a membership, so its summary shows the regular price and checkout takes the discount off. */
3951
- function automaticQuoteOffered(automatic, context) {
3952
- return automatic !== null && context?.type !== "membership";
3953
- }
3954
4933
  /** The quote's field, saying beside an applied code what it does to this purchase. */
3955
- function registrationCodeField(field, quote, paymentIntent) {
4934
+ function registrationCodeField(field, quote) {
3956
4935
  if (!field) return null;
3957
4936
  const applied = quote?.source === "typed" && quote.preview.type === "applied" ? quote.preview : null;
3958
4937
  return {
3959
4938
  ...field,
3960
- hint: appliedCodeHint(paymentIntent, applied)
4939
+ hint: appliedCodeHint(applied)
3961
4940
  };
3962
4941
  }
3963
4942
  /**
@@ -3991,6 +4970,24 @@ function resolveWizardDirectPaymentOptions(input) {
3991
4970
  }
3992
4971
  }
3993
4972
  }
4973
+ /**
4974
+ * The payment step's sentence when one booking's card options, as shown
4975
+ * (repriced, discounts included), have no deposit although its terms offer one.
4976
+ */
4977
+ function decidePaidInFullNote(input, cardOptions, liveNowIso) {
4978
+ const { eligibility } = input;
4979
+ if (!eligibility || input.selectionPayment.kind !== "one-item") return null;
4980
+ return paidInFullNote({
4981
+ paymentTerms: eligibility.paymentTerms,
4982
+ offeredKinds: cardOptions.map((option) => option.kind),
4983
+ dates: {
4984
+ bookingStartAt: getRegistrationStartAt(input.currentEvent, input.occurrenceContext) ?? null,
4985
+ instalmentCollectionDeadlineAt: eligibility.instalmentCollectionDeadlineAt,
4986
+ timeZone: resolveBookingBusinessTimeZone(input.currentEvent?.siteTimeZone),
4987
+ nowIso: liveNowIso
4988
+ }
4989
+ });
4990
+ }
3994
4991
  /** One item: its price less the automatic discount; a typed code is already out of the price. */
3995
4992
  function previewTotalWithAutomaticDiscount(input) {
3996
4993
  return (subtotalCents) => calculateEventRegistrationPreviewTotal({
@@ -4047,9 +5044,158 @@ function resolveWizardPaymentView(input) {
4047
5044
  paymentSelection: resolveRegistrationPhaseSelection(input.step, input.paymentIntent, paymentDecision.selection)
4048
5045
  };
4049
5046
  }
5047
+ /**
5048
+ * Several dates' ways to pay, and what they decide for the payment step: its
5049
+ * button, the terms the visitor agrees to and the choice submit sends.
5050
+ */
5051
+ function decideWizardSelectionFunding(input) {
5052
+ const view = presentWizardSelectionFunding(input);
5053
+ const option = lookupChosenOption(input.lookup);
5054
+ return {
5055
+ view,
5056
+ paymentStepState: fundingPaymentStepState(input.cardStepState, input.lookup, view, input.pricing.ready),
5057
+ termsSurface: view?.termsSurface ?? "primary",
5058
+ choice: option ? fundingChoice(option) : null
5059
+ };
5060
+ }
5061
+ /**
5062
+ * The payment step's view of the dates' ways to pay, once the server has
5063
+ * sent them. The money rows keep the card options' own words.
5064
+ */
5065
+ function presentWizardSelectionFunding(input) {
5066
+ const currency = input.eligibility?.currency;
5067
+ if (input.lookup.tag !== "loaded" || !currency) return null;
5068
+ const dates = fundingDatesOf(input.selection, input.itemPrice);
5069
+ return presentSelectionFunding({
5070
+ funding: input.lookup.funding,
5071
+ pick: input.lookup.pick,
5072
+ dates,
5073
+ places: input.places,
5074
+ currency,
5075
+ moneyRows: moneyRows(input, dates.length === 1),
5076
+ chosenOrder: input.pricing.ready ? quotedOrder(input.pricing.quote) : null,
5077
+ reductions: quoteReductions(input.pricing.quote),
5078
+ availableCreditCents: availableCreditCents(input.creditState, currency),
5079
+ minimumCardChargeCents: getStripeMinimumChargeRequirement(currency)?.minimumAmountCents ?? null,
5080
+ formatDay: fundingDayFormatter(input.event)
5081
+ });
5082
+ }
5083
+ /**
5084
+ * How the money option is offered. Several dates are paid in full, so one row. One date
5085
+ * keeps each of its card options (a deposit, say), so choosing money still chooses how.
5086
+ */
5087
+ function moneyRows(input, oneDate) {
5088
+ const { directPaymentOptions, paymentDecision, lookup } = input;
5089
+ const money = lookup.tag === "loaded" && lookup.pick.kind === "money";
5090
+ const chosen = paymentDecision.directPaymentSelectionState.kind === "valid" ? paymentDecision.directPaymentSelectionState.selection.collectionOptionKind : null;
5091
+ if (!oneDate || directPaymentOptions.length === 0) {
5092
+ const card = directPaymentOptions[0];
5093
+ return [{
5094
+ key: "card",
5095
+ label: moneyRowLabel(money && chosen !== null, paymentDecision.preview, card?.label),
5096
+ details: card ? paymentChoiceDetails(card) : [],
5097
+ price: null,
5098
+ card: null,
5099
+ current: true
5100
+ }];
5101
+ }
5102
+ return directPaymentOptions.map((card) => ({
5103
+ key: card.kind,
5104
+ label: moneyRowLabel(money && chosen === card.kind, paymentDecision.preview, card.label),
5105
+ details: paymentChoiceDetails(card),
5106
+ price: paymentChoicePrice(card.amounts),
5107
+ card: directPaymentOptions.length > 1 ? card.kind : null,
5108
+ current: directPaymentOptions.length === 1 || chosen === card.kind
5109
+ }));
5110
+ }
5111
+ /** A chosen money row says site credit when the credit preview spends it, as the card step does. */
5112
+ function moneyRowLabel(chosen, preview, label) {
5113
+ if (!chosen || preview.kind !== "applied") return label ?? "Pay by card";
5114
+ return preview.outcome === "credit_only" ? "Pay with site credit" : "Use site credit + card";
5115
+ }
5116
+ /**
5117
+ * The payment step's model for the dates; null while nothing is asked, and for one date
5118
+ * the card alone pays for, which keeps the card step it always had. Picks wait while a
5119
+ * payment is under way.
5120
+ */
5121
+ function selectionFundingStepModel(input) {
5122
+ const { funding, view, locked } = input;
5123
+ const lookup = funding.lookup;
5124
+ if (lookup.tag === "idle" || cardStepServesDates(lookup, input.dateCount)) return null;
5125
+ return {
5126
+ status: lookup.tag,
5127
+ view,
5128
+ dateCount: input.dateCount,
5129
+ notice: lookup.tag === "loaded" ? lookup.notice : null,
5130
+ choose: (row) => {
5131
+ if (locked) return;
5132
+ funding.choose(row.pick);
5133
+ if (row.card !== null) input.chooseCard(row.card);
5134
+ },
5135
+ retry: funding.reset
5136
+ };
5137
+ }
5138
+ /** The server's price for the chosen option's order, from its quote. */
5139
+ function quotedOrder(quote) {
5140
+ if (!quote) return null;
5141
+ const { subtotalCents, totalAfterDiscountCents } = quote.preview;
5142
+ return {
5143
+ totalCents: totalAfterDiscountCents,
5144
+ discountCents: subtotalCents - totalAfterDiscountCents
5145
+ };
5146
+ }
5147
+ /**
5148
+ * Asks for the dates' ways to pay while the payment step is open, and
5149
+ * what the quote then prices: the chosen option's whole order.
5150
+ */
5151
+ function useWizardSelectionFunding(input) {
5152
+ const { target, attendanceMode, ticketSelections, selectedSlidingAmount } = input;
5153
+ const eventSeriesId = input.event?.seriesId ?? null;
5154
+ const request = useMemo(() => selectionFundingRequest({
5155
+ target,
5156
+ eventSeriesId,
5157
+ attendanceMode,
5158
+ ticketSelections,
5159
+ selectedSlidingAmount
5160
+ }), [
5161
+ target,
5162
+ eventSeriesId,
5163
+ attendanceMode,
5164
+ ticketSelections,
5165
+ selectedSlidingAmount
5166
+ ]);
5167
+ const selectionFunding = useSelectionFunding({
5168
+ api: input.api,
5169
+ request,
5170
+ identity: input.identity,
5171
+ enabled: input.step === "select-payment" && input.portalAuthState !== "checking"
5172
+ });
5173
+ return {
5174
+ selectionFunding,
5175
+ datesQuote: useMemo(() => selectionDatesQuote(selectionFunding.lookup, request), [selectionFunding.lookup, request])
5176
+ };
5177
+ }
5178
+ /** Several items, or one date paid with a pass or membership, are priced as one whole order. */
5179
+ function pricedAsWholeOrder(several, datesQuote) {
5180
+ return several !== null || datesQuote !== null;
5181
+ }
5182
+ /** One date's card options keep the date's own price while a pass or membership is picked. */
5183
+ function cardOptionsSubtotal(input) {
5184
+ return input.several === null && input.datesQuote !== null ? input.primarySubtotalCents : input.ticketSelectionSubtotalCents;
5185
+ }
5186
+ /** How many dates the funding step's copy speaks of; 0 for anything that isn't dates. */
5187
+ function fundingDateCount(target) {
5188
+ return target?.selection.kind === "dates" ? target.selection.occurrenceIds.length : 0;
5189
+ }
5190
+ /** Account credit the visitor can spend on this booking's currency. */
5191
+ function availableCreditCents(state, currency) {
5192
+ if (state.kind !== "loaded") return 0;
5193
+ const summary = state.credit?.summary;
5194
+ return summary && summary.currency.toUpperCase() === currency.toUpperCase() ? Math.max(0, summary.availableCents) : 0;
5195
+ }
4050
5196
  //#endregion
4051
5197
  //#region ../blocks/src/system/runtime/nodes/event-registration/EventRegistrationPayment.tsx
4052
- const Payment = lazy(() => import("./EventEmbeddedCheckoutStep-B18VbNS_.mjs"));
5198
+ const Payment = lazy(() => import("./EventEmbeddedCheckoutStep-BDnicDM6.mjs"));
4053
5199
  /** The one Stripe mount, shared by the standard wizard and headless arrangements. */
4054
5200
  function EventPaymentMount({ state, onComplete, onRetry, onBack, buttonVariant }) {
4055
5201
  if (state.kind === "abandoning") return /* @__PURE__ */ jsx("p", {
@@ -4082,4 +5228,4 @@ function EventRegistrationPayment({ flow }) {
4082
5228
  });
4083
5229
  }
4084
5230
  //#endregion
4085
- export { planEventRegistrationSurface as a, useEventRegistrationRecoveryRequest as i, EventRegistrationPayment as n, registrationAdmissionSurface as o, useEventRegistrationWizard as r, resolveEventRegistrationClientSurface as s, EventPaymentMount as t };
5231
+ export { ONE_DATE_FUNDING_LOAD_FAILED as a, planEventRegistrationSurface as c, summaryExplainsMoreThanTheOption as i, registrationAdmissionSurface as l, EventRegistrationPayment as n, SELECTION_FUNDING_LOAD_FAILED as o, useEventRegistrationWizard as r, useEventRegistrationRecoveryRequest as s, EventPaymentMount as t, resolveEventRegistrationClientSurface as u };