@riverbankcms/sdk 0.181.0 → 0.183.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 (226) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +49 -3
  3. package/dist/_dts/{BlocksIslandsHydrator-CVCasDPz.d.ts → BlocksIslandsHydrator-X1_G96iN.d.ts} +1 -1
  4. package/dist/_dts/{Page-Dtj2Ui3S.d.ts → Page-CEqZJZEE.d.ts} +7 -7
  5. package/dist/_dts/{SdkPreviewMode-D1f_60WW.d.ts → SdkPreviewMode-DQejfbXL.d.ts} +2 -2
  6. package/dist/_dts/{client-Chr9pNVW.d.ts → client-B_B_amKD.d.ts} +2 -3
  7. package/dist/_dts/{content-types-kjccgopX.d.ts → content-types-Dhx5Ocvx.d.ts} +9 -16
  8. package/dist/_dts/{contracts-BodaiS00.d.ts → contracts-FeOnfoa1.d.ts} +3 -3
  9. package/dist/_dts/{generatePageMetadata-BS6kaJFp.d.ts → generatePageMetadata-m70J6tit.d.ts} +2 -2
  10. package/dist/_dts/{index-Brl6_I2j.d.ts → index-BOpUh8kO.d.ts} +1 -1
  11. package/dist/_dts/{index-CJkefwYh.d.ts → index-Bizdaxji.d.ts} +2 -2
  12. package/dist/_dts/{index-Diqt0PvG.d.ts → index-BxCmCit0.d.ts} +1 -1
  13. package/dist/_dts/{index-DG0OvBs0.d.ts → index-CjAkEWAp.d.ts} +4 -4
  14. package/dist/_dts/{index-D1WpKwQe.d.ts → index-iuFrbIjt.d.ts} +1 -1
  15. package/dist/_dts/{index-Dy50xUMK.d.ts → index-liuhlOX7.d.ts} +2 -2
  16. package/dist/_dts/{loadContent-BgxshKrA.d.ts → loadContent-D4wrTIIw.d.ts} +7 -7
  17. package/dist/_dts/{request-CA0izds5.d.ts → request-Gn0O1blj.d.ts} +25042 -23761
  18. package/dist/_dts/{resolveBlockData-ChQmwEd3.d.ts → resolveBlockData-D5duwuqS.d.ts} +5 -5
  19. package/dist/_dts/{resolvePageContent-BvGyvblj.d.ts → resolvePageContent-xzJ3c9Na.d.ts} +1 -1
  20. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  21. package/dist/_dts/sdk/src/client/types.d.ts +2 -2
  22. package/dist/_dts/sdk/src/client.d.ts +7 -7
  23. package/dist/_dts/sdk/src/config/index.d.ts +7 -7
  24. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  25. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  26. package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +2 -2
  27. package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
  28. package/dist/_dts/sdk/src/data/types.d.ts +2 -2
  29. package/dist/_dts/sdk/src/gifting/client.d.ts +1 -1
  30. package/dist/_dts/sdk/src/index.d.ts +8 -8
  31. package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
  32. package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
  33. package/dist/_dts/sdk/src/navigation/index.d.ts +3 -3
  34. package/dist/_dts/sdk/src/next/index.d.ts +7 -7
  35. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  36. package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
  37. package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
  38. package/dist/_dts/sdk/src/portal/index.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 +1 -1
  45. package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +1 -1
  46. package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +4 -4
  47. package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
  48. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  49. package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
  50. package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
  51. package/dist/_dts/sdk/src/routing/index.d.ts +6 -6
  52. package/dist/_dts/sdk/src/server.d.ts +5 -5
  53. package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
  54. package/dist/_dts/sdk/src/theme/index.d.ts +91 -2
  55. package/dist/_dts/{serviceBookingOutline-BgFbJQhU.d.ts → serviceBookingOutline-B1gyJon_.d.ts} +7 -7
  56. package/dist/_dts/{types-CgS3xLk8.d.ts → types-BoITy0rA.d.ts} +41 -4
  57. package/dist/_dts/{types-CQrsP1x_.d.ts → types-DBNuMtSk.d.ts} +16 -5
  58. package/dist/_dts/{types-R65DKjPn.d.ts → types-DHMcuoeQ.d.ts} +7 -7
  59. package/dist/_dts/{validation-6LTIbuBA.d.ts → validation-BIPO-XlE.d.ts} +4 -4
  60. package/dist/client/{BlocksIslandsHydrator-DqZPz6oW.mjs → BlocksIslandsHydrator-Ct8slgRk.mjs} +22 -18
  61. package/dist/client/{BookingMailingListNote-uWfR2kaG.mjs → BookingMailingListNote-qqTxGGS4.mjs} +7 -7
  62. package/dist/client/{BookingQuestionFields-CyNIKw6k.mjs → BookingQuestionFields-DCh9MUIF.mjs} +2 -2
  63. package/dist/client/{CalendarAction-D_Glwvz2.mjs → CalendarAction-RcdaStG7.mjs} +1 -1
  64. package/dist/client/{CalendarNavigationChevron-BGCX3zwG.mjs → CalendarNavigationChevron-D7Wt-Oaa.mjs} +27 -10
  65. package/dist/client/{CheckboxChoice-C8i4NraK.mjs → CheckboxChoice-BdGxZWeg.mjs} +1 -1
  66. package/dist/client/{DemoBookingPortalAccess-DFLPyuqe.mjs → DemoBookingPortalAccess-HFVkoOac.mjs} +5 -5
  67. package/dist/client/{EventCalendar.client-zDL4-t-B.mjs → EventCalendar.client-BtkJW8bA.mjs} +10 -10
  68. package/dist/client/{EventCombined.client-uciDKLID.mjs → EventCombined.client-DxaGjFFS.mjs} +9 -9
  69. package/dist/client/{EventEmbeddedCheckoutStep-BGkbUhuw.mjs → EventEmbeddedCheckoutStep-B2c5dR49.mjs} +1 -1
  70. package/dist/client/{EventItem-CwzrjcRw.mjs → EventItem-Fr2qi2C2.mjs} +33 -186
  71. package/dist/client/{EventListWeekNavigation-ChvcnPma.mjs → EventListWeekNavigation-BRMaq0ky.mjs} +1 -1
  72. package/dist/client/{EventListing.client-DA57Qoyx.mjs → EventListing.client-BhGxfbjt.mjs} +3 -3
  73. package/dist/client/{EventListing.view-DZ0qMFF4.mjs → EventListing.view-COuEJzbO.mjs} +8 -8
  74. package/dist/client/{EventRegistrationPayment-DSqCJL8E.mjs → EventRegistrationPayment-BTLYhVxD.mjs} +41 -195
  75. package/dist/client/{Page-C7mygH_f.mjs → Page-CgbQZP5g.mjs} +2947 -1018
  76. package/dist/client/{ProtectedSubmitButton-BNnKuir8.mjs → ProtectedSubmitButton-BG7my0Qf.mjs} +1 -1
  77. package/dist/client/{SiteTermsAgreementField-B4z-e4Wq.mjs → SiteTermsAgreementField-DQNkfNLA.mjs} +3 -3
  78. package/dist/client/{StepIndicator-Dn_DY4oY.mjs → StepIndicator-DvPekKeM.mjs} +1 -1
  79. package/dist/client/{StepIndicator-atfDU82W.mjs → StepIndicator-DyXoI3ob.mjs} +221 -20
  80. package/dist/client/{ThemedButton-PFOhXktM.mjs → ThemedButton-Bc9DBbVp.mjs} +42 -9
  81. package/dist/client/{accessibleSurfaces-n6kS6Hct.mjs → accessibleSurfaces-wj4Rloo5.mjs} +1214 -724
  82. package/dist/client/{accordion-CsW8U3ff.mjs → accordion-BVXfjnh-.mjs} +1 -1
  83. package/dist/client/{booking-form.client-cBWM392H.mjs → booking-form.client-DycPGtke.mjs} +191 -71
  84. package/dist/client/{bookingForm-DgySpp6C.mjs → bookingForm-DrWSUqL3.mjs} +4 -4
  85. package/dist/client/bookings.mjs +5 -5
  86. package/dist/client/{boxStyleClassNames-BpGVdLFD.mjs → boxStyleClassNames-CduDRcIk.mjs} +2 -2
  87. package/dist/client/buttonParts-CJEtVOUy.mjs +1511 -0
  88. package/dist/client/{carousel-DJoleFV3.mjs → carousel-DyCLMP8s.mjs} +2 -2
  89. package/dist/client/{carousel.client-BtLwHefX.mjs → carousel.client-DffP_Nv0.mjs} +1 -1
  90. package/dist/client/{cart-EO5o6uPH.mjs → cart-BuEp_cj4.mjs} +3 -3
  91. package/dist/client/{cart.client-D_gPw45z.mjs → cart.client-CAO39uDG.mjs} +1 -1
  92. package/dist/client/{checkout-NVfZW0kR.mjs → checkout-BoxzT64s.mjs} +3 -3
  93. package/dist/client/{checkout.client-DD3JuqOy.mjs → checkout.client-IGUy7XOx.mjs} +1 -1
  94. package/dist/client/{checkoutUrls-z2gXvlGw.mjs → checkoutUrls-D0UsiFmm.mjs} +1 -1
  95. package/dist/client/client.mjs +466 -94
  96. package/dist/client/{constants-CoOkvw__.mjs → constants-C_8AxMdm.mjs} +1 -1
  97. package/dist/client/{context-CRhn9qzS.mjs → context-D1L0pe__.mjs} +23 -5
  98. package/dist/client/{dateFormatting-BnWB4L1s.mjs → dateFormatting-HvfmS_cH.mjs} +1 -1
  99. package/dist/client/{demoPortalMagicLink-CWDGSTBu.mjs → demoPortalMagicLink-BunFTnIq.mjs} +1 -1
  100. package/dist/client/{enhanceHeaderSection-tdP_-Z9o.mjs → enhanceHeaderSection-CtLAG651.mjs} +4 -4
  101. package/dist/client/{event-registration.client-D7YYKySQ.mjs → event-registration.client-DiSxkBUP.mjs} +15 -15
  102. package/dist/client/{eventCalendar-CsAfu5d0.mjs → eventCalendar-DUnhwZ1o.mjs} +4 -4
  103. package/dist/client/{eventCombined-VXJB5CoS.mjs → eventCombined-BvBQo0nF.mjs} +4 -4
  104. package/dist/client/{eventListing-B3KIZNfY.mjs → eventListing-aTLifOX7.mjs} +4 -4
  105. package/dist/client/{eventRegistration-BP-dEk1c.mjs → eventRegistration-DFd7pr09.mjs} +4 -4
  106. package/dist/client/{form-DM8Zbxbv.mjs → form-Dikmc2AO.mjs} +3 -3
  107. package/dist/client/{form.client-e2z_Tlgk.mjs → form.client-zHaQK5I9.mjs} +5 -5
  108. package/dist/client/{form.parts-Ctljy1a3.mjs → form.parts-BLl9n8TH.mjs} +3 -3
  109. package/dist/client/gifting/client.mjs +16 -9
  110. package/dist/client/{gifting-DWIsqQru.mjs → gifting-CufPM38H.mjs} +4 -4
  111. package/dist/client/{gifting.client-QsSWF0uA.mjs → gifting.client--N1GaSY8.mjs} +155 -84
  112. package/dist/client/gifting.interactive-D9MK4HkV.mjs +157 -0
  113. package/dist/client/gifting.parts-CRtiRzo-.mjs +119 -0
  114. package/dist/client/{headerSection-DAkRkwb-.mjs → headerSection-BIaBpmk3.mjs} +2 -2
  115. package/dist/client/{noop-Dl4mZ-rr.mjs → islands-DJDLGQEm.mjs} +16008 -8676
  116. package/dist/client/{newsletter-form.client-WYja9-WN.mjs → newsletter-form.client-wg_JHTxm.mjs} +6 -6
  117. package/dist/client/{newsletter-form.interactive-RuM86VAv.mjs → newsletter-form.interactive-hzpkW9NQ.mjs} +384 -326
  118. package/dist/client/{newsletter-form.parts-2petDnWv.mjs → newsletter-form.parts-CgzpSv9p.mjs} +2 -2
  119. package/dist/client/{newsletterForm-BUbXdA_e.mjs → newsletterForm-CvxLiEBT.mjs} +3 -3
  120. package/dist/client/portal/client.mjs +291 -101
  121. package/dist/client/{portalOrders-COGn4BKG.mjs → portalOrders-tCxS04g0.mjs} +3 -2
  122. package/dist/client/{portalRoutes-D72yvtDh.mjs → portalRoutes-DTHlWg_F.mjs} +33 -7
  123. package/dist/client/{product-detail.client-pOAryevt.mjs → product-detail.client-22Q7zgjN.mjs} +1 -1
  124. package/dist/client/{product-list.client-CcUpUiud.mjs → product-list.client-DFWYvK8z.mjs} +1 -1
  125. package/dist/client/{productDetail-BZJCfqat.mjs → productDetail-DhZAwo60.mjs} +3 -3
  126. package/dist/client/{productList-CiRs3mNb.mjs → productList-BiVpbZK2.mjs} +3 -3
  127. package/dist/client/{propsDecoder--uHW4tFM.mjs → propsDecoder-DFYqKnLy.mjs} +4 -2
  128. package/dist/client/{registry.server-CDNNd8wC.mjs → registry.server-C3OBRg7x.mjs} +2305 -873
  129. package/dist/client/rendering/client.mjs +29 -26
  130. package/dist/client/rendering/islands.mjs +1 -1
  131. package/dist/client/rendering.mjs +5 -5
  132. package/dist/client/{richText-coerce-CQGE_wHV.mjs → richText-coerce-ms477Z08.mjs} +2 -2
  133. package/dist/client/{routeIslandApiConfig-BtCg87-N.mjs → routeIslandApiConfig-B6nQeqvH.mjs} +1 -1
  134. package/dist/client/{runtimeResponse-Ds9cmBUf.mjs → runtimeResponse-BYqsV1Kb.mjs} +1 -1
  135. package/dist/client/runtimeResponse-CUX_lldL.mjs +3 -0
  136. package/dist/client/{shop-commerce-D8evQnMT.mjs → shop-commerce-DVsIcPaI.mjs} +16 -15
  137. package/dist/client/{shop-commerce-store-C9PcsSTj.mjs → shop-commerce-store-7mO6KY7_.mjs} +1 -1
  138. package/dist/client/{shop-discount-apply.state-D5CtGfJI.mjs → shop-discount-apply.state-L1Vge8tG.mjs} +2 -2
  139. package/dist/client/{shop-Rx_gEMK8.mjs → shop-xt4dQ3HH.mjs} +3 -3
  140. package/dist/client/{shop.client-D4lzQ9oY.mjs → shop.client-DNJfD3VQ.mjs} +28 -17
  141. package/dist/client/{shopShared-BVbq7Nm-.mjs → shopShared-DS8t6749.mjs} +2 -2
  142. package/dist/client/spam-protection.mjs +1 -1
  143. package/dist/client/{src-ZSqRK3dD.mjs → src-Do_s2lqH.mjs} +16 -19
  144. package/dist/client/{timetableModel-BQJrSK0K.mjs → timetableModel-Dy3nNfTG.mjs} +13 -17
  145. package/dist/client/{useAvailableSlots-Dm3lKJKR.mjs → useAvailableSlots-DcjtDpUu.mjs} +2 -2
  146. package/dist/client/{useDiscountCodeUi-klgfGn7f.mjs → useDiscountCodeUi-DvdFFWOT.mjs} +1 -1
  147. package/dist/client/{useEventPagination-Jnjt7_ly.mjs → useEventPagination-Cq-7sU5_.mjs} +8 -8
  148. package/dist/client/{view-CC_yQLSA.mjs → view-4gnPcpWJ.mjs} +24 -9
  149. package/dist/client/{wizardSteps-BliJOzEX.mjs → wizardSteps-DDvL3iza.mjs} +375 -186
  150. package/dist/preview-next/client/{EventEmbeddedCheckoutStep-aRJjq4x8.mjs → EventEmbeddedCheckoutStep-CLqSRUpt.mjs} +1 -1
  151. package/dist/preview-next/client/{LocationPickerEnvironment-BW3dRFIv.mjs → LocationPickerEnvironment-CIdAg-Tm.mjs} +1 -1
  152. package/dist/preview-next/client/{MapLibreEditMap-Db9BHyXh.mjs → MapLibreEditMap-Bm85jX35.mjs} +2 -2
  153. package/dist/preview-next/client/{PageSectionToolbar-BhL0uADo.mjs → PageSectionToolbar-D8srnz9R.mjs} +445 -18
  154. package/dist/preview-next/client/{PreviewEditorSidebar-Ct8eIm0i.mjs → PreviewEditorSidebar-DVpk5cqp.mjs} +3871 -1947
  155. package/dist/preview-next/client/{PreviewEditorUI-BS32G4V9.mjs → PreviewEditorUI-XoTtHSFH.mjs} +11 -36
  156. package/dist/preview-next/client/{PreviewShell-RL0WfZXD.mjs → PreviewShell-VQHsRg2u.mjs} +40 -35
  157. package/dist/preview-next/client/{SdkPreviewModeRuntime-MK_gHeGy.mjs → SdkPreviewModeRuntime-CLdF9f6o.mjs} +51 -20
  158. package/dist/preview-next/client/{ThemedButton-CVYz7h68.mjs → ThemedButton-ORNN4x-3.mjs} +782 -16
  159. package/dist/preview-next/client/{lucide-react-00FF_oar.mjs → lucide-react-eAi3tDAr.mjs} +11 -1
  160. package/dist/preview-next/client/{previewAssistantSlot-CQyS8pcq.mjs → previewAssistantSlot-CqH91EwA.mjs} +20687 -8562
  161. package/dist/preview-next/client/{previewChromeRoot-BSxp3Mfu.mjs → previewChromeRoot-B3ySEu6p.mjs} +3 -90
  162. package/dist/preview-next/client/runtime.mjs +3 -3
  163. package/dist/preview-next/client/{sdk-runtime-DKnTzy74.mjs → sdk-runtime-CdpSupcr.mjs} +2 -2
  164. package/dist/preview-next/client/{siteStyleAccess-BlmbvbLN.mjs → siteStyleAccess-C6eOP6QW.mjs} +35 -6
  165. package/dist/preview-next/client/{useAutosaveStatus-D-7GwZOQ.mjs → useAutosaveStatus-BhPg4e-r.mjs} +49 -3
  166. package/dist/preview-next/client/{useOpenBlockForSetup-BNZtGM5g.mjs → useOpenBlockForSetup-BaWUF9D7.mjs} +2007 -448
  167. package/dist/preview-next/container-responsive.css +320 -0
  168. package/dist/preview-next/editor-chrome.css +23 -2
  169. package/dist/preview-next/keepAlive.mjs +1 -1
  170. package/dist/preview-next/middleware.mjs +1 -1
  171. package/dist/preview-next/{route-contract-R3PcMmax.mjs → route-contract-Ch0X99vE.mjs} +183 -18
  172. package/dist/server/{Block.shared-CniF9tSu.mjs → Block.shared-B2FmczLO.mjs} +5 -5
  173. package/dist/server/{ThemeScopeCore-BQWsnGT6.mjs → ThemeScopeCore-DtAyv9qA.mjs} +51 -29
  174. package/dist/server/{accessibleSurfaces-WPzUAHp4.mjs → accessibleSurfaces-BtPqb76u.mjs} +509 -389
  175. package/dist/server/{accordions-By_0Ykks.mjs → accordions-vzdZ2Wt1.mjs} +1 -1
  176. package/dist/server/{bindings-DxojjtK3.mjs → bindings-B_9JuU66.mjs} +7 -7
  177. package/dist/server/{client-CDndhbYO.mjs → client-DC7cjiSw.mjs} +489 -93
  178. package/dist/server/config-validation.mjs +1 -1
  179. package/dist/server/config.mjs +2 -2
  180. package/dist/server/{constants-VyF5nEhL.mjs → constants-d6nPNJpe.mjs} +33 -6
  181. package/dist/server/{customCss-C9kgPHvr.mjs → customCss-rtIfEYwQ.mjs} +1 -18
  182. package/dist/server/data/resolveBlockData.mjs +1 -1
  183. package/dist/server/{resolveButtonColourStates-B0O1IM16.mjs → expandPalette-DxPrNOAB.mjs} +950 -316
  184. package/dist/server/index.mjs +3 -3
  185. package/dist/server/{loadContent-BKstMBmX.mjs → loadContent-hb27HYic.mjs} +11 -10
  186. package/dist/server/{loadPage-IgNnZaqr.mjs → loadPage-JToD8wDD.mjs} +3 -3
  187. package/dist/server/{lookMediaFrame-TFjgNG61.mjs → lookMediaFrame-CTsycLLK.mjs} +94 -39
  188. package/dist/server/manifest.mjs +2 -2
  189. package/dist/server/{navigation-quBYlSKD.mjs → navigation-B2WhGofA.mjs} +1 -1
  190. package/dist/server/navigation.mjs +1 -1
  191. package/dist/server/next.mjs +8 -8
  192. package/dist/server/{overrideResolution-CCaAPpIa.mjs → overrideResolution-vD5KTClL.mjs} +1 -1
  193. package/dist/server/page-converter.mjs +3 -3
  194. package/dist/server/{pageRenderPlan-B7iULvKe.mjs → pageRenderPlan-CdqJ1NQZ.mjs} +242 -336
  195. package/dist/server/{pageRuntimeSupport-BytMroxn.mjs → pageRuntimeSupport-CAhr4oOf.mjs} +3 -3
  196. package/dist/server/{pageShared-Dcs_XTIO.mjs → pageShared-m80Xu2pd.mjs} +1292 -877
  197. package/dist/server/{parseThemeForPersistence-Bihl4W5K.mjs → parseThemeForPersistence-CRwOZfpa.mjs} +3 -3
  198. package/dist/server/{portal-CMW_b9mG.mjs → portal-B2wCQno_.mjs} +1 -1
  199. package/dist/server/portal.mjs +2 -2
  200. package/dist/server/{prebuild-agaH-vZV.mjs → prebuild-BWIkFaXq.mjs} +1 -1
  201. package/dist/server/prebuild.mjs +1 -1
  202. package/dist/server/{prefetchBlockData-DwpRjqw4.mjs → prefetchBlockData-D1PHU-K9.mjs} +3 -3
  203. package/dist/server/{registry-DM9dHfDC.mjs → registry-KtsOsAzY.mjs} +21703 -10936
  204. package/dist/server/rendering/components/pageShared.mjs +1 -1
  205. package/dist/server/rendering/helpers/loadPage.mjs +1 -1
  206. package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
  207. package/dist/server/rendering/server.mjs +4 -4
  208. package/dist/server/rendering.mjs +9 -9
  209. package/dist/server/{resolveBlockData-CinHGf8l.mjs → resolveBlockData-sjIDJYl7.mjs} +1 -1
  210. package/dist/server/{schema-CwfxQjc4.mjs → schema-BBEqquBM.mjs} +44 -28
  211. package/dist/server/server.mjs +3 -3
  212. package/dist/server/{servicePageContent-BBBhOtdE.mjs → servicePageContent-ChEZDRwU.mjs} +38 -15
  213. package/dist/server/theme-bridge.mjs +34 -9
  214. package/dist/server/theme.mjs +2 -2
  215. package/dist/server/{three-pass-converter-DPaUPTfl.mjs → three-pass-converter-DKCIBeb1.mjs} +2 -2
  216. package/dist/server/{titleSourceSchema-NhK6azFS.mjs → titleSourceSchema-DybHErxH.mjs} +4 -4
  217. package/dist/server/{typeGuards-CTW_9AXq.mjs → typeGuards-DZOaGTEv.mjs} +126 -126
  218. package/dist/server/{types-BKaBZFjD.mjs → types-vyz09w64.mjs} +479 -8
  219. package/dist/server/{validation-DG5jX3jH.mjs → validation-Cvi-1TZZ.mjs} +13 -9
  220. package/dist/server/{version-CipbxPHL.mjs → version-B-icAIV1.mjs} +1 -1
  221. package/dist/server/{video-Cdr3wh-q.mjs → video-DBaeSawZ.mjs} +1 -1
  222. package/dist/styles/index.css +2568 -154
  223. package/package.json +1 -1
  224. package/dist/client/gifting.parts-CedLgwa_.mjs +0 -86
  225. package/dist/client/runtimeResponse-DL_ARBpa.mjs +0 -3
  226. package/dist/client/types-BEaKfam_.mjs +0 -778
@@ -1,8 +1,8 @@
1
1
  "use client";
2
- import { Bc as Arrow, Cc as usePortalContainer, Fc as Root, Fi as systemCustomizeFacetAppliesToLayoutVariant, Gc as useId$1, Gr as fieldsNotShownIn, Hc as Root2$1, I as lookTilesFor, Ic as createRovingFocusGroupScope, Ii as systemCustomizeFacetDefinitionForBlock, Io as resolveEditorArrangementLook, Jc as DismissableLayer, Jn as manifestFieldSectionOptions, Jo as getCuratedSiteStyle, Js as Root$1, Ju as syncStateOf, Kc as FocusScope, Kn as createManifestFormAdapter, Lc as Presence, Li as systemCustomizeFacetDefinitionsForBlock, M as usePreviewRenderReadiness, Mi as arrangementKnobChoices, Mo as decideSectionPhoto, Ms as augmentManifestWithStyleGroups, Nc as hideOthers, Ni as resolveArrangementKnobs, No as sectionPhotoPresence, Pc as Item, Pi as isSystemCustomizeFacetId, Qc as useControllableState, Rc as Portal$2, Ri as systemCustomizeFacetStoredValue, Tn as shouldRevealAllBlockFieldValidation, Uc as createPopperScope, Uo as lookDefinitionForId, Vc as Content, Vt as derivePromotedFieldPlan, Wo as readStoredMode, Xc as useDirection, Yc as useCallbackRef, Zc as createCollection, bc as menuItemInteractionClassName, br as mergeManifestWithSdkOptions, cl as createSlot, cr as parseCanonicalSectionBackground, dl as useComposedRefs, du as asSiteStyleId, el as createContextScope, fl as cn, gs as lookModes, i as usePreviewSidebarNavigation, ko as resolveVisiblePromotedFieldPathsForEditorBlock, ll as createSlottable, mi as eventCalendarPagingFields, ms as isThemeV2NormalEditorRawStylePath, ni as resolveFieldOwnership, nl as Primitive, o as usePreviewPageDesignEditorState, or as parseBackgroundColorToken, ps as isThemeV2NormalEditorRawStyleFieldName, qc as useFocusGuards, ri as getBlockDefinition, rl as dispatchDiscreteCustomEvent, sl as cva, ti as fieldPathsOwnedBy, tl as composeEventHandlers, ul as composeRefs, vr as createCustomBlockRegistry, wc as ReactRemoveScroll, xa as eventCalendarListGroupingDecision, xc as menuTriggerInteractionClassName, xn as useEditorUiStoreInstance, yr as mergeBlockDescriptorsWithRegistry, zc as Anchor } from "./previewAssistantSlot-CQyS8pcq.mjs";
3
- import { it as Circle, pt as Check, ut as ChevronRight } from "./lucide-react-00FF_oar.mjs";
2
+ import { $c as Anchor, A as usePreviewRenderReadiness, At as useEditorPageTemplate, Bi as systemCustomizeFacetDefinitionsForBlock, Bo as decideSectionPhoto, Cl as createSlottable, El as cn, Es as isThemeV2NormalEditorRawStyleFieldName, Fc as menuTriggerInteractionClassName, Fi as resolveArrangementKnobs, Fl as matchSummaryPart, Gi as fieldsNotShownIn, Gl as readConditionFact, Go as sectionPhotoPresence, Ho as sectionPhotoFieldLabel, Ii as shownKnobValues, Il as placedEditingPaths, Jc as Item, Jo as resolveEditorArrangementLook, Kl as unavailableSiteFacts, Lc as usePortalContainer, Lr as getAtPath, Na as classPriceItemKinds, Nu as asSiteStyleId, Pc as menuItemInteractionClassName, Pd as assertNever, Pl as editingGroups, Qc as Portal$2, Rc as ReactRemoveScroll, Ri as systemCustomizeFacetAppliesToLayoutVariant, Sl as createSlot, Tl as useComposedRefs, Tn as shouldRevealAllBlockFieldValidation, Uo as sectionPhotoFieldShown, Vl as matchVisibleWhen, Vo as sectionPhotoFieldHint, Wl as unknownBlockObservations, Ws as augmentManifestWithStyleGroups, Xc as createRovingFocusGroupScope, Yc as Root, Zc as Presence, _l as dispatchDiscreteCustomEvent, _r as createCustomBlockRegistry, ai as getBlockDefinition, al as useId$1, br as mergeManifestWithSdkOptions, cc as Root$1, cl as DismissableLayer, dl as createCollection, el as Arrow, fl as useControllableState, gd as syncStateOf, gl as Primitive, hl as composeEventHandlers, i as usePreviewSidebarNavigation, ii as resolveFieldOwnership, ll as useCallbackRef, ml as createContextScope, ni as fieldPathsOwnedBy, nl as Root2$1, ns as readStoredMode, o as usePreviewPageDesignEditorState, ol as FocusScope, os as getCuratedSiteStyle, qc as hideOthers, qn as createManifestFormAdapter, rc as unwrapResponse, ri as isDedicatedStyleField, rl as createPopperScope, sl as useFocusGuards, tl as Content, ul as useDirection, vr as mergeBlockDescriptorsWithRegistry, wl as composeRefs, xl as cva, xn as useEditorUiStoreInstance, yr as blockEditingIssues } from "./previewAssistantSlot-CqH91EwA.mjs";
3
+ import { it as Circle, pt as Check, ut as ChevronRight } from "./lucide-react-eAi3tDAr.mjs";
4
4
  import * as React$1 from "react";
5
- import { createContext, useContext, useMemo } from "react";
5
+ import { createContext, useContext, useEffect, useMemo, useRef, useState } from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import deepEqual from "fast-deep-equal";
8
8
  //#region ../../node_modules/.pnpm/@radix-ui+react-menu@2.1.18_@types+react-dom@19.3.0_@types+react@19.3.0__@types+react@1_f24ea5a0a00ace27996dbef7fb5354f4/node_modules/@radix-ui/react-menu/dist/index.mjs
@@ -1741,7 +1741,12 @@ const READINESS_REASON_COPY = {
1741
1741
  members_empty: "Add someone to show here. Until you do, this block stays hidden from visitors.",
1742
1742
  product_not_chosen: "Choose a product. Until you do, this block stays hidden from visitors.",
1743
1743
  product_gone: "The product this block showed is no longer available. Choose another one. Until you do, this block stays hidden from visitors.",
1744
- gallery_empty: "Add a photo. Until you do, this gallery stays hidden from visitors."
1744
+ gallery_empty: "Add a photo. Until you do, this gallery stays hidden from visitors.",
1745
+ video_grid_empty: "Add a video. Until you do, this block stays hidden from visitors.",
1746
+ audio_not_chosen: "Choose an audio file. Until you do, this player stays hidden from visitors.",
1747
+ file_not_chosen: "Choose a file. Until you do, this block stays hidden from visitors.",
1748
+ shop_nothing_on_sale: "You don't have a pass or a membership on sale yet. Until you have one, this block stays hidden from visitors.",
1749
+ shop_nothing_chosen: "Choose whether to show passes, memberships or both. Until you do, this block stays hidden from visitors."
1745
1750
  };
1746
1751
  const HIDDEN_REASON_COPY = {
1747
1752
  events_empty: "Nothing's scheduled here yet, so visitors won't see this section. It'll appear once you add something.",
@@ -1803,24 +1808,1401 @@ function normalizeCustomBlockEntries(customBlocks) {
1803
1808
  });
1804
1809
  }
1805
1810
  //#endregion
1806
- //#region ../editor-blocks/src/block-editor/colourFieldVisibility.ts
1811
+ //#region ../block-form/src/utils/fieldHelpers.ts
1812
+ const VALID_FIELD_INTENTS = [
1813
+ "content",
1814
+ "display",
1815
+ "behavior",
1816
+ "style"
1817
+ ];
1818
+ /**
1819
+ * Get the ui object from a field config, properly typed.
1820
+ */
1821
+ function getFieldUi(field) {
1822
+ return field.ui;
1823
+ }
1824
+ function parseFieldIntent(value) {
1825
+ if (typeof value !== "string") return null;
1826
+ return VALID_FIELD_INTENTS.includes(value) ? value : null;
1827
+ }
1828
+ /**
1829
+ * Check if a field should render in the block header.
1830
+ * Header fields are rendered in the collapsed block header area.
1831
+ */
1832
+ function isHeaderField(field) {
1833
+ return getFieldUi(field)?.renderInHeader === true;
1834
+ }
1835
+ /**
1836
+ * Check if a field is hidden.
1837
+ */
1838
+ function isHiddenField(field) {
1839
+ return getFieldUi(field)?.hidden === true;
1840
+ }
1841
+ /**
1842
+ * Check if a field has visibility conditions.
1843
+ */
1844
+ function hasVisibilityConditions(field) {
1845
+ const ui = getFieldUi(field);
1846
+ return ui?.hidden === true || ui?.visibleWhen !== void 0;
1847
+ }
1848
+ /**
1849
+ * Get the widget hint from a field, if present.
1850
+ * Falls back to field.type if no widget is specified.
1851
+ */
1852
+ function getWidgetKey(field) {
1853
+ return getFieldUi(field)?.widget ?? field.type;
1854
+ }
1855
+ /**
1856
+ * Resolve semantic intent for top-level form routing.
1857
+ * Priority:
1858
+ * 1) ui.intent (if valid)
1859
+ * 2) default content
1860
+ */
1861
+ function getFieldIntent(field) {
1862
+ const rawIntent = field.ui?.intent;
1863
+ const parsedIntent = parseFieldIntent(rawIntent);
1864
+ if (parsedIntent) return parsedIntent;
1865
+ if (typeof rawIntent === "string") console.warn(`[fieldHelpers] Invalid ui.intent "${rawIntent}" on field "${field.id}", falling back to "content"`);
1866
+ return "content";
1867
+ }
1868
+ function partitionFieldsByIntent(fields) {
1869
+ const result = {
1870
+ content: [],
1871
+ display: [],
1872
+ behavior: [],
1873
+ style: []
1874
+ };
1875
+ for (const field of fields) result[getFieldIntent(field)].push(field);
1876
+ return result;
1877
+ }
1878
+ /**
1879
+ * Check if a single value is "non-empty" (meaningful).
1880
+ * Returns false for null, undefined, empty string, false, and empty objects/arrays.
1881
+ */
1882
+ function isNonEmptyValue(value) {
1883
+ if (value == null || value === "" || value === false) return false;
1884
+ if (typeof value === "object") {
1885
+ if (Array.isArray(value)) return value.length > 0;
1886
+ return Object.keys(value).length > 0;
1887
+ }
1888
+ return true;
1889
+ }
1890
+ //#endregion
1891
+ //#region ../block-form/src/utils/computeWatchedPath.ts
1892
+ /**
1893
+ * Builds the absolute path for a watched field from a relative reference
1894
+ *
1895
+ * @param currentPath - Current field's absolute path (e.g., "background.scale")
1896
+ * @param relativeField - Relative field reference from visibleWhen (e.g., "objectFit")
1897
+ * Prefix with `$root.` to read from the form root instead of a sibling.
1898
+ * @returns Absolute path to watched field (e.g., "background.objectFit")
1899
+ *
1900
+ * @example
1901
+ * computeWatchedPath('background.scale', 'objectFit')
1902
+ * // => 'background.objectFit' (sibling field)
1903
+ *
1904
+ * computeWatchedPath('items.0.settings.customColor', 'useCustom')
1905
+ * // => 'items.0.settings.useCustom' (sibling in nested structure)
1906
+ *
1907
+ * computeWatchedPath('subtitle', 'showSubtitle')
1908
+ * // => 'showSubtitle' (top-level sibling)
1909
+ */
1910
+ function computeWatchedPath(currentPath, relativeField) {
1911
+ if (!relativeField) return null;
1912
+ if (relativeField.startsWith("$root.")) return relativeField.slice(6) || null;
1913
+ const parentSegments = currentPath.split(".").slice(0, -1);
1914
+ const watchFieldSegments = relativeField.split(".");
1915
+ return [...parentSegments, ...watchFieldSegments].filter((s) => s.length > 0).join(".");
1916
+ }
1917
+ //#endregion
1918
+ //#region ../block-form/src/utils/visibleWhen.ts
1919
+ /** Effective presentation values override stored values for visibility only. */
1920
+ function withVisibilityValues(reader, values) {
1921
+ return {
1922
+ ...reader,
1923
+ getValue: (path) => Object.prototype.hasOwnProperty.call(values, path) ? values[path] : reader.getValue(path)
1924
+ };
1925
+ }
1926
+ /** The tests on other fields' values in a condition: what a widget watches to re-evaluate it. */
1927
+ function getVisibleWhenPredicates(visibleWhen) {
1928
+ const nested = (conditions) => conditions.flatMap((condition) => [...getVisibleWhenPredicates(condition)]);
1929
+ return matchVisibleWhen(visibleWhen, {
1930
+ field: (condition) => [condition],
1931
+ fact: () => [],
1932
+ look: () => [],
1933
+ knob: () => [],
1934
+ template: () => [],
1935
+ observation: () => [],
1936
+ allOf: nested,
1937
+ anyOf: nested
1938
+ });
1939
+ }
1940
+ /**
1941
+ * Three-valued, so an unread fact can't hide a field by accident. `allOf`
1942
+ * fails if any part fails, and is otherwise unknown if any part is; `anyOf`
1943
+ * is met if any part is, and otherwise unknown if any part is.
1944
+ */
1945
+ function evaluateVisibleWhen(visibleWhen, evaluate) {
1946
+ const results = (conditions) => conditions.map((condition) => evaluateVisibleWhen(condition, evaluate));
1947
+ return matchVisibleWhen(visibleWhen, {
1948
+ field: (condition) => evaluate.field(condition) ? "met" : "failed",
1949
+ fact: evaluate.fact,
1950
+ look: evaluate.look,
1951
+ knob: evaluate.knob,
1952
+ template: evaluate.template,
1953
+ observation: evaluate.observation,
1954
+ allOf: (conditions) => combined(results(conditions), "failed", "met"),
1955
+ anyOf: (conditions) => conditions.length === 0 ? "met" : combined(results(conditions), "met", "failed")
1956
+ });
1957
+ }
1958
+ /** `decisive` settles it on its own; failing that, one unknown part leaves the whole unknown. */
1959
+ function combined(results, decisive, otherwise) {
1960
+ if (results.includes(decisive)) return decisive;
1961
+ return results.includes("unknown") ? "unknown" : otherwise;
1962
+ }
1963
+ /** A field shows unless its condition has failed: an unknown condition leaves it showing. */
1964
+ function conditionShows(result) {
1965
+ return result !== "failed";
1966
+ }
1967
+ function evaluateFactPredicate(condition, siteFacts) {
1968
+ const fact = readConditionFact(siteFacts, condition.fact);
1969
+ if (fact.kind === "Unavailable") return "unknown";
1970
+ return fact.value === condition.is ? "met" : "failed";
1971
+ }
1972
+ function evaluateLookPredicate(condition, look) {
1973
+ if (look.kind === "Unavailable") return "unknown";
1974
+ return look.value.state === condition.look ? "met" : "failed";
1975
+ }
1976
+ /**
1977
+ * Met when a Look draws the knob with one of the values; failed with no Look,
1978
+ * or a value outside them. A knob the block doesn't have can't be read, so
1979
+ * that's unknown rather than a reason to hide.
1980
+ */
1981
+ function evaluateKnobPredicate(condition, look) {
1982
+ if (look.kind === "Unavailable") return "unknown";
1983
+ if (look.value.state === "none") return "failed";
1984
+ const value = look.value.knobs[condition.knob];
1985
+ if (value === void 0) return "unknown";
1986
+ return condition.oneOf.includes(value) ? "met" : "failed";
1987
+ }
1988
+ function evaluateTemplatePredicate(condition, block) {
1989
+ if (block.template.kind === "Unavailable") return "unknown";
1990
+ return block.template.value.kind === condition.template ? "met" : "failed";
1991
+ }
1992
+ /** Met when what the block's selection resolves to includes the value; unknown until it has loaded. */
1993
+ function evaluateObservationPredicate(condition, block) {
1994
+ const observed = block.observations[condition.observation];
1995
+ if (observed.kind === "Unavailable") return "unknown";
1996
+ return observed.value.includes(condition.includes) ? "met" : "failed";
1997
+ }
1998
+ function evaluateVisibleWhenPredicate(condition, watchedValue) {
1999
+ if (condition.equals !== void 0) return watchedValue === condition.equals;
2000
+ if (condition.notEquals !== void 0) return watchedValue !== condition.notEquals;
2001
+ if (condition.oneOf !== void 0) return condition.oneOf.includes(watchedValue);
2002
+ if (condition.notIn !== void 0) return !condition.notIn.includes(watchedValue);
2003
+ if (condition.minItems !== void 0) return Array.isArray(watchedValue) && watchedValue.length >= condition.minItems;
2004
+ if (condition.maxItems !== void 0) return Array.isArray(watchedValue) && watchedValue.length <= condition.maxItems;
2005
+ if (condition.hasValue !== void 0) return hasValue(watchedValue) === condition.hasValue;
2006
+ return true;
2007
+ }
2008
+ /** Whether there's something there: text, a link, a photo, a list item. An empty rich text document isn't. */
2009
+ function hasValue(value) {
2010
+ if (value === null || value === void 0 || value === false) return false;
2011
+ if (typeof value === "string") return value.trim() !== "";
2012
+ if (Array.isArray(value)) return value.length > 0;
2013
+ if (typeof value === "object") return hasContent(value);
2014
+ return true;
2015
+ }
2016
+ function hasContent(value) {
2017
+ if ("type" in value && value.type === "doc") return richTextHasText(value);
2018
+ return Object.values(value).some(hasValue);
2019
+ }
2020
+ function richTextHasText(node) {
2021
+ if ("text" in node && typeof node.text === "string" && node.text.trim() !== "") return true;
2022
+ return ("content" in node && Array.isArray(node.content) ? node.content : []).some((child) => typeof child === "object" && child !== null && richTextHasText(child));
2023
+ }
2024
+ //#endregion
2025
+ //#region ../block-form/src/utils/evaluateVisibility.ts
2026
+ function collectVisibleWhenWatchPaths(field, path) {
2027
+ const visibleWhen = field.ui?.visibleWhen;
2028
+ if (!visibleWhen) return [];
2029
+ return getVisibleWhenPredicates(visibleWhen).map((condition) => computeWatchedPath(path, condition.field)).filter((watchedPath) => Boolean(watchedPath));
2030
+ }
2031
+ /**
2032
+ * Evaluates whether a field should be visible based on its configuration
2033
+ *
2034
+ * @param field - The field configuration containing ui.hidden and ui.visibleWhen
2035
+ * @param reader - Other fields' values, and what the site has
2036
+ * @param path - Current field's absolute path (e.g., "items.0.title")
2037
+ * @returns true if field should be visible, false if it should be hidden
2038
+ *
2039
+ * @example
2040
+ * // Field with conditional visibility
2041
+ * const field = {
2042
+ * id: 'scale',
2043
+ * ui: {
2044
+ * visibleWhen: { field: 'objectFit', equals: 'custom' }
2045
+ * }
2046
+ * }
2047
+ *
2048
+ * // At path "background.scale", watches "background.objectFit"
2049
+ * const visible = evaluateVisibility(field, reader, 'background.scale')
2050
+ *
2051
+ * A condition that turns on a site fact that couldn't be read leaves the
2052
+ * field visible.
2053
+ */
2054
+ function evaluateVisibility(field, reader, path) {
2055
+ if (field.ui?.hidden) return false;
2056
+ const visibleWhen = field.ui?.visibleWhen;
2057
+ if (!visibleWhen) return true;
2058
+ return conditionShows(evaluateVisibleWhen(visibleWhen, {
2059
+ field: (condition) => evaluateFieldCondition(condition, reader, path),
2060
+ fact: (condition) => evaluateFactPredicate(condition, reader.siteFacts),
2061
+ look: (condition) => evaluateLookPredicate(condition, reader.block.look),
2062
+ knob: (condition) => evaluateKnobPredicate(condition, reader.block.look),
2063
+ template: (condition) => evaluateTemplatePredicate(condition, reader.block),
2064
+ observation: (condition) => evaluateObservationPredicate(condition, reader.block)
2065
+ }));
2066
+ }
2067
+ function evaluateFieldCondition(condition, reader, path) {
2068
+ const absolutePath = computeWatchedPath(path, condition.field);
2069
+ if (!absolutePath) return true;
2070
+ return evaluateVisibleWhenPredicate(condition, reader.getValue(absolutePath));
2071
+ }
2072
+ //#endregion
2073
+ //#region ../block-form/src/utils/resolvePromotedFields.ts
2074
+ function ancestorsOf(ref) {
2075
+ return ref.ancestors ?? [];
2076
+ }
2077
+ function isGroupField(field) {
2078
+ return field.type === "group";
2079
+ }
2080
+ function isModalField(field) {
2081
+ return field.type === "modal";
2082
+ }
2083
+ function isRepeaterField(field) {
2084
+ return field.type === "repeater";
2085
+ }
2086
+ function isNumericSegment(segment) {
2087
+ return Boolean(segment && /^\d+$/.test(segment));
2088
+ }
2089
+ function getNestedFields(field) {
2090
+ if (isGroupField(field)) return field.fields;
2091
+ if (isModalField(field)) return field.schema?.fields ?? [];
2092
+ if (isRepeaterField(field)) {
2093
+ if (field.polymorphic && field.itemTypes) {
2094
+ const all = [];
2095
+ for (const itemType of Object.values(field.itemTypes)) all.push(...itemType.fields ?? []);
2096
+ return all;
2097
+ }
2098
+ return field.fields ?? [];
2099
+ }
2100
+ return [];
2101
+ }
2102
+ function getChildren(parent, parentPath, getValue) {
2103
+ const { field, tabSelections, sdkSectionOption } = parent;
2104
+ const ancestors = [...ancestorsOf(parent), {
2105
+ field,
2106
+ path: parentPath
2107
+ }];
2108
+ if (field.type === "tabGroup") {
2109
+ const activeTab = field.activeTabField ? getValue(`${parentPath}.${field.activeTabField}`) : void 0;
2110
+ return [...field.tabs].sort((a, b) => Number(b.id === activeTab) - Number(a.id === activeTab)).flatMap((tab) => tab.fields.map((child) => ({
2111
+ ancestors,
2112
+ field: child,
2113
+ sdkSectionOption: tab.sdkSectionOption ?? sdkSectionOption,
2114
+ tabSelections: field.activeTabField ? [...tabSelections, {
2115
+ parentPath,
2116
+ controlField: field.activeTabField,
2117
+ tabId: tab.id
2118
+ }] : tabSelections
2119
+ })));
2120
+ }
2121
+ return getNestedFields(field).map((child) => ({
2122
+ ancestors,
2123
+ field: child,
2124
+ sdkSectionOption,
2125
+ tabSelections
2126
+ }));
2127
+ }
2128
+ function findGreedyChild(children, segments, startIndex) {
2129
+ const max = segments.length;
2130
+ for (let end = max; end > startIndex; end -= 1) {
2131
+ const candidateId = segments.slice(startIndex, end).join(".");
2132
+ const match = children.find((c) => c.field.id === candidateId);
2133
+ if (match) return {
2134
+ child: match,
2135
+ consumed: end - startIndex
2136
+ };
2137
+ }
2138
+ return null;
2139
+ }
2140
+ function defaultPromotedLabel(path, field) {
2141
+ if (path.endsWith(".background.image")) return field.type === "media" && field.mediaKinds?.includes("video") ? "Background video" : "Background image";
2142
+ return null;
2143
+ }
2144
+ /**
2145
+ * Resolve a list of promoted field paths into renderable field configs.
2146
+ *
2147
+ * Notes:
2148
+ * - This is a render-only shortcut. The returned `field` is *not* added to the
2149
+ * manifest/schema; it should be rendered at `path` while continuing to store
2150
+ * data within the existing nested object shape.
2151
+ * - Field IDs in manifests can contain dots (e.g. `overlay.color`). This resolver
2152
+ * uses greedy matching against child IDs to support those paths.
2153
+ * - Array indexes in paths (e.g. `items.0.title`) are ignored for matching.
2154
+ */
2155
+ function resolvePromotedFields(fields, promotedPaths, getValue) {
2156
+ if (!promotedPaths || promotedPaths.length === 0) return [];
2157
+ const unique = Array.from(new Set(promotedPaths.map((p) => p.trim()).filter((p) => p.length > 0)));
2158
+ const resolved = [];
2159
+ for (const path of unique) {
2160
+ const segments = path.split(".").filter((s) => s.length > 0);
2161
+ if (segments.length === 0) continue;
2162
+ let children = fields.map((field) => ({
2163
+ field,
2164
+ tabSelections: []
2165
+ }));
2166
+ let activeSdkOption;
2167
+ let current = null;
2168
+ let i = 0;
2169
+ while (i < segments.length) {
2170
+ const seg = segments[i];
2171
+ if (isNumericSegment(seg)) {
2172
+ i += 1;
2173
+ continue;
2174
+ }
2175
+ const match = findGreedyChild(children, segments, i);
2176
+ if (!match) {
2177
+ current = null;
2178
+ break;
2179
+ }
2180
+ current = match.child;
2181
+ if (current.sdkSectionOption) activeSdkOption = current.sdkSectionOption;
2182
+ i += match.consumed;
2183
+ if (i >= segments.length) break;
2184
+ children = getChildren(current, segments.slice(0, i).join("."), getValue);
2185
+ if (isNumericSegment(segments[i])) i += 1;
2186
+ }
2187
+ if (!current) continue;
2188
+ const labelOverride = defaultPromotedLabel(path, current.field);
2189
+ const promotedField = labelOverride ? {
2190
+ ...current.field,
2191
+ label: labelOverride
2192
+ } : current.field;
2193
+ resolved.push({
2194
+ path,
2195
+ tabSelections: current.tabSelections,
2196
+ ancestors: ancestorsOf(current),
2197
+ field: promotedField,
2198
+ sdkSectionOption: activeSdkOption
2199
+ });
2200
+ }
2201
+ return resolved;
2202
+ }
2203
+ //#endregion
2204
+ //#region ../block-form/src/editing/derivedSummary.ts
2205
+ /**
2206
+ * The line for a group nobody wrote a summary for: "More settings" today, and
2207
+ * the two derived groups of a block that hasn't declared its own. It reads
2208
+ * field labels, so it's only as good as they are.
2209
+ */
2210
+ function derivedSettingsSummary(items, getValue) {
2211
+ const summaries = items.flatMap(({ field, path }) => {
2212
+ const value = getValue(path) ?? field.defaultValue;
2213
+ if (typeof value === "boolean") return value ? [field.label] : [];
2214
+ const label = settingsValueLabel(field, value);
2215
+ return label ? [`${field.label}: ${label}`] : [];
2216
+ });
2217
+ return [...summaries.slice(0, 3), ...summaries.length > 3 ? [`and ${summaries.length - 3} more`] : []].join(" · ");
2218
+ }
2219
+ function isSummaryScalar(value) {
2220
+ return value !== "" && (typeof value === "string" || typeof value === "number");
2221
+ }
2222
+ /** Multi-select labels form one summary value, using the same option lookup as scalars. */
2223
+ function settingsValueLabel(field, value) {
2224
+ const values = Array.isArray(value) ? value.filter(isSummaryScalar) : isSummaryScalar(value) ? [value] : [];
2225
+ if (Array.isArray(value) && field.type !== "select") return void 0;
2226
+ return values.map((selected) => field.type === "select" ? field.options.find((option) => option.value === selected)?.label ?? String(selected) : String(selected)).join(", ") || void 0;
2227
+ }
2228
+ //#endregion
2229
+ //#region ../block-form/src/editing/groupSummary.ts
2230
+ function summariseGroup(summary, reader) {
2231
+ const said = summary.parts.filter((part) => reader.isVisible(part.field)).map((part) => ({
2232
+ path: part.field,
2233
+ ...sayPart(part, reader)
2234
+ }));
2235
+ const phrases = said.flatMap((entry) => entry.phrase ? [entry.phrase] : []);
2236
+ return {
2237
+ line: phrases.length > 0 ? capitalised(phrases.join(", ")) : summary.none,
2238
+ unphrased: said.flatMap((entry) => entry.unphrased === void 0 ? [] : [{
2239
+ path: entry.path,
2240
+ value: entry.unphrased
2241
+ }])
2242
+ };
2243
+ }
2244
+ function sayPart(part, reader) {
2245
+ const value = reader.getValue(part.field);
2246
+ return matchSummaryPart(part, {
2247
+ on: ({ on }) => ({ phrase: value === true ? on : null }),
2248
+ options: ({ options }) => sayOption(options, value),
2249
+ text: ({ text }) => ({ phrase: typeof value === "string" && value.trim() !== "" ? `${text.before ?? ""}${value.trim()}${text.after ?? ""}` : text.empty ?? null }),
2250
+ set: ({ set, unset }) => ({ phrase: hasValue(value) ? set : unset ?? null }),
2251
+ count: ({ count }) => ({ phrase: sayCount(count, value) }),
2252
+ chosen: ({ chosen }) => ({ phrase: hasValue(value) ? `${chosen.before ?? ""}${reader.chosenLabel?.(part.field, value) ?? chosen.fallback}${chosen.after ?? ""}` : null })
2253
+ });
2254
+ }
2255
+ function sayOption(options, value) {
2256
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return { phrase: null };
2257
+ const key = String(value);
2258
+ return Object.prototype.hasOwnProperty.call(options, key) ? { phrase: options[key] ?? null } : {
2259
+ phrase: null,
2260
+ unphrased: key
2261
+ };
2262
+ }
2263
+ function sayCount(count, value) {
2264
+ const size = Array.isArray(value) ? value.length : 0;
2265
+ if (size === 0) return null;
2266
+ return size === 1 ? count.one : count.many.split("{n}").join(String(size));
2267
+ }
2268
+ function capitalised(line) {
2269
+ return line.charAt(0).toUpperCase() + line.slice(1);
2270
+ }
2271
+ //#endregion
2272
+ //#region ../block-form/src/manifest/filterSdkTabs.ts
2273
+ function isSdkSectionOptionEnabled(sdkSectionOption, isSdkSite, sectionOptions) {
2274
+ if (!isSdkSite || !sectionOptions) return true;
2275
+ if (!sdkSectionOption) return true;
2276
+ return sectionOptions[sdkSectionOption] !== false;
2277
+ }
2278
+ /**
2279
+ * Filters tabs based on SDK section options.
2280
+ *
2281
+ * This pure function handles the filtering logic that was previously embedded
2282
+ * in TabGroupField. It's designed to be testable and reusable.
2283
+ *
2284
+ * ## Filtering Rules
2285
+ *
2286
+ * - If not an SDK site or no sectionOptions exist, all tabs are returned
2287
+ * - Tabs without `sdkSectionOption` are always visible
2288
+ * - Tabs with `sdkSectionOption` are visible unless explicitly disabled
2289
+ * - A disabled option is when `sectionOptions[key] === false`
2290
+ *
2291
+ * @param tabs - Array of tabs to filter
2292
+ * @param isSdkSite - Whether this is an SDK-configured site
2293
+ * @param sectionOptions - SDK section options (may be null)
2294
+ * @returns Filtered array of visible tabs
2295
+ *
2296
+ * @example
2297
+ * ```typescript
2298
+ * const visibleTabs = filterTabsBySdkOptions(
2299
+ * config.tabs,
2300
+ * isSdkSite,
2301
+ * sectionOptions
2302
+ * )
2303
+ * ```
2304
+ */
2305
+ function filterTabsBySdkOptions(tabs, isSdkSite, sectionOptions) {
2306
+ return tabs.filter((tab) => isSdkSectionOptionEnabled(tab.sdkSectionOption, isSdkSite, sectionOptions));
2307
+ }
2308
+ /**
2309
+ * The tab a tab group shows: the one its control field names, or the first
2310
+ * the site offers. Null when the site offers none, and the group draws nothing.
2311
+ * TabGroupField draws from this, and the editing plan reads it to say which
2312
+ * fields are on screen.
2313
+ */
2314
+ function shownTab(tabs, controlValue, sdk) {
2315
+ const visibleTabs = filterTabsBySdkOptions(tabs, sdk.isSdkSite, sdk.sectionOptions);
2316
+ const active = visibleTabs.find((tab) => tab.id === controlValue) ?? visibleTabs[0];
2317
+ return active ? {
2318
+ visibleTabs,
2319
+ active
2320
+ } : null;
2321
+ }
2322
+ //#endregion
2323
+ //#region ../block-form/src/widgets/groupFieldHelpers.ts
2324
+ /** The one nested placement rule, shared by GroupField and the repeater row that hoists a group's settings. */
2325
+ function splitGroupFields(config, path) {
2326
+ const { content, display, behavior, style } = partitionFieldsByIntent(config.fields);
2327
+ const flatten = shouldFlattenInRepeater(path, config);
2328
+ return {
2329
+ content,
2330
+ settings: [
2331
+ ...display,
2332
+ ...behavior,
2333
+ ...style
2334
+ ].map((field) => resolveFieldPlacement(field, path, flatten))
2335
+ };
2336
+ }
2337
+ function groupSettingsHost(config, path) {
2338
+ return shouldHideLabel(config) && isDirectlyInRepeaterItem(path) ? "repeater-row" : "group";
2339
+ }
2340
+ function groupPresentation(config) {
2341
+ if (getLayout(config) === "grid") return "grid";
2342
+ return getWidgetPreset(config) === "disclosure" ? "disclosure" : "stack";
2343
+ }
2344
+ function layoutGroupFields(config, path) {
2345
+ const presentation = groupPresentation(config);
2346
+ const flatten = shouldFlattenInRepeater(path, config);
2347
+ const place = (field) => resolveFieldPlacement(field, path, flatten);
2348
+ const fields = config.fields.map(place);
2349
+ if (presentation === "disclosure") return {
2350
+ presentation,
2351
+ inline: fields,
2352
+ ownSettings: [],
2353
+ fields
2354
+ };
2355
+ const split = splitGroupFields(config, path);
2356
+ return {
2357
+ presentation,
2358
+ fields,
2359
+ inline: split.content.map(place),
2360
+ ownSettings: groupSettingsHost(config, path) === "group" ? split.settings : []
2361
+ };
2362
+ }
2363
+ /** The fields a group or modal field shows in its dialog (ModalGroupField). */
2364
+ function modalGroupFields(config, path) {
2365
+ return (config.type === "modal" ? config.schema.fields : config.schema?.fields ?? config.fields ?? []).map((field) => resolveFieldPlacement(field, path, false));
2366
+ }
2367
+ function isDirectlyInRepeaterItem(path) {
2368
+ const segments = path.split(".");
2369
+ return segments.length >= 2 && /^\d+$/.test(segments[segments.length - 2] ?? "");
2370
+ }
2371
+ function resolveFieldPlacement(field, basePath, flatten) {
2372
+ return {
2373
+ field,
2374
+ path: buildChildPath(basePath, field.id, flatten)
2375
+ };
2376
+ }
2377
+ /**
2378
+ * Determines if a group field should flatten its children when inside a repeater
2379
+ *
2380
+ * @param path - Current field path (e.g., "items.0.meta")
2381
+ * @param config - Group field configuration
2382
+ * @returns true if the group should flatten (children rendered at parent level)
2383
+ */
2384
+ function shouldFlattenInRepeater(path, config) {
2385
+ return Boolean(config.ui?.flattenInRepeater) && isDirectlyInRepeaterItem(path);
2386
+ }
2387
+ /**
2388
+ * Extracts the group preset from field configuration.
2389
+ *
2390
+ * @param config - Group field configuration
2391
+ * @returns Preset name or null
2392
+ */
2393
+ function getWidgetPreset(config) {
2394
+ return config.ui?.preset ?? null;
2395
+ }
2396
+ /**
2397
+ * Builds a child field path, accounting for flattening behavior
2398
+ *
2399
+ * @param basePath - Base path for the group field
2400
+ * @param childId - Child field ID
2401
+ * @param shouldFlatten - Whether the group is flattened
2402
+ * @returns Full path to the child field
2403
+ */
2404
+ function buildChildPath(basePath, childId, shouldFlatten) {
2405
+ if (shouldFlatten) {
2406
+ const parentPath = basePath.split(".").slice(0, -1).join(".");
2407
+ return parentPath ? `${parentPath}.${childId}` : childId;
2408
+ }
2409
+ return basePath ? `${basePath}.${childId}` : childId;
2410
+ }
2411
+ /**
2412
+ * Checks if label should be hidden
2413
+ */
2414
+ function shouldHideLabel(config) {
2415
+ return Boolean(config.ui?.hideLabel);
2416
+ }
2417
+ /**
2418
+ * Gets the layout mode for a group field
2419
+ */
2420
+ function getLayout(config) {
2421
+ return config.ui?.layout === "grid" ? "grid" : "stack";
2422
+ }
2423
+ /**
2424
+ * Gets the number of columns for grid layout
2425
+ */
2426
+ function getColumns(config) {
2427
+ const columns = config.ui?.columns;
2428
+ if (typeof columns === "number" && columns >= 2 && columns <= 4) return columns;
2429
+ return 2;
2430
+ }
2431
+ /**
2432
+ * Validates and clamps colSpan to valid range
2433
+ */
2434
+ function getValidColSpan(colSpan, columns) {
2435
+ if (!colSpan || colSpan < 1) return 1;
2436
+ if (colSpan > columns) {
2437
+ console.warn(`[GroupField] colSpan ${colSpan} exceeds columns ${columns}, clamping`);
2438
+ return columns;
2439
+ }
2440
+ return colSpan;
2441
+ }
2442
+ /**
2443
+ * Groups fields by their ui.row property
2444
+ * Fields without a row property each get their own row
2445
+ */
2446
+ function groupFieldsByRow(fields) {
2447
+ const rowMap = /* @__PURE__ */ new Map();
2448
+ const orderedRows = [];
2449
+ for (const field of fields) {
2450
+ const rowKey = field.ui?.row ?? `__single_${field.id}`;
2451
+ if (!rowMap.has(rowKey)) {
2452
+ rowMap.set(rowKey, []);
2453
+ orderedRows.push(rowKey);
2454
+ }
2455
+ const row = rowMap.get(rowKey);
2456
+ if (row) row.push(field);
2457
+ }
2458
+ return orderedRows.map((key) => rowMap.get(key) ?? []);
2459
+ }
2460
+ //#endregion
2461
+ //#region ../block-form/src/widgets/RepeaterField/utils/getRepeaterItemFields.ts
2462
+ /**
2463
+ * Get the fields for a specific repeater item.
2464
+ *
2465
+ * For monomorphic repeaters, returns config.fields.
2466
+ * For polymorphic repeaters, looks up the item's _type and returns
2467
+ * the fields from the corresponding itemType schema.
2468
+ *
2469
+ * @param config - Repeater field configuration
2470
+ * @param backend - Form backend for reading values
2471
+ * @param basePath - Base path to the repeater array
2472
+ * @param index - Index of the item in the array
2473
+ * @returns Array of field configs for this item
2474
+ */
2475
+ function getRepeaterItemFields(config, backend, basePath, index) {
2476
+ if (config.polymorphic && config.itemTypes) {
2477
+ const itemValue = backend.getValue(`${basePath}.${index}`);
2478
+ const itemType = typeof itemValue?._type === "string" ? itemValue._type : Object.keys(config.itemTypes)[0] ?? "";
2479
+ return (itemType ? config.itemTypes[itemType] : void 0)?.fields ?? [];
2480
+ }
2481
+ return config.fields ?? [];
2482
+ }
2483
+ //#endregion
2484
+ //#region ../block-form/src/widgets/RepeaterField/utils/getRepeaterItemFieldGroups.ts
2485
+ /** A row's own settings fields go in its settings; an unlabelled group's settings join them. */
2486
+ function deriveFieldPlacement(field, rowPath) {
2487
+ const placement = resolveFieldPlacement(field, rowPath, false);
2488
+ if (getFieldIntent(field) !== "content") return {
2489
+ content: [],
2490
+ settings: [placement],
2491
+ excludedId: [field.id]
2492
+ };
2493
+ const hoisted = field.type === "group" && groupSettingsHost(field, placement.path) === "repeater-row" ? splitGroupFields(field, placement.path).settings : [];
2494
+ return {
2495
+ content: [field],
2496
+ settings: hoisted,
2497
+ excludedId: []
2498
+ };
2499
+ }
2500
+ function getRepeaterItemFieldGroups(config, backend, basePath, index) {
2501
+ const placements = getRepeaterItemFields(config, backend, basePath, index).map((field) => deriveFieldPlacement(field, `${basePath}.${index}`));
2502
+ return {
2503
+ contentFields: placements.flatMap(({ content }) => content),
2504
+ settingsFields: placements.flatMap(({ settings }) => settings),
2505
+ settingsFieldIds: new Set(placements.flatMap(({ excludedId }) => excludedId))
2506
+ };
2507
+ }
2508
+ //#endregion
2509
+ //#region ../block-form/src/editing/nestedPlacement.ts
2510
+ function revealStepKey(step) {
2511
+ return `${step.kind}:${step.path}`;
2512
+ }
2513
+ /**
2514
+ * The steps that bring `target` on screen, for a field the form draws at
2515
+ * `path`. Null when this field doesn't draw it: the target is elsewhere, its
2516
+ * condition hides it, its row or item type doesn't exist, it sits in a tab
2517
+ * that isn't showing, or its owner took it out of the form.
2518
+ *
2519
+ * It follows a field by its type. A host widget that draws a group or
2520
+ * repeater its own way gets the same steps and may not act on them.
2521
+ */
2522
+ function revealStepsWithin(field, path, target, context) {
2523
+ const container = containerOf(field);
2524
+ switch (container.kind) {
2525
+ case "leaf": return target === path || target.startsWith(`${path}.`) ? [] : null;
2526
+ case "group": return withinGroup(container.field, path, target, context);
2527
+ case "modal": {
2528
+ const open = {
2529
+ kind: "modal",
2530
+ path
2531
+ };
2532
+ if (target === path) return [open];
2533
+ return after([open], revealStepsAmong(modalGroupFields(container.field, path), target, context));
2534
+ }
2535
+ case "tabGroup": return withinTabGroup(container.field, path, target, context);
2536
+ case "repeater": return withinRepeater(container.field, path, target, context);
2537
+ default: return assertNever(container);
2538
+ }
2539
+ }
2540
+ /** The first of these placements that draws `target`, skipping any its condition hides. */
2541
+ function revealStepsAmong(placements, target, context) {
2542
+ for (const { field, path } of placements) {
2543
+ if (!evaluateVisibility(field, context, path)) continue;
2544
+ const steps = revealStepsWithin(field, path, target, context);
2545
+ if (steps) return steps;
2546
+ }
2547
+ return null;
2548
+ }
2549
+ function containerOf(field) {
2550
+ if (field.type === "modal") return {
2551
+ kind: "modal",
2552
+ field
2553
+ };
2554
+ if (field.type === "group") return getWidgetKey(field) === "modal" ? {
2555
+ kind: "modal",
2556
+ field
2557
+ } : {
2558
+ kind: "group",
2559
+ field
2560
+ };
2561
+ if (field.type === "tabGroup") return {
2562
+ kind: "tabGroup",
2563
+ field
2564
+ };
2565
+ if (field.type === "repeater") return {
2566
+ kind: "repeater",
2567
+ field
2568
+ };
2569
+ return { kind: "leaf" };
2570
+ }
2571
+ function after(steps, rest) {
2572
+ return rest ? [...steps, ...rest] : null;
2573
+ }
2574
+ function withinGroup(field, path, target, context) {
2575
+ const layout = layoutGroupFields(field, path);
2576
+ const own = layout.presentation === "disclosure" ? [{
2577
+ kind: "group-disclosure",
2578
+ path
2579
+ }] : [];
2580
+ if (target === path) return own;
2581
+ return after(own, revealStepsAmong(layout.inline, target, context)) ?? after([...own, {
2582
+ kind: "group-settings",
2583
+ path
2584
+ }], revealStepsAmong(layout.ownSettings, target, context));
2585
+ }
2586
+ function withinTabGroup(field, path, target, context) {
2587
+ const controlValue = field.activeTabField ? context.getValue(`${path}.${field.activeTabField}`) : void 0;
2588
+ const shown = shownTab(field.tabs, controlValue, context.sdk);
2589
+ if (!shown) return null;
2590
+ if (target === path) return [];
2591
+ return revealStepsAmong(shown.active.fields.map((child) => resolveFieldPlacement(child, path, false)), target, context);
2592
+ }
2593
+ function withinRepeater(field, path, target, context) {
2594
+ const list = {
2595
+ kind: "repeater-list",
2596
+ path
2597
+ };
2598
+ if (target === path) return [list];
2599
+ const index = rowIndexOf(path, target);
2600
+ const rows = context.getValue(path);
2601
+ if (index === null || !Array.isArray(rows) || index >= rows.length) return null;
2602
+ const rowPath = `${path}.${index}`;
2603
+ const row = [list, {
2604
+ kind: "repeater-row",
2605
+ path: rowPath
2606
+ }];
2607
+ if (target === rowPath) return row;
2608
+ const groups = getRepeaterItemFieldGroups(field, context, path, index);
2609
+ return after(row, revealStepsAmong(groups.contentFields.map((child) => resolveFieldPlacement(child, rowPath, false)), target, context)) ?? after([...row, {
2610
+ kind: "row-settings",
2611
+ path: rowPath
2612
+ }], revealStepsAmong(groups.settingsFields, target, context));
2613
+ }
2614
+ function rowIndexOf(repeaterPath, target) {
2615
+ if (!target.startsWith(`${repeaterPath}.`)) return null;
2616
+ const segment = target.slice(repeaterPath.length + 1).split(".")[0] ?? "";
2617
+ return /^\d+$/u.test(segment) ? Number(segment) : null;
2618
+ }
2619
+ const derivedGroups = {
2620
+ whatItShows: {
2621
+ id: "derived:what-it-shows",
2622
+ title: "What it shows"
2623
+ },
2624
+ moreSettings: {
2625
+ id: "derived:more-settings",
2626
+ title: "More settings"
2627
+ }
2628
+ };
2629
+ /**
2630
+ * The allocation rule. A declared field goes where it's declared. Every system
2631
+ * block declares all its own fields, so the derived rule only places SDK
2632
+ * fields: a custom block's, or ones an SDK extension appends. It puts content
2633
+ * fields, and required display or behaviour fields with no default, with the
2634
+ * content, other behaviour in "What it shows", the rest in "More settings",
2635
+ * after any declared groups. The Look's fields and the style groups are taken
2636
+ * out first, so no declaration moves them.
2637
+ */
2638
+ function layoutBlockEditing(input) {
2639
+ const offered = offeredFields(input.sections);
2640
+ const placed = placeFields(offered.own, input.editing);
2641
+ const entries = [...placed.settings.flatMap((entry) => "group" in entry ? declaredGroup(entry.group, entry.fields, input) : [plainEntry(entry)]), ...["whatItShows", "moreSettings"].flatMap((place) => derivedGroup(place, placed.derived(place), input.getValue))];
2642
+ return {
2643
+ layout: {
2644
+ look: offered.look,
2645
+ content: placed.content,
2646
+ settings: settingsFor(entries.map(({ entry }) => entry), placed.declaredContent, input.lookOwnsFields && offered.styles.length === 0),
2647
+ styles: offered.styles
2648
+ },
2649
+ unphrased: entries.flatMap(({ unphrased }) => unphrased)
2650
+ };
2651
+ }
2652
+ /** The Look's fields and the style groups come out first; the rest are the block's own, to be placed. */
2653
+ function offeredFields(sections) {
2654
+ const body = sections.flatMap((entry) => {
2655
+ const section = entry.section;
2656
+ return section === "look" ? [] : entry.fields.map((field) => ({
2657
+ field,
2658
+ section
2659
+ }));
2660
+ });
2661
+ return {
2662
+ look: sections.find((entry) => entry.section === "look")?.fields ?? [],
2663
+ styles: body.filter(({ field }) => isDedicatedStyleField(field.path)).map(({ field }) => field),
2664
+ own: body.filter(({ field }) => !isDedicatedStyleField(field.path))
2665
+ };
2666
+ }
2667
+ /** Declared paths the form isn't offering now (hidden by a condition, owned by the Look) are simply absent. */
2668
+ function placeFields(own, editing) {
2669
+ const present = (paths) => paths.flatMap((path) => own.find(({ field }) => field.path === path)?.field ?? []);
2670
+ const declared = new Set(editing ? placedEditingPaths(editing) : []);
2671
+ const derived = (place) => own.filter(({ field, section }) => !declared.has(field.path) && derivedPlace(field, section) === place).map(({ field }) => field);
2672
+ const declaredContent = present(editing?.content ?? []);
2673
+ return {
2674
+ declaredContent,
2675
+ content: [...declaredContent, ...derived("content")],
2676
+ settings: (editing?.settings ?? []).flatMap((entry) => typeof entry === "string" ? present([entry]) : [{
2677
+ group: entry,
2678
+ fields: present(entry.fields)
2679
+ }]),
2680
+ derived
2681
+ };
2682
+ }
2683
+ function plainEntry(field) {
2684
+ return {
2685
+ entry: {
2686
+ kind: "field",
2687
+ field
2688
+ },
2689
+ unphrased: []
2690
+ };
2691
+ }
2692
+ /** The derived rule, for SDK fields only (system blocks declare theirs): content, and what must be filled in, sits with the content. */
2693
+ function derivedPlace(field, section) {
2694
+ switch (section) {
2695
+ case "whatItShows":
2696
+ case "text": return "content";
2697
+ case "moreSettings": return getFieldIntent(field.field) === "behavior" ? "whatItShows" : "moreSettings";
2698
+ default: return assertNever(section);
2699
+ }
2700
+ }
2701
+ function declaredGroup(group, fields, input) {
2702
+ if (fields.length === 0) return [];
2703
+ const said = summariseGroup(group.summary, {
2704
+ getValue: (path) => input.getValue(path) ?? nestedDefault(input.fields, path, input.getValue),
2705
+ isVisible: (path) => revealStepsAmong(fields, path, input.nested) !== null,
2706
+ chosenLabel: input.chosenLabel
2707
+ });
2708
+ return [{
2709
+ entry: {
2710
+ kind: "group",
2711
+ group: {
2712
+ id: group.id,
2713
+ title: group.title,
2714
+ summary: said.line,
2715
+ fields
2716
+ }
2717
+ },
2718
+ unphrased: said.unphrased.map((entry) => ({
2719
+ groupId: group.id,
2720
+ ...entry
2721
+ }))
2722
+ }];
2723
+ }
2724
+ /**
2725
+ * What a field inside a group shows before anything is stored for it: its own
2726
+ * default, or its place in a containing group's. The widgets fall back the
2727
+ * same way, so a line and the switch it describes agree.
2728
+ */
2729
+ function nestedDefault(fields, path, getValue) {
2730
+ const resolved = resolvePromotedFields([...fields], [path], getValue)[0];
2731
+ if (!resolved) return void 0;
2732
+ const innermostFirst = [...resolved.ancestors].reverse();
2733
+ return resolved.field.defaultValue ?? innermostFirst.map((ancestor) => getAtPath(ancestor.field.defaultValue, path.slice(ancestor.path.length + 1))).find((value) => value !== void 0);
2734
+ }
2735
+ function derivedGroup(place, fields, getValue) {
2736
+ if (fields.length === 0) return [];
2737
+ return [{
2738
+ entry: {
2739
+ kind: "group",
2740
+ group: {
2741
+ ...derivedGroups[place],
2742
+ summary: derivedSettingsSummary(fields, getValue),
2743
+ fields
2744
+ }
2745
+ },
2746
+ unphrased: []
2747
+ }];
2748
+ }
2749
+ function entryFields(entry) {
2750
+ switch (entry.kind) {
2751
+ case "field": return [entry.field];
2752
+ case "group": return entry.group.fields;
2753
+ default: return assertNever(entry);
2754
+ }
2755
+ }
2756
+ /** Decided from what's left after the Look and conditions, so a block with few settings on this site has no rows. */
2757
+ function settingsFor(entries, declaredContent, lookTookTheRest) {
2758
+ const fields = entries.flatMap(entryFields);
2759
+ if (fields.length === 0 && lookTookTheRest) return { kind: "set-by-look" };
2760
+ if (fields.length <= 3) return {
2761
+ kind: "plain",
2762
+ fields
2763
+ };
2764
+ const list = declaredContent.find((item) => item.field.type === "repeater");
2765
+ return {
2766
+ kind: "rows",
2767
+ entries,
2768
+ position: list ? {
2769
+ kind: "before-content-field",
2770
+ path: list.path
2771
+ } : { kind: "after-content" }
2772
+ };
2773
+ }
2774
+ /** The part of the layout that draws this path, with the steps to it inside that field. */
2775
+ function destinationInLayout(layout, fieldPath, context) {
2776
+ const within = (fields) => revealStepsAmong(fields, fieldPath, context);
2777
+ const look = within(layout.look);
2778
+ if (look) return {
2779
+ kind: "look",
2780
+ reveal: look
2781
+ };
2782
+ const ownView = within([
2783
+ ...layout.content,
2784
+ ...ownViewSettings(layout.settings),
2785
+ ...layout.styles
2786
+ ]);
2787
+ if (ownView) return {
2788
+ kind: "content",
2789
+ reveal: ownView
2790
+ };
2791
+ const inGroup = rowGroups(layout.settings).map((group) => ({
2792
+ group,
2793
+ reveal: within(group.fields)
2794
+ })).find((candidate) => candidate.reveal !== null);
2795
+ return inGroup?.reveal ? {
2796
+ kind: "group",
2797
+ groupId: inGroup.group.id,
2798
+ reveal: inGroup.reveal
2799
+ } : { kind: "unavailable" };
2800
+ }
2801
+ function ownViewSettings(settings) {
2802
+ switch (settings.kind) {
2803
+ case "plain": return settings.fields;
2804
+ case "rows": return settings.entries.flatMap((entry) => entry.kind === "field" ? [entry.field] : []);
2805
+ case "set-by-look": return [];
2806
+ default: return assertNever(settings);
2807
+ }
2808
+ }
2809
+ function rowGroups(settings) {
2810
+ switch (settings.kind) {
2811
+ case "plain":
2812
+ case "set-by-look": return [];
2813
+ case "rows": return settings.entries.flatMap((entry) => entry.kind === "group" ? [entry.group] : []);
2814
+ default: return assertNever(settings);
2815
+ }
2816
+ }
2817
+ function blockViewParts(layout) {
2818
+ const content = contentAroundRows(layout.content, layout.settings);
2819
+ return [
2820
+ {
2821
+ kind: "look",
2822
+ fields: layout.look
2823
+ },
2824
+ {
2825
+ kind: "content",
2826
+ fields: content.before
2827
+ },
2828
+ ...settingsParts(layout.settings),
2829
+ ...fieldsPart(content.after),
2830
+ ...layout.styles.length > 0 ? [{
2831
+ kind: "styles",
2832
+ fields: layout.styles
2833
+ }] : []
2834
+ ];
2835
+ }
2836
+ function fieldsPart(fields) {
2837
+ return fields.length > 0 ? [{
2838
+ kind: "fields",
2839
+ fields
2840
+ }] : [];
2841
+ }
2842
+ /** The content either side of the rows: all of it before them, unless they sit above the block's list. */
2843
+ function contentAroundRows(content, settings) {
2844
+ const above = settings.kind === "rows" && settings.position.kind === "before-content-field" ? settings.position.path : null;
2845
+ const at = above === null ? -1 : content.findIndex((item) => item.path === above);
2846
+ return at < 0 ? {
2847
+ before: content,
2848
+ after: []
2849
+ } : {
2850
+ before: content.slice(0, at),
2851
+ after: content.slice(at)
2852
+ };
2853
+ }
2854
+ function settingsParts(settings) {
2855
+ switch (settings.kind) {
2856
+ case "plain": return fieldsPart(settings.fields);
2857
+ case "set-by-look": return [{ kind: "set-by-look" }];
2858
+ case "rows": return settings.entries.reduce(withEntry, []);
2859
+ default: return assertNever(settings);
2860
+ }
2861
+ }
2862
+ /** Neighbouring groups share one list of rows; a setting between them is drawn in place, where it was declared. */
2863
+ function withEntry(parts, entry) {
2864
+ const last = parts.at(-1);
2865
+ switch (entry.kind) {
2866
+ case "group": return last?.kind === "rows" ? [...parts.slice(0, -1), {
2867
+ kind: "rows",
2868
+ groups: [...last.groups, entry.group]
2869
+ }] : [...parts, {
2870
+ kind: "rows",
2871
+ groups: [entry.group]
2872
+ }];
2873
+ case "field": return last?.kind === "fields" ? [...parts.slice(0, -1), {
2874
+ kind: "fields",
2875
+ fields: [...last.fields, entry.field]
2876
+ }] : [...parts, {
2877
+ kind: "fields",
2878
+ fields: [entry.field]
2879
+ }];
2880
+ default: return assertNever(entry);
2881
+ }
2882
+ }
2883
+ /** Every field the form places, in any view: the Look, the content, the settings and the style groups. */
2884
+ function placedFields(layout) {
2885
+ const { look, content, settings, styles } = layout;
2886
+ return [
2887
+ ...look,
2888
+ ...content,
2889
+ ...ownViewSettings(settings),
2890
+ ...rowGroups(settings).flatMap((group) => group.fields),
2891
+ ...styles
2892
+ ];
2893
+ }
2894
+ //#endregion
2895
+ //#region ../block-form/src/editing/fieldSections.ts
2896
+ /** The four sections, always in this order. */
2897
+ const blockFieldSectionOrder = [
2898
+ "look",
2899
+ "whatItShows",
2900
+ "text",
2901
+ "moreSettings"
2902
+ ];
2903
+ /** A manifest's own Look field, or its named layouts standing in for Looks, become tiles in the Look section. */
2904
+ function manifestFieldSectionOptions(manifest, options = {}) {
2905
+ const layoutField = !manifest.lookField && manifest.variantMeaning.kind === "arrangement" ? "variant" : void 0;
2906
+ return {
2907
+ ...options,
2908
+ lookField: manifest.lookField,
2909
+ layoutField,
2910
+ lookOwnedPaths: manifest.lookField ? [] : [...options.lookOwnedPaths ?? [], ...layoutField ? [layoutField] : []]
2911
+ };
2912
+ }
2913
+ function hasSatisfyingDefault(field) {
2914
+ const value = field.defaultValue;
2915
+ if (typeof value === "boolean") return true;
2916
+ if (typeof value === "number") return Number.isFinite(value);
2917
+ if (typeof value === "string") return value.trim().length > 0;
2918
+ if (Array.isArray(value)) return value.length > 0;
2919
+ return Boolean(value && typeof value === "object" && Object.keys(value).length > 0);
2920
+ }
2921
+ function isAutomaticallyPromotable(field) {
2922
+ const intent = getFieldIntent(field);
2923
+ return field.required === true && !hasSatisfyingDefault(field) && !isHiddenField(field) && !isHeaderField(field) && (intent === "display" || intent === "behavior");
2924
+ }
2925
+ function sectionFor(item, promoted, look) {
2926
+ if (look.has(item.path)) return "look";
2927
+ if (promoted.has(item.path)) return "whatItShows";
2928
+ return getFieldIntent(item.field) === "content" ? "text" : "moreSettings";
2929
+ }
2930
+ /** The one allocation rule. Callers supply the prepared fields and effective visibility values. */
2931
+ function allocateFieldSections(suppliedFields, reader, options = {}) {
2932
+ const { getValue } = reader;
2933
+ const fields = prunePromotedFields(suppliedFields, new Set(options.excludedFieldIds ?? []));
2934
+ const look = lookPathsFor(options);
2935
+ const requested = [...fields.filter(isAutomaticallyPromotable).map((field) => field.id), ...look];
2936
+ const lifted = (options.liftedPaths ?? []).filter((path) => !fields.some((field) => field.id === path));
2937
+ const shortcuts = resolvePromotedFields(fields, [...requested, ...lifted], getValue).filter((item) => !isHiddenField(item.field) && evaluateVisibility(item.field, reader, item.path) && item.ancestors.every((ancestor) => conditionAllows(ancestor.field, ancestor.path, reader)));
2938
+ const drawnOut = new Set(shortcuts.map((item) => item.path));
2939
+ const promotedPaths = new Set(requested.filter((path) => drawnOut.has(path)));
2940
+ const ordinary = prunePromotedFields(fields, drawnOut).filter((field) => !isHiddenField(field) && !isHeaderField(field)).filter((field) => evaluateVisibility(field, reader, field.id)).map((field) => ({
2941
+ field,
2942
+ path: field.id,
2943
+ tabSelections: [],
2944
+ ancestors: []
2945
+ }));
2946
+ const items = [...disjointPromotions(shortcuts, drawnOut), ...ordinary].map((item) => ({
2947
+ ...item,
2948
+ field: decidedVisibility(item.field)
2949
+ }));
2950
+ return {
2951
+ sections: blockFieldSectionOrder.map((section) => ({
2952
+ section,
2953
+ fields: items.filter((item) => sectionFor(item, promotedPaths, look) === section)
2954
+ })),
2955
+ tilePaths: new Set([options.lookField, options.layoutField].filter((path) => path !== void 0))
2956
+ };
2957
+ }
2958
+ /** An SDK site can turn off a section option (a background colour, say); its shortcut goes with it. */
2959
+ function withSdkSectionOptions(allocated, sdk) {
2960
+ return {
2961
+ ...allocated,
2962
+ sections: allocated.sections.map((entry) => ({
2963
+ ...entry,
2964
+ fields: entry.fields.filter((item) => isSdkSectionOptionEnabled(item.sdkSectionOption, sdk.isSdkSite, sdk.sectionOptions))
2965
+ }))
2966
+ };
2967
+ }
2968
+ /** The section whose field draws this path, with the steps to it inside that field. */
2969
+ function destinationIn(sections, fieldPath, context) {
2970
+ for (const { section, fields } of sections) {
2971
+ const reveal = revealStepsAmong(fields, fieldPath, context);
2972
+ if (reveal) return section === "look" ? {
2973
+ kind: "look",
2974
+ reveal
2975
+ } : {
2976
+ kind: "section",
2977
+ section,
2978
+ reveal
2979
+ };
2980
+ }
2981
+ return { kind: "unavailable" };
2982
+ }
2983
+ /**
2984
+ * The layout of a manifest form outside the block editors (ManifestForm):
2985
+ * the same allocation rule, with no block preparation or page design.
2986
+ */
2987
+ function layoutManifestForm(input) {
2988
+ const allocated = withSdkSectionOptions(allocateFieldSections(input.fields, {
2989
+ getValue: (path) => input.getValue(path) ?? input.fields.find((field) => field.id === path)?.defaultValue,
2990
+ siteFacts: input.siteFacts,
2991
+ block: input.block
2992
+ }, input.options), input.sdk);
2993
+ const context = {
2994
+ getValue: input.getValue,
2995
+ siteFacts: input.siteFacts,
2996
+ block: input.block,
2997
+ sdk: input.sdk
2998
+ };
2999
+ return {
3000
+ ...allocated,
3001
+ destinationOf: (fieldPath) => destinationIn(allocated.sections, fieldPath, context)
3002
+ };
3003
+ }
3004
+ /**
3005
+ * A container's condition goes with a field drawn out of it. Its `hidden`
3006
+ * flag doesn't: a shortcut is how a hidden style group's photo, or a
3007
+ * header-drawn group's field, reaches the form on purpose.
3008
+ */
3009
+ function conditionAllows(container, path, reader) {
3010
+ if (!container.ui || !("visibleWhen" in container.ui)) return true;
3011
+ return evaluateVisibility({
3012
+ ...container,
3013
+ ui: {
3014
+ ...container.ui,
3015
+ hidden: false
3016
+ }
3017
+ }, reader, path);
3018
+ }
3019
+ function lookPathsFor(options) {
3020
+ return /* @__PURE__ */ new Set([...options.lookOwnedPaths ?? [], ...options.lookField ? [options.lookField] : []]);
3021
+ }
3022
+ function disjointPromotions(items, promotedPaths) {
3023
+ return items.flatMap((item) => {
3024
+ const descendants = new Set([...promotedPaths].filter((path) => path.startsWith(`${item.path}.`)).map(toFieldConfigPath));
3025
+ const parentPath = item.path.split(".").slice(0, -1).join(".");
3026
+ const field = prunePromotedField(item.field, descendants, parentPath);
3027
+ return field ? [{
3028
+ ...item,
3029
+ field
3030
+ }] : [];
3031
+ });
3032
+ }
3033
+ function prunePromotedField(field, promotedSchemaPaths, parentPath) {
3034
+ const path = parentPath ? `${parentPath}.${field.id}` : field.id;
3035
+ if (promotedSchemaPaths.has(path)) return null;
3036
+ const container = pruneContainerField(field, promotedSchemaPaths, path);
3037
+ if (container.handled) return container.field;
3038
+ if (field.type === "repeater" && !field.polymorphic) {
3039
+ const fields = prunePromotedFieldsAtPath(field.fields ?? [], promotedSchemaPaths, path);
3040
+ return fields.length > 0 ? {
3041
+ ...field,
3042
+ fields
3043
+ } : null;
3044
+ }
3045
+ if (field.type === "repeater" && field.polymorphic && field.itemTypes) return prunePolymorphicRepeater(field, promotedSchemaPaths, path);
3046
+ if (field.type === "tabGroup") {
3047
+ const tabs = field.tabs.flatMap((tab) => {
3048
+ const fields = prunePromotedFieldsAtPath(tab.fields, promotedSchemaPaths, path);
3049
+ return fields.length > 0 ? [{
3050
+ ...tab,
3051
+ fields
3052
+ }] : [];
3053
+ });
3054
+ return tabs.length > 0 ? {
3055
+ ...field,
3056
+ tabs
3057
+ } : null;
3058
+ }
3059
+ return field;
3060
+ }
3061
+ function pruneContainerField(field, promotedPaths, path) {
3062
+ if (field.type === "group") {
3063
+ const fields = prunePromotedFieldsAtPath(field.fields, promotedPaths, path);
3064
+ return {
3065
+ handled: true,
3066
+ field: fields.length > 0 ? {
3067
+ ...field,
3068
+ fields
3069
+ } : null
3070
+ };
3071
+ }
3072
+ if (field.type === "modal") {
3073
+ const fields = prunePromotedFieldsAtPath(field.schema.fields, promotedPaths, path);
3074
+ return {
3075
+ handled: true,
3076
+ field: fields.length > 0 ? {
3077
+ ...field,
3078
+ schema: {
3079
+ ...field.schema,
3080
+ fields
3081
+ }
3082
+ } : null
3083
+ };
3084
+ }
3085
+ return { handled: false };
3086
+ }
3087
+ function prunePolymorphicRepeater(field, promotedPaths, path) {
3088
+ if (!field.itemTypes) return field;
3089
+ const itemTypes = Object.fromEntries(Object.entries(field.itemTypes).flatMap(([key, item]) => {
3090
+ const fields = prunePromotedFieldsAtPath(item.fields ?? [], promotedPaths, path);
3091
+ return fields.length > 0 ? [[key, {
3092
+ ...item,
3093
+ fields
3094
+ }]] : [];
3095
+ }));
3096
+ return Object.keys(itemTypes).length > 0 ? {
3097
+ ...field,
3098
+ itemTypes
3099
+ } : null;
3100
+ }
3101
+ function prunePromotedFieldsAtPath(fields, promotedSchemaPaths, parentPath) {
3102
+ return fields.flatMap((field) => {
3103
+ const pruned = prunePromotedField(field, promotedSchemaPaths, parentPath);
3104
+ return pruned ? [pruned] : [];
3105
+ });
3106
+ }
3107
+ function toFieldConfigPath(path) {
3108
+ return path.split(".").filter((segment) => !/^\d+$/u.test(segment)).join(".");
3109
+ }
3110
+ function prunePromotedFields(fields, promotedPaths, parentPath = "") {
3111
+ return prunePromotedFieldsAtPath(fields, new Set([...promotedPaths].map(toFieldConfigPath)), parentPath);
3112
+ }
3113
+ function decidedVisibility(field) {
3114
+ if (!field.ui || !("visibleWhen" in field.ui)) return field;
3115
+ const { visibleWhen: _condition, ...ui } = field.ui;
3116
+ return {
3117
+ ...field,
3118
+ ui
3119
+ };
3120
+ }
3121
+ //#endregion
3122
+ //#region ../block-form/src/editing/pageDesignContext.ts
3123
+ /**
3124
+ * Fields kept out of the block form on a newer style: the arrangement and its
3125
+ * knobs, which the Look section edits, and, once a Look resolves, the
3126
+ * presentation it owns. The field ownership decision says which those are.
3127
+ */
3128
+ function arrangementOwnedFieldIds(block) {
3129
+ if (!block?.arrangementLookSelection) return [];
3130
+ const manifest = getBlockDefinition(block.blockKind)?.manifest;
3131
+ if (!manifest) return [];
3132
+ const ownership = resolveFieldOwnership({
3133
+ blockKind: block.blockKind,
3134
+ manifest,
3135
+ arrangementLook: true
3136
+ });
3137
+ const owners = arrangementVisibilityValues(block) ? [
3138
+ "knob",
3139
+ "arrangement",
3140
+ "look"
3141
+ ] : ["knob", "arrangement"];
3142
+ const modeField = manifest.variantMeaning?.kind === "mode" ? ["variant"] : [];
3143
+ return [...fieldPathsOwnedBy(ownership, owners), ...modeField];
3144
+ }
3145
+ /** Content fields the block's current Look leaves out; the form keeps them, with a note. */
3146
+ function lookNotShownFieldIds(block) {
3147
+ const arrangement = arrangementVisibilityValues(block)?.arrangement ?? null;
3148
+ return block ? fieldsNotShownIn(block.blockKind, arrangement) : [];
3149
+ }
3150
+ function arrangementLookResolution(block) {
3151
+ const selection = block.arrangementLookSelection;
3152
+ return selection ? {
3153
+ ...resolveEditorArrangementLook(selection, arrangementBlockMode(block), block.look.kind === "user-pinned" ? block.look.value : null),
3154
+ skin: selection.style.skin
3155
+ } : null;
3156
+ }
3157
+ function arrangementBlockMode(block) {
3158
+ const meaning = getBlockDefinition(block.blockKind)?.manifest.variantMeaning;
3159
+ return meaning?.kind === "mode" ? readStoredMode({
3160
+ keys: [],
3161
+ defaultKey: null,
3162
+ variantMeaning: meaning
3163
+ }, { variant: block.layoutChoice.effectiveValue }) : null;
3164
+ }
3165
+ function arrangementVisibilityValues(block) {
3166
+ if (!block) return null;
3167
+ const resolved = arrangementLookResolution(block);
3168
+ if (!resolved || resolved.kind === "none" || resolved.kind === "recipe") return null;
3169
+ const meaning = getBlockDefinition(block.blockKind)?.manifest.variantMeaning;
3170
+ const arrangementField = meaning?.kind === "mode" ? meaning.arrangementField : "variant";
3171
+ const arrangement = resolved.look.structure.byMode[arrangementBlockMode(block) ?? "default"];
3172
+ return arrangement ? {
3173
+ lookId: resolved.look.id,
3174
+ arrangementField,
3175
+ arrangement,
3176
+ mediaLook: editorMediaLook(block, resolved.look, resolved.skin)
3177
+ } : null;
3178
+ }
3179
+ /** Keep the style's knob restrictions with the Look until live field values are available. */
3180
+ function editorMediaLook(block, look, skin) {
3181
+ const offer = block.arrangementLookSelection?.style.offers.find((entry) => entry.id === look.id);
3182
+ return {
3183
+ look,
3184
+ skin,
3185
+ removeKnobs: offer?.removeKnobs ?? [],
3186
+ addKnobs: offer?.addKnobs ?? [],
3187
+ knobValues: offer?.knobValues ?? {}
3188
+ };
3189
+ }
3190
+ /** Legacy Look knobs keep their ordinary manifest fields in Look, without a second widget inventory. */
3191
+ function blockLookOwnedFieldPaths(block) {
3192
+ if (!block || block.arrangementLookSelection) return [];
3193
+ return systemCustomizeFacetDefinitionsForBlock(block.blockKind).filter((facet) => systemCustomizeFacetAppliesToLayoutVariant(facet, block.layoutChoice.effectiveValue ?? null)).map((facet) => facet.target.kind === "content-field" ? facet.target.field : "listLayout");
3194
+ }
3195
+ //#endregion
3196
+ //#region ../block-form/src/editing/colourFieldVisibility.ts
1807
3197
  /** Only changes form presentation; the validation manifest and saved data stay intact. */
1808
3198
  function hideUnavailableColourFields(manifest, options) {
1809
3199
  if (options.colour && options.gradient) return manifest;
1810
- const hiddenPaths = [];
1811
- const visit = (fields, parent) => fields.flatMap((field) => {
1812
- const path = parent ? `${parent}.${field.id}` : field.id;
3200
+ const visit = (fields) => fields.flatMap((field) => {
1813
3201
  const widget = field.ui?.widget;
1814
- if (widget === "backgroundColor" && !options.colour || widget === "backgroundGradient" && !options.gradient) {
1815
- hiddenPaths.push(path);
1816
- return [];
1817
- }
3202
+ if (widget === "backgroundColor" && !options.colour || widget === "backgroundGradient" && !options.gradient) return [];
1818
3203
  if (field.type === "group" || field.type === "modal") {
1819
- const children = visit(field.schema.fields, path);
1820
- if (!children.length) {
1821
- hiddenPaths.push(path);
1822
- return [];
1823
- }
3204
+ const children = visit(field.schema.fields);
3205
+ if (!children.length) return [];
1824
3206
  return [{
1825
3207
  ...field,
1826
3208
  schema: {
@@ -1833,26 +3215,23 @@ function hideUnavailableColourFields(manifest, options) {
1833
3215
  ...field,
1834
3216
  ...field.schema ? { schema: {
1835
3217
  ...field.schema,
1836
- fields: visit(field.schema.fields, path)
3218
+ fields: visit(field.schema.fields)
1837
3219
  } } : {},
1838
3220
  ...field.itemTypes ? { itemTypes: Object.fromEntries(Object.entries(field.itemTypes).map(([id, item]) => [id, {
1839
3221
  ...item,
1840
- fields: visit(item.fields, path)
3222
+ fields: visit(item.fields)
1841
3223
  }])) } : {}
1842
3224
  }];
1843
3225
  if (field.type === "tabGroup") {
1844
3226
  const tabs = field.tabs.flatMap((tab) => {
1845
- const children = visit(tab.fields, path);
3227
+ const children = visit(tab.fields);
1846
3228
  const unavailableTab = tab.sdkSectionOption === "backgroundColor" && !options.colour || tab.sdkSectionOption === "backgroundGradient" && !options.gradient;
1847
3229
  return children.length && !unavailableTab ? [{
1848
3230
  ...tab,
1849
3231
  fields: children
1850
3232
  }] : [];
1851
3233
  });
1852
- if (!tabs.length) {
1853
- hiddenPaths.push(path);
1854
- return [];
1855
- }
3234
+ if (!tabs.length) return [];
1856
3235
  return [{
1857
3236
  ...field,
1858
3237
  tabs
@@ -1860,24 +3239,16 @@ function hideUnavailableColourFields(manifest, options) {
1860
3239
  }
1861
3240
  return [field];
1862
3241
  });
1863
- const fields = visit(manifest.fields, "");
1864
3242
  return {
1865
3243
  ...manifest,
1866
- fields,
1867
- promotedFields: manifest.promotedFields?.filter((path) => !hiddenPaths.some((hidden) => path === hidden || path.startsWith(`${hidden}.`)))
3244
+ fields: visit(manifest.fields)
1868
3245
  };
1869
3246
  }
1870
3247
  //#endregion
1871
- //#region ../editor-blocks/src/block-editor/settingsIntent.ts
3248
+ //#region ../block-form/src/editing/rawStyleFields.ts
1872
3249
  function isThemeV2NormalEditorRawStyleField(field) {
1873
3250
  return isThemeV2NormalEditorRawStyleFieldName(field.id);
1874
3251
  }
1875
- function filterThemeV2NormalEditorRawPromotedFields(promotedFields, allowedFieldPaths = void 0) {
1876
- if (!promotedFields) return void 0;
1877
- const allowedFieldPathSet = new Set(allowedFieldPaths ?? []);
1878
- const filtered = promotedFields.filter((fieldPath) => !isThemeV2NormalEditorRawStylePath(fieldPath) || allowedFieldPathSet.has(fieldPath));
1879
- return filtered.length > 0 ? filtered : void 0;
1880
- }
1881
3252
  function hideThemeV2NormalEditorRawStyleFieldsInRenderFields(fields) {
1882
3253
  return fields.map((field) => {
1883
3254
  if (!isThemeV2NormalEditorRawStyleField(field)) return field;
@@ -1891,31 +3262,44 @@ function hideThemeV2NormalEditorRawStyleFieldsInRenderFields(fields) {
1891
3262
  });
1892
3263
  }
1893
3264
  //#endregion
1894
- //#region ../editor-blocks/src/block-editor/preparedManifest.ts
1895
- const showRawStyleFields = { kind: "show-raw-style-fields" };
1896
- const hideThemeV2RawStyleFields = { kind: "hide-theme-v2-raw-style-fields" };
1897
- const EDITOR_OWNED_FEATURE_CARD_FIELD_IDS = /* @__PURE__ */ new Set(["_generatedIconSizePx"]);
1898
- function hideEditorOwnedFields(manifest, blockKind) {
1899
- if (blockKind !== "block.feature-cards") return manifest;
3265
+ //#region ../block-form/src/editing/preparedManifest.ts
3266
+ /** A host with nothing but the form: every field the block offers is in it. */
3267
+ const FORM_ONLY_HOST = { featureCardIconSize: false };
3268
+ /** The fields a host's own commands edit, for this block. The plan is the only place that decides it. */
3269
+ function hostEditedFieldIds(blockKind, commands) {
3270
+ return blockKind === "block.feature-cards" && commands.featureCardIconSize ? ["_generatedIconSizePx"] : [];
3271
+ }
3272
+ function hideHostEditedFields(manifest, fieldIds) {
3273
+ if (fieldIds.length === 0) return manifest;
1900
3274
  return {
1901
3275
  ...manifest,
1902
- fields: manifest.fields?.map((field) => EDITOR_OWNED_FEATURE_CARD_FIELD_IDS.has(field.id) ? {
3276
+ fields: manifest.fields?.map((field) => fieldIds.includes(field.id) ? {
1903
3277
  ...field,
1904
3278
  ui: {
1905
3279
  ...field.ui ?? {},
1906
3280
  hidden: true
1907
3281
  }
1908
- } : field),
1909
- promotedFields: manifest.promotedFields?.filter((fieldPath) => !EDITOR_OWNED_FEATURE_CARD_FIELD_IDS.has(fieldPath))
3282
+ } : field)
3283
+ };
3284
+ }
3285
+ /** The SDK merge and the theme's style groups: what validation checks a block's content against. */
3286
+ function mergedAndValidationManifests(input) {
3287
+ const merged = mergeManifestWithSdkOptions(input.manifest, input.blockKind, input.blockFieldOptions, input.blockFieldExtensions);
3288
+ return {
3289
+ merged,
3290
+ validation: augmentManifestWithStyleGroups(merged, input.theme?.styleGroups, input.blockKind)
1910
3291
  };
1911
3292
  }
3293
+ /** The manifest a block's content is validated against, for hosts that only validate. */
3294
+ function deriveBlockValidationManifest(input) {
3295
+ return mergedAndValidationManifests(input).validation;
3296
+ }
1912
3297
  function prepareBlockEditorManifest(input) {
1913
- const mergedManifest = mergeManifestWithSdkOptions(input.manifest, input.blockKind, input.blockFieldOptions, input.blockFieldExtensions);
1914
- const validationManifest = augmentManifestWithStyleGroups(mergedManifest, input.theme?.styleGroups, input.blockKind);
3298
+ const { merged: mergedManifest, validation: validationManifest } = mergedAndValidationManifests(input);
1915
3299
  const renderManifest = editorRenderManifest(input, mergedManifest, validationManifest);
1916
3300
  return {
1917
3301
  validationManifest,
1918
- renderManifest: noteFieldsNotShown(hideCalendarGroupingField(hideEditorOwnedFields(input.colourFieldOptions ? hideUnavailableColourFields(renderManifest, input.colourFieldOptions) : renderManifest, input.blockKind), input.theme?.siteStyleId), input.notShownFieldIds ?? [])
3302
+ renderManifest: noteFieldsNotShown(hideHostEditedFields(input.colourFieldOptions ? hideUnavailableColourFields(renderManifest, input.colourFieldOptions) : renderManifest, hostEditedFieldIds(input.blockKind, input.hostCommands)), input.notShownFieldIds ?? [])
1919
3303
  };
1920
3304
  }
1921
3305
  const lookNotShownNote = "Not shown in this Look.";
@@ -1930,108 +3314,296 @@ function noteFieldsNotShown(manifest, fieldIds) {
1930
3314
  } : field)
1931
3315
  };
1932
3316
  }
1933
- /** Preserve validation/stored intent while limiting weekly presentation, and its unpaged list, to arrangement styles. */
1934
- function hideCalendarGroupingField(manifest, siteStyleId) {
1935
- if (manifest.name !== "block.event-calendar") return manifest;
1936
- if (eventCalendarListGroupingDecision({
1937
- arrangementLooks: (siteStyleId ? getCuratedSiteStyle(asSiteStyleId(siteStyleId)) : void 0)?.looks.kind === "offers",
1938
- variant: "list"
1939
- }).available) return manifest;
1940
- const upcomingPaging = new Map(eventCalendarPagingFields(false).map((field) => [field.id, field]));
1941
- return {
1942
- ...manifest,
1943
- fields: manifest.fields.map((field) => field.id === "listBy" ? {
1944
- ...field,
1945
- ui: {
1946
- ...field.ui,
1947
- hidden: true
1948
- }
1949
- } : upcomingPaging.get(field.id) ?? field),
1950
- promotedFields: manifest.promotedFields?.filter((path) => path !== "listBy")
1951
- };
1952
- }
1953
3317
  /** Form presentation uses the merged manifest; synthetic style groups remain validation-only. */
1954
3318
  function editorRenderManifest(input, merged, validation) {
1955
- if (input.visibilityPolicy.kind !== "hide-theme-v2-raw-style-fields") return validation;
3319
+ if (input.rawStyleFields !== "hide-theme-v2") return validation;
1956
3320
  return {
1957
3321
  ...merged,
1958
- fields: hideThemeV2NormalEditorRawStyleFieldsInRenderFields(merged.fields),
1959
- promotedFields: filterThemeV2NormalEditorRawPromotedFields(merged.promotedFields, input.allowedPromotedFieldPaths)
3322
+ fields: hideThemeV2NormalEditorRawStyleFieldsInRenderFields(merged.fields)
1960
3323
  };
1961
3324
  }
1962
3325
  //#endregion
1963
- //#region ../editor-blocks/src/block-editor/blockFieldSectionContext.ts
3326
+ //#region ../block-form/src/editing/blockEditingPlan.ts
3327
+ /** Not exported: only this module can make a plan. */
3328
+ const ownedPlan = Symbol("BlockEditingPlan");
1964
3329
  /**
1965
- * Fields kept out of the block form on a newer style: the arrangement and its
1966
- * knobs, which the Look section edits, and, once a Look resolves, the
1967
- * presentation it owns. The field ownership decision says which those are.
3330
+ * The single owner of where a block's fields go, in every editor. It takes
3331
+ * the block's manifest as registered and its current draft values, and does
3332
+ * all the preparation: SDK options and extensions, style groups, raw style
3333
+ * fields, colour options, the section photo, notes for content the Look
3334
+ * leaves out, whether a Look shapes the block, and what the Look owns. Then
3335
+ * it places what's left by the block's `editing` declaration.
1968
3336
  */
1969
- function arrangementOwnedFieldIds(block) {
1970
- if (!block?.arrangementLookSelection) return [];
1971
- const manifest = getBlockDefinition(block.blockKind)?.manifest;
1972
- if (!manifest) return [];
1973
- const ownership = resolveFieldOwnership({
1974
- blockKind: block.blockKind,
3337
+ function deriveBlockEditingPlan(input) {
3338
+ const { context } = input;
3339
+ const photo = sectionPhotoFor(input.manifest, input.values, context);
3340
+ const prepared = prepareForContext(input.manifest, context);
3341
+ const fields = createManifestFormAdapter(prepared.renderManifest, { role: context.role }).fields;
3342
+ const visibilityValues = arrangementVisibilityValues(context.pageDesignBlock);
3343
+ const block = {
3344
+ look: blockLookFact(context, visibilityValues, input.values),
3345
+ template: context.pageTemplate,
3346
+ observations: context.observations
3347
+ };
3348
+ const shownValues = shownValueReader(input.values, visibilityValues, context.siteFacts, block);
3349
+ const effectiveValue = (path) => shownValues.getValue(path) ?? fields.find((field) => field.id === path)?.defaultValue;
3350
+ const editing = prepared.renderManifest.editing;
3351
+ const offered = withSectionPhotoCopy(withSdkSectionOptions(allocateFieldSections(fields, {
3352
+ getValue: effectiveValue,
3353
+ siteFacts: context.siteFacts,
3354
+ block
3355
+ }, manifestFieldSectionOptions(prepared.renderManifest, {
3356
+ excludedFieldIds: arrangementOwnedFieldIds(context.pageDesignBlock),
3357
+ lookOwnedPaths: blockLookOwnedFieldPaths(context.pageDesignBlock),
3358
+ liftedPaths: editing ? placedEditingPaths(editing).filter((path) => path !== "_sectionStyles.background.image" || photo.offered) : []
3359
+ })), context.sdk), photo);
3360
+ const lookSource = lookSourceOf(prepared.renderManifest, offered.sections);
3361
+ const lookInForm = context.lookFields === "in-form" || lookSource.kind === "sdk";
3362
+ const nested = {
3363
+ getValue: shownValues.getValue,
3364
+ siteFacts: context.siteFacts,
3365
+ block,
3366
+ sdk: context.sdk
3367
+ };
3368
+ const placed = layoutBlockEditing({
3369
+ sections: offered.sections,
3370
+ editing,
3371
+ fields,
3372
+ getValue: effectiveValue,
3373
+ chosenLabel: context.chosenLabel,
3374
+ nested,
3375
+ lookOwnsFields: lookSource.kind === "built-in" && lookOwnsFields(context.pageDesignBlock)
3376
+ });
3377
+ const layout = lookInForm ? placed.layout : {
3378
+ ...placed.layout,
3379
+ look: []
3380
+ };
3381
+ return {
3382
+ [ownedPlan]: true,
3383
+ blockKind: context.blockKind,
3384
+ layout,
3385
+ viewParts: blockViewParts(layout),
3386
+ destinationOf: (fieldPath) => destinationWith(placed.layout, fieldPath, lookInForm, nested),
3387
+ issues: [...declarationIssues(input.manifest, context), ...placed.unphrased.map(unphrasedIssue)],
3388
+ tilePaths: offered.tilePaths,
3389
+ visibilityValues,
3390
+ siteFacts: context.siteFacts,
3391
+ block,
3392
+ fields,
3393
+ renderManifest: prepared.renderManifest,
3394
+ validationManifest: prepared.validationManifest,
3395
+ lookSource
3396
+ };
3397
+ }
3398
+ /** Checked against the manifest as registered with the site's SDK options and extensions merged in, as the form is. */
3399
+ function declarationIssues(manifest, context) {
3400
+ return blockEditingIssues({
3401
+ blockKind: context.blockKind,
1975
3402
  manifest,
1976
- arrangementLook: true
3403
+ sdkBlockFieldOptions: context.sdk.blockFieldOptions,
3404
+ sdkBlockFieldExtensions: context.sdk.blockFieldExtensions
1977
3405
  });
1978
- const owners = arrangementVisibilityValues(block) ? [
1979
- "knob",
1980
- "arrangement",
1981
- "look"
1982
- ] : ["knob", "arrangement"];
1983
- const modeField = manifest.variantMeaning?.kind === "mode" ? ["variant"] : [];
1984
- return [...fieldPathsOwnedBy(ownership, owners), ...modeField];
1985
3406
  }
1986
- /** Content fields the block's current Look leaves out; the form keeps them, with a note. */
1987
- function lookNotShownFieldIds(block) {
1988
- const arrangement = arrangementVisibilityValues(block)?.arrangement ?? null;
1989
- return block ? fieldsNotShownIn(block.blockKind, arrangement) : [];
3407
+ function unphrasedIssue(value) {
3408
+ return {
3409
+ kind: "value-without-phrase",
3410
+ ...value
3411
+ };
1990
3412
  }
1991
- function arrangementLookResolution(block) {
1992
- const selection = block.arrangementLookSelection;
1993
- return selection ? {
1994
- ...resolveEditorArrangementLook(selection, arrangementBlockMode(block), block.look.kind === "user-pinned" ? block.look.value : null),
1995
- skin: selection.style.skin
1996
- } : null;
3413
+ const BLOCK_VIEW = { kind: "block" };
3414
+ /**
3415
+ * What a host shows for the view it has open. When the open group is no
3416
+ * longer in the plan (a choice or an Undo hid its last field, or the settings
3417
+ * now show plainly), it falls back to the block's own view.
3418
+ */
3419
+ function resolveOpenView(plan, openView) {
3420
+ if (openView.kind === "block") return BLOCK_VIEW;
3421
+ const group = rowGroups(plan.layout.settings).find((entry) => entry.id === openView.groupId);
3422
+ return group ? {
3423
+ kind: "group",
3424
+ group
3425
+ } : BLOCK_VIEW;
1997
3426
  }
1998
- function arrangementBlockMode(block) {
1999
- const meaning = getBlockDefinition(block.blockKind)?.manifest.variantMeaning;
2000
- return meaning?.kind === "mode" ? readStoredMode({
2001
- keys: [],
2002
- defaultKey: null,
2003
- variantMeaning: meaning
2004
- }, { variant: block.layoutChoice.effectiveValue }) : null;
3427
+ /** The person closed the open group's view: back to the block's own, with focus owed to that group's row. */
3428
+ function closeGroupView(openView) {
3429
+ return openView.kind === "group" ? {
3430
+ kind: "block",
3431
+ closedGroupId: openView.groupId
3432
+ } : { kind: "block" };
2005
3433
  }
2006
- function arrangementVisibilityValues(block) {
2007
- if (!block) return null;
2008
- const resolved = arrangementLookResolution(block);
2009
- if (!resolved || resolved.kind === "none" || resolved.kind === "recipe") return null;
2010
- const meaning = getBlockDefinition(block.blockKind)?.manifest.variantMeaning;
2011
- const arrangementField = meaning?.kind === "mode" ? meaning.arrangementField : "variant";
2012
- const arrangement = resolved.look.structure.byMode[arrangementBlockMode(block) ?? "default"];
2013
- return arrangement ? {
2014
- lookId: resolved.look.id,
2015
- arrangementField,
2016
- arrangement,
2017
- mediaLook: editorMediaLook(block, resolved.look, resolved.skin)
2018
- } : null;
3434
+ /**
3435
+ * The view a field's destination is in, for a host asked to focus that field:
3436
+ * a group's own view for a field in a group, the block's own view for its
3437
+ * content, plain settings, styles and Look. A field the form doesn't offer
3438
+ * leaves the open view as it is. Going to the block's view this way isn't
3439
+ * closing a group, so no row is owed focus.
3440
+ */
3441
+ function openViewForDestination(destination, current) {
3442
+ switch (destination.kind) {
3443
+ case "group": return {
3444
+ kind: "group",
3445
+ groupId: destination.groupId
3446
+ };
3447
+ case "content":
3448
+ case "look": return { kind: "block" };
3449
+ case "unavailable": return current;
3450
+ default: return assertNever(destination);
3451
+ }
2019
3452
  }
2020
- /** Keep the style's knob restrictions with the Look until live field values are available. */
2021
- function editorMediaLook(block, look, skin) {
2022
- const offer = block.arrangementLookSelection?.style.offers.find((entry) => entry.id === look.id);
3453
+ /** Whether two states show the same view, however each was reached. */
3454
+ function sameOpenView(left, right) {
3455
+ return left.kind === "group" ? right.kind === "group" && right.groupId === left.groupId : right.kind === "block";
3456
+ }
3457
+ function prepareForContext(manifest, context) {
3458
+ return prepareBlockEditorManifest({
3459
+ manifest,
3460
+ blockKind: context.blockKind,
3461
+ theme: context.theme,
3462
+ colourFieldOptions: context.colourFieldOptions,
3463
+ blockFieldOptions: context.sdk.blockFieldOptions,
3464
+ blockFieldExtensions: context.sdk.blockFieldExtensions,
3465
+ rawStyleFields: context.rawStyleFields,
3466
+ notShownFieldIds: lookNotShownFieldIds(context.pageDesignBlock),
3467
+ hostCommands: context.hostCommands
3468
+ });
3469
+ }
3470
+ function sectionPhotoFor(manifest, values, context) {
3471
+ const declared = manifest.sectionPhoto;
3472
+ if (!declared) return {
3473
+ offered: false,
3474
+ copy: null
3475
+ };
3476
+ if (context.rawStyleFields === "show") return {
3477
+ offered: true,
3478
+ copy: null
3479
+ };
3480
+ if (!context.pageDesignBlock) return {
3481
+ offered: false,
3482
+ copy: null
3483
+ };
3484
+ const decision = decideSectionPhoto({
3485
+ block: context.pageDesignBlock,
3486
+ sectionPhoto: declared,
3487
+ draftPhoto: sectionPhotoPresence(values)
3488
+ });
2023
3489
  return {
2024
- look,
2025
- skin,
2026
- removeKnobs: offer?.removeKnobs ?? [],
2027
- addKnobs: offer?.addKnobs ?? [],
2028
- knobValues: offer?.knobValues ?? {}
3490
+ offered: sectionPhotoFieldShown(decision),
3491
+ copy: decision.kind === "arrangement" ? { hint: sectionPhotoFieldHint(decision) } : null
2029
3492
  };
2030
3493
  }
2031
- /** Legacy Look knobs keep their ordinary manifest fields in Look, without a second widget inventory. */
2032
- function blockLookOwnedFieldPaths(block) {
2033
- if (!block || block.arrangementLookSelection) return [];
2034
- return systemCustomizeFacetDefinitionsForBlock(block.blockKind).filter((facet) => systemCustomizeFacetAppliesToLayoutVariant(facet, block.layoutChoice.effectiveValue ?? null)).map((facet) => facet.target.kind === "content-field" ? facet.target.field : "listLayout");
3494
+ /** On an arrangement Look the section photo is called Photo wherever it's placed, with the Look's line under it. */
3495
+ function withSectionPhotoCopy(allocated, photo) {
3496
+ const copy = photo.copy;
3497
+ if (!copy) return allocated;
3498
+ const relabel = (item) => item.path === "_sectionStyles.background.image" ? {
3499
+ ...item,
3500
+ field: {
3501
+ ...item.field,
3502
+ label: sectionPhotoFieldLabel,
3503
+ ...copy.hint ? { description: copy.hint } : {}
3504
+ }
3505
+ } : item;
3506
+ return {
3507
+ ...allocated,
3508
+ sections: allocated.sections.map((entry) => ({
3509
+ ...entry,
3510
+ fields: entry.fields.map(relabel)
3511
+ }))
3512
+ };
3513
+ }
3514
+ /**
3515
+ * The draft with the Look's effective arrangement over it: what the nested
3516
+ * widgets read for visibility. Placing top-level fields also falls back to
3517
+ * each field's default.
3518
+ */
3519
+ function shownValueReader(values, visibilityValues, siteFacts, block) {
3520
+ return withVisibilityValues({
3521
+ getValue: (path) => getAtPath(values, path),
3522
+ siteFacts,
3523
+ block
3524
+ }, visibilityOverrides(visibilityValues));
3525
+ }
3526
+ /**
3527
+ * Whether a Look shapes the block, and the knob values it draws with, for the
3528
+ * conditions that turn on them. With the block's page design it's whether a
3529
+ * Look resolves for the block, as the page renders it, and its knobs come
3530
+ * from the resolver the renderer uses, over the draft. Without one, a style
3531
+ * that offers no Looks still settles it; otherwise (a block not yet on a
3532
+ * page, a template) it's unknown, and such a condition leaves its field
3533
+ * showing.
3534
+ */
3535
+ function blockLookFact(context, visibilityValues, values) {
3536
+ if (context.pageDesignBlock) {
3537
+ if (!visibilityValues) return {
3538
+ kind: "Loaded",
3539
+ value: { state: "none" }
3540
+ };
3541
+ return {
3542
+ kind: "Loaded",
3543
+ value: {
3544
+ state: "applies",
3545
+ knobs: visibilityValues.mediaLook ? shownKnobValues(context.blockKind, resolveArrangementKnobs({
3546
+ blockKind: context.blockKind,
3547
+ look: visibilityValues.mediaLook,
3548
+ content: values
3549
+ }).knobs) : {}
3550
+ }
3551
+ };
3552
+ }
3553
+ const siteStyleId = context.theme?.siteStyleId;
3554
+ const style = siteStyleId ? getCuratedSiteStyle(asSiteStyleId(siteStyleId)) : void 0;
3555
+ return style && style.looks.kind !== "offers" ? {
3556
+ kind: "Loaded",
3557
+ value: { state: "none" }
3558
+ } : { kind: "Unavailable" };
3559
+ }
3560
+ function visibilityOverrides(visibilityValues) {
3561
+ return visibilityValues ? {
3562
+ blockLook: visibilityValues.lookId,
3563
+ [visibilityValues.arrangementField]: visibilityValues.arrangement
3564
+ } : {};
3565
+ }
3566
+ function lookSourceOf(manifest, sections) {
3567
+ if (!manifest.lookField) return { kind: "built-in" };
3568
+ return {
3569
+ kind: "sdk",
3570
+ item: (sections.find((entry) => entry.section === "look")?.fields ?? []).find((item) => item.path === manifest.lookField) ?? null
3571
+ };
3572
+ }
3573
+ /** Whether the block's Look, or its arrangement, has taken any of the block's fields out of the form. */
3574
+ function lookOwnsFields(block) {
3575
+ return arrangementOwnedFieldIds(block).length + blockLookOwnedFieldPaths(block).length > 0;
3576
+ }
3577
+ /** Destinations come from the placement before a Look edited elsewhere takes its fields, so they don't fall to a parent. */
3578
+ function destinationWith(placed, fieldPath, lookInForm, nested) {
3579
+ const destination = destinationInLayout(placed, fieldPath, nested);
3580
+ return destination.kind === "look" && !lookInForm ? { kind: "unavailable" } : destination;
3581
+ }
3582
+ //#endregion
3583
+ //#region ../block-form/src/editing/chosenFields.ts
3584
+ /**
3585
+ * The fields a block's summaries name the chosen item of, so an editor knows
3586
+ * which names to look up before it derives the plan. Empty for a block whose
3587
+ * lines name nothing.
3588
+ */
3589
+ function chosenSummaryFields(manifest) {
3590
+ const paths = manifest.editing ? editingGroups(manifest.editing).flatMap((group) => group.summary.parts.flatMap(chosenPath)) : [];
3591
+ if (paths.length === 0) return [];
3592
+ return resolvePromotedFields(createManifestFormAdapter(manifest).fields, [...paths], () => void 0).map(({ path, field }) => ({
3593
+ path,
3594
+ field
3595
+ }));
3596
+ }
3597
+ function chosenPath(part) {
3598
+ const none = () => [];
3599
+ return matchSummaryPart(part, {
3600
+ on: none,
3601
+ options: none,
3602
+ text: none,
3603
+ set: none,
3604
+ count: none,
3605
+ chosen: ({ field }) => [field]
3606
+ });
2035
3607
  }
2036
3608
  //#endregion
2037
3609
  //#region ../block-form/src/sdk-config/SdkConfigContext.tsx
@@ -2302,7 +3874,7 @@ function createStoreBackend(options) {
2302
3874
  setFocus: (path) => {
2303
3875
  if (scope !== "blocks") return;
2304
3876
  getStoreState().requestFocus?.({
2305
- kind: "main-field",
3877
+ kind: "field",
2306
3878
  blockId: getBlockId(),
2307
3879
  fieldPath: path
2308
3880
  });
@@ -2370,250 +3942,316 @@ function createStoreBackend(options) {
2370
3942
  }), backend.subscribe, (value) => value));
2371
3943
  }
2372
3944
  //#endregion
2373
- //#region ../preview-next/src/client/blocks/arrangementControlsModel.ts
3945
+ //#region ../block-form/src/context/DisplayLabelResolverContext.tsx
3946
+ const DisplayLabelResolverContext = createContext({});
2374
3947
  /**
2375
- * Decides the arrangement-Look controls for one block from the editor read
2376
- * model and the content the editor holds. Null means the block's style uses
2377
- * the legacy catalogue, so the legacy controls apply unchanged.
3948
+ * Access the display label resolver map.
3949
+ * Returns an empty map when no provider is present (resolvers are optional).
2378
3950
  */
2379
- function arrangementBlockControlsFor(input) {
2380
- const selection = input.block.arrangementLookSelection;
2381
- if (!selection) return null;
2382
- const mode = arrangementBlockMode(input.block);
2383
- const pin = pinnedLookId(input.block);
2384
- const offered = offeredLooksForMode(selection, mode);
2385
- const resolved = resolveEditorArrangementLook(selection, mode, pin);
2386
- const effective = resolved.kind === "none" || resolved.kind === "recipe" ? null : resolved.look;
2387
- const knobState = effective ? resolveArrangementKnobs({
2388
- blockKind: input.block.blockKind,
2389
- look: compiledKnobLook(selection.style.offers, effective),
2390
- content: input.content
2391
- }) : null;
2392
- return {
2393
- look: lookPosition(resolved, input.block),
2394
- tiles: lookTilesFor({
2395
- looks: offered,
2396
- defaultLookId: resolvedLookId(resolveEditorArrangementLook(selection, mode, null)),
2397
- shownLookId: effective?.id ?? null
2398
- }),
2399
- mode: modeSwitch(input.block, selection.available, mode),
2400
- knobs: knobState ? knobControls(input.block.blockKind, knobState.exposure, knobState.knobs, input.content, effective?.structure.knobDescriptions) : [],
2401
- headlineHint: knobState ? headlineHint(knobState.knobs, knobState.length) : null
2402
- };
3951
+ function useDisplayLabelResolvers() {
3952
+ return useContext(DisplayLabelResolverContext);
2403
3953
  }
2404
- /** The name of the Look a block shows, for the page outline. Null on a legacy style. */
2405
- function arrangementLookNameFor(block) {
2406
- const selection = block.arrangementLookSelection;
2407
- if (!selection) return null;
2408
- return lookPosition(resolveEditorArrangementLook(selection, arrangementBlockMode(block), pinnedLookId(block)), block)?.lookName ?? null;
3954
+ //#endregion
3955
+ //#region ../editor-blocks/src/block-editor/ColourFieldOptionsProvider.tsx
3956
+ const ColourFieldOptionsContext = createContext(void 0);
3957
+ function useColourFieldOptions() {
3958
+ return useContext(ColourFieldOptionsContext);
3959
+ }
3960
+ //#endregion
3961
+ //#region ../editor-blocks/src/block-editor/useChosenLabels.ts
3962
+ const NO_LABELS = {};
3963
+ function labelKey(path, value) {
3964
+ return `${path}:${JSON.stringify(value) ?? ""}`;
2409
3965
  }
2410
- /** The Look a resolution renders; unpinned, that's the style's own pick. */
2411
- function resolvedLookId(resolved) {
2412
- return resolved.kind === "none" || resolved.kind === "recipe" ? null : resolved.look.id;
3966
+ function hasChoice(value) {
3967
+ return value !== null && value !== void 0 && value !== "" && !(Array.isArray(value) && value.length === 0);
2413
3968
  }
2414
- function pinnedLookId(block) {
2415
- return block.look.kind === "user-pinned" ? block.look.value : null;
3969
+ function siblingPath(path, fieldId) {
3970
+ const parent = path.split(".").slice(0, -1).join(".");
3971
+ return parent ? `${parent}.${fieldId}` : fieldId;
2416
3972
  }
2417
- /** Offer order, as the resolver uses it, for the Looks that support the mode. */
2418
- function offeredLooksForMode(selection, mode) {
2419
- return selection.style.offers.flatMap((offer) => {
2420
- const look = selection.available.find((candidate) => candidate.id === offer.id);
2421
- return look && lookModes(look).includes(mode) ? [look] : [];
3973
+ /**
3974
+ * The names of what a block's picker fields have chosen, for the editing
3975
+ * plan's summary lines ("with Anna"). They come from the editor's existing
3976
+ * display-label resolvers, the ones that name a repeater's rows. A name that
3977
+ * hasn't loaded, or an editor with no resolver for the field, gives null and
3978
+ * the line says the block's own phrase. Null for a block whose lines name
3979
+ * nothing, so its plan isn't rederived when labels load elsewhere.
3980
+ */
3981
+ function useChosenLabels(manifest, values) {
3982
+ const resolvers = useDisplayLabelResolvers();
3983
+ const chosen = useMemo(() => manifest ? chosenSummaryFields(manifest) : [], [manifest]);
3984
+ const [labels, setLabels] = useState(NO_LABELS);
3985
+ const wantedKey = chosen.map(({ path }) => labelKey(path, getAtPath(values, path))).join("|");
3986
+ const latestValues = useRef(values);
3987
+ useEffect(() => {
3988
+ latestValues.current = values;
2422
3989
  });
3990
+ useEffect(() => {
3991
+ const request = { cancelled: false };
3992
+ const current = latestValues.current;
3993
+ const lookUp = ({ path, field }) => {
3994
+ const value = getAtPath(current, path);
3995
+ const resolve = resolvers[field.type];
3996
+ if (!resolve || !hasChoice(value)) return;
3997
+ resolve(value, field, { getSiblingValue: (fieldId) => getAtPath(current, siblingPath(path, fieldId)) }).then((label) => {
3998
+ if (label && !request.cancelled) setLabels((known) => ({
3999
+ ...known,
4000
+ [labelKey(path, value)]: label
4001
+ }));
4002
+ }).catch(() => void 0);
4003
+ };
4004
+ chosen.forEach(lookUp);
4005
+ return () => {
4006
+ request.cancelled = true;
4007
+ };
4008
+ }, [
4009
+ chosen,
4010
+ resolvers,
4011
+ wantedKey
4012
+ ]);
4013
+ return useMemo(() => chosen.length === 0 ? null : (path, value) => labels[labelKey(path, value)] ?? null, [chosen, labels]);
2423
4014
  }
2424
- function compiledKnobLook(offers, look) {
2425
- const offer = offers.find((candidate) => candidate.id === look.id);
4015
+ //#endregion
4016
+ //#region ../editor-blocks/src/block-editor/blockObservations.ts
4017
+ function createBlockLoaderReader(siteId, client) {
2426
4018
  return {
2427
- look,
2428
- addKnobs: offer?.addKnobs ?? [],
2429
- removeKnobs: offer?.removeKnobs ?? [],
2430
- knobValues: offer?.knobValues ?? {}
4019
+ siteId,
4020
+ read: async (request) => {
4021
+ const result = unwrapResponse(await client()({
4022
+ endpoint: "batchBlockLoaders",
4023
+ params: {
4024
+ siteId,
4025
+ stage: "preview"
4026
+ },
4027
+ body: { requests: [request] }
4028
+ })).results[request.id];
4029
+ if (!result?.ok) throw new Error(`Block loader ${request.endpoint} failed`);
4030
+ return result.data;
4031
+ }
2431
4032
  };
2432
4033
  }
2433
- function lookPosition(resolved, block) {
2434
- switch (resolved.kind) {
2435
- case "offered": return resolved.source === "auto" ? {
2436
- kind: "automatic",
2437
- lookName: resolved.look.label
2438
- } : {
2439
- kind: "pinned",
2440
- lookName: resolved.look.label
4034
+ const observationLoaders = { "block.class-prices": {
4035
+ field: "seriesId",
4036
+ load: async (seriesId, reader) => typeof seriesId === "string" && seriesId !== "" ? { "classPrices.items": classPriceItemKinds(await reader.read({
4037
+ id: "observation",
4038
+ endpoint: "getPublicEventDetails",
4039
+ params: {
4040
+ seriesId,
4041
+ limit: "1"
4042
+ }
4043
+ })) } : {}
4044
+ } };
4045
+ /**
4046
+ * What the block's own selection resolves to, for its conditions. Loaded
4047
+ * again whenever the observed field changes; until it has loaded for the
4048
+ * current value, or if the read fails, or outside an editor, every
4049
+ * observation is unknown and the fields it guards stay in the form.
4050
+ */
4051
+ function useBlockObservations(reader, blockKind, values) {
4052
+ const loader = observationLoaders[blockKind];
4053
+ const value = loader ? getAtPath(values, loader.field) : void 0;
4054
+ const key = loader && reader ? `${reader.siteId}:${blockKind}:${JSON.stringify(value) ?? ""}` : null;
4055
+ const [loaded, setLoaded] = useState(null);
4056
+ const latestValue = useRef(value);
4057
+ useEffect(() => {
4058
+ latestValue.current = value;
4059
+ });
4060
+ useEffect(() => {
4061
+ if (!loader || !reader || key === null) return;
4062
+ const request = { cancelled: false };
4063
+ loader.load(latestValue.current, reader).then((found) => {
4064
+ if (!request.cancelled) setLoaded({
4065
+ key,
4066
+ observations: {
4067
+ ...unknownBlockObservations,
4068
+ ...found
4069
+ }
4070
+ });
4071
+ }).catch(() => void 0);
4072
+ return () => {
4073
+ request.cancelled = true;
2441
4074
  };
2442
- case "style-fallback": return {
2443
- kind: "style-fallback",
2444
- requestedName: lookName(resolved.requested),
2445
- lookName: resolved.look.label
4075
+ }, [
4076
+ key,
4077
+ loader,
4078
+ reader
4079
+ ]);
4080
+ return loaded?.key === key ? loaded.observations : unknownBlockObservations;
4081
+ }
4082
+ //#endregion
4083
+ //#region ../editor-blocks/src/block-editor/EditorSiteFactsProvider.tsx
4084
+ const EditorSiteFactsContext = createContext(unavailableSiteFacts);
4085
+ const EditorBlockLoaderContext = createContext(null);
4086
+ /**
4087
+ * What the site has (passes on sale, say), read once for the editor so every
4088
+ * block form's conditions use the same facts. Until they arrive, or if the
4089
+ * read fails, every fact is unavailable, and a field a fact condition guards
4090
+ * stays in the form.
4091
+ *
4092
+ * It also lends block forms the site's public block loaders, so a block's
4093
+ * observations (the price items for its chosen class) load through the same
4094
+ * client. Its client must reach both, so a host that mounts it can't leave
4095
+ * observations out.
4096
+ */
4097
+ function EditorSiteFactsProvider({ siteId, apiClient, children }) {
4098
+ const [loaded, setLoaded] = useState(null);
4099
+ const latestClient = useRef(apiClient);
4100
+ useEffect(() => {
4101
+ latestClient.current = apiClient;
4102
+ });
4103
+ useEffect(() => {
4104
+ const request = { cancelled: false };
4105
+ loadEditorSiteFacts({
4106
+ apiClient: latestClient.current,
4107
+ siteId
4108
+ }).then((facts) => {
4109
+ if (!request.cancelled) setLoaded({
4110
+ siteId,
4111
+ facts
4112
+ });
4113
+ }).catch(() => void 0);
4114
+ return () => {
4115
+ request.cancelled = true;
2446
4116
  };
2447
- case "mode-mismatch": return {
2448
- kind: "mode-mismatch",
2449
- requestedName: lookName(resolved.requested),
2450
- requestedModeLabel: requestedModeLabel(block, resolved.requested),
2451
- lookName: resolved.look.label
4117
+ }, [siteId, useTabReturns()]);
4118
+ const facts = loaded?.siteId === siteId ? loaded.facts : unavailableSiteFacts;
4119
+ const reader = useMemo(() => createBlockLoaderReader(siteId, () => latestClient.current), [siteId]);
4120
+ return /* @__PURE__ */ jsx(EditorSiteFactsContext.Provider, {
4121
+ value: facts,
4122
+ children: /* @__PURE__ */ jsx(EditorBlockLoaderContext.Provider, {
4123
+ value: reader,
4124
+ children
4125
+ })
4126
+ });
4127
+ }
4128
+ /** Counts the times the person comes back to this tab. */
4129
+ function useTabReturns() {
4130
+ const [returns, setReturns] = useState(0);
4131
+ useEffect(() => {
4132
+ const onVisible = () => {
4133
+ if (document.visibilityState === "visible") setReturns((count) => count + 1);
2452
4134
  };
2453
- case "recipe":
2454
- case "none": return null;
2455
- }
4135
+ document.addEventListener("visibilitychange", onVisible);
4136
+ return () => document.removeEventListener("visibilitychange", onVisible);
4137
+ }, []);
4138
+ return returns;
2456
4139
  }
2457
- /** The requested Look may be one this style doesn't offer, so read the shared catalogue. */
2458
- function lookName(id) {
2459
- return lookDefinitionForId(id)?.label ?? "your chosen Look";
2460
- }
2461
- function requestedModeLabel(block, id) {
2462
- const look = lookDefinitionForId(id);
2463
- const mode = look ? lookModes(look).find((candidate) => candidate !== null) : void 0;
2464
- return mode ? modeLabel(block, mode) : "another";
2465
- }
2466
- function modeSwitch(block, available, current) {
2467
- if (current === null) return null;
2468
- const modesWithLooks = available.flatMap((look) => lookModes(look)).filter((mode) => mode !== null);
2469
- const modes = [...new Set(modesWithLooks)];
2470
- return modes.length > 1 ? {
2471
- current,
2472
- options: modes.map((mode) => ({
2473
- mode,
2474
- label: modeLabel(block, mode)
2475
- }))
2476
- } : null;
4140
+ function useEditorSiteFacts() {
4141
+ return useContext(EditorSiteFactsContext);
2477
4142
  }
2478
- function modeLabel(block, mode) {
2479
- const meaning = getBlockDefinition(block.blockKind)?.manifest.variantMeaning;
2480
- return (meaning?.kind === "mode" ? meaning.modeLabels?.[mode] : void 0) ?? block.availableLayouts.find((layout) => layout.id === mode)?.label ?? mode.charAt(0).toUpperCase() + mode.slice(1);
2481
- }
2482
- function knobControls(blockKind, exposure, knobs, content, descriptions = {}) {
2483
- return exposure.flatMap((entry) => {
2484
- const knob = knobs[entry.definition.id];
2485
- const facet = shownKnobFacet(blockKind, entry, knob);
2486
- if (!facet || !knob || knob.kind === "kept") return [];
2487
- const control = knobControl(entry, knob, facet, systemCustomizeFacetStoredValue(facet, { ...content }));
2488
- const description = descriptions[entry.definition.id] ?? facet.description;
2489
- return [control.kind === "choice" && description !== void 0 ? {
2490
- ...control,
2491
- description
2492
- } : control];
2493
- });
2494
- }
2495
- /** Only knobs the current Look exposes and doesn't force get a control. */
2496
- function shownKnobFacet(blockKind, entry, knob) {
2497
- const id = entry.definition.id;
2498
- if (entry.definition.textMaxLength === void 0 && arrangementKnobChoices(entry).length <= 1 || !entry.exposed || entry.forced !== void 0 || !knob || knob.kind === "kept" || !isSystemCustomizeFacetId(id)) return null;
2499
- return systemCustomizeFacetDefinitionForBlock(blockKind, id);
2500
- }
2501
- function knobControl(entry, knob, facet, stored) {
2502
- if (entry.definition.textMaxLength !== void 0) return {
2503
- kind: "text",
2504
- facetId: facet.id,
2505
- label: facet.label,
2506
- value: knob.value,
2507
- stored,
2508
- maxLength: entry.definition.textMaxLength
2509
- };
2510
- const choices = arrangementKnobChoices(entry);
2511
- const preference = knob.kind === "clamped" && knob.reason === "length" && choices.includes(knob.stored) ? knob.stored : knob.value;
2512
- const labelOf = (value) => facet.values.find((option) => option.value === value)?.label ?? value;
2513
- return {
2514
- kind: "choice",
2515
- presentation: knobPresentation(facet, choices),
2516
- facetId: facet.id,
2517
- label: facet.label,
2518
- value: preference,
2519
- stored,
2520
- notOffered: knob.kind === "clamped" && knob.reason !== "length" ? {
2521
- by: knob.reason,
2522
- choice: labelOf(knob.stored),
2523
- shows: labelOf(knob.value)
2524
- } : null,
2525
- options: choices.map((value) => ({
2526
- value,
2527
- label: labelOf(value)
2528
- }))
2529
- };
4143
+ /** The site's public block loaders, or null outside an editor, where every observation stays unknown. */
4144
+ function useEditorBlockLoaderReader() {
4145
+ return useContext(EditorBlockLoaderContext);
2530
4146
  }
2531
- /** On/off knobs store `'true'` and `'false'`; the switch is on for `'true'`. */
2532
- function knobPresentation(facet, choices) {
2533
- if (facet.target.kind === "content-field" && facet.target.boolean === true && choices.length === 2 && choices.includes("true") && choices.includes("false")) return "switch";
2534
- return choices.length <= 3 ? "segments" : "menu";
4147
+ async function loadEditorSiteFacts(input) {
4148
+ return unwrapResponse(await input.apiClient({
4149
+ endpoint: "getEditorSiteFacts",
4150
+ params: { siteId: input.siteId }
4151
+ }));
2535
4152
  }
2536
- function headlineHint(knobs, length) {
2537
- const headline = knobs.titleSize;
2538
- return headline?.kind === "clamped" && headline.reason === "length" && length !== null && length !== "short" ? { length } : null;
4153
+ //#endregion
4154
+ //#region ../editor-blocks/src/block-editor/useBlockEditingPlan.ts
4155
+ function useBlockEditingPlan(input) {
4156
+ const context = useBlockEditingContext(input);
4157
+ const { manifest, values } = input;
4158
+ return useMemo(() => manifest ? deriveBlockEditingPlan({
4159
+ manifest,
4160
+ values,
4161
+ context
4162
+ }) : null, [
4163
+ context,
4164
+ manifest,
4165
+ values
4166
+ ]);
2539
4167
  }
2540
4168
  /**
2541
- * Section backgrounds for an arrangement-Look style: the style's own surfaces
2542
- * by plain name, plus the page rhythm. A background is never a Look. A Look
2543
- * that paints its photo behind the text has no Background row, because the
2544
- * photo is the background. Any other Look offers the surfaces until the
2545
- * section has a photo, which replaces the colour choice.
4169
+ * The context every plan in this editor is derived with, from the editor's
4170
+ * providers. Setup before a block is added derives its questions from the
4171
+ * same providers (`setupEditingContext`), so they follow the same conditions
4172
+ * as the block's form.
2546
4173
  */
2547
- function arrangementBackgroundControlFor(input) {
2548
- const selection = input.block.arrangementLookSelection;
2549
- if (!selection || input.block.backgroundSupport.kind === "unsupported") return null;
2550
- const photo = decideSectionPhoto({
2551
- block: input.block,
2552
- promotedFieldPaths: getBlockDefinition(input.block.blockKind)?.manifest.promotedFields,
2553
- draftPhoto: sectionPhotoPresence(input.content)
2554
- });
2555
- if (photo.kind === "arrangement" && photo.use === "behind") return null;
2556
- if (photo.kind === "arrangement" && photo.photo === "present") return {
2557
- kind: "held-by-photo",
2558
- photo: "section-photo"
2559
- };
2560
- const options = arrangementSurfaceOptions(selection.style);
2561
- const stored = storedSurfaceChoice(parseCanonicalSectionBackground({ ...input.content }), options);
2562
- return stored.kind === "held-by-photo" ? stored : {
2563
- kind: "surfaces",
2564
- selected: stored.selected,
2565
- options,
2566
- rhythm: options.find((option) => option.token === input.decidedBackground) ?? null
2567
- };
2568
- }
2569
- function arrangementSurfaceOptions(style) {
2570
- return Object.entries(style.surfaces).flatMap(([name, spec]) => {
2571
- const token = spec.kind === "token" && !spec.roleOnly ? parseBackgroundColorToken(spec.token) : null;
2572
- return token ? [{
2573
- name,
2574
- label: arrangementSurfaceLabel(name),
2575
- token
2576
- }] : [];
2577
- });
4174
+ function useBlockEditingContext(input) {
4175
+ const environment = useEditorPlanEnvironment();
4176
+ const { manifest, blockKind, values, theme, hideThemeV2RawStyleFields, pageDesignBlock, lookFields, hostCommands } = input;
4177
+ const chosenLabel = useChosenLabels(manifest, values);
4178
+ const observations = useBlockObservations(useEditorBlockLoaderReader(), blockKind, values);
4179
+ return useMemo(() => editingContextFor(environment, {
4180
+ blockKind,
4181
+ theme,
4182
+ hideThemeV2RawStyleFields,
4183
+ pageDesignBlock,
4184
+ lookFields,
4185
+ hostCommands,
4186
+ chosenLabel,
4187
+ observations
4188
+ }), [
4189
+ environment,
4190
+ blockKind,
4191
+ theme,
4192
+ hideThemeV2RawStyleFields,
4193
+ pageDesignBlock,
4194
+ lookFields,
4195
+ hostCommands,
4196
+ chosenLabel,
4197
+ observations
4198
+ ]);
2578
4199
  }
2579
- /** Which surface the stored background shows as chosen, once the section has no photo of its own. */
2580
- function storedSurfaceChoice(stored, options) {
2581
- switch (stored.kind) {
2582
- case "none": return {
2583
- kind: "surface",
2584
- selected: null
2585
- };
2586
- case "block-authored":
2587
- if (stored.background.type === "image" || stored.background.type === "video") return {
2588
- kind: "held-by-photo",
2589
- photo: "older-style-photo"
2590
- };
2591
- return {
2592
- kind: "surface",
2593
- selected: stored.background.type === "color" ? surfaceForToken(options, stored.background.color) : null
2594
- };
2595
- case "page-design-override": {
2596
- const override = stored.parsed.kind === "supported" ? stored.parsed.override : null;
2597
- return {
2598
- kind: "surface",
2599
- selected: override?.kind === "color" ? surfaceForToken(options, override.token) : null
2600
- };
2601
- }
2602
- }
4200
+ function useEditorPlanEnvironment() {
4201
+ const { blockFieldOptions, blockFieldExtensions, isSdkSite, sectionOptions } = useSdkConfig();
4202
+ const colourFieldOptions = useColourFieldOptions();
4203
+ const siteFacts = useEditorSiteFacts();
4204
+ const pageTemplate = useEditorPageTemplate();
4205
+ return useMemo(() => ({
4206
+ sdk: {
4207
+ blockFieldOptions,
4208
+ blockFieldExtensions,
4209
+ isSdkSite,
4210
+ sectionOptions
4211
+ },
4212
+ colourFieldOptions,
4213
+ siteFacts,
4214
+ pageTemplate
4215
+ }), [
4216
+ blockFieldExtensions,
4217
+ blockFieldOptions,
4218
+ colourFieldOptions,
4219
+ isSdkSite,
4220
+ sectionOptions,
4221
+ siteFacts,
4222
+ pageTemplate
4223
+ ]);
2603
4224
  }
2604
- const arrangementSurfaceLabels = {
2605
- base: "Page ground",
2606
- band: "Quiet band",
2607
- brand: "Brand colour",
2608
- deep: "Deepest tone",
2609
- inverse: "Opposite ground",
2610
- pop: "Pop colour"
2611
- };
2612
- function arrangementSurfaceLabel(name) {
2613
- return arrangementSurfaceLabels[name] ?? name.charAt(0).toUpperCase() + name.slice(1).replace(/[-_]+/g, " ");
4225
+ function editingContextFor(environment, input) {
4226
+ return {
4227
+ ...environment,
4228
+ blockKind: input.blockKind,
4229
+ theme: input.theme,
4230
+ rawStyleFields: input.hideThemeV2RawStyleFields ? "hide-theme-v2" : "show",
4231
+ pageDesignBlock: input.pageDesignBlock,
4232
+ lookFields: input.lookFields,
4233
+ hostCommands: input.hostCommands,
4234
+ chosenLabel: input.chosenLabel,
4235
+ observations: input.observations
4236
+ };
2614
4237
  }
2615
- function surfaceForToken(options, token) {
2616
- return options.find((option) => option.token === token)?.name ?? null;
4238
+ /**
4239
+ * The context setup questions are decided in: the block isn't on the page
4240
+ * yet, so it has no page design of its own, and the setup form is the only
4241
+ * host. Picking a block and the setup view both use this, so they agree on
4242
+ * whether there's anything to ask.
4243
+ */
4244
+ function setupEditingContext(environment, input) {
4245
+ return editingContextFor(environment, {
4246
+ blockKind: input.blockKind,
4247
+ theme: input.theme,
4248
+ hideThemeV2RawStyleFields: false,
4249
+ pageDesignBlock: null,
4250
+ lookFields: "in-form",
4251
+ hostCommands: FORM_ONLY_HOST,
4252
+ chosenLabel: null,
4253
+ observations: unknownBlockObservations
4254
+ });
2617
4255
  }
2618
4256
  //#endregion
2619
4257
  //#region ../preview-next/src/client/blocks/blockNeedsSetup.ts
@@ -2656,89 +4294,26 @@ function needsSetupAsk(needs) {
2656
4294
  return READINESS_REASON_COPY[needs.reason].split(" Until ")[0] ?? READINESS_REASON_COPY[needs.reason];
2657
4295
  }
2658
4296
  //#endregion
2659
- //#region ../preview-next/src/client/blocks/sectionPhotoField.ts
2660
- /**
2661
- * Arrangement Looks call the section photo's field Photo. Looks that show it
2662
- * say what the section shows until one is added; a Look that doesn't show it
2663
- * only lists the field while a photo is stored, so the owner can remove it.
2664
- * Older recipe Looks keep the field as it is.
2665
- */
2666
- function sectionPhotoFieldCopy(photo) {
2667
- if (photo.kind !== "arrangement") return null;
2668
- if (photo.use === "none") return photo.photo === "present" ? {
2669
- label: "Photo",
2670
- hint: "This Look doesn’t show the photo. Remove it to choose a background colour."
2671
- } : null;
2672
- if (photo.photo === "present") return {
2673
- label: "Photo",
2674
- hint: null
2675
- };
2676
- return {
2677
- label: "Photo",
2678
- hint: photo.withoutPhoto === "shows-another-look" ? "Add a photo. Until you do, this section shows the title on its own." : "Add a photo. This Look is built around one, so it can look a little bare without it."
2679
- };
2680
- }
2681
- /** Applies the Photo copy to the promoted photo field in the Look section. */
2682
- function withSectionPhotoField(plan, photo) {
2683
- const copy = sectionPhotoFieldCopy(photo);
2684
- if (copy === null) return plan;
2685
- const look = plan.sections.look.map((item) => item.path === "_sectionStyles.background.image" ? {
2686
- ...item,
2687
- field: {
2688
- ...item.field,
2689
- label: copy.label,
2690
- description: copy.hint ?? void 0
2691
- }
2692
- } : item);
2693
- return {
2694
- ...plan,
2695
- sections: {
2696
- ...plan.sections,
2697
- look
2698
- }
2699
- };
2700
- }
2701
- //#endregion
2702
4297
  //#region ../preview-next/src/client/blocks/useBlockCustomizeControls.ts
4298
+ const NO_LOOK = { kind: "built-in" };
2703
4299
  function useBlockCustomizeControls({ blockId, blockKind, content, uiStore, theme, sdkConfig }) {
2704
- const { blockFieldOptions, blockFieldExtensions, sdkConfig: contextSdkConfig } = useSdkConfig();
4300
+ const { sdkConfig: contextSdkConfig } = useSdkConfig();
2705
4301
  const effectiveSdkConfig = sdkConfig ?? contextSdkConfig;
2706
4302
  const manifest = useMemo(() => resolveBlockManifest(blockKind, effectiveSdkConfig ?? null), [blockKind, effectiveSdkConfig]);
2707
4303
  const { state: pageDesignState } = usePreviewPageDesignEditorState();
2708
4304
  const designBlock = useMemo(() => pageDesignState.kind === "loaded" ? pageDesignState.editorModel.blocks.find((block) => String(block.blockId) === String(blockId)) ?? null : null, [blockId, pageDesignState]);
2709
- const draftPhoto = sectionPhotoPresence(content);
2710
- const preparedManifest = useMemo(() => {
2711
- if (!manifest) return null;
2712
- return prepareBlockEditorManifest({
2713
- manifest,
2714
- blockKind,
2715
- theme,
2716
- blockFieldOptions,
2717
- blockFieldExtensions,
2718
- visibilityPolicy: hideThemeV2RawStyleFields,
2719
- allowedPromotedFieldPaths: designBlock ? resolveVisiblePromotedFieldPathsForEditorBlock({
2720
- block: designBlock,
2721
- promotedFieldPaths: manifest.promotedFields,
2722
- draftPhoto
2723
- }) : void 0
2724
- });
2725
- }, [
2726
- designBlock,
2727
- draftPhoto,
2728
- blockFieldExtensions,
2729
- blockFieldOptions,
2730
- blockKind,
4305
+ const plan = useBlockEditingPlan({
2731
4306
  manifest,
2732
- theme
2733
- ]);
2734
- const ownedFieldIds = useMemo(() => arrangementOwnedFieldIds(designBlock), [designBlock]);
2735
- const visibilityValues = useMemo(() => arrangementVisibilityValues(designBlock), [designBlock]);
2736
- const fields = useMemo(() => {
2737
- if (!preparedManifest) return [];
2738
- return createManifestFormAdapter(preparedManifest.renderManifest).fields.filter((field) => !ownedFieldIds.includes(field.id));
2739
- }, [ownedFieldIds, preparedManifest]);
4307
+ blockKind,
4308
+ values: content,
4309
+ theme,
4310
+ hideThemeV2RawStyleFields: true,
4311
+ pageDesignBlock: designBlock,
4312
+ lookFields: "in-form",
4313
+ hostCommands: FORM_ONLY_HOST
4314
+ });
2740
4315
  const backend = useMemo(() => {
2741
- if (!preparedManifest) return null;
4316
+ if (!manifest) return null;
2742
4317
  return createStoreBackend({
2743
4318
  scope: "blocks",
2744
4319
  store: uiStore,
@@ -2746,36 +4321,20 @@ function useBlockCustomizeControls({ blockId, blockKind, content, uiStore, theme
2746
4321
  });
2747
4322
  }, [
2748
4323
  blockId,
2749
- preparedManifest,
4324
+ manifest,
2750
4325
  uiStore
2751
4326
  ]);
2752
- const getValue = (path) => visibilityValues && path === "blockLook" ? visibilityValues.lookId : visibilityValues && path === visibilityValues.arrangementField ? visibilityValues.arrangement : backend?.getValue(path) ?? content[path] ?? fields.find((field) => field.id === path)?.defaultValue;
2753
- const sectionOptions = preparedManifest ? manifestFieldSectionOptions(preparedManifest.renderManifest, { lookOwnedPaths: blockLookOwnedFieldPaths(designBlock) }) : {};
2754
- const plan = derivePromotedFieldPlan(fields, preparedManifest?.renderManifest.promotedFields, getValue, sectionOptions);
2755
- const sectionPlan = designBlock && manifest ? withSectionPhotoField(plan, decideSectionPhoto({
2756
- block: designBlock,
2757
- promotedFieldPaths: manifest.promotedFields,
2758
- draftPhoto
2759
- })) : plan;
2760
- const renderManifest = preparedManifest?.renderManifest ?? null;
2761
4327
  return {
2762
- manifest: renderManifest,
2763
- fields,
2764
- sectionPlan,
4328
+ plan,
4329
+ lookSource: plan?.lookSource ?? NO_LOOK,
4330
+ manifest,
2765
4331
  backend,
2766
- designBlock,
2767
- lookSource: resolveBlockLookSource(renderManifest, sectionPlan)
4332
+ designBlock
2768
4333
  };
2769
4334
  }
2770
4335
  function resolveBlockManifest(blockKind, sdkConfig) {
2771
4336
  return getBlockManifestFromSdkConfig(blockKind, sdkConfig) ?? getBlockDefinition(blockKind)?.manifest ?? null;
2772
4337
  }
2773
- function resolveBlockLookSource(manifest, plan) {
2774
- return manifest?.lookField ? {
2775
- kind: "sdk",
2776
- item: plan.sections.look.find((item) => item.path === manifest.lookField) ?? null
2777
- } : { kind: "built-in" };
2778
- }
2779
4338
  //#endregion
2780
4339
  //#region ../preview-next/src/client/blocks/useOpenBlockForSetup.ts
2781
4340
  /**
@@ -2789,7 +4348,7 @@ function useOpenBlockForSetup() {
2789
4348
  const openField = (blockId, fieldPath) => {
2790
4349
  open(blockId);
2791
4350
  uiStore.getState().requestFocus({
2792
- kind: "main-field",
4351
+ kind: "field",
2793
4352
  blockId,
2794
4353
  fieldPath: fieldPath.startsWith("content.") ? fieldPath : `content.${fieldPath}`
2795
4354
  });
@@ -2802,4 +4361,4 @@ function useOpenBlockForSetup() {
2802
4361
  };
2803
4362
  }
2804
4363
  //#endregion
2805
- export { Tooltip as A, DropdownMenuRadioItem as B, blockLookOwnedFieldPaths as C, showRawStyleFields as D, prepareBlockEditorManifest as E, DropdownMenu as F, DropdownMenuTrigger as H, DropdownMenuContent as I, DropdownMenuItem as L, TooltipProvider as M, TooltipTrigger as N, getBlockManifestFromSdkConfig as O, Badge as P, DropdownMenuLabel as R, arrangementVisibilityValues as S, hideThemeV2RawStyleFields as T, DropdownMenuSeparator as V, createFieldObservation as _, blockNoticeAction as a, arrangementLookResolution as b, needsSetupAsk as c, arrangementBackgroundControlFor as d, arrangementBlockControlsFor as f, isRecord as g, isObjectRecord as h, NEEDS_SETUP_LABEL as i, TooltipContent as j, mergeBlockDescriptors as k, needsSetupOf as l, createStoreBackend as m, resolveBlockManifest as n, blockNoticeLabel as o, arrangementLookNameFor as p, useBlockCustomizeControls as r, blockNoticeMessage as s, useOpenBlockForSetup as t, useBlockNotice as u, SdkConfigProvider as v, lookNotShownFieldIds as w, arrangementOwnedFieldIds as x, useSdkConfig as y, DropdownMenuRadioGroup as z };
4364
+ export { hasVisibilityConditions as $, arrangementBlockMode as A, getColumns as B, closeGroupView as C, sameOpenView as D, resolveOpenView as E, revealStepKey as F, shouldHideLabel as G, groupFieldsByRow as H, revealStepsAmong as I, resolvePromotedFields as J, shownTab as K, getRepeaterItemFieldGroups as L, layoutManifestForm as M, manifestFieldSectionOptions as N, visibilityOverrides as O, placedFields as P, getWidgetKey as Q, getRepeaterItemFields as R, useSdkConfig as S, openViewForDestination as T, layoutGroupFields as U, getValidColSpan as V, modalGroupFields as W, evaluateVisibility as X, collectVisibleWhenWatchPaths as Y, withVisibilityValues as Z, createStoreBackend as _, DropdownMenuTrigger as _t, blockNoticeAction as a, Tooltip as at, createFieldObservation as b, needsSetupAsk as c, TooltipTrigger as ct, setupEditingContext as d, DropdownMenuContent as dt, isNonEmptyValue as et, useBlockEditingPlan as f, DropdownMenuItem as ft, useDisplayLabelResolvers as g, DropdownMenuSeparator as gt, useEditorSiteFacts as h, DropdownMenuRadioItem as ht, NEEDS_SETUP_LABEL as i, READINESS_REASON_COPY as it, arrangementLookResolution as j, deriveBlockValidationManifest as k, needsSetupOf as l, Badge as lt, EditorSiteFactsProvider as m, DropdownMenuRadioGroup as mt, resolveBlockManifest as n, mergeBlockDescriptors as nt, blockNoticeLabel as o, TooltipContent as ot, useEditorPlanEnvironment as p, DropdownMenuLabel as pt, derivedSettingsSummary as q, useBlockCustomizeControls as r, HIDDEN_REASON_COPY as rt, blockNoticeMessage as s, TooltipProvider as st, useOpenBlockForSetup as t, getBlockManifestFromSdkConfig as tt, useBlockNotice as u, DropdownMenu as ut, isObjectRecord as v, deriveBlockEditingPlan as w, SdkConfigProvider as x, isRecord as y, buildChildPath as z };