@aglyn/shared-ui-theme 1.0.0-beta.284 → 1.0.0-beta.287

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/shared-ui-theme",
3
- "version": "1.0.0-beta.284",
3
+ "version": "1.0.0-beta.287",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,9 +25,9 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/shared-data-types": "1.0.0-beta.284",
29
- "@aglyn/shared-util-tools": "1.0.0-beta.284",
30
- "@aglyn/shared-util-vendor": "1.0.0-beta.284",
28
+ "@aglyn/shared-data-types": "1.0.0-beta.287",
29
+ "@aglyn/shared-util-tools": "1.0.0-beta.287",
30
+ "@aglyn/shared-util-vendor": "1.0.0-beta.287",
31
31
  "@emotion/cache": "^11.14.0",
32
32
  "@emotion/react": "11.14.0",
33
33
  "@swc/helpers": "0.5.23",
@@ -14,8 +14,9 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import type { HostTheme, HostThemeFontCategory, HostThemeTypographyVariantKey, HostThemeScheme, HostThemeSchemeColors } from '@aglyn/shared-data-types';
17
+ import type { HostTheme, HostThemeScheme, HostThemeSchemeColors } from '@aglyn/shared-data-types';
18
18
  import { type HostThemeComponentKey } from './host-theme';
19
+ export { firstStackFamily, fontFamilyStack, readThemeFonts, THEME_HEADING_VARIANTS, writeThemeFonts, type ThemeFontChoice, type ThemeFontSelection, } from '@aglyn/shared-util-tools/theme-fonts';
19
20
  /**
20
21
  * The host theme editor's field catalog (AGL-2938): every control the editor
21
22
  * renders, the range each one accepts, the token it writes, and the write
@@ -140,7 +141,6 @@ export declare const GOOGLE_FONT_OPTIONS: Array<{
140
141
  category: 'sans-serif' | 'serif' | 'monospace' | 'display';
141
142
  weights: Array<number>;
142
143
  }>;
143
- export declare function fontFamilyStack(family: string, category: HostThemeFontCategory): string;
144
144
  export declare function getSchemeColor(colors: HostThemeSchemeColors | undefined, path: SurfaceColorPath): string | undefined;
145
145
  /** The two color schemes the editor edits, in tab order. */
146
146
  export declare const THEME_EDITOR_SCHEMES: readonly HostThemeScheme[];
@@ -285,57 +285,6 @@ export declare function readFontFamily(theme: HostTheme | undefined): string;
285
285
  * theme default. A family outside the curated list changes nothing.
286
286
  */
287
287
  export declare function writeFontFamily(theme: HostTheme, value: string): HostTheme;
288
- /**
289
- * The text styles a separate heading font is set on: `h1`…`h6`, and
290
- * `displayXl`, the platform's rung above `h1`, which a heading font left off
291
- * would draw in the body font — and load the body font's heaviest weight for.
292
- */
293
- export declare const THEME_HEADING_VARIANTS: readonly HostThemeTypographyVariantKey[];
294
- /**
295
- * One family a theme sets text in, as the font picker shows and writes it
296
- * (AGL-3656): a `fonts` entry and the role it plays.
297
- */
298
- export interface ThemeFontChoice {
299
- family: string;
300
- category: HostThemeFontCategory;
301
- /** Upright weights to load, ascending. */
302
- weights: number[];
303
- /** Italic weights to load, ascending; absent or empty for none. */
304
- italics?: number[];
305
- source: 'google' | 'custom';
306
- }
307
- /**
308
- * The theme's body font and, when it differs, its heading font. `null` is the
309
- * theme default: the base stack, nothing loaded.
310
- */
311
- export interface ThemeFontSelection {
312
- body: ThemeFontChoice | null;
313
- heading: ThemeFontChoice | null;
314
- }
315
- /** The first family a CSS font-family stack names, unquoted. */
316
- export declare function firstStackFamily(stack: unknown): string | undefined;
317
- /**
318
- * The body and heading fonts a theme sets text in (AGL-3656).
319
- *
320
- * The body font is the family the theme-wide stack names first, when the
321
- * theme loads it: a font the theme lists that no stack names draws nothing,
322
- * which is what the theme default is. The heading font is the family `h1`
323
- * names, when that is a loaded font other than the body's.
324
- */
325
- export declare function readThemeFonts(theme: HostTheme | undefined): ThemeFontSelection;
326
- /**
327
- * Sets the theme's body and heading fonts (AGL-3656): the `fonts` entries the
328
- * page loads, the theme-wide stack, and the stack of each style in
329
- * {@link THEME_HEADING_VARIANTS} for a heading font of its own. `null` goes
330
- * back to the theme default for that role.
331
- *
332
- * An uploaded (`custom`) font the theme lists but no longer sets text in is
333
- * kept, because it is the site's own and is picked again from the list; a
334
- * Google font nothing sets text in any more is dropped, so the page stops
335
- * loading it. Everything else in the typography — sizes, weights, a variant's own
336
- * family that is not a heading — is left as it was.
337
- */
338
- export declare function writeThemeFonts(theme: HostTheme, selection: ThemeFontSelection): HostTheme;
339
288
  /** Sets the corner radius, or clears it with `undefined` so it inherits. */
340
289
  export declare function writeBorderRadius(theme: HostTheme, value: number | undefined): HostTheme;
341
290
  /** Sets the spacing unit; anything but a positive number clears it. */
@@ -14,7 +14,12 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */ import { _ as _extends } from "@swc/helpers/_/_extends";
17
+ import { readThemeFonts, writeThemeFonts } from "@aglyn/shared-util-tools/theme-fonts";
17
18
  import { HOST_THEME_COMPONENT_WHITELIST } from "./host-theme.js";
19
+ // The font read and write live in `@aglyn/shared-util-tools/theme-fonts`
20
+ // (AGL-4049), where the platform core can reach them too; every name stays
21
+ // importable from here.
22
+ export { firstStackFamily, fontFamilyStack, readThemeFonts, THEME_HEADING_VARIANTS, writeThemeFonts } from "@aglyn/shared-util-tools/theme-fonts";
18
23
  /**
19
24
  * The host theme editor's field catalog (AGL-2938): every control the editor
20
25
  * renders, the range each one accepts, the token it writes, and the write
@@ -341,10 +346,6 @@ export const SURFACE_COLOR_FIELDS = [
341
346
  ]
342
347
  }
343
348
  ];
344
- export function fontFamilyStack(family, category) {
345
- const fallback = category === 'monospace' ? 'monospace' : category === 'serif' ? 'serif' : 'sans-serif';
346
- return `"${family}", ${fallback}`;
347
- }
348
349
  export function getSchemeColor(colors, path) {
349
350
  var _colors_group;
350
351
  const [group, key] = path;
@@ -643,159 +644,6 @@ export const FONT_FAMILY_FIELD = {
643
644
  heading: current.heading
644
645
  });
645
646
  }
646
- /**
647
- * The text styles a separate heading font is set on: `h1`…`h6`, and
648
- * `displayXl`, the platform's rung above `h1`, which a heading font left off
649
- * would draw in the body font — and load the body font's heaviest weight for.
650
- */ export const THEME_HEADING_VARIANTS = [
651
- 'displayXl',
652
- 'h1',
653
- 'h2',
654
- 'h3',
655
- 'h4',
656
- 'h5',
657
- 'h6'
658
- ];
659
- /** The first family a CSS font-family stack names, unquoted. */ export function firstStackFamily(stack) {
660
- var _stack_split_;
661
- if (typeof stack !== 'string') return undefined;
662
- const first = (_stack_split_ = stack.split(',')[0]) == null ? void 0 : _stack_split_.trim().replace(/^["']|["']$/g, '').trim();
663
- return first || undefined;
664
- }
665
- /** The category a stack's generic keyword names, for a font that records none. */ function stackCategory(stack) {
666
- if (typeof stack !== 'string') return 'sans-serif';
667
- if (/\bmonospace\b/i.test(stack)) return 'monospace';
668
- if (/(^|,)\s*serif\b/i.test(stack)) return 'serif';
669
- return 'sans-serif';
670
- }
671
- function sortedWeights(values) {
672
- return [
673
- ...new Set((values != null ? values : []).map((value)=>Math.round(Number(value))).filter((value)=>Number.isFinite(value) && value >= 1 && value <= 1000))
674
- ].sort((a, b)=>a - b);
675
- }
676
- function choiceOf(font, stack) {
677
- var _font_category;
678
- const italics = sortedWeights(font.italics);
679
- return _extends({
680
- family: font.family.trim(),
681
- category: (_font_category = font.category) != null ? _font_category : stackCategory(stack),
682
- weights: sortedWeights(font.weights).length ? sortedWeights(font.weights) : [
683
- 400
684
- ]
685
- }, italics.length ? {
686
- italics
687
- } : {}, {
688
- source: font.source === 'custom' ? 'custom' : 'google'
689
- });
690
- }
691
- function findFont(theme, family) {
692
- var _theme_fonts;
693
- if (!family) return undefined;
694
- const wanted = family.toLowerCase();
695
- return theme == null ? void 0 : (_theme_fonts = theme.fonts) == null ? void 0 : _theme_fonts.find((font)=>{
696
- var _font_source;
697
- var _font_family;
698
- return ((_font_family = font.family) == null ? void 0 : _font_family.trim().toLowerCase()) === wanted && ((_font_source = font.source) != null ? _font_source : 'google') !== 'system';
699
- });
700
- }
701
- /**
702
- * The body and heading fonts a theme sets text in (AGL-3656).
703
- *
704
- * The body font is the family the theme-wide stack names first, when the
705
- * theme loads it: a font the theme lists that no stack names draws nothing,
706
- * which is what the theme default is. The heading font is the family `h1`
707
- * names, when that is a loaded font other than the body's.
708
- */ export function readThemeFonts(theme) {
709
- var _theme_typography, _theme_typography_variants_h1, _theme_typography_variants, _theme_typography1;
710
- const stack = theme == null ? void 0 : (_theme_typography = theme.typography) == null ? void 0 : _theme_typography.fontFamily;
711
- const bodyFont = findFont(theme, firstStackFamily(stack));
712
- const headingStack = theme == null ? void 0 : (_theme_typography1 = theme.typography) == null ? void 0 : (_theme_typography_variants = _theme_typography1.variants) == null ? void 0 : (_theme_typography_variants_h1 = _theme_typography_variants.h1) == null ? void 0 : _theme_typography_variants_h1.fontFamily;
713
- const headingFont = findFont(theme, firstStackFamily(headingStack));
714
- return {
715
- body: bodyFont ? choiceOf(bodyFont, stack) : null,
716
- heading: headingFont && headingFont !== bodyFont ? choiceOf(headingFont, headingStack) : null
717
- };
718
- }
719
- function fontEntry(choice) {
720
- const italics = sortedWeights(choice.italics);
721
- return _extends({
722
- family: choice.family.trim(),
723
- weights: sortedWeights(choice.weights).length ? sortedWeights(choice.weights) : [
724
- 400
725
- ]
726
- }, italics.length ? {
727
- italics
728
- } : {}, {
729
- source: choice.source,
730
- category: choice.category
731
- });
732
- }
733
- /**
734
- * Sets the theme's body and heading fonts (AGL-3656): the `fonts` entries the
735
- * page loads, the theme-wide stack, and the stack of each style in
736
- * {@link THEME_HEADING_VARIANTS} for a heading font of its own. `null` goes
737
- * back to the theme default for that role.
738
- *
739
- * An uploaded (`custom`) font the theme lists but no longer sets text in is
740
- * kept, because it is the site's own and is picked again from the list; a
741
- * Google font nothing sets text in any more is dropped, so the page stops
742
- * loading it. Everything else in the typography — sizes, weights, a variant's own
743
- * family that is not a heading — is left as it was.
744
- */ export function writeThemeFonts(theme, selection) {
745
- var _ref, _theme_fonts;
746
- var _theme_typography_variants_h1, _theme_typography_variants, _theme_typography, _theme_typography1;
747
- const body = selection.body;
748
- const heading = selection.heading && (!body || selection.heading.family.toLowerCase() !== body.family.toLowerCase()) ? selection.heading : null;
749
- const previous = readThemeFonts(theme);
750
- const previousHeadingStack = previous.heading ? (_theme_typography = theme.typography) == null ? void 0 : (_theme_typography_variants = _theme_typography.variants) == null ? void 0 : (_theme_typography_variants_h1 = _theme_typography_variants.h1) == null ? void 0 : _theme_typography_variants_h1.fontFamily : undefined;
751
- const chosen = [
752
- body,
753
- heading
754
- ].filter((entry)=>!!entry);
755
- const chosenKeys = new Set(chosen.map((entry)=>entry.family.trim().toLowerCase()));
756
- // Families a text style other than a heading still names, by hand or by
757
- // an earlier editor: they keep loading, as their style keeps drawing them.
758
- const otherStyles = new Set(Object.entries((_ref = (_theme_typography1 = theme.typography) == null ? void 0 : _theme_typography1.variants) != null ? _ref : {}).filter(([key])=>!THEME_HEADING_VARIANTS.includes(key)).map(([, variant])=>{
759
- var _firstStackFamily;
760
- return (_firstStackFamily = firstStackFamily(variant == null ? void 0 : variant.fontFamily)) == null ? void 0 : _firstStackFamily.toLowerCase();
761
- }).filter((family)=>!!family));
762
- const kept = ((_theme_fonts = theme.fonts) != null ? _theme_fonts : []).filter((font)=>{
763
- var _ref;
764
- var _font_family;
765
- const key = (_ref = (_font_family = font.family) == null ? void 0 : _font_family.trim().toLowerCase()) != null ? _ref : '';
766
- if (!key || chosenKeys.has(key)) return false;
767
- return font.source === 'custom' || otherStyles.has(key);
768
- });
769
- const fonts = [
770
- ...chosen.map(fontEntry),
771
- ...kept
772
- ];
773
- const typography = _extends({}, theme.typography);
774
- if (body) typography.fontFamily = fontFamilyStack(body.family.trim(), body.category);
775
- else delete typography.fontFamily;
776
- const variants = _extends({}, typography.variants);
777
- for (const key of THEME_HEADING_VARIANTS){
778
- const variant = _extends({}, variants[key]);
779
- if (heading) {
780
- variant.fontFamily = fontFamilyStack(heading.family.trim(), heading.category);
781
- } else if (variant.fontFamily !== undefined && (variant.fontFamily === previousHeadingStack || !findFont({
782
- fonts
783
- }, firstStackFamily(variant.fontFamily)))) {
784
- // The heading font this theme had, or a family it no longer loads.
785
- delete variant.fontFamily;
786
- }
787
- if (Object.keys(variant).length) variants[key] = variant;
788
- else delete variants[key];
789
- }
790
- if (Object.keys(variants).length) typography.variants = variants;
791
- else delete typography.variants;
792
- const next = _extends({}, theme);
793
- if (fonts.length) next.fonts = fonts;
794
- else delete next.fonts;
795
- if (Object.keys(typography).length) next.typography = typography;
796
- else delete next.typography;
797
- return next;
798
- }
799
647
  /** Sets the corner radius, or clears it with `undefined` so it inherits. */ export function writeBorderRadius(theme, value) {
800
648
  if (value !== undefined && Number.isFinite(value)) {
801
649
  return _extends({}, theme, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/shared/ui/theme/src/lib/util/theme-editor-fields.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n HostTheme,\n HostThemeComponentOverride,\n HostThemeFont,\n HostThemeFontCategory,\n HostThemeTypographyVariantKey,\n HostThemeScheme,\n HostThemeSchemeColors,\n} from '@aglyn/shared-data-types'\nimport {\n HOST_THEME_COMPONENT_WHITELIST,\n type HostThemeComponentKey,\n} from './host-theme'\n\n/**\n * The host theme editor's field catalog (AGL-2938): every control the editor\n * renders, the range each one accepts, the token it writes, and the write\n * itself.\n *\n * It lives here rather than beside the editor because the editor is not the\n * only thing that changes a site's theme. Anything that proposes a theme\n * change has to offer exactly the controls the editor offers, with the same\n * bounds, and has to write each one the way the editor writes it. A copy of\n * this list anywhere else is a second answer to \"what can a theme hold\" that\n * drifts from the first the day a control is added, so the editor renders\n * from this module and every other writer reads it.\n *\n * Pure data and pure functions over `HostTheme`: no MUI, no React and no\n * brand theme. What a control resolves to when the site sets nothing is the\n * brand theme's business, in `theme-editor-defaults.ts`.\n *\n * Deliberately NOT re-exported from this library's index: the index reaches\n * every published page, and nothing a visitor renders needs the catalog.\n * Reach it as `@aglyn/shared-ui-theme/util/theme-editor-fields`.\n */\n\n/**\n * MUI's own toolbar breakpoint. `mixins.toolbar` has to carry this exact\n * query, because the rule it competes with is MUI's `@media (min-width:600px)\n * { min-height: 64px }` (AGL-1242).\n */\nexport const TOOLBAR_SM_MIN_WIDTH = 600\nexport const TOOLBAR_SM_QUERY = `@media (min-width:${TOOLBAR_SM_MIN_WIDTH}px)`\n/** MUI's stock Toolbar heights, shown when the host has set none. */\nexport const DEFAULT_TOOLBAR_XS = 56\nexport const DEFAULT_TOOLBAR_SM = 64\n/**\n * `createMixins` spreads `...mixins` AFTER its default, so anything we write\n * REPLACES the stock toolbar wholesale — including its short-landscape rule.\n * Carrying it forward keeps that behavior instead of dropping it silently.\n */\nexport const TOOLBAR_LANDSCAPE_QUERY = '@media (min-width:0px)'\nexport const TOOLBAR_LANDSCAPE_RULE = {\n '@media (orientation: landscape)': { minHeight: 48 },\n}\n\n/** Reads a px `minHeight` out of `mixins.toolbar` for one breakpoint. */\nexport function readToolbarHeight(theme: HostTheme, breakpoint: 'xs' | 'sm') {\n const toolbar = theme.mixins?.toolbar\n if (!toolbar) return undefined\n const raw =\n breakpoint === 'xs'\n ? toolbar.minHeight\n : (toolbar[TOOLBAR_SM_QUERY] as { minHeight?: unknown } | undefined)\n ?.minHeight\n const value = parseFloat(String(raw ?? ''))\n return Number.isFinite(value) ? value : undefined\n}\n\n/**\n * Builds a COMPLETE `mixins.toolbar`, in the order MUI emits it.\n *\n * Two things this exists to get right, both because `mixins.toolbar` replaces\n * MUI's default wholesale rather than merging into it (AGL-1242):\n *\n * - **Completeness.** Anything omitted is simply gone. Writing only a desktop\n * height left portrait phones with no `min-height` at all, so unset\n * breakpoints fall back to MUI's own 56 / 64.\n * - **Key order.** These land in one CSS rule, so the last matching\n * declaration wins. MUI emits the landscape clause BEFORE the sm height;\n * emitting it after makes a wide landscape window — i.e. every desktop —\n * 48px tall.\n */\nexport function buildToolbarMixin(xs: number | undefined, sm: number | undefined) {\n return {\n minHeight: `${xs ?? DEFAULT_TOOLBAR_XS}px`,\n [TOOLBAR_LANDSCAPE_QUERY]: TOOLBAR_LANDSCAPE_RULE,\n [TOOLBAR_SM_QUERY]: { minHeight: `${sm ?? DEFAULT_TOOLBAR_SM}px` },\n }\n}\n\n/**\n * Serializes the branches whose KEY ORDER changes what renders.\n *\n * `deepEqual` is order-INsensitive on purpose (AGL-56: Firestore hands the\n * palette back in a different key order than the editor builds it, and a\n * string compare left Save enabled forever), so on its own it cannot see a\n * reorder of `mixins.toolbar` — a change that really does alter the CSS.\n *\n * Deliberately narrow: only `mixins`. `components.*.styleOverrides` are CSS\n * objects too, but widening this would re-expose the AGL-56 failure for every\n * host with component overrides, and order-sensitivity has only actually been\n * demonstrated here.\n *\n * Firestore does NOT hand a map back in the order it was written, and it\n * hands different readers different orders (AGL-3146) — which is why what\n * renders is canonicalized in `hostThemeToThemeOptions` rather than trusted\n * from storage. A freshly-loaded document is still not dirty here, because\n * the draft is seeded from the loaded document itself: both sides of this\n * comparison carry whatever order THIS reader was given.\n */\nexport function orderSensitiveKey(theme: HostTheme): string {\n return JSON.stringify(theme.mixins ?? {})\n}\n\nexport type PaletteColorKey =\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'surface'\n | 'error'\n | 'warning'\n | 'info'\n | 'success'\n\nexport const PALETTE_COLOR_FIELDS: Array<{\n key: PaletteColorKey\n label: string\n}> = [\n { key: 'primary', label: 'Primary' },\n { key: 'secondary', label: 'Secondary' },\n { key: 'tertiary', label: 'Tertiary' },\n { key: 'surface', label: 'Surface' },\n { key: 'error', label: 'Error' },\n { key: 'warning', label: 'Warning' },\n { key: 'info', label: 'Info' },\n { key: 'success', label: 'Success' },\n]\n\nexport type SurfaceColorPath =\n | ['background', 'default']\n | ['background', 'paper']\n | ['text', 'primary']\n | ['text', 'secondary']\n | ['text', 'disabled']\n | ['tint', 'primary']\n | ['tint', 'secondary']\n | ['tint', 'tertiary']\n\nexport const SURFACE_COLOR_FIELDS: Array<{\n path: SurfaceColorPath\n label: string\n}> = [\n { path: ['background', 'default'], label: 'Background' },\n { path: ['background', 'paper'], label: 'Paper' },\n { path: ['text', 'primary'], label: 'Text' },\n { path: ['text', 'secondary'], label: 'Secondary text' },\n { path: ['text', 'disabled'], label: 'Disabled text' },\n]\n\n/**\n * Pale accent washes (AGL-1244).\n *\n * Separate from {@link PALETTE_COLOR_FIELDS} because a tint is a STRING LEAF,\n * not a `{ main }` record — the palette fields all write `main`, and a tint has\n * none. It rides the same `SurfaceColorPath` machinery as `background`/`text`\n * for exactly that reason, and is listed apart only so the editor can head it\n * \"Tints\" instead of filing it under \"Background & text\".\n */\nexport const TINT_COLOR_FIELDS: Array<{\n path: SurfaceColorPath\n label: string\n}> = [\n { path: ['tint', 'primary'], label: 'Primary tint' },\n { path: ['tint', 'secondary'], label: 'Secondary tint' },\n { path: ['tint', 'tertiary'], label: 'Tertiary tint' },\n]\n\n/** The one color leaf that is neither a palette color nor a member of a group. */\nexport const DIVIDER_COLOR_FIELD = { key: 'divider', label: 'Divider' } as const\n\n/** Curated Google Fonts choices for the font family selector. */\nexport const GOOGLE_FONT_OPTIONS: Array<{\n family: string\n category: 'sans-serif' | 'serif' | 'monospace' | 'display'\n weights: Array<number>\n}> = [\n { family: 'Inter', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Roboto', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Open Sans', category: 'sans-serif', weights: [400, 600, 700] },\n { family: 'Lato', category: 'sans-serif', weights: [400, 700] },\n { family: 'Montserrat', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Poppins', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Nunito', category: 'sans-serif', weights: [400, 600, 700] },\n { family: 'Work Sans', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Raleway', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Merriweather', category: 'serif', weights: [400, 700] },\n { family: 'Playfair Display', category: 'serif', weights: [400, 700] },\n { family: 'Lora', category: 'serif', weights: [400, 700] },\n { family: 'Source Serif 4', category: 'serif', weights: [400, 700] },\n { family: 'JetBrains Mono', category: 'monospace', weights: [400, 700] },\n { family: 'Bebas Neue', category: 'display', weights: [400] },\n]\n\nexport function fontFamilyStack(\n family: string,\n category: HostThemeFontCategory,\n) {\n const fallback = category === 'monospace' ? 'monospace' : category === 'serif' ? 'serif' : 'sans-serif'\n return `\"${family}\", ${fallback}`\n}\n\nexport function getSchemeColor(\n colors: HostThemeSchemeColors | undefined,\n path: SurfaceColorPath,\n): string | undefined {\n const [group, key] = path\n return (colors?.[group] as Record<string, string> | undefined)?.[key]\n}\n\n/* ------------------------------------------------------------------------ *\n * The controls, as one catalog\n * ------------------------------------------------------------------------ */\n\n/** The two color schemes the editor edits, in tab order. */\nexport const THEME_EDITOR_SCHEMES: readonly HostThemeScheme[] = ['light', 'dark']\n\n/**\n * Every color the editor edits per scheme, named the way a diff names it: a\n * palette key (`primary`), a group path joined with a dot\n * (`background.default`, `tint.primary`), or `divider`.\n */\nexport type ThemeColorToken =\n | PaletteColorKey\n | 'background.default'\n | 'background.paper'\n | 'text.primary'\n | 'text.secondary'\n | 'text.disabled'\n | 'tint.primary'\n | 'tint.secondary'\n | 'tint.tertiary'\n | 'divider'\n\n/** Where a color control sits in the editor's Color scheme card. */\nexport type ThemeColorGroup = 'palette' | 'surface' | 'tint' | 'divider'\n\n/** Every color field the editor renders, in the order it renders them. */\nexport const THEME_COLOR_FIELDS: ReadonlyArray<{\n token: ThemeColorToken\n label: string\n group: ThemeColorGroup\n}> = [\n ...PALETTE_COLOR_FIELDS.map(({ key, label }) => ({\n token: key,\n label,\n group: 'palette' as const,\n })),\n ...SURFACE_COLOR_FIELDS.map(({ path, label }) => ({\n token: path.join('.') as ThemeColorToken,\n label,\n group: 'surface' as const,\n })),\n ...TINT_COLOR_FIELDS.map(({ path, label }) => ({\n token: path.join('.') as ThemeColorToken,\n label,\n group: 'tint' as const,\n })),\n {\n token: DIVIDER_COLOR_FIELD.key,\n label: DIVIDER_COLOR_FIELD.label,\n group: 'divider' as const,\n },\n]\n\n/** Whether visitors get a dark scheme; absent from the document means `auto`. */\nexport type ThemeDarkSchemeValue = 'auto' | 'off'\n\nexport const DARK_SCHEME_FIELD = {\n label: 'Dark scheme',\n options: [\n { value: 'auto', label: 'Follows the visitor' },\n { value: 'off', label: 'Off — always light' },\n ],\n} as const\n\n/**\n * The font select's value for \"no font of the site's own\": the theme's\n * default stack, with nothing to load.\n */\nexport const SYSTEM_FONT_VALUE = '__system__'\n\nexport const FONT_FAMILY_FIELD = { label: 'Font family' } as const\n\n/** The corner radius slider, in px. */\nexport const BORDER_RADIUS_FIELD = {\n label: 'Border radius',\n min: 0,\n max: 24,\n step: 1,\n} as const\n\n/** The spacing unit MUI multiplies every `spacing(n)` by, in px. */\nexport const SPACING_FIELD = {\n label: 'Spacing unit (px)',\n min: 2,\n max: 16,\n step: 1,\n} as const\n\n/** The two nav heights, either side of MUI's toolbar breakpoint, in px. */\nexport const TOOLBAR_HEIGHT_FIELDS = {\n xs: { label: 'Nav height, mobile (px)', min: 40, max: 160, step: 1 },\n sm: { label: 'Nav height, desktop (px)', min: 40, max: 160, step: 1 },\n} as const\n\n/**\n * The site-wide look of components: the click-only fields in\n * {@link THEME_COMPONENT_LOOK_FIELDS}, with the full override set behind\n * them limited to the sanitizer's whitelist.\n */\nexport const COMPONENT_OVERRIDES_FIELD = {\n label: 'Style components',\n components: HOST_THEME_COMPONENT_WHITELIST,\n} as const\n\n/**\n * The media queries a component override may scope a style to: either side\n * of MUI's own toolbar breakpoint, the one breakpoint the editor already\n * names. MUI's `down('sm')` stops a twentieth of a pixel short of it.\n */\nexport const THEME_EDITOR_MEDIA_QUERIES = {\n mobile: `@media (max-width:${TOOLBAR_SM_MIN_WIDTH - 0.05}px)`,\n desktop: TOOLBAR_SM_QUERY,\n} as const\n\nexport type ThemeEditorMedia = keyof typeof THEME_EDITOR_MEDIA_QUERIES\n\nexport type ThemeEditorControlId =\n | `color.${ThemeColorToken}`\n | 'darkScheme'\n | 'fontFamily'\n | 'borderRadius'\n | 'spacing'\n | 'navHeight.xs'\n | 'navHeight.sm'\n | 'components'\n\n/** One control the editor renders, described well enough to be offered elsewhere. */\nexport interface ThemeEditorControl {\n /** Stable id: what a diff row, a proposal and a spec name the control by. */\n id: ThemeEditorControlId\n /** The label the editor shows. */\n label: string\n kind: 'color' | 'select' | 'number' | 'components'\n /** Edited once per scheme, under the Light and Dark tabs. */\n perScheme: boolean\n /** A color control's token. */\n token?: ThemeColorToken\n /** A select's values, or the components a components control may style. */\n options?: readonly string[]\n /** A number control's inclusive bounds and its step. */\n min?: number\n max?: number\n step?: number\n}\n\n/**\n * Every value-bearing control the editor renders, in the order it renders\n * them. The buttons that act on these values rather than hold one — Copy\n * from light, Reset to default, Discard, Save — are not controls: a reset is\n * a control set back to nothing, and a copy is every color control of one\n * scheme written from the other.\n */\nexport const THEME_EDITOR_CONTROLS: readonly ThemeEditorControl[] = [\n {\n id: 'darkScheme',\n label: DARK_SCHEME_FIELD.label,\n kind: 'select',\n perScheme: false,\n options: DARK_SCHEME_FIELD.options.map((option) => option.value),\n },\n ...THEME_COLOR_FIELDS.map(({ token, label }) => ({\n id: `color.${token}` as const,\n label,\n kind: 'color' as const,\n perScheme: true,\n token,\n })),\n {\n id: 'fontFamily',\n label: FONT_FAMILY_FIELD.label,\n kind: 'select',\n perScheme: false,\n options: [SYSTEM_FONT_VALUE, ...GOOGLE_FONT_OPTIONS.map((option) => option.family)],\n },\n {\n id: 'borderRadius',\n label: BORDER_RADIUS_FIELD.label,\n kind: 'number',\n perScheme: false,\n min: BORDER_RADIUS_FIELD.min,\n max: BORDER_RADIUS_FIELD.max,\n step: BORDER_RADIUS_FIELD.step,\n },\n {\n id: 'spacing',\n label: SPACING_FIELD.label,\n kind: 'number',\n perScheme: false,\n min: SPACING_FIELD.min,\n max: SPACING_FIELD.max,\n step: SPACING_FIELD.step,\n },\n {\n id: 'navHeight.xs',\n label: TOOLBAR_HEIGHT_FIELDS.xs.label,\n kind: 'number',\n perScheme: false,\n min: TOOLBAR_HEIGHT_FIELDS.xs.min,\n max: TOOLBAR_HEIGHT_FIELDS.xs.max,\n step: TOOLBAR_HEIGHT_FIELDS.xs.step,\n },\n {\n id: 'navHeight.sm',\n label: TOOLBAR_HEIGHT_FIELDS.sm.label,\n kind: 'number',\n perScheme: false,\n min: TOOLBAR_HEIGHT_FIELDS.sm.min,\n max: TOOLBAR_HEIGHT_FIELDS.sm.max,\n step: TOOLBAR_HEIGHT_FIELDS.sm.step,\n },\n {\n id: 'components',\n label: COMPONENT_OVERRIDES_FIELD.label,\n kind: 'components',\n perScheme: false,\n options: COMPONENT_OVERRIDES_FIELD.components,\n },\n]\n\n/** The catalog entry for a control id. */\nexport function themeEditorControl(id: ThemeEditorControlId): ThemeEditorControl {\n const control = THEME_EDITOR_CONTROLS.find((entry) => entry.id === id)\n if (!control) throw new Error(`unknown theme editor control ${id}`)\n return control\n}\n\n/* ------------------------------------------------------------------------ *\n * Reads and writes, exactly as the editor performs them\n * ------------------------------------------------------------------------ */\n\nfunction setSchemeValue(\n theme: HostTheme,\n scheme: HostThemeScheme,\n update: (colors: HostThemeSchemeColors) => HostThemeSchemeColors,\n): HostTheme {\n const colors = theme.colorSchemes?.[scheme] ?? {}\n return {\n ...theme,\n colorSchemes: { ...theme.colorSchemes, [scheme]: update(colors) },\n }\n}\n\n/** A color the site set for one scheme; `undefined` when the slot inherits. */\nexport function readThemeColor(\n theme: HostTheme | undefined,\n scheme: HostThemeScheme,\n token: ThemeColorToken,\n): string | undefined {\n const colors = theme?.colorSchemes?.[scheme]\n if (token === 'divider') return colors?.divider\n const [group, key] = token.split('.')\n if (!key) return colors?.[group as PaletteColorKey]?.main\n return getSchemeColor(colors, [group, key] as SurfaceColorPath)\n}\n\n/**\n * Sets one color for one scheme, or clears it with `undefined` so the slot\n * inherits again. A palette color writes a record of `main` alone: its\n * `light`, `dark` and `contrastText` were derived from (or authored for) the\n * old `main`, and the editor offers no control for them, so a kept shade\n * would go on painting the old color (an outlined button reads `dark`) with\n * no way for the owner to see or change it. Dropped, the theme derives them\n * from the new `main`. Clearing it drops the record; a group member that\n * leaves its group empty drops the group.\n */\nexport function writeThemeColor(\n theme: HostTheme,\n scheme: HostThemeScheme,\n token: ThemeColorToken,\n hex: string | undefined,\n): HostTheme {\n return setSchemeValue(theme, scheme, (colors) => {\n const next: HostThemeSchemeColors = { ...colors }\n if (token === 'divider') {\n if (hex) next.divider = hex\n else delete next.divider\n return next\n }\n const [group, key] = token.split('.')\n if (!key) {\n const paletteKey = group as PaletteColorKey\n if (hex) next[paletteKey] = { main: hex }\n else delete next[paletteKey]\n // An accent's tint is a wash of its old `main` for the same reason, so\n // it goes too and the theme washes one from the new color.\n const tint = next.tint as Record<string, string> | undefined\n if (tint && paletteKey in tint) {\n const rest = { ...tint }\n delete rest[paletteKey]\n if (Object.keys(rest).length) next.tint = rest as HostThemeSchemeColors['tint']\n else delete next.tint\n }\n return next\n }\n const groupKey = group as 'background' | 'text' | 'tint'\n const groupValue = {\n ...(colors[groupKey] as Record<string, string> | undefined),\n }\n if (hex) groupValue[key] = hex\n else delete groupValue[key]\n const grouped = { ...next, [groupKey]: groupValue } as HostThemeSchemeColors\n if (!Object.keys(groupValue).length) delete grouped[groupKey]\n return grouped\n })\n}\n\n/** Replaces one scheme's colors with a copy of the other's. */\nexport function copyThemeSchemeColors(\n theme: HostTheme,\n from: HostThemeScheme,\n to: HostThemeScheme,\n): HostTheme {\n const source = theme.colorSchemes?.[from]\n if (!source) return theme\n return {\n ...theme,\n colorSchemes: {\n ...theme.colorSchemes,\n [to]: JSON.parse(JSON.stringify(source)),\n },\n }\n}\n\n/** The dark scheme switch as the select shows it. */\nexport function readDarkScheme(theme: HostTheme | undefined): ThemeDarkSchemeValue {\n return theme?.darkScheme === 'off' ? 'off' : 'auto'\n}\n\n/**\n * Absent means \"follows the visitor\"; only the opt-out is written, so the\n * saved document stays empty for the common case.\n */\nexport function writeDarkScheme(\n theme: HostTheme,\n value: ThemeDarkSchemeValue,\n): HostTheme {\n const next: HostTheme = { ...theme }\n if (value === 'off') next.darkScheme = 'off'\n else delete next.darkScheme\n return next\n}\n\n/** The font select's value: the site's font, or {@link SYSTEM_FONT_VALUE}. */\nexport function readFontFamily(theme: HostTheme | undefined): string {\n return readThemeFonts(theme).body?.family ?? SYSTEM_FONT_VALUE\n}\n\n/**\n * Picks a font from {@link GOOGLE_FONT_OPTIONS}, loading it and naming it as\n * the typography's stack, or {@link SYSTEM_FONT_VALUE} to go back to the\n * theme default. A family outside the curated list changes nothing.\n */\nexport function writeFontFamily(theme: HostTheme, value: string): HostTheme {\n // Through writeThemeFonts (AGL-3656), so a heading font and the site's own\n // uploaded fonts survive a body font picked from the short list or by the\n // AI theme step; replacing `fonts` wholesale dropped both.\n const current = readThemeFonts(theme)\n if (value === SYSTEM_FONT_VALUE) {\n return writeThemeFonts(theme, { body: null, heading: current.heading })\n }\n const option = GOOGLE_FONT_OPTIONS.find((entry) => entry.family === value)\n if (!option) return theme\n return writeThemeFonts(theme, {\n body: {\n family: option.family,\n category: option.category,\n weights: option.weights,\n source: 'google',\n },\n heading: current.heading,\n })\n}\n\n/**\n * The text styles a separate heading font is set on: `h1`…`h6`, and\n * `displayXl`, the platform's rung above `h1`, which a heading font left off\n * would draw in the body font — and load the body font's heaviest weight for.\n */\nexport const THEME_HEADING_VARIANTS: readonly HostThemeTypographyVariantKey[] = [\n 'displayXl',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n]\n\n/**\n * One family a theme sets text in, as the font picker shows and writes it\n * (AGL-3656): a `fonts` entry and the role it plays.\n */\nexport interface ThemeFontChoice {\n family: string\n category: HostThemeFontCategory\n /** Upright weights to load, ascending. */\n weights: number[]\n /** Italic weights to load, ascending; absent or empty for none. */\n italics?: number[]\n source: 'google' | 'custom'\n}\n\n/**\n * The theme's body font and, when it differs, its heading font. `null` is the\n * theme default: the base stack, nothing loaded.\n */\nexport interface ThemeFontSelection {\n body: ThemeFontChoice | null\n heading: ThemeFontChoice | null\n}\n\n/** The first family a CSS font-family stack names, unquoted. */\nexport function firstStackFamily(stack: unknown): string | undefined {\n if (typeof stack !== 'string') return undefined\n const first = stack.split(',')[0]?.trim().replace(/^[\"']|[\"']$/g, '').trim()\n return first || undefined\n}\n\n/** The category a stack's generic keyword names, for a font that records none. */\nfunction stackCategory(stack: unknown): HostThemeFontCategory {\n if (typeof stack !== 'string') return 'sans-serif'\n if (/\\bmonospace\\b/i.test(stack)) return 'monospace'\n if (/(^|,)\\s*serif\\b/i.test(stack)) return 'serif'\n return 'sans-serif'\n}\n\nfunction sortedWeights(values: readonly unknown[] | undefined): number[] {\n return [\n ...new Set(\n (values ?? [])\n .map((value) => Math.round(Number(value)))\n .filter((value) => Number.isFinite(value) && value >= 1 && value <= 1000),\n ),\n ].sort((a, b) => a - b)\n}\n\nfunction choiceOf(font: HostThemeFont, stack: unknown): ThemeFontChoice {\n const italics = sortedWeights(font.italics)\n return {\n family: font.family.trim(),\n category: font.category ?? stackCategory(stack),\n weights: sortedWeights(font.weights).length ? sortedWeights(font.weights) : [400],\n ...(italics.length ? { italics } : {}),\n source: font.source === 'custom' ? 'custom' : 'google',\n }\n}\n\nfunction findFont(theme: HostTheme | undefined, family: string | undefined) {\n if (!family) return undefined\n const wanted = family.toLowerCase()\n return theme?.fonts?.find(\n (font) =>\n font.family?.trim().toLowerCase() === wanted && (font.source ?? 'google') !== 'system',\n )\n}\n\n/**\n * The body and heading fonts a theme sets text in (AGL-3656).\n *\n * The body font is the family the theme-wide stack names first, when the\n * theme loads it: a font the theme lists that no stack names draws nothing,\n * which is what the theme default is. The heading font is the family `h1`\n * names, when that is a loaded font other than the body's.\n */\nexport function readThemeFonts(theme: HostTheme | undefined): ThemeFontSelection {\n const stack = theme?.typography?.fontFamily\n const bodyFont = findFont(theme, firstStackFamily(stack))\n const headingStack = theme?.typography?.variants?.h1?.fontFamily\n const headingFont = findFont(theme, firstStackFamily(headingStack))\n return {\n body: bodyFont ? choiceOf(bodyFont, stack) : null,\n heading:\n headingFont && headingFont !== bodyFont ? choiceOf(headingFont, headingStack) : null,\n }\n}\n\nfunction fontEntry(choice: ThemeFontChoice): HostThemeFont {\n const italics = sortedWeights(choice.italics)\n return {\n family: choice.family.trim(),\n weights: sortedWeights(choice.weights).length ? sortedWeights(choice.weights) : [400],\n ...(italics.length ? { italics } : {}),\n source: choice.source,\n category: choice.category,\n }\n}\n\n/**\n * Sets the theme's body and heading fonts (AGL-3656): the `fonts` entries the\n * page loads, the theme-wide stack, and the stack of each style in\n * {@link THEME_HEADING_VARIANTS} for a heading font of its own. `null` goes\n * back to the theme default for that role.\n *\n * An uploaded (`custom`) font the theme lists but no longer sets text in is\n * kept, because it is the site's own and is picked again from the list; a\n * Google font nothing sets text in any more is dropped, so the page stops\n * loading it. Everything else in the typography — sizes, weights, a variant's own\n * family that is not a heading — is left as it was.\n */\nexport function writeThemeFonts(theme: HostTheme, selection: ThemeFontSelection): HostTheme {\n const body = selection.body\n const heading =\n selection.heading &&\n (!body || selection.heading.family.toLowerCase() !== body.family.toLowerCase())\n ? selection.heading\n : null\n const previous = readThemeFonts(theme)\n const previousHeadingStack = previous.heading\n ? theme.typography?.variants?.h1?.fontFamily\n : undefined\n\n const chosen = [body, heading].filter((entry): entry is ThemeFontChoice => !!entry)\n const chosenKeys = new Set(chosen.map((entry) => entry.family.trim().toLowerCase()))\n // Families a text style other than a heading still names, by hand or by\n // an earlier editor: they keep loading, as their style keeps drawing them.\n const otherStyles = new Set(\n Object.entries(theme.typography?.variants ?? {})\n .filter(([key]) => !(THEME_HEADING_VARIANTS as readonly string[]).includes(key))\n .map(([, variant]) => firstStackFamily(variant?.fontFamily)?.toLowerCase())\n .filter((family): family is string => !!family),\n )\n const kept = (theme.fonts ?? []).filter((font) => {\n const key = font.family?.trim().toLowerCase() ?? ''\n if (!key || chosenKeys.has(key)) return false\n return font.source === 'custom' || otherStyles.has(key)\n })\n const fonts = [...chosen.map(fontEntry), ...kept]\n\n const typography = { ...theme.typography }\n if (body) typography.fontFamily = fontFamilyStack(body.family.trim(), body.category)\n else delete typography.fontFamily\n\n const variants = { ...typography.variants }\n for (const key of THEME_HEADING_VARIANTS) {\n const variant = { ...variants[key] }\n if (heading) {\n variant.fontFamily = fontFamilyStack(heading.family.trim(), heading.category)\n } else if (\n variant.fontFamily !== undefined &&\n (variant.fontFamily === previousHeadingStack ||\n !findFont({ fonts }, firstStackFamily(variant.fontFamily)))\n ) {\n // The heading font this theme had, or a family it no longer loads.\n delete variant.fontFamily\n }\n if (Object.keys(variant).length) variants[key] = variant\n else delete variants[key]\n }\n if (Object.keys(variants).length) typography.variants = variants\n else delete typography.variants\n\n const next: HostTheme = { ...theme }\n if (fonts.length) next.fonts = fonts\n else delete next.fonts\n if (Object.keys(typography).length) next.typography = typography\n else delete next.typography\n return next\n}\n\n/** Sets the corner radius, or clears it with `undefined` so it inherits. */\nexport function writeBorderRadius(\n theme: HostTheme,\n value: number | undefined,\n): HostTheme {\n if (value !== undefined && Number.isFinite(value)) {\n return { ...theme, shape: { ...theme.shape, borderRadius: value } }\n }\n const next = { ...theme }\n const shape = { ...next.shape }\n delete shape.borderRadius\n if (Object.keys(shape).length) next.shape = shape\n else delete next.shape\n return next\n}\n\n/** Sets the spacing unit; anything but a positive number clears it. */\nexport function writeSpacing(theme: HostTheme, value: number | undefined): HostTheme {\n const next = { ...theme }\n if (value !== undefined && Number.isFinite(value) && value > 0) next.spacing = value\n else delete next.spacing\n return next\n}\n\n/**\n * Sets one nav height — anything but a positive number clears it — and\n * rebuilds the whole toolbar mixin around both, because `mixins.toolbar`\n * replaces MUI's default rather than merging into it (AGL-1242).\n */\nexport function writeToolbarHeight(\n theme: HostTheme,\n breakpoint: 'xs' | 'sm',\n value: number | undefined,\n): HostTheme {\n const valid = value !== undefined && Number.isFinite(value) && value > 0\n const edited = valid ? value : undefined\n const xs = breakpoint === 'xs' ? edited : readToolbarHeight(theme, 'xs')\n const sm = breakpoint === 'sm' ? edited : readToolbarHeight(theme, 'sm')\n const next = { ...theme }\n if (xs === undefined && sm === undefined) {\n delete next.mixins\n return next\n }\n next.mixins = { toolbar: buildToolbarMixin(xs, sm) }\n return next\n}\n\n/**\n * Drops the site's component overrides. With nothing stored the site renders\n * the brand's own component styles, which is what the editor's \"Reset to\n * theme defaults\" means.\n */\nexport function resetComponentOverrides(theme: HostTheme): HostTheme {\n const next = { ...theme }\n delete next.components\n return next\n}\n\n/** One leaf of a component override, as a writer names it. */\nexport interface ThemeComponentOverrideLeaf {\n component: HostThemeComponentKey\n /**\n * `styleOverrides` styles a slot in literal CSS; `sx` styles it in theme\n * terms, so a value may name a palette path (`primary.main`) or a spacing\n * unit (AGL-3403); `defaultProps` sets a prop's default.\n */\n target: 'styleOverrides' | 'sx' | 'defaultProps'\n /** The style slot (`root`, `contained`, `h1`); `null` for a default prop. */\n slot: string | null\n /** A camelCase CSS property, or the prop's name. */\n property: string\n /** Scopes a style to one side of the toolbar breakpoint; `null` for every width. */\n media: ThemeEditorMedia | null\n value: string | number | boolean\n}\n\n/**\n * Sets one leaf inside the site's component overrides and keeps every other\n * override the site has. The stored overrides are deep-merged over the\n * brand's own at render time, so naming one property changes that property\n * and inherits the rest of the component.\n */\nexport function writeComponentOverride(\n theme: HostTheme,\n leaf: ThemeComponentOverrideLeaf,\n): HostTheme {\n const components = { ...theme.components }\n const entry: HostThemeComponentOverride = { ...components[leaf.component] }\n if (leaf.target === 'defaultProps') {\n entry.defaultProps = { ...entry.defaultProps, [leaf.property]: leaf.value }\n } else {\n const slot = leaf.slot ?? 'root'\n const styles: Record<string, unknown> = {\n ...(leaf.target === 'sx' ? entry.sx : entry.styleOverrides),\n }\n const slotStyles = { ...(styles[slot] as Record<string, unknown> | undefined) }\n if (leaf.media) {\n const query = THEME_EDITOR_MEDIA_QUERIES[leaf.media]\n slotStyles[query] = {\n ...(slotStyles[query] as Record<string, unknown> | undefined),\n [leaf.property]: leaf.value,\n }\n } else {\n slotStyles[leaf.property] = leaf.value\n }\n styles[slot] = slotStyles\n if (leaf.target === 'sx') {\n entry.sx = styles as HostThemeComponentOverride['sx']\n } else {\n entry.styleOverrides = styles\n }\n }\n components[leaf.component] = entry\n return { ...theme, components }\n}\n\n/** Where one leaf lives, without the value it holds. */\nexport type ThemeComponentOverrideTarget = Omit<ThemeComponentOverrideLeaf, 'value'>\n\n/**\n * Removes one leaf from the site's component overrides, and every slot,\n * branch and component it leaves empty, so a field set back to \"Theme\n * default\" stores nothing and the site inherits that property again.\n */\nexport function clearComponentOverride(\n theme: HostTheme,\n target: ThemeComponentOverrideTarget,\n): HostTheme {\n const existing = theme.components?.[target.component]\n if (!existing) return theme\n const entry: HostThemeComponentOverride = { ...existing }\n if (target.target === 'defaultProps') {\n const props = { ...entry.defaultProps }\n delete props[target.property]\n if (Object.keys(props).length) entry.defaultProps = props\n else delete entry.defaultProps\n } else {\n const branch = target.target === 'sx' ? 'sx' : 'styleOverrides'\n const styles: Record<string, unknown> = { ...entry[branch] }\n const slot = target.slot ?? 'root'\n const slotStyles = { ...(styles[slot] as Record<string, unknown> | undefined) }\n if (target.media) {\n const query = THEME_EDITOR_MEDIA_QUERIES[target.media]\n const scoped = { ...(slotStyles[query] as Record<string, unknown> | undefined) }\n delete scoped[target.property]\n if (Object.keys(scoped).length) slotStyles[query] = scoped\n else delete slotStyles[query]\n } else {\n delete slotStyles[target.property]\n }\n if (Object.keys(slotStyles).length) styles[slot] = slotStyles\n else delete styles[slot]\n if (Object.keys(styles).length) {\n if (branch === 'sx') entry.sx = styles as HostThemeComponentOverride['sx']\n else entry.styleOverrides = styles\n } else {\n delete entry[branch]\n }\n }\n const components = { ...theme.components }\n if (Object.keys(entry).length) components[target.component] = entry\n else delete components[target.component]\n const next: HostTheme = { ...theme }\n if (Object.keys(components).length) next.components = components\n else delete next.components\n return next\n}\n\n/** The value one override leaf holds; `undefined` when the site does not set it. */\nexport function readComponentOverride(\n theme: HostTheme | undefined,\n target: ThemeComponentOverrideTarget,\n): unknown {\n const entry = theme?.components?.[target.component]\n if (!entry) return undefined\n if (target.target === 'defaultProps') return entry.defaultProps?.[target.property]\n const styles = (target.target === 'sx' ? entry.sx : entry.styleOverrides) as\n | Record<string, unknown>\n | undefined\n const slotStyles = styles?.[target.slot ?? 'root'] as Record<string, unknown> | undefined\n if (!target.media) return slotStyles?.[target.property]\n const query = THEME_EDITOR_MEDIA_QUERIES[target.media]\n return (slotStyles?.[query] as Record<string, unknown> | undefined)?.[target.property]\n}\n\n/* ------------------------------------------------------------------------ *\n * The look of components, as click-only fields\n * ------------------------------------------------------------------------ */\n\n/** The components the Style components card sets a site-wide look for. */\nexport type ThemeComponentLookGroup = 'button' | 'input' | 'card'\n\nexport const THEME_COMPONENT_LOOK_GROUPS: ReadonlyArray<{\n group: ThemeComponentLookGroup\n label: string\n}> = [\n { group: 'button', label: 'Buttons' },\n { group: 'input', label: 'Form inputs' },\n { group: 'card', label: 'Cards' },\n]\n\nexport type ThemeComponentLookId =\n | 'button.variant'\n | 'button.corners'\n | 'button.textCase'\n | 'button.weight'\n | 'button.padding'\n | 'input.variant'\n | 'input.corners'\n | 'input.background'\n | 'input.border'\n | 'card.variant'\n | 'card.elevation'\n | 'card.corners'\n\n/** One choice a look field offers. */\nexport interface ThemeComponentLookOption {\n /** What the select holds. */\n value: string\n label: string\n /**\n * What each of the field's targets stores, in target order; one value\n * stands for every target.\n */\n stored: string | number | ReadonlyArray<string | number>\n /** A theme color this choice draws in, for its swatch. */\n token?: ThemeColorToken\n}\n\n/**\n * A click-only field over the site's component overrides. Each choice writes\n * the same leaves the Advanced overrides hold, so the two are one setting\n * seen two ways, and anything that writes override leaves can set it.\n */\nexport interface ThemeComponentLookField {\n id: ThemeComponentLookId\n group: ThemeComponentLookGroup\n label: string\n /** `color` choices are theme colors, shown as swatches of the scheme in view. */\n kind: 'select' | 'color'\n /** The leaves a choice sets, read back from the first. */\n targets: readonly ThemeComponentOverrideTarget[]\n /** Leaves set alongside any choice and cleared with it: what makes the choice draw right. */\n companions?: readonly ThemeComponentOverrideLeaf[]\n options: readonly ThemeComponentLookOption[]\n}\n\n/** The select's value for a field the site does not set: the theme's own look. */\nexport const THEME_LOOK_DEFAULT = ''\n/** The select's value for a leaf set to something no choice names, by hand or by AI. */\nexport const THEME_LOOK_CUSTOM = '__custom__'\n\nfunction lookTarget(\n component: HostThemeComponentKey,\n target: ThemeComponentOverrideLeaf['target'],\n property: string,\n slot: string | null = target === 'defaultProps' ? null : 'root',\n): ThemeComponentOverrideTarget {\n return { component, target, slot, property, media: null }\n}\n\n/**\n * Corner choices, as multiples of the site's Border radius (an `sx`\n * `borderRadius` number is one), so a component follows the Shape & spacing\n * slider instead of freezing a pixel value.\n */\nconst CORNER_OPTIONS: readonly ThemeComponentLookOption[] = [\n { value: 'square', label: 'Square', stored: 0 },\n { value: 'subtle', label: 'Half the site radius', stored: 0.5 },\n { value: 'site', label: 'The site radius', stored: 1 },\n { value: 'rounded', label: 'Twice the site radius', stored: 2 },\n { value: 'extra', label: 'Three times the site radius', stored: 3 },\n]\nconst PILL_OPTION: ThemeComponentLookOption = { value: 'pill', label: 'Pill', stored: '999px' }\n\n/**\n * Every component look field, in the order the card shows them.\n *\n * Inputs style both of MUI's boxes: `MuiOutlinedInput` and `MuiFilledInput`,\n * because the Input style choice picks between them and the other choices\n * have to hold whichever is in use. A border color sets the outlined box's\n * own border, which the Besigner's Input element draws, and the notched\n * outline a stock text field draws.\n */\nexport const THEME_COMPONENT_LOOK_FIELDS: readonly ThemeComponentLookField[] = [\n {\n id: 'button.variant',\n group: 'button',\n label: 'Button style',\n kind: 'select',\n targets: [lookTarget('MuiButton', 'defaultProps', 'variant')],\n options: [\n { value: 'contained', label: 'Filled', stored: 'contained' },\n { value: 'outlined', label: 'Outlined', stored: 'outlined' },\n { value: 'text', label: 'Text only', stored: 'text' },\n ],\n },\n {\n id: 'button.corners',\n group: 'button',\n label: 'Button corners',\n kind: 'select',\n targets: [lookTarget('MuiButton', 'sx', 'borderRadius')],\n options: [...CORNER_OPTIONS, PILL_OPTION],\n },\n {\n id: 'button.textCase',\n group: 'button',\n label: 'Button text case',\n kind: 'select',\n targets: [lookTarget('MuiButton', 'styleOverrides', 'textTransform')],\n options: [\n { value: 'none', label: 'As typed', stored: 'none' },\n { value: 'uppercase', label: 'UPPERCASE', stored: 'uppercase' },\n { value: 'capitalize', label: 'Capitalize Each Word', stored: 'capitalize' },\n ],\n },\n {\n id: 'button.weight',\n group: 'button',\n label: 'Button text weight',\n kind: 'select',\n targets: [lookTarget('MuiButton', 'styleOverrides', 'fontWeight')],\n options: [\n { value: '400', label: 'Regular', stored: 400 },\n { value: '500', label: 'Medium', stored: 500 },\n { value: '600', label: 'Semibold', stored: 600 },\n { value: '700', label: 'Bold', stored: 700 },\n ],\n },\n {\n id: 'button.padding',\n group: 'button',\n label: 'Button padding',\n kind: 'select',\n // Spacing units, so padding follows the site's Spacing unit.\n targets: [lookTarget('MuiButton', 'sx', 'px'), lookTarget('MuiButton', 'sx', 'py')],\n options: [\n { value: 'compact', label: 'Compact', stored: [1.5, 0.5] },\n { value: 'comfortable', label: 'Comfortable', stored: [2, 0.75] },\n { value: 'roomy', label: 'Roomy', stored: [3, 1] },\n { value: 'wide', label: 'Wide', stored: [4, 1.25] },\n ],\n },\n {\n id: 'input.variant',\n group: 'input',\n label: 'Input style',\n kind: 'select',\n targets: [lookTarget('MuiTextField', 'defaultProps', 'variant')],\n options: [\n { value: 'outlined', label: 'Outlined', stored: 'outlined' },\n { value: 'filled', label: 'Filled', stored: 'filled' },\n ],\n },\n {\n id: 'input.corners',\n group: 'input',\n label: 'Input corners',\n kind: 'select',\n targets: [\n lookTarget('MuiOutlinedInput', 'sx', 'borderRadius'),\n lookTarget('MuiFilledInput', 'sx', 'borderRadius'),\n ],\n // A filled box's underline runs edge to edge; clipping it to the corners\n // keeps it inside a rounded box.\n companions: [{ ...lookTarget('MuiFilledInput', 'styleOverrides', 'overflow'), value: 'hidden' }],\n options: [...CORNER_OPTIONS, PILL_OPTION],\n },\n {\n id: 'input.background',\n group: 'input',\n label: 'Input background',\n kind: 'color',\n targets: [\n lookTarget('MuiOutlinedInput', 'sx', 'bgcolor'),\n lookTarget('MuiFilledInput', 'sx', 'bgcolor'),\n ],\n options: [\n { value: 'transparent', label: 'None', stored: 'transparent' },\n { value: 'paper', label: 'Paper', stored: 'background.paper', token: 'background.paper' },\n {\n value: 'background',\n label: 'Background',\n stored: 'background.default',\n token: 'background.default',\n },\n { value: 'tintPrimary', label: 'Primary tint', stored: 'tint.primary', token: 'tint.primary' },\n {\n value: 'tintSecondary',\n label: 'Secondary tint',\n stored: 'tint.secondary',\n token: 'tint.secondary',\n },\n {\n value: 'tintTertiary',\n label: 'Tertiary tint',\n stored: 'tint.tertiary',\n token: 'tint.tertiary',\n },\n ],\n },\n {\n id: 'input.border',\n group: 'input',\n label: 'Input border color',\n kind: 'color',\n targets: [\n lookTarget('MuiOutlinedInput', 'sx', 'borderColor'),\n lookTarget('MuiOutlinedInput', 'sx', 'borderColor', 'notchedOutline'),\n ],\n options: [\n { value: 'divider', label: 'Divider', stored: 'divider', token: 'divider' },\n {\n value: 'textSecondary',\n label: 'Secondary text',\n stored: 'text.secondary',\n token: 'text.secondary',\n },\n { value: 'text', label: 'Text', stored: 'text.primary', token: 'text.primary' },\n { value: 'primary', label: 'Primary', stored: 'primary.main', token: 'primary' },\n { value: 'secondary', label: 'Secondary', stored: 'secondary.main', token: 'secondary' },\n { value: 'tertiary', label: 'Tertiary', stored: 'tertiary.main', token: 'tertiary' },\n ],\n },\n {\n id: 'card.variant',\n group: 'card',\n label: 'Card style',\n kind: 'select',\n targets: [lookTarget('MuiCard', 'defaultProps', 'variant')],\n options: [\n { value: 'elevation', label: 'Shadow', stored: 'elevation' },\n { value: 'outlined', label: 'Outline', stored: 'outlined' },\n ],\n },\n {\n id: 'card.elevation',\n group: 'card',\n label: 'Card shadow depth',\n kind: 'select',\n targets: [lookTarget('MuiCard', 'defaultProps', 'elevation')],\n options: [\n { value: '0', label: 'Flat', stored: 0 },\n { value: '1', label: 'Soft', stored: 1 },\n { value: '3', label: 'Medium', stored: 3 },\n { value: '8', label: 'Strong', stored: 8 },\n ],\n },\n {\n id: 'card.corners',\n group: 'card',\n label: 'Card corners',\n kind: 'select',\n targets: [lookTarget('MuiCard', 'sx', 'borderRadius')],\n options: CORNER_OPTIONS,\n },\n]\n\n/** The catalog entry for a look field id. */\nexport function themeComponentLookField(id: ThemeComponentLookId): ThemeComponentLookField {\n const field = THEME_COMPONENT_LOOK_FIELDS.find((entry) => entry.id === id)\n if (!field) throw new Error(`unknown component look field ${id}`)\n return field\n}\n\nfunction storedFor(option: ThemeComponentLookOption, index: number) {\n return Array.isArray(option.stored)\n ? (option.stored as ReadonlyArray<string | number>)[index]\n : (option.stored as string | number)\n}\n\n/**\n * A look field as its select shows it: the choice the site's overrides hold,\n * {@link THEME_LOOK_DEFAULT} when they set nothing, or\n * {@link THEME_LOOK_CUSTOM} when they set a value no choice names.\n */\nexport function readComponentLook(\n theme: HostTheme | undefined,\n field: ThemeComponentLookField,\n): string {\n const values = field.targets.map((target) => readComponentOverride(theme, target))\n if (values.every((value) => value === undefined)) return THEME_LOOK_DEFAULT\n const match = field.options.find((option) =>\n values.every((value, index) => value === storedFor(option, index)),\n )\n return match ? match.value : THEME_LOOK_CUSTOM\n}\n\n/**\n * Sets a look field to one of its choices, or back to the theme's own look\n * with {@link THEME_LOOK_DEFAULT}, which clears every leaf it sets. Any other\n * value changes nothing.\n */\nexport function writeComponentLook(\n theme: HostTheme,\n field: ThemeComponentLookField,\n value: string,\n): HostTheme {\n if (value === THEME_LOOK_DEFAULT) {\n let next = theme\n for (const target of [...field.targets, ...(field.companions ?? [])]) {\n next = clearComponentOverride(next, target)\n }\n return next\n }\n const option = field.options.find((entry) => entry.value === value)\n if (!option) return theme\n let next = theme\n field.targets.forEach((target, index) => {\n next = writeComponentOverride(next, { ...target, value: storedFor(option, index) })\n })\n for (const companion of field.companions ?? []) next = writeComponentOverride(next, companion)\n return next\n}\n"],"names":["HOST_THEME_COMPONENT_WHITELIST","TOOLBAR_SM_MIN_WIDTH","TOOLBAR_SM_QUERY","DEFAULT_TOOLBAR_XS","DEFAULT_TOOLBAR_SM","TOOLBAR_LANDSCAPE_QUERY","TOOLBAR_LANDSCAPE_RULE","minHeight","readToolbarHeight","theme","breakpoint","toolbar","mixins","undefined","raw","value","parseFloat","String","Number","isFinite","buildToolbarMixin","xs","sm","orderSensitiveKey","JSON","stringify","PALETTE_COLOR_FIELDS","key","label","SURFACE_COLOR_FIELDS","path","TINT_COLOR_FIELDS","DIVIDER_COLOR_FIELD","GOOGLE_FONT_OPTIONS","family","category","weights","fontFamilyStack","fallback","getSchemeColor","colors","group","THEME_EDITOR_SCHEMES","THEME_COLOR_FIELDS","map","token","join","DARK_SCHEME_FIELD","options","SYSTEM_FONT_VALUE","FONT_FAMILY_FIELD","BORDER_RADIUS_FIELD","min","max","step","SPACING_FIELD","TOOLBAR_HEIGHT_FIELDS","COMPONENT_OVERRIDES_FIELD","components","THEME_EDITOR_MEDIA_QUERIES","mobile","desktop","THEME_EDITOR_CONTROLS","id","kind","perScheme","option","themeEditorControl","control","find","entry","Error","setSchemeValue","scheme","update","colorSchemes","readThemeColor","divider","split","main","writeThemeColor","hex","next","paletteKey","tint","rest","Object","keys","length","groupKey","groupValue","grouped","copyThemeSchemeColors","from","to","source","parse","readDarkScheme","darkScheme","writeDarkScheme","readFontFamily","readThemeFonts","body","writeFontFamily","current","writeThemeFonts","heading","THEME_HEADING_VARIANTS","firstStackFamily","stack","first","trim","replace","stackCategory","test","sortedWeights","values","Set","Math","round","filter","sort","a","b","choiceOf","font","italics","findFont","wanted","toLowerCase","fonts","typography","fontFamily","bodyFont","headingStack","variants","h1","headingFont","fontEntry","choice","selection","previous","previousHeadingStack","chosen","chosenKeys","otherStyles","entries","includes","variant","kept","has","writeBorderRadius","shape","borderRadius","writeSpacing","spacing","writeToolbarHeight","valid","edited","resetComponentOverrides","writeComponentOverride","leaf","component","target","defaultProps","property","slot","styles","sx","styleOverrides","slotStyles","media","query","clearComponentOverride","existing","props","branch","scoped","readComponentOverride","THEME_COMPONENT_LOOK_GROUPS","THEME_LOOK_DEFAULT","THEME_LOOK_CUSTOM","lookTarget","CORNER_OPTIONS","stored","PILL_OPTION","THEME_COMPONENT_LOOK_FIELDS","targets","companions","themeComponentLookField","field","storedFor","index","Array","isArray","readComponentLook","every","match","writeComponentLook","forEach","companion"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAWD,SACEA,8BAA8B,QAEzB,kBAAc;AAErB;;;;;;;;;;;;;;;;;;;;CAoBC,GAED;;;;CAIC,GACD,OAAO,MAAMC,uBAAuB,IAAG;AACvC,OAAO,MAAMC,mBAAmB,CAAC,kBAAkB,EAAED,qBAAqB,GAAG,CAAC,CAAA;AAC9E,mEAAmE,GACnE,OAAO,MAAME,qBAAqB,GAAE;AACpC,OAAO,MAAMC,qBAAqB,GAAE;AACpC;;;;CAIC,GACD,OAAO,MAAMC,0BAA0B,yBAAwB;AAC/D,OAAO,MAAMC,yBAAyB;IACpC,mCAAmC;QAAEC,WAAW;IAAG;AACrD,EAAC;AAED,uEAAuE,GACvE,OAAO,SAASC,kBAAkBC,KAAgB,EAAEC,UAAuB;QACzDD,eAKTE;IALP,MAAMA,WAAUF,gBAAAA,MAAMG,MAAM,qBAAZH,cAAcE,OAAO;IACrC,IAAI,CAACA,SAAS,OAAOE;IACrB,MA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AC,CAACpC,QAAQ6B;QAC7B9G,OAAO8E,uBAAuB9E,MAAM,aAAKiF;YAAQpJ,OAAOgL,UAAU7H,QAAQ8H;;IAC5E;IACA,KAAK,MAAMQ,cAAaV,oBAAAA,MAAMF,UAAU,YAAhBE,oBAAoB,EAAE,CAAE5G,OAAO8E,uBAAuB9E,MAAMsH;IACpF,OAAOtH;AACT"}
1
+ {"version":3,"sources":["../../../../../../../../libs/shared/ui/theme/src/lib/util/theme-editor-fields.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n HostTheme,\n HostThemeComponentOverride,\n HostThemeScheme,\n HostThemeSchemeColors,\n} from '@aglyn/shared-data-types'\nimport { readThemeFonts, writeThemeFonts } from '@aglyn/shared-util-tools/theme-fonts'\nimport {\n HOST_THEME_COMPONENT_WHITELIST,\n type HostThemeComponentKey,\n} from './host-theme'\n\n// The font read and write live in `@aglyn/shared-util-tools/theme-fonts`\n// (AGL-4049), where the platform core can reach them too; every name stays\n// importable from here.\nexport {\n firstStackFamily,\n fontFamilyStack,\n readThemeFonts,\n THEME_HEADING_VARIANTS,\n writeThemeFonts,\n type ThemeFontChoice,\n type ThemeFontSelection,\n} from '@aglyn/shared-util-tools/theme-fonts'\n\n/**\n * The host theme editor's field catalog (AGL-2938): every control the editor\n * renders, the range each one accepts, the token it writes, and the write\n * itself.\n *\n * It lives here rather than beside the editor because the editor is not the\n * only thing that changes a site's theme. Anything that proposes a theme\n * change has to offer exactly the controls the editor offers, with the same\n * bounds, and has to write each one the way the editor writes it. A copy of\n * this list anywhere else is a second answer to \"what can a theme hold\" that\n * drifts from the first the day a control is added, so the editor renders\n * from this module and every other writer reads it.\n *\n * Pure data and pure functions over `HostTheme`: no MUI, no React and no\n * brand theme. What a control resolves to when the site sets nothing is the\n * brand theme's business, in `theme-editor-defaults.ts`.\n *\n * Deliberately NOT re-exported from this library's index: the index reaches\n * every published page, and nothing a visitor renders needs the catalog.\n * Reach it as `@aglyn/shared-ui-theme/util/theme-editor-fields`.\n */\n\n/**\n * MUI's own toolbar breakpoint. `mixins.toolbar` has to carry this exact\n * query, because the rule it competes with is MUI's `@media (min-width:600px)\n * { min-height: 64px }` (AGL-1242).\n */\nexport const TOOLBAR_SM_MIN_WIDTH = 600\nexport const TOOLBAR_SM_QUERY = `@media (min-width:${TOOLBAR_SM_MIN_WIDTH}px)`\n/** MUI's stock Toolbar heights, shown when the host has set none. */\nexport const DEFAULT_TOOLBAR_XS = 56\nexport const DEFAULT_TOOLBAR_SM = 64\n/**\n * `createMixins` spreads `...mixins` AFTER its default, so anything we write\n * REPLACES the stock toolbar wholesale — including its short-landscape rule.\n * Carrying it forward keeps that behavior instead of dropping it silently.\n */\nexport const TOOLBAR_LANDSCAPE_QUERY = '@media (min-width:0px)'\nexport const TOOLBAR_LANDSCAPE_RULE = {\n '@media (orientation: landscape)': { minHeight: 48 },\n}\n\n/** Reads a px `minHeight` out of `mixins.toolbar` for one breakpoint. */\nexport function readToolbarHeight(theme: HostTheme, breakpoint: 'xs' | 'sm') {\n const toolbar = theme.mixins?.toolbar\n if (!toolbar) return undefined\n const raw =\n breakpoint === 'xs'\n ? toolbar.minHeight\n : (toolbar[TOOLBAR_SM_QUERY] as { minHeight?: unknown } | undefined)\n ?.minHeight\n const value = parseFloat(String(raw ?? ''))\n return Number.isFinite(value) ? value : undefined\n}\n\n/**\n * Builds a COMPLETE `mixins.toolbar`, in the order MUI emits it.\n *\n * Two things this exists to get right, both because `mixins.toolbar` replaces\n * MUI's default wholesale rather than merging into it (AGL-1242):\n *\n * - **Completeness.** Anything omitted is simply gone. Writing only a desktop\n * height left portrait phones with no `min-height` at all, so unset\n * breakpoints fall back to MUI's own 56 / 64.\n * - **Key order.** These land in one CSS rule, so the last matching\n * declaration wins. MUI emits the landscape clause BEFORE the sm height;\n * emitting it after makes a wide landscape window — i.e. every desktop —\n * 48px tall.\n */\nexport function buildToolbarMixin(xs: number | undefined, sm: number | undefined) {\n return {\n minHeight: `${xs ?? DEFAULT_TOOLBAR_XS}px`,\n [TOOLBAR_LANDSCAPE_QUERY]: TOOLBAR_LANDSCAPE_RULE,\n [TOOLBAR_SM_QUERY]: { minHeight: `${sm ?? DEFAULT_TOOLBAR_SM}px` },\n }\n}\n\n/**\n * Serializes the branches whose KEY ORDER changes what renders.\n *\n * `deepEqual` is order-INsensitive on purpose (AGL-56: Firestore hands the\n * palette back in a different key order than the editor builds it, and a\n * string compare left Save enabled forever), so on its own it cannot see a\n * reorder of `mixins.toolbar` — a change that really does alter the CSS.\n *\n * Deliberately narrow: only `mixins`. `components.*.styleOverrides` are CSS\n * objects too, but widening this would re-expose the AGL-56 failure for every\n * host with component overrides, and order-sensitivity has only actually been\n * demonstrated here.\n *\n * Firestore does NOT hand a map back in the order it was written, and it\n * hands different readers different orders (AGL-3146) — which is why what\n * renders is canonicalized in `hostThemeToThemeOptions` rather than trusted\n * from storage. A freshly-loaded document is still not dirty here, because\n * the draft is seeded from the loaded document itself: both sides of this\n * comparison carry whatever order THIS reader was given.\n */\nexport function orderSensitiveKey(theme: HostTheme): string {\n return JSON.stringify(theme.mixins ?? {})\n}\n\nexport type PaletteColorKey =\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'surface'\n | 'error'\n | 'warning'\n | 'info'\n | 'success'\n\nexport const PALETTE_COLOR_FIELDS: Array<{\n key: PaletteColorKey\n label: string\n}> = [\n { key: 'primary', label: 'Primary' },\n { key: 'secondary', label: 'Secondary' },\n { key: 'tertiary', label: 'Tertiary' },\n { key: 'surface', label: 'Surface' },\n { key: 'error', label: 'Error' },\n { key: 'warning', label: 'Warning' },\n { key: 'info', label: 'Info' },\n { key: 'success', label: 'Success' },\n]\n\nexport type SurfaceColorPath =\n | ['background', 'default']\n | ['background', 'paper']\n | ['text', 'primary']\n | ['text', 'secondary']\n | ['text', 'disabled']\n | ['tint', 'primary']\n | ['tint', 'secondary']\n | ['tint', 'tertiary']\n\nexport const SURFACE_COLOR_FIELDS: Array<{\n path: SurfaceColorPath\n label: string\n}> = [\n { path: ['background', 'default'], label: 'Background' },\n { path: ['background', 'paper'], label: 'Paper' },\n { path: ['text', 'primary'], label: 'Text' },\n { path: ['text', 'secondary'], label: 'Secondary text' },\n { path: ['text', 'disabled'], label: 'Disabled text' },\n]\n\n/**\n * Pale accent washes (AGL-1244).\n *\n * Separate from {@link PALETTE_COLOR_FIELDS} because a tint is a STRING LEAF,\n * not a `{ main }` record — the palette fields all write `main`, and a tint has\n * none. It rides the same `SurfaceColorPath` machinery as `background`/`text`\n * for exactly that reason, and is listed apart only so the editor can head it\n * \"Tints\" instead of filing it under \"Background & text\".\n */\nexport const TINT_COLOR_FIELDS: Array<{\n path: SurfaceColorPath\n label: string\n}> = [\n { path: ['tint', 'primary'], label: 'Primary tint' },\n { path: ['tint', 'secondary'], label: 'Secondary tint' },\n { path: ['tint', 'tertiary'], label: 'Tertiary tint' },\n]\n\n/** The one color leaf that is neither a palette color nor a member of a group. */\nexport const DIVIDER_COLOR_FIELD = { key: 'divider', label: 'Divider' } as const\n\n/** Curated Google Fonts choices for the font family selector. */\nexport const GOOGLE_FONT_OPTIONS: Array<{\n family: string\n category: 'sans-serif' | 'serif' | 'monospace' | 'display'\n weights: Array<number>\n}> = [\n { family: 'Inter', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Roboto', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Open Sans', category: 'sans-serif', weights: [400, 600, 700] },\n { family: 'Lato', category: 'sans-serif', weights: [400, 700] },\n { family: 'Montserrat', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Poppins', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Nunito', category: 'sans-serif', weights: [400, 600, 700] },\n { family: 'Work Sans', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Raleway', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Merriweather', category: 'serif', weights: [400, 700] },\n { family: 'Playfair Display', category: 'serif', weights: [400, 700] },\n { family: 'Lora', category: 'serif', weights: [400, 700] },\n { family: 'Source Serif 4', category: 'serif', weights: [400, 700] },\n { family: 'JetBrains Mono', category: 'monospace', weights: [400, 700] },\n { family: 'Bebas Neue', category: 'display', weights: [400] },\n]\n\nexport function getSchemeColor(\n colors: HostThemeSchemeColors | undefined,\n path: SurfaceColorPath,\n): string | undefined {\n const [group, key] = path\n return (colors?.[group] as Record<string, string> | undefined)?.[key]\n}\n\n/* ------------------------------------------------------------------------ *\n * The controls, as one catalog\n * ------------------------------------------------------------------------ */\n\n/** The two color schemes the editor edits, in tab order. */\nexport const THEME_EDITOR_SCHEMES: readonly HostThemeScheme[] = ['light', 'dark']\n\n/**\n * Every color the editor edits per scheme, named the way a diff names it: a\n * palette key (`primary`), a group path joined with a dot\n * (`background.default`, `tint.primary`), or `divider`.\n */\nexport type ThemeColorToken =\n | PaletteColorKey\n | 'background.default'\n | 'background.paper'\n | 'text.primary'\n | 'text.secondary'\n | 'text.disabled'\n | 'tint.primary'\n | 'tint.secondary'\n | 'tint.tertiary'\n | 'divider'\n\n/** Where a color control sits in the editor's Color scheme card. */\nexport type ThemeColorGroup = 'palette' | 'surface' | 'tint' | 'divider'\n\n/** Every color field the editor renders, in the order it renders them. */\nexport const THEME_COLOR_FIELDS: ReadonlyArray<{\n token: ThemeColorToken\n label: string\n group: ThemeColorGroup\n}> = [\n ...PALETTE_COLOR_FIELDS.map(({ key, label }) => ({\n token: key,\n label,\n group: 'palette' as const,\n })),\n ...SURFACE_COLOR_FIELDS.map(({ path, label }) => ({\n token: path.join('.') as ThemeColorToken,\n label,\n group: 'surface' as const,\n })),\n ...TINT_COLOR_FIELDS.map(({ path, label }) => ({\n token: path.join('.') as ThemeColorToken,\n label,\n group: 'tint' as const,\n })),\n {\n token: DIVIDER_COLOR_FIELD.key,\n label: DIVIDER_COLOR_FIELD.label,\n group: 'divider' as const,\n },\n]\n\n/** Whether visitors get a dark scheme; absent from the document means `auto`. */\nexport type ThemeDarkSchemeValue = 'auto' | 'off'\n\nexport const DARK_SCHEME_FIELD = {\n label: 'Dark scheme',\n options: [\n { value: 'auto', label: 'Follows the visitor' },\n { value: 'off', label: 'Off — always light' },\n ],\n} as const\n\n/**\n * The font select's value for \"no font of the site's own\": the theme's\n * default stack, with nothing to load.\n */\nexport const SYSTEM_FONT_VALUE = '__system__'\n\nexport const FONT_FAMILY_FIELD = { label: 'Font family' } as const\n\n/** The corner radius slider, in px. */\nexport const BORDER_RADIUS_FIELD = {\n label: 'Border radius',\n min: 0,\n max: 24,\n step: 1,\n} as const\n\n/** The spacing unit MUI multiplies every `spacing(n)` by, in px. */\nexport const SPACING_FIELD = {\n label: 'Spacing unit (px)',\n min: 2,\n max: 16,\n step: 1,\n} as const\n\n/** The two nav heights, either side of MUI's toolbar breakpoint, in px. */\nexport const TOOLBAR_HEIGHT_FIELDS = {\n xs: { label: 'Nav height, mobile (px)', min: 40, max: 160, step: 1 },\n sm: { label: 'Nav height, desktop (px)', min: 40, max: 160, step: 1 },\n} as const\n\n/**\n * The site-wide look of components: the click-only fields in\n * {@link THEME_COMPONENT_LOOK_FIELDS}, with the full override set behind\n * them limited to the sanitizer's whitelist.\n */\nexport const COMPONENT_OVERRIDES_FIELD = {\n label: 'Style components',\n components: HOST_THEME_COMPONENT_WHITELIST,\n} as const\n\n/**\n * The media queries a component override may scope a style to: either side\n * of MUI's own toolbar breakpoint, the one breakpoint the editor already\n * names. MUI's `down('sm')` stops a twentieth of a pixel short of it.\n */\nexport const THEME_EDITOR_MEDIA_QUERIES = {\n mobile: `@media (max-width:${TOOLBAR_SM_MIN_WIDTH - 0.05}px)`,\n desktop: TOOLBAR_SM_QUERY,\n} as const\n\nexport type ThemeEditorMedia = keyof typeof THEME_EDITOR_MEDIA_QUERIES\n\nexport type ThemeEditorControlId =\n | `color.${ThemeColorToken}`\n | 'darkScheme'\n | 'fontFamily'\n | 'borderRadius'\n | 'spacing'\n | 'navHeight.xs'\n | 'navHeight.sm'\n | 'components'\n\n/** One control the editor renders, described well enough to be offered elsewhere. */\nexport interface ThemeEditorControl {\n /** Stable id: what a diff row, a proposal and a spec name the control by. */\n id: ThemeEditorControlId\n /** The label the editor shows. */\n label: string\n kind: 'color' | 'select' | 'number' | 'components'\n /** Edited once per scheme, under the Light and Dark tabs. */\n perScheme: boolean\n /** A color control's token. */\n token?: ThemeColorToken\n /** A select's values, or the components a components control may style. */\n options?: readonly string[]\n /** A number control's inclusive bounds and its step. */\n min?: number\n max?: number\n step?: number\n}\n\n/**\n * Every value-bearing control the editor renders, in the order it renders\n * them. The buttons that act on these values rather than hold one — Copy\n * from light, Reset to default, Discard, Save — are not controls: a reset is\n * a control set back to nothing, and a copy is every color control of one\n * scheme written from the other.\n */\nexport const THEME_EDITOR_CONTROLS: readonly ThemeEditorControl[] = [\n {\n id: 'darkScheme',\n label: DARK_SCHEME_FIELD.label,\n kind: 'select',\n perScheme: false,\n options: DARK_SCHEME_FIELD.options.map((option) => option.value),\n },\n ...THEME_COLOR_FIELDS.map(({ token, label }) => ({\n id: `color.${token}` as const,\n label,\n kind: 'color' as const,\n perScheme: true,\n token,\n })),\n {\n id: 'fontFamily',\n label: FONT_FAMILY_FIELD.label,\n kind: 'select',\n perScheme: false,\n options: [SYSTEM_FONT_VALUE, ...GOOGLE_FONT_OPTIONS.map((option) => option.family)],\n },\n {\n id: 'borderRadius',\n label: BORDER_RADIUS_FIELD.label,\n kind: 'number',\n perScheme: false,\n min: BORDER_RADIUS_FIELD.min,\n max: BORDER_RADIUS_FIELD.max,\n step: BORDER_RADIUS_FIELD.step,\n },\n {\n id: 'spacing',\n label: SPACING_FIELD.label,\n kind: 'number',\n perScheme: false,\n min: SPACING_FIELD.min,\n max: SPACING_FIELD.max,\n step: SPACING_FIELD.step,\n },\n {\n id: 'navHeight.xs',\n label: TOOLBAR_HEIGHT_FIELDS.xs.label,\n kind: 'number',\n perScheme: false,\n min: TOOLBAR_HEIGHT_FIELDS.xs.min,\n max: TOOLBAR_HEIGHT_FIELDS.xs.max,\n step: TOOLBAR_HEIGHT_FIELDS.xs.step,\n },\n {\n id: 'navHeight.sm',\n label: TOOLBAR_HEIGHT_FIELDS.sm.label,\n kind: 'number',\n perScheme: false,\n min: TOOLBAR_HEIGHT_FIELDS.sm.min,\n max: TOOLBAR_HEIGHT_FIELDS.sm.max,\n step: TOOLBAR_HEIGHT_FIELDS.sm.step,\n },\n {\n id: 'components',\n label: COMPONENT_OVERRIDES_FIELD.label,\n kind: 'components',\n perScheme: false,\n options: COMPONENT_OVERRIDES_FIELD.components,\n },\n]\n\n/** The catalog entry for a control id. */\nexport function themeEditorControl(id: ThemeEditorControlId): ThemeEditorControl {\n const control = THEME_EDITOR_CONTROLS.find((entry) => entry.id === id)\n if (!control) throw new Error(`unknown theme editor control ${id}`)\n return control\n}\n\n/* ------------------------------------------------------------------------ *\n * Reads and writes, exactly as the editor performs them\n * ------------------------------------------------------------------------ */\n\nfunction setSchemeValue(\n theme: HostTheme,\n scheme: HostThemeScheme,\n update: (colors: HostThemeSchemeColors) => HostThemeSchemeColors,\n): HostTheme {\n const colors = theme.colorSchemes?.[scheme] ?? {}\n return {\n ...theme,\n colorSchemes: { ...theme.colorSchemes, [scheme]: update(colors) },\n }\n}\n\n/** A color the site set for one scheme; `undefined` when the slot inherits. */\nexport function readThemeColor(\n theme: HostTheme | undefined,\n scheme: HostThemeScheme,\n token: ThemeColorToken,\n): string | undefined {\n const colors = theme?.colorSchemes?.[scheme]\n if (token === 'divider') return colors?.divider\n const [group, key] = token.split('.')\n if (!key) return colors?.[group as PaletteColorKey]?.main\n return getSchemeColor(colors, [group, key] as SurfaceColorPath)\n}\n\n/**\n * Sets one color for one scheme, or clears it with `undefined` so the slot\n * inherits again. A palette color writes a record of `main` alone: its\n * `light`, `dark` and `contrastText` were derived from (or authored for) the\n * old `main`, and the editor offers no control for them, so a kept shade\n * would go on painting the old color (an outlined button reads `dark`) with\n * no way for the owner to see or change it. Dropped, the theme derives them\n * from the new `main`. Clearing it drops the record; a group member that\n * leaves its group empty drops the group.\n */\nexport function writeThemeColor(\n theme: HostTheme,\n scheme: HostThemeScheme,\n token: ThemeColorToken,\n hex: string | undefined,\n): HostTheme {\n return setSchemeValue(theme, scheme, (colors) => {\n const next: HostThemeSchemeColors = { ...colors }\n if (token === 'divider') {\n if (hex) next.divider = hex\n else delete next.divider\n return next\n }\n const [group, key] = token.split('.')\n if (!key) {\n const paletteKey = group as PaletteColorKey\n if (hex) next[paletteKey] = { main: hex }\n else delete next[paletteKey]\n // An accent's tint is a wash of its old `main` for the same reason, so\n // it goes too and the theme washes one from the new color.\n const tint = next.tint as Record<string, string> | undefined\n if (tint && paletteKey in tint) {\n const rest = { ...tint }\n delete rest[paletteKey]\n if (Object.keys(rest).length) next.tint = rest as HostThemeSchemeColors['tint']\n else delete next.tint\n }\n return next\n }\n const groupKey = group as 'background' | 'text' | 'tint'\n const groupValue = {\n ...(colors[groupKey] as Record<string, string> | undefined),\n }\n if (hex) groupValue[key] = hex\n else delete groupValue[key]\n const grouped = { ...next, [groupKey]: groupValue } as HostThemeSchemeColors\n if (!Object.keys(groupValue).length) delete grouped[groupKey]\n return grouped\n })\n}\n\n/** Replaces one scheme's colors with a copy of the other's. */\nexport function copyThemeSchemeColors(\n theme: HostTheme,\n from: HostThemeScheme,\n to: HostThemeScheme,\n): HostTheme {\n const source = theme.colorSchemes?.[from]\n if (!source) return theme\n return {\n ...theme,\n colorSchemes: {\n ...theme.colorSchemes,\n [to]: JSON.parse(JSON.stringify(source)),\n },\n }\n}\n\n/** The dark scheme switch as the select shows it. */\nexport function readDarkScheme(theme: HostTheme | undefined): ThemeDarkSchemeValue {\n return theme?.darkScheme === 'off' ? 'off' : 'auto'\n}\n\n/**\n * Absent means \"follows the visitor\"; only the opt-out is written, so the\n * saved document stays empty for the common case.\n */\nexport function writeDarkScheme(\n theme: HostTheme,\n value: ThemeDarkSchemeValue,\n): HostTheme {\n const next: HostTheme = { ...theme }\n if (value === 'off') next.darkScheme = 'off'\n else delete next.darkScheme\n return next\n}\n\n/** The font select's value: the site's font, or {@link SYSTEM_FONT_VALUE}. */\nexport function readFontFamily(theme: HostTheme | undefined): string {\n return readThemeFonts(theme).body?.family ?? SYSTEM_FONT_VALUE\n}\n\n/**\n * Picks a font from {@link GOOGLE_FONT_OPTIONS}, loading it and naming it as\n * the typography's stack, or {@link SYSTEM_FONT_VALUE} to go back to the\n * theme default. A family outside the curated list changes nothing.\n */\nexport function writeFontFamily(theme: HostTheme, value: string): HostTheme {\n // Through writeThemeFonts (AGL-3656), so a heading font and the site's own\n // uploaded fonts survive a body font picked from the short list or by the\n // AI theme step; replacing `fonts` wholesale dropped both.\n const current = readThemeFonts(theme)\n if (value === SYSTEM_FONT_VALUE) {\n return writeThemeFonts(theme, { body: null, heading: current.heading })\n }\n const option = GOOGLE_FONT_OPTIONS.find((entry) => entry.family === value)\n if (!option) return theme\n return writeThemeFonts(theme, {\n body: {\n family: option.family,\n category: option.category,\n weights: option.weights,\n source: 'google',\n },\n heading: current.heading,\n })\n}\n\n/** Sets the corner radius, or clears it with `undefined` so it inherits. */\nexport function writeBorderRadius(\n theme: HostTheme,\n value: number | undefined,\n): HostTheme {\n if (value !== undefined && Number.isFinite(value)) {\n return { ...theme, shape: { ...theme.shape, borderRadius: value } }\n }\n const next = { ...theme }\n const shape = { ...next.shape }\n delete shape.borderRadius\n if (Object.keys(shape).length) next.shape = shape\n else delete next.shape\n return next\n}\n\n/** Sets the spacing unit; anything but a positive number clears it. */\nexport function writeSpacing(theme: HostTheme, value: number | undefined): HostTheme {\n const next = { ...theme }\n if (value !== undefined && Number.isFinite(value) && value > 0) next.spacing = value\n else delete next.spacing\n return next\n}\n\n/**\n * Sets one nav height — anything but a positive number clears it — and\n * rebuilds the whole toolbar mixin around both, because `mixins.toolbar`\n * replaces MUI's default rather than merging into it (AGL-1242).\n */\nexport function writeToolbarHeight(\n theme: HostTheme,\n breakpoint: 'xs' | 'sm',\n value: number | undefined,\n): HostTheme {\n const valid = value !== undefined && Number.isFinite(value) && value > 0\n const edited = valid ? value : undefined\n const xs = breakpoint === 'xs' ? edited : readToolbarHeight(theme, 'xs')\n const sm = breakpoint === 'sm' ? edited : readToolbarHeight(theme, 'sm')\n const next = { ...theme }\n if (xs === undefined && sm === undefined) {\n delete next.mixins\n return next\n }\n next.mixins = { toolbar: buildToolbarMixin(xs, sm) }\n return next\n}\n\n/**\n * Drops the site's component overrides. With nothing stored the site renders\n * the brand's own component styles, which is what the editor's \"Reset to\n * theme defaults\" means.\n */\nexport function resetComponentOverrides(theme: HostTheme): HostTheme {\n const next = { ...theme }\n delete next.components\n return next\n}\n\n/** One leaf of a component override, as a writer names it. */\nexport interface ThemeComponentOverrideLeaf {\n component: HostThemeComponentKey\n /**\n * `styleOverrides` styles a slot in literal CSS; `sx` styles it in theme\n * terms, so a value may name a palette path (`primary.main`) or a spacing\n * unit (AGL-3403); `defaultProps` sets a prop's default.\n */\n target: 'styleOverrides' | 'sx' | 'defaultProps'\n /** The style slot (`root`, `contained`, `h1`); `null` for a default prop. */\n slot: string | null\n /** A camelCase CSS property, or the prop's name. */\n property: string\n /** Scopes a style to one side of the toolbar breakpoint; `null` for every width. */\n media: ThemeEditorMedia | null\n value: string | number | boolean\n}\n\n/**\n * Sets one leaf inside the site's component overrides and keeps every other\n * override the site has. The stored overrides are deep-merged over the\n * brand's own at render time, so naming one property changes that property\n * and inherits the rest of the component.\n */\nexport function writeComponentOverride(\n theme: HostTheme,\n leaf: ThemeComponentOverrideLeaf,\n): HostTheme {\n const components = { ...theme.components }\n const entry: HostThemeComponentOverride = { ...components[leaf.component] }\n if (leaf.target === 'defaultProps') {\n entry.defaultProps = { ...entry.defaultProps, [leaf.property]: leaf.value }\n } else {\n const slot = leaf.slot ?? 'root'\n const styles: Record<string, unknown> = {\n ...(leaf.target === 'sx' ? entry.sx : entry.styleOverrides),\n }\n const slotStyles = { ...(styles[slot] as Record<string, unknown> | undefined) }\n if (leaf.media) {\n const query = THEME_EDITOR_MEDIA_QUERIES[leaf.media]\n slotStyles[query] = {\n ...(slotStyles[query] as Record<string, unknown> | undefined),\n [leaf.property]: leaf.value,\n }\n } else {\n slotStyles[leaf.property] = leaf.value\n }\n styles[slot] = slotStyles\n if (leaf.target === 'sx') {\n entry.sx = styles as HostThemeComponentOverride['sx']\n } else {\n entry.styleOverrides = styles\n }\n }\n components[leaf.component] = entry\n return { ...theme, components }\n}\n\n/** Where one leaf lives, without the value it holds. */\nexport type ThemeComponentOverrideTarget = Omit<ThemeComponentOverrideLeaf, 'value'>\n\n/**\n * Removes one leaf from the site's component overrides, and every slot,\n * branch and component it leaves empty, so a field set back to \"Theme\n * default\" stores nothing and the site inherits that property again.\n */\nexport function clearComponentOverride(\n theme: HostTheme,\n target: ThemeComponentOverrideTarget,\n): HostTheme {\n const existing = theme.components?.[target.component]\n if (!existing) return theme\n const entry: HostThemeComponentOverride = { ...existing }\n if (target.target === 'defaultProps') {\n const props = { ...entry.defaultProps }\n delete props[target.property]\n if (Object.keys(props).length) entry.defaultProps = props\n else delete entry.defaultProps\n } else {\n const branch = target.target === 'sx' ? 'sx' : 'styleOverrides'\n const styles: Record<string, unknown> = { ...entry[branch] }\n const slot = target.slot ?? 'root'\n const slotStyles = { ...(styles[slot] as Record<string, unknown> | undefined) }\n if (target.media) {\n const query = THEME_EDITOR_MEDIA_QUERIES[target.media]\n const scoped = { ...(slotStyles[query] as Record<string, unknown> | undefined) }\n delete scoped[target.property]\n if (Object.keys(scoped).length) slotStyles[query] = scoped\n else delete slotStyles[query]\n } else {\n delete slotStyles[target.property]\n }\n if (Object.keys(slotStyles).length) styles[slot] = slotStyles\n else delete styles[slot]\n if (Object.keys(styles).length) {\n if (branch === 'sx') entry.sx = styles as HostThemeComponentOverride['sx']\n else entry.styleOverrides = styles\n } else {\n delete entry[branch]\n }\n }\n const components = { ...theme.components }\n if (Object.keys(entry).length) components[target.component] = entry\n else delete components[target.component]\n const next: HostTheme = { ...theme }\n if (Object.keys(components).length) next.components = components\n else delete next.components\n return next\n}\n\n/** The value one override leaf holds; `undefined` when the site does not set it. */\nexport function readComponentOverride(\n theme: HostTheme | undefined,\n target: ThemeComponentOverrideTarget,\n): unknown {\n const entry = theme?.components?.[target.component]\n if (!entry) return undefined\n if (target.target === 'defaultProps') return entry.defaultProps?.[target.property]\n const styles = (target.target === 'sx' ? entry.sx : entry.styleOverrides) as\n | Record<string, unknown>\n | undefined\n const slotStyles = styles?.[target.slot ?? 'root'] as Record<string, unknown> | undefined\n if (!target.media) return slotStyles?.[target.property]\n const query = THEME_EDITOR_MEDIA_QUERIES[target.media]\n return (slotStyles?.[query] as Record<string, unknown> | undefined)?.[target.property]\n}\n\n/* ------------------------------------------------------------------------ *\n * The look of components, as click-only fields\n * ------------------------------------------------------------------------ */\n\n/** The components the Style components card sets a site-wide look for. */\nexport type ThemeComponentLookGroup = 'button' | 'input' | 'card'\n\nexport const THEME_COMPONENT_LOOK_GROUPS: ReadonlyArray<{\n group: ThemeComponentLookGroup\n label: string\n}> = [\n { group: 'button', label: 'Buttons' },\n { group: 'input', label: 'Form inputs' },\n { group: 'card', label: 'Cards' },\n]\n\nexport type ThemeComponentLookId =\n | 'button.variant'\n | 'button.corners'\n | 'button.textCase'\n | 'button.weight'\n | 'button.padding'\n | 'input.variant'\n | 'input.corners'\n | 'input.background'\n | 'input.border'\n | 'card.variant'\n | 'card.elevation'\n | 'card.corners'\n\n/** One choice a look field offers. */\nexport interface ThemeComponentLookOption {\n /** What the select holds. */\n value: string\n label: string\n /**\n * What each of the field's targets stores, in target order; one value\n * stands for every target.\n */\n stored: string | number | ReadonlyArray<string | number>\n /** A theme color this choice draws in, for its swatch. */\n token?: ThemeColorToken\n}\n\n/**\n * A click-only field over the site's component overrides. Each choice writes\n * the same leaves the Advanced overrides hold, so the two are one setting\n * seen two ways, and anything that writes override leaves can set it.\n */\nexport interface ThemeComponentLookField {\n id: ThemeComponentLookId\n group: ThemeComponentLookGroup\n label: string\n /** `color` choices are theme colors, shown as swatches of the scheme in view. */\n kind: 'select' | 'color'\n /** The leaves a choice sets, read back from the first. */\n targets: readonly ThemeComponentOverrideTarget[]\n /** Leaves set alongside any choice and cleared with it: what makes the choice draw right. */\n companions?: readonly ThemeComponentOverrideLeaf[]\n options: readonly ThemeComponentLookOption[]\n}\n\n/** The select's value for a field the site does not set: the theme's own look. */\nexport const THEME_LOOK_DEFAULT = ''\n/** The select's value for a leaf set to something no choice names, by hand or by AI. */\nexport const THEME_LOOK_CUSTOM = '__custom__'\n\nfunction lookTarget(\n component: HostThemeComponentKey,\n target: ThemeComponentOverrideLeaf['target'],\n property: string,\n slot: string | null = target === 'defaultProps' ? null : 'root',\n): ThemeComponentOverrideTarget {\n return { component, target, slot, property, media: null }\n}\n\n/**\n * Corner choices, as multiples of the site's Border radius (an `sx`\n * `borderRadius` number is one), so a component follows the Shape & spacing\n * slider instead of freezing a pixel value.\n */\nconst CORNER_OPTIONS: readonly ThemeComponentLookOption[] = [\n { value: 'square', label: 'Square', stored: 0 },\n { value: 'subtle', label: 'Half the site radius', stored: 0.5 },\n { value: 'site', label: 'The site radius', stored: 1 },\n { value: 'rounded', label: 'Twice the site radius', stored: 2 },\n { value: 'extra', label: 'Three times the site radius', stored: 3 },\n]\nconst PILL_OPTION: ThemeComponentLookOption = { value: 'pill', label: 'Pill', stored: '999px' }\n\n/**\n * Every component look field, in the order the card shows them.\n *\n * Inputs style both of MUI's boxes: `MuiOutlinedInput` and `MuiFilledInput`,\n * because the Input style choice picks between them and the other choices\n * have to hold whichever is in use. A border color sets the outlined box's\n * own border, which the Besigner's Input element draws, and the notched\n * outline a stock text field draws.\n */\nexport const THEME_COMPONENT_LOOK_FIELDS: readonly ThemeComponentLookField[] = [\n {\n id: 'button.variant',\n group: 'button',\n label: 'Button style',\n kind: 'select',\n targets: [lookTarget('MuiButton', 'defaultProps', 'variant')],\n options: [\n { value: 'contained', label: 'Filled', stored: 'contained' },\n { value: 'outlined', label: 'Outlined', stored: 'outlined' },\n { value: 'text', label: 'Text only', stored: 'text' },\n ],\n },\n {\n id: 'button.corners',\n group: 'button',\n label: 'Button corners',\n kind: 'select',\n targets: [lookTarget('MuiButton', 'sx', 'borderRadius')],\n options: [...CORNER_OPTIONS, PILL_OPTION],\n },\n {\n id: 'button.textCase',\n group: 'button',\n label: 'Button text case',\n kind: 'select',\n targets: [lookTarget('MuiButton', 'styleOverrides', 'textTransform')],\n options: [\n { value: 'none', label: 'As typed', stored: 'none' },\n { value: 'uppercase', label: 'UPPERCASE', stored: 'uppercase' },\n { value: 'capitalize', label: 'Capitalize Each Word', stored: 'capitalize' },\n ],\n },\n {\n id: 'button.weight',\n group: 'button',\n label: 'Button text weight',\n kind: 'select',\n targets: [lookTarget('MuiButton', 'styleOverrides', 'fontWeight')],\n options: [\n { value: '400', label: 'Regular', stored: 400 },\n { value: '500', label: 'Medium', stored: 500 },\n { value: '600', label: 'Semibold', stored: 600 },\n { value: '700', label: 'Bold', stored: 700 },\n ],\n },\n {\n id: 'button.padding',\n group: 'button',\n label: 'Button padding',\n kind: 'select',\n // Spacing units, so padding follows the site's Spacing unit.\n targets: [lookTarget('MuiButton', 'sx', 'px'), lookTarget('MuiButton', 'sx', 'py')],\n options: [\n { value: 'compact', label: 'Compact', stored: [1.5, 0.5] },\n { value: 'comfortable', label: 'Comfortable', stored: [2, 0.75] },\n { value: 'roomy', label: 'Roomy', stored: [3, 1] },\n { value: 'wide', label: 'Wide', stored: [4, 1.25] },\n ],\n },\n {\n id: 'input.variant',\n group: 'input',\n label: 'Input style',\n kind: 'select',\n targets: [lookTarget('MuiTextField', 'defaultProps', 'variant')],\n options: [\n { value: 'outlined', label: 'Outlined', stored: 'outlined' },\n { value: 'filled', label: 'Filled', stored: 'filled' },\n ],\n },\n {\n id: 'input.corners',\n group: 'input',\n label: 'Input corners',\n kind: 'select',\n targets: [\n lookTarget('MuiOutlinedInput', 'sx', 'borderRadius'),\n lookTarget('MuiFilledInput', 'sx', 'borderRadius'),\n ],\n // A filled box's underline runs edge to edge; clipping it to the corners\n // keeps it inside a rounded box.\n companions: [{ ...lookTarget('MuiFilledInput', 'styleOverrides', 'overflow'), value: 'hidden' }],\n options: [...CORNER_OPTIONS, PILL_OPTION],\n },\n {\n id: 'input.background',\n group: 'input',\n label: 'Input background',\n kind: 'color',\n targets: [\n lookTarget('MuiOutlinedInput', 'sx', 'bgcolor'),\n lookTarget('MuiFilledInput', 'sx', 'bgcolor'),\n ],\n options: [\n { value: 'transparent', label: 'None', stored: 'transparent' },\n { value: 'paper', label: 'Paper', stored: 'background.paper', token: 'background.paper' },\n {\n value: 'background',\n label: 'Background',\n stored: 'background.default',\n token: 'background.default',\n },\n { value: 'tintPrimary', label: 'Primary tint', stored: 'tint.primary', token: 'tint.primary' },\n {\n value: 'tintSecondary',\n label: 'Secondary tint',\n stored: 'tint.secondary',\n token: 'tint.secondary',\n },\n {\n value: 'tintTertiary',\n label: 'Tertiary tint',\n stored: 'tint.tertiary',\n token: 'tint.tertiary',\n },\n ],\n },\n {\n id: 'input.border',\n group: 'input',\n label: 'Input border color',\n kind: 'color',\n targets: [\n lookTarget('MuiOutlinedInput', 'sx', 'borderColor'),\n lookTarget('MuiOutlinedInput', 'sx', 'borderColor', 'notchedOutline'),\n ],\n options: [\n { value: 'divider', label: 'Divider', stored: 'divider', token: 'divider' },\n {\n value: 'textSecondary',\n label: 'Secondary text',\n stored: 'text.secondary',\n token: 'text.secondary',\n },\n { value: 'text', label: 'Text', stored: 'text.primary', token: 'text.primary' },\n { value: 'primary', label: 'Primary', stored: 'primary.main', token: 'primary' },\n { value: 'secondary', label: 'Secondary', stored: 'secondary.main', token: 'secondary' },\n { value: 'tertiary', label: 'Tertiary', stored: 'tertiary.main', token: 'tertiary' },\n ],\n },\n {\n id: 'card.variant',\n group: 'card',\n label: 'Card style',\n kind: 'select',\n targets: [lookTarget('MuiCard', 'defaultProps', 'variant')],\n options: [\n { value: 'elevation', label: 'Shadow', stored: 'elevation' },\n { value: 'outlined', label: 'Outline', stored: 'outlined' },\n ],\n },\n {\n id: 'card.elevation',\n group: 'card',\n label: 'Card shadow depth',\n kind: 'select',\n targets: [lookTarget('MuiCard', 'defaultProps', 'elevation')],\n options: [\n { value: '0', label: 'Flat', stored: 0 },\n { value: '1', label: 'Soft', stored: 1 },\n { value: '3', label: 'Medium', stored: 3 },\n { value: '8', label: 'Strong', stored: 8 },\n ],\n },\n {\n id: 'card.corners',\n group: 'card',\n label: 'Card corners',\n kind: 'select',\n targets: [lookTarget('MuiCard', 'sx', 'borderRadius')],\n options: CORNER_OPTIONS,\n },\n]\n\n/** The catalog entry for a look field id. */\nexport function themeComponentLookField(id: ThemeComponentLookId): ThemeComponentLookField {\n const field = THEME_COMPONENT_LOOK_FIELDS.find((entry) => entry.id === id)\n if (!field) throw new Error(`unknown component look field ${id}`)\n return field\n}\n\nfunction storedFor(option: ThemeComponentLookOption, index: number) {\n return Array.isArray(option.stored)\n ? (option.stored as ReadonlyArray<string | number>)[index]\n : (option.stored as string | number)\n}\n\n/**\n * A look field as its select shows it: the choice the site's overrides hold,\n * {@link THEME_LOOK_DEFAULT} when they set nothing, or\n * {@link THEME_LOOK_CUSTOM} when they set a value no choice names.\n */\nexport function readComponentLook(\n theme: HostTheme | undefined,\n field: ThemeComponentLookField,\n): string {\n const values = field.targets.map((target) => readComponentOverride(theme, target))\n if (values.every((value) => value === undefined)) return THEME_LOOK_DEFAULT\n const match = field.options.find((option) =>\n values.every((value, index) => value === storedFor(option, index)),\n )\n return match ? match.value : THEME_LOOK_CUSTOM\n}\n\n/**\n * Sets a look field to one of its choices, or back to the theme's own look\n * with {@link THEME_LOOK_DEFAULT}, which clears every leaf it sets. Any other\n * value changes nothing.\n */\nexport function writeComponentLook(\n theme: HostTheme,\n field: ThemeComponentLookField,\n value: string,\n): HostTheme {\n if (value === THEME_LOOK_DEFAULT) {\n let next = theme\n for (const target of [...field.targets, ...(field.companions ?? [])]) {\n next = clearComponentOverride(next, target)\n }\n return next\n }\n const option = field.options.find((entry) => entry.value === value)\n if (!option) return theme\n let next = theme\n field.targets.forEach((target, index) => {\n next = writeComponentOverride(next, { ...target, value: storedFor(option, index) })\n })\n for (const companion of field.companions ?? []) next = writeComponentOverride(next, companion)\n return next\n}\n"],"names":["readThemeFonts","writeThemeFonts","HOST_THEME_COMPONENT_WHITELIST","firstStackFamily","fontFamilyStack","THEME_HEADING_VARIANTS","TOOLBAR_SM_MIN_WIDTH","TOOLBAR_SM_QUERY","DEFAULT_TOOLBAR_XS","DEFAULT_TOOLBAR_SM","TOOLBAR_LANDSCAPE_QUERY","TOOLBAR_LANDSCAPE_RULE","minHeight","readToolbarHeight","theme","breakpoint","toolbar","mixins","undefined","raw","value","parseFloat","String","Number","isFinite","buildToolbarMixin","xs","sm","orderSensitiveKey","JSON","stringify","PALETTE_COLOR_FIELDS","key","label","SURFACE_COLOR_FIELDS","path","TINT_COLOR_FIELDS","DIVIDER_COLOR_FIELD","GOOGLE_FONT_OPTIONS","family","category","weights","getSchemeColor","colors","group","THEME_EDITOR_SCHEMES","THEME_COLOR_FIELDS","map","token","join","DARK_SCHEME_FIELD","options","SYSTEM_FONT_VALUE","FONT_FAMILY_FIELD","BORDER_RADIUS_FIELD","min","max","step","SPACING_FIELD","TOOLBAR_HEIGHT_FIELDS","COMPONENT_OVERRIDES_FIELD","components","THEME_EDITOR_MEDIA_QUERIES","mobile","desktop","THEME_EDITOR_CONTROLS","id","kind","perScheme","option","themeEditorControl","control","find","entry","Error","setSchemeValue","scheme","update","colorSchemes","readThemeColor","divider","split","main","writeThemeColor","hex","next","paletteKey","tint","rest","Object","keys","length","groupKey","groupValue","grouped","copyThemeSchemeColors","from","to","source","parse","readDarkScheme","darkScheme","writeDarkScheme","readFontFamily","body","writeFontFamily","current","heading","writeBorderRadius","shape","borderRadius","writeSpacing","spacing","writeToolbarHeight","valid","edited","resetComponentOverrides","writeComponentOverride","leaf","component","target","defaultProps","property","slot","styles","sx","styleOverrides","slotStyles","media","query","clearComponentOverride","existing","props","branch","scoped","readComponentOverride","THEME_COMPONENT_LOOK_GROUPS","THEME_LOOK_DEFAULT","THEME_LOOK_CUSTOM","lookTarget","CORNER_OPTIONS","stored","PILL_OPTION","THEME_COMPONENT_LOOK_FIELDS","targets","companions","themeComponentLookField","field","storedFor","index","Array","isArray","readComponentLook","values","every","match","writeComponentLook","forEach","companion"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAQD,SAASA,cAAc,EAAEC,eAAe,QAAQ,uCAAsC;AACtF,SACEC,8BAA8B,QAEzB,kBAAc;AAErB,yEAAyE;AACzE,2EAA2E;AAC3E,wBAAwB;AACxB,SACEC,gBAAgB,EAChBC,eAAe,EACfJ,cAAc,EACdK,sBAAsB,EACtBJ,eAAe,QAGV,uCAAsC;AAE7C;;;;;;;;;;;;;;;;;;;;CAoBC,GAED;;;;CAIC,GACD,OAAO,MAAMK,uBAAuB,IAAG;AACvC,OAAO,MAAMC,mBAAmB,CAAC,kBAAkB,EAAED,qBAAqB,GAAG,CAAC,CAAA;AAC9E,mEAAmE,GACnE,OAAO,MAAME,qBAAqB,GAAE;AACpC,OAAO,MAAMC,qBAAqB,GAAE;AACpC;;;;CAIC,GACD,OAAO,MAAMC,0BAA0B,yBAAwB;AAC/D,OAAO,MAAMC,yBAAyB;IACpC,mCAAmC;QAAEC,WAAW;IAAG;AACrD,EAAC;AAED,uEAAuE,GACvE,OAAO,SAASC,kBAAkBC,KAAgB,EAAEC,UAAuB;QACzDD,eAKTE;IALP,MAAMA,WAAUF,gBAAAA,MAAMG,MAAM,qBAAZH,cAAcE,OAAO;IACrC,IAAI,CAACA,SAAS,OAAOE;IACrB,MAA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