@riverbankcms/sdk 0.181.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 (196) hide show
  1. package/dist/_dts/{BlocksIslandsHydrator-CVCasDPz.d.ts → BlocksIslandsHydrator-Bvw2bUif.d.ts} +1 -1
  2. package/dist/_dts/{Page-Dtj2Ui3S.d.ts → Page-B2EAT-bE.d.ts} +7 -7
  3. package/dist/_dts/{SdkPreviewMode-D1f_60WW.d.ts → SdkPreviewMode-D0vww6rh.d.ts} +2 -2
  4. package/dist/_dts/{client-Chr9pNVW.d.ts → client-D6T430bk.d.ts} +1 -3
  5. package/dist/_dts/{content-types-kjccgopX.d.ts → content-types-wZVWccC6.d.ts} +2 -2
  6. package/dist/_dts/{contracts-BodaiS00.d.ts → contracts-B-vtOcr8.d.ts} +3 -3
  7. package/dist/_dts/{generatePageMetadata-BS6kaJFp.d.ts → generatePageMetadata-CxfwHE6z.d.ts} +2 -2
  8. package/dist/_dts/{index-Brl6_I2j.d.ts → index-CEyYMhLJ.d.ts} +1 -1
  9. package/dist/_dts/{index-DG0OvBs0.d.ts → index-CQrb3Ccc.d.ts} +4 -4
  10. package/dist/_dts/{index-Dy50xUMK.d.ts → index-CciRW_w1.d.ts} +2 -2
  11. package/dist/_dts/{index-Diqt0PvG.d.ts → index-Cqxis-nv.d.ts} +1 -1
  12. package/dist/_dts/{index-CJkefwYh.d.ts → index-DIU-wL1M.d.ts} +2 -2
  13. package/dist/_dts/{index-D1WpKwQe.d.ts → index-DqPKdeTk.d.ts} +1 -1
  14. package/dist/_dts/{loadContent-BgxshKrA.d.ts → loadContent-D0wrxiSp.d.ts} +7 -7
  15. package/dist/_dts/{request-CA0izds5.d.ts → request-DEwxUSw8.d.ts} +130 -28
  16. package/dist/_dts/{resolveBlockData-ChQmwEd3.d.ts → resolveBlockData-VaG_MYbN.d.ts} +5 -5
  17. package/dist/_dts/{resolvePageContent-BvGyvblj.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 -1
  28. package/dist/_dts/sdk/src/index.d.ts +7 -7
  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 +7 -7
  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 +1 -1
  36. package/dist/_dts/sdk/src/portal/index.d.ts +1 -1
  37. package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
  38. package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
  39. package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
  40. package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
  41. package/dist/_dts/sdk/src/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-BgFbJQhU.d.ts → serviceBookingOutline-DtQuFlID.d.ts} +6 -6
  54. package/dist/_dts/{types-CgS3xLk8.d.ts → types-B3RjeBLV.d.ts} +2 -2
  55. package/dist/_dts/{types-CQrsP1x_.d.ts → types-BvUSGQrw.d.ts} +3 -3
  56. package/dist/_dts/{types-R65DKjPn.d.ts → types-CkRFtBqd.d.ts} +7 -7
  57. package/dist/_dts/{validation-6LTIbuBA.d.ts → validation-BZA3DhcV.d.ts} +4 -4
  58. package/dist/client/{BlocksIslandsHydrator-DqZPz6oW.mjs → BlocksIslandsHydrator-CQMf0HdN.mjs} +17 -17
  59. package/dist/client/{BookingMailingListNote-uWfR2kaG.mjs → BookingMailingListNote-7kdvuPow.mjs} +6 -6
  60. package/dist/client/{BookingQuestionFields-CyNIKw6k.mjs → BookingQuestionFields-BJI7mZuV.mjs} +1 -1
  61. package/dist/client/{CalendarNavigationChevron-BGCX3zwG.mjs → CalendarNavigationChevron-DPUD6wjy.mjs} +7 -7
  62. package/dist/client/{DemoBookingPortalAccess-DFLPyuqe.mjs → DemoBookingPortalAccess-8kwNF9HN.mjs} +4 -4
  63. package/dist/client/{EventCalendar.client-zDL4-t-B.mjs → EventCalendar.client-Dhb14bcC.mjs} +9 -9
  64. package/dist/client/{EventCombined.client-uciDKLID.mjs → EventCombined.client-C1jEZBN9.mjs} +8 -8
  65. package/dist/client/{EventItem-CwzrjcRw.mjs → EventItem-Bb0ppG2N.mjs} +8 -176
  66. package/dist/client/{EventListWeekNavigation-ChvcnPma.mjs → EventListWeekNavigation-DMryCaNV.mjs} +1 -1
  67. package/dist/client/{EventListing.client-DA57Qoyx.mjs → EventListing.client-BuH5kKA3.mjs} +3 -3
  68. package/dist/client/{EventListing.view-DZ0qMFF4.mjs → EventListing.view-DsqvuulZ.mjs} +7 -7
  69. package/dist/client/{EventRegistrationPayment-DSqCJL8E.mjs → EventRegistrationPayment-D4FvQSFF.mjs} +31 -164
  70. package/dist/client/{Page-C7mygH_f.mjs → Page-sV6BJkXX.mjs} +172 -102
  71. package/dist/client/{SiteTermsAgreementField-B4z-e4Wq.mjs → SiteTermsAgreementField-VfSd6JU-.mjs} +2 -2
  72. package/dist/client/{StepIndicator-Dn_DY4oY.mjs → StepIndicator-B6o5B7g3.mjs} +1 -1
  73. package/dist/client/{StepIndicator-atfDU82W.mjs → StepIndicator-BTqO7cJl.mjs} +220 -19
  74. package/dist/client/{accessibleSurfaces-n6kS6Hct.mjs → accessibleSurfaces-BogaGutk.mjs} +966 -693
  75. package/dist/client/{accordion-CsW8U3ff.mjs → accordion-6cuswD_s.mjs} +1 -1
  76. package/dist/client/{booking-form.client-cBWM392H.mjs → booking-form.client-BOMe_SKi.mjs} +15 -15
  77. package/dist/client/{bookingForm-DgySpp6C.mjs → bookingForm-DSCH-VHo.mjs} +4 -4
  78. package/dist/client/bookings.mjs +5 -5
  79. package/dist/client/{boxStyleClassNames-BpGVdLFD.mjs → boxStyleClassNames-BFuqZCfz.mjs} +2 -2
  80. package/dist/client/{carousel-DJoleFV3.mjs → carousel-CGyQVV1M.mjs} +1 -1
  81. package/dist/client/{cart-EO5o6uPH.mjs → cart-BYOe7MCh.mjs} +3 -3
  82. package/dist/client/{cart.client-D_gPw45z.mjs → cart.client-BKFkaXdV.mjs} +1 -1
  83. package/dist/client/{checkout-NVfZW0kR.mjs → checkout-Dwd7Di77.mjs} +3 -3
  84. package/dist/client/{checkout.client-DD3JuqOy.mjs → checkout.client-C25hpi-z.mjs} +1 -1
  85. package/dist/client/{checkoutUrls-z2gXvlGw.mjs → checkoutUrls-tG788sw0.mjs} +1 -1
  86. package/dist/client/client.mjs +25 -6
  87. package/dist/client/{constants-CoOkvw__.mjs → constants-DdxFG3Ic.mjs} +1 -1
  88. package/dist/client/{context-CRhn9qzS.mjs → context-Hi1RuYEM.mjs} +23 -5
  89. package/dist/client/{dateFormatting-BnWB4L1s.mjs → dateFormatting-C8vBCHuo.mjs} +1 -1
  90. package/dist/client/{demoPortalMagicLink-CWDGSTBu.mjs → demoPortalMagicLink-BAL5UIDG.mjs} +1 -1
  91. package/dist/client/{enhanceHeaderSection-tdP_-Z9o.mjs → enhanceHeaderSection-Dv1Lr9kJ.mjs} +3 -3
  92. package/dist/client/{event-registration.client-D7YYKySQ.mjs → event-registration.client-dB_Z7bb-.mjs} +12 -12
  93. package/dist/client/{eventCalendar-CsAfu5d0.mjs → eventCalendar-CQnRA4Ww.mjs} +4 -4
  94. package/dist/client/{eventCombined-VXJB5CoS.mjs → eventCombined-BDOG1hVp.mjs} +4 -4
  95. package/dist/client/{eventListing-B3KIZNfY.mjs → eventListing-DSVmhy9n.mjs} +4 -4
  96. package/dist/client/{eventRegistration-BP-dEk1c.mjs → eventRegistration-CD5mRtEH.mjs} +4 -4
  97. package/dist/client/{form-DM8Zbxbv.mjs → form-DWnlEVSK.mjs} +3 -3
  98. package/dist/client/{form.client-e2z_Tlgk.mjs → form.client-D7zmeqNI.mjs} +4 -4
  99. package/dist/client/{form.parts-Ctljy1a3.mjs → form.parts-C-G6N_MK.mjs} +1 -1
  100. package/dist/client/gifting/client.mjs +7 -7
  101. package/dist/client/{gifting-DWIsqQru.mjs → gifting-Cn0jidP5.mjs} +4 -4
  102. package/dist/client/{gifting.client-QsSWF0uA.mjs → gifting.client-DVo1YFLs.mjs} +4 -4
  103. package/dist/client/{gifting.parts-CedLgwa_.mjs → gifting.parts-Bak93gD2.mjs} +2 -2
  104. package/dist/client/{headerSection-DAkRkwb-.mjs → headerSection-DjQuj_6v.mjs} +2 -2
  105. package/dist/client/{newsletter-form.client-WYja9-WN.mjs → newsletter-form.client-rIYPziZC.mjs} +5 -5
  106. package/dist/client/{newsletter-form.interactive-RuM86VAv.mjs → newsletter-form.interactive-DVt3enLr.mjs} +162 -135
  107. package/dist/client/{newsletter-form.parts-2petDnWv.mjs → newsletter-form.parts-CH6dGfdn.mjs} +1 -1
  108. package/dist/client/{newsletterForm-BUbXdA_e.mjs → newsletterForm-Cg8cBDHd.mjs} +3 -3
  109. package/dist/client/{noop-Dl4mZ-rr.mjs → noop-jesvJXEE.mjs} +239 -229
  110. package/dist/client/portal/client.mjs +269 -83
  111. package/dist/client/{portalOrders-COGn4BKG.mjs → portalOrders-oEoTvzkW.mjs} +1 -1
  112. package/dist/client/{portalRoutes-D72yvtDh.mjs → portalRoutes-ByyVZfVq.mjs} +13 -2
  113. package/dist/client/{product-detail.client-pOAryevt.mjs → product-detail.client-5aHq-vuu.mjs} +1 -1
  114. package/dist/client/{product-list.client-CcUpUiud.mjs → product-list.client-CyAk5rnC.mjs} +1 -1
  115. package/dist/client/{productDetail-BZJCfqat.mjs → productDetail-B8aZ2mqY.mjs} +3 -3
  116. package/dist/client/{productList-CiRs3mNb.mjs → productList-BuLemmod.mjs} +3 -3
  117. package/dist/client/{propsDecoder--uHW4tFM.mjs → propsDecoder-0Unsqn3R.mjs} +2 -2
  118. package/dist/client/{registry.server-CDNNd8wC.mjs → registry.server-DzvtVVD0.mjs} +352 -166
  119. package/dist/client/rendering/client.mjs +23 -23
  120. package/dist/client/rendering/islands.mjs +1 -1
  121. package/dist/client/rendering.mjs +5 -5
  122. package/dist/client/{richText-coerce-CQGE_wHV.mjs → richText-coerce-Bnng7JFA.mjs} +2 -2
  123. package/dist/client/{routeIslandApiConfig-BtCg87-N.mjs → routeIslandApiConfig-BGfcc9sk.mjs} +1 -1
  124. package/dist/client/{runtimeResponse-Ds9cmBUf.mjs → runtimeResponse-DAPVRToN.mjs} +1 -1
  125. package/dist/client/{runtimeResponse-DL_ARBpa.mjs → runtimeResponse-nXT8VAMl.mjs} +1 -1
  126. package/dist/client/{shop-Rx_gEMK8.mjs → shop-GuMqnDL-.mjs} +3 -3
  127. package/dist/client/{shop-commerce-D8evQnMT.mjs → shop-commerce-D5bDY1o1.mjs} +12 -12
  128. package/dist/client/{shop-commerce-store-C9PcsSTj.mjs → shop-commerce-store-B7sHnLwI.mjs} +1 -1
  129. package/dist/client/{shop-discount-apply.state-D5CtGfJI.mjs → shop-discount-apply.state-Dos2zdC2.mjs} +2 -2
  130. package/dist/client/{shop.client-D4lzQ9oY.mjs → shop.client-uvj5GDZb.mjs} +11 -11
  131. package/dist/client/{shopShared-BVbq7Nm-.mjs → shopShared-3giNWE3H.mjs} +2 -2
  132. package/dist/client/{src-ZSqRK3dD.mjs → src-CmXh3JWs.mjs} +5 -1
  133. package/dist/client/{timetableModel-BQJrSK0K.mjs → timetableModel-GA-hn1qM.mjs} +8 -15
  134. package/dist/client/{useAvailableSlots-Dm3lKJKR.mjs → useAvailableSlots-CBneCxbG.mjs} +2 -2
  135. package/dist/client/{useDiscountCodeUi-klgfGn7f.mjs → useDiscountCodeUi-D0kGF0C7.mjs} +1 -1
  136. package/dist/client/{useEventPagination-Jnjt7_ly.mjs → useEventPagination-xX8n_Tuu.mjs} +7 -7
  137. package/dist/client/{view-CC_yQLSA.mjs → view-DOyZc-DF.mjs} +3 -3
  138. package/dist/client/{wizardSteps-BliJOzEX.mjs → wizardSteps-B952ify5.mjs} +303 -31
  139. package/dist/preview-next/client/{PageSectionToolbar-BhL0uADo.mjs → PageSectionToolbar-BI3UCdpu.mjs} +3 -3
  140. package/dist/preview-next/client/{PreviewEditorSidebar-Ct8eIm0i.mjs → PreviewEditorSidebar-jkfLVOgY.mjs} +12 -9
  141. package/dist/preview-next/client/{PreviewEditorUI-BS32G4V9.mjs → PreviewEditorUI-DwJQs4hM.mjs} +4 -4
  142. package/dist/preview-next/client/{PreviewShell-RL0WfZXD.mjs → PreviewShell-BAxAkuz8.mjs} +5 -5
  143. package/dist/preview-next/client/{SdkPreviewModeRuntime-MK_gHeGy.mjs → SdkPreviewModeRuntime-0UVB-39f.mjs} +44 -17
  144. package/dist/preview-next/client/{previewAssistantSlot-CQyS8pcq.mjs → previewAssistantSlot-BgiYk3PB.mjs} +2577 -1683
  145. package/dist/preview-next/client/{previewChromeRoot-BSxp3Mfu.mjs → previewChromeRoot-tieNdF3E.mjs} +1 -1
  146. package/dist/preview-next/client/runtime.mjs +3 -3
  147. package/dist/preview-next/client/{sdk-runtime-DKnTzy74.mjs → sdk-runtime-DXb_Evl0.mjs} +2 -2
  148. package/dist/preview-next/client/{siteStyleAccess-BlmbvbLN.mjs → siteStyleAccess-BlN0jt2c.mjs} +1 -1
  149. package/dist/preview-next/client/{useAutosaveStatus-D-7GwZOQ.mjs → useAutosaveStatus-BUEPA4oL.mjs} +1 -1
  150. package/dist/preview-next/client/{useOpenBlockForSetup-BNZtGM5g.mjs → useOpenBlockForSetup-BVfr5P--.mjs} +1 -1
  151. package/dist/preview-next/keepAlive.mjs +1 -1
  152. package/dist/preview-next/middleware.mjs +1 -1
  153. package/dist/preview-next/{route-contract-R3PcMmax.mjs → route-contract-BHTBA48n.mjs} +20 -1
  154. package/dist/server/{Block.shared-CniF9tSu.mjs → Block.shared-hGoyEdjJ.mjs} +5 -5
  155. package/dist/server/{ThemeScopeCore-BQWsnGT6.mjs → ThemeScopeCore-BfUCTOwj.mjs} +37 -25
  156. package/dist/server/{accessibleSurfaces-WPzUAHp4.mjs → accessibleSurfaces-Dskni4Xj.mjs} +94 -361
  157. package/dist/server/{bindings-DxojjtK3.mjs → bindings-DMJH4bvo.mjs} +4 -4
  158. package/dist/server/{client-CDndhbYO.mjs → client-DrwlRNAH.mjs} +22 -3
  159. package/dist/server/config-validation.mjs +1 -1
  160. package/dist/server/config.mjs +2 -2
  161. package/dist/server/{constants-VyF5nEhL.mjs → constants-CeMywaiD.mjs} +11 -0
  162. package/dist/server/data/resolveBlockData.mjs +1 -1
  163. package/dist/server/{resolveButtonColourStates-B0O1IM16.mjs → expandPalette-ehuW8r2g.mjs} +769 -227
  164. package/dist/server/index.mjs +2 -2
  165. package/dist/server/{loadContent-BKstMBmX.mjs → loadContent-D0prFflT.mjs} +4 -4
  166. package/dist/server/{loadPage-IgNnZaqr.mjs → loadPage-CBLke9pJ.mjs} +3 -3
  167. package/dist/server/{lookMediaFrame-TFjgNG61.mjs → lookMediaFrame-H0fi4bJk.mjs} +2 -2
  168. package/dist/server/{navigation-quBYlSKD.mjs → navigation-wrcuWmgp.mjs} +1 -1
  169. package/dist/server/navigation.mjs +1 -1
  170. package/dist/server/next.mjs +8 -8
  171. package/dist/server/{overrideResolution-CCaAPpIa.mjs → overrideResolution-DUgCEH8z.mjs} +1 -1
  172. package/dist/server/page-converter.mjs +1 -1
  173. package/dist/server/{pageRenderPlan-B7iULvKe.mjs → pageRenderPlan-BHrmogsW.mjs} +161 -244
  174. package/dist/server/{pageRuntimeSupport-BytMroxn.mjs → pageRuntimeSupport-D2-YMRei.mjs} +1 -1
  175. package/dist/server/{pageShared-Dcs_XTIO.mjs → pageShared-CG8O31Eo.mjs} +1265 -1032
  176. package/dist/server/{parseThemeForPersistence-Bihl4W5K.mjs → parseThemeForPersistence-CrPlbJEN.mjs} +1 -1
  177. package/dist/server/{portal-CMW_b9mG.mjs → portal-pG_uhsI2.mjs} +1 -1
  178. package/dist/server/portal.mjs +2 -2
  179. package/dist/server/{prebuild-agaH-vZV.mjs → prebuild-C8Amvzce.mjs} +1 -1
  180. package/dist/server/prebuild.mjs +1 -1
  181. package/dist/server/{prefetchBlockData-DwpRjqw4.mjs → prefetchBlockData-BxUETRIZ.mjs} +2 -2
  182. package/dist/server/{registry-DM9dHfDC.mjs → registry-Cc88-23f.mjs} +1173 -745
  183. package/dist/server/rendering/components/pageShared.mjs +1 -1
  184. package/dist/server/rendering/helpers/loadPage.mjs +1 -1
  185. package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
  186. package/dist/server/rendering/server.mjs +4 -4
  187. package/dist/server/rendering.mjs +8 -8
  188. package/dist/server/{resolveBlockData-CinHGf8l.mjs → resolveBlockData-OG3KOkig.mjs} +1 -1
  189. package/dist/server/server.mjs +3 -3
  190. package/dist/server/{servicePageContent-BBBhOtdE.mjs → servicePageContent-BcFuhhD7.mjs} +5 -5
  191. package/dist/server/theme-bridge.mjs +33 -8
  192. package/dist/server/theme.mjs +1 -1
  193. package/dist/server/{validation-DG5jX3jH.mjs → validation-BovmbS8N.mjs} +3 -3
  194. package/dist/server/{version-CipbxPHL.mjs → version-hws4hgyX.mjs} +1 -1
  195. package/dist/styles/index.css +86 -46
  196. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
- import { c as buttonEffectApplicationSchema, m as parseOpaqueButtonColourToken, s as unsafeAsOpaqueButtonColourToken, w as surfaceForegroundValue } from "./types-BKaBZFjD.mjs";
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";
2
+ import { z } from "zod";
2
3
  //#region ../theme-core/src/palette/utils/colorConversion.ts
3
4
  const clamp01 = (x) => Math.max(0, Math.min(1, x));
4
5
  const mod = (a, n) => (a % n + n) % n;
@@ -227,6 +228,10 @@ function solidPaint(hex, index) {
227
228
  const y = hexLuminance(hex, index);
228
229
  return new Interval(y, y);
229
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
+ }
230
235
  function luminanceRatio(a, b) {
231
236
  return a >= b ? (a + .05) / (b + .05) : (b + .05) / (a + .05);
232
237
  }
@@ -242,8 +247,8 @@ function assertContrastRatio(ratio) {
242
247
  * The one black-or-white rule: literal black or white, whichever contrasts more
243
248
  * with the whole paint (black on a tie). It always returns, even when neither
244
249
  * reaches the ratio a caller wants; callers decide what a shortfall means.
245
- * A style's preferred neutral is a separate input (`neutralInk`) and never
246
- * 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.
247
252
  */
248
253
  function maxContrastBlackOrWhite(paint) {
249
254
  const blackContrast = (paint.lo + .05) / .05;
@@ -256,6 +261,9 @@ function maxContrastBlackOrWhite(paint) {
256
261
  ratio: whiteContrast
257
262
  };
258
263
  }
264
+ function literalInkHex(ink) {
265
+ return ink === "black" ? "#000000" : "#FFFFFF";
266
+ }
259
267
  function contrastRatio(hex1, hex2, index) {
260
268
  const L1 = indexedLuminance(hex1, index);
261
269
  const L2 = indexedLuminance(hex2, index);
@@ -263,119 +271,116 @@ function contrastRatio(hex1, hex2, index) {
263
271
  return (hi + .05) / (lo + .05);
264
272
  }
265
273
  //#endregion
266
- //#region ../theme-core/src/palette/generateShades.ts
267
- function generateShades(hexColor, name) {
268
- const shadeSteps = [
269
- 50,
270
- 100,
271
- 200,
272
- 300,
273
- 400,
274
- 500,
275
- 600,
276
- 700,
277
- 800,
278
- 900,
279
- 950
280
- ];
281
- const base = featuresFromHex(hexColor);
282
- const hue = base.okH;
283
- const baseChroma = base.okC;
284
- const toneMap = {
285
- 50: .975,
286
- 100: .945,
287
- 200: .89,
288
- 300: .82,
289
- 400: .74,
290
- 500: .66,
291
- 600: .58,
292
- 700: .49,
293
- 800: .4,
294
- 900: .28,
295
- 950: .16
296
- };
297
- const shadeDefs = shadeSteps.map((step, idx) => {
298
- const t = idx / (shadeSteps.length - 1);
299
- const L = toneMap[step];
300
- const C = baseChroma * (.06 + .94 * Math.sin(Math.PI * t));
301
- return {
302
- name: `${name}-${step}`,
303
- hex: oklchToHexGamut(L, C, hue)
304
- };
305
- });
306
- shadeDefs.push({
307
- name,
308
- hex: hexColor
309
- });
310
- return shadeDefs;
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}`);
311
281
  }
312
- //#endregion
313
- //#region ../theme-core/src/palette/neutralScale.ts
314
- /**
315
- * A neutral scale from near-white (`neutral-50`) to near-black (`neutral-950`)
316
- * on every palette, light or dark. Readers that want "the ground" or "the
317
- * text" ask the palette for those roles, not a fixed end of this scale.
318
- */
319
- function generateNeutralScale({ steps = 11, warm = false } = {}) {
320
- const shadeNames = [
321
- 50,
322
- 100,
323
- 200,
324
- 300,
325
- 400,
326
- 500,
327
- 600,
328
- 700,
329
- 800,
330
- 900,
331
- 950
332
- ];
333
- const count = Math.min(steps, shadeNames.length);
334
- return shadeNames.slice(0, count).map((shadeName, index) => ({
335
- name: `neutral-${shadeName}`,
336
- hex: oklchToHexGamut(mix(.98, .1, index / (count - 1)), .02, warm ? 85 : 250)
337
- }));
282
+ function paletteColorFingerprint(colors) {
283
+ return PALETTE_TOKEN_NAMES.map((name) => `${name}:${colors[name]}`).join("|");
338
284
  }
339
- function mix(a, b, t) {
340
- return a + (b - a) * Math.max(0, Math.min(1, t));
285
+ function canonicalPaletteHashInput(colors, mode) {
286
+ return `${mode}|${paletteColorFingerprint(colors)}`;
341
287
  }
342
- //#endregion
343
- //#region ../theme-core/src/palette/utils/textColor.ts
344
288
  /**
345
- * Pick the better of black/white text for a given background using actual
346
- * contrast ratios, not a simple luminance cutoff. This is
347
- * `maxContrastBlackOrWhite` for a solid ground.
348
- *
349
- * @param background - Background color in hex or rgb/rgba format (e.g., '#FFFFFF' or 'rgb(255, 255, 255)')
350
- * @param _minContrast - Kept for callers. It cannot change the result: when
351
- * only one of black or white reaches it, that one is also the better of the two.
352
- * @returns '#000000' for light backgrounds, '#FFFFFF' for dark backgrounds
353
- */
354
- function pickBlackOrWhiteTextColor(background, _minContrast = 4.5) {
355
- const { r, g, b } = parseColorToRgb(background);
356
- return maxContrastBlackOrWhite(luminanceInterval(relativeLuminance(r, g, b))).ink === "black" ? "#000000" : "#FFFFFF";
357
- }
358
- /**
359
- * Backwards-compatible alias for callers that want the best black/white text
360
- * color for a background.
289
+ * Stable curated-catalogue identity. Do not reorder roles: the order comes
290
+ * from PALETTE_TOKEN_NAMES through canonicalPaletteHashInput.
361
291
  */
362
- function getTextColorForBackground(background) {
363
- return pickBlackOrWhiteTextColor(background);
364
- }
365
- function parseColorToRgb(input) {
366
- const trimmed = input.trim();
367
- if (trimmed.startsWith("#")) return hexToRgb(trimmed);
368
- 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);
369
- if (rgbMatch?.[1] && rgbMatch[2] && rgbMatch[3]) return {
370
- r: clamp255(Number(rgbMatch[1])),
371
- g: clamp255(Number(rgbMatch[2])),
372
- b: clamp255(Number(rgbMatch[3]))
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;
313
+ }
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
373
375
  };
374
- throw new Error("Unsupported color format");
375
376
  }
376
- function clamp255(value) {
377
- if (Number.isNaN(value)) return 0;
378
- 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;
379
384
  }
380
385
  //#endregion
381
386
  //#region ../theme-core/src/palette/utils/onColor.ts
@@ -401,117 +406,6 @@ function isOnColorBackgroundCandidateToken(token) {
401
406
  return BACKGROUND_ROLE_NAMES.has(role);
402
407
  }
403
408
  //#endregion
404
- //#region ../theme-core/src/palette/expandPalette.ts
405
- function colorsToMap(palette) {
406
- const map = {};
407
- for (const c of palette.colors) map[c.name] = c.hex;
408
- return map;
409
- }
410
- const nonShadeablePaletteRoleNames = /* @__PURE__ */ new Set([
411
- "success",
412
- "warning",
413
- "destructive"
414
- ]);
415
- /**
416
- * Status role aliases the persisted palette does not carry itself.
417
- *
418
- * Generators reference `--tb-error` (the site-style-owned input error border)
419
- * and `--tb-info` (`.alert-info`, `.status-info`, the field-note rule), but the
420
- * palette schema only defines `destructive` and has no `info` role at all.
421
- * Without these aliases those declarations name variables that are never
422
- * defined and browsers drop them. The SDK bridge resolves the same pair via
423
- * TOKEN_ALIASES, so both runtimes agree on what a status token means.
424
- *
425
- * Runs after the danger → destructive promotion above, so `destructive` is
426
- * already the single source of truth for the error colour.
427
- */
428
- function statusAliasTokens(expanded) {
429
- const aliases = {};
430
- if (expanded.destructive) aliases.error = expanded.destructive;
431
- if (expanded.accent) aliases.info = expanded.accent;
432
- return aliases;
433
- }
434
- function expandPalette(palette, options = {}) {
435
- return {
436
- ...expandBasePalette(palette),
437
- ...arrangementPaletteTokens(colorsToMap(palette), options)
438
- };
439
- }
440
- function expandBasePalette(palette) {
441
- const base = colorsToMap(palette);
442
- const expanded = { ...base };
443
- generateNeutralScale({
444
- steps: 11,
445
- warm: false
446
- }).forEach((n) => {
447
- expanded[n.name] = n.hex;
448
- });
449
- for (const [name, hex] of Object.entries(base)) {
450
- if (nonShadeablePaletteRoleNames.has(name)) continue;
451
- if (hex) generateShades(hex, name).forEach((shade) => {
452
- expanded[shade.name] = shade.hex;
453
- });
454
- }
455
- if (base.text) expanded.body = base.text;
456
- if (base.danger && !base.destructive) expanded.destructive = base.danger;
457
- Object.assign(expanded, statusAliasTokens(expanded));
458
- expanded.mutedText = readableMutedText(expanded["neutral-500"] ?? "#888", base);
459
- for (const [token, hex] of Object.entries({ ...expanded })) {
460
- if (!hex || !isOnColorBackgroundCandidateToken(token)) continue;
461
- const onToken = onColorTokenName(token);
462
- if (expanded[onToken]) continue;
463
- expanded[onToken] = getTextColorForBackground(hex);
464
- }
465
- return expanded;
466
- }
467
- /**
468
- * The neutral step stays when it reads on the ground. Otherwise (a dark palette
469
- * on a mid-tone ground, or a tinted light one) it's the ground-to-text blend
470
- * with a 4.5:1 floor, heading for black or white when the text can't reach it.
471
- */
472
- function readableMutedText(step, base) {
473
- const ground = base.background || base.surface;
474
- if (!ground || contrastRatio(step, ground) >= 4.5) return step;
475
- return deriveSurfaceMutedColor(ground, base.text && contrastRatio(base.text, ground) >= 4.5 ? base.text : getTextColorForBackground(ground));
476
- }
477
- /** Derived decoration colours never become editable palette swatches. */
478
- function deriveSurfaceDecorationColors(ground, text, accent) {
479
- const ink = getTextColorForBackground(ground);
480
- return {
481
- line: firstContrastBlend(ground, text, ground, 1.5),
482
- mark: firstContrastBlend(accent, ink, ground, 3)
483
- };
484
- }
485
- /** Secondary ink is blended toward its ground, with an ordinary-text contrast floor. */
486
- function deriveSurfaceMutedColor(ground, text) {
487
- const start = hexToRgb(ground);
488
- const end = hexToRgb(text);
489
- 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));
490
- return firstSafeMutedSample(sample, ground, 0, 100);
491
- }
492
- /** The blend moves monotonically from the ground toward its validated ink. */
493
- function firstSafeMutedSample(sample, ground, low, high) {
494
- if (low === high) return sample(high);
495
- const middle = Math.floor((low + high) / 2);
496
- return contrastRatio(sample(middle), ground) >= 4.5 ? firstSafeMutedSample(sample, ground, low, middle) : firstSafeMutedSample(sample, ground, middle + 1, high);
497
- }
498
- function firstContrastBlend(from, to, ground, threshold) {
499
- const start = hexToRgb(from);
500
- const end = hexToRgb(to);
501
- return Array.from({ length: 101 }, (_, index) => {
502
- const amount = index / 100;
503
- return rgbToHex(mix$1(start.r, end.r, amount), mix$1(start.g, end.g, amount), mix$1(start.b, end.b, amount));
504
- }).find((hex) => contrastRatio(hex, ground) >= threshold) ?? to;
505
- }
506
- /** `markSource` names the colour surface marks are derived from when a style marks in its brand rather than its accent. */
507
- function arrangementPaletteTokens(base, options) {
508
- if (options.arrangement !== true || !base.text) return {};
509
- return {
510
- onText: getTextColorForBackground(base.text),
511
- ...options.marksFrom === "primary" && base.primary ? { markSource: base.primary } : {}
512
- };
513
- }
514
- //#endregion
515
409
  //#region \0@oxc-project+runtime@0.137.0/helpers/esm/assertClassBrand.js
516
410
  function _assertClassBrand(e, t, n) {
517
411
  if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
@@ -609,6 +503,250 @@ function member(hex, sample) {
609
503
  };
610
504
  }
611
505
  //#endregion
506
+ //#region ../theme-core/src/palette/utils/inkSolver.ts
507
+ /**
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).
511
+ */
512
+ const BRAND_INK_MAX_DELTA_E = .08;
513
+ /**
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.
519
+ */
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
+ };
559
+ }
560
+ /**
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.
566
+ */
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
+ }
589
+ /**
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`.
593
+ */
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
+ }
627
+ /**
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.
632
+ */
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
+ }
667
+ /**
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.
670
+ */
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
+ }
676
+ /**
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.
684
+ */
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
+ };
709
+ }
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;
715
+ }
716
+ //#endregion
717
+ //#region ../theme-core/src/palette/utils/textColor.ts
718
+ /**
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.
724
+ *
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
729
+ */
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));
748
+ }
749
+ //#endregion
612
750
  //#region ../theme-core/src/buttons/constants.ts
613
751
  /**
614
752
  * Shared constants for button CSS generation
@@ -1454,13 +1592,13 @@ function resolveSolid(input, backgroundToken, preferredForeground) {
1454
1592
  function resolveSolidButtonColour(input, backgroundToken, preferredForeground) {
1455
1593
  return resolveSolid(input, backgroundToken, preferredForeground);
1456
1594
  }
1457
- /** 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. */
1458
1596
  function resolveSolidInk(input, backgroundToken, backgroundHex, preferredForeground) {
1459
1597
  if (preferredForeground !== void 0) {
1460
1598
  const preferred = checkedSolidInk(input, backgroundToken, backgroundHex, preferredForeground);
1461
1599
  if (preferred) return preferred;
1462
1600
  }
1463
- return checkedSolidInk(input, backgroundToken, backgroundHex, unsafeAsOpaqueButtonColourToken(solidForegroundToken(backgroundToken))) ?? blackOrWhiteSolidInk(backgroundToken, backgroundHex);
1601
+ return checkedSolidInk(input, backgroundToken, backgroundHex, unsafeAsOpaqueButtonColourToken(solidForegroundToken(backgroundToken))) ?? paletteSolidInk(input, backgroundToken, backgroundHex);
1464
1602
  }
1465
1603
  function checkedSolidInk(input, backgroundToken, backgroundHex, foregroundToken) {
1466
1604
  const candidate = input.palette[foregroundToken];
@@ -1482,14 +1620,18 @@ function checkedSolidInk(input, backgroundToken, backgroundHex, foregroundToken)
1482
1620
  };
1483
1621
  return null;
1484
1622
  }
1485
- function blackOrWhiteSolidInk(backgroundToken, backgroundHex) {
1486
- 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);
1487
1629
  return {
1488
- foregroundHex,
1630
+ foregroundHex: literal,
1489
1631
  colour: {
1490
1632
  kind: "known-solid",
1491
1633
  backgroundCss: tokenCss(backgroundToken),
1492
- foregroundCss: foregroundHex
1634
+ foregroundCss: literal
1493
1635
  }
1494
1636
  };
1495
1637
  }
@@ -1567,4 +1709,404 @@ function interpolateHex(startHex, endHex, position) {
1567
1709
  return `#${channel(start.r, end.r)}${channel(start.g, end.g)}${channel(start.b, end.b)}`;
1568
1710
  }
1569
1711
  //#endregion
1570
- export { featuresFromHex as A, contrastRatio as C, relativeLuminance as D, preparePaletteColourIndex as E, oklchToOklab as F, rgbToHex as I, srgbToOklab as L, oklabToOklch as M, oklabToSrgb as N, solidPaint as O, oklchToHexGamut as P, assertContrastRatio as S, maxContrastBlackOrWhite as T, isOnColorBackgroundCandidateToken as _, formatButtonColourContractError as a, pickBlackOrWhiteTextColor as b, DEFAULT_BUTTON_SIZES as c, generateShadowValue as d, colourFamily as f, expandPalette as g, deriveSurfaceMutedColor as h, BUTTON_CONTRAST_POLICY as i, hexToRgb as j, worstContrast as k, ELEVATION_OFFSET as l, deriveSurfaceDecorationColors as m, compileButtonColourStates as n, BORDER_RADIUS_MAP as o, oklabDistance as p, resolveSolidButtonColour as r, BORDER_WIDTH_MAP as s, buttonStateBorder as t, FONT_SIZE_MAP as u, onColorTokenName as v, hexLuminance as w, ORDINARY_TEXT_MIN_CONTRAST_RATIO as x, getTextColorForBackground as y };
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 };