@riverbankcms/sdk 0.165.0 → 0.167.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 (246) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +5 -0
  3. package/dist/_dts/{BlocksIslandsHydrator-CdsSMQEv.d.ts → BlocksIslandsHydrator-Dgb-ptph.d.ts} +1 -1
  4. package/dist/_dts/{Page-D6gp2Ipb.d.ts → Page-Bs3WxFgr.d.ts} +20 -258
  5. package/dist/_dts/{SdkPreviewMode-DNXAvnet.d.ts → SdkPreviewMode-DtUCsaHY.d.ts} +26 -3
  6. package/dist/_dts/{client-BkkExozE.d.ts → client-CwsI23pj.d.ts} +13 -1
  7. package/dist/_dts/{content-types-CXNAD7ef.d.ts → content-types-CAeP_-cV.d.ts} +3 -3
  8. package/dist/_dts/{contracts-XRXhbLWP.d.ts → contracts-BXHCiF-b.d.ts} +8 -5
  9. package/dist/_dts/{footerPageOutline-BP2bJYdY.d.ts → footerPageOutline-Bb2gbppW.d.ts} +6 -6
  10. package/dist/_dts/{generatePageMetadata-DcMtbztV.d.ts → generatePageMetadata-DaBBDx7M.d.ts} +2 -2
  11. package/dist/_dts/{index-DKNEgSOS.d.ts → index-5_jf52sZ.d.ts} +2 -2
  12. package/dist/_dts/{index-CQfJhOEA.d.ts → index-C20yUyob.d.ts} +1 -1
  13. package/dist/_dts/{index-CRRiddNp.d.ts → index-CS6b1B-c.d.ts} +4 -4
  14. package/dist/_dts/{index-B4ozSzFP.d.ts → index-ChpjHK0U.d.ts} +9737 -8316
  15. package/dist/_dts/{index-BdkHhyf8.d.ts → index-D7EbliE3.d.ts} +1 -1
  16. package/dist/_dts/{index-RXkE3a7M.d.ts → index-DeHDwMfu.d.ts} +4 -3
  17. package/dist/_dts/{index-DAPTSmBM.d.ts → index-RugyUnqR.d.ts} +2499 -2218
  18. package/dist/_dts/{index-C_3kdrUb.d.ts → index-bDln38Hm.d.ts} +2 -2
  19. package/dist/_dts/{loadContent-B9vJMq3s.d.ts → loadContent-CTqcL7CS.d.ts} +9 -6
  20. package/dist/_dts/resolveBlockData-C3s9WMPs.d.ts +136 -0
  21. package/dist/_dts/{resolvePageContent-DIQyYUi-.d.ts → resolvePageContent-JPwgRxwh.d.ts} +3 -2
  22. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  23. package/dist/_dts/sdk/src/client/types.d.ts +2 -2
  24. package/dist/_dts/sdk/src/client.d.ts +9 -6
  25. package/dist/_dts/sdk/src/config/index.d.ts +6 -6
  26. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  27. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  28. package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +20 -0
  29. package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +2 -0
  30. package/dist/_dts/sdk/src/data/types.d.ts +54 -0
  31. package/dist/_dts/sdk/src/index.d.ts +8 -8
  32. package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
  33. package/dist/_dts/sdk/src/metadata/index.d.ts +6 -1
  34. package/dist/_dts/sdk/src/navigation/index.d.ts +2 -2
  35. package/dist/_dts/sdk/src/next/index.d.ts +9 -8
  36. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  37. package/dist/_dts/sdk/src/page-converter/index.d.ts +36 -48
  38. package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
  39. package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
  40. package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
  41. package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
  42. package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
  43. package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
  44. package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +2 -0
  45. package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +3 -0
  46. package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +260 -0
  47. package/dist/_dts/sdk/src/rendering/index.d.ts +8 -7
  48. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  49. package/dist/_dts/sdk/src/rendering/server.d.ts +3 -3
  50. package/dist/_dts/{themeAdmission-D_qtGYAT.d.ts → sdk/src/rendering/themeAdmission.d.ts} +3 -1
  51. package/dist/_dts/sdk/src/routing/index.d.ts +5 -5
  52. package/dist/_dts/sdk/src/server.d.ts +7 -5
  53. package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
  54. package/dist/_dts/sdk/src/theme/index.d.ts +1 -1
  55. package/dist/_dts/{types-BDF73NzM.d.ts → types-BlaCuPLr.d.ts} +2 -2
  56. package/dist/_dts/{types-Cl0nP6al.d.ts → types-CwtTcaQP.d.ts} +3 -3
  57. package/dist/_dts/{types-mstFvhK4.d.ts → types-D-WElMCy.d.ts} +8 -7
  58. package/dist/_dts/{validation-DVWqSvjK.d.ts → validation-Y5wD9fGK.d.ts} +4 -4
  59. package/dist/client/{BlocksIslandsHydrator-CzKpH9Pm.mjs → BlocksIslandsHydrator-DFqkx158.mjs} +31 -24
  60. package/dist/client/{BookingMailingListNote-rUqsBN7L.mjs → BookingMailingListNote-CCVXX1LN.mjs} +2 -2
  61. package/dist/client/{CalendarNavigationChevron-YGzw2IPB.mjs → CalendarNavigationChevron-DQwJ7BPx.mjs} +167 -18
  62. package/dist/client/{CheckboxChoice-DlTC4J2a.mjs → CheckboxChoice-CZ-anOqV.mjs} +1 -1
  63. package/dist/client/{DemoBookingPortalAccess-D2LyS_Bi.mjs → DemoBookingPortalAccess-DdkY86qI.mjs} +6 -6
  64. package/dist/client/{DemoPortalSignInLink-BaFg2Uit.mjs → DemoPortalSignInLink-B9YrzZt2.mjs} +1 -1
  65. package/dist/client/{EventCalendar.client-tRrhPscX.mjs → EventCalendar.client-DAeQPV76.mjs} +11 -30
  66. package/dist/client/{EventCombined.client-6cfAVtnZ.mjs → EventCombined.client-Bus9R0bj.mjs} +137 -61
  67. package/dist/client/{EventEmbeddedCheckoutStep-CDNUpI0S.mjs → EventEmbeddedCheckoutStep-D_14yqAU.mjs} +27 -2
  68. package/dist/client/{EventItem-dILw2PN_.mjs → EventItem-DPBLjGwj.mjs} +75 -13
  69. package/dist/client/{EventListWeekNavigation-ClgLtjNY.mjs → EventListWeekNavigation-D6cwU82_.mjs} +1 -1
  70. package/dist/client/{EventListing.client-BNueAHmU.mjs → EventListing.client-Bogi_SnJ.mjs} +3 -3
  71. package/dist/client/{EventListing.view-DtVbKVkt.mjs → EventListing.view-CEumpN7i.mjs} +35 -51
  72. package/dist/client/{EventRegistrationPayment-CzkG0NSJ.mjs → EventRegistrationPayment-CIQw6vNy.mjs} +113 -11
  73. package/dist/client/{LocationMapActions-zWQsJhE5.mjs → LocationMapActions-BVO-qx4q.mjs} +2 -2
  74. package/dist/client/{MapDrawingSvg-D1AO_o4h.mjs → MapDrawingSvg-CcGaFawl.mjs} +22 -2
  75. package/dist/client/{Page-DUr2YhFR.mjs → Page-D4_H_u9V.mjs} +23892 -32266
  76. package/dist/client/{ProtectedSubmitButton-2fJqT_NR.mjs → ProtectedSubmitButton-8DuDw2ag.mjs} +1 -1
  77. package/dist/client/{StepIndicator-udNHcpOT.mjs → StepIndicator-Dptantmg.mjs} +3 -3
  78. package/dist/client/{TabBarFragment-C_kt-PXh.mjs → TabBarFragment-BxEGsKUx.mjs} +19 -19
  79. package/dist/client/{ThemedButton-Cfbo1bfh.mjs → ThemedButton-8jUc02mZ.mjs} +64 -2
  80. package/dist/client/{accordion-3CYNWzTS.mjs → accordion--EUHmEGa.mjs} +1 -1
  81. package/dist/client/{booking-form.client-BSbWgLyx.mjs → booking-form.client-BCXwOnhc.mjs} +19 -14
  82. package/dist/client/{bookingForm-2MoFBWSt.mjs → bookingForm-sHHcdism.mjs} +4 -4
  83. package/dist/client/bookings.mjs +6 -6
  84. package/dist/client/{carousel-Cu5mcpO-.mjs → carousel-Cp9xPBFZ.mjs} +2 -2
  85. package/dist/client/{carousel.client-CQLV8_Al.mjs → carousel.client-BO7sCEpH.mjs} +1 -1
  86. package/dist/client/{cart-CDc6x9cR.mjs → cart-CCZZC-Lq.mjs} +3 -3
  87. package/dist/client/{cart.client-BWS2r5Ef.mjs → cart.client-B7JfA19I.mjs} +1 -1
  88. package/dist/client/{checkout-CkxPqSwD.mjs → checkout-CipmYL4A.mjs} +3 -3
  89. package/dist/client/{checkout.client-DJfomKQc.mjs → checkout.client-DraalWdH.mjs} +1 -1
  90. package/dist/client/client.mjs +9550 -17
  91. package/dist/client/{context-CBV21-9L.mjs → context-Cv3QHjAF.mjs} +11 -6
  92. package/dist/client/{cta-Bw-al3cs.mjs → cta-P2vJVTEn.mjs} +45 -28
  93. package/dist/client/{dateFormatting-CFIUJ4Uf.mjs → dateFormatting-D8D47VT4.mjs} +1 -1
  94. package/dist/client/{demoPortalMagicLink-D0veHJyi.mjs → demoPortalMagicLink-CXWZoV-d.mjs} +1 -1
  95. package/dist/client/{enhanceHeaderSection-CEqqq92r.mjs → enhanceHeaderSection-BkAro1DJ.mjs} +4 -4
  96. package/dist/client/{event-details.client-Bk2kQ7ax.mjs → event-details.client-dLmyuPap.mjs} +2 -2
  97. package/dist/client/{event-registration.client-QMqtIywj.mjs → event-registration.client-BEhC2_-Y.mjs} +34 -20
  98. package/dist/client/{eventCalendar-BTDTMosr.mjs → eventCalendar-FBMS2Cpb.mjs} +4 -4
  99. package/dist/client/{eventCombined-BC7a709c.mjs → eventCombined-BrBhUvGe.mjs} +4 -4
  100. package/dist/client/{eventDetails-DL08GpUc.mjs → eventDetails-C7WUrbZ2.mjs} +2 -2
  101. package/dist/client/{eventListing-BfzuEQp_.mjs → eventListing-Bih-BgQM.mjs} +4 -4
  102. package/dist/client/{eventRegistration-Lfyzh1Ab.mjs → eventRegistration-DfTlqGbl.mjs} +4 -4
  103. package/dist/client/{form-L-xZOBUS.mjs → form-Bw1uuiUs.mjs} +3 -3
  104. package/dist/client/{form.client-BtpK3TZW.mjs → form.client-pZ-9gN33.mjs} +5 -5
  105. package/dist/client/{form.parts-Djos5Un4.mjs → form.parts-PXlu6XQO.mjs} +3 -3
  106. package/dist/client/{formatDate-DGmrm7YB.mjs → formatDate-DI3DP48e.mjs} +1 -1
  107. package/dist/client/gifting/client.mjs +3 -4
  108. package/dist/client/{headerSection-f16OGkz-.mjs → headerSection-BpJYUMd6.mjs} +2 -2
  109. package/dist/client/{mediaAssets-DHAmrVIi.mjs → mediaAssets-DpPauppt.mjs} +1 -1
  110. package/dist/client/{mediaContext-CwT6ZOm7.mjs → mediaContext-BLo4NtjP.mjs} +25 -19
  111. package/dist/client/{newsletter-form.client-DpHNZc7k.mjs → newsletter-form.client-CSoP0cGR.mjs} +6 -6
  112. package/dist/client/{newsletter-form.parts-CLGH20PL.mjs → newsletter-form.parts-DDbX_Sj0.mjs} +2 -2
  113. package/dist/client/{newsletterForm-BEU0Ocu9.mjs → newsletterForm-vCxYRar_.mjs} +3 -3
  114. package/dist/client/{noop-CQU7tiMg.mjs → noop-ByVtIWf4.mjs} +420 -170
  115. package/dist/client/portal/client.mjs +13 -14
  116. package/dist/client/{product-detail.client-Be-om1BT.mjs → product-detail.client-7Pi6avM-.mjs} +1 -1
  117. package/dist/client/{product-list.client-DR7hD5Vs.mjs → product-list.client-DEad-Pma.mjs} +1 -1
  118. package/dist/client/{productDetail-BD42UOmG.mjs → productDetail-G1SMXG13.mjs} +3 -3
  119. package/dist/client/{productList-CSk8sXCl.mjs → productList-B21TGdpT.mjs} +3 -3
  120. package/dist/client/{propsDecoder-C_Y6VYnF.mjs → propsDecoder-B3vIBkex.mjs} +4 -5
  121. package/dist/client/{registry.server-CIKtTsCl.mjs → registry.server-B8aQhJpO.mjs} +399 -473
  122. package/dist/client/rendering/client.mjs +29 -28
  123. package/dist/client/rendering/islands.mjs +1 -1
  124. package/dist/client/rendering.mjs +70 -8
  125. package/dist/client/{richText-coerce-spWtx86G.mjs → richText-coerce-DHkBtO0G.mjs} +1 -1
  126. package/dist/client/{routeIslandApiConfig-CROHPlYS.mjs → routeIslandApiConfig-DbHX4JOS.mjs} +1 -1
  127. package/dist/client/{shop-commerce-CDUohm_2.mjs → shop-commerce-B2UmrQg_.mjs} +12 -12
  128. package/dist/client/{shop-commerce-store-B9nw4lRP.mjs → shop-commerce-store-B7n-Z7nY.mjs} +1 -1
  129. package/dist/client/{shop-DscvMz86.mjs → shop-mqyoOvOK.mjs} +3 -3
  130. package/dist/client/{shop.client-M3kNsVPi.mjs → shop.client-BH-BBnA9.mjs} +13 -13
  131. package/dist/client/{shop.interactive-BGmkdIAZ.mjs → shop.interactive-mdM3UMWG.mjs} +74 -36
  132. package/dist/client/{shopShared-BdWp6LHa.mjs → shopShared-CXF5wxdg.mjs} +2 -2
  133. package/dist/client/site-styles-CMCUxsIM.mjs +3 -0
  134. package/dist/{preview-next/client/ThemedButton-Dc6aJ34Z.mjs → client/site-styles-D56hT2u1.mjs} +26000 -16565
  135. package/dist/client/spam-protection.mjs +1 -1
  136. package/dist/client/src-DjnxOjXG.mjs +217 -0
  137. package/dist/client/surfaceTransportMarker-BXepAVF6.mjs +152 -0
  138. package/dist/client/{timetableModel-Dynh5-j4.mjs → timetableModel-CrC80EOG.mjs} +13 -140
  139. package/dist/client/types-sF-IrGQr.mjs +633 -0
  140. package/dist/client/{useAvailableSlots-Cw9paRPY.mjs → useAvailableSlots-C4LOaI_Z.mjs} +8 -5
  141. package/dist/client/{useBookingNowIso-C9SF2rC6.mjs → useBookingNowIso-BDmWkYUW.mjs} +1 -1
  142. package/dist/client/{useDiscountApply-B-QJfBg0.mjs → useDiscountApply-6Q0nToVA.mjs} +3 -3
  143. package/dist/client/{useDiscountCodeUi-Uvum8q9d.mjs → useDiscountCodeUi-CM-DTX5X.mjs} +1 -1
  144. package/dist/client/{useEventPagination-BfM3xk6j.mjs → useEventPagination-Bcs89BR5.mjs} +9 -9
  145. package/dist/client/{view-DlkCDfuN.mjs → view-BN-fxyfq.mjs} +287 -232
  146. package/dist/client/{view-DXOuduIr.mjs → view-Dh2tGoS0.mjs} +4 -4
  147. package/dist/client/{wizardSteps-DManVJpc.mjs → wizardSteps-DtkhwKXK.mjs} +468 -149
  148. package/dist/preview-next/before-render.mjs +3 -140
  149. package/dist/preview-next/client/ArrangementLookControls-D4VjPs-r.mjs +31197 -0
  150. package/dist/preview-next/client/{EventEmbeddedCheckoutStep-Die6Y25O.mjs → EventEmbeddedCheckoutStep-C_h1cMYm.mjs} +33 -4
  151. package/dist/preview-next/client/{LocationPickerEnvironment-Bp4BHLCL.mjs → LocationPickerEnvironment-D56RD3e_.mjs} +1 -1
  152. package/dist/preview-next/client/{MapLibreEditMap-Cb0JhM9p.mjs → MapLibreEditMap-DFnyCckr.mjs} +2 -2
  153. package/dist/preview-next/client/PreviewEditorSidebar-Ckr2zk_L.mjs +37247 -0
  154. package/dist/preview-next/client/{PreviewEditorUI-CxwlLBGw.mjs → PreviewEditorUI-KOZgw_gS.mjs} +45 -17
  155. package/dist/preview-next/client/PreviewShell-CyO2V4kB.mjs +4757 -0
  156. package/dist/preview-next/client/SdkPreviewModeRuntime-DW3uKvNF.mjs +4258 -0
  157. package/dist/preview-next/client/SiteChromeCustomizeButton-CU9VD-7O.mjs +72202 -0
  158. package/dist/preview-next/client/ThemedButton-C0dgGJ5k.mjs +2006 -0
  159. package/dist/preview-next/client/{lucide-react-CqxuVAyz.mjs → lucide-react-CPBCf6QT.mjs} +15 -2
  160. package/dist/preview-next/client/previewAssistantSlot-DBi-WybM.mjs +112193 -0
  161. package/dist/preview-next/client/{previewChromeSurface-yuwnDP3B.mjs → previewChromeSurface-BhkUJst9.mjs} +90 -28
  162. package/dist/preview-next/client/runtime.mjs +3 -3
  163. package/dist/preview-next/client/sdk-runtime-BjCb6lOn.mjs +5 -0
  164. package/dist/preview-next/client/{editorStatusDecision-DR4BBKhy.mjs → useAutosaveStatus-CKxTaC3j.mjs} +40 -3
  165. package/dist/preview-next/client/useBlockCustomizeControls-B7MLTjBX.mjs +2633 -0
  166. package/dist/preview-next/client/useOpenBlockForSetup-BTUc0g9X.mjs +28 -0
  167. package/dist/preview-next/keepAlive.mjs +25 -2
  168. package/dist/preview-next/middleware.mjs +1 -1
  169. package/dist/preview-next/{route-contract-BBAJjFIz.mjs → route-contract-Bv3nkdpV.mjs} +215 -118
  170. package/dist/server/{Block.shared-ClFI3qpX.mjs → Block.shared-4fMqzltx.mjs} +7 -4
  171. package/dist/server/{src-DsYPhTbs.mjs → ThemeScopeCore-C72VC_lR.mjs} +894 -2556
  172. package/dist/server/accessibleSurfaces-B_Y_dA20.mjs +2305 -0
  173. package/dist/server/{bindings-Bi8EoRZD.mjs → bindings-ConMYJ2U.mjs} +2 -3
  174. package/dist/server/{publicProducts-Bz8loTRn.mjs → client-Cot-H5fQ.mjs} +2558 -343
  175. package/dist/server/config-validation.mjs +1 -1
  176. package/dist/server/config.mjs +33 -2
  177. package/dist/server/data/dataLoaderContext.mjs +2 -0
  178. package/dist/server/data/resolveBlockData.mjs +2 -0
  179. package/dist/server/data/types.mjs +1 -0
  180. package/dist/server/dataLoaderContext-B3fXA54R.mjs +47 -0
  181. package/dist/server/identity-Bn9OQiT1.mjs +6 -0
  182. package/dist/server/index.mjs +3 -3
  183. package/dist/server/{loadContent-dEEhQxL7.mjs → loadContent-BkaWYEwt.mjs} +6 -5
  184. package/dist/server/{loadPage-DBFBad8A.mjs → loadPage-kviUdH8c.mjs} +4 -2
  185. package/dist/server/manifest.mjs +1 -1
  186. package/dist/server/media-DnlczCMA.mjs +231 -0
  187. package/dist/server/metadata.mjs +5 -1
  188. package/dist/server/mode-Cv_TG9gP.mjs +63 -0
  189. package/dist/server/next/revalidate.mjs +9 -4
  190. package/dist/server/next.mjs +11 -11
  191. package/dist/server/opaqueSurface-BTnS09GS.mjs +54 -0
  192. package/dist/server/{overrideResolution-BIJbiXYc.mjs → overrideResolution-itXZCXs7.mjs} +2 -1
  193. package/dist/server/overrides-CD4d-1w7.mjs +177 -0
  194. package/dist/server/page-converter.mjs +243 -91
  195. package/dist/server/pageRenderPlan-CDyn7iLy.mjs +4162 -0
  196. package/dist/server/{themeAdmission-CSknYpxk.mjs → pageRuntimeSupport-DZ6cLxrM.mjs} +13 -28
  197. package/dist/server/{overrides-DhF87Vsd.mjs → pageShared-Q_Vij87H.mjs} +3808 -1928
  198. package/dist/server/parseThemeForPersistence-CDrF51tJ.mjs +52 -0
  199. package/dist/server/{prebuild-DaemmWQL.mjs → prebuild-DOG4MkOy.mjs} +1 -1
  200. package/dist/server/prebuild.mjs +1 -1
  201. package/dist/server/prefetchBlockData-DlprLLsc.mjs +756 -0
  202. package/dist/server/{registry-Cdvz1OtL.mjs → registry-BPFcpn6k.mjs} +21838 -709
  203. package/dist/server/rendering/components/pageShared.mjs +2 -0
  204. package/dist/server/rendering/helpers/loadPage.mjs +2 -0
  205. package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +2 -0
  206. package/dist/server/rendering/server.mjs +5 -4
  207. package/dist/server/rendering/themeAdmission.mjs +2 -0
  208. package/dist/server/rendering.mjs +11 -10
  209. package/dist/server/repeaterFields-MIz7r1ez.mjs +9 -0
  210. package/dist/server/{resolveBlockData-CLpAJWWf.mjs → resolveBlockData-BHvfGD4y.mjs} +6 -48
  211. package/dist/server/resolveButtonColourStates-OXFRGn5M.mjs +2682 -0
  212. package/dist/server/responseMedia-D8J3VAFs.mjs +115 -0
  213. package/dist/server/{richTextSchema-YYc85FX4.mjs → richTextSchema-Euhuj-7V.mjs} +26 -1
  214. package/dist/server/routing.mjs +1 -1
  215. package/dist/server/schema-DEizlyi4.mjs +2524 -0
  216. package/dist/server/server.mjs +3 -3
  217. package/dist/server/theme-bridge.mjs +1031 -1
  218. package/dist/server/theme.mjs +2 -1
  219. package/dist/server/themeAdmission-DGSAlFUK.mjs +18 -0
  220. package/dist/server/{three-pass-converter-Chnb1XD-.mjs → three-pass-converter-_j2UE2tR.mjs} +1 -1
  221. package/dist/server/validation-CDd6m8Ry.mjs +140 -0
  222. package/dist/server/{validation-DYxhLzqQ.mjs → validation-bl6WcAi_.mjs} +419 -3
  223. package/dist/server/{version-Beu4q-Gv.mjs → version-BLXZ31S-.mjs} +1 -1
  224. package/dist/styles/index.css +710 -29
  225. package/package.json +39 -1
  226. package/dist/client/events-BmqPeeQm.mjs +0 -20
  227. package/dist/client/purchase-BV5xfaZH.mjs +0 -894
  228. package/dist/client/schema-BdSglH2X.mjs +0 -16084
  229. package/dist/client/site-styles-CWHmlVT5.mjs +0 -14503
  230. package/dist/client/src-VIsPY-kw.mjs +0 -62
  231. package/dist/preview-next/client/PreviewEditorSidebar-DEP3xD9K.mjs +0 -5810
  232. package/dist/preview-next/client/SdkPreviewModeRuntime-Cpe-XP8e.mjs +0 -3
  233. package/dist/preview-next/client/SdkPreviewModeRuntime-QDkMPASV.mjs +0 -8059
  234. package/dist/preview-next/client/SiteChromeCustomizeButton-1JaoGOKX.mjs +0 -9367
  235. package/dist/preview-next/client/previewSidebarNavigation-AXUj9-qQ.mjs +0 -224683
  236. package/dist/preview-next/client/result-BjJUoxUF.mjs +0 -16
  237. package/dist/preview-next/client/sdk-runtime-O-eA9-rV.mjs +0 -4
  238. package/dist/preview-next/refresh-contract-uQ6BXgLJ.mjs +0 -25
  239. package/dist/server/bindings-Dgt_0goJ.mjs +0 -17
  240. package/dist/server/client-DfMDbZ41.mjs +0 -2330
  241. package/dist/server/effectiveNavLinkStyle-BHIYPVG1.mjs +0 -13713
  242. package/dist/server/loadPage-CnVB-aeL.mjs +0 -2
  243. package/dist/server/prefetchBlockData-FwcsT5H2.mjs +0 -4359
  244. package/dist/server/schema-uSA_x1Zh.mjs +0 -16311
  245. package/dist/server/site-styles-CntHn2KI.mjs +0 -793
  246. package/dist/server/siteChromeOverlayClearance-DqP40Ka0.mjs +0 -802
@@ -0,0 +1,4258 @@
1
+ "use client";
2
+ import { $n as getAtPath, Bl as cardFragment, Bu as parseGeneratedIconSetId, Ca as setContextResolveImageUrlContext, Cr as resolveLocationMapLocation, D as PreviewRenderPlanProjection, Du as validateManifestDraft, Dv as toUtcIsoDateTimeString, Eu as compileManifestContentContract, Fc as bookingConsentCarrierSchema, G as useEntryEditorController, G_ as selectedContentVersionId, Ga as OFFERINGS_PREVIEW_EVENT_PRESET_DEFINITIONS, Gl as formEmbedFragment, H as usePreviewToken, H_ as NO_BLOCK_VERSIONS, Hl as faqHeadingFragment, Il as pageTemplateFromEntry, Im as canWriteLinkedEntry, Jl as testimonialsHeadingFragment, Ju as inlineTextToPlainText, Kl as formCopyFragment, Lh as compileButtonColourStates, Li as calendarWindowQuerySchema, Lu as parseBlockIconValue, Lv as assertNever, M as lookPositionLabel, M_ as sameMailingListPlacementTargeting, Mh as parseSurfaceTree, N as lookTilePosition, Nc as publicEventsArraySchema, O_ as parseMailingListPlacementTargeting, Oh as textColorStyle, Rl as richTextFragment, S_ as buildMailingListSignupBlockSourceRef, Sa as getCurrentResolveImageUrlContext, Sr as normalizeLocationMapSource, Su as runTransforms, T as ObservedJoin, Tn as unsafeAsLinkedContentEntryId, U_ as readEditorBlockVersionsFromPlacement, Uf as isObjectRecord, Ul as blogFeaturedPostFragment, Uu as coerceInlineTextWithFallback, Vl as faqAccordionFragment, W_ as readPublishedBlockPlacement, Wf as isRecord$1, Wl as singleButtonFragment, Wu as deriveInlineTextFieldChanges, Xl as heroCtaRowFragment, Yl as ctaCopyFragment, Ym as themeSchema, Yu as isInlineTextEmpty, Za as offeringsListingFor, Zl as ctaRowFragment, _n as remoteDraftValues, ar as readinessFactsFromLoaders, b as pageDesignLookPosition, b_ as generateUuidV4, bn as resolveRenderedValues, br as normalizeBlockContent, en as useEditorUiStore, er as siblingPath, eu as heroCopyFragment, fl as readRuntimeNow, h_ as authoredValuesEqual, i as usePreviewSidebarNavigation, ii as publicRouteCandidatesSchema, iv as unsafeAsEditorBlockId, lg as expandPalette, nu as defineFragment, o as usePreviewPageDesignEditorState, oa as RichText$1, od as bindingSchema, or as selectBlockContent, pi as projectRecurringSchedule, pl as resolveDateRuntimeContext, pu as ctaButton, ql as testimonialsCarouselFragment, ri as offeringsPreviewBlockDefinition, rp as unwrapResponse, s as usePreviewPageDesignRenderState, tn as useEditorUiStoreInstance, tu as bodyCopyFragment, vn as renderSourceFor, vr as getBlockDefinition, xa as buildResolveImageUrlContext, y as cyclePageDesignBlockLook, yn as renderedFieldChanges, zl as headingFragment, zu as parseGeneratedIconAssetId } from "./previewAssistantSlot-DBi-WybM.mjs";
3
+ import { Bt as publicLocationSchema, Mt as decideLocationSourcePermission, Rt as parseLocationValue, s as TriangleAlert, zt as projectPublicLocation } from "./lucide-react-CPBCf6QT.mjs";
4
+ import { A as applyPreviewRuntimeContentProjections, At as blockLookFromContent, Ct as planArrangementContent, D as usePreviewCompiledThemeOptional, Dt as retargetJoinsAcrossOmissions, Et as renderedJoinLayout, Ft as renderInlineText, Gt as createEditorPresentationPageReader, Ht as resolveEntryRouteTarget, It as logger, Lt as Text$1, M as runtimeContentDecorationProjectionFromServerPage, Mt as getDefaultComponentRegistry, N as mergeResolvedDataContext, Nt as buildLoadedOfferingsPreviewListing, O as pageDesignRuntimeProjectionFromSource, Ot as makeDefaultBlockComponent, P as withRenderedContentEntry, Pt as buildAppointmentServicesView, St as createPageRenderPlanReader, Tt as joinSlotKey, Ut as resolvePageRouteTarget, Vt as defaultTransforms, Wt as resolveRouteTarget, Yt as buildThemeRuntime, Zt as mergeContentWithBlockStyleOverrides, hn as defaultThemeTokens, i as PreviewChromeFloatingControl, j as entryFieldRebindingProjection, jt as readBlockComposition, k as resolveRuntimePreviewSourceForTheme, kt as arrangementHooksFromContent, l as planBlockToolbarPlacement, nt as clientComponentRegistry, o as readThemeCustomProperties, r as PreviewChromeFloatingBar, s as measureSiteTopChromeClearance, wt as composePageJoins, zt as coerceLinkedContentEntriesPayload } from "./SiteChromeCustomizeButton-CU9VD-7O.mjs";
5
+ import { L as createStandardButtonSurfacePolicy } from "./ThemedButton-C0dgGJ5k.mjs";
6
+ import { A as EditorCanvasNameChip, C as useRichTextEditor, D as decideDocumentReplacement, E as InlineTextEditor, M as EditorSelectionFrame, O as resolveSdkFooterMode, T as parseRichTextDoc, a as LookCyclePill, b as RichTextEditorSurface, h as useRichTextImageProjection, j as EditorInsertionMarker, k as EditorCanvasChipRow, n as ArrangementLookPill, r as ArrangementModeSwitchPill, s as useArrangementToolbar, w as EMPTY_DOC } from "./ArrangementLookControls-D4VjPs-r.mjs";
7
+ import { a as needsSetupMessage, n as useBlockCustomizeControls, r as NEEDS_SETUP_LABEL, s as useBlockNeedsSetup } from "./useBlockCustomizeControls-B7MLTjBX.mjs";
8
+ import { f as useEditor } from "./previewChromeSurface-BhkUJst9.mjs";
9
+ import { a as dispatchLinkedEntryFieldFocusEvent, c as useLinkedSaveHandoverRetention, d as linkedEntryRenderOverlaysFromStore, f as PREVIEW_EDITABLE_OUTLINE, i as dispatchLinkedEntryEditEvent, l as applyLinkedEntryRenderOverlay, o as defaultPreviewThemeRuntime, r as dispatchBlockFieldFocusEvent, s as linkedSaveHandoversVersion, t as PreviewShell, u as applyLinkedEntryRenderOverlayToDataContext } from "./PreviewShell-CyO2V4kB.mjs";
10
+ import { t as useOpenBlockForSetup } from "./useOpenBlockForSetup-BTUc0g9X.mjs";
11
+ import * as React$1 from "react";
12
+ import React, { createContext, memo, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
13
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
14
+ import { createPortal } from "react-dom";
15
+ //#region ../theme-core/src/buttons/parseThemeForPersistence.ts
16
+ /**
17
+ * Proves that every persisted button variant compiles against the theme's
18
+ * concrete palette. Public rendering may still recover from malformed
19
+ * external/runtime input, but persistence boundaries must reject it.
20
+ */
21
+ function parseThemeForPersistence(value) {
22
+ const parsed = themeSchema.safeParse(value);
23
+ if (!parsed.success) return {
24
+ ok: false,
25
+ error: {
26
+ kind: "invalid-theme-schema",
27
+ issues: parsed.error.issues
28
+ }
29
+ };
30
+ const parsedTheme = parsed.data;
31
+ const theme = parsedTheme.buttons && !parsedTheme.buttons.surfacePolicy ? {
32
+ ...parsedTheme,
33
+ buttons: {
34
+ ...parsedTheme.buttons,
35
+ surfacePolicy: createStandardButtonSurfacePolicy()
36
+ }
37
+ } : parsedTheme;
38
+ if (!theme.buttons) return {
39
+ ok: true,
40
+ value: theme
41
+ };
42
+ const palette = expandPalette(theme.palette);
43
+ for (const variant of theme.buttons.variants) {
44
+ const result = compileButtonColourStates({
45
+ variant,
46
+ global: theme.buttons.global,
47
+ palette
48
+ });
49
+ if (!result.ok) return {
50
+ ok: false,
51
+ error: {
52
+ kind: "invalid-button-colour-contract",
53
+ variantId: variant.id,
54
+ cause: result.error
55
+ }
56
+ };
57
+ }
58
+ return {
59
+ ok: true,
60
+ value: theme
61
+ };
62
+ }
63
+ //#endregion
64
+ //#region ../blocks/src/system/fragments/library/headerCta.ts
65
+ const headerCtaFragment = defineFragment({
66
+ variantMeaning: { kind: "arrangement" },
67
+ id: "headerCta",
68
+ title: "Header CTA",
69
+ description: "Single call-to-action button for the site header.",
70
+ fields: [{
71
+ id: "cta",
72
+ type: "group",
73
+ label: "Call to action",
74
+ description: "Primary action button displayed on CTA variant layouts.",
75
+ schema: { fields: [
76
+ {
77
+ id: "label",
78
+ type: "text",
79
+ label: "Label",
80
+ description: "Button label shown in the header."
81
+ },
82
+ {
83
+ id: "link",
84
+ type: "link",
85
+ label: "Link",
86
+ description: "Select an internal page or provide a custom destination."
87
+ },
88
+ {
89
+ id: "variant",
90
+ type: "select",
91
+ label: "Style",
92
+ defaultValue: "primary",
93
+ options: [
94
+ {
95
+ value: "primary",
96
+ label: "Primary"
97
+ },
98
+ {
99
+ value: "secondary",
100
+ label: "Secondary"
101
+ },
102
+ {
103
+ value: "outline",
104
+ label: "Outline"
105
+ }
106
+ ]
107
+ }
108
+ ] }
109
+ }],
110
+ layout: [ctaButton({
111
+ basePath: "cta",
112
+ whenPath: "cta.label"
113
+ })]
114
+ });
115
+ //#endregion
116
+ //#region ../blocks/src/system/fragments/lazyInit.ts
117
+ let initialized = false;
118
+ const ALL_FRAGMENTS = [
119
+ bodyCopyFragment,
120
+ heroCopyFragment,
121
+ ctaRowFragment,
122
+ heroCtaRowFragment,
123
+ ctaCopyFragment,
124
+ testimonialsHeadingFragment,
125
+ testimonialsCarouselFragment,
126
+ formCopyFragment,
127
+ formEmbedFragment,
128
+ headerCtaFragment,
129
+ singleButtonFragment,
130
+ blogFeaturedPostFragment,
131
+ faqHeadingFragment,
132
+ faqAccordionFragment,
133
+ cardFragment,
134
+ headingFragment,
135
+ richTextFragment
136
+ ];
137
+ /**
138
+ * Register all fragment definitions lazily.
139
+ * This function is called by the registry on first access.
140
+ *
141
+ * @param registerFn - Function to register a single fragment
142
+ */
143
+ function lazyRegisterFragments(registerFn) {
144
+ if (initialized) return;
145
+ ALL_FRAGMENTS.forEach(registerFn);
146
+ initialized = true;
147
+ }
148
+ //#endregion
149
+ //#region ../blocks/src/system/fragments/registry.ts
150
+ const fragmentRegistry = {};
151
+ /**
152
+ * Ensure all fragments are registered.
153
+ * This is called automatically by getFragmentRegistry() and getFragment().
154
+ * Can also be called explicitly to force registration.
155
+ */
156
+ function ensureInitialized() {
157
+ lazyRegisterFragments((fragment) => {
158
+ if (!fragmentRegistry[fragment.id]) fragmentRegistry[fragment.id] = fragment;
159
+ });
160
+ }
161
+ /**
162
+ * Get the full fragment registry.
163
+ * Useful for passing to runtime components.
164
+ *
165
+ * @returns The complete fragment registry
166
+ */
167
+ function getFragmentRegistry() {
168
+ ensureInitialized();
169
+ return fragmentRegistry;
170
+ }
171
+ //#endregion
172
+ //#region ../blocks/src/system/icons/generatedAssets.ts
173
+ function isRecord(value) {
174
+ return typeof value === "object" && value !== null && !Array.isArray(value);
175
+ }
176
+ function generatedIconAssetRefKey(ref) {
177
+ return `${ref.setId}\u0000${ref.assetId}`;
178
+ }
179
+ function collectGeneratedIconAssetRefs(page) {
180
+ const blocks = [];
181
+ for (const block of page.blocks) {
182
+ if (block.kind !== "block.feature-cards" || typeof block.id !== "string") continue;
183
+ const content = isRecord(block.draftContent) ? block.draftContent : isRecord(block.content) ? block.content : null;
184
+ const cards = Array.isArray(content?.cards) ? content.cards : [];
185
+ const refs = /* @__PURE__ */ new Map();
186
+ for (const card of cards) {
187
+ if (!isRecord(card)) continue;
188
+ const icon = parseBlockIconValue(card.icon);
189
+ if (icon.kind !== "generated") continue;
190
+ const ref = {
191
+ setId: icon.setId,
192
+ assetId: icon.assetId
193
+ };
194
+ refs.set(generatedIconAssetRefKey(ref), ref);
195
+ }
196
+ if (refs.size > 0) blocks.push({
197
+ blockId: block.id,
198
+ refs: [...refs.values()]
199
+ });
200
+ }
201
+ return blocks;
202
+ }
203
+ function dedupeGeneratedIconAssetRefs(blocks) {
204
+ return [...new Map(blocks.flatMap((block) => block.refs).map((ref) => [generatedIconAssetRefKey(ref), ref])).values()];
205
+ }
206
+ function mapGeneratedIconAssetsToBlocks(blocks, resolvedAssets) {
207
+ const byKey = new Map(resolvedAssets.map((asset) => [generatedIconAssetRefKey(asset), asset]));
208
+ return Object.fromEntries(blocks.flatMap((block) => {
209
+ const assets = block.refs.flatMap((ref) => {
210
+ const asset = byKey.get(generatedIconAssetRefKey(ref));
211
+ if (!asset) return [];
212
+ const setId = parseGeneratedIconSetId(asset.setId);
213
+ const assetId = parseGeneratedIconAssetId(asset.assetId);
214
+ if (!setId || !assetId) return [];
215
+ return [{
216
+ setId,
217
+ assetId,
218
+ src: asset.src,
219
+ ...asset.width === void 0 ? {} : { width: asset.width },
220
+ ...asset.height === void 0 ? {} : { height: asset.height }
221
+ }];
222
+ });
223
+ return assets.length > 0 ? [[block.blockId, assets]] : [];
224
+ }));
225
+ }
226
+ function mergeGeneratedIconAssetsIntoResolvedData(resolvedData, assetsByBlock) {
227
+ if (Object.keys(assetsByBlock).length === 0) return resolvedData;
228
+ const merged = { ...resolvedData };
229
+ for (const [blockId, generatedIconAssets] of Object.entries(assetsByBlock)) merged[blockId] = {
230
+ ...merged[blockId] ?? {},
231
+ generatedIconAssets
232
+ };
233
+ return merged;
234
+ }
235
+ //#endregion
236
+ //#region ../blocks/src/system/data/utils.ts
237
+ /**
238
+ * Normalize data loaders from block definition
239
+ */
240
+ function normalizeDataLoaders(def) {
241
+ if (!def?.dataLoaders) return [];
242
+ return Object.entries(def.dataLoaders).map(([key, loader]) => ({
243
+ key,
244
+ loader
245
+ }));
246
+ }
247
+ /**
248
+ * Normalize params for API calls.
249
+ * Converts supplied values to strings, preserving absent versus explicitly empty params.
250
+ */
251
+ function normalizeParams(input) {
252
+ if (!input || typeof input !== "object") return {};
253
+ const output = {};
254
+ for (const [key, value] of Object.entries(input)) if (value !== void 0 && value !== null) output[key] = coerceToString(value);
255
+ return output;
256
+ }
257
+ function isNonArrayObject(value) {
258
+ return typeof value === "object" && value !== null && !Array.isArray(value);
259
+ }
260
+ function safeJsonStringify(value) {
261
+ try {
262
+ return JSON.stringify(value);
263
+ } catch {
264
+ return;
265
+ }
266
+ }
267
+ /**
268
+ * Coerce value to string for API params
269
+ */
270
+ function coerceToString(value) {
271
+ if (value === null || value === void 0) return "";
272
+ if (Array.isArray(value)) {
273
+ if (value.some(isNonArrayObject)) {
274
+ const json = safeJsonStringify(value);
275
+ if (typeof json === "string") return json;
276
+ }
277
+ return value.map(coerceToString).join(",");
278
+ }
279
+ if (isNonArrayObject(value)) {
280
+ const json = safeJsonStringify(value);
281
+ if (typeof json === "string") return json;
282
+ }
283
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return String(value);
284
+ return "";
285
+ }
286
+ /**
287
+ * The appointment-services catalogue (issue 1403) pairs the services with the
288
+ * site's ordered categories. Both are needed to group them, so that response
289
+ * is passed through whole; any other `{ services }` wrapper is unwrapped.
290
+ */
291
+ function coerceServicesPayload(record) {
292
+ return Array.isArray(record.services) && Array.isArray(record.categories) ? {
293
+ services: record.services,
294
+ categories: record.categories
295
+ } : record.services;
296
+ }
297
+ /**
298
+ * Extract data from API response.
299
+ * Unwraps common response wrappers: { data }, { form }, { entries }, { services }, { teamMembers }
300
+ *
301
+ * Note: We check that properties are NOT functions to avoid returning
302
+ * built-in methods like Array.prototype.entries
303
+ */
304
+ function coercePayload(payload) {
305
+ const linkedContentEntries = coerceLinkedContentEntriesPayload(payload);
306
+ if (linkedContentEntries !== payload) return linkedContentEntries;
307
+ if (payload && typeof payload === "object" && !Array.isArray(payload)) {
308
+ const record = payload;
309
+ if ("data" in record && typeof record.data !== "function") return record.data;
310
+ if ("form" in record && typeof record.form !== "function") return record.form;
311
+ if ("entries" in record && typeof record.entries !== "function") return record.entries;
312
+ if ("services" in record && typeof record.services !== "function") return coerceServicesPayload(record);
313
+ if ("teamMembers" in record && typeof record.teamMembers !== "function") return record.teamMembers;
314
+ }
315
+ return payload;
316
+ }
317
+ //#endregion
318
+ //#region ../blocks/src/system/data/fetchLoaderData.ts
319
+ const ALL_PAGE_SIZE = 50;
320
+ /** The shared loader owns All pagination and rejects adapters that repeat a page. */
321
+ async function fetchLoaderData(apiClient, endpoint, params) {
322
+ if (params.limit === "all") return fetchAllPages(apiClient, endpoint, params, 0, /* @__PURE__ */ new Set());
323
+ return coercePayload(await apiClient({
324
+ endpoint,
325
+ params
326
+ }));
327
+ }
328
+ function planLoaderPage(data, offset, seenPages) {
329
+ if (!isUnknownArray(data)) return {
330
+ kind: "invalid",
331
+ message: "Expected paged loader entries"
332
+ };
333
+ if (data.length < ALL_PAGE_SIZE) return {
334
+ kind: "complete",
335
+ entries: data
336
+ };
337
+ const ids = data.map((entry) => isObjectRecord(entry) && typeof entry.id === "string" ? entry.id : null);
338
+ const key = JSON.stringify(ids.every((id) => id !== null) ? [...ids].sort() : data);
339
+ if (seenPages.has(key)) return {
340
+ kind: "invalid",
341
+ message: "Paged loader made no progress"
342
+ };
343
+ return {
344
+ kind: "continue",
345
+ entries: data,
346
+ offset: offset + data.length,
347
+ seenPages: /* @__PURE__ */ new Set([...seenPages, key])
348
+ };
349
+ }
350
+ async function fetchAllPages(apiClient, endpoint, params, offset, seenPages) {
351
+ const page = planLoaderPage(coercePayload(await apiClient({
352
+ endpoint,
353
+ params: {
354
+ ...params,
355
+ limit: String(ALL_PAGE_SIZE),
356
+ offset: String(offset)
357
+ }
358
+ })), offset, seenPages);
359
+ switch (page.kind) {
360
+ case "invalid": throw new Error(page.message);
361
+ case "complete": return page.entries;
362
+ case "continue": return [...page.entries, ...await fetchAllPages(apiClient, endpoint, params, page.offset, page.seenPages)];
363
+ default: return assertNever(page);
364
+ }
365
+ }
366
+ function isUnknownArray(value) {
367
+ return Array.isArray(value);
368
+ }
369
+ //#endregion
370
+ //#region ../blocks/src/system/runtime/bindings.ts
371
+ const shouldLogWarnings = isNonProductionEnv();
372
+ function isPlainObject(value) {
373
+ return typeof value === "object" && value !== null && !Array.isArray(value);
374
+ }
375
+ function isRouteMapEntry(value) {
376
+ if (typeof value === "string") return true;
377
+ return isPlainObject(value);
378
+ }
379
+ function isRouteMap(value) {
380
+ if (!isPlainObject(value)) return false;
381
+ return Object.values(value).every(isRouteMapEntry);
382
+ }
383
+ function isPageIdentifierMap(value) {
384
+ if (!isPlainObject(value)) return false;
385
+ return Object.values(value).every((v) => typeof v === "string");
386
+ }
387
+ function isEntryIdentifierMap(value) {
388
+ if (!isPlainObject(value)) return false;
389
+ for (const v of Object.values(value)) {
390
+ if (!isPlainObject(v)) return false;
391
+ if (!Object.values(v).every((inner) => typeof inner === "string")) return false;
392
+ }
393
+ return true;
394
+ }
395
+ function buildTransformContext(vm, dateContext, now) {
396
+ const root = vm.$root;
397
+ const stage = root && isPlainObject(root) && root.previewStage === "preview" ? "preview" : "published";
398
+ const routes = root && isPlainObject(root) && isRouteMap(root.routes) ? root.routes : void 0;
399
+ const pagesByIdentifier = root && isPlainObject(root) && isPageIdentifierMap(root.pagesByIdentifier) ? root.pagesByIdentifier : void 0;
400
+ const entriesByIdentifier = root && isPlainObject(root) && isEntryIdentifierMap(root.entriesByIdentifier) ? root.entriesByIdentifier : void 0;
401
+ return {
402
+ theme: defaultThemeTokens,
403
+ dateContext,
404
+ now,
405
+ stage,
406
+ data: vm.content,
407
+ routes,
408
+ pagesByIdentifier,
409
+ entriesByIdentifier
410
+ };
411
+ }
412
+ function resolveParamsBindings(input, vm, meta, dateContext = resolveDateRuntimeContext(typeof vm.$root?.bookingTimeZone === "string" ? vm.$root.bookingTimeZone : void 0), now = readRuntimeNow(vm.$root?.now)) {
413
+ return resolveLoaderParam(input, {
414
+ vm,
415
+ meta,
416
+ transforms: buildTransformContext(vm, dateContext, now)
417
+ });
418
+ }
419
+ function resolveLoaderParam(input, runtime) {
420
+ if (input === null || typeof input !== "object") return input;
421
+ if (Array.isArray(input)) return input.map((value) => resolveLoaderParam(value, runtime));
422
+ const inputRecord = input;
423
+ const binding = inputRecord.$bind;
424
+ if (binding && typeof binding === "object") return resolveBoundLoaderParam(binding, runtime);
425
+ return Object.fromEntries(Object.entries(inputRecord).map(([key, value]) => [key, resolveLoaderParam(value, runtime)]));
426
+ }
427
+ function resolveBoundLoaderParam(input, runtime) {
428
+ try {
429
+ const binding = bindingSchema.parse(input);
430
+ const value = resolveBinding(binding.from, runtime.vm);
431
+ const resolved = value === void 0 || value === null ? binding.fallback : runTransforms(value, binding.transforms, runtime.transforms, defaultTransforms);
432
+ return resolved === void 0 || resolved === null || resolved === "" ? binding.fallback : resolved;
433
+ } catch (err) {
434
+ if (shouldLogWarnings) console.warn(`bindings: failed to parse loader param binding for block "${runtime.meta?.blockKind ?? "unknown"}"`, err);
435
+ return;
436
+ }
437
+ }
438
+ function resolveBinding(path, vm) {
439
+ const segments = splitPath(path);
440
+ if (!segments.length) return void 0;
441
+ const [first, ...rest] = segments;
442
+ let source = vm;
443
+ if (first === "$root") {
444
+ source = vm;
445
+ return readFromSource(source, [first, ...rest]);
446
+ }
447
+ if (first === "content") {
448
+ source = vm.content;
449
+ return readFromSource(source, rest);
450
+ }
451
+ const contentResult = readFromSource(vm.content, segments);
452
+ if (contentResult !== void 0) return contentResult;
453
+ return readFromSource(vm, segments);
454
+ }
455
+ function splitPath(path) {
456
+ const PATH_SEPARATOR_REGEX = /\./g;
457
+ const BRACKET_ACCESS_REGEX = /\[(?<token>[^\]]+)\]/g;
458
+ const segments = [];
459
+ const parts = path.split(PATH_SEPARATOR_REGEX);
460
+ for (const raw of parts) {
461
+ if (!raw) continue;
462
+ const baseMatch = raw.match(/^([^\[]+)/);
463
+ if (baseMatch && baseMatch[1]) segments.push(baseMatch[1]);
464
+ const bracketMatches = raw.matchAll(BRACKET_ACCESS_REGEX);
465
+ for (const match of bracketMatches) {
466
+ const token = match.groups?.token ?? "";
467
+ if (token.startsWith("\"") || token.startsWith("'")) segments.push(token.slice(1, -1));
468
+ else if (/^\d+$/.test(token)) segments.push(Number(token));
469
+ else segments.push(token);
470
+ }
471
+ if (!baseMatch && !raw.includes("[")) segments.push(raw);
472
+ }
473
+ return segments;
474
+ }
475
+ function readFromSource(source, segments) {
476
+ return segments.reduce((current, segment) => {
477
+ if (current === void 0 || current === null) return void 0;
478
+ if (typeof segment === "number") {
479
+ if (Array.isArray(current)) return current[segment];
480
+ return;
481
+ }
482
+ if (typeof current === "object" && current !== null && segment in current) return current[segment];
483
+ }, source);
484
+ }
485
+ function isNonProductionEnv() {
486
+ if (typeof globalThis === "undefined") return true;
487
+ return globalThis.process?.env?.NODE_ENV !== "production";
488
+ }
489
+ //#endregion
490
+ //#region ../blocks/src/system/data/prefetchBlockData.ts
491
+ /**
492
+ * Core block data prefetching logic (framework-agnostic).
493
+ *
494
+ * This module provides the shared implementation for prefetching block data loaders.
495
+ * It works with any API client by accepting it as a parameter (dependency injection).
496
+ *
497
+ * Usage:
498
+ * - Frontend: provide internal API client
499
+ * - SDK: provide SDK client with endpoint mapping
500
+ */
501
+ function projectDataLoaders(loaders, shouldLoad, blockId, blockKind) {
502
+ if (!shouldLoad) return [...loaders];
503
+ return loaders.filter(({ key }) => shouldLoad({
504
+ blockId,
505
+ blockKind,
506
+ loaderKey: key
507
+ }));
508
+ }
509
+ function shouldSkipResolvedLoader(input) {
510
+ if (input.loader.requiredParams?.some((param) => !input.params[param]?.trim())) return true;
511
+ return Boolean(input.isValidEndpoint && !input.isValidEndpoint(input.endpoint));
512
+ }
513
+ /** Resolve once through the shared bindings owner; request reuse never reuses content provenance. */
514
+ function planBlockDataRequests(page, context, options = {}) {
515
+ const runtime = admitLoaderDateRuntime(context);
516
+ const blocks = page.blocks.flatMap((block) => block.id ? [planBlockRequests(block, block.id, context, options, runtime)] : []);
517
+ return {
518
+ blocks,
519
+ loaderSnapshot: {
520
+ stage: context.previewStage === "preview" ? "draft" : "published",
521
+ blocks: Object.fromEntries(blocks.map((block) => [block.id, {
522
+ kind: block.kind,
523
+ content: block.content,
524
+ requests: Object.fromEntries(block.requests.map(({ key, endpoint, params }) => [key, {
525
+ endpoint,
526
+ params
527
+ }]))
528
+ }]))
529
+ }
530
+ };
531
+ }
532
+ function projectBlockDataOutcomes(plan, outcomes) {
533
+ return {
534
+ ...projectLoaderOutcomes(plan.blocks, outcomes),
535
+ loaderSnapshot: plan.loaderSnapshot
536
+ };
537
+ }
538
+ function planBlockRequests(block, id, context, options, runtime) {
539
+ const definition = (options.getBlockDefinition ?? getBlockDefinition)(block.kind);
540
+ const loaders = definition ? normalizeDataLoaders(definition) : customLoaders(block.kind, options);
541
+ const vm = {
542
+ content: plannedLoaderContent(block, definition, context),
543
+ $root: {
544
+ ...context.root,
545
+ siteId: context.siteId,
546
+ pageId: context.pageId,
547
+ previewStage: context.previewStage
548
+ }
549
+ };
550
+ const requests = projectDataLoaders(loaders, options.shouldLoad, id, block.kind).flatMap((entry) => {
551
+ const request = planLoaderRequest(entry, block, id, vm, options, runtime);
552
+ return request ? [request] : [];
553
+ });
554
+ return {
555
+ id,
556
+ kind: block.kind,
557
+ content: selectBlockContent(block, context.previewStage),
558
+ requests
559
+ };
560
+ }
561
+ function customLoaders(kind, options) {
562
+ return Object.entries(options.getCustomBlockLoaders?.(kind) ?? {}).map(([key, loader]) => ({
563
+ key,
564
+ loader
565
+ }));
566
+ }
567
+ function planLoaderRequest({ key, loader }, block, blockId, vm, options, runtime) {
568
+ if (loader.mode === "client") return null;
569
+ const resolve = options.resolveParamsBindings ?? resolveParamsBindings;
570
+ const coordinates = { blockKind: block.kind };
571
+ if (loader.when !== void 0 && resolve(loader.when, vm, coordinates, runtime.dateContext, runtime.now) !== true) return null;
572
+ const params = normalizeParams(resolve(loader.params, vm, coordinates, runtime.dateContext, runtime.now));
573
+ if (shouldSkipResolvedLoader({
574
+ loader,
575
+ endpoint: loader.endpoint,
576
+ params,
577
+ isValidEndpoint: options.isValidEndpoint
578
+ })) return null;
579
+ return {
580
+ blockId,
581
+ blockKind: block.kind,
582
+ key,
583
+ endpoint: loader.endpoint,
584
+ params
585
+ };
586
+ }
587
+ async function executeBlockDataRequest(request, options) {
588
+ try {
589
+ return {
590
+ kind: "loaded",
591
+ request,
592
+ data: await fetchLoaderData(options.apiClient, request.endpoint, request.params)
593
+ };
594
+ } catch (error) {
595
+ options.onError?.(error, {
596
+ block: request.blockKind,
597
+ loader: request.key
598
+ });
599
+ return {
600
+ kind: "failed",
601
+ request
602
+ };
603
+ }
604
+ }
605
+ function projectLoaderOutcomes(blocks, outcomes) {
606
+ return {
607
+ resolvedData: Object.fromEntries(blocks.flatMap((block) => {
608
+ const values = outcomes.flatMap((outcome) => outcome.request.blockId === block.id && outcome.kind === "loaded" ? [[outcome.request.key, outcome.data]] : []);
609
+ return values.length ? [[block.id, Object.fromEntries(values)]] : [];
610
+ })),
611
+ loaderFailures: Object.fromEntries(blocks.flatMap((block) => {
612
+ const values = outcomes.flatMap((outcome) => outcome.request.blockId === block.id && outcome.kind === "failed" ? [[outcome.request.key, {
613
+ endpoint: outcome.request.endpoint,
614
+ params: outcome.request.params
615
+ }]] : []);
616
+ return values.length ? [[block.id, Object.fromEntries(values)]] : [];
617
+ }))
618
+ };
619
+ }
620
+ /** Prefetch executes the render-plan content stage before resolving loader bindings. */
621
+ function plannedLoaderContent(block, definition, context) {
622
+ const content = selectBlockContent(block, context.previewStage);
623
+ if (!definition || content._arrangementLooks === void 0) return content;
624
+ return planArrangementContent(block.kind, definition.manifest, content, context.previewStage === "preview" ? "authoring" : "public");
625
+ }
626
+ function admitLoaderDateRuntime(context) {
627
+ const root = context.root;
628
+ return {
629
+ now: root?.now === void 0 ? toUtcIsoDateTimeString((/* @__PURE__ */ new Date()).toISOString()) : readRuntimeNow(root.now),
630
+ dateContext: resolveDateRuntimeContext(typeof root?.bookingTimeZone === "string" ? root.bookingTimeZone : void 0)
631
+ };
632
+ }
633
+ //#endregion
634
+ //#region ../blocks/src/system/data/loaderEndpoints.ts
635
+ const SUPPORTED_LOADER_ENDPOINTS = [
636
+ "listPublishedEntries",
637
+ "getPublishedEntryPreview",
638
+ "listPublicEvents",
639
+ "listPublicEventCalendarWindow",
640
+ "listPublicRecurringSchedule",
641
+ "getPublicEventDetails",
642
+ "listPublicRouteCandidates",
643
+ "listPublicTeamMembers",
644
+ "listPublicProducts",
645
+ "listPublicPasses",
646
+ "listPublicMemberships",
647
+ "getPublicFormById",
648
+ "getPublicBookingServices",
649
+ "getPublicWeeklySlotAvailability"
650
+ ];
651
+ function isSupportedLoaderEndpoint(endpoint) {
652
+ return SUPPORTED_LOADER_ENDPOINTS.includes(endpoint);
653
+ }
654
+ //#endregion
655
+ //#region ../blocks/src/system/data/batching.ts
656
+ function stableNormalize(value) {
657
+ if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
658
+ if (Array.isArray(value)) return value.map(stableNormalize);
659
+ if (typeof value === "object" && value) {
660
+ const obj = value;
661
+ const keys = Object.keys(obj).sort();
662
+ const out = {};
663
+ for (const key of keys) {
664
+ const v = obj[key];
665
+ if (v === void 0) continue;
666
+ out[key] = stableNormalize(v);
667
+ }
668
+ return out;
669
+ }
670
+ if (typeof value === "bigint" || typeof value === "symbol" || typeof value === "undefined") return String(value);
671
+ return null;
672
+ }
673
+ function stableSerialize(value) {
674
+ return JSON.stringify(stableNormalize(value));
675
+ }
676
+ function createMicrobatcher(options) {
677
+ const schedule = options.schedule ?? ((fn) => queueMicrotask(fn));
678
+ const inFlight = /* @__PURE__ */ new Map();
679
+ const queued = /* @__PURE__ */ new Map();
680
+ let flushPromise = null;
681
+ let nextRequestId = 0;
682
+ const flush = async () => {
683
+ while (queued.size > 0) {
684
+ const batchEntries = Array.from(queued.entries()).slice(0, options.maxBatchSize);
685
+ const batch = batchEntries.map(([, value]) => value);
686
+ for (const [key] of batchEntries) queued.delete(key);
687
+ const requests = batch.map((item) => item.request);
688
+ try {
689
+ const results = await options.runBatch(requests);
690
+ for (const item of batch) {
691
+ const result = results[item.request.id];
692
+ if (!result) {
693
+ item.reject(/* @__PURE__ */ new Error("Missing batch result"));
694
+ continue;
695
+ }
696
+ if (result.ok) item.resolve(result.data);
697
+ else item.reject(new Error(result.error.message));
698
+ }
699
+ } catch (error) {
700
+ for (const item of batch) item.reject(error);
701
+ }
702
+ }
703
+ };
704
+ const scheduleFlush = () => {
705
+ if (flushPromise) return flushPromise;
706
+ flushPromise = new Promise((resolve, reject) => {
707
+ schedule(() => {
708
+ flush().then(resolve, reject);
709
+ });
710
+ }).finally(() => {
711
+ flushPromise = null;
712
+ if (queued.size > 0) scheduleFlush();
713
+ });
714
+ return flushPromise;
715
+ };
716
+ const getOrEnqueue = (key, makeRequest) => {
717
+ const existing = inFlight.get(key);
718
+ if (existing) return existing;
719
+ const promise = new Promise((resolve, reject) => {
720
+ const id = `r${nextRequestId++}`;
721
+ queued.set(key, {
722
+ request: makeRequest(id),
723
+ resolve,
724
+ reject
725
+ });
726
+ }).finally(() => {
727
+ inFlight.delete(key);
728
+ });
729
+ inFlight.set(key, promise);
730
+ scheduleFlush();
731
+ return promise;
732
+ };
733
+ return { getOrEnqueue };
734
+ }
735
+ //#endregion
736
+ //#region ../blocks/src/system/data/normalizeLoaderParams.ts
737
+ function toStringParams(value) {
738
+ if (!isObjectRecord(value)) return {};
739
+ const out = {};
740
+ for (const [k, v] of Object.entries(value)) if (typeof v === "string") out[k] = v;
741
+ return out;
742
+ }
743
+ function stripEmptyStringValues(params, endpoint) {
744
+ for (const [key, value] of Object.entries(params)) if (value === "" && !(key === "seriesIds" && (endpoint === "listPublicEvents" || endpoint === "listPublicEventCalendarWindow"))) delete params[key];
745
+ }
746
+ function ensureSiteId(params, context) {
747
+ if (!params.siteId && typeof context.siteId === "string" && context.siteId) params.siteId = context.siteId;
748
+ }
749
+ /**
750
+ * Map the embed block's author-facing order values onto the public
751
+ * `listPublishedEntries` `order` contract enum.
752
+ *
753
+ * `'order'` ("Your own order") is the MANUAL-ORDERING axis: it means "render
754
+ * entries in the content type's author-defined order". It intentionally maps to
755
+ * `undefined` (endpoint default) here rather than a fixed `manual.asc`, because
756
+ * this transform is schema-blind — it can't tell whether the embedded content
757
+ * type actually opts into `ordering.mode: 'manual'`. Forcing `manual.asc` for a
758
+ * non-manual type would silently flip its default sort (all `manualOrder` values
759
+ * are equal, so it would degrade to createdAt-asc) — a render regression.
760
+ *
761
+ * The content-type schema owns the default order. Both management lists and
762
+ * public entry loaders resolve it with resolveContentEntryOrder; explicit
763
+ * caller sorts still override that default.
764
+ */
765
+ function normalizeOrder(orderBy) {
766
+ switch (orderBy) {
767
+ case "newest": return "published_at.desc";
768
+ case "oldest": return "published_at.asc";
769
+ case "title": return "title.asc";
770
+ case "order": return;
771
+ default: return;
772
+ }
773
+ }
774
+ /**
775
+ * Normalize loader params emitted by the block runtime into a consistent shape
776
+ * (canonical keys + required context-derived fields).
777
+ *
778
+ * Note: params are already stringified by the core prefetch implementation.
779
+ */
780
+ function normalizeLoaderParams(endpoint, params, context) {
781
+ const out = toStringParams(params);
782
+ stripEmptyStringValues(out, endpoint);
783
+ if (endpoint === "getPublicFormById") {
784
+ ensureSiteId(out, context);
785
+ if (!out.formId && out.formSlug) {
786
+ out.formId = out.formSlug;
787
+ delete out.formSlug;
788
+ }
789
+ return out;
790
+ }
791
+ if (endpoint === "getPublicBookingServices") {
792
+ ensureSiteId(out, context);
793
+ return out;
794
+ }
795
+ if (endpoint === "getPublicWeeklySlotAvailability") {
796
+ ensureSiteId(out, context);
797
+ return out;
798
+ }
799
+ if (endpoint === "listPublicEvents" || endpoint === "listPublicRecurringSchedule" || endpoint === "listPublicEventCalendarWindow") {
800
+ ensureSiteId(out, context);
801
+ return out;
802
+ }
803
+ if (endpoint === "getPublicEventDetails") {
804
+ ensureSiteId(out, context);
805
+ return out;
806
+ }
807
+ if (endpoint === "listPublicProducts") {
808
+ ensureSiteId(out, context);
809
+ return out;
810
+ }
811
+ if (endpoint === "listPublicTeamMembers") {
812
+ ensureSiteId(out, context);
813
+ return out;
814
+ }
815
+ if (endpoint === "listPublicRouteCandidates") {
816
+ ensureSiteId(out, context);
817
+ return out;
818
+ }
819
+ if (endpoint === "getPublishedEntryPreview") {
820
+ ensureSiteId(out, context);
821
+ return out;
822
+ }
823
+ ensureSiteId(out, context);
824
+ return out;
825
+ }
826
+ /**
827
+ * Normalize loader params into the shapes expected by the public API endpoints.
828
+ *
829
+ * Prefer this when the loader endpoint maps 1:1 to a public API route.
830
+ */
831
+ function normalizePublicApiLoaderParams(endpoint, params, context) {
832
+ const out = normalizeLoaderParams(endpoint, params, context);
833
+ if (endpoint === "listPublishedEntries" && !out.order && out.orderBy) {
834
+ const mapped = normalizeOrder(out.orderBy);
835
+ if (mapped) out.order = mapped;
836
+ delete out.orderBy;
837
+ }
838
+ return out;
839
+ }
840
+ //#endregion
841
+ //#region ../blocks/src/pageRenderAudience.tsx
842
+ /**
843
+ * The single policy for what a non-renderable block looks like.
844
+ *
845
+ * Public visitors never see renderer diagnostics, so every reason omits.
846
+ * Authoring surfaces keep the wording they have always had — the strings below
847
+ * are moved verbatim from the five former `fallback()` call sites.
848
+ */
849
+ function presentNotRenderableBlock(reason, audience) {
850
+ if (audience === "public") return null;
851
+ if (reason.kind === "hidden-business-location" && reason.businessDetailsHref) return diagnostic(/* @__PURE__ */ jsxs(Fragment$1, { children: [
852
+ authoringMessage(reason),
853
+ " ",
854
+ /* @__PURE__ */ jsx("a", {
855
+ href: reason.businessDetailsHref,
856
+ children: "Open Business details"
857
+ })
858
+ ] }));
859
+ return diagnostic(authoringMessage(reason));
860
+ }
861
+ function authoringMessage(reason) {
862
+ switch (reason.kind) {
863
+ case "invalid-admission": return `Invalid content for block kind "${reason.blockKind}".`;
864
+ case "missing-definition": return reason.isCustom ? `No renderer available for block kind "${reason.blockKind}". The custom block definition was not found (missing manifest).` : `No renderer available for block kind "${reason.blockKind}".`;
865
+ case "missing-layout": return reason.isCustom ? `No renderer available for block kind "${reason.blockKind}". This custom block has no layout/variants, so it must be rendered via blockOverrides["${reason.blockKind}"].` : `No renderer available for block kind "${reason.blockKind}".`;
866
+ case "hidden-business-location": return "This map is hidden because your business address is hidden.";
867
+ case "unresolved-location":
868
+ if (reason.source === "business_address") return "Business address details are not configured yet.";
869
+ return reason.source === "venue" ? "This map is hidden on your site until the venue has a location." : "This map is hidden on your site until you choose a place.";
870
+ case "editor-unpreviewable":
871
+ case "render-threw": return `Unable to render block kind "${reason.blockKind}".`;
872
+ }
873
+ }
874
+ /**
875
+ * The empty-page notice. Authoring-only for the same reason as the block
876
+ * diagnostics: "No blocks found." is a message for whoever is building the
877
+ * page, not for whoever is reading it.
878
+ */
879
+ function presentEmptyPage(audience) {
880
+ if (audience === "public") return null;
881
+ return diagnostic("No blocks found.");
882
+ }
883
+ function diagnostic(message) {
884
+ return /* @__PURE__ */ jsx("div", {
885
+ className: "rb-p-6 rb-caption",
886
+ style: textColorStyle("mutedText"),
887
+ children: message
888
+ });
889
+ }
890
+ //#endregion
891
+ //#region ../blocks/src/pageRenderingMode.ts
892
+ var MissingBlockOverrideError = class extends Error {
893
+ constructor(blockKind) {
894
+ super(`Override-only rendering requires an override for block kind "${blockKind}".`);
895
+ this.blockKind = blockKind;
896
+ this.code = "missing_block_override";
897
+ this.name = "MissingBlockOverrideError";
898
+ }
899
+ };
900
+ function isOverrideOnlyResourceInput(props) {
901
+ return props.rendering?.kind === "overrides-only";
902
+ }
903
+ function isTokensOnlyResourceInput(props) {
904
+ return props.rendering?.kind === "tokens-only";
905
+ }
906
+ function resolvePageThemeResources(props) {
907
+ if (isOverrideOnlyResourceInput(props)) return { kind: "unavailable" };
908
+ if (isTokensOnlyResourceInput(props)) return {
909
+ kind: "available",
910
+ tokens: props.themeTokens
911
+ };
912
+ return {
913
+ kind: "available",
914
+ tokens: props.themeTokens ?? buildThemeRuntime(props.theme).tokens,
915
+ config: props.theme
916
+ };
917
+ }
918
+ function requireBlockOverride(resources, override, blockKind) {
919
+ if (resources.kind === "unavailable" && !override) throw new MissingBlockOverrideError(blockKind);
920
+ }
921
+ function overrideThemeProps(resources) {
922
+ return resources.kind === "available" ? {
923
+ theme: resources.tokens,
924
+ ...resources.config ? { themeConfig: resources.config } : {}
925
+ } : {};
926
+ }
927
+ function requireThemeResources(resources, blockKind) {
928
+ if (resources.kind === "unavailable") throw new MissingBlockOverrideError(blockKind);
929
+ return resources;
930
+ }
931
+ //#endregion
932
+ //#region ../blocks/src/pageRendererBoundaries.tsx
933
+ function joinSlotsByPair(slots) {
934
+ return new Map(slots.map((slot) => [joinSlotKey(slot.previousBlockId, slot.nextBlockId), slot]));
935
+ }
936
+ function joinSlotBetween(previousBlockId, nextBlockId, slots) {
937
+ if (!previousBlockId || !nextBlockId) return null;
938
+ return slots.get(joinSlotKey(previousBlockId, nextBlockId)) ?? null;
939
+ }
940
+ /**
941
+ * The markup at one join: the painted boundary element when the join draws,
942
+ * then whatever `renderJoin` adds. Null when there is nothing to render.
943
+ */
944
+ function renderJoinSlot(input) {
945
+ const { slot } = input;
946
+ if (!slot) return null;
947
+ const layout = renderedJoinLayout(slot.join);
948
+ const painted = slot.join && layout ? /* @__PURE__ */ jsx("div", {
949
+ "aria-hidden": "true",
950
+ "data-block-boundary": "",
951
+ "data-boundary-id": slot.join.boundaryId,
952
+ "data-boundary-previous-block-id": slot.previousBlockId,
953
+ "data-boundary-next-block-id": slot.nextBlockId,
954
+ "data-boundary-treatment": slot.join.treatment,
955
+ "data-boundary-placement": layout.placement,
956
+ style: boundaryPaintStyle(layout.paint)
957
+ }, `${input.blockKey}:boundary`) : null;
958
+ const extra = input.renderJoin?.({
959
+ previousBlockId: slot.previousBlockId,
960
+ nextBlockId: slot.nextBlockId,
961
+ join: slot.join
962
+ });
963
+ if (!painted && (extra === null || extra === void 0)) return null;
964
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [painted, extra] }, `${input.blockKey}:join`);
965
+ }
966
+ /**
967
+ * The one render-edge place a theme token becomes CSS.
968
+ */
969
+ function themeTokenCss(token) {
970
+ return `rgb(var(--tb-${token}))`;
971
+ }
972
+ function boundaryPaintStyle(paint) {
973
+ return {
974
+ "--boundary-shape-paint": themeTokenCss(paint.shape),
975
+ ...paint.band ? { "--boundary-band-paint": themeTokenCss(paint.band) } : {}
976
+ };
977
+ }
978
+ /**
979
+ * Reserve attributes and variables for a block wrapper, from the joins on
980
+ * either side. A join's `before` reserve sits inside its previous section, so
981
+ * it pads the bottom of the block above the join; its `after` reserve pads the
982
+ * top of the block below. Joins that do not draw reserve nothing.
983
+ */
984
+ function blockBoundaryReserves(input) {
985
+ const top = reserveOnSide(input.before, "after");
986
+ const bottom = reserveOnSide(input.after, "before");
987
+ const style = {
988
+ ...top ? { "--site-style-boundary-before-reserve": top.length } : {},
989
+ ...bottom ? { "--site-style-boundary-after-reserve": bottom.length } : {}
990
+ };
991
+ return {
992
+ topPlacement: top?.placement,
993
+ bottomPlacement: bottom?.placement,
994
+ fieldSeam: input.before?.fieldsMeet ? "top" : void 0,
995
+ style: top || bottom ? style : void 0
996
+ };
997
+ }
998
+ /** The reserve one join needs on one side of itself, if it draws at all. */
999
+ function reserveOnSide(slot, side) {
1000
+ const layout = renderedJoinLayout(slot?.join ?? null);
1001
+ const length = layout?.reserves[side] ?? null;
1002
+ return layout && length ? {
1003
+ length,
1004
+ placement: layout.placement
1005
+ } : null;
1006
+ }
1007
+ function pageBlockPosition(index, blockCount) {
1008
+ if (blockCount <= 1) return "only";
1009
+ if (index === 0) return "first";
1010
+ if (index === blockCount - 1) return "last";
1011
+ return "middle";
1012
+ }
1013
+ //#endregion
1014
+ //#region ../blocks/src/pageRendererContracts.ts
1015
+ /** Loader provenance gates admission; block rendering reads its own resolved data and shared runtime. */
1016
+ function sameBlockRenderDataContext(previous, current, blockId) {
1017
+ if (previous === current) return true;
1018
+ if (!previous || !current) return false;
1019
+ const keys = Object.keys(previous).filter(isSharedRenderContextKey);
1020
+ return keys.length === Object.keys(current).filter(isSharedRenderContextKey).length && keys.every((key) => Object.prototype.hasOwnProperty.call(current, key) && Object.is(Reflect.get(previous, key), Reflect.get(current, key))) && (!blockId || previous.resolvedData?.[blockId] === current.resolvedData?.[blockId]);
1021
+ }
1022
+ function isSharedRenderContextKey(key) {
1023
+ return key !== "resolvedData" && key !== "prefetchedBlockData" && key !== "loaderSnapshot";
1024
+ }
1025
+ function buildPageRendererRootRuntime(dataContext) {
1026
+ const { siteId = null, siteName, pageId = null, pathname = null, previewStage = "published", apiBaseUrl = null, portalToken = null, readAuthority, openingHours, siteTerms, mailingList = { tag: "not_configured" }, loaderFailures = {} } = dataContext ?? {};
1027
+ return {
1028
+ siteId,
1029
+ demoEmailSuppressed: resolveDemoEmailSuppression(dataContext),
1030
+ siteName,
1031
+ site: publicLocationRuntime(dataContext),
1032
+ pageId,
1033
+ pathname,
1034
+ ...pageBookingRuntime(dataContext),
1035
+ ...pageRuntimeContext(dataContext),
1036
+ previewStage,
1037
+ apiBaseUrl,
1038
+ portalToken,
1039
+ readAuthority,
1040
+ openingHours,
1041
+ siteTerms,
1042
+ mailingList,
1043
+ loaderFailures
1044
+ };
1045
+ }
1046
+ function publicLocationRuntime(context) {
1047
+ return {
1048
+ businessAddress: context?.businessLocation ?? null,
1049
+ venuesById: context?.venuesById ?? {},
1050
+ siteCountry: context?.siteCountry ?? null
1051
+ };
1052
+ }
1053
+ function resolveDemoEmailSuppression(dataContext) {
1054
+ return dataContext?.demoEmailSuppressed === true;
1055
+ }
1056
+ function pageRuntimeContext(dataContext) {
1057
+ return {
1058
+ interactionContext: dataContext?.interactionContext,
1059
+ dateContext: pageDateRuntimeContext(dataContext),
1060
+ now: dataContext?.now,
1061
+ template: dataContext?.template ?? { kind: "page" }
1062
+ };
1063
+ }
1064
+ function pageDateRuntimeContext(dataContext) {
1065
+ return dataContext?.dateContext ?? resolveDateRuntimeContext(dataContext?.bookingTimeZone);
1066
+ }
1067
+ /** Booking context keeps its defaults together across SSR and authoring. */
1068
+ function pageBookingRuntime(context) {
1069
+ const { bookingTimeZone, bookingOfferingPresets = [], appointmentServicePathPrefix = null } = context ?? {};
1070
+ return {
1071
+ bookingTimeZone,
1072
+ bookingOfferingPresets,
1073
+ appointmentServicePathPrefix
1074
+ };
1075
+ }
1076
+ //#endregion
1077
+ //#region ../blocks/src/pageRenderDiagnostics.ts
1078
+ /**
1079
+ * Emits one structured record per omitted block, per server render pass.
1080
+ *
1081
+ * Server-only by decision D3: public pages are server-rendered, and this is the
1082
+ * runtime whose logger transport reaches centralised collection. A browser-side
1083
+ * record would not, and re-render/hydration would multiply it. The cost is that
1084
+ * an omission only a client navigation can see goes unlogged.
1085
+ *
1086
+ * Deliberately *not* inside the plan's `useMemo` — React makes no promises about
1087
+ * when a memo recomputes, so a log placed there is neither reliable nor bounded.
1088
+ */
1089
+ function logOmittedBlocks(plan, dataContext) {
1090
+ if (typeof window !== "undefined") return;
1091
+ if (plan.omitted.length === 0) return;
1092
+ const page = {
1093
+ siteId: dataContext?.siteId ?? null,
1094
+ pageId: dataContext?.pageId ?? null
1095
+ };
1096
+ if (plan.entries.length === 0) {
1097
+ logger.error("blocks.pageRenderer.pageFullyOmitted", {
1098
+ ...page,
1099
+ omittedCount: plan.omitted.length,
1100
+ blocks: plan.omitted.map((omission) => ({
1101
+ blockId: omission.blockId,
1102
+ blockKind: omission.blockKind,
1103
+ reason: omission.reason.kind
1104
+ }))
1105
+ });
1106
+ debugOmittedCustomBlocks(plan);
1107
+ return;
1108
+ }
1109
+ for (const omission of plan.omitted) logger.warn("blocks.pageRenderer.blockOmitted", {
1110
+ ...page,
1111
+ blockId: omission.blockId,
1112
+ blockKind: omission.blockKind,
1113
+ reason: omission.reason.kind,
1114
+ admissionError: omission.reason.kind === "invalid-admission" ? omission.reason.error.kind : null
1115
+ });
1116
+ debugOmittedCustomBlocks(plan);
1117
+ }
1118
+ /**
1119
+ * Unlike the plan-time omissions this one genuinely can fire per re-render —
1120
+ * it is raised where the failure happens, and no once-ness is claimed for it.
1121
+ */
1122
+ function logRenderThrew(block, dataContext) {
1123
+ if (typeof window !== "undefined") return;
1124
+ logger.warn("blocks.pageRenderer.blockRenderThrew", {
1125
+ siteId: dataContext?.siteId ?? null,
1126
+ pageId: dataContext?.pageId ?? null,
1127
+ blockId: block.id ?? null,
1128
+ blockKind: block.kind
1129
+ });
1130
+ }
1131
+ /**
1132
+ * Opt-in developer affordance for tracking down custom-block resolution.
1133
+ *
1134
+ * Driven off the plan's omissions so it stays reachable on **public** renders —
1135
+ * "my custom block doesn't show up on the live site" is the exact situation it
1136
+ * exists for, and that is the render where the block is now silently absent.
1137
+ */
1138
+ function debugOmittedCustomBlocks(plan) {
1139
+ if (!shouldDebugCustomBlocks()) return;
1140
+ for (const omission of plan.omitted) {
1141
+ if (!omission.blockKind.startsWith("custom.")) continue;
1142
+ debugCustomBlockResolution(omission.reason.kind, omission.blockId, omission.blockKind, omission.debug);
1143
+ }
1144
+ }
1145
+ /** The authoring-side equivalent, where the block stays in the entry list. */
1146
+ function debugCustomBlockDiagnostic(reason, block, debug) {
1147
+ if (!block.kind.startsWith("custom.") || !shouldDebugCustomBlocks()) return;
1148
+ debugCustomBlockResolution(reason.kind, block.id ?? null, block.kind, debug);
1149
+ }
1150
+ function debugCustomBlockResolution(reasonKind, blockId, blockKind, debug) {
1151
+ try {
1152
+ console.warn(reasonKind === "missing-definition" ? "[blocks:PageRenderer] custom block definition missing" : "[blocks:PageRenderer] custom block has no layout/variants and no override", {
1153
+ blockId,
1154
+ blockKind,
1155
+ hasOverride: debug.hasOverride,
1156
+ sdkCustomBlocksCount: debug.sdkCustomBlocksCount,
1157
+ dbCustomBlocksCount: debug.dbCustomBlocksCount,
1158
+ manifestKeys: debug.manifestKeys
1159
+ });
1160
+ } catch {}
1161
+ }
1162
+ function shouldDebugCustomBlocks() {
1163
+ try {
1164
+ return globalThis.process?.env?.DEBUG_CUSTOM_BLOCKS === "1";
1165
+ } catch {
1166
+ return false;
1167
+ }
1168
+ }
1169
+ //#endregion
1170
+ //#region ../blocks/src/system/blocks/offerings-preview/photoCount.ts
1171
+ /** Count the selected cards, without loading or selecting again. */
1172
+ function offeringsPreviewPhotoCount(listing) {
1173
+ switch (listing.kind) {
1174
+ case "no-groups":
1175
+ case "nothing-to-show": return 0;
1176
+ case "by-date": return listing.items.filter(({ item }) => hasPhoto(item)).length;
1177
+ case "by-type": return listing.groups.reduce((count, load) => count + groupPhotoCount(load), 0);
1178
+ default: return assertNever(listing);
1179
+ }
1180
+ }
1181
+ function groupPhotoCount(load) {
1182
+ switch (load.kind) {
1183
+ case "empty":
1184
+ case "failed": return 0;
1185
+ case "items": return load.items.filter(hasPhoto).length;
1186
+ default: return assertNever(load);
1187
+ }
1188
+ }
1189
+ function hasPhoto(item) {
1190
+ switch (item.kind) {
1191
+ case "event": return Boolean(item.event.presentation?.image);
1192
+ case "run": return Boolean(item.run.representative.presentation?.image);
1193
+ default: return assertNever(item);
1194
+ }
1195
+ }
1196
+ //#endregion
1197
+ //#region ../blocks/src/system/manifest/hydrateLinks.ts
1198
+ /**
1199
+ * Hydrates link objects within block content using the provided route map. Returns
1200
+ * the original content reference when no mutations are required to avoid unnecessary renders.
1201
+ */
1202
+ function hydrateManifestLinks(manifest, content, routes, pagesByIdentifier, entriesByIdentifier) {
1203
+ if (!routes || !manifest?.fields?.length) return content;
1204
+ return hydrateLinks(content, routes, pagesByIdentifier, entriesByIdentifier);
1205
+ }
1206
+ /** Hydrate identifier-aware links in data loaded after manifest content. */
1207
+ function hydrateLinks(value, routes, pagesByIdentifier, entriesByIdentifier) {
1208
+ return hydrateValue(value, {
1209
+ routes,
1210
+ pagesByIdentifier,
1211
+ entriesByIdentifier
1212
+ });
1213
+ }
1214
+ /**
1215
+ * Hydrate links only inside resolved booking-consent documents. Loader payloads are
1216
+ * otherwise opaque and may legitimately contain objects that resemble link values.
1217
+ */
1218
+ function hydrateResolvedBookingConsentLinks(value, routes, pagesByIdentifier, entriesByIdentifier) {
1219
+ return hydrateResolvedBookingConsentValue(value, {
1220
+ routes,
1221
+ pagesByIdentifier,
1222
+ entriesByIdentifier
1223
+ });
1224
+ }
1225
+ function hydrateResolvedBookingConsentValue(value, context) {
1226
+ if (Array.isArray(value)) {
1227
+ const hydratedItems = value.map((item) => hydrateResolvedBookingConsentValue(item, context));
1228
+ return hydratedItems.every((item, index) => item === value[index]) ? value : hydratedItems;
1229
+ }
1230
+ if (!isRecord$1(value)) return value;
1231
+ if (isBookingConsentCarrier(value)) {
1232
+ const agreement = hydrateValue(value.agreement, context);
1233
+ return agreement === value.agreement ? value : {
1234
+ ...value,
1235
+ agreement
1236
+ };
1237
+ }
1238
+ const hydratedEntries = Object.entries(value).map(([key, entry]) => [key, hydrateResolvedBookingConsentValue(entry, context)]);
1239
+ return hydratedEntries.every(([key, entry]) => entry === value[key]) ? value : Object.fromEntries(hydratedEntries);
1240
+ }
1241
+ function isBookingConsentCarrier(value) {
1242
+ return bookingConsentCarrierSchema.safeParse(value).success;
1243
+ }
1244
+ function hydrateValue(value, context) {
1245
+ try {
1246
+ if (Array.isArray(value)) {
1247
+ const resolvedItems = value.map((item) => hydrateValue(item, context));
1248
+ return resolvedItems.every((item, index) => item === value[index]) ? value : resolvedItems;
1249
+ }
1250
+ if (isRecord$1(value)) {
1251
+ if (isInternalLink(value)) return hydrateInternalLink(value, context.routes);
1252
+ if (isPageLink(value)) return hydratePageLink(value, context);
1253
+ if (isEntryLink(value)) return hydrateEntryLink(value, context);
1254
+ const resolvedEntries = Object.entries(value).map(([key, entry]) => [key, hydrateValue(entry, context)]);
1255
+ return resolvedEntries.every(([key, entry]) => entry === value[key]) ? value : Object.fromEntries(resolvedEntries);
1256
+ }
1257
+ return value;
1258
+ } catch (err) {
1259
+ console.error("[hydrateLinks] Error hydrating value:", err, value);
1260
+ return value;
1261
+ }
1262
+ }
1263
+ function hydrateInternalLink(link, routes) {
1264
+ const resolved = resolveRouteTarget(link.routeId, routes);
1265
+ if (!resolved) return link;
1266
+ const nextHref = resolved.href;
1267
+ const currentHref = typeof link.href === "string" && link.href.length > 0 ? link.href : null;
1268
+ const nextUpdatedAt = resolved.updatedAt;
1269
+ const updates = {};
1270
+ if (nextHref && nextHref !== currentHref) updates.href = nextHref;
1271
+ if (nextUpdatedAt && link.updatedAt !== nextUpdatedAt) updates.updatedAt = nextUpdatedAt;
1272
+ return Object.keys(updates).length > 0 ? {
1273
+ ...link,
1274
+ ...updates
1275
+ } : link;
1276
+ }
1277
+ function isInternalLink(value) {
1278
+ if (value.kind !== "internal") return false;
1279
+ if (typeof value.routeId !== "string" || value.routeId.length === 0) return false;
1280
+ return true;
1281
+ }
1282
+ function isPageLink(value) {
1283
+ if (value.kind !== "page") return false;
1284
+ if (typeof value.identifier !== "string" || value.identifier.length === 0) return false;
1285
+ return true;
1286
+ }
1287
+ function hydratePageLink(link, context) {
1288
+ const resolved = resolvePageRouteTarget(link, context);
1289
+ if (!resolved) return link;
1290
+ return {
1291
+ ...link,
1292
+ href: resolved.href,
1293
+ routeId: resolved.routeId
1294
+ };
1295
+ }
1296
+ function isEntryLink(value) {
1297
+ if (value.kind !== "entry") return false;
1298
+ if (typeof value.contentType !== "string" || value.contentType.length === 0) return false;
1299
+ if (typeof value.identifier !== "string" || value.identifier.length === 0) return false;
1300
+ return true;
1301
+ }
1302
+ function hydrateEntryLink(link, context) {
1303
+ const resolved = resolveEntryRouteTarget(link, context);
1304
+ if (!resolved) return link;
1305
+ return {
1306
+ ...link,
1307
+ href: resolved.href,
1308
+ routeId: resolved.routeId
1309
+ };
1310
+ }
1311
+ //#endregion
1312
+ //#region ../blocks/src/system/manifest/resolveBlockData.ts
1313
+ function resolveBlockData(blockId, dataLoaders, dataContext, routes) {
1314
+ const raw = blockId ? dataContext?.resolvedData?.[blockId] : void 0;
1315
+ if (isRecord$1(raw)) return routes ? hydrateResolvedBookingConsentLinks(raw, routes, dataContext?.pagesByIdentifier, dataContext?.entriesByIdentifier) : raw;
1316
+ return dataLoaders && typeof dataLoaders === "object" && Object.keys(dataLoaders).length > 0 ? {} : void 0;
1317
+ }
1318
+ //#endregion
1319
+ //#region ../blocks/src/system/runtime/nodes/newsletter-form.block-submission.ts
1320
+ /** Authorise one block source for both public and preview rendering. */
1321
+ function planNewsletterBlockSubmission(placement) {
1322
+ if (placement.stage === "published") {
1323
+ const sourceRef = buildMailingListSignupBlockSourceRef(placement.blockId, placement.selectedContentVersionId);
1324
+ return sourceRef ? {
1325
+ tag: "ready",
1326
+ sourceRef
1327
+ } : { tag: "unavailable" };
1328
+ }
1329
+ const published = placement.publishedPlacement;
1330
+ if (published === null) return placement.stage === "preview" ? { tag: "unpublished-form" } : { tag: "unavailable" };
1331
+ switch (published.kind) {
1332
+ case "incomplete": return { tag: "unpublished-settings" };
1333
+ case "published": return planNewsletterPreviewSubmission({
1334
+ blockId: placement.blockId,
1335
+ publishedContentId: published.id,
1336
+ renderedContent: placement.renderedContent,
1337
+ publishedContent: published.content
1338
+ });
1339
+ }
1340
+ }
1341
+ /** Decide whether the visible draft can safely cite the published placement. */
1342
+ function planNewsletterPreviewSubmission(placement) {
1343
+ if (!placement.publishedContentId) return { tag: "unpublished-form" };
1344
+ if (!placement.publishedContent) return { tag: "unpublished-settings" };
1345
+ const draft = parseMailingListPlacementTargeting(placement.renderedContent.targeting);
1346
+ const published = parseMailingListPlacementTargeting(placement.publishedContent.targeting);
1347
+ if (!draft.ok || !published.ok || !sameMailingListPlacementTargeting(draft.value, published.value)) return { tag: "unpublished-settings" };
1348
+ const sourceRef = buildMailingListSignupBlockSourceRef(placement.blockId, placement.publishedContentId);
1349
+ return sourceRef ? {
1350
+ tag: "ready",
1351
+ sourceRef
1352
+ } : { tag: "unpublished-settings" };
1353
+ }
1354
+ //#endregion
1355
+ //#region ../blocks/src/pageRenderPreparation.ts
1356
+ /** Reuse block preparation while keeping survivor/adjacency decisions page-wide. */
1357
+ function createPageRenderPreparationReader() {
1358
+ const memo = { current: null };
1359
+ return (input) => {
1360
+ memo.current = preparePageRenderEntries(input, memo.current);
1361
+ return memo.current.preparation;
1362
+ };
1363
+ }
1364
+ function preparePageRenderEntries(input, previous = null) {
1365
+ const admission = preparationAdmission(input);
1366
+ const prepared = admission.entries.map((entry) => [entry, readPreparedPlanEntry(entry, input, previous, admission.permission)]);
1367
+ const entries = prepared.map(([, value]) => value);
1368
+ const constructionFailures = entries.filter((candidate) => candidate.prepared.kind === "render-threw").map((candidate) => candidate.entry);
1369
+ const survivors = input.audience === "authoring" ? entries : entries.filter((candidate) => candidate.prepared.kind !== "render-threw" && candidate.prepared.kind !== "unresolved-location");
1370
+ return {
1371
+ input,
1372
+ byEntry: new Map(prepared),
1373
+ preparation: {
1374
+ entries: survivors,
1375
+ constructionFailures,
1376
+ joins: composeSurvivorJoins(input.plan, survivors, input.themeResources)
1377
+ }
1378
+ };
1379
+ }
1380
+ /** Admission always sees current loader provenance, even when block preparation can be reused. */
1381
+ function preparationAdmission(input) {
1382
+ const facts = readinessFactsFromLoaders("published", {
1383
+ prefetched: input.dataContext?.prefetchedBlockData,
1384
+ previewStage: input.dataContext?.previewStage,
1385
+ mailingList: input.dataContext?.mailingList,
1386
+ template: input.dataContext?.template ?? pageTemplateFromEntry(input.dataContext?.contentEntry)
1387
+ });
1388
+ const permission = input.dataContext?.businessLocationPermission ?? decideLocationSourcePermission("business_address", input.dataContext?.businessAddressVisibility);
1389
+ return {
1390
+ permission,
1391
+ entries: input.plan.entries.filter((entry) => input.audience === "authoring" || !entryNeedsSetup(entry, facts, input.dataContext?.interactionContext)).filter((entry) => isPublicSourcePermitted(entry, permission) || input.audience === "authoring" && permission.kind === "hidden")
1392
+ };
1393
+ }
1394
+ function readPreparedPlanEntry(entry, input, previous, permission) {
1395
+ const cached = previous?.byEntry.get(entry);
1396
+ if (cached && previous && samePreparationSettings(previous.input, input) && sameBlockRenderDataContext(previous.input.dataContext, input.dataContext, entry.block.id)) return cached;
1397
+ return preparedPlanEntry(entry, prepareSourceEntry(entry, input, permission));
1398
+ }
1399
+ function samePreparationSettings(previous, current) {
1400
+ return previous.audience === current.audience && previous.routeMap === current.routeMap && previous.themeResources === current.themeResources && previous.imageResolveContext === current.imageResolveContext;
1401
+ }
1402
+ /** Source availability is decided before constructing the block or its hydration props. */
1403
+ function prepareSourceEntry(entry, input, permission) {
1404
+ if (!isPublicSourcePermitted(entry, permission)) return {
1405
+ kind: "hidden-business-location",
1406
+ businessDetailsHref: input.dataContext?.authoringBusinessDetailsHref ?? null
1407
+ };
1408
+ if (entry.block.kind === "block.location-map") {
1409
+ const content = entry.renderableContent;
1410
+ const resolved = resolveLocationMapLocation({
1411
+ location: content.location,
1412
+ locationSource: typeof content.locationSource === "string" ? content.locationSource : null,
1413
+ venueId: typeof content.venueId === "string" ? content.venueId : null,
1414
+ businessAddress: input.dataContext?.businessLocation,
1415
+ venuesById: input.dataContext?.venuesById
1416
+ });
1417
+ if (resolved.kind === "unresolved") return {
1418
+ kind: "unresolved-location",
1419
+ source: resolved.source
1420
+ };
1421
+ }
1422
+ return prepareEntry(entry, input);
1423
+ }
1424
+ /** No source data, override component or wrapper is touched for a hidden map. */
1425
+ function isPublicSourcePermitted(entry, permission) {
1426
+ if (entry.block.kind !== "block.location-map") return true;
1427
+ const rawSource = entry.renderableContent.locationSource;
1428
+ return normalizeLocationMapSource(typeof rawSource === "string" ? rawSource : null) !== "business_address" || permission.kind === "permitted";
1429
+ }
1430
+ function entryNeedsSetup(entry, facts, interaction) {
1431
+ return entry.kind === "renderable" && entry.definition.readiness?.assess(entry.renderableContent, facts, interaction).kind === "NeedsSetup";
1432
+ }
1433
+ /**
1434
+ * The only place joins are composed. Plan-time omissions were already
1435
+ * re-pointed by the plan; construction failures are re-pointed here by the
1436
+ * same primitive, so `[A, B, C]` losing B still gets an A→C join. Each
1437
+ * survivor is then classified from its final content.
1438
+ */
1439
+ function composeSurvivorJoins(plan, survivors, themeResources) {
1440
+ return composePageJoins({
1441
+ joins: retargetJoinsAcrossOmissions({
1442
+ joins: plan.runtimeJoins,
1443
+ originalBlocks: plan.entries.map((planned) => planned.block),
1444
+ survivingBlocks: new Set(survivors.map((survivor) => survivor.entry.block))
1445
+ }),
1446
+ survivors: survivors.map(({ entry }) => ({
1447
+ id: entry.block.id,
1448
+ kind: entry.block.kind,
1449
+ content: boundaryClassificationContent(entry, themeResources)
1450
+ }))
1451
+ });
1452
+ }
1453
+ /**
1454
+ * The content a join is classified from must be the content that paints the
1455
+ * section. The default block renderer layers the theme's per-block style
1456
+ * defaults (`theme.blockOverrides[kind].styles`, background included) under
1457
+ * the block's own `_sectionStyles`, so classify that same projection. An
1458
+ * override component renders its own markup from the unmerged content.
1459
+ */
1460
+ function boundaryClassificationContent(entry, themeResources) {
1461
+ if (entry.kind !== "renderable" || entry.override) return entry.renderableContent;
1462
+ return mergeContentWithBlockStyleOverrides(entry.renderableContent, themeResources.kind === "available" ? themeResources.config : void 0, entry.block.kind);
1463
+ }
1464
+ function prepareEntry(entry, input) {
1465
+ if (entry.kind !== "renderable") return { kind: "plan-decided" };
1466
+ const draftContent = previewableEditorContent(entry);
1467
+ if (draftContent === null) return { kind: "editor-unpreviewable" };
1468
+ try {
1469
+ return buildPreparedContent(entry, draftContent, input);
1470
+ } catch {
1471
+ return { kind: "render-threw" };
1472
+ }
1473
+ }
1474
+ /**
1475
+ * Editor admission validates raw in-flight values without minting a renderable
1476
+ * proof. Returns `null` when even relaxed validation rejects the draft.
1477
+ */
1478
+ function previewableEditorContent(entry) {
1479
+ if (entry.block.presentationAdmission.kind !== "editor") return entry.renderableContent;
1480
+ const draft = validateManifestDraft(compileManifestContentContract(entry.definition.manifest), entry.renderableContent);
1481
+ return draft.kind === "previewable" ? draft.data : null;
1482
+ }
1483
+ function buildPreparedContent(entry, content, input) {
1484
+ const { dataContext } = input;
1485
+ const block = entry.block;
1486
+ const routes = input.routeMap ?? dataContext?.routes;
1487
+ const hydratedContent = routes ? hydrateManifestLinks(entry.definition.manifest, content, routes, dataContext?.pagesByIdentifier, dataContext?.entriesByIdentifier) : content;
1488
+ const resolved = resolveBlockData(block.id, entry.definition.dataLoaders, dataContext, routes);
1489
+ return {
1490
+ kind: "content",
1491
+ baseProps: preparedBlockProps(entry, hydratedContent, resolved, input),
1492
+ component: entry.override ? void 0 : makeDefaultBlockComponent({ manifest: entry.definition.manifest }),
1493
+ hasResolvedData: !!resolved && typeof resolved === "object" && Object.keys(resolved).length > 0,
1494
+ routes
1495
+ };
1496
+ }
1497
+ function preparedBlockProps(entry, content, data, input) {
1498
+ return {
1499
+ ...buildBlockOverrideProps({
1500
+ content: arrangementResolvedContent(entry.block.kind, content, data, input.dataContext),
1501
+ data: arrangementResolvedData(entry.block.kind, content, data),
1502
+ block: entry.block,
1503
+ themeResources: input.themeResources,
1504
+ dataContext: input.dataContext,
1505
+ imageResolveContext: input.imageResolveContext,
1506
+ routeMap: input.routeMap
1507
+ }),
1508
+ bookingTimeZone: input.dataContext?.bookingTimeZone
1509
+ };
1510
+ }
1511
+ /**
1512
+ * The serialisable prop bundle every block component and override receives.
1513
+ *
1514
+ * Shared by the with-definition and override-without-definition paths, which
1515
+ * differ only in the content and resolved data they pass in.
1516
+ */
1517
+ function buildBlockOverrideProps(input) {
1518
+ const { block, dataContext } = input;
1519
+ return {
1520
+ content: bindArrangementInkPolicy(input.content, input.themeResources),
1521
+ dateContext: pageDateRuntimeContext(dataContext),
1522
+ now: dataContext?.now,
1523
+ ...overrideThemeProps(input.themeResources),
1524
+ data: input.data,
1525
+ ...blockSessionProps(dataContext),
1526
+ ...blockSubjectProps(dataContext),
1527
+ imageResolveContext: input.imageResolveContext,
1528
+ linkResolveContext: {
1529
+ routes: input.routeMap ?? dataContext?.routes,
1530
+ pagesByIdentifier: dataContext?.pagesByIdentifier,
1531
+ entriesByIdentifier: dataContext?.entriesByIdentifier,
1532
+ stage: dataContext?.previewStage
1533
+ },
1534
+ blockId: block.id ?? null,
1535
+ contentVersionId: block.contentVersionId ?? null,
1536
+ ...newsletterBlockProps(block, input.content, dataContext?.previewStage),
1537
+ blockKind: block.kind
1538
+ };
1539
+ }
1540
+ function newsletterBlockProps(block, renderedContent, stage) {
1541
+ if (block.kind !== "block.newsletter-signup") return {};
1542
+ return { newsletterBlockSubmission: planNewsletterBlockSubmission({
1543
+ blockId: block.id,
1544
+ selectedContentVersionId: block.contentVersionId ?? null,
1545
+ publishedPlacement: block.publishedPlacement,
1546
+ renderedContent,
1547
+ stage
1548
+ }) };
1549
+ }
1550
+ /** Site, transport and session context a block needs to call back to the API. */
1551
+ function blockSessionProps(dataContext) {
1552
+ const context = dataContext ?? {};
1553
+ return {
1554
+ siteId: context.siteId,
1555
+ interactionContext: context.interactionContext,
1556
+ apiBaseUrl: context.apiBaseUrl,
1557
+ supabaseUrl: context.supabaseUrl,
1558
+ portalToken: context.portalToken ?? null,
1559
+ previewToken: context.previewToken ?? null,
1560
+ readAuthority: context.readAuthority,
1561
+ stage: context.previewStage
1562
+ };
1563
+ }
1564
+ /** What this render is *about* — the entry, occurrence or surface in scope. */
1565
+ function blockSubjectProps(dataContext) {
1566
+ return {
1567
+ occurrenceContext: dataContext?.occurrenceContext ?? null,
1568
+ entrySubrouteContext: dataContext?.entrySubrouteContext ?? null,
1569
+ contentEntry: dataContext?.contentEntry ?? null,
1570
+ pageSurface: dataContext?.pageSurface ?? null,
1571
+ subject: dataContext?.subject ?? null
1572
+ };
1573
+ }
1574
+ function arrangementResolvedData(kind, content, data) {
1575
+ if (kind !== "block.testimonials" || content._effectiveLook === void 0 || !Array.isArray(data?.entries)) return data;
1576
+ return {
1577
+ ...data,
1578
+ entries: content._quoteCount === null ? data.entries : data.entries.slice(0, Number(content._quoteCount))
1579
+ };
1580
+ }
1581
+ function arrangementResolvedContent(kind, content, data, context) {
1582
+ if (content._effectiveLook === void 0 || !data || kind !== "block.offerings-preview" && kind !== "block.appointment-services") return content;
1583
+ if (kind === "block.appointment-services") return appointmentArrangementContent(content, data, context);
1584
+ const normalized = normalizeBlockContent(offeringsPreviewBlockDefinition, content);
1585
+ const now = new Date(readRuntimeNow(context?.now));
1586
+ const listing = buildLoadedOfferingsPreviewListing({
1587
+ now,
1588
+ listingMode: offeringsListingFor(cardListArrangementForContent(content) ?? "legacy"),
1589
+ routeCandidates: publicRouteCandidatesSchema.safeParse(data.routeCandidates).data,
1590
+ ...normalized,
1591
+ presets: context?.bookingOfferingPresets,
1592
+ catalogueEvents: readPublicEvents(data.catalogueEvents),
1593
+ wholeSeriesRunEvents: readPublicEvents(data.wholeSeriesRunEvents),
1594
+ ...Object.fromEntries(OFFERINGS_PREVIEW_EVENT_PRESET_DEFINITIONS.map((definition) => [definition.dataKey, readPublicEvents(data[definition.dataKey])]))
1595
+ });
1596
+ return withCardListPhotoCount({
1597
+ ...content,
1598
+ _offeringsPreviewInput: {
1599
+ kind: "prepared",
1600
+ listing,
1601
+ now
1602
+ }
1603
+ }, content.showPhotos === false ? 0 : offeringsPreviewPhotoCount(listing));
1604
+ }
1605
+ function readPublicEvents(value) {
1606
+ const parsed = publicEventsArraySchema.safeParse(value);
1607
+ return parsed.success ? parsed.data : void 0;
1608
+ }
1609
+ function appointmentArrangementContent(content, data, context) {
1610
+ const view = buildAppointmentServicesView({
1611
+ arrangement: cardListArrangementForContent(content),
1612
+ services: data.services,
1613
+ categoryId: content.categoryId,
1614
+ pathname: context?.pathname,
1615
+ servicePathPrefix: context?.appointmentServicePathPrefix
1616
+ });
1617
+ const rows = view.kind === "items" ? view.rows : view.kind === "groups" ? view.groups.flatMap((group) => group.rows) : [];
1618
+ const photoCount = content.showPhotos === false ? 0 : rows.filter((row) => row.media).length;
1619
+ return withCardListPhotoCount({
1620
+ ...content,
1621
+ _appointmentServicesView: view
1622
+ }, photoCount);
1623
+ }
1624
+ function withCardListPhotoCount(content, photoCount) {
1625
+ const hooks = typeof content._lookHooks === "object" && content._lookHooks !== null ? content._lookHooks : {};
1626
+ return {
1627
+ ...content,
1628
+ _lookHooks: {
1629
+ ...hooks,
1630
+ "data-has-photo": String(photoCount > 0),
1631
+ "data-photo-count": String(photoCount)
1632
+ }
1633
+ };
1634
+ }
1635
+ function cardListArrangementForContent(content) {
1636
+ const hooks = content._lookHooks;
1637
+ if (typeof hooks !== "object" || hooks === null || !("data-arrangement" in hooks)) return void 0;
1638
+ const arrangement = hooks["data-arrangement"];
1639
+ switch (arrangement) {
1640
+ case "cards":
1641
+ case "lead-support":
1642
+ case "index":
1643
+ case "sequence":
1644
+ case "plates":
1645
+ case "slides":
1646
+ case "track": return arrangement;
1647
+ default: return;
1648
+ }
1649
+ }
1650
+ function preparedPlanEntry(entry, prepared) {
1651
+ return {
1652
+ entry: entry.kind === "renderable" && prepared.kind === "content" ? {
1653
+ ...entry,
1654
+ renderableContent: prepared.baseProps.content
1655
+ } : entry,
1656
+ prepared
1657
+ };
1658
+ }
1659
+ /** Compiled Looks share the render's authority, including transported item contexts. */
1660
+ function bindArrangementInkPolicy(content, theme) {
1661
+ const policy = theme.kind === "available" ? theme.tokens.solvedInks ?? "withhold" : "withhold";
1662
+ return Object.fromEntries(Object.entries(content).map(([key, value]) => [key, key === "_effectiveLook" || key === "_arrangementLooks" ? parseSurfaceTree(value, policy) : value]));
1663
+ }
1664
+ //#endregion
1665
+ //#region ../blocks/src/BlockErrorBoundary.tsx
1666
+ /**
1667
+ * Catches a throw from inside a block component's own render.
1668
+ *
1669
+ * `preparePageRender` guards everything that happens while *building* a block's
1670
+ * element; this covers the part React runs afterwards, which no try/catch can
1671
+ * reach. Without it one bad block takes the whole page down.
1672
+ *
1673
+ * Error boundaries have to be classes, and a class in a React Server Component
1674
+ * tree is called without `new`, so this file has to be a client module. Which is
1675
+ * also why it imports nothing from the rest of the package: the bundler groups
1676
+ * modules into chunks by which entries reach them, so importing
1677
+ * `pageRenderAudience` or `pageRenderDiagnostics` here would put them in a
1678
+ * chunk marked `"use client"` and turn `presentEmptyPage`, `logOmittedBlocks`
1679
+ * and friends into client references that the server can no longer call. The
1680
+ * fallback node and the log record come in as props instead.
1681
+ *
1682
+ * See the "Render Audiences" section of the package README for what this does
1683
+ * and does not catch on the server.
1684
+ */
1685
+ function createBlockErrorBoundary() {
1686
+ if (typeof React$1.Component !== "function") return function ServerBlockErrorBoundary({ children }) {
1687
+ return children;
1688
+ };
1689
+ return class ClientBlockErrorBoundary extends React$1.Component {
1690
+ constructor(props) {
1691
+ super(props);
1692
+ this.state = {
1693
+ failed: false,
1694
+ resetKey: props.resetKey
1695
+ };
1696
+ }
1697
+ static getDerivedStateFromError() {
1698
+ return { failed: true };
1699
+ }
1700
+ static getDerivedStateFromProps(props, state) {
1701
+ if (props.resetKey === state.resetKey) return null;
1702
+ return {
1703
+ failed: false,
1704
+ resetKey: props.resetKey
1705
+ };
1706
+ }
1707
+ componentDidCatch(error) {
1708
+ try {
1709
+ console.error("blocks.pageRenderer.blockRenderThrew", {
1710
+ ...this.props.record,
1711
+ message: error instanceof Error ? error.message : String(error)
1712
+ });
1713
+ } catch {}
1714
+ }
1715
+ render() {
1716
+ return this.state.failed ? this.props.fallback : this.props.children;
1717
+ }
1718
+ };
1719
+ }
1720
+ const BlockErrorBoundary = createBlockErrorBoundary();
1721
+ //#endregion
1722
+ //#region ../blocks/src/PageRenderer.tsx
1723
+ function EditorPageRenderer(props) {
1724
+ const readPage = React$1.useMemo(createEditorPresentationPageReader, []);
1725
+ const page = React$1.useMemo(() => readPage(props.page), [props.page, readPage]);
1726
+ const { previewAs, ...rendererProps } = props;
1727
+ return /* @__PURE__ */ jsx(PageRendererCore, { ...usePageDateRuntime({
1728
+ ...rendererProps,
1729
+ page,
1730
+ audience: previewAs === "visitor" ? "public" : "authoring"
1731
+ }) });
1732
+ }
1733
+ function PageRendererCore(props) {
1734
+ const { page, audience, dataContext, routeMap } = props;
1735
+ const imageResolveContext = React$1.useMemo(() => resolvePageRendererImageResolveContext(dataContext), [
1736
+ dataContext?.imageResolveContext,
1737
+ dataContext?.mediaAssets,
1738
+ dataContext?.siteId,
1739
+ dataContext?.supabaseUrl
1740
+ ]);
1741
+ const plan = usePageRenderPlan(props);
1742
+ const readPreparation = React$1.useMemo(createPageRenderPreparationReader, []);
1743
+ const themeResources = React$1.useMemo(() => resolvePageThemeResources(props), [
1744
+ props.rendering,
1745
+ props.theme,
1746
+ props.themeTokens
1747
+ ]);
1748
+ const preparation = React$1.useMemo(() => readPreparation({
1749
+ plan,
1750
+ audience,
1751
+ dataContext,
1752
+ routeMap,
1753
+ themeResources,
1754
+ imageResolveContext
1755
+ }), [
1756
+ plan,
1757
+ audience,
1758
+ dataContext,
1759
+ routeMap,
1760
+ themeResources,
1761
+ imageResolveContext,
1762
+ readPreparation
1763
+ ]);
1764
+ reportAndReplayOmissions({
1765
+ plan,
1766
+ preparation,
1767
+ dataContext,
1768
+ themeResources
1769
+ });
1770
+ if (!page || preparation.entries.length === 0) return props.wrapPage ? props.wrapPage(plan, presentEmptyPage(audience)) : presentEmptyPage(audience);
1771
+ setContextResolveImageUrlContext(imageResolveContext);
1772
+ const rendered = renderPreparedPage(props, preparation, themeResources, imageResolveContext);
1773
+ return props.wrapPage ? props.wrapPage(plan, rendered) : rendered;
1774
+ }
1775
+ function renderPreparedPage(props, preparation, themeResources, imageResolveContext) {
1776
+ const resolvedRegistry = props.registry ?? getDefaultComponentRegistry();
1777
+ const joinSlots = joinSlotsByPair(preparation.joins);
1778
+ return /* @__PURE__ */ jsx("div", { children: preparation.entries.map((entry, index) => renderGuardedPlanEntry({
1779
+ entry,
1780
+ index,
1781
+ entries: preparation.entries,
1782
+ props,
1783
+ themeResources,
1784
+ imageResolveContext,
1785
+ resolvedRegistry,
1786
+ joinSlots,
1787
+ wrapBlock: props.wrapBlock,
1788
+ renderJoin: props.renderJoin
1789
+ })) });
1790
+ }
1791
+ /**
1792
+ * The render pass's effects, kept out of both memos and run in the order the
1793
+ * renderer has always run them in.
1794
+ *
1795
+ * Logging comes first because the replay below can throw: in overrides-only
1796
+ * mode a missing-definition omission would otherwise abort the render before
1797
+ * the deploy-skew signal was ever emitted — the configuration where it is most
1798
+ * diagnostic. Logging is side-effect-free and cannot fail the render.
1799
+ */
1800
+ function reportAndReplayOmissions(input) {
1801
+ const { plan, dataContext } = input;
1802
+ logOmittedBlocks(plan, dataContext);
1803
+ for (const failed of input.preparation.constructionFailures) logRenderThrew(failed.block, dataContext);
1804
+ for (const omission of plan.omitted) switch (omission.reason.kind) {
1805
+ case "invalid-admission": break;
1806
+ case "missing-definition":
1807
+ case "missing-layout":
1808
+ requireBlockOverride(input.themeResources, omission.override, omission.blockKind);
1809
+ break;
1810
+ }
1811
+ for (const failed of input.preparation.constructionFailures) requireEntryBlockOverride(failed, input.themeResources);
1812
+ }
1813
+ const blockKeyFor = (block, index) => block.id ?? `${block.kind}-${index}`;
1814
+ const entryResetTokens = /* @__PURE__ */ new WeakMap();
1815
+ let nextEntryResetToken = 0;
1816
+ /**
1817
+ * A serialisable stand-in for the identity of the block an entry renders.
1818
+ *
1819
+ * The error boundary is a client component, so anything crossing into it has to
1820
+ * survive RSC serialisation — and a prepared entry carries the block definition
1821
+ * and override components. A number minted once per block object says the same
1822
+ * thing: it changes exactly when the block's content does, which is when a
1823
+ * boundary should forget that this block failed.
1824
+ *
1825
+ * Keyed on the block rather than the prepared entry on purpose. `toPresentationPage`
1826
+ * memoises blocks on `props.page`, while a prepared entry is a fresh object every
1827
+ * time preparation recomputes — any `dataContext`, `routeMap` or `themeResources`
1828
+ * identity change — so keying on the entry would reset a failed boundary on renders
1829
+ * where nothing about the block changed, and it would retry and re-log each time.
1830
+ */
1831
+ function entryResetToken(entry) {
1832
+ const block = entry.entry.block;
1833
+ const existing = entryResetTokens.get(block);
1834
+ if (existing !== void 0) return existing;
1835
+ const token = ++nextEntryResetToken;
1836
+ entryResetTokens.set(block, token);
1837
+ return token;
1838
+ }
1839
+ /**
1840
+ * Wraps one entry — wrapper, block and boundary sibling alike — in the per-block
1841
+ * error boundary, so a throw from inside the block's own render takes only that
1842
+ * block out of the page rather than the page itself.
1843
+ */
1844
+ function renderGuardedPlanEntry(input) {
1845
+ const block = input.entry.entry.block;
1846
+ const dataContext = input.props.dataContext;
1847
+ requireEntryBlockOverride(input.entry.entry, input.themeResources);
1848
+ return /* @__PURE__ */ jsx(BlockErrorBoundary, {
1849
+ fallback: presentNotRenderableBlock({
1850
+ kind: "render-threw",
1851
+ blockKind: block.kind
1852
+ }, input.props.audience),
1853
+ record: {
1854
+ siteId: dataContext?.siteId ?? null,
1855
+ pageId: dataContext?.pageId ?? null,
1856
+ blockId: block.id ?? null,
1857
+ blockKind: block.kind
1858
+ },
1859
+ resetKey: entryResetToken(input.entry),
1860
+ children: renderPlanEntry(input)
1861
+ }, blockKeyFor(block, input.index));
1862
+ }
1863
+ /**
1864
+ * The overrides-only guard, run in the order the renderer has always run it:
1865
+ * after an admission failure has already returned, before anything else.
1866
+ */
1867
+ function requireEntryBlockOverride(entry, themeResources) {
1868
+ if (entry.kind === "diagnostic") {
1869
+ if (entry.reason.kind === "invalid-admission") return;
1870
+ requireBlockOverride(themeResources, void 0, entry.block.kind);
1871
+ return;
1872
+ }
1873
+ requireBlockOverride(themeResources, entry.override, entry.block.kind);
1874
+ }
1875
+ /**
1876
+ * Renders one planned block: its wrapper, style-group data attributes,
1877
+ * boundary reserve space and the join markup that follows it.
1878
+ *
1879
+ * Extracted from PageRendererCore so the component stays about wiring the plan
1880
+ * rather than also owning per-block markup.
1881
+ */
1882
+ function renderPlanEntry(input) {
1883
+ const { index, entries, props, themeResources, imageResolveContext, resolvedRegistry, joinSlots, wrapBlock, renderJoin } = input;
1884
+ const entry = input.entry.entry;
1885
+ const block = entry.block;
1886
+ const blockPosition = pageBlockPosition(index, entries.length);
1887
+ const blockKey = blockKeyFor(block, index);
1888
+ const previousBlock = entries[index - 1]?.entry.block ?? null;
1889
+ const nextBlock = entries[index + 1]?.entry.block ?? null;
1890
+ const joinBefore = joinSlotBetween(previousBlock?.id, block.id, joinSlots);
1891
+ const joinAfter = joinSlotBetween(block.id, nextBlock?.id, joinSlots);
1892
+ const boundaryElement = renderJoinSlot({
1893
+ slot: joinAfter,
1894
+ blockKey,
1895
+ renderJoin
1896
+ });
1897
+ const cleanKind = block.kind.replace(/^block\./, "");
1898
+ const managesOwnWrapper = entry.kind === "renderable" && entry.managesOwnWrapper;
1899
+ const renderableContent = entry.renderableContent;
1900
+ const variantKey = entry.kind === "renderable" ? entry.variantKey : null;
1901
+ const shouldUseWrapper = !managesOwnWrapper || Boolean(wrapBlock);
1902
+ const blockSectionProps = buildBlockSectionProps({
1903
+ props,
1904
+ themeResources,
1905
+ entry: input.entry,
1906
+ blockKey,
1907
+ imageResolveContext,
1908
+ registry: resolvedRegistry
1909
+ });
1910
+ if (!shouldUseWrapper) {
1911
+ const rendered = /* @__PURE__ */ jsx(MemoBlockSection, { ...blockSectionProps }, `${blockKey}:block`);
1912
+ return boundaryElement ? /* @__PURE__ */ jsxs(React$1.Fragment, { children: [rendered, boundaryElement] }, blockKey) : rendered;
1913
+ }
1914
+ const wrapperClassName = [`block-${cleanKind}`, wrapBlock ? "group relative" : null].filter(Boolean).join(" ");
1915
+ const styleGroup = typeof renderableContent.styleGroup === "string" ? renderableContent.styleGroup : void 0;
1916
+ const blockLook = blockLookFromContent(renderableContent);
1917
+ const blockComposition = readBlockComposition(renderableContent.blockComposition);
1918
+ const reserves = blockBoundaryReserves({
1919
+ before: joinBefore,
1920
+ after: joinAfter
1921
+ });
1922
+ const blockElement = /* @__PURE__ */ jsx("div", {
1923
+ className: wrapperClassName,
1924
+ ...arrangementHooksFromContent(renderableContent),
1925
+ "data-block": cleanKind,
1926
+ "data-block-id": block.id ?? void 0,
1927
+ "data-block-kind": block.kind,
1928
+ "data-variant": variantKey ?? void 0,
1929
+ "data-block-variant": variantKey ?? void 0,
1930
+ "data-block-look": blockLook,
1931
+ "data-block-composition": blockComposition?.treatment,
1932
+ "data-block-composition-kind": blockComposition?.kind,
1933
+ "data-page-block-position": blockPosition,
1934
+ "data-site-style-boundary-before": reserves.topPlacement,
1935
+ "data-site-style-boundary-after": reserves.bottomPlacement,
1936
+ "data-site-style-field-seam": reserves.fieldSeam,
1937
+ "data-style-group": styleGroup,
1938
+ style: reserves.style,
1939
+ children: /* @__PURE__ */ jsx(MemoBlockSection, { ...blockSectionProps })
1940
+ }, blockKey);
1941
+ if (boundaryElement) return /* @__PURE__ */ jsxs(React$1.Fragment, { children: [blockElement, boundaryElement] }, blockKey);
1942
+ return blockElement;
1943
+ }
1944
+ function resolvePageRendererImageResolveContext(dataContext) {
1945
+ const input = dataContext?.imageResolveContext;
1946
+ return buildResolveImageUrlContext({
1947
+ siteId: input?.siteId ?? dataContext?.siteId,
1948
+ supabaseUrl: input?.supabaseUrl ?? dataContext?.supabaseUrl,
1949
+ mediaAssetIndex: input?.mediaAssetIndex,
1950
+ mediaAssets: input?.mediaAssets ?? dataContext?.mediaAssets
1951
+ });
1952
+ }
1953
+ function buildBlockSectionProps(input) {
1954
+ return {
1955
+ themeResources: input.themeResources,
1956
+ entry: input.entry,
1957
+ audience: input.props.audience,
1958
+ dataContext: input.props.dataContext,
1959
+ blockKey: input.blockKey,
1960
+ registry: input.registry,
1961
+ routeMap: input.props.routeMap,
1962
+ wrapBlock: input.props.wrapBlock,
1963
+ imageResolveContext: input.imageResolveContext,
1964
+ previewAuthoring: input.props.previewAuthoring
1965
+ };
1966
+ }
1967
+ const DEFAULT_PERF_SLOW_BLOCK_RENDER_THRESHOLD_MS = 25;
1968
+ let cachedPerfSlowBlockRenderThresholdMs = null;
1969
+ function getPerfSlowBlockRenderThresholdMs() {
1970
+ if (cachedPerfSlowBlockRenderThresholdMs !== null) return cachedPerfSlowBlockRenderThresholdMs;
1971
+ const raw = globalThis.process?.env?.DEBUG_PERF_BLOCK_MS;
1972
+ const parsed = raw ? Number.parseInt(raw, 10) : NaN;
1973
+ cachedPerfSlowBlockRenderThresholdMs = Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_PERF_SLOW_BLOCK_RENDER_THRESHOLD_MS;
1974
+ return cachedPerfSlowBlockRenderThresholdMs;
1975
+ }
1976
+ /**
1977
+ * Route and identifier maps for CTA link resolution at render time. Omitted
1978
+ * rather than nulled when absent, because a binding checks for the key.
1979
+ */
1980
+ function blockRootLookups(dataContext, routes) {
1981
+ return {
1982
+ ...routes ? { routes } : {},
1983
+ ...dataContext?.pagesByIdentifier ? { pagesByIdentifier: dataContext.pagesByIdentifier } : {},
1984
+ ...dataContext?.entriesByIdentifier ? { entriesByIdentifier: dataContext.entriesByIdentifier } : {}
1985
+ };
1986
+ }
1987
+ /**
1988
+ * The internal-block path: everything a system block component needs and an
1989
+ * override deliberately does not receive.
1990
+ */
1991
+ function renderSystemBlockElement(input) {
1992
+ const { prepared, dataContext } = input;
1993
+ const block = input.entry.block;
1994
+ const BlockComponent = prepared.component;
1995
+ if (!BlockComponent) return null;
1996
+ const rootContext = { $root: {
1997
+ ...buildPageRendererRootRuntime(dataContext),
1998
+ ...blockRootLookups(dataContext, prepared.routes),
1999
+ ...blockSubjectProps(dataContext)
2000
+ } };
2001
+ return /* @__PURE__ */ jsx(BlockComponent, {
2002
+ ...prepared.baseProps,
2003
+ dateContext: rootContext.$root.dateContext,
2004
+ now: rootContext.$root.now,
2005
+ effectiveVariantKey: input.entry.effectiveArrangementKey,
2006
+ effectiveListArrangementKey: input.entry.effectiveListArrangementKey,
2007
+ registry: input.registry,
2008
+ pathBase: typeof block.id === "string" && block.id.length > 0 ? `blocks.${block.id}.` : void 0,
2009
+ blockBindings: block.bindings,
2010
+ editableRouteMetadataFieldIds: dataContext?.editableRouteMetadataFieldIds ?? void 0,
2011
+ viewModelOverrides: rootContext,
2012
+ fragmentRegistry: getFragmentRegistry(),
2013
+ imageResolveContext: input.imageResolveContext,
2014
+ previewAuthoring: input.previewAuthoring
2015
+ });
2016
+ }
2017
+ /** Pure diagnostic choice; the audience owner controls its presentation. */
2018
+ function preparationDiagnostic(prepared, blockKind) {
2019
+ switch (prepared.kind) {
2020
+ case "hidden-business-location": return {
2021
+ reason: {
2022
+ kind: prepared.kind,
2023
+ blockKind,
2024
+ businessDetailsHref: prepared.businessDetailsHref
2025
+ },
2026
+ outcome: "invalidPlaceholder"
2027
+ };
2028
+ case "unresolved-location": return {
2029
+ reason: {
2030
+ kind: prepared.kind,
2031
+ blockKind,
2032
+ source: prepared.source
2033
+ },
2034
+ outcome: "invalidPlaceholder"
2035
+ };
2036
+ case "editor-unpreviewable": return {
2037
+ reason: {
2038
+ kind: prepared.kind,
2039
+ blockKind
2040
+ },
2041
+ outcome: "invalidPlaceholder"
2042
+ };
2043
+ case "render-threw": return {
2044
+ reason: {
2045
+ kind: prepared.kind,
2046
+ blockKind
2047
+ },
2048
+ outcome: "exception"
2049
+ };
2050
+ case "content":
2051
+ case "plan-decided": return null;
2052
+ }
2053
+ }
2054
+ function blockRenderPerformanceMeta(meta) {
2055
+ return {
2056
+ outcome: meta?.outcome ?? "ok",
2057
+ override: meta?.override ?? false,
2058
+ hasResolvedData: meta?.hasResolvedData ?? false
2059
+ };
2060
+ }
2061
+ function finishBlockRender(node, block, perfStart, meta) {
2062
+ if (!perfStart) return node;
2063
+ const durationMs = Date.now() - perfStart;
2064
+ if (durationMs < getPerfSlowBlockRenderThresholdMs()) return node;
2065
+ try {
2066
+ console.debug("perf.blocks.blockRender", {
2067
+ blockId: block.id ?? null,
2068
+ blockKind: block.kind,
2069
+ durationMs,
2070
+ ...blockRenderPerformanceMeta(meta)
2071
+ });
2072
+ } catch {}
2073
+ return node;
2074
+ }
2075
+ /**
2076
+ * Memoized block section component.
2077
+ *
2078
+ * Custom memoization prevents render loops during editing by explicitly checking
2079
+ * referential equality of all props that affect rendering. Standard React.memo
2080
+ * wouldn't catch all the render triggers from the editor store.
2081
+ */
2082
+ const MemoBlockSection = React$1.memo(function MemoBlockSection({ themeResources, entry: preparedEntry, routeMap, audience, dataContext, registry, wrapBlock, imageResolveContext, previewAuthoring }) {
2083
+ const { entry, prepared } = preparedEntry;
2084
+ const block = entry.block;
2085
+ const perfStart = globalThis.process?.env?.DEBUG_PERF === "1" && typeof window === "undefined" ? Date.now() : 0;
2086
+ const resolvedImageResolveContext = imageResolveContext ?? getCurrentResolveImageUrlContext();
2087
+ const finish = (node, meta) => finishBlockRender(node, block, perfStart, meta);
2088
+ function wrapped(node) {
2089
+ return wrapBlock && block.id ? /* @__PURE__ */ jsx(Fragment$1, { children: wrapBlock(block.id, node, {
2090
+ block,
2091
+ content: entry.renderableContent
2092
+ }) }) : /* @__PURE__ */ jsx(Fragment$1, { children: node });
2093
+ }
2094
+ if (entry.kind === "diagnostic" && entry.reason.kind === "invalid-admission") return finish(presentNotRenderableBlock(entry.reason, audience), {
2095
+ outcome: "invalidContent",
2096
+ override: false
2097
+ });
2098
+ const OverrideComponent = entry.kind === "diagnostic" ? void 0 : entry.override;
2099
+ if (entry.kind === "diagnostic") {
2100
+ debugCustomBlockDiagnostic(entry.reason, block, entry.debug);
2101
+ return finish(presentNotRenderableBlock(entry.reason, audience), {
2102
+ outcome: entry.reason.kind === "missing-definition" ? "missingDefinition" : "missingLayout",
2103
+ override: false
2104
+ });
2105
+ }
2106
+ const diagnostic = preparationDiagnostic(prepared, block.kind);
2107
+ if (diagnostic) return finish(wrapped(presentNotRenderableBlock(diagnostic.reason, audience)), {
2108
+ outcome: diagnostic.outcome,
2109
+ override: false
2110
+ });
2111
+ if (entry.kind === "override-only") {
2112
+ const OverrideOnlyComponent = entry.override;
2113
+ return finish(wrapped(/* @__PURE__ */ jsx(OverrideOnlyComponent, { ...buildBlockOverrideProps({
2114
+ content: entry.renderableContent,
2115
+ data: void 0,
2116
+ block,
2117
+ themeResources,
2118
+ dataContext,
2119
+ imageResolveContext: resolvedImageResolveContext,
2120
+ routeMap
2121
+ }) })), {
2122
+ outcome: "overrideWithoutDefinition",
2123
+ override: true,
2124
+ hasResolvedData: false
2125
+ });
2126
+ }
2127
+ if (prepared.kind !== "content") return null;
2128
+ let rendered;
2129
+ if (OverrideComponent) rendered = /* @__PURE__ */ jsx(OverrideComponent, { ...prepared.baseProps });
2130
+ else {
2131
+ requireThemeResources(themeResources, block.kind);
2132
+ rendered = renderSystemBlockElement({
2133
+ prepared,
2134
+ entry,
2135
+ dataContext,
2136
+ registry,
2137
+ previewAuthoring,
2138
+ imageResolveContext: resolvedImageResolveContext
2139
+ });
2140
+ }
2141
+ return finish(wrapped(rendered), {
2142
+ override: Boolean(OverrideComponent),
2143
+ hasResolvedData: prepared.hasResolvedData
2144
+ });
2145
+ }, (prev, next) => {
2146
+ return prev.entry === next.entry && prev.audience === next.audience && prev.registry === next.registry && sameBlockRenderDataContext(prev.dataContext, next.dataContext, next.entry.entry.block.id) && prev.themeResources === next.themeResources && prev.routeMap === next.routeMap && prev.wrapBlock === next.wrapBlock && prev.imageResolveContext === next.imageResolveContext && prev.previewAuthoring === next.previewAuthoring;
2147
+ });
2148
+ /** Every plan input participates in memo identity; the builder owns all rules. */
2149
+ function usePageRenderPlan(props) {
2150
+ const readPlan = React$1.useMemo(createPageRenderPlanReader, []);
2151
+ const { page, audience, runtimeJoins, sdkConfig, customBlocks, blockOverrides } = props;
2152
+ const siteStyleId = props.theme?.siteStyleId ?? null;
2153
+ const previewStage = props.dataContext?.previewStage ?? "published";
2154
+ return React$1.useMemo(() => readPlan({
2155
+ page: page ?? {
2156
+ name: "",
2157
+ path: "",
2158
+ purpose: "",
2159
+ blocks: []
2160
+ },
2161
+ siteStyleId,
2162
+ audience,
2163
+ runtimeJoins,
2164
+ previewStage,
2165
+ sdkConfig,
2166
+ customBlocks,
2167
+ blockOverrides
2168
+ }), [
2169
+ page,
2170
+ siteStyleId,
2171
+ audience,
2172
+ runtimeJoins,
2173
+ previewStage,
2174
+ sdkConfig,
2175
+ customBlocks,
2176
+ blockOverrides,
2177
+ readPlan
2178
+ ]);
2179
+ }
2180
+ function usePageDateRuntime(props) {
2181
+ const supplied = props.dataContext?.dateContext;
2182
+ const zone = props.dataContext?.bookingTimeZone;
2183
+ const dateContext = React$1.useMemo(() => supplied ?? resolveDateRuntimeContext(zone), [supplied, zone]);
2184
+ const dataContext = React$1.useMemo(() => props.dataContext ? {
2185
+ ...props.dataContext,
2186
+ dateContext,
2187
+ template: props.dataContext.template ?? pageTemplateFromEntry(props.dataContext.contentEntry)
2188
+ } : void 0, [props.dataContext, dateContext]);
2189
+ return {
2190
+ ...props,
2191
+ dataContext
2192
+ };
2193
+ }
2194
+ //#endregion
2195
+ //#region ../blocks/src/primitives/content/primitives.tsx
2196
+ const Text = Text$1;
2197
+ const RichText = RichText$1;
2198
+ //#endregion
2199
+ //#region ../api/src/publicProducts.ts
2200
+ function decodePublicProductCategorySelectorQuery(input) {
2201
+ if (input.productCategoryScope === "category" && typeof input.productCategoryId === "string" && input.productCategoryId.length > 0) return {
2202
+ kind: "category",
2203
+ productCategoryId: input.productCategoryId
2204
+ };
2205
+ if (input.productCategoryScope === "current-category-page" && typeof input.productCategoryEntryId === "string" && input.productCategoryEntryId.length > 0) return {
2206
+ kind: "current-category-page",
2207
+ productCategoryEntryId: input.productCategoryEntryId
2208
+ };
2209
+ return null;
2210
+ }
2211
+ //#endregion
2212
+ //#region ../content-editor/src/components/EditableBlockProvider.tsx
2213
+ const BlockDataContext = createContext(null);
2214
+ function EditableBlockProvider({ blockId, children }) {
2215
+ const editorBlockId = unsafeAsEditorBlockId(blockId);
2216
+ const blockData = useEditorUiStore((state) => state.drafts.getCurrentValues(editorBlockId));
2217
+ return /* @__PURE__ */ jsx(BlockDataContext.Provider, {
2218
+ value: {
2219
+ blockId,
2220
+ blockData
2221
+ },
2222
+ children
2223
+ });
2224
+ }
2225
+ //#endregion
2226
+ //#region ../content-editor/src/primitives/usePlainTextDocument.ts
2227
+ /** Stable attachment and one replacement boundary for the browser-owned text document. */
2228
+ function usePlainTextDocument(value, editable) {
2229
+ const [element, attach] = useState(null);
2230
+ const applied = useRef(null);
2231
+ const session = useRef({ composing: false });
2232
+ useEffect(() => {
2233
+ if (!element) return;
2234
+ if (applied.current?.element !== element) session.current.composing = false;
2235
+ const reconcile = () => {
2236
+ const previous = applied.current;
2237
+ const decision = decideDocumentReplacement({
2238
+ hydrated: previous?.element === element,
2239
+ inputChanged: previous?.value !== value || previous?.editable === true && !editable,
2240
+ documentMatches: element.textContent === value,
2241
+ session: session.current.composing ? "composing" : document.activeElement === element ? "focused" : "idle",
2242
+ editable,
2243
+ kind: "observe"
2244
+ });
2245
+ if (decision === "defer") return;
2246
+ if (decision === "replace") element.textContent = value;
2247
+ applied.current = {
2248
+ element,
2249
+ value,
2250
+ editable
2251
+ };
2252
+ };
2253
+ const start = () => {
2254
+ session.current.composing = true;
2255
+ };
2256
+ const pending = { timer: void 0 };
2257
+ const end = () => {
2258
+ session.current.composing = false;
2259
+ pending.timer = setTimeout(reconcile, 0);
2260
+ };
2261
+ element.addEventListener("compositionstart", start);
2262
+ element.addEventListener("compositionend", end);
2263
+ element.addEventListener("blur", reconcile);
2264
+ reconcile();
2265
+ return () => {
2266
+ clearTimeout(pending.timer);
2267
+ element.removeEventListener("compositionstart", start);
2268
+ element.removeEventListener("compositionend", end);
2269
+ element.removeEventListener("blur", reconcile);
2270
+ };
2271
+ }, [
2272
+ element,
2273
+ value,
2274
+ editable
2275
+ ]);
2276
+ return attach;
2277
+ }
2278
+ //#endregion
2279
+ //#region ../content-editor/src/primitives/shared/storeBinding.ts
2280
+ /**
2281
+ * Parse editor path into store and field components.
2282
+ * Supports three patterns:
2283
+ * - blocks.<blockId>.<field> → drafts store (block editing)
2284
+ * - content.<field> → content store (content entry editing)
2285
+ * - metadata.<field> → metadata store (entry metadata editing)
2286
+ */
2287
+ function parseEditorPath(path) {
2288
+ const blocksMatch = path.match(/^blocks\.([^.]+)\.(.+)$/);
2289
+ if (blocksMatch?.[1] && blocksMatch[2]) return {
2290
+ store: "blocks",
2291
+ blockId: unsafeAsEditorBlockId(blocksMatch[1]),
2292
+ field: blocksMatch[2]
2293
+ };
2294
+ const contentMatch = path.match(/^content\.(.+)$/);
2295
+ if (contentMatch?.[1]) return {
2296
+ store: "content",
2297
+ field: contentMatch[1]
2298
+ };
2299
+ const metadataMatch = path.match(/^metadata\.(.+)$/);
2300
+ if (metadataMatch?.[1]) return {
2301
+ store: "metadata",
2302
+ field: metadataMatch[1]
2303
+ };
2304
+ return null;
2305
+ }
2306
+ /** A linked entry owns its write target even when it also has a canvas display path. */
2307
+ function resolvePreviewTextBinding(path, linkedEntryField) {
2308
+ const input = linkedEntryField?.write ?? path;
2309
+ if (!input) throw new Error("Preview text requires a path or linkedEntryField");
2310
+ return input;
2311
+ }
2312
+ function resolveStoreBindingInput(input) {
2313
+ if (typeof input === "string") return parseEditorPath(input);
2314
+ if (input.kind === "linked-entry-write-field") return {
2315
+ store: "linkedEntry",
2316
+ entryId: unsafeAsLinkedContentEntryId(input.entryId),
2317
+ field: input.fieldPath
2318
+ };
2319
+ return null;
2320
+ }
2321
+ function requireStoreBindingPath(input) {
2322
+ const path = resolveStoreBindingInput(input);
2323
+ if (!path) throw new Error("useStoreBinding: invalid binding input");
2324
+ return path;
2325
+ }
2326
+ function bindingChangeCommand({ input, value }) {
2327
+ const path = requireStoreBindingPath(input);
2328
+ switch (path.store) {
2329
+ case "blocks": return {
2330
+ type: "set-block-value",
2331
+ blockId: path.blockId,
2332
+ path: path.field,
2333
+ value
2334
+ };
2335
+ case "content": return {
2336
+ type: "set-content-value",
2337
+ path: path.field,
2338
+ value
2339
+ };
2340
+ case "metadata": return {
2341
+ type: "set-metadata-value",
2342
+ path: path.field,
2343
+ value
2344
+ };
2345
+ case "linkedEntry": return {
2346
+ type: "set-linked-entry-value",
2347
+ entryId: path.entryId,
2348
+ path: path.field,
2349
+ value
2350
+ };
2351
+ }
2352
+ }
2353
+ /** One user edit may update several bound fields, but enters history and autosave once. */
2354
+ function useStoreBindingWriter() {
2355
+ const uiStore = useEditorUiStoreInstance();
2356
+ return useCallback((changes) => {
2357
+ const commands = changes.map(bindingChangeCommand);
2358
+ if (commands.length === 0) return;
2359
+ uiStore.getState().applyCommand(commands.length === 1 && commands[0] ? commands[0] : {
2360
+ type: "batch",
2361
+ changes: commands
2362
+ });
2363
+ }, [uiStore]);
2364
+ }
2365
+ /** Observe the immutable field value directly; the snapshot owners preserve identity. */
2366
+ function useStoreBinding(input) {
2367
+ const pathInfo = useMemo(() => requireStoreBindingPath(input), [input]);
2368
+ const value = useEditorUiStore((state) => readBindingValue(state, pathInfo));
2369
+ const canWrite = useEditorUiStore((state) => pathInfo.store !== "linkedEntry" || canWriteLinkedEntry(state, pathInfo.entryId));
2370
+ const writeValues = useStoreBindingWriter();
2371
+ return {
2372
+ value,
2373
+ setValue: useCallback((nextValue) => writeValues([{
2374
+ input,
2375
+ value: nextValue
2376
+ }]), [input, writeValues]),
2377
+ canWrite,
2378
+ pathInfo
2379
+ };
2380
+ }
2381
+ function readBindingValue(state, path) {
2382
+ switch (path.store) {
2383
+ case "blocks": return state.drafts.getAtPath(path.blockId, path.field);
2384
+ case "content": return state.content.getAtPath(path.field);
2385
+ case "metadata": return state.metadata.getAtPath(path.field);
2386
+ case "linkedEntry": return state.linkedEntries.getAtPath(path.field, path.entryId);
2387
+ }
2388
+ }
2389
+ //#endregion
2390
+ //#region ../content-editor/src/primitives/shared/activePreviewField.ts
2391
+ /**
2392
+ * Returns true when the given editor path targets the same block-field that
2393
+ * the sidebar has currently focused (the "linked focus" affordance).
2394
+ *
2395
+ * Encapsulates the `blocks.{blockId}.{fieldPath}` path convention so editor
2396
+ * primitives and tests share a single source of truth.
2397
+ */
2398
+ function isLinkedSidebarField(editorPath, activeField) {
2399
+ if (!activeField) return false;
2400
+ if (activeField.kind !== "block") return false;
2401
+ return editorPath === `blocks.${activeField.blockId}.${activeField.fieldPath}`;
2402
+ }
2403
+ function isLinkedEntrySidebarField(binding, activeField) {
2404
+ if (!binding || !activeField) return false;
2405
+ if (activeField.kind !== "linked-entry") return false;
2406
+ return activeField.entryId === binding.write.entryId && activeField.fieldPath === binding.write.fieldPath;
2407
+ }
2408
+ /** Linked-entry bindings take precedence over a block's display path. */
2409
+ function isSidebarFocusedField(field, activeField) {
2410
+ if (field.linkedEntryField) return isLinkedEntrySidebarField(field.linkedEntryField, activeField);
2411
+ return field.path !== void 0 && isLinkedSidebarField(field.path, activeField);
2412
+ }
2413
+ /** A read-only inline field remains an opener for its scoped editor. */
2414
+ function linkedEntryActivation(binding, canWrite, onOpen) {
2415
+ const open = () => {
2416
+ if (binding && !canWrite) onOpen?.(binding);
2417
+ };
2418
+ return {
2419
+ tabIndex: binding && !canWrite ? 0 : void 0,
2420
+ onClick: open,
2421
+ onFocus: open
2422
+ };
2423
+ }
2424
+ //#endregion
2425
+ //#region ../content-editor/src/primitives/PreviewTextEditor.tsx
2426
+ /** Browser-owned text with one deliberate external-document boundary. */
2427
+ function PreviewTextEditor(props) {
2428
+ const { path, linkedEntryField, onLinkedEntryFieldFocus, onBlockFieldFocus, children, className, style, "data-slot": dataSlot, "data-surface": dataSurface, maxLength, placeholder = "Add text", ariaLabel, as: Comp = "span" } = props;
2429
+ const { isEditingMode } = useEditor();
2430
+ const fallbackValue = useMemo(() => normalizeChildren(children), [children]);
2431
+ const { value, setValue, canWrite } = useStoreBinding(resolvePreviewTextBinding(path, linkedEntryField));
2432
+ const isLinkedSidebarFocus = useEditorUiStore((state) => isSidebarFocusedField({
2433
+ linkedEntryField,
2434
+ path
2435
+ }, state.activePreviewField));
2436
+ const [isFocused, setIsFocused] = useState(false);
2437
+ const normalizedValue = normalizeValue(value, fallbackValue);
2438
+ const isEmpty = normalizedValue.trim().length === 0;
2439
+ const accessibleLabel = ariaLabel ?? placeholder;
2440
+ const handleSetValue = useCallback((nextValue) => {
2441
+ if (!canWrite) return;
2442
+ setValue(limitTextLength(nextValue, maxLength));
2443
+ }, [
2444
+ maxLength,
2445
+ setValue,
2446
+ canWrite
2447
+ ]);
2448
+ const readLimitedEditableText = useCallback((element) => {
2449
+ const nextValue = element.textContent ?? "";
2450
+ const limited = limitTextLength(nextValue, maxLength);
2451
+ if (limited !== nextValue) {
2452
+ element.textContent = limited;
2453
+ moveCaretToEnd(element);
2454
+ }
2455
+ return limited;
2456
+ }, [maxLength]);
2457
+ const attach = usePlainTextDocument(normalizedValue, canWrite);
2458
+ if (!isEditingMode) return null;
2459
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("style", { children: `
2460
+ [data-rb-preview-text-editor] {
2461
+ transition: background-color 160ms ease, outline-color 160ms ease;
2462
+ }
2463
+ [data-rb-preview-text-editor][data-rb-preview-text-empty="true"] {
2464
+ min-width: 1ch;
2465
+ }
2466
+ [data-rb-preview-text-editor]:hover,
2467
+ [data-rb-preview-text-editor][data-rb-preview-text-linked-focus="true"],
2468
+ [data-rb-preview-text-editor]:focus-visible {
2469
+ outline: ${PREVIEW_EDITABLE_OUTLINE} !important;
2470
+ outline-offset: 2px;
2471
+ }
2472
+ [data-rb-preview-text-editor][data-rb-preview-text-empty="true"]::before {
2473
+ content: attr(data-placeholder);
2474
+ color: rgba(148, 163, 184, 0.86);
2475
+ }
2476
+ ` }), /* @__PURE__ */ jsx(Comp, {
2477
+ "data-slot": dataSlot,
2478
+ "data-surface": dataSurface,
2479
+ style: dataSlot === void 0 ? void 0 : style,
2480
+ "data-rb-preview-text-editor": true,
2481
+ "data-rb-preview-text-empty": isEmpty ? "true" : void 0,
2482
+ "data-rb-preview-text-linked-focus": isLinkedSidebarFocus ? "true" : void 0,
2483
+ "data-placeholder": placeholder,
2484
+ ref: attach,
2485
+ contentEditable: canWrite,
2486
+ tabIndex: 0,
2487
+ "aria-readonly": !canWrite,
2488
+ suppressContentEditableWarning: true,
2489
+ role: "textbox",
2490
+ "aria-multiline": "false",
2491
+ "aria-label": accessibleLabel,
2492
+ className: `rounded transition-colors focus:bg-white/10 focus-visible:bg-white/10 ${isLinkedSidebarFocus || isFocused ? "bg-white/5" : ""} ${className ?? ""}`,
2493
+ onCompositionEnd: (event) => handleSetValue(readLimitedEditableText(event.currentTarget)),
2494
+ onInput: (event) => {
2495
+ if ("isComposing" in event.nativeEvent && event.nativeEvent.isComposing) return;
2496
+ handleSetValue(readLimitedEditableText(event.currentTarget));
2497
+ },
2498
+ onFocus: () => {
2499
+ setIsFocused(true);
2500
+ if (linkedEntryField) onLinkedEntryFieldFocus?.(linkedEntryField);
2501
+ else if (path) onBlockFieldFocus?.(path);
2502
+ },
2503
+ onBlur: () => setIsFocused(false)
2504
+ })] });
2505
+ }
2506
+ function normalizeChildren(input) {
2507
+ if (input === null || input === void 0) return "";
2508
+ if (typeof input === "string" || typeof input === "number") return String(input);
2509
+ if (Array.isArray(input)) return input.map((item) => normalizeChildren(item)).join("");
2510
+ return "";
2511
+ }
2512
+ function normalizeValue(raw, fallback) {
2513
+ if (raw === void 0) return fallback;
2514
+ if (raw === null) return "";
2515
+ if (typeof raw === "string") return raw;
2516
+ if (typeof raw === "number") return String(raw);
2517
+ return fallback;
2518
+ }
2519
+ function limitTextLength(value, maxLength) {
2520
+ if (typeof maxLength !== "number") return value;
2521
+ if (!Number.isFinite(maxLength) || maxLength < 0) return value;
2522
+ return value.length > maxLength ? value.slice(0, maxLength) : value;
2523
+ }
2524
+ function moveCaretToEnd(element) {
2525
+ const selection = window.getSelection();
2526
+ if (!selection) return;
2527
+ const range = document.createRange();
2528
+ range.selectNodeContents(element);
2529
+ range.collapse(false);
2530
+ selection.removeAllRanges();
2531
+ selection.addRange(range);
2532
+ }
2533
+ //#endregion
2534
+ //#region ../content-editor/src/primitives/PreviewInlineTextEditor.tsx
2535
+ function PreviewInlineTextEditor({ path, plainTextPath, fallbackPlainText = "", onBlockFieldFocus, className, style, "data-slot": dataSlot, "data-surface": dataSurface, maxLength, placeholder = "Add heading", ariaLabel, as: Comp = "span" }) {
2536
+ const { isEditingMode } = useEditor();
2537
+ const { value } = useStoreBinding(path);
2538
+ const { value: plainTextValue } = useStoreBinding(plainTextPath);
2539
+ const writeValues = useStoreBindingWriter();
2540
+ const [isFocused, setIsFocused] = useState(false);
2541
+ const isLinkedSidebarFocus = useEditorUiStore((state) => isSidebarFocusedField({ path }, state.activePreviewField));
2542
+ const editorValue = useMemo(() => coerceInlineTextWithFallback(value, typeof plainTextValue === "string" ? plainTextValue : fallbackPlainText), [
2543
+ fallbackPlainText,
2544
+ plainTextValue,
2545
+ value
2546
+ ]);
2547
+ const handleChange = useCallback((nextValue) => {
2548
+ writeValues(deriveInlineTextFieldChanges(nextValue, {
2549
+ formatted: path,
2550
+ plain: plainTextPath
2551
+ }).map((change) => ({
2552
+ input: change.path,
2553
+ value: change.value
2554
+ })));
2555
+ }, [
2556
+ path,
2557
+ plainTextPath,
2558
+ writeValues
2559
+ ]);
2560
+ if (!isEditingMode) return null;
2561
+ return /* @__PURE__ */ jsx(InlineTextEditor, {
2562
+ "data-slot": dataSlot,
2563
+ "data-surface": dataSurface,
2564
+ style,
2565
+ value: editorValue,
2566
+ onChange: handleChange,
2567
+ as: Comp,
2568
+ maxLength,
2569
+ placeholder,
2570
+ ariaLabel: ariaLabel ?? placeholder,
2571
+ toolbarTone: "dark",
2572
+ className: `rounded transition-colors focus:bg-white/10 focus-visible:bg-white/10 ${isLinkedSidebarFocus || isFocused ? "bg-white/5" : ""} ${className ?? ""}`,
2573
+ onFocus: () => {
2574
+ setIsFocused(true);
2575
+ onBlockFieldFocus?.(path);
2576
+ },
2577
+ onBlur: () => setIsFocused(false)
2578
+ });
2579
+ }
2580
+ //#endregion
2581
+ //#region ../content-editor/src/primitives/PreviewRichTextEditor.tsx
2582
+ function resolvePreviewRichTextDoc(value) {
2583
+ if (value === null || value === void 0) return EMPTY_DOC;
2584
+ try {
2585
+ return parseRichTextDoc(value);
2586
+ } catch {
2587
+ logger.warn("previewRichTextEditor.invalidDocument", {});
2588
+ return EMPTY_DOC;
2589
+ }
2590
+ }
2591
+ /** The shared rich-text adapter owns document reconciliation and editor lifetime. */
2592
+ const PreviewRichTextEditorInner = ({ path, linkedEntryField, onLinkedEntryFieldFocus, onBlockFieldFocus, className, style, "data-slot": dataSlot, "data-surface": dataSurface, doc, as: Comp = "div", variant, placeholder = "Add description", ariaLabel, renderToolbarHost }) => {
2593
+ const { value, setValue, canWrite } = useStoreBinding(resolvePreviewTextBinding(path, linkedEntryField));
2594
+ const isLinkedSidebarFocus = useEditorUiStore((state) => isSidebarFocusedField({
2595
+ linkedEntryField,
2596
+ path
2597
+ }, state.activePreviewField));
2598
+ const [isFocused, setIsFocused] = useState(false);
2599
+ const [isHovered, setIsHovered] = useState(false);
2600
+ const suppliedDoc = value ?? doc;
2601
+ const { editor, isEmpty, config } = useRichTextEditor({
2602
+ content: useMemo(() => resolvePreviewRichTextDoc(suppliedDoc), [suppliedDoc]),
2603
+ editable: canWrite,
2604
+ variant: variant ?? "full",
2605
+ projection: useRichTextImageProjection(),
2606
+ onCanonicalChange: setValue
2607
+ });
2608
+ useEffect(() => {
2609
+ if (!editor) return;
2610
+ const handleFocus = () => {
2611
+ setIsFocused(true);
2612
+ if (linkedEntryField) onLinkedEntryFieldFocus?.(linkedEntryField);
2613
+ else if (path) onBlockFieldFocus?.(path);
2614
+ };
2615
+ const handleBlur = () => {
2616
+ setIsFocused(false);
2617
+ };
2618
+ editor.on("focus", handleFocus);
2619
+ editor.on("blur", handleBlur);
2620
+ return () => {
2621
+ editor.off("focus", handleFocus);
2622
+ editor.off("blur", handleBlur);
2623
+ };
2624
+ }, [
2625
+ editor,
2626
+ linkedEntryField,
2627
+ onBlockFieldFocus,
2628
+ onLinkedEntryFieldFocus,
2629
+ path
2630
+ ]);
2631
+ const showAffordance = isHovered || isFocused || isLinkedSidebarFocus;
2632
+ const resolvedClassName = className?.trim() || "rb-prose rb-max-w-none";
2633
+ return /* @__PURE__ */ jsxs(Comp, {
2634
+ "data-rb-preview-richtext-editor": true,
2635
+ "data-slot": dataSlot,
2636
+ "data-surface": dataSurface,
2637
+ style: dataSlot === void 0 ? void 0 : style,
2638
+ ...linkedEntryActivation(linkedEntryField, canWrite, onLinkedEntryFieldFocus),
2639
+ "data-placeholder": placeholder,
2640
+ "data-rb-preview-richtext-linked-focus": isLinkedSidebarFocus ? "true" : void 0,
2641
+ className: resolvedClassName,
2642
+ onMouseEnter: () => setIsHovered(true),
2643
+ onMouseLeave: () => setIsHovered(false),
2644
+ children: [/* @__PURE__ */ jsx("style", { children: `
2645
+ [data-rb-preview-richtext-editor] .ProseMirror:focus-visible,
2646
+ [data-rb-preview-richtext-editor] .ProseMirror *:focus-visible {
2647
+ outline: none !important;
2648
+ }
2649
+ [data-rb-preview-richtext-editor] .ProseMirror > :first-child {
2650
+ margin-top: 0;
2651
+ }
2652
+ [data-rb-preview-richtext-editor] .ProseMirror > :last-child {
2653
+ margin-bottom: 0;
2654
+ }
2655
+ ` }), /* @__PURE__ */ jsx(RichTextEditorSurface, {
2656
+ editor,
2657
+ config,
2658
+ isEmpty,
2659
+ className: "",
2660
+ contentClassName: "cursor-text",
2661
+ placeholderClassName: "text-gray-400",
2662
+ placeholderText: placeholder,
2663
+ ariaLabel: ariaLabel ?? placeholder,
2664
+ toolbarLayout: {
2665
+ ...renderToolbarHost ? {
2666
+ kind: "external",
2667
+ renderHost: renderToolbarHost
2668
+ } : { kind: "chrome" },
2669
+ tone: "dark",
2670
+ visibility: {
2671
+ kind: "controlled",
2672
+ visible: isFocused || isLinkedSidebarFocus
2673
+ }
2674
+ },
2675
+ renderContent: (content) => /* @__PURE__ */ jsx("div", {
2676
+ "data-rb-preview-richtext-affordance": showAffordance ? "true" : void 0,
2677
+ className: `relative rounded cursor-text ${isEmpty ? "min-h-[30px]" : ""} ${showAffordance ? "bg-white/5" : "bg-transparent"}`,
2678
+ style: showAffordance ? {
2679
+ outline: PREVIEW_EDITABLE_OUTLINE,
2680
+ outlineOffset: "2px"
2681
+ } : void 0,
2682
+ children: content
2683
+ })
2684
+ })]
2685
+ });
2686
+ };
2687
+ /**
2688
+ * Memoized version to prevent unnecessary re-renders.
2689
+ * Only re-renders when path, doc, variant, or className props actually change.
2690
+ */
2691
+ const PreviewRichTextEditor = memo(PreviewRichTextEditorInner);
2692
+ //#endregion
2693
+ //#region ../preview-next/src/client/blocks/authoringLocationMaps.ts
2694
+ /** A render-only projection. Canonical drafts in the editor store remain untouched. */
2695
+ function projectAuthoringLocationMaps(page, admitted, siteCountry) {
2696
+ const ready = new Map((admitted?.blocks ?? []).flatMap((block) => {
2697
+ const parsed = publicLocationSchema.safeParse(block.content?.location);
2698
+ return block.id && parsed.success ? [[block.id, parsed.data]] : [];
2699
+ }));
2700
+ return {
2701
+ ...page,
2702
+ blocks: page.blocks.map((block) => {
2703
+ if (block.kind !== "block.location-map") return block;
2704
+ const project = (content) => projectAuthoringMapContent(content, block.id ? ready.get(block.id) : void 0, siteCountry);
2705
+ return {
2706
+ ...block,
2707
+ content: project(block.content),
2708
+ draftContent: block.draftContent ? project(block.draftContent) : block.draftContent
2709
+ };
2710
+ })
2711
+ };
2712
+ }
2713
+ function projectAuthoringMapContent(content, ready, siteCountry) {
2714
+ if (!content || content.locationSource === "business_address" || content.locationSource === "venue") return content ?? void 0;
2715
+ const canonical = parseLocationValue(content.location ?? null);
2716
+ if (!canonical.ok || canonical.value === null) return content;
2717
+ const location = projectPublicLocation(canonical.value, siteCountry);
2718
+ const drawing = drawingAtCurrentPin(location, ready);
2719
+ return {
2720
+ ...content,
2721
+ location: {
2722
+ ...location,
2723
+ ...drawing ? { drawing } : {}
2724
+ }
2725
+ };
2726
+ }
2727
+ /** Geometry identity is the pin, never the block ID or an older address label. */
2728
+ function drawingAtCurrentPin(location, ready) {
2729
+ if (!ready?.pin || !location.pin) return void 0;
2730
+ return ready.pin.lat === location.pin.lat && ready.pin.lng === location.pin.lng ? ready.drawing : void 0;
2731
+ }
2732
+ //#endregion
2733
+ //#region ../preview-next/src/client/blocks/previewBatchLoaderParams.ts
2734
+ function isBatchableEndpoint(endpoint) {
2735
+ return endpoint === "listPublicEvents" || endpoint === "listPublicEventCalendarWindow" || endpoint === "getPublicEventDetails" || endpoint === "listPublicRouteCandidates" || endpoint === "listPublicTeamMembers" || endpoint === "listPublicProducts" || endpoint === "getPublicBookingServices" || endpoint === "getPublicWeeklySlotAvailability" || endpoint === "getPublicFormById";
2736
+ }
2737
+ function buildBatchLoaderRequest(id, endpoint, params) {
2738
+ switch (endpoint) {
2739
+ case "listPublicEventCalendarWindow": return {
2740
+ id,
2741
+ endpoint,
2742
+ params: calendarWindowQuerySchema.parse(params ?? {})
2743
+ };
2744
+ case "listPublicEvents": {
2745
+ const typedParams = params;
2746
+ return typedParams ? {
2747
+ id,
2748
+ endpoint,
2749
+ params: typedParams
2750
+ } : {
2751
+ id,
2752
+ endpoint
2753
+ };
2754
+ }
2755
+ case "getPublicEventDetails": {
2756
+ const typedParams = params;
2757
+ return typedParams ? {
2758
+ id,
2759
+ endpoint,
2760
+ params: typedParams
2761
+ } : {
2762
+ id,
2763
+ endpoint
2764
+ };
2765
+ }
2766
+ case "listPublicRouteCandidates": return {
2767
+ id,
2768
+ endpoint
2769
+ };
2770
+ case "listPublicProducts": {
2771
+ const typedParams = params;
2772
+ return typedParams ? {
2773
+ id,
2774
+ endpoint,
2775
+ params: typedParams
2776
+ } : {
2777
+ id,
2778
+ endpoint
2779
+ };
2780
+ }
2781
+ case "listPublicTeamMembers": return {
2782
+ id,
2783
+ endpoint
2784
+ };
2785
+ case "getPublicBookingServices": {
2786
+ const typedParams = params;
2787
+ return typedParams ? {
2788
+ id,
2789
+ endpoint,
2790
+ params: typedParams
2791
+ } : {
2792
+ id,
2793
+ endpoint
2794
+ };
2795
+ }
2796
+ case "getPublicWeeklySlotAvailability": return {
2797
+ id,
2798
+ endpoint,
2799
+ params: params ?? { serviceId: "" }
2800
+ };
2801
+ case "getPublicFormById": return {
2802
+ id,
2803
+ endpoint,
2804
+ params: params ?? { formId: "" }
2805
+ };
2806
+ }
2807
+ }
2808
+ function stripUndefined(obj) {
2809
+ const out = {};
2810
+ for (const [key, value] of Object.entries(obj)) if (value !== void 0) out[key] = value;
2811
+ return out;
2812
+ }
2813
+ function normalizeIdsParam(ids) {
2814
+ if (!ids) return void 0;
2815
+ const parts = ids.split(",").map((id) => id.trim()).filter(Boolean).sort();
2816
+ return parts.length ? parts.join(",") : void 0;
2817
+ }
2818
+ function optionalParam(params, key) {
2819
+ return params[key] || void 0;
2820
+ }
2821
+ function eventLoaderParams(params) {
2822
+ return stripUndefined({
2823
+ limit: optionalParam(params, "limit"),
2824
+ from: params.from || void 0,
2825
+ to: params.to || void 0,
2826
+ afterStartsAt: params.afterStartsAt || void 0,
2827
+ afterId: params.afterId || void 0,
2828
+ categoryIds: params.categoryIds || void 0,
2829
+ venueId: params.venueId || void 0,
2830
+ staffMemberId: params.staffMemberId || void 0,
2831
+ kind: params.kind || void 0,
2832
+ eventSurface: params.eventSurface || void 0,
2833
+ eventPresets: params.eventPresets || void 0,
2834
+ scheduleScope: params.scheduleScope || void 0,
2835
+ entryId: params.entryId || void 0,
2836
+ seriesId: params.seriesId || void 0,
2837
+ seriesIds: params.seriesIds,
2838
+ includeOccurrenceId: params.includeOccurrenceId || void 0
2839
+ });
2840
+ }
2841
+ function nonEmpty(params) {
2842
+ return Object.keys(params).length ? params : void 0;
2843
+ }
2844
+ function toPreviewBatchParams(endpoint, params) {
2845
+ switch (endpoint) {
2846
+ case "listPublicEventCalendarWindow": return calendarWindowQuerySchema.parse(params);
2847
+ case "listPublicEvents": return nonEmpty({
2848
+ ...eventLoaderParams(params),
2849
+ detailLevel: params.detailLevel || void 0,
2850
+ readProfile: params.readProfile || void 0
2851
+ });
2852
+ case "getPublicEventDetails": return nonEmpty(eventLoaderParams(params));
2853
+ case "listPublicProducts": return nonEmpty(stripUndefined({ categorySelector: decodePublicProductCategorySelectorQuery(params) ?? void 0 }));
2854
+ case "getPublicBookingServices": return nonEmpty(stripUndefined({ ids: normalizeIdsParam(params.ids || void 0) }));
2855
+ case "getPublicFormById": return { formId: params.formId ?? "" };
2856
+ case "listPublicRouteCandidates":
2857
+ case "listPublicTeamMembers":
2858
+ case "getPublicWeeklySlotAvailability": return;
2859
+ }
2860
+ }
2861
+ //#endregion
2862
+ //#region ../preview-next/src/client/blocks/previewBlockDataClient.ts
2863
+ const MAX_PREVIEW_BLOCK_DATA_BATCH_SIZE = 25;
2864
+ function createPreviewBlockDataApiClient(dashboardApiClient, context) {
2865
+ const signals = /* @__PURE__ */ new Map();
2866
+ const batcher = createMicrobatcher({
2867
+ maxBatchSize: MAX_PREVIEW_BLOCK_DATA_BATCH_SIZE,
2868
+ runBatch: (requests) => runPreviewBatch(dashboardApiClient, context, signals, requests)
2869
+ });
2870
+ return (signal) => async ({ endpoint, params }) => {
2871
+ signal.throwIfAborted();
2872
+ if (!isSupportedLoaderEndpoint(endpoint)) throw new Error(`Unsupported block loader endpoint: ${endpoint}`);
2873
+ const normalizedParams = normalizePublicApiLoaderParams(endpoint, params, context);
2874
+ if (isBatchableEndpoint(endpoint)) {
2875
+ const batchParams = toPreviewBatchParams(endpoint, normalizedParams);
2876
+ const batchKey = `${endpoint}:${stableSerialize(batchParams ?? null)}:${generateUuidV4()}`;
2877
+ return batcher.getOrEnqueue(batchKey, (id) => {
2878
+ signals.set(id, signal);
2879
+ return buildBatchLoaderRequest(id, endpoint, batchParams);
2880
+ });
2881
+ }
2882
+ return callDirectLoaderApiEndpoint(dashboardApiClient, endpoint, normalizedParams, signal);
2883
+ };
2884
+ }
2885
+ async function runPreviewBatch(client, context, signals, requests) {
2886
+ const batch = batchAbortSignal(requests.flatMap((request) => {
2887
+ const signal = signals.get(request.id);
2888
+ return signal ? [signal] : [];
2889
+ }));
2890
+ try {
2891
+ if (!context.siteId) return Object.fromEntries(requests.map(({ id }) => [id, {
2892
+ ok: false,
2893
+ error: {
2894
+ code: "missing_site_id",
2895
+ message: "Missing siteId"
2896
+ }
2897
+ }]));
2898
+ const active = requests.filter((request) => !signals.get(request.id)?.aborted);
2899
+ if (active.length === 0) return {};
2900
+ return unwrapResponse(await client({
2901
+ endpoint: "batchBlockLoaders",
2902
+ params: {
2903
+ siteId: context.siteId,
2904
+ stage: context.previewStage
2905
+ },
2906
+ body: { requests: active },
2907
+ options: { signal: batch.signal }
2908
+ })).results;
2909
+ } finally {
2910
+ batch.dispose();
2911
+ requests.forEach((request) => signals.delete(request.id));
2912
+ }
2913
+ }
2914
+ async function callDirectLoaderApiEndpoint(client, endpoint, params, signal) {
2915
+ switch (endpoint) {
2916
+ case "listPublishedEntries": return unwrapResponse(await client({
2917
+ endpoint,
2918
+ params,
2919
+ options: { signal }
2920
+ }));
2921
+ case "getPublishedEntryPreview": return unwrapResponse(await client({
2922
+ endpoint,
2923
+ params,
2924
+ options: { signal }
2925
+ }));
2926
+ case "listPublicPasses": return unwrapResponse(await client({
2927
+ endpoint,
2928
+ params,
2929
+ options: { signal }
2930
+ }));
2931
+ case "listPublicMemberships": return unwrapResponse(await client({
2932
+ endpoint,
2933
+ params,
2934
+ options: { signal }
2935
+ }));
2936
+ case "listPublicRecurringSchedule": return projectRecurringSchedule(unwrapResponse(await client({
2937
+ endpoint: "listPublicEvents",
2938
+ params,
2939
+ options: { signal }
2940
+ })));
2941
+ }
2942
+ }
2943
+ /** One shared transport may abort only after every participating request is obsolete. */
2944
+ function batchAbortSignal(signals) {
2945
+ const controller = new AbortController();
2946
+ const abort = () => {
2947
+ if (signals.every((signal) => signal.aborted)) controller.abort();
2948
+ };
2949
+ signals.forEach((signal) => signal.addEventListener("abort", abort));
2950
+ abort();
2951
+ return {
2952
+ signal: controller.signal,
2953
+ dispose: () => signals.forEach((signal) => signal.removeEventListener("abort", abort))
2954
+ };
2955
+ }
2956
+ //#endregion
2957
+ //#region ../preview-next/src/client/blocks/usePreviewBlockResolvedData.ts
2958
+ /** Only active resolved requests live here; the current plan always owns content provenance. */
2959
+ function createPreviewLoaderRequests(apiClient, context) {
2960
+ const entries = /* @__PURE__ */ new Map();
2961
+ const listeners = /* @__PURE__ */ new Set();
2962
+ const version = { current: 0 };
2963
+ const previous = {
2964
+ data: {},
2965
+ failures: {}
2966
+ };
2967
+ const client = createPreviewBlockDataApiClient(apiClient, context);
2968
+ const keyFor = (request) => stableSerialize({
2969
+ endpoint: request.endpoint,
2970
+ params: isSupportedLoaderEndpoint(request.endpoint) ? normalizePublicApiLoaderParams(request.endpoint, request.params, context) : request.params
2971
+ });
2972
+ const notify = () => {
2973
+ version.current += 1;
2974
+ listeners.forEach((listener) => listener());
2975
+ };
2976
+ const start = (request, key) => {
2977
+ const entry = { controller: new AbortController() };
2978
+ entries.set(key, entry);
2979
+ executeBlockDataRequest(request, { apiClient: client(entry.controller.signal) }).then((outcome) => {
2980
+ if (entries.get(key) !== entry || entry.controller.signal.aborted) return;
2981
+ entry.outcome = outcome;
2982
+ notify();
2983
+ });
2984
+ };
2985
+ return {
2986
+ subscribe: (listener) => {
2987
+ listeners.add(listener);
2988
+ return () => {
2989
+ listeners.delete(listener);
2990
+ };
2991
+ },
2992
+ version: () => version.current,
2993
+ reconcile: (plan) => {
2994
+ const requests = new Map(plan.blocks.flatMap((block) => block.requests.map((request) => [keyFor(request), request])));
2995
+ entries.forEach((entry, key) => {
2996
+ if (!requests.has(key)) {
2997
+ entries.delete(key);
2998
+ entry.controller.abort();
2999
+ }
3000
+ });
3001
+ requests.forEach((request, key) => {
3002
+ if (!entries.has(key)) start(request, key);
3003
+ });
3004
+ },
3005
+ project: (plan, server) => {
3006
+ const current = projectBlockDataOutcomes(plan, plan.blocks.flatMap((block) => block.requests.map((request) => {
3007
+ const outcome = entries.get(keyFor(request))?.outcome;
3008
+ return outcome ? {
3009
+ ...outcome,
3010
+ request
3011
+ } : matchingServerOutcome(plan, request, server);
3012
+ })));
3013
+ const data = {
3014
+ ...Object.fromEntries(plan.blocks.filter((block) => block.requests.length > 0 || Object.keys(server?.loaderSnapshot.blocks[block.id]?.requests ?? {}).length > 0).map((block) => [block.id, {}])),
3015
+ ...current.resolvedData
3016
+ };
3017
+ previous.data = reuseLoaderBlockResults(previous.data, data);
3018
+ previous.failures = stableSerialize(previous.failures) === stableSerialize(current.loaderFailures) ? previous.failures : current.loaderFailures;
3019
+ return {
3020
+ ...current,
3021
+ resolvedData: previous.data,
3022
+ loaderFailures: previous.failures
3023
+ };
3024
+ },
3025
+ dispose: () => {
3026
+ entries.forEach((entry) => entry.controller.abort());
3027
+ entries.clear();
3028
+ }
3029
+ };
3030
+ }
3031
+ /** Loader values retain their block identity when their actual loaded values are unchanged. */
3032
+ function reuseLoaderBlockResults(previous, next) {
3033
+ const blocks = Object.fromEntries(Object.entries(next).map(([id, values]) => {
3034
+ const before = previous[id];
3035
+ return [id, before && Object.keys(before).length === Object.keys(values).length && Object.entries(values).every(([key, value]) => Object.prototype.hasOwnProperty.call(before, key) && Object.is(before[key], value)) ? before : values];
3036
+ }));
3037
+ return Object.keys(previous).length === Object.keys(blocks).length && Object.entries(blocks).every(([id, block]) => previous[id] === block) ? previous : blocks;
3038
+ }
3039
+ function serverRequestMatches(plan, request, snapshot) {
3040
+ if (snapshot.stage !== plan.loaderSnapshot.stage) return false;
3041
+ const source = snapshot.blocks[request.blockId];
3042
+ if (!source || source.kind !== request.blockKind) return false;
3043
+ const saved = source.requests[request.key];
3044
+ return Boolean(saved && saved.endpoint === request.endpoint && stableSerialize(saved.params) === stableSerialize(request.params));
3045
+ }
3046
+ function matchingServerOutcome(plan, request, server) {
3047
+ if (!server || !serverRequestMatches(plan, request, server.loaderSnapshot)) return {
3048
+ kind: "failed",
3049
+ request
3050
+ };
3051
+ const values = server.resolvedData[request.blockId];
3052
+ const failure = server.loaderFailures[request.blockId]?.[request.key];
3053
+ return values && Object.prototype.hasOwnProperty.call(values, request.key) && !failure ? {
3054
+ kind: "loaded",
3055
+ request,
3056
+ data: values[request.key]
3057
+ } : {
3058
+ kind: "failed",
3059
+ request
3060
+ };
3061
+ }
3062
+ function serverLoaderGeneration(context) {
3063
+ if (!context) return void 0;
3064
+ return context.prefetchedBlockData ?? context.loaderSnapshot ?? context.resolvedData;
3065
+ }
3066
+ function usePreviewBlockResolvedData(input) {
3067
+ const { page, dataContext, apiClient } = input;
3068
+ const serverGeneration = serverLoaderGeneration(input.serverDataContext ?? dataContext);
3069
+ const context = buildPreviewBlockDataContext(dataContext);
3070
+ const scope = stableSerialize({
3071
+ siteId: context.siteId,
3072
+ pageId: context.pageId,
3073
+ stage: context.previewStage,
3074
+ token: dataContext?.previewToken,
3075
+ apiBaseUrl: dataContext?.apiBaseUrl
3076
+ });
3077
+ const requests = useMemo(() => apiClient && context.siteId ? createPreviewLoaderRequests(apiClient, context) : null, [
3078
+ apiClient,
3079
+ scope,
3080
+ serverGeneration
3081
+ ]);
3082
+ const plan = useMemo(() => planBlockDataRequests(page, context, { isValidEndpoint: isSupportedLoaderEndpoint }), [page, dataContext]);
3083
+ const version = useSyncExternalStore(requests?.subscribe ?? emptySubscribe, requests?.version ?? zero, zero);
3084
+ useEffect(() => {
3085
+ requests?.reconcile(plan);
3086
+ }, [plan, requests]);
3087
+ useEffect(() => () => requests?.dispose(), [requests]);
3088
+ const icons = usePreviewGeneratedIcons(page, dataContext?.siteId, apiClient, scope, serverGeneration);
3089
+ const current = useMemo(() => {
3090
+ const server = dataContext?.prefetchedBlockData ?? (dataContext?.loaderSnapshot ? {
3091
+ resolvedData: dataContext.resolvedData ?? {},
3092
+ loaderFailures: dataContext.loaderFailures ?? {},
3093
+ loaderSnapshot: dataContext.loaderSnapshot
3094
+ } : void 0);
3095
+ return requests?.project(plan, server);
3096
+ }, [
3097
+ dataContext,
3098
+ plan,
3099
+ requests,
3100
+ version
3101
+ ]);
3102
+ const resolvedData = useMemo(() => current ? mergeGeneratedIconAssetsIntoResolvedData(current.resolvedData, icons) : null, [current?.resolvedData, icons]);
3103
+ return useMemo(() => {
3104
+ if (!current || !resolvedData) return {
3105
+ resolvedData: null,
3106
+ loaderFailures: null
3107
+ };
3108
+ const prefetchedBlockData = {
3109
+ ...current,
3110
+ resolvedData
3111
+ };
3112
+ return {
3113
+ resolvedData,
3114
+ loaderFailures: current.loaderFailures,
3115
+ prefetchedBlockData,
3116
+ loaderSnapshot: current.loaderSnapshot
3117
+ };
3118
+ }, [current, resolvedData]);
3119
+ }
3120
+ const emptySubscribe = () => () => {};
3121
+ const zero = () => 0;
3122
+ function buildPreviewBlockDataContext(dataContext) {
3123
+ if (!dataContext) return {};
3124
+ const { siteId, pageId, previewStage, now, bookingTimeZone, routes, pagesByIdentifier, entriesByIdentifier, occurrenceContext = null, entrySubrouteContext = null, contentEntry = null, bookingOfferingPresets = [] } = dataContext;
3125
+ return {
3126
+ siteId,
3127
+ pageId,
3128
+ previewStage,
3129
+ root: {
3130
+ now,
3131
+ bookingTimeZone,
3132
+ routes,
3133
+ pagesByIdentifier,
3134
+ entriesByIdentifier,
3135
+ occurrenceContext,
3136
+ entrySubrouteContext,
3137
+ contentEntry,
3138
+ bookingOfferingPresets
3139
+ }
3140
+ };
3141
+ }
3142
+ function usePreviewGeneratedIcons(page, siteId, apiClient, scope, serverGeneration) {
3143
+ const refs = collectGeneratedIconAssetRefs(page);
3144
+ const request = useMemo(() => {
3145
+ return {
3146
+ state: {
3147
+ data: {},
3148
+ version: 0
3149
+ },
3150
+ listeners: /* @__PURE__ */ new Set(),
3151
+ refs
3152
+ };
3153
+ }, [
3154
+ apiClient,
3155
+ stableSerialize(refs),
3156
+ scope,
3157
+ serverGeneration
3158
+ ]);
3159
+ useSyncExternalStore(useMemo(() => (listener) => {
3160
+ request.listeners.add(listener);
3161
+ return () => {
3162
+ request.listeners.delete(listener);
3163
+ };
3164
+ }, [request]), () => request.state.version, zero);
3165
+ useEffect(() => {
3166
+ if (!apiClient || !siteId || request.refs.length === 0) return;
3167
+ const controller = new AbortController();
3168
+ apiClient({
3169
+ endpoint: "getGeneratedIconRenderAssets",
3170
+ params: { siteId },
3171
+ body: { refs: dedupeGeneratedIconAssetRefs(request.refs) },
3172
+ options: { signal: controller.signal }
3173
+ }).then((response) => {
3174
+ if (controller.signal.aborted) return;
3175
+ request.state.data = mapGeneratedIconAssetsToBlocks(request.refs, unwrapResponse(response).assets);
3176
+ request.state.version += 1;
3177
+ request.listeners.forEach((listener) => listener());
3178
+ }).catch(() => {});
3179
+ return () => controller.abort();
3180
+ }, [
3181
+ apiClient,
3182
+ request,
3183
+ siteId
3184
+ ]);
3185
+ return request.state.data;
3186
+ }
3187
+ //#endregion
3188
+ //#region ../preview-next/src/client/blocks/composer/mergeDrafts.ts
3189
+ const EMPTY_LINKED_ENTRY_OVERLAY = /* @__PURE__ */ new Map();
3190
+ /**
3191
+ * Draft snapshots as the preview renders them: `current` follows the tab's render
3192
+ * source (its own edits, or another tab's live drafts while it only views).
3193
+ */
3194
+ function getDraftSnapshots(uiStore) {
3195
+ const state = uiStore.getState();
3196
+ const source = renderSourceFor(state.editability);
3197
+ return new Map(state.drafts.inspect().map((snap) => [snap.id, {
3198
+ id: snap.id,
3199
+ baseline: snap.sync.baseline.values,
3200
+ current: resolveRenderedValues(source, snap, remoteDraftValues(state.remoteDrafts, {
3201
+ kind: "block",
3202
+ id: snap.id
3203
+ }))
3204
+ }]));
3205
+ }
3206
+ function mergeBlockWithDraft(block, draftMap, index, projections = [], linkedEntryOverlays = EMPTY_LINKED_ENTRY_OVERLAY, versions = NO_BLOCK_VERSIONS) {
3207
+ const { id, baseline, draftContent } = blockRenderSources(block, draftMap);
3208
+ return {
3209
+ id,
3210
+ kind: block.kind,
3211
+ purpose: "content",
3212
+ orderIndex: block.orderIndex ?? index,
3213
+ content: renderBlockContent(block, baseline, projections, linkedEntryOverlays),
3214
+ draftContent: renderBlockContent(block, draftContent, projections, linkedEntryOverlays),
3215
+ versions,
3216
+ bindings: block.bindings ?? null
3217
+ };
3218
+ }
3219
+ /** Select canonical sources once; runtime decorations never change either source. */
3220
+ function blockRenderSources(block, drafts) {
3221
+ const id = block.id ?? null;
3222
+ const snapshot = id ? drafts.get(unsafeAsEditorBlockId(id)) : void 0;
3223
+ const baseline = snapshot?.baseline ?? block.content ?? null;
3224
+ return {
3225
+ id,
3226
+ baseline,
3227
+ draftContent: id ? snapshot?.current ?? baseline : null
3228
+ };
3229
+ }
3230
+ function renderBlockContent(block, content, projections, linkedEntryOverlays = EMPTY_LINKED_ENTRY_OVERLAY) {
3231
+ return applyPreviewRuntimeContentProjections(block, applyLinkedEntryRenderOverlay(content, linkedEntryOverlays), projections);
3232
+ }
3233
+ //#endregion
3234
+ //#region ../preview-next/src/client/blocks/composer/transformBlock.ts
3235
+ function transformToPageBlock(enriched) {
3236
+ return {
3237
+ id: enriched.id,
3238
+ publishedPlacement: enriched.versions.publishedPlacement,
3239
+ contentVersionId: selectedContentVersionId(enriched.versions),
3240
+ kind: enriched.kind,
3241
+ purpose: enriched.purpose,
3242
+ content: enriched.content ?? {},
3243
+ draftContent: enriched.draftContent ?? void 0,
3244
+ bindings: enriched.bindings ?? void 0
3245
+ };
3246
+ }
3247
+ //#endregion
3248
+ //#region ../preview-next/src/client/blocks/composer/caching.ts
3249
+ function applyCacheOptimization(enrichedBlocks, cacheRef) {
3250
+ const cache = cacheRef.current;
3251
+ const presentIds = /* @__PURE__ */ new Set();
3252
+ const renderedBlocks = enrichedBlocks.map((block) => {
3253
+ const id = block.id;
3254
+ if (id) {
3255
+ presentIds.add(id);
3256
+ const cached = cache.get(id);
3257
+ if (cached && sameRenderedBlock(cached.src, block)) return cached.out;
3258
+ const out = transformToPageBlock(block);
3259
+ cache.set(id, {
3260
+ src: block,
3261
+ out
3262
+ });
3263
+ return out;
3264
+ }
3265
+ return transformToPageBlock(block);
3266
+ });
3267
+ Array.from(cache.keys()).filter((key) => !presentIds.has(key)).forEach((key) => cache.delete(key));
3268
+ return renderedBlocks;
3269
+ }
3270
+ function sameRenderedBlock(previous, current) {
3271
+ return previous.id === current.id && previous.kind === current.kind && previous.purpose === current.purpose && previous.orderIndex === current.orderIndex && sameRenderValue(previous.content, current.content) && sameRenderValue(previous.draftContent, current.draftContent) && sameRenderValue(previous.versions, current.versions) && sameRenderValue(previous.bindings, current.bindings);
3272
+ }
3273
+ /** Exact rendered values: unlike authored equality, absent, empty and null stay distinct. */
3274
+ function sameRenderValue(previous, current) {
3275
+ if (Object.is(previous, current)) return true;
3276
+ if (Array.isArray(previous)) return Array.isArray(current) && previous.length === current.length && sameRenderMembers(previous, current);
3277
+ if (!plainRenderRecord(previous) || !plainRenderRecord(current)) return false;
3278
+ return sameRenderMembers(previous, current);
3279
+ }
3280
+ function sameRenderMembers(previous, current) {
3281
+ const keys = Object.keys(previous);
3282
+ return keys.length === Object.keys(current).length && keys.every((key) => Object.prototype.hasOwnProperty.call(current, key) && sameRenderValue(Reflect.get(previous, key), Reflect.get(current, key)));
3283
+ }
3284
+ function plainRenderRecord(value) {
3285
+ return typeof value === "object" && value !== null && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
3286
+ }
3287
+ //#endregion
3288
+ //#region ../preview-next/src/client/blocks/composer/composePageFromBlocks.ts
3289
+ function composePageFromBlocks(args, cacheRef) {
3290
+ const { page, blockItems, projections = [], uiStore } = args;
3291
+ const draftMap = getDraftSnapshots(uiStore);
3292
+ const entryProjections = entryDraftProjections(uiStore, args.dateContext);
3293
+ const linkedEntryOverlays = linkedEntryRenderOverlaysFromStore(uiStore);
3294
+ return composePreviewRenderPage({
3295
+ page,
3296
+ blockItems,
3297
+ draftSnapshots: Array.from(draftMap.values()),
3298
+ projections: [...entryProjections, ...projections],
3299
+ linkedEntryOverlays,
3300
+ blockVersions: uiStore.getState().blockVersions.get
3301
+ }, cacheRef);
3302
+ }
3303
+ function composePreviewRenderPage(args, cacheRef) {
3304
+ const { page, blockItems, draftSnapshots, linkedEntryOverlays, blockVersions } = args;
3305
+ if (!page) return page;
3306
+ const projections = args.projections.some((projection) => projection.kind === "runtime-content-decoration" && projection.source === "page-design") ? args.projections : [...args.projections, runtimeContentDecorationProjectionFromServerPage(page.blocks)];
3307
+ if (!blockItems.length) return {
3308
+ ...page,
3309
+ blocks: applyCacheOptimization(page.blocks.map((block, index) => mergeTemplateBlock(block, index, projections, linkedEntryOverlays)), cacheRef)
3310
+ };
3311
+ const draftMap = draftSnapshotMap(draftSnapshots);
3312
+ const renderedBlocks = applyCacheOptimization([...blockItems.map((block, index) => mergeBlockWithDraft(block, draftMap, index, projections, linkedEntryOverlays, (block.id ? blockVersions(unsafeAsEditorBlockId(block.id)) : null) ?? NO_BLOCK_VERSIONS))].sort((a, b) => (a.orderIndex ?? 0) - (b.orderIndex ?? 0)), cacheRef);
3313
+ return {
3314
+ ...page,
3315
+ blocks: renderedBlocks
3316
+ };
3317
+ }
3318
+ function mergeTemplateBlock(block, index, projections, linkedEntryOverlays) {
3319
+ return {
3320
+ id: block.id ?? null,
3321
+ kind: block.kind,
3322
+ purpose: block.purpose,
3323
+ orderIndex: index,
3324
+ content: renderBlockContent(block, block.content ?? null, projections, linkedEntryOverlays),
3325
+ draftContent: block.draftContent ? renderBlockContent(block, block.draftContent, projections, linkedEntryOverlays) : null,
3326
+ versions: NO_BLOCK_VERSIONS,
3327
+ bindings: block.bindings ?? null
3328
+ };
3329
+ }
3330
+ /** Entry fields changed in the editor (locally or live from another tab) are bound in first. */
3331
+ function entryDraftProjections(uiStore, dateContext) {
3332
+ const state = uiStore.getState();
3333
+ const projection = entryFieldRebindingProjection(renderedFieldChanges(renderSourceFor(state.editability), state.content?.getSnapshot() ?? null, remoteDraftValues(state.remoteDrafts, { kind: "content" })), dateContext);
3334
+ return projection ? [projection] : [];
3335
+ }
3336
+ function draftSnapshotMap(snapshots) {
3337
+ return new Map(snapshots.map((snap) => [snap.id, snap]));
3338
+ }
3339
+ //#endregion
3340
+ //#region ../preview-next/src/client/blocks/editorRegistry.tsx
3341
+ function requireClientRegistryComponent(key) {
3342
+ const component = clientComponentRegistry[key];
3343
+ if (!component) throw new Error(`[editorRegistry] Missing component: ${String(key)}`);
3344
+ return component;
3345
+ }
3346
+ const ButtonComponent = requireClientRegistryComponent("button");
3347
+ function dispatchBlockFieldFocusEventFromPath(path) {
3348
+ const match = path.match(/^blocks\.([^.]+)\.(.+)$/);
3349
+ if (!match?.[1] || !match[2]) return;
3350
+ dispatchBlockFieldFocusEvent({
3351
+ kind: "block-field",
3352
+ blockId: match[1],
3353
+ fieldPath: match[2]
3354
+ });
3355
+ }
3356
+ const TextWithEditor = ({ value, children, path, linkedEntryField, inlineTextFallbackPath, blockContent, ...rest }) => {
3357
+ const fallbackContent = inlineTextFallbackPath ? readStringPath(blockContent, inlineTextFallbackPath) ?? normalizeTextChildren(children) : normalizeTextChildren(value ?? children);
3358
+ const inlineText = coercePreviewInlineText(value, fallbackContent);
3359
+ const content = inlineText ? inlineTextToPlainText(inlineText) : fallbackContent;
3360
+ const { isEditingMode } = useEditor();
3361
+ if (inlineTextFallbackPath && path && !linkedEntryField) {
3362
+ const plainTextPath = siblingPath(path, inlineTextFallbackPath);
3363
+ if (isEditingMode) return /* @__PURE__ */ jsx(PreviewInlineTextEditor, {
3364
+ ...rest,
3365
+ path,
3366
+ plainTextPath,
3367
+ fallbackPlainText: content,
3368
+ onBlockFieldFocus: dispatchBlockFieldFocusEventFromPath
3369
+ });
3370
+ return /* @__PURE__ */ jsx(Text, {
3371
+ ...rest,
3372
+ path,
3373
+ children: inlineText && !isInlineTextEmpty(inlineText) ? renderInlineText(inlineText) : content
3374
+ });
3375
+ }
3376
+ if (isEditingMode) return path || linkedEntryField ? /* @__PURE__ */ jsx(PreviewTextEditor, {
3377
+ ...rest,
3378
+ path,
3379
+ linkedEntryField,
3380
+ onLinkedEntryFieldFocus: dispatchLinkedEntryFieldFocusEvent,
3381
+ onBlockFieldFocus: dispatchBlockFieldFocusEventFromPath,
3382
+ children: content
3383
+ }) : /* @__PURE__ */ jsx(Text, {
3384
+ ...rest,
3385
+ children: content
3386
+ });
3387
+ return /* @__PURE__ */ jsx(Text, {
3388
+ ...rest,
3389
+ path,
3390
+ children: content
3391
+ });
3392
+ };
3393
+ function coercePreviewInlineText(value, fallbackPlainText) {
3394
+ const coerced = coerceInlineTextWithFallback(value, fallbackPlainText);
3395
+ return !isInlineTextEmpty(coerced) || fallbackPlainText.length === 0 ? coerced : null;
3396
+ }
3397
+ function readStringPath(source, path) {
3398
+ const value = getAtPath(source, path);
3399
+ return typeof value === "string" ? value : null;
3400
+ }
3401
+ function normalizeTextChildren(input) {
3402
+ if (input === null || input === void 0) return "";
3403
+ if (typeof input === "string" || typeof input === "number") return String(input);
3404
+ if (Array.isArray(input)) return input.map((item) => normalizeTextChildren(item)).join("");
3405
+ return "";
3406
+ }
3407
+ function renderPreviewRichTextToolbarHost(toolbar) {
3408
+ return /* @__PURE__ */ jsx(PreviewChromeFloatingBar, {
3409
+ anchorSelector: "[data-rb-preview-richtext-editor]",
3410
+ children: toolbar
3411
+ });
3412
+ }
3413
+ const RichTextWithEditor = ({ value, path, linkedEntryField, ...rest }) => {
3414
+ const { isEditingMode } = useEditor();
3415
+ if (isEditingMode && (path || linkedEntryField)) return /* @__PURE__ */ jsx(PreviewRichTextEditor, {
3416
+ ...rest,
3417
+ path,
3418
+ linkedEntryField,
3419
+ onLinkedEntryFieldFocus: dispatchLinkedEntryFieldFocusEvent,
3420
+ onBlockFieldFocus: dispatchBlockFieldFocusEventFromPath,
3421
+ renderToolbarHost: renderPreviewRichTextToolbarHost,
3422
+ doc: value
3423
+ });
3424
+ return /* @__PURE__ */ jsx(RichText, {
3425
+ ...rest,
3426
+ path,
3427
+ doc: value
3428
+ });
3429
+ };
3430
+ const LinkedEntryEditFrame = ({ target, children }) => {
3431
+ const { isEditingMode } = useEditor();
3432
+ if (!isEditingMode) return /* @__PURE__ */ jsx(Fragment$1, { children });
3433
+ return /* @__PURE__ */ jsxs("div", {
3434
+ className: "group/linked-entry-edit relative",
3435
+ "data-linked-entry-id": target.entryId,
3436
+ "data-linked-entry-type": target.contentTypeKey,
3437
+ children: [children, /* @__PURE__ */ jsx("button", {
3438
+ type: "button",
3439
+ "aria-label": `Edit ${target.contentTypeLabel}: ${target.title}`,
3440
+ className: "absolute right-2 top-2 z-20 rounded-full border border-white/80 bg-neutral-950/85 px-3 py-1 text-xs font-medium text-white opacity-0 shadow-sm transition focus:opacity-100 group-hover/linked-entry-edit:opacity-100",
3441
+ onClick: (event) => {
3442
+ event.preventDefault();
3443
+ event.stopPropagation();
3444
+ dispatchLinkedEntryEditEvent(target);
3445
+ },
3446
+ children: "Edit"
3447
+ })]
3448
+ });
3449
+ };
3450
+ /**
3451
+ * In editing mode, a click on a preview button must not perform its real
3452
+ * action (navigate, submit, etc.) — instead it should hand focus to the
3453
+ * inline editable label so the author can edit the text. The caller-supplied
3454
+ * `onClick` is intentionally not invoked here; outside editing mode the
3455
+ * underlying button component receives all props unchanged.
3456
+ */
3457
+ const ButtonWithEditorInterception = (props) => {
3458
+ const { isEditingMode } = useEditor();
3459
+ if (!isEditingMode) return /* @__PURE__ */ jsx(ButtonComponent, { ...props });
3460
+ const { onClick: _suppressedCallerOnClick, ...rest } = props;
3461
+ return /* @__PURE__ */ jsx(ButtonComponent, {
3462
+ ...rest,
3463
+ onClick: (event) => {
3464
+ event.preventDefault();
3465
+ event.currentTarget.querySelector("[contenteditable=\"true\"]")?.focus();
3466
+ }
3467
+ });
3468
+ };
3469
+ const editorRegistry = {
3470
+ ...clientComponentRegistry,
3471
+ text: TextWithEditor,
3472
+ richText: RichTextWithEditor,
3473
+ button: ButtonWithEditorInterception,
3474
+ media: requireClientRegistryComponent("media"),
3475
+ linkedEntryEditFrame: LinkedEntryEditFrame
3476
+ };
3477
+ //#endregion
3478
+ //#region ../preview-next/src/client/blocks/useBlockSelection.ts
3479
+ const PHONE_VIEWPORT_QUERY = "(max-width: 639px)";
3480
+ /**
3481
+ * Click to select: a click anywhere in the block selects it, so its controls
3482
+ * stay put instead of only showing on hover. A click on an empty placeholder
3483
+ * also opens the side panel on the field that fills it.
3484
+ */
3485
+ function useBlockSelection(input) {
3486
+ const probeRef = useRef(null);
3487
+ const selection = usePreviewSidebarNavigation();
3488
+ const selectBlock = selection.selectBlock;
3489
+ const onOpenFieldRef = useRef(input.onOpenField);
3490
+ onOpenFieldRef.current = input.onOpenField;
3491
+ const phone = useMediaQuery(PHONE_VIEWPORT_QUERY);
3492
+ const [blockElement, setBlockElement] = useState(null);
3493
+ useEffect(() => {
3494
+ const block = probeRef.current?.closest("[data-block-id]") ?? null;
3495
+ setBlockElement(block);
3496
+ if (!block || !selectBlock) return;
3497
+ const handleClick = (event) => {
3498
+ selectBlock(input.blockId);
3499
+ const fieldPath = (event.target instanceof Element ? event.target.closest("[data-placeholder-field]") : null)?.dataset.placeholderField;
3500
+ if (fieldPath) onOpenFieldRef.current(fieldPath);
3501
+ };
3502
+ block.addEventListener("click", handleClick);
3503
+ return () => block.removeEventListener("click", handleClick);
3504
+ }, [input.blockId, selectBlock]);
3505
+ return {
3506
+ probeRef,
3507
+ selected: selection.navigation.selectedBlock?.blockId === input.blockId,
3508
+ blockElement,
3509
+ selectedElsewhere: selection.navigation.selectedBlock?.blockId != null && selection.navigation.selectedBlock?.blockId !== input.blockId,
3510
+ phone
3511
+ };
3512
+ }
3513
+ function useMediaQuery(query) {
3514
+ const [matches, setMatches] = useState(false);
3515
+ useEffect(() => {
3516
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
3517
+ const list = window.matchMedia(query);
3518
+ const update = () => setMatches(list.matches);
3519
+ update();
3520
+ list.addEventListener("change", update);
3521
+ return () => list.removeEventListener("change", update);
3522
+ }, [query]);
3523
+ return matches;
3524
+ }
3525
+ //#endregion
3526
+ //#region ../preview-next/src/client/blocks/BlockReadinessNote.tsx
3527
+ /**
3528
+ * The canvas note on a block that isn't set up yet: only editors see it, and
3529
+ * it sits inside the block so it moves with it.
3530
+ */
3531
+ function BlockReadinessNote({ needs, element, blockName, onSetUp }) {
3532
+ if (!needs || !element) return null;
3533
+ return createPortal(/* @__PURE__ */ jsxs("div", {
3534
+ "data-preview-readiness-note": "",
3535
+ role: "note",
3536
+ "aria-label": `${blockName}: ${NEEDS_SETUP_LABEL}`,
3537
+ className: "absolute left-4 top-4 z-20 flex max-w-[22rem] gap-2.5 rounded-xl border border-amber-300 bg-amber-50 p-3 text-left font-sans text-[13px] leading-snug text-slate-900 shadow-md",
3538
+ children: [/* @__PURE__ */ jsx(TriangleAlert, {
3539
+ className: "mt-0.5 h-4 w-4 shrink-0 text-amber-600",
3540
+ "aria-hidden": "true"
3541
+ }), /* @__PURE__ */ jsxs("div", {
3542
+ className: "min-w-0 space-y-1.5",
3543
+ children: [
3544
+ /* @__PURE__ */ jsxs("p", {
3545
+ className: "font-semibold",
3546
+ children: [
3547
+ blockName,
3548
+ " ",
3549
+ /* @__PURE__ */ jsxs("span", {
3550
+ className: "font-normal text-amber-800",
3551
+ children: ["· ", NEEDS_SETUP_LABEL]
3552
+ })
3553
+ ]
3554
+ }),
3555
+ /* @__PURE__ */ jsx("p", { children: needsSetupMessage(needs) }),
3556
+ /* @__PURE__ */ jsx("p", {
3557
+ className: "text-xs text-slate-600",
3558
+ children: "You're seeing this because you're editing."
3559
+ }),
3560
+ /* @__PURE__ */ jsx("button", {
3561
+ type: "button",
3562
+ onClick: onSetUp,
3563
+ className: "rounded-full bg-slate-900 px-3 py-1 text-xs font-semibold text-white hover:bg-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500",
3564
+ children: "Set this up"
3565
+ })
3566
+ ]
3567
+ })]
3568
+ }), element);
3569
+ }
3570
+ //#endregion
3571
+ //#region ../preview-next/src/client/blocks/insertionEdge.ts
3572
+ /**
3573
+ * A new block at `position` goes above the block now at that index; one at the
3574
+ * end goes below the last block. Every other block shows nothing.
3575
+ */
3576
+ function insertionEdgeFor(input) {
3577
+ const { index, count, position } = input;
3578
+ if (position === null || index < 0) return null;
3579
+ if (position === index) return "top";
3580
+ return position >= count && index === count - 1 ? "bottom" : null;
3581
+ }
3582
+ //#endregion
3583
+ //#region ../preview-next/src/client/blocks/InsertionMarker.tsx
3584
+ /**
3585
+ * The edge this block shows the marker on, if the sidebar is adding a block
3586
+ * next to it in the collection that's mounted. Each block subscribes for
3587
+ * itself, so moving the marker only re-renders the blocks it moves between.
3588
+ */
3589
+ function useInsertionEdge(blockId) {
3590
+ return useEditorUiStore((state) => {
3591
+ const view = state.sidebarNavigation.view;
3592
+ if (view.kind !== "addBlock" && view.kind !== "chooseLook") return null;
3593
+ if (!authoredValuesEqual(view.anchor.owner, state.structure.getOwner())) return null;
3594
+ const blocks = state.structure.getList();
3595
+ return insertionEdgeFor({
3596
+ index: blocks.findIndex((block) => String(block.id) === blockId),
3597
+ count: blocks.length,
3598
+ position: view.anchor.position
3599
+ });
3600
+ });
3601
+ }
3602
+ /**
3603
+ * While the sidebar is adding a block, the canvas shows where it'll go: a
3604
+ * line on the edge of the block it goes next to, brought into view.
3605
+ */
3606
+ function InsertionMarker({ blockId, element }) {
3607
+ const edge = useInsertionEdge(blockId);
3608
+ const ref = useRef(null);
3609
+ useEffect(() => {
3610
+ const marker = ref.current;
3611
+ if (edge && marker) return revealWhenShown(marker);
3612
+ }, [edge, element]);
3613
+ if (!edge || !element) return null;
3614
+ return createPortal(/* @__PURE__ */ jsx(EditorInsertionMarker, {
3615
+ ref,
3616
+ edge
3617
+ }), element);
3618
+ }
3619
+ /**
3620
+ * Scrolls the marker into view once it can be seen. On phones the canvas is a
3621
+ * hidden tab while the sidebar adds a block, so this waits for that tab.
3622
+ */
3623
+ function revealWhenShown(marker) {
3624
+ const reveal = () => marker.scrollIntoView({
3625
+ block: "center",
3626
+ behavior: "smooth"
3627
+ });
3628
+ if (typeof ResizeObserver === "undefined") {
3629
+ reveal();
3630
+ return () => {};
3631
+ }
3632
+ const observer = new ResizeObserver(() => {
3633
+ if (marker.getClientRects().length === 0) return;
3634
+ reveal();
3635
+ observer.disconnect();
3636
+ });
3637
+ observer.observe(marker);
3638
+ return () => observer.disconnect();
3639
+ }
3640
+ //#endregion
3641
+ //#region ../preview-next/src/client/blocks/BlockToolbar.tsx
3642
+ function BlockToolbar(input) {
3643
+ const { selection, controls, toolbar, open, openField, cycleSdk, cycleRecipe } = useBlockToolbar(input);
3644
+ const needs = useBlockNeedsSetup(input.blockId);
3645
+ const name = controls.manifest?.title ?? getBlockDefinition(input.blockKind)?.manifest.title ?? input.blockKind;
3646
+ const row = /* @__PURE__ */ jsxs(EditorCanvasChipRow, {
3647
+ label: `${name} controls`,
3648
+ children: [
3649
+ /* @__PURE__ */ jsx(EditorCanvasNameChip, {
3650
+ name,
3651
+ onOpen: open
3652
+ }),
3653
+ toolbar?.controls.mode ? /* @__PURE__ */ jsx(ArrangementModeSwitchPill, {
3654
+ blockLabel: name,
3655
+ mode: toolbar.controls.mode,
3656
+ onChoose: toolbar.chooseMode
3657
+ }) : null,
3658
+ /* @__PURE__ */ jsx(ToolbarLook, {
3659
+ controls,
3660
+ toolbar,
3661
+ onCycleSdk: cycleSdk,
3662
+ onCycleRecipe: cycleRecipe
3663
+ })
3664
+ ]
3665
+ });
3666
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3667
+ /* @__PURE__ */ jsx("span", {
3668
+ ref: selection.probeRef,
3669
+ "aria-hidden": "true"
3670
+ }),
3671
+ /* @__PURE__ */ jsx(BlockSelectionFrame, {
3672
+ selected: selection.selected,
3673
+ element: selection.blockElement
3674
+ }),
3675
+ /* @__PURE__ */ jsx(BlockReadinessNote, {
3676
+ needs,
3677
+ element: selection.blockElement,
3678
+ blockName: name,
3679
+ onSetUp: () => needs?.repair.kind === "field" ? openField(needs.repair.path) : open()
3680
+ }),
3681
+ /* @__PURE__ */ jsx(InsertionMarker, {
3682
+ blockId: input.blockId,
3683
+ element: selection.blockElement
3684
+ }),
3685
+ /* @__PURE__ */ jsx(ToolbarPlacement, {
3686
+ blockId: input.blockId,
3687
+ placement: currentBlockToolbarPlacement,
3688
+ selected: selection.selected,
3689
+ phone: selection.phone,
3690
+ children: row
3691
+ })
3692
+ ] });
3693
+ }
3694
+ /** A separate frame preserves the site's own borders, shadows and outlines. */
3695
+ function BlockSelectionFrame({ selected, element }) {
3696
+ return selected && element ? createPortal(/* @__PURE__ */ jsx(EditorSelectionFrame, {}), element) : null;
3697
+ }
3698
+ function useBlockToolbar(input) {
3699
+ const uiStore = useEditorUiStoreInstance();
3700
+ const editorBlockId = useMemo(() => unsafeAsEditorBlockId(input.blockId), [input.blockId]);
3701
+ const values = useEditorUiStore((state) => state.drafts.getCurrentValues(editorBlockId)) ?? input.content;
3702
+ const opener = useOpenBlockForSetup();
3703
+ const open = () => opener.open(editorBlockId);
3704
+ const openField = (fieldPath) => opener.openField(editorBlockId, fieldPath);
3705
+ const selection = useBlockSelection({
3706
+ blockId: editorBlockId,
3707
+ onOpenField: openField
3708
+ });
3709
+ const controls = useBlockCustomizeControls({
3710
+ blockId: editorBlockId,
3711
+ blockKind: input.blockKind,
3712
+ content: values,
3713
+ uiStore,
3714
+ theme: input.theme
3715
+ });
3716
+ const { state, applyAction } = usePreviewPageDesignEditorState();
3717
+ const toolbar = useArrangementToolbar({
3718
+ designBlock: controls.designBlock,
3719
+ content: values,
3720
+ pageDesignState: state,
3721
+ selected: selection.selected,
3722
+ save: (action) => {
3723
+ applyAction(action, { runtimeContent: values });
3724
+ },
3725
+ chooseBackground: open,
3726
+ openField
3727
+ });
3728
+ const cycleSdk = (direction) => cycleSdkLook(controls, direction);
3729
+ const cycleRecipe = (direction) => {
3730
+ if (!controls.designBlock) return;
3731
+ const action = cyclePageDesignBlockLook(controls.designBlock, direction);
3732
+ if (action) applyAction(action, { runtimeContent: values });
3733
+ };
3734
+ return {
3735
+ selection,
3736
+ controls,
3737
+ toolbar,
3738
+ open,
3739
+ openField,
3740
+ cycleSdk,
3741
+ cycleRecipe
3742
+ };
3743
+ }
3744
+ function cycleSdkLook(controls, direction) {
3745
+ const item = controls.lookSource.kind === "sdk" ? controls.lookSource.item : null;
3746
+ if (item?.field.type !== "select" || !controls.backend) return;
3747
+ const options = item.field.options;
3748
+ const current = options.findIndex((option) => option.value === (controls.backend?.getValue(item.path) ?? item.field.defaultValue));
3749
+ const next = options[(Math.max(0, current) + (direction === "next" ? 1 : options.length - 1)) % options.length];
3750
+ if (next) controls.backend.setValue(item.path, next.value);
3751
+ }
3752
+ /** The Look pill shows only while its arrows have somewhere to go. */
3753
+ function ToolbarLook({ controls, toolbar, onCycleSdk, onCycleRecipe }) {
3754
+ if (controls.lookSource.kind === "sdk") {
3755
+ const field = cyclableSdkLookField(controls.lookSource.item);
3756
+ return field && controls.lookSource.item ? /* @__PURE__ */ jsx(SdkToolbarLook, {
3757
+ field,
3758
+ value: controls.backend?.getValue(controls.lookSource.item.path),
3759
+ onCycle: onCycleSdk
3760
+ }) : null;
3761
+ }
3762
+ if (toolbar?.controls.look) return toolbar.controls.tiles.length > 1 ? /* @__PURE__ */ jsx(ArrangementLookPill, {
3763
+ look: toolbar.controls.look,
3764
+ position: lookTilePosition(toolbar.controls.tiles),
3765
+ onCycle: toolbar.cycleLook
3766
+ }) : null;
3767
+ if (!controls.designBlock) return null;
3768
+ const preset = pageDesignLookPosition(controls.designBlock);
3769
+ return preset.canCycle ? /* @__PURE__ */ jsx(LookCyclePill, {
3770
+ lookName: preset.lookName,
3771
+ position: preset.position,
3772
+ onCycle: onCycleRecipe
3773
+ }) : null;
3774
+ }
3775
+ function cyclableSdkLookField(item) {
3776
+ return item?.field.type === "select" && item.field.options.length > 1 ? item.field : null;
3777
+ }
3778
+ function ToolbarPlacement({ blockId, placement, selected, phone, children }) {
3779
+ if (phone && selected && typeof document !== "undefined") return createPortal(/* @__PURE__ */ jsx("div", {
3780
+ "data-preview-block-dock": "",
3781
+ className: "builder-dashboard-chrome-theme fixed inset-x-2 bottom-[calc(var(--builder-editor-chrome-offset,0px)+0.5rem)] rounded-xl border bg-background/95 p-2 text-foreground shadow-xl [body:has([data-state=inactive]_[data-preview-scroll-viewport])_&]:hidden",
3782
+ style: {
3783
+ ...readThemeCustomProperties(document.querySelector(`[data-block-id="${blockId}"]`) ?? document.documentElement),
3784
+ zIndex: 30
3785
+ },
3786
+ children
3787
+ }), document.body);
3788
+ return /* @__PURE__ */ jsx(PreviewChromeFloatingControl, {
3789
+ anchorSelector: `[data-block-id="${blockId}"]`,
3790
+ placement,
3791
+ selected,
3792
+ stayInsideAnchor: true,
3793
+ fallbackClassName: "absolute right-4 top-2",
3794
+ children
3795
+ });
3796
+ }
3797
+ /** The floating chrome owner reads geometry; content rendering never subscribes to it. */
3798
+ function currentBlockToolbarPlacement() {
3799
+ return planBlockToolbarPlacement({ headerClearance: measureSiteTopChromeClearance() });
3800
+ }
3801
+ function SdkToolbarLook({ field, value, onCycle }) {
3802
+ const index = field.options.findIndex((option) => option.value === (value ?? field.defaultValue));
3803
+ return /* @__PURE__ */ jsx(LookCyclePill, {
3804
+ lookName: field.options[index]?.label ?? "Choose a Look",
3805
+ position: lookPositionLabel(index, field.options.length),
3806
+ onCycle
3807
+ });
3808
+ }
3809
+ //#endregion
3810
+ //#region ../preview-next/src/client/blocks/EditablePageRenderer.tsx
3811
+ /** Published requests bypass every editor, draft and design projection. View presentation of a live draft still uses the draft renderer. */
3812
+ function EditablePageRenderer(props) {
3813
+ const shown = usePreviewCompiledThemeOptional();
3814
+ if (props.dataContext?.previewStage === "published") {
3815
+ const { blockDataApiClient: _blockDataApiClient, previewAs: _previewAs, previewAuthoring: _previewAuthoring, renderJoin: _renderJoin, ...published } = props;
3816
+ const page = published.page ? {
3817
+ ...published.page,
3818
+ blocks: published.page.blocks.map((block) => ({
3819
+ ...block,
3820
+ draftContent: null,
3821
+ publishedPlacement: readPublishedBlockPlacement(typeof block.contentVersionId === "string" ? block.contentVersionId : null, block.content)
3822
+ }))
3823
+ } : null;
3824
+ return /* @__PURE__ */ jsx(EditorPageRenderer, {
3825
+ ...published,
3826
+ page,
3827
+ previewAs: "visitor",
3828
+ previewAuthoring: void 0
3829
+ });
3830
+ }
3831
+ return /* @__PURE__ */ jsx(EditableDraftPageRenderer, { ...props.rendering?.kind === "overrides-only" || !shown ? props : {
3832
+ ...props,
3833
+ rendering: void 0,
3834
+ theme: shown.theme
3835
+ } });
3836
+ }
3837
+ function EditableDraftPageRenderer(props) {
3838
+ const { blockDataApiClient = null, ...pageRendererProps } = props;
3839
+ const { blocks } = useEntryEditorController();
3840
+ const uiStore = useEditorUiStoreInstance();
3841
+ const pageDesignState = usePreviewPageDesignRenderState();
3842
+ const blockItems = useMemo(() => blocks.list, [blocks.list]);
3843
+ const { isEditingMode } = useEditor();
3844
+ const { allowInlineEditing, previewAs } = editorRenderMode(isEditingMode);
3845
+ const activePreviewField = useEditorUiStore((state) => state.activePreviewField ?? null);
3846
+ const previewAuthoring = useMemo(() => {
3847
+ if (!allowInlineEditing || activePreviewField?.kind !== "block") return void 0;
3848
+ return { activeField: {
3849
+ kind: "block-field",
3850
+ blockId: String(activePreviewField.blockId),
3851
+ fieldPath: activePreviewField.fieldPath
3852
+ } };
3853
+ }, [activePreviewField, allowInlineEditing]);
3854
+ const isEntryTemplatePage = Boolean(pageRendererProps.dataContext?.contentEntry);
3855
+ const cacheRef = useRef(/* @__PURE__ */ new Map());
3856
+ const renderStateVersion = useEditorUiStore((state) => {
3857
+ const snapshots = state.drafts.inspect();
3858
+ const linkedEntries = state.linkedEntries.inspect();
3859
+ return [
3860
+ snapshots.map((s) => `${s.id}:${s.version}`).join("|"),
3861
+ linkedEntries.map((entry) => `${entry.meta.entryId}:${entry.version}`).join("|"),
3862
+ `generated-icons:${state.generatedIconAssets?.revision ?? 0}`,
3863
+ linkedSaveHandoversVersion(state.linkedSaveHandovers),
3864
+ `block-versions:${state.blockVersions.revision}`
3865
+ ].join("|");
3866
+ });
3867
+ const remoteDrafts = useEditorUiStore((state) => state.remoteDrafts);
3868
+ const contentSnapshot = useEditorUiStore((state) => state.content.getSnapshot());
3869
+ const renderSource = useEditorUiStore((state) => renderSourceFor(state.editability));
3870
+ const linkedEntryOverlays = useMemo(() => linkedEntryRenderOverlaysFromStore(uiStore), [
3871
+ uiStore,
3872
+ renderStateVersion,
3873
+ remoteDrafts,
3874
+ renderSource
3875
+ ]);
3876
+ const entryDataContext = useMemo(() => withRenderedContentEntry(pageRendererProps.dataContext, resolveRenderedValues(renderSource, contentSnapshot, remoteDraftValues(remoteDrafts, { kind: "content" }))), [
3877
+ contentSnapshot,
3878
+ pageRendererProps.dataContext,
3879
+ remoteDrafts,
3880
+ renderSource
3881
+ ]);
3882
+ const linkedEntryDataContext = useMemo(() => applyLinkedEntryRenderOverlayToDataContext(entryDataContext, linkedEntryOverlays), [linkedEntryOverlays, entryDataContext]);
3883
+ const previewTheme = pageRendererProps.rendering?.kind === "overrides-only" ? null : pageRendererProps.theme;
3884
+ const runtimePreviewSource = useMemo(() => resolveRuntimePreviewSourceForTheme(pageDesignState, previewTheme), [pageDesignState, previewTheme]);
3885
+ const runtimeProjection = useMemo(() => pageDesignRuntimeProjectionFromSource(runtimePreviewSource), [runtimePreviewSource]);
3886
+ const renderProjections = useMemo(() => runtimeProjection ? [runtimeProjection] : [], [runtimeProjection]);
3887
+ const dateContext = usePreviewDateContext(pageRendererProps.dataContext);
3888
+ const mergedPage = useMemo(() => {
3889
+ return composePageFromBlocks({
3890
+ page: pageRendererProps.page,
3891
+ dateContext,
3892
+ blockItems,
3893
+ uiStore,
3894
+ projections: renderProjections
3895
+ }, cacheRef);
3896
+ }, [
3897
+ blockItems,
3898
+ dateContext,
3899
+ pageRendererProps.page,
3900
+ renderProjections,
3901
+ uiStore,
3902
+ renderStateVersion,
3903
+ remoteDrafts,
3904
+ contentSnapshot,
3905
+ renderSource
3906
+ ]);
3907
+ const renderPage = useMemo(() => projectAuthoringLocationMaps(mergedPage ?? {
3908
+ name: "",
3909
+ path: "",
3910
+ purpose: "",
3911
+ blocks: []
3912
+ }, pageRendererProps.page, linkedEntryDataContext?.siteCountry), [
3913
+ mergedPage,
3914
+ pageRendererProps.page,
3915
+ linkedEntryDataContext?.siteCountry
3916
+ ]);
3917
+ const runtimeJoins = editorRuntimeJoins(runtimeProjection, pageRendererProps.runtimeJoins);
3918
+ const renderedBlockById = useMemo(() => {
3919
+ return new Map(renderPage.blocks.filter((block) => Boolean(block.id)).map((block) => [block.id, block]));
3920
+ }, [renderPage.blocks]);
3921
+ const renderJoinWithControl = useCallback((input) => {
3922
+ const previousBlock = renderedBlockById.get(input.previousBlockId);
3923
+ const nextBlock = renderedBlockById.get(input.nextBlockId);
3924
+ const control = !isEntryTemplatePage && previousBlock && nextBlock ? /* @__PURE__ */ jsx(ObservedJoin, {
3925
+ previousBlockId: input.previousBlockId,
3926
+ nextBlockId: input.nextBlockId,
3927
+ outcome: input.join?.outcome ?? null
3928
+ }) : null;
3929
+ const extra = pageRendererProps.renderJoin?.(input) ?? null;
3930
+ if (!control && !extra) return null;
3931
+ return /* @__PURE__ */ jsxs("div", {
3932
+ className: "relative",
3933
+ "data-preview-boundary-wrapper": "",
3934
+ "data-boundary-previous-block-id": input.previousBlockId,
3935
+ "data-boundary-next-block-id": input.nextBlockId,
3936
+ children: [extra, control]
3937
+ });
3938
+ }, [
3939
+ isEntryTemplatePage,
3940
+ pageRendererProps.renderJoin,
3941
+ renderedBlockById
3942
+ ]);
3943
+ const bookingOfferingPresets = pageRendererProps.dataContext?.bookingOfferingPresets;
3944
+ const wrapBlockWithProvider = useCallback((blockId, rendered, { block, content }) => {
3945
+ return /* @__PURE__ */ jsx(EditableBlockProvider, {
3946
+ blockId,
3947
+ children: /* @__PURE__ */ jsxs(Fragment$1, { children: [rendered, /* @__PURE__ */ jsx(Fragment$1, { children: !isEntryTemplatePage ? /* @__PURE__ */ jsx(BlockToolbar, {
3948
+ blockId,
3949
+ blockKind: block.kind,
3950
+ content,
3951
+ bookingOfferingPresets: bookingOfferingPresets ?? [],
3952
+ theme: previewTheme
3953
+ }) : null })] })
3954
+ });
3955
+ }, [
3956
+ bookingOfferingPresets,
3957
+ isEntryTemplatePage,
3958
+ previewTheme
3959
+ ]);
3960
+ const liveResolvedData = usePreviewBlockResolvedData({
3961
+ page: renderPage,
3962
+ dataContext: linkedEntryDataContext,
3963
+ apiClient: blockDataApiClient,
3964
+ serverDataContext: pageRendererProps.dataContext
3965
+ });
3966
+ useLinkedSaveHandoverRetention(uiStore, entryDataContext, liveResolvedData.resolvedData);
3967
+ const generatedIconAssetOverlay = useMemo(() => generatedIconAssetsByBlock(uiStore, renderPage.blocks), [
3968
+ renderPage.blocks,
3969
+ renderStateVersion,
3970
+ uiStore
3971
+ ]);
3972
+ const dataContext = useMemo(() => mergeGeneratedIconAssetsIntoDataContext(applyLinkedEntryRenderOverlayToDataContext(mergeLiveLoaderContext(linkedEntryDataContext, liveResolvedData), linkedEntryOverlays), generatedIconAssetOverlay), [
3973
+ generatedIconAssetOverlay,
3974
+ linkedEntryDataContext,
3975
+ liveResolvedData,
3976
+ linkedEntryOverlays
3977
+ ]);
3978
+ const readinessLoaderInput = useMemo(() => ({
3979
+ prefetched: dataContext?.prefetchedBlockData,
3980
+ previewStage: dataContext?.previewStage,
3981
+ interactionContext: dataContext?.interactionContext,
3982
+ mailingList: dataContext?.mailingList,
3983
+ template: dataContext?.template ?? pageTemplateFromEntry(dataContext?.contentEntry)
3984
+ }), [dataContext]);
3985
+ return /* @__PURE__ */ jsx(EditorPageRenderer, {
3986
+ ...pageRendererProps,
3987
+ page: renderPage,
3988
+ wrapPage: (plan, rendered) => /* @__PURE__ */ jsx(PreviewRenderPlanProjection, {
3989
+ plan,
3990
+ loaderInput: readinessLoaderInput,
3991
+ children: rendered
3992
+ }),
3993
+ runtimeJoins,
3994
+ registry: allowInlineEditing ? editorRegistry : pageRendererProps.registry ?? clientComponentRegistry,
3995
+ wrapBlock: allowInlineEditing ? wrapBlockWithProvider : pageRendererProps.wrapBlock,
3996
+ renderJoin: allowInlineEditing ? renderJoinWithControl : pageRendererProps.renderJoin,
3997
+ dataContext,
3998
+ previewAuthoring,
3999
+ previewAs
4000
+ });
4001
+ }
4002
+ /** Presentation follows edit mode; visitor presentation still renders the draft. */
4003
+ function editorRenderMode(isEditingMode) {
4004
+ return {
4005
+ allowInlineEditing: isEditingMode,
4006
+ previewAs: isEditingMode ? "editor" : "visitor"
4007
+ };
4008
+ }
4009
+ const emptyRuntimeJoins = [];
4010
+ /**
4011
+ * The editor's joins: its live projection wins, then whatever the caller sent.
4012
+ */
4013
+ function editorRuntimeJoins(projection, fallback) {
4014
+ return projection?.joins ?? fallback ?? emptyRuntimeJoins;
4015
+ }
4016
+ function mergeLiveLoaderContext(context, live) {
4017
+ const merged = mergeResolvedDataContext(context, live.resolvedData);
4018
+ return merged && live.loaderFailures ? {
4019
+ ...merged,
4020
+ loaderFailures: live.loaderFailures,
4021
+ prefetchedBlockData: live.prefetchedBlockData,
4022
+ loaderSnapshot: live.loaderSnapshot
4023
+ } : merged;
4024
+ }
4025
+ function mergeGeneratedIconAssetsIntoDataContext(dataContext, byBlock) {
4026
+ if (!dataContext || Object.keys(byBlock).length === 0) return dataContext;
4027
+ return {
4028
+ ...dataContext,
4029
+ resolvedData: mergeGeneratedIconAssetsIntoResolvedData(dataContext.resolvedData ?? {}, byBlock)
4030
+ };
4031
+ }
4032
+ /** Each rendered block's generated icon assets, for blocks that have any. */
4033
+ function generatedIconAssetsByBlock(uiStore, blocks) {
4034
+ const assets = uiStore.getState().generatedIconAssets;
4035
+ return Object.fromEntries(blocks.flatMap((block) => {
4036
+ const forBlock = block.id ? assets?.getForBlock(unsafeAsEditorBlockId(block.id)) ?? [] : [];
4037
+ return block.id && forBlock.length > 0 ? [[block.id, forBlock]] : [];
4038
+ }));
4039
+ }
4040
+ function usePreviewDateContext(dataContext) {
4041
+ const supplied = dataContext?.dateContext;
4042
+ const zone = dataContext?.bookingTimeZone;
4043
+ return useMemo(() => supplied ?? resolveDateRuntimeContext(zone), [supplied, zone]);
4044
+ }
4045
+ //#endregion
4046
+ //#region ../preview-next/src/client/sdk/contentStorage.ts
4047
+ /**
4048
+ * Reads the current content storage endpoint from the legacy content wire
4049
+ * shape. Keep the provider-specific field in this adapter so preview
4050
+ * rendering only depends on the neutral storage URL it receives.
4051
+ */
4052
+ function resolveContentStorageUrl(content) {
4053
+ return typeof content.supabaseUrl === "string" && content.supabaseUrl.length > 0 ? content.supabaseUrl : void 0;
4054
+ }
4055
+ //#endregion
4056
+ //#region ../preview-next/src/client/sdk/SdkPreviewModeRuntime.tsx
4057
+ function SdkEditablePageRenderer(props) {
4058
+ const previewToken = usePreviewToken();
4059
+ return /* @__PURE__ */ jsx(EditablePageRenderer, {
4060
+ ...props,
4061
+ dataContext: {
4062
+ ...props.dataContext,
4063
+ previewToken
4064
+ }
4065
+ });
4066
+ }
4067
+ function isSdkCustomBlockArray(value) {
4068
+ return Array.isArray(value);
4069
+ }
4070
+ function toPreviewBlock(block, index) {
4071
+ return {
4072
+ id: block.id,
4073
+ kind: block.kind,
4074
+ purpose: block.purpose,
4075
+ orderIndex: index,
4076
+ content: block.content ?? null,
4077
+ draftContent: block.draftContent ?? null,
4078
+ bindings: block.bindings ?? null,
4079
+ versions: readEditorBlockVersionsFromPlacement(block.draftContentId, block.publishedPlacement)
4080
+ };
4081
+ }
4082
+ function getSdkConfigForPreview(value) {
4083
+ if (!value || typeof value !== "object") return null;
4084
+ if (!("customBlocks" in value)) return { layout: { footerMode: resolveSdkFooterMode(value) } };
4085
+ const customBlocks = value.customBlocks;
4086
+ return {
4087
+ layout: { footerMode: resolveSdkFooterMode(value) },
4088
+ ...isSdkCustomBlockArray(customBlocks) ? { customBlocks } : {}
4089
+ };
4090
+ }
4091
+ function SdkPreviewModeRuntime(props) {
4092
+ const { apiBaseUrl, siteId, siteSlug, previewSession, previewToken } = props;
4093
+ const model = resolveSdkPreviewRuntimeModel(props);
4094
+ const { content, customBlocks, dataContext, initialBlocks, page, pageMetadata, resolvedDashboardBaseUrl, routeMap, sdkConfig, surfaceId, typedBlockOverrides } = model;
4095
+ const siteFontStorageUrl = resolveContentStorageUrl(content);
4096
+ const sdkConfigForEditor = useMemo(() => {
4097
+ const blocks = customBlocks ?? sdkConfig?.customBlocks ?? void 0;
4098
+ return {
4099
+ layout: sdkConfig?.layout,
4100
+ ...blocks?.length ? { customBlocks: blocks } : {}
4101
+ };
4102
+ }, [sdkConfig, customBlocks]);
4103
+ const blockApiConfig = useMemo(() => ({
4104
+ baseUrl: apiBaseUrl,
4105
+ auth: {
4106
+ type: "bearer",
4107
+ token: previewToken
4108
+ },
4109
+ siteId,
4110
+ isPreview: true
4111
+ }), [
4112
+ apiBaseUrl,
4113
+ previewToken,
4114
+ siteId
4115
+ ]);
4116
+ const editablePage = model.rendering.kind === "overrides-only" ? /* @__PURE__ */ jsx(SdkEditablePageRenderer, {
4117
+ rendering: { kind: "overrides-only" },
4118
+ page,
4119
+ dataContext,
4120
+ routeMap,
4121
+ blockOverrides: typedBlockOverrides ?? {},
4122
+ sdkConfig: sdkConfig ?? void 0,
4123
+ customBlocks: customBlocks ?? void 0
4124
+ }) : /* @__PURE__ */ jsx(SdkEditablePageRenderer, {
4125
+ theme: requireSdkPreviewTheme(model.theme),
4126
+ page,
4127
+ dataContext,
4128
+ routeMap,
4129
+ blockOverrides: typedBlockOverrides ?? void 0,
4130
+ sdkConfig: sdkConfig ?? void 0,
4131
+ customBlocks: customBlocks ?? void 0
4132
+ });
4133
+ const shellProps = {
4134
+ businessTimeZone: content.bookingTimeZone,
4135
+ apiBaseUrl,
4136
+ blockApiConfig,
4137
+ siteId,
4138
+ siteSlug,
4139
+ editableId: content.pageId,
4140
+ previewSession,
4141
+ previewToken,
4142
+ dashboardBaseUrl: resolvedDashboardBaseUrl,
4143
+ surfaceId,
4144
+ pageId: content.pageId,
4145
+ routeId: content.routeId,
4146
+ initialStatus: "draft",
4147
+ initialBlocks,
4148
+ pageMetadata,
4149
+ isSiteLaunched: true,
4150
+ maintenanceModeEnabled: false,
4151
+ entrySubrouteContext: null,
4152
+ sdkConfig: sdkConfigForEditor,
4153
+ mediaAssets: content.mediaAssets,
4154
+ supabaseUrl: content.supabaseUrl,
4155
+ siteFontStorageUrl,
4156
+ designEditorEligibility: { kind: "sdk-page" },
4157
+ renderingOverride: { kind: "none" },
4158
+ pageAdaptationFacts: {
4159
+ visibleBanner: false,
4160
+ opening: null
4161
+ },
4162
+ hideSiteStyleConfigurator: true
4163
+ };
4164
+ if (model.rendering.kind === "overrides-only") return /* @__PURE__ */ jsx(PreviewShell, {
4165
+ ...shellProps,
4166
+ rendering: model.rendering,
4167
+ children: editablePage
4168
+ });
4169
+ return /* @__PURE__ */ jsx(PreviewShell, {
4170
+ ...shellProps,
4171
+ themeInput: {
4172
+ kind: "no-journal",
4173
+ theme: requireSdkPreviewTheme(model.theme)
4174
+ },
4175
+ themeRuntime: model.rendering.themeRuntime,
4176
+ children: editablePage
4177
+ });
4178
+ }
4179
+ function requireSdkPreviewTheme(theme) {
4180
+ if (!theme) throw new Error("Themed SDK preview requires a canonical theme.");
4181
+ return theme;
4182
+ }
4183
+ function sdkPreviewDataContext(props, routeMap) {
4184
+ const { content, siteId, apiBaseUrl } = props;
4185
+ return {
4186
+ ...sdkPreviewDateRuntime(content),
4187
+ siteId,
4188
+ apiBaseUrl,
4189
+ portalToken: null,
4190
+ resolvedData: content.resolvedData,
4191
+ routes: routeMap,
4192
+ pagesByIdentifier: content.pagesByIdentifier ?? void 0,
4193
+ entriesByIdentifier: content.entriesByIdentifier ?? void 0,
4194
+ occurrenceContext: null,
4195
+ entrySubrouteContext: null,
4196
+ contentEntry: null,
4197
+ editableRouteMetadataFieldIds: null,
4198
+ previewStage: "preview",
4199
+ supabaseUrl: content.supabaseUrl,
4200
+ mediaAssets: content.mediaAssets
4201
+ };
4202
+ }
4203
+ function resolveSdkPreviewRuntimeModel(props) {
4204
+ const { apiBaseUrl, content } = props;
4205
+ const rendering = props.rendering ?? {
4206
+ kind: "themed",
4207
+ themeRuntime: props.themeRuntime ?? defaultPreviewThemeRuntime
4208
+ };
4209
+ const page = content.page;
4210
+ const routeMap = content.routeMap ?? void 0;
4211
+ const sdkConfig = getSdkConfigForPreview(content.sdkConfig);
4212
+ const customBlocks = isSdkCustomBlockArray(content.customBlocks) ? content.customBlocks : null;
4213
+ const initialBlocks = (page.blocks ?? []).map(toPreviewBlock);
4214
+ const commonModel = {
4215
+ content,
4216
+ customBlocks,
4217
+ dataContext: sdkPreviewDataContext(props, routeMap),
4218
+ initialBlocks,
4219
+ page,
4220
+ pageMetadata: content.pageMetadata,
4221
+ resolvedDashboardBaseUrl: props.dashboardBaseUrl ?? deriveDashboardBaseUrlFromApiBaseUrl(apiBaseUrl),
4222
+ routeMap,
4223
+ sdkConfig,
4224
+ surfaceId: props.surfaceId ?? "core",
4225
+ typedBlockOverrides: props.blockOverrides ?? null
4226
+ };
4227
+ if (rendering.kind === "overrides-only") return {
4228
+ ...commonModel,
4229
+ rendering,
4230
+ theme: null
4231
+ };
4232
+ return {
4233
+ ...commonModel,
4234
+ rendering,
4235
+ theme: parseSdkPreviewTheme(content.theme)
4236
+ };
4237
+ }
4238
+ function parseSdkPreviewTheme(value) {
4239
+ const parsedTheme = parseThemeForPersistence(value);
4240
+ if (!parsedTheme.ok) throw new Error(`Preview theme does not satisfy the canonical runtime contract: ${parsedTheme.error.kind}`);
4241
+ return parsedTheme.value;
4242
+ }
4243
+ function deriveDashboardBaseUrlFromApiBaseUrl(apiBaseUrl) {
4244
+ try {
4245
+ return new URL(apiBaseUrl).origin;
4246
+ } catch {
4247
+ return null;
4248
+ }
4249
+ }
4250
+ function sdkPreviewDateRuntime(content) {
4251
+ return {
4252
+ now: readRuntimeNow(content.now),
4253
+ bookingTimeZone: content.bookingTimeZone,
4254
+ dateContext: resolveDateRuntimeContext(content.bookingTimeZone)
4255
+ };
4256
+ }
4257
+ //#endregion
4258
+ export { SdkPreviewModeRuntime };