@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,12 +1,9 @@
1
1
  "use client";
2
- import { jn as unsafeAsContentEntryId } from "./shop.interactive-D7wky1GL.mjs";
3
2
  import { a as mediaIdentifierSchema, i as resolveManagedMediaReference, n as renderableMediaAssetSchema, o as parseCanonicalMediaIdentifier, s as parseMediaIdentifier, t as buildRenderableMediaAssetIndex } from "./renderableMediaAssetAdmission-BlfqYLJW.mjs";
4
- import { $r as parseInlineTextFromUnknown, Ba as resolveDateRuntimeContext, Fr as resolveImageSourceSetWithContext$1, Ir as resolveImageUrl$1, Lr as resolveImageUrlWithContext$1, Or as RichText$2, Po as sanitizeHref, Zr as inlineTextToPlainText, ei as plainTextToInlineText, is as offeringLabelForPageSurfaceSubject, jr as computeMediaTransformStyle, vs as unsafeAsEventCategoryId, za as readRuntimeNow } from "./display-D1oVR5Eh.mjs";
5
- import { Ft as EVENT_PRESET_VALUES, Pt as isRecord, dt as runtimeMediaSchema, hn as toUtcIsoDateTimeString, it as createRichTextDoc, lt as mediaSchema, rt as buildRichTextSchema, ut as persistableMediaSchema } from "./noop-D11X-B6n.mjs";
6
- import { $ as projectRepeaterGridLayout$1, A as SUPPORTED_LOADER_ENDPOINTS, B as resolveRouteHrefForStage, C as resolveSdkBlockManifest, D as MISSING_SDK_THEME_ERROR_CODE, E as resolveSiteCustomBlocks, F as renderBlock, G as siteHeaderManifest, H as getBlockDefinition, I as getDefaultComponentRegistry, J as compileManifestContentContract, K as blockDesignCapabilityMapFromDefinitions, L as resolveAuthoredLinkHref, N as planBlockDataRequests, O as MissingSdkThemeError, P as makeDefaultBlockComponent, Q as fieldPlanToZod, R as isRouteVisibleInStage, S as readInvalidBlockAdmission, T as siteBlockRenderContext, U as systemBlockDefinitions, V as allOutlineBlocks, W as siteFooterManifest, X as admitLayoutGridForPlan, Y as registeredManifestContentContract, Z as deriveFieldValidationPlan, _ as buildRenderablePageOutline, a as solvedInksForThemeRuntime, b as invalidRenderableBlock$1, c as MissingBlockOverrideError, ct as applyCompiledRuntimeFieldsToContent, d as buildThemeRuntime, dt as readPublishedBlockPlacement, et as projectRepeaterGridLayoutForRendering$1, f as parseBlocksTheme, g as blockDesignInputsForDefinition, h as resolveRuntimeJoinFacts, i as renderWithSdkThemeRuntime, it as isRecord$1, j as prefetchBlockDataWithFailures, k as requireSdkTheme, l as PageRenderer, lt as compileEditorModelRuntime, m as isEntryBoundBlockEmpty, n as planLayoutThemeRuntime, nt as normalizeRepeaterGridSpan, o as ThemeScope, ot as parseListLook, p as applyBindingsToContent, q as admitTransportedRenderableManifestContent, r as renderWithOverrideOnlyRuntime, rt as resolveRepeaterGridAcceptedSpans, s as EditorPageRenderer, st as buildPageDesignEditorReadModel, t as Page, tt as flowRepeaterGridItems, u as toBlocksPageRendererDataContext, v as buildSiteRenderSupport, w as sanitizeSdkRuntimeBlockContent, x as projectRenderablePageOutline, y as collectMediaAssetSidecar, z as normalizeRenderStage } from "./Page-DqETUt-U.mjs";
7
- import { Bn as resolveRepeaterGridRowFieldId, Kn as isCanonicalRichTextDoc, Vn as resolveRepeaterGridSpanFieldId, zn as resolveRepeaterGridColumnFieldId, zt as parseFieldDefinition } from "./registry.server-Bn0gE0uP.mjs";
8
- import { F as surfaceResolutionContextFromTheme, O as componentRuntimeRulesForSiteStyle, Q as parsePageDesignIntent, hn as asLayoutVariantKey, j as requireCuratedSiteStyle, k as designRuntimeRulesForSiteStyle, mn as asDesignBlockId, pn as asAppearancePresetId, w as buildInitialPolicyPageDesignIntent, wt as appearancePresets } from "./lookSurfaces-C2VzJfyG.mjs";
9
- import { l as parseBackgroundContent } from "./boxStyleClassNames-BHoMAcun.mjs";
3
+ import { $a as RichText$2, Eo as resolveImageUrlWithContext$1, Jo as resolveDateRuntimeContext, To as resolveImageUrl$1, Yo as sanitizeHref, bo as computeMediaTransformStyle, qo as readRuntimeNow, wo as resolveImageSourceSetWithContext$1 } from "./wizardSteps-CWIQyRIw.mjs";
4
+ import { X as persistableMediaSchema, Y as mediaSchema, Z as runtimeMediaSchema, vn as toUtcIsoDateTimeString } from "./src-o7WEvbK1.mjs";
5
+ import { $ as bookingPageDesign, B as SERVICE_BOOKING_BLOCK_IDS, C as siteBlockRenderContext, D as resolveBlockDataWithDeps, E as createBlockDataLoadPolicy, G as bookingPageSeedData, H as BOOKING_PAGE_BLOCK_IDS, I as MISSING_SDK_THEME_ERROR_CODE, J as plainTextDoc, K as buildBookingPageOutline, L as MissingSdkThemeError, N as normalizeDataLoaderSearchParams, O as SUPPORTED_LOADER_ENDPOINTS, Q as bookingHero, R as requireSdkTheme, S as projectRenderablePageOutline, T as DEFAULT_RESOLVE_BLOCK_DATA_DEPS, U as bookingDetailEvents, V as buildServiceBookingOutline, W as bookingPageFacts, X as createPublicBlockContentContractResolver, Y as buildCodeOwnedPageBlocks, Z as bookingDescription, a as solvedInksForThemeRuntime, at as makeDefaultBlockComponent, b as buildSiteRenderSupport, c as MissingBlockOverrideError, ct as deriveFieldValidationPlan, d as buildThemeRuntime, dt as getDefaultComponentRegistry, et as bookingSectionBlocks, f as parseBlocksTheme, ft as resolveAuthoredLinkHref, g as loadContent, h as isPageSurfaceContent, ht as resolveRouteHrefForStage, i as renderWithSdkThemeRuntime, it as siteHeaderManifest, k as prefetchBlockDataWithFailures, l as PageRenderer, lt as projectRepeaterGridLayout$1, m as isPageContent, mt as normalizeRenderStage, n as planLayoutThemeRuntime, nt as getBlockDefinition, o as ThemeScope, ot as renderBlock, p as isEntryContent, pt as isRouteVisibleInStage, q as bookingPageIdentity, r as renderWithOverrideOnlyRuntime, rt as siteFooterManifest, s as EditorPageRenderer, st as admitLayoutGridForPlan, t as Page, tt as planBlockDataRequests, u as toBlocksPageRendererDataContext, ut as projectRepeaterGridLayoutForRendering$1, v as loadContentFromContentResponseWithDeps, w as resolveSiteCustomBlocks, x as collectMediaAssetSidecar, y as buildRenderablePageOutline, z as parseServicePageContent } from "./Page-bX7iy_MK.mjs";
6
+ import { W as parseFieldDefinition } from "./registry.server-Bj9cmHHF.mjs";
10
7
  import { o as setContextResolveImageUrlContext, t as buildResolveImageUrlContext } from "./mediaContext-Fusweriw.mjs";
11
8
  import { n as toBlocksImageResolveContextInput, r as toBlocksMediaAssets } from "./mediaAssets-B99AP7ai.mjs";
12
9
  import "react";
@@ -32,77 +29,6 @@ const footerModeSchema = z.enum([
32
29
  "none"
33
30
  ]);
34
31
  //#endregion
35
- //#region ../theme-core/src/site-styles/contentTemplateDesignIntent.ts
36
- function asContentTemplateDesignBlockId(value) {
37
- return asDesignBlockId(value);
38
- }
39
- function parseContentTemplateDesignIntent(value) {
40
- return parsePageDesignIntent(value, {
41
- unsupportedSchemaVersionMessage: "Unsupported Theme V2 content template design intent schemaVersion.",
42
- invalidShapeMessage: "Invalid Theme V2 content template design intent shape."
43
- });
44
- }
45
- function contentTemplateDesignIntentToJsonRecord(intent) {
46
- return {
47
- schemaVersion: intent.schemaVersion,
48
- siteStyleId: intent.siteStyleId,
49
- pageFlowPresetId: intent.pageFlowPresetId,
50
- blockLookPins: intent.blockLookPins.map((pin) => ({
51
- blockId: pin.blockId,
52
- blockKind: pin.blockKind,
53
- choice: {
54
- kind: pin.choice.kind,
55
- value: pin.choice.value
56
- }
57
- })),
58
- boundaryPins: intent.boundaryPins.map((pin) => ({
59
- boundaryId: pin.boundaryId,
60
- previousBlockId: pin.previousBlockId,
61
- nextBlockId: pin.nextBlockId,
62
- choice: {
63
- kind: pin.choice.kind,
64
- value: pin.choice.value
65
- }
66
- }))
67
- };
68
- }
69
- //#endregion
70
- //#region ../theme-core/src/site-styles/contentTemplateRuntimeCompiler.ts
71
- function compileContentTemplateRuntimeFields(input) {
72
- const orderedBlocks = [...input.blocks].sort((a, b) => a.orderIndex - b.orderIndex);
73
- const editorModel = buildPageDesignEditorReadModel({
74
- joinResolution: {
75
- surfaceResolutionContext: input.surfaceResolutionContext,
76
- resolveFacts: input.resolveJoinFacts,
77
- contentForBlock: (id) => {
78
- const block = orderedBlocks.find((block) => block.blockId === id);
79
- if (!block) throw new Error(`Missing materialized template content for ${id}`);
80
- return block.content;
81
- }
82
- },
83
- siteStyleId: input.intent.siteStyleId,
84
- siteStyle: input.siteStyle,
85
- intent: input.intent,
86
- blocks: orderedBlocks
87
- });
88
- const compiled = compileEditorModelRuntime({
89
- editorModel,
90
- surfaceResolutionContext: input.surfaceResolutionContext,
91
- designRules: designRuntimeRulesForSiteStyle(requireCuratedSiteStyle(input.intent.siteStyleId)),
92
- componentRules: componentRuntimeRulesForSiteStyle(requireCuratedSiteStyle(input.intent.siteStyleId))
93
- });
94
- const blocks = compiled.blocks.map((block) => ({
95
- blockId: block.blockId,
96
- fields: block.fields
97
- }));
98
- return {
99
- blocks,
100
- joins: compiled.joins,
101
- fieldsByBlockId: new Map(blocks.map((block) => [block.blockId, block.fields])),
102
- issues: editorModel.issues
103
- };
104
- }
105
- //#endregion
106
32
  //#region ../theme-core/src/footer/mode.ts
107
33
  /** Reads only SDK footer intent; unrelated config and theme fields are not authorities. */
108
34
  function resolveSdkFooterMode(config) {
@@ -1165,532 +1091,6 @@ function Block(props) {
1165
1091
  return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(HydratorWithContextProps, { ...toBlockHydrationBootstrapConfig(props) }), /* @__PURE__ */ jsx(BlockContent, { ...props })] });
1166
1092
  }
1167
1093
  //#endregion
1168
- //#region src/data/defineOwnDataProperty.ts
1169
- /** Define a string key as ordinary data without invoking legacy prototype setters. */
1170
- function defineOwnDataProperty(target, key, value) {
1171
- Object.defineProperty(target, key, {
1172
- value,
1173
- enumerable: true,
1174
- configurable: true,
1175
- writable: true
1176
- });
1177
- }
1178
- //#endregion
1179
- //#region src/data/dataLoaderContext.ts
1180
- function assertNever$2(value) {
1181
- throw new Error(`Unhandled data loader render target: ${String(value)}`);
1182
- }
1183
- function getDataLoaderOwnerPageId(target) {
1184
- switch (target.kind) {
1185
- case "page": return target.pageId;
1186
- case "entry-template":
1187
- case "page-surface-template": return target.templateId;
1188
- default: return assertNever$2(target);
1189
- }
1190
- }
1191
- function normalizeDataLoaderSearchParams(input) {
1192
- if (!input) return Object.freeze({});
1193
- const normalized = {};
1194
- for (const [key, value] of Object.entries(input)) defineOwnDataProperty(normalized, key, value === void 0 || typeof value === "string" ? value : Object.freeze([...value]));
1195
- return Object.freeze(normalized);
1196
- }
1197
- function resolveDataLoaderBlockContent(block, previewStage) {
1198
- if (previewStage === "preview" && block.draftContent) return block.draftContent;
1199
- return block.content ?? {};
1200
- }
1201
- function createDataLoaderContext(input) {
1202
- return {
1203
- siteId: input.siteId,
1204
- pageId: getDataLoaderOwnerPageId(input.renderTarget),
1205
- blockId: input.blockId,
1206
- blockKind: input.blockKind,
1207
- content: input.content,
1208
- previewStage: input.previewStage,
1209
- searchParams: input.searchParams,
1210
- renderTarget: input.renderTarget
1211
- };
1212
- }
1213
- //#endregion
1214
- //#region src/types/block-kinds.ts
1215
- /**
1216
- * System block kind identifiers.
1217
- *
1218
- * SDK-owned copy of the system block kind list.
1219
- *
1220
- * Rationale: SDK consumers must be able to typecheck without installing
1221
- * `@riverbankcms/blocks` (which is not a public dependency). This list is a
1222
- * stable public contract; keep it in sync with the internal blocks runtime.
1223
- */
1224
- const SYSTEM_BLOCK_KINDS = [
1225
- "block.hero",
1226
- "block.intro",
1227
- "block.columns",
1228
- "block.collection",
1229
- "block.class-prices",
1230
- "block.feature-cards",
1231
- "block.media-text",
1232
- "block.cta-full",
1233
- "block.single-button",
1234
- "block.body-text",
1235
- "block.location-map",
1236
- "block.faq",
1237
- "block.list",
1238
- "block.testimonials",
1239
- "block.team-members",
1240
- "block.embed",
1241
- "block.blog-post",
1242
- "block.blog-listing",
1243
- "block.site-header",
1244
- "block.site-footer",
1245
- "block.form",
1246
- "block.contact-newsletter",
1247
- "block.appointment-booking",
1248
- "block.appointment-services",
1249
- "block.service-details",
1250
- "block.weekly-slot-availability",
1251
- "block.event-registration",
1252
- "block.event-details",
1253
- "block.event-spotlight",
1254
- "block.event-listing",
1255
- "block.event-calendar",
1256
- "block.recurring-schedule",
1257
- "block.offerings-preview",
1258
- "block.shop",
1259
- "block.product-list",
1260
- "block.product-detail",
1261
- "block.cart",
1262
- "block.checkout",
1263
- "block.gifting",
1264
- "block.newsletter-signup",
1265
- "block.image-gallery",
1266
- "block.video-grid",
1267
- "block.audio-player",
1268
- "block.file-download"
1269
- ];
1270
- //#endregion
1271
- //#region src/data/dataLoaderValue.ts
1272
- const MAX_DATA_LOADER_VALUE_NODES = 1e4;
1273
- const MAX_DATA_LOADER_VALUE_DEPTH = 100;
1274
- function failure(issue) {
1275
- return {
1276
- ok: false,
1277
- issue
1278
- };
1279
- }
1280
- function inspectArray(value) {
1281
- try {
1282
- if (Object.getPrototypeOf(value) !== Array.prototype) return {
1283
- ok: false,
1284
- issue: { kind: "non-plain-object" }
1285
- };
1286
- const descriptors = Object.getOwnPropertyDescriptors(value);
1287
- const ownKeys = Reflect.ownKeys(descriptors);
1288
- if (ownKeys.some((key) => typeof key === "symbol")) return {
1289
- ok: false,
1290
- issue: { kind: "symbol-key" }
1291
- };
1292
- const lengthDescriptor = descriptors.length;
1293
- if (!lengthDescriptor || !("value" in lengthDescriptor) || typeof lengthDescriptor.value !== "number") return {
1294
- ok: false,
1295
- issue: { kind: "invalid-array" }
1296
- };
1297
- const length = lengthDescriptor.value;
1298
- if (!Number.isSafeInteger(length) || length < 0 || length > MAX_DATA_LOADER_VALUE_NODES) return {
1299
- ok: false,
1300
- issue: { kind: "complexity-limit-exceeded" }
1301
- };
1302
- const children = [];
1303
- for (const key of ownKeys) {
1304
- if (key === "length") continue;
1305
- if (typeof key !== "string" || !/^(0|[1-9]\d*)$/.test(key)) return {
1306
- ok: false,
1307
- issue: { kind: "invalid-array" }
1308
- };
1309
- const index = Number(key);
1310
- if (!Number.isSafeInteger(index) || index < 0 || index >= length) return {
1311
- ok: false,
1312
- issue: { kind: "invalid-array" }
1313
- };
1314
- const descriptor = descriptors[key];
1315
- if (!descriptor || !descriptor.enumerable || !("value" in descriptor)) return {
1316
- ok: false,
1317
- issue: { kind: "accessor-property" }
1318
- };
1319
- }
1320
- for (let index = 0; index < length; index += 1) {
1321
- const descriptor = descriptors[String(index)];
1322
- if (!descriptor || !descriptor.enumerable || !("value" in descriptor)) return {
1323
- ok: false,
1324
- issue: { kind: "invalid-array" }
1325
- };
1326
- children.push({
1327
- key: String(index),
1328
- value: descriptor.value
1329
- });
1330
- }
1331
- return {
1332
- ok: true,
1333
- containerKind: "array",
1334
- length,
1335
- children
1336
- };
1337
- } catch {
1338
- return {
1339
- ok: false,
1340
- issue: { kind: "inspection-failed" }
1341
- };
1342
- }
1343
- }
1344
- function inspectPlainObject(value) {
1345
- try {
1346
- if (Object.getPrototypeOf(value) !== Object.prototype) return {
1347
- ok: false,
1348
- issue: { kind: "non-plain-object" }
1349
- };
1350
- const descriptors = Object.getOwnPropertyDescriptors(value);
1351
- const ownKeys = Reflect.ownKeys(descriptors);
1352
- if (ownKeys.length > MAX_DATA_LOADER_VALUE_NODES) return {
1353
- ok: false,
1354
- issue: { kind: "complexity-limit-exceeded" }
1355
- };
1356
- if (ownKeys.some((key) => typeof key === "symbol")) return {
1357
- ok: false,
1358
- issue: { kind: "symbol-key" }
1359
- };
1360
- const children = [];
1361
- for (const key of ownKeys) {
1362
- if (typeof key !== "string") return {
1363
- ok: false,
1364
- issue: { kind: "symbol-key" }
1365
- };
1366
- const descriptor = descriptors[key];
1367
- if (!descriptor || !descriptor.enumerable || !("value" in descriptor)) return {
1368
- ok: false,
1369
- issue: { kind: "accessor-property" }
1370
- };
1371
- children.push({
1372
- key,
1373
- value: descriptor.value
1374
- });
1375
- }
1376
- return {
1377
- ok: true,
1378
- containerKind: "object",
1379
- children
1380
- };
1381
- } catch {
1382
- return {
1383
- ok: false,
1384
- issue: { kind: "inspection-failed" }
1385
- };
1386
- }
1387
- }
1388
- /**
1389
- * Validates and snapshots arbitrary loader output without invoking getters,
1390
- * setters, or conversion hooks. Reflection failures are returned as data,
1391
- * never thrown, and accepted containers are detached and frozen.
1392
- */
1393
- function validateDataLoaderValue(input) {
1394
- const pending = [{
1395
- kind: "visit",
1396
- value: input,
1397
- depth: 0,
1398
- target: { kind: "root" }
1399
- }];
1400
- const activeAncestors = /* @__PURE__ */ new WeakSet();
1401
- let validatedRoot = null;
1402
- let visitedNodes = 0;
1403
- const assignOutput = (target, value) => {
1404
- switch (target.kind) {
1405
- case "root":
1406
- validatedRoot = value;
1407
- return;
1408
- case "object-property":
1409
- defineOwnDataProperty(target.parent, target.key, value);
1410
- return;
1411
- case "array-index":
1412
- target.parent[target.index] = value;
1413
- return;
1414
- }
1415
- };
1416
- while (pending.length > 0) {
1417
- const next = pending.pop();
1418
- if (!next) continue;
1419
- if (next.kind === "leave") {
1420
- activeAncestors.delete(next.source);
1421
- Object.freeze(next.output);
1422
- continue;
1423
- }
1424
- visitedNodes += 1;
1425
- if (visitedNodes > MAX_DATA_LOADER_VALUE_NODES || next.depth > MAX_DATA_LOADER_VALUE_DEPTH) return failure({ kind: "complexity-limit-exceeded" });
1426
- let objectValue;
1427
- switch (typeof next.value) {
1428
- case "undefined": return failure({
1429
- kind: "unsupported-type",
1430
- valueType: "undefined"
1431
- });
1432
- case "bigint": return failure({
1433
- kind: "unsupported-type",
1434
- valueType: "bigint"
1435
- });
1436
- case "symbol": return failure({
1437
- kind: "unsupported-type",
1438
- valueType: "symbol"
1439
- });
1440
- case "function": return failure({
1441
- kind: "unsupported-type",
1442
- valueType: "function"
1443
- });
1444
- case "string":
1445
- case "boolean":
1446
- assignOutput(next.target, next.value);
1447
- continue;
1448
- case "number":
1449
- if (!Number.isFinite(next.value)) return failure({ kind: "non-finite-number" });
1450
- assignOutput(next.target, next.value);
1451
- continue;
1452
- case "object":
1453
- if (next.value === null) {
1454
- assignOutput(next.target, null);
1455
- continue;
1456
- }
1457
- objectValue = next.value;
1458
- break;
1459
- }
1460
- if (activeAncestors.has(objectValue)) return failure({ kind: "cycle" });
1461
- activeAncestors.add(objectValue);
1462
- let isArray;
1463
- try {
1464
- isArray = Array.isArray(objectValue);
1465
- } catch {
1466
- return failure({ kind: "inspection-failed" });
1467
- }
1468
- const inspection = isArray ? inspectArray(objectValue) : inspectPlainObject(objectValue);
1469
- if (!inspection.ok) return failure(inspection.issue);
1470
- if (inspection.containerKind === "array") {
1471
- const output = new Array(inspection.length);
1472
- assignOutput(next.target, output);
1473
- pending.push({
1474
- kind: "leave",
1475
- source: objectValue,
1476
- output
1477
- });
1478
- for (const child of inspection.children) pending.push({
1479
- kind: "visit",
1480
- value: child.value,
1481
- depth: next.depth + 1,
1482
- target: {
1483
- kind: "array-index",
1484
- parent: output,
1485
- index: Number(child.key)
1486
- }
1487
- });
1488
- continue;
1489
- }
1490
- const output = {};
1491
- assignOutput(next.target, output);
1492
- pending.push({
1493
- kind: "leave",
1494
- source: objectValue,
1495
- output
1496
- });
1497
- for (const child of inspection.children) pending.push({
1498
- kind: "visit",
1499
- value: child.value,
1500
- depth: next.depth + 1,
1501
- target: {
1502
- kind: "object-property",
1503
- parent: output,
1504
- key: child.key
1505
- }
1506
- });
1507
- }
1508
- return {
1509
- ok: true,
1510
- value: validatedRoot
1511
- };
1512
- }
1513
- //#endregion
1514
- //#region src/data/executeCodeLoaders.ts
1515
- const systemBlockKindSet = new Set(SYSTEM_BLOCK_KINDS);
1516
- function isBlockKind(value) {
1517
- return value.startsWith("custom.") || systemBlockKindSet.has(value);
1518
- }
1519
- function toFailureBase(context, loaderKey) {
1520
- return {
1521
- siteId: context.siteId,
1522
- pageId: context.pageId,
1523
- blockId: context.blockId,
1524
- blockKind: context.blockKind,
1525
- loaderKey,
1526
- previewStage: context.previewStage,
1527
- renderTargetKind: context.renderTarget.kind
1528
- };
1529
- }
1530
- /**
1531
- * Runs all matching host loaders concurrently. The function returns closed
1532
- * outcomes and never logs; warning ownership belongs to the shared resolver.
1533
- */
1534
- async function executeCodeLoaders(page, context, overrides) {
1535
- const tasks = [];
1536
- for (const block of allOutlineBlocks(page)) {
1537
- const blockId = block.id;
1538
- if (!blockId || !isBlockKind(block.kind)) continue;
1539
- const blockLoaders = overrides[block.kind];
1540
- if (!blockLoaders) continue;
1541
- for (const [loaderKey, loader] of Object.entries(blockLoaders)) {
1542
- const loaderContext = createDataLoaderContext({
1543
- siteId: context.siteId,
1544
- renderTarget: context.renderTarget,
1545
- blockId,
1546
- blockKind: block.kind,
1547
- content: resolveDataLoaderBlockContent(block, context.previewStage),
1548
- previewStage: context.previewStage,
1549
- searchParams: context.searchParams
1550
- });
1551
- tasks.push((async () => {
1552
- let output;
1553
- try {
1554
- output = await loader(loaderContext);
1555
- } catch {
1556
- return {
1557
- ok: false,
1558
- failure: {
1559
- kind: "execution-failed",
1560
- ...toFailureBase(loaderContext, loaderKey)
1561
- }
1562
- };
1563
- }
1564
- const validation = validateDataLoaderValue(output);
1565
- if (!validation.ok) return {
1566
- ok: false,
1567
- failure: {
1568
- kind: "invalid-result",
1569
- ...toFailureBase(loaderContext, loaderKey),
1570
- validationIssueKind: validation.issue.kind
1571
- }
1572
- };
1573
- return {
1574
- ok: true,
1575
- blockId,
1576
- loaderKey,
1577
- value: validation.value
1578
- };
1579
- })());
1580
- }
1581
- }
1582
- const outcomes = await Promise.all(tasks);
1583
- const data = {};
1584
- const failures = [];
1585
- for (const outcome of outcomes) {
1586
- if (!outcome.ok) {
1587
- failures.push(outcome.failure);
1588
- continue;
1589
- }
1590
- const blockData = { ...data[outcome.blockId] };
1591
- defineOwnDataProperty(blockData, outcome.loaderKey, outcome.value);
1592
- defineOwnDataProperty(data, outcome.blockId, blockData);
1593
- }
1594
- return {
1595
- data,
1596
- failures
1597
- };
1598
- }
1599
- /** Successful host values take precedence on per-block loader-key collisions. */
1600
- function mergeLoaderResults(configResults, codeResults) {
1601
- const merged = { ...configResults };
1602
- for (const [blockId, loaderData] of Object.entries(codeResults)) defineOwnDataProperty(merged, blockId, {
1603
- ...merged[blockId],
1604
- ...loaderData
1605
- });
1606
- return merged;
1607
- }
1608
- //#endregion
1609
- //#region src/data/resolveBlockData.ts
1610
- const CONFIG_ONLY_BLOCK_DATA_POLICY = Object.freeze({ kind: "config-only" });
1611
- function warnHostDataLoaderFailure(warning) {
1612
- console.warn("[resolveBlockData] Host data loader failed:", warning);
1613
- }
1614
- function assertNever$1(value, context) {
1615
- throw new Error(`Unhandled ${context}: ${String(value)}`);
1616
- }
1617
- function toHostDataLoaderWarning(failure) {
1618
- const coordinates = {
1619
- siteId: failure.siteId,
1620
- pageId: failure.pageId,
1621
- blockId: failure.blockId,
1622
- blockKind: failure.blockKind,
1623
- loaderKey: failure.loaderKey,
1624
- previewStage: failure.previewStage,
1625
- renderTargetKind: failure.renderTargetKind
1626
- };
1627
- switch (failure.kind) {
1628
- case "execution-failed": return {
1629
- ...coordinates,
1630
- failureKind: failure.kind
1631
- };
1632
- case "invalid-result": return {
1633
- ...coordinates,
1634
- failureKind: failure.kind,
1635
- validationIssueKind: failure.validationIssueKind
1636
- };
1637
- default: return assertNever$1(failure, "host data loader failure");
1638
- }
1639
- }
1640
- const DEFAULT_RESOLVE_BLOCK_DATA_DEPS = {
1641
- prefetchBlockData: prefetchBlockDataWithFailures,
1642
- executeCodeLoaders,
1643
- mergeLoaderResults,
1644
- warn: warnHostDataLoaderFailure
1645
- };
1646
- function hasRegisteredDataLoaders(overrides) {
1647
- if (!overrides) return false;
1648
- return Object.values(overrides).some((loaders) => loaders !== void 0 && Object.keys(loaders).length > 0);
1649
- }
1650
- function createBlockDataLoadPolicy(overrides, searchParams) {
1651
- return hasRegisteredDataLoaders(overrides) ? {
1652
- kind: "config-and-host",
1653
- overrides,
1654
- searchParams
1655
- } : CONFIG_ONLY_BLOCK_DATA_POLICY;
1656
- }
1657
- function configLoaderRoot(renderTarget, bookingTimeZone, now) {
1658
- const zone = {
1659
- ...bookingTimeZone && bookingTimeZone !== "UTC" ? { bookingTimeZone } : {},
1660
- ...now ? { now } : {}
1661
- };
1662
- switch (renderTarget.kind) {
1663
- case "page":
1664
- case "entry-template": return Object.keys(zone).length ? zone : void 0;
1665
- case "page-surface-template": return {
1666
- ...zone,
1667
- subject: renderTarget.subject
1668
- };
1669
- default: return assertNever$1(renderTarget, "config loader render target");
1670
- }
1671
- }
1672
- async function resolveBlockDataWithDeps(deps, input) {
1673
- const root = configLoaderRoot(input.renderTarget, input.bookingTimeZone, input.now);
1674
- const configData = await deps.prefetchBlockData(input.page, {
1675
- siteId: input.siteId,
1676
- pageId: getDataLoaderOwnerPageId(input.renderTarget),
1677
- previewStage: input.previewStage,
1678
- ...root ? { root } : {}
1679
- }, input.client, { customBlocks: input.customBlocks });
1680
- if (input.policy.kind === "config-only" || !hasRegisteredDataLoaders(input.policy.overrides)) return configData;
1681
- const hostResult = await deps.executeCodeLoaders(input.page, {
1682
- siteId: input.siteId,
1683
- renderTarget: input.renderTarget,
1684
- previewStage: input.previewStage,
1685
- searchParams: input.policy.searchParams
1686
- }, input.policy.overrides);
1687
- for (const failure of hostResult.failures) deps.warn(toHostDataLoaderWarning(failure));
1688
- return {
1689
- ...configData,
1690
- resolvedData: deps.mergeLoaderResults(configData.resolvedData, hostResult.data)
1691
- };
1692
- }
1693
- //#endregion
1694
1094
  //#region src/rendering/helpers/loadPage.ts
1695
1095
  /**
1696
1096
  * Server-side helper to fetch all data needed for <Page> component.
@@ -1754,7 +1154,7 @@ async function loadPage(params) {
1754
1154
  }
1755
1155
  async function loadPageWithDeps(deps, params) {
1756
1156
  const { client, siteId, path, pageId, preview = false, dataLoaderOverrides, searchParams, forceSite } = params;
1757
- const [site, pageResponse] = await Promise.all([client.getSite({
1157
+ const [site, pageRead] = await Promise.all([client.getSite({
1758
1158
  id: siteId,
1759
1159
  currentPath: path,
1760
1160
  ...forceSite ? { force: true } : {}
@@ -1763,6 +1163,23 @@ async function loadPageWithDeps(deps, params) {
1763
1163
  path,
1764
1164
  preview
1765
1165
  })]);
1166
+ if (pageRead.result.kind !== "cms") {
1167
+ const content = await loadContentFromContentResponseWithDeps(deps, {
1168
+ client,
1169
+ siteId,
1170
+ site,
1171
+ contentResponse: pageRead,
1172
+ preview,
1173
+ dataLoaderOverrides,
1174
+ searchParams
1175
+ });
1176
+ if (!isPageContent(content)) throw new Error("Expected a selected system page");
1177
+ return {
1178
+ ...content,
1179
+ theme: requireSdkTheme(content.theme, siteId)
1180
+ };
1181
+ }
1182
+ const pageResponse = pageRead.result.content;
1766
1183
  const pageData = requirePageRecord(pageResponse);
1767
1184
  const support = buildSiteRenderSupport(site, collectMediaAssetSidecar(pageResponse.mediaAssets));
1768
1185
  const previewStage = preview ? "preview" : "published";
@@ -1824,2236 +1241,6 @@ function requirePageRecord(response) {
1824
1241
  if ("pageSurface" in response) throw new Error("This path resolves to a page surface, not a page. Use loadContent() instead, which handles pages, entries, and page surfaces.");
1825
1242
  return response.page;
1826
1243
  }
1827
- const PAGE_SECTIONS_ANCHOR_BLOCK_KIND = "system.page-sections";
1828
- function isSystemTemplateBlockKind(value) {
1829
- return value === "system.entry-slot" || value === "system.page-sections";
1830
- }
1831
- //#endregion
1832
- //#region ../content-model/src/entry-slots/types.ts
1833
- function ok(value) {
1834
- return {
1835
- ok: true,
1836
- value
1837
- };
1838
- }
1839
- function err(error) {
1840
- return {
1841
- ok: false,
1842
- error
1843
- };
1844
- }
1845
- const SLOT_KEY_PATTERN = /^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$/;
1846
- function unsafeAsSlotKey(value) {
1847
- return value;
1848
- }
1849
- function parseSlotKey(value) {
1850
- if (typeof value !== "string") return err({ kind: "not-string" });
1851
- const normalized = value.trim();
1852
- if (!normalized) return err({ kind: "empty" });
1853
- if (!SLOT_KEY_PATTERN.test(normalized)) return err({
1854
- kind: "invalid-format",
1855
- value: normalized
1856
- });
1857
- return ok(unsafeAsSlotKey(normalized));
1858
- }
1859
- function selectBlocksForDeclaredEntrySlot(input) {
1860
- return input.entrySlots.find((slot) => slot.slotKey === input.declaredSlotKey)?.blocks ?? [];
1861
- }
1862
- //#endregion
1863
- //#region ../content-model/src/page-sections/types.ts
1864
- /**
1865
- * Page sections (#1703): owner-defined, structured sections on a subject's
1866
- * pages. A definition says what a section is (its heading, what goes in it)
1867
- * and where it applies. The values live in each page's own content.
1868
- */
1869
- const BODY_SECTION_KINDS = [
1870
- "list",
1871
- "headedLists",
1872
- "questions",
1873
- "cards",
1874
- "text",
1875
- "textWithPhoto"
1876
- ];
1877
- function unsafeAsPageSectionId(value) {
1878
- return value;
1879
- }
1880
- const uuidSchema = z.string().trim().toLowerCase().uuid();
1881
- const pageSectionIdSchema = uuidSchema.transform(unsafeAsPageSectionId);
1882
- const FACT_OPTION_MAX = 30;
1883
- const factTextSchema = z.string().trim().max(120).refine((value) => !/[\r\n\u2028\u2029]/u.test(value), { message: "Use a single line" });
1884
- const sectionLabelSchema = z.string().trim().min(1).max(120);
1885
- const sectionHintSchema = z.string().trim().max(500).nullable().transform((hint) => hint === null || hint === "" ? null : hint);
1886
- const bodySectionKindSchema = z.enum(BODY_SECTION_KINDS);
1887
- const factSectionShapeSchema = z.discriminatedUnion("kind", [z.object({
1888
- placement: z.literal("facts"),
1889
- kind: z.literal("choice"),
1890
- options: z.array(factTextSchema.pipe(z.string().min(1))).min(1).max(FACT_OPTION_MAX).refine((options) => new Set(options).size === options.length, { message: "Name each option once" })
1891
- }).strict(), z.object({
1892
- placement: z.literal("facts"),
1893
- kind: z.literal("shortText")
1894
- }).strict()]);
1895
- const sectionShapeSchema = z.union([z.object({
1896
- placement: z.literal("body"),
1897
- kind: bodySectionKindSchema
1898
- }).strict(), factSectionShapeSchema]);
1899
- /** The distinct values, in first-seen order, or null when there are none. */
1900
- function toNonEmptyUnique(values) {
1901
- const [first, ...rest] = [...new Set(values)];
1902
- return first === void 0 ? null : [first, ...rest];
1903
- }
1904
- function nonEmptyUnique(item) {
1905
- return z.array(item).transform((values, ctx) => {
1906
- const unique = toNonEmptyUnique(values);
1907
- if (unique) return unique;
1908
- ctx.addIssue({
1909
- code: "custom",
1910
- message: "Name at least one, or use \"all\""
1911
- });
1912
- return z.NEVER;
1913
- });
1914
- }
1915
- const eventCategoryIdSchema = uuidSchema.transform(unsafeAsEventCategoryId);
1916
- const applicabilitySchema = z.discriminatedUnion("subject", [z.object({ subject: z.literal("service") }).strict(), z.object({
1917
- subject: z.literal("event"),
1918
- presets: z.union([z.literal("all"), nonEmptyUnique(z.enum(EVENT_PRESET_VALUES))]),
1919
- categories: z.union([z.literal("all"), nonEmptyUnique(eventCategoryIdSchema)])
1920
- }).strict()]);
1921
- function isActiveSection(definition) {
1922
- return definition.state.kind === "active";
1923
- }
1924
- z.object({
1925
- id: pageSectionIdSchema,
1926
- label: sectionLabelSchema,
1927
- hint: sectionHintSchema,
1928
- shape: sectionShapeSchema,
1929
- applicability: applicabilitySchema,
1930
- position: z.number().int().nonnegative(),
1931
- state: z.discriminatedUnion("kind", [z.object({ kind: z.literal("active") }).strict(), z.object({
1932
- kind: z.literal("archived"),
1933
- archivedAt: z.string()
1934
- }).strict()])
1935
- }).strict();
1936
- //#endregion
1937
- //#region ../content-model/src/page-sections/values.ts
1938
- /**
1939
- * The most a section of each list-like kind can hold: how many items, and how
1940
- * long each piece of text can be. They're the one source for these limits.
1941
- * The stored-value schema enforces them when a value is saved, and the Content
1942
- * tab's fields take them as `maxLength` and `maxItems`.
1943
- *
1944
- * A headed list's `maxPoints` counts the points in all its groups together,
1945
- * the same limit as a List's, so turning Headed lists into a List always
1946
- * gives a List that can be saved, with every point kept.
1947
- */
1948
- const SECTION_VALUE_LIMITS = {
1949
- list: {
1950
- maxPoints: 100,
1951
- maxPointLength: 500
1952
- },
1953
- headedLists: {
1954
- maxGroups: 100,
1955
- maxPoints: 100,
1956
- maxHeadingLength: 500,
1957
- maxPointLength: 500
1958
- },
1959
- questions: {
1960
- maxQuestions: 30,
1961
- maxQuestionLength: 160,
1962
- maxAnswerLength: 5e3
1963
- },
1964
- cards: {
1965
- maxCards: 8,
1966
- maxTitleLength: 120,
1967
- maxTextLength: 5e3
1968
- }
1969
- };
1970
- const tooMany = (items, count, limit) => count > limit ? {
1971
- kind: "tooMany",
1972
- items,
1973
- count,
1974
- limit
1975
- } : null;
1976
- const tooLong = (text, values, limit) => values.some((value) => value.length > limit) ? {
1977
- kind: "tooLong",
1978
- text,
1979
- limit
1980
- } : null;
1981
- /** The first breach in the order given, or null. */
1982
- const firstBreach = (...breaches) => breaches.find((breach) => breach !== null) ?? null;
1983
- /**
1984
- * The first limit a value goes over, or null when it's within all of them.
1985
- * Counts come before lengths, so the message names the bigger problem first.
1986
- */
1987
- function findSectionLimitBreach(value) {
1988
- switch (value.kind) {
1989
- case "list": {
1990
- const limits = SECTION_VALUE_LIMITS.list;
1991
- return firstBreach(tooMany("points", value.items.length, limits.maxPoints), tooLong("point", value.items, limits.maxPointLength));
1992
- }
1993
- case "headedLists": {
1994
- const limits = SECTION_VALUE_LIMITS.headedLists;
1995
- const points = value.groups.flatMap((group) => group.items);
1996
- return firstBreach(tooMany("groups", value.groups.length, limits.maxGroups), tooMany("points", points.length, limits.maxPoints), tooLong("heading", value.groups.map((group) => group.heading), limits.maxHeadingLength), tooLong("point", points, limits.maxPointLength));
1997
- }
1998
- case "questions": {
1999
- const limits = SECTION_VALUE_LIMITS.questions;
2000
- return firstBreach(tooMany("questions", value.items.length, limits.maxQuestions), tooLong("question", value.items.map((item) => item.question), limits.maxQuestionLength), tooLong("answer", value.items.map((item) => item.answer), limits.maxAnswerLength));
2001
- }
2002
- case "cards": {
2003
- const limits = SECTION_VALUE_LIMITS.cards;
2004
- return firstBreach(tooMany("cards", value.cards.length, limits.maxCards), tooLong("cardTitle", value.cards.map((card) => card.title), limits.maxTitleLength), tooLong("cardText", value.cards.map((card) => card.text), limits.maxTextLength));
2005
- }
2006
- case "choice":
2007
- case "shortText":
2008
- case "text":
2009
- case "textWithPhoto": return null;
2010
- }
2011
- }
2012
- const richTextDocSchema = z.custom(isCanonicalRichTextDoc, { message: "Expected a rich text document" });
2013
- const mediaValueSchema = z.object({ identifier: z.string().trim().min(1) }).passthrough();
2014
- /** A value that can be stored: the right shape, and within `SECTION_VALUE_LIMITS`. */
2015
- const sectionValueSchema = z.discriminatedUnion("kind", [
2016
- z.object({
2017
- kind: z.literal("choice"),
2018
- value: factTextSchema
2019
- }).strict(),
2020
- z.object({
2021
- kind: z.literal("shortText"),
2022
- value: factTextSchema
2023
- }).strict(),
2024
- z.object({
2025
- kind: z.literal("list"),
2026
- items: z.array(z.string())
2027
- }).strict(),
2028
- z.object({
2029
- kind: z.literal("headedLists"),
2030
- groups: z.array(z.object({
2031
- heading: z.string(),
2032
- items: z.array(z.string())
2033
- }).strict())
2034
- }).strict(),
2035
- z.object({
2036
- kind: z.literal("questions"),
2037
- items: z.array(z.object({
2038
- question: z.string(),
2039
- answer: z.string()
2040
- }).strict())
2041
- }).strict(),
2042
- z.object({
2043
- kind: z.literal("cards"),
2044
- cards: z.array(z.object({
2045
- title: z.string(),
2046
- text: z.string()
2047
- }).strict())
2048
- }).strict(),
2049
- z.object({
2050
- kind: z.literal("text"),
2051
- body: richTextDocSchema
2052
- }).strict(),
2053
- z.object({
2054
- kind: z.literal("textWithPhoto"),
2055
- body: richTextDocSchema,
2056
- photo: z.nullable(mediaValueSchema)
2057
- }).strict()
2058
- ]).superRefine((value, ctx) => {
2059
- const breach = findSectionLimitBreach(value);
2060
- if (!breach) return;
2061
- const what = breach.kind === "tooMany" ? breach.items : breach.text;
2062
- ctx.addIssue({
2063
- code: "custom",
2064
- message: `Over the ${what} limit of ${breach.limit}`,
2065
- params: { breach }
2066
- });
2067
- });
2068
- function parseSectionValue(value) {
2069
- const parsed = z.safeParse(sectionValueSchema, value);
2070
- return parsed.success ? parsed.data : null;
2071
- }
2072
- function nodeHasVisibleText(node) {
2073
- if (typeof node.text === "string" && node.text.trim().length > 0) return true;
2074
- return (node.content ?? []).some(nodeHasVisibleText);
2075
- }
2076
- function richTextHasVisibleText(doc) {
2077
- return doc.content.some(nodeHasVisibleText);
2078
- }
2079
- const trimmedItems = (items) => items.map((item) => item.trim()).filter((item) => item.length > 0);
2080
- /** One normaliser per kind: incomplete items go, and whitespace is trimmed. */
2081
- const normalisers = {
2082
- choice: (value) => ({
2083
- kind: "choice",
2084
- value: value.value.trim()
2085
- }),
2086
- shortText: (value) => ({
2087
- kind: "shortText",
2088
- value: value.value.trim()
2089
- }),
2090
- list: (value) => ({
2091
- kind: "list",
2092
- items: trimmedItems(value.items)
2093
- }),
2094
- headedLists: (value) => ({
2095
- kind: "headedLists",
2096
- groups: value.groups.map((group) => ({
2097
- heading: group.heading.trim(),
2098
- items: trimmedItems(group.items)
2099
- })).filter((group) => group.items.length > 0)
2100
- }),
2101
- questions: (value) => ({
2102
- kind: "questions",
2103
- items: value.items.map((item) => ({
2104
- question: item.question.trim(),
2105
- answer: item.answer.trim()
2106
- })).filter((item) => item.question.length > 0 && item.answer.length > 0)
2107
- }),
2108
- cards: (value) => ({
2109
- kind: "cards",
2110
- cards: value.cards.map((card) => ({
2111
- title: card.title.trim(),
2112
- text: card.text.trim()
2113
- })).filter((card) => card.title.length > 0)
2114
- }),
2115
- text: (value) => value,
2116
- textWithPhoto: (value) => value
2117
- };
2118
- function normaliseOf(value) {
2119
- const normalise = normalisers[value.kind];
2120
- return normalise(value);
2121
- }
2122
- function normaliseSectionValue(value) {
2123
- return normaliseOf(value);
2124
- }
2125
- /** Emptiness is decided only from a normalised value. */
2126
- function isSectionValueEmpty(value) {
2127
- switch (value.kind) {
2128
- case "choice":
2129
- case "shortText": return value.value.length === 0;
2130
- case "list": return value.items.length === 0;
2131
- case "headedLists": return value.groups.length === 0;
2132
- case "questions": return value.items.length === 0;
2133
- case "cards": return value.cards.length === 0;
2134
- case "text":
2135
- case "textWithPhoto": return !richTextHasVisibleText(value.body);
2136
- }
2137
- }
2138
- /**
2139
- * Read a stored value as another kind. List/Headed lists and choice/short text
2140
- * convert within their placements. Choice membership is checked by readFactValue.
2141
- * Other pairs are incompatible, and the value is treated as
2142
- * empty but kept.
2143
- */
2144
- function convertSectionValue(value, toKind) {
2145
- if (value.kind === toKind) return {
2146
- kind: "converted",
2147
- value
2148
- };
2149
- if ((value.kind === "choice" || value.kind === "shortText") && (toKind === "choice" || toKind === "shortText")) return {
2150
- kind: "converted",
2151
- value: {
2152
- kind: toKind,
2153
- value: value.value
2154
- }
2155
- };
2156
- if (value.kind === "list" && toKind === "headedLists") return {
2157
- kind: "converted",
2158
- value: {
2159
- kind: "headedLists",
2160
- groups: [{
2161
- heading: "",
2162
- items: value.items
2163
- }]
2164
- }
2165
- };
2166
- if (value.kind === "headedLists" && toKind === "list") return {
2167
- kind: "converted",
2168
- value: {
2169
- kind: "list",
2170
- items: value.groups.flatMap((group) => group.items)
2171
- }
2172
- };
2173
- return { kind: "incompatible" };
2174
- }
2175
- function readSectionValue(stored, kind) {
2176
- if (stored === void 0 || stored === null) return {
2177
- kind: "empty",
2178
- reason: "missing"
2179
- };
2180
- const parsed = parseSectionValue(stored);
2181
- if (!parsed) return {
2182
- kind: "empty",
2183
- reason: "unreadable"
2184
- };
2185
- const converted = convertSectionValue(parsed, kind);
2186
- if (converted.kind === "incompatible") return {
2187
- kind: "empty",
2188
- reason: "incompatible"
2189
- };
2190
- const normalised = normaliseSectionValue(converted.value);
2191
- return isSectionValueEmpty(normalised) ? {
2192
- kind: "empty",
2193
- reason: "blank"
2194
- } : {
2195
- kind: "filled",
2196
- value: normalised
2197
- };
2198
- }
2199
- //#endregion
2200
- //#region ../content-model/src/page-sections/applicability.ts
2201
- /** Whether one applicability covers a subject with these facts. */
2202
- function appliesTo(applicability, facts) {
2203
- if (applicability.subject === "service" || facts.subject === "service") return applicability.subject === facts.subject;
2204
- const presetMatches = applicability.presets === "all" || applicability.presets.includes(facts.preset);
2205
- const categoryMatches = applicability.categories === "all" || facts.categoryId !== null && applicability.categories.includes(facts.categoryId);
2206
- return presetMatches && categoryMatches;
2207
- }
2208
- const applicableBrand = Symbol("applicable-sections");
2209
- function compareSectionOrder(left, right) {
2210
- return left.position - right.position || left.id.localeCompare(right.id);
2211
- }
2212
- /** The one rule for which sections a subject's page has. */
2213
- function resolveApplicableSections(definitions, facts) {
2214
- const applicable = definitions.filter((definition) => isActiveSection(definition) && appliesTo(definition.applicability, facts));
2215
- return {
2216
- [applicableBrand]: true,
2217
- sections: [...applicable].sort(compareSectionOrder)
2218
- };
2219
- }
2220
- Object.freeze({
2221
- [applicableBrand]: true,
2222
- sections: []
2223
- });
2224
- //#endregion
2225
- //#region ../content-model/src/page-sections/contentValues.ts
2226
- /**
2227
- * Section values live in a page's own content, under one key, as
2228
- * `{ sections: { [definitionId]: SectionValue } }`.
2229
- */
2230
- const SECTION_VALUES_CONTENT_KEY = "sections";
2231
- function readStoredSectionValues(content) {
2232
- if (!isRecord(content)) return {};
2233
- const sections = content[SECTION_VALUES_CONTENT_KEY];
2234
- return isRecord(sections) ? sections : {};
2235
- }
2236
- //#endregion
2237
- //#region ../content-model/src/page-sections/facts.ts
2238
- /** A removed option is hidden, never rewritten. Restoring that option restores its value. */
2239
- function readShapeValue(stored, shape) {
2240
- const read = readSectionValue(stored, shape.kind);
2241
- if (read.kind === "empty" || shape.kind !== "choice" || read.value.kind !== "choice") return read;
2242
- return shape.options.includes(read.value.value) ? read : {
2243
- kind: "empty",
2244
- reason: "removedOption"
2245
- };
2246
- }
2247
- function readFactValue(stored, shape) {
2248
- const read = readShapeValue(stored, shape);
2249
- return read.kind === "filled" && (read.value.kind === "choice" || read.value.kind === "shortText") ? read.value.value : null;
2250
- }
2251
- /** Uses the selected content version; listing callers must supply published values. */
2252
- function projectPageFacts(input) {
2253
- return resolveApplicableSections(input.definitions, input.facts).sections.flatMap((definition) => {
2254
- if (definition.shape.placement !== "facts") return [];
2255
- const value = readFactValue(input.values[definition.id], definition.shape);
2256
- return value === null ? [] : [{
2257
- label: definition.label,
2258
- value
2259
- }];
2260
- });
2261
- }
2262
- //#endregion
2263
- //#region ../block-form/src/widgets/utils/readNumericUiConfig.ts
2264
- function readNumericInputUiConfig(ui) {
2265
- if (!ui || typeof ui !== "object") return {};
2266
- const rec = ui;
2267
- return {
2268
- min: typeof rec.min === "number" ? rec.min : void 0,
2269
- max: typeof rec.max === "number" ? rec.max : void 0,
2270
- step: typeof rec.step === "number" ? rec.step : void 0
2271
- };
2272
- }
2273
- function readNumberFieldUiConfig(ui) {
2274
- return readNumericInputUiConfig(ui);
2275
- }
2276
- //#endregion
2277
- //#region ../block-form/src/manifest/utils.ts
2278
- function assertNever(value) {
2279
- throw new Error(`Unhandled manifest variant: ${JSON.stringify(value)}`);
2280
- }
2281
- function getGroupChildFields(field) {
2282
- return field.schema?.fields ?? field.fields;
2283
- }
2284
- function getRepeaterChildFields(field) {
2285
- return field.schema?.fields ?? field.fields ?? [];
2286
- }
2287
- /** Data fields of a repeater item: flattened groups contribute children at the item level. */
2288
- function getRepeaterItemDataFields(fields) {
2289
- return fields.flatMap((field) => field.type === "group" && field.ui?.flattenInRepeater ? getGroupChildFields(field) : [field]);
2290
- }
2291
- //#endregion
2292
- //#region ../block-form/src/manifest/canonicalValidation.ts
2293
- function buildCanonicalFieldSchema(field) {
2294
- return fieldPlanToZod(deriveFieldValidationPlan(normalizeFieldForCanonicalValidation(field)), { allowNull: !field.required });
2295
- }
2296
- function normalizeFieldForCanonicalValidation(field) {
2297
- return parseFieldDefinition(toManifestFieldInput(field));
2298
- }
2299
- function toManifestFieldInput(field) {
2300
- switch (field.type) {
2301
- case "number": return numberFieldToManifestInput(field);
2302
- case "group": return groupFieldToManifestInput(field);
2303
- case "modal": return modalFieldToManifestInput(field);
2304
- case "repeater": return repeaterFieldToManifestInput(field);
2305
- case "tabGroup": return {
2306
- ...field,
2307
- tabs: field.tabs.map((tab) => ({
2308
- ...tab,
2309
- fields: tab.fields.map(toManifestFieldInput)
2310
- }))
2311
- };
2312
- case "button": throw new Error("Button fields do not have canonical content validation");
2313
- case "text":
2314
- case "inlineText":
2315
- case "richText":
2316
- case "media":
2317
- case "file":
2318
- case "boolean":
2319
- case "date":
2320
- case "time":
2321
- case "datetime":
2322
- case "slug":
2323
- case "url":
2324
- case "link":
2325
- case "select":
2326
- case "reference":
2327
- case "presetOrCustom":
2328
- case "contentTypeSelect":
2329
- case "entryPicker": return field;
2330
- }
2331
- return assertNever(field);
2332
- }
2333
- function numberFieldToManifestInput(field) {
2334
- const ui = readNumberFieldUiConfig(field.ui);
2335
- return {
2336
- ...field,
2337
- min: field.min ?? ui.min,
2338
- max: field.max ?? ui.max,
2339
- step: field.step ?? ui.step
2340
- };
2341
- }
2342
- function groupFieldToManifestInput(field) {
2343
- return {
2344
- ...field,
2345
- schema: {
2346
- ...field.schema,
2347
- fields: getGroupChildFields(field).map(toManifestFieldInput)
2348
- }
2349
- };
2350
- }
2351
- function modalFieldToManifestInput(field) {
2352
- return {
2353
- ...field,
2354
- schema: {
2355
- ...field.schema,
2356
- fields: field.schema.fields.map(toManifestFieldInput)
2357
- }
2358
- };
2359
- }
2360
- function repeaterFieldToManifestInput(field) {
2361
- if (field.polymorphic) return {
2362
- ...field,
2363
- itemTypes: Object.fromEntries(Object.entries(field.itemTypes).map(([typeId, itemType]) => [typeId, {
2364
- ...itemType,
2365
- fields: itemType.fields.map(toManifestFieldInput)
2366
- }]))
2367
- };
2368
- return {
2369
- ...field,
2370
- schema: {
2371
- ...field.schema,
2372
- fields: getRepeaterChildFields(field).map(toManifestFieldInput)
2373
- }
2374
- };
2375
- }
2376
- //#endregion
2377
- //#region ../block-form/src/widgets/TextField/textFieldSchema.ts
2378
- function buildTextFieldSchema(field) {
2379
- return buildCanonicalFieldSchema(field);
2380
- }
2381
- //#endregion
2382
- //#region ../block-form/src/widgets/stringDefaultValue.ts
2383
- function readStringDefaultValue(value) {
2384
- if (typeof value === "string") return value;
2385
- if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return String(value);
2386
- return null;
2387
- }
2388
- //#endregion
2389
- //#region ../block-form/src/widgets/TextField/textFieldDefaults.ts
2390
- function getTextFieldDefault(field) {
2391
- const defaultValue = readStringDefaultValue(field.defaultValue);
2392
- if (defaultValue !== null) return defaultValue;
2393
- if (field.required) return field.label;
2394
- return "";
2395
- }
2396
- //#endregion
2397
- //#region ../block-form/src/widgets/NumberField/numberFieldSchema.ts
2398
- function buildNumberFieldSchema(field) {
2399
- return buildCanonicalFieldSchema(field);
2400
- }
2401
- //#endregion
2402
- //#region ../block-form/src/widgets/NumberField/numberFieldDefaults.ts
2403
- function getNumberFieldDefault(field) {
2404
- if (field.defaultValue !== void 0) return typeof field.defaultValue === "number" ? field.defaultValue : null;
2405
- return null;
2406
- }
2407
- //#endregion
2408
- //#region ../block-form/src/widgets/SelectField/selectFieldSchema.ts
2409
- function buildSelectFieldSchema(field) {
2410
- return buildCanonicalFieldSchema(field);
2411
- }
2412
- //#endregion
2413
- //#region ../block-form/src/widgets/SelectField/selectFieldDefaults.ts
2414
- function getSelectFieldDefault(field) {
2415
- if (field.multiple) {
2416
- if (Array.isArray(field.defaultValue)) return field.defaultValue.filter((v) => typeof v === "string");
2417
- if (typeof field.defaultValue === "string" && field.defaultValue.trim().length > 0) return [field.defaultValue];
2418
- if (field.required) {
2419
- const first = field.options?.[0]?.value;
2420
- if (typeof first === "string") return [first];
2421
- }
2422
- return [];
2423
- }
2424
- const defaultValue = readStringDefaultValue(field.defaultValue);
2425
- if (defaultValue !== null) return defaultValue;
2426
- return field.options?.[0]?.value ?? "";
2427
- }
2428
- //#endregion
2429
- //#region ../block-form/src/widgets/BooleanField/booleanFieldSchema.ts
2430
- /**
2431
- * BooleanField validation schema builder
2432
- * Server-safe - no React, no browser APIs
2433
- */
2434
- function buildBooleanFieldSchema(field) {
2435
- const base = z.boolean();
2436
- return field.required ? base : base.optional().nullable();
2437
- }
2438
- //#endregion
2439
- //#region ../block-form/src/widgets/BooleanField/booleanFieldDefaults.ts
2440
- function getBooleanFieldDefault(field) {
2441
- if (field.defaultValue !== void 0) return Boolean(field.defaultValue);
2442
- return false;
2443
- }
2444
- //#endregion
2445
- //#region ../block-form/src/widgets/GroupField/groupFieldSchema.ts
2446
- /**
2447
- * GroupField validation schema builder
2448
- * Server-safe - no React, no browser APIs
2449
- */
2450
- function buildGroupFieldSchema(field, ctx) {
2451
- const shape = {};
2452
- const fields = field.fields ?? field.schema?.fields ?? [];
2453
- for (const child of fields) shape[child.id] = ctx.getFieldSchema(child);
2454
- return z.object(shape).catchall(z.unknown()).passthrough();
2455
- }
2456
- //#endregion
2457
- //#region ../block-form/src/widgets/GroupField/groupFieldDefaults.ts
2458
- function getGroupFieldDefault(field, ctx) {
2459
- if (field.ui?.valueContract === "location") return null;
2460
- const fields = field.fields ?? field.schema?.fields ?? [];
2461
- return Object.fromEntries(fields.map((child) => [child.id, ctx.resolve(child)]));
2462
- }
2463
- //#endregion
2464
- //#region ../block-form/src/widgets/ModalGroupField/modalFieldSchema.ts
2465
- /**
2466
- * ModalGroupField validation schema builder
2467
- * Server-safe - no React, no browser APIs
2468
- *
2469
- * Modal fields are structurally identical to group fields - they just render differently in the UI.
2470
- */
2471
- function buildModalFieldSchema(field, ctx) {
2472
- const shape = {};
2473
- const fields = field.schema.fields;
2474
- for (const child of fields) shape[child.id] = ctx.getFieldSchema(child);
2475
- return z.object(shape).catchall(z.unknown()).passthrough();
2476
- }
2477
- //#endregion
2478
- //#region ../block-form/src/widgets/ModalGroupField/modalFieldDefaults.ts
2479
- function getModalFieldDefault(field, ctx) {
2480
- const obj = {};
2481
- const fields = field.schema?.fields ?? field.fields ?? [];
2482
- for (const child of fields) obj[child.id] = ctx.resolve(child);
2483
- return obj;
2484
- }
2485
- //#endregion
2486
- //#region ../block-form/src/widgets/RepeaterField/repeaterFieldSchema.ts
2487
- /**
2488
- * RepeaterField validation schema builder
2489
- * Server-safe - no React, no browser APIs
2490
- */
2491
- function hasAtLeastTwo(items) {
2492
- return items.length >= 2;
2493
- }
2494
- function buildRepeaterFieldSchema(field, ctx) {
2495
- const itemSchema = buildRepeaterItemSchema(field, ctx);
2496
- const customValidation = field.validation;
2497
- if (customValidation) {
2498
- if (field.required) return customValidation;
2499
- return z.optional(customValidation);
2500
- }
2501
- const arraySchema = z.array(itemSchema);
2502
- const minItems = field.minItems ?? 0;
2503
- const minSchema = minItems > 0 ? arraySchema.min(minItems, `Must have at least ${minItems} item(s)`) : arraySchema;
2504
- const schema = field.maxItems !== void 0 ? minSchema.max(field.maxItems, `Must have at most ${field.maxItems} item(s)`) : minSchema;
2505
- return field.required ? schema : z.optional(schema);
2506
- }
2507
- function buildItemSchema(fields, ctx, typeKey) {
2508
- return z.object({
2509
- ...typeKey !== void 0 ? { _type: z.literal(typeKey) } : {},
2510
- ...Object.fromEntries(getRepeaterItemDataFields(fields).map((child) => [child.id, ctx.getFieldSchema(child)]))
2511
- }).catchall(z.unknown()).passthrough();
2512
- }
2513
- function buildRepeaterItemSchema(field, ctx) {
2514
- if (!field.polymorphic) return buildItemSchema(getRepeaterChildFields(field), ctx);
2515
- const schemas = Object.entries(field.itemTypes).map(([typeKey, itemType]) => buildItemSchema(itemType.fields, ctx, typeKey));
2516
- return hasAtLeastTwo(schemas) ? z.discriminatedUnion("_type", schemas) : schemas[0] ?? z.object({ _type: z.string() }).passthrough();
2517
- }
2518
- //#endregion
2519
- //#region ../block-form/src/widgets/RepeaterField/repeaterFieldDefaults.ts
2520
- /**
2521
- * RepeaterField default value builder
2522
- * Server-safe - no React, no browser APIs
2523
- */
2524
- function isRecordArray(value) {
2525
- return Array.isArray(value) && value.every((item) => {
2526
- return typeof item === "object" && item !== null && !Array.isArray(item);
2527
- });
2528
- }
2529
- function getRepeaterFieldDefault(field, ctx) {
2530
- if (field.defaultValue !== void 0) return isRecordArray(field.defaultValue) ? field.defaultValue : [];
2531
- return seedFixedLayoutGridPositions(field, Array.from({ length: field.minItems ?? 0 }, () => getRepeaterItemDefault(field, ctx)));
2532
- }
2533
- /** Shared owner for newly added rows and manifest-seeded minimum rows. */
2534
- function getRepeaterItemDefault(field, ctx, itemType) {
2535
- const typeKey = field.polymorphic ? itemType ?? Object.keys(field.itemTypes)[0] ?? "" : void 0;
2536
- const fields = field.polymorphic ? field.itemTypes[typeKey ?? ""]?.fields ?? [] : getRepeaterChildFields(field);
2537
- return applyLayoutGridDefaultWidth(field, fields, {
2538
- ...typeKey !== void 0 ? { _type: typeKey } : {},
2539
- ...Object.fromEntries(getRepeaterItemDataFields(fields).map((child) => [child.id, ctx.resolve(child)]))
2540
- });
2541
- }
2542
- /** New rows get an accepted default; existing saved values are never normalized here. */
2543
- function applyLayoutGridDefaultWidth(field, fields, value) {
2544
- if (field.ui?.repeaterPreset !== "layoutGrid") return value;
2545
- const spanField = resolveRepeaterGridSpanFieldId({ id: typeof field.ui.layoutGridSpanField === "string" ? field.ui.layoutGridSpanField : void 0 });
2546
- const acceptedSpans = resolveRepeaterGridAcceptedSpans(fields, spanField);
2547
- if (!acceptedSpans) return value;
2548
- const columns = typeof field.ui.layoutGridColumns === "number" ? field.ui.layoutGridColumns : 6;
2549
- return {
2550
- ...value,
2551
- [spanField]: String(normalizeRepeaterGridSpan(value[spanField], columns, acceptedSpans))
2552
- };
2553
- }
2554
- /** Minimum rows are new content too: place them through the same planner as Add. */
2555
- function seedFixedLayoutGridPositions(field, defaults) {
2556
- const columns = field.ui?.layoutGridColumns;
2557
- if (field.ui?.repeaterPreset !== "layoutGrid" || typeof columns !== "number") return defaults;
2558
- const spanId = resolveRepeaterGridSpanFieldId({ id: typeof field.ui.layoutGridSpanField === "string" ? field.ui.layoutGridSpanField : void 0 });
2559
- const rowId = resolveRepeaterGridRowFieldId({ id: typeof field.ui.layoutGridRowField === "string" ? field.ui.layoutGridRowField : void 0 });
2560
- const columnId = resolveRepeaterGridColumnFieldId({ id: typeof field.ui.layoutGridColumnField === "string" ? field.ui.layoutGridColumnField : void 0 });
2561
- const placed = flowRepeaterGridItems(defaults.map((item, index) => ({
2562
- id: String(index),
2563
- span: Number(item[spanId]),
2564
- row: 1,
2565
- colStart: 1,
2566
- startNewRow: typeof field.ui?.layoutGridStartNewRowField === "string" && item[field.ui.layoutGridStartNewRowField] === true
2567
- })), columns);
2568
- return defaults.map((item, index) => ({
2569
- ...item,
2570
- [rowId]: placed[index]?.row,
2571
- [columnId]: placed[index]?.colStart
2572
- }));
2573
- }
2574
- //#endregion
2575
- //#region ../block-form/src/widgets/UrlField/urlFieldSchema.ts
2576
- /**
2577
- * Build Zod validation schema for URL field
2578
- */
2579
- function buildUrlFieldSchema(field) {
2580
- return buildCanonicalFieldSchema(field);
2581
- }
2582
- //#endregion
2583
- //#region ../block-form/src/widgets/UrlField/urlFieldDefaults.ts
2584
- /**
2585
- * Get default value for URL field
2586
- */
2587
- function getUrlFieldDefault(field) {
2588
- return field.defaultValue ?? "";
2589
- }
2590
- //#endregion
2591
- //#region ../block-form/src/widgets/TimeField/timeFieldSchema.ts
2592
- /**
2593
- * Build Zod validation schema for Time field
2594
- */
2595
- function buildTimeFieldSchema(field) {
2596
- return buildCanonicalFieldSchema(field);
2597
- }
2598
- //#endregion
2599
- //#region ../block-form/src/widgets/TimeField/timeFieldDefaults.ts
2600
- /**
2601
- * Get default value for Time field
2602
- */
2603
- function getTimeFieldDefault(field) {
2604
- return field.defaultValue ?? null;
2605
- }
2606
- //#endregion
2607
- //#region ../block-form/src/widgets/DateField/dateFieldSchema.ts
2608
- /**
2609
- * Build Zod validation schema for Date field
2610
- */
2611
- function buildDateFieldSchema(field) {
2612
- return buildCanonicalFieldSchema(field);
2613
- }
2614
- //#endregion
2615
- //#region ../block-form/src/widgets/DateField/dateFieldDefaults.ts
2616
- /**
2617
- * Get default value for Date field
2618
- */
2619
- function getDateFieldDefault(field) {
2620
- return field.defaultValue ?? null;
2621
- }
2622
- //#endregion
2623
- //#region ../block-form/src/widgets/DateTimeField/dateTimeFieldSchema.ts
2624
- /**
2625
- * Build Zod validation schema for DateTime field
2626
- *
2627
- * Validates ISO 8601 date-time strings
2628
- */
2629
- function buildDateTimeFieldSchema(field) {
2630
- return buildCanonicalFieldSchema(field);
2631
- }
2632
- //#endregion
2633
- //#region ../block-form/src/widgets/DateTimeField/dateTimeFieldDefaults.ts
2634
- /**
2635
- * Get default value for DateTime field
2636
- */
2637
- function getDateTimeFieldDefault(field) {
2638
- return field.defaultValue ?? null;
2639
- }
2640
- //#endregion
2641
- //#region ../block-form/src/widgets/SlugField/slugFieldSchema.ts
2642
- /**
2643
- * Build Zod validation schema for Slug field
2644
- *
2645
- * Validates:
2646
- * - Lowercase letters, numbers, and dashes only
2647
- * - Optional slashes for paths (e.g., 'parent/child')
2648
- * - Optional maxLength constraint
2649
- */
2650
- function buildSlugFieldSchema(field) {
2651
- return buildCanonicalFieldSchema(field);
2652
- }
2653
- //#endregion
2654
- //#region ../block-form/src/widgets/SlugField/slugFieldDefaults.ts
2655
- /**
2656
- * Get default value for Slug field
2657
- */
2658
- function getSlugFieldDefault(field) {
2659
- return field.defaultValue ?? "";
2660
- }
2661
- //#endregion
2662
- //#region ../block-form/src/widgets/LinkField/linkFieldSchema.ts
2663
- function buildLinkFieldSchema(field) {
2664
- return buildCanonicalFieldSchema(field);
2665
- }
2666
- //#endregion
2667
- //#region ../block-form/src/widgets/LinkField/linkFieldDefaults.ts
2668
- /**
2669
- * Get default value for LinkField
2670
- */
2671
- function getLinkFieldDefault(field) {
2672
- if (field.defaultValue !== void 0) return field.defaultValue;
2673
- if (field.required) return {
2674
- kind: "url",
2675
- href: "#"
2676
- };
2677
- }
2678
- //#endregion
2679
- //#region ../block-form/src/widgets/RichTextField/richTextFieldSchema.ts
2680
- /**
2681
- * Build Zod validation schema for rich text field
2682
- *
2683
- * Uses the shared rich text schema from @riverbankcms/blocks to ensure consistency
2684
- * between the form editor and block rendering validation.
2685
- *
2686
- * @param config - Rich text field configuration
2687
- * @returns Zod schema for rich text validation
2688
- */
2689
- function buildRichTextFieldSchema(config) {
2690
- const schema = buildRichTextSchema({
2691
- required: config.required,
2692
- label: config.label
2693
- });
2694
- return config.required ? schema : z.union([schema, z.null()]).optional();
2695
- }
2696
- //#endregion
2697
- //#region ../block-form/src/widgets/RichTextField/richTextFieldDefaults.ts
2698
- /**
2699
- * Empty TipTap document structure
2700
- */
2701
- const EMPTY_RICH_TEXT_DOC = createRichTextDoc([""]);
2702
- /**
2703
- * Get default value for rich text field
2704
- * Returns empty TipTap document structure
2705
- */
2706
- function getRichTextFieldDefaultValue(_config) {
2707
- return EMPTY_RICH_TEXT_DOC;
2708
- }
2709
- //#endregion
2710
- //#region ../block-form/src/widgets/InlineTextField/inlineTextFieldSchema.ts
2711
- function buildInlineTextFieldSchema(field) {
2712
- return buildCanonicalFieldSchema(field);
2713
- }
2714
- //#endregion
2715
- //#region ../block-form/src/widgets/InlineTextField/inlineTextFieldDefaults.ts
2716
- function getInlineTextFieldDefaultValue(field) {
2717
- if (field.defaultValue !== void 0) return field.defaultValue;
2718
- return field.required ? plainTextToInlineText(field.label) : [];
2719
- }
2720
- //#endregion
2721
- //#region ../block-form/src/widgets/MediaField/mediaFieldSchema.ts
2722
- /**
2723
- * Build Zod validation schema for media field
2724
- * Validates media object structure or null
2725
- */
2726
- function buildMediaFieldSchema(config) {
2727
- return buildCanonicalFieldSchema(config);
2728
- }
2729
- //#endregion
2730
- //#region ../block-form/src/widgets/MediaField/mediaFieldDefaults.ts
2731
- /**
2732
- * Get default value for media field
2733
- * Media fields default to null (no media selected)
2734
- */
2735
- function getMediaFieldDefaultValue(_config) {
2736
- return null;
2737
- }
2738
- //#endregion
2739
- //#region ../block-form/src/widgets/TabGroupField/tabGroupFieldSchema.ts
2740
- /**
2741
- * TabGroupField validation schema builder
2742
- * Server-safe - no React, no browser APIs
2743
- */
2744
- /**
2745
- * Build validation schema for TabGroupField
2746
- *
2747
- * TabGroup is a UI container that organizes fields into tabs.
2748
- * It validates all child fields across all tabs, and optionally
2749
- * validates the activeTabField if one is specified.
2750
- */
2751
- function buildTabGroupFieldSchema(field, ctx) {
2752
- const shape = {};
2753
- for (const tab of field.tabs) for (const child of tab.fields) shape[child.id] = ctx.getFieldSchema(child);
2754
- if (field.activeTabField) {
2755
- const tabIds = field.tabs.map((t) => t.id);
2756
- if (tabIds.length > 0) shape[field.activeTabField] = z.enum(tabIds);
2757
- }
2758
- return z.object(shape).catchall(z.unknown()).passthrough();
2759
- }
2760
- /**
2761
- * Get default value for TabGroupField
2762
- *
2763
- * Returns an object containing default values for all child fields
2764
- * across all tabs, plus the activeTabField if specified.
2765
- *
2766
- * Follows the same pattern as GroupField - includes all fields
2767
- * even if their default value is undefined.
2768
- */
2769
- function getTabGroupFieldDefault(field, ctx) {
2770
- const defaults = {};
2771
- for (const tab of field.tabs) for (const child of tab.fields) defaults[child.id] = ctx.resolve(child);
2772
- if (field.activeTabField && field.tabs.length > 0 && field.tabs[0]) defaults[field.activeTabField] = field.tabs[0].id;
2773
- return defaults;
2774
- }
2775
- //#endregion
2776
- //#region ../block-form/src/widgets/PresetOrCustomField/presetOrCustomFieldSchema.ts
2777
- function buildPresetOrCustomFieldSchema(field, _ctx) {
2778
- field.presets.map((p) => p.value);
2779
- return z.string();
2780
- }
2781
- //#endregion
2782
- //#region ../block-form/src/widgets/PresetOrCustomField/presetOrCustomFieldDefaults.ts
2783
- function getPresetOrCustomFieldDefault(field, _ctx) {
2784
- const defaultValue = readStringDefaultValue(field.defaultValue);
2785
- if (defaultValue !== null) return defaultValue;
2786
- return field.presets[0]?.value ?? "";
2787
- }
2788
- //#endregion
2789
- //#region ../block-form/src/widgets/ReferenceField/referenceFieldSchema.ts
2790
- function buildReferenceFieldSchema(field, _ctx) {
2791
- return buildCanonicalFieldSchema(field);
2792
- }
2793
- //#endregion
2794
- //#region ../block-form/src/widgets/ReferenceField/referenceFieldDefaults.ts
2795
- function getReferenceFieldDefault(field, _ctx) {
2796
- const defaultValue = readStringDefaultValue(field.defaultValue);
2797
- if (defaultValue !== null) return defaultValue;
2798
- if (field.required) return `placeholder-${field.id}`;
2799
- return "";
2800
- }
2801
- //#endregion
2802
- //#region ../block-form/src/widgets/ContentTypeSelectField/contentTypeSelectFieldSchema.ts
2803
- function buildContentTypeSelectFieldSchema(field, _ctx) {
2804
- const schema = z.string();
2805
- if (field.required) return schema.min(1, "This field is required");
2806
- return z.optional(schema).nullable().or(z.literal(""));
2807
- }
2808
- //#endregion
2809
- //#region ../block-form/src/widgets/ContentTypeSelectField/contentTypeSelectFieldDefaults.ts
2810
- function getContentTypeSelectFieldDefault(field, _ctx) {
2811
- const defaultValue = readStringDefaultValue(field.defaultValue);
2812
- if (defaultValue !== null) return defaultValue;
2813
- return "";
2814
- }
2815
- //#endregion
2816
- //#region ../block-form/src/widgets/EntryPickerField/entryPickerFieldSchema.ts
2817
- function buildEntryPickerFieldSchema(field, _ctx) {
2818
- const schema = z.string();
2819
- if (field.required) return schema.min(1, "This field is required");
2820
- return z.optional(schema).nullable().or(z.literal(""));
2821
- }
2822
- //#endregion
2823
- //#region ../block-form/src/widgets/EntryPickerField/entryPickerFieldDefaults.ts
2824
- function getEntryPickerFieldDefault(field, _ctx) {
2825
- const defaultValue = readStringDefaultValue(field.defaultValue);
2826
- if (defaultValue !== null) return defaultValue;
2827
- if (field.required) return `placeholder-${field.id}`;
2828
- return "";
2829
- }
2830
- //#endregion
2831
- //#region ../block-form/src/registry/schemas.ts
2832
- /**
2833
- * Schema and Default Value Registry
2834
- * Maps field types to validation schemas and default value builders
2835
- *
2836
- * Server-safe - no React, no browser APIs
2837
- * Can be used in API routes, server components, and validation
2838
- */
2839
- const SCHEMA_BUILDERS = {
2840
- text: buildTextFieldSchema,
2841
- number: buildNumberFieldSchema,
2842
- select: buildSelectFieldSchema,
2843
- boolean: buildBooleanFieldSchema,
2844
- group: buildGroupFieldSchema,
2845
- modal: buildModalFieldSchema,
2846
- repeater: buildRepeaterFieldSchema,
2847
- url: buildUrlFieldSchema,
2848
- time: buildTimeFieldSchema,
2849
- date: buildDateFieldSchema,
2850
- datetime: buildDateTimeFieldSchema,
2851
- slug: buildSlugFieldSchema,
2852
- link: buildLinkFieldSchema,
2853
- richText: buildRichTextFieldSchema,
2854
- inlineText: buildInlineTextFieldSchema,
2855
- media: buildMediaFieldSchema,
2856
- file: buildMediaFieldSchema,
2857
- tabGroup: buildTabGroupFieldSchema,
2858
- presetOrCustom: buildPresetOrCustomFieldSchema,
2859
- reference: buildReferenceFieldSchema,
2860
- contentTypeSelect: buildContentTypeSelectFieldSchema,
2861
- entryPicker: buildEntryPickerFieldSchema
2862
- };
2863
- const DEFAULT_VALUE_BUILDERS = {
2864
- text: getTextFieldDefault,
2865
- number: getNumberFieldDefault,
2866
- select: getSelectFieldDefault,
2867
- boolean: getBooleanFieldDefault,
2868
- group: getGroupFieldDefault,
2869
- modal: getModalFieldDefault,
2870
- repeater: getRepeaterFieldDefault,
2871
- url: getUrlFieldDefault,
2872
- time: getTimeFieldDefault,
2873
- date: getDateFieldDefault,
2874
- datetime: getDateTimeFieldDefault,
2875
- slug: getSlugFieldDefault,
2876
- link: getLinkFieldDefault,
2877
- richText: getRichTextFieldDefaultValue,
2878
- inlineText: getInlineTextFieldDefaultValue,
2879
- media: getMediaFieldDefaultValue,
2880
- file: getMediaFieldDefaultValue,
2881
- tabGroup: getTabGroupFieldDefault,
2882
- presetOrCustom: getPresetOrCustomFieldDefault,
2883
- reference: getReferenceFieldDefault,
2884
- contentTypeSelect: getContentTypeSelectFieldDefault,
2885
- entryPicker: getEntryPickerFieldDefault
2886
- };
2887
- /**
2888
- * Helper to build a validation schema for a single field
2889
- * Recursively handles nested fields (group, repeater)
2890
- */
2891
- function buildFieldSchema(field, ctx) {
2892
- const builder = SCHEMA_BUILDERS[field.type];
2893
- if (!builder) {
2894
- console.warn(`No schema builder registered for field type: ${field.type}`);
2895
- return z.any();
2896
- }
2897
- return builder(field, ctx);
2898
- }
2899
- /**
2900
- * Helper to get default value for a single field
2901
- * Recursively handles nested fields (group, repeater)
2902
- */
2903
- function getFieldDefault(field, ctx) {
2904
- const getDefault = DEFAULT_VALUE_BUILDERS[field.type];
2905
- if (!getDefault) {
2906
- console.warn(`No default value builder registered for field type: ${field.type}`);
2907
- return field.defaultValue;
2908
- }
2909
- return getDefault(field, ctx);
2910
- }
2911
- //#endregion
2912
- //#region ../block-form/src/manifest/manifestFormAdapter.ts
2913
- const DEFAULT_ROLE = "author";
2914
- const rolePriority = {
2915
- author: 0,
2916
- designer: 1,
2917
- admin: 2
2918
- };
2919
- /**
2920
- * Transform a BlockManifest into form fields and validation schema
2921
- */
2922
- function createManifestFormAdapter(manifest, options) {
2923
- const role = options?.role ?? DEFAULT_ROLE;
2924
- const fields = (manifest.fields ?? []).map((field) => transformField(field, role)).filter(Boolean);
2925
- return {
2926
- fields,
2927
- schema: buildValidationSchema(fields)
2928
- };
2929
- }
2930
- /**
2931
- * Transform a single field, filtering by role and flattening nested structure
2932
- */
2933
- function transformField(field, role) {
2934
- if (!isFieldVisible(field, role)) return;
2935
- if (field.type !== "group" && field.type !== "repeater" && field.type !== "modal" && field.type !== "tabGroup") return field;
2936
- if (field.type === "group") {
2937
- const children = (field.schema?.fields ?? []).map((child) => transformField(child, role)).filter(Boolean);
2938
- if (!children.length) return;
2939
- const { schema: _schema, ...rest } = field;
2940
- return {
2941
- ...rest,
2942
- fields: children
2943
- };
2944
- }
2945
- if (field.type === "modal") {
2946
- const children = (field.schema?.fields ?? []).map((child) => transformField(child, role)).filter(Boolean);
2947
- if (!children.length) return;
2948
- const { schema: _schema, ...rest } = field;
2949
- return {
2950
- ...rest,
2951
- schema: { fields: children }
2952
- };
2953
- }
2954
- if (field.type === "tabGroup") {
2955
- const tabs = (field.tabs ?? []).flatMap((tab) => {
2956
- const children = (tab.fields ?? []).map((child) => transformField(child, role)).filter(Boolean);
2957
- return children.length ? [{
2958
- ...tab,
2959
- fields: children
2960
- }] : [];
2961
- });
2962
- if (!tabs.length) return;
2963
- return {
2964
- ...field,
2965
- tabs
2966
- };
2967
- }
2968
- if (field.type === "repeater") {
2969
- if (field.polymorphic && field.itemTypes) {
2970
- const itemTypes = {};
2971
- for (const [typeKey, itemType] of Object.entries(field.itemTypes)) {
2972
- const children = (itemType.fields ?? []).map((child) => transformField(child, role)).filter(Boolean);
2973
- if (children.length > 0) itemTypes[typeKey] = {
2974
- label: itemType.label,
2975
- icon: itemType.icon,
2976
- fields: children
2977
- };
2978
- }
2979
- if (Object.keys(itemTypes).length === 0) return;
2980
- const { schema: _schema2, ...rest } = field;
2981
- return {
2982
- ...rest,
2983
- polymorphic: true,
2984
- itemTypes
2985
- };
2986
- }
2987
- const children = (field.schema?.fields ?? []).map((child) => transformField(child, role)).filter(Boolean);
2988
- if (!children.length) return;
2989
- const { schema: _schema3, polymorphic: _polymorphic, itemTypes: _itemTypes, ...rest } = field;
2990
- return {
2991
- ...rest,
2992
- fields: children
2993
- };
2994
- }
2995
- }
2996
- /**
2997
- * Check if a field is visible to the current role
2998
- */
2999
- function isFieldVisible(field, role) {
3000
- if (role === "admin") return true;
3001
- const allowed = field.visibleRoles;
3002
- if (!allowed || allowed.length === 0) return true;
3003
- return allowed.some((visibility) => rolePriority[role] >= rolePriority[visibility]);
3004
- }
3005
- /**
3006
- * Build a Zod validation schema from field configs using the schema registry
3007
- */
3008
- function buildValidationSchema(fields) {
3009
- const shape = {};
3010
- const ctx = { getFieldSchema: (field) => buildManifestFieldSchema(field, ctx) };
3011
- for (const field of fields) shape[field.id] = buildManifestFieldSchema(field, ctx);
3012
- return z.object(shape).catchall(z.unknown()).passthrough();
3013
- }
3014
- function buildManifestFieldSchema(field, ctx) {
3015
- if (shouldUseCanonicalSchema(field)) return buildCanonicalFieldSchema(field);
3016
- return buildFieldSchema(field, ctx);
3017
- }
3018
- function shouldUseCanonicalSchema(field) {
3019
- switch (field.type) {
3020
- case "text":
3021
- case "number":
3022
- case "select":
3023
- case "boolean":
3024
- case "url":
3025
- case "slug":
3026
- case "link":
3027
- case "media":
3028
- case "file":
3029
- case "reference":
3030
- case "inlineText": return true;
3031
- case "group": return getGroupChildFields(field).every(shouldUseCanonicalSchema);
3032
- case "modal": return field.schema.fields.every(shouldUseCanonicalSchema);
3033
- case "repeater":
3034
- if (field.polymorphic) return Object.values(field.itemTypes).every((itemType) => itemType.fields.every(shouldUseCanonicalSchema));
3035
- return getRepeaterChildFields(field).every(shouldUseCanonicalSchema);
3036
- case "tabGroup":
3037
- if (field.activeTabField) return false;
3038
- return field.tabs.every((tab) => tab.fields.every(shouldUseCanonicalSchema));
3039
- case "richText":
3040
- case "date":
3041
- case "time":
3042
- case "datetime":
3043
- case "presetOrCustom":
3044
- case "contentTypeSelect":
3045
- case "entryPicker":
3046
- case "button": return false;
3047
- }
3048
- return assertNever(field);
3049
- }
3050
- //#endregion
3051
- //#region ../block-form/src/manifest/manifestDefaultValues.ts
3052
- /** Construct initial field values through the same field-type default owner on server and client. */
3053
- function createManifestDefaultValues(manifest, data = {}, options = {}) {
3054
- const { fields } = createManifestFormAdapter(manifest, {
3055
- role: options.role,
3056
- ...options.adapterOptions
3057
- });
3058
- const ctx = { resolve: (field) => getFieldDefault(field, ctx) };
3059
- return fields.reduce((values, field) => ({
3060
- ...values,
3061
- ...defaultFieldEntry(field, data, ctx)
3062
- }), {});
3063
- }
3064
- /** Inline text owns both its document value and its declared plain-text mirror. */
3065
- function defaultFieldEntry(field, data, ctx) {
3066
- const raw = data[field.id];
3067
- const plain = field.type === "inlineText" && field.plainTextField ? data[field.plainTextField] : void 0;
3068
- const value = raw === void 0 && typeof plain === "string" ? plainTextToInlineText(plain) : ensureFieldValue(field, raw, ctx);
3069
- if (field.type !== "inlineText" || !field.plainTextField) return { [field.id]: value };
3070
- const parsed = parseInlineTextFromUnknown(value);
3071
- return parsed.ok ? {
3072
- [field.id]: value,
3073
- [field.plainTextField]: inlineTextToPlainText(parsed.value)
3074
- } : { [field.id]: value };
3075
- }
3076
- function ensureFieldValue(field, raw, ctx) {
3077
- const value = raw === void 0 ? getFieldDefault(field, ctx) : raw;
3078
- if (field.type !== "repeater") return value;
3079
- return (Array.isArray(value) ? value : []).map((item) => ensureRepeaterItem(field, item, ctx));
3080
- }
3081
- function ensureRepeaterItem(field, value, ctx) {
3082
- const itemData = isRecord(value) ? value : {};
3083
- const itemType = typeof itemData._type === "string" ? itemData._type : Object.keys(field.itemTypes ?? {})[0] ?? "";
3084
- const fields = field.polymorphic ? field.itemTypes[itemType]?.fields ?? [] : getRepeaterChildFields(field);
3085
- return {
3086
- ...itemData,
3087
- ...Object.fromEntries(getRepeaterItemDataFields(fields).map((child) => [child.id, ensureFieldValue(child, itemData[child.id], ctx)]))
3088
- };
3089
- }
3090
- //#endregion
3091
- //#region ../site-renderer/dist/index.mjs
3092
- /** Each adapter maps meaning to manifest fields; layout stays with the block and site style. */
3093
- function sectionBlockContent(label, value) {
3094
- switch (value.kind) {
3095
- case "list": return {
3096
- title: label,
3097
- list: {
3098
- kind: "list",
3099
- items: value.items.map((text) => ({ text }))
3100
- }
3101
- };
3102
- case "headedLists": return {
3103
- title: label,
3104
- list: {
3105
- kind: "headedLists",
3106
- groups: value.groups.map((group) => ({
3107
- heading: group.heading,
3108
- items: group.items.map((text) => ({ text }))
3109
- }))
3110
- }
3111
- };
3112
- case "questions": return {
3113
- title: label,
3114
- items: value.items.map((item) => ({
3115
- question: item.question,
3116
- answer: createRichTextDoc([item.answer])
3117
- }))
3118
- };
3119
- case "cards": return {
3120
- title: label,
3121
- cards: value.cards.map((card) => ({
3122
- title: card.title,
3123
- ...card.text === "" ? {} : { body: createRichTextDoc([card.text]) }
3124
- }))
3125
- };
3126
- case "text": return {
3127
- heading: label,
3128
- body: value.body
3129
- };
3130
- case "textWithPhoto": return {
3131
- title: label,
3132
- text: value.body,
3133
- images: value.photo !== null ? [{ image: {
3134
- ...value.photo,
3135
- type: "image"
3136
- } }] : []
3137
- };
3138
- }
3139
- }
3140
- /** The same kind-aware Look admission is used when writing and rendering. */
3141
- function resolvePageSectionLook(kind, raw) {
3142
- if (kind === "list" || kind === "headedLists") return parseListLook(kind, raw);
3143
- const blockKind = pageSectionBlockKind(kind);
3144
- return appearancePresets.find((preset) => preset.id === raw && preset.blockKinds.some((candidate) => candidate === blockKind))?.id ?? null;
3145
- }
3146
- /** The block each body section kind renders through. */
3147
- function pageSectionBlockKind(kind) {
3148
- switch (kind) {
3149
- case "list":
3150
- case "headedLists": return "block.list";
3151
- case "questions": return "block.faq";
3152
- case "cards": return "block.feature-cards";
3153
- case "text": return "block.body-text";
3154
- case "textWithPhoto": return "block.media-text";
3155
- }
3156
- }
3157
- /** Section Looks stored on the template anchor. Full pages only: booking pages always use the style's default (README decision 8). */
3158
- function pageSectionLookOverrides(blocks) {
3159
- const looks = blocks.find((block) => block.blockKind === PAGE_SECTIONS_ANCHOR_BLOCK_KIND)?.content?.looks;
3160
- return isRecord$1(looks) ? looks : {};
3161
- }
3162
- /** Pure, shared by public pages and preview. Empty values disappear before layout. */
3163
- function compilePageSections(input, lookOverrides) {
3164
- const sections = resolveApplicableSections(input.definitions, input.facts).sections.flatMap((definition) => {
3165
- if (definition.shape.placement !== "body") return [];
3166
- const read = readSectionValue(input.values[definition.id], definition.shape.kind);
3167
- if (read.kind === "empty") return [];
3168
- const block = {
3169
- blockKind: pageSectionBlockKind(definition.shape.kind),
3170
- content: sectionBlockContent(definition.label, read.value)
3171
- };
3172
- return [{
3173
- look: resolvePageSectionLook(definition.shape.kind, lookOverrides[definition.id]),
3174
- block: {
3175
- id: `page-section-${definition.id}`,
3176
- orderIndex: definition.position,
3177
- scope: "template",
3178
- blockKind: block.blockKind,
3179
- content: block.content,
3180
- bindings: null
3181
- }
3182
- }];
3183
- });
3184
- return {
3185
- blocks: sections.map((section) => section.block),
3186
- lookPins: sections.flatMap(({ block, look }) => look === null ? [] : [{
3187
- blockId: asContentTemplateDesignBlockId(block.id),
3188
- blockKind: block.blockKind,
3189
- choice: {
3190
- kind: "user-pinned",
3191
- value: asAppearancePresetId(look)
3192
- }
3193
- }])
3194
- };
3195
- }
3196
- function buildContentTemplateRuntime(template, theme, contentForBlock) {
3197
- const parsed = parseContentTemplateDesignIntent(template.designState);
3198
- const intent = parsed.kind === "parsed" ? parsed.intent : parsed.kind === "absent" && theme?.siteStyleId !== void 0 ? buildInitialPolicyPageDesignIntent(theme.siteStyleId) : null;
3199
- if (intent === null || theme === null) return {
3200
- fieldsByBlockId: /* @__PURE__ */ new Map(),
3201
- joins: []
3202
- };
3203
- const compiled = compileContentTemplateRuntimeFields({
3204
- intent,
3205
- resolveJoinFacts: resolveRuntimeJoinFacts,
3206
- surfaceResolutionContext: surfaceResolutionContextFromTheme(theme),
3207
- blocks: template.blocks.map((block) => {
3208
- const content = contentForBlock(block);
3209
- const storedVariant = resolveTemplateBlockLayoutVariantKey({
3210
- ...block,
3211
- content
3212
- });
3213
- const definition = systemBlockDefinitions.find((definition) => definition.manifest.name === block.blockKind);
3214
- const designInputs = blockDesignInputsForDefinition(block.blockKind, definition, content);
3215
- return {
3216
- blockId: asContentTemplateDesignBlockId(block.id),
3217
- blockKind: block.blockKind,
3218
- content,
3219
- scope: block.scope,
3220
- orderIndex: block.orderIndex,
3221
- ...designInputs,
3222
- storedVariant
3223
- };
3224
- })
3225
- });
3226
- return {
3227
- fieldsByBlockId: new Map(compiled.blocks.map((block) => [block.blockId, block.fields])),
3228
- joins: compiled.joins
3229
- };
3230
- }
3231
- function resolveTemplateBlockLayoutVariantKey(block) {
3232
- const key = toLayoutVariantKey(readLiteralBindingString(block.bindings?.variant)) ?? toLayoutVariantKey(readStringProperty(block.content, "variant"));
3233
- return key !== null ? {
3234
- kind: "explicit",
3235
- key
3236
- } : { kind: "absent" };
3237
- }
3238
- function readStringProperty(value, key) {
3239
- const property = value?.[key];
3240
- if (typeof property !== "string") return null;
3241
- const trimmed = property.trim();
3242
- return trimmed.length > 0 ? trimmed : null;
3243
- }
3244
- function readLiteralBindingString(value) {
3245
- if (!isRecord$1(value)) return null;
3246
- if (value.source !== "literal") return null;
3247
- const literal = value.value;
3248
- if (typeof literal !== "string") return null;
3249
- const trimmed = literal.trim();
3250
- return trimmed.length > 0 ? trimmed : null;
3251
- }
3252
- function toLayoutVariantKey(value) {
3253
- if (value === null || value.length === 0) return null;
3254
- try {
3255
- return asLayoutVariantKey(value);
3256
- } catch {
3257
- return null;
3258
- }
3259
- }
3260
- /** A block that renders as a diagnostic (authoring) or is omitted (public). */
3261
- function invalidRenderableBlock(block, error) {
3262
- return {
3263
- ...block,
3264
- admission: {
3265
- kind: "invalid",
3266
- error
3267
- }
3268
- };
3269
- }
3270
- /** The content contract of a registered system block, or null when unknown. */
3271
- function resolveRegisteredBlockContentContract(blockKind) {
3272
- const manifest = getBlockDefinition(blockKind)?.manifest;
3273
- return manifest !== void 0 ? registeredManifestContentContract(manifest) : null;
3274
- }
3275
- const CONTENT_ENTRY_SUBJECT_BINDING_SCHEMA = {
3276
- kind: "contentEntry",
3277
- fieldSource: "entry.content",
3278
- metaSource: "entry.meta.v1",
3279
- metaKeys: [
3280
- "id",
3281
- "title",
3282
- "slug",
3283
- "path",
3284
- "publishAt",
3285
- "status",
3286
- "createdAt",
3287
- "updatedAt",
3288
- "subject",
3289
- "offeringLabel"
3290
- ]
3291
- };
3292
- function buildContentEntryRenderableSurface({ entry, dateContext, subject, page }) {
3293
- const contentEntryId = unsafeAsContentEntryId(entry.id);
3294
- const route = buildContentEntryRouteRenderMetadata(entry, page);
3295
- const bindingContext = buildContentEntrySubjectBindingContext(entry, contentEntryId, route, dateContext, subject);
3296
- return {
3297
- kind: "contentEntry",
3298
- route,
3299
- subject: {
3300
- kind: "contentEntry",
3301
- id: contentEntryId,
3302
- entry
3303
- },
3304
- bindingSchema: CONTENT_ENTRY_SUBJECT_BINDING_SCHEMA,
3305
- bindingContext,
3306
- slotContainer: {
3307
- kind: "entrySlots",
3308
- owner: {
3309
- kind: "contentEntry",
3310
- contentEntryId
3311
- }
3312
- }
3313
- };
3314
- }
3315
- function resolveRenderableSurfaceOutlineMetadata(surface, template) {
3316
- return {
3317
- name: surface.route.outlineName ?? surface.route.title,
3318
- path: surface.route.outlinePath ?? surface.route.path ?? (surface.route.slug !== null && surface.route.slug.length > 0 ? `/${surface.route.slug}` : "/"),
3319
- purpose: surface.route.outlinePurpose ?? template.templateKey
3320
- };
3321
- }
3322
- function buildContentEntrySubjectBindingContext(entry, id, route, dateContext, subject) {
3323
- return {
3324
- dateContext,
3325
- fields: isRecord$1(entry.content) ? entry.content : {},
3326
- meta: {
3327
- ...subject === void 0 ? {} : { subject },
3328
- id,
3329
- title: route.title,
3330
- slug: route.slug,
3331
- path: route.path,
3332
- publishAt: route.publishAt,
3333
- status: route.status,
3334
- offeringLabel: offeringLabelForPageSurfaceSubject(subject),
3335
- ...entry.createdAt === void 0 ? {} : { createdAt: entry.createdAt },
3336
- ...entry.updatedAt === void 0 ? {} : { updatedAt: entry.updatedAt }
3337
- }
3338
- };
3339
- }
3340
- function buildContentEntryRouteRenderMetadata(entry, page) {
3341
- return {
3342
- title: entry.title,
3343
- slug: entry.slug,
3344
- path: entry.path,
3345
- publishAt: entry.publishAt,
3346
- status: entry.status,
3347
- outlineName: page?.name,
3348
- outlinePath: page?.path,
3349
- outlinePurpose: page?.purpose
3350
- };
3351
- }
3352
- function materializeTemplateBlockContent(input) {
3353
- const rawContent = isRecord$1(input.block.content) ? { ...input.block.content } : {};
3354
- return applyTemplateRuntimeFields(input.block.scope === "entry" && isRecord$1(input.block.bindings) ? applyBindingsToContent(rawContent, input.block.bindings, input.context) : rawContent, input.runtimeFields);
3355
- }
3356
- /**
3357
- * Admits materialized template content for rendering only.
3358
- *
3359
- * Entry-scoped blocks bind values from an entry that the loaders have already
3360
- * hydrated, so a bound media field legitimately carries `assetId`,
3361
- * `storagePath` and friends. Stored admission rejects exactly those keys as
3362
- * non-portable, which is right for persistence and wrong here: this content is
3363
- * on its way to a renderer and can never reach a writer, because the
3364
- * transported admitter returns `RenderableManifestContent` rather than granting
3365
- * a stored proof. Portability stays enforced where it belongs — write admission
3366
- * and the backup export gate, both of which see the raw stored content.
3367
- */
3368
- function admitMaterializedTemplateContent(materialized, contract) {
3369
- return admitTransportedRenderableManifestContent(contract, materialized);
3370
- }
3371
- /**
3372
- * Builds a renderable page outline from a content entry and its template.
3373
- *
3374
- * This is the single binding/runtime merge path used by both public rendering and
3375
- * dashboard preview. Template-scoped blocks render their stored content exactly;
3376
- * entry-scoped blocks render stored defaults with bound entry data layered on top.
3377
- * Theme V2 runtime fields are applied after that content decision so preview and
3378
- * public render cannot drift.
3379
- */
3380
- function buildTemplatePageOutline(input) {
3381
- const { entry, resolveEntrySlotBlocks, resolveBlockContentContract = resolveRegisteredBlockContentContract } = input;
3382
- const { template, pageSections, surface, context, runtime } = prepareTemplatePage(input);
3383
- if (!template.blocks.length) return null;
3384
- const outlineBlocks = withTitleFacts(template, pageSections, runtime.fieldsByBlockId).blocks.flatMap((block) => buildBlocksFromTemplateBlock({
3385
- block,
3386
- context,
3387
- entry,
3388
- template,
3389
- runtimeFields: runtime.fieldsByBlockId.get(block.id),
3390
- resolveEntrySlotBlocks,
3391
- resolveBlockContentContract
3392
- }));
3393
- if (!outlineBlocks.length) return null;
3394
- return {
3395
- ...resolveRenderableSurfaceOutlineMetadata(surface, template),
3396
- runtimeJoins: runtime.joins,
3397
- blocks: outlineBlocks
3398
- };
3399
- }
3400
- /** Public and editor outlines materialize the same subject bindings and design runtime. */
3401
- function prepareTemplatePage({ entry, dateContext, subject, template: sourceTemplate, pageSections: sectionContext, page, theme }) {
3402
- const pageSections = sectionContext === void 0 ? void 0 : {
3403
- ...sectionContext,
3404
- values: readStoredSectionValues(entry.content)
3405
- };
3406
- const template = expandPageSections(sourceTemplate, pageSections, theme ?? null);
3407
- const surface = buildContentEntryRenderableSurface({
3408
- entry,
3409
- page,
3410
- dateContext,
3411
- subject
3412
- });
3413
- const context = surface.bindingContext;
3414
- return {
3415
- template,
3416
- pageSections,
3417
- surface,
3418
- context,
3419
- runtime: buildContentTemplateRuntime(template, theme ?? null, (block) => materializeTemplateBlockContent({
3420
- block,
3421
- context,
3422
- runtimeFields: null
3423
- }))
3424
- };
3425
- }
3426
- function buildBlocksFromTemplateBlock({ block, context, entry, template, runtimeFields, resolveEntrySlotBlocks, resolveBlockContentContract }) {
3427
- const slotKey = readEntrySlotKey(block);
3428
- if (slotKey !== null) return resolveEntrySlotBlocks?.({
3429
- entry,
3430
- template,
3431
- templateBlock: block,
3432
- slotKey
3433
- }) ?? [];
3434
- if (isSystemTemplateBlockKind(block.blockKind)) return [];
3435
- return buildBlockFromTemplate(block, context, runtimeFields, resolveBlockContentContract(block.blockKind));
3436
- }
3437
- function readEntrySlotKey(block) {
3438
- if (block.blockKind !== "system.entry-slot" || block.scope !== "template") return null;
3439
- const parsed = parseSlotKey(block.content?.slotKey);
3440
- return parsed.ok ? parsed.value : null;
3441
- }
3442
- function buildBlockFromTemplate(block, context, runtimeFields, contract) {
3443
- const base = {
3444
- id: block.id,
3445
- kind: block.blockKind,
3446
- purpose: "content",
3447
- publishedPlacement: null,
3448
- ...isRecord$1(block.bindings) ? { bindings: block.bindings } : {}
3449
- };
3450
- if (contract === null) return [invalidRenderableBlock(base, { kind: "manifest_unavailable" })];
3451
- const materialized = materializeTemplateBlockContent({
3452
- block,
3453
- context,
3454
- runtimeFields
3455
- });
3456
- if (block.scope === "entry" && isRecord$1(block.bindings) && isEntryBoundBlockEmpty(materialized, block.bindings, contract)) return [];
3457
- const admission = admitMaterializedTemplateContent(materialized, contract);
3458
- return [admission.ok ? {
3459
- ...base,
3460
- admission: {
3461
- kind: "renderable",
3462
- content: admission.value
3463
- }
3464
- } : invalidRenderableBlock(base, {
3465
- kind: "invalid_manifest_content",
3466
- error: admission.error
3467
- })];
3468
- }
3469
- function applyTemplateRuntimeFields(content, runtimeFields) {
3470
- return applyMissingImageBackgroundFallback(canonicalizeSectionBackground(runtimeFields !== null && runtimeFields !== void 0 ? applyCompiledRuntimeFieldsToContent(content, runtimeFields) : content));
3471
- }
3472
- function canonicalizeSectionBackground(content) {
3473
- const sectionStyles = isRecord$1(content._sectionStyles) ? content._sectionStyles : null;
3474
- if (sectionStyles === null || sectionStyles.background === void 0) return content;
3475
- const background = parseBackgroundContent(sectionStyles.background);
3476
- return background !== null ? {
3477
- ...content,
3478
- _sectionStyles: {
3479
- ...sectionStyles,
3480
- background
3481
- }
3482
- } : content;
3483
- }
3484
- function applyMissingImageBackgroundFallback(content) {
3485
- const sectionStyles = isRecord$1(content._sectionStyles) ? content._sectionStyles : null;
3486
- const background = parseBackgroundContent(sectionStyles?.background);
3487
- if (sectionStyles === null || background?.type !== "image" || background.image !== null && background.image !== void 0) return content;
3488
- const fallbackColor = resolveMissingImageFallbackColor(background);
3489
- return {
3490
- ...content,
3491
- _sectionStyles: {
3492
- ...sectionStyles,
3493
- background: {
3494
- type: "color",
3495
- color: fallbackColor,
3496
- textColor: background.textColor,
3497
- headingColor: background.headingColor,
3498
- linkColor: background.linkColor,
3499
- supportingColor: background.supportingColor
3500
- }
3501
- }
3502
- };
3503
- }
3504
- function resolveMissingImageFallbackColor(background) {
3505
- const overlayColor = background.overlay?.type === "color" ? background.overlay.color?.trim() ?? null : null;
3506
- if (overlayColor !== null && overlayColor !== "") return overlayColor;
3507
- return background.textColor === "primaryForeground" ? "primary" : "surface";
3508
- }
3509
- /** Replace the anchor before runtime joins and manifest admission see the outline. */
3510
- function expandPageSections(template, input, theme) {
3511
- if (!template.blocks.some((block) => block.blockKind === "system.page-sections")) return template;
3512
- const sections = input !== void 0 ? compilePageSections(input, pageSectionLookOverrides(template.blocks)) : {
3513
- blocks: [],
3514
- lookPins: []
3515
- };
3516
- const design = parseContentTemplateDesignIntent(template.designState);
3517
- const intent = design.kind === "parsed" ? design.intent : sections.lookPins.length > 0 && theme?.siteStyleId !== void 0 ? buildInitialPolicyPageDesignIntent(theme.siteStyleId) : null;
3518
- const sectionIds = new Set(sections.blocks.map((block) => block.id));
3519
- return {
3520
- ...template,
3521
- designState: sections.lookPins.length > 0 && intent !== null ? contentTemplateDesignIntentToJsonRecord({
3522
- ...intent,
3523
- blockLookPins: [...intent.blockLookPins.filter((pin) => !sectionIds.has(pin.blockId)), ...sections.lookPins]
3524
- }) : template.designState,
3525
- blocks: template.blocks.flatMap((block) => block.blockKind === "system.page-sections" ? sections.blocks : [block]).map((block, orderIndex) => ({
3526
- ...block,
3527
- orderIndex
3528
- }))
3529
- };
3530
- }
3531
- /** The title owner is selected once, after the template's Look arrangements are known. */
3532
- function withTitleFacts(template, input, runtime) {
3533
- const facts = input !== void 0 ? projectPageFacts(input) : [];
3534
- const title = template.blocks.find((block) => isPageTitleBlock(block, runtime.get(block.id)));
3535
- if (facts.length === 0 || title === void 0) return template;
3536
- return {
3537
- ...template,
3538
- blocks: template.blocks.map((block) => block.id === title.id ? {
3539
- ...block,
3540
- content: {
3541
- ...block.content,
3542
- _pageFacts: facts
3543
- }
3544
- } : block)
3545
- };
3546
- }
3547
- function isPageTitleBlock(block, runtime) {
3548
- if (block.blockKind === "block.event-details") return runtime?._arrangementLooks?.byMode.default?.look.structure.byMode.default === "event-header";
3549
- return block.blockKind === "block.hero" && block.scope === "entry" && (isEntryTitleBinding(block.bindings?.headlineInline) || isEntryTitleBinding(block.bindings?.headline));
3550
- }
3551
- function isEntryTitleBinding(binding) {
3552
- if (!isRecord$1(binding)) return false;
3553
- return binding.source === "meta" && binding.path === "title" || binding.source === "transform" && isEntryTitleBinding(binding.input);
3554
- }
3555
- blockDesignCapabilityMapFromDefinitions(systemBlockDefinitions);
3556
- createManifestDefaultValues(siteHeaderManifest);
3557
- //#endregion
3558
- //#region src/rendering/helpers/templateContent.ts
3559
- function createTemplateRenderTarget(source, templateId) {
3560
- switch (source.kind) {
3561
- case "entry-template": return {
3562
- kind: source.kind,
3563
- templateId,
3564
- entryId: source.entryId,
3565
- entryType: source.entryType
3566
- };
3567
- case "page-surface-template": return {
3568
- kind: source.kind,
3569
- templateId,
3570
- pageSurfaceId: source.pageSurfaceId,
3571
- routeId: source.routeId,
3572
- subject: source.subject
3573
- };
3574
- }
3575
- }
3576
- function processEntryTemplate(input) {
3577
- return processTemplatePage({
3578
- ...input,
3579
- slotContent: input.entrySlots,
3580
- pageName: "Entry Template",
3581
- pagePath: input.entry.path || "/",
3582
- pagePurpose: "entry-template",
3583
- renderTargetSource: {
3584
- kind: "entry-template",
3585
- entryId: input.entry.id,
3586
- entryType: input.entry.type
3587
- }
3588
- });
3589
- }
3590
- async function processTemplatePage(input) {
3591
- const template = input.templates?.[0];
3592
- if (!template?.blocks?.length) return {
3593
- templatePage: null,
3594
- resolvedData: {}
3595
- };
3596
- const templatePage = materializeSdkTemplate(input, template);
3597
- if (templatePage === null) return {
3598
- templatePage: null,
3599
- resolvedData: {}
3600
- };
3601
- const prefetched = await resolveBlockDataWithDeps(input.deps, {
3602
- bookingTimeZone: input.bookingTimeZone,
3603
- now: input.now,
3604
- page: projectRenderablePageOutline(templatePage),
3605
- siteId: input.siteId,
3606
- renderTarget: createTemplateRenderTarget(input.renderTargetSource, template.id),
3607
- previewStage: input.previewStage,
3608
- policy: input.blockDataPolicy,
3609
- client: input.client,
3610
- customBlocks: input.customBlocks
3611
- });
3612
- return {
3613
- templatePage,
3614
- prefetchedBlockData: prefetched,
3615
- ...prefetched
3616
- };
3617
- }
3618
- /** Pure adapter: the shared renderer owns bindings, applicability, Looks and admission. */
3619
- function materializeSdkTemplate(input, template) {
3620
- return buildTemplatePageOutline({
3621
- entry: input.entry,
3622
- subject: templateCompilerSubject(input.renderTargetSource),
3623
- dateContext: resolveDateRuntimeContext(input.bookingTimeZone),
3624
- template: toContentTemplate(template),
3625
- page: {
3626
- name: template.name || input.pageName,
3627
- path: input.pagePath,
3628
- purpose: input.pagePurpose
3629
- },
3630
- theme: input.theme,
3631
- pageSections: input.pageSections,
3632
- resolveEntrySlotBlocks: ({ slotKey }) => selectBlocksForDeclaredEntrySlot({
3633
- declaredSlotKey: slotKey,
3634
- entrySlots: input.slotContent ?? []
3635
- }).map((block) => admitEntrySlotBlock(block, input.customBlocks, input.previewStage)),
3636
- resolveBlockContentContract: (kind) => {
3637
- const manifest = resolveSdkBlockManifest(kind, input.customBlocks);
3638
- return manifest === null ? null : compileManifestContentContract(manifest);
3639
- }
3640
- });
3641
- }
3642
- function templateCompilerSubject(source) {
3643
- switch (source.kind) {
3644
- case "entry-template": return;
3645
- case "page-surface-template": return source.subject;
3646
- }
3647
- }
3648
- /** Adapt the SDK transport to the shared template renderer; decisions stay there. */
3649
- function toContentTemplate(template) {
3650
- return {
3651
- id: template.id,
3652
- name: template.name,
3653
- templateKey: template.templateKey,
3654
- designState: template.designState,
3655
- blocks: template.blocks.map((block, orderIndex) => ({
3656
- ...block,
3657
- orderIndex,
3658
- content: sanitizeSdkRuntimeBlockContent(block.blockKind, block.content ?? {}),
3659
- bindings: block.bindings ?? null
3660
- }))
3661
- };
3662
- }
3663
- function admitEntrySlotBlock(block, customBlocks, previewStage) {
3664
- const base = {
3665
- id: block.id ?? block.blockId ?? null,
3666
- contentVersionId: block.contentVersionId,
3667
- ...entrySlotBlockIdentity(block, previewStage),
3668
- kind: block.kind,
3669
- purpose: block.purpose,
3670
- ...isRecord$1(block.bindings) ? { bindings: block.bindings } : {}
3671
- };
3672
- const transportedAdmission = readInvalidBlockAdmission(block.admission);
3673
- if (transportedAdmission) return invalidRenderableBlock$1(base, transportedAdmission.error);
3674
- const manifest = resolveSdkBlockManifest(block.kind, customBlocks);
3675
- if (manifest === null) return invalidRenderableBlock$1(base, { kind: "manifest_unavailable" });
3676
- const renderable = admitTransportedRenderableManifestContent(compileManifestContentContract(manifest), block.content ?? {});
3677
- return renderable.ok ? {
3678
- ...base,
3679
- admission: {
3680
- kind: "renderable",
3681
- content: renderable.value
3682
- }
3683
- } : invalidRenderableBlock$1(base, {
3684
- kind: "invalid_manifest_content",
3685
- error: renderable.error
3686
- });
3687
- }
3688
- function entrySlotBlockIdentity(block, previewStage) {
3689
- return {
3690
- draftContentId: block.draftContentId ?? null,
3691
- publishedPlacement: previewStage === "preview" ? readPublishedBlockPlacement(block.publishedContentId, isRecord$1(block.publishedContent) && isRecord$1(block.publishedContent.data) ? block.publishedContent.data : null) : null
3692
- };
3693
- }
3694
- //#endregion
3695
- //#region src/rendering/helpers/loadContent.ts
3696
- /**
3697
- * Type guard to check if result is a page
3698
- */
3699
- function isPageContent(result) {
3700
- return result.type === "page";
3701
- }
3702
- /**
3703
- * Type guard to check if result is an entry
3704
- */
3705
- function isEntryContent(result) {
3706
- return result.type === "entry";
3707
- }
3708
- function isPageSurfaceContent(result) {
3709
- return result.type === "pageSurface";
3710
- }
3711
- function isContentLoadNotFoundError(error) {
3712
- if (typeof error !== "object" || error === null || !("status" in error)) return false;
3713
- return Reflect.get(error, "status") === 404;
3714
- }
3715
- function getRejectedReason(result) {
3716
- return result.reason;
3717
- }
3718
- function toTemplateContentRenderSupport(support, siteId) {
3719
- return {
3720
- bookingOfferingPresets: support.bookingOfferingPresets,
3721
- openingHours: support.openingHours,
3722
- siteTerms: support.siteTerms,
3723
- mailingList: support.mailingList,
3724
- interactionContext: support.interactionContext,
3725
- bookingTimeZone: support.bookingTimeZone,
3726
- now: support.now,
3727
- ...support.customBlocks ? { customBlocks: support.customBlocks } : {},
3728
- entriesByIdentifier: support.entriesByIdentifier,
3729
- ...support.mediaAssets ? { mediaAssets: support.mediaAssets } : {},
3730
- pagesByIdentifier: support.pagesByIdentifier,
3731
- routeMap: support.routeMap,
3732
- sdkConfig: support.sdkConfig,
3733
- site: support.site,
3734
- siteId,
3735
- supabaseUrl: support.supabaseUrl,
3736
- theme: support.theme
3737
- };
3738
- }
3739
- /**
3740
- * Server-side helper to fetch content by path.
3741
- *
3742
- * Returns a discriminated union - either page data (ready for `<Page>` component)
3743
- * or raw entry data (for custom rendering).
3744
- *
3745
- * @example Dynamic routing with both pages and entries
3746
- * ```tsx
3747
- * import { loadContent, Page, isPageContent } from '@riverbankcms/sdk';
3748
- *
3749
- * export default async function DynamicRoute({ params }) {
3750
- * const content = await loadContent({
3751
- * client,
3752
- * siteId: 'site-123',
3753
- * path: `/${params.slug?.join('/') || ''}`,
3754
- * });
3755
- *
3756
- * if (isPageContent(content)) {
3757
- * if (!content.theme) throw new MissingSdkThemeError(content.siteId, 'cms_theme_absent');
3758
- * return <Page {...content} />;
3759
- * }
3760
- *
3761
- * // Render entry with custom UI
3762
- * return (
3763
- * <article>
3764
- * <h1>{content.entry.title}</h1>
3765
- * <div>{content.entry.content.body}</div>
3766
- * </article>
3767
- * );
3768
- * }
3769
- * ```
3770
- *
3771
- * @example Entry-specific rendering based on content type
3772
- * ```tsx
3773
- * const content = await loadContent({ client, siteId, path });
3774
- *
3775
- * if (content.type === 'entry') {
3776
- * switch (content.entry.type) {
3777
- * case 'blog-post':
3778
- * return <BlogPost entry={content.entry} theme={content.theme} />;
3779
- * case 'product':
3780
- * return <ProductPage entry={content.entry} theme={content.theme} />;
3781
- * default:
3782
- * return <GenericEntry entry={content.entry} />;
3783
- * }
3784
- * }
3785
- *
3786
- * if (!content.theme) throw new MissingSdkThemeError(content.siteId, 'cms_theme_absent');
3787
- * return <Page {...content} />;
3788
- * ```
3789
- *
3790
- * @example Preview mode for draft content
3791
- * ```tsx
3792
- * const content = await loadContent({
3793
- * client,
3794
- * siteId,
3795
- * path,
3796
- * preview: true, // Fetches draft content for both pages and entries
3797
- * });
3798
- * ```
3799
- */
3800
- async function loadContent(params) {
3801
- return loadContentWithDeps(DEFAULT_RESOLVE_BLOCK_DATA_DEPS, params);
3802
- }
3803
- async function loadContentWithDeps(deps, params) {
3804
- const { client, siteId, path, preview = false, forceSite, dataLoaderOverrides, searchParams } = params;
3805
- const [siteResult, contentResult] = await Promise.allSettled([client.getSite({
3806
- id: siteId,
3807
- currentPath: path,
3808
- ...forceSite ? { force: true } : {}
3809
- }), client.getPage({
3810
- siteId,
3811
- path,
3812
- preview
3813
- })]);
3814
- if (siteResult.status === "rejected" || contentResult.status === "rejected") {
3815
- const failures = [siteResult, contentResult].filter((result) => result.status === "rejected").map(getRejectedReason);
3816
- throw failures.find((error) => !isContentLoadNotFoundError(error)) ?? failures[0];
3817
- }
3818
- const site = siteResult.value;
3819
- const contentResponse = contentResult.value;
3820
- return loadContentFromContentResponseWithDeps(deps, {
3821
- client,
3822
- siteId,
3823
- site,
3824
- contentResponse,
3825
- preview,
3826
- dataLoaderOverrides,
3827
- searchParams
3828
- });
3829
- }
3830
- async function loadContentFromContentResponseWithDeps(deps, params) {
3831
- const { client, siteId, site, contentResponse, preview = false, dataLoaderOverrides, searchParams } = params;
3832
- const previewStage = preview ? "preview" : "published";
3833
- const blockDataPolicy = createBlockDataLoadPolicy(dataLoaderOverrides, normalizeDataLoaderSearchParams(searchParams));
3834
- const support = buildSiteRenderSupport(site, collectMediaAssetSidecar(contentResponse.mediaAssets));
3835
- const templateContentSupport = toTemplateContentRenderSupport(support, siteId);
3836
- if (isEntryResponse(contentResponse)) {
3837
- const entryData = contentResponse.entry;
3838
- const draftContent = entryData.draftContent;
3839
- const hasDraftContent = draftContent && Object.keys(draftContent).length > 0;
3840
- const entry = {
3841
- id: entryData.id,
3842
- type: entryData.type,
3843
- title: entryData.title,
3844
- slug: entryData.slug,
3845
- path: entryData.path,
3846
- status: entryData.status,
3847
- publishAt: entryData.publishAt,
3848
- lastPublishedAt: entryData.lastPublishedAt,
3849
- content: preview && hasDraftContent ? draftContent : entryData.content,
3850
- metaTitle: preview ? entryData.draftMetaTitle ?? entryData.metaTitle : entryData.metaTitle,
3851
- metaDescription: preview ? entryData.draftMetaDescription ?? entryData.metaDescription : entryData.metaDescription,
3852
- createdAt: entryData.createdAt,
3853
- updatedAt: entryData.updatedAt
3854
- };
3855
- const { templatePage, resolvedData, prefetchedBlockData, loaderSnapshot, loaderFailures } = await processEntryTemplate({
3856
- theme: support.theme,
3857
- bookingTimeZone: support.bookingTimeZone,
3858
- now: support.now,
3859
- templates: contentResponse.templates,
3860
- entrySlots: contentResponse.entrySlots,
3861
- entry,
3862
- siteId,
3863
- previewStage,
3864
- blockDataPolicy,
3865
- client,
3866
- deps,
3867
- customBlocks: support.customBlocks
3868
- });
3869
- return {
3870
- type: "entry",
3871
- entry,
3872
- templatePage,
3873
- resolvedData,
3874
- dataContext: {
3875
- ...siteBlockRenderContext(support),
3876
- previewStage,
3877
- prefetchedBlockData,
3878
- loaderSnapshot,
3879
- loaderFailures,
3880
- contentEntry: {
3881
- ...entry.content ?? {},
3882
- id: entry.id,
3883
- slug: entry.slug,
3884
- contentTypeSlug: entry.type,
3885
- _entryId: entry.id,
3886
- _entrySlug: entry.slug,
3887
- _contentTypeSlug: entry.type
3888
- }
3889
- },
3890
- ...templateContentSupport
3891
- };
3892
- }
3893
- if (isPageSurfaceResponse(contentResponse)) {
3894
- const pageSurfaceData = contentResponse.pageSurface;
3895
- const pageSurface = {
3896
- id: pageSurfaceData.id,
3897
- routeId: pageSurfaceData.routeId,
3898
- readinessState: pageSurfaceData.readinessState,
3899
- subject: pageSurfaceData.subject,
3900
- title: pageSurfaceData.title,
3901
- slug: pageSurfaceData.slug,
3902
- path: pageSurfaceData.path,
3903
- status: pageSurfaceData.status,
3904
- publishAt: pageSurfaceData.publishAt,
3905
- lastPublishedAt: pageSurfaceData.lastPublishedAt,
3906
- content: pageSurfaceData.content,
3907
- metaTitle: preview ? pageSurfaceData.draftMetaTitle ?? pageSurfaceData.metaTitle : pageSurfaceData.metaTitle,
3908
- metaDescription: preview ? pageSurfaceData.draftMetaDescription ?? pageSurfaceData.metaDescription : pageSurfaceData.metaDescription,
3909
- createdAt: pageSurfaceData.createdAt,
3910
- updatedAt: pageSurfaceData.updatedAt,
3911
- contentSource: pageSurfaceData.contentSource
3912
- };
3913
- const { templatePage, resolvedData, prefetchedBlockData, loaderSnapshot, loaderFailures } = await processTemplatePage({
3914
- entry: pageSurface,
3915
- theme: support.theme,
3916
- pageSections: contentResponse.pageSections,
3917
- bookingTimeZone: support.bookingTimeZone,
3918
- now: support.now,
3919
- templates: contentResponse.templates,
3920
- slotContent: contentResponse.surfaceSlots,
3921
- pageName: pageSurface.title || "Page Surface Template",
3922
- pagePath: pageSurface.path || "/",
3923
- pagePurpose: "page-surface-template",
3924
- siteId,
3925
- previewStage,
3926
- blockDataPolicy,
3927
- renderTargetSource: {
3928
- kind: "page-surface-template",
3929
- pageSurfaceId: pageSurface.id,
3930
- routeId: pageSurface.routeId,
3931
- subject: pageSurface.subject
3932
- },
3933
- client,
3934
- deps,
3935
- customBlocks: support.customBlocks
3936
- });
3937
- return {
3938
- type: "pageSurface",
3939
- pageSurface,
3940
- templatePage,
3941
- resolvedData,
3942
- dataContext: {
3943
- ...siteBlockRenderContext(support),
3944
- previewStage,
3945
- prefetchedBlockData,
3946
- loaderSnapshot,
3947
- loaderFailures,
3948
- pageSurface: {
3949
- ...pageSurface.content ?? {},
3950
- id: pageSurface.id,
3951
- slug: pageSurface.slug,
3952
- subject: pageSurface.subject,
3953
- _pageSurfaceId: pageSurface.id,
3954
- _pageSurfaceSlug: pageSurface.slug
3955
- },
3956
- subject: pageSurface.subject
3957
- },
3958
- ...templateContentSupport
3959
- };
3960
- }
3961
- const { page: pageData } = contentResponse;
3962
- const pageRecord = pageData;
3963
- const canonicalPagePath = pageData.path ?? pageRecord.path ?? "/";
3964
- const pageOutline = buildRenderablePageOutline({
3965
- name: pageData.name,
3966
- path: canonicalPagePath,
3967
- fallbackPath: "/",
3968
- purpose: pageData.purpose,
3969
- blocks: pageData.blocks,
3970
- previewStage,
3971
- customBlocks: support.customBlocks
3972
- });
3973
- const prefetched = await resolveBlockDataWithDeps(deps, {
3974
- bookingTimeZone: support.bookingTimeZone,
3975
- now: support.now,
3976
- page: projectRenderablePageOutline(pageOutline),
3977
- siteId,
3978
- renderTarget: {
3979
- kind: "page",
3980
- pageId: pageData.id
3981
- },
3982
- previewStage,
3983
- policy: blockDataPolicy,
3984
- client,
3985
- customBlocks: support.customBlocks
3986
- });
3987
- return {
3988
- type: "page",
3989
- pageId: pageRecord.id,
3990
- routeId: pageRecord.routeId ?? null,
3991
- pageMetadata: projectPagePreviewMetadata(pageRecord, pageData.name, canonicalPagePath),
3992
- page: pageOutline,
3993
- runtimeJoins: pageData.runtimeJoins,
3994
- theme: support.theme,
3995
- siteId,
3996
- ...support.customBlocks ? { customBlocks: support.customBlocks } : {},
3997
- resolvedData: prefetched.resolvedData,
3998
- dataContext: {
3999
- previewStage,
4000
- ...siteBlockRenderContext(support),
4001
- prefetchedBlockData: prefetched,
4002
- loaderSnapshot: prefetched.loaderSnapshot,
4003
- loaderFailures: prefetched.loaderFailures
4004
- },
4005
- bookingOfferingPresets: support.bookingOfferingPresets,
4006
- openingHours: support.openingHours,
4007
- siteTerms: support.siteTerms,
4008
- mailingList: support.mailingList,
4009
- interactionContext: support.interactionContext,
4010
- bookingTimeZone: support.bookingTimeZone,
4011
- now: support.now,
4012
- site: support.site,
4013
- sdkConfig: support.sdkConfig,
4014
- supabaseUrl: support.supabaseUrl,
4015
- routeMap: support.routeMap,
4016
- pagesByIdentifier: support.pagesByIdentifier,
4017
- entriesByIdentifier: support.entriesByIdentifier,
4018
- ...support.mediaAssets ? { mediaAssets: support.mediaAssets } : {}
4019
- };
4020
- }
4021
- function projectPagePreviewMetadata(page, pageName, canonicalPath) {
4022
- return {
4023
- ...projectDraftPageMetadata(page, pageName, canonicalPath),
4024
- ...projectPublishedPageMetadata(page, pageName, canonicalPath)
4025
- };
4026
- }
4027
- function projectDraftPageMetadata(page, pageName, canonicalPath) {
4028
- return {
4029
- draftTitle: page.draftTitle ?? page.name ?? pageName,
4030
- draftPath: page.draftPath ?? page.path ?? canonicalPath,
4031
- draftStatus: page.draftStatus ?? page.status ?? "draft",
4032
- draftMetaTitle: page.draftMetaTitle ?? null,
4033
- draftMetaDescription: page.draftMetaDescription ?? null
4034
- };
4035
- }
4036
- function projectPublishedPageMetadata(page, pageName, canonicalPath) {
4037
- return {
4038
- title: page.name ?? pageName,
4039
- path: canonicalPath,
4040
- status: page.status ?? page.draftStatus ?? "draft",
4041
- publishedAt: page.publishedAt ?? null,
4042
- lastPublishedAt: page.lastPublishedAt ?? null,
4043
- publishedMetaTitle: page.publishedMetaTitle ?? null,
4044
- publishedMetaDescription: page.publishedMetaDescription ?? null,
4045
- ogImageId: page.ogImageId ?? null
4046
- };
4047
- }
4048
- /**
4049
- * Type guard to check if API response is an entry
4050
- */
4051
- function isEntryResponse(response) {
4052
- return "entry" in response;
4053
- }
4054
- function isPageSurfaceResponse(response) {
4055
- return response.type === "pageSurface";
4056
- }
4057
1244
  //#endregion
4058
1245
  //#region src/contracts/rendering.ts
4059
1246
  const ImagePresets = {
@@ -4150,4 +1337,4 @@ function projectRepeaterGridLayoutForRendering(layout, columns = layout.columns)
4150
1337
  return projectRepeaterGridLayoutForRendering$1(layout, columns);
4151
1338
  }
4152
1339
  //#endregion
4153
- export { Block, EditorPageRenderer, ImagePresets, Layout, MISSING_SDK_THEME_ERROR_CODE, MissingBlockOverrideError, MissingSdkThemeError, Page, PageRenderer, RichText, ThemeScope, UnsupportedOverrideOnlyLayoutChromeError, buildFooterRenderablePageOutline, buildRenderableMediaAssetIndex, buildRepeaterGridLayoutForRendering, buildThemeRuntime, defineBlockOverrideRegistrations, defineBlockOverrides, defineLazyBlockOverride, isEntryContent, isPageContent, isPageSurfaceContent, loadContent, loadPage, mediaIdentifierSchema, mediaSchema, parseCanonicalMediaIdentifier, parseMediaIdentifier, persistableMediaSchema, projectRepeaterGridLayout, projectRepeaterGridLayoutForRendering, renderableMediaAssetSchema, resolveImageRenderProps, resolveImageSourceSetWithContext, resolveImageUrl, resolveImageUrlWithContext, resolveLinkHref, resolveManagedMediaReference, runtimeMediaSchema, toBlocksImageResolveContextInput, toBlocksMediaAssets, toBlocksPageRendererDataContext };
1340
+ export { BOOKING_PAGE_BLOCK_IDS, Block, EditorPageRenderer, ImagePresets, Layout, MISSING_SDK_THEME_ERROR_CODE, MissingBlockOverrideError, MissingSdkThemeError, Page, PageRenderer, RichText, SERVICE_BOOKING_BLOCK_IDS, ThemeScope, UnsupportedOverrideOnlyLayoutChromeError, bookingDescription, bookingDetailEvents, bookingHero, bookingPageDesign, bookingPageFacts, bookingPageIdentity, bookingPageSeedData, bookingSectionBlocks, buildBookingPageOutline, buildCodeOwnedPageBlocks, buildFooterRenderablePageOutline, buildRenderableMediaAssetIndex, buildRepeaterGridLayoutForRendering, buildServiceBookingOutline, buildThemeRuntime, createPublicBlockContentContractResolver, defineBlockOverrideRegistrations, defineBlockOverrides, defineLazyBlockOverride, isEntryContent, isPageContent, isPageSurfaceContent, loadContent, loadPage, mediaIdentifierSchema, mediaSchema, parseCanonicalMediaIdentifier, parseMediaIdentifier, parseServicePageContent, persistableMediaSchema, plainTextDoc, projectRepeaterGridLayout, projectRepeaterGridLayoutForRendering, renderableMediaAssetSchema, resolveImageRenderProps, resolveImageSourceSetWithContext, resolveImageUrl, resolveImageUrlWithContext, resolveLinkHref, resolveManagedMediaReference, runtimeMediaSchema, toBlocksImageResolveContextInput, toBlocksMediaAssets, toBlocksPageRendererDataContext };