@riverbankcms/sdk 0.160.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 (207) hide show
  1. package/dist/_dts/{BlocksIslandsHydrator-CoqeotCL.d.ts → BlocksIslandsHydrator-Bx4kLiTA.d.ts} +1 -1
  2. package/dist/_dts/{Page-C0ENVLCF.d.ts → Page-Dm7_P13o.d.ts} +211 -9
  3. package/dist/_dts/{SdkPreviewMode-jZK0A49V.d.ts → SdkPreviewMode-D7HdWWwF.d.ts} +4 -4
  4. package/dist/_dts/{auth-contract-FPg0-2MC.d.ts → auth-contract-CgJ5nMaH.d.ts} +2 -0
  5. package/dist/_dts/{client-uMMuPq9V.d.ts → client-Ep0jI9eE.d.ts} +1 -1
  6. package/dist/_dts/{content-types-D6nXGqdQ.d.ts → content-types-BgAzCrBc.d.ts} +2 -2
  7. package/dist/_dts/{contracts-Bnmj1nxu.d.ts → contracts-DUiOnj9e.d.ts} +8 -5
  8. package/dist/_dts/{footerPageOutline-CeLjFX8b.d.ts → footerPageOutline-B-uXamTG.d.ts} +6 -6
  9. package/dist/_dts/{generatePageMetadata-nyU8q02J.d.ts → generatePageMetadata-BDkZYEcS.d.ts} +2 -2
  10. package/dist/_dts/{index-Blwl7yl6.d.ts → index-BQDBQvdu.d.ts} +1 -1
  11. package/dist/_dts/{index-lkpjIg5i.d.ts → index-BVkP8f70.d.ts} +1 -1
  12. package/dist/_dts/{index-CEaKil7G.d.ts → index-CF6Cjs7b.d.ts} +2 -2
  13. package/dist/_dts/{index-nVoi_74l.d.ts → index-CSsfq6KG.d.ts} +3 -17
  14. package/dist/_dts/{index-DahMwisK.d.ts → index-D_8uz4OP.d.ts} +3 -3
  15. package/dist/_dts/{index-Bg64CkV-.d.ts → index-DvKQA6AZ.d.ts} +4 -4
  16. package/dist/_dts/{index-C5xslEBn.d.ts → index-KPrWM0KF.d.ts} +1 -1
  17. package/dist/_dts/{index-BaaGBY1v.d.ts → index-ylivB7Jj.d.ts} +2 -2
  18. package/dist/_dts/{loadContent-CYLmzvLq.d.ts → loadContent-DTjKOO-T.d.ts} +10 -10
  19. package/dist/_dts/{resolvePageContent-DqnxChOs.d.ts → resolvePageContent-C1vA5c5w.d.ts} +2 -2
  20. package/dist/_dts/{schema-D0bNcPWK.d.ts → schema-BHu0PYWl.d.ts} +18821 -16622
  21. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  22. package/dist/_dts/sdk/src/client/types.d.ts +2 -2
  23. package/dist/_dts/sdk/src/client.d.ts +7 -7
  24. package/dist/_dts/sdk/src/config/index.d.ts +6 -6
  25. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  26. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  27. package/dist/_dts/sdk/src/index.d.ts +8 -8
  28. package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
  29. package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
  30. package/dist/_dts/sdk/src/navigation/index.d.ts +2 -2
  31. package/dist/_dts/sdk/src/next/index.d.ts +7 -7
  32. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  33. package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
  34. package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
  35. package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
  36. package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
  37. package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
  38. package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
  39. package/dist/_dts/sdk/src/preview-next/keep-alive.d.ts +1 -1
  40. package/dist/_dts/sdk/src/preview-next/session.d.ts +2 -2
  41. package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
  42. package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
  43. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  44. package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
  45. package/dist/_dts/sdk/src/routing/index.d.ts +5 -5
  46. package/dist/_dts/sdk/src/server.d.ts +5 -5
  47. package/dist/_dts/sdk/src/theme/index.d.ts +1 -1
  48. package/dist/_dts/{session-Ba2CsnK5.d.ts → session-C_gtSFyZ.d.ts} +2 -1
  49. package/dist/_dts/{types-D8czmbQF.d.ts → types-BR1Yboa9.d.ts} +1060 -140
  50. package/dist/_dts/{types-Dm-KW7nj.d.ts → types-CJXTCF_F.d.ts} +3 -3
  51. package/dist/_dts/{types-CFrYuXYP.d.ts → types-D02ngcUH.d.ts} +4 -2
  52. package/dist/_dts/{types-DSgmJ15W.d.ts → types-ZGUiHpDE.d.ts} +7 -7
  53. package/dist/_dts/{validation-Bmb4WnHg.d.ts → validation-BaV565gb.d.ts} +4 -4
  54. package/dist/client/{BlocksIslandsHydrator-DZRKi6tT.mjs → BlocksIslandsHydrator-DTExCJsb.mjs} +22 -21
  55. package/dist/client/{BookingMailingListNote-C00sLLdL.mjs → BookingMailingListNote-BDpxmn1p.mjs} +1 -1
  56. package/dist/client/{CalendarNavigationChevron-CHSi9b3E.mjs → CalendarNavigationChevron-PeCiL82X.mjs} +6 -6
  57. package/dist/client/{CheckboxChoice-Bhm6RAUL.mjs → CheckboxChoice-DWexRLf6.mjs} +1 -1
  58. package/dist/client/{DemoBookingPortalAccess-CaN-7ui7.mjs → DemoBookingPortalAccess-3zmIqakW.mjs} +5 -5
  59. package/dist/client/{DemoPortalSignInLink-ClxN5_xZ.mjs → DemoPortalSignInLink-GHi-8BW5.mjs} +1 -1
  60. package/dist/client/{EventCalendar.client-BncvSa1n.mjs → EventCalendar.client-BxQLY5cX.mjs} +9 -9
  61. package/dist/client/{EventCombined.client-DluBxVVu.mjs → EventCombined.client-B5bmQ03b.mjs} +8 -8
  62. package/dist/client/{EventEmbeddedCheckoutStep-BiJrMtfp.mjs → EventEmbeddedCheckoutStep-CgMZ9TeU.mjs} +1 -1
  63. package/dist/client/{EventItem-CXhnT9pF.mjs → EventItem-BEx-qiDE.mjs} +4 -4
  64. package/dist/client/{EventListWeekNavigation-V-dtoDlD.mjs → EventListWeekNavigation-CyH5tA6Y.mjs} +1 -1
  65. package/dist/client/{EventListing.client-DPO6SZbx.mjs → EventListing.client-D3uySdGP.mjs} +3 -3
  66. package/dist/client/{EventListing.view-B-Yi5JZS.mjs → EventListing.view-9RFrBejr.mjs} +29 -13
  67. package/dist/client/{EventRegistrationPayment-Dc3Fnlnw.mjs → EventRegistrationPayment-CG2tQx8K.mjs} +25 -13
  68. package/dist/client/LocationMapActions-Wsr83Q7q.mjs +268 -0
  69. package/dist/client/{Page-7PkzO04N.mjs → Page-Bf2nPACI.mjs} +809 -298
  70. package/dist/client/{StepIndicator-DiD6euZ8.mjs → StepIndicator-CZweb1vs.mjs} +2 -2
  71. package/dist/client/{TabBarFragment-BHd8GN8y.mjs → TabBarFragment-Bkgz67gt.mjs} +1 -1
  72. package/dist/client/ThemedButton-CnyL3s1A.mjs +2243 -0
  73. package/dist/client/{accordion-2m27DsIk.mjs → accordion-TcimLLRQ.mjs} +1 -1
  74. package/dist/client/{booking-form.client-BddWV5w1.mjs → booking-form.client-q-RpJ4aF.mjs} +12 -12
  75. package/dist/client/{bookingForm-bcdXQjmw.mjs → bookingForm-DjGfk3Wj.mjs} +4 -4
  76. package/dist/client/bookings.mjs +5 -5
  77. package/dist/client/{carousel-D7nj9I0y.mjs → carousel-CGAk6j0m.mjs} +2 -2
  78. package/dist/client/{carousel.client-AffDJo_s.mjs → carousel.client-ArlGmYWV.mjs} +1 -1
  79. package/dist/client/{cart-PN6yCw1H.mjs → cart-D_h3rAZ2.mjs} +3 -3
  80. package/dist/client/{cart.client-D4t1f0cJ.mjs → cart.client-DHOxZbJ7.mjs} +1 -1
  81. package/dist/client/{checkout-CsTwXVSb.mjs → checkout-tC-3CzuM.mjs} +3 -3
  82. package/dist/client/{checkout.client-BhQE3zY7.mjs → checkout.client-DsBb2Pkm.mjs} +1 -1
  83. package/dist/client/client.mjs +5 -4
  84. package/dist/client/{context-BLAvalAa.mjs → context-9ZfMb6GA.mjs} +1 -1
  85. package/dist/client/{cta-CUXhX_D7.mjs → cta-D-ZqL7-e.mjs} +1 -1
  86. package/dist/client/{dateFormatting-BHIHxNuo.mjs → dateFormatting-BCwLqYpW.mjs} +1 -1
  87. package/dist/client/{demoPortalMagicLink-R-awbk_0.mjs → demoPortalMagicLink-BxkSS9fx.mjs} +1 -1
  88. package/dist/client/{enhanceHeaderSection-9Q93uvTo.mjs → enhanceHeaderSection-xg6to91E.mjs} +3 -3
  89. package/dist/client/{event-details.client-BS1WtG-a.mjs → event-details.client-C670TgRd.mjs} +2 -17
  90. package/dist/client/{event-registration.client-BXndwsET.mjs → event-registration.client-C6GApWTB.mjs} +16 -16
  91. package/dist/client/{eventCalendar-HyoOt1Qz.mjs → eventCalendar-CWc0dg9i.mjs} +4 -4
  92. package/dist/client/{eventCombined-sdG5oEaH.mjs → eventCombined-D4DbOrvQ.mjs} +4 -4
  93. package/dist/client/{eventDetails-FFAknE4w.mjs → eventDetails-C2DfmbC0.mjs} +2 -2
  94. package/dist/client/{eventListing-CGK6urk3.mjs → eventListing-C_yXmHyz.mjs} +4 -4
  95. package/dist/client/{eventRegistration-VhrvCs4l.mjs → eventRegistration-DJuaCB-O.mjs} +4 -4
  96. package/dist/client/{form-C-B5O_ko.mjs → form-QZhtdFHA.mjs} +3 -3
  97. package/dist/client/{form.client-DoZVcl8d.mjs → form.client-CgvPACwG.mjs} +4 -4
  98. package/dist/client/{form.parts-mttKpgif.mjs → form.parts-2uI0-5N-.mjs} +3 -3
  99. package/dist/client/{formatDate-xUSCknEO.mjs → formatDate-Danr0Nk4.mjs} +1 -1
  100. package/dist/client/gifting/client.mjs +3 -3
  101. package/dist/client/{headerSection-BHUEXsaI.mjs → headerSection-DJdlLdvZ.mjs} +2 -2
  102. package/dist/client/{mediaAssets-BOj-Co0B.mjs → mediaAssets-BvjcAZpS.mjs} +1 -1
  103. package/dist/client/mediaContext-jPeJ2PmJ.mjs +10801 -0
  104. package/dist/client/{newsletter-form.client-D_n0rftg.mjs → newsletter-form.client-Cbepz2KU.mjs} +5 -5
  105. package/dist/client/{newsletter-form.parts-DKHye4IE.mjs → newsletter-form.parts-DN8oMCQ0.mjs} +2 -2
  106. package/dist/client/{newsletterForm-tEaYelzx.mjs → newsletterForm-wjLtW-wq.mjs} +3 -3
  107. package/dist/client/{noop-B610YKEx.mjs → noop-B7H6gCbj.mjs} +297 -3
  108. package/dist/client/portal/client.mjs +12 -12
  109. package/dist/client/{product-detail.client-DUf5x5Jt.mjs → product-detail.client-CYTR165c.mjs} +1 -1
  110. package/dist/client/{product-list.client-Cqp1BPTV.mjs → product-list.client-B4vTvag8.mjs} +1 -1
  111. package/dist/client/{productDetail-B8bBiogP.mjs → productDetail-k8LEMSWn.mjs} +3 -3
  112. package/dist/client/{productList-BKN4D-1z.mjs → productList-DEo8Bqoe.mjs} +3 -3
  113. package/dist/client/{propsDecoder-2nNZh2Oe.mjs → propsDecoder-G0j0HXBO.mjs} +3 -28
  114. package/dist/client/{registry.server-BAm4RPNJ.mjs → registry.server-BTmSXE3D.mjs} +355 -162
  115. package/dist/client/rendering/client.mjs +27 -28
  116. package/dist/client/rendering/islands.mjs +1 -1
  117. package/dist/client/rendering.mjs +15 -9
  118. package/dist/client/{richText-coerce-Cv-qomNB.mjs → richText-coerce-B19taoH6.mjs} +1 -1
  119. package/dist/client/{routeIslandApiConfig-C5u8MbAA.mjs → routeIslandApiConfig-Chu5BHra.mjs} +1 -1
  120. package/dist/client/{ThemedButton-C22C9cCF.mjs → schema-C-m8XHuW.mjs} +990 -2310
  121. package/dist/client/{shop-DZNC0VKk.mjs → shop-RGWa43H7.mjs} +3 -3
  122. package/dist/client/{shop-commerce-DdX4LSa3.mjs → shop-commerce-TJYCBO_H.mjs} +11 -11
  123. package/dist/client/{shop-commerce-store-BJtrZov9.mjs → shop-commerce-store-CjCcUB_o.mjs} +1 -1
  124. package/dist/client/{shop.client-DmDd-igg.mjs → shop.client-tsKfZw1W.mjs} +12 -12
  125. package/dist/client/{shop.interactive-5SnnDHz3.mjs → shop.interactive-CVqLAU53.mjs} +6 -158
  126. package/dist/client/{shopShared-CPqUlAh9.mjs → shopShared-C3lHMz_R.mjs} +2 -2
  127. package/dist/client/{timetableModel-C19rcHEw.mjs → timetableModel-V2ifvGGy.mjs} +148 -8
  128. package/dist/client/{useAvailableSlots-BjbJXotk.mjs → useAvailableSlots-D1X69-pN.mjs} +3 -3
  129. package/dist/client/{useBookingNowIso-CMgfL7YJ.mjs → useBookingNowIso-Ch30jino.mjs} +1 -1
  130. package/dist/client/{useDiscountApply-KG8jB7WC.mjs → useDiscountApply-Bwzr1RjV.mjs} +2 -2
  131. package/dist/client/{useDiscountCodeUi-DK2w_i0a.mjs → useDiscountCodeUi-BimJbFC7.mjs} +1 -1
  132. package/dist/client/{useEventPagination-DW6MCirb.mjs → useEventPagination-CLAS0upd.mjs} +8 -21
  133. package/dist/client/{view-CkUn3Y0Y.mjs → view-BUh4LnLS.mjs} +4 -4
  134. package/dist/client/{view-CseyBW07.mjs → view-Dj_FZHmg.mjs} +18 -15
  135. package/dist/client/wizardSteps-BkZc-hKH.mjs +6598 -0
  136. package/dist/preview-next/before-render.mjs +5 -4
  137. package/dist/preview-next/chrome.css +2 -0
  138. package/dist/preview-next/client/{EventEmbeddedCheckoutStep-lUHBrzHv.mjs → EventEmbeddedCheckoutStep-CwerMfzn.mjs} +2 -1
  139. package/dist/preview-next/client/LocationPickerEnvironment-QtSG2Bl-.mjs +138 -0
  140. package/dist/preview-next/client/MapLibreEditMap-B-rohNcG.mjs +488 -0
  141. package/dist/preview-next/client/{PreviewEditorSidebar-DWyUGCAG.mjs → PreviewEditorSidebar-Dvq-RW9-.mjs} +110 -63
  142. package/dist/preview-next/client/{PreviewEditorUI-Wq0b3Daw.mjs → PreviewEditorUI-BdFjS39R.mjs} +4 -3
  143. package/dist/preview-next/client/{SdkPreviewModeRuntime-wSI_R361.mjs → SdkPreviewModeRuntime-BEfHln1E.mjs} +425 -412
  144. package/dist/preview-next/client/{SdkPreviewModeRuntime-BtZPcwYV.mjs → SdkPreviewModeRuntime-CjkGh1IG.mjs} +1 -1
  145. package/dist/preview-next/client/{SiteChromeCustomizeContext-Hc4pYnNe.mjs → SiteChromeCustomizeContext-CDbxk_qZ.mjs} +2982 -53859
  146. package/dist/preview-next/client/{ThemedButton-DzeycIlD.mjs → ThemedButton-b14Bv03E.mjs} +1079 -340
  147. package/dist/preview-next/client/lucide-react-CA9cpo0P.mjs +51984 -0
  148. package/dist/preview-next/client/maplibre-gl-DykfOYYn.mjs +34208 -0
  149. package/dist/preview-next/client/{previewChromeSurface-Corq4AG7.mjs → previewChromeSurface-Dd1_mNIg.mjs} +1 -1
  150. package/dist/preview-next/client/result-BjJUoxUF.mjs +16 -0
  151. package/dist/preview-next/client/rolldown-runtime-CE6sIgz8.mjs +34 -0
  152. package/dist/preview-next/client/runtime.mjs +3 -3
  153. package/dist/preview-next/client/{sdk-runtime-CWymRWhK.mjs → sdk-runtime-B-CXyGVb.mjs} +1 -1
  154. package/dist/preview-next/client/siteStyleAccess-Kqk0j0dE.mjs +5812 -0
  155. package/dist/preview-next/client/{spinner-C4If5Y-O.mjs → spinner-CGxS8Ns-.mjs} +2 -1
  156. package/dist/preview-next/{constants-D8Ya7bO4.mjs → constants-Bf-vqdKH.mjs} +2 -1
  157. package/dist/preview-next/editor-base.css +2 -2
  158. package/dist/preview-next/keepAlive.mjs +2 -2
  159. package/dist/preview-next/middleware.mjs +7 -3
  160. package/dist/preview-next/{route-contract-8csADeIT.mjs → route-contract-hLg-yjQN.mjs} +41 -4
  161. package/dist/preview-next/{session-BgkrPqu0.mjs → session-P1R_ajT7.mjs} +12 -2
  162. package/dist/preview-next/session.mjs +1 -1
  163. package/dist/server/{Block.shared-D1_gonwM.mjs → Block.shared-CeTd2saO.mjs} +4 -4
  164. package/dist/server/{bindings-CFmJg5lm.mjs → bindings-C5YpKuKt.mjs} +2 -1
  165. package/dist/server/{client-DPsi0Dai.mjs → client-Cv26lZQ4.mjs} +7 -5
  166. package/dist/server/config-validation.mjs +1 -1
  167. package/dist/server/config.mjs +2 -2
  168. package/dist/server/{siteChromeOverlayClearance-DALIAMwo.mjs → effectiveNavLinkStyle-CGvGr3yD.mjs} +461 -1064
  169. package/dist/server/index.mjs +3 -3
  170. package/dist/server/{loadContent-RMCcuVU_.mjs → loadContent-C8a0b-cC.mjs} +11 -5
  171. package/dist/server/loadPage--DXBwI8V.mjs +2 -0
  172. package/dist/server/{loadPage-DhDGzj7t.mjs → loadPage-BW7dklu3.mjs} +3 -2
  173. package/dist/server/next.mjs +9 -9
  174. package/dist/server/{overrideResolution-OxY5FMuy.mjs → overrideResolution-tIuqmJB3.mjs} +1 -1
  175. package/dist/server/{overrides-Bz_A6sB9.mjs → overrides-D1fiPOKF.mjs} +596 -301
  176. package/dist/server/page-converter.mjs +1 -1
  177. package/dist/server/{prebuild-B_1vrSru.mjs → prebuild--fO0E2tr.mjs} +1 -1
  178. package/dist/server/prebuild.mjs +1 -1
  179. package/dist/server/{prefetchBlockData-B7ukYXXR.mjs → prefetchBlockData-CqJnokWJ.mjs} +133 -87
  180. package/dist/server/{publicProducts-Djbpc81A.mjs → publicProducts-CvvZ4JIe.mjs} +41 -3
  181. package/dist/server/{registry-eFjKtEhF.mjs → registry-BVfCqaCq.mjs} +477 -1021
  182. package/dist/server/rendering/server.mjs +4 -4
  183. package/dist/server/rendering.mjs +8 -8
  184. package/dist/server/{resolveBlockData-DYvEa9c5.mjs → resolveBlockData-DPNvhXEz.mjs} +1 -1
  185. package/dist/server/routing.mjs +1 -1
  186. package/dist/server/{schema-C3dJ5UkL.mjs → schema-CD4peO7m.mjs} +2203 -1223
  187. package/dist/server/server.mjs +3 -3
  188. package/dist/server/site-styles-H-EvTJiW.mjs +787 -0
  189. package/dist/server/siteChromeOverlayClearance-DNC2k1U0.mjs +750 -0
  190. package/dist/server/{src-C5Mu-z0F.mjs → src-ILxc6pid.mjs} +161 -3
  191. package/dist/server/theme-bridge.mjs +1 -1
  192. package/dist/server/theme.mjs +1 -1
  193. package/dist/server/{themeAdmission-ruoyXb_0.mjs → themeAdmission-BNHIXiUj.mjs} +117 -26
  194. package/dist/server/{validation-B-Xar8QS.mjs → validation-B1ieVemg.mjs} +2 -2
  195. package/dist/server/{version-Bg7VHK3i.mjs → version-BQK44wFg.mjs} +1 -1
  196. package/dist/styles/index.css +157 -0
  197. package/package.json +1 -1
  198. package/dist/client/LeafletStaticMap-ClZCCzAm.mjs +0 -135
  199. package/dist/client/location-map.client-Cylb_MHw.mjs +0 -28
  200. package/dist/client/location-map.view-Cx4Bl7ij.mjs +0 -345
  201. package/dist/client/locationMap-QnKJi-nZ.mjs +0 -15
  202. package/dist/client/mediaContext-DThoeEBU.mjs +0 -136
  203. package/dist/client/renderableMediaAssetAdmission-DGjBr_e-.mjs +0 -152
  204. package/dist/client/wizardSteps-zgq10lN1.mjs +0 -17181
  205. package/dist/preview-next/client/siteStyleAccess-QZkJRHl5.mjs +0 -1359
  206. package/dist/server/loadPage-DUPP51C-.mjs +0 -2
  207. package/dist/server/media-CcHwZkdJ.mjs +0 -243
@@ -1,140 +1,69 @@
1
- import { a as mediaSchema, c as videoMediaSchema, n as externalMediaSchema, r as imageMediaSchema, t as assetMediaSchema } from "./media-CcHwZkdJ.mjs";
2
1
  import { z } from "zod";
3
- //#region ../theme-core/src/palette/utils/colorConversion.ts
4
- const clamp01 = (x) => Math.max(0, Math.min(1, x));
5
- const mod = (a, n) => (a % n + n) % n;
6
- const deg = (x) => mod(x, 360);
7
- const mix$1 = (a, b, t) => a + (b - a) * clamp01(t);
8
- function hexToRgb(hex) {
9
- const h = hex.replace(/^#/, "");
10
- const m = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
11
- if (m.length !== 6) throw new Error("Bad hex");
12
- const int = parseInt(m, 16);
13
- return {
14
- r: int >> 16 & 255,
15
- g: int >> 8 & 255,
16
- b: int & 255
17
- };
18
- }
19
- function rgbToHex(r, g, b) {
20
- const to = (n) => Math.round(n).toString(16).padStart(2, "0");
21
- return `#${to(r)}${to(g)}${to(b)}`;
22
- }
23
- function srgbToLinear(u) {
24
- const x = u / 255;
25
- return x <= .04045 ? x / 12.92 : Math.pow((x + .055) / 1.055, 2.4);
26
- }
27
- function linearToSrgb(x) {
28
- return clamp01(x <= .0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - .055) * 255;
29
- }
30
- function rgbToHsl(r, g, b) {
31
- const R = r / 255, G = g / 255, B = b / 255;
32
- const max = Math.max(R, G, B), min = Math.min(R, G, B);
33
- const d = max - min;
34
- let h = 0;
35
- if (d !== 0) {
36
- switch (max) {
37
- case R:
38
- h = (G - B) / d + (G < B ? 6 : 0);
39
- break;
40
- case G:
41
- h = (B - R) / d + 2;
42
- break;
43
- case B:
44
- h = (R - G) / d + 4;
45
- break;
46
- }
47
- h *= 60;
48
- }
49
- const l = (max + min) / 2;
50
- const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
51
- return {
52
- h,
53
- s,
54
- l
55
- };
56
- }
57
- function srgbToOklab(r, g, b) {
58
- const R = srgbToLinear(r), G = srgbToLinear(g), B = srgbToLinear(b);
59
- const l = .4122214708 * R + .5363325363 * G + .0514459929 * B;
60
- const m = .2119034982 * R + .6806995451 * G + .1073969566 * B;
61
- const s = .0883024619 * R + .2817188376 * G + .6299787005 * B;
62
- const l_ = Math.cbrt(l), m_ = Math.cbrt(m), s_ = Math.cbrt(s);
63
- return {
64
- L: .2104542553 * l_ + .793617785 * m_ - .0040720468 * s_,
65
- a: 1.9779984951 * l_ - 2.428592205 * m_ + .4505937099 * s_,
66
- b: .0259040371 * l_ + .7827717662 * m_ - .808675766 * s_
67
- };
68
- }
69
- function oklabToSrgb(L, a, b) {
70
- const l_ = Math.pow(L + .3963377774 * a + .2158037573 * b, 3);
71
- const m_ = Math.pow(L - .1055613458 * a - .0638541728 * b, 3);
72
- const s_ = Math.pow(L - .0894841775 * a - 1.291485548 * b, 3);
73
- const R = 4.0767416621 * l_ - 3.3077115913 * m_ + .2309699292 * s_;
74
- const G = -1.2684380046 * l_ + 2.6097574011 * m_ - .3413193965 * s_;
75
- const B = -.0041960863 * l_ - .7034186147 * m_ + 1.707614701 * s_;
76
- return {
77
- r: linearToSrgb(R),
78
- g: linearToSrgb(G),
79
- b: linearToSrgb(B)
80
- };
81
- }
82
- function oklabToOklch(L, a, b) {
83
- const C = Math.sqrt(a * a + b * b);
84
- return {
85
- L,
86
- C,
87
- h: C < 1e-7 ? 0 : deg(Math.atan2(b, a) * 180 / Math.PI)
88
- };
89
- }
90
- function oklchToOklab(L, C, h) {
91
- const hr = h * Math.PI / 180;
2
+ //#region ../core/src/result.ts
3
+ function ok(value) {
92
4
  return {
93
- L,
94
- a: C * Math.cos(hr),
95
- b: C * Math.sin(hr)
5
+ ok: true,
6
+ value
96
7
  };
97
8
  }
98
- function inSRGB(r, g, b) {
99
- return r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255;
100
- }
101
- function oklchToHexGamut(L, C, h) {
102
- let lo = 0, hi = C, best = 0;
103
- for (let i = 0; i < 18; i++) {
104
- const mid = (lo + hi) / 2;
105
- const { a, b } = oklchToOklab(L, mid, h);
106
- const { r, g, b: bb } = oklabToSrgb(L, a, b);
107
- if (inSRGB(r, g, bb)) {
108
- best = mid;
109
- lo = mid;
110
- } else hi = mid;
111
- }
112
- const { a, b } = oklchToOklab(L, best, h);
113
- const { r, g, b: bb } = oklabToSrgb(L, a, b);
114
- return rgbToHex(r, g, bb);
115
- }
116
- function featuresFromHex(hex) {
117
- const { r, g, b } = hexToRgb(hex);
118
- const { h, s, l } = rgbToHsl(r, g, b);
119
- const { L, a, b: b2 } = srgbToOklab(r, g, b);
120
- const { L: okL, C: okC, h: okH } = oklabToOklch(L, a, b2);
9
+ function err(error) {
121
10
  return {
122
- r,
123
- g,
124
- b,
125
- h,
126
- s,
127
- l,
128
- v: Math.max(r, g, b) / 255,
129
- Y: .2126 * srgbToLinear(r) + .7152 * srgbToLinear(g) + .0722 * srgbToLinear(b),
130
- chroma: s,
131
- okL,
132
- okC,
133
- okH,
134
- hex
11
+ ok: false,
12
+ error
135
13
  };
136
14
  }
137
15
  //#endregion
16
+ //#region ../core/src/branded.ts
17
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
18
+ function parseUuidBrand(value, unsafeConstructor) {
19
+ if (typeof value !== "string") return err({ kind: "not_string" });
20
+ const normalized = value.trim().toLowerCase();
21
+ if (normalized.length === 0) return err({ kind: "empty_string" });
22
+ if (!UUID_PATTERN.test(normalized)) return err({ kind: "invalid_uuid" });
23
+ return ok(unsafeConstructor(normalized));
24
+ }
25
+ const unsafeAsSiteId = (id) => id;
26
+ const unsafeAsApiKeyId = (id) => id;
27
+ const unsafeAsEventOfferingId = (id) => id;
28
+ const unsafeAsEventSeriesId = (id) => id;
29
+ const unsafeAsMediaAssetId = (id) => id;
30
+ const unsafeAsStorageBucketName = (value) => value;
31
+ const unsafeAsStoragePath = (value) => value;
32
+ const unsafeAsUserId = (id) => id;
33
+ const unsafeAsSiteTermsVersionId = (id) => id;
34
+ const unsafeAsContentVersionId = (id) => id;
35
+ const parseSiteId = (value) => parseUuidBrand(value, unsafeAsSiteId);
36
+ const parseApiKeyId = (value) => parseUuidBrand(value, unsafeAsApiKeyId);
37
+ const parseEventOfferingId = (value) => parseUuidBrand(value, unsafeAsEventOfferingId);
38
+ const parseUserId = (value) => parseUuidBrand(value, unsafeAsUserId);
39
+ const parseMediaAssetId = (value) => parseUuidBrand(value, unsafeAsMediaAssetId);
40
+ const parseContentVersionId = (value) => parseUuidBrand(value, unsafeAsContentVersionId);
41
+ const parseSiteTermsVersionId = (value) => parseUuidBrand(value, unsafeAsSiteTermsVersionId);
42
+ const parseEventSeriesId = (value) => parseUuidBrand(value, unsafeAsEventSeriesId);
43
+ //#endregion
44
+ //#region ../theme-core/src/buttons/typography.ts
45
+ const textTransformSchema = z.enum([
46
+ "none",
47
+ "uppercase",
48
+ "lowercase",
49
+ "capitalize"
50
+ ]);
51
+ const fontWeightSchema = z.union([
52
+ z.literal(400),
53
+ z.literal(500),
54
+ z.literal(600),
55
+ z.literal(700),
56
+ z.literal(800)
57
+ ]);
58
+ const buttonTypographySchema = z.enum(["body", "heading"]);
59
+ const letterSpacingSchema = z.enum([
60
+ "tight",
61
+ "normal",
62
+ "slight",
63
+ "loose",
64
+ "wide"
65
+ ]);
66
+ //#endregion
138
67
  //#region ../theme-core/src/tokens/colorTokenParts.ts
139
68
  function parseOpacityPercent(source) {
140
69
  const trimmed = source.trim();
@@ -283,423 +212,1082 @@ function parseThemeColorToken(value) {
283
212
  }
284
213
  const themeColorTokenSchema = z.string().min(1).refine((value) => Boolean(isThemeColorToken(value)), "Expected a known Theme V2 color token");
285
214
  //#endregion
286
- //#region ../theme-core/src/palette/colors.ts
287
- const HEX_COLOR_REGEX = /^#[0-9a-f]{6}$/;
288
- const NORMALIZABLE_HEX_REGEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
289
- const THEME_PALETTE_COLOR_ORDER = [
215
+ //#region ../theme-core/src/buttons/types.ts
216
+ /**
217
+ * Standard semantic variant roles a theme exposes.
218
+ *
219
+ * Block content references variants by role; the active theme determines
220
+ * what each role looks like.
221
+ */
222
+ const VARIANT_ROLES = [
290
223
  "primary",
291
224
  "secondary",
292
- "accent",
293
- "success",
294
- "warning",
295
- "destructive",
296
- "background",
297
- "surface",
298
- "surfaceAlt",
299
- "muted",
300
- "text",
301
- "primaryForeground",
302
- "border"
225
+ "outline",
226
+ "ghost",
227
+ "accent"
303
228
  ];
304
- const hexColorSchema = z.string().regex(HEX_COLOR_REGEX, "Hex must be #RRGGBB (lowercase)").transform((value) => value);
305
- const paletteModeSchema = z.enum(["light", "dark"]);
306
- const PALETTE_VALUE_KEY_PREFIX = "palette-value:v1|";
307
- z.string().regex(/^[0-9a-f]{64}$/, "Palette hash must be a lowercase SHA-256 value").transform((value) => value);
308
- const paletteColorsSchema = z.object({
309
- primary: hexColorSchema,
310
- primaryForeground: hexColorSchema,
311
- secondary: hexColorSchema,
312
- accent: hexColorSchema,
313
- success: hexColorSchema,
314
- warning: hexColorSchema,
315
- destructive: hexColorSchema,
316
- background: hexColorSchema,
317
- surface: hexColorSchema,
318
- surfaceAlt: hexColorSchema,
319
- muted: hexColorSchema,
320
- text: hexColorSchema,
321
- border: hexColorSchema
322
- }).strict().transform((value) => value);
323
- function normalizePaletteHex(value) {
324
- if (!NORMALIZABLE_HEX_REGEX.test(value)) return null;
325
- const normalized = value.toLowerCase();
326
- if (normalized.length === 7) return normalized;
327
- const triplet = normalized.slice(1);
328
- const red = triplet.charAt(0);
329
- const green = triplet.charAt(1);
330
- const blue = triplet.charAt(2);
331
- return `#${red}${red}${green}${green}${blue}${blue}`;
332
- }
333
- function paletteColorsFromEntries(entries) {
334
- const values = {};
335
- for (const entry of entries) {
336
- const parsedRole = paletteTokenNameSchema.safeParse(entry.name);
337
- if (!parsedRole.success) return {
338
- ok: false,
339
- error: {
340
- kind: "unknown-role",
341
- role: entry.name
342
- }
343
- };
344
- const role = parsedRole.data;
345
- if (values[role] !== void 0) return {
346
- ok: false,
347
- error: {
348
- kind: "duplicate-role",
349
- role
350
- }
351
- };
352
- const hex = normalizePaletteHex(entry.hex);
353
- if (!hex) return {
354
- ok: false,
355
- error: {
356
- kind: "invalid-color",
357
- role,
358
- value: entry.hex
359
- }
360
- };
361
- values[role] = hex;
362
- }
363
- const missing = PALETTE_TOKEN_NAMES.filter((role) => values[role] === void 0);
364
- if (missing.length > 0) return {
365
- ok: false,
366
- error: {
367
- kind: "missing-roles",
368
- roles: missing
369
- }
370
- };
371
- return {
372
- ok: true,
373
- colors: paletteColorsSchema.parse(values)
374
- };
229
+ function isVariantRole(value) {
230
+ return VARIANT_ROLES.includes(value);
375
231
  }
376
- function requirePaletteColorsFromEntries(entries) {
377
- const result = paletteColorsFromEntries(entries);
378
- if (result.ok) return result.colors;
379
- throw new Error(`Invalid complete palette: ${result.error.kind}`);
380
- }
381
- function paletteColorEntries(colors) {
382
- return THEME_PALETTE_COLOR_ORDER.map((name) => ({
383
- name,
384
- hex: colors[name]
385
- }));
386
- }
387
- function paletteColorFingerprint(colors) {
388
- return PALETTE_TOKEN_NAMES.map((name) => `${name}:${colors[name]}`).join("|");
389
- }
390
- function canonicalPaletteHashInput(colors, mode) {
391
- return `${mode}|${paletteColorFingerprint(colors)}`;
232
+ /**
233
+ * Canonical persisted/CSS-safe button variant identifier.
234
+ *
235
+ * IDs become class selectors, so keep the contract deliberately narrower than
236
+ * an arbitrary string and shared with every authoring/runtime boundary.
237
+ */
238
+ const buttonVariantIdSchema = z.string().min(1).max(50).regex(/^[a-z0-9-]+$/, "Button variant IDs may contain lowercase letters, numbers, and hyphens only").refine((value) => value !== "link" && value !== "tertiary", { message: "Retired button role IDs are not valid variant IDs" });
239
+ function asSpecialVariantId(value) {
240
+ const parsed = buttonVariantIdSchema.safeParse(value);
241
+ if (!parsed.success) throw new Error("SpecialVariantId must be a CSS-safe button variant ID");
242
+ return parsed.data;
392
243
  }
393
244
  /**
394
- * Stable curated-catalogue identity. Do not reorder roles: the order comes
395
- * from PALETTE_TOKEN_NAMES through canonicalPaletteHashInput.
245
+ * Magic alias the CSS generator emits for the highest-priority variant.
246
+ *
247
+ * Shared between generator and renderer so neither side hard-codes the string.
396
248
  */
397
- function paletteValueKey(colors, mode) {
398
- return `${PALETTE_VALUE_KEY_PREFIX}${canonicalPaletteHashInput(colors, mode)}`;
249
+ const DEFAULT_VARIANT_ALIAS_ID = "default";
250
+ function parseOpaqueButtonColourToken(value) {
251
+ const token = parseThemeColorToken(value);
252
+ if (token === null) return null;
253
+ const parts = parseColorTokenParts(token);
254
+ return parts.kind === "token" && parts.opacityPercent === null ? token : null;
399
255
  }
400
- /** Parses only the exact v1 canonical form emitted by paletteValueKey. */
401
- function parsePaletteValueKey(value) {
402
- if (typeof value !== "string" || !value.startsWith(PALETTE_VALUE_KEY_PREFIX)) return null;
403
- const [rawMode, ...rawRoles] = value.slice(17).split("|");
404
- const mode = paletteModeSchema.safeParse(rawMode);
405
- if (!mode.success || rawRoles.length !== PALETTE_TOKEN_NAMES.length) return null;
406
- const colors = paletteColorsFromEntries(rawRoles.map((roleValue) => {
407
- const separator = roleValue.indexOf(":");
408
- return separator === -1 ? {
409
- name: "",
410
- hex: ""
411
- } : {
412
- name: roleValue.slice(0, separator),
413
- hex: roleValue.slice(separator + 1)
414
- };
415
- }));
416
- if (!colors.ok || paletteValueKey(colors.colors, mode.data) !== value) return null;
256
+ function unsafeAsOpaqueButtonColourToken(value) {
417
257
  return value;
418
258
  }
419
- const paletteValueKeySchema = z.string().transform((value, ctx) => {
420
- const parsed = parsePaletteValueKey(value);
421
- if (parsed) return parsed;
422
- ctx.addIssue({
423
- code: "custom",
424
- message: "Invalid canonical palette value key"
425
- });
426
- return z.NEVER;
259
+ const opaqueButtonColourTokenSchema = themeColorTokenSchema.refine((value) => parseOpaqueButtonColourToken(value) !== null, "Button colour tokens must be opaque").transform((value) => {
260
+ const token = parseOpaqueButtonColourToken(value);
261
+ if (token === null) throw new Error("Invariant: opaque button token passed its schema");
262
+ return token;
427
263
  });
428
- //#endregion
429
- //#region ../theme-core/src/palette/utils/opaqueSurfaceColor.ts
430
- /** Resolve an opaque colour, compositing alpha against an explicit underlay. */
431
- function resolveOpaqueSurfaceHex(reference, palette, underlayReference) {
432
- const opaque = resolveConcreteColorHex(reference, palette);
433
- if (opaque) return opaque;
434
- if (!underlayReference) return null;
435
- const underlayHex = resolveConcreteColorHex(underlayReference, palette);
436
- if (!underlayHex) return null;
437
- const parts = parseColorTokenParts(reference);
438
- if (parts.kind === "token" && parts.opacityPercent !== null) {
439
- const foregroundHex = normalizePaletteHex(palette[parts.token] ?? "");
440
- return foregroundHex ? compositeHex(foregroundHex, underlayHex, parts.opacityPercent / 100) : null;
441
- }
442
- const rgba = parseRgba(parts.kind === "raw" ? parts.value : reference);
443
- return rgba ? compositeHex(rgbToHex(rgba.r, rgba.g, rgba.b), underlayHex, rgba.alpha) : null;
444
- }
445
- /** Resolve a colour reference only when it is already fully opaque. */
446
- function resolveConcreteColorHex(reference, palette) {
447
- const literalHex = normalizePaletteHex(reference);
448
- if (literalHex) return literalHex;
449
- const parts = parseColorTokenParts(reference);
450
- if (parts.kind === "token") {
451
- if (parts.opacityPercent !== null) return null;
452
- return normalizePaletteHex(palette[parts.token] ?? "");
453
- }
454
- const literal = parts.kind === "raw" ? parts.value : reference;
455
- if (literal.toLowerCase() === "black") return "#000000";
456
- if (literal.toLowerCase() === "white") return "#ffffff";
457
- return normalizePaletteHex(literal);
458
- }
459
- function compositeHex(foregroundHex, underlayHex, alpha) {
460
- const foreground = hexToRgb(foregroundHex);
461
- const underlay = hexToRgb(underlayHex);
462
- const channel = (foregroundValue, underlayValue) => Math.round(foregroundValue * alpha + underlayValue * (1 - alpha));
463
- return rgbToHex(channel(foreground.r, underlay.r), channel(foreground.g, underlay.g), channel(foreground.b, underlay.b));
464
- }
465
- function parseRgba(value) {
466
- const match = value.trim().match(/^rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*(?:,|\/)\s*([\d.]+%?))?\s*\)$/i);
467
- if (!match) return null;
468
- const [, rSource, gSource, bSource] = match;
469
- if (!rSource || !gSource || !bSource) return null;
470
- const r = Number(rSource);
471
- const g = Number(gSource);
472
- const b = Number(bSource);
473
- const alpha = parseAlpha(match[4]);
474
- if (alpha === null || !isRgbChannel(r) || !isRgbChannel(g) || !isRgbChannel(b)) return null;
475
- return {
476
- r,
477
- g,
478
- b,
479
- alpha
480
- };
481
- }
482
- function parseAlpha(source) {
483
- if (!source) return 1;
484
- const value = source.endsWith("%") ? Number(source.slice(0, -1)) / 100 : Number(source);
485
- return Number.isFinite(value) && value >= 0 && value <= 1 ? value : null;
486
- }
487
- function isRgbChannel(value) {
488
- return Number.isFinite(value) && value >= 0 && value <= 255;
489
- }
490
- function relativeLuminance(r, g, b) {
491
- const R = srgbToLinear(r), G = srgbToLinear(g), B = srgbToLinear(b);
492
- return .2126 * R + .7152 * G + .0722 * B;
493
- }
494
- function preparePaletteColourIndex(palette) {
495
- const colours = [.../* @__PURE__ */ new Set([
496
- ...Object.values(palette),
497
- "#000000",
498
- "#ffffff",
499
- "#FFFFFF"
500
- ])];
501
- return Object.freeze(Object.fromEntries(colours.flatMap(colourIndexEntry)));
502
- }
503
- /** An unused unsupported colour must not turn preparation into an eager validation failure. */
504
- function colourIndexEntry(hex) {
505
- try {
506
- return [[hex, colourLuminance(hex)]];
507
- } catch {
508
- return [];
509
- }
510
- }
511
- function colourLuminance(hex) {
512
- const { r, g, b } = hexToRgb(hex);
513
- return relativeLuminance(r, g, b);
514
- }
515
- function indexedLuminance(hex, index) {
516
- return (index && Object.prototype.hasOwnProperty.call(index, hex) ? index[hex] : void 0) ?? colourLuminance(hex);
517
- }
518
- function contrastRatio(hex1, hex2, index) {
519
- const L1 = indexedLuminance(hex1, index);
520
- const L2 = indexedLuminance(hex2, index);
521
- const [hi, lo] = L1 >= L2 ? [L1, L2] : [L2, L1];
522
- return (hi + .05) / (lo + .05);
523
- }
524
- //#endregion
525
- //#region ../theme-core/src/palette/generateShades.ts
526
- function generateShades(hexColor, name) {
527
- const shadeSteps = [
528
- 50,
529
- 100,
530
- 200,
531
- 300,
532
- 400,
533
- 500,
534
- 600,
535
- 700,
536
- 800,
537
- 900,
538
- 950
539
- ];
540
- const base = featuresFromHex(hexColor);
541
- const hue = base.okH;
542
- const baseChroma = base.okC;
543
- const toneMap = {
544
- 50: .975,
545
- 100: .945,
546
- 200: .89,
547
- 300: .82,
548
- 400: .74,
549
- 500: .66,
550
- 600: .58,
551
- 700: .49,
552
- 800: .4,
553
- 900: .28,
554
- 950: .16
555
- };
556
- const shadeDefs = shadeSteps.map((step, idx) => {
557
- const t = idx / (shadeSteps.length - 1);
558
- const L = toneMap[step];
559
- const C = baseChroma * (.06 + .94 * Math.sin(Math.PI * t));
560
- return {
561
- name: `${name}-${step}`,
562
- hex: oklchToHexGamut(L, C, hue)
563
- };
564
- });
565
- shadeDefs.push({
566
- name,
567
- hex: hexColor
568
- });
569
- return shadeDefs;
570
- }
571
- //#endregion
572
- //#region ../theme-core/src/palette/neutralScale.ts
573
- function generateNeutralScale({ background, steps = 11, warm = false }) {
574
- const isDark = background === "#000000" || background.startsWith("#0") || background.startsWith("#1");
575
- const shadeNames = [
576
- 50,
577
- 100,
578
- 200,
579
- 300,
580
- 400,
581
- 500,
582
- 600,
583
- 700,
584
- 800,
585
- 900,
586
- 950
587
- ];
588
- const count = Math.min(steps, shadeNames.length);
589
- const scale = [];
590
- for (let i = 0; i < count; i++) {
591
- const shadeName = shadeNames[i] ?? shadeNames[shadeNames.length - 1] ?? 950;
592
- const t = i / (count - 1);
593
- const hex = oklchToHexGamut(isDark ? mix(.06, .92, t) : mix(.98, .1, t), .02, warm ? 85 : 250);
594
- const name = `neutral-${shadeName}`;
595
- scale.push({
596
- name,
597
- hex
598
- });
599
- }
600
- return scale;
601
- }
602
- function mix(a, b, t) {
603
- return a + (b - a) * Math.max(0, Math.min(1, t));
604
- }
605
- //#endregion
606
- //#region ../theme-core/src/palette/utils/textColor.ts
264
+ const contextualButtonHoverSchema = z.strictObject({
265
+ kind: z.literal("shade-shift"),
266
+ seedToken: opaqueButtonColourTokenSchema,
267
+ fallbackDirection: z.enum(["lighter", "darker"]),
268
+ preferredToken: opaqueButtonColourTokenSchema.optional()
269
+ });
270
+ const buttonShadeAmountSchema = z.number().finite().min(0).max(900).multipleOf(100);
271
+ const buttonShadowIntensitySchema = z.enum([
272
+ "subtle",
273
+ "medium",
274
+ "strong"
275
+ ]);
607
276
  /**
608
- * Pick the better of black/white text for a given background using actual
609
- * contrast ratios, not a simple luminance cutoff.
277
+ * The complete persisted button-effect contract.
610
278
  *
611
- * @param background - Background color in hex or rgb/rgba format (e.g., '#FFFFFF' or 'rgb(255, 255, 255)')
612
- * @param minContrast - Preferred minimum contrast ratio for body-sized text
613
- * @returns '#000000' for light backgrounds, '#FFFFFF' for dark backgrounds
614
- */
615
- function pickBlackOrWhiteTextColor(background, minContrast = 4.5) {
616
- const { r, g, b } = parseColorToRgb(background);
617
- const luminance = relativeLuminance(r, g, b);
618
- const blackContrast = (luminance + .05) / .05;
619
- const whiteContrast = 1.05 / (luminance + .05);
620
- if (blackContrast >= minContrast && whiteContrast < minContrast) return "#000000";
621
- if (whiteContrast >= minContrast && blackContrast < minContrast) return "#FFFFFF";
622
- return blackContrast >= whiteContrast ? "#000000" : "#FFFFFF";
623
- }
624
- /**
625
- * Backwards-compatible alias for callers that want the best black/white text
626
- * color for a background.
279
+ * Navigation has its own generic interactive-effect model. Button variants use
280
+ * this closed union so unsupported effect IDs, unknown option keys, and unsafe
281
+ * CSS values cannot become representable after the schema boundary.
627
282
  */
628
- function getTextColorForBackground(background) {
629
- return pickBlackOrWhiteTextColor(background);
630
- }
631
- function parseColorToRgb(input) {
632
- const trimmed = input.trim();
633
- if (trimmed.startsWith("#")) return hexToRgb(trimmed);
634
- const rgbMatch = trimmed.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(?:0|1|0?\.\d+))?\s*\)$/i);
635
- if (rgbMatch?.[1] && rgbMatch[2] && rgbMatch[3]) return {
636
- r: clamp255(Number(rgbMatch[1])),
637
- g: clamp255(Number(rgbMatch[2])),
638
- b: clamp255(Number(rgbMatch[3]))
639
- };
640
- throw new Error("Unsupported color format");
641
- }
642
- function clamp255(value) {
643
- if (Number.isNaN(value)) return 0;
644
- return Math.max(0, Math.min(255, value));
645
- }
646
- //#endregion
647
- //#region ../theme-core/src/palette/utils/onColor.ts
648
- const BACKGROUND_ROLE_NAMES = /* @__PURE__ */ new Set([
649
- "primary",
650
- "secondary",
651
- "accent",
652
- "success",
653
- "warning",
654
- "destructive",
655
- "info",
656
- "background",
657
- "surface",
658
- "surfaceAlt",
659
- "muted",
660
- "neutral"
283
+ const buttonPressOffsetSchema = z.strictObject({
284
+ x: z.number().int().min(0).max(12),
285
+ y: z.number().int().min(0).max(12)
286
+ });
287
+ const buttonEffectApplicationSchema = z.discriminatedUnion("effectId", [
288
+ z.strictObject({
289
+ effectId: z.literal("darken-background"),
290
+ options: z.strictObject({ amount: buttonShadeAmountSchema.optional() }).optional()
291
+ }),
292
+ z.strictObject({
293
+ effectId: z.literal("lighten-background"),
294
+ options: z.strictObject({ amount: buttonShadeAmountSchema.optional() }).optional()
295
+ }),
296
+ z.strictObject({
297
+ effectId: z.literal("background-on-hover"),
298
+ options: z.strictObject({ colorToken: opaqueButtonColourTokenSchema.optional() }).optional()
299
+ }),
300
+ z.strictObject({
301
+ effectId: z.literal("animated-gradient"),
302
+ options: z.strictObject({ direction: z.enum(["horizontal", "vertical"]).optional() }).optional()
303
+ }),
304
+ z.strictObject({
305
+ effectId: z.literal("drop-shadow"),
306
+ options: z.strictObject({ intensity: buttonShadowIntensitySchema.optional() }).optional()
307
+ }),
308
+ z.strictObject({
309
+ effectId: z.literal("inner-shadow"),
310
+ options: z.strictObject({}).optional()
311
+ }),
312
+ z.strictObject({
313
+ effectId: z.literal("neumorphic-shadow"),
314
+ options: z.strictObject({
315
+ mode: z.enum(["raised", "pressed"]).optional(),
316
+ intensity: buttonShadowIntensitySchema.optional()
317
+ }).optional()
318
+ }),
319
+ z.strictObject({
320
+ effectId: z.literal("retro-3d-shadow"),
321
+ options: z.strictObject({}).optional()
322
+ }),
323
+ z.strictObject({
324
+ effectId: z.literal("scale-up"),
325
+ options: z.strictObject({ scale: z.enum([
326
+ "1.02",
327
+ "1.03",
328
+ "1.05",
329
+ "1.10"
330
+ ]).optional() }).optional()
331
+ }),
332
+ z.strictObject({
333
+ effectId: z.literal("scale-down"),
334
+ options: z.strictObject({ scale: z.enum([
335
+ "0.90",
336
+ "0.95",
337
+ "0.97",
338
+ "0.98"
339
+ ]).optional() }).optional()
340
+ }),
341
+ z.strictObject({
342
+ effectId: z.literal("lift"),
343
+ options: z.strictObject({ amount: z.enum([
344
+ "0.125",
345
+ "0.25",
346
+ "0.5",
347
+ "1"
348
+ ]).optional() }).optional()
349
+ }),
350
+ z.strictObject({
351
+ effectId: z.literal("press-down"),
352
+ options: z.strictObject({ offset: buttonPressOffsetSchema.optional() }).optional()
353
+ }),
354
+ z.strictObject({
355
+ effectId: z.literal("pop"),
356
+ options: z.strictObject({ intensity: z.enum([
357
+ "subtle",
358
+ "medium",
359
+ "dramatic"
360
+ ]).optional() }).optional()
361
+ }),
362
+ z.strictObject({
363
+ effectId: z.literal("border-bottom-grow"),
364
+ options: z.strictObject({
365
+ height: z.union([z.literal(1), z.literal(2)]).optional(),
366
+ origin: z.enum([
367
+ "left",
368
+ "center",
369
+ "right"
370
+ ]).optional(),
371
+ persistent: z.boolean().optional(),
372
+ colourRole: z.literal("mark").optional()
373
+ }).optional()
374
+ }),
375
+ z.strictObject({
376
+ effectId: z.literal("sketchy-border"),
377
+ options: z.strictObject({ intensity: buttonShadowIntensitySchema.optional() }).optional()
378
+ })
661
379
  ]);
662
- function onColorTokenName(backgroundToken) {
663
- return `on${backgroundToken.split("-").filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("")}`;
664
- }
665
- function isOnColorBackgroundCandidateToken(token) {
666
- const role = token.match(/^(.*?)(?:-\d{2,3})?$/)?.[1] ?? token;
667
- return BACKGROUND_ROLE_NAMES.has(role);
668
- }
669
- //#endregion
670
- //#region ../theme-core/src/palette/expandPalette.ts
671
- function colorsToMap(palette) {
672
- const map = {};
673
- for (const c of palette.colors) map[c.name] = c.hex;
674
- return map;
675
- }
676
- function isBackgroundDark(hex) {
677
- try {
678
- return featuresFromHex(hex).Y < .5;
679
- } catch {
680
- return false;
681
- }
380
+ const cornerStyleSchema = z.enum([
381
+ "square",
382
+ "rounded",
383
+ "pill"
384
+ ]);
385
+ const shadowSizeSchema = z.enum([
386
+ "none",
387
+ "low",
388
+ "medium",
389
+ "high"
390
+ ]);
391
+ const hoverTransformSchema = z.enum([
392
+ "none",
393
+ "lift",
394
+ "scale",
395
+ "press"
396
+ ]);
397
+ z.enum(["none", "token"]);
398
+ const buttonPaddingPresetSchema = z.enum([
399
+ "compact",
400
+ "default",
401
+ "spacious"
402
+ ]);
403
+ const gradientStyleSchema = z.enum([
404
+ "linear",
405
+ "radial",
406
+ "conic"
407
+ ]);
408
+ const gradientSharpnessSchema = z.enum([
409
+ "smooth",
410
+ "medium",
411
+ "hard"
412
+ ]);
413
+ const prioritySchema = z.union([
414
+ z.literal(1),
415
+ z.literal(2),
416
+ z.literal(3)
417
+ ]);
418
+ const variantRoleSchema = z.enum(VARIANT_ROLES);
419
+ const buttonSurfaceFallbackSchema = z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("surface-outline") }), z.strictObject({
420
+ kind: z.literal("variant"),
421
+ role: variantRoleSchema
422
+ })]);
423
+ const standardButtonSurfacePolicy = {
424
+ primary: [{ kind: "surface-outline" }],
425
+ secondary: [{ kind: "surface-outline" }, {
426
+ kind: "variant",
427
+ role: "primary"
428
+ }],
429
+ outline: [{ kind: "surface-outline" }],
430
+ ghost: [{ kind: "surface-outline" }],
431
+ accent: [{ kind: "surface-outline" }, {
432
+ kind: "variant",
433
+ role: "primary"
434
+ }]
435
+ };
436
+ const STANDARD_BUTTON_SURFACE_POLICY = Object.freeze(Object.fromEntries(VARIANT_ROLES.map((role) => [role, Object.freeze([...standardButtonSurfacePolicy[role]])])));
437
+ function createStandardButtonSurfacePolicy() {
438
+ return Object.fromEntries(VARIANT_ROLES.map((role) => [role, [...STANDARD_BUTTON_SURFACE_POLICY[role]]]));
682
439
  }
683
- const nonShadeablePaletteRoleNames = /* @__PURE__ */ new Set([
684
- "success",
685
- "warning",
686
- "destructive"
440
+ const buttonSurfacePolicyShape = Object.fromEntries(VARIANT_ROLES.map((role) => [role, z.array(buttonSurfaceFallbackSchema).max(VARIANT_ROLES.length)]));
441
+ const buttonSurfacePolicySchema = z.strictObject(buttonSurfacePolicyShape);
442
+ const buttonSizeNameSchema = z.enum([
443
+ "sm",
444
+ "md",
445
+ "lg",
446
+ "xl"
687
447
  ]);
688
448
  /**
689
- * Status role aliases the persisted palette does not carry itself.
690
- *
691
- * Generators reference `--tb-error` (the site-style-owned input error border)
692
- * and `--tb-info` (`.alert-info`, `.status-info`, the field-note rule), but the
693
- * palette schema only defines `destructive` and has no `info` role at all.
694
- * Without these aliases those declarations name variables that are never
695
- * defined and browsers drop them. The SDK bridge resolves the same pair via
696
- * TOKEN_ALIASES, so both runtimes agree on what a status token means.
449
+ * CSS padding string in `"<vertical> <horizontal>"` shorthand form.
697
450
  *
698
- * Runs after the danger → destructive promotion above, so `destructive` is
699
- * already the single source of truth for the error colour.
451
+ * Exactly two space-separated CSS length tokens. Each token is either the
452
+ * literal `0` or a number followed by `rem`/`em`/`px`/`%`. This lets the
453
+ * generator trust the shape rather than defensively defaulting downstream.
700
454
  */
701
- function statusAliasTokens(expanded) {
702
- const aliases = {};
455
+ const PADDING_TOKEN_PATTERN = /^(?:0|\d+(?:\.\d+)?(?:rem|em|px|%))$/;
456
+ const paddingShorthandSchema = z.string().refine((value) => {
457
+ const parts = value.split(/\s+/).filter(Boolean);
458
+ return parts.length === 2 && parts.every((token) => PADDING_TOKEN_PATTERN.test(token));
459
+ }, { message: "Padding must be two space-separated CSS length tokens (e.g. \"0.5rem 1rem\"). Use `0` for zero." });
460
+ const buttonSizeConfigSchema = z.object({
461
+ padding: paddingShorthandSchema,
462
+ fontSize: z.string().optional(),
463
+ borderRadius: z.string().optional()
464
+ });
465
+ /**
466
+ * `xl` is optional on the wire so themes persisted before the `xl` size was
467
+ * added (e.g. SWTS) continue to parse. When `xl` is missing the schema
468
+ * backfills it from `lg`, keeping `ButtonSizes` a complete `sm/md/lg/xl` map
469
+ * downstream — generators never need to deal with an undefined `xl`.
470
+ */
471
+ const buttonSizesSchema = z.object({
472
+ sm: buttonSizeConfigSchema,
473
+ md: buttonSizeConfigSchema,
474
+ lg: buttonSizeConfigSchema,
475
+ xl: buttonSizeConfigSchema.optional()
476
+ }).transform(({ sm, md, lg, xl }) => ({
477
+ sm,
478
+ md,
479
+ lg,
480
+ xl: xl ?? lg
481
+ }));
482
+ const buttonGlobalSettingsBaseSchema = z.strictObject({
483
+ cornerStyle: cornerStyleSchema,
484
+ cornerRadius: z.number().min(0).max(24).optional(),
485
+ /**
486
+ * Family-level shadow inherited by variants that don't set their own.
487
+ * Optional and flat-by-default: when omitted, buttons carry no drop shadow
488
+ * (`elevation: 'none'`). A personality opts the whole family into a shadow by
489
+ * setting this; individual variants still override. There is no system-level
490
+ * shadow-by-default — shadows only appear when explicitly declared.
491
+ */
492
+ shadow: shadowSizeSchema.optional(),
493
+ textTransform: textTransformSchema,
494
+ fontWeight: fontWeightSchema,
495
+ typography: buttonTypographySchema.optional(),
496
+ fontSize: z.string().optional(),
497
+ letterSpacing: letterSpacingSchema.optional(),
498
+ italic: z.boolean().optional(),
499
+ paddingPreset: buttonPaddingPresetSchema.optional(),
500
+ hoverTransform: hoverTransformSchema,
501
+ gradientStyle: gradientStyleSchema.optional(),
502
+ gradientAngle: z.number().min(0).max(360).optional(),
503
+ gradientSharpness: gradientSharpnessSchema.optional()
504
+ });
505
+ const buttonGlobalSettingsSchema = z.discriminatedUnion("hoverColor", [buttonGlobalSettingsBaseSchema.extend({
506
+ hoverColor: z.literal("none"),
507
+ hoverColorToken: z.never().optional()
508
+ }), buttonGlobalSettingsBaseSchema.extend({
509
+ hoverColor: z.literal("token"),
510
+ hoverColorToken: opaqueButtonColourTokenSchema
511
+ })]);
512
+ const gradientDirectionSchema$1 = z.enum([
513
+ "to-r",
514
+ "to-l",
515
+ "to-t",
516
+ "to-b",
517
+ "to-tr",
518
+ "to-tl",
519
+ "to-br",
520
+ "to-bl"
521
+ ]);
522
+ const buttonColourTreatmentSchema = z.discriminatedUnion("type", [
523
+ z.strictObject({
524
+ type: z.literal("solid"),
525
+ colorToken: opaqueButtonColourTokenSchema
526
+ }),
527
+ z.strictObject({
528
+ type: z.literal("gradient"),
529
+ stops: z.array(opaqueButtonColourTokenSchema).min(2).transform((stops) => {
530
+ const [first, second, ...rest] = stops;
531
+ if (first === void 0 || second === void 0) throw new Error("Invariant: gradient stops passed the minimum length schema");
532
+ return [
533
+ first,
534
+ second,
535
+ ...rest
536
+ ];
537
+ }),
538
+ direction: gradientDirectionSchema$1,
539
+ foregroundToken: opaqueButtonColourTokenSchema
540
+ }),
541
+ z.strictObject({
542
+ type: z.literal("surface"),
543
+ role: z.literal("link")
544
+ })
545
+ ]);
546
+ const buttonBackgroundSchema = buttonColourTreatmentSchema;
547
+ const buttonBorderSchema = z.strictObject({
548
+ widthClass: z.string(),
549
+ marksBoundary: z.literal(true).optional(),
550
+ ring: z.literal(true).optional(),
551
+ boundaryInk: opaqueButtonColourTokenSchema.optional()
552
+ });
553
+ const buttonVariantAffordanceSchema = z.strictObject({ iconId: z.string().min(1) });
554
+ const variantShadowSchema = z.strictObject({
555
+ elevation: z.enum([
556
+ "none",
557
+ "low",
558
+ "medium",
559
+ "high"
560
+ ]),
561
+ softness: z.enum([
562
+ "crisp",
563
+ "soft",
564
+ "hard"
565
+ ]).nullable(),
566
+ position: z.enum(["bottom", "bottom-right"]).default("bottom"),
567
+ colorToken: opaqueButtonColourTokenSchema.optional()
568
+ });
569
+ /** Recipe states own every visual property; treatment owns its readable label. */
570
+ const buttonVisualAppearanceSchema = z.strictObject({
571
+ background: buttonColourTreatmentSchema,
572
+ text: z.literal("treatment"),
573
+ border: z.union([z.literal("none"), buttonBorderSchema]),
574
+ borderRadius: z.string(),
575
+ shadow: z.union([z.literal("focus-indicator"), variantShadowSchema]),
576
+ sizes: buttonSizesSchema,
577
+ typography: z.strictObject({
578
+ fontWeight: fontWeightSchema,
579
+ typography: buttonTypographySchema,
580
+ fontSize: z.string().nullable(),
581
+ letterSpacing: z.union([letterSpacingSchema, z.literal("heading")]).nullable(),
582
+ italic: z.boolean(),
583
+ textTransform: textTransformSchema
584
+ }),
585
+ effects: z.array(buttonEffectApplicationSchema),
586
+ transform: z.literal("none").optional(),
587
+ contextualHover: contextualButtonHoverSchema.optional()
588
+ });
589
+ const buttonVisualStatesSchema = z.strictObject({
590
+ base: buttonVisualAppearanceSchema.extend({ shadow: variantShadowSchema }),
591
+ hover: buttonVisualAppearanceSchema.extend({ shadow: variantShadowSchema }),
592
+ focus: buttonVisualAppearanceSchema.extend({
593
+ shadow: z.literal("focus-indicator"),
594
+ indicator: z.strictObject({
595
+ kind: z.literal("surface-ink"),
596
+ width: z.union([z.literal(2), z.literal(3)]),
597
+ offset: z.union([z.literal(3), z.literal(4)])
598
+ }).optional()
599
+ }),
600
+ active: buttonVisualAppearanceSchema.extend({ shadow: variantShadowSchema }),
601
+ disabled: buttonVisualAppearanceSchema.extend({ shadow: variantShadowSchema })
602
+ });
603
+ const variantEffectsSchema = z.strictObject({
604
+ base: z.array(buttonEffectApplicationSchema).optional(),
605
+ hover: z.array(buttonEffectApplicationSchema).optional(),
606
+ active: z.array(buttonEffectApplicationSchema).optional(),
607
+ focus: z.array(buttonEffectApplicationSchema).optional()
608
+ });
609
+ /**
610
+ * Per-variant size overrides schema — every entry is optional.
611
+ *
612
+ * For each size key present, the values override the theme's `sizes` config
613
+ * for that size on this variant. Missing sizes fall through to theme.sizes,
614
+ * then system defaults.
615
+ */
616
+ const variantSizeOverridesSchema = z.object({
617
+ sm: buttonSizeConfigSchema.optional(),
618
+ md: buttonSizeConfigSchema.optional(),
619
+ lg: buttonSizeConfigSchema.optional(),
620
+ xl: buttonSizeConfigSchema.optional()
621
+ });
622
+ /**
623
+ * Unified variant schema. Every variant participates in the size system; the
624
+ * optional `sizes` field lets a variant scale differently than the theme
625
+ * default (e.g. link-style variants declaring zero horizontal padding at
626
+ * every size).
627
+ */
628
+ const buttonVariantSchema = z.strictObject({
629
+ id: buttonVariantIdSchema,
630
+ name: z.string().min(1).max(20),
631
+ enabled: z.boolean(),
632
+ priority: prioritySchema,
633
+ visualStates: buttonVisualStatesSchema.optional(),
634
+ background: buttonBackgroundSchema,
635
+ /** Tailwind radius token (e.g. `'rounded-md'`). Omit to inherit from `global.cornerStyle`. */
636
+ borderRadius: z.string().optional(),
637
+ shadow: variantShadowSchema.optional(),
638
+ border: buttonBorderSchema.optional(),
639
+ hoverBackgroundToken: opaqueButtonColourTokenSchema.optional(),
640
+ contextualHover: contextualButtonHoverSchema.optional(),
641
+ effects: variantEffectsSchema.optional(),
642
+ sizes: variantSizeOverridesSchema.optional(),
643
+ affordance: buttonVariantAffordanceSchema.optional()
644
+ });
645
+ const buttonSystemSchema = z.strictObject({
646
+ global: buttonGlobalSettingsSchema,
647
+ variants: z.array(buttonVariantSchema).min(1).max(6),
648
+ sizes: buttonSizesSchema.optional(),
649
+ surfacePolicy: buttonSurfacePolicySchema.optional(),
650
+ surfaceContexts: z.record(z.string(), z.strictObject({ primary: opaqueButtonColourTokenSchema })).optional()
651
+ }).superRefine((system, ctx) => {
652
+ const seen = /* @__PURE__ */ new Set();
653
+ system.variants.forEach((variant, index) => {
654
+ if (seen.has(variant.id)) ctx.addIssue({
655
+ code: "custom",
656
+ path: [
657
+ "variants",
658
+ index,
659
+ "id"
660
+ ],
661
+ message: `Duplicate button variant ID: ${variant.id}`
662
+ });
663
+ seen.add(variant.id);
664
+ });
665
+ });
666
+ //#endregion
667
+ //#region ../theme-core/src/site-styles/ownedThemeSnapshot.ts
668
+ /** Copy before freezing: the editor still owns its source data. */
669
+ function ownedThemeSnapshot(input) {
670
+ return freezeOwnedThemeValue(structuredClone(input));
671
+ }
672
+ /** Only freshly owned data belongs here; no caller-owned object is frozen. */
673
+ function freezeOwnedThemeValue(value) {
674
+ if (typeof value === "object" && value !== null) {
675
+ Object.values(value).forEach(freezeOwnedThemeValue);
676
+ Object.freeze(value);
677
+ }
678
+ return value;
679
+ }
680
+ //#endregion
681
+ //#region ../theme-core/src/palette/colors.ts
682
+ const HEX_COLOR_REGEX = /^#[0-9a-f]{6}$/;
683
+ const NORMALIZABLE_HEX_REGEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
684
+ const THEME_PALETTE_COLOR_ORDER = [
685
+ "primary",
686
+ "secondary",
687
+ "accent",
688
+ "success",
689
+ "warning",
690
+ "destructive",
691
+ "background",
692
+ "surface",
693
+ "surfaceAlt",
694
+ "muted",
695
+ "text",
696
+ "primaryForeground",
697
+ "border"
698
+ ];
699
+ const hexColorSchema = z.string().regex(HEX_COLOR_REGEX, "Hex must be #RRGGBB (lowercase)").transform((value) => value);
700
+ const paletteModeSchema = z.enum(["light", "dark"]);
701
+ const PALETTE_VALUE_KEY_PREFIX = "palette-value:v1|";
702
+ z.string().regex(/^[0-9a-f]{64}$/, "Palette hash must be a lowercase SHA-256 value").transform((value) => value);
703
+ const paletteColorsSchema = z.object({
704
+ primary: hexColorSchema,
705
+ primaryForeground: hexColorSchema,
706
+ secondary: hexColorSchema,
707
+ accent: hexColorSchema,
708
+ success: hexColorSchema,
709
+ warning: hexColorSchema,
710
+ destructive: hexColorSchema,
711
+ background: hexColorSchema,
712
+ surface: hexColorSchema,
713
+ surfaceAlt: hexColorSchema,
714
+ muted: hexColorSchema,
715
+ text: hexColorSchema,
716
+ border: hexColorSchema
717
+ }).strict().transform((value) => value);
718
+ function normalizePaletteHex(value) {
719
+ if (!NORMALIZABLE_HEX_REGEX.test(value)) return null;
720
+ const normalized = value.toLowerCase();
721
+ if (normalized.length === 7) return normalized;
722
+ const triplet = normalized.slice(1);
723
+ const red = triplet.charAt(0);
724
+ const green = triplet.charAt(1);
725
+ const blue = triplet.charAt(2);
726
+ return `#${red}${red}${green}${green}${blue}${blue}`;
727
+ }
728
+ function paletteColorsFromEntries(entries) {
729
+ const values = {};
730
+ for (const entry of entries) {
731
+ const parsedRole = paletteTokenNameSchema.safeParse(entry.name);
732
+ if (!parsedRole.success) return {
733
+ ok: false,
734
+ error: {
735
+ kind: "unknown-role",
736
+ role: entry.name
737
+ }
738
+ };
739
+ const role = parsedRole.data;
740
+ if (values[role] !== void 0) return {
741
+ ok: false,
742
+ error: {
743
+ kind: "duplicate-role",
744
+ role
745
+ }
746
+ };
747
+ const hex = normalizePaletteHex(entry.hex);
748
+ if (!hex) return {
749
+ ok: false,
750
+ error: {
751
+ kind: "invalid-color",
752
+ role,
753
+ value: entry.hex
754
+ }
755
+ };
756
+ values[role] = hex;
757
+ }
758
+ const missing = PALETTE_TOKEN_NAMES.filter((role) => values[role] === void 0);
759
+ if (missing.length > 0) return {
760
+ ok: false,
761
+ error: {
762
+ kind: "missing-roles",
763
+ roles: missing
764
+ }
765
+ };
766
+ return {
767
+ ok: true,
768
+ colors: paletteColorsSchema.parse(values)
769
+ };
770
+ }
771
+ function requirePaletteColorsFromEntries(entries) {
772
+ const result = paletteColorsFromEntries(entries);
773
+ if (result.ok) return result.colors;
774
+ throw new Error(`Invalid complete palette: ${result.error.kind}`);
775
+ }
776
+ function paletteColorEntries(colors) {
777
+ return THEME_PALETTE_COLOR_ORDER.map((name) => ({
778
+ name,
779
+ hex: colors[name]
780
+ }));
781
+ }
782
+ function paletteColorFingerprint(colors) {
783
+ return PALETTE_TOKEN_NAMES.map((name) => `${name}:${colors[name]}`).join("|");
784
+ }
785
+ function canonicalPaletteHashInput(colors, mode) {
786
+ return `${mode}|${paletteColorFingerprint(colors)}`;
787
+ }
788
+ /**
789
+ * Stable curated-catalogue identity. Do not reorder roles: the order comes
790
+ * from PALETTE_TOKEN_NAMES through canonicalPaletteHashInput.
791
+ */
792
+ function paletteValueKey(colors, mode) {
793
+ return `${PALETTE_VALUE_KEY_PREFIX}${canonicalPaletteHashInput(colors, mode)}`;
794
+ }
795
+ /** Parses only the exact v1 canonical form emitted by paletteValueKey. */
796
+ function parsePaletteValueKey(value) {
797
+ if (typeof value !== "string" || !value.startsWith(PALETTE_VALUE_KEY_PREFIX)) return null;
798
+ const [rawMode, ...rawRoles] = value.slice(17).split("|");
799
+ const mode = paletteModeSchema.safeParse(rawMode);
800
+ if (!mode.success || rawRoles.length !== PALETTE_TOKEN_NAMES.length) return null;
801
+ const colors = paletteColorsFromEntries(rawRoles.map((roleValue) => {
802
+ const separator = roleValue.indexOf(":");
803
+ return separator === -1 ? {
804
+ name: "",
805
+ hex: ""
806
+ } : {
807
+ name: roleValue.slice(0, separator),
808
+ hex: roleValue.slice(separator + 1)
809
+ };
810
+ }));
811
+ if (!colors.ok || paletteValueKey(colors.colors, mode.data) !== value) return null;
812
+ return value;
813
+ }
814
+ const paletteValueKeySchema = z.string().transform((value, ctx) => {
815
+ const parsed = parsePaletteValueKey(value);
816
+ if (parsed) return parsed;
817
+ ctx.addIssue({
818
+ code: "custom",
819
+ message: "Invalid canonical palette value key"
820
+ });
821
+ return z.NEVER;
822
+ });
823
+ //#endregion
824
+ //#region ../theme-core/src/palette/utils/colorConversion.ts
825
+ const clamp01 = (x) => Math.max(0, Math.min(1, x));
826
+ const mod = (a, n) => (a % n + n) % n;
827
+ const deg = (x) => mod(x, 360);
828
+ const mix$1 = (a, b, t) => a + (b - a) * clamp01(t);
829
+ function hexToRgb(hex) {
830
+ const h = hex.replace(/^#/, "");
831
+ const m = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
832
+ if (m.length !== 6) throw new Error("Bad hex");
833
+ const int = parseInt(m, 16);
834
+ return {
835
+ r: int >> 16 & 255,
836
+ g: int >> 8 & 255,
837
+ b: int & 255
838
+ };
839
+ }
840
+ function rgbToHex(r, g, b) {
841
+ const to = (n) => Math.round(n).toString(16).padStart(2, "0");
842
+ return `#${to(r)}${to(g)}${to(b)}`;
843
+ }
844
+ function srgbToLinear(u) {
845
+ const x = u / 255;
846
+ return x <= .04045 ? x / 12.92 : Math.pow((x + .055) / 1.055, 2.4);
847
+ }
848
+ function linearToSrgb(x) {
849
+ return clamp01(x <= .0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - .055) * 255;
850
+ }
851
+ function rgbToHsl(r, g, b) {
852
+ const R = r / 255, G = g / 255, B = b / 255;
853
+ const max = Math.max(R, G, B), min = Math.min(R, G, B);
854
+ const d = max - min;
855
+ let h = 0;
856
+ if (d !== 0) {
857
+ switch (max) {
858
+ case R:
859
+ h = (G - B) / d + (G < B ? 6 : 0);
860
+ break;
861
+ case G:
862
+ h = (B - R) / d + 2;
863
+ break;
864
+ case B:
865
+ h = (R - G) / d + 4;
866
+ break;
867
+ }
868
+ h *= 60;
869
+ }
870
+ const l = (max + min) / 2;
871
+ const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
872
+ return {
873
+ h,
874
+ s,
875
+ l
876
+ };
877
+ }
878
+ function srgbToOklab(r, g, b) {
879
+ const R = srgbToLinear(r), G = srgbToLinear(g), B = srgbToLinear(b);
880
+ const l = .4122214708 * R + .5363325363 * G + .0514459929 * B;
881
+ const m = .2119034982 * R + .6806995451 * G + .1073969566 * B;
882
+ const s = .0883024619 * R + .2817188376 * G + .6299787005 * B;
883
+ const l_ = Math.cbrt(l), m_ = Math.cbrt(m), s_ = Math.cbrt(s);
884
+ return {
885
+ L: .2104542553 * l_ + .793617785 * m_ - .0040720468 * s_,
886
+ a: 1.9779984951 * l_ - 2.428592205 * m_ + .4505937099 * s_,
887
+ b: .0259040371 * l_ + .7827717662 * m_ - .808675766 * s_
888
+ };
889
+ }
890
+ function oklabToSrgb(L, a, b) {
891
+ const l_ = Math.pow(L + .3963377774 * a + .2158037573 * b, 3);
892
+ const m_ = Math.pow(L - .1055613458 * a - .0638541728 * b, 3);
893
+ const s_ = Math.pow(L - .0894841775 * a - 1.291485548 * b, 3);
894
+ const R = 4.0767416621 * l_ - 3.3077115913 * m_ + .2309699292 * s_;
895
+ const G = -1.2684380046 * l_ + 2.6097574011 * m_ - .3413193965 * s_;
896
+ const B = -.0041960863 * l_ - .7034186147 * m_ + 1.707614701 * s_;
897
+ return {
898
+ r: linearToSrgb(R),
899
+ g: linearToSrgb(G),
900
+ b: linearToSrgb(B)
901
+ };
902
+ }
903
+ function oklabToOklch(L, a, b) {
904
+ const C = Math.sqrt(a * a + b * b);
905
+ return {
906
+ L,
907
+ C,
908
+ h: C < 1e-7 ? 0 : deg(Math.atan2(b, a) * 180 / Math.PI)
909
+ };
910
+ }
911
+ function oklchToOklab(L, C, h) {
912
+ const hr = h * Math.PI / 180;
913
+ return {
914
+ L,
915
+ a: C * Math.cos(hr),
916
+ b: C * Math.sin(hr)
917
+ };
918
+ }
919
+ function inSRGB(r, g, b) {
920
+ return r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255;
921
+ }
922
+ function oklchToHexGamut(L, C, h) {
923
+ let lo = 0, hi = C, best = 0;
924
+ for (let i = 0; i < 18; i++) {
925
+ const mid = (lo + hi) / 2;
926
+ const { a, b } = oklchToOklab(L, mid, h);
927
+ const { r, g, b: bb } = oklabToSrgb(L, a, b);
928
+ if (inSRGB(r, g, bb)) {
929
+ best = mid;
930
+ lo = mid;
931
+ } else hi = mid;
932
+ }
933
+ const { a, b } = oklchToOklab(L, best, h);
934
+ const { r, g, b: bb } = oklabToSrgb(L, a, b);
935
+ return rgbToHex(r, g, bb);
936
+ }
937
+ function featuresFromHex(hex) {
938
+ const { r, g, b } = hexToRgb(hex);
939
+ const { h, s, l } = rgbToHsl(r, g, b);
940
+ const { L, a, b: b2 } = srgbToOklab(r, g, b);
941
+ const { L: okL, C: okC, h: okH } = oklabToOklch(L, a, b2);
942
+ return {
943
+ r,
944
+ g,
945
+ b,
946
+ h,
947
+ s,
948
+ l,
949
+ v: Math.max(r, g, b) / 255,
950
+ Y: .2126 * srgbToLinear(r) + .7152 * srgbToLinear(g) + .0722 * srgbToLinear(b),
951
+ chroma: s,
952
+ okL,
953
+ okC,
954
+ okH,
955
+ hex
956
+ };
957
+ }
958
+ //#endregion
959
+ //#region ../theme-core/src/palette/utils/opaqueSurfaceColor.ts
960
+ /** Resolve an opaque colour, compositing alpha against an explicit underlay. */
961
+ function resolveOpaqueSurfaceHex(reference, palette, underlayReference) {
962
+ const opaque = resolveConcreteColorHex(reference, palette);
963
+ if (opaque) return opaque;
964
+ if (!underlayReference) return null;
965
+ const underlayHex = resolveConcreteColorHex(underlayReference, palette);
966
+ if (!underlayHex) return null;
967
+ const parts = parseColorTokenParts(reference);
968
+ if (parts.kind === "token" && parts.opacityPercent !== null) {
969
+ const foregroundHex = normalizePaletteHex(palette[parts.token] ?? "");
970
+ return foregroundHex ? compositeHex$1(foregroundHex, underlayHex, parts.opacityPercent / 100) : null;
971
+ }
972
+ const rgba = parseRgba(parts.kind === "raw" ? parts.value : reference);
973
+ return rgba ? compositeHex$1(rgbToHex(rgba.r, rgba.g, rgba.b), underlayHex, rgba.alpha) : null;
974
+ }
975
+ /** Resolve a colour reference only when it is already fully opaque. */
976
+ function resolveConcreteColorHex(reference, palette) {
977
+ const literalHex = normalizePaletteHex(reference);
978
+ if (literalHex) return literalHex;
979
+ const parts = parseColorTokenParts(reference);
980
+ if (parts.kind === "token") {
981
+ if (parts.opacityPercent !== null) return null;
982
+ return normalizePaletteHex(palette[parts.token] ?? "");
983
+ }
984
+ const literal = parts.kind === "raw" ? parts.value : reference;
985
+ if (literal.toLowerCase() === "black") return "#000000";
986
+ if (literal.toLowerCase() === "white") return "#ffffff";
987
+ return normalizePaletteHex(literal);
988
+ }
989
+ function compositeHex$1(foregroundHex, underlayHex, alpha) {
990
+ const foreground = hexToRgb(foregroundHex);
991
+ const underlay = hexToRgb(underlayHex);
992
+ const channel = (foregroundValue, underlayValue) => Math.round(foregroundValue * alpha + underlayValue * (1 - alpha));
993
+ return rgbToHex(channel(foreground.r, underlay.r), channel(foreground.g, underlay.g), channel(foreground.b, underlay.b));
994
+ }
995
+ function parseRgba(value) {
996
+ const match = value.trim().match(/^rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*(?:,|\/)\s*([\d.]+%?))?\s*\)$/i);
997
+ if (!match) return null;
998
+ const [, rSource, gSource, bSource] = match;
999
+ if (!rSource || !gSource || !bSource) return null;
1000
+ const r = Number(rSource);
1001
+ const g = Number(gSource);
1002
+ const b = Number(bSource);
1003
+ const alpha = parseAlpha(match[4]);
1004
+ if (alpha === null || !isRgbChannel(r) || !isRgbChannel(g) || !isRgbChannel(b)) return null;
1005
+ return {
1006
+ r,
1007
+ g,
1008
+ b,
1009
+ alpha
1010
+ };
1011
+ }
1012
+ function parseAlpha(source) {
1013
+ if (!source) return 1;
1014
+ const value = source.endsWith("%") ? Number(source.slice(0, -1)) / 100 : Number(source);
1015
+ return Number.isFinite(value) && value >= 0 && value <= 1 ? value : null;
1016
+ }
1017
+ function isRgbChannel(value) {
1018
+ return Number.isFinite(value) && value >= 0 && value <= 255;
1019
+ }
1020
+ function relativeLuminance(r, g, b) {
1021
+ const R = srgbToLinear(r), G = srgbToLinear(g), B = srgbToLinear(b);
1022
+ return .2126 * R + .7152 * G + .0722 * B;
1023
+ }
1024
+ function preparePaletteColourIndex(palette) {
1025
+ const colours = [.../* @__PURE__ */ new Set([
1026
+ ...Object.values(palette),
1027
+ "#000000",
1028
+ "#ffffff",
1029
+ "#FFFFFF"
1030
+ ])];
1031
+ return Object.freeze(Object.fromEntries(colours.flatMap(colourIndexEntry)));
1032
+ }
1033
+ /** An unused unsupported colour must not turn preparation into an eager validation failure. */
1034
+ function colourIndexEntry(hex) {
1035
+ try {
1036
+ return [[hex, colourLuminance(hex)]];
1037
+ } catch {
1038
+ return [];
1039
+ }
1040
+ }
1041
+ function colourLuminance(hex) {
1042
+ const { r, g, b } = hexToRgb(hex);
1043
+ return relativeLuminance(r, g, b);
1044
+ }
1045
+ function indexedLuminance(hex, index) {
1046
+ return (index && Object.prototype.hasOwnProperty.call(index, hex) ? index[hex] : void 0) ?? colourLuminance(hex);
1047
+ }
1048
+ function contrastRatio(hex1, hex2, index) {
1049
+ const L1 = indexedLuminance(hex1, index);
1050
+ const L2 = indexedLuminance(hex2, index);
1051
+ const [hi, lo] = L1 >= L2 ? [L1, L2] : [L2, L1];
1052
+ return (hi + .05) / (lo + .05);
1053
+ }
1054
+ //#endregion
1055
+ //#region ../theme-core/src/palette/utils/scrimContrast.ts
1056
+ const WHITE = "#ffffff";
1057
+ const BLACK = "#000000";
1058
+ /** `top` at `alpha` over opaque `bottom`, blended as CSS paints an overlay. */
1059
+ function compositeHex(topHex, alpha, bottomHex) {
1060
+ const top = hexToRgb(topHex);
1061
+ const bottom = hexToRgb(bottomHex);
1062
+ const mix = (a, b) => Math.round(alpha * a + (1 - alpha) * b);
1063
+ return rgbToHex(mix(top.r, bottom.r), mix(top.g, bottom.g), mix(top.b, bottom.b));
1064
+ }
1065
+ /**
1066
+ * The lowest contrast `foreground` can reach over `scrim` at `alpha` laid on
1067
+ * any pixel. A foreground whose luminance falls inside the range the
1068
+ * composites can take has a worst case of 1:1.
1069
+ */
1070
+ function worstCaseScrimContrast(input) {
1071
+ const overWhite = compositeHex(input.scrimHex, input.alpha, WHITE);
1072
+ const overBlack = compositeHex(input.scrimHex, input.alpha, BLACK);
1073
+ const luminance = (hex) => {
1074
+ const { r, g, b } = hexToRgb(hex);
1075
+ return relativeLuminance(r, g, b);
1076
+ };
1077
+ const foreground = luminance(input.foregroundHex);
1078
+ const low = luminance(overBlack);
1079
+ const high = luminance(overWhite);
1080
+ if (foreground >= low && foreground <= high) return 1;
1081
+ return Math.min(contrastRatio(input.foregroundHex, overWhite), contrastRatio(input.foregroundHex, overBlack));
1082
+ }
1083
+ /** Shared samples for literal RGB washes and palette-token gradient veils. */
1084
+ function gradientScrimSamples(gradient, alpha, palette) {
1085
+ const literal = [...gradient.matchAll(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/g)].map((stop) => ({
1086
+ hex: rgbToHex(Number(stop[1]), Number(stop[2]), Number(stop[3])),
1087
+ alpha: alpha * (stop[4] === void 0 ? 1 : Number(stop[4]))
1088
+ }));
1089
+ const tokens = [...gradient.matchAll(/var\(--tb-([\w-]+)\)/g)].flatMap((stop) => {
1090
+ const hex = stop[1] ? resolveConcreteColorHex(stop[1], palette) : null;
1091
+ return hex ? [{
1092
+ hex,
1093
+ alpha
1094
+ }] : [];
1095
+ });
1096
+ return [...literal, ...tokens];
1097
+ }
1098
+ /** The ink with the stronger worst-pixel guarantee identifies the veil tone.
1099
+ * No readable samples (or a tie) leaves classification to the foreground owner.
1100
+ */
1101
+ function scrimTone(samples) {
1102
+ if (samples.length === 0) return null;
1103
+ const worst = (foregroundHex) => Math.min(...samples.map((sample) => worstCaseScrimContrast({
1104
+ foregroundHex,
1105
+ scrimHex: sample.hex,
1106
+ alpha: sample.alpha
1107
+ })));
1108
+ const white = worst(WHITE);
1109
+ const black = worst(BLACK);
1110
+ return white === black ? null : white > black ? "dark" : "light";
1111
+ }
1112
+ //#endregion
1113
+ //#region ../theme-core/src/palette/generateShades.ts
1114
+ function generateShades(hexColor, name) {
1115
+ const shadeSteps = [
1116
+ 50,
1117
+ 100,
1118
+ 200,
1119
+ 300,
1120
+ 400,
1121
+ 500,
1122
+ 600,
1123
+ 700,
1124
+ 800,
1125
+ 900,
1126
+ 950
1127
+ ];
1128
+ const base = featuresFromHex(hexColor);
1129
+ const hue = base.okH;
1130
+ const baseChroma = base.okC;
1131
+ const toneMap = {
1132
+ 50: .975,
1133
+ 100: .945,
1134
+ 200: .89,
1135
+ 300: .82,
1136
+ 400: .74,
1137
+ 500: .66,
1138
+ 600: .58,
1139
+ 700: .49,
1140
+ 800: .4,
1141
+ 900: .28,
1142
+ 950: .16
1143
+ };
1144
+ const shadeDefs = shadeSteps.map((step, idx) => {
1145
+ const t = idx / (shadeSteps.length - 1);
1146
+ const L = toneMap[step];
1147
+ const C = baseChroma * (.06 + .94 * Math.sin(Math.PI * t));
1148
+ return {
1149
+ name: `${name}-${step}`,
1150
+ hex: oklchToHexGamut(L, C, hue)
1151
+ };
1152
+ });
1153
+ shadeDefs.push({
1154
+ name,
1155
+ hex: hexColor
1156
+ });
1157
+ return shadeDefs;
1158
+ }
1159
+ //#endregion
1160
+ //#region ../theme-core/src/palette/neutralScale.ts
1161
+ function generateNeutralScale({ background, steps = 11, warm = false }) {
1162
+ const isDark = background === "#000000" || background.startsWith("#0") || background.startsWith("#1");
1163
+ const shadeNames = [
1164
+ 50,
1165
+ 100,
1166
+ 200,
1167
+ 300,
1168
+ 400,
1169
+ 500,
1170
+ 600,
1171
+ 700,
1172
+ 800,
1173
+ 900,
1174
+ 950
1175
+ ];
1176
+ const count = Math.min(steps, shadeNames.length);
1177
+ const scale = [];
1178
+ for (let i = 0; i < count; i++) {
1179
+ const shadeName = shadeNames[i] ?? shadeNames[shadeNames.length - 1] ?? 950;
1180
+ const t = i / (count - 1);
1181
+ const hex = oklchToHexGamut(isDark ? mix(.06, .92, t) : mix(.98, .1, t), .02, warm ? 85 : 250);
1182
+ const name = `neutral-${shadeName}`;
1183
+ scale.push({
1184
+ name,
1185
+ hex
1186
+ });
1187
+ }
1188
+ return scale;
1189
+ }
1190
+ function mix(a, b, t) {
1191
+ return a + (b - a) * Math.max(0, Math.min(1, t));
1192
+ }
1193
+ //#endregion
1194
+ //#region ../theme-core/src/palette/utils/textColor.ts
1195
+ /**
1196
+ * Pick the better of black/white text for a given background using actual
1197
+ * contrast ratios, not a simple luminance cutoff.
1198
+ *
1199
+ * @param background - Background color in hex or rgb/rgba format (e.g., '#FFFFFF' or 'rgb(255, 255, 255)')
1200
+ * @param minContrast - Preferred minimum contrast ratio for body-sized text
1201
+ * @returns '#000000' for light backgrounds, '#FFFFFF' for dark backgrounds
1202
+ */
1203
+ function pickBlackOrWhiteTextColor(background, minContrast = 4.5) {
1204
+ const { r, g, b } = parseColorToRgb(background);
1205
+ const luminance = relativeLuminance(r, g, b);
1206
+ const blackContrast = (luminance + .05) / .05;
1207
+ const whiteContrast = 1.05 / (luminance + .05);
1208
+ if (blackContrast >= minContrast && whiteContrast < minContrast) return "#000000";
1209
+ if (whiteContrast >= minContrast && blackContrast < minContrast) return "#FFFFFF";
1210
+ return blackContrast >= whiteContrast ? "#000000" : "#FFFFFF";
1211
+ }
1212
+ /**
1213
+ * Backwards-compatible alias for callers that want the best black/white text
1214
+ * color for a background.
1215
+ */
1216
+ function getTextColorForBackground(background) {
1217
+ return pickBlackOrWhiteTextColor(background);
1218
+ }
1219
+ function parseColorToRgb(input) {
1220
+ const trimmed = input.trim();
1221
+ if (trimmed.startsWith("#")) return hexToRgb(trimmed);
1222
+ const rgbMatch = trimmed.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(?:0|1|0?\.\d+))?\s*\)$/i);
1223
+ if (rgbMatch?.[1] && rgbMatch[2] && rgbMatch[3]) return {
1224
+ r: clamp255(Number(rgbMatch[1])),
1225
+ g: clamp255(Number(rgbMatch[2])),
1226
+ b: clamp255(Number(rgbMatch[3]))
1227
+ };
1228
+ throw new Error("Unsupported color format");
1229
+ }
1230
+ function clamp255(value) {
1231
+ if (Number.isNaN(value)) return 0;
1232
+ return Math.max(0, Math.min(255, value));
1233
+ }
1234
+ //#endregion
1235
+ //#region ../theme-core/src/palette/utils/onColor.ts
1236
+ const BACKGROUND_ROLE_NAMES = /* @__PURE__ */ new Set([
1237
+ "primary",
1238
+ "secondary",
1239
+ "accent",
1240
+ "success",
1241
+ "warning",
1242
+ "destructive",
1243
+ "info",
1244
+ "background",
1245
+ "surface",
1246
+ "surfaceAlt",
1247
+ "muted",
1248
+ "neutral"
1249
+ ]);
1250
+ function onColorTokenName(backgroundToken) {
1251
+ return `on${backgroundToken.split("-").filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("")}`;
1252
+ }
1253
+ function isOnColorBackgroundCandidateToken(token) {
1254
+ const role = token.match(/^(.*?)(?:-\d{2,3})?$/)?.[1] ?? token;
1255
+ return BACKGROUND_ROLE_NAMES.has(role);
1256
+ }
1257
+ //#endregion
1258
+ //#region ../theme-core/src/palette/expandPalette.ts
1259
+ function colorsToMap(palette) {
1260
+ const map = {};
1261
+ for (const c of palette.colors) map[c.name] = c.hex;
1262
+ return map;
1263
+ }
1264
+ function isBackgroundDark(hex) {
1265
+ try {
1266
+ return featuresFromHex(hex).Y < .5;
1267
+ } catch {
1268
+ return false;
1269
+ }
1270
+ }
1271
+ const nonShadeablePaletteRoleNames = /* @__PURE__ */ new Set([
1272
+ "success",
1273
+ "warning",
1274
+ "destructive"
1275
+ ]);
1276
+ /**
1277
+ * Status role aliases the persisted palette does not carry itself.
1278
+ *
1279
+ * Generators reference `--tb-error` (the site-style-owned input error border)
1280
+ * and `--tb-info` (`.alert-info`, `.status-info`, the field-note rule), but the
1281
+ * palette schema only defines `destructive` and has no `info` role at all.
1282
+ * Without these aliases those declarations name variables that are never
1283
+ * defined and browsers drop them. The SDK bridge resolves the same pair via
1284
+ * TOKEN_ALIASES, so both runtimes agree on what a status token means.
1285
+ *
1286
+ * Runs after the danger → destructive promotion above, so `destructive` is
1287
+ * already the single source of truth for the error colour.
1288
+ */
1289
+ function statusAliasTokens(expanded) {
1290
+ const aliases = {};
703
1291
  if (expanded.destructive) aliases.error = expanded.destructive;
704
1292
  if (expanded.accent) aliases.info = expanded.accent;
705
1293
  return aliases;
@@ -743,8 +1331,8 @@ function expandBasePalette(palette) {
743
1331
  function deriveSurfaceDecorationColors(ground, text, accent) {
744
1332
  const ink = getTextColorForBackground(ground);
745
1333
  return {
746
- line: firstContrastBlend(ground, text, ground, 1.5),
747
- mark: firstContrastBlend(accent, ink, ground, 3)
1334
+ line: firstContrastBlend$1(ground, text, ground, 1.5),
1335
+ mark: firstContrastBlend$1(accent, ink, ground, 3)
748
1336
  };
749
1337
  }
750
1338
  /** Secondary ink is blended toward its ground, with an ordinary-text contrast floor. */
@@ -760,7 +1348,7 @@ function firstSafeMutedSample(sample, ground, low, high) {
760
1348
  const middle = Math.floor((low + high) / 2);
761
1349
  return contrastRatio(sample(middle), ground) >= 4.5 ? firstSafeMutedSample(sample, ground, low, middle) : firstSafeMutedSample(sample, ground, middle + 1, high);
762
1350
  }
763
- function firstContrastBlend(from, to, ground, threshold) {
1351
+ function firstContrastBlend$1(from, to, ground, threshold) {
764
1352
  const start = hexToRgb(from);
765
1353
  const end = hexToRgb(to);
766
1354
  return Array.from({ length: 101 }, (_, index) => {
@@ -834,671 +1422,196 @@ function surfaceForegroundStyle(input) {
834
1422
  [SURFACE_FOREGROUND_CSS_VARS.text]: foregrounds.text,
835
1423
  [SURFACE_FOREGROUND_CSS_VARS.heading]: foregrounds.heading,
836
1424
  [SURFACE_FOREGROUND_CSS_VARS.link]: foregrounds.link,
837
- [SURFACE_FOREGROUND_CSS_VARS.linkHover]: foregrounds.linkHover,
838
- [SURFACE_FOREGROUND_CSS_VARS.supporting]: foregrounds.supporting,
839
- ...input.muted === void 0 ? {} : { [SURFACE_FOREGROUND_CSS_VARS.muted]: foregrounds.muted },
840
- "--rb-surface-link-hover-decoration": hoverDecoration(input)
841
- };
842
- }
843
- function surfaceForegroundDeclarations(input) {
844
- return Object.entries(surfaceForegroundStyle(input)).map(([property, value]) => `${property}: ${value};`);
845
- }
846
- function surfaceForegroundInputFromResolved(foreground, color) {
847
- const { roles } = foreground;
848
- return {
849
- text: color(roles.text),
850
- heading: color(roles.heading),
851
- link: color(roles.link),
852
- linkHover: color(roles.linkHover),
853
- supporting: color(roles.supporting),
854
- hoverDecoration: foreground.hoverDecoration
855
- };
856
- }
857
- function hoverDecoration(input) {
858
- return input.hoverDecoration ?? "underline";
859
- }
860
- //#endregion
861
- //#region ../theme-core/src/tokens/tokens.ts
862
- const defaultThemeTokens = {
863
- color: {
864
- "background/base": "#ffffff",
865
- "background/elevated": "#f5f5f5",
866
- "surface/base": "#ffffff",
867
- "surface/subtle": "#f9f9fb",
868
- "surface/inverted": "#111111",
869
- "content/primary": "#111111",
870
- "content/secondary": "#3f3f46",
871
- "accent/primary": "#2563eb",
872
- "accent/secondary": "#1d4ed8",
873
- "border/base": "#e5e7eb"
874
- },
875
- typography: {
876
- "display/hero": {
877
- fontSize: "clamp(48px, 8vw, 96px)",
878
- lineHeight: "1.05",
879
- fontWeight: "700"
880
- },
881
- "display/section": {
882
- fontSize: "clamp(40px, 6vw, 72px)",
883
- lineHeight: "1.1",
884
- fontWeight: "700"
885
- },
886
- "heading/large": {
887
- fontSize: "clamp(32px, 4vw, 48px)",
888
- lineHeight: "1.2",
889
- fontWeight: "600"
890
- },
891
- "heading/medium": {
892
- fontSize: "clamp(24px, 3vw, 32px)",
893
- lineHeight: "1.25",
894
- fontWeight: "600"
895
- },
896
- "heading/small": {
897
- fontSize: "20px",
898
- lineHeight: "1.3",
899
- fontWeight: "600"
900
- },
901
- "body/normal": {
902
- fontSize: "16px",
903
- lineHeight: "1.6",
904
- fontWeight: "400"
905
- },
906
- "body/small": {
907
- fontSize: "14px",
908
- lineHeight: "1.5",
909
- fontWeight: "400"
910
- },
911
- caption: {
912
- fontSize: "12px",
913
- lineHeight: "1.4",
914
- fontWeight: "500"
915
- }
916
- },
917
- spacing: {
918
- none: "0px",
919
- "3xs": "4px",
920
- "2xs": "8px",
921
- xs: "12px",
922
- sm: "16px",
923
- md: "24px",
924
- lg: "32px",
925
- xl: "40px",
926
- "2xl": "56px",
927
- "3xl": "72px"
928
- },
929
- radius: {
930
- none: "0px",
931
- xs: "2px",
932
- sm: "4px",
933
- md: "8px",
934
- lg: "12px",
935
- pill: "999px",
936
- full: "9999px"
937
- },
938
- shadow: {
939
- none: "none",
940
- soft: "0px 2px 8px rgba(15, 23, 42, 0.08)",
941
- medium: "0px 6px 18px rgba(15, 23, 42, 0.12)",
942
- strong: "0px 12px 36px rgba(15, 23, 42, 0.16)"
943
- },
944
- palette: {
945
- surface: "#ffffff",
946
- "neutral-50": "#f9fafb",
947
- "neutral-900": "#111827",
948
- primary: "#2563eb",
949
- "primary-50": "#eff6ff",
950
- "primary-500": "#2563eb",
951
- "primary-900": "#1d4ed8",
952
- secondary: "#9333ea",
953
- "secondary-50": "#f3e8ff",
954
- "secondary-500": "#9333ea",
955
- "secondary-900": "#4c1d95",
956
- accent: "#f97316",
957
- "accent-50": "#fff7ed",
958
- "accent-500": "#f97316",
959
- "accent-900": "#7c2d12"
960
- }
961
- };
962
- /**
963
- * Project the expanded semantic palette into the token buckets consumed by
964
- * runtime transforms. Keep this mapping shared by full themes and the
965
- * tokens-only hosted-booking runtime so the two paths cannot drift.
966
- */
967
- function buildThemeTokens(palette) {
968
- const tokens = cloneThemeTokens(defaultThemeTokens);
969
- const paletteStrings = {};
970
- for (const [key, value] of Object.entries(palette)) if (typeof value === "string" && value.trim().length > 0) paletteStrings[key] = value;
971
- tokens.palette = paletteStrings;
972
- const resolveColor = (...keys) => {
973
- for (const key of keys) {
974
- const value = paletteStrings[key];
975
- if (value) return value;
976
- }
977
- };
978
- const assignColor = (token, ...keys) => {
979
- const value = resolveColor(...keys);
980
- if (value) tokens.color[token] = value;
981
- };
982
- assignColor("background/base", "background", "surface", "primary-50");
983
- assignColor("background/elevated", "surface", "background");
984
- assignColor("surface/base", "surface", "background");
985
- assignColor("surface/subtle", "neutral-100", "surface", "background");
986
- assignColor("surface/inverted", "neutral-900", "text", "primary-900");
987
- assignColor("content/primary", "text", "body", "neutral-900");
988
- assignColor("content/secondary", "mutedText", "secondary", "neutral-600");
989
- assignColor("accent/primary", "primary", "accent");
990
- assignColor("accent/secondary", "accent", "secondary", "primary-400");
991
- assignColor("border/base", "border", "neutral-300");
992
- return tokens;
993
- }
994
- function cloneThemeTokens(source) {
995
- return JSON.parse(JSON.stringify(source));
996
- }
997
- //#endregion
998
- //#region ../theme-core/src/surfaces/logoVariant.ts
999
- /** Concrete hex behind a plain, opaque palette token, or null otherwise. */
1000
- function opaquePaletteHexForToken(expandedPalette, token) {
1001
- if (!token) return null;
1002
- const parts = parseColorTokenParts(token);
1003
- if (parts.kind !== "token" || parts.opacityPercent !== null) return null;
1004
- return expandedPalette[parts.token] ?? null;
1005
- }
1006
- /**
1007
- * Tone of the surface a foreground token was resolved for.
1008
- *
1009
- * A token with opacity has no known underlay to composite against, and a raw
1010
- * or unrecognised token has no palette hex, so both are `unknown` rather than
1011
- * a guess.
1012
- */
1013
- function surfaceToneFromForegroundToken(expandedPalette, foregroundToken) {
1014
- const hex = opaquePaletteHexForToken(expandedPalette, foregroundToken);
1015
- if (!hex) return "unknown";
1016
- return featuresFromHex(hex).Y >= .5 ? "dark" : "light";
1017
- }
1018
- /**
1019
- * The logo to draw on a surface of the given tone. A missing variant falls
1020
- * back to the other one, and an unknown tone uses the light-backgrounds logo,
1021
- * which is what every site rendered before variants existed.
1022
- */
1023
- function selectLogoVariant(tone, variants) {
1024
- const { forLightBackgrounds, forDarkBackgrounds } = variants;
1025
- return tone === "dark" ? forDarkBackgrounds ?? forLightBackgrounds : forLightBackgrounds ?? forDarkBackgrounds;
1026
- }
1027
- //#endregion
1028
- //#region ../theme-core/src/buttons/typography.ts
1029
- const textTransformSchema = z.enum([
1030
- "none",
1031
- "uppercase",
1032
- "lowercase",
1033
- "capitalize"
1034
- ]);
1035
- const fontWeightSchema = z.union([
1036
- z.literal(400),
1037
- z.literal(500),
1038
- z.literal(600),
1039
- z.literal(700),
1040
- z.literal(800)
1041
- ]);
1042
- const buttonTypographySchema = z.enum(["body", "heading"]);
1043
- const letterSpacingSchema = z.enum([
1044
- "tight",
1045
- "normal",
1046
- "slight",
1047
- "loose",
1048
- "wide"
1049
- ]);
1050
- //#endregion
1051
- //#region ../theme-core/src/buttons/types.ts
1052
- /**
1053
- * Standard semantic variant roles a theme exposes.
1054
- *
1055
- * Block content references variants by role; the active theme determines
1056
- * what each role looks like.
1057
- */
1058
- const VARIANT_ROLES = [
1059
- "primary",
1060
- "secondary",
1061
- "outline",
1062
- "ghost",
1063
- "accent"
1064
- ];
1065
- function isVariantRole(value) {
1066
- return VARIANT_ROLES.includes(value);
1067
- }
1068
- /**
1069
- * Canonical persisted/CSS-safe button variant identifier.
1070
- *
1071
- * IDs become class selectors, so keep the contract deliberately narrower than
1072
- * an arbitrary string and shared with every authoring/runtime boundary.
1073
- */
1074
- const buttonVariantIdSchema = z.string().min(1).max(50).regex(/^[a-z0-9-]+$/, "Button variant IDs may contain lowercase letters, numbers, and hyphens only").refine((value) => value !== "link" && value !== "tertiary", { message: "Retired button role IDs are not valid variant IDs" });
1075
- function asSpecialVariantId(value) {
1076
- const parsed = buttonVariantIdSchema.safeParse(value);
1077
- if (!parsed.success) throw new Error("SpecialVariantId must be a CSS-safe button variant ID");
1078
- return parsed.data;
1425
+ [SURFACE_FOREGROUND_CSS_VARS.linkHover]: foregrounds.linkHover,
1426
+ [SURFACE_FOREGROUND_CSS_VARS.supporting]: foregrounds.supporting,
1427
+ ...input.muted === void 0 ? {} : { [SURFACE_FOREGROUND_CSS_VARS.muted]: foregrounds.muted },
1428
+ "--rb-surface-link-hover-decoration": hoverDecoration(input)
1429
+ };
1079
1430
  }
1080
- /**
1081
- * Magic alias the CSS generator emits for the highest-priority variant.
1082
- *
1083
- * Shared between generator and renderer so neither side hard-codes the string.
1084
- */
1085
- const DEFAULT_VARIANT_ALIAS_ID = "default";
1086
- function parseOpaqueButtonColourToken(value) {
1087
- const token = parseThemeColorToken(value);
1088
- if (token === null) return null;
1089
- const parts = parseColorTokenParts(token);
1090
- return parts.kind === "token" && parts.opacityPercent === null ? token : null;
1431
+ function surfaceForegroundDeclarations(input) {
1432
+ return Object.entries(surfaceForegroundStyle(input)).map(([property, value]) => `${property}: ${value};`);
1091
1433
  }
1092
- function unsafeAsOpaqueButtonColourToken(value) {
1093
- return value;
1434
+ function surfaceForegroundInputFromResolved(foreground, color) {
1435
+ const { roles } = foreground;
1436
+ return {
1437
+ text: color(roles.text),
1438
+ heading: color(roles.heading),
1439
+ link: color(roles.link),
1440
+ linkHover: color(roles.linkHover),
1441
+ supporting: color(roles.supporting),
1442
+ hoverDecoration: foreground.hoverDecoration
1443
+ };
1094
1444
  }
1095
- const opaqueButtonColourTokenSchema = themeColorTokenSchema.refine((value) => parseOpaqueButtonColourToken(value) !== null, "Button colour tokens must be opaque").transform((value) => {
1096
- const token = parseOpaqueButtonColourToken(value);
1097
- if (token === null) throw new Error("Invariant: opaque button token passed its schema");
1098
- return token;
1099
- });
1100
- const contextualButtonHoverSchema = z.strictObject({
1101
- kind: z.literal("shade-shift"),
1102
- seedToken: opaqueButtonColourTokenSchema,
1103
- fallbackDirection: z.enum(["lighter", "darker"]),
1104
- preferredToken: opaqueButtonColourTokenSchema.optional()
1105
- });
1106
- const buttonShadeAmountSchema = z.number().finite().min(0).max(900).multipleOf(100);
1107
- const buttonShadowIntensitySchema = z.enum([
1108
- "subtle",
1109
- "medium",
1110
- "strong"
1111
- ]);
1112
- /**
1113
- * The complete persisted button-effect contract.
1114
- *
1115
- * Navigation has its own generic interactive-effect model. Button variants use
1116
- * this closed union so unsupported effect IDs, unknown option keys, and unsafe
1117
- * CSS values cannot become representable after the schema boundary.
1118
- */
1119
- const buttonPressOffsetSchema = z.strictObject({
1120
- x: z.number().int().min(0).max(12),
1121
- y: z.number().int().min(0).max(12)
1122
- });
1123
- const buttonEffectApplicationSchema = z.discriminatedUnion("effectId", [
1124
- z.strictObject({
1125
- effectId: z.literal("darken-background"),
1126
- options: z.strictObject({ amount: buttonShadeAmountSchema.optional() }).optional()
1127
- }),
1128
- z.strictObject({
1129
- effectId: z.literal("lighten-background"),
1130
- options: z.strictObject({ amount: buttonShadeAmountSchema.optional() }).optional()
1131
- }),
1132
- z.strictObject({
1133
- effectId: z.literal("background-on-hover"),
1134
- options: z.strictObject({ colorToken: opaqueButtonColourTokenSchema.optional() }).optional()
1135
- }),
1136
- z.strictObject({
1137
- effectId: z.literal("animated-gradient"),
1138
- options: z.strictObject({ direction: z.enum(["horizontal", "vertical"]).optional() }).optional()
1139
- }),
1140
- z.strictObject({
1141
- effectId: z.literal("drop-shadow"),
1142
- options: z.strictObject({ intensity: buttonShadowIntensitySchema.optional() }).optional()
1143
- }),
1144
- z.strictObject({
1145
- effectId: z.literal("inner-shadow"),
1146
- options: z.strictObject({}).optional()
1147
- }),
1148
- z.strictObject({
1149
- effectId: z.literal("neumorphic-shadow"),
1150
- options: z.strictObject({
1151
- mode: z.enum(["raised", "pressed"]).optional(),
1152
- intensity: buttonShadowIntensitySchema.optional()
1153
- }).optional()
1154
- }),
1155
- z.strictObject({
1156
- effectId: z.literal("retro-3d-shadow"),
1157
- options: z.strictObject({}).optional()
1158
- }),
1159
- z.strictObject({
1160
- effectId: z.literal("scale-up"),
1161
- options: z.strictObject({ scale: z.enum([
1162
- "1.02",
1163
- "1.03",
1164
- "1.05",
1165
- "1.10"
1166
- ]).optional() }).optional()
1167
- }),
1168
- z.strictObject({
1169
- effectId: z.literal("scale-down"),
1170
- options: z.strictObject({ scale: z.enum([
1171
- "0.90",
1172
- "0.95",
1173
- "0.97",
1174
- "0.98"
1175
- ]).optional() }).optional()
1176
- }),
1177
- z.strictObject({
1178
- effectId: z.literal("lift"),
1179
- options: z.strictObject({ amount: z.enum([
1180
- "0.125",
1181
- "0.25",
1182
- "0.5",
1183
- "1"
1184
- ]).optional() }).optional()
1185
- }),
1186
- z.strictObject({
1187
- effectId: z.literal("press-down"),
1188
- options: z.strictObject({ offset: buttonPressOffsetSchema.optional() }).optional()
1189
- }),
1190
- z.strictObject({
1191
- effectId: z.literal("pop"),
1192
- options: z.strictObject({ intensity: z.enum([
1193
- "subtle",
1194
- "medium",
1195
- "dramatic"
1196
- ]).optional() }).optional()
1197
- }),
1198
- z.strictObject({
1199
- effectId: z.literal("border-bottom-grow"),
1200
- options: z.strictObject({
1201
- height: z.union([z.literal(1), z.literal(2)]).optional(),
1202
- origin: z.enum([
1203
- "left",
1204
- "center",
1205
- "right"
1206
- ]).optional(),
1207
- persistent: z.boolean().optional(),
1208
- colourRole: z.literal("mark").optional()
1209
- }).optional()
1210
- }),
1211
- z.strictObject({
1212
- effectId: z.literal("sketchy-border"),
1213
- options: z.strictObject({ intensity: buttonShadowIntensitySchema.optional() }).optional()
1214
- })
1215
- ]);
1216
- const cornerStyleSchema = z.enum([
1217
- "square",
1218
- "rounded",
1219
- "pill"
1220
- ]);
1221
- const shadowSizeSchema = z.enum([
1222
- "none",
1223
- "low",
1224
- "medium",
1225
- "high"
1226
- ]);
1227
- const hoverTransformSchema = z.enum([
1228
- "none",
1229
- "lift",
1230
- "scale",
1231
- "press"
1232
- ]);
1233
- z.enum(["none", "token"]);
1234
- const buttonPaddingPresetSchema = z.enum([
1235
- "compact",
1236
- "default",
1237
- "spacious"
1238
- ]);
1239
- const gradientStyleSchema = z.enum([
1240
- "linear",
1241
- "radial",
1242
- "conic"
1243
- ]);
1244
- const gradientSharpnessSchema = z.enum([
1245
- "smooth",
1246
- "medium",
1247
- "hard"
1248
- ]);
1249
- const prioritySchema = z.union([
1250
- z.literal(1),
1251
- z.literal(2),
1252
- z.literal(3)
1253
- ]);
1254
- const variantRoleSchema = z.enum(VARIANT_ROLES);
1255
- const buttonSurfaceFallbackSchema = z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("surface-outline") }), z.strictObject({
1256
- kind: z.literal("variant"),
1257
- role: variantRoleSchema
1258
- })]);
1259
- const standardButtonSurfacePolicy = {
1260
- primary: [{ kind: "surface-outline" }],
1261
- secondary: [{ kind: "surface-outline" }, {
1262
- kind: "variant",
1263
- role: "primary"
1264
- }],
1265
- outline: [{ kind: "surface-outline" }],
1266
- ghost: [{ kind: "surface-outline" }],
1267
- accent: [{ kind: "surface-outline" }, {
1268
- kind: "variant",
1269
- role: "primary"
1270
- }]
1445
+ function hoverDecoration(input) {
1446
+ return input.hoverDecoration ?? "underline";
1447
+ }
1448
+ //#endregion
1449
+ //#region ../theme-core/src/tokens/tokens.ts
1450
+ const defaultThemeTokens = {
1451
+ color: {
1452
+ "background/base": "#ffffff",
1453
+ "background/elevated": "#f5f5f5",
1454
+ "surface/base": "#ffffff",
1455
+ "surface/subtle": "#f9f9fb",
1456
+ "surface/inverted": "#111111",
1457
+ "content/primary": "#111111",
1458
+ "content/secondary": "#3f3f46",
1459
+ "accent/primary": "#2563eb",
1460
+ "accent/secondary": "#1d4ed8",
1461
+ "border/base": "#e5e7eb"
1462
+ },
1463
+ typography: {
1464
+ "display/hero": {
1465
+ fontSize: "clamp(48px, 8vw, 96px)",
1466
+ lineHeight: "1.05",
1467
+ fontWeight: "700"
1468
+ },
1469
+ "display/section": {
1470
+ fontSize: "clamp(40px, 6vw, 72px)",
1471
+ lineHeight: "1.1",
1472
+ fontWeight: "700"
1473
+ },
1474
+ "heading/large": {
1475
+ fontSize: "clamp(32px, 4vw, 48px)",
1476
+ lineHeight: "1.2",
1477
+ fontWeight: "600"
1478
+ },
1479
+ "heading/medium": {
1480
+ fontSize: "clamp(24px, 3vw, 32px)",
1481
+ lineHeight: "1.25",
1482
+ fontWeight: "600"
1483
+ },
1484
+ "heading/small": {
1485
+ fontSize: "20px",
1486
+ lineHeight: "1.3",
1487
+ fontWeight: "600"
1488
+ },
1489
+ "body/normal": {
1490
+ fontSize: "16px",
1491
+ lineHeight: "1.6",
1492
+ fontWeight: "400"
1493
+ },
1494
+ "body/small": {
1495
+ fontSize: "14px",
1496
+ lineHeight: "1.5",
1497
+ fontWeight: "400"
1498
+ },
1499
+ caption: {
1500
+ fontSize: "12px",
1501
+ lineHeight: "1.4",
1502
+ fontWeight: "500"
1503
+ }
1504
+ },
1505
+ spacing: {
1506
+ none: "0px",
1507
+ "3xs": "4px",
1508
+ "2xs": "8px",
1509
+ xs: "12px",
1510
+ sm: "16px",
1511
+ md: "24px",
1512
+ lg: "32px",
1513
+ xl: "40px",
1514
+ "2xl": "56px",
1515
+ "3xl": "72px"
1516
+ },
1517
+ radius: {
1518
+ none: "0px",
1519
+ xs: "2px",
1520
+ sm: "4px",
1521
+ md: "8px",
1522
+ lg: "12px",
1523
+ pill: "999px",
1524
+ full: "9999px"
1525
+ },
1526
+ shadow: {
1527
+ none: "none",
1528
+ soft: "0px 2px 8px rgba(15, 23, 42, 0.08)",
1529
+ medium: "0px 6px 18px rgba(15, 23, 42, 0.12)",
1530
+ strong: "0px 12px 36px rgba(15, 23, 42, 0.16)"
1531
+ },
1532
+ palette: {
1533
+ surface: "#ffffff",
1534
+ "neutral-50": "#f9fafb",
1535
+ "neutral-900": "#111827",
1536
+ primary: "#2563eb",
1537
+ "primary-50": "#eff6ff",
1538
+ "primary-500": "#2563eb",
1539
+ "primary-900": "#1d4ed8",
1540
+ secondary: "#9333ea",
1541
+ "secondary-50": "#f3e8ff",
1542
+ "secondary-500": "#9333ea",
1543
+ "secondary-900": "#4c1d95",
1544
+ accent: "#f97316",
1545
+ "accent-50": "#fff7ed",
1546
+ "accent-500": "#f97316",
1547
+ "accent-900": "#7c2d12"
1548
+ }
1271
1549
  };
1272
- const STANDARD_BUTTON_SURFACE_POLICY = Object.freeze(Object.fromEntries(VARIANT_ROLES.map((role) => [role, Object.freeze([...standardButtonSurfacePolicy[role]])])));
1273
- function createStandardButtonSurfacePolicy() {
1274
- return Object.fromEntries(VARIANT_ROLES.map((role) => [role, [...STANDARD_BUTTON_SURFACE_POLICY[role]]]));
1275
- }
1276
- const buttonSurfacePolicyShape = Object.fromEntries(VARIANT_ROLES.map((role) => [role, z.array(buttonSurfaceFallbackSchema).max(VARIANT_ROLES.length)]));
1277
- const buttonSurfacePolicySchema = z.strictObject(buttonSurfacePolicyShape);
1278
- const buttonSizeNameSchema = z.enum([
1279
- "sm",
1280
- "md",
1281
- "lg",
1282
- "xl"
1283
- ]);
1284
- /**
1285
- * CSS padding string in `"<vertical> <horizontal>"` shorthand form.
1286
- *
1287
- * Exactly two space-separated CSS length tokens. Each token is either the
1288
- * literal `0` or a number followed by `rem`/`em`/`px`/`%`. This lets the
1289
- * generator trust the shape rather than defensively defaulting downstream.
1290
- */
1291
- const PADDING_TOKEN_PATTERN = /^(?:0|\d+(?:\.\d+)?(?:rem|em|px|%))$/;
1292
- const paddingShorthandSchema = z.string().refine((value) => {
1293
- const parts = value.split(/\s+/).filter(Boolean);
1294
- return parts.length === 2 && parts.every((token) => PADDING_TOKEN_PATTERN.test(token));
1295
- }, { message: "Padding must be two space-separated CSS length tokens (e.g. \"0.5rem 1rem\"). Use `0` for zero." });
1296
- const buttonSizeConfigSchema = z.object({
1297
- padding: paddingShorthandSchema,
1298
- fontSize: z.string().optional(),
1299
- borderRadius: z.string().optional()
1300
- });
1301
1550
  /**
1302
- * `xl` is optional on the wire so themes persisted before the `xl` size was
1303
- * added (e.g. SWTS) continue to parse. When `xl` is missing the schema
1304
- * backfills it from `lg`, keeping `ButtonSizes` a complete `sm/md/lg/xl` map
1305
- * downstream — generators never need to deal with an undefined `xl`.
1551
+ * Project the expanded semantic palette into the token buckets consumed by
1552
+ * runtime transforms. Keep this mapping shared by full themes and the
1553
+ * tokens-only hosted-booking runtime so the two paths cannot drift.
1306
1554
  */
1307
- const buttonSizesSchema = z.object({
1308
- sm: buttonSizeConfigSchema,
1309
- md: buttonSizeConfigSchema,
1310
- lg: buttonSizeConfigSchema,
1311
- xl: buttonSizeConfigSchema.optional()
1312
- }).transform(({ sm, md, lg, xl }) => ({
1313
- sm,
1314
- md,
1315
- lg,
1316
- xl: xl ?? lg
1317
- }));
1318
- const buttonGlobalSettingsBaseSchema = z.strictObject({
1319
- cornerStyle: cornerStyleSchema,
1320
- cornerRadius: z.number().min(0).max(24).optional(),
1321
- /**
1322
- * Family-level shadow inherited by variants that don't set their own.
1323
- * Optional and flat-by-default: when omitted, buttons carry no drop shadow
1324
- * (`elevation: 'none'`). A personality opts the whole family into a shadow by
1325
- * setting this; individual variants still override. There is no system-level
1326
- * shadow-by-default — shadows only appear when explicitly declared.
1327
- */
1328
- shadow: shadowSizeSchema.optional(),
1329
- textTransform: textTransformSchema,
1330
- fontWeight: fontWeightSchema,
1331
- typography: buttonTypographySchema.optional(),
1332
- fontSize: z.string().optional(),
1333
- letterSpacing: letterSpacingSchema.optional(),
1334
- italic: z.boolean().optional(),
1335
- paddingPreset: buttonPaddingPresetSchema.optional(),
1336
- hoverTransform: hoverTransformSchema,
1337
- gradientStyle: gradientStyleSchema.optional(),
1338
- gradientAngle: z.number().min(0).max(360).optional(),
1339
- gradientSharpness: gradientSharpnessSchema.optional()
1340
- });
1341
- const buttonGlobalSettingsSchema = z.discriminatedUnion("hoverColor", [buttonGlobalSettingsBaseSchema.extend({
1342
- hoverColor: z.literal("none"),
1343
- hoverColorToken: z.never().optional()
1344
- }), buttonGlobalSettingsBaseSchema.extend({
1345
- hoverColor: z.literal("token"),
1346
- hoverColorToken: opaqueButtonColourTokenSchema
1347
- })]);
1348
- const gradientDirectionSchema$1 = z.enum([
1349
- "to-r",
1350
- "to-l",
1351
- "to-t",
1352
- "to-b",
1353
- "to-tr",
1354
- "to-tl",
1355
- "to-br",
1356
- "to-bl"
1357
- ]);
1358
- const buttonColourTreatmentSchema = z.discriminatedUnion("type", [
1359
- z.strictObject({
1360
- type: z.literal("solid"),
1361
- colorToken: opaqueButtonColourTokenSchema
1362
- }),
1363
- z.strictObject({
1364
- type: z.literal("gradient"),
1365
- stops: z.array(opaqueButtonColourTokenSchema).min(2).transform((stops) => {
1366
- const [first, second, ...rest] = stops;
1367
- if (first === void 0 || second === void 0) throw new Error("Invariant: gradient stops passed the minimum length schema");
1368
- return [
1369
- first,
1370
- second,
1371
- ...rest
1372
- ];
1373
- }),
1374
- direction: gradientDirectionSchema$1,
1375
- foregroundToken: opaqueButtonColourTokenSchema
1376
- }),
1377
- z.strictObject({
1378
- type: z.literal("surface"),
1379
- role: z.literal("link")
1380
- })
1381
- ]);
1382
- const buttonBackgroundSchema = buttonColourTreatmentSchema;
1383
- const buttonBorderSchema = z.strictObject({
1384
- widthClass: z.string(),
1385
- marksBoundary: z.literal(true).optional(),
1386
- ring: z.literal(true).optional(),
1387
- boundaryInk: opaqueButtonColourTokenSchema.optional()
1388
- });
1389
- const buttonVariantAffordanceSchema = z.strictObject({ iconId: z.string().min(1) });
1390
- const variantShadowSchema = z.strictObject({
1391
- elevation: z.enum([
1392
- "none",
1393
- "low",
1394
- "medium",
1395
- "high"
1396
- ]),
1397
- softness: z.enum([
1398
- "crisp",
1399
- "soft",
1400
- "hard"
1401
- ]).nullable(),
1402
- position: z.enum(["bottom", "bottom-right"]).default("bottom"),
1403
- colorToken: opaqueButtonColourTokenSchema.optional()
1404
- });
1405
- /** Recipe states own every visual property; treatment owns its readable label. */
1406
- const buttonVisualAppearanceSchema = z.strictObject({
1407
- background: buttonColourTreatmentSchema,
1408
- text: z.literal("treatment"),
1409
- border: z.union([z.literal("none"), buttonBorderSchema]),
1410
- borderRadius: z.string(),
1411
- shadow: z.union([z.literal("focus-indicator"), variantShadowSchema]),
1412
- sizes: buttonSizesSchema,
1413
- typography: z.strictObject({
1414
- fontWeight: fontWeightSchema,
1415
- typography: buttonTypographySchema,
1416
- fontSize: z.string().nullable(),
1417
- letterSpacing: z.union([letterSpacingSchema, z.literal("heading")]).nullable(),
1418
- italic: z.boolean(),
1419
- textTransform: textTransformSchema
1420
- }),
1421
- effects: z.array(buttonEffectApplicationSchema),
1422
- transform: z.literal("none").optional(),
1423
- contextualHover: contextualButtonHoverSchema.optional()
1424
- });
1425
- const buttonVisualStatesSchema = z.strictObject({
1426
- base: buttonVisualAppearanceSchema.extend({ shadow: variantShadowSchema }),
1427
- hover: buttonVisualAppearanceSchema.extend({ shadow: variantShadowSchema }),
1428
- focus: buttonVisualAppearanceSchema.extend({
1429
- shadow: z.literal("focus-indicator"),
1430
- indicator: z.strictObject({
1431
- kind: z.literal("surface-ink"),
1432
- width: z.union([z.literal(2), z.literal(3)]),
1433
- offset: z.union([z.literal(3), z.literal(4)])
1434
- }).optional()
1435
- }),
1436
- active: buttonVisualAppearanceSchema.extend({ shadow: variantShadowSchema }),
1437
- disabled: buttonVisualAppearanceSchema.extend({ shadow: variantShadowSchema })
1438
- });
1439
- const variantEffectsSchema = z.strictObject({
1440
- base: z.array(buttonEffectApplicationSchema).optional(),
1441
- hover: z.array(buttonEffectApplicationSchema).optional(),
1442
- active: z.array(buttonEffectApplicationSchema).optional(),
1443
- focus: z.array(buttonEffectApplicationSchema).optional()
1444
- });
1555
+ function buildThemeTokens(palette) {
1556
+ const tokens = cloneThemeTokens(defaultThemeTokens);
1557
+ const paletteStrings = {};
1558
+ for (const [key, value] of Object.entries(palette)) if (typeof value === "string" && value.trim().length > 0) paletteStrings[key] = value;
1559
+ tokens.palette = paletteStrings;
1560
+ const resolveColor = (...keys) => {
1561
+ for (const key of keys) {
1562
+ const value = paletteStrings[key];
1563
+ if (value) return value;
1564
+ }
1565
+ };
1566
+ const assignColor = (token, ...keys) => {
1567
+ const value = resolveColor(...keys);
1568
+ if (value) tokens.color[token] = value;
1569
+ };
1570
+ assignColor("background/base", "background", "surface", "primary-50");
1571
+ assignColor("background/elevated", "surface", "background");
1572
+ assignColor("surface/base", "surface", "background");
1573
+ assignColor("surface/subtle", "neutral-100", "surface", "background");
1574
+ assignColor("surface/inverted", "neutral-900", "text", "primary-900");
1575
+ assignColor("content/primary", "text", "body", "neutral-900");
1576
+ assignColor("content/secondary", "mutedText", "secondary", "neutral-600");
1577
+ assignColor("accent/primary", "primary", "accent");
1578
+ assignColor("accent/secondary", "accent", "secondary", "primary-400");
1579
+ assignColor("border/base", "border", "neutral-300");
1580
+ return tokens;
1581
+ }
1582
+ function cloneThemeTokens(source) {
1583
+ return JSON.parse(JSON.stringify(source));
1584
+ }
1585
+ //#endregion
1586
+ //#region ../theme-core/src/surfaces/logoVariant.ts
1587
+ /** Concrete hex behind a plain, opaque palette token, or null otherwise. */
1588
+ function opaquePaletteHexForToken(expandedPalette, token) {
1589
+ if (!token) return null;
1590
+ const parts = parseColorTokenParts(token);
1591
+ if (parts.kind !== "token" || parts.opacityPercent !== null) return null;
1592
+ return expandedPalette[parts.token] ?? null;
1593
+ }
1445
1594
  /**
1446
- * Per-variant size overrides schema — every entry is optional.
1595
+ * Tone of the surface a foreground token was resolved for.
1447
1596
  *
1448
- * For each size key present, the values override the theme's `sizes` config
1449
- * for that size on this variant. Missing sizes fall through to theme.sizes,
1450
- * then system defaults.
1597
+ * A token with opacity has no known underlay to composite against, and a raw
1598
+ * or unrecognised token has no palette hex, so both are `unknown` rather than
1599
+ * a guess.
1451
1600
  */
1452
- const variantSizeOverridesSchema = z.object({
1453
- sm: buttonSizeConfigSchema.optional(),
1454
- md: buttonSizeConfigSchema.optional(),
1455
- lg: buttonSizeConfigSchema.optional(),
1456
- xl: buttonSizeConfigSchema.optional()
1457
- });
1601
+ function surfaceToneFromForegroundToken(expandedPalette, foregroundToken) {
1602
+ const hex = opaquePaletteHexForToken(expandedPalette, foregroundToken);
1603
+ if (!hex) return "unknown";
1604
+ return featuresFromHex(hex).Y >= .5 ? "dark" : "light";
1605
+ }
1458
1606
  /**
1459
- * Unified variant schema. Every variant participates in the size system; the
1460
- * optional `sizes` field lets a variant scale differently than the theme
1461
- * default (e.g. link-style variants declaring zero horizontal padding at
1462
- * every size).
1607
+ * The logo to draw on a surface of the given tone. A missing variant falls
1608
+ * back to the other one, and an unknown tone uses the light-backgrounds logo,
1609
+ * which is what every site rendered before variants existed.
1463
1610
  */
1464
- const buttonVariantSchema = z.strictObject({
1465
- id: buttonVariantIdSchema,
1466
- name: z.string().min(1).max(20),
1467
- enabled: z.boolean(),
1468
- priority: prioritySchema,
1469
- visualStates: buttonVisualStatesSchema.optional(),
1470
- background: buttonBackgroundSchema,
1471
- /** Tailwind radius token (e.g. `'rounded-md'`). Omit to inherit from `global.cornerStyle`. */
1472
- borderRadius: z.string().optional(),
1473
- shadow: variantShadowSchema.optional(),
1474
- border: buttonBorderSchema.optional(),
1475
- hoverBackgroundToken: opaqueButtonColourTokenSchema.optional(),
1476
- contextualHover: contextualButtonHoverSchema.optional(),
1477
- effects: variantEffectsSchema.optional(),
1478
- sizes: variantSizeOverridesSchema.optional(),
1479
- affordance: buttonVariantAffordanceSchema.optional()
1480
- });
1481
- const buttonSystemSchema = z.strictObject({
1482
- global: buttonGlobalSettingsSchema,
1483
- variants: z.array(buttonVariantSchema).min(1).max(6),
1484
- sizes: buttonSizesSchema.optional(),
1485
- surfacePolicy: buttonSurfacePolicySchema.optional(),
1486
- surfaceContexts: z.record(z.string(), z.strictObject({ primary: opaqueButtonColourTokenSchema })).optional()
1487
- }).superRefine((system, ctx) => {
1488
- const seen = /* @__PURE__ */ new Set();
1489
- system.variants.forEach((variant, index) => {
1490
- if (seen.has(variant.id)) ctx.addIssue({
1491
- code: "custom",
1492
- path: [
1493
- "variants",
1494
- index,
1495
- "id"
1496
- ],
1497
- message: `Duplicate button variant ID: ${variant.id}`
1498
- });
1499
- seen.add(variant.id);
1500
- });
1501
- });
1611
+ function selectLogoVariant(tone, variants) {
1612
+ const { forLightBackgrounds, forDarkBackgrounds } = variants;
1613
+ return tone === "dark" ? forDarkBackgrounds ?? forLightBackgrounds : forLightBackgrounds ?? forDarkBackgrounds;
1614
+ }
1502
1615
  //#endregion
1503
1616
  //#region ../theme-core/src/buttons/styles/domain.ts
1504
1617
  const PUBLIC_BUTTON_ROLES = VARIANT_ROLES;
@@ -2935,25 +3048,42 @@ function resolveSurfaceButtonContext(input) {
2935
3048
  kind: "reset",
2936
3049
  styles: contextualButtonSurfaceResetStyles()
2937
3050
  };
2938
- return {
2939
- kind: "resolved",
2940
- styles: knownSurfaceButtonContextStyles({
2941
- surface: context.surface,
2942
- palette: input.palette,
2943
- colourIndex: input.colourIndex,
2944
- buttonSystem: surfaceButtonSystem(input.buttonSystem, input.primaryToken)
2945
- })
2946
- };
2947
- }
2948
- /** Every role's contextual styles against one proven solid surface. */
2949
- function knownSurfaceButtonContextStyles(input) {
2950
- return Object.fromEntries(VARIANT_ROLES.flatMap((role) => Object.entries(contextualButtonSurfaceStyles(resolveContextualButtonRole({
2951
- role,
2952
- buttonSystem: input.buttonSystem,
3051
+ return knownSurfaceButtonContext({
3052
+ surface: context.surface,
2953
3053
  palette: input.palette,
2954
3054
  colourIndex: input.colourIndex,
2955
- surface: input.surface
2956
- })))));
3055
+ buttonSystem: surfaceButtonSystem(input.buttonSystem, input.primaryToken)
3056
+ });
3057
+ }
3058
+ function knownSurfaceButtonContext(input) {
3059
+ const roles = freezeOwnedThemeValue({
3060
+ primary: resolveContextualButtonRole({
3061
+ ...input,
3062
+ role: "primary"
3063
+ }),
3064
+ secondary: resolveContextualButtonRole({
3065
+ ...input,
3066
+ role: "secondary"
3067
+ }),
3068
+ outline: resolveContextualButtonRole({
3069
+ ...input,
3070
+ role: "outline"
3071
+ }),
3072
+ ghost: resolveContextualButtonRole({
3073
+ ...input,
3074
+ role: "ghost"
3075
+ }),
3076
+ accent: resolveContextualButtonRole({
3077
+ ...input,
3078
+ role: "accent"
3079
+ })
3080
+ });
3081
+ const styles = Object.fromEntries(VARIANT_ROLES.flatMap((role) => Object.entries(contextualButtonSurfaceStyles(roles[role]))));
3082
+ return Object.defineProperty({
3083
+ kind: "resolved",
3084
+ styles,
3085
+ roles
3086
+ }, "roles", { enumerable: false });
2957
3087
  }
2958
3088
  function resolveContextualButtonRole(input) {
2959
3089
  const requested = findVariant(input.buttonSystem, input.role);
@@ -2976,15 +3106,18 @@ function preferredButtonResolution(requested, compiled, role) {
2976
3106
  focusIndicator: compiled.focusIndicator,
2977
3107
  boundary: boundaryForVariant(requested)
2978
3108
  };
2979
- return compiled.contextualHoverRepair ? {
3109
+ const boundaries = boundariesForVariant(requested);
3110
+ return compiled.contextualHoverRepair ? hideBoundaryEvidence({
2980
3111
  ...appearance,
3112
+ boundaries,
2981
3113
  kind: "repaired",
2982
3114
  candidate: "contextual-hover",
2983
3115
  rejectedCandidates: []
2984
- } : {
3116
+ }) : hideBoundaryEvidence({
2985
3117
  ...appearance,
3118
+ boundaries,
2986
3119
  kind: "preferred"
2987
- };
3120
+ });
2988
3121
  }
2989
3122
  /** Ordered, lazy fallback selection; the rejected evidence belongs to this decision. */
2990
3123
  function resolveFallbackButtonRole(input, requested, fallbacks, rejected) {
@@ -2997,15 +3130,16 @@ function resolveFallbackButtonRole(input, requested, fallbacks, rejected) {
2997
3130
  const candidate = candidateVariant(fallback, requested, input.buttonSystem);
2998
3131
  if (!candidate) return resolveFallbackButtonRole(input, requested, remaining, rejected);
2999
3132
  const compiled = compileCandidate(candidate.variant, input);
3000
- return compiled.ok ? {
3133
+ return compiled.ok ? hideBoundaryEvidence({
3001
3134
  kind: "repaired",
3002
3135
  requestedRole: input.role,
3003
3136
  candidate: candidate.name,
3137
+ boundaries: boundariesForVariant(candidate.variant),
3004
3138
  states: candidate.name === "surface-outline" ? withSurfaceInversion(compiled.states, input.surface) : compiled.states,
3005
3139
  focusIndicator: compiled.focusIndicator,
3006
3140
  boundary: candidate.boundary,
3007
3141
  rejectedCandidates: rejected
3008
- } : resolveFallbackButtonRole(input, requested, remaining, [...rejected, {
3142
+ }) : resolveFallbackButtonRole(input, requested, remaining, [...rejected, {
3009
3143
  candidate: candidate.name,
3010
3144
  error: compiled.error
3011
3145
  }]);
@@ -3112,6 +3246,25 @@ function candidateVariant(fallback, requested, system) {
3112
3246
  }
3113
3247
  };
3114
3248
  }
3249
+ function hideBoundaryEvidence(value) {
3250
+ return Object.defineProperty(value, "boundaries", { enumerable: false });
3251
+ }
3252
+ function boundariesForVariant(variant) {
3253
+ const boundary = (state) => {
3254
+ const appearance = variant.visualStates?.[state];
3255
+ return boundaryForVariant(appearance ? {
3256
+ ...variant,
3257
+ border: appearance.border === "none" ? void 0 : appearance.border
3258
+ } : variant);
3259
+ };
3260
+ return freezeOwnedThemeValue({
3261
+ base: boundary("base"),
3262
+ hover: boundary("hover"),
3263
+ focus: boundary("focus"),
3264
+ active: boundary("active"),
3265
+ disabled: boundary("disabled")
3266
+ });
3267
+ }
3115
3268
  function boundaryForVariant(variant) {
3116
3269
  if (!variant.border) return null;
3117
3270
  return {
@@ -3241,6 +3394,7 @@ function opaqueSurfaceContextFromTheme(theme) {
3241
3394
  * inherit a band's light text or its band-resolved buttons.
3242
3395
  */
3243
3396
  function opaqueSurfaceDeclarations(surface, arrangement = false) {
3397
+ requireResolvedSurface(surface);
3244
3398
  if (surface.kind === "inherit") return inheritedSurfaceDeclarations(arrangement);
3245
3399
  const foreground = surface.foreground;
3246
3400
  return [
@@ -3271,6 +3425,335 @@ function inheritedSurfaceDeclarations(arrangement) {
3271
3425
  ].map((property) => `${property}: inherit;`);
3272
3426
  }
3273
3427
  //#endregion
3428
+ //#region ../theme-core/src/surfaces/mapDrawingTokens.ts
3429
+ /**
3430
+ * The one map token contract (issue 1611). Drawings carry semantic classes only;
3431
+ * these variables are the only colours a map receives. Each value is resolved
3432
+ * from the section ground the map sits on, so the same geometry reads on light,
3433
+ * brand and dark grounds without regeneration.
3434
+ */
3435
+ const MAP_DRAWING_COLOUR_VARS = {
3436
+ land: "--map-land",
3437
+ water: "--map-water",
3438
+ park: "--map-park",
3439
+ building: "--map-building",
3440
+ buildingEdge: "--map-building-edge",
3441
+ road: "--map-road",
3442
+ roadCasing: "--map-road-casing",
3443
+ roadMajor: "--map-road-major",
3444
+ roadMajorCasing: "--map-road-major-casing",
3445
+ path: "--map-path",
3446
+ label: "--map-label",
3447
+ labelHalo: "--map-label-halo",
3448
+ pin: "--map-pin",
3449
+ pinEdge: "--map-pin-edge",
3450
+ frame: "--map-frame-color"
3451
+ };
3452
+ const MAP_DRAWING_SHAPE_VARS = {
3453
+ frameRadius: "--map-frame-radius",
3454
+ frameWidth: "--map-frame-width",
3455
+ frameShadow: "--map-frame-shadow",
3456
+ labelFont: "--map-label-font",
3457
+ labelWeight: "--map-label-weight",
3458
+ casingScale: "--map-casing-scale"
3459
+ };
3460
+ const defaultMapDrawingTreatment = {
3461
+ land: .035,
3462
+ water: {
3463
+ roles: [
3464
+ "primary",
3465
+ "accent",
3466
+ "secondary"
3467
+ ],
3468
+ amount: .2
3469
+ },
3470
+ park: {
3471
+ roles: [
3472
+ "success",
3473
+ "secondary",
3474
+ "primary"
3475
+ ],
3476
+ amount: .16
3477
+ },
3478
+ building: .09,
3479
+ buildingEdge: .17,
3480
+ roadLift: .7,
3481
+ casingSink: .2,
3482
+ majorRoad: {
3483
+ roles: ["accent", "primary"],
3484
+ amount: .16
3485
+ },
3486
+ path: .42,
3487
+ labelContrast: 6,
3488
+ pin: [
3489
+ "primary",
3490
+ "accent",
3491
+ "secondary"
3492
+ ],
3493
+ frame: {
3494
+ radius: "var(--rb-block-radius, 8px)",
3495
+ width: "1px",
3496
+ shadow: "none",
3497
+ colour: .16
3498
+ },
3499
+ labelWeight: 500,
3500
+ casingScale: 1
3501
+ };
3502
+ /** Per arrangement style (keyed by its skin). Legacy themes without a skin use the default. */
3503
+ const mapDrawingTreatments = {
3504
+ fulcrum: {
3505
+ ...defaultMapDrawingTreatment,
3506
+ land: .025,
3507
+ water: {
3508
+ roles: ["primary", "secondary"],
3509
+ amount: .2
3510
+ },
3511
+ park: {
3512
+ roles: ["success", "primary"],
3513
+ amount: .12
3514
+ },
3515
+ building: .07,
3516
+ buildingEdge: .14,
3517
+ casingSink: .16,
3518
+ majorRoad: {
3519
+ roles: ["accent"],
3520
+ amount: .12
3521
+ },
3522
+ pin: ["accent", "primary"],
3523
+ frame: {
3524
+ radius: "var(--rb-skin-radius, 3px)",
3525
+ width: "var(--rb-skin-rule, 1px)",
3526
+ shadow: "none",
3527
+ colour: .16
3528
+ }
3529
+ },
3530
+ poster: {
3531
+ ...defaultMapDrawingTreatment,
3532
+ land: 0,
3533
+ water: {
3534
+ roles: ["primary", "secondary"],
3535
+ amount: .32
3536
+ },
3537
+ park: {
3538
+ roles: ["success", "accent"],
3539
+ amount: .26
3540
+ },
3541
+ building: .12,
3542
+ buildingEdge: .3,
3543
+ roadLift: 1,
3544
+ casingSink: .55,
3545
+ majorRoad: {
3546
+ roles: ["accent", "primary"],
3547
+ amount: .55
3548
+ },
3549
+ path: .7,
3550
+ labelContrast: 9,
3551
+ pin: ["primary", "accent"],
3552
+ frame: {
3553
+ radius: "var(--rb-skin-radius, 0px)",
3554
+ width: "var(--rb-skin-rule, 3px)",
3555
+ shadow: "offset",
3556
+ colour: 1
3557
+ },
3558
+ labelWeight: 600,
3559
+ casingScale: 1.15
3560
+ },
3561
+ lantern: {
3562
+ ...defaultMapDrawingTreatment,
3563
+ land: .04,
3564
+ water: {
3565
+ roles: ["secondary", "primary"],
3566
+ amount: .22
3567
+ },
3568
+ park: {
3569
+ roles: ["success", "secondary"],
3570
+ amount: .14
3571
+ },
3572
+ building: .08,
3573
+ buildingEdge: .14,
3574
+ casingSink: .35,
3575
+ majorRoad: {
3576
+ roles: ["accent", "primary"],
3577
+ amount: .24
3578
+ },
3579
+ path: .4,
3580
+ pin: ["accent", "primary"],
3581
+ frame: {
3582
+ radius: "var(--rb-skin-radius, 10px)",
3583
+ width: "var(--rb-skin-rule, 1px)",
3584
+ shadow: "none",
3585
+ colour: .18
3586
+ }
3587
+ },
3588
+ measure: {
3589
+ ...defaultMapDrawingTreatment,
3590
+ land: .03,
3591
+ water: {
3592
+ roles: ["accent", "primary"],
3593
+ amount: .16
3594
+ },
3595
+ park: {
3596
+ roles: ["success"],
3597
+ amount: .12
3598
+ },
3599
+ building: .1,
3600
+ buildingEdge: .2,
3601
+ casingSink: .26,
3602
+ majorRoad: {
3603
+ roles: ["accent"],
3604
+ amount: 0
3605
+ },
3606
+ path: .5,
3607
+ pin: ["accent", "primary"],
3608
+ frame: {
3609
+ radius: "var(--rb-skin-radius, 0px)",
3610
+ width: "var(--rb-skin-rule, 2px)",
3611
+ shadow: "none",
3612
+ colour: .6
3613
+ },
3614
+ labelWeight: 600
3615
+ },
3616
+ folio: {
3617
+ ...defaultMapDrawingTreatment,
3618
+ land: .03,
3619
+ water: {
3620
+ roles: ["secondary", "primary"],
3621
+ amount: .18
3622
+ },
3623
+ park: {
3624
+ roles: ["success", "primary"],
3625
+ amount: .18
3626
+ },
3627
+ building: .08,
3628
+ buildingEdge: .15,
3629
+ casingSink: .18,
3630
+ majorRoad: {
3631
+ roles: ["accent"],
3632
+ amount: .14
3633
+ },
3634
+ pin: ["primary", "accent"],
3635
+ frame: {
3636
+ radius: "var(--rb-skin-radius, 10px)",
3637
+ width: "var(--rb-skin-rule, 1px)",
3638
+ shadow: "none",
3639
+ colour: .18
3640
+ }
3641
+ }
3642
+ };
3643
+ function mapDrawingTreatmentFor(skin) {
3644
+ return (skin === void 0 ? void 0 : mapDrawingTreatments[skin]) ?? defaultMapDrawingTreatment;
3645
+ }
3646
+ const toLab = (hex) => {
3647
+ const { r, g, b } = hexToRgb(hex);
3648
+ return srgbToOklab(r, g, b);
3649
+ };
3650
+ const toHex = ({ L, a, b }) => {
3651
+ const rgb = oklabToSrgb(L, a, b);
3652
+ return rgbToHex(rgb.r, rgb.g, rgb.b);
3653
+ };
3654
+ const blend = (from, to, t) => ({
3655
+ L: from.L + (to.L - from.L) * t,
3656
+ a: from.a + (to.a - from.a) * t,
3657
+ b: from.b + (to.b - from.b) * t
3658
+ });
3659
+ const distance = (x, y) => Math.hypot(x.L - y.L, x.a - y.a, x.b - y.b);
3660
+ /** A nearly neutral pole in the ground's hue, so lifts and sinks stay in the site's temperature. */
3661
+ function pole(ground, L) {
3662
+ const { C, h } = oklabToOklch(ground.L, ground.a, ground.b);
3663
+ return toLab(oklchToHexGamut(L, Math.min(C, .012), h));
3664
+ }
3665
+ /** The first blend from `from` toward `to` that reaches the contrast floor against every backdrop. */
3666
+ function firstContrastBlend(from, to, backdrops, floor) {
3667
+ return Array.from({ length: 41 }, (_, index) => toHex(blend(from, to, index / 40))).find((hex) => backdrops.every((backdrop) => contrastRatio(hex, backdrop) >= floor)) ?? toHex(to);
3668
+ }
3669
+ /** 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. */
3670
+ function tint(base, spec, palette, ink) {
3671
+ return spec.roles.flatMap((role) => {
3672
+ const hex = resolveConcreteColorHex(role, palette);
3673
+ return hex ? [blend(base, toLab(hex), spec.amount)] : [];
3674
+ }).find((candidate) => distance(candidate, base) >= .025) ?? blend(base, ink, Math.max(spec.amount * .6, .06));
3675
+ }
3676
+ /** Pure: one ground, one ink, one palette and one treatment decide every map colour. */
3677
+ function resolveMapDrawingColours(input) {
3678
+ const { treatment: t, palette } = input;
3679
+ const ground = toLab(input.ground);
3680
+ const ink = toLab(input.ink);
3681
+ const darkGround = ink.L > ground.L;
3682
+ const light = darkGround ? blend(ground, ink, .22) : pole(ground, Math.max(ground.L, .995));
3683
+ const dark = darkGround ? pole(ground, Math.max(ground.L - .22, .04)) : ink;
3684
+ const tinted = blend(ground, ink, t.land);
3685
+ const land = contrastRatio(toHex(tinted), input.ink) >= 4.5 ? tinted : ground;
3686
+ const landHex = toHex(land);
3687
+ const road = blend(land, light, t.roadLift);
3688
+ const casing = blend(land, dark, t.casingSink);
3689
+ const building = blend(land, ink, t.building);
3690
+ const majorTint = t.majorRoad.amount === 0 ? road : tint(road, t.majorRoad, palette, ink);
3691
+ const pinBackdrops = [
3692
+ landHex,
3693
+ toHex(road),
3694
+ toHex(building)
3695
+ ];
3696
+ const pinRoles = t.pin.flatMap((role) => {
3697
+ const hex = resolveConcreteColorHex(role, palette);
3698
+ return hex ? [hex] : [];
3699
+ });
3700
+ const pin = [...pinRoles, input.ink].find((hex) => pinBackdrops.every((backdrop) => contrastRatio(hex, backdrop) >= 3)) ?? firstContrastBlend(toLab(pinRoles[0] ?? input.ink), ink, pinBackdrops, 3);
3701
+ const pinEdge = [
3702
+ toHex(light),
3703
+ toHex(dark),
3704
+ landHex
3705
+ ].reduce((best, hex) => contrastRatio(hex, pin) > contrastRatio(best, pin) ? hex : best);
3706
+ return {
3707
+ land: landHex,
3708
+ water: toHex(tint(land, t.water, palette, ink)),
3709
+ park: toHex(tint(land, t.park, palette, ink)),
3710
+ building: toHex(building),
3711
+ buildingEdge: toHex(blend(land, ink, t.buildingEdge)),
3712
+ road: toHex(road),
3713
+ roadCasing: toHex(casing),
3714
+ roadMajor: toHex(majorTint),
3715
+ roadMajorCasing: toHex(blend(casing, dark, .15)),
3716
+ path: toHex(blend(land, ink, t.path)),
3717
+ label: firstContrastBlend(land, ink, [landHex], Math.max(4.5, t.labelContrast)),
3718
+ labelHalo: landHex,
3719
+ pin,
3720
+ pinEdge,
3721
+ frame: toHex(blend(ground, ink, t.frame.colour))
3722
+ };
3723
+ }
3724
+ function mapDrawingShapeStyle(treatment) {
3725
+ return {
3726
+ [MAP_DRAWING_SHAPE_VARS.frameRadius]: treatment.frame.radius,
3727
+ [MAP_DRAWING_SHAPE_VARS.frameWidth]: treatment.frame.width,
3728
+ [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",
3729
+ [MAP_DRAWING_SHAPE_VARS.labelFont]: "var(--font-body, system-ui, sans-serif)",
3730
+ [MAP_DRAWING_SHAPE_VARS.labelWeight]: String(treatment.labelWeight),
3731
+ [MAP_DRAWING_SHAPE_VARS.casingScale]: String(treatment.casingScale)
3732
+ };
3733
+ }
3734
+ /**
3735
+ * Everything a map needs from the section it sits on. Unmeasured grounds
3736
+ * (photos, gradients) keep the structural fallbacks for colour; the style's
3737
+ * shape still applies.
3738
+ */
3739
+ function mapDrawingStyle(input) {
3740
+ const treatment = mapDrawingTreatmentFor(input.skin);
3741
+ const shape = mapDrawingShapeStyle(treatment);
3742
+ if (input.foreground.kind !== "known" || input.foreground.provenance.kind !== "measured") return shape;
3743
+ const ink = resolveConcreteColorHex(input.foreground.roles.text, input.palette);
3744
+ if (ink === null) return shape;
3745
+ const colours = resolveMapDrawingColours({
3746
+ ground: input.foreground.provenance.backdropHex,
3747
+ ink,
3748
+ palette: input.palette,
3749
+ treatment
3750
+ });
3751
+ return {
3752
+ ...shape,
3753
+ ...Object.fromEntries(Object.entries(colours).map(([role, value]) => [MAP_DRAWING_COLOUR_VARS[role], value]))
3754
+ };
3755
+ }
3756
+ //#endregion
3274
3757
  //#region ../theme-core/src/utils/colorStyles.ts
3275
3758
  const COLOR_VAR_PREFIX = "--tb-";
3276
3759
  function parseToken(source) {
@@ -4025,12 +4508,67 @@ function terminalFallbackSurface(input) {
4025
4508
  rejectedCandidates: input.rejectedCandidates
4026
4509
  };
4027
4510
  }
4511
+ const resolvedSurfaceBrand = Symbol("ResolvedSurface");
4512
+ const surfaceOwners = /* @__PURE__ */ new WeakSet();
4513
+ const preparedIndexOwners = /* @__PURE__ */ new WeakSet();
4514
+ const surfaceTransports = /* @__PURE__ */ new WeakMap();
4515
+ const ownedRevisionInputs = /* @__PURE__ */ new WeakMap();
4516
+ const revisionOwners = /* @__PURE__ */ new WeakMap();
4517
+ const surfaceRevisionOwners = /* @__PURE__ */ new WeakMap();
4518
+ const surfaceTextPolicy = Object.freeze({
4519
+ heading: "large-text-aa",
4520
+ text: "body-aa",
4521
+ link: "body-aa",
4522
+ linkHover: "body-aa",
4523
+ supporting: "body-aa",
4524
+ muted: "body-aa"
4525
+ });
4526
+ function ownSurfaceRevision(context) {
4527
+ if (!ownedRevisionInputs.get(context.palette)?.has(context.buttonSystem)) {
4528
+ const revision = ownedThemeSnapshot({
4529
+ palette: context.palette,
4530
+ buttonSystem: context.buttonSystem
4531
+ });
4532
+ registerOwnedRevisionInputs(revision);
4533
+ surfaceRevisionOwners.set(revision, revision);
4534
+ revisionOwners.set(revision.palette, /* @__PURE__ */ new Map([[revision.buttonSystem, revision]]));
4535
+ return revision;
4536
+ }
4537
+ const revisions = revisionOwners.get(context.palette) ?? /* @__PURE__ */ new Map();
4538
+ const existing = revisions.get(context.buttonSystem);
4539
+ if (existing) return existing;
4540
+ const revision = Object.freeze({
4541
+ palette: context.palette,
4542
+ buttonSystem: context.buttonSystem
4543
+ });
4544
+ surfaceRevisionOwners.set(revision, revision);
4545
+ revisions.set(context.buttonSystem, revision);
4546
+ revisionOwners.set(context.palette, revisions);
4547
+ return revision;
4548
+ }
4549
+ /** Called only after copying and recursively freezing owner inputs. */
4550
+ function registerOwnedRevisionInputs(context) {
4551
+ const buttons = ownedRevisionInputs.get(context.palette) ?? /* @__PURE__ */ new Set();
4552
+ buttons.add(context.buttonSystem);
4553
+ ownedRevisionInputs.set(context.palette, buttons);
4554
+ }
4555
+ function isResolvedSurface(value) {
4556
+ return typeof value === "object" && value !== null && surfaceOwners.has(value) && "kind" in value && (value.kind === "owned" || value.kind === "inherit");
4557
+ }
4558
+ /** Opaque immutable surface/context values have no child DTOs to project. */
4559
+ function isSurfaceTransportLeaf(value) {
4560
+ return isResolvedSurface(value) || isSurfaceTreeRecord(value) && surfaceRevisionOwners.has(value);
4561
+ }
4562
+ /** Runtime serializers reject copies and forged structural objects, too. */
4563
+ function requireResolvedSurface(value) {
4564
+ if (!isResolvedSurface(value)) throw new Error("Surface must be produced by resolveSurface");
4565
+ }
4028
4566
  function resolveSurface(spec, context) {
4029
- return spec.kind === "section" ? resolveSectionSurface(spec.background, context) : preparedSurfaceValue(spec, context) ?? resolveSurfaceSpec(spec, context);
4567
+ return spec.kind === "section" ? resolveSectionSurface(spec.background, context) : preparedSurfaceValue(spec, context) ?? certifySurface(spec, context);
4030
4568
  }
4031
4569
  function preparedSurfaceValue(spec, context) {
4032
4570
  const index = context.preparedSurfaces;
4033
- if (!index || index.palette !== context.palette || index.buttonSystem !== context.buttonSystem || index.colourIndex !== context.colourIndex) return void 0;
4571
+ if (!index || !preparedIndexOwners.has(index) || index.palette !== context.palette || index.buttonSystem !== context.buttonSystem || index.colourIndex !== context.colourIndex) return void 0;
4034
4572
  return index.values[surfaceResolutionKey(spec, context)];
4035
4573
  }
4036
4574
  function surfaceResolutionKey(spec, context) {
@@ -4118,7 +4656,7 @@ function resolveOwnedSurface(paint, context) {
4118
4656
  }, context.palette, {
4119
4657
  linkHover: context.linkHoverToken,
4120
4658
  ...context.foreground
4121
- });
4659
+ }, { compositeBase: context.compositeBase });
4122
4660
  return {
4123
4661
  kind: "owned",
4124
4662
  paint,
@@ -4153,6 +4691,7 @@ function resolveSurfaceButtons(paint, foreground, context) {
4153
4691
  palette: context.palette,
4154
4692
  colourIndex: context.colourIndex,
4155
4693
  buttonSystem: context.buttonSystem,
4694
+ fallbackToken: context.compositeBase,
4156
4695
  primaryToken: context.buttonContext?.primary ?? (paint.kind === "solid" ? context.buttonSystem?.surfaceContexts?.[paint.token]?.primary : void 0),
4157
4696
  withoutButtonSystem: "reset"
4158
4697
  });
@@ -4179,24 +4718,35 @@ function resolveSectionSurface(background, context) {
4179
4718
  linkHover: context.linkHoverToken,
4180
4719
  ...context.foreground
4181
4720
  }, { compositeBase: context.compositeBase });
4182
- return {
4721
+ const surface = background === null ? { kind: "inherit" } : background.type === "color" ? {
4722
+ kind: "solid",
4723
+ color: background.color,
4724
+ composited: false,
4725
+ foreground: foreground.kind === "known" ? foreground.roles.link : void 0
4726
+ } : background.type === "gradient" ? { kind: "gradient" } : { kind: "image" };
4727
+ const revision = ownSurfaceRevision(context);
4728
+ const result = {
4183
4729
  kind: "section",
4184
4730
  foreground,
4185
4731
  buttonStyles: resolveSurfaceButtonContext({
4186
- surface: background === null ? { kind: "inherit" } : background.type === "color" ? {
4187
- kind: "solid",
4188
- color: background.color,
4189
- composited: false,
4190
- foreground: foreground.kind === "known" ? foreground.roles.link : void 0
4191
- } : background.type === "gradient" ? { kind: "gradient" } : { kind: "image" },
4192
- palette: context.palette,
4193
- colourIndex: context.colourIndex,
4194
- buttonSystem: context.buttonSystem,
4732
+ surface,
4733
+ palette: revision.palette,
4734
+ buttonSystem: revision.buttonSystem,
4195
4735
  primaryToken: sectionPrimaryButtonToken(background, context),
4196
4736
  fallbackToken: context.compositeBase,
4197
4737
  withoutButtonSystem: "inherit"
4198
- }).styles
4199
- };
4738
+ }).styles,
4739
+ proof: sectionProof(background, foreground),
4740
+ revision,
4741
+ textPolicy: surfaceTextPolicy,
4742
+ [resolvedSurfaceBrand]: true
4743
+ };
4744
+ Object.defineProperties(result, {
4745
+ proof: { enumerable: false },
4746
+ revision: { enumerable: false },
4747
+ textPolicy: { enumerable: false }
4748
+ });
4749
+ return freezeOwnedThemeValue(result);
4200
4750
  }
4201
4751
  function sectionPrimaryButtonToken(background, context) {
4202
4752
  if (background?.type !== "color" || typeof background.color !== "string") return void 0;
@@ -4227,15 +4777,246 @@ function resolveTintSurface(spec, context) {
4227
4777
  ...context,
4228
4778
  foreground: base.foreground
4229
4779
  });
4230
- return spec.gradient === "radial" ? {
4780
+ if (spec.gradient !== "radial") return surface;
4781
+ assertTintSamples(surface, spec.base, context.palette);
4782
+ return {
4231
4783
  ...surface,
4232
4784
  tintBase: spec.base
4233
- } : surface;
4785
+ };
4786
+ }
4787
+ /** A sampled gradient may never borrow a proof for just its painted endpoint. */
4788
+ function assertTintSamples(surface, base, palette) {
4789
+ if (surface.paint.kind !== "solid") throw new Error("Tint must paint a solid endpoint");
4790
+ const paint = resolveOpaqueSurfaceHex(surface.paint.token, palette, base);
4791
+ const underlay = resolveOpaqueSurfaceHex(base, palette, "background");
4792
+ if (!paint || !underlay) throw new Error("Tint needs a measurable underlay");
4793
+ const samples = [
4794
+ 0,
4795
+ .25,
4796
+ .5,
4797
+ .75,
4798
+ 1
4799
+ ].map((alpha) => compositeHex(paint, alpha, underlay));
4800
+ Object.entries(surface.foreground).forEach(([role, token]) => {
4801
+ if (!samples.every((sample) => {
4802
+ const ink = resolveOpaqueSurfaceHex(token, palette, sample);
4803
+ return ink !== null && contrastRatio(ink, sample) >= (role === "heading" ? 3 : 4.5);
4804
+ })) throw new RangeError(`No checked tint gradient for ${role} on ${base}`);
4805
+ });
4234
4806
  }
4235
4807
  function hexToRgba(hex, alpha) {
4236
4808
  const { r, g, b } = hexToRgb(hex);
4237
4809
  return `rgba(${r}, ${g}, ${b}, ${alpha})`;
4238
4810
  }
4811
+ const foregroundInputSchema = z.object({
4812
+ text: z.string().nullable().optional(),
4813
+ heading: z.string().nullable().optional(),
4814
+ link: z.string().nullable().optional(),
4815
+ linkHover: z.string().nullable().optional(),
4816
+ supporting: z.string().nullable().optional()
4817
+ });
4818
+ const paintInputSchema = z.discriminatedUnion("kind", [
4819
+ z.object({
4820
+ kind: z.literal("solid"),
4821
+ token: z.string(),
4822
+ foregroundToken: z.string().optional()
4823
+ }),
4824
+ z.object({
4825
+ kind: z.literal("gradient"),
4826
+ foregroundToken: z.string().optional()
4827
+ }),
4828
+ z.object({ kind: z.literal("transparent") })
4829
+ ]);
4830
+ const buttonInputSchema = z.object({ primary: opaqueButtonColourTokenSchema });
4831
+ const surfaceSpecSchema = z.discriminatedUnion("kind", [
4832
+ z.object({
4833
+ kind: z.literal("recipe"),
4834
+ intent: z.enum([
4835
+ "base",
4836
+ "muted-band",
4837
+ "accent-band",
4838
+ "brand-depth-band"
4839
+ ])
4840
+ }),
4841
+ z.object({
4842
+ kind: z.literal("paint"),
4843
+ paint: paintInputSchema
4844
+ }),
4845
+ z.object({
4846
+ kind: z.literal("token"),
4847
+ token: z.string(),
4848
+ foreground: foregroundInputSchema.optional(),
4849
+ buttonContext: buttonInputSchema.optional()
4850
+ }),
4851
+ z.object({
4852
+ kind: z.literal("tint"),
4853
+ base: z.string(),
4854
+ source: z.enum(["text", "mark"]),
4855
+ opacity: z.number().finite(),
4856
+ gradient: z.literal("radial").optional()
4857
+ })
4858
+ ]);
4859
+ const surfaceTransportSchema = z.object({ $surface: z.object({
4860
+ spec: surfaceSpecSchema,
4861
+ context: z.object({
4862
+ palette: z.record(z.string(), z.string()),
4863
+ buttonSystem: buttonSystemSchema.optional(),
4864
+ foreground: foregroundInputSchema.optional(),
4865
+ linkHoverToken: z.string().optional(),
4866
+ compositeBase: z.string().optional(),
4867
+ buttonContext: buttonInputSchema.optional()
4868
+ })
4869
+ }) });
4870
+ /** Deserialised output is never evidence: parse the inputs and rerun their owner. */
4871
+ function parseResolvedSurface(value) {
4872
+ if (isResolvedSurface(value)) return value;
4873
+ const { spec, context } = surfaceTransportSchema.parse(value).$surface;
4874
+ return resolveSurface(spec, {
4875
+ ...context,
4876
+ buttonSystem: context.buttonSystem
4877
+ });
4878
+ }
4879
+ /** Wire only the owner inputs; parsed CSS/results are recomputed, never trusted. */
4880
+ function serializeResolvedSurface(surface) {
4881
+ requireResolvedSurface(surface);
4882
+ const inputs = surfaceTransports.get(surface);
4883
+ if (!inputs) throw new Error("Missing surface inputs");
4884
+ return { $surface: inputs };
4885
+ }
4886
+ function certifySurface(spec, context) {
4887
+ const revision = ownSurfaceRevision(context);
4888
+ const inputs = {
4889
+ spec: ownedThemeSnapshot(spec),
4890
+ context: Object.freeze({
4891
+ ...revision,
4892
+ ...ownedThemeSnapshot({
4893
+ foreground: context.foreground,
4894
+ linkHoverToken: context.linkHoverToken,
4895
+ compositeBase: context.compositeBase,
4896
+ buttonContext: context.buttonContext
4897
+ })
4898
+ })
4899
+ };
4900
+ const decision = resolveSurfaceSpec(inputs.spec, inputs.context);
4901
+ const result = Object.assign(decision, {
4902
+ [resolvedSurfaceBrand]: true,
4903
+ proof: surfaceProof(decision, spec),
4904
+ revision,
4905
+ textPolicy: surfaceTextPolicy,
4906
+ $surface: inputs
4907
+ });
4908
+ Object.defineProperties(result, {
4909
+ proof: { enumerable: false },
4910
+ revision: { enumerable: false },
4911
+ textPolicy: { enumerable: false }
4912
+ });
4913
+ surfaceOwners.add(result);
4914
+ surfaceTransports.set(result, inputs);
4915
+ return freezeOwnedThemeValue(result);
4916
+ }
4917
+ function surfaceProof(decision, spec) {
4918
+ if (decision.kind === "inherit") return "inherit";
4919
+ if (decision.contrast.kind === "unmeasured") return "unproven-media";
4920
+ if (spec.kind === "tint") return spec.gradient === "radial" ? "checked-gradient-or-scrim" : "checked-composited";
4921
+ return decision.paint.kind === "solid" && /\/|rgba\(/.test(decision.paint.token) ? "checked-composited" : "checked-solid";
4922
+ }
4923
+ function sectionProof(background, foreground) {
4924
+ if (background === null) return "inherit";
4925
+ if (foreground.kind !== "known" || foreground.provenance.kind !== "measured") return "unproven-media";
4926
+ return /\/|rgba\(/.test(background.color ?? "") ? "checked-composited" : "checked-solid";
4927
+ }
4928
+ /** One theme revision per JSON envelope, shared by all nested Look slots. */
4929
+ function serializeSurfaceTree(value) {
4930
+ const revisions = [];
4931
+ const indices = /* @__PURE__ */ new Map();
4932
+ const revisionIndex = (revision) => {
4933
+ const index = indices.get(revision) ?? revisions.length;
4934
+ if (!indices.has(revision)) {
4935
+ indices.set(revision, index);
4936
+ revisions.push(revision);
4937
+ }
4938
+ return index;
4939
+ };
4940
+ const encode = (item) => {
4941
+ const revision = isSurfaceTreeRecord(item) ? surfaceRevisionOwners.get(item) : void 0;
4942
+ if (revision) return { $surfaceRevision: revisionIndex(revision) };
4943
+ if (isResolvedSurface(item)) {
4944
+ const input = serializeResolvedSurface(item).$surface;
4945
+ const index = revisionIndex(item.revision);
4946
+ const { palette: _palette, buttonSystem: _buttons, ...context } = input.context;
4947
+ return { $surface: {
4948
+ spec: input.spec,
4949
+ context,
4950
+ revision: index
4951
+ } };
4952
+ }
4953
+ return mapSurfaceTreeChildren(item, encode);
4954
+ };
4955
+ const encoded = encode(value);
4956
+ return revisions.length === 0 ? encoded : { $surfaceTransport: {
4957
+ revisions,
4958
+ value: encoded
4959
+ } };
4960
+ }
4961
+ const surfaceEnvelopeSchema = z.object({ $surfaceTransport: z.object({
4962
+ revisions: z.array(z.object({
4963
+ palette: z.record(z.string(), z.string()),
4964
+ buttonSystem: buttonSystemSchema.optional()
4965
+ })),
4966
+ value: z.unknown()
4967
+ }) });
4968
+ const surfaceReferenceSchema = z.object({ $surface: z.object({
4969
+ spec: surfaceSpecSchema,
4970
+ revision: z.number().int().nonnegative(),
4971
+ context: z.object({
4972
+ foreground: foregroundInputSchema.optional(),
4973
+ linkHoverToken: z.string().optional(),
4974
+ compositeBase: z.string().optional(),
4975
+ buttonContext: buttonInputSchema.optional()
4976
+ })
4977
+ }) });
4978
+ const surfaceRevisionReferenceSchema = z.object({ $surfaceRevision: z.number().int().nonnegative() });
4979
+ /** Recreate owner results before any island's ordinary schema consumes them. */
4980
+ function parseSurfaceTree(value) {
4981
+ if (isSurfaceTransportLeaf(value)) return value;
4982
+ if (!isSurfaceTreeRecord(value) || !("$surfaceTransport" in value)) return mapSurfaceTreeChildren(value, parseSurfaceTree);
4983
+ const envelope = surfaceEnvelopeSchema.parse(value).$surfaceTransport;
4984
+ const revisions = envelope.revisions.map((revision) => {
4985
+ const owned = ownedThemeSnapshot({
4986
+ palette: revision.palette,
4987
+ buttonSystem: revision.buttonSystem
4988
+ });
4989
+ registerOwnedRevisionInputs(owned);
4990
+ return ownSurfaceRevision(owned);
4991
+ });
4992
+ const decode = (item) => {
4993
+ if (isSurfaceTreeRecord(item) && "$surfaceRevision" in item) {
4994
+ const revision = revisions[surfaceRevisionReferenceSchema.parse(item).$surfaceRevision];
4995
+ if (!revision) throw new Error("Unknown surface revision");
4996
+ return revision;
4997
+ }
4998
+ if (isSurfaceTreeRecord(item) && "$surface" in item) {
4999
+ const request = surfaceReferenceSchema.parse(item).$surface;
5000
+ const revision = revisions[request.revision];
5001
+ if (!revision) throw new Error("Unknown surface revision");
5002
+ return resolveSurface(request.spec, {
5003
+ ...revision,
5004
+ ...request.context,
5005
+ buttonSystem: revision.buttonSystem
5006
+ });
5007
+ }
5008
+ return mapSurfaceTreeChildren(item, decode);
5009
+ };
5010
+ return decode(envelope.value);
5011
+ }
5012
+ function isSurfaceTreeRecord(value) {
5013
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5014
+ }
5015
+ function mapSurfaceTreeChildren(value, map) {
5016
+ if (Array.isArray(value)) return value.map(map);
5017
+ if (value instanceof Date) return value;
5018
+ return isSurfaceTreeRecord(value) ? Object.fromEntries(Object.entries(value).map(([key, item]) => [key, map(item)])) : value;
5019
+ }
4239
5020
  //#endregion
4240
5021
  //#region ../theme-core/src/site-styles/types.ts
4241
5022
  /**
@@ -5458,6 +6239,205 @@ function getDefaultCardVariants() {
5458
6239
  ];
5459
6240
  }
5460
6241
  //#endregion
6242
+ //#region ../media-core/src/identifiers.ts
6243
+ function slugifyMediaIdentifier(value) {
6244
+ return value.toLowerCase().trim().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-");
6245
+ }
6246
+ function parseMediaIdentifier(value) {
6247
+ if (typeof value !== "string") return err({ kind: "not_string" });
6248
+ const trimmed = value.trim();
6249
+ if (trimmed.length === 0) return err({ kind: "empty_identifier" });
6250
+ const normalized = slugifyMediaIdentifier(trimmed);
6251
+ if (normalized.length === 0) return err({
6252
+ kind: "empty_after_normalization",
6253
+ value
6254
+ });
6255
+ return ok(normalized);
6256
+ }
6257
+ /**
6258
+ * Admits identifiers read from trusted persistence without repairing dirty data in memory.
6259
+ * User input should use parseMediaIdentifier, which intentionally canonicalizes it.
6260
+ */
6261
+ function parseCanonicalMediaIdentifier(value) {
6262
+ if (typeof value !== "string") return err({ kind: "not_string" });
6263
+ const parsed = parseMediaIdentifier(value);
6264
+ if (!parsed.ok) return parsed;
6265
+ if (value !== parsed.value) return err({
6266
+ kind: "non_canonical_identifier",
6267
+ value,
6268
+ canonical: parsed.value
6269
+ });
6270
+ return parsed;
6271
+ }
6272
+ //#endregion
6273
+ //#region ../media-core/src/mediaIdentifierSchema.ts
6274
+ /** Strict stored-reference admission delegates the canonical identifier decision. */
6275
+ const mediaIdentifierSchema = z.string().transform((value, context) => {
6276
+ const parsed = parseCanonicalMediaIdentifier(value);
6277
+ if (parsed.ok) return parsed.value;
6278
+ context.addIssue({
6279
+ code: "custom",
6280
+ message: "Expected a canonical media identifier"
6281
+ });
6282
+ return z.NEVER;
6283
+ });
6284
+ //#endregion
6285
+ //#region ../media-core/src/mediaKinds.ts
6286
+ const mediaTypeDiscriminants = [
6287
+ "image",
6288
+ "video",
6289
+ "audio",
6290
+ "document",
6291
+ "spreadsheet",
6292
+ "archive"
6293
+ ];
6294
+ //#endregion
6295
+ //#region ../media-core/src/renderableMediaAsset.ts
6296
+ /** Shared identifier indexing for admitted site-scoped projections. */
6297
+ function buildMediaIdentifierIndex(assets) {
6298
+ const index = new Map(assets.map((asset) => [asset.identifier, asset]));
6299
+ if (index.size !== assets.length) throw new Error("Duplicate media identifier in a site asset list");
6300
+ return index;
6301
+ }
6302
+ /** Index already admitted projections, including runtime registration updates. */
6303
+ function indexRenderableMediaAssets(assets) {
6304
+ if (!assets.length) return void 0;
6305
+ const byId = new Map(assets.map((asset) => [asset.id, asset]));
6306
+ const byIdentifier = buildMediaIdentifierIndex(assets);
6307
+ if (byId.size !== assets.length) throw new Error("Duplicate media asset identity in a site asset list");
6308
+ return {
6309
+ assets,
6310
+ byId,
6311
+ byIdentifier
6312
+ };
6313
+ }
6314
+ /** A portable reference never uses an incidental UUID, URL or storage snapshot for identity. */
6315
+ function resolveManagedMediaReference(reference, index) {
6316
+ const asset = index?.byIdentifier.get(reference.identifier);
6317
+ return asset ? {
6318
+ kind: "resolved",
6319
+ reference,
6320
+ asset
6321
+ } : {
6322
+ kind: "missing",
6323
+ reference
6324
+ };
6325
+ }
6326
+ //#endregion
6327
+ //#region ../media-core/src/renderableMediaAssetAdmission.ts
6328
+ const mediaAssetIdSchema = z.string().transform((value, context) => {
6329
+ const parsed = parseMediaAssetId(value);
6330
+ if (parsed.ok) return parsed.value;
6331
+ context.addIssue({
6332
+ code: "custom",
6333
+ message: "Expected a media asset ID"
6334
+ });
6335
+ return z.NEVER;
6336
+ });
6337
+ const nonemptyStorageValue = z.string().refine((value) => value.trim().length > 0);
6338
+ const renderableMediaAssetSchema = z.object({
6339
+ id: mediaAssetIdSchema,
6340
+ identifier: mediaIdentifierSchema,
6341
+ storageBucket: nonemptyStorageValue,
6342
+ storagePath: nonemptyStorageValue,
6343
+ mimeType: nonemptyStorageValue,
6344
+ filename: z.string().optional(),
6345
+ width: z.number().positive().nullable(),
6346
+ height: z.number().positive().nullable()
6347
+ });
6348
+ /** Admission precedes the identifier-only runtime resolution decision. */
6349
+ function buildRenderableMediaAssetIndex(assets) {
6350
+ if (!assets?.length) return void 0;
6351
+ return indexRenderableMediaAssets(assets.map((asset) => renderableMediaAssetSchema.parse(asset)));
6352
+ }
6353
+ //#endregion
6354
+ //#region ../media-core/src/media.ts
6355
+ const hotspotSchema = z.object({
6356
+ x: z.number().min(0).max(1),
6357
+ y: z.number().min(0).max(1),
6358
+ radius: z.number().optional()
6359
+ });
6360
+ const rotationSchema = z.union([
6361
+ z.literal(0),
6362
+ z.literal(90),
6363
+ z.literal(180),
6364
+ z.literal(270)
6365
+ ]);
6366
+ const rectSchema = z.tuple([
6367
+ z.number(),
6368
+ z.number(),
6369
+ z.number(),
6370
+ z.number()
6371
+ ]);
6372
+ const aspectCropSchema = z.object({
6373
+ aspect: z.preprocess((value) => value == null ? void 0 : value, z.string().optional()),
6374
+ rect: z.preprocess((value) => value == null ? void 0 : value, rectSchema.optional()),
6375
+ hotspot: z.preprocess((value) => value == null ? void 0 : value, hotspotSchema.optional()),
6376
+ rotation: z.preprocess((value) => value == null ? void 0 : value, rotationSchema.optional())
6377
+ });
6378
+ const transformSchema = z.object({
6379
+ aspectCrops: z.preprocess((value) => {
6380
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
6381
+ return value;
6382
+ }, z.record(z.string(), aspectCropSchema.catch({}))).optional(),
6383
+ rect: rectSchema.optional(),
6384
+ hotspot: hotspotSchema.optional(),
6385
+ rotation: rotationSchema.optional()
6386
+ });
6387
+ const mediaPosterSchema = z.discriminatedUnion("tag", [z.object({
6388
+ tag: z.literal("media"),
6389
+ identifier: mediaIdentifierSchema
6390
+ }).strict(), z.object({
6391
+ tag: z.literal("external-src"),
6392
+ src: z.string().url()
6393
+ }).strict()]);
6394
+ const mediaUsageShape = {
6395
+ purpose: z.string().optional(),
6396
+ placeholder: z.boolean().default(true).optional(),
6397
+ alt: z.string().optional(),
6398
+ filename: z.string().optional(),
6399
+ width: z.number().optional(),
6400
+ height: z.number().optional(),
6401
+ poster: mediaPosterSchema.optional(),
6402
+ transform: transformSchema.optional()
6403
+ };
6404
+ const environmentExclusions = {
6405
+ assetId: z.never().optional(),
6406
+ id: z.never().optional(),
6407
+ src: z.never().optional(),
6408
+ storageBucket: z.never().optional(),
6409
+ storagePath: z.never().optional(),
6410
+ mimeType: z.never().optional()
6411
+ };
6412
+ const mediaBaseSchema = z.object({
6413
+ ...mediaUsageShape,
6414
+ ...environmentExclusions,
6415
+ identifier: mediaIdentifierSchema
6416
+ }).strict();
6417
+ const imageMediaSchema = mediaBaseSchema.extend({ type: z.literal("image") });
6418
+ const videoMediaSchema = mediaBaseSchema.extend({ type: z.literal("video") });
6419
+ const mediaSchema = mediaBaseSchema.extend({ type: z.enum(mediaTypeDiscriminants) });
6420
+ const persistableMediaSchema = mediaSchema;
6421
+ const externalMediaSchema = z.object({
6422
+ ...mediaUsageShape,
6423
+ ...environmentExclusions,
6424
+ type: z.enum(mediaTypeDiscriminants),
6425
+ src: z.string().min(1),
6426
+ identifier: z.never().optional()
6427
+ }).strict();
6428
+ const assetMediaSchema = z.object({
6429
+ ...mediaUsageShape,
6430
+ ...environmentExclusions,
6431
+ type: z.enum(mediaTypeDiscriminants),
6432
+ asset: renderableMediaAssetSchema,
6433
+ identifier: z.never().optional()
6434
+ }).strict();
6435
+ const runtimeMediaSchema = z.union([
6436
+ mediaSchema,
6437
+ externalMediaSchema,
6438
+ assetMediaSchema
6439
+ ]);
6440
+ //#endregion
5461
6441
  //#region ../theme-core/src/site-styles/rawStyleFields.ts
5462
6442
  const themeV2RuntimeStyleFieldNames = [
5463
6443
  "_frameStyles",
@@ -14525,4 +15505,4 @@ z.object({
14525
15505
  themes: z.array(themeSchema).length(3)
14526
15506
  });
14527
15507
  //#endregion
14528
- export { NAV_LINK_TEXT_SIZE_MAP as $, hexToRgb as $n, surfaceDecorationColors as $t, RESOLVED_BUTTON_DISABLED_DECLARATIONS as A, surfaceForegroundInputFromResolved as An, asPageFlowPresetId as At, headerInteractionPaletteValues as B, resolveConcreteColorHex as Bn, headingDecorationColorTokenValues as Bt, ACCORDION_SPACING_MAP as C, selectLogoVariant as Cn, asBoundaryOptionId as Ct, ICON_SIZE_PX as D, DEFAULT_SURFACE_TEXT_COLOR as Dn, asDesignPageId as Dt, ICON_CONFIG as E, defaultThemeTokens as En, asDesignEntryId as Et, themeButtonExtraClassesWithTrailingIcon as F, isOnColorBackgroundCandidateToken as Fn, defineFrameCapability as Ft, buttonStyleSelectionSchema as G, paletteValueKey as Gn, panelFrame as Gt, brandDisplayModeValues as H, hexColorSchema as Hn, makeBoundaryId as Ht, themeButtonSizeClassName as I, onColorTokenName as In, eventListTreatmentValues as It, generateInteractiveChildInheritanceCSS as J, parseThemeColorToken as Jn, testimonialsCompositionTreatmentValues as Jt, generateEffectsCSS as K, paletteValueKeySchema as Kn, plainFrame as Kt, themeButtonVariantClassNames as L, getTextColorForBackground as Ln, eyebrowTreatmentValues as Lt, resolvedButtonFocusDeclarations as M, surfaceForegroundValue as Mn, assertNever as Mt, generateDefaultButtonSystem as N, surfaceForegroundValueWithOpacity as Nn, defineBlockDesignCapability as Nt, generateButtonActionLayoutCss as O, SURFACE_FOREGROUND_CSS_VARS as On, asDesignSystemTemplateId as Ot, parseThemeButtonVariantId as P, expandPalette as Pn, defineExactCatalog as Pt, NAV_LINK_PADDING_X_MAP as Q, featuresFromHex as Qn, resolveSurface as Qt, parseThemeForPersistence as R, contrastRatio as Rn, featureCardCompositionTreatmentValues as Rt, ACCORDION_OPEN_ACCENT_THICKNESS as S, unsafeAsOpaqueButtonColourToken as Sn, asBlockOrderIndex as St, ACCORDION_TRIGGER_LETTER_SPACING as T, buildThemeTokens as Tn, asDesignBoundaryId as Tt, logoSizePolicyValues as U, paletteColorsSchema as Un, noHeadingDecoration as Ut, headerInteractionQuietPalette as V, resolveOpaqueSurfaceHex as Vn, introCompositionTreatmentValues as Vt, defaultButtonStyleSelectionFor as W, paletteModeSchema as Wn, offeringsPreviewCompositionTreatmentValues as Wt, NAV_LINK_LETTER_SPACING_MAP as X, parseBlockColorToken as Xn, toNonEmptyReadonlyArray as Xt, NAV_LINK_BORDER_RADIUS_MAP as Y, themeColorShadeSteps as Yn, tileTreatmentValues as Yt, NAV_LINK_PADDING_MAP as Z, parseColorTokenParts as Zn, visibleHeadingDecorationFamilyValues as Zt, parseCustomCssRules as _, resolveThemeColorReferenceValue as _n, cardRoleValues as _t, generateMobileOverlayBackdropFilterFix as a, borderColorStyle as an, boxBackgroundSchema as at, INPUT_SPACING_MAP as b, PUBLIC_BUTTON_ROLES as bn, asAppearancePresetId as bt, MQ_LG_UP as c, rgbColorValue as cn, siteChromeBackgroundOverrideOwner as ct, MQ_SM_UP as d, opaqueSurfaceContextFromTheme as dn, generateCardCoreCss as dt, resolveSurfaceForeground as en, rgbToHex as er, navLinkHoverColorCandidate as et, MQ_TABLET_ONLY as f, opaqueSurfaceDeclarations as fn, getDefaultCardVariants as ft, parseBlockCustomCssRules as g, resolveOnColorForThemeToken as gn, cardRoleSchema as gt, getComponentShadowVar as h, isCssColorLiteral as hn, generateShadowValue as ht, generateHeaderScrollTreatmentStyles as i, backgroundColorStyle as in, boxBackgroundOverlaySchema as it, resolvedButtonColourDeclarations as j, surfaceForegroundStyle as jn, asSiteStyleId as jt, generateButtonCss as k, surfaceForegroundDeclarations as kn, asLayoutVariantKey as kt, MQ_MD_DOWN as l, textColorStyle as ln, stripStaleTransitionStyleGroup as lt, getComponentBorderWidthPx as m, formatButtonColourContractError as mn, renderCssDeclarations as mt, headerPositioningValues as n, planForegroundHover as nn, navLinkOwnsUnderline as nt, getHeaderPaintTargets as o, cssVarValue as on, runtimeBoxBackgroundSchema as ot, headerVariantValues as p, compileButtonColourStates as pn, generateCardCss as pt, generateBaseInteractiveCSS as q, requirePaletteColorsFromEntries as qn, requireNonEmptyReadonlyArray as qt, themeSchema as r, TokenResolver as rn, navEffectPolicy as rt, renderHeaderPaintTargetRules as s, mergeStyles as sn, pageDesignEditorBackgroundOverrideOwner as st, corners as t, safeTokenOr as tn, navLinkOwnsHoverForeground as tt, MQ_SM_DOWN as u, textColorValue as un, themeV2RuntimeStyleFieldNames as ut, FONT_WEIGHT_MAP as v, resolveTokenOrCssColorValue as vn, cardVariantRoleValues as vt, ACCORDION_TRIGGER_FONT_SCALE as w, surfaceToneFromForegroundToken as wn, asDesignBlockId as wt, LABEL_FONT_SIZE_MAP as x, buttonVariantIdSchema as xn, asBlockContentVersionId as xt, INPUT_FONT_SIZE_MAP as y, generateShadowValue$1 as yn, normalizeCardRole as yt, skinTokenCssVars as z, relativeLuminance as zn, flushPanelFrame as zt };
15508
+ export { NAV_LINK_TEXT_SIZE_MAP as $, resolveOpaqueSurfaceHex as $n, noHeadingDecoration as $t, RESOLVED_BUTTON_DISABLED_DECLARATIONS as A, resolveOnColorForThemeToken as An, asAppearancePresetId as At, headerInteractionPaletteValues as B, SURFACE_FOREGROUND_CSS_VARS as Bn, asPageFlowPresetId as Bt, ACCORDION_SPACING_MAP as C, textColorValue as Cn, unsafeAsStoragePath as Cr, generateCardCss as Ct, ICON_SIZE_PX as D, compileButtonColourStates as Dn, cardRoleValues as Dt, ICON_CONFIG as E, opaqueSurfaceDeclarations as En, cardRoleSchema as Et, themeButtonExtraClassesWithTrailingIcon as F, selectLogoVariant as Fn, asDesignBoundaryId as Ft, buttonStyleSelectionSchema as G, surfaceForegroundValueWithOpacity as Gn, defineFrameCapability as Gt, brandDisplayModeValues as H, surfaceForegroundInputFromResolved as Hn, assertNever as Ht, themeButtonSizeClassName as I, surfaceToneFromForegroundToken as In, asDesignEntryId as It, generateInteractiveChildInheritanceCSS as J, onColorTokenName as Jn, featureCardCompositionTreatmentValues as Jt, generateEffectsCSS as K, expandPalette as Kn, eventListTreatmentValues as Kt, themeButtonVariantClassNames as L, buildThemeTokens as Ln, asDesignPageId as Lt, resolvedButtonFocusDeclarations as M, resolveTokenOrCssColorValue as Mn, asBlockOrderIndex as Mt, generateDefaultButtonSystem as N, generateShadowValue$1 as Nn, asBoundaryOptionId as Nt, generateButtonActionLayoutCss as O, formatButtonColourContractError as On, cardVariantRoleValues as Ot, parseThemeButtonVariantId as P, PUBLIC_BUTTON_ROLES as Pn, asDesignBlockId as Pt, NAV_LINK_PADDING_X_MAP as Q, resolveConcreteColorHex as Qn, makeBoundaryId as Qt, parseThemeForPersistence as R, defaultThemeTokens as Rn, asDesignSystemTemplateId as Rt, ACCORDION_OPEN_ACCENT_THICKNESS as S, textColorStyle as Sn, unsafeAsStorageBucketName as Sr, getDefaultCardVariants as St, ACCORDION_TRIGGER_LETTER_SPACING as T, opaqueSurfaceContextFromTheme as Tn, ok as Tr, generateShadowValue as Tt, logoSizePolicyValues as U, surfaceForegroundStyle as Un, defineBlockDesignCapability as Ut, headerInteractionQuietPalette as V, surfaceForegroundDeclarations as Vn, asSiteStyleId as Vt, defaultButtonStyleSelectionFor as W, surfaceForegroundValue as Wn, defineExactCatalog as Wt, NAV_LINK_LETTER_SPACING_MAP as X, gradientScrimSamples as Xn, headingDecorationColorTokenValues as Xt, NAV_LINK_BORDER_RADIUS_MAP as Y, getTextColorForBackground as Yn, flushPanelFrame as Yt, NAV_LINK_PADDING_MAP as Z, scrimTone as Zn, introCompositionTreatmentValues as Zt, parseCustomCssRules as _, backgroundColorStyle as _n, parseEventSeriesId as _r, resolveManagedMediaReference as _t, generateMobileOverlayBackdropFilterFix as a, tileTreatmentValues as an, paletteValueKey as ar, boxBackgroundSchema as at, INPUT_SPACING_MAP as b, mergeStyles as bn, parseUserId as br, parseMediaIdentifier as bt, MQ_LG_UP as c, parseResolvedSurface as cn, buttonVariantIdSchema as cr, siteChromeBackgroundOverrideOwner as ct, MQ_SM_UP as d, serializeSurfaceTree as dn, themeColorShadeSteps as dr, mediaSchema as dt, offeringsPreviewCompositionTreatmentValues as en, featuresFromHex as er, navLinkHoverColorCandidate as et, MQ_TABLET_ONLY as f, surfaceDecorationColors as fn, parseBlockColorToken as fr, persistableMediaSchema as ft, parseBlockCustomCssRules as g, TokenResolver as gn, parseEventOfferingId as gr, indexRenderableMediaAssets as gt, getComponentShadowVar as h, planForegroundHover as hn, parseContentVersionId as hr, renderableMediaAssetSchema as ht, generateHeaderScrollTreatmentStyles as i, testimonialsCompositionTreatmentValues as in, paletteModeSchema as ir, boxBackgroundOverlaySchema as it, resolvedButtonColourDeclarations as j, resolveThemeColorReferenceValue as jn, asBlockContentVersionId as jt, generateButtonCss as k, isCssColorLiteral as kn, normalizeCardRole as kt, MQ_MD_DOWN as l, parseSurfaceTree as ln, unsafeAsOpaqueButtonColourToken as lr, stripStaleTransitionStyleGroup as lt, getComponentBorderWidthPx as m, safeTokenOr as mn, parseApiKeyId as mr, buildRenderableMediaAssetIndex as mt, headerPositioningValues as n, plainFrame as nn, hexColorSchema as nr, navLinkOwnsUnderline as nt, getHeaderPaintTargets as o, toNonEmptyReadonlyArray as on, paletteValueKeySchema as or, runtimeBoxBackgroundSchema as ot, headerVariantValues as p, resolveSurfaceForeground as pn, parseColorTokenParts as pr, runtimeMediaSchema as pt, generateBaseInteractiveCSS as q, isOnColorBackgroundCandidateToken as qn, eyebrowTreatmentValues as qt, themeSchema as r, requireNonEmptyReadonlyArray as rn, paletteColorsSchema as rr, navEffectPolicy as rt, renderHeaderPaintTargetRules as s, visibleHeadingDecorationFamilyValues as sn, requirePaletteColorsFromEntries as sr, pageDesignEditorBackgroundOverrideOwner as st, corners as t, panelFrame as tn, hexToRgb as tr, navLinkOwnsHoverForeground as tt, MQ_SM_DOWN as u, resolveSurface as un, parseThemeColorToken as ur, themeV2RuntimeStyleFieldNames as ut, FONT_WEIGHT_MAP as v, borderColorStyle as vn, parseSiteId as vr, mediaIdentifierSchema as vt, ACCORDION_TRIGGER_FONT_SCALE as w, mapDrawingStyle as wn, err as wr, renderCssDeclarations as wt, LABEL_FONT_SIZE_MAP as x, rgbColorValue as xn, unsafeAsMediaAssetId as xr, generateCardCoreCss as xt, INPUT_FONT_SIZE_MAP as y, cssVarValue as yn, parseSiteTermsVersionId as yr, parseCanonicalMediaIdentifier as yt, skinTokenCssVars as z, DEFAULT_SURFACE_TEXT_COLOR as zn, asLayoutVariantKey as zt };