@tenphi/glaze 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -16,6 +16,16 @@ type MinContrast$1 = number | ContrastPreset;
16
16
  * | `'min'` | 15 | Dividers/decorative; APCA "point of invisibility" |
17
17
  */
18
18
  type ApcaPreset = 'preferred' | 'body' | 'content' | 'large' | 'non-text' | 'min';
19
+ declare const APCA_PRESETS: Record<ApcaPreset, number>;
20
+ /**
21
+ * APCA-W3 "Enhanced Level" delta added to a bare APCA target in high-contrast
22
+ * mode when no explicit HC value is provided (analogous to WCAG AAA over AA).
23
+ * Only applied when neither the outer `contrast` pair nor the inner `apca`
24
+ * pair carries an explicit HC entry.
25
+ */
26
+ declare const APCA_HC_ENHANCEMENT = 15;
27
+ /** Upper bound for an APCA Lc target after HC enhancement. */
28
+ declare const APCA_MAX_LC = 106;
19
29
  /**
20
30
  * Resolve an APCA target — a raw Lc number (kept as-is) or an `ApcaPreset`
21
31
  * keyword mapped to its Lc value. The magnitude is forced non-negative.
@@ -40,8 +50,18 @@ declare function resolveMinContrast(value: MinContrast$1): number;
40
50
  * given mode into `{ metric, target }`. Handles the inner metric HC pair and
41
51
  * preset resolution. `polarity` is passed through to the result for the APCA
42
52
  * branch (it controls argument order in the solver); WCAG ignores it.
53
+ *
54
+ * `outerExplicitHC` indicates whether the caller selected this `spec` from an
55
+ * explicit high-contrast entry of the outer `contrast` pair. Together with the
56
+ * inner metric pair, it decides whether the HC auto-enhancement fires:
57
+ * - APCA: +15 Lc "Enhanced Level" boost when neither level is explicit.
58
+ * - WCAG: AA → AAA / AA-large → AAA-large promotion (SC 1.4.3 → 1.4.6) when
59
+ * neither level is explicit. AAA-family presets and bare numbers are left
60
+ * unchanged (AAA is the top WCAG tier).
61
+ * Defaults to `false` (correct for direct callers, which pass a single
62
+ * selected spec rather than an outer pair).
43
63
  */
44
- declare function resolveContrastForMode(spec: ContrastSpec, isHighContrast: boolean, polarity?: 'fg' | 'bg'): ResolvedContrast;
64
+ declare function resolveContrastForMode(spec: ContrastSpec, isHighContrast: boolean, polarity?: 'fg' | 'bg', outerExplicitHC?: boolean): ResolvedContrast;
45
65
  /**
46
66
  * APCA lightness contrast (Lc), signed: positive for dark text on light bg,
47
67
  * negative for light text on dark bg. Inputs are screen luminances (0–1).
@@ -445,7 +465,11 @@ interface GlazeConfig {
445
465
  darkTone?: ToneWindow;
446
466
  /** Saturation reduction factor for dark scheme (0–1). Default: 0.1. */
447
467
  darkDesaturation?: number;
448
- /** State alias names for token export. */
468
+ /**
469
+ * State alias names for Tasty token export. Default to media-query states
470
+ * (`'@media(prefers-color-scheme: dark)'` / `'@media(prefers-contrast: more)'`)
471
+ * so tokens react to the OS preference without registering custom states.
472
+ */
449
473
  states?: {
450
474
  dark?: string;
451
475
  highContrast?: string;
@@ -760,7 +784,7 @@ interface GlazeColorToken {
760
784
  token(options?: GlazeTokenOptions): Record<string, string>;
761
785
  /**
762
786
  * Export as a tasty style-to-state binding (no color name key).
763
- * Uses `#name` keys and state aliases (`''`, `@dark`, etc.).
787
+ * Uses `#name` keys and state aliases (`''`, `'@media(prefers-color-scheme: dark)'`, etc.).
764
788
  * @see https://tasty.style/docs
765
789
  */
766
790
  tasty(options?: GlazeTokenOptions): Record<string, string>;
@@ -896,7 +920,7 @@ interface GlazeTheme {
896
920
  tokens(options?: GlazeJsonOptions): Record<string, Record<string, string>>;
897
921
  /**
898
922
  * Export as tasty style-to-state bindings.
899
- * Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
923
+ * Uses `#name` color token keys and state aliases (`''`, `'@media(prefers-color-scheme: dark)'`, etc.).
900
924
  * Spread into component styles or register as a recipe via `configure({ recipes })`.
901
925
  * @see https://tasty.style/docs
902
926
  */
@@ -1214,7 +1238,7 @@ interface GlazePalette {
1214
1238
  tokens(options?: GlazeJsonOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
1215
1239
  /**
1216
1240
  * Export all themes as tasty style-to-state bindings.
1217
- * Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
1241
+ * Uses `#name` color token keys and state aliases (`''`, `'@media(prefers-color-scheme: dark)'`, etc.).
1218
1242
  * Prefix defaults to `true`. Inherits the palette-level `primary`.
1219
1243
  * @see https://tasty.style/docs
1220
1244
  */
@@ -1543,5 +1567,5 @@ declare function srgbToHex(rgb: [number, number, number]): `#${string}`;
1543
1567
  */
1544
1568
  declare function okhslToOklch(h: number, s: number, l: number, pastel?: boolean): [number, number, number];
1545
1569
  //#endregion
1546
- export { type AdaptationMode, type ApcaPreset, type ChannelCtx, type ColorDef, type ColorMap, type ContrastPreset, type ContrastSpec, type DtcgColorSpace, type DtcgColorToken, type DtcgColorValue, type DtcgDocument, type DtcgOklchColorValue, type DtcgResolverModifier, type DtcgResolverRef, type DtcgResolverSet, type DtcgSrgbColorValue, type DtcgTokenTree, type ExtremeValue, type FindToneForContrastOptions, type FindToneForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorCssOptions, type GlazeColorDtcgResolverOptions, type GlazeColorDtcgResult, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type GlazeColorTailwindOptions, type GlazeColorToken, type GlazeColorTokenExport, type GlazeColorValue, type GlazeConfig, type GlazeConfigOverride, type GlazeConfigResolved, type GlazeCssOptions, type GlazeCssResult, type GlazeDtcgOptions, type GlazeDtcgResolverContextNames, type GlazeDtcgResolverDocument, type GlazeDtcgResolverOptions, type GlazeDtcgResult, type GlazeExtendOptions, type GlazeFromInput, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTailwindOptions, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type HueDeclaration, type HuePlan, type MinContrast, type MixColorDef, type OkhslColor, type OkhstColor, type OklchColor, type Polarity, REF_EPS, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ResolvedContrast, type RgbColor, type Role, type RoleInput, type ShadowColorDef, type ShadowTuning, type ToneValue, type ToneWindow, apcaContrast, assertAllPastel, assertNativeFormat, contrastRatioFromLuminance, cuspLightness, findToneForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOkhst, formatOklch, formatRgb, fromTone, gamutClampedLuminance, glaze, hslToSrgb, inferRoleFromName, normalizeRole, okhslToLinearSrgb, okhslToOkhst, okhslToOklab, okhslToOklch, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, oppositeRole, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveApcaTarget, resolveContrastForMode, resolveMinContrast, roleToPolarity, srgbToHex, srgbToOkhsl, toTone, toneFromY, variantToOkhsl, yFromTone };
1570
+ export { APCA_HC_ENHANCEMENT, APCA_MAX_LC, APCA_PRESETS, type AdaptationMode, type ApcaPreset, type ChannelCtx, type ColorDef, type ColorMap, type ContrastPreset, type ContrastSpec, type DtcgColorSpace, type DtcgColorToken, type DtcgColorValue, type DtcgDocument, type DtcgOklchColorValue, type DtcgResolverModifier, type DtcgResolverRef, type DtcgResolverSet, type DtcgSrgbColorValue, type DtcgTokenTree, type ExtremeValue, type FindToneForContrastOptions, type FindToneForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorCssOptions, type GlazeColorDtcgResolverOptions, type GlazeColorDtcgResult, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type GlazeColorTailwindOptions, type GlazeColorToken, type GlazeColorTokenExport, type GlazeColorValue, type GlazeConfig, type GlazeConfigOverride, type GlazeConfigResolved, type GlazeCssOptions, type GlazeCssResult, type GlazeDtcgOptions, type GlazeDtcgResolverContextNames, type GlazeDtcgResolverDocument, type GlazeDtcgResolverOptions, type GlazeDtcgResult, type GlazeExtendOptions, type GlazeFromInput, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTailwindOptions, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type HueDeclaration, type HuePlan, type MinContrast, type MixColorDef, type OkhslColor, type OkhstColor, type OklchColor, type Polarity, REF_EPS, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ResolvedContrast, type RgbColor, type Role, type RoleInput, type ShadowColorDef, type ShadowTuning, type ToneValue, type ToneWindow, apcaContrast, assertAllPastel, assertNativeFormat, contrastRatioFromLuminance, cuspLightness, findToneForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOkhst, formatOklch, formatRgb, fromTone, gamutClampedLuminance, glaze, hslToSrgb, inferRoleFromName, normalizeRole, okhslToLinearSrgb, okhslToOkhst, okhslToOklab, okhslToOklch, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, oppositeRole, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveApcaTarget, resolveContrastForMode, resolveMinContrast, roleToPolarity, srgbToHex, srgbToOkhsl, toTone, toneFromY, variantToOkhsl, yFromTone };
1547
1571
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -16,6 +16,16 @@ type MinContrast$1 = number | ContrastPreset;
16
16
  * | `'min'` | 15 | Dividers/decorative; APCA "point of invisibility" |
17
17
  */
18
18
  type ApcaPreset = 'preferred' | 'body' | 'content' | 'large' | 'non-text' | 'min';
19
+ declare const APCA_PRESETS: Record<ApcaPreset, number>;
20
+ /**
21
+ * APCA-W3 "Enhanced Level" delta added to a bare APCA target in high-contrast
22
+ * mode when no explicit HC value is provided (analogous to WCAG AAA over AA).
23
+ * Only applied when neither the outer `contrast` pair nor the inner `apca`
24
+ * pair carries an explicit HC entry.
25
+ */
26
+ declare const APCA_HC_ENHANCEMENT = 15;
27
+ /** Upper bound for an APCA Lc target after HC enhancement. */
28
+ declare const APCA_MAX_LC = 106;
19
29
  /**
20
30
  * Resolve an APCA target — a raw Lc number (kept as-is) or an `ApcaPreset`
21
31
  * keyword mapped to its Lc value. The magnitude is forced non-negative.
@@ -40,8 +50,18 @@ declare function resolveMinContrast(value: MinContrast$1): number;
40
50
  * given mode into `{ metric, target }`. Handles the inner metric HC pair and
41
51
  * preset resolution. `polarity` is passed through to the result for the APCA
42
52
  * branch (it controls argument order in the solver); WCAG ignores it.
53
+ *
54
+ * `outerExplicitHC` indicates whether the caller selected this `spec` from an
55
+ * explicit high-contrast entry of the outer `contrast` pair. Together with the
56
+ * inner metric pair, it decides whether the HC auto-enhancement fires:
57
+ * - APCA: +15 Lc "Enhanced Level" boost when neither level is explicit.
58
+ * - WCAG: AA → AAA / AA-large → AAA-large promotion (SC 1.4.3 → 1.4.6) when
59
+ * neither level is explicit. AAA-family presets and bare numbers are left
60
+ * unchanged (AAA is the top WCAG tier).
61
+ * Defaults to `false` (correct for direct callers, which pass a single
62
+ * selected spec rather than an outer pair).
43
63
  */
44
- declare function resolveContrastForMode(spec: ContrastSpec, isHighContrast: boolean, polarity?: 'fg' | 'bg'): ResolvedContrast;
64
+ declare function resolveContrastForMode(spec: ContrastSpec, isHighContrast: boolean, polarity?: 'fg' | 'bg', outerExplicitHC?: boolean): ResolvedContrast;
45
65
  /**
46
66
  * APCA lightness contrast (Lc), signed: positive for dark text on light bg,
47
67
  * negative for light text on dark bg. Inputs are screen luminances (0–1).
@@ -445,7 +465,11 @@ interface GlazeConfig {
445
465
  darkTone?: ToneWindow;
446
466
  /** Saturation reduction factor for dark scheme (0–1). Default: 0.1. */
447
467
  darkDesaturation?: number;
448
- /** State alias names for token export. */
468
+ /**
469
+ * State alias names for Tasty token export. Default to media-query states
470
+ * (`'@media(prefers-color-scheme: dark)'` / `'@media(prefers-contrast: more)'`)
471
+ * so tokens react to the OS preference without registering custom states.
472
+ */
449
473
  states?: {
450
474
  dark?: string;
451
475
  highContrast?: string;
@@ -760,7 +784,7 @@ interface GlazeColorToken {
760
784
  token(options?: GlazeTokenOptions): Record<string, string>;
761
785
  /**
762
786
  * Export as a tasty style-to-state binding (no color name key).
763
- * Uses `#name` keys and state aliases (`''`, `@dark`, etc.).
787
+ * Uses `#name` keys and state aliases (`''`, `'@media(prefers-color-scheme: dark)'`, etc.).
764
788
  * @see https://tasty.style/docs
765
789
  */
766
790
  tasty(options?: GlazeTokenOptions): Record<string, string>;
@@ -896,7 +920,7 @@ interface GlazeTheme {
896
920
  tokens(options?: GlazeJsonOptions): Record<string, Record<string, string>>;
897
921
  /**
898
922
  * Export as tasty style-to-state bindings.
899
- * Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
923
+ * Uses `#name` color token keys and state aliases (`''`, `'@media(prefers-color-scheme: dark)'`, etc.).
900
924
  * Spread into component styles or register as a recipe via `configure({ recipes })`.
901
925
  * @see https://tasty.style/docs
902
926
  */
@@ -1214,7 +1238,7 @@ interface GlazePalette {
1214
1238
  tokens(options?: GlazeJsonOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
1215
1239
  /**
1216
1240
  * Export all themes as tasty style-to-state bindings.
1217
- * Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
1241
+ * Uses `#name` color token keys and state aliases (`''`, `'@media(prefers-color-scheme: dark)'`, etc.).
1218
1242
  * Prefix defaults to `true`. Inherits the palette-level `primary`.
1219
1243
  * @see https://tasty.style/docs
1220
1244
  */
@@ -1543,5 +1567,5 @@ declare function srgbToHex(rgb: [number, number, number]): `#${string}`;
1543
1567
  */
1544
1568
  declare function okhslToOklch(h: number, s: number, l: number, pastel?: boolean): [number, number, number];
1545
1569
  //#endregion
1546
- export { type AdaptationMode, type ApcaPreset, type ChannelCtx, type ColorDef, type ColorMap, type ContrastPreset, type ContrastSpec, type DtcgColorSpace, type DtcgColorToken, type DtcgColorValue, type DtcgDocument, type DtcgOklchColorValue, type DtcgResolverModifier, type DtcgResolverRef, type DtcgResolverSet, type DtcgSrgbColorValue, type DtcgTokenTree, type ExtremeValue, type FindToneForContrastOptions, type FindToneForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorCssOptions, type GlazeColorDtcgResolverOptions, type GlazeColorDtcgResult, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type GlazeColorTailwindOptions, type GlazeColorToken, type GlazeColorTokenExport, type GlazeColorValue, type GlazeConfig, type GlazeConfigOverride, type GlazeConfigResolved, type GlazeCssOptions, type GlazeCssResult, type GlazeDtcgOptions, type GlazeDtcgResolverContextNames, type GlazeDtcgResolverDocument, type GlazeDtcgResolverOptions, type GlazeDtcgResult, type GlazeExtendOptions, type GlazeFromInput, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTailwindOptions, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type HueDeclaration, type HuePlan, type MinContrast, type MixColorDef, type OkhslColor, type OkhstColor, type OklchColor, type Polarity, REF_EPS, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ResolvedContrast, type RgbColor, type Role, type RoleInput, type ShadowColorDef, type ShadowTuning, type ToneValue, type ToneWindow, apcaContrast, assertAllPastel, assertNativeFormat, contrastRatioFromLuminance, cuspLightness, findToneForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOkhst, formatOklch, formatRgb, fromTone, gamutClampedLuminance, glaze, hslToSrgb, inferRoleFromName, normalizeRole, okhslToLinearSrgb, okhslToOkhst, okhslToOklab, okhslToOklch, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, oppositeRole, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveApcaTarget, resolveContrastForMode, resolveMinContrast, roleToPolarity, srgbToHex, srgbToOkhsl, toTone, toneFromY, variantToOkhsl, yFromTone };
1570
+ export { APCA_HC_ENHANCEMENT, APCA_MAX_LC, APCA_PRESETS, type AdaptationMode, type ApcaPreset, type ChannelCtx, type ColorDef, type ColorMap, type ContrastPreset, type ContrastSpec, type DtcgColorSpace, type DtcgColorToken, type DtcgColorValue, type DtcgDocument, type DtcgOklchColorValue, type DtcgResolverModifier, type DtcgResolverRef, type DtcgResolverSet, type DtcgSrgbColorValue, type DtcgTokenTree, type ExtremeValue, type FindToneForContrastOptions, type FindToneForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorCssOptions, type GlazeColorDtcgResolverOptions, type GlazeColorDtcgResult, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type GlazeColorTailwindOptions, type GlazeColorToken, type GlazeColorTokenExport, type GlazeColorValue, type GlazeConfig, type GlazeConfigOverride, type GlazeConfigResolved, type GlazeCssOptions, type GlazeCssResult, type GlazeDtcgOptions, type GlazeDtcgResolverContextNames, type GlazeDtcgResolverDocument, type GlazeDtcgResolverOptions, type GlazeDtcgResult, type GlazeExtendOptions, type GlazeFromInput, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTailwindOptions, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type HueDeclaration, type HuePlan, type MinContrast, type MixColorDef, type OkhslColor, type OkhstColor, type OklchColor, type Polarity, REF_EPS, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ResolvedContrast, type RgbColor, type Role, type RoleInput, type ShadowColorDef, type ShadowTuning, type ToneValue, type ToneWindow, apcaContrast, assertAllPastel, assertNativeFormat, contrastRatioFromLuminance, cuspLightness, findToneForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOkhst, formatOklch, formatRgb, fromTone, gamutClampedLuminance, glaze, hslToSrgb, inferRoleFromName, normalizeRole, okhslToLinearSrgb, okhslToOkhst, okhslToOklab, okhslToOklch, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, oppositeRole, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveApcaTarget, resolveContrastForMode, resolveMinContrast, roleToPolarity, srgbToHex, srgbToOkhsl, toTone, toneFromY, variantToOkhsl, yFromTone };
1547
1571
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -688,8 +688,8 @@ function defaultConfig() {
688
688
  },
689
689
  darkDesaturation: .1,
690
690
  states: {
691
- dark: "@dark",
692
- highContrast: "@high-contrast"
691
+ dark: "@media(prefers-color-scheme: dark)",
692
+ highContrast: "@media(prefers-contrast: more)"
693
693
  },
694
694
  modes: {
695
695
  dark: true,
@@ -1085,6 +1085,15 @@ const APCA_PRESETS = {
1085
1085
  min: 15
1086
1086
  };
1087
1087
  /**
1088
+ * APCA-W3 "Enhanced Level" delta added to a bare APCA target in high-contrast
1089
+ * mode when no explicit HC value is provided (analogous to WCAG AAA over AA).
1090
+ * Only applied when neither the outer `contrast` pair nor the inner `apca`
1091
+ * pair carries an explicit HC entry.
1092
+ */
1093
+ const APCA_HC_ENHANCEMENT = 15;
1094
+ /** Upper bound for an APCA Lc target after HC enhancement. */
1095
+ const APCA_MAX_LC = 106;
1096
+ /**
1088
1097
  * Resolve an APCA target — a raw Lc number (kept as-is) or an `ApcaPreset`
1089
1098
  * keyword mapped to its Lc value. The magnitude is forced non-negative.
1090
1099
  */
@@ -1098,10 +1107,35 @@ const CONTRAST_PRESETS = {
1098
1107
  "AA-large": 3,
1099
1108
  "AAA-large": 4.5
1100
1109
  };
1110
+ /**
1111
+ * WCAG high-contrast auto-promotion (analog of APCA's Enhanced Level). A bare
1112
+ * AA / AA-large preset is promoted to its spec-defined "Enhanced" successor
1113
+ * (SC 1.4.3 → SC 1.4.6) in high-contrast mode. AAA / AAA-large are already
1114
+ * the top WCAG tier and are left unchanged. Bare numeric targets have no
1115
+ * defined successor tier and are also left unchanged. An explicit HC value
1116
+ * (outer or inner pair) always overrides.
1117
+ */
1118
+ const WCAG_HC_PROMOTION = {
1119
+ AA: "AAA",
1120
+ "AA-large": "AAA-large"
1121
+ };
1101
1122
  function resolveMinContrast(value) {
1102
1123
  if (typeof value === "number") return Math.max(1, value);
1103
1124
  return CONTRAST_PRESETS[value];
1104
1125
  }
1126
+ /**
1127
+ * Resolve a WCAG target (number or preset) for a mode, applying the
1128
+ * high-contrast auto-promotion when `explicitHC` is false and the value is an
1129
+ * AA-family preset. Bare numbers and AAA-family presets pass through.
1130
+ */
1131
+ function resolveWcagTarget(value, isHighContrast, explicitHC) {
1132
+ if (typeof value === "number") return resolveMinContrast(value);
1133
+ if (isHighContrast && !explicitHC) {
1134
+ const promoted = WCAG_HC_PROMOTION[value];
1135
+ if (promoted !== void 0) return resolveMinContrast(promoted);
1136
+ }
1137
+ return resolveMinContrast(value);
1138
+ }
1105
1139
  function pickPair(p, isHighContrast) {
1106
1140
  return Array.isArray(p) ? isHighContrast ? p[1] : p[0] : p;
1107
1141
  }
@@ -1110,20 +1144,35 @@ function pickPair(p, isHighContrast) {
1110
1144
  * given mode into `{ metric, target }`. Handles the inner metric HC pair and
1111
1145
  * preset resolution. `polarity` is passed through to the result for the APCA
1112
1146
  * branch (it controls argument order in the solver); WCAG ignores it.
1113
- */
1114
- function resolveContrastForMode(spec, isHighContrast, polarity) {
1147
+ *
1148
+ * `outerExplicitHC` indicates whether the caller selected this `spec` from an
1149
+ * explicit high-contrast entry of the outer `contrast` pair. Together with the
1150
+ * inner metric pair, it decides whether the HC auto-enhancement fires:
1151
+ * - APCA: +15 Lc "Enhanced Level" boost when neither level is explicit.
1152
+ * - WCAG: AA → AAA / AA-large → AAA-large promotion (SC 1.4.3 → 1.4.6) when
1153
+ * neither level is explicit. AAA-family presets and bare numbers are left
1154
+ * unchanged (AAA is the top WCAG tier).
1155
+ * Defaults to `false` (correct for direct callers, which pass a single
1156
+ * selected spec rather than an outer pair).
1157
+ */
1158
+ function resolveContrastForMode(spec, isHighContrast, polarity, outerExplicitHC) {
1115
1159
  if (typeof spec === "number" || typeof spec === "string") return {
1116
1160
  metric: "wcag",
1117
- target: resolveMinContrast(spec)
1118
- };
1119
- if ("apca" in spec) return {
1120
- metric: "apca",
1121
- target: resolveApcaTarget(pickPair(spec.apca, isHighContrast)),
1122
- polarity: polarity ?? "fg"
1161
+ target: resolveWcagTarget(spec, isHighContrast, !!outerExplicitHC)
1123
1162
  };
1163
+ if ("apca" in spec) {
1164
+ const baseTarget = resolveApcaTarget(pickPair(spec.apca, isHighContrast));
1165
+ const innerExplicitHC = Array.isArray(spec.apca);
1166
+ return {
1167
+ metric: "apca",
1168
+ target: isHighContrast && !outerExplicitHC && !innerExplicitHC ? Math.min(baseTarget + APCA_HC_ENHANCEMENT, APCA_MAX_LC) : baseTarget,
1169
+ polarity: polarity ?? "fg"
1170
+ };
1171
+ }
1172
+ const innerExplicitHC = Array.isArray(spec.wcag);
1124
1173
  return {
1125
1174
  metric: "wcag",
1126
- target: resolveMinContrast(pickPair(spec.wcag, isHighContrast))
1175
+ target: resolveWcagTarget(pickPair(spec.wcag, isHighContrast), isHighContrast, !!outerExplicitHC || innerExplicitHC)
1127
1176
  };
1128
1177
  }
1129
1178
  const APCA_EXPONENTS = {
@@ -1825,7 +1874,8 @@ function resolveRole(name, def, ctx) {
1825
1874
  return resolveRoleInMap(name, def, ctx.defs, ctx.config.inferRole, ctx.roles);
1826
1875
  }
1827
1876
  function resolveContrastSpec(spec, isHighContrast, polarity) {
1828
- return resolveContrastForMode(isHighContrast ? pairHC(spec) : pairNormal(spec), isHighContrast, polarity);
1877
+ const outerExplicitHC = Array.isArray(spec);
1878
+ return resolveContrastForMode(isHighContrast ? pairHC(spec) : pairNormal(spec), isHighContrast, polarity, outerExplicitHC);
1829
1879
  }
1830
1880
  /**
1831
1881
  * Apply the relative-tone delta against a base, honoring `flip`.
@@ -3717,5 +3767,5 @@ glaze.resetConfig = function resetConfig$1() {
3717
3767
  };
3718
3768
 
3719
3769
  //#endregion
3720
- export { REF_EPS, apcaContrast, assertAllPastel, assertNativeFormat, contrastRatioFromLuminance, cuspLightness, findToneForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOkhst, formatOklch, formatRgb, fromTone, gamutClampedLuminance, glaze, hslToSrgb, inferRoleFromName, normalizeRole, okhslToLinearSrgb, okhslToOkhst, okhslToOklab, okhslToOklch, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, oppositeRole, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveApcaTarget, resolveContrastForMode, resolveMinContrast, roleToPolarity, srgbToHex, srgbToOkhsl, toTone, toneFromY, variantToOkhsl, yFromTone };
3770
+ export { APCA_HC_ENHANCEMENT, APCA_MAX_LC, APCA_PRESETS, REF_EPS, apcaContrast, assertAllPastel, assertNativeFormat, contrastRatioFromLuminance, cuspLightness, findToneForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOkhst, formatOklch, formatRgb, fromTone, gamutClampedLuminance, glaze, hslToSrgb, inferRoleFromName, normalizeRole, okhslToLinearSrgb, okhslToOkhst, okhslToOklab, okhslToOklch, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, oppositeRole, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveApcaTarget, resolveContrastForMode, resolveMinContrast, roleToPolarity, srgbToHex, srgbToOkhsl, toTone, toneFromY, variantToOkhsl, yFromTone };
3721
3771
  //# sourceMappingURL=index.mjs.map