@riverbankcms/sdk 0.159.0 → 0.161.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 (218) hide show
  1. package/README.md +4 -4
  2. package/dist/_dts/{BlocksIslandsHydrator-Cj1i1Yhh.d.ts → BlocksIslandsHydrator-Bx4kLiTA.d.ts} +1 -1
  3. package/dist/_dts/{Page-Cgzbv22M.d.ts → Page-Dm7_P13o.d.ts} +217 -8
  4. package/dist/_dts/{SdkPreviewMode-BC_FGc6b.d.ts → SdkPreviewMode-D7HdWWwF.d.ts} +55 -127
  5. package/dist/_dts/{auth-contract-FPg0-2MC.d.ts → auth-contract-CgJ5nMaH.d.ts} +2 -0
  6. package/dist/_dts/{client-BOK-YHVJ.d.ts → client-Ep0jI9eE.d.ts} +1 -1
  7. package/dist/_dts/{content-types-CsrYWxq_.d.ts → content-types-BgAzCrBc.d.ts} +18 -18
  8. package/dist/_dts/{contracts-ClgMD-9g.d.ts → contracts-DUiOnj9e.d.ts} +10 -6
  9. package/dist/_dts/{footerPageOutline-C_IDuELl.d.ts → footerPageOutline-B-uXamTG.d.ts} +6 -6
  10. package/dist/_dts/{generatePageMetadata-B7bhYSWx.d.ts → generatePageMetadata-BDkZYEcS.d.ts} +2 -2
  11. package/dist/_dts/index-BQDBQvdu.d.ts +13 -0
  12. package/dist/_dts/index-BVkP8f70.d.ts +66 -0
  13. package/dist/_dts/{index-Dt3XSGzY.d.ts → index-CF6Cjs7b.d.ts} +2 -2
  14. package/dist/_dts/{index-Ci1PEk82.d.ts → index-CSsfq6KG.d.ts} +3 -17
  15. package/dist/_dts/{index-BZ4fb2zz.d.ts → index-D_8uz4OP.d.ts} +3 -3
  16. package/dist/_dts/{index-CcaG6O13.d.ts → index-DvKQA6AZ.d.ts} +4 -4
  17. package/dist/_dts/{index-DMOfW1A7.d.ts → index-KPrWM0KF.d.ts} +2 -2
  18. package/dist/_dts/{index-DzUdUaJ-.d.ts → index-ylivB7Jj.d.ts} +2 -2
  19. package/dist/_dts/{loadContent-C1JI2pG0.d.ts → loadContent-DTjKOO-T.d.ts} +19 -10
  20. package/dist/_dts/{resolvePageContent-BtRUtrJa.d.ts → resolvePageContent-C1vA5c5w.d.ts} +2 -2
  21. package/dist/_dts/{constants-DkcKHMX-.d.ts → runtime-BY8DQBbT.d.ts} +10 -16
  22. package/dist/_dts/{hosted-booking-appearance-ChGCQYdQ.d.ts → schema-BHu0PYWl.d.ts} +25911 -23567
  23. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  24. package/dist/_dts/sdk/src/client/types.d.ts +2 -2
  25. package/dist/_dts/sdk/src/client.d.ts +13 -7
  26. package/dist/_dts/sdk/src/config/index.d.ts +6 -6
  27. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  28. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  29. package/dist/_dts/sdk/src/index.d.ts +8 -8
  30. package/dist/_dts/sdk/src/manifest/index.d.ts +6 -6
  31. package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
  32. package/dist/_dts/sdk/src/navigation/index.d.ts +2 -2
  33. package/dist/_dts/sdk/src/next/index.d.ts +7 -7
  34. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  35. package/dist/_dts/sdk/src/page-converter/index.d.ts +10 -28
  36. package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
  37. package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
  38. package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
  39. package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
  40. package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
  41. package/dist/_dts/sdk/src/preview-next/keep-alive.d.ts +1 -1
  42. package/dist/_dts/sdk/src/preview-next/session.d.ts +2 -2
  43. package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
  44. package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
  45. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  46. package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
  47. package/dist/_dts/sdk/src/routing/index.d.ts +5 -5
  48. package/dist/_dts/sdk/src/server.d.ts +5 -5
  49. package/dist/_dts/sdk/src/theme/index.d.ts +1 -1
  50. package/dist/_dts/{session-Ba2CsnK5.d.ts → session-C_gtSFyZ.d.ts} +2 -1
  51. package/dist/_dts/{navigation-BnV_hOZy.d.ts → types-BR1Yboa9.d.ts} +15530 -16017
  52. package/dist/_dts/{types-CMFIZGUI.d.ts → types-CJXTCF_F.d.ts} +10 -13
  53. package/dist/_dts/{types-CI9dYWJ8.d.ts → types-D02ngcUH.d.ts} +4 -2
  54. package/dist/_dts/{types--oWXIfyz.d.ts → types-ZGUiHpDE.d.ts} +7 -7
  55. package/dist/_dts/{validation-Ct-GL0eA.d.ts → validation-BaV565gb.d.ts} +4 -4
  56. package/dist/client/{BlocksIslandsHydrator-DKS8Ba30.mjs → BlocksIslandsHydrator-DTExCJsb.mjs} +22 -21
  57. package/dist/client/{BookingMailingListNote-Cg9v6d7Y.mjs → BookingMailingListNote-BDpxmn1p.mjs} +2 -2
  58. package/dist/client/{CalendarNavigationChevron-BoVCTUXy.mjs → CalendarNavigationChevron-PeCiL82X.mjs} +6 -6
  59. package/dist/client/{CheckboxChoice-BF9eCNno.mjs → CheckboxChoice-DWexRLf6.mjs} +1 -1
  60. package/dist/client/{DemoBookingPortalAccess-BxRVCJG3.mjs → DemoBookingPortalAccess-3zmIqakW.mjs} +6 -6
  61. package/dist/client/{DemoPortalSignInLink-DHxYgkT6.mjs → DemoPortalSignInLink-GHi-8BW5.mjs} +1 -1
  62. package/dist/client/{EventCalendar.client-BI-kvwXf.mjs → EventCalendar.client-BxQLY5cX.mjs} +10 -9
  63. package/dist/client/{EventCombined.client-DIvnoN5l.mjs → EventCombined.client-B5bmQ03b.mjs} +8 -8
  64. package/dist/client/{EventEmbeddedCheckoutStep-B3XUyNY9.mjs → EventEmbeddedCheckoutStep-CgMZ9TeU.mjs} +1 -1
  65. package/dist/client/{EventItem-BRMtEaa6.mjs → EventItem-BEx-qiDE.mjs} +11 -6
  66. package/dist/client/{EventListWeekNavigation-B8DzAUDa.mjs → EventListWeekNavigation-CyH5tA6Y.mjs} +1 -1
  67. package/dist/client/{EventListing.client-Bo4qzQi0.mjs → EventListing.client-D3uySdGP.mjs} +3 -3
  68. package/dist/client/{EventListing.view-D2vemnCx.mjs → EventListing.view-9RFrBejr.mjs} +31 -15
  69. package/dist/client/{EventRegistrationPayment-e5XWtygG.mjs → EventRegistrationPayment-CG2tQx8K.mjs} +92 -99
  70. package/dist/client/LocationMapActions-Wsr83Q7q.mjs +268 -0
  71. package/dist/client/{Page-Dqpv9Ggi.mjs → Page-Bf2nPACI.mjs} +2673 -2290
  72. package/dist/client/{StepIndicator-BrvKa_8H.mjs → StepIndicator-CZweb1vs.mjs} +3 -3
  73. package/dist/client/{TabBarFragment-DvzIV75f.mjs → TabBarFragment-Bkgz67gt.mjs} +1 -1
  74. package/dist/client/ThemedButton-CnyL3s1A.mjs +2243 -0
  75. package/dist/client/{accordion-ByLpb4Dz.mjs → accordion-TcimLLRQ.mjs} +1 -1
  76. package/dist/client/{booking-form.client-BLndwxpx.mjs → booking-form.client-q-RpJ4aF.mjs} +13 -13
  77. package/dist/client/{bookingForm-CTxTEgHX.mjs → bookingForm-DjGfk3Wj.mjs} +4 -4
  78. package/dist/client/bookings.mjs +6 -6
  79. package/dist/client/{carousel-C8ef0vnT.mjs → carousel-CGAk6j0m.mjs} +2 -2
  80. package/dist/client/{carousel.client-BJGoJVtg.mjs → carousel.client-ArlGmYWV.mjs} +1 -1
  81. package/dist/client/{cart-BpH6jkUO.mjs → cart-D_h3rAZ2.mjs} +3 -3
  82. package/dist/client/{cart.client-DV78Td13.mjs → cart.client-DHOxZbJ7.mjs} +1 -1
  83. package/dist/client/{checkout-BJVb2RpL.mjs → checkout-tC-3CzuM.mjs} +3 -3
  84. package/dist/client/{checkout.client-CqGPXPSm.mjs → checkout.client-DsBb2Pkm.mjs} +1 -1
  85. package/dist/client/client.mjs +28 -15
  86. package/dist/client/{context-BRgBWthI.mjs → context-9ZfMb6GA.mjs} +1 -1
  87. package/dist/client/{cta-D8ucLsvX.mjs → cta-D-ZqL7-e.mjs} +2 -1
  88. package/dist/client/{dateFormatting-LeKNQ-iX.mjs → dateFormatting-BCwLqYpW.mjs} +1 -1
  89. package/dist/client/{demoPortalMagicLink-CjstiFPh.mjs → demoPortalMagicLink-BxkSS9fx.mjs} +1 -1
  90. package/dist/client/{enhanceHeaderSection-BaQJyI9x.mjs → enhanceHeaderSection-xg6to91E.mjs} +3 -3
  91. package/dist/client/{event-details.client-CYNQYOsP.mjs → event-details.client-C670TgRd.mjs} +2 -17
  92. package/dist/client/{event-registration.client-DDqSpN36.mjs → event-registration.client-C6GApWTB.mjs} +17 -17
  93. package/dist/client/{eventCalendar-3vQtuC9X.mjs → eventCalendar-CWc0dg9i.mjs} +4 -4
  94. package/dist/client/{eventCombined-CEJFMjqV.mjs → eventCombined-D4DbOrvQ.mjs} +4 -4
  95. package/dist/client/{eventDetails-nGh47jef.mjs → eventDetails-C2DfmbC0.mjs} +2 -2
  96. package/dist/client/{eventListing-BL3Ptb83.mjs → eventListing-C_yXmHyz.mjs} +4 -4
  97. package/dist/client/{eventRegistration-DDSO6KB2.mjs → eventRegistration-DJuaCB-O.mjs} +4 -4
  98. package/dist/client/{form-DjNLfy2Z.mjs → form-QZhtdFHA.mjs} +3 -3
  99. package/dist/client/{form.client-Cj0By6ot.mjs → form.client-CgvPACwG.mjs} +5 -5
  100. package/dist/client/{form.parts-DyA9C5Hy.mjs → form.parts-2uI0-5N-.mjs} +3 -3
  101. package/dist/client/{formatDate-CZo0MPTA.mjs → formatDate-Danr0Nk4.mjs} +1 -1
  102. package/dist/client/gifting/client.mjs +3 -3
  103. package/dist/client/{headerSection-JjSq6Mzp.mjs → headerSection-DJdlLdvZ.mjs} +2 -2
  104. package/dist/client/{mediaAssets-BOj-Co0B.mjs → mediaAssets-BvjcAZpS.mjs} +1 -1
  105. package/dist/client/mediaContext-jPeJ2PmJ.mjs +10801 -0
  106. package/dist/client/{newsletter-form.client-C2EgEBP1.mjs → newsletter-form.client-Cbepz2KU.mjs} +8 -8
  107. package/dist/client/{newsletter-form.parts-CaldoFmi.mjs → newsletter-form.parts-DN8oMCQ0.mjs} +2 -2
  108. package/dist/client/{newsletterForm-hm7L17LM.mjs → newsletterForm-wjLtW-wq.mjs} +3 -3
  109. package/dist/client/{noop-M8FTSgm2.mjs → noop-B7H6gCbj.mjs} +306 -5
  110. package/dist/client/portal/client.mjs +4560 -115
  111. package/dist/client/{product-detail.client-y86uwzEI.mjs → product-detail.client-CYTR165c.mjs} +1 -1
  112. package/dist/client/{product-list.client-_JBndYZT.mjs → product-list.client-B4vTvag8.mjs} +1 -1
  113. package/dist/client/{productDetail-D-9fb2cW.mjs → productDetail-k8LEMSWn.mjs} +3 -3
  114. package/dist/client/{productList-BSRlnwBW.mjs → productList-DEo8Bqoe.mjs} +3 -3
  115. package/dist/client/{propsDecoder-DhbGL302.mjs → propsDecoder-G0j0HXBO.mjs} +3 -28
  116. package/dist/client/{registry.server-BaX0hxf5.mjs → registry.server-BTmSXE3D.mjs} +1154 -997
  117. package/dist/client/rendering/client.mjs +28 -28
  118. package/dist/client/rendering/islands.mjs +1 -1
  119. package/dist/client/rendering.mjs +57 -32
  120. package/dist/client/{richText-coerce-Cny2Ukb6.mjs → richText-coerce-B19taoH6.mjs} +1 -1
  121. package/dist/client/{routeIslandApiConfig-96er7pIx.mjs → routeIslandApiConfig-Chu5BHra.mjs} +1 -1
  122. package/dist/client/{ThemedButton-DVBC_pS9.mjs → schema-C-m8XHuW.mjs} +1123 -2362
  123. package/dist/client/{shop-CnIJfdZA.mjs → shop-RGWa43H7.mjs} +3 -3
  124. package/dist/client/{shop-commerce-CsLwzq5O.mjs → shop-commerce-TJYCBO_H.mjs} +12 -12
  125. package/dist/client/{shop-commerce-store--O8GRBwr.mjs → shop-commerce-store-CjCcUB_o.mjs} +1 -1
  126. package/dist/client/{shop.client-BcaJ-acA.mjs → shop.client-tsKfZw1W.mjs} +15 -15
  127. package/dist/client/{shop.interactive-BxL_bshW.mjs → shop.interactive-CVqLAU53.mjs} +370 -189
  128. package/dist/client/{shopShared-VZjPOfCX.mjs → shopShared-C3lHMz_R.mjs} +2 -2
  129. package/dist/client/{src-7cXhT0G_.mjs → src-VIsPY-kw.mjs} +6 -1
  130. package/dist/client/timetableModel-V2ifvGGy.mjs +1100 -0
  131. package/dist/client/{useAvailableSlots-pTXuY3jV.mjs → useAvailableSlots-D1X69-pN.mjs} +4 -4
  132. package/dist/client/{useBookingNowIso-D14J-EhJ.mjs → useBookingNowIso-Ch30jino.mjs} +1 -1
  133. package/dist/client/{useDiscountApply-o5sIVZ2u.mjs → useDiscountApply-Bwzr1RjV.mjs} +3 -3
  134. package/dist/client/{useDiscountCodeUi-DJhFP_rg.mjs → useDiscountCodeUi-BimJbFC7.mjs} +1 -1
  135. package/dist/client/{useEventPagination-DMmNf2FP.mjs → useEventPagination-CLAS0upd.mjs} +12 -24
  136. package/dist/client/uuid-BETKW8rS.mjs +12 -0
  137. package/dist/client/{view-BgPql2yH2.mjs → view-BUh4LnLS.mjs} +4 -4
  138. package/dist/client/{view-D1R3Lk05.mjs → view-Dj_FZHmg.mjs} +19 -15
  139. package/dist/client/wizardSteps-BkZc-hKH.mjs +6598 -0
  140. package/dist/preview-next/before-render.mjs +5 -4
  141. package/dist/preview-next/chrome.css +2 -0
  142. package/dist/preview-next/client/{EventEmbeddedCheckoutStep-BFlBqSu4.mjs → EventEmbeddedCheckoutStep-CwerMfzn.mjs} +2 -1
  143. package/dist/preview-next/client/LocationPickerEnvironment-QtSG2Bl-.mjs +138 -0
  144. package/dist/preview-next/client/MapLibreEditMap-B-rohNcG.mjs +488 -0
  145. package/dist/preview-next/client/{PreviewEditorSidebar-DADCj_ET.mjs → PreviewEditorSidebar-Dvq-RW9-.mjs} +1328 -171
  146. package/dist/preview-next/client/{PreviewEditorUI-La40Dmmh.mjs → PreviewEditorUI-BdFjS39R.mjs} +53 -79
  147. package/dist/preview-next/client/{SdkPreviewModeRuntime-406Hw9zY.mjs → SdkPreviewModeRuntime-BEfHln1E.mjs} +1249 -2551
  148. package/dist/preview-next/client/{SdkPreviewModeRuntime-CWN44I_B.mjs → SdkPreviewModeRuntime-CjkGh1IG.mjs} +1 -1
  149. package/dist/preview-next/client/{SiteChromeCustomizeContext-BdwEZoo9.mjs → SiteChromeCustomizeContext-CDbxk_qZ.mjs} +117481 -162497
  150. package/dist/preview-next/client/{ThemedButton-BEOPss9H.mjs → ThemedButton-b14Bv03E.mjs} +1253 -403
  151. package/dist/preview-next/client/lucide-react-CA9cpo0P.mjs +51984 -0
  152. package/dist/preview-next/client/maplibre-gl-DykfOYYn.mjs +34208 -0
  153. package/dist/preview-next/client/{previewChromeSurface-BVUKIYG0.mjs → previewChromeSurface-Dd1_mNIg.mjs} +3 -8
  154. package/dist/preview-next/client/result-BjJUoxUF.mjs +16 -0
  155. package/dist/preview-next/client/rolldown-runtime-CE6sIgz8.mjs +34 -0
  156. package/dist/preview-next/client/runtime.mjs +3 -3
  157. package/dist/preview-next/client/{sdk-runtime-Cy9AKPy5.mjs → sdk-runtime-B-CXyGVb.mjs} +1 -1
  158. package/dist/preview-next/client/siteStyleAccess-Kqk0j0dE.mjs +5812 -0
  159. package/dist/preview-next/client/{spinner-Bhpzz2vO.mjs → spinner-CGxS8Ns-.mjs} +2 -1
  160. package/dist/preview-next/{constants-D8Ya7bO4.mjs → constants-Bf-vqdKH.mjs} +2 -1
  161. package/dist/preview-next/editor-base.css +64 -2
  162. package/dist/preview-next/editor-chrome.css +85 -0
  163. package/dist/preview-next/keepAlive.mjs +2 -2
  164. package/dist/preview-next/middleware.mjs +7 -3
  165. package/dist/preview-next/{route-contract-DM22uOXM.mjs → route-contract-hLg-yjQN.mjs} +190 -116
  166. package/dist/preview-next/{session-BgkrPqu0.mjs → session-P1R_ajT7.mjs} +12 -2
  167. package/dist/preview-next/session.mjs +1 -1
  168. package/dist/server/{Block.shared-DB6fb1pR.mjs → Block.shared-CeTd2saO.mjs} +6 -6
  169. package/dist/server/{bindings-z2daXp-2.mjs → bindings-C5YpKuKt.mjs} +3 -2
  170. package/dist/server/{client-Cv-osXoU.mjs → client-Cv26lZQ4.mjs} +14 -10
  171. package/dist/server/config-template-validation.mjs +50 -10
  172. package/dist/server/config-validation.mjs +1 -1
  173. package/dist/server/config.mjs +2 -2
  174. package/dist/server/{siteChromeOverlayClearance-BangtD8A.mjs → effectiveNavLinkStyle-CGvGr3yD.mjs} +572 -1078
  175. package/dist/server/index.mjs +3 -3
  176. package/dist/server/{loadContent-BNMDYCm8.mjs → loadContent-C8a0b-cC.mjs} +40 -21
  177. package/dist/server/loadPage--DXBwI8V.mjs +2 -0
  178. package/dist/server/{loadPage-CjA_F_AF.mjs → loadPage-BW7dklu3.mjs} +9 -5
  179. package/dist/server/manifest.mjs +1 -1
  180. package/dist/server/next.mjs +9 -9
  181. package/dist/server/{overrideResolution-CGodrtqi.mjs → overrideResolution-tIuqmJB3.mjs} +1 -1
  182. package/dist/server/{overrides-DxRC724a.mjs → overrides-D1fiPOKF.mjs} +1158 -754
  183. package/dist/server/page-converter.mjs +8 -10
  184. package/dist/server/{prebuild-C6bhjRKT.mjs → prebuild--fO0E2tr.mjs} +1 -1
  185. package/dist/server/prebuild.mjs +1 -1
  186. package/dist/server/{prefetchBlockData-DZ5Fq_-r.mjs → prefetchBlockData-CqJnokWJ.mjs} +968 -968
  187. package/dist/server/{publicProducts-C3meXS2o.mjs → publicProducts-CvvZ4JIe.mjs} +207 -132
  188. package/dist/server/{blocks-BaG8Qpaa.mjs → registry-BVfCqaCq.mjs} +2853 -2799
  189. package/dist/server/rendering/server.mjs +4 -4
  190. package/dist/server/rendering.mjs +8 -8
  191. package/dist/server/{resolveBlockData-CbGDakvp.mjs → resolveBlockData-DPNvhXEz.mjs} +6 -3
  192. package/dist/server/routing.mjs +1 -1
  193. package/dist/server/{schema-Bs735S27.mjs → schema-CD4peO7m.mjs} +2441 -1401
  194. package/dist/server/server.mjs +3 -3
  195. package/dist/server/site-styles-H-EvTJiW.mjs +787 -0
  196. package/dist/server/siteChromeOverlayClearance-DNC2k1U0.mjs +750 -0
  197. package/dist/server/{src-B935_bzN.mjs → src-ILxc6pid.mjs} +427 -190
  198. package/dist/server/theme-bridge.mjs +1 -1
  199. package/dist/server/theme.mjs +1 -1
  200. package/dist/server/{themeAdmission-DK2YBNqy.mjs → themeAdmission-BNHIXiUj.mjs} +117 -26
  201. package/dist/server/{three-pass-converter-CmmchOFC.mjs → three-pass-converter-Chnb1XD-.mjs} +2 -58
  202. package/dist/server/{validation-BtHE2S_D.mjs → validation-B1ieVemg.mjs} +22 -63
  203. package/dist/server/{version-CNCdL6id.mjs → version-BQK44wFg.mjs} +1 -1
  204. package/dist/styles/index.css +235 -0
  205. package/package.json +8 -3
  206. package/dist/_dts/index-CXsnaCGe.d.ts +0 -10
  207. package/dist/_dts/index-cnymEAZY.d.ts +0 -1
  208. package/dist/client/LeafletStaticMap-dlapZ6mi.mjs +0 -135
  209. package/dist/client/location-map.client-DRN1JePj.mjs +0 -28
  210. package/dist/client/location-map.view-CuCvQdvp.mjs +0 -282
  211. package/dist/client/locationMap-B9srHHzZ.mjs +0 -15
  212. package/dist/client/mediaContext-DThoeEBU.mjs +0 -136
  213. package/dist/client/renderableMediaAssetAdmission-DGjBr_e-.mjs +0 -152
  214. package/dist/client/timetableModel-D09jPdue.mjs +0 -480
  215. package/dist/client/wizardSteps-C0TsNqJc.mjs +0 -17049
  216. package/dist/preview-next/client/siteStyleAccess-CFMmoMZb.mjs +0 -1326
  217. package/dist/server/loadPage-jade28Xh.mjs +0 -2
  218. package/dist/server/media-CcHwZkdJ.mjs +0 -243
@@ -1,53 +1,8 @@
1
1
  "use client";
2
+ import { n as ok, t as err } from "./result-BjJUoxUF.mjs";
2
3
  import "react";
3
4
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
4
5
  import { z } from "zod";
5
- //#region \0rolldown/runtime.js
6
- var __create = Object.create;
7
- var __defProp = Object.defineProperty;
8
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
- var __getOwnPropNames = Object.getOwnPropertyNames;
10
- var __getProtoOf = Object.getPrototypeOf;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
13
- var __exportAll = (all, no_symbols) => {
14
- let target = {};
15
- for (var name in all) __defProp(target, name, {
16
- get: all[name],
17
- enumerable: true
18
- });
19
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
20
- return target;
21
- };
22
- var __copyProps = (to, from, except, desc) => {
23
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
24
- key = keys[i];
25
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
26
- get: ((k) => from[k]).bind(null, key),
27
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
28
- });
29
- }
30
- return to;
31
- };
32
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
33
- value: mod,
34
- enumerable: true
35
- }) : target, mod));
36
- //#endregion
37
- //#region ../core/src/result.ts
38
- function ok(value) {
39
- return {
40
- ok: true,
41
- value
42
- };
43
- }
44
- function err(error) {
45
- return {
46
- ok: false,
47
- error
48
- };
49
- }
50
- //#endregion
51
6
  //#region ../core/src/branded.ts
52
7
  const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
53
8
  function parseUuidBrand(value, unsafeConstructor) {
@@ -776,70 +731,92 @@ const checkoutCopy = {
776
731
  //#region ../commerce/src/purchase/event-registration-errors.ts
777
732
  const eventRegistrationErrors = {
778
733
  registrationClosed: {
734
+ endsCommand: false,
779
735
  message: "Booking is currently closed for this event. Please contact the organiser if you’d like to find out more.",
780
736
  action: "none"
781
737
  },
782
738
  paymentInvestigationRequired: {
739
+ endsCommand: false,
783
740
  message: "We still can’t confirm your payment. Please don’t make another payment. Contact the organiser so they can check your booking.",
784
741
  action: "none"
785
742
  },
786
743
  paymentProviderUnavailable: {
744
+ endsCommand: false,
787
745
  message: "We couldn’t reach the payment provider. Please try again in a minute.",
788
746
  action: "retry"
789
747
  },
790
748
  paymentHostUnavailable: {
749
+ endsCommand: false,
791
750
  message: "Card payments aren’t available on this web address yet. Please contact the organiser to book.",
792
751
  action: "none"
793
752
  },
794
- checkoutTemporarilyUnavailable: {
795
- message: "Event payments are temporarily unavailable while we make an update. Please try again later.",
796
- action: "retry"
797
- },
798
753
  paymentPageUnavailable: {
754
+ endsCommand: false,
799
755
  message: "We couldn’t open the payment page. Please refresh this page and try again. If this keeps happening, contact the organiser for help.",
800
756
  action: "retry"
801
757
  },
802
758
  paymentUnavailable: {
759
+ endsCommand: false,
803
760
  message: "Online payment is not available for this event right now. Please contact the organiser for help with booking.",
804
761
  action: "none"
805
762
  },
806
763
  capacityChanged: {
764
+ endsCommand: false,
807
765
  message: "Sorry, there aren’t enough places left for your selection. Please check the available places and choose again.",
808
766
  action: "places"
809
767
  },
810
768
  selectionChanged: {
769
+ endsCommand: false,
811
770
  message: "The booking options for this event have changed. Please check the latest options and choose your places again.",
812
771
  action: "places"
813
772
  },
773
+ paymentSetupFailed: {
774
+ endsCommand: true,
775
+ message: "We couldn't set up payment for this booking, so your place hasn't been reserved and you haven't been charged. Please try again in a few minutes, or contact the organiser if it keeps happening.",
776
+ action: "retry"
777
+ },
778
+ registrationAttemptEnded: {
779
+ endsCommand: true,
780
+ message: "That booking attempt has ended, so we couldn't finish it. You haven't been charged. Please start your booking again.",
781
+ action: "start"
782
+ },
814
783
  registrationPreparationChanged: {
784
+ endsCommand: true,
815
785
  message: "The booking options for this event have changed. Please check the latest options and choose your places again.",
816
786
  action: "places"
817
787
  },
818
788
  registrationAlreadyExists: {
789
+ endsCommand: false,
819
790
  message: "You already have a booking for this event. Please check your bookings to see its status. If you need help, contact the organiser.",
820
791
  action: "portal"
821
792
  },
822
793
  holdExpired: {
794
+ endsCommand: false,
823
795
  message: "Your reservation has timed out. Please check availability and choose your places again.",
824
796
  action: "start"
825
797
  },
826
798
  waitlistUnavailable: {
799
+ endsCommand: false,
827
800
  message: "Sorry, the waiting list place offered in this invitation is no longer available. Please check the event for available places or contact the organiser for help.",
828
801
  action: "event"
829
802
  },
830
803
  paymentContextMismatch: {
804
+ endsCommand: false,
831
805
  message: "The payment options for this event have changed. Please check the latest options before continuing.",
832
806
  action: "payment-options"
833
807
  },
834
808
  verificationFailed: {
809
+ endsCommand: false,
835
810
  message: "We couldn’t confirm this request came from a person. Please refresh the page and try again.",
836
811
  action: "none"
837
812
  },
838
813
  idempotencyConflict: {
814
+ endsCommand: false,
839
815
  message: "You’ve already started booking this event. Please finish in the other tab if it’s still open, or check your booking status before starting again.",
840
816
  action: "portal"
841
817
  },
842
818
  invalidCommitInput: {
819
+ endsCommand: false,
843
820
  message: "We couldn’t accept your booking details. Please check the information you entered and try again. If this keeps happening, contact the organiser for help.",
844
821
  action: "details"
845
822
  }
@@ -847,6 +824,11 @@ const eventRegistrationErrors = {
847
824
  function parseEventRegistrationErrorReason(value) {
848
825
  return typeof value === "string" && Object.prototype.hasOwnProperty.call(eventRegistrationErrors, value) ? value : null;
849
826
  }
827
+ /** Only a server-confirmed refusal ends an identity; transport uncertainty retains it. */
828
+ function eventRegistrationErrorEndsCommand(value) {
829
+ const reason = parseEventRegistrationErrorReason(value);
830
+ return reason !== null && eventRegistrationErrors[reason].endsCommand;
831
+ }
850
832
  //#endregion
851
833
  //#region ../commerce/src/purchase/checkoutPresentation.ts
852
834
  function publishableKeyMode(publishableKey) {
@@ -3333,11 +3315,33 @@ function relativeLuminance(r, g, b) {
3333
3315
  const R = srgbToLinear(r), G = srgbToLinear(g), B = srgbToLinear(b);
3334
3316
  return .2126 * R + .7152 * G + .0722 * B;
3335
3317
  }
3336
- function contrastRatio(hex1, hex2) {
3337
- const { r: r1, g: g1, b: b1 } = hexToRgb(hex1);
3338
- const { r: r2, g: g2, b: b2 } = hexToRgb(hex2);
3339
- const L1 = relativeLuminance(r1, g1, b1);
3340
- const L2 = relativeLuminance(r2, g2, b2);
3318
+ function preparePaletteColourIndex(palette) {
3319
+ const colours = [.../* @__PURE__ */ new Set([
3320
+ ...Object.values(palette),
3321
+ "#000000",
3322
+ "#ffffff",
3323
+ "#FFFFFF"
3324
+ ])];
3325
+ return Object.freeze(Object.fromEntries(colours.flatMap(colourIndexEntry)));
3326
+ }
3327
+ /** An unused unsupported colour must not turn preparation into an eager validation failure. */
3328
+ function colourIndexEntry(hex) {
3329
+ try {
3330
+ return [[hex, colourLuminance(hex)]];
3331
+ } catch {
3332
+ return [];
3333
+ }
3334
+ }
3335
+ function colourLuminance(hex) {
3336
+ const { r, g, b } = hexToRgb(hex);
3337
+ return relativeLuminance(r, g, b);
3338
+ }
3339
+ function indexedLuminance(hex, index) {
3340
+ return (index && Object.prototype.hasOwnProperty.call(index, hex) ? index[hex] : void 0) ?? colourLuminance(hex);
3341
+ }
3342
+ function contrastRatio(hex1, hex2, index) {
3343
+ const L1 = indexedLuminance(hex1, index);
3344
+ const L2 = indexedLuminance(hex2, index);
3341
3345
  const [hi, lo] = L1 >= L2 ? [L1, L2] : [L2, L1];
3342
3346
  return (hi + .05) / (lo + .05);
3343
3347
  }
@@ -3490,10 +3494,10 @@ function resolveOpaqueSurfaceHex(reference, palette, underlayReference) {
3490
3494
  const parts = parseColorTokenParts(reference);
3491
3495
  if (parts.kind === "token" && parts.opacityPercent !== null) {
3492
3496
  const foregroundHex = normalizePaletteHex(palette[parts.token] ?? "");
3493
- return foregroundHex ? compositeHex$1(foregroundHex, underlayHex, parts.opacityPercent / 100) : null;
3497
+ return foregroundHex ? compositeHex$2(foregroundHex, underlayHex, parts.opacityPercent / 100) : null;
3494
3498
  }
3495
3499
  const rgba = parseRgba(parts.kind === "raw" ? parts.value : reference);
3496
- return rgba ? compositeHex$1(rgbToHex(rgba.r, rgba.g, rgba.b), underlayHex, rgba.alpha) : null;
3500
+ return rgba ? compositeHex$2(rgbToHex(rgba.r, rgba.g, rgba.b), underlayHex, rgba.alpha) : null;
3497
3501
  }
3498
3502
  /** Resolve a colour reference only when it is already fully opaque. */
3499
3503
  function resolveConcreteColorHex(reference, palette) {
@@ -3509,7 +3513,7 @@ function resolveConcreteColorHex(reference, palette) {
3509
3513
  if (literal.toLowerCase() === "white") return "#ffffff";
3510
3514
  return normalizePaletteHex(literal);
3511
3515
  }
3512
- function compositeHex$1(foregroundHex, underlayHex, alpha) {
3516
+ function compositeHex$2(foregroundHex, underlayHex, alpha) {
3513
3517
  const foreground = hexToRgb(foregroundHex);
3514
3518
  const underlay = hexToRgb(underlayHex);
3515
3519
  const channel = (foregroundValue, underlayValue) => Math.round(foregroundValue * alpha + underlayValue * (1 - alpha));
@@ -3583,10 +3587,10 @@ const CONTRAST_GLASS_ALPHA = .6;
3583
3587
  */
3584
3588
  function worstCaseGlassBackdrop(tone) {
3585
3589
  const [over, tint] = tone === "dark" ? ["#ffffff", "#000000"] : ["#000000", "#ffffff"];
3586
- return compositeHex(tint, over, CONTRAST_GLASS_ALPHA);
3590
+ return compositeHex$1(tint, over, CONTRAST_GLASS_ALPHA);
3587
3591
  }
3588
3592
  /** Flatten `foreground` at `alpha` over `background` into an opaque hex. */
3589
- function compositeHex(foreground, background, alpha) {
3593
+ function compositeHex$1(foreground, background, alpha) {
3590
3594
  const f = hexToRgb(foreground);
3591
3595
  const b = hexToRgb(background);
3592
3596
  return rgbToHex(Math.round(mix$1(b.r, f.r, alpha)), Math.round(mix$1(b.g, f.g, alpha)), Math.round(mix$1(b.b, f.b, alpha)));
@@ -3846,8 +3850,8 @@ function expandBasePalette(palette) {
3846
3850
  function deriveSurfaceDecorationColors(ground, text, accent) {
3847
3851
  const ink = getTextColorForBackground(ground);
3848
3852
  return {
3849
- line: firstContrastBlend(ground, text, ground, 1.5),
3850
- mark: firstContrastBlend(accent, ink, ground, 3)
3853
+ line: firstContrastBlend$1(ground, text, ground, 1.5),
3854
+ mark: firstContrastBlend$1(accent, ink, ground, 3)
3851
3855
  };
3852
3856
  }
3853
3857
  /** Secondary ink is blended toward its ground, with an ordinary-text contrast floor. */
@@ -3863,7 +3867,7 @@ function firstSafeMutedSample(sample, ground, low, high) {
3863
3867
  const middle = Math.floor((low + high) / 2);
3864
3868
  return contrastRatio(sample(middle), ground) >= 4.5 ? firstSafeMutedSample(sample, ground, low, middle) : firstSafeMutedSample(sample, ground, middle + 1, high);
3865
3869
  }
3866
- function firstContrastBlend(from, to, ground, threshold) {
3870
+ function firstContrastBlend$1(from, to, ground, threshold) {
3867
3871
  const start = hexToRgb(from);
3868
3872
  const end = hexToRgb(to);
3869
3873
  return Array.from({ length: 101 }, (_, index) => {
@@ -4064,6 +4068,20 @@ function selectLogoVariant(tone, variants) {
4064
4068
  return tone === "dark" ? forDarkBackgrounds ?? forLightBackgrounds : forLightBackgrounds ?? forDarkBackgrounds;
4065
4069
  }
4066
4070
  //#endregion
4071
+ //#region ../theme-core/src/site-styles/ownedThemeSnapshot.ts
4072
+ /** Copy before freezing: the editor still owns its source data. */
4073
+ function ownedThemeSnapshot(input) {
4074
+ return freezeOwnedThemeValue(structuredClone(input));
4075
+ }
4076
+ /** Only freshly owned data belongs here; no caller-owned object is frozen. */
4077
+ function freezeOwnedThemeValue(value) {
4078
+ if (typeof value === "object" && value !== null) {
4079
+ Object.values(value).forEach(freezeOwnedThemeValue);
4080
+ Object.freeze(value);
4081
+ }
4082
+ return value;
4083
+ }
4084
+ //#endregion
4067
4085
  //#region ../theme-core/src/buttons/styles/domain.ts
4068
4086
  const PUBLIC_BUTTON_ROLES = VARIANT_ROLES;
4069
4087
  function defineButtonStyleRecipe(recipe) {
@@ -4071,6 +4089,7 @@ function defineButtonStyleRecipe(recipe) {
4071
4089
  }
4072
4090
  function mapButtonVisualAppearances(states, transform) {
4073
4091
  return {
4092
+ ...states,
4074
4093
  base: transform(states.base, "base"),
4075
4094
  hover: transform(states.hover, "hover"),
4076
4095
  focus: transform(states.focus, "focus"),
@@ -4889,7 +4908,7 @@ function formatButtonColourContractError(error) {
4889
4908
  }
4890
4909
  }
4891
4910
  function validateButtonSurfaceContrast(input) {
4892
- const ratio = contrastRatio(input.buttonPaint, input.surfaceHex);
4911
+ const ratio = contrastRatio(input.buttonPaint, input.surfaceHex, input.colourIndex);
4893
4912
  return ratio >= BUTTON_CONTRAST_POLICY.nonTextMinimumRatio ? { ok: true } : {
4894
4913
  ok: false,
4895
4914
  error: {
@@ -4904,7 +4923,7 @@ function validateButtonSurfaceContrast(input) {
4904
4923
  };
4905
4924
  }
4906
4925
  function validateButtonTextContrast(input) {
4907
- const ratio = contrastRatio(input.backgroundHex, input.foregroundHex);
4926
+ const ratio = contrastRatio(input.backgroundHex, input.foregroundHex, input.colourIndex);
4908
4927
  return ratio >= BUTTON_CONTRAST_POLICY.textMinimumRatio ? { ok: true } : {
4909
4928
  ok: false,
4910
4929
  error: {
@@ -4926,7 +4945,7 @@ function solidForegroundToken(backgroundToken) {
4926
4945
  //#region ../theme-core/src/buttons/contextualHover.ts
4927
4946
  function resolveContextualHoverPreference(input) {
4928
4947
  const preferred = input.instruction.preferredToken;
4929
- if (preferred && isSafeCandidate(preferred, input.palette, input.surface)) return {
4948
+ if (preferred && isSafeCandidate(preferred, input.palette, input.surface, input.colourIndex)) return {
4930
4949
  kind: "resolved",
4931
4950
  token: preferred,
4932
4951
  repair: null
@@ -4954,7 +4973,7 @@ function resolveContextualHover(input) {
4954
4973
  kind: "unavailable",
4955
4974
  reason: "no-distinct-shade"
4956
4975
  };
4957
- const textSafe = candidates.filter((candidate) => hasSafeTextContrast(candidate.token, input.palette));
4976
+ const textSafe = candidates.filter((candidate) => hasSafeTextContrast(candidate.token, input.palette, input.colourIndex));
4958
4977
  if (textSafe.length === 0) return {
4959
4978
  kind: "unavailable",
4960
4979
  reason: "no-text-safe-candidate"
@@ -4971,17 +4990,12 @@ function resolveContextualHover(input) {
4971
4990
  reason: "no-text-safe-candidate"
4972
4991
  };
4973
4992
  }
4974
- const selected = textSafe.map((candidate) => ({
4975
- ...candidate,
4976
- surfaceContrast: contrastRatio(input.palette[candidate.token] ?? "", input.surface?.backgroundHex ?? "")
4977
- })).filter((candidate) => candidate.surfaceContrast !== null && candidate.surfaceContrast >= BUTTON_CONTRAST_POLICY.nonTextMinimumRatio).sort((left, right) => {
4978
- const distanceDifference = left.distance - right.distance;
4979
- if (distanceDifference !== 0) return distanceDifference;
4980
- const contrastDifference = (right.surfaceContrast ?? 0) - (left.surfaceContrast ?? 0);
4981
- if (contrastDifference !== 0) return contrastDifference;
4982
- if (left.direction === right.direction) return left.token.localeCompare(right.token);
4983
- return left.direction === input.instruction.fallbackDirection ? -1 : 1;
4984
- })[0];
4993
+ const selected = selectSurfaceSafeHover(textSafe, {
4994
+ palette: input.palette,
4995
+ surface: input.surface,
4996
+ colourIndex: input.colourIndex,
4997
+ fallbackDirection: input.instruction.fallbackDirection
4998
+ });
4985
4999
  return selected ? {
4986
5000
  kind: "resolved",
4987
5001
  token: selected.token,
@@ -4992,6 +5006,20 @@ function resolveContextualHover(input) {
4992
5006
  reason: "no-surface-safe-candidate"
4993
5007
  };
4994
5008
  }
5009
+ /** Rank the proven-surface candidates without mixing selection with fallback policy. */
5010
+ function selectSurfaceSafeHover(candidates, input) {
5011
+ return candidates.map((candidate) => ({
5012
+ ...candidate,
5013
+ surfaceContrast: contrastRatio(input.palette[candidate.token] ?? "", input.surface.backgroundHex, input.colourIndex)
5014
+ })).filter((candidate) => candidate.surfaceContrast !== null && candidate.surfaceContrast >= BUTTON_CONTRAST_POLICY.nonTextMinimumRatio).sort((left, right) => {
5015
+ const distanceDifference = left.distance - right.distance;
5016
+ if (distanceDifference !== 0) return distanceDifference;
5017
+ const contrastDifference = (right.surfaceContrast ?? 0) - (left.surfaceContrast ?? 0);
5018
+ if (contrastDifference !== 0) return contrastDifference;
5019
+ if (left.direction === right.direction) return left.token.localeCompare(right.token);
5020
+ return left.direction === input.fallbackDirection ? -1 : 1;
5021
+ })[0];
5022
+ }
4995
5023
  function shadeCandidates(seedToken, palette) {
4996
5024
  const match = String(seedToken).match(/^(.*?)(?:-(\d{2,3}))?$/);
4997
5025
  const family = match?.[1] ?? String(seedToken);
@@ -5017,14 +5045,14 @@ function candidate(family, shade, currentShade, direction, seedHex, palette) {
5017
5045
  surfaceContrast: null
5018
5046
  };
5019
5047
  }
5020
- function hasSafeTextContrast(token, palette) {
5048
+ function hasSafeTextContrast(token, palette, colourIndex) {
5021
5049
  const background = palette[token];
5022
5050
  const foreground = palette[solidForegroundToken(token)];
5023
- return typeof background === "string" && typeof foreground === "string" && contrastRatio(background, foreground) >= BUTTON_CONTRAST_POLICY.textMinimumRatio;
5051
+ return typeof background === "string" && typeof foreground === "string" && contrastRatio(background, foreground, colourIndex) >= BUTTON_CONTRAST_POLICY.textMinimumRatio;
5024
5052
  }
5025
- function isSafeCandidate(token, palette, surface) {
5026
- if (!hasSafeTextContrast(token, palette)) return false;
5027
- return surface ? contrastRatio(palette[token] ?? "", surface.backgroundHex) >= BUTTON_CONTRAST_POLICY.nonTextMinimumRatio : true;
5053
+ function isSafeCandidate(token, palette, surface, colourIndex) {
5054
+ if (!hasSafeTextContrast(token, palette, colourIndex)) return false;
5055
+ return surface ? contrastRatio(palette[token] ?? "", surface.backgroundHex, colourIndex) >= BUTTON_CONTRAST_POLICY.nonTextMinimumRatio : true;
5028
5056
  }
5029
5057
  function escapeRegExp(value) {
5030
5058
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -5036,6 +5064,7 @@ function resolveButtonHoverTreatment(input) {
5036
5064
  const contextual = resolveContextualHoverPreference({
5037
5065
  instruction: input.variant.contextualHover,
5038
5066
  palette: input.palette,
5067
+ colourIndex: input.colourIndex,
5039
5068
  surface: input.surface
5040
5069
  });
5041
5070
  if (contextual.kind === "resolved") return {
@@ -5087,7 +5116,8 @@ function compileButtonColourStates(input) {
5087
5116
  global: input.global,
5088
5117
  fallback: base.treatment,
5089
5118
  palette: input.palette,
5090
- surface: input.surface
5119
+ surface: input.surface,
5120
+ colourIndex: input.colourIndex
5091
5121
  });
5092
5122
  const edge = buttonEdge(input.variant);
5093
5123
  const colours = collectStateColours(mapVisualStates((state) => compileVisualState(input, state, state === "hover" ? hover.treatment : base.treatment, edge, base.nonColourEffects)));
@@ -5145,6 +5175,7 @@ function compileDeclaredVisualState(input, states, state, treatment) {
5145
5175
  treatment: transition.treatment,
5146
5176
  palette: input.palette,
5147
5177
  surface: input.surface,
5178
+ colourIndex: input.colourIndex,
5148
5179
  edge
5149
5180
  });
5150
5181
  return resolved.ok ? {
@@ -5171,6 +5202,7 @@ function compileVisualState(input, state, treatment, edge, baseEffects) {
5171
5202
  treatment: transition.treatment,
5172
5203
  palette: input.palette,
5173
5204
  surface: input.surface,
5205
+ colourIndex: input.colourIndex,
5174
5206
  edge
5175
5207
  });
5176
5208
  return resolved.ok ? {
@@ -5389,11 +5421,11 @@ function interpolateHex(startHex, endHex, position) {
5389
5421
  * Derive only what the rendered section can honestly prove about its backing.
5390
5422
  * Images, gradients, alpha/composite layers and arbitrary CSS remain unknown.
5391
5423
  */
5392
- function deriveButtonSurfaceContext(input, palette, fallbackToken) {
5424
+ function deriveButtonSurfaceContext(input, palette, fallbackToken, colourIndex) {
5393
5425
  const background = deriveKnownBackground(input, palette, fallbackToken);
5394
5426
  if (background.kind === "unknown") return background;
5395
5427
  const explicitForeground = resolveKnownColour(input.kind === "solid" || input.kind === "inherit" ? input.foreground ?? "" : "", palette);
5396
- const foreground = explicitForeground && contrastRatio(background.colour.hex, explicitForeground.hex) >= 4.5 ? explicitForeground : safestBlackOrWhite(background.colour.hex);
5428
+ const foreground = explicitForeground && contrastRatio(background.colour.hex, explicitForeground.hex, colourIndex) >= 4.5 ? explicitForeground : safestBlackOrWhite(background.colour.hex, colourIndex);
5397
5429
  return {
5398
5430
  kind: "known-solid",
5399
5431
  source: background.source,
@@ -5476,7 +5508,7 @@ function resolveSurfaceButtonContext(input) {
5476
5508
  kind: "inherit",
5477
5509
  styles: {}
5478
5510
  };
5479
- const context = deriveButtonSurfaceContext(input.surface, input.palette, input.fallbackToken);
5511
+ const context = deriveButtonSurfaceContext(input.surface, input.palette, input.fallbackToken, input.colourIndex);
5480
5512
  if (context.kind !== "known-solid") return context.reason === "missing-background" ? {
5481
5513
  kind: "inherit",
5482
5514
  styles: {}
@@ -5484,23 +5516,42 @@ function resolveSurfaceButtonContext(input) {
5484
5516
  kind: "reset",
5485
5517
  styles: contextualButtonSurfaceResetStyles()
5486
5518
  };
5487
- return {
5488
- kind: "resolved",
5489
- styles: knownSurfaceButtonContextStyles({
5490
- surface: context.surface,
5491
- palette: input.palette,
5492
- buttonSystem: surfaceButtonSystem(input.buttonSystem, input.primaryToken)
5493
- })
5494
- };
5495
- }
5496
- /** Every role's contextual styles against one proven solid surface. */
5497
- function knownSurfaceButtonContextStyles(input) {
5498
- return Object.fromEntries(VARIANT_ROLES.flatMap((role) => Object.entries(contextualButtonSurfaceStyles(resolveContextualButtonRole({
5499
- role,
5500
- buttonSystem: input.buttonSystem,
5519
+ return knownSurfaceButtonContext({
5520
+ surface: context.surface,
5501
5521
  palette: input.palette,
5502
- surface: input.surface
5503
- })))));
5522
+ colourIndex: input.colourIndex,
5523
+ buttonSystem: surfaceButtonSystem(input.buttonSystem, input.primaryToken)
5524
+ });
5525
+ }
5526
+ function knownSurfaceButtonContext(input) {
5527
+ const roles = freezeOwnedThemeValue({
5528
+ primary: resolveContextualButtonRole({
5529
+ ...input,
5530
+ role: "primary"
5531
+ }),
5532
+ secondary: resolveContextualButtonRole({
5533
+ ...input,
5534
+ role: "secondary"
5535
+ }),
5536
+ outline: resolveContextualButtonRole({
5537
+ ...input,
5538
+ role: "outline"
5539
+ }),
5540
+ ghost: resolveContextualButtonRole({
5541
+ ...input,
5542
+ role: "ghost"
5543
+ }),
5544
+ accent: resolveContextualButtonRole({
5545
+ ...input,
5546
+ role: "accent"
5547
+ })
5548
+ });
5549
+ const styles = Object.fromEntries(VARIANT_ROLES.flatMap((role) => Object.entries(contextualButtonSurfaceStyles(roles[role]))));
5550
+ return Object.defineProperty({
5551
+ kind: "resolved",
5552
+ styles,
5553
+ roles
5554
+ }, "roles", { enumerable: false });
5504
5555
  }
5505
5556
  function resolveContextualButtonRole(input) {
5506
5557
  const requested = findVariant(input.buttonSystem, input.role);
@@ -5509,57 +5560,57 @@ function resolveContextualButtonRole(input) {
5509
5560
  requestedRole: input.role,
5510
5561
  rejectedCandidates: []
5511
5562
  };
5512
- const rejected = [];
5513
- const preferred = compileCandidate(requested, input.buttonSystem, input.palette, input.surface);
5514
- if (preferred.ok) {
5515
- if (preferred.contextualHoverRepair) return {
5516
- kind: "repaired",
5517
- requestedRole: input.role,
5518
- candidate: "contextual-hover",
5519
- states: preferred.states,
5520
- focusIndicator: preferred.focusIndicator,
5521
- boundary: boundaryForVariant(requested),
5522
- rejectedCandidates: []
5523
- };
5524
- return {
5525
- kind: "preferred",
5526
- requestedRole: input.role,
5527
- states: preferred.states,
5528
- focusIndicator: preferred.focusIndicator,
5529
- boundary: boundaryForVariant(requested)
5530
- };
5531
- }
5532
- rejected.push({
5563
+ const preferred = compileCandidate(requested, input);
5564
+ if (preferred.ok) return preferredButtonResolution(requested, preferred, input.role);
5565
+ return resolveFallbackButtonRole(input, requested, (input.buttonSystem.surfacePolicy ?? STANDARD_BUTTON_SURFACE_POLICY)[input.role], [{
5533
5566
  candidate: "preferred",
5534
5567
  error: preferred.error
5568
+ }]);
5569
+ }
5570
+ function preferredButtonResolution(requested, compiled, role) {
5571
+ const appearance = {
5572
+ requestedRole: role,
5573
+ states: compiled.states,
5574
+ focusIndicator: compiled.focusIndicator,
5575
+ boundary: boundaryForVariant(requested)
5576
+ };
5577
+ const boundaries = boundariesForVariant(requested);
5578
+ return compiled.contextualHoverRepair ? hideBoundaryEvidence({
5579
+ ...appearance,
5580
+ boundaries,
5581
+ kind: "repaired",
5582
+ candidate: "contextual-hover",
5583
+ rejectedCandidates: []
5584
+ }) : hideBoundaryEvidence({
5585
+ ...appearance,
5586
+ boundaries,
5587
+ kind: "preferred"
5535
5588
  });
5536
- const policy = input.buttonSystem.surfacePolicy ?? STANDARD_BUTTON_SURFACE_POLICY;
5537
- for (const fallback of policy[input.role]) {
5538
- const candidate = candidateVariant(fallback, requested, input.buttonSystem);
5539
- if (!candidate) continue;
5540
- const compiled = compileCandidate(candidate.variant, input.buttonSystem, input.palette, input.surface);
5541
- if (!compiled.ok) {
5542
- rejected.push({
5543
- candidate: candidate.name,
5544
- error: compiled.error
5545
- });
5546
- continue;
5547
- }
5548
- return {
5549
- kind: "repaired",
5550
- requestedRole: input.role,
5551
- candidate: candidate.name,
5552
- states: candidate.name === "surface-outline" ? withSurfaceInversion(compiled.states, input.surface) : compiled.states,
5553
- focusIndicator: compiled.focusIndicator,
5554
- boundary: candidate.boundary,
5555
- rejectedCandidates: rejected
5556
- };
5557
- }
5558
- return {
5589
+ }
5590
+ /** Ordered, lazy fallback selection; the rejected evidence belongs to this decision. */
5591
+ function resolveFallbackButtonRole(input, requested, fallbacks, rejected) {
5592
+ const [fallback, ...remaining] = fallbacks;
5593
+ if (!fallback) return {
5559
5594
  kind: "unresolved",
5560
5595
  requestedRole: input.role,
5561
5596
  rejectedCandidates: rejected
5562
5597
  };
5598
+ const candidate = candidateVariant(fallback, requested, input.buttonSystem);
5599
+ if (!candidate) return resolveFallbackButtonRole(input, requested, remaining, rejected);
5600
+ const compiled = compileCandidate(candidate.variant, input);
5601
+ return compiled.ok ? hideBoundaryEvidence({
5602
+ kind: "repaired",
5603
+ requestedRole: input.role,
5604
+ candidate: candidate.name,
5605
+ boundaries: boundariesForVariant(candidate.variant),
5606
+ states: candidate.name === "surface-outline" ? withSurfaceInversion(compiled.states, input.surface) : compiled.states,
5607
+ focusIndicator: compiled.focusIndicator,
5608
+ boundary: candidate.boundary,
5609
+ rejectedCandidates: rejected
5610
+ }) : resolveFallbackButtonRole(input, requested, remaining, [...rejected, {
5611
+ candidate: candidate.name,
5612
+ error: compiled.error
5613
+ }]);
5563
5614
  }
5564
5615
  function contextualButtonSurfaceStyles(resolution) {
5565
5616
  if (resolution.kind === "unresolved") return resetActionVariables(resolution.requestedRole);
@@ -5624,12 +5675,13 @@ function actionVariableFallback(role, state, property, fallback) {
5624
5675
  function actionVariablePrefix(role, state) {
5625
5676
  return `--rb-action-${role}-${state}`;
5626
5677
  }
5627
- function compileCandidate(variant, system, palette, surface) {
5678
+ function compileCandidate(variant, context) {
5628
5679
  return compileButtonColourStates({
5629
5680
  variant,
5630
- global: system.global,
5631
- palette,
5632
- surface
5681
+ global: context.buttonSystem.global,
5682
+ palette: context.palette,
5683
+ surface: context.surface,
5684
+ colourIndex: context.colourIndex
5633
5685
  });
5634
5686
  }
5635
5687
  function candidateVariant(fallback, requested, system) {
@@ -5662,6 +5714,25 @@ function candidateVariant(fallback, requested, system) {
5662
5714
  }
5663
5715
  };
5664
5716
  }
5717
+ function hideBoundaryEvidence(value) {
5718
+ return Object.defineProperty(value, "boundaries", { enumerable: false });
5719
+ }
5720
+ function boundariesForVariant(variant) {
5721
+ const boundary = (state) => {
5722
+ const appearance = variant.visualStates?.[state];
5723
+ return boundaryForVariant(appearance ? {
5724
+ ...variant,
5725
+ border: appearance.border === "none" ? void 0 : appearance.border
5726
+ } : variant);
5727
+ };
5728
+ return freezeOwnedThemeValue({
5729
+ base: boundary("base"),
5730
+ hover: boundary("hover"),
5731
+ focus: boundary("focus"),
5732
+ active: boundary("active"),
5733
+ disabled: boundary("disabled")
5734
+ });
5735
+ }
5665
5736
  function boundaryForVariant(variant) {
5666
5737
  if (!variant.border) return null;
5667
5738
  return {
@@ -5749,8 +5820,8 @@ function normalizeOpaqueHex(value) {
5749
5820
  if (!match?.[1]) return null;
5750
5821
  return `#${(match[1].length === 3 ? match[1].split("").map((digit) => `${digit}${digit}`).join("") : match[1]).toLowerCase()}`;
5751
5822
  }
5752
- function safestBlackOrWhite(backgroundHex) {
5753
- return contrastRatio(backgroundHex, "#000000") >= contrastRatio(backgroundHex, "#ffffff") ? {
5823
+ function safestBlackOrWhite(backgroundHex, colourIndex) {
5824
+ return contrastRatio(backgroundHex, "#000000", colourIndex) >= contrastRatio(backgroundHex, "#ffffff", colourIndex) ? {
5754
5825
  hex: "#000000",
5755
5826
  css: "#000000",
5756
5827
  source: "literal-css"
@@ -5774,246 +5845,77 @@ function contextualBoundaryStyles(boundary) {
5774
5845
  };
5775
5846
  }
5776
5847
  //#endregion
5777
- //#region ../theme-core/src/surfaces/opaqueSurface.ts
5778
- function opaqueSurfaceContextFromTheme(theme) {
5779
- return {
5780
- palette: expandPalette(theme.palette),
5781
- buttonSystem: theme.buttons,
5782
- linkHoverToken: theme.typography.proseLinkStyle?.hoverColorToken
5783
- };
5848
+ //#region ../theme-core/src/palette/utils/scrimContrast.ts
5849
+ const WHITE = "#ffffff";
5850
+ const BLACK = "#000000";
5851
+ /** `top` at `alpha` over opaque `bottom`, blended as CSS paints an overlay. */
5852
+ function compositeHex(topHex, alpha, bottomHex) {
5853
+ const top = hexToRgb(topHex);
5854
+ const bottom = hexToRgb(bottomHex);
5855
+ const mix = (a, b) => Math.round(alpha * a + (1 - alpha) * b);
5856
+ return rgbToHex(mix(top.r, bottom.r), mix(top.g, bottom.g), mix(top.b, bottom.b));
5784
5857
  }
5785
5858
  /**
5786
- * The declarations that make an element own its surface: `color`, every
5787
- * `--rb-surface-*` role and every `--rb-action-*` variable. Card roles and
5788
- * opaque block panels both publish through this, so a nested surface can never
5789
- * inherit a band's light text or its band-resolved buttons.
5859
+ * The lowest contrast `foreground` can reach over `scrim` at `alpha` laid on
5860
+ * any pixel. A foreground whose luminance falls inside the range the
5861
+ * composites can take has a worst case of 1:1.
5790
5862
  */
5791
- function opaqueSurfaceDeclarations(surface, arrangement = false) {
5792
- if (surface.kind === "inherit") return inheritedSurfaceDeclarations(arrangement);
5793
- const foreground = surface.foreground;
5794
- return [
5795
- ...surfaceForegroundDeclarations({
5796
- text: colorValue(foreground.text),
5797
- heading: colorValue(foreground.heading),
5798
- link: colorValue(foreground.link),
5799
- linkHover: colorValue(foreground.linkHover),
5800
- supporting: colorValue(foreground.supporting),
5801
- ...arrangement ? { muted: colorValue(foreground.muted) } : {},
5802
- hoverDecoration: surface.hoverDecoration
5803
- }),
5804
- ...arrangement && surface.decorations !== void 0 ? [`${SURFACE_FOREGROUND_CSS_VARS.line}: ${surface.decorations.line};`, `${SURFACE_FOREGROUND_CSS_VARS.mark}: ${surface.decorations.mark};`] : [],
5805
- ...Object.entries(surface.buttonContext.styles).map(([property, value]) => `${property}: ${value};`)
5806
- ];
5807
- }
5808
- function colorValue(token) {
5809
- const parsed = parseThemeColorToken(token);
5810
- return parsed ? rgbColorValue(parsed) : token;
5811
- }
5812
- /** Every property a surface publishes, set to `inherit`. */
5813
- function inheritedSurfaceDeclarations(arrangement) {
5814
- return [
5815
- "color",
5816
- ...Object.entries(SURFACE_FOREGROUND_CSS_VARS).filter(([role]) => arrangement || role !== "line" && role !== "mark" && role !== "muted").map(([, variable]) => variable),
5817
- "--rb-surface-link-hover-decoration",
5818
- ...Object.keys(contextualButtonSurfaceResetStyles())
5819
- ].map((property) => `${property}: inherit;`);
5820
- }
5821
- //#endregion
5822
- //#region ../theme-core/src/utils/colorStyles.ts
5823
- const COLOR_VAR_PREFIX = "--tb-";
5824
- function parseToken(source) {
5825
- const parts = parseColorTokenParts(source);
5826
- if (parts.kind === "raw") return {
5827
- token: source,
5828
- raw: parts.value
5829
- };
5830
- if (parts.kind === "invalid") return { token: source };
5831
- return {
5832
- token: parts.token,
5833
- opacityPercent: parts.opacityPercent === null ? void 0 : parts.opacityPercent
5863
+ function worstCaseScrimContrast(input) {
5864
+ const overWhite = compositeHex(input.scrimHex, input.alpha, WHITE);
5865
+ const overBlack = compositeHex(input.scrimHex, input.alpha, BLACK);
5866
+ const luminance = (hex) => {
5867
+ const { r, g, b } = hexToRgb(hex);
5868
+ return relativeLuminance(r, g, b);
5834
5869
  };
5835
- }
5836
- const SURFACE_TEXT_ROLE_BY_TOKEN = {
5837
- text: "text",
5838
- heading: "heading",
5839
- mutedText: "supporting"
5840
- };
5841
- function surfaceRoleForTextToken(token) {
5842
- return Object.prototype.hasOwnProperty.call(SURFACE_TEXT_ROLE_BY_TOKEN, token) ? SURFACE_TEXT_ROLE_BY_TOKEN[token] : null;
5843
- }
5844
- /**
5845
- * Converts a theme color token to a CSS rgb value.
5846
- * This is the primary function for applying theme colors to CSS properties.
5847
- *
5848
- * @param token - Theme color token (semantic, with opacity, or raw)
5849
- * @returns CSS color value (rgb with optional alpha, or raw CSS value)
5850
- *
5851
- * @example
5852
- * rgbColorValue('primary') // => 'rgb(var(--tb-primary))'
5853
- * rgbColorValue('surface/95') // => 'rgb(var(--tb-surface) / 0.95)'
5854
- * rgbColorValue('raw:transparent') // => 'transparent'
5855
- */
5856
- function rgbColorValue(token) {
5857
- const { token: baseToken, opacityPercent, raw } = parseToken(token);
5858
- if (raw) return raw;
5859
- const cssVar = `${COLOR_VAR_PREFIX}${baseToken}`;
5860
- if (opacityPercent === void 0) return `rgb(var(${cssVar}))`;
5861
- return `rgb(var(${cssVar}) / ${opacityPercent / 100})`;
5862
- }
5863
- /**
5864
- * Converts a theme color token to a CSS variable reference.
5865
- * Note: This returns the base variable without rgb() wrapper, ignoring opacity.
5866
- *
5867
- * @param token - Theme color token
5868
- * @returns CSS variable reference
5869
- *
5870
- * @example
5871
- * cssVarValue('primary') // => 'var(--tb-primary)'
5872
- * cssVarValue('surface/95') // => 'var(--tb-surface)' (opacity ignored)
5873
- */
5874
- function cssVarValue(token) {
5875
- const { token: baseToken } = parseToken(token);
5876
- return `var(${COLOR_VAR_PREFIX}${baseToken})`;
5877
- }
5878
- /**
5879
- * Creates a backgroundColor style object from a theme token.
5880
- *
5881
- * @param token - Theme color token
5882
- * @returns CSSProperties with backgroundColor
5883
- */
5884
- function backgroundColorStyle(token) {
5885
- return { backgroundColor: rgbColorValue(token) };
5886
- }
5887
- /**
5888
- * Converts a text color token to a CSS color value that follows the enclosing
5889
- * surface. The semantic text tokens (`text`, `heading`, `mutedText`) resolve
5890
- * to the surface foreground variables, so text adapts when a section's
5891
- * background changes; any other token is a fixed theme color.
5892
- *
5893
- * @param token - Theme color token
5894
- * @returns CSS color value
5895
- */
5896
- function textColorValue(token) {
5897
- const parsed = parseToken(token);
5898
- const surfaceRole = parsed.raw ? null : surfaceRoleForTextToken(parsed.token);
5899
- if (!surfaceRole) return rgbColorValue(token);
5900
- return parsed.opacityPercent === void 0 ? surfaceForegroundValue(surfaceRole) : surfaceForegroundValueWithOpacity(surfaceRole, parsed.opacityPercent);
5870
+ const foreground = luminance(input.foregroundHex);
5871
+ const low = luminance(overBlack);
5872
+ const high = luminance(overWhite);
5873
+ if (foreground >= low && foreground <= high) return 1;
5874
+ return Math.min(contrastRatio(input.foregroundHex, overWhite), contrastRatio(input.foregroundHex, overBlack));
5901
5875
  }
5902
5876
  /**
5903
- * Creates a text color style object from a theme token.
5904
- *
5905
- * @param token - Theme color token
5906
- * @returns CSSProperties with color
5877
+ * The smallest scrim opacity, in hundredths, at which every foreground keeps
5878
+ * `threshold` contrast over any pixel. `null` when even an opaque scrim fails,
5879
+ * which means the foreground was never legible on the scrim colour itself.
5907
5880
  */
5908
- function textColorStyle(token) {
5909
- return { color: textColorValue(token) };
5881
+ function minimumScrimOpacity(input) {
5882
+ const passes = (alpha) => input.foregroundHexes.every((foregroundHex) => worstCaseScrimContrast({
5883
+ foregroundHex,
5884
+ scrimHex: input.scrimHex,
5885
+ alpha
5886
+ }) >= input.threshold);
5887
+ return Array.from({ length: 101 }, (_, hundredths) => hundredths / 100).find(passes) ?? null;
5888
+ }
5889
+ /** Shared samples for literal RGB washes and palette-token gradient veils. */
5890
+ function gradientScrimSamples(gradient, alpha, palette) {
5891
+ const literal = [...gradient.matchAll(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/g)].map((stop) => ({
5892
+ hex: rgbToHex(Number(stop[1]), Number(stop[2]), Number(stop[3])),
5893
+ alpha: alpha * (stop[4] === void 0 ? 1 : Number(stop[4]))
5894
+ }));
5895
+ const tokens = [...gradient.matchAll(/var\(--tb-([\w-]+)\)/g)].flatMap((stop) => {
5896
+ const hex = stop[1] ? resolveConcreteColorHex(stop[1], palette) : null;
5897
+ return hex ? [{
5898
+ hex,
5899
+ alpha
5900
+ }] : [];
5901
+ });
5902
+ return [...literal, ...tokens];
5910
5903
  }
5911
- /**
5912
- * Creates a border color style object from a theme token.
5913
- *
5914
- * @param token - Theme color token
5915
- * @returns CSSProperties with borderColor
5904
+ /** The ink with the stronger worst-pixel guarantee identifies the veil tone.
5905
+ * No readable samples (or a tie) leaves classification to the foreground owner.
5916
5906
  */
5917
- function borderColorStyle(token) {
5918
- return { borderColor: rgbColorValue(token) };
5919
- }
5920
- /**
5921
- * Merges multiple CSSProperties objects into a single object.
5922
- * Later styles override earlier ones. Undefined values are filtered out.
5923
- * Returns undefined if the merged result is empty.
5924
- *
5925
- * @param styles - Variable number of CSSProperties objects (can be undefined)
5926
- * @returns Merged CSSProperties object, or undefined if empty
5927
- *
5928
- * @example
5929
- * mergeStyles(
5930
- * backgroundColorStyle('surface'),
5931
- * textColorStyle('text'),
5932
- * borderColorStyle('border')
5933
- * )
5934
- * // => { backgroundColor: '...', color: '...', borderColor: '...' }
5935
- */
5936
- function mergeStyles(...styles) {
5937
- const merged = {};
5938
- for (const style of styles) {
5939
- if (!style) continue;
5940
- Object.assign(merged, style);
5941
- }
5942
- return Object.keys(merged).length ? merged : void 0;
5907
+ function scrimTone(samples) {
5908
+ if (samples.length === 0) return null;
5909
+ const worst = (foregroundHex) => Math.min(...samples.map((sample) => worstCaseScrimContrast({
5910
+ foregroundHex,
5911
+ scrimHex: sample.hex,
5912
+ alpha: sample.alpha
5913
+ })));
5914
+ const white = worst(WHITE);
5915
+ const black = worst(BLACK);
5916
+ return white === black ? null : white > black ? "dark" : "light";
5943
5917
  }
5944
5918
  //#endregion
5945
- //#region ../theme-core/src/tokens/resolver.ts
5946
- /**
5947
- * Resolves theme tokens to CSS variables
5948
- *
5949
- * This resolver ensures all button styles use theme tokens (not hardcoded colors)
5950
- * so that changing the palette automatically updates all buttons.
5951
- */
5952
- var TokenResolver = class {
5953
- constructor(theme) {
5954
- this.theme = theme;
5955
- }
5956
- /**
5957
- * Resolve a color token to a CSS variable reference wrapped in rgb()
5958
- *
5959
- * @param token - Token name (e.g., 'primary-500', 'white', 'text-900')
5960
- * @returns CSS rgb() function with var reference (e.g., 'rgb(var(--tb-primary-500))')
5961
- *
5962
- * Note: CSS variables are stored as RGB channels (e.g., "37 99 235") following Tailwind convention,
5963
- * so we must wrap them with rgb() to create a valid color value.
5964
- *
5965
- * @example
5966
- * resolver.getColor('primary-500') // => 'rgb(var(--tb-primary-500))'
5967
- * resolver.getColor('white') // => 'rgb(var(--tb-white))'
5968
- */
5969
- getColor(token) {
5970
- if (!this.tokenExists(token)) console.warn(`[TokenResolver] Color token "${token}" not found in theme palette. Button may render incorrectly.`);
5971
- return rgbColorValue(token);
5972
- }
5973
- /**
5974
- * Adjust a color token's shade by a given amount
5975
- *
5976
- * @param token - Base token (e.g., 'primary-500')
5977
- * @param amount - Shade adjustment (+100 = darker, -100 = lighter)
5978
- * @returns Adjusted token name (e.g., 'primary-600')
5979
- *
5980
- * @example
5981
- * resolver.adjustShade('primary-500', 100) // => 'primary-600' (darker)
5982
- * resolver.adjustShade('primary-500', -100) // => 'primary-400' (lighter)
5983
- */
5984
- adjustShade(token, amount) {
5985
- const parts = token.split("-");
5986
- if (parts.length < 2) return `${token}-${Math.max(100, Math.min(900, 500 + amount))}`;
5987
- const base = parts.slice(0, -1).join("-");
5988
- const shade = parseInt(parts[parts.length - 1] ?? "", 10);
5989
- if (isNaN(shade)) {
5990
- console.warn(`[TokenResolver] Cannot adjust shade for non-shade token "${token}". Returning original token.`);
5991
- return token;
5992
- }
5993
- return `${base}-${Math.max(100, Math.min(900, shade + amount))}`;
5994
- }
5995
- /**
5996
- * Check if a token exists in the theme palette
5997
- *
5998
- * @param token - Token name to check
5999
- * @returns True if token exists in theme
6000
- */
6001
- tokenExists(token) {
6002
- if ([
6003
- "white",
6004
- "black",
6005
- "transparent"
6006
- ].includes(token)) return true;
6007
- const parts = token.split("-");
6008
- if (parts.length >= 2) {
6009
- const lastPart = parts[parts.length - 1] ?? "";
6010
- const shade = parseInt(lastPart, 10);
6011
- if (!isNaN(shade) && shade >= 100 && shade <= 900 && shade % 100 === 0) return true;
6012
- }
6013
- return true;
6014
- }
6015
- };
6016
- //#endregion
6017
5919
  //#region ../theme-core/src/site-styles/accessibleSurfaces.ts
6018
5920
  const ON_BACKGROUND = { kind: "on-background" };
6019
5921
  const contrastThresholdByPolicy = {
@@ -6374,9 +6276,139 @@ function terminalFallbackSurface(input) {
6374
6276
  function assertNeverSurface(value) {
6375
6277
  throw new Error(`Unhandled Theme V2 surface intent: ${String(value)}`);
6376
6278
  }
6279
+ const resolvedSurfaceBrand = Symbol("ResolvedSurface");
6280
+ const surfaceOwners = /* @__PURE__ */ new WeakSet();
6281
+ const preparedIndexOwners = /* @__PURE__ */ new WeakSet();
6282
+ const surfaceTransports = /* @__PURE__ */ new WeakMap();
6283
+ const ownedRevisionInputs = /* @__PURE__ */ new WeakMap();
6284
+ const revisionOwners = /* @__PURE__ */ new WeakMap();
6285
+ const surfaceRevisionOwners = /* @__PURE__ */ new WeakMap();
6286
+ const surfaceTextPolicy = Object.freeze({
6287
+ heading: "large-text-aa",
6288
+ text: "body-aa",
6289
+ link: "body-aa",
6290
+ linkHover: "body-aa",
6291
+ supporting: "body-aa",
6292
+ muted: "body-aa"
6293
+ });
6294
+ function ownSurfaceRevision(context) {
6295
+ if (!ownedRevisionInputs.get(context.palette)?.has(context.buttonSystem)) {
6296
+ const revision = ownedThemeSnapshot({
6297
+ palette: context.palette,
6298
+ buttonSystem: context.buttonSystem
6299
+ });
6300
+ registerOwnedRevisionInputs(revision);
6301
+ surfaceRevisionOwners.set(revision, revision);
6302
+ revisionOwners.set(revision.palette, /* @__PURE__ */ new Map([[revision.buttonSystem, revision]]));
6303
+ return revision;
6304
+ }
6305
+ const revisions = revisionOwners.get(context.palette) ?? /* @__PURE__ */ new Map();
6306
+ const existing = revisions.get(context.buttonSystem);
6307
+ if (existing) return existing;
6308
+ const revision = Object.freeze({
6309
+ palette: context.palette,
6310
+ buttonSystem: context.buttonSystem
6311
+ });
6312
+ surfaceRevisionOwners.set(revision, revision);
6313
+ revisions.set(context.buttonSystem, revision);
6314
+ revisionOwners.set(context.palette, revisions);
6315
+ return revision;
6316
+ }
6317
+ /** Local computation keeps its colour index; transport references only the owning revision inputs. */
6318
+ function surfaceTransportContext(context) {
6319
+ const revision = ownSurfaceRevision(context);
6320
+ const result = Object.freeze({
6321
+ ...revision,
6322
+ colourIndex: context.colourIndex
6323
+ });
6324
+ surfaceRevisionOwners.set(result, revision);
6325
+ return result;
6326
+ }
6327
+ /** Called only after copying and recursively freezing owner inputs. */
6328
+ function registerOwnedRevisionInputs(context) {
6329
+ const buttons = ownedRevisionInputs.get(context.palette) ?? /* @__PURE__ */ new Set();
6330
+ buttons.add(context.buttonSystem);
6331
+ ownedRevisionInputs.set(context.palette, buttons);
6332
+ }
6333
+ function isResolvedSurface(value) {
6334
+ return typeof value === "object" && value !== null && surfaceOwners.has(value) && "kind" in value && (value.kind === "owned" || value.kind === "inherit");
6335
+ }
6336
+ /** Opaque immutable surface/context values have no child DTOs to project. */
6337
+ function isSurfaceTransportLeaf(value) {
6338
+ return isResolvedSurface(value) || isSurfaceTreeRecord(value) && surfaceRevisionOwners.has(value);
6339
+ }
6340
+ /** Runtime serializers reject copies and forged structural objects, too. */
6341
+ function requireResolvedSurface(value) {
6342
+ if (!isResolvedSurface(value)) throw new Error("Surface must be produced by resolveSurface");
6343
+ }
6377
6344
  function resolveSurface(spec, context) {
6345
+ return spec.kind === "section" ? resolveSectionSurface(spec.background, context) : preparedSurfaceValue(spec, context) ?? certifySurface(spec, context);
6346
+ }
6347
+ /** Own one theme revision; derive its surface decisions without copying its inputs again. */
6348
+ function prepareThemeSurfaceRevision(inputTheme, selectSurfaces = () => []) {
6349
+ const theme = structuredClone(inputTheme);
6350
+ const snapshot = freezeOwnedThemeValue(theme);
6351
+ const declarations = ownedThemeSnapshot(selectSurfaces(snapshot));
6352
+ const palette = freezeOwnedThemeValue(expandPalette(snapshot.palette, {
6353
+ arrangement: snapshot.skin !== void 0,
6354
+ marksFrom: snapshot.skinMarks
6355
+ }));
6356
+ const context = Object.freeze({
6357
+ kind: "concrete-palette",
6358
+ palette,
6359
+ colourIndex: preparePaletteColourIndex(palette),
6360
+ buttonSystem: snapshot.buttons
6361
+ });
6362
+ registerOwnedRevisionInputs(context);
6363
+ const preparedSurfaces = declarations.length === 0 ? void 0 : surfaceIndexFromOwnedInputs(declarations, context);
6364
+ return Object.freeze({
6365
+ theme,
6366
+ context: Object.freeze({
6367
+ ...context,
6368
+ preparedSurfaces
6369
+ })
6370
+ });
6371
+ }
6372
+ /** Private construction path: both entry points above own and freeze these inputs. */
6373
+ function surfaceIndexFromOwnedInputs(specs, context) {
6374
+ registerOwnedRevisionInputs(context);
6375
+ const entries = [...new Map(specs.map((spec) => [surfaceResolutionKey(spec, context), spec]))].flatMap(([key, spec]) => preparedSurfaceEntry(key, spec, context));
6376
+ const index = Object.freeze({
6377
+ palette: context.palette,
6378
+ buttonSystem: context.buttonSystem,
6379
+ colourIndex: context.colourIndex,
6380
+ values: freezeOwnedThemeValue(Object.fromEntries(entries))
6381
+ });
6382
+ preparedIndexOwners.add(index);
6383
+ return index;
6384
+ }
6385
+ function preparedSurfaceEntry(key, spec, context) {
6386
+ try {
6387
+ return [[key, certifySurface(spec, context)]];
6388
+ } catch {
6389
+ return [];
6390
+ }
6391
+ }
6392
+ function preparedSurfaceValue(spec, context) {
6393
+ const index = context.preparedSurfaces;
6394
+ if (!index || !preparedIndexOwners.has(index) || index.palette !== context.palette || index.buttonSystem !== context.buttonSystem || index.colourIndex !== context.colourIndex) return void 0;
6395
+ return index.values[surfaceResolutionKey(spec, context)];
6396
+ }
6397
+ function surfaceResolutionKey(spec, context) {
6398
+ const declaration = spec.kind === "tint" ? {
6399
+ ...spec,
6400
+ opacity: String(spec.opacity)
6401
+ } : spec;
6402
+ return JSON.stringify([
6403
+ declaration,
6404
+ context.linkHoverToken,
6405
+ context.foreground,
6406
+ context.compositeBase,
6407
+ context.buttonContext
6408
+ ]);
6409
+ }
6410
+ function resolveSurfaceSpec(spec, context) {
6378
6411
  switch (spec.kind) {
6379
- case "section": return resolveSectionSurface(spec.background, context);
6380
6412
  case "recipe": return resolveRecipeSurface(spec.intent, context);
6381
6413
  case "paint": return spec.paint.kind === "transparent" ? { kind: "inherit" } : resolveOwnedSurface(spec.paint, context);
6382
6414
  case "token": return resolveOwnedSurface({
@@ -6447,7 +6479,7 @@ function resolveOwnedSurface(paint, context) {
6447
6479
  }, context.palette, {
6448
6480
  linkHover: context.linkHoverToken,
6449
6481
  ...context.foreground
6450
- });
6482
+ }, { compositeBase: context.compositeBase });
6451
6483
  return {
6452
6484
  kind: "owned",
6453
6485
  paint,
@@ -6455,7 +6487,7 @@ function resolveOwnedSurface(paint, context) {
6455
6487
  decorations: surfaceDecorationColors(resolved, context.palette),
6456
6488
  hoverDecoration: resolved.kind === "known" ? resolved.hoverDecoration : "underline",
6457
6489
  buttonContext: resolveSurfaceButtons(paint, resolved, context),
6458
- contrast: surfaceContrast(resolved, context.palette)
6490
+ contrast: surfaceContrast(resolved, context.palette, context.colourIndex)
6459
6491
  };
6460
6492
  }
6461
6493
  /** Unprovable legacy paint retains its declared foreground instead of inventing one. */
@@ -6480,15 +6512,17 @@ function resolveSurfaceButtons(paint, foreground, context) {
6480
6512
  foreground: foreground.kind === "known" ? foreground.roles.link : void 0
6481
6513
  } : { kind: "gradient" },
6482
6514
  palette: context.palette,
6515
+ colourIndex: context.colourIndex,
6483
6516
  buttonSystem: context.buttonSystem,
6517
+ fallbackToken: context.compositeBase,
6484
6518
  primaryToken: context.buttonContext?.primary ?? (paint.kind === "solid" ? context.buttonSystem?.surfaceContexts?.[paint.token]?.primary : void 0),
6485
6519
  withoutButtonSystem: "reset"
6486
6520
  });
6487
6521
  }
6488
- function surfaceContrast(foreground, palette) {
6522
+ function surfaceContrast(foreground, palette, colourIndex) {
6489
6523
  if (foreground.kind !== "known" || foreground.provenance.kind !== "measured") return { kind: "unmeasured" };
6490
6524
  const backdrop = foreground.provenance.backdropHex;
6491
- const ratio = (token) => contrastRatio(resolveConcreteColorHex(token, palette) ?? backdrop, backdrop);
6525
+ const ratio = (token) => contrastRatio(resolveConcreteColorHex(token, palette) ?? backdrop, backdrop, colourIndex);
6492
6526
  return {
6493
6527
  kind: "measured",
6494
6528
  ratios: {
@@ -6507,23 +6541,35 @@ function resolveSectionSurface(background, context) {
6507
6541
  linkHover: context.linkHoverToken,
6508
6542
  ...context.foreground
6509
6543
  }, { compositeBase: context.compositeBase });
6510
- return {
6544
+ const surface = background === null ? { kind: "inherit" } : background.type === "color" ? {
6545
+ kind: "solid",
6546
+ color: background.color,
6547
+ composited: false,
6548
+ foreground: foreground.kind === "known" ? foreground.roles.link : void 0
6549
+ } : background.type === "gradient" ? { kind: "gradient" } : { kind: "image" };
6550
+ const revision = ownSurfaceRevision(context);
6551
+ const result = {
6511
6552
  kind: "section",
6512
6553
  foreground,
6513
6554
  buttonStyles: resolveSurfaceButtonContext({
6514
- surface: background === null ? { kind: "inherit" } : background.type === "color" ? {
6515
- kind: "solid",
6516
- color: background.color,
6517
- composited: false,
6518
- foreground: foreground.kind === "known" ? foreground.roles.link : void 0
6519
- } : background.type === "gradient" ? { kind: "gradient" } : { kind: "image" },
6520
- palette: context.palette,
6521
- buttonSystem: context.buttonSystem,
6555
+ surface,
6556
+ palette: revision.palette,
6557
+ buttonSystem: revision.buttonSystem,
6522
6558
  primaryToken: sectionPrimaryButtonToken(background, context),
6523
6559
  fallbackToken: context.compositeBase,
6524
6560
  withoutButtonSystem: "inherit"
6525
- }).styles
6561
+ }).styles,
6562
+ proof: sectionProof(background, foreground),
6563
+ revision,
6564
+ textPolicy: surfaceTextPolicy,
6565
+ [resolvedSurfaceBrand]: true
6526
6566
  };
6567
+ Object.defineProperties(result, {
6568
+ proof: { enumerable: false },
6569
+ revision: { enumerable: false },
6570
+ textPolicy: { enumerable: false }
6571
+ });
6572
+ return freezeOwnedThemeValue(result);
6527
6573
  }
6528
6574
  function sectionPrimaryButtonToken(background, context) {
6529
6575
  if (background?.type !== "color" || typeof background.color !== "string") return void 0;
@@ -6537,10 +6583,11 @@ function surfaceDecorationColors(foreground, palette) {
6537
6583
  }
6538
6584
  /** Composite the declared palette tint before checking every foreground role. */
6539
6585
  function resolveTintSurface(spec, context) {
6540
- const base = resolveOwnedSurface({
6541
- kind: "solid",
6586
+ const base = resolveSurface({
6587
+ kind: "token",
6542
6588
  token: spec.base
6543
6589
  }, context);
6590
+ if (base.kind !== "owned") throw new Error(`Cannot derive tint on ${spec.base}`);
6544
6591
  const source = spec.source === "text" ? base.foreground.text : base.decorations?.mark;
6545
6592
  const token = source ? resolveOpaqueSurfaceHex(`${source}/${spec.opacity}`, context.palette, spec.base) : null;
6546
6593
  const hex = source ? resolveConcreteColorHex(source, context.palette) : null;
@@ -6553,15 +6600,818 @@ function resolveTintSurface(spec, context) {
6553
6600
  ...context,
6554
6601
  foreground: base.foreground
6555
6602
  });
6556
- return spec.gradient === "radial" ? {
6603
+ if (spec.gradient !== "radial") return surface;
6604
+ assertTintSamples(surface, spec.base, context.palette);
6605
+ return {
6557
6606
  ...surface,
6558
6607
  tintBase: spec.base
6559
- } : surface;
6608
+ };
6609
+ }
6610
+ /** A sampled gradient may never borrow a proof for just its painted endpoint. */
6611
+ function assertTintSamples(surface, base, palette) {
6612
+ if (surface.paint.kind !== "solid") throw new Error("Tint must paint a solid endpoint");
6613
+ const paint = resolveOpaqueSurfaceHex(surface.paint.token, palette, base);
6614
+ const underlay = resolveOpaqueSurfaceHex(base, palette, "background");
6615
+ if (!paint || !underlay) throw new Error("Tint needs a measurable underlay");
6616
+ const samples = [
6617
+ 0,
6618
+ .25,
6619
+ .5,
6620
+ .75,
6621
+ 1
6622
+ ].map((alpha) => compositeHex(paint, alpha, underlay));
6623
+ Object.entries(surface.foreground).forEach(([role, token]) => {
6624
+ if (!samples.every((sample) => {
6625
+ const ink = resolveOpaqueSurfaceHex(token, palette, sample);
6626
+ return ink !== null && contrastRatio(ink, sample) >= (role === "heading" ? 3 : 4.5);
6627
+ })) throw new RangeError(`No checked tint gradient for ${role} on ${base}`);
6628
+ });
6560
6629
  }
6561
6630
  function hexToRgba(hex, alpha) {
6562
6631
  const { r, g, b } = hexToRgb(hex);
6563
6632
  return `rgba(${r}, ${g}, ${b}, ${alpha})`;
6564
6633
  }
6634
+ const foregroundInputSchema = z.object({
6635
+ text: z.string().nullable().optional(),
6636
+ heading: z.string().nullable().optional(),
6637
+ link: z.string().nullable().optional(),
6638
+ linkHover: z.string().nullable().optional(),
6639
+ supporting: z.string().nullable().optional()
6640
+ });
6641
+ const paintInputSchema = z.discriminatedUnion("kind", [
6642
+ z.object({
6643
+ kind: z.literal("solid"),
6644
+ token: z.string(),
6645
+ foregroundToken: z.string().optional()
6646
+ }),
6647
+ z.object({
6648
+ kind: z.literal("gradient"),
6649
+ foregroundToken: z.string().optional()
6650
+ }),
6651
+ z.object({ kind: z.literal("transparent") })
6652
+ ]);
6653
+ const buttonInputSchema = z.object({ primary: opaqueButtonColourTokenSchema });
6654
+ const surfaceSpecSchema = z.discriminatedUnion("kind", [
6655
+ z.object({
6656
+ kind: z.literal("recipe"),
6657
+ intent: z.enum([
6658
+ "base",
6659
+ "muted-band",
6660
+ "accent-band",
6661
+ "brand-depth-band"
6662
+ ])
6663
+ }),
6664
+ z.object({
6665
+ kind: z.literal("paint"),
6666
+ paint: paintInputSchema
6667
+ }),
6668
+ z.object({
6669
+ kind: z.literal("token"),
6670
+ token: z.string(),
6671
+ foreground: foregroundInputSchema.optional(),
6672
+ buttonContext: buttonInputSchema.optional()
6673
+ }),
6674
+ z.object({
6675
+ kind: z.literal("tint"),
6676
+ base: z.string(),
6677
+ source: z.enum(["text", "mark"]),
6678
+ opacity: z.number().finite(),
6679
+ gradient: z.literal("radial").optional()
6680
+ })
6681
+ ]);
6682
+ const surfaceTransportSchema = z.object({ $surface: z.object({
6683
+ spec: surfaceSpecSchema,
6684
+ context: z.object({
6685
+ palette: z.record(z.string(), z.string()),
6686
+ buttonSystem: buttonSystemSchema.optional(),
6687
+ foreground: foregroundInputSchema.optional(),
6688
+ linkHoverToken: z.string().optional(),
6689
+ compositeBase: z.string().optional(),
6690
+ buttonContext: buttonInputSchema.optional()
6691
+ })
6692
+ }) });
6693
+ /** Deserialised output is never evidence: parse the inputs and rerun their owner. */
6694
+ function parseResolvedSurface(value) {
6695
+ if (isResolvedSurface(value)) return value;
6696
+ const { spec, context } = surfaceTransportSchema.parse(value).$surface;
6697
+ return resolveSurface(spec, {
6698
+ ...context,
6699
+ buttonSystem: context.buttonSystem
6700
+ });
6701
+ }
6702
+ /** Wire only the owner inputs; parsed CSS/results are recomputed, never trusted. */
6703
+ function serializeResolvedSurface(surface) {
6704
+ requireResolvedSurface(surface);
6705
+ const inputs = surfaceTransports.get(surface);
6706
+ if (!inputs) throw new Error("Missing surface inputs");
6707
+ return { $surface: inputs };
6708
+ }
6709
+ function certifySurface(spec, context) {
6710
+ const revision = ownSurfaceRevision(context);
6711
+ const inputs = {
6712
+ spec: ownedThemeSnapshot(spec),
6713
+ context: Object.freeze({
6714
+ ...revision,
6715
+ ...ownedThemeSnapshot({
6716
+ foreground: context.foreground,
6717
+ linkHoverToken: context.linkHoverToken,
6718
+ compositeBase: context.compositeBase,
6719
+ buttonContext: context.buttonContext
6720
+ })
6721
+ })
6722
+ };
6723
+ const decision = resolveSurfaceSpec(inputs.spec, inputs.context);
6724
+ const result = Object.assign(decision, {
6725
+ [resolvedSurfaceBrand]: true,
6726
+ proof: surfaceProof(decision, spec),
6727
+ revision,
6728
+ textPolicy: surfaceTextPolicy,
6729
+ $surface: inputs
6730
+ });
6731
+ Object.defineProperties(result, {
6732
+ proof: { enumerable: false },
6733
+ revision: { enumerable: false },
6734
+ textPolicy: { enumerable: false }
6735
+ });
6736
+ surfaceOwners.add(result);
6737
+ surfaceTransports.set(result, inputs);
6738
+ return freezeOwnedThemeValue(result);
6739
+ }
6740
+ function surfaceProof(decision, spec) {
6741
+ if (decision.kind === "inherit") return "inherit";
6742
+ if (decision.contrast.kind === "unmeasured") return "unproven-media";
6743
+ if (spec.kind === "tint") return spec.gradient === "radial" ? "checked-gradient-or-scrim" : "checked-composited";
6744
+ return decision.paint.kind === "solid" && /\/|rgba\(/.test(decision.paint.token) ? "checked-composited" : "checked-solid";
6745
+ }
6746
+ function sectionProof(background, foreground) {
6747
+ if (background === null) return "inherit";
6748
+ if (foreground.kind !== "known" || foreground.provenance.kind !== "measured") return "unproven-media";
6749
+ return /\/|rgba\(/.test(background.color ?? "") ? "checked-composited" : "checked-solid";
6750
+ }
6751
+ /** One theme revision per JSON envelope, shared by all nested Look slots. */
6752
+ function serializeSurfaceTree(value) {
6753
+ const revisions = [];
6754
+ const indices = /* @__PURE__ */ new Map();
6755
+ const revisionIndex = (revision) => {
6756
+ const index = indices.get(revision) ?? revisions.length;
6757
+ if (!indices.has(revision)) {
6758
+ indices.set(revision, index);
6759
+ revisions.push(revision);
6760
+ }
6761
+ return index;
6762
+ };
6763
+ const encode = (item) => {
6764
+ const revision = isSurfaceTreeRecord(item) ? surfaceRevisionOwners.get(item) : void 0;
6765
+ if (revision) return { $surfaceRevision: revisionIndex(revision) };
6766
+ if (isResolvedSurface(item)) {
6767
+ const input = serializeResolvedSurface(item).$surface;
6768
+ const index = revisionIndex(item.revision);
6769
+ const { palette: _palette, buttonSystem: _buttons, ...context } = input.context;
6770
+ return { $surface: {
6771
+ spec: input.spec,
6772
+ context,
6773
+ revision: index
6774
+ } };
6775
+ }
6776
+ return mapSurfaceTreeChildren(item, encode);
6777
+ };
6778
+ const encoded = encode(value);
6779
+ return revisions.length === 0 ? encoded : { $surfaceTransport: {
6780
+ revisions,
6781
+ value: encoded
6782
+ } };
6783
+ }
6784
+ const surfaceEnvelopeSchema = z.object({ $surfaceTransport: z.object({
6785
+ revisions: z.array(z.object({
6786
+ palette: z.record(z.string(), z.string()),
6787
+ buttonSystem: buttonSystemSchema.optional()
6788
+ })),
6789
+ value: z.unknown()
6790
+ }) });
6791
+ const surfaceReferenceSchema = z.object({ $surface: z.object({
6792
+ spec: surfaceSpecSchema,
6793
+ revision: z.number().int().nonnegative(),
6794
+ context: z.object({
6795
+ foreground: foregroundInputSchema.optional(),
6796
+ linkHoverToken: z.string().optional(),
6797
+ compositeBase: z.string().optional(),
6798
+ buttonContext: buttonInputSchema.optional()
6799
+ })
6800
+ }) });
6801
+ const surfaceRevisionReferenceSchema = z.object({ $surfaceRevision: z.number().int().nonnegative() });
6802
+ /** Recreate owner results before any island's ordinary schema consumes them. */
6803
+ function parseSurfaceTree(value) {
6804
+ if (isSurfaceTransportLeaf(value)) return value;
6805
+ if (!isSurfaceTreeRecord(value) || !("$surfaceTransport" in value)) return mapSurfaceTreeChildren(value, parseSurfaceTree);
6806
+ const envelope = surfaceEnvelopeSchema.parse(value).$surfaceTransport;
6807
+ const revisions = envelope.revisions.map((revision) => {
6808
+ const owned = ownedThemeSnapshot({
6809
+ palette: revision.palette,
6810
+ buttonSystem: revision.buttonSystem
6811
+ });
6812
+ registerOwnedRevisionInputs(owned);
6813
+ return ownSurfaceRevision(owned);
6814
+ });
6815
+ const decode = (item) => {
6816
+ if (isSurfaceTreeRecord(item) && "$surfaceRevision" in item) {
6817
+ const revision = revisions[surfaceRevisionReferenceSchema.parse(item).$surfaceRevision];
6818
+ if (!revision) throw new Error("Unknown surface revision");
6819
+ return revision;
6820
+ }
6821
+ if (isSurfaceTreeRecord(item) && "$surface" in item) {
6822
+ const request = surfaceReferenceSchema.parse(item).$surface;
6823
+ const revision = revisions[request.revision];
6824
+ if (!revision) throw new Error("Unknown surface revision");
6825
+ return resolveSurface(request.spec, {
6826
+ ...revision,
6827
+ ...request.context,
6828
+ buttonSystem: revision.buttonSystem
6829
+ });
6830
+ }
6831
+ return mapSurfaceTreeChildren(item, decode);
6832
+ };
6833
+ return decode(envelope.value);
6834
+ }
6835
+ function isSurfaceTreeRecord(value) {
6836
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6837
+ }
6838
+ function mapSurfaceTreeChildren(value, map) {
6839
+ if (Array.isArray(value)) return value.map(map);
6840
+ if (value instanceof Date) return value;
6841
+ return isSurfaceTreeRecord(value) ? Object.fromEntries(Object.entries(value).map(([key, item]) => [key, map(item)])) : value;
6842
+ }
6843
+ //#endregion
6844
+ //#region ../theme-core/src/surfaces/opaqueSurface.ts
6845
+ function opaqueSurfaceContextFromTheme(theme) {
6846
+ const palette = expandPalette(theme.palette);
6847
+ return {
6848
+ palette,
6849
+ colourIndex: preparePaletteColourIndex(palette),
6850
+ buttonSystem: theme.buttons,
6851
+ linkHoverToken: theme.typography.proseLinkStyle?.hoverColorToken
6852
+ };
6853
+ }
6854
+ /**
6855
+ * The declarations that make an element own its surface: `color`, every
6856
+ * `--rb-surface-*` role and every `--rb-action-*` variable. Card roles and
6857
+ * opaque block panels both publish through this, so a nested surface can never
6858
+ * inherit a band's light text or its band-resolved buttons.
6859
+ */
6860
+ function opaqueSurfaceDeclarations(surface, arrangement = false) {
6861
+ requireResolvedSurface(surface);
6862
+ if (surface.kind === "inherit") return inheritedSurfaceDeclarations(arrangement);
6863
+ const foreground = surface.foreground;
6864
+ return [
6865
+ ...surfaceForegroundDeclarations({
6866
+ text: colorValue(foreground.text),
6867
+ heading: colorValue(foreground.heading),
6868
+ link: colorValue(foreground.link),
6869
+ linkHover: colorValue(foreground.linkHover),
6870
+ supporting: colorValue(foreground.supporting),
6871
+ ...arrangement ? { muted: colorValue(foreground.muted) } : {},
6872
+ hoverDecoration: surface.hoverDecoration
6873
+ }),
6874
+ ...arrangement && surface.decorations !== void 0 ? [`${SURFACE_FOREGROUND_CSS_VARS.line}: ${surface.decorations.line};`, `${SURFACE_FOREGROUND_CSS_VARS.mark}: ${surface.decorations.mark};`] : [],
6875
+ ...Object.entries(surface.buttonContext.styles).map(([property, value]) => `${property}: ${value};`)
6876
+ ];
6877
+ }
6878
+ function colorValue(token) {
6879
+ const parsed = parseThemeColorToken(token);
6880
+ return parsed ? rgbColorValue(parsed) : token;
6881
+ }
6882
+ /** Every property a surface publishes, set to `inherit`. */
6883
+ function inheritedSurfaceDeclarations(arrangement) {
6884
+ return [
6885
+ "color",
6886
+ ...Object.entries(SURFACE_FOREGROUND_CSS_VARS).filter(([role]) => arrangement || role !== "line" && role !== "mark" && role !== "muted").map(([, variable]) => variable),
6887
+ "--rb-surface-link-hover-decoration",
6888
+ ...Object.keys(contextualButtonSurfaceResetStyles())
6889
+ ].map((property) => `${property}: inherit;`);
6890
+ }
6891
+ //#endregion
6892
+ //#region ../theme-core/src/surfaces/mapDrawingTokens.ts
6893
+ /**
6894
+ * The one map token contract (issue 1611). Drawings carry semantic classes only;
6895
+ * these variables are the only colours a map receives. Each value is resolved
6896
+ * from the section ground the map sits on, so the same geometry reads on light,
6897
+ * brand and dark grounds without regeneration.
6898
+ */
6899
+ const MAP_DRAWING_COLOUR_VARS = {
6900
+ land: "--map-land",
6901
+ water: "--map-water",
6902
+ park: "--map-park",
6903
+ building: "--map-building",
6904
+ buildingEdge: "--map-building-edge",
6905
+ road: "--map-road",
6906
+ roadCasing: "--map-road-casing",
6907
+ roadMajor: "--map-road-major",
6908
+ roadMajorCasing: "--map-road-major-casing",
6909
+ path: "--map-path",
6910
+ label: "--map-label",
6911
+ labelHalo: "--map-label-halo",
6912
+ pin: "--map-pin",
6913
+ pinEdge: "--map-pin-edge",
6914
+ frame: "--map-frame-color"
6915
+ };
6916
+ const MAP_DRAWING_SHAPE_VARS = {
6917
+ frameRadius: "--map-frame-radius",
6918
+ frameWidth: "--map-frame-width",
6919
+ frameShadow: "--map-frame-shadow",
6920
+ labelFont: "--map-label-font",
6921
+ labelWeight: "--map-label-weight",
6922
+ casingScale: "--map-casing-scale"
6923
+ };
6924
+ const defaultMapDrawingTreatment = {
6925
+ land: .035,
6926
+ water: {
6927
+ roles: [
6928
+ "primary",
6929
+ "accent",
6930
+ "secondary"
6931
+ ],
6932
+ amount: .2
6933
+ },
6934
+ park: {
6935
+ roles: [
6936
+ "success",
6937
+ "secondary",
6938
+ "primary"
6939
+ ],
6940
+ amount: .16
6941
+ },
6942
+ building: .09,
6943
+ buildingEdge: .17,
6944
+ roadLift: .7,
6945
+ casingSink: .2,
6946
+ majorRoad: {
6947
+ roles: ["accent", "primary"],
6948
+ amount: .16
6949
+ },
6950
+ path: .42,
6951
+ labelContrast: 6,
6952
+ pin: [
6953
+ "primary",
6954
+ "accent",
6955
+ "secondary"
6956
+ ],
6957
+ frame: {
6958
+ radius: "var(--rb-block-radius, 8px)",
6959
+ width: "1px",
6960
+ shadow: "none",
6961
+ colour: .16
6962
+ },
6963
+ labelWeight: 500,
6964
+ casingScale: 1
6965
+ };
6966
+ /** Per arrangement style (keyed by its skin). Legacy themes without a skin use the default. */
6967
+ const mapDrawingTreatments = {
6968
+ fulcrum: {
6969
+ ...defaultMapDrawingTreatment,
6970
+ land: .025,
6971
+ water: {
6972
+ roles: ["primary", "secondary"],
6973
+ amount: .2
6974
+ },
6975
+ park: {
6976
+ roles: ["success", "primary"],
6977
+ amount: .12
6978
+ },
6979
+ building: .07,
6980
+ buildingEdge: .14,
6981
+ casingSink: .16,
6982
+ majorRoad: {
6983
+ roles: ["accent"],
6984
+ amount: .12
6985
+ },
6986
+ pin: ["accent", "primary"],
6987
+ frame: {
6988
+ radius: "var(--rb-skin-radius, 3px)",
6989
+ width: "var(--rb-skin-rule, 1px)",
6990
+ shadow: "none",
6991
+ colour: .16
6992
+ }
6993
+ },
6994
+ poster: {
6995
+ ...defaultMapDrawingTreatment,
6996
+ land: 0,
6997
+ water: {
6998
+ roles: ["primary", "secondary"],
6999
+ amount: .32
7000
+ },
7001
+ park: {
7002
+ roles: ["success", "accent"],
7003
+ amount: .26
7004
+ },
7005
+ building: .12,
7006
+ buildingEdge: .3,
7007
+ roadLift: 1,
7008
+ casingSink: .55,
7009
+ majorRoad: {
7010
+ roles: ["accent", "primary"],
7011
+ amount: .55
7012
+ },
7013
+ path: .7,
7014
+ labelContrast: 9,
7015
+ pin: ["primary", "accent"],
7016
+ frame: {
7017
+ radius: "var(--rb-skin-radius, 0px)",
7018
+ width: "var(--rb-skin-rule, 3px)",
7019
+ shadow: "offset",
7020
+ colour: 1
7021
+ },
7022
+ labelWeight: 600,
7023
+ casingScale: 1.15
7024
+ },
7025
+ lantern: {
7026
+ ...defaultMapDrawingTreatment,
7027
+ land: .04,
7028
+ water: {
7029
+ roles: ["secondary", "primary"],
7030
+ amount: .22
7031
+ },
7032
+ park: {
7033
+ roles: ["success", "secondary"],
7034
+ amount: .14
7035
+ },
7036
+ building: .08,
7037
+ buildingEdge: .14,
7038
+ casingSink: .35,
7039
+ majorRoad: {
7040
+ roles: ["accent", "primary"],
7041
+ amount: .24
7042
+ },
7043
+ path: .4,
7044
+ pin: ["accent", "primary"],
7045
+ frame: {
7046
+ radius: "var(--rb-skin-radius, 10px)",
7047
+ width: "var(--rb-skin-rule, 1px)",
7048
+ shadow: "none",
7049
+ colour: .18
7050
+ }
7051
+ },
7052
+ measure: {
7053
+ ...defaultMapDrawingTreatment,
7054
+ land: .03,
7055
+ water: {
7056
+ roles: ["accent", "primary"],
7057
+ amount: .16
7058
+ },
7059
+ park: {
7060
+ roles: ["success"],
7061
+ amount: .12
7062
+ },
7063
+ building: .1,
7064
+ buildingEdge: .2,
7065
+ casingSink: .26,
7066
+ majorRoad: {
7067
+ roles: ["accent"],
7068
+ amount: 0
7069
+ },
7070
+ path: .5,
7071
+ pin: ["accent", "primary"],
7072
+ frame: {
7073
+ radius: "var(--rb-skin-radius, 0px)",
7074
+ width: "var(--rb-skin-rule, 2px)",
7075
+ shadow: "none",
7076
+ colour: .6
7077
+ },
7078
+ labelWeight: 600
7079
+ },
7080
+ folio: {
7081
+ ...defaultMapDrawingTreatment,
7082
+ land: .03,
7083
+ water: {
7084
+ roles: ["secondary", "primary"],
7085
+ amount: .18
7086
+ },
7087
+ park: {
7088
+ roles: ["success", "primary"],
7089
+ amount: .18
7090
+ },
7091
+ building: .08,
7092
+ buildingEdge: .15,
7093
+ casingSink: .18,
7094
+ majorRoad: {
7095
+ roles: ["accent"],
7096
+ amount: .14
7097
+ },
7098
+ pin: ["primary", "accent"],
7099
+ frame: {
7100
+ radius: "var(--rb-skin-radius, 10px)",
7101
+ width: "var(--rb-skin-rule, 1px)",
7102
+ shadow: "none",
7103
+ colour: .18
7104
+ }
7105
+ }
7106
+ };
7107
+ function mapDrawingTreatmentFor(skin) {
7108
+ return (skin === void 0 ? void 0 : mapDrawingTreatments[skin]) ?? defaultMapDrawingTreatment;
7109
+ }
7110
+ const toLab = (hex) => {
7111
+ const { r, g, b } = hexToRgb(hex);
7112
+ return srgbToOklab(r, g, b);
7113
+ };
7114
+ const toHex = ({ L, a, b }) => {
7115
+ const rgb = oklabToSrgb(L, a, b);
7116
+ return rgbToHex(rgb.r, rgb.g, rgb.b);
7117
+ };
7118
+ const blend = (from, to, t) => ({
7119
+ L: from.L + (to.L - from.L) * t,
7120
+ a: from.a + (to.a - from.a) * t,
7121
+ b: from.b + (to.b - from.b) * t
7122
+ });
7123
+ const distance = (x, y) => Math.hypot(x.L - y.L, x.a - y.a, x.b - y.b);
7124
+ /** A nearly neutral pole in the ground's hue, so lifts and sinks stay in the site's temperature. */
7125
+ function pole(ground, L) {
7126
+ const { C, h } = oklabToOklch(ground.L, ground.a, ground.b);
7127
+ return toLab(oklchToHexGamut(L, Math.min(C, .012), h));
7128
+ }
7129
+ /** The first blend from `from` toward `to` that reaches the contrast floor against every backdrop. */
7130
+ function firstContrastBlend(from, to, backdrops, floor) {
7131
+ return Array.from({ length: 41 }, (_, index) => toHex(blend(from, to, index / 40))).find((hex) => backdrops.every((backdrop) => contrastRatio(hex, backdrop) >= floor)) ?? toHex(to);
7132
+ }
7133
+ /** A tint must stand apart from what it is drawn on (a brand river on a brand band would vanish); else a step toward the ink. */
7134
+ function tint(base, spec, palette, ink) {
7135
+ return spec.roles.flatMap((role) => {
7136
+ const hex = resolveConcreteColorHex(role, palette);
7137
+ return hex ? [blend(base, toLab(hex), spec.amount)] : [];
7138
+ }).find((candidate) => distance(candidate, base) >= .025) ?? blend(base, ink, Math.max(spec.amount * .6, .06));
7139
+ }
7140
+ /** Pure: one ground, one ink, one palette and one treatment decide every map colour. */
7141
+ function resolveMapDrawingColours(input) {
7142
+ const { treatment: t, palette } = input;
7143
+ const ground = toLab(input.ground);
7144
+ const ink = toLab(input.ink);
7145
+ const darkGround = ink.L > ground.L;
7146
+ const light = darkGround ? blend(ground, ink, .22) : pole(ground, Math.max(ground.L, .995));
7147
+ const dark = darkGround ? pole(ground, Math.max(ground.L - .22, .04)) : ink;
7148
+ const tinted = blend(ground, ink, t.land);
7149
+ const land = contrastRatio(toHex(tinted), input.ink) >= 4.5 ? tinted : ground;
7150
+ const landHex = toHex(land);
7151
+ const road = blend(land, light, t.roadLift);
7152
+ const casing = blend(land, dark, t.casingSink);
7153
+ const building = blend(land, ink, t.building);
7154
+ const majorTint = t.majorRoad.amount === 0 ? road : tint(road, t.majorRoad, palette, ink);
7155
+ const pinBackdrops = [
7156
+ landHex,
7157
+ toHex(road),
7158
+ toHex(building)
7159
+ ];
7160
+ const pinRoles = t.pin.flatMap((role) => {
7161
+ const hex = resolveConcreteColorHex(role, palette);
7162
+ return hex ? [hex] : [];
7163
+ });
7164
+ const pin = [...pinRoles, input.ink].find((hex) => pinBackdrops.every((backdrop) => contrastRatio(hex, backdrop) >= 3)) ?? firstContrastBlend(toLab(pinRoles[0] ?? input.ink), ink, pinBackdrops, 3);
7165
+ const pinEdge = [
7166
+ toHex(light),
7167
+ toHex(dark),
7168
+ landHex
7169
+ ].reduce((best, hex) => contrastRatio(hex, pin) > contrastRatio(best, pin) ? hex : best);
7170
+ return {
7171
+ land: landHex,
7172
+ water: toHex(tint(land, t.water, palette, ink)),
7173
+ park: toHex(tint(land, t.park, palette, ink)),
7174
+ building: toHex(building),
7175
+ buildingEdge: toHex(blend(land, ink, t.buildingEdge)),
7176
+ road: toHex(road),
7177
+ roadCasing: toHex(casing),
7178
+ roadMajor: toHex(majorTint),
7179
+ roadMajorCasing: toHex(blend(casing, dark, .15)),
7180
+ path: toHex(blend(land, ink, t.path)),
7181
+ label: firstContrastBlend(land, ink, [landHex], Math.max(4.5, t.labelContrast)),
7182
+ labelHalo: landHex,
7183
+ pin,
7184
+ pinEdge,
7185
+ frame: toHex(blend(ground, ink, t.frame.colour))
7186
+ };
7187
+ }
7188
+ function mapDrawingShapeStyle(treatment) {
7189
+ return {
7190
+ [MAP_DRAWING_SHAPE_VARS.frameRadius]: treatment.frame.radius,
7191
+ [MAP_DRAWING_SHAPE_VARS.frameWidth]: treatment.frame.width,
7192
+ [MAP_DRAWING_SHAPE_VARS.frameShadow]: treatment.frame.shadow === "offset" ? `var(--rb-skin-shadow-offset, 6px) var(--rb-skin-shadow-offset, 6px) 0 var(${MAP_DRAWING_COLOUR_VARS.frame})` : "none",
7193
+ [MAP_DRAWING_SHAPE_VARS.labelFont]: "var(--font-body, system-ui, sans-serif)",
7194
+ [MAP_DRAWING_SHAPE_VARS.labelWeight]: String(treatment.labelWeight),
7195
+ [MAP_DRAWING_SHAPE_VARS.casingScale]: String(treatment.casingScale)
7196
+ };
7197
+ }
7198
+ /**
7199
+ * Everything a map needs from the section it sits on. Unmeasured grounds
7200
+ * (photos, gradients) keep the structural fallbacks for colour; the style's
7201
+ * shape still applies.
7202
+ */
7203
+ function mapDrawingStyle(input) {
7204
+ const treatment = mapDrawingTreatmentFor(input.skin);
7205
+ const shape = mapDrawingShapeStyle(treatment);
7206
+ if (input.foreground.kind !== "known" || input.foreground.provenance.kind !== "measured") return shape;
7207
+ const ink = resolveConcreteColorHex(input.foreground.roles.text, input.palette);
7208
+ if (ink === null) return shape;
7209
+ const colours = resolveMapDrawingColours({
7210
+ ground: input.foreground.provenance.backdropHex,
7211
+ ink,
7212
+ palette: input.palette,
7213
+ treatment
7214
+ });
7215
+ return {
7216
+ ...shape,
7217
+ ...Object.fromEntries(Object.entries(colours).map(([role, value]) => [MAP_DRAWING_COLOUR_VARS[role], value]))
7218
+ };
7219
+ }
7220
+ //#endregion
7221
+ //#region ../theme-core/src/utils/colorStyles.ts
7222
+ const COLOR_VAR_PREFIX = "--tb-";
7223
+ function parseToken(source) {
7224
+ const parts = parseColorTokenParts(source);
7225
+ if (parts.kind === "raw") return {
7226
+ token: source,
7227
+ raw: parts.value
7228
+ };
7229
+ if (parts.kind === "invalid") return { token: source };
7230
+ return {
7231
+ token: parts.token,
7232
+ opacityPercent: parts.opacityPercent === null ? void 0 : parts.opacityPercent
7233
+ };
7234
+ }
7235
+ const SURFACE_TEXT_ROLE_BY_TOKEN = {
7236
+ text: "text",
7237
+ heading: "heading",
7238
+ mutedText: "supporting"
7239
+ };
7240
+ function surfaceRoleForTextToken(token) {
7241
+ return Object.prototype.hasOwnProperty.call(SURFACE_TEXT_ROLE_BY_TOKEN, token) ? SURFACE_TEXT_ROLE_BY_TOKEN[token] : null;
7242
+ }
7243
+ /**
7244
+ * Converts a theme color token to a CSS rgb value.
7245
+ * This is the primary function for applying theme colors to CSS properties.
7246
+ *
7247
+ * @param token - Theme color token (semantic, with opacity, or raw)
7248
+ * @returns CSS color value (rgb with optional alpha, or raw CSS value)
7249
+ *
7250
+ * @example
7251
+ * rgbColorValue('primary') // => 'rgb(var(--tb-primary))'
7252
+ * rgbColorValue('surface/95') // => 'rgb(var(--tb-surface) / 0.95)'
7253
+ * rgbColorValue('raw:transparent') // => 'transparent'
7254
+ */
7255
+ function rgbColorValue(token) {
7256
+ const { token: baseToken, opacityPercent, raw } = parseToken(token);
7257
+ if (raw) return raw;
7258
+ const cssVar = `${COLOR_VAR_PREFIX}${baseToken}`;
7259
+ if (opacityPercent === void 0) return `rgb(var(${cssVar}))`;
7260
+ return `rgb(var(${cssVar}) / ${opacityPercent / 100})`;
7261
+ }
7262
+ /**
7263
+ * Converts a theme color token to a CSS variable reference.
7264
+ * Note: This returns the base variable without rgb() wrapper, ignoring opacity.
7265
+ *
7266
+ * @param token - Theme color token
7267
+ * @returns CSS variable reference
7268
+ *
7269
+ * @example
7270
+ * cssVarValue('primary') // => 'var(--tb-primary)'
7271
+ * cssVarValue('surface/95') // => 'var(--tb-surface)' (opacity ignored)
7272
+ */
7273
+ function cssVarValue(token) {
7274
+ const { token: baseToken } = parseToken(token);
7275
+ return `var(${COLOR_VAR_PREFIX}${baseToken})`;
7276
+ }
7277
+ /**
7278
+ * Creates a backgroundColor style object from a theme token.
7279
+ *
7280
+ * @param token - Theme color token
7281
+ * @returns CSSProperties with backgroundColor
7282
+ */
7283
+ function backgroundColorStyle(token) {
7284
+ return { backgroundColor: rgbColorValue(token) };
7285
+ }
7286
+ /**
7287
+ * Converts a text color token to a CSS color value that follows the enclosing
7288
+ * surface. The semantic text tokens (`text`, `heading`, `mutedText`) resolve
7289
+ * to the surface foreground variables, so text adapts when a section's
7290
+ * background changes; any other token is a fixed theme color.
7291
+ *
7292
+ * @param token - Theme color token
7293
+ * @returns CSS color value
7294
+ */
7295
+ function textColorValue(token) {
7296
+ const parsed = parseToken(token);
7297
+ const surfaceRole = parsed.raw ? null : surfaceRoleForTextToken(parsed.token);
7298
+ if (!surfaceRole) return rgbColorValue(token);
7299
+ return parsed.opacityPercent === void 0 ? surfaceForegroundValue(surfaceRole) : surfaceForegroundValueWithOpacity(surfaceRole, parsed.opacityPercent);
7300
+ }
7301
+ /**
7302
+ * Creates a text color style object from a theme token.
7303
+ *
7304
+ * @param token - Theme color token
7305
+ * @returns CSSProperties with color
7306
+ */
7307
+ function textColorStyle(token) {
7308
+ return { color: textColorValue(token) };
7309
+ }
7310
+ /**
7311
+ * Creates a border color style object from a theme token.
7312
+ *
7313
+ * @param token - Theme color token
7314
+ * @returns CSSProperties with borderColor
7315
+ */
7316
+ function borderColorStyle(token) {
7317
+ return { borderColor: rgbColorValue(token) };
7318
+ }
7319
+ /**
7320
+ * Merges multiple CSSProperties objects into a single object.
7321
+ * Later styles override earlier ones. Undefined values are filtered out.
7322
+ * Returns undefined if the merged result is empty.
7323
+ *
7324
+ * @param styles - Variable number of CSSProperties objects (can be undefined)
7325
+ * @returns Merged CSSProperties object, or undefined if empty
7326
+ *
7327
+ * @example
7328
+ * mergeStyles(
7329
+ * backgroundColorStyle('surface'),
7330
+ * textColorStyle('text'),
7331
+ * borderColorStyle('border')
7332
+ * )
7333
+ * // => { backgroundColor: '...', color: '...', borderColor: '...' }
7334
+ */
7335
+ function mergeStyles(...styles) {
7336
+ const merged = {};
7337
+ for (const style of styles) {
7338
+ if (!style) continue;
7339
+ Object.assign(merged, style);
7340
+ }
7341
+ return Object.keys(merged).length ? merged : void 0;
7342
+ }
7343
+ //#endregion
7344
+ //#region ../theme-core/src/tokens/resolver.ts
7345
+ /**
7346
+ * Resolves theme tokens to CSS variables
7347
+ *
7348
+ * This resolver ensures all button styles use theme tokens (not hardcoded colors)
7349
+ * so that changing the palette automatically updates all buttons.
7350
+ */
7351
+ var TokenResolver = class {
7352
+ constructor(theme) {
7353
+ this.theme = theme;
7354
+ }
7355
+ /**
7356
+ * Resolve a color token to a CSS variable reference wrapped in rgb()
7357
+ *
7358
+ * @param token - Token name (e.g., 'primary-500', 'white', 'text-900')
7359
+ * @returns CSS rgb() function with var reference (e.g., 'rgb(var(--tb-primary-500))')
7360
+ *
7361
+ * Note: CSS variables are stored as RGB channels (e.g., "37 99 235") following Tailwind convention,
7362
+ * so we must wrap them with rgb() to create a valid color value.
7363
+ *
7364
+ * @example
7365
+ * resolver.getColor('primary-500') // => 'rgb(var(--tb-primary-500))'
7366
+ * resolver.getColor('white') // => 'rgb(var(--tb-white))'
7367
+ */
7368
+ getColor(token) {
7369
+ if (!this.tokenExists(token)) console.warn(`[TokenResolver] Color token "${token}" not found in theme palette. Button may render incorrectly.`);
7370
+ return rgbColorValue(token);
7371
+ }
7372
+ /**
7373
+ * Adjust a color token's shade by a given amount
7374
+ *
7375
+ * @param token - Base token (e.g., 'primary-500')
7376
+ * @param amount - Shade adjustment (+100 = darker, -100 = lighter)
7377
+ * @returns Adjusted token name (e.g., 'primary-600')
7378
+ *
7379
+ * @example
7380
+ * resolver.adjustShade('primary-500', 100) // => 'primary-600' (darker)
7381
+ * resolver.adjustShade('primary-500', -100) // => 'primary-400' (lighter)
7382
+ */
7383
+ adjustShade(token, amount) {
7384
+ const parts = token.split("-");
7385
+ if (parts.length < 2) return `${token}-${Math.max(100, Math.min(900, 500 + amount))}`;
7386
+ const base = parts.slice(0, -1).join("-");
7387
+ const shade = parseInt(parts[parts.length - 1] ?? "", 10);
7388
+ if (isNaN(shade)) {
7389
+ console.warn(`[TokenResolver] Cannot adjust shade for non-shade token "${token}". Returning original token.`);
7390
+ return token;
7391
+ }
7392
+ return `${base}-${Math.max(100, Math.min(900, shade + amount))}`;
7393
+ }
7394
+ /**
7395
+ * Check if a token exists in the theme palette
7396
+ *
7397
+ * @param token - Token name to check
7398
+ * @returns True if token exists in theme
7399
+ */
7400
+ tokenExists(token) {
7401
+ if ([
7402
+ "white",
7403
+ "black",
7404
+ "transparent"
7405
+ ].includes(token)) return true;
7406
+ const parts = token.split("-");
7407
+ if (parts.length >= 2) {
7408
+ const lastPart = parts[parts.length - 1] ?? "";
7409
+ const shade = parseInt(lastPart, 10);
7410
+ if (!isNaN(shade) && shade >= 100 && shade <= 900 && shade % 100 === 0) return true;
7411
+ }
7412
+ return true;
7413
+ }
7414
+ };
6565
7415
  //#endregion
6566
7416
  //#region ../theme-core/src/utils/cssDeclarations.ts
6567
7417
  /** Render CSS declarations whether callers provide terminators or fragments. */
@@ -9961,7 +10811,7 @@ const EFFECT_PRESETS = [
9961
10811
  customizableOption: {
9962
10812
  name: "solidOnHover",
9963
10813
  type: "select",
9964
- label: "Hover Behavior",
10814
+ label: "Hover behaviour",
9965
10815
  default: "false",
9966
10816
  options: ["false", "true"]
9967
10817
  },
@@ -16945,4 +17795,4 @@ function ThemedAuthoredButton({ label, href, variant, size, extraClassName, disa
16945
17795
  });
16946
17796
  }
16947
17797
  //#endregion
16948
- export { headerInteractionPalettePair as $, paletteValueKeySchema as $n, parseColorTokenParts as $r, toAccessibleColorSurfaceIntent as $t, resolveButtonStyleSelection as A, parseUserId as Ai, contrastRatio as An, eyebrowTreatmentValues as Ar, NAV_LINK_LETTER_SPACING_MAP as At, generateBaseInteractiveCSS as B, unsafeAsStorageBucketName as Bi, surfaceForegroundValue as Bn, requireNonEmptyReadonlyArray as Br, INPUT_SPACING_MAP as Bt, FileTextIcon as C, parseEventOfferingId as Ci, planForegroundHover as Cn, asSiteStyleId as Cr, resolveBrandDisplay as Ct, buttonStyleSelectionParameterValue as D, parsePageSurfaceId as Di, buildThemeTokens as Dn, defineFrameCapability as Dr, parseBlockCustomCssRules as Dt, buttonStyleHoverPreferenceValue as E, parsePageId as Ei, resolveOpaqueSurfaceHex as En, defineExactCatalog as Er, getComponentShadowVar as Et, buttonStyleSelectionsEqual as F, unsafeAsMediaAssetId as Fi, DEFAULT_SURFACE_TEXT_COLOR as Fn, makeBoundaryId as Fr, navLinkOwnsHoverForeground as Ft, containerStylesOverrideSchema as G, __exportAll as Gi, cardVariantRoleValues as Gn, buildFontPreviewUrl as Gr, ACCORDION_TRIGGER_LETTER_SPACING as Gt, parseThemeButtonVariantId as H, err as Hi, generateShadowValue$1 as Hn, tileTreatmentValues as Hr, ACCORDION_OPEN_ACCENT_THICKNESS as Ht, generateButtonActionLayoutCss as I, unsafeAsPassId as Ii, SURFACE_FOREGROUND_CSS_VARS as In, noHeadingDecoration as Ir, navLinkOwnsUnderline as It, sectionStylesOverrideSchema as J, paletteColorEntries as Jn, VARIANT_ROLES as Jr, generateCardCss as Jt, corners as K, __toESM as Ki, normalizeCardRole as Kn, generateFontFaceCss as Kr, ICON_CONFIG as Kt, generateButtonCss as L, unsafeAsPositiveByteCount as Li, surfaceForegroundDeclarations as Ln, offeringsPreviewCompositionTreatmentValues as Lr, navEffectPolicy as Lt, updateButtonStyleSelectionChoice as M, unsafeAsAppointmentServiceId as Mi, featuresFromHex as Mn, flushPanelFrame as Mr, NAV_LINK_PADDING_X_MAP as Mt, buttonStyleSelectionKey as N, unsafeAsCustomerPassId as Ni, hexToRgb as Nn, headingDecorationColorTokenValues as Nr, NAV_LINK_TEXT_SIZE_MAP as Nt, defaultButtonStyleSelectionFor as O, parseSiteId as Oi, defaultThemeTokens as On, designIssueSeverityForPolicy as Or, parseCustomCssRules as Ot, buttonStyleSelectionSchema as P, unsafeAsFormId as Pi, rgbToHex as Pn, introCompositionTreatmentValues as Pr, navLinkHoverColorCandidate as Pt, runtimeBoxBackgroundSchema as Q, paletteValueKey as Qn, parseBlockColorToken as Qr, surfaceDecorationColors as Qt, generateDefaultButtonSystem as R, unsafeAsPositiveSeconds as Ri, surfaceForegroundInputFromResolved as Rn, panelFrame as Rr, FONT_WEIGHT_MAP$1 as Rt, FileSpreadsheetIcon as S, parseEditorClientId as Si, compositeHex as Sn, asPageFlowPresetId as Sr, logoSizePolicyValues as St, PlusIcon as T, parseFormId as Ti, resolveConcreteColorHex as Tn, defineBlockDesignCapability as Tr, getComponentBorderWidthPx as Tt, parseThemeForPersistence as U, ok as Ui, cardRoleSchema as Un, toNonEmptyReadonlyArray as Ur, ACCORDION_SPACING_MAP as Ut, generateInteractiveChildInheritanceCSS as V, unsafeAsStoragePath as Vi, surfaceForegroundValueWithOpacity as Vn, testimonialsCompositionTreatmentValues as Vr, LABEL_FONT_SIZE_MAP as Vt, cardStylesOverrideSchema as W, __commonJSMin as Wi, cardRoleValues as Wn, visibleHeadingDecorationFamilyValues as Wr, ACCORDION_TRIGGER_FONT_SCALE as Wt, boxBackgroundOverlaySchema as X, paletteColorsSchema as Xn, parseThemeColorToken as Xr, contrastThresholdByPolicy as Xt, themeSchema as Y, paletteColorsEqual as Yn, unsafeAsOpaqueButtonColourToken as Yr, renderCssDeclarations as Yt, boxBackgroundSchema as Z, paletteModeSchema as Zn, themeColorShadeSteps as Zr, resolveSurface as Zt, CirclePlusIcon as _, formatCurrencyAmount as _i, surfaceToneFromForegroundToken as _n, asDesignBoundaryId as _r, siteChromeBackgroundOverrideOwner as _t, ThemedDownloadLink as a, checkoutCopy as ai, rgbColorValue as an, buildRenderableMediaAssetIndex as ar, renderHeaderPaintTargetRules as at, FileArchiveIcon as b, parseContentEntryId as bi, expandPalette as bn, asDesignSystemTemplateId as br, brandDisplayModeValues as bt, isKnownIconName as c, planCheckoutPaymentFlow as ci, opaqueSurfaceContextFromTheme as cn, resolveManagedMediaReference as cr, MQ_LG_UP as ct, resolveIconPickerPreset as d, repriceBookingCollectionOptions as di, resolveOnColorForThemeToken as dn, skinTokenCssVars as dr, MQ_SM_UP as dt, SpinnerNode as ei, TokenResolver as en, requirePaletteColorsFromEntries as er, headerInteractionPaletteValues as et, SEMANTIC_ICON_DEFINITIONS as f, resolveAvailableBookingCollectionOptions as fi, resolveThemeColorReferenceValue as fn, asAppearancePresetId as fr, MQ_TABLET_ONLY as ft, CircleMinusIcon as g, getBookingInstalmentPlanIntervalCount as gi, selectLogoVariant as gn, asDesignBlockId as gr, pageDesignEditorBackgroundOverrideOwner as gt, ChevronDownIcon as h, validateBookingPaymentOptionKinds as hi, PUBLIC_BUTTON_ROLES as hn, asBoundaryOptionId as hr, isThemeV2NormalEditorRawStylePath as ht, ThemedButtonSpecimen as i, parseEventRegistrationErrorReason as ii, mergeStyles as in, runtimeMediaSchema as ir, getHeaderPaintTargets as it, updateButtonStyleHoverPreference as j, unsafeAsAppointmentResourceId as ji, relativeLuminance as jn, featureCardCompositionTreatmentValues as jr, NAV_LINK_PADDING_MAP as jt, findButtonStyleRecipe as k, parseSiteTermsVersionId as ki, ORDINARY_TEXT_MIN_CONTRAST_RATIO as kn, eventListTreatmentValues as kr, NAV_LINK_BORDER_RADIUS_MAP as kt, ICON_PICKER_PRESETS as l, planFlexibleBalanceCreditFirst as li, opaqueSurfaceDeclarations as ln, mediaIdentifierSchema as lr, MQ_MD_DOWN as lt, ArrowDownIcon as m, getBookingLaterInstalments as mi, generateShadowValue as mn, asBlockOrderIndex as mr, isThemeV2NormalEditorRawStyleFieldName as mt, ThemedButton as n, checkBrowserStripeKey as ni, borderColorStyle as nn, mediaPosterSchema as nr, generateHeaderScrollTreatmentStyles as nt, getIconComponent as o, getStripeMinimumChargeRequirement as oi, textColorStyle as on, renderableMediaAssetSchema as or, BREAKPOINT_LG as ot, isSemanticIconId as p, resolveBookingCollectionOptionFacts as pi, resolveTokenOrCssColorValue as pn, asBlockContentVersionId as pr, headerVariantValues as pt, headerPositioningValues as q, hexColorSchema as qn, getSiteFontsStorageUrl as qr, ICON_SIZE_PX as qt, ThemedButtonLink as r, eventRegistrationErrors as ri, cssVarValue as rn, mediaSchema as rr, generateMobileOverlayBackdropFilterFix as rt, getIconPickerOptionsForPreset as s, confirmationPaymentSchema as si, textColorValue as sn, indexRenderableMediaAssets as sr, BREAKPOINT_XL as st, ThemedAuthoredButton as t, clsx as ti, backgroundColorStyle as tn, imageMediaSchema as tr, headerInteractionQuietPalette as tt, isIconPickerPreset as u, isBookingCollectionEquivalentToUpfront as ui, isCssColorLiteral as un, parseCanonicalMediaIdentifier as ur, MQ_SM_DOWN as ut, ClockIcon as v, expectParsedBrandedId as vi, resolveSurfaceForeground as vn, asDesignEntryId as vr, stripStaleTransitionStyleGroup as vt, MinusIcon as w, parseEventSeriesId as wi, worstCaseGlassBackdrop as wn, assertNever as wr, selectLogoAccommodation as wt, FileAudioIcon as x, parseContentVersionId as xi, getTextColorForBackground as xn, asLayoutVariantKey as xr, deterministicLogoFactsForShape as xt, ExternalLinkIcon as y, parseApiKeyId as yi, safeTokenOr as yn, asDesignPageId as yr, themeV2RuntimeStyleFieldNames as yt, generateEffectsCSS as z, unsafeAsSiteId as zi, surfaceForegroundStyle as zn, plainFrame as zr, INPUT_FONT_SIZE_MAP as zt };
17798
+ export { headerInteractionPalettePair as $, hexColorSchema as $n, VARIANT_ROLES as $r, cssVarValue as $t, resolveButtonStyleSelection as A, parseEventSeriesId as Ai, getTextColorForBackground as An, defineBlockDesignCapability as Ar, NAV_LINK_LETTER_SPACING_MAP as At, generateBaseInteractiveCSS as B, unsafeAsFormId as Bi, hexToRgb as Bn, makeBoundaryId as Br, INPUT_SPACING_MAP as Bt, FileTextIcon as C, formatCurrencyAmount as Ci, generateShadowValue as Cn, asDesignEntryId as Cr, resolveBrandDisplay as Ct, buttonStyleSelectionParameterValue as D, parseContentVersionId as Di, resolveSurfaceForeground as Dn, asPageFlowPresetId as Dr, parseBlockCustomCssRules as Dt, buttonStyleHoverPreferenceValue as E, parseContentEntryId as Ei, surfaceToneFromForegroundToken as En, asLayoutVariantKey as Er, getComponentShadowVar as Et, buttonStyleSelectionsEqual as F, parseSiteTermsVersionId as Fi, resolveOpaqueSurfaceHex as Fn, eyebrowTreatmentValues as Fr, navLinkOwnsHoverForeground as Ft, containerStylesOverrideSchema as G, unsafeAsSiteId as Gi, surfaceForegroundStyle as Gn, requireNonEmptyReadonlyArray as Gr, ACCORDION_TRIGGER_LETTER_SPACING as Gt, parseThemeButtonVariantId as H, unsafeAsPassId as Hi, SURFACE_FOREGROUND_CSS_VARS as Hn, offeringsPreviewCompositionTreatmentValues as Hr, ACCORDION_OPEN_ACCENT_THICKNESS as Ht, generateButtonActionLayoutCss as I, parseUserId as Ii, buildThemeTokens as In, featureCardCompositionTreatmentValues as Ir, navLinkOwnsUnderline as It, sectionStylesOverrideSchema as J, generateShadowValue$1 as Jn, toNonEmptyReadonlyArray as Jr, generateCardCss as Jt, corners as K, unsafeAsStorageBucketName as Ki, surfaceForegroundValue as Kn, testimonialsCompositionTreatmentValues as Kr, ICON_CONFIG as Kt, generateButtonCss as L, unsafeAsAppointmentResourceId as Li, defaultThemeTokens as Ln, flushPanelFrame as Lr, navEffectPolicy as Lt, updateButtonStyleSelectionChoice as M, parsePageId as Mi, planForegroundHover as Mn, defineFrameCapability as Mr, NAV_LINK_PADDING_X_MAP as Mt, buttonStyleSelectionKey as N, parsePageSurfaceId as Ni, worstCaseGlassBackdrop as Nn, designIssueSeverityForPolicy as Nr, NAV_LINK_TEXT_SIZE_MAP as Nt, defaultButtonStyleSelectionFor as O, parseEditorClientId as Oi, safeTokenOr as On, asSiteStyleId as Or, parseCustomCssRules as Ot, buttonStyleSelectionSchema as P, parseSiteId as Pi, resolveConcreteColorHex as Pn, eventListTreatmentValues as Pr, navLinkHoverColorCandidate as Pt, runtimeBoxBackgroundSchema as Q, normalizeCardRole as Qn, getSiteFontsStorageUrl as Qr, borderColorStyle as Qt, generateDefaultButtonSystem as R, unsafeAsAppointmentServiceId as Ri, ORDINARY_TEXT_MIN_CONTRAST_RATIO as Rn, headingDecorationColorTokenValues as Rr, FONT_WEIGHT_MAP$1 as Rt, FileSpreadsheetIcon as S, getBookingInstalmentPlanIntervalCount as Si, resolveTokenOrCssColorValue as Sn, asDesignBoundaryId as Sr, logoSizePolicyValues as St, PlusIcon as T, parseApiKeyId as Ti, selectLogoVariant as Tn, asDesignSystemTemplateId as Tr, getComponentBorderWidthPx as Tt, parseThemeForPersistence as U, unsafeAsPositiveByteCount as Ui, surfaceForegroundDeclarations as Un, panelFrame as Ur, ACCORDION_SPACING_MAP as Ut, generateInteractiveChildInheritanceCSS as V, unsafeAsMediaAssetId as Vi, DEFAULT_SURFACE_TEXT_COLOR as Vn, noHeadingDecoration as Vr, LABEL_FONT_SIZE_MAP as Vt, cardStylesOverrideSchema as W, unsafeAsPositiveSeconds as Wi, surfaceForegroundInputFromResolved as Wn, plainFrame as Wr, ACCORDION_TRIGGER_FONT_SCALE as Wt, boxBackgroundOverlaySchema as X, cardRoleValues as Xn, buildFontPreviewUrl as Xr, TokenResolver as Xt, themeSchema as Y, cardRoleSchema as Yn, visibleHeadingDecorationFamilyValues as Yr, renderCssDeclarations as Yt, boxBackgroundSchema as Z, cardVariantRoleValues as Zn, generateFontFaceCss as Zr, backgroundColorStyle as Zt, CirclePlusIcon as _, repriceBookingCollectionOptions as _i, minimumScrimOpacity as _n, asAppearancePresetId as _r, siteChromeBackgroundOverrideOwner as _t, ThemedDownloadLink as a, SpinnerNode as ai, opaqueSurfaceContextFromTheme as an, paletteValueKeySchema as ar, renderHeaderPaintTargetRules as at, FileArchiveIcon as b, getBookingLaterInstalments as bi, resolveOnColorForThemeToken as bn, asBoundaryOptionId as br, brandDisplayModeValues as bt, isKnownIconName as c, eventRegistrationErrorEndsCommand as ci, parseResolvedSurface as cn, mediaSchema as cr, MQ_LG_UP as ct, resolveIconPickerPreset as d, checkoutCopy as di, resolveSurface as dn, renderableMediaAssetSchema as dr, MQ_SM_UP as dt, unsafeAsOpaqueButtonColourToken as ei, mergeStyles as en, paletteColorEntries as er, headerInteractionPaletteValues as et, SEMANTIC_ICON_DEFINITIONS as f, getStripeMinimumChargeRequirement as fi, serializeSurfaceTree as fn, indexRenderableMediaAssets as fr, MQ_TABLET_ONLY as ft, CircleMinusIcon as g, isBookingCollectionEquivalentToUpfront as gi, gradientScrimSamples as gn, skinTokenCssVars as gr, pageDesignEditorBackgroundOverrideOwner as gt, ChevronDownIcon as h, planFlexibleBalanceCreditFirst as hi, toAccessibleColorSurfaceIntent as hn, parseCanonicalMediaIdentifier as hr, isThemeV2NormalEditorRawStylePath as ht, ThemedButtonSpecimen as i, parseColorTokenParts as ii, mapDrawingStyle as in, paletteValueKey as ir, getHeaderPaintTargets as it, updateButtonStyleHoverPreference as j, parseFormId as ji, compositeHex$1 as jn, defineExactCatalog as jr, NAV_LINK_PADDING_MAP as jt, findButtonStyleRecipe as k, parseEventOfferingId as ki, expandPalette as kn, assertNever as kr, NAV_LINK_BORDER_RADIUS_MAP as kt, ICON_PICKER_PRESETS as l, eventRegistrationErrors as li, parseSurfaceTree as ln, runtimeMediaSchema as lr, MQ_MD_DOWN as lt, ArrowDownIcon as m, planCheckoutPaymentFlow as mi, surfaceTransportContext as mn, mediaIdentifierSchema as mr, isThemeV2NormalEditorRawStyleFieldName as mt, ThemedButton as n, themeColorShadeSteps as ni, textColorStyle as nn, paletteColorsSchema as nr, generateHeaderScrollTreatmentStyles as nt, getIconComponent as o, clsx as oi, opaqueSurfaceDeclarations as on, requirePaletteColorsFromEntries as or, BREAKPOINT_LG as ot, isSemanticIconId as p, confirmationPaymentSchema as pi, surfaceDecorationColors as pn, resolveManagedMediaReference as pr, headerVariantValues as pt, headerPositioningValues as q, unsafeAsStoragePath as qi, surfaceForegroundValueWithOpacity as qn, tileTreatmentValues as qr, ICON_SIZE_PX as qt, ThemedButtonLink as r, parseBlockColorToken as ri, textColorValue as rn, paletteModeSchema as rr, generateMobileOverlayBackdropFilterFix as rt, getIconPickerOptionsForPreset as s, checkBrowserStripeKey as si, contrastThresholdByPolicy as sn, imageMediaSchema as sr, BREAKPOINT_XL as st, ThemedAuthoredButton as t, parseThemeColorToken as ti, rgbColorValue as tn, paletteColorsEqual as tr, headerInteractionQuietPalette as tt, isIconPickerPreset as u, parseEventRegistrationErrorReason as ui, prepareThemeSurfaceRevision as un, buildRenderableMediaAssetIndex as ur, MQ_SM_DOWN as ut, ClockIcon as v, resolveAvailableBookingCollectionOptions as vi, scrimTone as vn, asBlockContentVersionId as vr, stripStaleTransitionStyleGroup as vt, MinusIcon as w, expectParsedBrandedId as wi, PUBLIC_BUTTON_ROLES as wn, asDesignPageId as wr, selectLogoAccommodation as wt, FileAudioIcon as x, validateBookingPaymentOptionKinds as xi, resolveThemeColorReferenceValue as xn, asDesignBlockId as xr, deterministicLogoFactsForShape as xt, ExternalLinkIcon as y, resolveBookingCollectionOptionFacts as yi, isCssColorLiteral as yn, asBlockOrderIndex as yr, themeV2RuntimeStyleFieldNames as yt, generateEffectsCSS as z, unsafeAsCustomerPassId as zi, featuresFromHex as zn, introCompositionTreatmentValues as zr, INPUT_FONT_SIZE_MAP as zt };