@getvitops/utils 0.9.0 → 1.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,108 @@
1
1
  # @getvitops/utils
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - bb92a14: **The colour system is rebuilt on a target-prefixed grammar and a shared lightness ladder.**
8
+ This is a breaking change to every colour token and utility class.
9
+
10
+ ## Why
11
+
12
+ Two axes shared one class namespace — functional _planes_ (`--<role>-bg-muted`) and
13
+ appearance-relative _stops_ (`--color-<role>-muted`) — arbitrated by a "plane wins" rule. The
14
+ result was not a scale. On the shipped palette, light mode:
15
+
16
+ | class | resolved to | step |
17
+ | ---------------------------------- | ------------ | --------------------------------------------- |
18
+ | `bg-ui-accent-x-muted` | stop | 100 |
19
+ | `bg-ui-accent-muted` | plane | 100 — identical, so `x-muted` was a dead rung |
20
+ | `bg-ui-accent` | plane | 50 — _lighter_ than both its "muted" rungs |
21
+ | `border-ui-accent-muted` / `-bold` | stop / plane | 300 / 300 — identical |
22
+ | `text-ui-accent-bold` | stop | 700 — _lighter_ than `text-…-muted` (800) |
23
+
24
+ Every family was non-monotonic, two had duplicate rungs, and `--color-<role>-muted` was
25
+ unreachable through any `bg-` class.
26
+
27
+ ## The new grammar
28
+
29
+ ```
30
+ --color-<target>-<role>[-<variant>] target ∈ bg | text | icon | border
31
+ ```
32
+
33
+ The target is **inside** the name, so `bg-danger-muted` and `text-danger-muted` are different
34
+ tokens and there is nothing left to arbitrate. **The class name is the token name minus
35
+ `--color-`** — one vocabulary instead of two.
36
+
37
+ Variants are ordinal (`xx-muted` < `x-muted` < `muted` < bare < `bold` < `x-bold`) and the
38
+ tables are sparse: only cells that hold their contrast target exist.
39
+
40
+ ## Role kinds
41
+
42
+ `colors.roles` values may now be `{ hue, kind }` as well as a bare hue string:
43
+
44
+ ```jsonc
45
+ "roles": {
46
+ "danger": "rust", // shorthand => chromatic
47
+ "surface": { "hue": "navy", "kind": "surface" }
48
+ }
49
+ ```
50
+
51
+ - **`surface`** — a page/panel colour: `bg-<role>` is the card, `bg-<role>-muted` the page
52
+ behind it, `bg-<role>-x-muted` a well, `bg-<role>-bold` the inverse surface. Full text scale.
53
+ - **`chromatic`** (default) — a signal colour: tints (`bg-<role>-x-muted`/`-muted`) and solids
54
+ (`bg-<role>-solid[-bold|-x-bold]`), with **no bare `bg-<role>`** — say how loud you mean.
55
+ `text-on-<role>` is the guaranteed foreground for the solid family.
56
+
57
+ ## Palette generation
58
+
59
+ Every ramp now sits on one **fixed lightness ladder** (50 → L 0.98 … 950 → L 0.21); only chroma
60
+ and hue vary. That is what makes a step mean the same lightness in every hue. Previously each
61
+ seed transposed the curve, so relative luminance at step 300 ranged from 0.253 to 0.384 across
62
+ the shipped palette — the same variant read differently depending on the role.
63
+
64
+ Authored colours are still reproduced **exactly**. A `seed`, an `anchors` entry or a `tones`
65
+ value is pinned verbatim at its nearest step; every other step takes the ladder. Snapping brand
66
+ colours to the ladder was measured and rejected: 11 of 18 real brand hexes moved beyond a
67
+ just-noticeable difference (worst ΔE-OK 0.050 — Facebook's `#1877F2` → `#0067e1`) and six left
68
+ sRGB gamut. Deviation is now bounded and local to pinned steps, and warns past ~0.03 L.
69
+
70
+ Two tones that claim the same step now **error** instead of one silently overwriting the other;
71
+ the record form (`tones: { "600": "…", "700": "…" }`) is how you resolve it.
72
+
73
+ ## New
74
+ - **`icon-<role>`** — a non-text tier, so a glyph may run more vivid than text. `icon` is now a
75
+ default utility family alongside `bg`/`text`/`border`.
76
+ - **`--color-border-focus`** — the focus-ring tone, taken from `ui-primary`'s solid.
77
+ - **Contrast is enforced at build time**, not only in tests: text ≥ APCA Lc 75 on its primary
78
+ background, ≥ 60 on secondary planes, icons and surface boundaries ≥ 45, both appearances.
79
+ A violation now fails `generate`. Chromatic text is checked against the _surface_ planes it
80
+ actually sits on, not only its own tints. `text-<role>-x-muted` (placeholder) and `-xx-muted`
81
+ (disabled) are explicitly exempt; nothing else is.
82
+
83
+ ## Migrating
84
+
85
+ Rename `--<role>-<suffix>` → `--color-<target>-<role>[-<variant>]`, and the same for classes:
86
+
87
+ | before | after |
88
+ | --------------------------------------- | ---------------------------------------------------------------- |
89
+ | `--<role>-bg` / `bg-<role>` (chromatic) | `--color-bg-<role>-x-muted` / `bg-<role>-x-muted` |
90
+ | `--<role>-bg-muted` | `--color-bg-<role>-muted` |
91
+ | `--<role>-solid` / `-solid-bold` | `--color-bg-<role>-solid` / `-solid-bold` |
92
+ | `--<role>-on-solid` / `text-on-<role>` | `--color-text-on-<role>` (class unchanged) |
93
+ | `--<role>-text` / `-text-muted` | `--color-text-<role>` / `-muted` |
94
+ | `--<role>-border` / `-border-bold` | `--color-border-<role>` / `-bold` |
95
+ | `--color-<role>-muted` (stop) | judge by use: `--color-bg-<role>-muted` or `--color-text-<role>` |
96
+
97
+ **`surface` background names rotate**, value-preserving: what was `--surface-bg` (the page) is
98
+ now `--color-bg-surface-muted`; what was `--surface-bg-bold` (raised) is now
99
+ `--color-bg-surface`. Elevation is expressed by which token you reach for — page `bg-muted`,
100
+ card `bg` — rather than a raised/sunken pair, which is what lets a future surfaces axis flatten
101
+ it without touching markup.
102
+
103
+ `vitops lint` reports role classes that no longer resolve, and now derives its suggestions from
104
+ what the generator actually emits rather than a hand-maintained list.
105
+
3
106
  ## 0.9.0
4
107
 
5
108
  ## 0.8.0
@@ -68,6 +68,30 @@ interface HarmonyDefinition {
68
68
  primaryIndex: number;
69
69
  }
70
70
  declare const HARMONY_DEFINITIONS: Record<HarmonyType, HarmonyDefinition>;
71
+ /**
72
+ * The shared lightness ladder every ramp is built on (lightest → darkest).
73
+ *
74
+ * Fixed, NOT seed-derived. Two hues at the same step have to read equally light,
75
+ * otherwise one contrast table cannot serve every hue and a `muted` variant means
76
+ * something different depending on which role you ask. Only chroma and hue vary
77
+ * between ramps.
78
+ *
79
+ * The previous engine transposed this curve onto each seed, which let relative
80
+ * luminance at step 300 range from 0.253 (rust) to 0.384 (amber) across the
81
+ * shipped palette — the drift this replaces.
82
+ *
83
+ * Anchored steps are the one deliberate exception: see `generateOklchPalette`.
84
+ */
85
+ declare const LIGHTNESS_LADDER: Record<StepName, number>;
86
+ /**
87
+ * Chroma a ramp decays to beyond its outermost anchors, so the near-white and
88
+ * near-black ends keep a whisper of the hue instead of going flat grey. The dark
89
+ * end carries slightly more because chroma reads weaker against black.
90
+ */
91
+ declare const ENDPOINT_CHROMA: {
92
+ readonly light: 0.008;
93
+ readonly dark: 0.015;
94
+ };
71
95
  interface OklchColor {
72
96
  l: number;
73
97
  c: number;
@@ -80,8 +104,36 @@ interface OklchColor {
80
104
  */
81
105
  declare function parseOklch(oklchString: string): OklchColor;
82
106
  /**
83
- * Generates a complete 11-step OKLCH palette from one or more colors.
84
- * Automatically determines which step each color belongs to based on lightness.
107
+ * The ladder step whose lightness is closest to `lightness` — i.e. where a
108
+ * supplied colour naturally belongs.
109
+ */
110
+ declare function assignStepByLightness(lightness: number): StepName;
111
+ /**
112
+ * How far an anchored colour sits from its step's ladder lightness.
113
+ *
114
+ * The generator surfaces this as a warning: a large deviation is legal (the
115
+ * caller asked for that exact colour) but it means the hue will read heavier or
116
+ * lighter than its siblings at that step, which is worth knowing rather than
117
+ * discovering later.
118
+ */
119
+ declare function ladderDeviation(step: StepName, lightness: number): number;
120
+ /**
121
+ * Build a complete 11-step OKLCH ramp from one or more anchor colours.
122
+ *
123
+ * **Ladder-first with exact anchors.** Every anchor is reproduced *verbatim* at
124
+ * its step; every other step takes its lightness from `LIGHTNESS_LADDER`, with
125
+ * chroma and hue interpolated between the flanking anchors and decayed toward
126
+ * `ENDPOINT_CHROMA` beyond the outermost ones.
127
+ *
128
+ * The consequence is the point: a client's brand hex survives byte-for-byte,
129
+ * while the other ten steps stay directly comparable to every other hue. The
130
+ * deviation from the ladder is bounded and *local to anchored steps* — unlike
131
+ * the previous engine, which warped the whole ramp to fit its anchors so every
132
+ * step drifted.
133
+ *
134
+ * Chroma may come out beyond the sRGB gamut here; that is deliberate.
135
+ * `oklchStringToHex` gamut-maps with the CSS algorithm, which reduces chroma
136
+ * while holding lightness, so the ladder survives the conversion.
85
137
  */
86
138
  declare function generateOklchPalette(input: string | string[] | Record<string, string>): Record<StepName, string>;
87
139
  /** APCA lightness-contrast (Lc) magnitude between a foreground and background. */
@@ -95,6 +147,11 @@ declare function pickOn(bg: string, hue?: number): string;
95
147
  * The tinted off-white / off-black endpoints for a hue — white/black with a
96
148
  * whisper of the hue mixed in. These are the text/background tints every ramp
97
149
  * needs (and the one exception strict brand kits allow).
150
+ *
151
+ * Derived from `LIGHTNESS_LADDER` and `ENDPOINT_CHROMA` rather than its own
152
+ * literals, so a strict tone kit's endpoints land on the same ladder rungs a
153
+ * generated ramp would have used. This is the single definition — callers must
154
+ * not hand-write their own near-white/near-black.
98
155
  */
99
156
  declare function tintedEndpoints(hue: number, chroma?: number): {
100
157
  light: string;
@@ -140,5 +197,5 @@ declare const DEFAULT_FUNCTIONAL_HUES: {
140
197
  */
141
198
  declare function suggestFunctionalColorHue(type: keyof typeof DEFAULT_FUNCTIONAL_HUES, existingHues: number[]): number;
142
199
  //#endregion
143
- export { COLOR_GROUPS, ColorGroup, DEFAULT_FUNCTIONAL_HUES, HARMONY_DEFINITIONS, HARMONY_STRATEGIES, HARMONY_TYPES, HarmonyDefinition, HarmonyOption, HarmonyStrategy, HarmonyType, RgbResult, STEP_NAMES, StepName, applyHarmonyStrategy, contrastLc, formatColorName, gamutMapOklchToHex, generateOklchPalette, getColorName, getColorNameWithHue, getHarmonySuggestions, hexToOklch, oklchStringToHex, oklchToHex, oklchToP3, oklchToSrgb, parseOklch, pickOn, suggestFunctionalColorHue, tintedEndpoints };
200
+ export { COLOR_GROUPS, ColorGroup, DEFAULT_FUNCTIONAL_HUES, ENDPOINT_CHROMA, HARMONY_DEFINITIONS, HARMONY_STRATEGIES, HARMONY_TYPES, HarmonyDefinition, HarmonyOption, HarmonyStrategy, HarmonyType, LIGHTNESS_LADDER, RgbResult, STEP_NAMES, StepName, applyHarmonyStrategy, assignStepByLightness, contrastLc, formatColorName, gamutMapOklchToHex, generateOklchPalette, getColorName, getColorNameWithHue, getHarmonySuggestions, hexToOklch, ladderDeviation, oklchStringToHex, oklchToHex, oklchToP3, oklchToSrgb, parseOklch, pickOn, suggestFunctionalColorHue, tintedEndpoints };
144
201
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/color/colors.ts","../../src/color/color-harmony.ts"],"mappings":";UAkBiB,SAAA;EACf,CAAA;EACA,CAAA;EACA,CAAA;EACA,OAAA;EAHA;EAKA,aAAA;AAAA;;;;AAAa;iBAOC,WAAA,CAAY,CAAA,UAAW,CAAA,UAAW,CAAA,WAAY,SAAS;;;;;iBAmBvD,SAAA,CAAU,CAAA,UAAW,CAAA,UAAW,CAAA,WAAY,SAAS;;;;AAnBE;iBAsCvD,kBAAA,CACd,CAAA,UACA,CAAA,UACA,CAAA,UACA,KAAA;AAAA,cAUW,UAAA;AAAA,KACD,QAAA,WAAmB,UAAU;AAAA,cAE5B,YAAA;AAAA,KAWD,UAAA,WAAqB,YAAY;;;;iBAK7B,UAAA,CAAW,GAAA;EAAgB,CAAA;EAAW,CAAA;EAAW,CAAA;AAAA;;;;iBAajD,UAAA,CAAW,KAAA;EAAS,CAAA;EAAW,CAAA;EAAW,CAAA;AAAA;;;;AAhC+B;iBA8CzE,gBAAA,CAAiB,WAAmB;;;;AA7CX;iBA8DzB,eAAA,CAAgB,IAAY;;;;iBA+G5B,YAAA,CAAa,GAAW;AAhKxC;;;AAAA,iBAsLgB,mBAAA,CAAoB,GAAW;AAAA,cAclC,aAAA;AAAA,KASD,WAAA,WAAsB,aAAa;AAAA,UAE9B,iBAAA;EACf,KAAA;EACA,OAAA;EACA,YAAA;AAAA;AAAA,cAGW,mBAAA,EAAqB,MAAA,CAAO,WAAA,EAAa,iBA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;AAAA;;;;AAzjBhF;;KCdY,eAAA;AAAA,UAWK,aAAA;EACf,EAAA,EAAI,eAAe;EACnB,KAAA;EACA,WAAA;EACA,QAAA;AAAA;AAAA,cAGW,kBAAA,EAAoB,aAAa;ADE/B;AAOf;;AAPe,iBC0DC,oBAAA,CAAqB,OAAA,UAAiB,QAAA,EAAU,eAAe;;;;iBAgB/D,qBAAA,CACd,OAAA,WACC,KAAK;EAAG,QAAA,EAAU,eAAA;EAAiB,GAAA;EAAa,KAAA;EAAe,WAAA;AAAA;;;;cAYrD,uBAAA;EAAA;;;;;;;;iBAUG,yBAAA,CACd,IAAA,eAAmB,uBAAuB,EAC1C,YAAA"}
@@ -332,18 +332,41 @@ const HARMONY_DEFINITIONS = {
332
332
  primaryIndex: 1
333
333
  }
334
334
  };
335
- const DEFAULT_LIGHTNESS_SCALE = {
336
- 50: .95,
337
- 100: .9,
338
- 200: .8,
339
- 300: .7,
340
- 400: .6,
341
- 500: .5,
342
- 600: .4,
343
- 700: .3,
344
- 800: .2,
345
- 900: .1,
346
- 950: .05
335
+ /**
336
+ * The shared lightness ladder every ramp is built on (lightest → darkest).
337
+ *
338
+ * Fixed, NOT seed-derived. Two hues at the same step have to read equally light,
339
+ * otherwise one contrast table cannot serve every hue and a `muted` variant means
340
+ * something different depending on which role you ask. Only chroma and hue vary
341
+ * between ramps.
342
+ *
343
+ * The previous engine transposed this curve onto each seed, which let relative
344
+ * luminance at step 300 range from 0.253 (rust) to 0.384 (amber) across the
345
+ * shipped palette — the drift this replaces.
346
+ *
347
+ * Anchored steps are the one deliberate exception: see `generateOklchPalette`.
348
+ */
349
+ const LIGHTNESS_LADDER = {
350
+ 50: .98,
351
+ 100: .95,
352
+ 200: .9,
353
+ 300: .83,
354
+ 400: .74,
355
+ 500: .65,
356
+ 600: .54,
357
+ 700: .47,
358
+ 800: .38,
359
+ 900: .29,
360
+ 950: .21
361
+ };
362
+ /**
363
+ * Chroma a ramp decays to beyond its outermost anchors, so the near-white and
364
+ * near-black ends keep a whisper of the hue instead of going flat grey. The dark
365
+ * end carries slightly more because chroma reads weaker against black.
366
+ */
367
+ const ENDPOINT_CHROMA = {
368
+ light: .008,
369
+ dark: .015
347
370
  };
348
371
  /**
349
372
  * Parses an OKLCH CSS string into numerical components.
@@ -367,69 +390,21 @@ function lerp(start, end, factor) {
367
390
  return start + factor * (end - start);
368
391
  }
369
392
  /**
370
- * Transpose the default lightness scale to match the provided anchors.
393
+ * Interpolate hue the short way round the wheel. A ramp anchored at 350° and 10°
394
+ * spans 20°, not 340° — the naive lerp sent it the long way through cyan.
371
395
  */
372
- function transposeLightnessScale(parsedAnchors, sortedAnchorSteps) {
373
- const transposedScale = {};
374
- if (sortedAnchorSteps.length === 1) {
375
- const anchorStep = sortedAnchorSteps[0];
376
- const anchorL = parsedAnchors[anchorStep].l;
377
- const defaultAnchorL = DEFAULT_LIGHTNESS_SCALE[anchorStep];
378
- for (const step of STEP_NAMES) {
379
- if (step === anchorStep) {
380
- transposedScale[step] = anchorL;
381
- continue;
382
- }
383
- const defaultStepL = DEFAULT_LIGHTNESS_SCALE[step];
384
- if (defaultStepL > defaultAnchorL) transposedScale[step] = lerp(anchorL, .97, (defaultStepL - defaultAnchorL) / (1 - defaultAnchorL));
385
- else transposedScale[step] = lerp(.05, anchorL, defaultStepL / defaultAnchorL);
386
- }
387
- return transposedScale;
388
- }
389
- for (const step of STEP_NAMES) {
390
- const anchored = parsedAnchors[step];
391
- if (anchored) {
392
- transposedScale[step] = anchored.l;
393
- continue;
394
- }
395
- let lowerStep = null;
396
- let upperStep = null;
397
- for (let i = sortedAnchorSteps.length - 1; i >= 0; i--) {
398
- const candidate = sortedAnchorSteps[i];
399
- if (candidate < step) {
400
- lowerStep = candidate;
401
- break;
402
- }
403
- }
404
- for (const anchorStep of sortedAnchorSteps) if (anchorStep > step) {
405
- upperStep = anchorStep;
406
- break;
407
- }
408
- if (lowerStep !== null && upperStep !== null) {
409
- const lowerL = parsedAnchors[lowerStep].l;
410
- const upperL = parsedAnchors[upperStep].l;
411
- const span = upperStep - lowerStep;
412
- transposedScale[step] = lerp(lowerL, upperL, (step - lowerStep) / span);
413
- } else if (lowerStep !== null) {
414
- const lowerL = parsedAnchors[lowerStep].l;
415
- const defaultLowerL = DEFAULT_LIGHTNESS_SCALE[lowerStep];
416
- transposedScale[step] = lerp(.05, lowerL, DEFAULT_LIGHTNESS_SCALE[step] / defaultLowerL);
417
- } else if (upperStep !== null) {
418
- const upperL = parsedAnchors[upperStep].l;
419
- const defaultUpperL = DEFAULT_LIGHTNESS_SCALE[upperStep];
420
- transposedScale[step] = lerp(upperL, .97, (DEFAULT_LIGHTNESS_SCALE[step] - defaultUpperL) / (1 - defaultUpperL));
421
- }
422
- }
423
- return transposedScale;
396
+ function lerpHue(start, end, factor) {
397
+ return (start + (((end - start) % 360 + 540) % 360 - 180) * factor + 360) % 360;
424
398
  }
425
399
  /**
426
- * Automatically assigns a color to the most appropriate step based on its lightness.
400
+ * The ladder step whose lightness is closest to `lightness` — i.e. where a
401
+ * supplied colour naturally belongs.
427
402
  */
428
403
  function assignStepByLightness(lightness) {
429
404
  let closestStep = 500;
430
- let minDiff = Math.abs(lightness - DEFAULT_LIGHTNESS_SCALE[500]);
405
+ let minDiff = Math.abs(lightness - LIGHTNESS_LADDER[500]);
431
406
  for (const step of STEP_NAMES) {
432
- const diff = Math.abs(lightness - DEFAULT_LIGHTNESS_SCALE[step]);
407
+ const diff = Math.abs(lightness - LIGHTNESS_LADDER[step]);
433
408
  if (diff < minDiff) {
434
409
  minDiff = diff;
435
410
  closestStep = step;
@@ -438,68 +413,78 @@ function assignStepByLightness(lightness) {
438
413
  return closestStep;
439
414
  }
440
415
  /**
441
- * Generates a complete 11-step OKLCH palette from one or more colors.
442
- * Automatically determines which step each color belongs to based on lightness.
416
+ * How far an anchored colour sits from its step's ladder lightness.
417
+ *
418
+ * The generator surfaces this as a warning: a large deviation is legal (the
419
+ * caller asked for that exact colour) but it means the hue will read heavier or
420
+ * lighter than its siblings at that step, which is worth knowing rather than
421
+ * discovering later.
422
+ */
423
+ function ladderDeviation(step, lightness) {
424
+ return lightness - LIGHTNESS_LADDER[step];
425
+ }
426
+ /** Absolute chroma ceiling — beyond this nothing survives gamut mapping anyway. */
427
+ const MAX_CHROMA = .37;
428
+ /**
429
+ * Build a complete 11-step OKLCH ramp from one or more anchor colours.
430
+ *
431
+ * **Ladder-first with exact anchors.** Every anchor is reproduced *verbatim* at
432
+ * its step; every other step takes its lightness from `LIGHTNESS_LADDER`, with
433
+ * chroma and hue interpolated between the flanking anchors and decayed toward
434
+ * `ENDPOINT_CHROMA` beyond the outermost ones.
435
+ *
436
+ * The consequence is the point: a client's brand hex survives byte-for-byte,
437
+ * while the other ten steps stay directly comparable to every other hue. The
438
+ * deviation from the ladder is bounded and *local to anchored steps* — unlike
439
+ * the previous engine, which warped the whole ramp to fit its anchors so every
440
+ * step drifted.
441
+ *
442
+ * Chroma may come out beyond the sRGB gamut here; that is deliberate.
443
+ * `oklchStringToHex` gamut-maps with the CSS algorithm, which reduces chroma
444
+ * while holding lightness, so the ladder survives the conversion.
443
445
  */
444
446
  function generateOklchPalette(input) {
445
447
  let anchors = {};
446
- if (typeof input === "string") {
447
- const step = assignStepByLightness(parseOklch(input).l);
448
- anchors[step] = input;
449
- } else if (Array.isArray(input)) for (const colorStr of input) {
450
- const step = assignStepByLightness(parseOklch(colorStr).l);
451
- anchors[step] = colorStr;
452
- }
453
- else if (typeof input === "object") anchors = input;
448
+ if (typeof input === "string") anchors[assignStepByLightness(parseOklch(input).l)] = input;
449
+ else if (Array.isArray(input)) for (const colorStr of input) anchors[assignStepByLightness(parseOklch(colorStr).l)] = colorStr;
450
+ else if (typeof input === "object" && input !== null) anchors = { ...input };
454
451
  else throw new Error("Input must be a color string, array of colors, or object with step assignments");
455
452
  const parsedAnchors = {};
456
- for (const key in anchors) parsedAnchors[parseInt(key)] = parseOklch(anchors[key]);
457
- const sortedAnchorSteps = Object.keys(parsedAnchors).map(Number).sort((a, b) => a - b);
458
- const lightnessScale = transposeLightnessScale(parsedAnchors, sortedAnchorSteps);
453
+ for (const [key, value] of Object.entries(anchors)) parsedAnchors[Number(key)] = parseOklch(value);
454
+ const anchorSteps = Object.keys(parsedAnchors).map(Number).sort((a, b) => a - b);
455
+ const idx = (step) => STEP_NAMES.indexOf(step);
456
+ const lastIdx = STEP_NAMES.length - 1;
459
457
  const palette = {};
460
458
  for (const step of STEP_NAMES) {
461
459
  if (parsedAnchors[step]) {
462
460
  palette[step] = anchors[step];
463
461
  continue;
464
462
  }
465
- let startStep = null;
466
- let endStep = null;
467
- for (let i = sortedAnchorSteps.length - 1; i >= 0; i--) {
468
- const candidate = sortedAnchorSteps[i];
469
- if (candidate < step) {
470
- startStep = candidate;
471
- break;
472
- }
473
- }
474
- for (const anchorStep of sortedAnchorSteps) if (anchorStep > step) {
475
- endStep = anchorStep;
476
- break;
477
- }
478
- let c_int, h_int;
479
- if (startStep !== null && endStep !== null) {
480
- const startColor = parsedAnchors[startStep];
481
- const endColor = parsedAnchors[endStep];
482
- const span = endStep - startStep;
483
- const factor = (step - startStep) / span;
484
- c_int = lerp(startColor.c, endColor.c, factor);
485
- h_int = lerp(startColor.h, endColor.h, factor);
486
- } else if (startStep !== null) {
487
- const a = parsedAnchors[startStep];
488
- c_int = a.c;
489
- h_int = a.h;
490
- } else if (endStep !== null) {
491
- const a = parsedAnchors[endStep];
492
- c_int = a.c;
493
- h_int = a.h;
463
+ const lighter = [...anchorSteps].reverse().find((s) => s < step);
464
+ const darker = anchorSteps.find((s) => s > step);
465
+ let chroma;
466
+ let hue;
467
+ if (lighter !== void 0 && darker !== void 0) {
468
+ const a = parsedAnchors[lighter];
469
+ const b = parsedAnchors[darker];
470
+ const factor = (idx(step) - idx(lighter)) / (idx(darker) - idx(lighter));
471
+ chroma = lerp(a.c, b.c, factor);
472
+ hue = lerpHue(a.h, b.h, factor);
473
+ } else if (lighter !== void 0) {
474
+ const a = parsedAnchors[lighter];
475
+ const factor = (idx(step) - idx(lighter)) / (lastIdx - idx(lighter));
476
+ chroma = lerp(a.c, ENDPOINT_CHROMA.dark, factor);
477
+ hue = a.h;
478
+ } else if (darker !== void 0) {
479
+ const b = parsedAnchors[darker];
480
+ const factor = (idx(darker) - idx(step)) / idx(darker);
481
+ chroma = lerp(b.c, ENDPOINT_CHROMA.light, factor);
482
+ hue = b.h;
494
483
  } else {
495
- c_int = .1;
496
- h_int = 0;
484
+ chroma = .1;
485
+ hue = 0;
497
486
  }
498
- const l_int = lightnessScale[step];
499
- const dampeningFactor = l_int < .25 ? .3 + l_int / .25 * .7 : l_int > .75 ? .3 + (1 - l_int) / .25 * .7 : 1;
500
- c_int *= dampeningFactor;
501
- c_int = Math.min(c_int, .37);
502
- palette[step] = `oklch(${(l_int * 100).toFixed(2) + "%"} ${c_int.toFixed(4)} ${h_int.toFixed(2)})`;
487
+ palette[step] = `oklch(${(LIGHTNESS_LADDER[step] * 100).toFixed(2) + "%"} ${Math.min(chroma, MAX_CHROMA).toFixed(4)} ${hue.toFixed(2)})`;
503
488
  }
504
489
  return palette;
505
490
  }
@@ -529,17 +514,22 @@ function pickOn(bg, hue) {
529
514
  * The tinted off-white / off-black endpoints for a hue — white/black with a
530
515
  * whisper of the hue mixed in. These are the text/background tints every ramp
531
516
  * needs (and the one exception strict brand kits allow).
517
+ *
518
+ * Derived from `LIGHTNESS_LADDER` and `ENDPOINT_CHROMA` rather than its own
519
+ * literals, so a strict tone kit's endpoints land on the same ladder rungs a
520
+ * generated ramp would have used. This is the single definition — callers must
521
+ * not hand-write their own near-white/near-black.
532
522
  */
533
- function tintedEndpoints(hue, chroma = .01) {
523
+ function tintedEndpoints(hue, chroma) {
534
524
  return {
535
525
  light: oklchToHex({
536
- l: .98,
537
- c: Math.min(chroma, .02),
526
+ l: LIGHTNESS_LADDER[50],
527
+ c: Math.min(chroma ?? ENDPOINT_CHROMA.light, .02),
538
528
  h: hue
539
529
  }),
540
530
  dark: oklchToHex({
541
- l: .16,
542
- c: Math.min(chroma * 1.5, .03),
531
+ l: LIGHTNESS_LADDER[950],
532
+ c: Math.min((chroma ?? ENDPOINT_CHROMA.dark) * 1.5, .03),
543
533
  h: hue
544
534
  })
545
535
  };
@@ -647,5 +637,5 @@ function suggestFunctionalColorHue(type, existingHues) {
647
637
  }
648
638
 
649
639
  //#endregion
650
- export { COLOR_GROUPS, DEFAULT_FUNCTIONAL_HUES, HARMONY_DEFINITIONS, HARMONY_STRATEGIES, HARMONY_TYPES, STEP_NAMES, applyHarmonyStrategy, contrastLc, formatColorName, gamutMapOklchToHex, generateOklchPalette, getColorName, getColorNameWithHue, getHarmonySuggestions, hexToOklch, oklchStringToHex, oklchToHex, oklchToP3, oklchToSrgb, parseOklch, pickOn, suggestFunctionalColorHue, tintedEndpoints };
640
+ export { COLOR_GROUPS, DEFAULT_FUNCTIONAL_HUES, ENDPOINT_CHROMA, HARMONY_DEFINITIONS, HARMONY_STRATEGIES, HARMONY_TYPES, LIGHTNESS_LADDER, STEP_NAMES, applyHarmonyStrategy, assignStepByLightness, contrastLc, formatColorName, gamutMapOklchToHex, generateOklchPalette, getColorName, getColorNameWithHue, getHarmonySuggestions, hexToOklch, ladderDeviation, oklchStringToHex, oklchToHex, oklchToP3, oklchToSrgb, parseOklch, pickOn, suggestFunctionalColorHue, tintedEndpoints };
651
641
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["OKLCH_Space","sRGB_Space","P3_Space"],"sources":["../../src/color/colors.ts","../../src/color/color-harmony.ts"],"sourcesContent":["import Color from 'colorjs.io';\nimport {\n OKLCH as OKLCH_Space,\n sRGB as sRGB_Space,\n P3 as P3_Space,\n ColorSpace,\n to,\n toGamutCSS,\n clone,\n serialize,\n type PlainColorObject,\n} from 'colorjs.io/fn';\n\n// Register color spaces once for functional API\nColorSpace.register(OKLCH_Space);\nColorSpace.register(sRGB_Space);\nColorSpace.register(P3_Space);\n\nexport interface RgbResult {\n r: number;\n g: number;\n b: number;\n inGamut: boolean;\n /** Max channel overshoot beyond [0,1] before clamping. 0 when in gamut. */\n gamutDistance: number;\n}\n\n/**\n * Convert OKLCh to sRGB, returning 0-255 clamped values with gamut flag.\n * Fast path for per-pixel canvas rendering (no gamut mapping, just clamp).\n */\nexport function oklchToSrgb(l: number, c: number, h: number): RgbResult {\n const col: PlainColorObject = { space: OKLCH_Space, coords: [l, c, h], alpha: 1 };\n const rgb = to(col, sRGB_Space);\n const [r, g, b] = rgb.coords;\n const inGamut = r >= 0 && r <= 1 && g >= 0 && g <= 1 && b >= 0 && b <= 1;\n const gamutDistance = inGamut ? 0 : Math.max(-r, r - 1, -g, g - 1, -b, b - 1, 0);\n return {\n r: Math.max(0, Math.min(255, Math.round(r * 255))),\n g: Math.max(0, Math.min(255, Math.round(g * 255))),\n b: Math.max(0, Math.min(255, Math.round(b * 255))),\n inGamut,\n gamutDistance,\n };\n}\n\n/**\n * Convert OKLCh to Display P3, returning 0-255 clamped values with gamut flag.\n * Fast path for per-pixel canvas rendering on P3 displays.\n */\nexport function oklchToP3(l: number, c: number, h: number): RgbResult {\n const col: PlainColorObject = { space: OKLCH_Space, coords: [l, c, h], alpha: 1 };\n const rgb = to(col, P3_Space);\n const [r, g, b] = rgb.coords;\n const inGamut = r >= 0 && r <= 1 && g >= 0 && g <= 1 && b >= 0 && b <= 1;\n const gamutDistance = inGamut ? 0 : Math.max(-r, r - 1, -g, g - 1, -b, b - 1, 0);\n return {\n r: Math.max(0, Math.min(255, Math.round(r * 255))),\n g: Math.max(0, Math.min(255, Math.round(g * 255))),\n b: Math.max(0, Math.min(255, Math.round(b * 255))),\n inGamut,\n gamutDistance,\n };\n}\n\n/**\n * Gamut-map an OKLCh color using the CSS gamut mapping algorithm, return hex.\n * Slower than oklchToSrgb/oklchToP3 (uses iterative reduction), use for single colors only.\n */\nexport function gamutMapOklchToHex(\n l: number,\n c: number,\n h: number,\n space: 'srgb' | 'p3' = 'srgb',\n): string {\n const col: PlainColorObject = { space: OKLCH_Space, coords: [l, c, h], alpha: 1 };\n const targetSpace = space === 'p3' ? P3_Space : sRGB_Space;\n const mapped = toGamutCSS(clone(col), { space: targetSpace });\n const rgb = to(mapped, sRGB_Space);\n return serialize(rgb, { format: 'hex' });\n}\n\n// Standard 11-step scale - will be transposed based on input anchors\nexport const STEP_NAMES = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950] as const;\nexport type StepName = (typeof STEP_NAMES)[number];\n\nexport const COLOR_GROUPS = [\n 'neutral',\n 'brand',\n 'primary',\n 'accent',\n 'complement',\n 'success',\n 'warning',\n 'error',\n 'info',\n] as const;\nexport type ColorGroup = (typeof COLOR_GROUPS)[number];\n\n/**\n * Convert hex color to OKLCH components\n */\nexport function hexToOklch(hex: string): { l: number; c: number; h: number } {\n const color = new Color(hex);\n const oklch = color.to('oklch');\n return {\n l: oklch.coords[0],\n c: oklch.coords[1],\n h: oklch.coords[2] || 0,\n };\n}\n\n/**\n * Convert OKLCH components to hex color\n */\nexport function oklchToHex(oklch: { l: number; c: number; h: number }): string {\n const color = new Color('oklch', [oklch.l, oklch.c, oklch.h]);\n // Convert to sRGB and clamp to gamut, then format as hex\n const srgb = color.to('srgb');\n if (!srgb.inGamut()) {\n srgb.toGamut({ method: 'css' });\n }\n return srgb.toString({ format: 'hex' });\n}\n\n/**\n * Convert OKLCH CSS string to hex color\n * @example oklchStringToHex(\"oklch(50% 0.15 270)\") => \"#8b5cf6\"\n */\nexport function oklchStringToHex(oklchString: string): string {\n try {\n const color = new Color(oklchString);\n const srgb = color.to('srgb');\n if (!srgb.inGamut()) {\n srgb.toGamut({ method: 'css' });\n }\n return srgb.toString({ format: 'hex' });\n } catch {\n return '#808080';\n }\n}\n\n/**\n * Format a color name by separating compound words\n * Examples: \"mediumseagreen\" -> \"Medium Sea Green\", \"darkblue\" -> \"Dark Blue\"\n */\nexport function formatColorName(name: string): string {\n if (!name) return 'Unknown';\n\n // Handle special cases with proper word separation\n const specialCases: Record<string, string> = {\n aliceblue: 'Alice Blue',\n antiquewhite: 'Antique White',\n blanchedalmond: 'Blanched Almond',\n blueviolet: 'Blue Violet',\n burlywood: 'Burly Wood',\n cadetblue: 'Cadet Blue',\n cornflowerblue: 'Cornflower Blue',\n darkblue: 'Dark Blue',\n darkcyan: 'Dark Cyan',\n darkgoldenrod: 'Dark Goldenrod',\n darkgray: 'Dark Gray',\n darkgreen: 'Dark Green',\n darkgrey: 'Dark Grey',\n darkkhaki: 'Dark Khaki',\n darkmagenta: 'Dark Magenta',\n darkolivegreen: 'Dark Olive Green',\n darkorange: 'Dark Orange',\n darkorchid: 'Dark Orchid',\n darkred: 'Dark Red',\n darksalmon: 'Dark Salmon',\n darkseagreen: 'Dark Sea Green',\n darkslateblue: 'Dark Slate Blue',\n darkslategray: 'Dark Slate Gray',\n darkslategrey: 'Dark Slate Grey',\n darkturquoise: 'Dark Turquoise',\n darkviolet: 'Dark Violet',\n deeppink: 'Deep Pink',\n deepskyblue: 'Deep Sky Blue',\n dimgray: 'Dim Gray',\n dimgrey: 'Dim Grey',\n dodgerblue: 'Dodger Blue',\n floralwhite: 'Floral White',\n forestgreen: 'Forest Green',\n ghostwhite: 'Ghost White',\n greenyellow: 'Green Yellow',\n hotpink: 'Hot Pink',\n indianred: 'Indian Red',\n lavenderblush: 'Lavender Blush',\n lawngreen: 'Lawn Green',\n lemonchiffon: 'Lemon Chiffon',\n lightblue: 'Light Blue',\n lightcoral: 'Light Coral',\n lightcyan: 'Light Cyan',\n lightgoldenrodyellow: 'Light Goldenrod Yellow',\n lightgray: 'Light Gray',\n lightgreen: 'Light Green',\n lightgrey: 'Light Grey',\n lightpink: 'Light Pink',\n lightsalmon: 'Light Salmon',\n lightseagreen: 'Light Sea Green',\n lightskyblue: 'Light Sky Blue',\n lightslategray: 'Light Slate Gray',\n lightslategrey: 'Light Slate Grey',\n lightsteelblue: 'Light Steel Blue',\n lightyellow: 'Light Yellow',\n limegreen: 'Lime Green',\n mediumaquamarine: 'Medium Aquamarine',\n mediumblue: 'Medium Blue',\n mediumorchid: 'Medium Orchid',\n mediumpurple: 'Medium Purple',\n mediumseagreen: 'Medium Sea Green',\n mediumslateblue: 'Medium Slate Blue',\n mediumspringgreen: 'Medium Spring Green',\n mediumturquoise: 'Medium Turquoise',\n mediumvioletred: 'Medium Violet Red',\n midnightblue: 'Midnight Blue',\n mintcream: 'Mint Cream',\n mistyrose: 'Misty Rose',\n navajowhite: 'Navajo White',\n oldlace: 'Old Lace',\n olivedrab: 'Olive Drab',\n orangered: 'Orange Red',\n palegoldenrod: 'Pale Goldenrod',\n palegreen: 'Pale Green',\n paleturquoise: 'Pale Turquoise',\n palevioletred: 'Pale Violet Red',\n papayawhip: 'Papaya Whip',\n peachpuff: 'Peach Puff',\n powderblue: 'Powder Blue',\n rosybrown: 'Rosy Brown',\n royalblue: 'Royal Blue',\n saddlebrown: 'Saddle Brown',\n sandybrown: 'Sandy Brown',\n seagreen: 'Sea Green',\n skyblue: 'Sky Blue',\n slateblue: 'Slate Blue',\n slategray: 'Slate Gray',\n slategrey: 'Slate Grey',\n springgreen: 'Spring Green',\n steelblue: 'Steel Blue',\n whitesmoke: 'White Smoke',\n yellowgreen: 'Yellow Green',\n };\n\n const lowerName = name.toLowerCase();\n if (specialCases[lowerName]) {\n return specialCases[lowerName];\n }\n\n // Default: just capitalize first letter\n return name.charAt(0).toUpperCase() + name.slice(1);\n}\n\n/**\n * Get the closest CSS color name for a hex color\n */\nexport function getColorName(hex: string): string {\n try {\n const color = new Color(hex);\n const oklch = color.to('oklch');\n const hue = oklch.coords[2] || 0;\n\n if (hue < 30 || hue >= 330) return 'Red';\n if (hue < 60) return 'Orange';\n if (hue < 90) return 'Yellow';\n if (hue < 150) return 'Green';\n if (hue < 210) return 'Cyan';\n if (hue < 270) return 'Blue';\n if (hue < 330) return 'Purple';\n return 'Unknown';\n } catch {\n return 'Unknown';\n }\n}\n\n/**\n * Get color name with hue value\n */\nexport function getColorNameWithHue(hex: string): string {\n try {\n const color = new Color(hex);\n const oklch = color.to('oklch');\n const hue = oklch.coords[2] || 0;\n const roundedHue = Math.round(hue / 10) * 10;\n const name = getColorName(hex);\n return `${name} ${roundedHue}`;\n } catch {\n return 'Unknown';\n }\n}\n\n// Color harmony definitions\nexport const HARMONY_TYPES = [\n 'single',\n 'analogous',\n 'triad',\n 'complementary',\n 'split-complementary',\n 'square',\n 'compound',\n] as const;\nexport type HarmonyType = (typeof HARMONY_TYPES)[number];\n\nexport interface HarmonyDefinition {\n label: string;\n offsets: number[];\n primaryIndex: number;\n}\n\nexport const HARMONY_DEFINITIONS: Record<HarmonyType, HarmonyDefinition> = {\n single: {\n label: 'Single',\n offsets: [0],\n primaryIndex: 0,\n },\n analogous: {\n label: 'Analogous',\n offsets: [-30, 0, 30],\n primaryIndex: 1,\n },\n triad: {\n label: 'Triad',\n offsets: [0, 120, 240],\n primaryIndex: 0,\n },\n complementary: {\n label: 'Complementary',\n offsets: [0, 180],\n primaryIndex: 0,\n },\n 'split-complementary': {\n label: 'Split Complementary',\n offsets: [0, 150, 210],\n primaryIndex: 0,\n },\n square: {\n label: 'Square',\n offsets: [0, 90, 180, 270],\n primaryIndex: 0,\n },\n compound: {\n label: 'Compound',\n offsets: [-30, 0, 180, 210],\n primaryIndex: 1,\n },\n};\n\n// Default lightness positions (lightest to darkest)\nconst DEFAULT_LIGHTNESS_SCALE: Record<StepName, number> = {\n 50: 0.95,\n 100: 0.9,\n 200: 0.8,\n 300: 0.7,\n 400: 0.6,\n 500: 0.5,\n 600: 0.4,\n 700: 0.3,\n 800: 0.2,\n 900: 0.1,\n 950: 0.05,\n};\n\ninterface OklchColor {\n l: number;\n c: number;\n h: number;\n}\n\n/**\n * Parses an OKLCH CSS string into numerical components.\n * @param oklchString - e.g., 'oklch(50% 0.15 270)'\n * @returns Lightness (0-1), Chroma (0-~0.37), Hue (0-360)\n */\nexport function parseOklch(oklchString: string): OklchColor {\n const parts = oklchString.match(/oklch\\(([^ ]+) ([^ ]+) ([^ ]+)\\)/);\n if (!parts) throw new Error('Invalid OKLCH string format.');\n\n const [, lRaw = '', cRaw = '', hRaw = ''] = parts;\n const l = parseFloat(lRaw) / (lRaw.includes('%') ? 100 : 1);\n const c = parseFloat(cRaw);\n const h = parseFloat(hRaw);\n\n return { l, c, h };\n}\n\n/**\n * Linearly interpolates a value between a start and end point.\n */\nfunction lerp(start: number, end: number, factor: number): number {\n return start + factor * (end - start);\n}\n\n/**\n * Transpose the default lightness scale to match the provided anchors.\n */\nfunction transposeLightnessScale(\n parsedAnchors: Record<StepName, OklchColor>,\n sortedAnchorSteps: StepName[],\n): Record<StepName, number> {\n const transposedScale: Record<number, number> = {};\n\n if (sortedAnchorSteps.length === 1) {\n const anchorStep = sortedAnchorSteps[0] as StepName;\n const anchorL = (parsedAnchors[anchorStep] as OklchColor).l;\n const defaultAnchorL = DEFAULT_LIGHTNESS_SCALE[anchorStep];\n\n for (const step of STEP_NAMES) {\n if (step === anchorStep) {\n transposedScale[step] = anchorL;\n continue;\n }\n\n const defaultStepL = DEFAULT_LIGHTNESS_SCALE[step];\n\n if (defaultStepL > defaultAnchorL) {\n const factor = (defaultStepL - defaultAnchorL) / (1.0 - defaultAnchorL);\n transposedScale[step] = lerp(anchorL, 0.97, factor);\n } else {\n const factor = defaultStepL / defaultAnchorL;\n transposedScale[step] = lerp(0.05, anchorL, factor);\n }\n }\n\n return transposedScale;\n }\n\n for (const step of STEP_NAMES) {\n const anchored = parsedAnchors[step];\n if (anchored) {\n transposedScale[step] = anchored.l;\n continue;\n }\n\n let lowerStep: StepName | null = null;\n let upperStep: StepName | null = null;\n\n for (let i = sortedAnchorSteps.length - 1; i >= 0; i--) {\n const candidate = sortedAnchorSteps[i] as StepName;\n if (candidate < step) {\n lowerStep = candidate;\n break;\n }\n }\n\n for (const anchorStep of sortedAnchorSteps) {\n if (anchorStep > step) {\n upperStep = anchorStep;\n break;\n }\n }\n\n if (lowerStep !== null && upperStep !== null) {\n const lowerL = (parsedAnchors[lowerStep] as OklchColor).l;\n const upperL = (parsedAnchors[upperStep] as OklchColor).l;\n const span = upperStep - lowerStep;\n const position = step - lowerStep;\n const factor = position / span;\n transposedScale[step] = lerp(lowerL, upperL, factor);\n } else if (lowerStep !== null) {\n const lowerL = (parsedAnchors[lowerStep] as OklchColor).l;\n const defaultLowerL = DEFAULT_LIGHTNESS_SCALE[lowerStep];\n const defaultStepL = DEFAULT_LIGHTNESS_SCALE[step];\n const factor = defaultStepL / defaultLowerL;\n transposedScale[step] = lerp(0.05, lowerL, factor);\n } else if (upperStep !== null) {\n const upperL = (parsedAnchors[upperStep] as OklchColor).l;\n const defaultUpperL = DEFAULT_LIGHTNESS_SCALE[upperStep];\n const defaultStepL = DEFAULT_LIGHTNESS_SCALE[step];\n const factor = (defaultStepL - defaultUpperL) / (1.0 - defaultUpperL);\n transposedScale[step] = lerp(upperL, 0.97, factor);\n }\n }\n\n return transposedScale;\n}\n\n/**\n * Automatically assigns a color to the most appropriate step based on its lightness.\n */\nfunction assignStepByLightness(lightness: number): StepName {\n let closestStep: StepName = 500;\n let minDiff = Math.abs(lightness - DEFAULT_LIGHTNESS_SCALE[500]);\n\n for (const step of STEP_NAMES) {\n const diff = Math.abs(lightness - DEFAULT_LIGHTNESS_SCALE[step]);\n if (diff < minDiff) {\n minDiff = diff;\n closestStep = step;\n }\n }\n\n return closestStep;\n}\n\n/**\n * Generates a complete 11-step OKLCH palette from one or more colors.\n * Automatically determines which step each color belongs to based on lightness.\n */\nexport function generateOklchPalette(\n input: string | string[] | Record<string, string>,\n): Record<StepName, string> {\n let anchors: Record<number, string> = {};\n\n if (typeof input === 'string') {\n const parsed = parseOklch(input);\n const step = assignStepByLightness(parsed.l);\n anchors[step] = input;\n } else if (Array.isArray(input)) {\n for (const colorStr of input) {\n const parsed = parseOklch(colorStr);\n const step = assignStepByLightness(parsed.l);\n anchors[step] = colorStr;\n }\n } else if (typeof input === 'object') {\n anchors = input;\n } else {\n throw new Error(\n 'Input must be a color string, array of colors, or object with step assignments',\n );\n }\n\n const parsedAnchors: Record<number, OklchColor> = {};\n\n for (const key in anchors) {\n parsedAnchors[parseInt(key)] = parseOklch(anchors[key] as string);\n }\n\n const sortedAnchorSteps = Object.keys(parsedAnchors)\n .map(Number)\n .sort((a, b) => a - b) as StepName[];\n\n const lightnessScale = transposeLightnessScale(\n parsedAnchors as Record<StepName, OklchColor>,\n sortedAnchorSteps,\n );\n\n const palette: Record<number, string> = {};\n\n for (const step of STEP_NAMES) {\n if (parsedAnchors[step]) {\n palette[step] = anchors[step] as string;\n continue;\n }\n\n let startStep: StepName | null = null;\n let endStep: StepName | null = null;\n\n for (let i = sortedAnchorSteps.length - 1; i >= 0; i--) {\n const candidate = sortedAnchorSteps[i] as StepName;\n if (candidate < step) {\n startStep = candidate;\n break;\n }\n }\n\n for (const anchorStep of sortedAnchorSteps) {\n if (anchorStep > step) {\n endStep = anchorStep;\n break;\n }\n }\n\n let c_int, h_int;\n\n if (startStep !== null && endStep !== null) {\n const startColor = parsedAnchors[startStep] as OklchColor;\n const endColor = parsedAnchors[endStep] as OklchColor;\n const span = endStep - startStep;\n const position = step - startStep;\n const factor = position / span;\n\n c_int = lerp(startColor.c, endColor.c, factor);\n h_int = lerp(startColor.h, endColor.h, factor);\n } else if (startStep !== null) {\n const a = parsedAnchors[startStep] as OklchColor;\n c_int = a.c;\n h_int = a.h;\n } else if (endStep !== null) {\n const a = parsedAnchors[endStep] as OklchColor;\n c_int = a.c;\n h_int = a.h;\n } else {\n c_int = 0.1;\n h_int = 0;\n }\n\n const l_int = lightnessScale[step] as number;\n\n const dampeningFactor =\n l_int < 0.25\n ? 0.3 + (l_int / 0.25) * 0.7\n : l_int > 0.75\n ? 0.3 + ((1 - l_int) / 0.25) * 0.7\n : 1.0;\n\n c_int *= dampeningFactor;\n c_int = Math.min(c_int, 0.37);\n\n const finalL = (l_int * 100).toFixed(2) + '%';\n const finalC = c_int.toFixed(4);\n const finalH = h_int.toFixed(2);\n\n palette[step] = `oklch(${finalL} ${finalC} ${finalH})`;\n }\n\n return palette;\n}\n\n// ── Contrast + endpoints (for the functional-token layer) ────────────────────\n\n/** APCA lightness-contrast (Lc) magnitude between a foreground and background. */\nexport function contrastLc(fg: string, bg: string): number {\n return Math.abs(new Color(bg).contrast(fg, 'APCA'));\n}\n\n/**\n * Pick a tinted near-white or near-black foreground for best contrast on `bg`\n * (a whisper of the background's hue mixed into off-white/off-black).\n */\nexport function pickOn(bg: string, hue?: number): string {\n const h = hue ?? hexToOklch(bg).h;\n const white = oklchToHex({ l: 0.98, c: 0.01, h });\n const black = oklchToHex({ l: 0.16, c: 0.02, h });\n return contrastLc(white, bg) >= contrastLc(black, bg) ? white : black;\n}\n\n/**\n * The tinted off-white / off-black endpoints for a hue — white/black with a\n * whisper of the hue mixed in. These are the text/background tints every ramp\n * needs (and the one exception strict brand kits allow).\n */\nexport function tintedEndpoints(hue: number, chroma = 0.01): { light: string; dark: string } {\n return {\n light: oklchToHex({ l: 0.98, c: Math.min(chroma, 0.02), h: hue }),\n dark: oklchToHex({ l: 0.16, c: Math.min(chroma * 1.5, 0.03), h: hue }),\n };\n}\n","/**\n * Color harmony strategies for generating complementary colors\n */\n\nexport type HarmonyStrategy =\n | 'complement'\n | 'analogous-plus'\n | 'analogous-minus'\n | 'triadic-plus'\n | 'triadic-minus'\n | 'split-plus'\n | 'split-minus'\n | 'tetradic-plus'\n | 'tetradic-minus';\n\nexport interface HarmonyOption {\n id: HarmonyStrategy;\n label: string;\n description: string;\n hueShift: number;\n}\n\nexport const HARMONY_STRATEGIES: HarmonyOption[] = [\n {\n id: 'complement',\n label: 'Complement',\n description: 'Opposite on color wheel (high contrast)',\n hueShift: 180,\n },\n {\n id: 'analogous-plus',\n label: 'Analogous+',\n description: 'Adjacent colors (harmonious)',\n hueShift: 30,\n },\n {\n id: 'analogous-minus',\n label: 'Analogous-',\n description: 'Adjacent colors (harmonious)',\n hueShift: -30,\n },\n {\n id: 'triadic-plus',\n label: 'Triadic+',\n description: 'Evenly spaced (balanced)',\n hueShift: 120,\n },\n {\n id: 'triadic-minus',\n label: 'Triadic-',\n description: 'Evenly spaced (balanced)',\n hueShift: -120,\n },\n {\n id: 'split-plus',\n label: 'Split Complement+',\n description: 'Near opposite (softer contrast)',\n hueShift: 150,\n },\n {\n id: 'split-minus',\n label: 'Split Complement-',\n description: 'Near opposite (softer contrast)',\n hueShift: -150,\n },\n {\n id: 'tetradic-plus',\n label: 'Tetradic+',\n description: 'Square spacing (rich palette)',\n hueShift: 90,\n },\n {\n id: 'tetradic-minus',\n label: 'Tetradic-',\n description: 'Square spacing (rich palette)',\n hueShift: -90,\n },\n];\n\n/**\n * Applies a harmony strategy to a hue value\n */\nexport function applyHarmonyStrategy(baseHue: number, strategy: HarmonyStrategy): number {\n const harmonyOption = HARMONY_STRATEGIES.find((h) => h.id === strategy);\n if (!harmonyOption) return baseHue;\n\n let newHue = baseHue + harmonyOption.hueShift;\n\n // Normalize to 0-360 range\n while (newHue < 0) newHue += 360;\n while (newHue >= 360) newHue -= 360;\n\n return newHue;\n}\n\n/**\n * Gets all harmony suggestions for a given base hue\n */\nexport function getHarmonySuggestions(\n baseHue: number,\n): Array<{ strategy: HarmonyStrategy; hue: number; label: string; description: string }> {\n return HARMONY_STRATEGIES.map((strategy) => ({\n strategy: strategy.id,\n hue: applyHarmonyStrategy(baseHue, strategy.id),\n label: strategy.label,\n description: strategy.description,\n }));\n}\n\n/**\n * Default functional color hues (if user doesn't specify)\n */\nexport const DEFAULT_FUNCTIONAL_HUES = {\n success: 142, // Green\n warning: 38, // Orange/Amber\n error: 0, // Red\n info: 200, // Blue\n} as const;\n\n/**\n * Suggests a functional color hue based on existing palette to maintain harmony\n */\nexport function suggestFunctionalColorHue(\n type: keyof typeof DEFAULT_FUNCTIONAL_HUES,\n existingHues: number[],\n): number {\n const defaultHue = DEFAULT_FUNCTIONAL_HUES[type];\n\n if (existingHues.length === 0) {\n return defaultHue;\n }\n\n // Find the closest existing hue and adjust slightly to maintain harmony\n const avgHue = existingHues.reduce((sum, h) => sum + h, 0) / existingHues.length;\n\n // Rotate the default hue to be more in line with the palette's color temperature\n const hueShift = avgHue - 200; // Assuming 200 is neutral blue\n let adjustedHue = defaultHue + hueShift * 0.3; // 30% influence\n\n // Normalize\n while (adjustedHue < 0) adjustedHue += 360;\n while (adjustedHue >= 360) adjustedHue -= 360;\n\n return adjustedHue;\n}\n"],"mappings":";;;;AAcA,WAAW,SAASA,KAAW;AAC/B,WAAW,SAASC,IAAU;AAC9B,WAAW,SAASC,EAAQ;;;;;AAe5B,SAAgB,YAAY,GAAW,GAAW,GAAsB;CAGtE,MAAM,CAAC,GAAG,GAAG,KADD,GAAG;EADiB,OAAOF;EAAa,QAAQ;GAAC;GAAG;GAAG;EAAC;EAAG,OAAO;CAC7D,GAAGC,IACA,CAAC,CAAC;CACtB,MAAM,UAAU,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK;CACvE,MAAM,gBAAgB,UAAU,IAAI,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC;CAC/E,OAAO;EACL,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,KAAK,MAAM,IAAI,GAAG,CAAC,CAAC;EACjD,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,KAAK,MAAM,IAAI,GAAG,CAAC,CAAC;EACjD,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,KAAK,MAAM,IAAI,GAAG,CAAC,CAAC;EACjD;EACA;CACF;AACF;;;;;AAMA,SAAgB,UAAU,GAAW,GAAW,GAAsB;CAGpE,MAAM,CAAC,GAAG,GAAG,KADD,GAAG;EADiB,OAAOD;EAAa,QAAQ;GAAC;GAAG;GAAG;EAAC;EAAG,OAAO;CAC7D,GAAGE,EACA,CAAC,CAAC;CACtB,MAAM,UAAU,KAAK,KAAK,KAAK,KAAK,KAAK,KAA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CACT,OAAO;CACP,MAAM;AACR;;;;AAKA,SAAgB,0BACd,MACA,cACQ;CACR,MAAM,aAAa,wBAAwB;CAE3C,IAAI,aAAa,WAAW,GAC1B,OAAO;CAQT,IAAI,cAAc,cAJH,aAAa,QAAQ,KAAK,MAAM,MAAM,GAAG,CAAC,IAAI,aAAa,SAGhD,OACgB;CAG1C,OAAO,cAAc,GAAG,eAAe;CACvC,OAAO,eAAe,KAAK,eAAe;CAE1C,OAAO;AACT"}
1
+ {"version":3,"file":"index.mjs","names":["OKLCH_Space","sRGB_Space","P3_Space"],"sources":["../../src/color/colors.ts","../../src/color/color-harmony.ts"],"sourcesContent":["import Color from 'colorjs.io';\nimport {\n OKLCH as OKLCH_Space,\n sRGB as sRGB_Space,\n P3 as P3_Space,\n ColorSpace,\n to,\n toGamutCSS,\n clone,\n serialize,\n type PlainColorObject,\n} from 'colorjs.io/fn';\n\n// Register color spaces once for functional API\nColorSpace.register(OKLCH_Space);\nColorSpace.register(sRGB_Space);\nColorSpace.register(P3_Space);\n\nexport interface RgbResult {\n r: number;\n g: number;\n b: number;\n inGamut: boolean;\n /** Max channel overshoot beyond [0,1] before clamping. 0 when in gamut. */\n gamutDistance: number;\n}\n\n/**\n * Convert OKLCh to sRGB, returning 0-255 clamped values with gamut flag.\n * Fast path for per-pixel canvas rendering (no gamut mapping, just clamp).\n */\nexport function oklchToSrgb(l: number, c: number, h: number): RgbResult {\n const col: PlainColorObject = { space: OKLCH_Space, coords: [l, c, h], alpha: 1 };\n const rgb = to(col, sRGB_Space);\n const [r, g, b] = rgb.coords;\n const inGamut = r >= 0 && r <= 1 && g >= 0 && g <= 1 && b >= 0 && b <= 1;\n const gamutDistance = inGamut ? 0 : Math.max(-r, r - 1, -g, g - 1, -b, b - 1, 0);\n return {\n r: Math.max(0, Math.min(255, Math.round(r * 255))),\n g: Math.max(0, Math.min(255, Math.round(g * 255))),\n b: Math.max(0, Math.min(255, Math.round(b * 255))),\n inGamut,\n gamutDistance,\n };\n}\n\n/**\n * Convert OKLCh to Display P3, returning 0-255 clamped values with gamut flag.\n * Fast path for per-pixel canvas rendering on P3 displays.\n */\nexport function oklchToP3(l: number, c: number, h: number): RgbResult {\n const col: PlainColorObject = { space: OKLCH_Space, coords: [l, c, h], alpha: 1 };\n const rgb = to(col, P3_Space);\n const [r, g, b] = rgb.coords;\n const inGamut = r >= 0 && r <= 1 && g >= 0 && g <= 1 && b >= 0 && b <= 1;\n const gamutDistance = inGamut ? 0 : Math.max(-r, r - 1, -g, g - 1, -b, b - 1, 0);\n return {\n r: Math.max(0, Math.min(255, Math.round(r * 255))),\n g: Math.max(0, Math.min(255, Math.round(g * 255))),\n b: Math.max(0, Math.min(255, Math.round(b * 255))),\n inGamut,\n gamutDistance,\n };\n}\n\n/**\n * Gamut-map an OKLCh color using the CSS gamut mapping algorithm, return hex.\n * Slower than oklchToSrgb/oklchToP3 (uses iterative reduction), use for single colors only.\n */\nexport function gamutMapOklchToHex(\n l: number,\n c: number,\n h: number,\n space: 'srgb' | 'p3' = 'srgb',\n): string {\n const col: PlainColorObject = { space: OKLCH_Space, coords: [l, c, h], alpha: 1 };\n const targetSpace = space === 'p3' ? P3_Space : sRGB_Space;\n const mapped = toGamutCSS(clone(col), { space: targetSpace });\n const rgb = to(mapped, sRGB_Space);\n return serialize(rgb, { format: 'hex' });\n}\n\n// Standard 11-step scale - will be transposed based on input anchors\nexport const STEP_NAMES = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950] as const;\nexport type StepName = (typeof STEP_NAMES)[number];\n\nexport const COLOR_GROUPS = [\n 'neutral',\n 'brand',\n 'primary',\n 'accent',\n 'complement',\n 'success',\n 'warning',\n 'error',\n 'info',\n] as const;\nexport type ColorGroup = (typeof COLOR_GROUPS)[number];\n\n/**\n * Convert hex color to OKLCH components\n */\nexport function hexToOklch(hex: string): { l: number; c: number; h: number } {\n const color = new Color(hex);\n const oklch = color.to('oklch');\n return {\n l: oklch.coords[0],\n c: oklch.coords[1],\n h: oklch.coords[2] || 0,\n };\n}\n\n/**\n * Convert OKLCH components to hex color\n */\nexport function oklchToHex(oklch: { l: number; c: number; h: number }): string {\n const color = new Color('oklch', [oklch.l, oklch.c, oklch.h]);\n // Convert to sRGB and clamp to gamut, then format as hex\n const srgb = color.to('srgb');\n if (!srgb.inGamut()) {\n srgb.toGamut({ method: 'css' });\n }\n return srgb.toString({ format: 'hex' });\n}\n\n/**\n * Convert OKLCH CSS string to hex color\n * @example oklchStringToHex(\"oklch(50% 0.15 270)\") => \"#8b5cf6\"\n */\nexport function oklchStringToHex(oklchString: string): string {\n try {\n const color = new Color(oklchString);\n const srgb = color.to('srgb');\n if (!srgb.inGamut()) {\n srgb.toGamut({ method: 'css' });\n }\n return srgb.toString({ format: 'hex' });\n } catch {\n return '#808080';\n }\n}\n\n/**\n * Format a color name by separating compound words\n * Examples: \"mediumseagreen\" -> \"Medium Sea Green\", \"darkblue\" -> \"Dark Blue\"\n */\nexport function formatColorName(name: string): string {\n if (!name) return 'Unknown';\n\n // Handle special cases with proper word separation\n const specialCases: Record<string, string> = {\n aliceblue: 'Alice Blue',\n antiquewhite: 'Antique White',\n blanchedalmond: 'Blanched Almond',\n blueviolet: 'Blue Violet',\n burlywood: 'Burly Wood',\n cadetblue: 'Cadet Blue',\n cornflowerblue: 'Cornflower Blue',\n darkblue: 'Dark Blue',\n darkcyan: 'Dark Cyan',\n darkgoldenrod: 'Dark Goldenrod',\n darkgray: 'Dark Gray',\n darkgreen: 'Dark Green',\n darkgrey: 'Dark Grey',\n darkkhaki: 'Dark Khaki',\n darkmagenta: 'Dark Magenta',\n darkolivegreen: 'Dark Olive Green',\n darkorange: 'Dark Orange',\n darkorchid: 'Dark Orchid',\n darkred: 'Dark Red',\n darksalmon: 'Dark Salmon',\n darkseagreen: 'Dark Sea Green',\n darkslateblue: 'Dark Slate Blue',\n darkslategray: 'Dark Slate Gray',\n darkslategrey: 'Dark Slate Grey',\n darkturquoise: 'Dark Turquoise',\n darkviolet: 'Dark Violet',\n deeppink: 'Deep Pink',\n deepskyblue: 'Deep Sky Blue',\n dimgray: 'Dim Gray',\n dimgrey: 'Dim Grey',\n dodgerblue: 'Dodger Blue',\n floralwhite: 'Floral White',\n forestgreen: 'Forest Green',\n ghostwhite: 'Ghost White',\n greenyellow: 'Green Yellow',\n hotpink: 'Hot Pink',\n indianred: 'Indian Red',\n lavenderblush: 'Lavender Blush',\n lawngreen: 'Lawn Green',\n lemonchiffon: 'Lemon Chiffon',\n lightblue: 'Light Blue',\n lightcoral: 'Light Coral',\n lightcyan: 'Light Cyan',\n lightgoldenrodyellow: 'Light Goldenrod Yellow',\n lightgray: 'Light Gray',\n lightgreen: 'Light Green',\n lightgrey: 'Light Grey',\n lightpink: 'Light Pink',\n lightsalmon: 'Light Salmon',\n lightseagreen: 'Light Sea Green',\n lightskyblue: 'Light Sky Blue',\n lightslategray: 'Light Slate Gray',\n lightslategrey: 'Light Slate Grey',\n lightsteelblue: 'Light Steel Blue',\n lightyellow: 'Light Yellow',\n limegreen: 'Lime Green',\n mediumaquamarine: 'Medium Aquamarine',\n mediumblue: 'Medium Blue',\n mediumorchid: 'Medium Orchid',\n mediumpurple: 'Medium Purple',\n mediumseagreen: 'Medium Sea Green',\n mediumslateblue: 'Medium Slate Blue',\n mediumspringgreen: 'Medium Spring Green',\n mediumturquoise: 'Medium Turquoise',\n mediumvioletred: 'Medium Violet Red',\n midnightblue: 'Midnight Blue',\n mintcream: 'Mint Cream',\n mistyrose: 'Misty Rose',\n navajowhite: 'Navajo White',\n oldlace: 'Old Lace',\n olivedrab: 'Olive Drab',\n orangered: 'Orange Red',\n palegoldenrod: 'Pale Goldenrod',\n palegreen: 'Pale Green',\n paleturquoise: 'Pale Turquoise',\n palevioletred: 'Pale Violet Red',\n papayawhip: 'Papaya Whip',\n peachpuff: 'Peach Puff',\n powderblue: 'Powder Blue',\n rosybrown: 'Rosy Brown',\n royalblue: 'Royal Blue',\n saddlebrown: 'Saddle Brown',\n sandybrown: 'Sandy Brown',\n seagreen: 'Sea Green',\n skyblue: 'Sky Blue',\n slateblue: 'Slate Blue',\n slategray: 'Slate Gray',\n slategrey: 'Slate Grey',\n springgreen: 'Spring Green',\n steelblue: 'Steel Blue',\n whitesmoke: 'White Smoke',\n yellowgreen: 'Yellow Green',\n };\n\n const lowerName = name.toLowerCase();\n if (specialCases[lowerName]) {\n return specialCases[lowerName];\n }\n\n // Default: just capitalize first letter\n return name.charAt(0).toUpperCase() + name.slice(1);\n}\n\n/**\n * Get the closest CSS color name for a hex color\n */\nexport function getColorName(hex: string): string {\n try {\n const color = new Color(hex);\n const oklch = color.to('oklch');\n const hue = oklch.coords[2] || 0;\n\n if (hue < 30 || hue >= 330) return 'Red';\n if (hue < 60) return 'Orange';\n if (hue < 90) return 'Yellow';\n if (hue < 150) return 'Green';\n if (hue < 210) return 'Cyan';\n if (hue < 270) return 'Blue';\n if (hue < 330) return 'Purple';\n return 'Unknown';\n } catch {\n return 'Unknown';\n }\n}\n\n/**\n * Get color name with hue value\n */\nexport function getColorNameWithHue(hex: string): string {\n try {\n const color = new Color(hex);\n const oklch = color.to('oklch');\n const hue = oklch.coords[2] || 0;\n const roundedHue = Math.round(hue / 10) * 10;\n const name = getColorName(hex);\n return `${name} ${roundedHue}`;\n } catch {\n return 'Unknown';\n }\n}\n\n// Color harmony definitions\nexport const HARMONY_TYPES = [\n 'single',\n 'analogous',\n 'triad',\n 'complementary',\n 'split-complementary',\n 'square',\n 'compound',\n] as const;\nexport type HarmonyType = (typeof HARMONY_TYPES)[number];\n\nexport interface HarmonyDefinition {\n label: string;\n offsets: number[];\n primaryIndex: number;\n}\n\nexport const HARMONY_DEFINITIONS: Record<HarmonyType, HarmonyDefinition> = {\n single: {\n label: 'Single',\n offsets: [0],\n primaryIndex: 0,\n },\n analogous: {\n label: 'Analogous',\n offsets: [-30, 0, 30],\n primaryIndex: 1,\n },\n triad: {\n label: 'Triad',\n offsets: [0, 120, 240],\n primaryIndex: 0,\n },\n complementary: {\n label: 'Complementary',\n offsets: [0, 180],\n primaryIndex: 0,\n },\n 'split-complementary': {\n label: 'Split Complementary',\n offsets: [0, 150, 210],\n primaryIndex: 0,\n },\n square: {\n label: 'Square',\n offsets: [0, 90, 180, 270],\n primaryIndex: 0,\n },\n compound: {\n label: 'Compound',\n offsets: [-30, 0, 180, 210],\n primaryIndex: 1,\n },\n};\n\n/**\n * The shared lightness ladder every ramp is built on (lightest → darkest).\n *\n * Fixed, NOT seed-derived. Two hues at the same step have to read equally light,\n * otherwise one contrast table cannot serve every hue and a `muted` variant means\n * something different depending on which role you ask. Only chroma and hue vary\n * between ramps.\n *\n * The previous engine transposed this curve onto each seed, which let relative\n * luminance at step 300 range from 0.253 (rust) to 0.384 (amber) across the\n * shipped palette — the drift this replaces.\n *\n * Anchored steps are the one deliberate exception: see `generateOklchPalette`.\n */\nexport const LIGHTNESS_LADDER: Record<StepName, number> = {\n 50: 0.98,\n 100: 0.95,\n 200: 0.9,\n 300: 0.83,\n 400: 0.74,\n 500: 0.65,\n 600: 0.54,\n 700: 0.47,\n 800: 0.38,\n 900: 0.29,\n 950: 0.21,\n};\n\n/**\n * Chroma a ramp decays to beyond its outermost anchors, so the near-white and\n * near-black ends keep a whisper of the hue instead of going flat grey. The dark\n * end carries slightly more because chroma reads weaker against black.\n */\nexport const ENDPOINT_CHROMA = { light: 0.008, dark: 0.015 } as const;\n\ninterface OklchColor {\n l: number;\n c: number;\n h: number;\n}\n\n/**\n * Parses an OKLCH CSS string into numerical components.\n * @param oklchString - e.g., 'oklch(50% 0.15 270)'\n * @returns Lightness (0-1), Chroma (0-~0.37), Hue (0-360)\n */\nexport function parseOklch(oklchString: string): OklchColor {\n const parts = oklchString.match(/oklch\\(([^ ]+) ([^ ]+) ([^ ]+)\\)/);\n if (!parts) throw new Error('Invalid OKLCH string format.');\n\n const [, lRaw = '', cRaw = '', hRaw = ''] = parts;\n const l = parseFloat(lRaw) / (lRaw.includes('%') ? 100 : 1);\n const c = parseFloat(cRaw);\n const h = parseFloat(hRaw);\n\n return { l, c, h };\n}\n\n/**\n * Linearly interpolates a value between a start and end point.\n */\nfunction lerp(start: number, end: number, factor: number): number {\n return start + factor * (end - start);\n}\n\n/**\n * Interpolate hue the short way round the wheel. A ramp anchored at 350° and 10°\n * spans 20°, not 340° — the naive lerp sent it the long way through cyan.\n */\nfunction lerpHue(start: number, end: number, factor: number): number {\n const delta = ((((end - start) % 360) + 540) % 360) - 180;\n return (start + delta * factor + 360) % 360;\n}\n\n/**\n * The ladder step whose lightness is closest to `lightness` — i.e. where a\n * supplied colour naturally belongs.\n */\nexport function assignStepByLightness(lightness: number): StepName {\n let closestStep: StepName = 500;\n let minDiff = Math.abs(lightness - LIGHTNESS_LADDER[500]);\n\n for (const step of STEP_NAMES) {\n const diff = Math.abs(lightness - LIGHTNESS_LADDER[step]);\n if (diff < minDiff) {\n minDiff = diff;\n closestStep = step;\n }\n }\n\n return closestStep;\n}\n\n/**\n * How far an anchored colour sits from its step's ladder lightness.\n *\n * The generator surfaces this as a warning: a large deviation is legal (the\n * caller asked for that exact colour) but it means the hue will read heavier or\n * lighter than its siblings at that step, which is worth knowing rather than\n * discovering later.\n */\nexport function ladderDeviation(step: StepName, lightness: number): number {\n return lightness - LIGHTNESS_LADDER[step];\n}\n\n/** Absolute chroma ceiling — beyond this nothing survives gamut mapping anyway. */\nconst MAX_CHROMA = 0.37;\n\n/**\n * Build a complete 11-step OKLCH ramp from one or more anchor colours.\n *\n * **Ladder-first with exact anchors.** Every anchor is reproduced *verbatim* at\n * its step; every other step takes its lightness from `LIGHTNESS_LADDER`, with\n * chroma and hue interpolated between the flanking anchors and decayed toward\n * `ENDPOINT_CHROMA` beyond the outermost ones.\n *\n * The consequence is the point: a client's brand hex survives byte-for-byte,\n * while the other ten steps stay directly comparable to every other hue. The\n * deviation from the ladder is bounded and *local to anchored steps* — unlike\n * the previous engine, which warped the whole ramp to fit its anchors so every\n * step drifted.\n *\n * Chroma may come out beyond the sRGB gamut here; that is deliberate.\n * `oklchStringToHex` gamut-maps with the CSS algorithm, which reduces chroma\n * while holding lightness, so the ladder survives the conversion.\n */\nexport function generateOklchPalette(\n input: string | string[] | Record<string, string>,\n): Record<StepName, string> {\n let anchors: Record<number, string> = {};\n\n if (typeof input === 'string') {\n anchors[assignStepByLightness(parseOklch(input).l)] = input;\n } else if (Array.isArray(input)) {\n for (const colorStr of input) {\n anchors[assignStepByLightness(parseOklch(colorStr).l)] = colorStr;\n }\n } else if (typeof input === 'object' && input !== null) {\n anchors = { ...input };\n } else {\n throw new Error(\n 'Input must be a color string, array of colors, or object with step assignments',\n );\n }\n\n const parsedAnchors: Record<number, OklchColor> = {};\n for (const [key, value] of Object.entries(anchors)) {\n parsedAnchors[Number(key)] = parseOklch(value);\n }\n\n const anchorSteps = Object.keys(parsedAnchors)\n .map(Number)\n .sort((a, b) => a - b) as StepName[];\n\n // Interpolate across step *index*, not the numeric label: the labels aren't\n // evenly spaced (50→100 is a smaller jump than 100→200), so lerping on them\n // would bunch the ramp up at the light end.\n const idx = (step: number) => STEP_NAMES.indexOf(step as StepName);\n const lastIdx = STEP_NAMES.length - 1;\n\n const palette: Record<number, string> = {};\n\n for (const step of STEP_NAMES) {\n // An anchor is the caller's exact colour. Emit it untouched.\n if (parsedAnchors[step]) {\n palette[step] = anchors[step] as string;\n continue;\n }\n\n // `lighter` is the nearest anchor with a smaller step (50 is lightest);\n // `darker` the nearest with a larger one.\n const lighter = [...anchorSteps].reverse().find((s) => s < step);\n const darker = anchorSteps.find((s) => s > step);\n\n let chroma: number;\n let hue: number;\n\n if (lighter !== undefined && darker !== undefined) {\n const a = parsedAnchors[lighter] as OklchColor;\n const b = parsedAnchors[darker] as OklchColor;\n const factor = (idx(step) - idx(lighter)) / (idx(darker) - idx(lighter));\n chroma = lerp(a.c, b.c, factor);\n hue = lerpHue(a.h, b.h, factor);\n } else if (lighter !== undefined) {\n // Past the darkest anchor — fade toward the tinted near-black end.\n const a = parsedAnchors[lighter] as OklchColor;\n const factor = (idx(step) - idx(lighter)) / (lastIdx - idx(lighter));\n chroma = lerp(a.c, ENDPOINT_CHROMA.dark, factor);\n hue = a.h;\n } else if (darker !== undefined) {\n // Past the lightest anchor — fade toward the tinted near-white end.\n const b = parsedAnchors[darker] as OklchColor;\n const factor = (idx(darker) - idx(step)) / idx(darker);\n chroma = lerp(b.c, ENDPOINT_CHROMA.light, factor);\n hue = b.h;\n } else {\n chroma = 0.1;\n hue = 0;\n }\n\n const lightness = LIGHTNESS_LADDER[step];\n const finalL = (lightness * 100).toFixed(2) + '%';\n const finalC = Math.min(chroma, MAX_CHROMA).toFixed(4);\n const finalH = hue.toFixed(2);\n\n palette[step] = `oklch(${finalL} ${finalC} ${finalH})`;\n }\n\n return palette;\n}\n\n// ── Contrast + endpoints (for the functional-token layer) ────────────────────\n\n/** APCA lightness-contrast (Lc) magnitude between a foreground and background. */\nexport function contrastLc(fg: string, bg: string): number {\n return Math.abs(new Color(bg).contrast(fg, 'APCA'));\n}\n\n/**\n * Pick a tinted near-white or near-black foreground for best contrast on `bg`\n * (a whisper of the background's hue mixed into off-white/off-black).\n */\nexport function pickOn(bg: string, hue?: number): string {\n const h = hue ?? hexToOklch(bg).h;\n const white = oklchToHex({ l: 0.98, c: 0.01, h });\n const black = oklchToHex({ l: 0.16, c: 0.02, h });\n return contrastLc(white, bg) >= contrastLc(black, bg) ? white : black;\n}\n\n/**\n * The tinted off-white / off-black endpoints for a hue — white/black with a\n * whisper of the hue mixed in. These are the text/background tints every ramp\n * needs (and the one exception strict brand kits allow).\n *\n * Derived from `LIGHTNESS_LADDER` and `ENDPOINT_CHROMA` rather than its own\n * literals, so a strict tone kit's endpoints land on the same ladder rungs a\n * generated ramp would have used. This is the single definition — callers must\n * not hand-write their own near-white/near-black.\n */\nexport function tintedEndpoints(hue: number, chroma?: number): { light: string; dark: string } {\n return {\n light: oklchToHex({\n l: LIGHTNESS_LADDER[50],\n c: Math.min(chroma ?? ENDPOINT_CHROMA.light, 0.02),\n h: hue,\n }),\n dark: oklchToHex({\n l: LIGHTNESS_LADDER[950],\n c: Math.min((chroma ?? ENDPOINT_CHROMA.dark) * 1.5, 0.03),\n h: hue,\n }),\n };\n}\n","/**\n * Color harmony strategies for generating complementary colors\n */\n\nexport type HarmonyStrategy =\n | 'complement'\n | 'analogous-plus'\n | 'analogous-minus'\n | 'triadic-plus'\n | 'triadic-minus'\n | 'split-plus'\n | 'split-minus'\n | 'tetradic-plus'\n | 'tetradic-minus';\n\nexport interface HarmonyOption {\n id: HarmonyStrategy;\n label: string;\n description: string;\n hueShift: number;\n}\n\nexport const HARMONY_STRATEGIES: HarmonyOption[] = [\n {\n id: 'complement',\n label: 'Complement',\n description: 'Opposite on color wheel (high contrast)',\n hueShift: 180,\n },\n {\n id: 'analogous-plus',\n label: 'Analogous+',\n description: 'Adjacent colors (harmonious)',\n hueShift: 30,\n },\n {\n id: 'analogous-minus',\n label: 'Analogous-',\n description: 'Adjacent colors (harmonious)',\n hueShift: -30,\n },\n {\n id: 'triadic-plus',\n label: 'Triadic+',\n description: 'Evenly spaced (balanced)',\n hueShift: 120,\n },\n {\n id: 'triadic-minus',\n label: 'Triadic-',\n description: 'Evenly spaced (balanced)',\n hueShift: -120,\n },\n {\n id: 'split-plus',\n label: 'Split Complement+',\n description: 'Near opposite (softer contrast)',\n hueShift: 150,\n },\n {\n id: 'split-minus',\n label: 'Split Complement-',\n description: 'Near opposite (softer contrast)',\n hueShift: -150,\n },\n {\n id: 'tetradic-plus',\n label: 'Tetradic+',\n description: 'Square spacing (rich palette)',\n hueShift: 90,\n },\n {\n id: 'tetradic-minus',\n label: 'Tetradic-',\n description: 'Square spacing (rich palette)',\n hueShift: -90,\n },\n];\n\n/**\n * Applies a harmony strategy to a hue value\n */\nexport function applyHarmonyStrategy(baseHue: number, strategy: HarmonyStrategy): number {\n const harmonyOption = HARMONY_STRATEGIES.find((h) => h.id === strategy);\n if (!harmonyOption) return baseHue;\n\n let newHue = baseHue + harmonyOption.hueShift;\n\n // Normalize to 0-360 range\n while (newHue < 0) newHue += 360;\n while (newHue >= 360) newHue -= 360;\n\n return newHue;\n}\n\n/**\n * Gets all harmony suggestions for a given base hue\n */\nexport function getHarmonySuggestions(\n baseHue: number,\n): Array<{ strategy: HarmonyStrategy; hue: number; label: string; description: string }> {\n return HARMONY_STRATEGIES.map((strategy) => ({\n strategy: strategy.id,\n hue: applyHarmonyStrategy(baseHue, strategy.id),\n label: strategy.label,\n description: strategy.description,\n }));\n}\n\n/**\n * Default functional color hues (if user doesn't specify)\n */\nexport const DEFAULT_FUNCTIONAL_HUES = {\n success: 142, // Green\n warning: 38, // Orange/Amber\n error: 0, // Red\n info: 200, // Blue\n} as const;\n\n/**\n * Suggests a functional color hue based on existing palette to maintain harmony\n */\nexport function suggestFunctionalColorHue(\n type: keyof typeof DEFAULT_FUNCTIONAL_HUES,\n existingHues: number[],\n): number {\n const defaultHue = DEFAULT_FUNCTIONAL_HUES[type];\n\n if (existingHues.length === 0) {\n return defaultHue;\n }\n\n // Find the closest existing hue and adjust slightly to maintain harmony\n const avgHue = existingHues.reduce((sum, h) => sum + h, 0) / existingHues.length;\n\n // Rotate the default hue to be more in line with the palette's color temperature\n const hueShift = avgHue - 200; // Assuming 200 is neutral blue\n let adjustedHue = defaultHue + hueShift * 0.3; // 30% influence\n\n // Normalize\n while (adjustedHue < 0) adjustedHue += 360;\n while (adjustedHue >= 360) adjustedHue -= 360;\n\n return adjustedHue;\n}\n"],"mappings":";;;;AAcA,WAAW,SAASA,KAAW;AAC/B,WAAW,SAASC,IAAU;AAC9B,WAAW,SAASC,EAAQ;;;;;AAe5B,SAAgB,YAAY,GAAW,GAAW,GAAsB;CAGtE,MAAM,CAAC,GAAG,GAAG,KADD,GAAG;EADiB,OAAOF;EAAa,QAAQ;GAAC;GAAG;GAAG;EAAC;EAAG,OAAO;CAC7D,GAAGC,IACA,CAAC,CAAC;CACtB,MAAM,UAAU,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KA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
+ "version": "1.0.0",
4
4
  "description": "Shared build-time utilities for the Vitops toolchain — favicon generation and friends.",
5
5
  "license": "MIT",
6
6
  "files": [