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