@riverbankcms/sdk 0.180.0 → 0.182.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 (232) hide show
  1. package/dist/_dts/{BlocksIslandsHydrator-DC_AvZwy.d.ts → BlocksIslandsHydrator-Bvw2bUif.d.ts} +1 -1
  2. package/dist/_dts/{Page-DQOxVtp3.d.ts → Page-B2EAT-bE.d.ts} +7 -7
  3. package/dist/_dts/{SdkPreviewMode-DrLgY9_f.d.ts → SdkPreviewMode-D0vww6rh.d.ts} +2 -2
  4. package/dist/_dts/{client-BP7VBRvs.d.ts → client-D6T430bk.d.ts} +56 -70
  5. package/dist/_dts/{content-types-1-K2qi__.d.ts → content-types-wZVWccC6.d.ts} +2 -2
  6. package/dist/_dts/{contracts-Dfqz0Tcu.d.ts → contracts-B-vtOcr8.d.ts} +3 -3
  7. package/dist/_dts/{generatePageMetadata-CSfAqmry.d.ts → generatePageMetadata-CxfwHE6z.d.ts} +2 -2
  8. package/dist/_dts/{index-BeM5Ylwf.d.ts → index-CEyYMhLJ.d.ts} +1 -2
  9. package/dist/_dts/{index-DQr358-m.d.ts → index-CQrb3Ccc.d.ts} +8 -8
  10. package/dist/_dts/{index-DCcxLa8p.d.ts → index-CciRW_w1.d.ts} +2 -2
  11. package/dist/_dts/{index-Blrw2oVk.d.ts → index-Cqxis-nv.d.ts} +1 -1
  12. package/dist/_dts/{index-CB5Csefo.d.ts → index-DIU-wL1M.d.ts} +2 -2
  13. package/dist/_dts/{index-DQBGwBPx.d.ts → index-DqPKdeTk.d.ts} +1 -1
  14. package/dist/_dts/{loadContent-BG2tLGXj.d.ts → loadContent-D0wrxiSp.d.ts} +7 -7
  15. package/dist/_dts/{request-P08l6mkr.d.ts → request-DEwxUSw8.d.ts} +2375 -883
  16. package/dist/_dts/{resolveBlockData-BDHc8lFs.d.ts → resolveBlockData-VaG_MYbN.d.ts} +5 -5
  17. package/dist/_dts/{resolvePageContent-Y3IZBbtL.d.ts → resolvePageContent-DTwklC_v.d.ts} +1 -1
  18. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  19. package/dist/_dts/sdk/src/client/types.d.ts +2 -2
  20. package/dist/_dts/sdk/src/client.d.ts +7 -7
  21. package/dist/_dts/sdk/src/config/index.d.ts +6 -6
  22. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  23. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  24. package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +2 -2
  25. package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
  26. package/dist/_dts/sdk/src/data/types.d.ts +2 -2
  27. package/dist/_dts/sdk/src/gifting/client.d.ts +1 -2
  28. package/dist/_dts/sdk/src/index.d.ts +104 -8
  29. package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
  30. package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
  31. package/dist/_dts/sdk/src/navigation/index.d.ts +3 -3
  32. package/dist/_dts/sdk/src/next/index.d.ts +83 -52
  33. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  34. package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
  35. package/dist/_dts/sdk/src/portal/client.d.ts +43 -56
  36. package/dist/_dts/sdk/src/portal/index.d.ts +3 -18
  37. package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
  38. package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
  39. package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
  40. package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
  41. package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
  42. package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +1 -1
  43. package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +1 -1
  44. package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +4 -4
  45. package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
  46. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  47. package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
  48. package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
  49. package/dist/_dts/sdk/src/routing/index.d.ts +6 -6
  50. package/dist/_dts/sdk/src/server.d.ts +5 -5
  51. package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
  52. package/dist/_dts/sdk/src/theme/index.d.ts +1 -1
  53. package/dist/_dts/{serviceBookingOutline-BvtNagjw.d.ts → serviceBookingOutline-DtQuFlID.d.ts} +6 -6
  54. package/dist/_dts/{types-DpEAnP4F.d.ts → types-B3RjeBLV.d.ts} +2 -2
  55. package/dist/_dts/{types-HAy1-Jjo.d.ts → types-BvUSGQrw.d.ts} +3 -3
  56. package/dist/_dts/{types-BrK6SS5c.d.ts → types-CkRFtBqd.d.ts} +7 -7
  57. package/dist/_dts/{validation-D6q3tOBA.d.ts → validation-BZA3DhcV.d.ts} +4 -4
  58. package/dist/client/{BlocksIslandsHydrator-DJSmdNUJ.mjs → BlocksIslandsHydrator-CQMf0HdN.mjs} +19 -19
  59. package/dist/client/{BookingMailingListNote-CGxg37zx.mjs → BookingMailingListNote-7kdvuPow.mjs} +93 -18
  60. package/dist/client/{BookingQuestionFields-DXegGSnS.mjs → BookingQuestionFields-BJI7mZuV.mjs} +7 -87
  61. package/dist/client/CalendarAction-D_Glwvz2.mjs +105 -0
  62. package/dist/client/{CalendarNavigationChevron-VfP50sYm.mjs → CalendarNavigationChevron-DPUD6wjy.mjs} +8 -8
  63. package/dist/client/{CheckboxChoice-BZPLCgTU.mjs → CheckboxChoice-C8i4NraK.mjs} +1 -1
  64. package/dist/client/{DemoBookingPortalAccess-0Ua44F1j.mjs → DemoBookingPortalAccess-8kwNF9HN.mjs} +9 -6
  65. package/dist/client/{EventCalendar.client-CrpiyDSP.mjs → EventCalendar.client-Dhb14bcC.mjs} +10 -10
  66. package/dist/client/{EventCombined.client-D0me9wnz.mjs → EventCombined.client-C1jEZBN9.mjs} +60 -10
  67. package/dist/client/{EventEmbeddedCheckoutStep-BDnicDM6.mjs → EventEmbeddedCheckoutStep-BGkbUhuw.mjs} +1 -1
  68. package/dist/client/{EventItem-CJITrGkF.mjs → EventItem-Bb0ppG2N.mjs} +9 -177
  69. package/dist/client/{EventListWeekNavigation-BlEm_xjq.mjs → EventListWeekNavigation-DMryCaNV.mjs} +1 -1
  70. package/dist/client/{EventListing.client-BNM_HuS0.mjs → EventListing.client-BuH5kKA3.mjs} +3 -3
  71. package/dist/client/{EventListing.view-CXfb7RRy.mjs → EventListing.view-DsqvuulZ.mjs} +8 -8
  72. package/dist/client/{EventRegistrationPayment-DiD9uYs6.mjs → EventRegistrationPayment-D4FvQSFF.mjs} +555 -502
  73. package/dist/client/{Page-bX7iy_MK.mjs → Page-sV6BJkXX.mjs} +550 -339
  74. package/dist/client/{ProtectedSubmitButton-De6AzhE6.mjs → ProtectedSubmitButton-BNnKuir8.mjs} +1 -1
  75. package/dist/client/{SiteTermsAgreementField-BAdW5DvE.mjs → SiteTermsAgreementField-VfSd6JU-.mjs} +7 -11
  76. package/dist/client/{StepIndicator-DCfdcb7s.mjs → StepIndicator-B6o5B7g3.mjs} +1 -1
  77. package/dist/client/{StepIndicator-DCqorVne.mjs → StepIndicator-BTqO7cJl.mjs} +235 -26
  78. package/dist/client/{ThemedButton-CnSa7o-I.mjs → ThemedButton-PFOhXktM.mjs} +1 -33
  79. package/dist/client/{accessibleSurfaces-Wl8-_OVJ.mjs → accessibleSurfaces-BogaGutk.mjs} +983 -634
  80. package/dist/client/{accordion-wofJY8xY.mjs → accordion-6cuswD_s.mjs} +1 -1
  81. package/dist/client/{booking-form.client-CYl9NrqS.mjs → booking-form.client-BOMe_SKi.mjs} +52 -29
  82. package/dist/client/bookingCalendar--aWnqFDn.mjs +180 -0
  83. package/dist/client/{bookingForm-kgVWtuMe.mjs → bookingForm-DSCH-VHo.mjs} +4 -4
  84. package/dist/client/bookings.mjs +17 -11
  85. package/dist/client/{boxStyleClassNames-CQHWz5gJ.mjs → boxStyleClassNames-BFuqZCfz.mjs} +2 -2
  86. package/dist/client/{carousel-BE1dEFsD.mjs → carousel-CGyQVV1M.mjs} +2 -2
  87. package/dist/client/{carousel.client-DMtGYTTM.mjs → carousel.client-BtLwHefX.mjs} +1 -1
  88. package/dist/client/{cart-BsjsdGZE.mjs → cart-BYOe7MCh.mjs} +3 -3
  89. package/dist/client/{cart.client-DylGUWXY.mjs → cart.client-BKFkaXdV.mjs} +1 -1
  90. package/dist/client/{checkout-B5KxEUDr.mjs → checkout-Dwd7Di77.mjs} +3 -3
  91. package/dist/client/{checkout.client-C98fhch3.mjs → checkout.client-C25hpi-z.mjs} +1 -1
  92. package/dist/client/{checkoutUrls-BMLYTf38.mjs → checkoutUrls-tG788sw0.mjs} +1 -1
  93. package/dist/client/client.mjs +106 -43
  94. package/dist/client/{constants-PfYJsEZF.mjs → constants-DdxFG3Ic.mjs} +1 -2
  95. package/dist/client/{context-DtKdUdkO.mjs → context-Hi1RuYEM.mjs} +753 -373
  96. package/dist/client/{dateFormatting-BaGPvQS3.mjs → dateFormatting-C8vBCHuo.mjs} +15 -25
  97. package/dist/client/{demoPortalMagicLink-B8eDjhuG.mjs → demoPortalMagicLink-BAL5UIDG.mjs} +2 -3
  98. package/dist/client/{enhanceHeaderSection-DvhD-8eE.mjs → enhanceHeaderSection-Dv1Lr9kJ.mjs} +4 -5
  99. package/dist/client/{event-registration.client-Du9a_xAN.mjs → event-registration.client-dB_Z7bb-.mjs} +191 -210
  100. package/dist/client/{eventCalendar-Di9wDfzl.mjs → eventCalendar-CQnRA4Ww.mjs} +4 -4
  101. package/dist/client/{eventCombined-CNW6nBsB.mjs → eventCombined-BDOG1hVp.mjs} +4 -4
  102. package/dist/client/{eventListing-CQMxQ8By.mjs → eventListing-DSVmhy9n.mjs} +4 -4
  103. package/dist/client/{eventRegistration-CprS9k1D.mjs → eventRegistration-CD5mRtEH.mjs} +4 -4
  104. package/dist/client/{form-Zl1_8RJ6.mjs → form-DWnlEVSK.mjs} +3 -3
  105. package/dist/client/{form.client-TaMUys6I.mjs → form.client-D7zmeqNI.mjs} +5 -5
  106. package/dist/client/{form.parts-CpNPbPPM.mjs → form.parts-C-G6N_MK.mjs} +3 -3
  107. package/dist/client/gifting/client.mjs +32 -29
  108. package/dist/client/{gifting-DNVa7-Wj.mjs → gifting-Cn0jidP5.mjs} +4 -4
  109. package/dist/client/{gifting.client-CFUq3GVx.mjs → gifting.client-DVo1YFLs.mjs} +5 -5
  110. package/dist/client/{gifting.parts-CDQvxA4A.mjs → gifting.parts-Bak93gD2.mjs} +2 -2
  111. package/dist/client/{headerSection-Cg6083rn.mjs → headerSection-DjQuj_6v.mjs} +2 -2
  112. package/dist/client/{mediaAssets-B99AP7ai.mjs → mediaAssets-COfQolI3.mjs} +1 -1
  113. package/dist/client/{mediaContext-Fusweriw.mjs → mediaContext-DzvnjYXm.mjs} +1 -1
  114. package/dist/client/{newsletter-form.client-VuL9I96G.mjs → newsletter-form.client-rIYPziZC.mjs} +7 -7
  115. package/dist/client/{newsletter-form.interactive-7Of3eYn0.mjs → newsletter-form.interactive-DVt3enLr.mjs} +181 -155
  116. package/dist/client/{newsletter-form.parts-OBqsfT24.mjs → newsletter-form.parts-CH6dGfdn.mjs} +2 -2
  117. package/dist/client/{newsletterForm-BkJe_RTv.mjs → newsletterForm-Cg8cBDHd.mjs} +3 -3
  118. package/dist/client/{lookSurfaces-gJ3OqPf9.mjs → noop-jesvJXEE.mjs} +403 -275
  119. package/dist/client/portal/client.mjs +12202 -7166
  120. package/dist/client/portalOrders-oEoTvzkW.mjs +596 -0
  121. package/dist/client/portalRoutes-ByyVZfVq.mjs +873 -0
  122. package/dist/client/{product-detail.client-B2hdxqJN.mjs → product-detail.client-5aHq-vuu.mjs} +1 -1
  123. package/dist/client/{product-list.client-CCEgu9rx.mjs → product-list.client-CyAk5rnC.mjs} +1 -1
  124. package/dist/client/{productDetail-CRX_ZRfS.mjs → productDetail-B8aZ2mqY.mjs} +3 -3
  125. package/dist/client/{productList-BAdJ6z5S.mjs → productList-BuLemmod.mjs} +3 -3
  126. package/dist/client/{propsDecoder-BLKAmX0S.mjs → propsDecoder-0Unsqn3R.mjs} +2 -2
  127. package/dist/client/{registry.server-Bj9cmHHF.mjs → registry.server-DzvtVVD0.mjs} +664 -434
  128. package/dist/client/{renderableMediaAssetAdmission-BlfqYLJW.mjs → renderableMediaAssetAdmission-BsOWd9lf.mjs} +1 -1
  129. package/dist/client/rendering/client.mjs +26 -26
  130. package/dist/client/rendering/islands.mjs +1 -1
  131. package/dist/client/rendering.mjs +16 -8
  132. package/dist/client/{richText-coerce-Z45OLLEX.mjs → richText-coerce-Bnng7JFA.mjs} +2 -1
  133. package/dist/client/{routeIslandApiConfig-DHpTTK77.mjs → routeIslandApiConfig-BGfcc9sk.mjs} +1 -1
  134. package/dist/client/{runtimeResponse-DtWSfWSZ.mjs → runtimeResponse-DAPVRToN.mjs} +1 -1
  135. package/dist/client/{runtimeResponse-D2j2-mOk.mjs → runtimeResponse-nXT8VAMl.mjs} +1 -1
  136. package/dist/client/{shop-BKsgxm_-.mjs → shop-GuMqnDL-.mjs} +3 -3
  137. package/dist/client/{shop-commerce-Cbtk_kUW.mjs → shop-commerce-D5bDY1o1.mjs} +53 -16
  138. package/dist/client/{shop-commerce-store-B-rv2p5h.mjs → shop-commerce-store-B7sHnLwI.mjs} +22 -5
  139. package/dist/client/{shop-discount-apply.state-CiCDLNh7.mjs → shop-discount-apply.state-Dos2zdC2.mjs} +2 -2
  140. package/dist/client/{shop.client-Rnqa74Tk.mjs → shop.client-uvj5GDZb.mjs} +17 -39
  141. package/dist/client/{shopShared-BaBfhjCq.mjs → shopShared-3giNWE3H.mjs} +2 -2
  142. package/dist/client/spam-protection.mjs +1 -1
  143. package/dist/client/src-Al4ooTl_.mjs +164 -0
  144. package/dist/client/{src-o7WEvbK1.mjs → src-CmXh3JWs.mjs} +233 -91
  145. package/dist/client/{timetableModel-BOff1Kk5.mjs → timetableModel-GA-hn1qM.mjs} +11 -87
  146. package/dist/client/{shop-add-feedback-DvC2kP1K.mjs → urlParams-C2QHo1Pa.mjs} +1 -42
  147. package/dist/client/{useAvailableSlots-DQJNh10g.mjs → useAvailableSlots-CBneCxbG.mjs} +2 -3
  148. package/dist/client/{useDiscountCodeUi-BcFQRI_7.mjs → useDiscountCodeUi-D0kGF0C7.mjs} +1 -1
  149. package/dist/client/{useEventPagination-BvdcexDC.mjs → useEventPagination-xX8n_Tuu.mjs} +8 -8
  150. package/dist/client/{view-CTBwSpKv.mjs → view-DOyZc-DF.mjs} +4 -4
  151. package/dist/client/{wizardSteps-CWIQyRIw.mjs → wizardSteps-B952ify5.mjs} +1241 -295
  152. package/dist/preview-next/client/{PageSectionToolbar-CG6KwITA.mjs → PageSectionToolbar-BI3UCdpu.mjs} +3 -3
  153. package/dist/preview-next/client/{PreviewEditorSidebar-BGBqrC9m.mjs → PreviewEditorSidebar-jkfLVOgY.mjs} +12 -9
  154. package/dist/preview-next/client/{PreviewEditorUI-Bwkyx28x.mjs → PreviewEditorUI-DwJQs4hM.mjs} +4 -4
  155. package/dist/preview-next/client/{PreviewShell-DB1l6JNU.mjs → PreviewShell-BAxAkuz8.mjs} +5 -5
  156. package/dist/preview-next/client/{SdkPreviewModeRuntime-Bs6Cwzr3.mjs → SdkPreviewModeRuntime-0UVB-39f.mjs} +68 -17
  157. package/dist/preview-next/client/{previewAssistantSlot-T-oDD_Dd.mjs → previewAssistantSlot-BgiYk3PB.mjs} +7347 -3516
  158. package/dist/preview-next/client/{previewChromeRoot-BeukcDRy.mjs → previewChromeRoot-tieNdF3E.mjs} +1 -1
  159. package/dist/preview-next/client/runtime.mjs +3 -3
  160. package/dist/preview-next/client/{sdk-runtime-ceDW_9q2.mjs → sdk-runtime-DXb_Evl0.mjs} +2 -2
  161. package/dist/preview-next/client/{siteStyleAccess-CCB9bScO.mjs → siteStyleAccess-BlN0jt2c.mjs} +3 -3
  162. package/dist/preview-next/client/{useAutosaveStatus-D4o0CKq7.mjs → useAutosaveStatus-BUEPA4oL.mjs} +1 -1
  163. package/dist/preview-next/client/{useOpenBlockForSetup-Seccrvwu.mjs → useOpenBlockForSetup-BVfr5P--.mjs} +1 -1
  164. package/dist/preview-next/container-responsive.css +203 -174
  165. package/dist/preview-next/keepAlive.mjs +1 -1
  166. package/dist/preview-next/middleware.mjs +1 -1
  167. package/dist/preview-next/{route-contract-FwFj8zGL.mjs → route-contract-BHTBA48n.mjs} +90 -37
  168. package/dist/server/{Block.shared-D6WrRCxX.mjs → Block.shared-hGoyEdjJ.mjs} +5 -5
  169. package/dist/server/{ThemeScopeCore-BQzjDQ2q.mjs → ThemeScopeCore-BfUCTOwj.mjs} +160 -142
  170. package/dist/server/{accessibleSurfaces-CM3QANtw.mjs → accessibleSurfaces-Dskni4Xj.mjs} +94 -330
  171. package/dist/server/accordions-By_0Ykks.mjs +111 -0
  172. package/dist/server/{bindings-CS6ih1Yc.mjs → bindings-DMJH4bvo.mjs} +7 -7
  173. package/dist/server/{client-m0ylCj_f.mjs → client-DrwlRNAH.mjs} +105 -42
  174. package/dist/server/config-validation.mjs +1 -1
  175. package/dist/server/config.mjs +2 -2
  176. package/dist/server/constants-CeMywaiD.mjs +1485 -0
  177. package/dist/server/{customCss-BZ8YSrQg.mjs → customCss-C9kgPHvr.mjs} +41 -5
  178. package/dist/server/data/resolveBlockData.mjs +1 -1
  179. package/dist/server/{resolveButtonColourStates--6yJp9Tq.mjs → expandPalette-ehuW8r2g.mjs} +745 -1229
  180. package/dist/server/index.mjs +3 -3
  181. package/dist/server/{loadContent-vgWMz1uD.mjs → loadContent-D0prFflT.mjs} +5 -4
  182. package/dist/server/{loadPage-CIOL3-9t.mjs → loadPage-CBLke9pJ.mjs} +3 -3
  183. package/dist/server/{lookMediaFrame-m-91jGGn.mjs → lookMediaFrame-H0fi4bJk.mjs} +38 -18
  184. package/dist/server/manifest.mjs +36 -25
  185. package/dist/server/{mapLocation-BM5WX7FY.mjs → mapLocation-MDDSubTp.mjs} +1 -1
  186. package/dist/server/media-BRmYrnzb.mjs +31 -0
  187. package/dist/server/{media-luf7RF22.mjs → media-gvfIw3z8.mjs} +2 -31
  188. package/dist/server/{navigation-BcNfYYuu.mjs → navigation-wrcuWmgp.mjs} +2 -2
  189. package/dist/server/navigation.mjs +1 -1
  190. package/dist/server/next.mjs +134 -81
  191. package/dist/server/{overrideResolution-BiHmsvTZ.mjs → overrideResolution-DUgCEH8z.mjs} +1 -1
  192. package/dist/server/page-converter.mjs +3 -3
  193. package/dist/server/{pageRenderPlan-DJo_obpi.mjs → pageRenderPlan-BHrmogsW.mjs} +165 -247
  194. package/dist/server/{pageRuntimeSupport-BnSuoHON.mjs → pageRuntimeSupport-D2-YMRei.mjs} +5 -5
  195. package/dist/server/{pageShared-BJuOzxzn.mjs → pageShared-CG8O31Eo.mjs} +3402 -3249
  196. package/dist/server/{parseThemeForPersistence-DOsfofCy.mjs → parseThemeForPersistence-CrPlbJEN.mjs} +3 -2
  197. package/dist/server/{portal-B4JVkdjc.mjs → portal-pG_uhsI2.mjs} +62 -46
  198. package/dist/server/portal.mjs +3 -3
  199. package/dist/server/portalQuestions-oUyohgL9.mjs +225 -0
  200. package/dist/server/{prebuild-Cr8p8T7V.mjs → prebuild-C8Amvzce.mjs} +1 -1
  201. package/dist/server/prebuild.mjs +1 -1
  202. package/dist/server/{prefetchBlockData-BZh57-ua.mjs → prefetchBlockData-BxUETRIZ.mjs} +4 -3
  203. package/dist/server/{registry-CvhFwbXJ.mjs → registry-Cc88-23f.mjs} +1514 -1190
  204. package/dist/server/rendering/components/pageShared.mjs +1 -1
  205. package/dist/server/rendering/helpers/loadPage.mjs +1 -1
  206. package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
  207. package/dist/server/rendering/server.mjs +4 -4
  208. package/dist/server/rendering.mjs +10 -9
  209. package/dist/server/{resolveBlockData-Cv_W1LVB.mjs → resolveBlockData-OG3KOkig.mjs} +2 -2
  210. package/dist/server/{responseMedia-KRKguBC5.mjs → responseMedia-IfH65QAH.mjs} +1 -1
  211. package/dist/server/{schema-BpsqaSSU.mjs → schema-CwfxQjc4.mjs} +10 -113
  212. package/dist/server/server.mjs +3 -3
  213. package/dist/server/{servicePageContent-CRKbTm_7.mjs → servicePageContent-BcFuhhD7.mjs} +22 -21
  214. package/dist/server/theme-bridge.mjs +34 -8
  215. package/dist/server/theme.mjs +2 -2
  216. package/dist/server/{three-pass-converter-39SXCCnh.mjs → three-pass-converter-DPaUPTfl.mjs} +34 -16
  217. package/dist/server/titleSourceSchema-NhK6azFS.mjs +2018 -0
  218. package/dist/server/typeGuards-CTW_9AXq.mjs +413 -0
  219. package/dist/server/types-BKaBZFjD.mjs +1085 -0
  220. package/dist/server/{validation-DCl-FCk_.mjs → validation-BovmbS8N.mjs} +70 -17
  221. package/dist/server/{version-DT_R5JAR.mjs → version-hws4hgyX.mjs} +1 -1
  222. package/dist/server/video-Cdr3wh-q.mjs +272 -0
  223. package/dist/styles/index.css +1098 -1885
  224. package/package.json +2 -1
  225. package/dist/_dts/index-B0_2-65A.d.ts +0 -101
  226. package/dist/client/TabBarFragment-DlKQRhP4.mjs +0 -56
  227. package/dist/client/checkoutRoute-DKlZRNZD.mjs +0 -22
  228. package/dist/client/creditProducts-BQ1t1erI.mjs +0 -266
  229. package/dist/client/formatDate-hhI1-tzt.mjs +0 -26
  230. package/dist/server/constants-Cj7hfbrA.mjs +0 -41
  231. package/dist/server/richTextSchema-QLaQrbII.mjs +0 -212
  232. package/dist/server/titleSourceSchema-Cu-3PRvv.mjs +0 -122
@@ -1,490 +1,5 @@
1
+ import { G as paletteColorsFromEntries, H as isThemeColorToken, J as parseColorTokenParts, U as normalizePaletteHex, V as hexColorSchema, c as buttonEffectApplicationSchema, m as parseOpaqueButtonColourToken, q as paletteModeSchema, s as unsafeAsOpaqueButtonColourToken, w as surfaceForegroundValue, z as PALETTE_TOKEN_NAMES } from "./types-BKaBZFjD.mjs";
1
2
  import { z } from "zod";
2
- //#region ../site-contracts/src/tokens.ts
3
- const blockColorTokenNames = [
4
- "text",
5
- "heading",
6
- "mutedText",
7
- "surface",
8
- "background",
9
- "foreground",
10
- "border",
11
- "primary",
12
- "secondary",
13
- "accent",
14
- "success",
15
- "warning",
16
- "info",
17
- "error",
18
- "destructive",
19
- "scrim",
20
- "shadow",
21
- "onPrimary",
22
- "onSecondary",
23
- "onAccent",
24
- "onSuccess",
25
- "onWarning",
26
- "onInfo",
27
- "onError",
28
- "onDestructive",
29
- "onSurface",
30
- "onText"
31
- ];
32
- function parseOpacityPercent(source) {
33
- const trimmed = source.trim();
34
- if (!trimmed) return null;
35
- if (!/^\d{1,3}(?:\.\d+)?$/.test(trimmed)) return null;
36
- const value = Number(trimmed);
37
- if (!Number.isFinite(value)) return null;
38
- if (value < 0 || value > 100) return null;
39
- return value;
40
- }
41
- function parseColorTokenParts(source) {
42
- const trimmed = source.trim();
43
- if (trimmed.startsWith("raw:")) return {
44
- kind: "raw",
45
- value: trimmed.slice(4)
46
- };
47
- const [token, opacityRaw, extra] = trimmed.split("/");
48
- if (!token || extra !== void 0) return {
49
- kind: "invalid",
50
- token: trimmed
51
- };
52
- if (opacityRaw === void 0) return {
53
- kind: "token",
54
- token,
55
- opacityPercent: null
56
- };
57
- const opacityPercent = parseOpacityPercent(opacityRaw);
58
- if (opacityPercent === null) return {
59
- kind: "invalid",
60
- token: trimmed
61
- };
62
- return {
63
- kind: "token",
64
- token,
65
- opacityPercent
66
- };
67
- }
68
- /**
69
- * Known palette role token names. This is the low-level source of truth for
70
- * palette roles used by palette variants, Theme V2 schemas, and runtime color
71
- * reference parsing.
72
- */
73
- const PALETTE_TOKEN_NAMES = [
74
- "primary",
75
- "primaryForeground",
76
- "secondary",
77
- "accent",
78
- "success",
79
- "warning",
80
- "destructive",
81
- "background",
82
- "surface",
83
- "surfaceAlt",
84
- "muted",
85
- "text",
86
- "border"
87
- ];
88
- const paletteTokenNameSchema = z.enum(PALETTE_TOKEN_NAMES);
89
- const themeColorBaseTokenNames = [
90
- ...PALETTE_TOKEN_NAMES,
91
- ...blockColorTokenNames,
92
- "white",
93
- "neutral",
94
- "primaryText",
95
- "secondaryForeground",
96
- "accentForeground"
97
- ];
98
- const themeColorBaseTokenSet = new Set(themeColorBaseTokenNames);
99
- const shadeStepSet = /* @__PURE__ */ new Set([
100
- "50",
101
- "100",
102
- "200",
103
- "300",
104
- "400",
105
- "500",
106
- "600",
107
- "700",
108
- "800",
109
- "900",
110
- "950"
111
- ]);
112
- function isKnownBaseToken(value) {
113
- return themeColorBaseTokenSet.has(value);
114
- }
115
- function isKnownShadeToken(value) {
116
- const match = value.match(/^([a-zA-Z][a-zA-Z0-9]*)(?:-([0-9]{2,3}))$/);
117
- if (!match) return false;
118
- const [, base, shade] = match;
119
- return Boolean(base && shade && isKnownBaseToken(base) && shadeStepSet.has(shade));
120
- }
121
- function isThemeColorTokenBase(value) {
122
- return isKnownBaseToken(value) || isKnownShadeToken(value);
123
- }
124
- function isThemeColorToken(value) {
125
- if (typeof value !== "string") return false;
126
- const parts = parseColorTokenParts(value);
127
- return parts.kind === "token" && isThemeColorTokenBase(parts.token);
128
- }
129
- function parseThemeColorToken(value) {
130
- if (!isThemeColorToken(value)) return null;
131
- return value.trim();
132
- }
133
- const themeColorTokenSchema = z.string().min(1).refine((value) => Boolean(isThemeColorToken(value)), "Expected a known Theme V2 color token");
134
- const HEX_COLOR_REGEX = /^#[0-9a-f]{6}$/;
135
- const NORMALIZABLE_HEX_REGEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
136
- const THEME_PALETTE_COLOR_ORDER = [
137
- "primary",
138
- "secondary",
139
- "accent",
140
- "success",
141
- "warning",
142
- "destructive",
143
- "background",
144
- "surface",
145
- "surfaceAlt",
146
- "muted",
147
- "text",
148
- "primaryForeground",
149
- "border"
150
- ];
151
- const hexColorSchema = z.string().regex(HEX_COLOR_REGEX, "Hex must be #RRGGBB (lowercase)").transform((value) => value);
152
- const paletteModeSchema = z.enum(["light", "dark"]);
153
- const paletteColorsSchema = z.object({
154
- primary: hexColorSchema,
155
- primaryForeground: hexColorSchema,
156
- secondary: hexColorSchema,
157
- accent: hexColorSchema,
158
- success: hexColorSchema,
159
- warning: hexColorSchema,
160
- destructive: hexColorSchema,
161
- background: hexColorSchema,
162
- surface: hexColorSchema,
163
- surfaceAlt: hexColorSchema,
164
- muted: hexColorSchema,
165
- text: hexColorSchema,
166
- border: hexColorSchema
167
- }).strict().transform((value) => value);
168
- function normalizePaletteHex(value) {
169
- if (!NORMALIZABLE_HEX_REGEX.test(value)) return null;
170
- const normalized = value.toLowerCase();
171
- if (normalized.length === 7) return normalized;
172
- const triplet = normalized.slice(1);
173
- const red = triplet.charAt(0);
174
- const green = triplet.charAt(1);
175
- const blue = triplet.charAt(2);
176
- return `#${red}${red}${green}${green}${blue}${blue}`;
177
- }
178
- function admitPaletteEntry(values, entry) {
179
- const parsedRole = paletteTokenNameSchema.safeParse(entry.name);
180
- if (!parsedRole.success) return {
181
- ok: false,
182
- error: {
183
- kind: "unknown-role",
184
- role: entry.name
185
- }
186
- };
187
- const role = parsedRole.data;
188
- if (values[role] !== void 0) return {
189
- ok: false,
190
- error: {
191
- kind: "duplicate-role",
192
- role
193
- }
194
- };
195
- const hex = normalizePaletteHex(entry.hex);
196
- if (hex === null) return {
197
- ok: false,
198
- error: {
199
- kind: "invalid-color",
200
- role,
201
- value: entry.hex
202
- }
203
- };
204
- return {
205
- ok: true,
206
- values: {
207
- ...values,
208
- [role]: hex
209
- }
210
- };
211
- }
212
- function paletteColorsFromEntries(entries) {
213
- const admitted = entries.reduce((result, entry) => result.ok ? admitPaletteEntry(result.values, entry) : result, {
214
- ok: true,
215
- values: {}
216
- });
217
- if (!admitted.ok) return admitted;
218
- const missing = PALETTE_TOKEN_NAMES.filter((role) => admitted.values[role] === void 0);
219
- return missing.length > 0 ? {
220
- ok: false,
221
- error: {
222
- kind: "missing-roles",
223
- roles: missing
224
- }
225
- } : {
226
- ok: true,
227
- colors: paletteColorsSchema.parse(admitted.values)
228
- };
229
- }
230
- function paletteColorEntries(colors) {
231
- return THEME_PALETTE_COLOR_ORDER.map((name) => ({
232
- name,
233
- hex: colors[name]
234
- }));
235
- }
236
- //#endregion
237
- //#region ../theme-core/src/utils/colorStyles.ts
238
- const COLOR_VAR_PREFIX = "--tb-";
239
- function parseToken(source) {
240
- const parts = parseColorTokenParts(source);
241
- if (parts.kind === "raw") return {
242
- token: source,
243
- raw: parts.value
244
- };
245
- if (parts.kind === "invalid") return { token: source };
246
- return {
247
- token: parts.token,
248
- opacityPercent: parts.opacityPercent === null ? void 0 : parts.opacityPercent
249
- };
250
- }
251
- const SURFACE_TEXT_ROLE_BY_TOKEN = {
252
- text: "text",
253
- heading: "heading",
254
- mutedText: "supporting"
255
- };
256
- function surfaceRoleForTextToken(token) {
257
- return Object.prototype.hasOwnProperty.call(SURFACE_TEXT_ROLE_BY_TOKEN, token) ? SURFACE_TEXT_ROLE_BY_TOKEN[token] : null;
258
- }
259
- /**
260
- * Converts a theme color token to a CSS rgb value.
261
- * This is the primary function for applying theme colors to CSS properties.
262
- *
263
- * @param token - Theme color token (semantic, with opacity, or raw)
264
- * @returns CSS color value (rgb with optional alpha, or raw CSS value)
265
- *
266
- * @example
267
- * rgbColorValue('primary') // => 'rgb(var(--tb-primary))'
268
- * rgbColorValue('surface/95') // => 'rgb(var(--tb-surface) / 0.95)'
269
- * rgbColorValue('raw:transparent') // => 'transparent'
270
- */
271
- function rgbColorValue(token) {
272
- const { token: baseToken, opacityPercent, raw } = parseToken(token);
273
- if (raw) return raw;
274
- const cssVar = `${COLOR_VAR_PREFIX}${baseToken}`;
275
- if (opacityPercent === void 0) return `rgb(var(${cssVar}))`;
276
- return `rgb(var(${cssVar}) / ${opacityPercent / 100})`;
277
- }
278
- /**
279
- * Converts a theme color token to a CSS variable reference.
280
- * Note: This returns the base variable without rgb() wrapper, ignoring opacity.
281
- *
282
- * @param token - Theme color token
283
- * @returns CSS variable reference
284
- *
285
- * @example
286
- * cssVarValue('primary') // => 'var(--tb-primary)'
287
- * cssVarValue('surface/95') // => 'var(--tb-surface)' (opacity ignored)
288
- */
289
- function cssVarValue(token) {
290
- const { token: baseToken } = parseToken(token);
291
- return `var(${COLOR_VAR_PREFIX}${baseToken})`;
292
- }
293
- /**
294
- * Creates a backgroundColor style object from a theme token.
295
- *
296
- * @param token - Theme color token
297
- * @returns CSSProperties with backgroundColor
298
- */
299
- function backgroundColorStyle(token) {
300
- return { backgroundColor: rgbColorValue(token) };
301
- }
302
- /**
303
- * Converts a text color token to a CSS color value that follows the enclosing
304
- * surface. The semantic text tokens (`text`, `heading`, `mutedText`) resolve
305
- * to the surface foreground variables, so text adapts when a section's
306
- * background changes; any other token is a fixed theme color.
307
- *
308
- * @param token - Theme color token
309
- * @returns CSS color value
310
- */
311
- function textColorValue(token) {
312
- const parsed = parseToken(token);
313
- const surfaceRole = parsed.raw ? null : surfaceRoleForTextToken(parsed.token);
314
- if (!surfaceRole) return rgbColorValue(token);
315
- return parsed.opacityPercent === void 0 ? surfaceForegroundValue(surfaceRole) : surfaceForegroundValueWithOpacity(surfaceRole, parsed.opacityPercent);
316
- }
317
- /**
318
- * Creates a text color style object from a theme token.
319
- *
320
- * @param token - Theme color token
321
- * @returns CSSProperties with color
322
- */
323
- function textColorStyle(token) {
324
- return { color: textColorValue(token) };
325
- }
326
- /**
327
- * Creates a border color style object from a theme token.
328
- *
329
- * @param token - Theme color token
330
- * @returns CSSProperties with borderColor
331
- */
332
- function borderColorStyle(token) {
333
- return { borderColor: rgbColorValue(token) };
334
- }
335
- /**
336
- * Merges multiple CSSProperties objects into a single object.
337
- * Later styles override earlier ones. Undefined values are filtered out.
338
- * Returns undefined if the merged result is empty.
339
- *
340
- * @param styles - Variable number of CSSProperties objects (can be undefined)
341
- * @returns Merged CSSProperties object, or undefined if empty
342
- *
343
- * @example
344
- * mergeStyles(
345
- * backgroundColorStyle('surface'),
346
- * textColorStyle('text'),
347
- * borderColorStyle('border')
348
- * )
349
- * // => { backgroundColor: '...', color: '...', borderColor: '...' }
350
- */
351
- function mergeStyles(...styles) {
352
- const merged = {};
353
- for (const style of styles) {
354
- if (!style) continue;
355
- Object.assign(merged, style);
356
- }
357
- return Object.keys(merged).length ? merged : void 0;
358
- }
359
- //#endregion
360
- //#region ../theme-core/src/surfaces/foregroundContract.ts
361
- const SURFACE_FOREGROUND_CSS_VARS = {
362
- text: "--rb-surface-text-color",
363
- heading: "--rb-surface-heading-color",
364
- link: "--rb-surface-link-color",
365
- linkHover: "--rb-surface-link-hover-color",
366
- supporting: "--rb-surface-supporting-color",
367
- muted: "--rb-surface-muted-color",
368
- line: "--rb-surface-line-color",
369
- mark: "--rb-surface-mark-color"
370
- };
371
- const DEFAULT_SURFACE_TEXT_COLOR = "rgb(var(--tb-text, 17 24 39))";
372
- const DEFAULT_SURFACE_LINK_COLOR = "rgb(var(--tb-primary, var(--tb-text, 17 24 39)))";
373
- const DEFAULT_SURFACE_SUPPORTING_COLOR = "rgb(var(--tb-mutedText, 100 116 139))";
374
- const DEFAULT_ROLE_FALLBACKS = {
375
- text: DEFAULT_SURFACE_TEXT_COLOR,
376
- heading: DEFAULT_SURFACE_TEXT_COLOR,
377
- link: DEFAULT_SURFACE_LINK_COLOR,
378
- linkHover: DEFAULT_SURFACE_LINK_COLOR,
379
- supporting: DEFAULT_SURFACE_SUPPORTING_COLOR,
380
- muted: DEFAULT_SURFACE_SUPPORTING_COLOR
381
- };
382
- function requireSurfaceColorValue(role, value) {
383
- const normalized = value.trim();
384
- if (normalized.length === 0) throw new RangeError(`Surface foreground ${role} must be a non-empty CSS color.`);
385
- return normalized;
386
- }
387
- function completeSurfaceForegrounds(input) {
388
- const text = requireSurfaceColorValue("text", input.text);
389
- const link = input.link === void 0 ? text : requireSurfaceColorValue("link", input.link);
390
- return {
391
- text,
392
- heading: input.heading === void 0 ? text : requireSurfaceColorValue("heading", input.heading),
393
- link,
394
- linkHover: input.linkHover === void 0 ? link : requireSurfaceColorValue("linkHover", input.linkHover),
395
- muted: input.muted === void 0 ? text : requireSurfaceColorValue("muted", input.muted),
396
- supporting: input.supporting === void 0 ? text : requireSurfaceColorValue("supporting", input.supporting)
397
- };
398
- }
399
- function surfaceForegroundValue(role, outsideProviderFallback = DEFAULT_ROLE_FALLBACKS[role]) {
400
- const roleVariable = SURFACE_FOREGROUND_CSS_VARS[role];
401
- const fallback = requireSurfaceColorValue("fallback", outsideProviderFallback);
402
- if (role === "text") return `var(${roleVariable}, ${fallback})`;
403
- if (role === "linkHover") return `var(${roleVariable}, ${surfaceForegroundValue("link", fallback)})`;
404
- return `var(${roleVariable}, var(${SURFACE_FOREGROUND_CSS_VARS.text}, ${fallback}))`;
405
- }
406
- /** The solved inks, published beside the foreground roles by the same surfaces. */
407
- const SURFACE_INK_CSS_VARS = {
408
- brand: "--rb-surface-brand-color",
409
- accent: "--rb-surface-accent-color",
410
- focus: "--rb-surface-focus-color",
411
- control: "--rb-surface-control-color"
412
- };
413
- /**
414
- * Read a solved ink, falling back straight to the declaration's own previous
415
- * expression. Unlike `surfaceForegroundValue` this never falls through to
416
- * `--rb-surface-text-color`: where no ink is published (bridge pages, unmeasured
417
- * paints) brand text must keep its brand colour, not turn into the text ink.
418
- */
419
- function surfaceInkValue(role, previousExpression) {
420
- return `var(${SURFACE_INK_CSS_VARS[role]}, ${requireSurfaceColorValue("fallback", previousExpression)})`;
421
- }
422
- /**
423
- * The declarations for a surface's ink publication. An exact ink is a token
424
- * reference (`rgb(var(--tb-primary))`), so a site's own token value wins; a
425
- * nudged or replaced ink is a literal colour.
426
- */
427
- function surfaceInkStyle(publication) {
428
- switch (publication.kind) {
429
- case "none": return {};
430
- case "reset": return inkVariables(() => "initial");
431
- case "solved": return inkVariables((role) => {
432
- const ink = publication.inks[role];
433
- const token = parseThemeColorToken(ink);
434
- return token ? rgbColorValue(token) : ink;
435
- });
436
- }
437
- }
438
- function surfaceInkDeclarations(publication) {
439
- return Object.entries(surfaceInkStyle(publication)).map(([property, value]) => `${property}: ${value};`);
440
- }
441
- function inkVariables(value) {
442
- return {
443
- [SURFACE_INK_CSS_VARS.brand]: value("brand"),
444
- [SURFACE_INK_CSS_VARS.accent]: value("accent"),
445
- [SURFACE_INK_CSS_VARS.focus]: value("focus"),
446
- [SURFACE_INK_CSS_VARS.control]: value("control")
447
- };
448
- }
449
- function surfaceForegroundValueWithOpacity(role, opacityPercent) {
450
- if (!Number.isFinite(opacityPercent) || opacityPercent < 0 || opacityPercent > 100) throw new RangeError("Surface foreground opacity must be between 0 and 100.");
451
- return `color-mix(in srgb, ${surfaceForegroundValue(role)} ${opacityPercent}%, transparent)`;
452
- }
453
- function surfaceForegroundStyle(input) {
454
- const foregrounds = completeSurfaceForegrounds(input);
455
- return {
456
- color: foregrounds.text,
457
- [SURFACE_FOREGROUND_CSS_VARS.text]: foregrounds.text,
458
- [SURFACE_FOREGROUND_CSS_VARS.heading]: foregrounds.heading,
459
- [SURFACE_FOREGROUND_CSS_VARS.link]: foregrounds.link,
460
- [SURFACE_FOREGROUND_CSS_VARS.linkHover]: foregrounds.linkHover,
461
- [SURFACE_FOREGROUND_CSS_VARS.supporting]: foregrounds.supporting,
462
- ...input.muted === void 0 ? {} : { [SURFACE_FOREGROUND_CSS_VARS.muted]: foregrounds.muted },
463
- "--rb-surface-link-hover-decoration": hoverDecoration(input)
464
- };
465
- }
466
- function surfaceForegroundDeclarations(input) {
467
- return Object.entries(surfaceForegroundStyle(input)).map(([property, value]) => `${property}: ${value};`);
468
- }
469
- function surfaceForegroundInputFromResolved(foreground, color) {
470
- const { roles } = foreground;
471
- const value = (ink) => {
472
- const token = parseThemeColorToken(ink);
473
- return token ? color(token) : ink;
474
- };
475
- return {
476
- text: value(roles.text),
477
- heading: value(roles.heading),
478
- link: value(roles.link),
479
- linkHover: value(roles.linkHover),
480
- supporting: value(roles.supporting),
481
- hoverDecoration: foreground.hoverDecoration
482
- };
483
- }
484
- function hoverDecoration(input) {
485
- return input.hoverDecoration ?? "underline";
486
- }
487
- //#endregion
488
3
  //#region ../theme-core/src/palette/utils/colorConversion.ts
489
4
  const clamp01 = (x) => Math.max(0, Math.min(1, x));
490
5
  const mod = (a, n) => (a % n + n) % n;
@@ -713,6 +228,10 @@ function solidPaint(hex, index) {
713
228
  const y = hexLuminance(hex, index);
714
229
  return new Interval(y, y);
715
230
  }
231
+ /** The smallest paint covering every given paint: an ink that clears it clears each of them. */
232
+ function spanningPaint(first, ...rest) {
233
+ return rest.reduce((span, paint) => new Interval(paint.lo < span.lo ? paint.lo : span.lo, paint.hi > span.hi ? paint.hi : span.hi), first);
234
+ }
716
235
  function luminanceRatio(a, b) {
717
236
  return a >= b ? (a + .05) / (b + .05) : (b + .05) / (a + .05);
718
237
  }
@@ -728,8 +247,8 @@ function assertContrastRatio(ratio) {
728
247
  * The one black-or-white rule: literal black or white, whichever contrasts more
729
248
  * with the whole paint (black on a tie). It always returns, even when neither
730
249
  * reaches the ratio a caller wants; callers decide what a shortfall means.
731
- * A style's preferred neutral is a separate input (`neutralInk`) and never
732
- * part of this rule.
250
+ * A style's preferred neutral or the palette's own roles are separate inputs
251
+ * (`neutralInk`, `paletteInk`) that are tried before this rule, never part of it.
733
252
  */
734
253
  function maxContrastBlackOrWhite(paint) {
735
254
  const blackContrast = (paint.lo + .05) / .05;
@@ -742,6 +261,9 @@ function maxContrastBlackOrWhite(paint) {
742
261
  ratio: whiteContrast
743
262
  };
744
263
  }
264
+ function literalInkHex(ink) {
265
+ return ink === "black" ? "#000000" : "#FFFFFF";
266
+ }
745
267
  function contrastRatio(hex1, hex2, index) {
746
268
  const L1 = indexedLuminance(hex1, index);
747
269
  const L2 = indexedLuminance(hex2, index);
@@ -749,119 +271,116 @@ function contrastRatio(hex1, hex2, index) {
749
271
  return (hi + .05) / (lo + .05);
750
272
  }
751
273
  //#endregion
752
- //#region ../theme-core/src/palette/generateShades.ts
753
- function generateShades(hexColor, name) {
754
- const shadeSteps = [
755
- 50,
756
- 100,
757
- 200,
758
- 300,
759
- 400,
760
- 500,
761
- 600,
762
- 700,
763
- 800,
764
- 900,
765
- 950
766
- ];
767
- const base = featuresFromHex(hexColor);
768
- const hue = base.okH;
769
- const baseChroma = base.okC;
770
- const toneMap = {
771
- 50: .975,
772
- 100: .945,
773
- 200: .89,
774
- 300: .82,
775
- 400: .74,
776
- 500: .66,
777
- 600: .58,
778
- 700: .49,
779
- 800: .4,
780
- 900: .28,
781
- 950: .16
782
- };
783
- const shadeDefs = shadeSteps.map((step, idx) => {
784
- const t = idx / (shadeSteps.length - 1);
785
- const L = toneMap[step];
786
- const C = baseChroma * (.06 + .94 * Math.sin(Math.PI * t));
787
- return {
788
- name: `${name}-${step}`,
789
- hex: oklchToHexGamut(L, C, hue)
790
- };
791
- });
792
- shadeDefs.push({
793
- name,
794
- hex: hexColor
795
- });
796
- return shadeDefs;
797
- }
798
- //#endregion
799
- //#region ../theme-core/src/palette/neutralScale.ts
800
- /**
801
- * A neutral scale from near-white (`neutral-50`) to near-black (`neutral-950`)
802
- * on every palette, light or dark. Readers that want "the ground" or "the
803
- * text" ask the palette for those roles, not a fixed end of this scale.
804
- */
805
- function generateNeutralScale({ steps = 11, warm = false } = {}) {
806
- const shadeNames = [
807
- 50,
808
- 100,
809
- 200,
810
- 300,
811
- 400,
812
- 500,
813
- 600,
814
- 700,
815
- 800,
816
- 900,
817
- 950
818
- ];
819
- const count = Math.min(steps, shadeNames.length);
820
- return shadeNames.slice(0, count).map((shadeName, index) => ({
821
- name: `neutral-${shadeName}`,
822
- hex: oklchToHexGamut(mix(.98, .1, index / (count - 1)), .02, warm ? 85 : 250)
823
- }));
274
+ //#region ../theme-core/src/palette/colors.ts
275
+ const PALETTE_VALUE_KEY_PREFIX = "palette-value:v1|";
276
+ z.string().regex(/^[0-9a-f]{64}$/, "Palette hash must be a lowercase SHA-256 value").transform((value) => value);
277
+ function requirePaletteColorsFromEntries(entries) {
278
+ const result = paletteColorsFromEntries(entries);
279
+ if (result.ok) return result.colors;
280
+ throw new Error(`Invalid complete palette: ${result.error.kind}`);
824
281
  }
825
- function mix(a, b, t) {
826
- return a + (b - a) * Math.max(0, Math.min(1, t));
282
+ function paletteColorFingerprint(colors) {
283
+ return PALETTE_TOKEN_NAMES.map((name) => `${name}:${colors[name]}`).join("|");
827
284
  }
828
- //#endregion
829
- //#region ../theme-core/src/palette/utils/textColor.ts
830
- /**
831
- * Pick the better of black/white text for a given background using actual
832
- * contrast ratios, not a simple luminance cutoff. This is
833
- * `maxContrastBlackOrWhite` for a solid ground.
834
- *
835
- * @param background - Background color in hex or rgb/rgba format (e.g., '#FFFFFF' or 'rgb(255, 255, 255)')
836
- * @param _minContrast - Kept for callers. It cannot change the result: when
837
- * only one of black or white reaches it, that one is also the better of the two.
838
- * @returns '#000000' for light backgrounds, '#FFFFFF' for dark backgrounds
839
- */
840
- function pickBlackOrWhiteTextColor(background, _minContrast = 4.5) {
841
- const { r, g, b } = parseColorToRgb(background);
842
- return maxContrastBlackOrWhite(luminanceInterval(relativeLuminance(r, g, b))).ink === "black" ? "#000000" : "#FFFFFF";
285
+ function canonicalPaletteHashInput(colors, mode) {
286
+ return `${mode}|${paletteColorFingerprint(colors)}`;
843
287
  }
844
288
  /**
845
- * Backwards-compatible alias for callers that want the best black/white text
846
- * color for a background.
289
+ * Stable curated-catalogue identity. Do not reorder roles: the order comes
290
+ * from PALETTE_TOKEN_NAMES through canonicalPaletteHashInput.
847
291
  */
848
- function getTextColorForBackground(background) {
849
- return pickBlackOrWhiteTextColor(background);
292
+ function paletteValueKey(colors, mode) {
293
+ return `${PALETTE_VALUE_KEY_PREFIX}${canonicalPaletteHashInput(colors, mode)}`;
294
+ }
295
+ /** Parses only the exact v1 canonical form emitted by paletteValueKey. */
296
+ function parsePaletteValueKey(value) {
297
+ if (typeof value !== "string" || !value.startsWith(PALETTE_VALUE_KEY_PREFIX)) return null;
298
+ const [rawMode, ...rawRoles] = value.slice(17).split("|");
299
+ const mode = paletteModeSchema.safeParse(rawMode);
300
+ if (!mode.success || rawRoles.length !== PALETTE_TOKEN_NAMES.length) return null;
301
+ const colors = paletteColorsFromEntries(rawRoles.map((roleValue) => {
302
+ const separator = roleValue.indexOf(":");
303
+ return separator === -1 ? {
304
+ name: "",
305
+ hex: ""
306
+ } : {
307
+ name: roleValue.slice(0, separator),
308
+ hex: roleValue.slice(separator + 1)
309
+ };
310
+ }));
311
+ if (!colors.ok || paletteValueKey(colors.colors, mode.data) !== value) return null;
312
+ return value;
850
313
  }
851
- function parseColorToRgb(input) {
852
- const trimmed = input.trim();
853
- if (trimmed.startsWith("#")) return hexToRgb(trimmed);
854
- 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);
855
- if (rgbMatch?.[1] && rgbMatch[2] && rgbMatch[3]) return {
856
- r: clamp255(Number(rgbMatch[1])),
857
- g: clamp255(Number(rgbMatch[2])),
858
- b: clamp255(Number(rgbMatch[3]))
314
+ const paletteValueKeySchema = z.string().transform((value, ctx) => {
315
+ const parsed = parsePaletteValueKey(value);
316
+ if (parsed) return parsed;
317
+ ctx.addIssue({
318
+ code: "custom",
319
+ message: "Invalid canonical palette value key"
320
+ });
321
+ return z.NEVER;
322
+ });
323
+ //#endregion
324
+ //#region ../theme-core/src/palette/utils/opaqueSurfaceColor.ts
325
+ /** Resolve an opaque colour, compositing alpha against an explicit underlay. */
326
+ function resolveOpaqueSurfaceHex(reference, palette, underlayReference) {
327
+ const opaque = resolveConcreteColorHex(reference, palette);
328
+ if (opaque) return opaque;
329
+ if (!underlayReference) return null;
330
+ const underlayHex = resolveConcreteColorHex(underlayReference, palette);
331
+ if (!underlayHex) return null;
332
+ const parts = parseColorTokenParts(reference);
333
+ if (parts.kind === "token" && parts.opacityPercent !== null) {
334
+ const foregroundHex = normalizePaletteHex(palette[parts.token] ?? "");
335
+ return foregroundHex ? compositeHex$1(foregroundHex, underlayHex, parts.opacityPercent / 100) : null;
336
+ }
337
+ const rgba = parseRgba(parts.kind === "raw" ? parts.value : reference);
338
+ return rgba ? compositeHex$1(rgbToHex(rgba.r, rgba.g, rgba.b), underlayHex, rgba.alpha) : null;
339
+ }
340
+ /** Resolve a colour reference only when it is already fully opaque. */
341
+ function resolveConcreteColorHex(reference, palette) {
342
+ const literalHex = normalizePaletteHex(reference);
343
+ if (literalHex) return literalHex;
344
+ const parts = parseColorTokenParts(reference);
345
+ if (parts.kind === "token") {
346
+ if (parts.opacityPercent !== null) return null;
347
+ return normalizePaletteHex(palette[parts.token] ?? "");
348
+ }
349
+ const literal = parts.kind === "raw" ? parts.value : reference;
350
+ if (literal.toLowerCase() === "black") return "#000000";
351
+ if (literal.toLowerCase() === "white") return "#ffffff";
352
+ return normalizePaletteHex(literal);
353
+ }
354
+ function compositeHex$1(foregroundHex, underlayHex, alpha) {
355
+ const foreground = hexToRgb(foregroundHex);
356
+ const underlay = hexToRgb(underlayHex);
357
+ const channel = (foregroundValue, underlayValue) => Math.round(foregroundValue * alpha + underlayValue * (1 - alpha));
358
+ return rgbToHex(channel(foreground.r, underlay.r), channel(foreground.g, underlay.g), channel(foreground.b, underlay.b));
359
+ }
360
+ function parseRgba(value) {
361
+ const match = value.trim().match(/^rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*(?:,|\/)\s*([\d.]+%?))?\s*\)$/i);
362
+ if (!match) return null;
363
+ const [, rSource, gSource, bSource] = match;
364
+ if (!rSource || !gSource || !bSource) return null;
365
+ const r = Number(rSource);
366
+ const g = Number(gSource);
367
+ const b = Number(bSource);
368
+ const alpha = parseAlpha(match[4]);
369
+ if (alpha === null || !isRgbChannel(r) || !isRgbChannel(g) || !isRgbChannel(b)) return null;
370
+ return {
371
+ r,
372
+ g,
373
+ b,
374
+ alpha
859
375
  };
860
- throw new Error("Unsupported color format");
861
376
  }
862
- function clamp255(value) {
863
- if (Number.isNaN(value)) return 0;
864
- return Math.max(0, Math.min(255, value));
377
+ function parseAlpha(source) {
378
+ if (!source) return 1;
379
+ const value = source.endsWith("%") ? Number(source.slice(0, -1)) / 100 : Number(source);
380
+ return Number.isFinite(value) && value >= 0 && value <= 1 ? value : null;
381
+ }
382
+ function isRgbChannel(value) {
383
+ return Number.isFinite(value) && value >= 0 && value <= 255;
865
384
  }
866
385
  //#endregion
867
386
  //#region ../theme-core/src/palette/utils/onColor.ts
@@ -887,117 +406,6 @@ function isOnColorBackgroundCandidateToken(token) {
887
406
  return BACKGROUND_ROLE_NAMES.has(role);
888
407
  }
889
408
  //#endregion
890
- //#region ../theme-core/src/palette/expandPalette.ts
891
- function colorsToMap(palette) {
892
- const map = {};
893
- for (const c of palette.colors) map[c.name] = c.hex;
894
- return map;
895
- }
896
- const nonShadeablePaletteRoleNames = /* @__PURE__ */ new Set([
897
- "success",
898
- "warning",
899
- "destructive"
900
- ]);
901
- /**
902
- * Status role aliases the persisted palette does not carry itself.
903
- *
904
- * Generators reference `--tb-error` (the site-style-owned input error border)
905
- * and `--tb-info` (`.alert-info`, `.status-info`, the field-note rule), but the
906
- * palette schema only defines `destructive` and has no `info` role at all.
907
- * Without these aliases those declarations name variables that are never
908
- * defined and browsers drop them. The SDK bridge resolves the same pair via
909
- * TOKEN_ALIASES, so both runtimes agree on what a status token means.
910
- *
911
- * Runs after the danger → destructive promotion above, so `destructive` is
912
- * already the single source of truth for the error colour.
913
- */
914
- function statusAliasTokens(expanded) {
915
- const aliases = {};
916
- if (expanded.destructive) aliases.error = expanded.destructive;
917
- if (expanded.accent) aliases.info = expanded.accent;
918
- return aliases;
919
- }
920
- function expandPalette(palette, options = {}) {
921
- return {
922
- ...expandBasePalette(palette),
923
- ...arrangementPaletteTokens(colorsToMap(palette), options)
924
- };
925
- }
926
- function expandBasePalette(palette) {
927
- const base = colorsToMap(palette);
928
- const expanded = { ...base };
929
- generateNeutralScale({
930
- steps: 11,
931
- warm: false
932
- }).forEach((n) => {
933
- expanded[n.name] = n.hex;
934
- });
935
- for (const [name, hex] of Object.entries(base)) {
936
- if (nonShadeablePaletteRoleNames.has(name)) continue;
937
- if (hex) generateShades(hex, name).forEach((shade) => {
938
- expanded[shade.name] = shade.hex;
939
- });
940
- }
941
- if (base.text) expanded.body = base.text;
942
- if (base.danger && !base.destructive) expanded.destructive = base.danger;
943
- Object.assign(expanded, statusAliasTokens(expanded));
944
- expanded.mutedText = readableMutedText(expanded["neutral-500"] ?? "#888", base);
945
- for (const [token, hex] of Object.entries({ ...expanded })) {
946
- if (!hex || !isOnColorBackgroundCandidateToken(token)) continue;
947
- const onToken = onColorTokenName(token);
948
- if (expanded[onToken]) continue;
949
- expanded[onToken] = getTextColorForBackground(hex);
950
- }
951
- return expanded;
952
- }
953
- /**
954
- * The neutral step stays when it reads on the ground. Otherwise (a dark palette
955
- * on a mid-tone ground, or a tinted light one) it's the ground-to-text blend
956
- * with a 4.5:1 floor, heading for black or white when the text can't reach it.
957
- */
958
- function readableMutedText(step, base) {
959
- const ground = base.background || base.surface;
960
- if (!ground || contrastRatio(step, ground) >= 4.5) return step;
961
- return deriveSurfaceMutedColor(ground, base.text && contrastRatio(base.text, ground) >= 4.5 ? base.text : getTextColorForBackground(ground));
962
- }
963
- /** Derived decoration colours never become editable palette swatches. */
964
- function deriveSurfaceDecorationColors(ground, text, accent) {
965
- const ink = getTextColorForBackground(ground);
966
- return {
967
- line: firstContrastBlend(ground, text, ground, 1.5),
968
- mark: firstContrastBlend(accent, ink, ground, 3)
969
- };
970
- }
971
- /** Secondary ink is blended toward its ground, with an ordinary-text contrast floor. */
972
- function deriveSurfaceMutedColor(ground, text) {
973
- const start = hexToRgb(ground);
974
- const end = hexToRgb(text);
975
- const sample = (index) => rgbToHex(mix$1(start.r, end.r, index / 100), mix$1(start.g, end.g, index / 100), mix$1(start.b, end.b, index / 100));
976
- return firstSafeMutedSample(sample, ground, 0, 100);
977
- }
978
- /** The blend moves monotonically from the ground toward its validated ink. */
979
- function firstSafeMutedSample(sample, ground, low, high) {
980
- if (low === high) return sample(high);
981
- const middle = Math.floor((low + high) / 2);
982
- return contrastRatio(sample(middle), ground) >= 4.5 ? firstSafeMutedSample(sample, ground, low, middle) : firstSafeMutedSample(sample, ground, middle + 1, high);
983
- }
984
- function firstContrastBlend(from, to, ground, threshold) {
985
- const start = hexToRgb(from);
986
- const end = hexToRgb(to);
987
- return Array.from({ length: 101 }, (_, index) => {
988
- const amount = index / 100;
989
- return rgbToHex(mix$1(start.r, end.r, amount), mix$1(start.g, end.g, amount), mix$1(start.b, end.b, amount));
990
- }).find((hex) => contrastRatio(hex, ground) >= threshold) ?? to;
991
- }
992
- /** `markSource` names the colour surface marks are derived from when a style marks in its brand rather than its accent. */
993
- function arrangementPaletteTokens(base, options) {
994
- if (options.arrangement !== true || !base.text) return {};
995
- return {
996
- onText: getTextColorForBackground(base.text),
997
- ...options.marksFrom === "primary" && base.primary ? { markSource: base.primary } : {}
998
- };
999
- }
1000
- //#endregion
1001
409
  //#region \0@oxc-project+runtime@0.137.0/helpers/esm/assertClassBrand.js
1002
410
  function _assertClassBrand(e, t, n) {
1003
411
  if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
@@ -1095,545 +503,249 @@ function member(hex, sample) {
1095
503
  };
1096
504
  }
1097
505
  //#endregion
1098
- //#region ../site-contracts/src/identity/blockKinds.ts
506
+ //#region ../theme-core/src/palette/utils/inkSolver.ts
1099
507
  /**
1100
- * Standard semantic variant roles a theme exposes.
1101
- *
1102
- * Block content references variants by role; the active theme determines
1103
- * what each role looks like.
508
+ * How far (OKLab ΔE) a brand colour drawn as ink may be nudged along its own
509
+ * family before it stops reading as that colour. Past this the caller uses
510
+ * neutral or palette text instead (Will, 2026-10-14).
1104
511
  */
1105
- const VARIANT_ROLES = [
1106
- "primary",
1107
- "secondary",
1108
- "outline",
1109
- "ghost",
1110
- "accent"
1111
- ];
1112
- const variantRoleSchema = z.enum(VARIANT_ROLES);
1113
- const SYSTEM_BLOCK_KINDS = [
1114
- "block.hero",
1115
- "block.intro",
1116
- "block.columns",
1117
- "block.collection",
1118
- "block.class-prices",
1119
- "block.feature-cards",
1120
- "block.media-text",
1121
- "block.cta-full",
1122
- "block.single-button",
1123
- "block.body-text",
1124
- "block.location-map",
1125
- "block.faq",
1126
- "block.list",
1127
- "block.testimonials",
1128
- "block.team-members",
1129
- "block.embed",
1130
- "block.blog-post",
1131
- "block.blog-listing",
1132
- "block.site-header",
1133
- "block.site-footer",
1134
- "block.form",
1135
- "block.contact-newsletter",
1136
- "block.appointment-booking",
1137
- "block.appointment-services",
1138
- "block.service-details",
1139
- "block.weekly-slot-availability",
1140
- "block.event-registration",
1141
- ...[
1142
- "block.event-details",
1143
- "block.event-spotlight",
1144
- "block.event-listing",
1145
- "block.event-calendar",
1146
- "block.recurring-schedule",
1147
- "block.offerings-preview"
1148
- ],
1149
- "block.shop",
1150
- "block.product-list",
1151
- "block.product-detail",
1152
- "block.cart",
1153
- "block.checkout",
1154
- "block.gifting",
1155
- "block.newsletter-signup",
1156
- "block.image-gallery",
1157
- "block.video-grid",
1158
- "block.audio-player",
1159
- "block.file-download"
1160
- ];
1161
- //#endregion
1162
- //#region ../site-contracts/src/theme/buttonTypography.ts
1163
- const textTransformSchema = z.enum([
1164
- "none",
1165
- "uppercase",
1166
- "lowercase",
1167
- "capitalize"
1168
- ]);
1169
- const fontWeightSchema = z.union([
1170
- z.literal(400),
1171
- z.literal(500),
1172
- z.literal(600),
1173
- z.literal(700),
1174
- z.literal(800)
1175
- ]);
1176
- const buttonTypographySchema = z.enum(["body", "heading"]);
1177
- const letterSpacingSchema = z.enum([
1178
- "tight",
1179
- "normal",
1180
- "slight",
1181
- "loose",
1182
- "wide"
1183
- ]);
1184
- //#endregion
1185
- //#region ../site-contracts/src/theme/buttons.ts
512
+ const BRAND_INK_MAX_DELTA_E = .08;
1186
513
  /**
1187
- * Canonical persisted/CSS-safe button variant identifier.
1188
- *
1189
- * IDs become class selectors, so keep the contract deliberately narrower than
1190
- * an arbitrary string and shared with every authoring/runtime boundary.
514
+ * The seed itself when it clears `paint`, otherwise the family member nearest
515
+ * the seed (OKLab ΔE) that clears. On a light ground that is darker, on a dark
516
+ * one lighter. A passing member further than `maxDistance` from the seed is
517
+ * refused as `too-far`, which is distinct from `unpaintable`: the family runs
518
+ * from black to white, so if no member clears, neither does black or white.
1191
519
  */
1192
- 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" });
1193
- function parseOpaqueButtonColourToken(value) {
1194
- const token = parseThemeColorToken(value);
1195
- if (token === null) return null;
1196
- const parts = parseColorTokenParts(token);
1197
- return parts.kind === "token" && parts.opacityPercent === null ? token : null;
520
+ function inkFrom(family, paint, ratio, maxDistance = BRAND_INK_MAX_DELTA_E) {
521
+ assertContrastRatio(ratio);
522
+ if (!Number.isFinite(maxDistance) || maxDistance < 0) throw new RangeError(`Maximum ink distance must be finite and not negative: ${maxDistance}`);
523
+ const seedRatio = worstContrast(family.seed.y, paint);
524
+ if (seedRatio >= ratio) return {
525
+ kind: "ink",
526
+ hex: family.seed.hex,
527
+ ratio: seedRatio,
528
+ source: "exact"
529
+ };
530
+ const nearest = family.members.reduce((best, member) => {
531
+ const achieved = worstContrast(member.y, paint);
532
+ if (achieved < ratio) return best;
533
+ const distance = oklabDistance(member.oklab, family.seed.oklab);
534
+ return best === null || distance < best.distance ? {
535
+ hex: member.hex,
536
+ distance,
537
+ ratio: achieved
538
+ } : best;
539
+ }, null);
540
+ if (nearest === null) return {
541
+ kind: "unpaintable",
542
+ interval: paint,
543
+ ratio
544
+ };
545
+ if (nearest.distance > maxDistance) return {
546
+ kind: "too-far",
547
+ nearest: {
548
+ hex: nearest.hex,
549
+ distance: nearest.distance
550
+ },
551
+ maxDistance
552
+ };
553
+ return {
554
+ kind: "ink",
555
+ hex: nearest.hex,
556
+ ratio: nearest.ratio,
557
+ source: "family"
558
+ };
1198
559
  }
1199
- const opaqueButtonColourTokenSchema = themeColorTokenSchema.refine((value) => parseOpaqueButtonColourToken(value) !== null, "Button colour tokens must be opaque").transform((value) => {
1200
- const token = parseOpaqueButtonColourToken(value);
1201
- if (token === null) throw new Error("Invariant: opaque button token passed its schema");
1202
- return token;
1203
- });
1204
- const contextualButtonHoverSchema = z.strictObject({
1205
- kind: z.literal("shade-shift"),
1206
- seedToken: opaqueButtonColourTokenSchema,
1207
- fallbackDirection: z.enum(["lighter", "darker"]),
1208
- preferredToken: opaqueButtonColourTokenSchema.optional()
1209
- });
1210
- const buttonShadeAmountSchema = z.number().finite().min(0).max(900).multipleOf(100);
1211
- const buttonShadowIntensitySchema = z.enum([
1212
- "subtle",
1213
- "medium",
1214
- "strong"
1215
- ]);
1216
560
  /**
1217
- * The complete persisted button-effect contract.
1218
- *
1219
- * Navigation has its own generic interactive-effect model. Button variants use
1220
- * this closed union so unsupported effect IDs, unknown option keys, and unsafe
1221
- * CSS values cannot become representable after the schema boundary.
561
+ * The one "preferred ink, else black or white" comparison. Of the candidates,
562
+ * the one with the most contrast against the whole paint wins if it reaches
563
+ * `ratio` (the earlier one on a tie); otherwise literal black or white by
564
+ * `maxContrastBlackOrWhite`; otherwise `unpaintable`. It's direction-neutral:
565
+ * a candidate pair of one dark and one light ink needs no light/dark branch.
1222
566
  */
1223
- const buttonPressOffsetSchema = z.strictObject({
1224
- x: z.number().int().min(0).max(12),
1225
- y: z.number().int().min(0).max(12)
1226
- });
1227
- const buttonEffectApplicationSchema = z.discriminatedUnion("effectId", [
1228
- z.strictObject({
1229
- effectId: z.literal("darken-background"),
1230
- options: z.strictObject({ amount: buttonShadeAmountSchema.optional() }).optional()
1231
- }),
1232
- z.strictObject({
1233
- effectId: z.literal("lighten-background"),
1234
- options: z.strictObject({ amount: buttonShadeAmountSchema.optional() }).optional()
1235
- }),
1236
- z.strictObject({
1237
- effectId: z.literal("background-on-hover"),
1238
- options: z.strictObject({ colorToken: opaqueButtonColourTokenSchema.optional() }).optional()
1239
- }),
1240
- z.strictObject({
1241
- effectId: z.literal("animated-gradient"),
1242
- options: z.strictObject({ direction: z.enum(["horizontal", "vertical"]).optional() }).optional()
1243
- }),
1244
- z.strictObject({
1245
- effectId: z.literal("drop-shadow"),
1246
- options: z.strictObject({ intensity: buttonShadowIntensitySchema.optional() }).optional()
1247
- }),
1248
- z.strictObject({
1249
- effectId: z.literal("inner-shadow"),
1250
- options: z.strictObject({}).optional()
1251
- }),
1252
- z.strictObject({
1253
- effectId: z.literal("neumorphic-shadow"),
1254
- options: z.strictObject({
1255
- mode: z.enum(["raised", "pressed"]).optional(),
1256
- intensity: buttonShadowIntensitySchema.optional()
1257
- }).optional()
1258
- }),
1259
- z.strictObject({
1260
- effectId: z.literal("retro-3d-shadow"),
1261
- options: z.strictObject({}).optional()
1262
- }),
1263
- z.strictObject({
1264
- effectId: z.literal("scale-up"),
1265
- options: z.strictObject({ scale: z.enum([
1266
- "1.02",
1267
- "1.03",
1268
- "1.05",
1269
- "1.10"
1270
- ]).optional() }).optional()
1271
- }),
1272
- z.strictObject({
1273
- effectId: z.literal("scale-down"),
1274
- options: z.strictObject({ scale: z.enum([
1275
- "0.90",
1276
- "0.95",
1277
- "0.97",
1278
- "0.98"
1279
- ]).optional() }).optional()
1280
- }),
1281
- z.strictObject({
1282
- effectId: z.literal("lift"),
1283
- options: z.strictObject({ amount: z.enum([
1284
- "0.125",
1285
- "0.25",
1286
- "0.5",
1287
- "1"
1288
- ]).optional() }).optional()
1289
- }),
1290
- z.strictObject({
1291
- effectId: z.literal("press-down"),
1292
- options: z.strictObject({ offset: buttonPressOffsetSchema.optional() }).optional()
1293
- }),
1294
- z.strictObject({
1295
- effectId: z.literal("pop"),
1296
- options: z.strictObject({ intensity: z.enum([
1297
- "subtle",
1298
- "gentle",
1299
- "medium",
1300
- "dramatic"
1301
- ]).optional() }).optional()
1302
- }),
1303
- z.strictObject({
1304
- effectId: z.literal("border-bottom-grow"),
1305
- options: z.strictObject({
1306
- height: z.union([z.literal(1), z.literal(2)]).optional(),
1307
- origin: z.enum([
1308
- "left",
1309
- "center",
1310
- "right"
1311
- ]).optional(),
1312
- persistent: z.boolean().optional(),
1313
- colourRole: z.literal("mark").optional()
1314
- }).optional()
1315
- }),
1316
- z.strictObject({
1317
- effectId: z.literal("inner-dashed-outline"),
1318
- options: z.strictObject({
1319
- colourRole: z.enum(["ink", "mark"]),
1320
- width: z.number().finite().min(.5).max(4),
1321
- inset: z.number().finite().min(0).max(16)
1322
- })
1323
- }),
1324
- z.strictObject({
1325
- effectId: z.literal("sketchy-border"),
1326
- options: z.strictObject({ intensity: buttonShadowIntensitySchema.optional() }).optional()
1327
- })
1328
- ]);
1329
- const cornerStyleSchema = z.enum([
1330
- "square",
1331
- "rounded",
1332
- "pill"
1333
- ]);
1334
- const shadowSizeSchema = z.enum([
1335
- "none",
1336
- "low",
1337
- "medium",
1338
- "high"
1339
- ]);
1340
- const hoverTransformSchema = z.enum([
1341
- "none",
1342
- "lift",
1343
- "scale",
1344
- "press"
1345
- ]);
1346
- const buttonPaddingPresetSchema = z.enum([
1347
- "compact",
1348
- "default",
1349
- "spacious"
1350
- ]);
1351
- const gradientStyleSchema = z.enum([
1352
- "linear",
1353
- "radial",
1354
- "conic"
1355
- ]);
1356
- const gradientSharpnessSchema = z.enum([
1357
- "smooth",
1358
- "medium",
1359
- "hard"
1360
- ]);
1361
- const prioritySchema = z.union([
1362
- z.literal(1),
1363
- z.literal(2),
1364
- z.literal(3)
1365
- ]);
1366
- const buttonSurfaceFallbackSchema = z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("surface-outline") }), z.strictObject({
1367
- kind: z.literal("variant"),
1368
- role: variantRoleSchema
1369
- })]);
1370
- const buttonSurfacePolicyShape = Object.fromEntries(VARIANT_ROLES.map((role) => [role, z.array(buttonSurfaceFallbackSchema).max(VARIANT_ROLES.length)]));
1371
- const buttonSurfacePolicySchema = z.strictObject(buttonSurfacePolicyShape);
567
+ function preferredOrLiteralInk(paint, ratio, candidates) {
568
+ assertContrastRatio(ratio);
569
+ const best = candidates.map((candidate) => ({
570
+ ...candidate,
571
+ ratio: worstContrast(hexLuminance(candidate.hex), paint)
572
+ })).reduce((winner, candidate) => winner === null || candidate.ratio > winner.ratio ? candidate : winner, null);
573
+ if (best !== null && best.ratio >= ratio) return {
574
+ kind: "candidate",
575
+ value: best.value,
576
+ ratio: best.ratio
577
+ };
578
+ const literal = maxContrastBlackOrWhite(paint);
579
+ return literal.ratio >= ratio ? {
580
+ kind: "literal",
581
+ ink: literal.ink,
582
+ ratio: literal.ratio
583
+ } : {
584
+ kind: "unpaintable",
585
+ interval: paint,
586
+ ratio
587
+ };
588
+ }
1372
589
  /**
1373
- * CSS padding string in `"<vertical> <horizontal>"` shorthand form.
1374
- *
1375
- * Exactly two space-separated CSS length tokens. Each token is either the
1376
- * literal `0` or a number followed by `rem`/`em`/`px`/`%`. This lets the
1377
- * generator trust the shape rather than defensively defaulting downstream.
590
+ * Neutral text for a paint. The style's preferred neutral wins when one of its
591
+ * pair clears (the higher-contrast one, dark on a tie); otherwise literal black
592
+ * or white by `maxContrastBlackOrWhite`; otherwise `unpaintable`.
1378
593
  */
1379
- const PADDING_TOKEN_PATTERN = /^(?:0|\d+(?:\.\d+)?(?:rem|em|px|%))$/;
1380
- const paddingShorthandSchema = z.string().refine((value) => {
1381
- const parts = value.split(/\s+/).filter(Boolean);
1382
- return parts.length === 2 && parts.every((token) => PADDING_TOKEN_PATTERN.test(token));
1383
- }, { message: "Padding must be two space-separated CSS length tokens (e.g. \"0.5rem 1rem\"). Use `0` for zero." });
1384
- const buttonSizeConfigSchema = z.object({
1385
- padding: paddingShorthandSchema,
1386
- fontSize: z.string().optional(),
1387
- borderRadius: z.string().optional()
1388
- });
594
+ function neutralInk(paint, ratio, preferred) {
595
+ const picked = preferredOrLiteralInk(paint, ratio, preferred ? [{
596
+ value: preferred.dark,
597
+ hex: preferred.dark
598
+ }, {
599
+ value: preferred.light,
600
+ hex: preferred.light
601
+ }] : []);
602
+ switch (picked.kind) {
603
+ case "candidate": return {
604
+ kind: "ink",
605
+ hex: picked.value,
606
+ ratio: picked.ratio,
607
+ source: "neutral"
608
+ };
609
+ case "literal": return {
610
+ kind: "ink",
611
+ hex: picked.ink === "black" ? "#000000" : "#ffffff",
612
+ ratio: picked.ratio,
613
+ source: "neutral"
614
+ };
615
+ case "unpaintable": return picked;
616
+ }
617
+ }
618
+ /** The palette's `background` and `text` as an ink pair, or null when either is missing or not a hex colour. */
619
+ function paletteInkRoles(palette) {
620
+ const background = hexColorSchema.safeParse(palette.background?.toLowerCase());
621
+ const text = hexColorSchema.safeParse(palette.text?.toLowerCase());
622
+ return background.success && text.success ? {
623
+ background: background.data,
624
+ text: text.data
625
+ } : null;
626
+ }
1389
627
  /**
1390
- * `xl` is optional on the wire so themes persisted before the `xl` size was
1391
- * added (e.g. SWTS) continue to parse. When `xl` is missing the schema
1392
- * backfills it from `lg`, keeping `ButtonSizes` a complete `sm/md/lg/xl` map
1393
- * downstream — generators never need to deal with an undefined `xl`.
628
+ * Palette text for a paint: of the palette's background and text, the one with
629
+ * more contrast against the whole paint when it reaches `ratio`; otherwise
630
+ * literal black or white; otherwise `unpaintable`. On a dark palette the
631
+ * background is the dark one, so the same rule mirrors with no mode branch.
1394
632
  */
1395
- const buttonSizesSchema = z.object({
1396
- sm: buttonSizeConfigSchema,
1397
- md: buttonSizeConfigSchema,
1398
- lg: buttonSizeConfigSchema,
1399
- xl: buttonSizeConfigSchema.optional()
1400
- }).transform(({ sm, md, lg, xl }) => ({
1401
- sm,
1402
- md,
1403
- lg,
1404
- xl: xl ?? lg
1405
- }));
1406
- const buttonGlobalSettingsBaseSchema = z.strictObject({
1407
- cornerStyle: cornerStyleSchema,
1408
- cornerRadius: z.number().min(0).max(24).optional(),
1409
- /**
1410
- * Family-level shadow inherited by variants that don't set their own.
1411
- * Optional and flat-by-default: when omitted, buttons carry no drop shadow
1412
- * (`elevation: 'none'`). A personality opts the whole family into a shadow by
1413
- * setting this; individual variants still override. There is no system-level
1414
- * shadow-by-default — shadows only appear when explicitly declared.
1415
- */
1416
- shadow: shadowSizeSchema.optional(),
1417
- textTransform: textTransformSchema,
1418
- fontWeight: fontWeightSchema,
1419
- typography: buttonTypographySchema.optional(),
1420
- fontSize: z.string().optional(),
1421
- letterSpacing: letterSpacingSchema.optional(),
1422
- italic: z.boolean().optional(),
1423
- paddingPreset: buttonPaddingPresetSchema.optional(),
1424
- hoverTransform: hoverTransformSchema,
1425
- gradientStyle: gradientStyleSchema.optional(),
1426
- gradientAngle: z.number().min(0).max(360).optional(),
1427
- gradientSharpness: gradientSharpnessSchema.optional()
1428
- });
1429
- const buttonGlobalSettingsSchema = z.discriminatedUnion("hoverColor", [buttonGlobalSettingsBaseSchema.extend({
1430
- hoverColor: z.literal("none"),
1431
- hoverColorToken: z.never().optional()
1432
- }), buttonGlobalSettingsBaseSchema.extend({
1433
- hoverColor: z.literal("token"),
1434
- hoverColorToken: opaqueButtonColourTokenSchema
1435
- })]);
1436
- const gradientDirectionSchema = z.enum([
1437
- "to-r",
1438
- "to-l",
1439
- "to-t",
1440
- "to-b",
1441
- "to-tr",
1442
- "to-tl",
1443
- "to-br",
1444
- "to-bl"
1445
- ]);
1446
- const buttonColourTreatmentSchema = z.discriminatedUnion("type", [
1447
- z.strictObject({
1448
- type: z.literal("solid"),
1449
- colorToken: opaqueButtonColourTokenSchema,
1450
- foregroundToken: opaqueButtonColourTokenSchema.optional()
1451
- }),
1452
- z.strictObject({
1453
- type: z.literal("gradient"),
1454
- stops: z.array(opaqueButtonColourTokenSchema).min(2).transform((stops) => {
1455
- const [first, second, ...rest] = stops;
1456
- if (first === void 0 || second === void 0) throw new Error("Invariant: gradient stops passed the minimum length schema");
1457
- return [
1458
- first,
1459
- second,
1460
- ...rest
1461
- ];
1462
- }),
1463
- direction: gradientDirectionSchema,
1464
- foregroundToken: opaqueButtonColourTokenSchema
1465
- }),
1466
- z.strictObject({
1467
- type: z.literal("surface"),
1468
- role: z.literal("link")
1469
- })
1470
- ]);
1471
- const buttonBackgroundSchema = buttonColourTreatmentSchema;
1472
- const buttonBorderSchema = z.strictObject({
1473
- widthClass: z.string(),
1474
- marksBoundary: z.literal(true).optional(),
1475
- ring: z.literal(true).optional(),
1476
- boundaryInk: opaqueButtonColourTokenSchema.optional()
1477
- });
1478
- const buttonVariantAffordanceSchema = z.strictObject({ iconId: z.string().min(1) });
1479
- const variantShadowSchema = z.strictObject({
1480
- elevation: z.enum([
1481
- "none",
1482
- "low",
1483
- "medium",
1484
- "high"
1485
- ]),
1486
- softness: z.enum([
1487
- "crisp",
1488
- "soft",
1489
- "hard"
1490
- ]).nullable(),
1491
- position: z.enum(["bottom", "bottom-right"]).default("bottom"),
1492
- colorToken: opaqueButtonColourTokenSchema.optional()
1493
- });
1494
- /** Recipe states own every visual property; treatment owns its readable label. */
1495
- const buttonVisualAppearanceSchema = z.strictObject({
1496
- background: buttonColourTreatmentSchema,
1497
- text: z.literal("treatment"),
1498
- border: z.union([z.literal("none"), buttonBorderSchema]),
1499
- borderRadius: z.string(),
1500
- shadow: z.union([z.literal("focus-indicator"), variantShadowSchema]),
1501
- sizes: buttonSizesSchema,
1502
- typography: z.strictObject({
1503
- fontWeight: fontWeightSchema,
1504
- typography: buttonTypographySchema,
1505
- fontSize: z.string().nullable(),
1506
- letterSpacing: z.union([letterSpacingSchema, z.literal("heading")]).nullable(),
1507
- italic: z.boolean(),
1508
- textTransform: textTransformSchema
1509
- }),
1510
- effects: z.array(buttonEffectApplicationSchema),
1511
- transform: z.literal("none").optional(),
1512
- contextualHover: contextualButtonHoverSchema.optional()
1513
- });
1514
- const buttonVisualStatesSchema = z.strictObject({
1515
- base: buttonVisualAppearanceSchema.extend({ shadow: variantShadowSchema }),
1516
- hover: buttonVisualAppearanceSchema.extend({ shadow: variantShadowSchema }),
1517
- focus: buttonVisualAppearanceSchema.extend({
1518
- shadow: z.literal("focus-indicator"),
1519
- indicator: z.strictObject({
1520
- kind: z.literal("surface-ink"),
1521
- width: z.union([z.literal(2), z.literal(3)]),
1522
- offset: z.union([z.literal(3), z.literal(4)])
1523
- }).optional()
1524
- }),
1525
- active: buttonVisualAppearanceSchema.extend({ shadow: variantShadowSchema }),
1526
- disabled: buttonVisualAppearanceSchema.extend({ shadow: variantShadowSchema })
1527
- });
1528
- const variantEffectsSchema = z.strictObject({
1529
- base: z.array(buttonEffectApplicationSchema).optional(),
1530
- hover: z.array(buttonEffectApplicationSchema).optional(),
1531
- active: z.array(buttonEffectApplicationSchema).optional(),
1532
- focus: z.array(buttonEffectApplicationSchema).optional()
1533
- });
633
+ function paletteInk(paint, roles, ratio = ORDINARY_TEXT_MIN_CONTRAST_RATIO) {
634
+ const picked = preferredOrLiteralInk(paint, ratio, roles ? ["text", "background"].map((role) => ({
635
+ value: {
636
+ role,
637
+ hex: roles[role]
638
+ },
639
+ hex: roles[role]
640
+ })) : []);
641
+ switch (picked.kind) {
642
+ case "candidate": return {
643
+ kind: "role",
644
+ ...picked.value,
645
+ ratio: picked.ratio
646
+ };
647
+ case "literal": return {
648
+ kind: "literal",
649
+ hex: literalInkHex(picked.ink),
650
+ ratio: picked.ratio
651
+ };
652
+ case "unpaintable": return picked;
653
+ }
654
+ }
655
+ /** Ordinary-text palette ink on one solid ground. Total: black or white always reaches 4.58:1 on a solid. */
656
+ function paletteInkOnSolid(groundHex, roles) {
657
+ const paint = solidPaint(groundHex);
658
+ const ink = paletteInk(paint, roles);
659
+ if (ink.kind !== "unpaintable") return ink;
660
+ const literal = maxContrastBlackOrWhite(paint);
661
+ return {
662
+ kind: "literal",
663
+ hex: literalInkHex(literal.ink),
664
+ ratio: literal.ratio
665
+ };
666
+ }
1534
667
  /**
1535
- * Per-variant size overrides schema — every entry is optional.
1536
- *
1537
- * For each size key present, the values override the theme's `sizes` config
1538
- * for that size on this variant. Missing sizes fall through to theme.sizes,
1539
- * then system defaults.
668
+ * The ink as token emitters write it: the role's theme token, so CSS follows
669
+ * the palette's variables, or the literal hex.
1540
670
  */
1541
- const variantSizeOverridesSchema = z.object({
1542
- sm: buttonSizeConfigSchema.optional(),
1543
- md: buttonSizeConfigSchema.optional(),
1544
- lg: buttonSizeConfigSchema.optional(),
1545
- xl: buttonSizeConfigSchema.optional()
1546
- });
671
+ function paletteInkToken(ink) {
672
+ if (ink.kind === "literal") return ink.hex;
673
+ if (!isThemeColorToken(ink.role)) throw new Error(`Palette ink role is not a theme token: ${ink.role}`);
674
+ return ink.role;
675
+ }
1547
676
  /**
1548
- * Unified variant schema. Every variant participates in the size system; the
1549
- * optional `sizes` field lets a variant scale differently than the theme
1550
- * default (e.g. link-style variants declaring zero horizontal padding at
1551
- * every size).
677
+ * Secondary text that has to read on several grounds (a surface and the tinted
678
+ * cards laid on it). The full-strength ink is `preferred` when it reaches 4.5:1
679
+ * on every ground, otherwise the palette's ink over the same paint; the muted
680
+ * ink is then the faintest blend from the first ground toward it that still
681
+ * reaches 4.5:1 everywhere. When no ink reaches 4.5:1 on every ground (a light
682
+ * ground and a dark one together), it's `unpaintable` and the caller decides
683
+ * which grounds to give up, rather than receiving a colour that only claims to read.
1552
684
  */
1553
- const buttonVariantSchema = z.strictObject({
1554
- id: buttonVariantIdSchema,
1555
- name: z.string().min(1).max(20),
1556
- enabled: z.boolean(),
1557
- priority: prioritySchema,
1558
- visualStates: buttonVisualStatesSchema.optional(),
1559
- background: buttonBackgroundSchema,
1560
- /** Tailwind radius token (e.g. `'rounded-md'`). Omit to inherit from `global.cornerStyle`. */
1561
- borderRadius: z.string().optional(),
1562
- shadow: variantShadowSchema.optional(),
1563
- border: buttonBorderSchema.optional(),
1564
- hoverBackgroundToken: opaqueButtonColourTokenSchema.optional(),
1565
- contextualHover: contextualButtonHoverSchema.optional(),
1566
- effects: variantEffectsSchema.optional(),
1567
- sizes: variantSizeOverridesSchema.optional(),
1568
- affordance: buttonVariantAffordanceSchema.optional()
1569
- });
1570
- const buttonSystemSchema = z.strictObject({
1571
- global: buttonGlobalSettingsSchema,
1572
- variants: z.array(buttonVariantSchema).min(1).max(6),
1573
- sizes: buttonSizesSchema.optional(),
1574
- surfacePolicy: buttonSurfacePolicySchema.optional(),
1575
- surfaceContexts: z.record(z.string(), z.strictObject({
1576
- primary: opaqueButtonColourTokenSchema,
1577
- primaryText: opaqueButtonColourTokenSchema.optional()
1578
- })).optional()
1579
- }).superRefine((system, ctx) => {
1580
- const seen = /* @__PURE__ */ new Set();
1581
- system.variants.forEach((variant, index) => {
1582
- if (seen.has(variant.id)) ctx.addIssue({
1583
- code: "custom",
1584
- path: [
1585
- "variants",
1586
- index,
1587
- "id"
1588
- ],
1589
- message: `Duplicate button variant ID: ${variant.id}`
1590
- });
1591
- seen.add(variant.id);
1592
- });
1593
- });
1594
- //#endregion
1595
- //#region ../theme-core/src/buttons/types.ts
1596
- function isVariantRole(value) {
1597
- return VARIANT_ROLES.includes(value);
685
+ function paletteMutedInk(grounds, preferred, roles) {
686
+ const [first, ...rest] = grounds;
687
+ const paint = spanningPaint(solidPaint(first), ...rest.map((ground) => solidPaint(ground)));
688
+ const contrast = (hex) => worstContrast(hexLuminance(hex), paint);
689
+ const passes = (hex) => contrast(hex) >= ORDINARY_TEXT_MIN_CONTRAST_RATIO;
690
+ const endpoint = preferred !== null && passes(preferred) ? {
691
+ kind: "preferred",
692
+ hex: preferred
693
+ } : paletteInk(paint, roles);
694
+ if (endpoint.kind === "unpaintable") return endpoint;
695
+ const start = hexToRgb(first);
696
+ const end = hexToRgb(endpoint.hex);
697
+ const sample = (index) => rgbToHex(mix$1(start.r, end.r, index / 100), mix$1(start.g, end.g, index / 100), mix$1(start.b, end.b, index / 100));
698
+ const firstPassing = (low, high) => {
699
+ if (low >= high) return high;
700
+ const middle = Math.floor((low + high) / 2);
701
+ return passes(sample(middle)) ? firstPassing(low, middle) : firstPassing(middle + 1, high);
702
+ };
703
+ const hex = sample(firstPassing(0, 100));
704
+ return {
705
+ kind: "muted",
706
+ hex,
707
+ ratio: contrast(hex)
708
+ };
1598
709
  }
1599
- function asSpecialVariantId(value) {
1600
- const parsed = buttonVariantIdSchema.safeParse(value);
1601
- if (!parsed.success) throw new Error("SpecialVariantId must be a CSS-safe button variant ID");
1602
- return parsed.data;
710
+ /** The muted ink on one solid ground. Total: black or white always reaches 4.58:1 on a solid. */
711
+ function paletteMutedInkOnSolid(ground, preferred, roles) {
712
+ const ink = paletteMutedInk([ground], preferred, roles);
713
+ if (ink.kind === "unpaintable") throw new Error(`No muted ink reads on the solid ground ${ground}`);
714
+ return ink.hex;
1603
715
  }
716
+ //#endregion
717
+ //#region ../theme-core/src/palette/utils/textColor.ts
1604
718
  /**
1605
- * Magic alias the CSS generator emits for the highest-priority variant.
719
+ * Pick the better of black/white text for a given background using actual
720
+ * contrast ratios, not a simple luminance cutoff. This is
721
+ * `maxContrastBlackOrWhite` for a solid ground. It is the literal fallback
722
+ * only: where a palette is in scope, `paletteInkOnSolid` tries the site's own
723
+ * background and text colours first.
1606
724
  *
1607
- * Shared between generator and renderer so neither side hard-codes the string.
725
+ * @param background - Background color in hex or rgb/rgba format (e.g., '#FFFFFF' or 'rgb(255, 255, 255)')
726
+ * @param _minContrast - Kept for callers. It cannot change the result: when
727
+ * only one of black or white reaches it, that one is also the better of the two.
728
+ * @returns '#000000' for light backgrounds, '#FFFFFF' for dark backgrounds
1608
729
  */
1609
- const DEFAULT_VARIANT_ALIAS_ID = "default";
1610
- function unsafeAsOpaqueButtonColourToken(value) {
1611
- return value;
730
+ function pickBlackOrWhiteTextColor(background, _minContrast = 4.5) {
731
+ const { r, g, b } = parseColorToRgb(background);
732
+ return literalInkHex(maxContrastBlackOrWhite(luminanceInterval(relativeLuminance(r, g, b))).ink);
733
+ }
734
+ function parseColorToRgb(input) {
735
+ const trimmed = input.trim();
736
+ if (trimmed.startsWith("#")) return hexToRgb(trimmed);
737
+ 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);
738
+ if (rgbMatch?.[1] && rgbMatch[2] && rgbMatch[3]) return {
739
+ r: clamp255(Number(rgbMatch[1])),
740
+ g: clamp255(Number(rgbMatch[2])),
741
+ b: clamp255(Number(rgbMatch[3]))
742
+ };
743
+ throw new Error("Unsupported color format");
744
+ }
745
+ function clamp255(value) {
746
+ if (Number.isNaN(value)) return 0;
747
+ return Math.max(0, Math.min(255, value));
1612
748
  }
1613
- z.enum(["none", "token"]);
1614
- const standardButtonSurfacePolicy = {
1615
- primary: [{ kind: "surface-outline" }],
1616
- secondary: [{ kind: "surface-outline" }, {
1617
- kind: "variant",
1618
- role: "primary"
1619
- }],
1620
- outline: [{ kind: "surface-outline" }],
1621
- ghost: [{ kind: "surface-outline" }],
1622
- accent: [{ kind: "surface-outline" }, {
1623
- kind: "variant",
1624
- role: "primary"
1625
- }]
1626
- };
1627
- const STANDARD_BUTTON_SURFACE_POLICY = Object.freeze(Object.fromEntries(VARIANT_ROLES.map((role) => [role, Object.freeze([...standardButtonSurfacePolicy[role]])])));
1628
- function createStandardButtonSurfacePolicy() {
1629
- return Object.fromEntries(VARIANT_ROLES.map((role) => [role, [...STANDARD_BUTTON_SURFACE_POLICY[role]]]));
1630
- }
1631
- const buttonSizeNameSchema = z.enum([
1632
- "sm",
1633
- "md",
1634
- "lg",
1635
- "xl"
1636
- ]);
1637
749
  //#endregion
1638
750
  //#region ../theme-core/src/buttons/constants.ts
1639
751
  /**
@@ -2480,13 +1592,13 @@ function resolveSolid(input, backgroundToken, preferredForeground) {
2480
1592
  function resolveSolidButtonColour(input, backgroundToken, preferredForeground) {
2481
1593
  return resolveSolid(input, backgroundToken, preferredForeground);
2482
1594
  }
2483
- /** Preserve checked on-colours (a requested label colour first); a solid state's last resort belongs to its actual fill. */
1595
+ /** Preserve checked on-colours (a requested label colour first); a solid state's last resort is the palette ink for its actual fill. */
2484
1596
  function resolveSolidInk(input, backgroundToken, backgroundHex, preferredForeground) {
2485
1597
  if (preferredForeground !== void 0) {
2486
1598
  const preferred = checkedSolidInk(input, backgroundToken, backgroundHex, preferredForeground);
2487
1599
  if (preferred) return preferred;
2488
1600
  }
2489
- return checkedSolidInk(input, backgroundToken, backgroundHex, unsafeAsOpaqueButtonColourToken(solidForegroundToken(backgroundToken))) ?? blackOrWhiteSolidInk(backgroundToken, backgroundHex);
1601
+ return checkedSolidInk(input, backgroundToken, backgroundHex, unsafeAsOpaqueButtonColourToken(solidForegroundToken(backgroundToken))) ?? paletteSolidInk(input, backgroundToken, backgroundHex);
2490
1602
  }
2491
1603
  function checkedSolidInk(input, backgroundToken, backgroundHex, foregroundToken) {
2492
1604
  const candidate = input.palette[foregroundToken];
@@ -2508,14 +1620,18 @@ function checkedSolidInk(input, backgroundToken, backgroundHex, foregroundToken)
2508
1620
  };
2509
1621
  return null;
2510
1622
  }
2511
- function blackOrWhiteSolidInk(backgroundToken, backgroundHex) {
2512
- const foregroundHex = pickBlackOrWhiteTextColor(backgroundHex);
1623
+ /** The palette's own background or text as the label where it reads (as a checked token), else literal black or white. */
1624
+ function paletteSolidInk(input, backgroundToken, backgroundHex) {
1625
+ const ink = paletteInkOnSolid(backgroundHex, paletteInkRoles(input.palette));
1626
+ const role = ink.kind === "role" ? checkedSolidInk(input, backgroundToken, backgroundHex, unsafeAsOpaqueButtonColourToken(ink.role)) : null;
1627
+ if (role) return role;
1628
+ const literal = pickBlackOrWhiteTextColor(backgroundHex);
2513
1629
  return {
2514
- foregroundHex,
1630
+ foregroundHex: literal,
2515
1631
  colour: {
2516
1632
  kind: "known-solid",
2517
1633
  backgroundCss: tokenCss(backgroundToken),
2518
- foregroundCss: foregroundHex
1634
+ foregroundCss: literal
2519
1635
  }
2520
1636
  };
2521
1637
  }
@@ -2593,4 +1709,404 @@ function interpolateHex(startHex, endHex, position) {
2593
1709
  return `#${channel(start.r, end.r)}${channel(start.g, end.g)}${channel(start.b, end.b)}`;
2594
1710
  }
2595
1711
  //#endregion
2596
- export { SURFACE_FOREGROUND_CSS_VARS as $, deriveSurfaceMutedColor as A, preparePaletteColourIndex as B, buttonVisualStatesSchema as C, paletteColorsFromEntries as Ct, colourFamily as D, parseThemeColorToken as Dt, VARIANT_ROLES as E, parseColorTokenParts as Et, pickBlackOrWhiteTextColor as F, hexToRgb as G, solidPaint as H, ORDINARY_TEXT_MIN_CONTRAST_RATIO as I, oklchToHexGamut as J, oklabToOklch as K, assertContrastRatio as L, isOnColorBackgroundCandidateToken as M, onColorTokenName as N, oklabDistance as O, themeColorTokenSchema as Ot, getTextColorForBackground as P, DEFAULT_SURFACE_TEXT_COLOR as Q, contrastRatio as R, buttonVariantIdSchema as S, paletteColorEntries as St, SYSTEM_BLOCK_KINDS as T, paletteModeSchema as Tt, worstContrast as U, relativeLuminance as V, featuresFromHex as W, rgbToHex as X, oklchToOklab as Y, srgbToOklab as Z, isVariantRole as _, PALETTE_TOKEN_NAMES as _t, formatButtonColourContractError as a, surfaceForegroundValue as at, buttonPressOffsetSchema as b, isThemeColorToken as bt, DEFAULT_BUTTON_SIZES as c, surfaceInkStyle as ct, generateShadowValue as d, borderColorStyle as dt, SURFACE_INK_CSS_VARS as et, DEFAULT_VARIANT_ALIAS_ID as f, cssVarValue as ft, createStandardButtonSurfacePolicy as g, textColorValue as gt, buttonSizeNameSchema as h, textColorStyle as ht, BUTTON_CONTRAST_POLICY as i, surfaceForegroundStyle as it, expandPalette as j, deriveSurfaceDecorationColors as k, ELEVATION_OFFSET as l, surfaceInkValue as lt, asSpecialVariantId as m, rgbColorValue as mt, compileButtonColourStates as n, surfaceForegroundDeclarations as nt, BORDER_RADIUS_MAP as o, surfaceForegroundValueWithOpacity as ot, STANDARD_BUTTON_SURFACE_POLICY as p, mergeStyles as pt, oklabToSrgb as q, resolveSolidButtonColour as r, surfaceForegroundInputFromResolved as rt, BORDER_WIDTH_MAP as s, surfaceInkDeclarations as st, buttonStateBorder as t, completeSurfaceForegrounds as tt, FONT_SIZE_MAP as u, backgroundColorStyle as ut, unsafeAsOpaqueButtonColourToken as v, blockColorTokenNames as vt, opaqueButtonColourTokenSchema as w, paletteColorsSchema as wt, buttonSystemSchema as x, normalizePaletteHex as xt, buttonEffectApplicationSchema as y, hexColorSchema as yt, maxContrastBlackOrWhite as z };
1712
+ //#region ../theme-core/src/palette/generateShades.ts
1713
+ function generateShades(hexColor, name) {
1714
+ const shadeSteps = [
1715
+ 50,
1716
+ 100,
1717
+ 200,
1718
+ 300,
1719
+ 400,
1720
+ 500,
1721
+ 600,
1722
+ 700,
1723
+ 800,
1724
+ 900,
1725
+ 950
1726
+ ];
1727
+ const base = featuresFromHex(hexColor);
1728
+ const hue = base.okH;
1729
+ const baseChroma = base.okC;
1730
+ const toneMap = {
1731
+ 50: .975,
1732
+ 100: .945,
1733
+ 200: .89,
1734
+ 300: .82,
1735
+ 400: .74,
1736
+ 500: .66,
1737
+ 600: .58,
1738
+ 700: .49,
1739
+ 800: .4,
1740
+ 900: .28,
1741
+ 950: .16
1742
+ };
1743
+ const shadeDefs = shadeSteps.map((step, idx) => {
1744
+ const t = idx / (shadeSteps.length - 1);
1745
+ const L = toneMap[step];
1746
+ const C = baseChroma * (.06 + .94 * Math.sin(Math.PI * t));
1747
+ return {
1748
+ name: `${name}-${step}`,
1749
+ hex: oklchToHexGamut(L, C, hue)
1750
+ };
1751
+ });
1752
+ shadeDefs.push({
1753
+ name,
1754
+ hex: hexColor
1755
+ });
1756
+ return shadeDefs;
1757
+ }
1758
+ //#endregion
1759
+ //#region ../theme-core/src/palette/neutralScale.ts
1760
+ /** The cool slate tint every scale had before #1863, kept for grounds with no hue to lend. */
1761
+ const SLATE_NEUTRAL_TINT = {
1762
+ hue: 250,
1763
+ chroma: .02
1764
+ };
1765
+ /** Below this OKLCH chroma a background reads as plain white, grey or black, so its hue is noise. */
1766
+ const ACHROMATIC_CHROMA = .005;
1767
+ /**
1768
+ * The tint a palette's greys take from its background: the background's own
1769
+ * hue at no more than the slate scale's chroma, so a cream site gets warm greys.
1770
+ * A background with no hue to lend (white, `#fafafa`, a missing or unreadable
1771
+ * value) keeps the slate tint, so those palettes keep their exact neutrals.
1772
+ */
1773
+ function neutralTint(background) {
1774
+ const parsed = hexColorSchema.safeParse(background?.toLowerCase());
1775
+ if (!parsed.success) return SLATE_NEUTRAL_TINT;
1776
+ const { r, g, b } = hexToRgb(parsed.data);
1777
+ const { L, a, b: ob } = srgbToOklab(r, g, b);
1778
+ const { C, h } = oklabToOklch(L, a, ob);
1779
+ return C < ACHROMATIC_CHROMA ? SLATE_NEUTRAL_TINT : {
1780
+ hue: h,
1781
+ chroma: Math.min(C, SLATE_NEUTRAL_TINT.chroma)
1782
+ };
1783
+ }
1784
+ /**
1785
+ * A neutral scale from near-white (`neutral-50`) to near-black (`neutral-950`)
1786
+ * on every palette, light or dark. Readers that want "the ground" or "the
1787
+ * text" ask the palette for those roles, not a fixed end of this scale.
1788
+ */
1789
+ function generateNeutralScale({ steps = 11, tint = SLATE_NEUTRAL_TINT } = {}) {
1790
+ const shadeNames = [
1791
+ 50,
1792
+ 100,
1793
+ 200,
1794
+ 300,
1795
+ 400,
1796
+ 500,
1797
+ 600,
1798
+ 700,
1799
+ 800,
1800
+ 900,
1801
+ 950
1802
+ ];
1803
+ const count = Math.min(steps, shadeNames.length);
1804
+ return shadeNames.slice(0, count).map((shadeName, index) => ({
1805
+ name: `neutral-${shadeName}`,
1806
+ hex: oklchToHexGamut(mix(.98, .1, index / (count - 1)), tint.chroma, tint.hue)
1807
+ }));
1808
+ }
1809
+ function mix(a, b, t) {
1810
+ return a + (b - a) * Math.max(0, Math.min(1, t));
1811
+ }
1812
+ //#endregion
1813
+ //#region ../theme-core/src/palette/utils/scrimContrast.ts
1814
+ const WHITE = "#ffffff";
1815
+ const BLACK = "#000000";
1816
+ /** `top` at `alpha` over opaque `bottom`, blended as CSS paints an overlay. */
1817
+ function compositeHex(topHex, alpha, bottomHex) {
1818
+ const top = hexToRgb(topHex);
1819
+ const bottom = hexToRgb(bottomHex);
1820
+ const mix = (a, b) => Math.round(alpha * a + (1 - alpha) * b);
1821
+ return rgbToHex(mix(top.r, bottom.r), mix(top.g, bottom.g), mix(top.b, bottom.b));
1822
+ }
1823
+ /**
1824
+ * The lowest contrast `foreground` can reach over `scrim` at `alpha` laid on
1825
+ * any pixel. A foreground whose luminance falls inside the range the
1826
+ * composites can take has a worst case of 1:1.
1827
+ */
1828
+ function worstCaseScrimContrast(input) {
1829
+ const overWhite = compositeHex(input.scrimHex, input.alpha, WHITE);
1830
+ const overBlack = compositeHex(input.scrimHex, input.alpha, BLACK);
1831
+ const luminance = (hex) => {
1832
+ const { r, g, b } = hexToRgb(hex);
1833
+ return relativeLuminance(r, g, b);
1834
+ };
1835
+ const foreground = luminance(input.foregroundHex);
1836
+ const low = luminance(overBlack);
1837
+ const high = luminance(overWhite);
1838
+ if (foreground >= low && foreground <= high) return 1;
1839
+ return Math.min(contrastRatio(input.foregroundHex, overWhite), contrastRatio(input.foregroundHex, overBlack));
1840
+ }
1841
+ /**
1842
+ * The smallest scrim opacity, in hundredths, at which every foreground keeps
1843
+ * `threshold` contrast over any pixel. `null` when even an opaque scrim fails,
1844
+ * which means the foreground was never legible on the scrim colour itself.
1845
+ */
1846
+ function minimumScrimOpacity(input) {
1847
+ const passes = (alpha) => input.foregroundHexes.every((foregroundHex) => worstCaseScrimContrast({
1848
+ foregroundHex,
1849
+ scrimHex: input.scrimHex,
1850
+ alpha
1851
+ }) >= input.threshold);
1852
+ return Array.from({ length: 101 }, (_, hundredths) => hundredths / 100).find(passes) ?? null;
1853
+ }
1854
+ /** Shared samples for literal RGB washes and palette-token gradient veils. */
1855
+ function gradientScrimSamples(gradient, alpha, palette) {
1856
+ const literal = [...gradient.matchAll(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/g)].map((stop) => ({
1857
+ hex: rgbToHex(Number(stop[1]), Number(stop[2]), Number(stop[3])),
1858
+ alpha: alpha * (stop[4] === void 0 ? 1 : Number(stop[4]))
1859
+ }));
1860
+ const tokens = [...gradient.matchAll(/var\(--tb-([\w-]+)\)/g)].flatMap((stop) => {
1861
+ const hex = stop[1] ? resolveConcreteColorHex(stop[1], palette) : null;
1862
+ return hex ? [{
1863
+ hex,
1864
+ alpha
1865
+ }] : [];
1866
+ });
1867
+ return [...literal, ...tokens];
1868
+ }
1869
+ /** The ink with the stronger worst-pixel guarantee identifies the veil tone.
1870
+ * No readable samples (or a tie) leaves classification to the foreground owner.
1871
+ */
1872
+ function scrimTone(samples) {
1873
+ if (samples.length === 0) return null;
1874
+ const worst = (foregroundHex) => Math.min(...samples.map((sample) => worstCaseScrimContrast({
1875
+ foregroundHex,
1876
+ scrimHex: sample.hex,
1877
+ alpha: sample.alpha
1878
+ })));
1879
+ const white = worst(WHITE);
1880
+ const black = worst(BLACK);
1881
+ return white === black ? null : white > black ? "dark" : "light";
1882
+ }
1883
+ //#endregion
1884
+ //#region ../theme-core/src/palette/expandPalette.ts
1885
+ function colorsToMap(palette) {
1886
+ const map = {};
1887
+ for (const c of palette.colors) map[c.name] = c.hex;
1888
+ return map;
1889
+ }
1890
+ const nonShadeablePaletteRoleNames = /* @__PURE__ */ new Set([
1891
+ "success",
1892
+ "warning",
1893
+ "destructive"
1894
+ ]);
1895
+ /**
1896
+ * Status role aliases the persisted palette does not carry itself.
1897
+ *
1898
+ * Generators reference `--tb-error` (the site-style-owned input error border)
1899
+ * and `--tb-info` (`.alert-info`, `.status-info`, the field-note rule), but the
1900
+ * palette schema only defines `destructive` and has no `info` role at all.
1901
+ * Without these aliases those declarations name variables that are never
1902
+ * defined and browsers drop them. The SDK bridge resolves the same pair via
1903
+ * TOKEN_ALIASES, so both runtimes agree on what a status token means.
1904
+ *
1905
+ * Runs after the danger → destructive promotion above, so `destructive` is
1906
+ * already the single source of truth for the error colour.
1907
+ */
1908
+ function statusAliasTokens(expanded) {
1909
+ const aliases = {};
1910
+ if (expanded.destructive) aliases.error = expanded.destructive;
1911
+ if (expanded.accent) aliases.info = expanded.accent;
1912
+ return aliases;
1913
+ }
1914
+ function expandPalette(palette, options = {}) {
1915
+ return {
1916
+ ...expandBasePalette(palette),
1917
+ ...arrangementPaletteTokens(colorsToMap(palette), options)
1918
+ };
1919
+ }
1920
+ function expandBasePalette(palette) {
1921
+ const base = colorsToMap(palette);
1922
+ const expanded = { ...base };
1923
+ const roles = paletteInkRoles(base);
1924
+ generateNeutralScale({
1925
+ steps: 11,
1926
+ tint: neutralTint(base.background)
1927
+ }).forEach((n) => {
1928
+ expanded[n.name] = n.hex;
1929
+ });
1930
+ for (const [name, hex] of Object.entries(base)) {
1931
+ if (nonShadeablePaletteRoleNames.has(name)) continue;
1932
+ if (hex) generateShades(hex, name).forEach((shade) => {
1933
+ expanded[shade.name] = shade.hex;
1934
+ });
1935
+ }
1936
+ if (base.text) expanded.body = base.text;
1937
+ if (base.danger && !base.destructive) expanded.destructive = base.danger;
1938
+ Object.assign(expanded, statusAliasTokens(expanded));
1939
+ expanded.mutedText = readableMutedText(expanded["neutral-500"] ?? "#888", base, roles);
1940
+ for (const [token, hex] of Object.entries({ ...expanded })) {
1941
+ if (!hex || !isOnColorBackgroundCandidateToken(token)) continue;
1942
+ const onToken = onColorTokenName(token);
1943
+ if (expanded[onToken]) continue;
1944
+ expanded[onToken] = paletteInkOnSolid(hex, roles).hex;
1945
+ }
1946
+ Object.assign(expanded, groundMutedInkTokens(expanded));
1947
+ return expanded;
1948
+ }
1949
+ /**
1950
+ * The strongest tints booking and registration screens lay over a ground
1951
+ * where secondary text sits: selected option cards, event tiles and summaries
1952
+ * tint `primary` at 5–10% (`blocks/vars/appointment-booking.ts`,
1953
+ * `blocks/vars/event-registration.ts`, `blocks-static/event-registration.css`),
1954
+ * the appointment summary and hover rows tint `text`/`onSurface` at 5%, and the
1955
+ * registration summary lays `muted` at 42%. A weaker tint of the same colour
1956
+ * sits between the ground and these, so solving against the strongest covers it.
1957
+ * A selected card lays its tint over its own ground, so the same list applies
1958
+ * over the surface and over the page background that event option cards paint.
1959
+ * A new tint under secondary text belongs here, and the CSS paints it with
1960
+ * the ground's faded tint token (`groundTintToken`) before the colour itself;
1961
+ * `secondaryTextTints.test.ts` fails if the CSS lays one that isn't covered or
1962
+ * doesn't read that token.
1963
+ */
1964
+ const SURFACE_SECONDARY_TEXT_TINTS = [
1965
+ {
1966
+ token: "primary",
1967
+ alpha: .1
1968
+ },
1969
+ {
1970
+ token: "text",
1971
+ alpha: .05
1972
+ },
1973
+ {
1974
+ token: "onSurface",
1975
+ alpha: .05
1976
+ },
1977
+ {
1978
+ token: "muted",
1979
+ alpha: .42
1980
+ }
1981
+ ];
1982
+ /** The strongest tint alpha per colour, for the CSS that paints those tints. */
1983
+ const SURFACE_SECONDARY_TEXT_TINT_ALPHA = Object.fromEntries(SURFACE_SECONDARY_TEXT_TINTS.map(({ token, alpha }) => [token, alpha]));
1984
+ /**
1985
+ * The grounds booking and registration secondary text sits on, with the token
1986
+ * its solved muted ink is published as: the surface (panels, details) and the
1987
+ * page background (event registration's option, ticket and payment cards).
1988
+ */
1989
+ const MUTED_INK_TOKENS = {
1990
+ surface: "onSurfaceMuted",
1991
+ background: "onBackgroundMuted"
1992
+ };
1993
+ /**
1994
+ * Secondary text on a ground, solved rather than faded from the ground's
1995
+ * on-colour in CSS, against the ground and every tint laid over it.
1996
+ *
1997
+ * Some palettes admit no single ink for all of them: a mid-tone surface with a
1998
+ * dark `primary` tint and a light `muted` one. The plain ground always has one
1999
+ * (black or white reads on any solid), so the ground is kept, each tint is kept
2000
+ * in list order while one ink still reads on everything kept so far, and the
2001
+ * tints that can't join are faded toward the ground until that ink reads on
2002
+ * them too. Fading the tint rather than giving it an ink of its own keeps every
2003
+ * line of text on it (titles and prices as well as secondary text) close to the
2004
+ * ground its colours were chosen for. Hosted palettes and the SDK bridge both
2005
+ * derive it here.
2006
+ */
2007
+ function groundMutedInk(palette, ground) {
2008
+ const groundHex = palette[ground];
2009
+ if (!groundHex) return null;
2010
+ const preferred = palette[onColorTokenName(ground)] ?? null;
2011
+ const roles = paletteInkRoles(palette);
2012
+ const initial = {
2013
+ grounds: [groundHex],
2014
+ hex: paletteMutedInkOnSolid(groundHex, preferred, roles),
2015
+ uncovered: []
2016
+ };
2017
+ const solved = SURFACE_SECONDARY_TEXT_TINTS.reduce((kept, { token, alpha }) => {
2018
+ const tintHex = palette[token];
2019
+ if (!tintHex) return kept;
2020
+ const grounds = [...kept.grounds, compositeHex(tintHex, alpha, groundHex)];
2021
+ const ink = paletteMutedInk(grounds, preferred, roles);
2022
+ return ink.kind === "unpaintable" ? {
2023
+ ...kept,
2024
+ uncovered: [...kept.uncovered, {
2025
+ token,
2026
+ alpha,
2027
+ tintHex
2028
+ }]
2029
+ } : {
2030
+ ...kept,
2031
+ grounds,
2032
+ hex: ink.hex
2033
+ };
2034
+ }, initial);
2035
+ return {
2036
+ hex: solved.hex,
2037
+ fadedTints: solved.uncovered.map(({ token, alpha, tintHex }) => ({
2038
+ token,
2039
+ hex: tintFadedUntilInkReads(tintHex, alpha, groundHex, solved.hex)
2040
+ }))
2041
+ };
2042
+ }
2043
+ /** The tint colour a ground publishes in place of a tint its muted ink can't read on, e.g. `surfaceTintMuted`. */
2044
+ function groundTintToken(ground, tint) {
2045
+ return `${ground}Tint${tint.charAt(0).toUpperCase()}${tint.slice(1)}`;
2046
+ }
2047
+ /**
2048
+ * The tint blended toward the ground in 1% steps, stopping at the first that
2049
+ * the ink reads on when laid at `alpha`. The ground itself always reads, since
2050
+ * the ink was solved on it.
2051
+ */
2052
+ function tintFadedUntilInkReads(tintHex, alpha, groundHex, inkHex) {
2053
+ const tint = hexToRgb(tintHex);
2054
+ const ground = hexToRgb(groundHex);
2055
+ return Array.from({ length: 101 }, (_, index) => {
2056
+ const amount = index / 100;
2057
+ return rgbToHex(mix$1(tint.r, ground.r, amount), mix$1(tint.g, ground.g, amount), mix$1(tint.b, ground.b, amount));
2058
+ }).find((hex) => contrastRatio(inkHex, compositeHex(hex, alpha, groundHex)) >= 4.5) ?? groundHex;
2059
+ }
2060
+ /**
2061
+ * The muted ink tokens a palette doesn't store itself, and the faded tint
2062
+ * colours of each ground whose ink is solved here, as hex.
2063
+ */
2064
+ function groundMutedInkTokens(palette) {
2065
+ return Object.fromEntries(Object.entries(MUTED_INK_TOKENS).flatMap(([ground, token]) => {
2066
+ if (palette[token]) return [];
2067
+ const ink = groundMutedInk(palette, ground);
2068
+ if (!ink) return [];
2069
+ const faded = ink.fadedTints.map(({ token: tint, hex }) => [groundTintToken(ground, tint), hex]);
2070
+ return [[token, ink.hex], ...faded.filter(([name]) => !palette[name])];
2071
+ }));
2072
+ }
2073
+ /**
2074
+ * The neutral step stays when it reads on the ground. Otherwise (a dark palette
2075
+ * on a mid-tone ground, or a tinted light one) it's the ground-to-text blend
2076
+ * with a 4.5:1 floor, heading for the palette's own ink on that ground.
2077
+ */
2078
+ function readableMutedText(step, base, roles) {
2079
+ const ground = base.background || base.surface;
2080
+ if (!ground || contrastRatio(step, ground) >= 4.5) return step;
2081
+ return paletteMutedInkOnSolid(ground, null, roles);
2082
+ }
2083
+ /**
2084
+ * Derived decoration colours never become editable palette swatches. The mark
2085
+ * blends toward literal black or white: it's a graphic endpoint for a 3:1
2086
+ * search, not text, so it stays off the palette ink rule.
2087
+ */
2088
+ function deriveSurfaceDecorationColors(ground, text, accent) {
2089
+ const ink = pickBlackOrWhiteTextColor(ground);
2090
+ return {
2091
+ line: firstContrastBlend(ground, text, ground, 1.5),
2092
+ mark: firstContrastBlend(accent, ink, ground, 3)
2093
+ };
2094
+ }
2095
+ function firstContrastBlend(from, to, ground, threshold) {
2096
+ const start = hexToRgb(from);
2097
+ const end = hexToRgb(to);
2098
+ return Array.from({ length: 101 }, (_, index) => {
2099
+ const amount = index / 100;
2100
+ return rgbToHex(mix$1(start.r, end.r, amount), mix$1(start.g, end.g, amount), mix$1(start.b, end.b, amount));
2101
+ }).find((hex) => contrastRatio(hex, ground) >= threshold) ?? to;
2102
+ }
2103
+ /** `markSource` names the colour surface marks are derived from when a style marks in its brand rather than its accent. */
2104
+ function arrangementPaletteTokens(base, options) {
2105
+ if (options.arrangement !== true || !base.text) return {};
2106
+ return {
2107
+ onText: base.onText ?? paletteInkOnSolid(base.text, paletteInkRoles(base)).hex,
2108
+ ...options.marksFrom === "primary" && base.primary ? { markSource: base.primary } : {}
2109
+ };
2110
+ }
2111
+ //#endregion
2112
+ export { onColorTokenName as A, preparePaletteColourIndex as B, paletteInk as C, paletteMutedInkOnSolid as D, paletteInkToken as E, requirePaletteColorsFromEntries as F, oklabToSrgb as G, featuresFromHex as H, ORDINARY_TEXT_MIN_CONTRAST_RATIO as I, rgbToHex as J, oklchToHexGamut as K, contrastRatio as L, resolveOpaqueSurfaceHex as M, paletteValueKey as N, colourFamily as O, paletteValueKeySchema as P, hexLuminance as R, neutralInk as S, paletteInkRoles as T, hexToRgb as U, solidPaint as V, oklabToOklch as W, srgbToOklab as Y, ELEVATION_OFFSET as _, compositeHex as a, pickBlackOrWhiteTextColor as b, scrimTone as c, resolveSolidButtonColour as d, BUTTON_CONTRAST_POLICY as f, DEFAULT_BUTTON_SIZES as g, BORDER_WIDTH_MAP as h, groundMutedInkTokens as i, resolveConcreteColorHex as j, isOnColorBackgroundCandidateToken as k, buttonStateBorder as l, BORDER_RADIUS_MAP as m, deriveSurfaceDecorationColors as n, gradientScrimSamples as o, formatButtonColourContractError as p, oklchToOklab as q, expandPalette as r, minimumScrimOpacity as s, SURFACE_SECONDARY_TEXT_TINT_ALPHA as t, compileButtonColourStates as u, FONT_SIZE_MAP as v, paletteInkOnSolid as w, inkFrom as x, generateShadowValue as y, luminanceInterval as z };