color-map 2.1.0 → 2.3.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/.claude-plugin/plugin.json +12 -0
- package/.codex-plugin/plugin.json +12 -0
- package/.cursor-plugin/plugin.json +12 -0
- package/CHANGELOG.md +94 -0
- package/README.md +71 -11
- package/bin/cli-CNBftDBE.js +6414 -0
- package/bin/color-map.js +9 -0
- package/bin/index.js +1 -0
- package/cjs/color/index.d.ts +5 -0
- package/cjs/color/index.js +52 -0
- package/cjs/color-wNrkrhC7.js +374 -0
- package/cjs/color-wNrkrhC7.js.map +1 -0
- package/cjs/contrast-XjF5Rwui.js +293 -0
- package/cjs/contrast-XjF5Rwui.js.map +1 -0
- package/cjs/gamut-CG1J2aat.d.ts +158 -0
- package/cjs/gamut-CG1J2aat.d.ts.map +1 -0
- package/cjs/index-BcEqCPHz.d.ts +137 -0
- package/cjs/index-BcEqCPHz.d.ts.map +1 -0
- package/cjs/index-CGKCqRqD.d.ts +111 -0
- package/cjs/index-CGKCqRqD.d.ts.map +1 -0
- package/cjs/index-Cv3iUUYE.d.ts +171 -0
- package/cjs/index-Cv3iUUYE.d.ts.map +1 -0
- package/cjs/index-Dw43Hj4v.d.ts +41 -0
- package/cjs/index-Dw43Hj4v.d.ts.map +1 -0
- package/cjs/index-Dy8UARqO.d.ts +72 -0
- package/cjs/index-Dy8UARqO.d.ts.map +1 -0
- package/cjs/index.d.ts +27 -5
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +89 -20
- package/cjs/index.js.map +1 -1
- package/cjs/legacy/index.d.ts +2 -0
- package/cjs/legacy/index.js +75 -0
- package/cjs/legacy/index.js.map +1 -0
- package/cjs/mix-Cs4owSbW.js +158 -0
- package/cjs/mix-Cs4owSbW.js.map +1 -0
- package/cjs/mix-DGlKoUw4.d.ts +31 -0
- package/cjs/mix-DGlKoUw4.d.ts.map +1 -0
- package/cjs/package.json +1 -1
- package/cjs/palette/index.d.ts +3 -0
- package/cjs/palette/index.js +8 -0
- package/cjs/palette-DyFV_KoJ.js +332 -0
- package/cjs/palette-DyFV_KoJ.js.map +1 -0
- package/cjs/parse-8mt2OMKf.js +1508 -0
- package/cjs/parse-8mt2OMKf.js.map +1 -0
- package/cjs/scale/index.d.ts +2 -0
- package/cjs/scale/index.js +11 -0
- package/cjs/scale-Cq9pXrc1.js +318 -0
- package/cjs/scale-Cq9pXrc1.js.map +1 -0
- package/cjs/semantic-CrEIo8tS.d.ts +52 -0
- package/cjs/semantic-CrEIo8tS.d.ts.map +1 -0
- package/cjs/serialize-C69DAmoE.d.ts +25 -0
- package/cjs/serialize-C69DAmoE.d.ts.map +1 -0
- package/cjs/serialize-Ci2X0cPN.js +103 -0
- package/cjs/serialize-Ci2X0cPN.js.map +1 -0
- package/cjs/tokens/index.d.ts +2 -0
- package/cjs/tokens/index.js +6 -0
- package/cjs/tokens-CzXxaMgM.js +168 -0
- package/cjs/tokens-CzXxaMgM.js.map +1 -0
- package/cjs/tone-BAhu-QzQ.js +118 -0
- package/cjs/tone-BAhu-QzQ.js.map +1 -0
- package/dist/color-map.es5.js +1 -1
- package/dist/color-map.es5.js.map +1 -1
- package/esm/color/a98-rgb.d.ts +7 -0
- package/esm/color/a98-rgb.d.ts.map +1 -0
- package/esm/color/a98-rgb.js +13 -0
- package/esm/color/a98-rgb.js.map +1 -0
- package/esm/color/argb.d.ts +6 -0
- package/esm/color/argb.d.ts.map +1 -0
- package/esm/color/argb.js +25 -0
- package/esm/color/argb.js.map +1 -0
- package/esm/color/calc.js +82 -0
- package/esm/color/calc.js.map +1 -0
- package/esm/color/compare.d.ts +20 -0
- package/esm/color/compare.d.ts.map +1 -0
- package/esm/color/compare.js +46 -0
- package/esm/color/compare.js.map +1 -0
- package/esm/color/contrast.d.ts +107 -0
- package/esm/color/contrast.d.ts.map +1 -0
- package/esm/color/contrast.js +242 -0
- package/esm/color/contrast.js.map +1 -0
- package/esm/color/convert.d.ts +9 -0
- package/esm/color/convert.d.ts.map +1 -0
- package/esm/color/convert.js +45 -0
- package/esm/color/convert.js.map +1 -0
- package/esm/color/display-p3-linear.d.ts +7 -0
- package/esm/color/display-p3-linear.d.ts.map +1 -0
- package/esm/color/display-p3-linear.js +12 -0
- package/esm/color/display-p3-linear.js.map +1 -0
- package/esm/color/display-p3.d.ts +7 -0
- package/esm/color/display-p3.d.ts.map +1 -0
- package/esm/color/display-p3.js +12 -0
- package/esm/color/display-p3.js.map +1 -0
- package/esm/color/expr.d.ts +43 -0
- package/esm/color/expr.d.ts.map +1 -0
- package/esm/color/expr.js +160 -0
- package/esm/color/expr.js.map +1 -0
- package/esm/color/gamut.d.ts +31 -0
- package/esm/color/gamut.d.ts.map +1 -0
- package/esm/color/gamut.js +210 -0
- package/esm/color/gamut.js.map +1 -0
- package/esm/color/hsl.d.ts +7 -0
- package/esm/color/hsl.d.ts.map +1 -0
- package/esm/color/hsl.js +67 -0
- package/esm/color/hsl.js.map +1 -0
- package/esm/color/hwb.d.ts +7 -0
- package/esm/color/hwb.d.ts.map +1 -0
- package/esm/color/hwb.js +40 -0
- package/esm/color/hwb.js.map +1 -0
- package/esm/color/index.d.ts +28 -0
- package/esm/color/index.js +27 -0
- package/esm/color/lab.d.ts +7 -0
- package/esm/color/lab.d.ts.map +1 -0
- package/esm/color/lab.js +33 -0
- package/esm/color/lab.js.map +1 -0
- package/esm/color/lch.d.ts +7 -0
- package/esm/color/lch.d.ts.map +1 -0
- package/esm/color/lch.js +11 -0
- package/esm/color/lch.js.map +1 -0
- package/esm/color/math.js +32 -0
- package/esm/color/math.js.map +1 -0
- package/esm/color/matrices.js +180 -0
- package/esm/color/matrices.js.map +1 -0
- package/esm/color/mix.d.ts +30 -0
- package/esm/color/mix.d.ts.map +1 -0
- package/esm/color/mix.js +152 -0
- package/esm/color/mix.js.map +1 -0
- package/esm/color/named.js +11 -0
- package/esm/color/named.js.map +1 -0
- package/esm/color/oklab.d.ts +7 -0
- package/esm/color/oklab.d.ts.map +1 -0
- package/esm/color/oklab.js +21 -0
- package/esm/color/oklab.js.map +1 -0
- package/esm/color/oklch.d.ts +7 -0
- package/esm/color/oklch.d.ts.map +1 -0
- package/esm/color/oklch.js +11 -0
- package/esm/color/oklch.js.map +1 -0
- package/esm/color/parse.d.ts +9 -0
- package/esm/color/parse.d.ts.map +1 -0
- package/esm/color/parse.js +452 -0
- package/esm/color/parse.js.map +1 -0
- package/esm/color/polar.js +27 -0
- package/esm/color/polar.js.map +1 -0
- package/esm/color/prophoto-rgb.d.ts +7 -0
- package/esm/color/prophoto-rgb.d.ts.map +1 -0
- package/esm/color/prophoto-rgb.js +18 -0
- package/esm/color/prophoto-rgb.js.map +1 -0
- package/esm/color/rec2020.d.ts +7 -0
- package/esm/color/rec2020.d.ts.map +1 -0
- package/esm/color/rec2020.js +13 -0
- package/esm/color/rec2020.js.map +1 -0
- package/esm/color/resolve.d.ts +18 -0
- package/esm/color/resolve.d.ts.map +1 -0
- package/esm/color/resolve.js +98 -0
- package/esm/color/resolve.js.map +1 -0
- package/esm/color/rgb.js +20 -0
- package/esm/color/rgb.js.map +1 -0
- package/esm/color/serialize.d.ts +24 -0
- package/esm/color/serialize.d.ts.map +1 -0
- package/esm/color/serialize.js +88 -0
- package/esm/color/serialize.js.map +1 -0
- package/esm/color/spaces.d.ts +6 -0
- package/esm/color/spaces.d.ts.map +1 -0
- package/esm/color/spaces.js +42 -0
- package/esm/color/spaces.js.map +1 -0
- package/esm/color/srgb-linear.d.ts +7 -0
- package/esm/color/srgb-linear.d.ts.map +1 -0
- package/esm/color/srgb-linear.js +12 -0
- package/esm/color/srgb-linear.js.map +1 -0
- package/esm/color/srgb.d.ts +7 -0
- package/esm/color/srgb.d.ts.map +1 -0
- package/esm/color/srgb.js +12 -0
- package/esm/color/srgb.js.map +1 -0
- package/esm/color/transfer.js +11 -0
- package/esm/color/transfer.js.map +1 -0
- package/esm/color/types.d.ts +23 -0
- package/esm/color/types.d.ts.map +1 -0
- package/esm/color/unknown-name.js +16 -0
- package/esm/color/unknown-name.js.map +1 -0
- package/esm/color/xyz-d50.d.ts +7 -0
- package/esm/color/xyz-d50.d.ts.map +1 -0
- package/esm/color/xyz-d50.js +15 -0
- package/esm/color/xyz-d50.js.map +1 -0
- package/esm/color/xyz-d65.d.ts +4 -0
- package/esm/color/xyz-d65.d.ts.map +1 -0
- package/esm/color/xyz-d65.js +10 -0
- package/esm/color/xyz-d65.js.map +1 -0
- package/esm/index.d.ts +63 -5
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +53 -4
- package/esm/index.js.map +1 -1
- package/esm/legacy/createColors.d.ts +9 -0
- package/esm/legacy/createColors.d.ts.map +1 -0
- package/esm/legacy/createColors.js +32 -0
- package/esm/legacy/createColors.js.map +1 -0
- package/esm/legacy/createColorsFromMap.d.ts +9 -0
- package/esm/legacy/createColorsFromMap.d.ts.map +1 -0
- package/esm/legacy/createColorsFromMap.js +24 -0
- package/esm/legacy/createColorsFromMap.js.map +1 -0
- package/esm/legacy/index.d.ts +6 -0
- package/esm/legacy/index.js +5 -0
- package/esm/legacy/interfaces.d.ts +19 -0
- package/esm/legacy/interfaces.d.ts.map +1 -0
- package/esm/{rgbHex.d.ts → legacy/rgbHex.d.ts} +2 -1
- package/esm/legacy/rgbHex.d.ts.map +1 -0
- package/esm/legacy/rgbHex.js +17 -0
- package/esm/legacy/rgbHex.js.map +1 -0
- package/esm/legacy/rgbaString.d.ts +4 -0
- package/esm/legacy/rgbaString.d.ts.map +1 -0
- package/esm/legacy/rgbaString.js +8 -0
- package/esm/legacy/rgbaString.js.map +1 -0
- package/esm/palette/dark.d.ts +23 -0
- package/esm/palette/dark.d.ts.map +1 -0
- package/esm/palette/dark.js +54 -0
- package/esm/palette/dark.js.map +1 -0
- package/esm/palette/harmony.d.ts +56 -0
- package/esm/palette/harmony.d.ts.map +1 -0
- package/esm/palette/harmony.js +115 -0
- package/esm/palette/harmony.js.map +1 -0
- package/esm/palette/index.d.ts +5 -0
- package/esm/palette/index.js +5 -0
- package/esm/palette/semantic.d.ts +53 -0
- package/esm/palette/semantic.d.ts.map +1 -0
- package/esm/palette/semantic.js +96 -0
- package/esm/palette/semantic.js.map +1 -0
- package/esm/palette/validate.d.ts +39 -0
- package/esm/palette/validate.d.ts.map +1 -0
- package/esm/palette/validate.js +56 -0
- package/esm/palette/validate.js.map +1 -0
- package/esm/scale/brand.d.ts +21 -0
- package/esm/scale/brand.d.ts.map +1 -0
- package/esm/scale/brand.js +63 -0
- package/esm/scale/brand.js.map +1 -0
- package/esm/scale/contrast-scale.d.ts +33 -0
- package/esm/scale/contrast-scale.d.ts.map +1 -0
- package/esm/scale/contrast-scale.js +26 -0
- package/esm/scale/contrast-scale.js.map +1 -0
- package/esm/scale/gradient.d.ts +38 -0
- package/esm/scale/gradient.d.ts.map +1 -0
- package/esm/scale/gradient.js +73 -0
- package/esm/scale/gradient.js.map +1 -0
- package/esm/scale/index.d.ts +6 -0
- package/esm/scale/index.js +6 -0
- package/esm/scale/scale.d.ts +31 -0
- package/esm/scale/scale.d.ts.map +1 -0
- package/esm/scale/scale.js +152 -0
- package/esm/scale/scale.js.map +1 -0
- package/esm/scale/tone.d.ts +25 -0
- package/esm/scale/tone.d.ts.map +1 -0
- package/esm/scale/tone.js +96 -0
- package/esm/scale/tone.js.map +1 -0
- package/esm/tokens/css.d.ts +18 -0
- package/esm/tokens/css.d.ts.map +1 -0
- package/esm/tokens/css.js +23 -0
- package/esm/tokens/css.js.map +1 -0
- package/esm/tokens/dtcg.d.ts +33 -0
- package/esm/tokens/dtcg.d.ts.map +1 -0
- package/esm/tokens/dtcg.js +42 -0
- package/esm/tokens/dtcg.js.map +1 -0
- package/esm/tokens/index.d.ts +5 -0
- package/esm/tokens/index.js +4 -0
- package/esm/tokens/tailwind.d.ts +19 -0
- package/esm/tokens/tailwind.d.ts.map +1 -0
- package/esm/tokens/tailwind.js +19 -0
- package/esm/tokens/tailwind.js.map +1 -0
- package/esm/tokens/tokens.d.ts +11 -0
- package/esm/tokens/tokens.d.ts.map +1 -0
- package/esm/tokens/tokens.js +77 -0
- package/esm/tokens/tokens.js.map +1 -0
- package/llms.txt +29 -0
- package/package.json +240 -56
- package/plugin.json +18 -0
- package/schemas/contrast.schema.json +24 -0
- package/schemas/convert.schema.json +60 -0
- package/schemas/export.schema.json +106 -0
- package/schemas/find-contrast.schema.json +51 -0
- package/schemas/harmony.schema.json +58 -0
- package/schemas/mix.schema.json +72 -0
- package/schemas/palette.schema.json +56 -0
- package/schemas/scale.schema.json +86 -0
- package/skills/color-map/SKILL.md +38 -0
- package/src/cli/bin.ts +11 -0
- package/src/cli/cli.ts +40 -0
- package/src/cli/commands/contrast.ts +36 -0
- package/src/cli/commands/convert.ts +37 -0
- package/src/cli/commands/export.ts +102 -0
- package/src/cli/commands/find-contrast.ts +37 -0
- package/src/cli/commands/harmony.ts +30 -0
- package/src/cli/commands/mix.ts +29 -0
- package/src/cli/commands/palette.ts +66 -0
- package/src/cli/commands/scale.ts +75 -0
- package/src/cli/index.ts +2 -0
- package/src/cli/schema-command.ts +31 -0
- package/src/cli/schemas.ts +86 -0
- package/src/cli/shared.ts +72 -0
- package/src/cli/testing.ts +27 -0
- package/src/color/a98-rgb.ts +11 -0
- package/src/color/argb.ts +21 -0
- package/src/color/calc.ts +84 -0
- package/src/color/compare.ts +53 -0
- package/src/color/contrast.ts +277 -0
- package/src/color/convert.ts +43 -0
- package/src/color/display-p3-linear.ts +9 -0
- package/src/color/display-p3.ts +9 -0
- package/src/color/expr.ts +158 -0
- package/src/color/gamut.ts +215 -0
- package/src/color/hsl.ts +57 -0
- package/src/color/hwb.ts +26 -0
- package/src/color/index.ts +43 -0
- package/src/color/lab.ts +29 -0
- package/src/color/lch.ts +8 -0
- package/src/color/math.ts +30 -0
- package/src/color/matrices.ts +91 -0
- package/src/color/mix.ts +158 -0
- package/src/color/named.ts +13 -0
- package/src/color/oklab.ts +19 -0
- package/src/color/oklch.ts +8 -0
- package/src/color/parse.ts +355 -0
- package/src/color/polar.ts +17 -0
- package/src/color/prophoto-rgb.ts +18 -0
- package/src/color/rec2020.ts +11 -0
- package/src/color/resolve.ts +87 -0
- package/src/color/rgb.ts +20 -0
- package/src/color/serialize.ts +96 -0
- package/src/color/spaces.ts +42 -0
- package/src/color/srgb-linear.ts +9 -0
- package/src/color/srgb.ts +9 -0
- package/src/color/test-utils.ts +10 -0
- package/src/color/transfer.ts +14 -0
- package/src/color/types.ts +41 -0
- package/src/color/unknown-name.ts +15 -0
- package/src/color/xyz-d50.ts +13 -0
- package/src/color/xyz-d65.ts +8 -0
- package/src/index.ts +37 -0
- package/src/legacy/createColors.ts +36 -0
- package/src/legacy/createColorsFromMap.ts +29 -0
- package/src/legacy/interfaces.ts +19 -0
- package/{ts → src/legacy}/rgbHex.ts +7 -7
- package/src/legacy/rgbaString.ts +6 -0
- package/src/palette/dark.ts +55 -0
- package/src/palette/harmony.ts +107 -0
- package/src/palette/index.ts +18 -0
- package/src/palette/semantic.ts +120 -0
- package/src/palette/validate.ts +82 -0
- package/src/scale/brand.ts +50 -0
- package/src/scale/contrast-scale.ts +48 -0
- package/src/scale/gradient.ts +91 -0
- package/src/scale/index.ts +5 -0
- package/src/scale/scale.ts +127 -0
- package/src/scale/tone.ts +69 -0
- package/src/tokens/css.ts +32 -0
- package/src/tokens/dtcg.ts +62 -0
- package/src/tokens/index.ts +11 -0
- package/src/tokens/tailwind.ts +24 -0
- package/src/tokens/tokens.ts +82 -0
- package/cjs/createColors.d.ts +0 -2
- package/cjs/createColors.js +0 -40
- package/cjs/createColors.js.map +0 -1
- package/cjs/createColors.spec.d.ts +0 -1
- package/cjs/createColors.spec.js +0 -176
- package/cjs/createColors.spec.js.map +0 -1
- package/cjs/createColorsFromMap.d.ts +0 -5
- package/cjs/createColorsFromMap.js +0 -25
- package/cjs/createColorsFromMap.js.map +0 -1
- package/cjs/createColorsFromMap.spec.d.ts +0 -1
- package/cjs/createColorsFromMap.spec.js +0 -11
- package/cjs/createColorsFromMap.spec.js.map +0 -1
- package/cjs/interfaces.d.ts +0 -14
- package/cjs/interfaces.js +0 -3
- package/cjs/interfaces.js.map +0 -1
- package/cjs/rgbHex.d.ts +0 -6
- package/cjs/rgbHex.js +0 -19
- package/cjs/rgbHex.js.map +0 -1
- package/cjs/rgbHex.spec.d.ts +0 -1
- package/cjs/rgbHex.spec.js +0 -16
- package/cjs/rgbHex.spec.js.map +0 -1
- package/cjs/rgbaString.d.ts +0 -2
- package/cjs/rgbaString.js +0 -7
- package/cjs/rgbaString.js.map +0 -1
- package/cjs/rgbaString.spec.d.ts +0 -1
- package/cjs/rgbaString.spec.js +0 -10
- package/cjs/rgbaString.spec.js.map +0 -1
- package/esm/createColors.d.ts +0 -2
- package/esm/createColors.js +0 -27
- package/esm/createColors.js.map +0 -1
- package/esm/createColors.spec.d.ts +0 -1
- package/esm/createColors.spec.js +0 -171
- package/esm/createColors.spec.js.map +0 -1
- package/esm/createColorsFromMap.d.ts +0 -5
- package/esm/createColorsFromMap.js +0 -22
- package/esm/createColorsFromMap.js.map +0 -1
- package/esm/createColorsFromMap.spec.d.ts +0 -1
- package/esm/createColorsFromMap.spec.js +0 -9
- package/esm/createColorsFromMap.spec.js.map +0 -1
- package/esm/interfaces.d.ts +0 -14
- package/esm/interfaces.js +0 -2
- package/esm/interfaces.js.map +0 -1
- package/esm/rgbHex.js +0 -16
- package/esm/rgbHex.js.map +0 -1
- package/esm/rgbHex.spec.d.ts +0 -1
- package/esm/rgbHex.spec.js +0 -14
- package/esm/rgbHex.spec.js.map +0 -1
- package/esm/rgbaString.d.ts +0 -2
- package/esm/rgbaString.js +0 -4
- package/esm/rgbaString.js.map +0 -1
- package/esm/rgbaString.spec.d.ts +0 -1
- package/esm/rgbaString.spec.js +0 -8
- package/esm/rgbaString.spec.js.map +0 -1
- package/ts/createColors.ts +0 -35
- package/ts/createColorsFromMap.ts +0 -26
- package/ts/interfaces.ts +0 -15
- package/ts/rgbaString.ts +0 -5
- package/{ts → src/legacy}/index.ts +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-8mt2OMKf.js","names":["toLinear","toGamma","channel"],"sources":["../src/color/matrices.ts","../src/color/math.ts","../src/color/rgb.ts","../src/color/transfer.ts","../src/color/a98-rgb.ts","../src/color/unknown-name.ts","../src/color/convert.ts","../src/color/oklab.ts","../src/color/display-p3.ts","../src/color/display-p3-linear.ts","../src/color/srgb.ts","../src/color/hsl.ts","../src/color/hwb.ts","../src/color/lab.ts","../src/color/polar.ts","../src/color/lch.ts","../src/color/oklch.ts","../src/color/xyz-d50.ts","../src/color/prophoto-rgb.ts","../src/color/rec2020.ts","../src/color/srgb-linear.ts","../src/color/xyz-d65.ts","../src/color/spaces.ts","../src/color/compare.ts","../src/color/gamut.ts","../src/color/named.ts","../src/color/parse.ts"],"sourcesContent":["// biome-ignore-all format: each matrix is written as its three rows\n// CSS Color 4, section 19 (sample code for color conversions). Each matrix is\n// flat, row by row.\nimport type { Matrix } from './math.js'\n\nexport const srgbToXyz: Matrix = [\n\t506752 / 1228815, 87881 / 245763, 12673 / 70218,\n\t87098 / 409605, 175762 / 245763, 12673 / 175545,\n\t7918 / 409605, 87881 / 737289, 1001167 / 1053270\n]\nexport const xyzToSrgb: Matrix = [\n\t12831 / 3959, -329 / 214, -1974 / 3959,\n\t-851781 / 878810, 1648619 / 878810, 36519 / 878810,\n\t705 / 12673, -2585 / 12673, 705 / 667\n]\n\nexport const p3ToXyz: Matrix = [\n\t608311 / 1250200, 189793 / 714400, 198249 / 1000160,\n\t35783 / 156275, 247089 / 357200, 198249 / 2500400,\n\t0, 32229 / 714400, 5220557 / 5000800\n]\nexport const xyzToP3: Matrix = [\n\t446124 / 178915, -333277 / 357830, -72051 / 178915,\n\t-14852 / 17905, 63121 / 35810, 423 / 17905,\n\t11844 / 330415, -50337 / 660830, 316169 / 330415\n]\n\nexport const a98ToXyz: Matrix = [\n\t573536 / 994567, 263643 / 1420810, 187206 / 994567,\n\t591459 / 1989134, 6239551 / 9945670, 374412 / 4972835,\n\t53769 / 1989134, 351524 / 4972835, 4929758 / 4972835\n]\nexport const xyzToA98: Matrix = [\n\t1829569 / 896150, -506331 / 896150, -308931 / 896150,\n\t-851781 / 878810, 1648619 / 878810, 36519 / 878810,\n\t16779 / 1248040, -147721 / 1248040, 1266979 / 1248040\n]\n\nexport const prophotoToXyzD50: Matrix = [\n\t0.7977666449006423, 0.13518129740053308, 0.0313477341283922,\n\t0.2880748288194013, 0.711835234241873, 0.00008993693872564,\n\t0, 0, 0.8251046025104602\n]\nexport const xyzD50ToProphoto: Matrix = [\n\t1.3457868816471583, -0.25557208737979464, -0.05110186497554526,\n\t-0.5446307051249019, 1.5082477428451468, 0.02052744743642139,\n\t0, 0, 1.2119675456389452\n]\n\nexport const rec2020ToXyz: Matrix = [\n\t63426534 / 99577255, 20160776 / 139408157, 47086771 / 278816314,\n\t26158966 / 99577255, 472592308 / 697040785, 8267143 / 139408157,\n\t0, 19567812 / 697040785, 295819943 / 278816314\n]\nexport const xyzToRec2020: Matrix = [\n\t30757411 / 17917100, -6372589 / 17917100, -4539589 / 17917100,\n\t-19765991 / 29648200, 47925759 / 29648200, 467509 / 29648200,\n\t792561 / 44930125, -1921689 / 44930125, 42328811 / 44930125\n]\n\nexport const d65ToD50: Matrix = [\n\t1.0479297925449969, 0.022946870601609652, -0.05019226628920524,\n\t0.02962780877005599, 0.9904344267538799, -0.017073799063418826,\n\t-0.009243040646204504, 0.015055191490298152, 0.7518742814281371\n]\nexport const d50ToD65: Matrix = [\n\t0.955473421488075, -0.02309845494876471, 0.06325924320057072,\n\t-0.0283697093338637, 1.0099953980813041, 0.021041441191917323,\n\t0.012314014864481998, -0.020507649298898964, 1.330365926242124\n]\n\nexport const xyzToLms: Matrix = [\n\t0.819022437996703, 0.3619062600528904, -0.1288737815209879,\n\t0.0329836539323885, 0.9292868615863434, 0.0361446663506424,\n\t0.0481771893596242, 0.2642395317527308, 0.6335478284694309\n]\nexport const lmsToOklab: Matrix = [\n\t0.210454268309314, 0.7936177747023054, -0.0040720430116193,\n\t1.9779985324311684, -2.42859224204858, 0.450593709617411,\n\t0.0259040424655478, 0.7827717124575296, -0.8086757549230774\n]\nexport const lmsToXyz: Matrix = [\n\t1.2268798758459243, -0.5578149944602171, 0.2813910456659647,\n\t-0.0405757452148008, 1.112286803280317, -0.0717110580655164,\n\t-0.0763729366746601, -0.4214933324022432, 1.5869240198367816\n]\nexport const oklabToLms: Matrix = [\n\t1, 0.3963377773761749, 0.2158037573099136,\n\t1, -0.1055613458156586, -0.0638541728258133,\n\t1, -0.0894841775298119, -1.2914855480194092\n]\n","import type { Vec3 } from './types.js'\n\n/** A 3x3 matrix, flat, row by row. */\nexport type Matrix = readonly [number, number, number, number, number, number, number, number, number]\n\n/** `m` times the column vector (x, y, z). Takes numbers rather than a Vec3, so callers need no array. */\nexport function multiply(m: Matrix, x: number, y: number, z: number): Vec3 {\n\treturn [m[0] * x + m[1] * y + m[2] * z, m[3] * x + m[4] * y + m[5] * z, m[6] * x + m[7] * y + m[8] * z]\n}\n\n/** Keeps the sign, so out-of-gamut values survive the transfer function. */\nexport function signed(f: (abs: number) => number): (n: number) => number {\n\treturn (n) => (n < 0 ? -f(-n) : f(n))\n}\n\nexport function normalizeHue(h: number): number {\n\treturn ((h % 360) + 360) % 360\n}\n\nexport const D50: Vec3 = [0.3457 / 0.3585, 1, (1 - 0.3457 - 0.3585) / 0.3585]\n\n/** The product of 3x3 matrices, left to right: `product(a, b)` applies `b` first. */\nexport function product(...ms: Matrix[]): Matrix {\n\treturn ms.reduce((a, b) => {\n\t\tconst out: number[] = []\n\t\tfor (let i = 0; i < 3; i++)\n\t\t\tfor (let j = 0; j < 3; j++) out.push(a[i * 3] * b[j] + a[i * 3 + 1] * b[3 + j] + a[i * 3 + 2] * b[6 + j])\n\t\treturn out as unknown as Matrix\n\t})\n}\n","import { type Matrix, multiply } from './math.js'\nimport type { ColorSpaceId, Space } from './types.js'\n\n/** An RGB space: a transfer function, then a matrix to XYZ-D65. */\nexport function rgbSpace(\n\tid: ColorSpaceId,\n\ttoLinear: (n: number) => number,\n\ttoGamma: (n: number) => number,\n\ttoXyz: Matrix,\n\tfromXyz: Matrix\n): Space {\n\treturn {\n\t\tid,\n\t\ttoXyz: (c) => multiply(toXyz, toLinear(c[0]), toLinear(c[1]), toLinear(c[2])),\n\t\tfromXyz: (xyz) => {\n\t\t\tconst v = multiply(fromXyz, xyz[0], xyz[1], xyz[2])\n\t\t\treturn [toGamma(v[0]), toGamma(v[1]), toGamma(v[2])]\n\t\t}\n\t}\n}\n","import { signed } from './math.js'\n\nexport const identity = (n: number): number => n\n\nexport const srgbToLinear = signed((a) => (a <= 0.04045 ? a / 12.92 : ((a + 0.055) / 1.055) ** 2.4))\nexport const srgbToGamma = signed((a) => (a > 0.0031308 ? 1.055 * a ** (1 / 2.4) - 0.055 : 12.92 * a))\n\nexport const power = (gamma: number): [(n: number) => number, (n: number) => number] => [\n\tsigned((a) => a ** gamma),\n\tsigned((a) => a ** (1 / gamma))\n]\n\nexport const prophotoToLinear = signed((a) => (a <= 16 / 512 ? a / 16 : a ** 1.8))\nexport const prophotoToGamma = signed((a) => (a >= 1 / 512 ? a ** (1 / 1.8) : 16 * a))\n","import { a98ToXyz, xyzToA98 } from './matrices.js'\nimport { rgbSpace } from './rgb.js'\nimport { power } from './transfer.js'\n\nconst [toLinear, toGamma] = power(563 / 256)\n\n/**\n * The CSS `a98-rgb` space (Adobe RGB 1998). Components are red, green and blue in 0 to 1, with a 563/256 power transfer curve.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const a98Rgb = rgbSpace('a98-rgb', toLinear, toGamma, a98ToXyz, xyzToA98)\n","/**\n * The error for a name a caller wrote that the library does not know: it names\n * the value and lists the valid ones, in the style of `unknown color space`.\n */\nexport function unknownName(what: string, value: unknown, valid: readonly string[]): Error {\n\treturn new Error(\n\t\t`color-map: unknown ${what} \"${String(value)}\"${valid.length ? `; use one of ${valid.join(', ')}` : ''}`\n\t)\n}\n\n/** `mode` itself when it is `light` or `dark`; any other value is an unknown mode. */\nexport function checkMode<T>(mode: T): T {\n\tif (mode !== 'light' && mode !== 'dark') throw unknownName('mode', mode, ['light', 'dark'])\n\treturn mode\n}\n","import type { Color, ColorSpaceId, Component, Space, Vec3 } from './types.js'\nimport { unknownName } from './unknown-name.js'\n\n/** Converts bare components between two spaces, through the XYZ-D65 hub. */\nexport function convertComponents(from: Space, to: Space, c: Vec3): Vec3 {\n\treturn from === to ? c : to.fromXyz(from.toXyz(c))\n}\n\n/** The components of a color in another space: a copy in the same space, else `none` becomes 0. */\nexport type ComponentsIn = (color: Color, to: ColorSpaceId) => Component[]\n\n/** {@link ComponentsIn} over the spaces given. */\nexport function componentsOver(spaces: Space[]): ComponentsIn {\n\tconst byId = new Map(spaces.map((s) => [s.id, s]))\n\tconst find = (id: ColorSpaceId): Space => {\n\t\tconst space = byId.get(id)\n\t\tif (!space) throw unknownName('color space', id, [...byId.keys()])\n\t\treturn space\n\t}\n\treturn (color, to) => {\n\t\tif (color.colorSpace === to) return [...color.components]\n\t\tconst from = find(color.colorSpace)\n\t\tconst c = color.components\n\t\t// Different ids, so different spaces: straight through the hub, `none` as 0.\n\t\treturn find(to).fromXyz(from.toXyz([c[0] ?? 0, c[1] ?? 0, c[2] ?? 0]))\n\t}\n}\n\n/** `convert` over the spaces `componentsIn` knows: the color in `to`, keeping its alpha. */\nexport function convertWith(componentsIn: ComponentsIn, color: Color, to: ColorSpaceId): Color {\n\tconst result: Color = { colorSpace: to, components: componentsIn(color, to) }\n\tif (color.alpha !== undefined) result.alpha = color.alpha\n\treturn result\n}\n\n/**\n * Builds `convert` over just the spaces given, so a bundle contains only those.\n * `none` components become 0 when the space changes.\n */\nexport function createConverter(...spaces: Space[]): (color: Color, to: ColorSpaceId) => Color {\n\tconst componentsIn = componentsOver(spaces)\n\treturn (color, to) => convertWith(componentsIn, color, to)\n}\n","import { multiply } from './math.js'\nimport { lmsToOklab, lmsToXyz, oklabToLms, xyzToLms } from './matrices.js'\nimport type { Space } from './types.js'\n\n/**\n * The CSS `oklab` space. Components are lightness in 0 to 1, then the a and b axes, which stay within about -0.4 to 0.4 for real colors.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const oklab: Space = {\n\tid: 'oklab',\n\ttoXyz: (c) => {\n\t\tconst v = multiply(oklabToLms, c[0], c[1], c[2])\n\t\treturn multiply(lmsToXyz, v[0] ** 3, v[1] ** 3, v[2] ** 3)\n\t},\n\tfromXyz: (xyz) => {\n\t\tconst v = multiply(xyzToLms, xyz[0], xyz[1], xyz[2])\n\t\treturn multiply(lmsToOklab, Math.cbrt(v[0]), Math.cbrt(v[1]), Math.cbrt(v[2]))\n\t}\n}\n","import { p3ToXyz, xyzToP3 } from './matrices.js'\nimport { rgbSpace } from './rgb.js'\nimport { srgbToGamma, srgbToLinear } from './transfer.js'\n\n/**\n * The CSS `display-p3` space. Components are red, green and blue in 0 to 1, with the sRGB transfer curve.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const displayP3 = rgbSpace('display-p3', srgbToLinear, srgbToGamma, p3ToXyz, xyzToP3)\n","import { p3ToXyz, xyzToP3 } from './matrices.js'\nimport { rgbSpace } from './rgb.js'\nimport { identity } from './transfer.js'\n\n/**\n * The CSS `display-p3-linear` space: Display P3 primaries without a transfer curve. Components are red, green and blue in 0 to 1.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const displayP3Linear = rgbSpace('display-p3-linear', identity, identity, p3ToXyz, xyzToP3)\n","import { srgbToXyz, xyzToSrgb } from './matrices.js'\nimport { rgbSpace } from './rgb.js'\nimport { srgbToGamma, srgbToLinear } from './transfer.js'\n\n/**\n * The CSS `srgb` space. Components are red, green and blue in 0 to 1, with the sRGB transfer curve.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const srgb = rgbSpace('srgb', srgbToLinear, srgbToGamma, srgbToXyz, xyzToSrgb)\n","import { normalizeHue } from './math.js'\nimport { srgb } from './srgb.js'\nimport type { Space, Vec3 } from './types.js'\n\nfunction channel(t1: number, t2: number, sextant: number): number {\n\tconst h = (sextant + 6) % 6\n\tif (h < 1) return (t2 - t1) * h + t1\n\tif (h < 3) return t2\n\tif (h < 4) return (t2 - t1) * (4 - h) + t1\n\treturn t1\n}\n\n/** CSS Color 4 hslToRgb. Hue in degrees, s and l in 0 to 1. */\nexport function hslToSrgb(h: number, s: number, l: number): Vec3 {\n\tconst t2 = l <= 0.5 ? l * (s + 1) : l + s - l * s\n\tconst t1 = l * 2 - t2\n\tconst hue = normalizeHue(h) / 60\n\treturn [channel(t1, t2, hue + 2), channel(t1, t2, hue), channel(t1, t2, hue - 2)]\n}\n\n/**\n * CSS Color 4 rgbToHsl. Returns hue in degrees, s and l in 0 to 1. For\n * out-of-gamut input the saturation can come out negative; it is made positive\n * and the hue turned by 180 degrees, unless `flipNegative` is false.\n */\nexport function srgbToHsl([r, g, b]: Vec3, flipNegative = true): Vec3 {\n\tconst max = Math.max(r, g, b)\n\tconst min = Math.min(r, g, b)\n\tconst l = (min + max) / 2\n\tconst d = max - min\n\tlet h = 0\n\tlet s = 0\n\t// A spread of rounding noise is a gray: a round trip leaves white at 1 - 1e-16.\n\tif (d > 1e-9) {\n\t\ts = l === 0 || l === 1 ? 0 : (max - l) / Math.min(l, 1 - l)\n\t\th = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4\n\t\th *= 60\n\t}\n\tif (s < 0) {\n\t\tif (flipNegative) h += 180\n\t\ts = -s\n\t}\n\treturn [normalizeHue(h), s, l]\n}\n\n/**\n * The CSS `hsl` space. Components are hue in degrees, then saturation and lightness in 0 to 100.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const hsl: Space = {\n\tid: 'hsl',\n\ttoXyz: ([h, s, l]) => srgb.toXyz(hslToSrgb(h, s / 100, l / 100)),\n\tfromXyz: (xyz) => {\n\t\tconst [h, s, l] = srgbToHsl(srgb.fromXyz(xyz))\n\t\treturn [h, s * 100, l * 100]\n\t}\n}\n","import { hslToSrgb, srgbToHsl } from './hsl.js'\nimport { srgb } from './srgb.js'\nimport type { Space } from './types.js'\n\n/**\n * The CSS `hwb` space. Components are hue in degrees, then whiteness and blackness in 0 to 100.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const hwb: Space = {\n\tid: 'hwb',\n\ttoXyz: ([h, w, b]) => {\n\t\tconst white = w / 100\n\t\tconst black = b / 100\n\t\tif (white + black >= 1) {\n\t\t\tconst gray = white / (white + black)\n\t\t\treturn srgb.toXyz([gray, gray, gray])\n\t\t}\n\t\tconst k = 1 - white - black\n\t\tconst [red, green, blue] = hslToSrgb(h, 1, 0.5)\n\t\treturn srgb.toXyz([red * k + white, green * k + white, blue * k + white])\n\t},\n\tfromXyz: (xyz) => {\n\t\tconst rgb = srgb.fromXyz(xyz)\n\t\treturn [srgbToHsl(rgb, false)[0], Math.min(...rgb) * 100, (1 - Math.max(...rgb)) * 100]\n\t}\n}\n","import { D50, multiply } from './math.js'\nimport { d50ToD65, d65ToD50 } from './matrices.js'\nimport type { Space } from './types.js'\n\nconst EPSILON = 216 / 24389\nconst KAPPA = 24389 / 27\n\nconst finv = (f: number): number => (f ** 3 > EPSILON ? f ** 3 : (116 * f - 16) / KAPPA)\nconst forward = (v: number): number => (v > EPSILON ? Math.cbrt(v) : (KAPPA * v + 16) / 116)\n\n/**\n * The CSS `lab` space (CIE Lab, D50 white). Components are lightness in 0 to 100, then the a and b axes, which are not bounded but stay near -125 to 125 for real colors.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const lab: Space = {\n\tid: 'lab',\n\ttoXyz: ([l, a, b]) => {\n\t\tconst fy = (l + 16) / 116\n\t\tconst y = l > KAPPA * EPSILON ? fy ** 3 : l / KAPPA\n\t\tconst x = finv(fy + a / 500)\n\t\tconst z = finv(fy - b / 200)\n\t\treturn multiply(d50ToD65, x * D50[0], y * D50[1], z * D50[2])\n\t},\n\tfromXyz: (xyz) => {\n\t\tconst [x, y, z] = multiply(d65ToD50, xyz[0], xyz[1], xyz[2])\n\t\tconst fy = forward(y / D50[1])\n\t\treturn [116 * fy - 16, 500 * (forward(x / D50[0]) - fy), 200 * (fy - forward(z / D50[2]))]\n\t}\n}\n","import { normalizeHue } from './math.js'\nimport type { Space } from './types.js'\n\n/** Wraps a rectangular Lab-like space as its polar (LCH-like) twin. */\nexport function polarSpace(id: 'lch' | 'oklch', base: Space): Space {\n\treturn {\n\t\tid,\n\t\ttoXyz: ([l, c, h]) => {\n\t\t\tconst r = (h * Math.PI) / 180\n\t\t\treturn base.toXyz([l, c * Math.cos(r), c * Math.sin(r)])\n\t\t},\n\t\tfromXyz: (xyz) => {\n\t\t\tconst [l, a, b] = base.fromXyz(xyz)\n\t\t\treturn [l, Math.hypot(a, b), normalizeHue((Math.atan2(b, a) * 180) / Math.PI)]\n\t\t}\n\t}\n}\n","import { lab } from './lab.js'\nimport { polarSpace } from './polar.js'\n\n/**\n * The CSS `lch` space, the polar form of `lab`. Components are lightness in 0 to 100, chroma (not bounded, about 0 to 150) and hue in degrees.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const lch = polarSpace('lch', lab)\n","import { oklab } from './oklab.js'\nimport { polarSpace } from './polar.js'\n\n/**\n * The CSS `oklch` space, the polar form of `oklab`. Components are lightness in 0 to 1, chroma (about 0 to 0.4) and hue in degrees.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const oklch = polarSpace('oklch', oklab)\n","import { multiply } from './math.js'\nimport { d50ToD65, d65ToD50 } from './matrices.js'\nimport type { Space } from './types.js'\n\n/**\n * The CSS `xyz-d50` space (CIE XYZ, D50 white). Components are X, Y and Z, where Y is 1 for white.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const xyzD50: Space = {\n\tid: 'xyz-d50',\n\ttoXyz: (c) => multiply(d50ToD65, c[0], c[1], c[2]),\n\tfromXyz: (xyz) => multiply(d65ToD50, xyz[0], xyz[1], xyz[2])\n}\n","import { prophotoToXyzD50, xyzD50ToProphoto } from './matrices.js'\nimport { rgbSpace } from './rgb.js'\nimport { prophotoToGamma, prophotoToLinear } from './transfer.js'\nimport type { Space } from './types.js'\nimport { xyzD50 } from './xyz-d50.js'\n\n// ProPhoto's matrices lead to XYZ-D50, so it goes through that space on the way to the hub.\nconst d50 = rgbSpace('prophoto-rgb', prophotoToLinear, prophotoToGamma, prophotoToXyzD50, xyzD50ToProphoto)\n\n/**\n * The CSS `prophoto-rgb` space. Components are red, green and blue in 0 to 1. It is defined against a D50 white and converted through `xyzD50`.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const prophotoRgb: Space = {\n\tid: 'prophoto-rgb',\n\ttoXyz: (c) => xyzD50.toXyz(d50.toXyz(c)),\n\tfromXyz: (xyz) => d50.fromXyz(xyzD50.fromXyz(xyz))\n}\n","import { rec2020ToXyz, xyzToRec2020 } from './matrices.js'\nimport { rgbSpace } from './rgb.js'\nimport { power } from './transfer.js'\n\nconst [toLinear, toGamma] = power(2.4)\n\n/**\n * The CSS `rec2020` space. Components are red, green and blue in 0 to 1, with a 2.4 power transfer curve.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const rec2020 = rgbSpace('rec2020', toLinear, toGamma, rec2020ToXyz, xyzToRec2020)\n","import { srgbToXyz, xyzToSrgb } from './matrices.js'\nimport { rgbSpace } from './rgb.js'\nimport { identity } from './transfer.js'\n\n/**\n * The CSS `srgb-linear` space: sRGB primaries without a transfer curve. Components are red, green and blue in 0 to 1.\n * Pass it to `createConverter` and to the narrow helpers such as `createMix` and `createToGamut`.\n */\nexport const srgbLinear = rgbSpace('srgb-linear', identity, identity, srgbToXyz, xyzToSrgb)\n","import type { Space } from './types.js'\n\n/** The hub every other space converts through. */\nexport const xyzD65: Space = {\n\tid: 'xyz-d65',\n\ttoXyz: (c) => c,\n\tfromXyz: (xyz) => xyz\n}\n","import { a98Rgb } from './a98-rgb.js'\nimport { componentsOver, createConverter } from './convert.js'\nimport { displayP3 } from './display-p3.js'\nimport { displayP3Linear } from './display-p3-linear.js'\nimport { hsl } from './hsl.js'\nimport { hwb } from './hwb.js'\nimport { lab } from './lab.js'\nimport { lch } from './lch.js'\nimport { oklab } from './oklab.js'\nimport { oklch } from './oklch.js'\nimport { prophotoRgb } from './prophoto-rgb.js'\nimport { rec2020 } from './rec2020.js'\nimport { srgb } from './srgb.js'\nimport { srgbLinear } from './srgb-linear.js'\nimport type { ColorSpaceId, Space } from './types.js'\nimport { xyzD50 } from './xyz-d50.js'\nimport { xyzD65 } from './xyz-d65.js'\n\n/** Every space. Importing this pulls them all in; import single spaces to avoid that. */\nexport const spaces: Record<ColorSpaceId, Space> = {\n\tsrgb,\n\t'srgb-linear': srgbLinear,\n\thsl,\n\thwb,\n\tlab,\n\tlch,\n\toklab,\n\toklch,\n\t'display-p3': displayP3,\n\t'display-p3-linear': displayP3Linear,\n\t'a98-rgb': a98Rgb,\n\t'prophoto-rgb': prophotoRgb,\n\trec2020,\n\t'xyz-d50': xyzD50,\n\t'xyz-d65': xyzD65\n}\n\n/** A color's components in any of the 15 spaces, as `convert` gives them, without the color object. */\nexport const componentsIn = componentsOver(Object.values(spaces))\n\n/** Converts a color to any of the 15 spaces. */\nexport const convert = createConverter(...Object.values(spaces))\n","import { type ComponentsIn, componentsOver, convertWith } from './convert.js'\nimport { oklab } from './oklab.js'\nimport { componentsIn } from './spaces.js'\nimport type { Color, Space } from './types.js'\n\n/** Euclidean distance in OKLab, the ΔEOK of CSS Color 4 gamut mapping. */\nexport function deltaEOk(a: Color, b: Color): number {\n\treturn deltaEOkWith(componentsIn, a, b)\n}\n\n/** {@link deltaEOk} over the spaces `componentsIn` knows, which must include `oklab`. */\nexport function deltaEOkWith(componentsIn: ComponentsIn, a: Color, b: Color): number {\n\tconst [l1, a1, b1] = componentsIn(a, 'oklab') as number[]\n\tconst [l2, a2, b2] = componentsIn(b, 'oklab') as number[]\n\treturn Math.hypot(l1 - l2, a1 - a2, b1 - b2)\n}\n\n/**\n * Builds {@link deltaEOk} over the spaces given, plus `oklab`, so a bundle\n * contains only those. A color in a space not given throws, naming that space.\n */\nexport function createDeltaEOk(...spaces: Space[]): (a: Color, b: Color) => number {\n\tconst over = componentsOver([oklab, ...spaces])\n\treturn (a, b) => deltaEOkWith(over, a, b)\n}\n\nconst same = (x: number | null | undefined, y: number | null | undefined, epsilon: number): boolean =>\n\tx === y || (x != null && y != null && Math.abs(x - y) <= epsilon)\n\n/**\n * True when both colors are the same within `epsilon` per component. Colors in\n * different spaces are compared in the first one's space. `none` equals only\n * `none`, and a missing alpha equals 1.\n */\nexport function equals(a: Color, b: Color, epsilon = 1e-6): boolean {\n\treturn equalsWith(componentsIn, a, b, epsilon)\n}\n\nfunction equalsWith(componentsIn: ComponentsIn, a: Color, b: Color, epsilon: number): boolean {\n\tconst other = convertWith(componentsIn, b, a.colorSpace)\n\treturn (\n\t\tsame(a.alpha ?? 1, other.alpha ?? 1, epsilon) && a.components.every((c, i) => same(c, other.components[i], epsilon))\n\t)\n}\n\n/**\n * Builds {@link equals} over the spaces given, so a bundle contains only those.\n * It needs no space of its own: give the spaces of both colors.\n */\nexport function createEquals(...spaces: Space[]): (a: Color, b: Color, epsilon?: number) => boolean {\n\tconst over = componentsOver(spaces)\n\treturn (a, b, epsilon = 1e-6) => equalsWith(over, a, b, epsilon)\n}\n","import { deltaEOkWith } from './compare.js'\nimport { type ComponentsIn, componentsOver, convertWith } from './convert.js'\nimport { type Matrix, product } from './math.js'\nimport { lmsToOklab, lmsToXyz, oklabToLms, srgbToXyz, xyzToLms, xyzToSrgb } from './matrices.js'\nimport { oklab } from './oklab.js'\nimport { oklch } from './oklch.js'\nimport { componentsIn } from './spaces.js'\nimport { srgb } from './srgb.js'\nimport { srgbToGamma } from './transfer.js'\nimport type { Color, ColorSpaceId, Component, Space, Vec3 } from './types.js'\n\n/** The bounded RGB spaces a color can be tested or mapped against. */\nexport type GamutId =\n\t| 'srgb'\n\t| 'srgb-linear'\n\t| 'display-p3'\n\t| 'display-p3-linear'\n\t| 'a98-rgb'\n\t| 'prophoto-rgb'\n\t| 'rec2020'\n\nconst within = (components: Component[], epsilon: number): boolean =>\n\tcomponents.every((c) => (c as number) >= -epsilon && (c as number) <= 1 + epsilon)\n\n/** True when every channel of `color`, seen in `gamut`, is within 0 to 1 (± `epsilon`). */\nexport function inGamut(color: Color, gamut: GamutId = 'srgb', epsilon = 1e-6): boolean {\n\treturn within(componentsIn(color, gamut), epsilon)\n}\n\n/**\n * Builds {@link inGamut} over the spaces given, plus `srgb`, so a bundle\n * contains only those. Give the gamut too when it is not `srgb`. A color or\n * gamut in a space not given throws, naming that space.\n */\nexport function createInGamut(...spaces: Space[]): (color: Color, gamut?: GamutId, epsilon?: number) => boolean {\n\tconst over = componentsOver([srgb, ...spaces])\n\treturn (color, gamut = 'srgb', epsilon = 1e-6) => within(over(color, gamut), epsilon)\n}\n\n/** Options for `toGamut` and the function `createToGamut` returns. */\nexport interface ToGamutOptions {\n\t/** The gamut to fit into. Default `srgb`. */\n\tgamut?: GamutId\n\t/** `css` is the CSS Color 4 OKLCH chroma reduction. `clip` clamps each channel. Default `css`. */\n\tmethod?: 'css' | 'clip'\n}\n\n/** `color` with `components`, which are in `gamut`, clamped to 0 to 1: what `convert` then a clamp gives. */\nfunction clipped(color: Color, gamut: GamutId, components: Component[]): Color {\n\treturn withAlpha(\n\t\t{ colorSpace: gamut, components: components.map((c) => Math.min(1, Math.max(0, c as number))) },\n\t\tcolor\n\t)\n}\n\n/**\n * Maps a color into a gamut and returns it in its original space. `css` follows\n * CSS Color 4 section 13.2: reduce OKLCH chroma until the clipped color is\n * within a just-noticeable ΔEOK of 0.02.\n */\nexport function toGamut(color: Color, options: ToGamutOptions = {}): Color {\n\treturn toGamutWith(componentsIn, color, options)\n}\n\n/**\n * Builds {@link toGamut} over the spaces given, plus `srgb`, `oklch` and\n * `oklab`, which the CSS method works in. Give the gamut too when it is not\n * `srgb`. A color or gamut in a space not given throws, naming that space.\n */\nexport function createToGamut(...spaces: Space[]): (color: Color, options?: ToGamutOptions) => Color {\n\tconst over = componentsOver([srgb, oklch, oklab, ...spaces])\n\treturn (color, options = {}) => toGamutWith(over, color, options)\n}\n\n/** {@link toGamut} over the spaces `componentsIn` knows, which must include `oklch` and `oklab`. */\nexport function toGamutWith(componentsIn: ComponentsIn, color: Color, options: ToGamutOptions): Color {\n\tconst { gamut = 'srgb', method = 'css' } = options\n\tconst deltaEOk = (a: Color, b: Color): number => deltaEOkWith(componentsIn, a, b)\n\tconst back = (c: Color): Color => convertWith(componentsIn, c, color.colorSpace as ColorSpaceId)\n\t// Each candidate is converted to the gamut once, then tested and clipped from that.\n\tconst fit = componentsIn(color, gamut)\n\tif (within(fit, 1e-6)) return color\n\tif (method === 'clip') return back(clipped(color, gamut, fit))\n\n\tconst origin = convertWith(componentsIn, color, 'oklch')\n\tconst [lightness, chroma, hue] = origin.components as [number, number, Component]\n\tif (lightness >= 1) return back(withAlpha({ colorSpace: gamut, components: [1, 1, 1] }, color))\n\tif (lightness <= 0) return back(withAlpha({ colorSpace: gamut, components: [0, 0, 0] }, color))\n\n\tconst JND = 0.02\n\tconst EPSILON = 0.0001\n\tif (gamut === 'srgb') return back(reduceChromaInSrgb(origin, lightness, chroma, hue))\n\tlet min = 0\n\tlet max = chroma\n\tlet minInGamut = true\n\tlet clip = clipped(origin, gamut, componentsIn(origin, gamut))\n\tif (deltaEOk(clip, origin) < JND) return back(clip)\n\twhile (max - min > EPSILON) {\n\t\tconst mid = (min + max) / 2\n\t\tconst current = withAlpha({ colorSpace: 'oklch', components: [lightness, mid, hue] }, origin)\n\t\tconst inGamutSpace = componentsIn(current, gamut)\n\t\tif (minInGamut && within(inGamutSpace, 1e-6)) {\n\t\t\tmin = mid\n\t\t\tcontinue\n\t\t}\n\t\tclip = clipped(current, gamut, inGamutSpace)\n\t\tconst e = deltaEOk(clip, current)\n\t\tif (e < JND) {\n\t\t\tif (JND - e < EPSILON) return back(clip)\n\t\t\tminInGamut = false\n\t\t\tmin = mid\n\t\t} else {\n\t\t\tmax = mid\n\t\t}\n\t}\n\t// The search ended by narrowing to EPSILON rather than by an early return. A\n\t// sweep of 88,000 colors never gets here, but the algorithm allows it.\n\t/* v8 ignore next */\n\treturn back(clip)\n}\n\nfunction withAlpha(c: Color, source: Color): Color {\n\tif (source.alpha !== undefined) c.alpha = source.alpha\n\treturn c\n}\n\nlet lmsToLinear: Matrix | undefined\nlet linearToLms: Matrix | undefined\n// The gamma-space tolerance of 1e-6 on each side, as a linear one: the transfer curve is monotone.\nconst LOW = -1e-6 / 12.92\nconst HIGH = ((1 + 1e-6 + 0.055) / 1.055) ** 2.4\n\n// A clipped channel of exactly 0 or 1 stays exactly that, as clipping after the curve gives.\nconst encode = (n: number): number => (n === 0 || n === 1 ? n : srgbToGamma(n))\nconst clamp01 = (n: number): number => Math.min(1, Math.max(0, n))\n\n/**\n * The CSS Color 4 section 13.2 search of `toGamut` for the `srgb` gamut, done in\n * linear sRGB so the loop has no hub conversion, `**` or trigonometry. Clipping\n * to 0 to 1 commutes with the monotone transfer curve, so it finds what the\n * generic path finds, up to rounding. Returns the mapped color in `srgb`.\n */\nfunction reduceChromaInSrgb(origin: Color, lightness: number, chroma: number, hue: Component): Color {\n\t// Composed on first use, so a bundle without this path does not pay for them at load.\n\tconst m = (lmsToLinear ??= product(xyzToSrgb, lmsToXyz))\n\tconst n = (linearToLms ??= product(xyzToLms, srgbToXyz))\n\tconst o = oklabToLms\n\tconst k = lmsToOklab\n\t// A `none` hue or chroma reads as 0, as it does in a conversion. A `none` lightness never gets here.\n\tconst l = lightness\n\tconst radians = ((hue ?? 0) * Math.PI) / 180\n\tconst cos = Math.cos(radians)\n\tconst sin = Math.sin(radians)\n\tlet r = 0\n\tlet g = 0\n\tlet b = 0\n\tlet inside = false\n\t/** Puts the candidate of chroma `c` in linear sRGB into r, g, b (unclipped), and says if it is within the gamut. */\n\tconst place = (c: number): void => {\n\t\tconst a = c * cos\n\t\tconst bb = c * sin\n\t\tconst x = l + o[1] * a + o[2] * bb\n\t\tconst y = l + o[4] * a + o[5] * bb\n\t\tconst z = l + o[7] * a + o[8] * bb\n\t\tconst x3 = x * x * x\n\t\tconst y3 = y * y * y\n\t\tconst z3 = z * z * z\n\t\tr = m[0] * x3 + m[1] * y3 + m[2] * z3\n\t\tg = m[3] * x3 + m[4] * y3 + m[5] * z3\n\t\tb = m[6] * x3 + m[7] * y3 + m[8] * z3\n\t\tinside = r >= LOW && r <= HIGH && g >= LOW && g <= HIGH && b >= LOW && b <= HIGH\n\t}\n\t/** Clips r, g, b and returns its ΔEOK to the candidate of chroma `c`. */\n\tconst clipAndMeasure = (c: number): number => {\n\t\tr = clamp01(r)\n\t\tg = clamp01(g)\n\t\tb = clamp01(b)\n\t\tconst x = Math.cbrt(n[0] * r + n[1] * g + n[2] * b)\n\t\tconst y = Math.cbrt(n[3] * r + n[4] * g + n[5] * b)\n\t\tconst z = Math.cbrt(n[6] * r + n[7] * g + n[8] * b)\n\t\tconst dl = k[0] * x + k[1] * y + k[2] * z - l\n\t\tconst da = k[3] * x + k[4] * y + k[5] * z - c * cos\n\t\tconst db = k[6] * x + k[7] * y + k[8] * z - c * sin\n\t\treturn Math.sqrt(dl * dl + da * da + db * db)\n\t}\n\tconst JND = 0.02\n\tconst EPSILON = 0.0001\n\tlet min = 0\n\tlet max = chroma\n\tlet minInGamut = true\n\tplace(chroma ?? 0)\n\tlet clip: Vec3\n\tlet e = clipAndMeasure(chroma ?? 0)\n\tclip = [r, g, b]\n\tif (e >= JND) {\n\t\twhile (max - min > EPSILON) {\n\t\t\tconst mid = (min + max) / 2\n\t\t\tplace(mid)\n\t\t\tif (minInGamut && inside) {\n\t\t\t\tmin = mid\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\te = clipAndMeasure(mid)\n\t\t\tclip = [r, g, b]\n\t\t\tif (e < JND) {\n\t\t\t\tif (JND - e < EPSILON) break\n\t\t\t\tminInGamut = false\n\t\t\t\tmin = mid\n\t\t\t} else {\n\t\t\t\tmax = mid\n\t\t\t}\n\t\t}\n\t}\n\treturn withAlpha({ colorSpace: 'srgb', components: clip.map(encode) }, origin)\n}\n","// The 148 CSS named colors (CSS Color 4 section 6.1), as `name:rrggbb` pairs.\nconst DATA =\n\t'aliceblue:f0f8ff,antiquewhite:faebd7,aqua:00ffff,aquamarine:7fffd4,azure:f0ffff,beige:f5f5dc,bisque:ffe4c4,black:000000,blanchedalmond:ffebcd,blue:0000ff,blueviolet:8a2be2,brown:a52a2a,burlywood:deb887,cadetblue:5f9ea0,chartreuse:7fff00,chocolate:d2691e,coral:ff7f50,cornflowerblue:6495ed,cornsilk:fff8dc,crimson:dc143c,cyan:00ffff,darkblue:00008b,darkcyan:008b8b,darkgoldenrod:b8860b,darkgray:a9a9a9,darkgreen:006400,darkgrey:a9a9a9,darkkhaki:bdb76b,darkmagenta:8b008b,darkolivegreen:556b2f,darkorange:ff8c00,darkorchid:9932cc,darkred:8b0000,darksalmon:e9967a,darkseagreen:8fbc8f,darkslateblue:483d8b,darkslategray:2f4f4f,darkslategrey:2f4f4f,darkturquoise:00ced1,darkviolet:9400d3,deeppink:ff1493,deepskyblue:00bfff,dimgray:696969,dimgrey:696969,dodgerblue:1e90ff,firebrick:b22222,floralwhite:fffaf0,forestgreen:228b22,fuchsia:ff00ff,gainsboro:dcdcdc,ghostwhite:f8f8ff,gold:ffd700,goldenrod:daa520,gray:808080,green:008000,greenyellow:adff2f,grey:808080,honeydew:f0fff0,hotpink:ff69b4,indianred:cd5c5c,indigo:4b0082,ivory:fffff0,khaki:f0e68c,lavender:e6e6fa,lavenderblush:fff0f5,lawngreen:7cfc00,lemonchiffon:fffacd,lightblue:add8e6,lightcoral:f08080,lightcyan:e0ffff,lightgoldenrodyellow:fafad2,lightgray:d3d3d3,lightgreen:90ee90,lightgrey:d3d3d3,lightpink:ffb6c1,lightsalmon:ffa07a,lightseagreen:20b2aa,lightskyblue:87cefa,lightslategray:778899,lightslategrey:778899,lightsteelblue:b0c4de,lightyellow:ffffe0,lime:00ff00,limegreen:32cd32,linen:faf0e6,magenta:ff00ff,maroon:800000,mediumaquamarine:66cdaa,mediumblue:0000cd,mediumorchid:ba55d3,mediumpurple:9370db,mediumseagreen:3cb371,mediumslateblue:7b68ee,mediumspringgreen:00fa9a,mediumturquoise:48d1cc,mediumvioletred:c71585,midnightblue:191970,mintcream:f5fffa,mistyrose:ffe4e1,moccasin:ffe4b5,navajowhite:ffdead,navy:000080,oldlace:fdf5e6,olive:808000,olivedrab:6b8e23,orange:ffa500,orangered:ff4500,orchid:da70d6,palegoldenrod:eee8aa,palegreen:98fb98,paleturquoise:afeeee,palevioletred:db7093,papayawhip:ffefd5,peachpuff:ffdab9,peru:cd853f,pink:ffc0cb,plum:dda0dd,powderblue:b0e0e6,purple:800080,rebeccapurple:663399,red:ff0000,rosybrown:bc8f8f,royalblue:4169e1,saddlebrown:8b4513,salmon:fa8072,sandybrown:f4a460,seagreen:2e8b57,seashell:fff5ee,sienna:a0522d,silver:c0c0c0,skyblue:87ceeb,slateblue:6a5acd,slategray:708090,slategrey:708090,snow:fffafa,springgreen:00ff7f,steelblue:4682b4,tan:d2b48c,teal:008080,thistle:d8bfd8,tomato:ff6347,turquoise:40e0d0,violet:ee82ee,wheat:f5deb3,white:ffffff,whitesmoke:f5f5f5,yellow:ffff00,yellowgreen:9acd32'\n\nlet table: Map<string, number> | undefined\n\n/** The 0xRRGGBB value of a CSS named color, or undefined. Built on first use. */\nexport function namedColor(name: string): number | undefined {\n\ttable ??= new Map(\n\t\tDATA.split(',').map((p) => [p.slice(0, p.indexOf(':')), Number.parseInt(p.slice(p.indexOf(':') + 1), 16)])\n\t)\n\treturn table.get(name)\n}\n","import { namedColor } from './named.js'\nimport type { Color, ColorSpaceId, Component } from './types.js'\n\nexport const NUMBER = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?/\n// Tables keyed by text a caller wrote have no prototype (`__proto__: null`), so `constructor` or `toString` is an unknown name, not Object.prototype's.\nexport const UNITS: Record<string, number> = {\n\t__proto__: null as never,\n\t'': 1,\n\tdeg: 1,\n\tgrad: 0.9,\n\trad: 180 / Math.PI,\n\tturn: 360\n}\n\n/** How one channel reads: what 100% means, and the allowed range. */\nexport interface Channel {\n\t/** The value of 100%. Also the factor applied to a plain number, usually 1. */\n\tpct: number\n\t/** A plain number is divided by this (255 for sRGB channels). */\n\tdiv?: number\n\tmin?: number\n\tmax?: number\n\thue?: boolean\n}\n\nexport function fail(input: string, what: string, token?: string): never {\n\tthrow new Error(`color-map: cannot parse \"${input}\": ${what}${token === undefined ? '' : ` \"${token}\"`}`)\n}\n\nexport function channel(token: string, spec: Channel, input: string): Component {\n\tif (token === 'none') return null\n\tconst m = NUMBER.exec(token)\n\tif (!m) return fail(input, 'invalid value', token)\n\tconst n = Number(m[0])\n\tconst rest = token.slice(m[0].length)\n\tlet value: number\n\tif (spec.hue) {\n\t\tconst unit = UNITS[rest]\n\t\tif (unit === undefined) return fail(input, 'invalid angle', token)\n\t\treturn n * unit\n\t}\n\tif (rest === '%') value = (n * spec.pct) / 100\n\telse if (rest === '') value = n / (spec.div ?? 1)\n\telse return fail(input, 'invalid value', token)\n\treturn Math.min(spec.max ?? Number.POSITIVE_INFINITY, Math.max(spec.min ?? Number.NEGATIVE_INFINITY, value))\n}\n\nexport const SRGB: Channel = { pct: 1, div: 255 }\nconst PCT100: Channel = { pct: 100, min: 0 }\nexport const UNIT: Channel = { pct: 1 }\nexport const ALPHA: Channel = { pct: 1, min: 0, max: 1 }\nconst HUE: Channel = { pct: 0, hue: true }\n\nexport const FUNCTIONS: Record<string, { space: ColorSpaceId; channels: [Channel, Channel, Channel] }> = {\n\t__proto__: null as never,\n\trgb: { space: 'srgb', channels: [SRGB, SRGB, SRGB] },\n\thsl: { space: 'hsl', channels: [HUE, PCT100, PCT100] },\n\thwb: { space: 'hwb', channels: [HUE, PCT100, PCT100] },\n\tlab: { space: 'lab', channels: [{ pct: 100, min: 0, max: 100 }, { pct: 125 }, { pct: 125 }] },\n\tlch: { space: 'lch', channels: [{ pct: 100, min: 0, max: 100 }, { pct: 150, min: 0 }, HUE] },\n\toklab: { space: 'oklab', channels: [{ pct: 1, min: 0, max: 1 }, { pct: 0.4 }, { pct: 0.4 }] },\n\toklch: { space: 'oklch', channels: [{ pct: 1, min: 0, max: 1 }, { pct: 0.4, min: 0 }, HUE] }\n}\n\n/** The spaces `color()` names, by the name it uses: their own, and `xyz` for `xyz-d65`. */\nexport const COLOR_SPACES: Record<string, ColorSpaceId> = { __proto__: null as never, xyz: 'xyz-d65' }\nfor (const id of [\n\t'srgb',\n\t'srgb-linear',\n\t'display-p3',\n\t'display-p3-linear',\n\t'a98-rgb',\n\t'prophoto-rgb',\n\t'rec2020',\n\t'xyz-d50',\n\t'xyz-d65'\n] as const)\n\tCOLOR_SPACES[id] = id\n\n/** `currentcolor` and the CSS Color 4 system colors (canvas, canvastext, linktext, buttonface, ...). */\nexport const VALUES_NEEDING_RESOLVE =\n\t/^(?:currentcolor|(?:canvas|field|highlight|selecteditem|mark|accentcolor)(?:text)?|(?:link|visited|active|button|gray)text|button(?:face|border))$/\n\nfunction hex(input: string): Color {\n\tconst digits = input.slice(1)\n\tif (!/^(?:[\\da-f]{3,4}|[\\da-f]{6}|[\\da-f]{8})$/.test(digits)) return fail(input, 'invalid hex color')\n\tconst full = digits.length < 5 ? [...digits].map((d) => d + d).join('') : digits\n\tconst byte = (i: number): number => Number.parseInt(full.slice(i * 2, i * 2 + 2), 16) / 255\n\tconst color: Color = { colorSpace: 'srgb', components: [byte(0), byte(1), byte(2)] }\n\tif (full.length === 8) color.alpha = byte(3)\n\treturn color\n}\n\nconst ALIASES: Record<string, string> = { __proto__: null as never, rgba: 'rgb', hsla: 'hsl' }\n\nfunction functional(rawName: string, body: string, input: string): Color {\n\tconst name = ALIASES[rawName] ?? rawName\n\tconst [main, alphaToken, ...extra] = body.split('/').map((s) => s.trim())\n\tif (extra.length > 0) return fail(input, 'more than one \"/\"')\n\tconst legacy = main.includes(',')\n\tconst tokens = (legacy ? main.split(',') : main.split(/\\s+/)).map((s) => s.trim()).filter(Boolean)\n\tlet alpha = alphaToken\n\tif (legacy) {\n\t\tif (name !== 'rgb' && name !== 'hsl') return fail(input, 'the comma syntax is only for rgb() and hsl()')\n\t\tif (alpha !== undefined) return fail(input, 'cannot mix \",\" and \"/\"')\n\t\tif (tokens.length === 4) alpha = tokens.pop() as string\n\t\tif (tokens.includes('none')) return fail(input, '\"none\" is not allowed in the comma syntax')\n\t}\n\tlet space: ColorSpaceId\n\tlet channels: [Channel, Channel, Channel]\n\tif (name === 'color') {\n\t\tconst id = COLOR_SPACES[tokens.shift() ?? '']\n\t\tif (!id) return fail(input, 'unknown color space', main.split(/\\s+/)[0])\n\t\tspace = id\n\t\tchannels = [UNIT, UNIT, UNIT]\n\t} else {\n\t\tconst fn = FUNCTIONS[name]\n\t\tif (!fn) return fail(input, 'unknown function', rawName)\n\t\t;({ space, channels } = fn)\n\t}\n\tif (tokens.length !== 3) return fail(input, `expected 3 components, got ${tokens.length}`)\n\tif (legacy) {\n\t\tconst percents = tokens.map((t) => t.endsWith('%'))\n\t\tconst ok = space === 'hsl' ? !percents[0] && percents[1] && percents[2] : percents.every((p) => p === percents[0])\n\t\tif (!ok) return fail(input, 'mixed numbers and percentages', tokens.join(', '))\n\t}\n\tconst color: Color = {\n\t\tcolorSpace: space,\n\t\tcomponents: tokens.map((t, i) => channel(t, channels[i], input))\n\t}\n\tif (alpha !== undefined) color.alpha = channel(alpha, ALPHA, input)\n\treturn color\n}\n\n/**\n * Parses a CSS Color 4 color: hex, named colors, `transparent`, `rgb()`,\n * `hsl()`, `hwb()`, `lab()`, `lch()`, `oklab()`, `oklch()` and `color()`.\n * `none` becomes `null`. Values that need a context (`currentcolor`, system\n * colors) throw, because nothing here can resolve them.\n */\nexport function parse(input: string): Color {\n\tconst text = input.trim().toLowerCase()\n\treturn scan(text) ?? parseGeneric(input, text)\n}\n\n/**\n * The regex-based parser: every accepted form, and every error message. `parse`\n * tries {@link scan} first, which takes only the plain valid forms and leaves\n * the rest, including every error, to this.\n */\nexport function parseGeneric(input: string, text: string): Color {\n\tif (text.startsWith('#')) return hex(text)\n\tconst fn = /^([a-z]+)\\((.*)\\)$/s.exec(text)\n\tif (fn) return functional(fn[1], fn[2], input)\n\tif (text === 'transparent') return { colorSpace: 'srgb', components: [0, 0, 0], alpha: 0 }\n\tconst named = namedColor(text)\n\tif (named !== undefined) {\n\t\treturn { colorSpace: 'srgb', components: [(named >> 16) / 255, ((named >> 8) & 255) / 255, (named & 255) / 255] }\n\t}\n\tif (VALUES_NEEDING_RESOLVE.test(text)) return fail(input, 'needs a context to resolve', text)\n\treturn fail(input, 'not a color')\n}\n\n/** A color as given, or parsed with {@link parse} when it is a string. */\nexport const toColor = (c: Color | string): Color => (typeof c === 'string' ? parse(c) : c)\n\n// --- The scanner: a char-code fast path for hex and the functional forms ---\n\nconst isSpace = (c: number): boolean => c === 32 || c === 9 || c === 10 || c === 13 || c === 12\nconst isDigit = (c: number): boolean => c >= 48 && c <= 57\nconst hexValue = (c: number): number => (c >= 48 && c <= 57 ? c - 48 : c >= 97 && c <= 102 ? c - 87 : -1)\n\n// Scanner state, shared across calls: `parse` is synchronous and does not re-enter.\nlet at = 0\nlet percent = false\n\nfunction scanHex(text: string): Color | undefined {\n\tconst len = text.length\n\tif (len !== 4 && len !== 5 && len !== 7 && len !== 9) return undefined\n\tconst short = len < 6\n\tconst count = short ? len - 1 : (len - 1) / 2\n\tconst bytes: number[] = []\n\tfor (let i = 0; i < count; i++) {\n\t\tlet value: number\n\t\tif (short) {\n\t\t\tconst d = hexValue(text.charCodeAt(1 + i))\n\t\t\tvalue = d * 17\n\t\t\tif (d < 0) return undefined\n\t\t} else {\n\t\t\tconst hi = hexValue(text.charCodeAt(1 + i * 2))\n\t\t\tconst lo = hexValue(text.charCodeAt(2 + i * 2))\n\t\t\tif (hi < 0 || lo < 0) return undefined\n\t\t\tvalue = hi * 16 + lo\n\t\t}\n\t\tbytes.push(value / 255)\n\t}\n\tconst color: Color = { colorSpace: 'srgb', components: [bytes[0], bytes[1], bytes[2]] }\n\tif (count === 4) color.alpha = bytes[3]\n\treturn color\n}\n\n/** Skips whitespace from `at` up to `end`. */\nfunction skip(text: string, end: number): void {\n\twhile (at < end && isSpace(text.charCodeAt(at))) at++\n}\n\n/** The end of the token that starts at `at`: it runs to whitespace, a comma, a slash or `end`. */\nfunction tokenEnd(text: string, end: number): number {\n\tlet j = at\n\twhile (j < end) {\n\t\tconst c = text.charCodeAt(j)\n\t\tif (isSpace(c) || c === 44 || c === 47) break\n\t\tj++\n\t}\n\treturn j\n}\n\n/**\n * Reads the token at `at` as {@link channel} would, or returns `undefined` when\n * it is anything but a plain valid one. Leaves `at` after the token.\n */\nfunction scanChannel(text: string, end: number, spec: Channel): Component | undefined {\n\tconst s = at\n\tconst e = tokenEnd(text, end)\n\tat = e\n\tif (e === s) return undefined\n\tif (e - s === 4 && text.startsWith('none', s)) return null\n\tlet j = s\n\tlet c = text.charCodeAt(j)\n\tif (c === 43 || c === 45) c = text.charCodeAt(++j)\n\tlet digits = 0\n\twhile (isDigit(c)) {\n\t\tc = text.charCodeAt(++j)\n\t\tdigits++\n\t}\n\tif (c === 46) {\n\t\tc = text.charCodeAt(++j)\n\t\twhile (isDigit(c)) {\n\t\t\tc = text.charCodeAt(++j)\n\t\t\tdigits++\n\t\t}\n\t}\n\tif (digits === 0) return undefined\n\tif (c === 101) {\n\t\tlet k = j + 1\n\t\tlet x = text.charCodeAt(k)\n\t\tif (x === 43 || x === 45) x = text.charCodeAt(++k)\n\t\tif (isDigit(x)) {\n\t\t\twhile (isDigit(text.charCodeAt(k))) k++\n\t\t\tj = k\n\t\t}\n\t}\n\tconst n = Number(text.slice(s, j))\n\tif (spec.hue) {\n\t\tconst unit = j === e ? 1 : UNITS[text.slice(j, e)]\n\t\treturn unit === undefined ? undefined : n * unit\n\t}\n\tlet value: number\n\tif (j === e) value = n / (spec.div ?? 1)\n\telse if (e - j === 1 && text.charCodeAt(j) === 37) {\n\t\tpercent = true\n\t\tvalue = (n * spec.pct) / 100\n\t} else return undefined\n\treturn Math.min(spec.max ?? Number.POSITIVE_INFINITY, Math.max(spec.min ?? Number.NEGATIVE_INFINITY, value))\n}\n\n/**\n * Parses the plain valid forms (hex, and the comma or space forms of the\n * functions) by char code, with no regex, split or per-token array. Anything\n * else returns `undefined`, so that {@link parseGeneric} handles it and says\n * why it is wrong.\n */\nfunction scan(text: string): Color | undefined {\n\tif (text.charCodeAt(0) === 35) return scanHex(text)\n\tconst end = text.length - 1\n\tif (text.charCodeAt(end) !== 41) return undefined\n\tlet open = 0\n\twhile (open < end) {\n\t\tconst c = text.charCodeAt(open)\n\t\tif (c < 97 || c > 122) break\n\t\topen++\n\t}\n\tif (open === 0 || text.charCodeAt(open) !== 40) return undefined\n\tconst rawName = text.slice(0, open)\n\tconst name = ALIASES[rawName] ?? rawName\n\tlet space: ColorSpaceId\n\tlet channels: [Channel, Channel, Channel]\n\tat = open + 1\n\tskip(text, end)\n\tif (name === 'color') {\n\t\tconst s = at\n\t\twhile (at < end && !isSpace(text.charCodeAt(at))) at++\n\t\tconst id = COLOR_SPACES[text.slice(s, at)]\n\t\tif (!id) return undefined\n\t\tspace = id\n\t\tchannels = [UNIT, UNIT, UNIT]\n\t\tskip(text, end)\n\t} else {\n\t\tconst fn = FUNCTIONS[name]\n\t\tif (!fn) return undefined\n\t\t;({ space, channels } = fn)\n\t}\n\tpercent = false\n\tconst c0 = scanChannel(text, end, channels[0])\n\tif (c0 === undefined) return undefined\n\tconst p0 = percent\n\tskip(text, end)\n\tconst comma = text.charCodeAt(at) === 44\n\tif (comma && name !== 'rgb' && name !== 'hsl') return undefined\n\tlet alpha: Component | undefined\n\tlet c1: Component | undefined\n\tlet c2: Component | undefined\n\tlet p1 = false\n\tlet p2 = false\n\tif (comma) {\n\t\tat++\n\t\tskip(text, end)\n\t\tpercent = false\n\t\tc1 = scanChannel(text, end, channels[1])\n\t\tp1 = percent\n\t\tskip(text, end)\n\t\tif (text.charCodeAt(at++) !== 44) return undefined\n\t\tskip(text, end)\n\t\tpercent = false\n\t\tc2 = scanChannel(text, end, channels[2])\n\t\tp2 = percent\n\t\tskip(text, end)\n\t\tif (c0 === null || c1 === undefined || c1 === null || c2 === undefined || c2 === null) return undefined\n\t\tconst ok = space === 'hsl' ? !p0 && p1 && p2 : p0 === p1 && p1 === p2\n\t\tif (!ok) return undefined\n\t\tif (at < end) {\n\t\t\tif (text.charCodeAt(at++) !== 44) return undefined\n\t\t\tskip(text, end)\n\t\t\talpha = scanChannel(text, end, ALPHA)\n\t\t\tif (alpha === undefined || alpha === null) return undefined\n\t\t\tskip(text, end)\n\t\t}\n\t} else {\n\t\tc1 = scanChannel(text, end, channels[1])\n\t\tskip(text, end)\n\t\tc2 = scanChannel(text, end, channels[2])\n\t\tskip(text, end)\n\t\tif (at < end) {\n\t\t\tif (text.charCodeAt(at++) !== 47) return undefined\n\t\t\tskip(text, end)\n\t\t\talpha = scanChannel(text, end, ALPHA)\n\t\t\tif (alpha === undefined) return undefined\n\t\t\tskip(text, end)\n\t\t}\n\t}\n\tif (at !== end || c1 === undefined || c2 === undefined) return undefined\n\tconst color: Color = { colorSpace: space, components: [c0, c1, c2] }\n\tif (alpha !== undefined) color.alpha = alpha\n\treturn color\n}\n"],"mappings":";AAKA,MAAa,YAAoB;CAChC,SAAS;CAAS,QAAQ;CAAQ,QAAQ;CAC1C,QAAQ;CAAQ,SAAS;CAAQ,QAAQ;CACzC,OAAO;CAAQ,QAAQ;CAAQ,UAAU;AAC1C;AACA,MAAa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;GAAI;GAAI;EAAE;CAAE;CACnE,IAAI,UAAU,KAAA,GAAW,MAAM,QAAQ;CACvC,OAAO;AACR"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as toneColor, c as createScale, d as createGradient, f as ContrastScaleOptions, g as scaleFromBrand, h as BrandScaleOptions, i as tonalPalette, l as GradientOptions, m as createContrastScale, n as TonalPaletteOptions, o as ScaleOptions, p as ContrastStep, r as lstar, s as ScalePreset, t as MATERIAL_TONES, u as GradientStop } from "../index-BcEqCPHz.js";
|
|
2
|
+
export { type BrandScaleOptions, type ContrastScaleOptions, type ContrastStep, type GradientOptions, type GradientStop, MATERIAL_TONES, type ScaleOptions, type ScalePreset, type TonalPaletteOptions, createContrastScale, createGradient, createScale, lstar, scaleFromBrand, tonalPalette, toneColor };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_tone = require("../tone-BAhu-QzQ.js");
|
|
3
|
+
const require_scale = require("../scale-Cq9pXrc1.js");
|
|
4
|
+
exports.MATERIAL_TONES = require_tone.MATERIAL_TONES;
|
|
5
|
+
exports.createContrastScale = require_scale.createContrastScale;
|
|
6
|
+
exports.createGradient = require_scale.createGradient;
|
|
7
|
+
exports.createScale = require_scale.createScale;
|
|
8
|
+
exports.lstar = require_tone.lstar;
|
|
9
|
+
exports.scaleFromBrand = require_scale.scaleFromBrand;
|
|
10
|
+
exports.tonalPalette = require_tone.tonalPalette;
|
|
11
|
+
exports.toneColor = require_tone.toneColor;
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
const require_parse = require("./parse-8mt2OMKf.js");
|
|
2
|
+
const require_contrast = require("./contrast-XjF5Rwui.js");
|
|
3
|
+
const require_mix = require("./mix-Cs4owSbW.js");
|
|
4
|
+
const require_tone = require("./tone-BAhu-QzQ.js");
|
|
5
|
+
// src/scale/brand.ts
|
|
6
|
+
const LIGHT_PROGRESS = [
|
|
7
|
+
0,
|
|
8
|
+
.0376,
|
|
9
|
+
.1,
|
|
10
|
+
.1796,
|
|
11
|
+
.2606,
|
|
12
|
+
.3466,
|
|
13
|
+
.4656,
|
|
14
|
+
.6312,
|
|
15
|
+
1
|
|
16
|
+
];
|
|
17
|
+
const CHROMA = [
|
|
18
|
+
.04,
|
|
19
|
+
.08,
|
|
20
|
+
.2,
|
|
21
|
+
.32,
|
|
22
|
+
.43,
|
|
23
|
+
.52,
|
|
24
|
+
.6,
|
|
25
|
+
.75
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* A 12-step UI scale from one brand color, after Radix's palette generator:
|
|
29
|
+
* the brand color is step 9 exactly (returned as given, never remapped), steps
|
|
30
|
+
* 1 to 8 run from the background to it, step 10 is its hover state, and steps
|
|
31
|
+
* 11 and 12 are low- and high-contrast text. Hue is the brand's throughout.
|
|
32
|
+
* Radix's generator also borrows the shape of the nearest of its hand-tuned
|
|
33
|
+
* scales; this one uses a single fixed shape instead.
|
|
34
|
+
*/
|
|
35
|
+
function scaleFromBrand(brand, options = {}) {
|
|
36
|
+
const { mode = "light", gamut = "srgb" } = options;
|
|
37
|
+
const dark = require_parse.checkMode(mode) === "dark";
|
|
38
|
+
const exact = require_parse.toColor(brand);
|
|
39
|
+
const [l9, c9, h9] = require_parse.componentsIn(exact, "oklch");
|
|
40
|
+
const hue = h9 ?? 0;
|
|
41
|
+
const bg = options.background;
|
|
42
|
+
const l1 = bg ? require_parse.componentsIn(require_parse.toColor(bg), "oklch")[0] : dark ? .18 : .992;
|
|
43
|
+
const step = (l, c) => require_parse.toGamut({
|
|
44
|
+
colorSpace: "oklch",
|
|
45
|
+
components: [
|
|
46
|
+
l,
|
|
47
|
+
c,
|
|
48
|
+
hue
|
|
49
|
+
]
|
|
50
|
+
}, { gamut });
|
|
51
|
+
const out = [];
|
|
52
|
+
for (let i = 0; i < 8; i++) out.push(step(l1 + (l9 - l1) * LIGHT_PROGRESS[i], c9 * CHROMA[i]));
|
|
53
|
+
out.push(exact);
|
|
54
|
+
const hover = .03 / (l9 + .1);
|
|
55
|
+
out.push(step(dark ? l9 + hover : l9 - hover, c9 * .93));
|
|
56
|
+
const c8 = c9 * CHROMA[7];
|
|
57
|
+
out.push(step(dark ? .78 : .5, Math.min(c9 * .9, Math.max(c8, c9))));
|
|
58
|
+
out.push(step(dark ? .93 : .3, Math.min(c9 * .35, Math.max(c8, c9))));
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
// src/scale/contrast-scale.ts
|
|
62
|
+
/**
|
|
63
|
+
* A Leonardo-style scale: each step is the color nearest the background's
|
|
64
|
+
* lightness, at the seed's hue and chroma, that reaches its target contrast.
|
|
65
|
+
* Contrast is the same across hues, which a fixed-lightness scale cannot give.
|
|
66
|
+
*/
|
|
67
|
+
function createContrastScale(options) {
|
|
68
|
+
const { seed, background, targets, contrast, direction } = options;
|
|
69
|
+
const [, chroma, hue] = require_parse.componentsIn(require_parse.toColor(seed), "oklch");
|
|
70
|
+
return (Array.isArray(targets) ? targets.map((t, i) => [String(i), t]) : Object.entries(targets)).map(([name, target]) => ({
|
|
71
|
+
name,
|
|
72
|
+
target,
|
|
73
|
+
...require_contrast.findContrast(background, target, {
|
|
74
|
+
hue: hue ?? 0,
|
|
75
|
+
chroma,
|
|
76
|
+
contrast,
|
|
77
|
+
direction
|
|
78
|
+
})
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
// src/scale/gradient.ts
|
|
82
|
+
/**
|
|
83
|
+
* Places each stop the way CSS gradients do (CSS Images 3 section 3.5.3): a
|
|
84
|
+
* first stop without a position goes at 0 and a last one at 1, a position
|
|
85
|
+
* before an earlier stop's moves up to it, and a run of stops without a
|
|
86
|
+
* position spreads evenly between the stops around it.
|
|
87
|
+
*/
|
|
88
|
+
function positions(stops) {
|
|
89
|
+
const n = stops.length;
|
|
90
|
+
const at = stops.map((s, i) => {
|
|
91
|
+
if (s.at !== void 0 && !Number.isFinite(s.at)) throw new Error(`stop ${i} has a position of ${s.at}`);
|
|
92
|
+
return s.at;
|
|
93
|
+
});
|
|
94
|
+
if (at[0] === void 0) at[0] = 0;
|
|
95
|
+
if (at[n - 1] === void 0) at[n - 1] = 1;
|
|
96
|
+
let max = Number.NEGATIVE_INFINITY;
|
|
97
|
+
for (let i = 0; i < n; i++) {
|
|
98
|
+
const p = at[i];
|
|
99
|
+
if (p !== void 0) at[i] = max = Math.max(max, p);
|
|
100
|
+
}
|
|
101
|
+
for (let i = 1; i < n; i++) {
|
|
102
|
+
if (at[i] !== void 0) continue;
|
|
103
|
+
let j = i;
|
|
104
|
+
while (at[j] === void 0) j++;
|
|
105
|
+
const from = at[i - 1];
|
|
106
|
+
const step = (at[j] - from) / (j - i + 1);
|
|
107
|
+
for (let k = i; k < j; k++) at[k] = from + step * (k - i + 1);
|
|
108
|
+
}
|
|
109
|
+
return at;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Builds `count` colors, evenly spaced from 0 to 1 along a gradient through
|
|
113
|
+
* `stops`, the way a CSS gradient blends them: each pair of neighboring stops
|
|
114
|
+
* is mixed with `mix()`, so `in` and `hue` work as they do there. A stop is
|
|
115
|
+
* `{ color, at? }`, or a bare color when it needs no position. Before the
|
|
116
|
+
* first stop and after the last, the color holds; where two stops share a
|
|
117
|
+
* position, the color changes there and the sample at that position takes the
|
|
118
|
+
* later stop. Colors come back in the `in` space, default `oklab`.
|
|
119
|
+
*
|
|
120
|
+
* Alpha comes from each stop's color, 1 when the color has none, so
|
|
121
|
+
* `rgb(0 0 255 / 0.2)` is a stop at alpha 0.2. Alpha is interpolated linearly
|
|
122
|
+
* between stops, and the other components are premultiplied by it, so a
|
|
123
|
+
* transparent stop does not pull its neighbor's color toward its own. A color
|
|
124
|
+
* whose alpha is 1 has no `alpha` key; a `none` alpha takes the neighboring
|
|
125
|
+
* stop's.
|
|
126
|
+
*
|
|
127
|
+
* ```ts
|
|
128
|
+
* createGradient([{ color: 'blue', at: 0 }, { color: 'lime', at: 0.6 }, { color: 'yellow', at: 1 }], 72)
|
|
129
|
+
* createGradient(['blue', 'lime'], 5, { in: 'oklch' })
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
function createGradient(stops, count, options = {}) {
|
|
133
|
+
if (stops.length < 2) throw new Error(`a gradient needs at least 2 stops, got ${stops.length}`);
|
|
134
|
+
if (!Number.isInteger(count) || count < 2) throw new Error(`count must be an integer of at least 2, got ${count}`);
|
|
135
|
+
const list = stops.map((s) => typeof s === "string" || "colorSpace" in s ? { color: s } : s);
|
|
136
|
+
const colors = list.map((s) => require_parse.toColor(s.color));
|
|
137
|
+
const at = positions(list);
|
|
138
|
+
const last = list.length - 2;
|
|
139
|
+
return Array.from({ length: count }, (_, i) => {
|
|
140
|
+
const t = i / (count - 1);
|
|
141
|
+
let s = 0;
|
|
142
|
+
while (s < last && at[s + 1] <= t) s++;
|
|
143
|
+
const from = at[s];
|
|
144
|
+
const width = at[s + 1] - from;
|
|
145
|
+
const local = width > 0 ? Math.min(1, Math.max(0, (t - from) / width)) : t < from ? 0 : 1;
|
|
146
|
+
return require_mix.mix(colors[s], colors[s + 1], local, options);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// src/scale/scale.ts
|
|
150
|
+
const TW_L = [
|
|
151
|
+
.97,
|
|
152
|
+
.932,
|
|
153
|
+
.882,
|
|
154
|
+
.809,
|
|
155
|
+
.707,
|
|
156
|
+
.623,
|
|
157
|
+
.546,
|
|
158
|
+
.488,
|
|
159
|
+
.424,
|
|
160
|
+
.379,
|
|
161
|
+
.282
|
|
162
|
+
];
|
|
163
|
+
const TW_C = [
|
|
164
|
+
.014,
|
|
165
|
+
.032,
|
|
166
|
+
.059,
|
|
167
|
+
.105,
|
|
168
|
+
.165,
|
|
169
|
+
.214,
|
|
170
|
+
.245,
|
|
171
|
+
.243,
|
|
172
|
+
.199,
|
|
173
|
+
.146,
|
|
174
|
+
.091
|
|
175
|
+
];
|
|
176
|
+
const TW_H = [
|
|
177
|
+
254.604,
|
|
178
|
+
255.585,
|
|
179
|
+
254.128,
|
|
180
|
+
251.813,
|
|
181
|
+
254.624,
|
|
182
|
+
259.815,
|
|
183
|
+
262.881,
|
|
184
|
+
264.376,
|
|
185
|
+
265.638,
|
|
186
|
+
265.522,
|
|
187
|
+
267.935
|
|
188
|
+
];
|
|
189
|
+
const RADIX_L = [
|
|
190
|
+
.992,
|
|
191
|
+
.978,
|
|
192
|
+
.953,
|
|
193
|
+
.925,
|
|
194
|
+
.894,
|
|
195
|
+
.857,
|
|
196
|
+
.81,
|
|
197
|
+
.745,
|
|
198
|
+
.62,
|
|
199
|
+
.585,
|
|
200
|
+
.52,
|
|
201
|
+
.32
|
|
202
|
+
];
|
|
203
|
+
const RADIX_C = [
|
|
204
|
+
.04,
|
|
205
|
+
.08,
|
|
206
|
+
.2,
|
|
207
|
+
.32,
|
|
208
|
+
.43,
|
|
209
|
+
.52,
|
|
210
|
+
.6,
|
|
211
|
+
.75,
|
|
212
|
+
1,
|
|
213
|
+
.95,
|
|
214
|
+
.9,
|
|
215
|
+
.35
|
|
216
|
+
];
|
|
217
|
+
function even(n) {
|
|
218
|
+
const t = (i) => i / (n - 1);
|
|
219
|
+
const bell = (i) => Math.sin(Math.PI * (.05 + .9 * t(i)));
|
|
220
|
+
const anchor = Math.round((n - 1) / 2);
|
|
221
|
+
return {
|
|
222
|
+
lightness: Array.from({ length: n }, (_, i) => .97 - .72 * t(i)),
|
|
223
|
+
chroma: Array.from({ length: n }, (_, i) => bell(i) / bell(anchor)),
|
|
224
|
+
hueShift: Array.from({ length: n }, () => 0),
|
|
225
|
+
anchor
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
const PRESETS = {
|
|
229
|
+
__proto__: null,
|
|
230
|
+
"tailwind-11": {
|
|
231
|
+
lightness: TW_L,
|
|
232
|
+
chroma: TW_C.map((c) => c / TW_C[5]),
|
|
233
|
+
hueShift: TW_H.map((h) => h - TW_H[5]),
|
|
234
|
+
anchor: 5
|
|
235
|
+
},
|
|
236
|
+
"radix-12": {
|
|
237
|
+
lightness: RADIX_L,
|
|
238
|
+
chroma: RADIX_C,
|
|
239
|
+
hueShift: RADIX_L.map(() => 0),
|
|
240
|
+
anchor: 8
|
|
241
|
+
},
|
|
242
|
+
"tone-13": {
|
|
243
|
+
lightness: [...require_tone.MATERIAL_TONES].reverse(),
|
|
244
|
+
chroma: require_tone.MATERIAL_TONES.map(() => 1),
|
|
245
|
+
hueShift: require_tone.MATERIAL_TONES.map(() => 0),
|
|
246
|
+
anchor: 6,
|
|
247
|
+
tone: true
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
function curveOf(steps) {
|
|
251
|
+
if (typeof steps === "number") {
|
|
252
|
+
if (!Number.isInteger(steps) || steps < 2) throw new Error(`steps must be an integer of at least 2, got ${steps}`);
|
|
253
|
+
return even(steps);
|
|
254
|
+
}
|
|
255
|
+
if (steps === "even") return even(11);
|
|
256
|
+
const curve = PRESETS[steps];
|
|
257
|
+
if (!curve) throw require_parse.unknownName("scale preset", steps, [...Object.keys(PRESETS), "even"]);
|
|
258
|
+
return curve;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Builds a scale from light to dark around `seed`: one color per step, in
|
|
262
|
+
* OKLCH, mapped into `gamut`. The preset gives each step's lightness, chroma
|
|
263
|
+
* (relative to the seed's) and hue drift; pass `lightness`, `chroma` or
|
|
264
|
+
* `hueShift` to replace any of them.
|
|
265
|
+
*/
|
|
266
|
+
function createScale(options) {
|
|
267
|
+
const { seed, steps = "tailwind-11", gamut = "srgb" } = options;
|
|
268
|
+
const curve = curveOf(steps);
|
|
269
|
+
const n = curve.lightness.length;
|
|
270
|
+
const pick = (name, over, base) => {
|
|
271
|
+
if (over === void 0) return base;
|
|
272
|
+
if (over.length !== n) throw new Error(`${name} needs ${n} values, got ${over.length}`);
|
|
273
|
+
return over;
|
|
274
|
+
};
|
|
275
|
+
const lightness = pick("lightness", options.lightness, curve.lightness);
|
|
276
|
+
const chroma = pick("chroma", options.chroma, curve.chroma);
|
|
277
|
+
const hueShift = pick("hueShift", typeof options.hueShift === "number" ? curve.lightness.map(() => options.hueShift) : options.hueShift, curve.hueShift);
|
|
278
|
+
const [, seedC, seedH] = require_parse.componentsIn(require_parse.toColor(seed), "oklch");
|
|
279
|
+
const hue = seedH ?? 0;
|
|
280
|
+
return lightness.map((l, i) => {
|
|
281
|
+
const c = seedC * chroma[i];
|
|
282
|
+
const h = hue + hueShift[i];
|
|
283
|
+
return curve.tone ? require_tone.toneColor(l, c, h, gamut) : require_parse.toGamut({
|
|
284
|
+
colorSpace: "oklch",
|
|
285
|
+
components: [
|
|
286
|
+
l,
|
|
287
|
+
c,
|
|
288
|
+
h
|
|
289
|
+
]
|
|
290
|
+
}, { gamut });
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
Object.defineProperty(exports, "createContrastScale", {
|
|
294
|
+
enumerable: true,
|
|
295
|
+
get: function() {
|
|
296
|
+
return createContrastScale;
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
Object.defineProperty(exports, "createGradient", {
|
|
300
|
+
enumerable: true,
|
|
301
|
+
get: function() {
|
|
302
|
+
return createGradient;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
Object.defineProperty(exports, "createScale", {
|
|
306
|
+
enumerable: true,
|
|
307
|
+
get: function() {
|
|
308
|
+
return createScale;
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
Object.defineProperty(exports, "scaleFromBrand", {
|
|
312
|
+
enumerable: true,
|
|
313
|
+
get: function() {
|
|
314
|
+
return scaleFromBrand;
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
//# sourceMappingURL=scale-Cq9pXrc1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scale-Cq9pXrc1.js","names":["checkMode","toColor","componentsIn","toGamut","componentsIn","toColor","findContrast","toColor","mix","MATERIAL_TONES","unknownName","componentsIn","toColor","toneColor","toGamut"],"sources":["../src/scale/brand.ts","../src/scale/contrast-scale.ts","../src/scale/gradient.ts","../src/scale/scale.ts"],"sourcesContent":["import type { GamutId } from '../color/gamut.js'\nimport { toGamut } from '../color/gamut.js'\nimport { toColor } from '../color/parse.js'\nimport { componentsIn } from '../color/spaces.js'\nimport type { Color } from '../color/types.js'\nimport { checkMode } from '../color/unknown-name.js'\n\n/** Options for `scaleFromBrand`. */\nexport interface BrandScaleOptions {\n\t/** `light` runs from a near-white step 1 to dark text; `dark` the other way. Default `light`. */\n\tmode?: 'light' | 'dark'\n\t/** The page background, whose lightness step 1 takes. Default near-white, or near-black in `dark`. */\n\tbackground?: Color | string\n\t/** The gamut steps other than 9 must fit. Default `srgb`. */\n\tgamut?: GamutId\n}\n\n// Radix-like lightness shapes, steps 1 to 9, as fractions of the way from\n// step 1 to step 9; chroma of steps 1 to 8 as multiples of the brand's.\nconst LIGHT_PROGRESS = [0, 0.0376, 0.1, 0.1796, 0.2606, 0.3466, 0.4656, 0.6312, 1]\nconst CHROMA = [0.04, 0.08, 0.2, 0.32, 0.43, 0.52, 0.6, 0.75]\n\n/**\n * A 12-step UI scale from one brand color, after Radix's palette generator:\n * the brand color is step 9 exactly (returned as given, never remapped), steps\n * 1 to 8 run from the background to it, step 10 is its hover state, and steps\n * 11 and 12 are low- and high-contrast text. Hue is the brand's throughout.\n * Radix's generator also borrows the shape of the nearest of its hand-tuned\n * scales; this one uses a single fixed shape instead.\n */\nexport function scaleFromBrand(brand: Color | string, options: BrandScaleOptions = {}): Color[] {\n\tconst { mode = 'light', gamut = 'srgb' } = options\n\tconst dark = checkMode(mode) === 'dark'\n\tconst exact = toColor(brand)\n\tconst [l9, c9, h9] = componentsIn(exact, 'oklch') as [number, number, number | null]\n\tconst hue = h9 ?? 0\n\tconst bg = options.background\n\tconst l1 = bg ? (componentsIn(toColor(bg), 'oklch')[0] as number) : dark ? 0.18 : 0.992\n\tconst step = (l: number, c: number): Color => toGamut({ colorSpace: 'oklch', components: [l, c, hue] }, { gamut })\n\n\tconst out: Color[] = []\n\tfor (let i = 0; i < 8; i++) out.push(step(l1 + (l9 - l1) * (LIGHT_PROGRESS[i] as number), c9 * (CHROMA[i] as number)))\n\tout.push(exact)\n\tconst hover = 0.03 / (l9 + 0.1)\n\tout.push(step(dark ? l9 + hover : l9 - hover, c9 * 0.93))\n\tconst c8 = c9 * (CHROMA[7] as number)\n\tout.push(step(dark ? 0.78 : 0.5, Math.min(c9 * 0.9, Math.max(c8, c9))))\n\tout.push(step(dark ? 0.93 : 0.3, Math.min(c9 * 0.35, Math.max(c8, c9))))\n\treturn out\n}\n","import { type ContrastOption, findContrast } from '../color/contrast.js'\nimport { toColor } from '../color/parse.js'\nimport { componentsIn } from '../color/spaces.js'\nimport type { Color } from '../color/types.js'\n\n/** Options for `createContrastScale`. */\nexport interface ContrastScaleOptions {\n\t/** The color the scale is built around: its hue and chroma carry to every step. */\n\tseed: Color | string\n\t/** What every step is measured against. */\n\tbackground: Color | string\n\t/** Target contrast per step, in order, or a record of named targets (`{ text: 7, border: 3 }`). */\n\ttargets: number[] | Record<string, number>\n\t/** Default `wcag2`. */\n\tcontrast?: ContrastOption\n\t/** Which way to look first from the background. Default: darker on a light background, lighter on a dark one. */\n\tdirection?: 'lighter' | 'darker'\n}\n\n/** One step of a contrast scale: the target it was given and the color and contrast it got. */\nexport interface ContrastStep {\n\t/** The key in a record of targets; otherwise the step's index as a string. */\n\tname: string\n\ttarget: number\n\tcolor: Color\n\t/** The contrast the color achieves, measured on the color itself. */\n\tcontrast: number\n\t/** False when no lightness reaches `target`; `color` is then the best one found. */\n\tmet: boolean\n}\n\n/**\n * A Leonardo-style scale: each step is the color nearest the background's\n * lightness, at the seed's hue and chroma, that reaches its target contrast.\n * Contrast is the same across hues, which a fixed-lightness scale cannot give.\n */\nexport function createContrastScale(options: ContrastScaleOptions): ContrastStep[] {\n\tconst { seed, background, targets, contrast, direction } = options\n\tconst [, chroma, hue] = componentsIn(toColor(seed), 'oklch') as [number, number, number | null]\n\tconst entries: [string, number][] = Array.isArray(targets)\n\t\t? targets.map((t, i) => [String(i), t])\n\t\t: Object.entries(targets)\n\treturn entries.map(([name, target]) => ({\n\t\tname,\n\t\ttarget,\n\t\t...findContrast(background, target, { hue: hue ?? 0, chroma, contrast, direction })\n\t}))\n}\n","import { type MixOptions, mix } from '../color/mix.js'\nimport { toColor } from '../color/parse.js'\nimport type { Color } from '../color/types.js'\n\n/** A color at a position on the gradient line. */\nexport interface GradientStop {\n\t/** A CSS color string or a color object. Its alpha is the stop's alpha. */\n\tcolor: Color | string\n\t/**\n\t * Where the stop sits, with 0 the start and 1 the end; it may fall outside\n\t * 0 to 1. Leave it out to spread the stop evenly between its neighbors, as\n\t * CSS gradients do.\n\t */\n\tat?: number\n}\n\n/** `in` and `hue` work as they do in `mix()`. The default space is `oklab`. */\nexport type GradientOptions = MixOptions\n\n/**\n * Places each stop the way CSS gradients do (CSS Images 3 section 3.5.3): a\n * first stop without a position goes at 0 and a last one at 1, a position\n * before an earlier stop's moves up to it, and a run of stops without a\n * position spreads evenly between the stops around it.\n */\nfunction positions(stops: readonly GradientStop[]): number[] {\n\tconst n = stops.length\n\tconst at: (number | undefined)[] = stops.map((s, i) => {\n\t\tif (s.at !== undefined && !Number.isFinite(s.at)) throw new Error(`stop ${i} has a position of ${s.at}`)\n\t\treturn s.at\n\t})\n\tif (at[0] === undefined) at[0] = 0\n\tif (at[n - 1] === undefined) at[n - 1] = 1\n\tlet max = Number.NEGATIVE_INFINITY\n\tfor (let i = 0; i < n; i++) {\n\t\tconst p = at[i]\n\t\tif (p !== undefined) at[i] = max = Math.max(max, p)\n\t}\n\tfor (let i = 1; i < n; i++) {\n\t\tif (at[i] !== undefined) continue\n\t\tlet j = i\n\t\twhile (at[j] === undefined) j++\n\t\tconst from = at[i - 1] as number\n\t\tconst step = ((at[j] as number) - from) / (j - i + 1)\n\t\tfor (let k = i; k < j; k++) at[k] = from + step * (k - i + 1)\n\t}\n\treturn at as number[]\n}\n\n/**\n * Builds `count` colors, evenly spaced from 0 to 1 along a gradient through\n * `stops`, the way a CSS gradient blends them: each pair of neighboring stops\n * is mixed with `mix()`, so `in` and `hue` work as they do there. A stop is\n * `{ color, at? }`, or a bare color when it needs no position. Before the\n * first stop and after the last, the color holds; where two stops share a\n * position, the color changes there and the sample at that position takes the\n * later stop. Colors come back in the `in` space, default `oklab`.\n *\n * Alpha comes from each stop's color, 1 when the color has none, so\n * `rgb(0 0 255 / 0.2)` is a stop at alpha 0.2. Alpha is interpolated linearly\n * between stops, and the other components are premultiplied by it, so a\n * transparent stop does not pull its neighbor's color toward its own. A color\n * whose alpha is 1 has no `alpha` key; a `none` alpha takes the neighboring\n * stop's.\n *\n * ```ts\n * createGradient([{ color: 'blue', at: 0 }, { color: 'lime', at: 0.6 }, { color: 'yellow', at: 1 }], 72)\n * createGradient(['blue', 'lime'], 5, { in: 'oklch' })\n * ```\n */\nexport function createGradient(\n\tstops: readonly (GradientStop | Color | string)[],\n\tcount: number,\n\toptions: GradientOptions = {}\n): Color[] {\n\tif (stops.length < 2) throw new Error(`a gradient needs at least 2 stops, got ${stops.length}`)\n\tif (!Number.isInteger(count) || count < 2) throw new Error(`count must be an integer of at least 2, got ${count}`)\n\tconst list = stops.map((s): GradientStop => (typeof s === 'string' || 'colorSpace' in s ? { color: s } : s))\n\tconst colors = list.map((s) => toColor(s.color))\n\tconst at = positions(list)\n\tconst last = list.length - 2\n\treturn Array.from({ length: count }, (_, i) => {\n\t\tconst t = i / (count - 1)\n\t\tlet s = 0\n\t\twhile (s < last && (at[s + 1] as number) <= t) s++\n\t\tconst from = at[s] as number\n\t\tconst width = (at[s + 1] as number) - from\n\t\tconst local = width > 0 ? Math.min(1, Math.max(0, (t - from) / width)) : t < from ? 0 : 1\n\t\treturn mix(colors[s] as Color, colors[s + 1] as Color, local, options)\n\t})\n}\n","import type { GamutId } from '../color/gamut.js'\nimport { toGamut } from '../color/gamut.js'\nimport { toColor } from '../color/parse.js'\nimport { componentsIn } from '../color/spaces.js'\nimport type { Color } from '../color/types.js'\nimport { unknownName } from '../color/unknown-name.js'\nimport { MATERIAL_TONES, toneColor } from './tone.js'\n\n/** The built-in step curves. */\nexport type ScalePreset = 'tailwind-11' | 'radix-12' | 'tone-13' | 'even'\n\n/** A step curve. `chroma` and `hueShift` are relative to the step at `anchor`, which takes the seed's own. */\ninterface Curve {\n\t/** OKLCH lightness 0 to 1, or CIE L* tones 0 to 100 when `tone` is set. */\n\tlightness: number[]\n\tchroma: number[]\n\thueShift: number[]\n\tanchor: number\n\ttone?: boolean\n}\n\n// Tailwind v4 blue, 50 to 950. The preset is this one hand-tuned scale, so a\n// seed of blue-500 gives Tailwind's blue back, and other hues get its shape.\n// biome-ignore lint/suspicious/noApproximativeNumericConstant: 0.707 is Tailwind blue-400's lightness, not 1/sqrt(2)\nconst TW_L = [0.97, 0.932, 0.882, 0.809, 0.707, 0.623, 0.546, 0.488, 0.424, 0.379, 0.282]\nconst TW_C = [0.014, 0.032, 0.059, 0.105, 0.165, 0.214, 0.245, 0.243, 0.199, 0.146, 0.091]\nconst TW_H = [254.604, 255.585, 254.128, 251.813, 254.624, 259.815, 262.881, 264.376, 265.638, 265.522, 267.935]\n\n// Radix-like light scale: step 9 is the pure solid, 11 and 12 are text.\nconst RADIX_L = [0.992, 0.978, 0.953, 0.925, 0.894, 0.857, 0.81, 0.745, 0.62, 0.585, 0.52, 0.32]\nconst RADIX_C = [0.04, 0.08, 0.2, 0.32, 0.43, 0.52, 0.6, 0.75, 1, 0.95, 0.9, 0.35]\n\nfunction even(n: number): Curve {\n\tconst t = (i: number) => i / (n - 1)\n\tconst bell = (i: number) => Math.sin(Math.PI * (0.05 + 0.9 * t(i)))\n\tconst anchor = Math.round((n - 1) / 2)\n\treturn {\n\t\tlightness: Array.from({ length: n }, (_, i) => 0.97 - 0.72 * t(i)),\n\t\tchroma: Array.from({ length: n }, (_, i) => bell(i) / bell(anchor)),\n\t\thueShift: Array.from({ length: n }, () => 0),\n\t\tanchor\n\t}\n}\n\nconst PRESETS: Record<string, Curve> = {\n\t__proto__: null as never,\n\t'tailwind-11': {\n\t\tlightness: TW_L,\n\t\tchroma: TW_C.map((c) => c / TW_C[5]),\n\t\thueShift: TW_H.map((h) => h - TW_H[5]),\n\t\tanchor: 5\n\t},\n\t'radix-12': {\n\t\tlightness: RADIX_L,\n\t\tchroma: RADIX_C,\n\t\thueShift: RADIX_L.map(() => 0),\n\t\tanchor: 8\n\t},\n\t'tone-13': {\n\t\tlightness: [...MATERIAL_TONES].reverse(),\n\t\tchroma: MATERIAL_TONES.map(() => 1),\n\t\thueShift: MATERIAL_TONES.map(() => 0),\n\t\tanchor: 6,\n\t\ttone: true\n\t}\n}\n\n/** Options for `createScale`. Only `seed` is required. */\nexport interface ScaleOptions {\n\t/** The color the scale is built around. Its hue and chroma set the anchor step. */\n\tseed: Color | string\n\t/**\n\t * A preset, or a number of steps for an even scale. Default `tailwind-11`.\n\t * `tone-13` steps are CIE L* tones, so any two steps whose tones differ by\n\t * 40 reach contrast 3 and by 50 about 4.5.\n\t */\n\tsteps?: ScalePreset | number\n\t/** Overrides the curve's lightness, one per step: OKLCH L 0 to 1 (L* tones 0 to 100 for `tone-13`). */\n\tlightness?: number[]\n\t/** Overrides chroma, as a multiplier of the seed's chroma, one per step. */\n\tchroma?: number[]\n\t/** Overrides hue drift, as degrees added to the seed's hue, one per step; a number is applied to every step. */\n\thueShift?: number[] | number\n\t/** The gamut every step must fit. Default `srgb`. */\n\tgamut?: GamutId\n}\n\nfunction curveOf(steps: ScalePreset | number): Curve {\n\tif (typeof steps === 'number') {\n\t\tif (!Number.isInteger(steps) || steps < 2) throw new Error(`steps must be an integer of at least 2, got ${steps}`)\n\t\treturn even(steps)\n\t}\n\tif (steps === 'even') return even(11)\n\tconst curve = PRESETS[steps]\n\tif (!curve) throw unknownName('scale preset', steps, [...Object.keys(PRESETS), 'even'])\n\treturn curve\n}\n\n/**\n * Builds a scale from light to dark around `seed`: one color per step, in\n * OKLCH, mapped into `gamut`. The preset gives each step's lightness, chroma\n * (relative to the seed's) and hue drift; pass `lightness`, `chroma` or\n * `hueShift` to replace any of them.\n */\nexport function createScale(options: ScaleOptions): Color[] {\n\tconst { seed, steps = 'tailwind-11', gamut = 'srgb' } = options\n\tconst curve = curveOf(steps)\n\tconst n = curve.lightness.length\n\tconst pick = <T>(name: string, over: T[] | undefined, base: T[]): T[] => {\n\t\tif (over === undefined) return base\n\t\tif (over.length !== n) throw new Error(`${name} needs ${n} values, got ${over.length}`)\n\t\treturn over\n\t}\n\tconst lightness = pick('lightness', options.lightness, curve.lightness)\n\tconst chroma = pick('chroma', options.chroma, curve.chroma)\n\tconst drift =\n\t\ttypeof options.hueShift === 'number' ? curve.lightness.map(() => options.hueShift as number) : options.hueShift\n\tconst hueShift = pick('hueShift', drift, curve.hueShift)\n\n\tconst [, seedC, seedH] = componentsIn(toColor(seed), 'oklch') as [number, number, number | null]\n\tconst hue = seedH ?? 0\n\treturn lightness.map((l, i) => {\n\t\tconst c = seedC * (chroma[i] as number)\n\t\tconst h = hue + (hueShift[i] as number)\n\t\treturn curve.tone ? toneColor(l, c, h, gamut) : toGamut({ colorSpace: 'oklch', components: [l, c, h] }, { gamut })\n\t})\n}\n"],"mappings":";;;;;AAmBA,MAAM,iBAAiB;CAAC;CAAG;CAAQ;CAAK;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;AAAC;AACjF,MAAM,SAAS;CAAC;CAAM;CAAM;CAAK;CAAM;CAAM;CAAM;CAAK;AAAI;;;;;;;;;AAU5D,SAAgB,eAAe,OAAuB,UAA6B,CAAC,GAAY;CAC/F,MAAM,EAAE,OAAO,SAAS,QAAQ,WAAW;CAC3C,MAAM,OAAOA,cAAAA,UAAU,IAAI,MAAM;CACjC,MAAM,QAAQC,cAAAA,QAAQ,KAAK;CAC3B,MAAM,CAAC,IAAI,IAAI,MAAMC,cAAAA,aAAa,OAAO,OAAO;CAChD,MAAM,MAA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,SAAS,KAAA,GAAW,OAAO;EAC/B,IAAI,KAAK,WAAW,GAAG,MAAM,IAAI,MAAM,GAAG,KAAK,SAAS,EAAE,eAAe,KAAK,QAAQ;EACtF,OAAO;CACR;CACA,MAAM,YAAY,KAAK,aAAa,QAAQ,WAAW,MAAM,SAAS;CACtE,MAAM,SAAS,KAAK,UAAU,QAAQ,QAAQ,MAAM,MAAM;CAG1D,MAAM,WAAW,KAAK,YADrB,OAAO,QAAQ,aAAa,WAAW,MAAM,UAAU,UAAU,QAAQ,QAAkB,IAAI,QAAQ,UAC/D,MAAM,QAAQ;CAEvD,MAAM,GAAG,OAAO,SAASC,cAAAA,aAAaC,cAAAA,QAAQ,IAAI,GAAG,OAAO;CAC5D,MAAM,MAAM,SAAS;CACrB,OAAO,UAAU,KAAK,GAAG,MAAM;EAC9B,MAAM,IAAI,QAAS,OAAO;EAC1B,MAAM,IAAI,MAAO,SAAS;EAC1B,OAAO,MAAM,OAAOC,aAAAA,UAAU,GAAG,GAAG,GAAG,KAAK,IAAIC,cAAAA,QAAQ;GAAE,YAAY;GAAS,YAAY;IAAC;IAAG;IAAG;GAAC;EAAE,GAAG,EAAE,MAAM,CAAC;CAClH,CAAC;AACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { S as Color, l as ContrastOption, t as GamutId } from "./gamut-CG1J2aat.js";
|
|
2
|
+
/** A background, the foreground drawn on it, and the contrast they reach. */
|
|
3
|
+
interface RolePair {
|
|
4
|
+
bg: Color;
|
|
5
|
+
fg: Color;
|
|
6
|
+
/** The contrast of `fg` on `bg`, as the algorithm reports it (absolute value). */
|
|
7
|
+
ratio: number;
|
|
8
|
+
/** The contrast the pair was built to reach. */
|
|
9
|
+
target: number;
|
|
10
|
+
}
|
|
11
|
+
/** Options for `semanticPalette`. Only `brand` is required. */
|
|
12
|
+
interface SemanticPaletteOptions {
|
|
13
|
+
/** The brand color; it sets the hue of the primary, the neutrals and the harmonized status colors. */
|
|
14
|
+
brand: Color | string;
|
|
15
|
+
/** Default `light`. */
|
|
16
|
+
mode?: 'light' | 'dark';
|
|
17
|
+
/** The contrast measure. Default `wcag2`. */
|
|
18
|
+
contrast?: ContrastOption;
|
|
19
|
+
/** The contrast text pairs must reach. Default 4.5, which fits WCAG 2 (pass about 60 for APCA Lc). */
|
|
20
|
+
target?: number;
|
|
21
|
+
/** The gamut every color must fit. Default `srgb`. */
|
|
22
|
+
gamut?: GamutId;
|
|
23
|
+
}
|
|
24
|
+
/** A role in a {@link SemanticPalette}. Each role holds a {@link RolePair}. */
|
|
25
|
+
type SemanticRole = 'primary' | 'primaryContainer' | 'success' | 'warning' | 'danger' | 'info' | 'surface' | 'surfaceVariant' | 'outline';
|
|
26
|
+
/** What `semanticPalette` returns: the settings it used, the tonal scales it built from, and a pair for each role. */
|
|
27
|
+
interface SemanticPalette {
|
|
28
|
+
meta: {
|
|
29
|
+
mode: 'light' | 'dark';
|
|
30
|
+
contrast: string;
|
|
31
|
+
target: number;
|
|
32
|
+
gamut: GamutId;
|
|
33
|
+
};
|
|
34
|
+
/** Material's 13 tones, dark to light, in the brand's hue (`primary`) and a faint tint of it (`neutral`). */
|
|
35
|
+
scales: {
|
|
36
|
+
primary: Color[];
|
|
37
|
+
neutral: Color[];
|
|
38
|
+
};
|
|
39
|
+
roles: Record<SemanticRole, RolePair>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A role-based palette from one brand color: primary and its container, four
|
|
43
|
+
* status colors (success, warning, danger, info) harmonized toward the brand's
|
|
44
|
+
* hue, a surface and a variant tinted by the brand hue, and an outline. Every
|
|
45
|
+
* pair is built from L* tones, so a 50-tone gap or more reaches about 4.5 on
|
|
46
|
+
* WCAG 2 (the worst pair, 100 on 50, gives 4.48). Each pair records the ratio
|
|
47
|
+
* it reached; a foreground that falls short of `target` is replaced by the
|
|
48
|
+
* closest one that meets it, and `validate` reports any that cannot.
|
|
49
|
+
*/
|
|
50
|
+
declare function semanticPalette(options: SemanticPaletteOptions): SemanticPalette;
|
|
51
|
+
export { semanticPalette as a, SemanticRole as i, SemanticPalette as n, SemanticPaletteOptions as r, RolePair as t };
|
|
52
|
+
//# sourceMappingURL=semantic-CrEIo8tS.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic-CrEIo8tS.d.ts","names":[],"sources":["../src/palette/semantic.ts"],"mappings":";;UAUiB;EAChB,IAAI;EACJ,IAAI;;EAEJ;;EAEA;;;UAIgB;;EAEhB,OAAO;;EAEP;;EAEA,WAAW;;EAEX;;EAEA,QAAQ;;;KAIG;;UAYK;EAChB;IAAQ;IAAwB;IAAkB;IAAgB,OAAO;;;EAEzE;IAAU,SAAS;IAAS,SAAS;;EACrC,OAAO,OAAO,cAAc;;;;;;;;;;;iBAmBb,gBAAgB,SAAS,yBAAyB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { S as Color, T as Space } from "./gamut-CG1J2aat.js";
|
|
2
|
+
/** Options for `toCss`. */
|
|
3
|
+
interface ToCssOptions {
|
|
4
|
+
/** Decimal places kept in every number. Default 5. */
|
|
5
|
+
precision?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Serializes a color as CSS. `srgb` and `hsl` print in the comma syntax
|
|
9
|
+
* (`rgb(255, 0, 0)`, `rgba(...)`) unless a component is `none`; the other
|
|
10
|
+
* spaces print in the space syntax (`oklch(0.7 0.1 200 / 0.5)`,
|
|
11
|
+
* `color(display-p3 1 0 0)`). Out-of-gamut values are kept, not clipped.
|
|
12
|
+
*/
|
|
13
|
+
declare function toCss(color: Color, options?: ToCssOptions): string;
|
|
14
|
+
/**
|
|
15
|
+
* The hex form of a color, `#rrggbb` or `#rrggbbaa` when it is not opaque.
|
|
16
|
+
* Colors outside sRGB are converted and clipped, so map them with `toGamut` first.
|
|
17
|
+
*/
|
|
18
|
+
declare function toHex(color: Color): string;
|
|
19
|
+
/**
|
|
20
|
+
* Builds {@link toHex} over the spaces given, plus `srgb`, so a bundle contains
|
|
21
|
+
* only those. A color in a space not given throws, naming that space.
|
|
22
|
+
*/
|
|
23
|
+
declare function createToHex(...spaces: Space[]): (color: Color) => string;
|
|
24
|
+
export { toHex as i, createToHex as n, toCss as r, ToCssOptions as t };
|
|
25
|
+
//# sourceMappingURL=serialize-C69DAmoE.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize-C69DAmoE.d.ts","names":[],"sources":["../src/color/serialize.ts"],"mappings":";;UAMiB;;EAEhB;;;;;;;;iBA2Ce,MAAM,OAAO,OAAO,UAAS;;;;;iBA2B7B,MAAM,OAAO;;;;;iBAcb,eAAe,QAAQ,WAAW,OAAO"}
|