@ansh-ui/core 0.2.0 → 0.3.1

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.
Files changed (54) hide show
  1. package/dist/behaviours.cjs +20 -15
  2. package/dist/behaviours.d.cts +2 -2
  3. package/dist/behaviours.d.ts +2 -2
  4. package/dist/behaviours.js +3 -2
  5. package/dist/{chunk-56NNBIAO.js → chunk-2DOA43UB.js} +1047 -18
  6. package/dist/chunk-2DOA43UB.js.map +1 -0
  7. package/dist/{chunk-7MYTSAPR.js → chunk-37GPMMMT.js} +3 -3
  8. package/dist/{chunk-7MYTSAPR.js.map → chunk-37GPMMMT.js.map} +1 -1
  9. package/dist/{chunk-23GSSIMK.cjs → chunk-4ORYTFY3.cjs} +3 -3
  10. package/dist/{chunk-23GSSIMK.cjs.map → chunk-4ORYTFY3.cjs.map} +1 -1
  11. package/dist/{chunk-MMO7KO53.cjs → chunk-FNR4B3KY.cjs} +3 -3
  12. package/dist/{chunk-MMO7KO53.cjs.map → chunk-FNR4B3KY.cjs.map} +1 -1
  13. package/dist/{chunk-BOQQHICI.js → chunk-GQH5ZHPB.js} +3 -3
  14. package/dist/{chunk-BOQQHICI.js.map → chunk-GQH5ZHPB.js.map} +1 -1
  15. package/dist/{chunk-R7UJ7MWP.cjs → chunk-OSNUN5JJ.cjs} +1070 -34
  16. package/dist/chunk-OSNUN5JJ.cjs.map +1 -0
  17. package/dist/{chunk-GHBRGMSO.cjs → chunk-PZF3YXVE.cjs} +6 -6
  18. package/dist/{chunk-GHBRGMSO.cjs.map → chunk-PZF3YXVE.cjs.map} +1 -1
  19. package/dist/{chunk-UJBXY6QC.cjs → chunk-SSAWZIO2.cjs} +150 -28
  20. package/dist/chunk-SSAWZIO2.cjs.map +1 -0
  21. package/dist/{chunk-C6XPQO2O.js → chunk-WLOGUD3G.js} +126 -5
  22. package/dist/{chunk-C6XPQO2O.js.map → chunk-WLOGUD3G.js.map} +1 -1
  23. package/dist/{chunk-KTUBCQC3.js → chunk-YHSCAGCI.js} +3 -3
  24. package/dist/{chunk-KTUBCQC3.js.map → chunk-YHSCAGCI.js.map} +1 -1
  25. package/dist/color.cjs +39 -39
  26. package/dist/color.d.cts +5 -4
  27. package/dist/color.d.ts +5 -4
  28. package/dist/color.js +3 -3
  29. package/dist/effects.cjs +53 -25
  30. package/dist/effects.d.cts +4 -4
  31. package/dist/effects.d.ts +4 -4
  32. package/dist/effects.js +4 -4
  33. package/dist/{index-CQEEPu-D.d.ts → index-DN0bQII7.d.ts} +47 -2
  34. package/dist/{index-DHOfsEIn.d.cts → index-DmJ3i1Tr.d.cts} +330 -4
  35. package/dist/{index-Dl8GCsya.d.cts → index-Dv3gw7Mb.d.cts} +47 -2
  36. package/dist/{index-CCdpefMp.d.ts → index-SO8zHlVo.d.ts} +330 -4
  37. package/dist/index.cjs +186 -154
  38. package/dist/index.d.cts +10 -9
  39. package/dist/index.d.ts +10 -9
  40. package/dist/index.js +9 -9
  41. package/dist/math.d.cts +3 -2
  42. package/dist/math.d.ts +3 -2
  43. package/dist/noise.d.cts +2 -1
  44. package/dist/noise.d.ts +2 -1
  45. package/dist/{palette-6HkVltYU.d.ts → palette-Dcomsp9R.d.cts} +2 -1
  46. package/dist/{palette-6HkVltYU.d.cts → palette-Dcomsp9R.d.ts} +2 -1
  47. package/dist/{random--4mSc5Lp.d.cts → random-YnhdaiIx.d.cts} +2 -1
  48. package/dist/{random--4mSc5Lp.d.ts → random-YnhdaiIx.d.ts} +2 -1
  49. package/dist/{reduced-motion-D0LUgZle.d.cts → reduced-motion-DaeXwgzb.d.cts} +2 -1
  50. package/dist/{reduced-motion-D0LUgZle.d.ts → reduced-motion-DaeXwgzb.d.ts} +2 -1
  51. package/package.json +1 -1
  52. package/dist/chunk-56NNBIAO.js.map +0 -1
  53. package/dist/chunk-R7UJ7MWP.cjs.map +0 -1
  54. package/dist/chunk-UJBXY6QC.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { composite, oklchToRgbMapped } from './chunk-KTUBCQC3.js';
1
+ import { composite, oklchToRgbMapped } from './chunk-YHSCAGCI.js';
2
2
  import { parseColor, relativeLuminance, rgbToOklch } from './chunk-QALZKHWH.js';
3
3
  import { clamp } from './chunk-KU2C6GEA.js';
4
4
 
@@ -79,5 +79,5 @@ function perceivedLightness(color) {
79
79
  }
80
80
 
81
81
  export { checkContrast, contrastRatio, ensureContrast, perceivedLightness, pickReadable, requiredRatio, worstContrast };
82
- //# sourceMappingURL=chunk-7MYTSAPR.js.map
83
- //# sourceMappingURL=chunk-7MYTSAPR.js.map
82
+ //# sourceMappingURL=chunk-37GPMMMT.js.map
83
+ //# sourceMappingURL=chunk-37GPMMMT.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/color/contrast.ts"],"names":[],"mappings":";;;;;AAyBO,SAAS,aAAA,CAAc,YAAwB,UAAA,EAAgC;AACpF,EAAA,MAAM,EAAA,GAAK,WAAW,UAAU,CAAA;AAChC,EAAA,MAAM,KAAA,GAAQ,WAAW,UAAU,CAAA;AACnC,EAAA,MAAM,KAAK,KAAA,CAAM,CAAA,GAAI,IAAI,SAAA,CAAU,EAAA,EAAI,KAAK,CAAA,GAAI,KAAA;AAEhD,EAAA,MAAM,EAAA,GAAK,kBAAkB,EAAE,CAAA;AAC/B,EAAA,MAAM,EAAA,GAAK,kBAAkB,EAAE,CAAA;AAC/B,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,GAAA,CAAI,EAAA,EAAI,EAAE,CAAA;AAC/B,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,GAAA,CAAI,EAAA,EAAI,EAAE,CAAA;AAC9B,EAAA,OAAA,CAAQ,OAAA,GAAU,SAAS,MAAA,GAAS,IAAA,CAAA;AACtC;AAGO,SAAS,aAAA,CAAc,OAAkB,IAAA,EAAwB;AACtE,EAAA,IAAI,KAAA,KAAU,KAAA,EAAO,OAAO,IAAA,KAAS,UAAU,GAAA,GAAM,CAAA;AACrD,EAAA,OAAO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AAA,EAAG,CAAA;AAClE,IAAA,MAAM,KAAA,GAAQ,aAAA,CAAc,SAAA,EAAW,EAAE,CAAA;AACzC,IAAA,IAAI,QAAQ,SAAA,EAAW;AACrB,MAAA,SAAA,GAAY,KAAA;AACZ,MAAA,IAAA,GAAO,SAAA;AACP,MAAA,IAAI,KAAA,IAAS,QAAQ,OAAO,EAAE,OAAO,SAAA,EAAW,KAAA,EAAO,UAAU,IAAA,EAAK;AAAA,IACxE;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,KAAA,EAAO,IAAA,EAAM,OAAO,SAAA,EAAW,QAAA,EAAU,aAAa,MAAA,EAAO;AACxE;AASO,SAAS,aAAA,CACd,YACA,WAAA,EACwC;AACxC,EAAA,IAAI,KAAA,GAAQ,QAAA;AACZ,EAAA,IAAI,OAAA,GAAsB,IAAA;AAC1B,EAAA,KAAA,MAAW,MAAM,WAAA,EAAa;AAC5B,IAAA,MAAM,KAAA,GAAQ,aAAA,CAAc,UAAA,EAAY,EAAE,CAAA;AAC1C,IAAA,IAAI,QAAQ,KAAA,EAAO;AACjB,MAAA,KAAA,GAAQ,KAAA;AACR,MAAA,OAAA,GAAU,WAAW,EAAE,CAAA;AAAA,IACzB;AAAA,EACF;AACA,EAAA,OAAO,EAAE,OAAO,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,GAAI,KAAA,GAAQ,IAAI,OAAA,EAAQ;AAC/D;AAUO,SAAS,mBAAmB,KAAA,EAA2B;AAC5D,EAAA,OAAO,UAAA,CAAW,UAAA,CAAW,KAAK,CAAC,CAAA,CAAE,CAAA;AACvC","file":"chunk-7MYTSAPR.js","sourcesContent":["import { clamp } from '../math/scalar'\nimport { relativeLuminance, rgbToOklch } from './convert'\nimport { oklchToRgbMapped } from './gamut'\nimport { parseColor } from './parse'\nimport { composite } from './interpolate'\nimport type { ColorInput, Rgb } from './types'\n\n/**\n * Contrast and legibility.\n *\n * Animated backgrounds are the single most common way a design ends up failing WCAG: the text\n * was legible against the mockup's midpoint and illegible against the animation's brightest\n * frame. These helpers let components check contrast against the *extremes* of their own\n * palette and adapt, rather than hoping.\n */\n\nexport type WcagLevel = 'AA' | 'AAA'\nexport type TextSize = 'normal' | 'large'\n\n/**\n * WCAG 2.x contrast ratio, from 1 (identical) to 21 (black on white).\n *\n * Semi-transparent colours are composited over `background` first, because a ratio computed\n * from a colour's own alpha is meaningless — what matters is what the eye actually receives.\n */\nexport function contrastRatio(foreground: ColorInput, background: ColorInput): number {\n const bg = parseColor(background)\n const fgRaw = parseColor(foreground)\n const fg = fgRaw.a < 1 ? composite(bg, fgRaw) : fgRaw\n\n const l1 = relativeLuminance(fg)\n const l2 = relativeLuminance(bg)\n const lighter = Math.max(l1, l2)\n const darker = Math.min(l1, l2)\n return (lighter + 0.05) / (darker + 0.05)\n}\n\n/** Minimum ratio required by WCAG 2.2 for the given level and text size. */\nexport function requiredRatio(level: WcagLevel, size: TextSize): number {\n if (level === 'AAA') return size === 'large' ? 4.5 : 7\n return size === 'large' ? 3 : 4.5\n}\n\nexport interface ContrastResult {\n ratio: number\n passes: boolean\n required: number\n level: WcagLevel\n size: TextSize\n}\n\n/** Check a foreground/background pair against a WCAG threshold. */\nexport function checkContrast(\n foreground: ColorInput,\n background: ColorInput,\n level: WcagLevel = 'AA',\n size: TextSize = 'normal',\n): ContrastResult {\n const ratio = contrastRatio(foreground, background)\n const required = requiredRatio(level, size)\n return { ratio, passes: ratio >= required, required, level, size }\n}\n\n/**\n * Pick whichever of `light`/`dark` reads better on `background`.\n *\n * This is the function to reach for when a component renders text over a user-supplied\n * colour, which is most of them.\n */\nexport function pickReadable(\n background: ColorInput,\n light: ColorInput = '#ffffff',\n dark: ColorInput = '#0b0b0f',\n): Rgb {\n const lightRatio = contrastRatio(light, background)\n const darkRatio = contrastRatio(dark, background)\n return parseColor(lightRatio >= darkRatio ? light : dark)\n}\n\n/**\n * Adjust a colour's lightness until it meets a contrast target against `background`.\n *\n * Works in OKLCH so hue and chroma survive the adjustment — the brand colour stays\n * recognisably itself, it just gets light or dark enough to read. Searches in whichever\n * direction has more headroom, and returns the best achievable colour if the target is\n * unreachable (a mid-grey background cannot support 7:1 with a saturated hue at any lightness).\n */\nexport function ensureContrast(\n foreground: ColorInput,\n background: ColorInput,\n target = 4.5,\n): { color: Rgb; ratio: number; achieved: boolean } {\n const fg = parseColor(foreground)\n const bg = parseColor(background)\n\n const initial = contrastRatio(fg, bg)\n if (initial >= target) return { color: fg, ratio: initial, achieved: true }\n\n const lch = rgbToOklch(fg)\n const bgLuminance = relativeLuminance(bg)\n // Move away from the background: darken against a light background, lighten against a dark one.\n const direction = bgLuminance > 0.35 ? -1 : 1\n\n let best = fg\n let bestRatio = initial\n\n // 24 steps across the available lightness range lands within ~4% of optimal, which is\n // finer than the eye can distinguish and costs 24 cheap conversions.\n const STEPS = 24\n const limit = direction > 0 ? 1 - lch.l : lch.l\n\n for (let i = 1; i <= STEPS; i++) {\n const l = clamp(lch.l + direction * (limit * (i / STEPS)), 0, 1)\n const candidate = oklchToRgbMapped({ l, c: lch.c, h: lch.h, alpha: fg.a })\n const ratio = contrastRatio(candidate, bg)\n if (ratio > bestRatio) {\n bestRatio = ratio\n best = candidate\n if (ratio >= target) return { color: candidate, ratio, achieved: true }\n }\n }\n\n // Last resort: drop chroma too. Desaturating buys real lightness range at the extremes.\n for (let i = 1; i <= 8; i++) {\n const c = lch.c * (1 - i / 8)\n const l = direction > 0 ? 1 : 0\n const candidate = oklchToRgbMapped({ l, c, h: lch.h, alpha: fg.a })\n const ratio = contrastRatio(candidate, bg)\n if (ratio > bestRatio) {\n bestRatio = ratio\n best = candidate\n if (ratio >= target) return { color: candidate, ratio, achieved: true }\n }\n }\n\n return { color: best, ratio: bestRatio, achieved: bestRatio >= target }\n}\n\n/**\n * Worst-case contrast of a foreground against every colour in a set.\n *\n * An animated gradient background cycles through many colours; text must be legible against\n * all of them. Components call this with their resolved palette and surface a dev warning when\n * it fails, which turns an invisible accessibility bug into a console message during development.\n */\nexport function worstContrast(\n foreground: ColorInput,\n backgrounds: readonly ColorInput[],\n): { ratio: number; against: Rgb | null } {\n let worst = Infinity\n let against: Rgb | null = null\n for (const bg of backgrounds) {\n const ratio = contrastRatio(foreground, bg)\n if (ratio < worst) {\n worst = ratio\n against = parseColor(bg)\n }\n }\n return { ratio: Number.isFinite(worst) ? worst : 21, against }\n}\n\n/**\n * APCA-style perceptual lightness, used for ordering colours by visual weight.\n *\n * Not a WCAG 3 implementation — that specification is still in flux and we won't ship a\n * moving target as if it were stable. This is OKLab's `L`, which is a better predictor of\n * perceived lightness than WCAG's relative luminance and is entirely sufficient for the\n * internal job of sorting a palette light-to-dark.\n */\nexport function perceivedLightness(color: ColorInput): number {\n return rgbToOklch(parseColor(color)).l\n}\n"]}
1
+ {"version":3,"sources":["../src/color/contrast.ts"],"names":[],"mappings":";;;;;AAyBO,SAAS,aAAA,CAAc,YAAwB,UAAA,EAAgC;AACpF,EAAA,MAAM,EAAA,GAAK,WAAW,UAAU,CAAA;AAChC,EAAA,MAAM,KAAA,GAAQ,WAAW,UAAU,CAAA;AACnC,EAAA,MAAM,KAAK,KAAA,CAAM,CAAA,GAAI,IAAI,SAAA,CAAU,EAAA,EAAI,KAAK,CAAA,GAAI,KAAA;AAEhD,EAAA,MAAM,EAAA,GAAK,kBAAkB,EAAE,CAAA;AAC/B,EAAA,MAAM,EAAA,GAAK,kBAAkB,EAAE,CAAA;AAC/B,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,GAAA,CAAI,EAAA,EAAI,EAAE,CAAA;AAC/B,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,GAAA,CAAI,EAAA,EAAI,EAAE,CAAA;AAC9B,EAAA,OAAA,CAAQ,OAAA,GAAU,SAAS,MAAA,GAAS,IAAA,CAAA;AACtC;AAGO,SAAS,aAAA,CAAc,OAAkB,IAAA,EAAwB;AACtE,EAAA,IAAI,KAAA,KAAU,KAAA,EAAO,OAAO,IAAA,KAAS,UAAU,GAAA,GAAM,CAAA;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AO,EAAA,CAAG,CAAA,EAAG,CAAA;AAClE,IAAA,MAAM,KAAA,GAAQ,aAAA,CAAc,SAAA,EAAW,EAAE,CAAA;AACzC,IAAA,IAAI,QAAQ,SAAA,EAAW;AACrB,MAAA,SAAA,GAAY,KAAA;AACZ,MAAA,IAAA,GAAO,SAAA;AACP,MAAA,IAAI,KAAA,IAAS,QAAQ,OAAO,EAAE,OAAO,SAAA,EAAW,KAAA,EAAO,UAAU,IAAA,EAAK;AAAA,IACxE;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,KAAA,EAAO,IAAA,EAAM,OAAO,SAAA,EAAW,QAAA,EAAU,aAAa,MAAA,EAAO;AACxE;AASO,SAAS,aAAA,CACd,YACA,WAAA,EACwC;AACxC,EAAA,IAAI,KAAA,GAAQ,QAAA;AACZ,EAAA,IAAI,OAAA,GAAsB,IAAA;AAC1B,EAAA,KAAA,MAAW,MAAM,WAAA,EAAa;AAC5B,IAAA,MAAM,KAAA,GAAQ,aAAA,CAAc,UAAA,EAAY,EAAE,CAAA;AAC1C,IAAA,IAAI,QAAQ,KAAA,EAAO;AACjB,MAAA,KAAA,GAAQ,KAAA;AACR,MAAA,OAAA,GAAU,WAAW,EAAE,CAAA;AAAA,IACzB;AAAA,EACF;AACA,EAAA,OAAO,EAAE,OAAO,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,GAAI,KAAA,GAAQ,IAAI,OAAA,EAAQ;AAC/D;AAUO,SAAS,mBAAmB,KAAA,EAA2B;AAC5D,EAAA,OAAO,UAAA,CAAW,UAAA,CAAW,KAAK,CAAC,CAAA,CAAE,CAAA;AACvC","file":"chunk-37GPMMMT.js","sourcesContent":["import { clamp } from '../math/scalar'\nimport { relativeLuminance, rgbToOklch } from './convert'\nimport { oklchToRgbMapped } from './gamut'\nimport { parseColor } from './parse'\nimport { composite } from './interpolate'\nimport type { ColorInput, Rgb } from './types'\n\n/**\n * Contrast and legibility.\n *\n * Animated backgrounds are the single most common way a design ends up failing WCAG: the text\n * was legible against the mockup's midpoint and illegible against the animation's brightest\n * frame. These helpers let components check contrast against the *extremes* of their own\n * palette and adapt, rather than hoping.\n */\n\nexport type WcagLevel = 'AA' | 'AAA'\nexport type TextSize = 'normal' | 'large'\n\n/**\n * WCAG 2.x contrast ratio, from 1 (identical) to 21 (black on white).\n *\n * Semi-transparent colours are composited over `background` first, because a ratio computed\n * from a colour's own alpha is meaningless — what matters is what the eye actually receives.\n */\nexport function contrastRatio(foreground: ColorInput, background: ColorInput): number {\n const bg = parseColor(background)\n const fgRaw = parseColor(foreground)\n const fg = fgRaw.a < 1 ? composite(bg, fgRaw) : fgRaw\n\n const l1 = relativeLuminance(fg)\n const l2 = relativeLuminance(bg)\n const lighter = Math.max(l1, l2)\n const darker = Math.min(l1, l2)\n return (lighter + 0.05) / (darker + 0.05)\n}\n\n/** Minimum ratio required by WCAG 2.2 for the given level and text size. */\nexport function requiredRatio(level: WcagLevel, size: TextSize): number {\n if (level === 'AAA') return size === 'large' ? 4.5 : 7\n return size === 'large' ? 3 : 4.5\n}\n\nexport interface ContrastResult {\n ratio: number\n passes: boolean\n required: number\n level: WcagLevel\n size: TextSize\n}\n\n/** Check a foreground/background pair against a WCAG threshold. */\nexport function checkContrast(\n foreground: ColorInput,\n background: ColorInput,\n level: WcagLevel = 'AA',\n size: TextSize = 'normal',\n): ContrastResult {\n const ratio = contrastRatio(foreground, background)\n const required = requiredRatio(level, size)\n return { ratio, passes: ratio >= required, required, level, size }\n}\n\n/**\n * Pick whichever of `light`/`dark` reads better on `background`.\n *\n * This is the function to reach for when a component renders text over a user-supplied\n * colour, which is most of them.\n */\nexport function pickReadable(\n background: ColorInput,\n light: ColorInput = '#ffffff',\n dark: ColorInput = '#0b0b0f',\n): Rgb {\n const lightRatio = contrastRatio(light, background)\n const darkRatio = contrastRatio(dark, background)\n return parseColor(lightRatio >= darkRatio ? light : dark)\n}\n\n/**\n * Adjust a colour's lightness until it meets a contrast target against `background`.\n *\n * Works in OKLCH so hue and chroma survive the adjustment — the brand colour stays\n * recognisably itself, it just gets light or dark enough to read. Searches in whichever\n * direction has more headroom, and returns the best achievable colour if the target is\n * unreachable (a mid-grey background cannot support 7:1 with a saturated hue at any lightness).\n */\nexport function ensureContrast(\n foreground: ColorInput,\n background: ColorInput,\n target = 4.5,\n): { color: Rgb; ratio: number; achieved: boolean } {\n const fg = parseColor(foreground)\n const bg = parseColor(background)\n\n const initial = contrastRatio(fg, bg)\n if (initial >= target) return { color: fg, ratio: initial, achieved: true }\n\n const lch = rgbToOklch(fg)\n const bgLuminance = relativeLuminance(bg)\n // Move away from the background: darken against a light background, lighten against a dark one.\n const direction = bgLuminance > 0.35 ? -1 : 1\n\n let best = fg\n let bestRatio = initial\n\n // 24 steps across the available lightness range lands within ~4% of optimal, which is\n // finer than the eye can distinguish and costs 24 cheap conversions.\n const STEPS = 24\n const limit = direction > 0 ? 1 - lch.l : lch.l\n\n for (let i = 1; i <= STEPS; i++) {\n const l = clamp(lch.l + direction * (limit * (i / STEPS)), 0, 1)\n const candidate = oklchToRgbMapped({ l, c: lch.c, h: lch.h, alpha: fg.a })\n const ratio = contrastRatio(candidate, bg)\n if (ratio > bestRatio) {\n bestRatio = ratio\n best = candidate\n if (ratio >= target) return { color: candidate, ratio, achieved: true }\n }\n }\n\n // Last resort: drop chroma too. Desaturating buys real lightness range at the extremes.\n for (let i = 1; i <= 8; i++) {\n const c = lch.c * (1 - i / 8)\n const l = direction > 0 ? 1 : 0\n const candidate = oklchToRgbMapped({ l, c, h: lch.h, alpha: fg.a })\n const ratio = contrastRatio(candidate, bg)\n if (ratio > bestRatio) {\n bestRatio = ratio\n best = candidate\n if (ratio >= target) return { color: candidate, ratio, achieved: true }\n }\n }\n\n return { color: best, ratio: bestRatio, achieved: bestRatio >= target }\n}\n\n/**\n * Worst-case contrast of a foreground against every colour in a set.\n *\n * An animated gradient background cycles through many colours; text must be legible against\n * all of them. Components call this with their resolved palette and surface a dev warning when\n * it fails, which turns an invisible accessibility bug into a console message during development.\n */\nexport function worstContrast(\n foreground: ColorInput,\n backgrounds: readonly ColorInput[],\n): { ratio: number; against: Rgb | null } {\n let worst = Infinity\n let against: Rgb | null = null\n for (const bg of backgrounds) {\n const ratio = contrastRatio(foreground, bg)\n if (ratio < worst) {\n worst = ratio\n against = parseColor(bg)\n }\n }\n return { ratio: Number.isFinite(worst) ? worst : 21, against }\n}\n\n/**\n * APCA-style perceptual lightness, used for ordering colours by visual weight.\n *\n * Not a WCAG 3 implementation — that specification is still in flux and we won't ship a\n * moving target as if it were stable. This is OKLab's `L`, which is a better predictor of\n * perceived lightness than WCAG's relative luminance and is entirely sufficient for the\n * internal job of sorting a palette light-to-dark.\n */\nexport function perceivedLightness(color: ColorInput): number {\n return rgbToOklch(parseColor(color)).l\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkFNR35HTL_cjs = require('./chunk-FNR35HTL.cjs');
4
3
  var chunkLGA3N3YJ_cjs = require('./chunk-LGA3N3YJ.cjs');
5
4
  var chunkGJRIHN76_cjs = require('./chunk-GJRIHN76.cjs');
5
+ var chunkFNR35HTL_cjs = require('./chunk-FNR35HTL.cjs');
6
6
  var chunkILKUL7GD_cjs = require('./chunk-ILKUL7GD.cjs');
7
7
 
8
8
  // src/color/format.ts
@@ -435,5 +435,5 @@ exports.toOklchString = toOklchString;
435
435
  exports.toRgbString = toRgbString;
436
436
  exports.toUint32 = toUint32;
437
437
  exports.withAlpha = withAlpha;
438
- //# sourceMappingURL=chunk-23GSSIMK.cjs.map
439
- //# sourceMappingURL=chunk-23GSSIMK.cjs.map
438
+ //# sourceMappingURL=chunk-4ORYTFY3.cjs.map
439
+ //# sourceMappingURL=chunk-4ORYTFY3.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/color/format.ts","../src/color/internal.ts","../src/color/gamut.ts","../src/color/interpolate.ts","../src/color/palette.ts"],"names":["clamp","roundTo","rgbToHsl","rgbToOklch","oklchToOklab","parseColor","lerp","rgbTo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AAS,SAAS,QAAQ,CAAA,EAAG,IAAI,CAAC,CAAA,KAAMA,4BAAA,CAAW,CAAC,CAAC,CAAA;AAAA,EAC/D;AACA,EAAA,IAAI,KAAA,CAAM,MAAA,KAAW,CAAA,EAAG,OAAO,QAAA,CAAS,QAAQ,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA,KAAMA,4BAAA,CAAW,CAAC,CAAC,CAAA;AAC1E,EAAA,OAAO,MAAM,GAAA,CAAI,CAAC,CAAA,KAAMA,4BAAA,CAAW,CAAC,CAAC,CAAA;AACvC","file":"chunk-23GSSIMK.cjs","sourcesContent":["import { clamp, roundTo } from '../math/scalar'\nimport { rgbToHsl, rgbToOklch } from './convert'\nimport type { Rgb } from './types'\n\n/**\n * Serialising colours back to strings.\n *\n * `toRgbString` is the workhorse: canvas `fillStyle` accepts it, it is the cheapest to\n * produce, and it is universally supported. The others exist for authoring output — the\n * theme generator emits `oklch()`, the docs site shows hex.\n */\n\nconst byte = (c: number) => Math.round(clamp(c, 0, 1) * 255)\n\n/** `#rrggbb`, or `#rrggbbaa` when not fully opaque (or when `forceAlpha` is set). */\nexport function toHex(color: Rgb, forceAlpha = false): string {\n const hex = (n: number) => n.toString(16).padStart(2, '0')\n const base = `#${hex(byte(color.r))}${hex(byte(color.g))}${hex(byte(color.b))}`\n return color.a < 1 || forceAlpha ? `${base}${hex(byte(color.a))}` : base\n}\n\n/**\n * `rgb(r g b)` / `rgb(r g b / a)`.\n *\n * Uses the legacy comma form because it is what every canvas implementation and every\n * browser back to 2015 accepts; the space-separated form is newer than our support target.\n */\nexport function toRgbString(color: Rgb): string {\n const r = byte(color.r)\n const g = byte(color.g)\n const b = byte(color.b)\n return color.a < 1\n ? `rgba(${r}, ${g}, ${b}, ${roundTo(clamp(color.a, 0, 1), 4)})`\n : `rgb(${r}, ${g}, ${b})`\n}\n\nexport function toHslString(color: Rgb): string {\n const hsl = rgbToHsl(color)\n const h = roundTo(hsl.h, 1)\n const s = roundTo(hsl.s * 100, 1)\n const l = roundTo(hsl.l * 100, 1)\n return hsl.a < 1 ? `hsla(${h}, ${s}%, ${l}%, ${roundTo(hsl.a, 4)})` : `hsl(${h}, ${s}%, ${l}%)`\n}\n\n/** `oklch(l% c h)` — the modern authoring form, and what the theme generator emits. */\nexport function toOklchString(color: Rgb): string {\n const lch = rgbToOklch(color)\n const l = roundTo(lch.l * 100, 2)\n const c = roundTo(lch.c, 4)\n const h = roundTo(lch.h, 2)\n return lch.alpha < 1\n ? `oklch(${l}% ${c} ${h} / ${roundTo(lch.alpha, 4)})`\n : `oklch(${l}% ${c} ${h})`\n}\n\n/**\n * Pack into a 32-bit integer as `0xAABBGGRR`.\n *\n * This is the byte order a `Uint32Array` view over `ImageData` expects on little-endian\n * machines, which is every platform we target. Effects that write pixels directly — the noise\n * layer, the grain overlay — use this to fill a row with one store per pixel instead of four.\n */\nexport function toUint32(color: Rgb): number {\n return (\n ((byte(color.a) << 24) | (byte(color.b) << 16) | (byte(color.g) << 8) | byte(color.r)) >>> 0\n )\n}\n\nexport function fromUint32(packed: number): Rgb {\n return {\n r: (packed & 0xff) / 255,\n g: ((packed >>> 8) & 0xff) / 255,\n b: ((packed >>> 16) & 0xff) / 255,\n a: ((packed >>> 24) & 0xff) / 255,\n }\n}\n\n/** Replace a colour's alpha, leaving its hue and lightness untouched. */\nexport function withAlpha(color: Rgb, alpha: number): Rgb {\n return { r: color.r, g: color.g, b: color.b, a: clamp(alpha, 0, 1) }\n}\n\n/** Scale a colour's existing alpha — useful for fading a whole palette at once. */\nexport function fadeBy(color: Rgb, factor: number): Rgb {\n return { r: color.r, g: color.g, b: color.b, a: clamp(color.a * factor, 0, 1) }\n}\n","import { oklchToOklab } from './convert'\nimport type { LinearRgb, Oklch } from './types'\n\n/**\n * OKLCH → linear RGB **without** clamping.\n *\n * Gamut testing needs to see the out-of-range values that the public conversion functions\n * deliberately clamp away, so this lives apart from `convert.ts` to keep that boundary\n * explicit: everything public returns displayable colour, and only the gamut mapper looks\n * at raw values.\n */\nexport function oklchToLinearUnclamped(lch: Oklch): LinearRgb {\n const lab = oklchToOklab(lch)\n const l_ = lab.l + 0.3963377774 * lab.a + 0.2158037573 * lab.b\n const m_ = lab.l - 0.1055613458 * lab.a - 0.0638541728 * lab.b\n const s_ = lab.l - 0.0894841775 * lab.a - 1.291485548 * lab.b\n\n const l = l_ * l_ * l_\n const m = m_ * m_ * m_\n const s = s_ * s_ * s_\n\n return {\n r: 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n g: -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n b: -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,\n a: lch.alpha,\n }\n}\n","import { oklchToLinearUnclamped } from './internal'\nimport { rgbToOklch } from './convert'\nimport type { Oklch, Rgb } from './types'\n\n/**\n * Gamut mapping for sRGB.\n *\n * OKLCH can describe colours sRGB cannot display. Naively clipping the RGB channels shifts\n * both hue and lightness — a vivid `oklch(0.7 0.35 150)` clips to a muddy, *lighter* green.\n *\n * The CSS Color 4 recommended approach, implemented here, is to hold lightness and hue fixed\n * and binary-search chroma down to the gamut boundary. The result is the most saturated\n * displayable colour with the same perceived hue and lightness, which is what an author means\n * when they ask for a colour that's out of range.\n */\n\nconst EPSILON = 1e-4\nconst TOLERANCE = 1e-5\n\n/** Is this OKLCH colour displayable in sRGB? */\nexport function inSrgbGamut(lch: Oklch): boolean {\n const lin = oklchToLinearUnclamped(lch)\n return (\n lin.r >= -TOLERANCE &&\n lin.r <= 1 + TOLERANCE &&\n lin.g >= -TOLERANCE &&\n lin.g <= 1 + TOLERANCE &&\n lin.b >= -TOLERANCE &&\n lin.b <= 1 + TOLERANCE\n )\n}\n\n/**\n * Reduce chroma until the colour fits in sRGB, preserving lightness and hue.\n *\n * Returns the input unchanged when it is already in gamut, so this is safe to call\n * unconditionally.\n */\nexport function gamutMapOklch(lch: Oklch): Oklch {\n if (inSrgbGamut(lch)) return lch\n\n // Pure black and white are always in gamut; anything outside [0,1] lightness cannot be\n // rescued by chroma reduction, so clamp lightness first.\n const l = Math.min(1, Math.max(0, lch.l))\n if (l <= 0) return { l: 0, c: 0, h: lch.h, alpha: lch.alpha }\n if (l >= 1) return { l: 1, c: 0, h: lch.h, alpha: lch.alpha }\n\n let low = 0\n let high = lch.c\n\n while (high - low > EPSILON) {\n const mid = (low + high) / 2\n if (inSrgbGamut({ l, c: mid, h: lch.h, alpha: lch.alpha })) low = mid\n else high = mid\n }\n\n return { l, c: low, h: lch.h, alpha: lch.alpha }\n}\n\n/**\n * The maximum chroma sRGB can display at a given lightness and hue.\n *\n * This is what makes \"vivid\" palette generation possible: rather than picking an arbitrary\n * chroma and hoping, you can ask for the most saturated colour available at each hue and get\n * a palette with consistent, maximal punch.\n */\nexport function maxChroma(l: number, h: number): number {\n if (l <= 0 || l >= 1) return 0\n let low = 0\n let high = 0.5 // Comfortably beyond the sRGB maximum of ~0.37.\n while (high - low > EPSILON) {\n const mid = (low + high) / 2\n if (inSrgbGamut({ l, c: mid, h, alpha: 1 })) low = mid\n else high = mid\n }\n return low\n}\n\n/** Gamut-map, then convert to sRGB. The safe path from OKLCH to a displayable colour. */\nexport function oklchToRgbMapped(lch: Oklch): Rgb {\n const mapped = gamutMapOklch(lch)\n const lin = oklchToLinearUnclamped(mapped)\n return {\n r: clamp01(linearToSrgb(lin.r)),\n g: clamp01(linearToSrgb(lin.g)),\n b: clamp01(linearToSrgb(lin.b)),\n a: mapped.alpha,\n }\n}\n\n/**\n * How far outside sRGB a colour sits, as a rough distance in chroma units.\n * `0` means in gamut. Used by the docs site to warn about unrenderable theme colours.\n */\nexport function gamutError(lch: Oklch): number {\n if (inSrgbGamut(lch)) return 0\n return lch.c - gamutMapOklch(lch).c\n}\n\n/** Does this sRGB colour survive a round trip through OKLCH unchanged? Diagnostic helper. */\nexport function isGamutStable(rgb: Rgb): boolean {\n return inSrgbGamut(rgbToOklch(rgb))\n}\n\nfunction clamp01(v: number): number {\n return v < 0 ? 0 : v > 1 ? 1 : v\n}\n\nfunction linearToSrgb(c: number): number {\n return c <= 0.0031308 ? c * 12.92 : 1.055 * Math.abs(c) ** (1 / 2.4) * Math.sign(c) - 0.055\n}\n","import { clamp, lerp, wrap } from '../math/scalar'\nimport { type EasingInput, resolveEasing } from '../easing'\nimport {\n hslToRgb,\n linearToRgb,\n oklabToRgb,\n rgbToHsl,\n rgbToLinear,\n rgbToOklab,\n rgbToOklch,\n} from './convert'\nimport { oklchToRgbMapped } from './gamut'\nimport { parseColor } from './parse'\nimport { toRgbString } from './format'\nimport type { ColorInput, ColorSpace, HueDirection, Rgb } from './types'\n\n/**\n * Colour interpolation and gradient construction.\n *\n * The default space is OKLab, and that default is load-bearing — but it is worth being precise\n * about *when* it matters, because the difference is not uniform.\n *\n * **Where sRGB fails badly: opposing hues.** Interpolating `#0000ff → #ffff00` in sRGB passes\n * through exactly `#808080` — a dead grey — because the channels cancel. In OKLab the same\n * transition keeps measurable chroma the whole way across. Any gradient spanning more than about a\n * quadrant of the hue circle hits some version of this.\n *\n * **Where sRGB merely differs: neighbouring hues.** For `#0275f4 → #9f0550` (blue to crimson,\n * ~104° apart) sRGB actually produces a *more* saturated midpoint, because it cuts the chord\n * straight through the colour solid. What it does not preserve is perceived *lightness* — the sRGB\n * path dips darker in the middle, so the transition reads as uneven even though it is vivid. OKLab\n * holds lightness steady, which is what makes a gradient feel smooth rather than lumpy.\n *\n * Use `oklch` when you want maximum vividness across distant hues; it travels the hue circle rather\n * than cutting across it, keeping chroma high throughout.\n */\n\nexport interface MixOptions {\n /** Space to interpolate through. Default `'oklab'`. */\n space?: ColorSpace\n /** Which way around the hue circle, for cylindrical spaces. Default `'shorter'`. */\n hue?: HueDirection\n /**\n * Gamut-map the result rather than clipping it.\n *\n * Slightly more expensive (a short binary search) but preserves hue and lightness for\n * out-of-gamut intermediates. Default `true` for `oklch`, `false` otherwise — `oklch`\n * interpolation is the one that routinely leaves the gamut.\n */\n gamutMap?: boolean\n}\n\n/**\n * Interpolate between two colours.\n *\n * `t` is clamped to `[0, 1]`. Alpha is always interpolated linearly, independent of space —\n * premultiplying would darken transitions to transparent, which is almost never wanted for\n * UI gradients.\n */\nexport function mixColors(from: ColorInput, to: ColorInput, t: number, options?: MixOptions): Rgb {\n const a = parseColor(from)\n const b = parseColor(to)\n return mixParsed(a, b, clamp(t, 0, 1), options)\n}\n\n/** The allocation-light path used by gradients, which have already parsed their stops. */\nexport function mixParsed(a: Rgb, b: Rgb, t: number, options?: MixOptions): Rgb {\n const space = options?.space ?? 'oklab'\n const alpha = lerp(a.a, b.a, t)\n\n switch (space) {\n case 'srgb':\n return { r: lerp(a.r, b.r, t), g: lerp(a.g, b.g, t), b: lerp(a.b, b.b, t), a: alpha }\n\n case 'lrgb': {\n const la = rgbToLinear(a)\n const lb = rgbToLinear(b)\n return linearToRgb({\n r: lerp(la.r, lb.r, t),\n g: lerp(la.g, lb.g, t),\n b: lerp(la.b, lb.b, t),\n a: alpha,\n })\n }\n\n case 'hsl': {\n const ha = rgbToHsl(a)\n const hb = rgbToHsl(b)\n return hslToRgb({\n h: lerpHue(ha.h, hb.h, t, options?.hue ?? 'shorter'),\n s: lerp(ha.s, hb.s, t),\n l: lerp(ha.l, hb.l, t),\n a: alpha,\n })\n }\n\n case 'oklch': {\n const ca = rgbToOklch(a)\n const cb = rgbToOklch(b)\n // A grey endpoint has an arbitrary hue; borrow the other end's so the transition\n // doesn't swing through unrelated colours on its way out of grey.\n const hueA = ca.c < 1e-5 ? cb.h : ca.h\n const hueB = cb.c < 1e-5 ? ca.h : cb.h\n const result = {\n l: lerp(ca.l, cb.l, t),\n c: lerp(ca.c, cb.c, t),\n h: lerpHue(hueA, hueB, t, options?.hue ?? 'shorter'),\n alpha,\n }\n return options?.gamutMap === false\n ? oklabToRgb({\n l: result.l,\n a: Math.cos((result.h * Math.PI) / 180) * result.c,\n b: Math.sin((result.h * Math.PI) / 180) * result.c,\n alpha,\n })\n : oklchToRgbMapped(result)\n }\n\n case 'oklab':\n default: {\n const la = rgbToOklab(a)\n const lb = rgbToOklab(b)\n return oklabToRgb({\n l: lerp(la.l, lb.l, t),\n a: lerp(la.a, lb.a, t),\n b: lerp(la.b, lb.b, t),\n alpha,\n })\n }\n }\n}\n\n/** Interpolate two hue angles, honouring the requested direction of travel. */\nexport function lerpHue(from: number, to: number, t: number, direction: HueDirection): number {\n const a = wrap(from, 0, 360)\n const b = wrap(to, 0, 360)\n let delta = b - a\n\n switch (direction) {\n case 'increasing':\n if (delta < 0) delta += 360\n break\n case 'decreasing':\n if (delta > 0) delta -= 360\n break\n case 'longer':\n // Take the long way round — produces rainbow sweeps rather than direct transitions.\n if (Math.abs(delta) < 180) delta += delta >= 0 ? -360 : 360\n break\n case 'shorter':\n default:\n if (delta > 180) delta -= 360\n else if (delta < -180) delta += 360\n break\n }\n\n return wrap(a + delta * t, 0, 360)\n}\n\n// ---------------------------------------------------------------------------\n// Gradients\n// ---------------------------------------------------------------------------\n\nexport interface GradientStop {\n /** Position in `[0, 1]`. */\n offset: number\n color: ColorInput\n}\n\nexport interface GradientOptions extends MixOptions {\n /**\n * Easing applied to the position *within each segment*, not across the whole gradient.\n *\n * This is how you get a gradient that lingers near one colour: `easeInQuad` compresses\n * the transition toward the end of each segment. Default linear.\n */\n easing?: EasingInput\n}\n\nexport interface Gradient {\n /** Colour at position `t` in `[0, 1]`. */\n at(t: number): Rgb\n /** Colour at position `t`, formatted for `fillStyle`. */\n cssAt(t: number): string\n /** Evenly sample the gradient into `count` colours. */\n sample(count: number): Rgb[]\n /** A `linear-gradient(...)` string with `count` stops, for CSS backgrounds. */\n toCss(direction?: string, count?: number): string\n readonly stops: readonly GradientStop[]\n}\n\n/**\n * Build a multi-stop gradient.\n *\n * Accepts either a flat list of colours (distributed evenly) or explicit stops. Any number of\n * colours is supported — there is no cap, and no assumption of two.\n */\nexport function createGradient(\n input: readonly ColorInput[] | readonly GradientStop[],\n options?: GradientOptions,\n): Gradient {\n const stops = normalizeStops(input)\n if (stops.length === 0) {\n throw new RangeError('[ansh] createGradient() requires at least one colour stop.')\n }\n\n const parsed = stops.map((s) => parseColor(s.color))\n const offsets = stops.map((s) => s.offset)\n const ease = resolveEasing(options?.easing)\n const mixOptions: MixOptions = {\n space: options?.space ?? 'oklab',\n hue: options?.hue ?? 'shorter',\n gamutMap: options?.gamutMap,\n }\n\n const at = (t: number): Rgb => {\n const clamped = clamp(t, 0, 1)\n const last = parsed.length - 1\n if (last === 0) return parsed[0]\n if (clamped <= offsets[0]) return parsed[0]\n if (clamped >= offsets[last]) return parsed[last]\n\n // Stops are sorted, so a linear scan is fine — gradients have a handful of stops, and a\n // scan beats a binary search at this size while keeping the code obvious.\n let i = 0\n while (i < last && offsets[i + 1] < clamped) i++\n\n const span = offsets[i + 1] - offsets[i]\n const local = span <= 0 ? 0 : (clamped - offsets[i]) / span\n return mixParsed(parsed[i], parsed[i + 1], ease(local), mixOptions)\n }\n\n return {\n at,\n cssAt: (t) => toRgbString(at(t)),\n sample(count) {\n const n = Math.max(1, Math.floor(count))\n const out: Rgb[] = new Array(n)\n for (let i = 0; i < n; i++) out[i] = at(n === 1 ? 0 : i / (n - 1))\n return out\n },\n toCss(direction = 'to right', count = 16) {\n const n = Math.max(2, Math.floor(count))\n const parts: string[] = []\n for (let i = 0; i < n; i++) {\n const t = i / (n - 1)\n parts.push(`${toRgbString(at(t))} ${(t * 100).toFixed(2)}%`)\n }\n return `linear-gradient(${direction}, ${parts.join(', ')})`\n },\n stops,\n }\n}\n\nfunction normalizeStops(input: readonly ColorInput[] | readonly GradientStop[]): GradientStop[] {\n if (input.length === 0) return []\n\n const isStopList =\n typeof input[0] === 'object' && input[0] !== null && 'offset' in (input[0] as object)\n\n const stops: GradientStop[] = isStopList\n ? (input as readonly GradientStop[]).map((s) => ({\n offset: clamp(s.offset, 0, 1),\n color: s.color,\n }))\n : (input as readonly ColorInput[]).map((color, i, arr) => ({\n offset: arr.length === 1 ? 0 : i / (arr.length - 1),\n color,\n }))\n\n return stops.sort((a, b) => a.offset - b.offset)\n}\n\n/**\n * Apply the gradient's stops to a native canvas gradient object.\n *\n * We can't hand the canvas our stops directly — it would interpolate them in sRGB and undo\n * the whole point. Instead we sample our own interpolation into `resolution` intermediate\n * stops, so the browser only ever interpolates over tiny intervals where the space barely\n * matters. 24 stops is visually indistinguishable from continuous.\n */\nexport function applyGradientStops(\n target: CanvasGradient,\n gradient: Gradient,\n resolution = 24,\n): CanvasGradient {\n const n = Math.max(2, Math.floor(resolution))\n for (let i = 0; i < n; i++) {\n const t = i / (n - 1)\n target.addColorStop(t, toRgbString(gradient.at(t)))\n }\n return target\n}\n\n/**\n * Blend a colour toward another by a fixed amount, in a chosen space.\n * Shorthand for the common \"10% lighter\" adjustment.\n */\nexport function blend(base: ColorInput, over: ColorInput, amount = 0.5, space?: ColorSpace): Rgb {\n return mixColors(base, over, amount, { space })\n}\n\n/**\n * Composite `over` onto `base` using its alpha — the \"source-over\" Porter-Duff operator,\n * evaluated in linear light so it matches what the GPU does.\n */\nexport function composite(base: ColorInput, over: ColorInput): Rgb {\n const b = rgbToLinear(parseColor(base))\n const o = rgbToLinear(parseColor(over))\n const alpha = o.a + b.a * (1 - o.a)\n if (alpha <= 0) return { r: 0, g: 0, b: 0, a: 0 }\n return linearToRgb({\n r: (o.r * o.a + b.r * b.a * (1 - o.a)) / alpha,\n g: (o.g * o.a + b.g * b.a * (1 - o.a)) / alpha,\n b: (o.b * o.a + b.b * b.a * (1 - o.a)) / alpha,\n a: alpha,\n })\n}\n","import { clamp, lerp, wrap } from '../math/scalar'\nimport { createRng } from '../math/random'\nimport { rgbToOklch } from './convert'\nimport { maxChroma, oklchToRgbMapped } from './gamut'\nimport { parseColor } from './parse'\nimport { createGradient } from './interpolate'\nimport { toHex } from './format'\nimport type { ColorInput, Rgb } from './types'\n\n/**\n * Palette generation in OKLCH.\n *\n * Generating a scale by scaling HSL lightness produces the familiar problem where the\n * \"same\" adjustment makes yellow wash out and blue go muddy — because HSL lightness is not\n * perceptual. Doing it in OKLCH means step 500 of a blue scale and step 500 of a yellow scale\n * have genuinely matching visual weight, which is what makes a generated theme usable.\n */\n\nexport type HarmonyKind =\n | 'analogous'\n | 'complementary'\n | 'splitComplementary'\n | 'triadic'\n | 'tetradic'\n | 'square'\n | 'monochromatic'\n\n/** Hue offsets in degrees for each classical harmony, relative to the base hue. */\nconst HARMONY_OFFSETS: Record<HarmonyKind, readonly number[]> = {\n analogous: [-30, 0, 30],\n complementary: [0, 180],\n splitComplementary: [0, 150, 210],\n triadic: [0, 120, 240],\n tetradic: [0, 60, 180, 240],\n square: [0, 90, 180, 270],\n monochromatic: [0],\n}\n\n/**\n * Derive a set of harmonious colours from a base.\n *\n * Chroma and lightness are preserved from the base and each result is gamut-mapped, so a\n * harmony built from a displayable colour is always itself displayable.\n */\nexport function harmony(base: ColorInput, kind: HarmonyKind = 'analogous'): Rgb[] {\n const lch = rgbToOklch(parseColor(base))\n const offsets = HARMONY_OFFSETS[kind]\n\n if (kind === 'monochromatic') {\n // A single hue varied by lightness instead — the only sensible reading of \"monochromatic\".\n return [0.35, 0.5, 0.65, 0.8].map((l) =>\n oklchToRgbMapped({ l, c: lch.c, h: lch.h, alpha: lch.alpha }),\n )\n }\n\n return offsets.map((offset) =>\n oklchToRgbMapped({ l: lch.l, c: lch.c, h: wrap(lch.h + offset, 0, 360), alpha: lch.alpha }),\n )\n}\n\nexport interface ScaleOptions {\n /**\n * Number of steps. `11` matches the Tailwind convention (50–950) and is the default,\n * because that is the shape most consumers will slot this into.\n */\n steps?: number\n /** Lightness of the lightest step, in OKLCH `[0, 1]`. Default `0.97`. */\n lightest?: number\n /** Lightness of the darkest step. Default `0.18`. */\n darkest?: number\n /**\n * How much chroma falls off at the extremes, in `[0, 1]`.\n *\n * Real pigments lose saturation as they approach white or black, and scales that hold\n * chroma constant look artificial at the ends. `0.35` is a natural-looking default.\n */\n chromaFalloff?: number\n /**\n * Hue drift across the scale, in degrees.\n *\n * Slightly warming the light end and cooling the dark end (or vice versa) is what makes\n * hand-tuned scales feel considered. Default `0` — opt in deliberately.\n */\n hueShift?: number\n}\n\nexport interface ColorScale {\n /** The generated colours, lightest first. */\n colors: Rgb[]\n /** Hex strings, lightest first. Convenient for theme output. */\n hex: string[]\n /** Tailwind-style numeric keys when `steps` is 11, otherwise `0..steps-1`. */\n byKey: Record<string, string>\n}\n\nconst TAILWIND_KEYS = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950']\n\n/**\n * Build a lightness scale from a single seed colour.\n *\n * The seed's own hue and chroma anchor the scale; its lightness is *not* preserved, since the\n * point of a scale is to span the range. Use `scale.colors[5]` (or key `500`) as the closest\n * equivalent of the input.\n */\nexport function createScale(base: ColorInput, options: ScaleOptions = {}): ColorScale {\n const steps = Math.max(2, Math.floor(options.steps ?? 11))\n const lightest = clamp(options.lightest ?? 0.97, 0, 1)\n const darkest = clamp(options.darkest ?? 0.18, 0, 1)\n const falloff = clamp(options.chromaFalloff ?? 0.35, 0, 1)\n const hueShift = options.hueShift ?? 0\n\n const lch = rgbToOklch(parseColor(base))\n\n const colors: Rgb[] = []\n for (let i = 0; i < steps; i++) {\n const t = i / (steps - 1)\n const l = lerp(lightest, darkest, t)\n\n // Chroma peaks in the middle of the scale and eases off toward both ends. `sin(πt)`\n // gives exactly that shape with no branching.\n const envelope = Math.sin(Math.PI * t)\n const chromaFactor = 1 - falloff * (1 - envelope)\n const c = Math.min(lch.c * chromaFactor, maxChroma(l, lch.h))\n\n const h = wrap(lch.h + hueShift * (t - 0.5) * 2, 0, 360)\n colors.push(oklchToRgbMapped({ l, c, h, alpha: 1 }))\n }\n\n const hex = colors.map((c) => toHex(c))\n const keys = steps === 11 ? TAILWIND_KEYS : colors.map((_, i) => String(i))\n const byKey: Record<string, string> = {}\n keys.forEach((key, i) => {\n byKey[key] = hex[i]\n })\n\n return { colors, hex, byKey }\n}\n\nexport interface PaletteOptions {\n /** Number of colours to generate. Default `5`. */\n count?: number\n /** Seed for the stochastic variation. Same seed ⇒ same palette. Default `1`. */\n seed?: number | string\n /**\n * Overall lightness of the palette in `[0, 1]`. `0.75` reads as pastel, `0.5` as vivid,\n * `0.3` as moody. Default `0.65`.\n */\n lightness?: number\n /** Chroma as a fraction of the maximum available at each hue, in `[0, 1]`. Default `0.85`. */\n saturation?: number\n /** Total hue span in degrees the palette covers. Default `120`. */\n spread?: number\n /** Starting hue in degrees. Random (but seeded) when omitted. */\n baseHue?: number\n /** Random variation applied to lightness and chroma, in `[0, 1]`. Default `0.12`. */\n variance?: number\n}\n\n/**\n * Generate a coherent palette from scratch.\n *\n * Hues are distributed with a golden-ratio walk rather than evenly, because even spacing\n * produces the flat, obviously-computed look of an auto-generated chart palette. The walk\n * gives spacing that reads as deliberate.\n */\nexport function generatePalette(options: PaletteOptions = {}): Rgb[] {\n const count = Math.max(1, Math.floor(options.count ?? 5))\n const rng = createRng(options.seed ?? 1)\n const lightness = clamp(options.lightness ?? 0.65, 0.05, 0.98)\n const saturation = clamp(options.saturation ?? 0.85, 0, 1)\n const spread = options.spread ?? 120\n const variance = clamp(options.variance ?? 0.12, 0, 1)\n const baseHue = options.baseHue ?? rng.next() * 360\n\n const GOLDEN_ANGLE = 137.507764\n const colors: Rgb[] = []\n\n for (let i = 0; i < count; i++) {\n // Constrain the golden walk to the requested spread so the palette stays coherent.\n const walk = count === 1 ? 0 : ((i * GOLDEN_ANGLE) % 360) / 360\n const h = wrap(baseHue + (walk - 0.5) * spread, 0, 360)\n\n const l = clamp(lightness + (rng.next() * 2 - 1) * variance * 0.5, 0.05, 0.98)\n const c = maxChroma(l, h) * clamp(saturation + (rng.next() * 2 - 1) * variance, 0, 1)\n\n colors.push(oklchToRgbMapped({ l, c, h, alpha: 1 }))\n }\n\n return colors\n}\n\n/**\n * Extend a short palette to `count` colours by interpolating between the ones given.\n *\n * Effects that need N colours (a mesh gradient with 6 control points, say) shouldn't force\n * the author to supply exactly N. This fills the gap perceptually, so the extras look like\n * they belong to the same palette rather than like interpolation artefacts.\n */\nexport function expandPalette(colors: readonly ColorInput[], count: number): Rgb[] {\n const n = Math.max(1, Math.floor(count))\n if (colors.length === 0) throw new RangeError('[ansh] expandPalette() needs at least one colour.')\n if (colors.length === 1) return new Array(n).fill(parseColor(colors[0]))\n if (colors.length >= n) return colors.slice(0, n).map((c) => parseColor(c))\n\n return createGradient(colors, { space: 'oklch' }).sample(n)\n}\n\n/**\n * Sort a palette by perceived lightness. Ascending puts the darkest first.\n * Layered effects use this so that lighter colours land on top by default.\n */\nexport function sortByLightness(colors: readonly ColorInput[], ascending = true): Rgb[] {\n return colors\n .map((c) => parseColor(c))\n .sort((a, b) => {\n const delta = rgbToOklch(a).l - rgbToOklch(b).l\n return ascending ? delta : -delta\n })\n}\n\n/**\n * Derive a palette suited to a dark surface from one designed for light (or vice versa).\n *\n * Not a lightness inversion — that ruins hue relationships. Instead lightness is reflected\n * about the midpoint while chroma is *raised*, compensating for the fact that saturated\n * colours read as less vivid against dark backgrounds (the Helmholtz–Kohlrausch effect).\n */\nexport function invertForSurface(colors: readonly ColorInput[], chromaBoost = 1.15): Rgb[] {\n return colors.map((input) => {\n const lch = rgbToOklch(parseColor(input))\n const l = clamp(1 - lch.l, 0.08, 0.95)\n const c = Math.min(lch.c * chromaBoost, maxChroma(l, lch.h))\n return oklchToRgbMapped({ l, c, h: lch.h, alpha: lch.alpha })\n })\n}\n\n/**\n * The Ansh signature palettes.\n *\n * These are the defaults every effect falls back to when no colours are supplied. They are\n * chosen so that a developer who writes `<AuroraBackground />` with no props gets something\n * that looks like a considered design decision rather than a debug view.\n */\nexport const palettes = {\n /** Deep blue → violet → magenta. The house palette. */\n ansh: ['#0275f4', '#5b3df5', '#9f0550'],\n /** Cool northern lights: teal, green, indigo. */\n aurora: ['#00d4ff', '#22e39a', '#4f46e5'],\n /** Warm dusk: amber through rose. */\n ember: ['#ff9d00', '#ff4d6d', '#c026d3'],\n /** Oceanic blues and cyans. */\n abyss: ['#012a4a', '#0275f4', '#00d4ff'],\n /** Monochrome with a cool cast — for restrained, editorial designs. */\n graphite: ['#f8fafc', '#94a3b8', '#0f172a'],\n /** High-energy neon for AI and developer-tool aesthetics. */\n neon: ['#00d4ff', '#8a2be2', '#ff0066'],\n /** Soft pastel wash for marketing and onboarding. */\n bloom: ['#fbcfe8', '#c7d2fe', '#a7f3d0'],\n /** Gold and bronze — luxury, premium tiers, testimonials. */\n gilded: ['#fde68a', '#d97706', '#78350f'],\n} as const satisfies Record<string, readonly string[]>\n\nexport type PaletteName = keyof typeof palettes\n\n/** Resolve a palette name, an explicit colour list, or `undefined` (→ the house palette). */\nexport function resolvePalette(\n input: PaletteName | readonly ColorInput[] | undefined,\n fallback: PaletteName = 'ansh',\n): Rgb[] {\n if (input === undefined) return palettes[fallback].map((c) => parseColor(c))\n if (typeof input === 'string') {\n const named = palettes[input as PaletteName]\n return (named ?? palettes[fallback]).map((c) => parseColor(c))\n }\n if (input.length === 0) return palettes[fallback].map((c) => parseColor(c))\n return input.map((c) => parseColor(c))\n}\n"]}
1
+ {"version":3,"sources":["../src/color/format.ts","../src/color/internal.ts","../src/color/gamut.ts","../src/color/interpolate.ts","../src/color/palette.ts"],"names":["clamp","roundTo","rgbToHsl","rgbToOklch","oklchToOklab","parseColor","lerp","rgbToLinear","linearToRgb","hslToRgb","oklabToRgb","rgbToOklab","wrap","resolveEasing","createRng"],"mappings":";;;;;;;;AAYA,IAAM,IAAA,GAAO,CAAC,CAAA,KAAc,IAAA,CAAK,KAAA,CAAMA,wBAAM,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA,GAAI,GAAG,CAAA;AAGpD,SAAS,KAAA,CAAM,KAAA,EAAY,UAAA,GAAa,KAAA,EAAe;AAC5D,EAAA,MAAM,GAAA,GAAM,CAAC,CAAA,KAAc,CAAA,CAAE,SAAS,EAAE,CAAA,CAAE,QAAA,CAAS,CAAA,EAAG,GAAG,CAAA;AACzD,EAAA,MAAM,IAAA,GAAO,IAAI,GAAA,CAAI,IAAA,CAAK,MAAM,CAAC,CAAC,CAAC,C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,EAExC,KAAA,EAAO,CAAC,SAAA,EAAW,SAAA,EAAW,SAAS,CAAA;AAAA;AAAA,EAEvC,KAAA,EAAO,CAAC,SAAA,EAAW,SAAA,EAAW,SAAS,CAAA;AAAA;AAAA,EAEvC,QAAA,EAAU,CAAC,SAAA,EAAW,SAAA,EAAW,SAAS,CAAA;AAAA;AAAA,EAE1C,IAAA,EAAM,CAAC,SAAA,EAAW,SAAA,EAAW,SAAS,CAAA;AAAA;AAAA,EAEtC,KAAA,EAAO,CAAC,SAAA,EAAW,SAAA,EAAW,SAAS,CAAA;AAAA;AAAA,EAEvC,MAAA,EAAQ,CAAC,SAAA,EAAW,SAAA,EAAW,SAAS;AAC1C;AAKO,SAAS,cAAA,CACd,KAAA,EACA,QAAA,GAAwB,MAAA,EACjB;AACP,EAAA,IAAI,KAAA,KAAU,MAAA,EAAW,OAAO,QAAA,CAAS,QAAQ,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA,KAAMK,4BAAA,CAAW,CAAC,CAAC,CAAA;AAC3E,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,MAAM,KAAA,GAAQ,SAAS,KAAoB,CAAA;AAC3C,IAAA,OAAA,CAAQ,KAAA,IAAS,SAAS,QAAQ,CAAA,EAAG,IAAI,CAAC,CAAA,KAAMA,4BAAA,CAAW,CAAC,CAAC,CAAA;AAAA,EAC/D;AACA,EAAA,IAAI,KAAA,CAAM,MAAA,KAAW,CAAA,EAAG,OAAO,QAAA,CAAS,QAAQ,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA,KAAMA,4BAAA,CAAW,CAAC,CAAC,CAAA;AAC1E,EAAA,OAAO,MAAM,GAAA,CAAI,CAAC,CAAA,KAAMA,4BAAA,CAAW,CAAC,CAAC,CAAA;AACvC","file":"chunk-4ORYTFY3.cjs","sourcesContent":["import { clamp, roundTo } from '../math/scalar'\nimport { rgbToHsl, rgbToOklch } from './convert'\nimport type { Rgb } from './types'\n\n/**\n * Serialising colours back to strings.\n *\n * `toRgbString` is the workhorse: canvas `fillStyle` accepts it, it is the cheapest to\n * produce, and it is universally supported. The others exist for authoring output — the\n * theme generator emits `oklch()`, the docs site shows hex.\n */\n\nconst byte = (c: number) => Math.round(clamp(c, 0, 1) * 255)\n\n/** `#rrggbb`, or `#rrggbbaa` when not fully opaque (or when `forceAlpha` is set). */\nexport function toHex(color: Rgb, forceAlpha = false): string {\n const hex = (n: number) => n.toString(16).padStart(2, '0')\n const base = `#${hex(byte(color.r))}${hex(byte(color.g))}${hex(byte(color.b))}`\n return color.a < 1 || forceAlpha ? `${base}${hex(byte(color.a))}` : base\n}\n\n/**\n * `rgb(r g b)` / `rgb(r g b / a)`.\n *\n * Uses the legacy comma form because it is what every canvas implementation and every\n * browser back to 2015 accepts; the space-separated form is newer than our support target.\n */\nexport function toRgbString(color: Rgb): string {\n const r = byte(color.r)\n const g = byte(color.g)\n const b = byte(color.b)\n return color.a < 1\n ? `rgba(${r}, ${g}, ${b}, ${roundTo(clamp(color.a, 0, 1), 4)})`\n : `rgb(${r}, ${g}, ${b})`\n}\n\nexport function toHslString(color: Rgb): string {\n const hsl = rgbToHsl(color)\n const h = roundTo(hsl.h, 1)\n const s = roundTo(hsl.s * 100, 1)\n const l = roundTo(hsl.l * 100, 1)\n return hsl.a < 1 ? `hsla(${h}, ${s}%, ${l}%, ${roundTo(hsl.a, 4)})` : `hsl(${h}, ${s}%, ${l}%)`\n}\n\n/** `oklch(l% c h)` — the modern authoring form, and what the theme generator emits. */\nexport function toOklchString(color: Rgb): string {\n const lch = rgbToOklch(color)\n const l = roundTo(lch.l * 100, 2)\n const c = roundTo(lch.c, 4)\n const h = roundTo(lch.h, 2)\n return lch.alpha < 1\n ? `oklch(${l}% ${c} ${h} / ${roundTo(lch.alpha, 4)})`\n : `oklch(${l}% ${c} ${h})`\n}\n\n/**\n * Pack into a 32-bit integer as `0xAABBGGRR`.\n *\n * This is the byte order a `Uint32Array` view over `ImageData` expects on little-endian\n * machines, which is every platform we target. Effects that write pixels directly — the noise\n * layer, the grain overlay — use this to fill a row with one store per pixel instead of four.\n */\nexport function toUint32(color: Rgb): number {\n return (\n ((byte(color.a) << 24) | (byte(color.b) << 16) | (byte(color.g) << 8) | byte(color.r)) >>> 0\n )\n}\n\nexport function fromUint32(packed: number): Rgb {\n return {\n r: (packed & 0xff) / 255,\n g: ((packed >>> 8) & 0xff) / 255,\n b: ((packed >>> 16) & 0xff) / 255,\n a: ((packed >>> 24) & 0xff) / 255,\n }\n}\n\n/** Replace a colour's alpha, leaving its hue and lightness untouched. */\nexport function withAlpha(color: Rgb, alpha: number): Rgb {\n return { r: color.r, g: color.g, b: color.b, a: clamp(alpha, 0, 1) }\n}\n\n/** Scale a colour's existing alpha — useful for fading a whole palette at once. */\nexport function fadeBy(color: Rgb, factor: number): Rgb {\n return { r: color.r, g: color.g, b: color.b, a: clamp(color.a * factor, 0, 1) }\n}\n","import { oklchToOklab } from './convert'\nimport type { LinearRgb, Oklch } from './types'\n\n/**\n * OKLCH → linear RGB **without** clamping.\n *\n * Gamut testing needs to see the out-of-range values that the public conversion functions\n * deliberately clamp away, so this lives apart from `convert.ts` to keep that boundary\n * explicit: everything public returns displayable colour, and only the gamut mapper looks\n * at raw values.\n */\nexport function oklchToLinearUnclamped(lch: Oklch): LinearRgb {\n const lab = oklchToOklab(lch)\n const l_ = lab.l + 0.3963377774 * lab.a + 0.2158037573 * lab.b\n const m_ = lab.l - 0.1055613458 * lab.a - 0.0638541728 * lab.b\n const s_ = lab.l - 0.0894841775 * lab.a - 1.291485548 * lab.b\n\n const l = l_ * l_ * l_\n const m = m_ * m_ * m_\n const s = s_ * s_ * s_\n\n return {\n r: 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n g: -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n b: -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,\n a: lch.alpha,\n }\n}\n","import { oklchToLinearUnclamped } from './internal'\nimport { rgbToOklch } from './convert'\nimport type { Oklch, Rgb } from './types'\n\n/**\n * Gamut mapping for sRGB.\n *\n * OKLCH can describe colours sRGB cannot display. Naively clipping the RGB channels shifts\n * both hue and lightness — a vivid `oklch(0.7 0.35 150)` clips to a muddy, *lighter* green.\n *\n * The CSS Color 4 recommended approach, implemented here, is to hold lightness and hue fixed\n * and binary-search chroma down to the gamut boundary. The result is the most saturated\n * displayable colour with the same perceived hue and lightness, which is what an author means\n * when they ask for a colour that's out of range.\n */\n\nconst EPSILON = 1e-4\nconst TOLERANCE = 1e-5\n\n/** Is this OKLCH colour displayable in sRGB? */\nexport function inSrgbGamut(lch: Oklch): boolean {\n const lin = oklchToLinearUnclamped(lch)\n return (\n lin.r >= -TOLERANCE &&\n lin.r <= 1 + TOLERANCE &&\n lin.g >= -TOLERANCE &&\n lin.g <= 1 + TOLERANCE &&\n lin.b >= -TOLERANCE &&\n lin.b <= 1 + TOLERANCE\n )\n}\n\n/**\n * Reduce chroma until the colour fits in sRGB, preserving lightness and hue.\n *\n * Returns the input unchanged when it is already in gamut, so this is safe to call\n * unconditionally.\n */\nexport function gamutMapOklch(lch: Oklch): Oklch {\n if (inSrgbGamut(lch)) return lch\n\n // Pure black and white are always in gamut; anything outside [0,1] lightness cannot be\n // rescued by chroma reduction, so clamp lightness first.\n const l = Math.min(1, Math.max(0, lch.l))\n if (l <= 0) return { l: 0, c: 0, h: lch.h, alpha: lch.alpha }\n if (l >= 1) return { l: 1, c: 0, h: lch.h, alpha: lch.alpha }\n\n let low = 0\n let high = lch.c\n\n while (high - low > EPSILON) {\n const mid = (low + high) / 2\n if (inSrgbGamut({ l, c: mid, h: lch.h, alpha: lch.alpha })) low = mid\n else high = mid\n }\n\n return { l, c: low, h: lch.h, alpha: lch.alpha }\n}\n\n/**\n * The maximum chroma sRGB can display at a given lightness and hue.\n *\n * This is what makes \"vivid\" palette generation possible: rather than picking an arbitrary\n * chroma and hoping, you can ask for the most saturated colour available at each hue and get\n * a palette with consistent, maximal punch.\n */\nexport function maxChroma(l: number, h: number): number {\n if (l <= 0 || l >= 1) return 0\n let low = 0\n let high = 0.5 // Comfortably beyond the sRGB maximum of ~0.37.\n while (high - low > EPSILON) {\n const mid = (low + high) / 2\n if (inSrgbGamut({ l, c: mid, h, alpha: 1 })) low = mid\n else high = mid\n }\n return low\n}\n\n/** Gamut-map, then convert to sRGB. The safe path from OKLCH to a displayable colour. */\nexport function oklchToRgbMapped(lch: Oklch): Rgb {\n const mapped = gamutMapOklch(lch)\n const lin = oklchToLinearUnclamped(mapped)\n return {\n r: clamp01(linearToSrgb(lin.r)),\n g: clamp01(linearToSrgb(lin.g)),\n b: clamp01(linearToSrgb(lin.b)),\n a: mapped.alpha,\n }\n}\n\n/**\n * How far outside sRGB a colour sits, as a rough distance in chroma units.\n * `0` means in gamut. Used by the docs site to warn about unrenderable theme colours.\n */\nexport function gamutError(lch: Oklch): number {\n if (inSrgbGamut(lch)) return 0\n return lch.c - gamutMapOklch(lch).c\n}\n\n/** Does this sRGB colour survive a round trip through OKLCH unchanged? Diagnostic helper. */\nexport function isGamutStable(rgb: Rgb): boolean {\n return inSrgbGamut(rgbToOklch(rgb))\n}\n\nfunction clamp01(v: number): number {\n return v < 0 ? 0 : v > 1 ? 1 : v\n}\n\nfunction linearToSrgb(c: number): number {\n return c <= 0.0031308 ? c * 12.92 : 1.055 * Math.abs(c) ** (1 / 2.4) * Math.sign(c) - 0.055\n}\n","import { clamp, lerp, wrap } from '../math/scalar'\nimport { type EasingInput, resolveEasing } from '../easing'\nimport {\n hslToRgb,\n linearToRgb,\n oklabToRgb,\n rgbToHsl,\n rgbToLinear,\n rgbToOklab,\n rgbToOklch,\n} from './convert'\nimport { oklchToRgbMapped } from './gamut'\nimport { parseColor } from './parse'\nimport { toRgbString } from './format'\nimport type { ColorInput, ColorSpace, HueDirection, Rgb } from './types'\n\n/**\n * Colour interpolation and gradient construction.\n *\n * The default space is OKLab, and that default is load-bearing — but it is worth being precise\n * about *when* it matters, because the difference is not uniform.\n *\n * **Where sRGB fails badly: opposing hues.** Interpolating `#0000ff → #ffff00` in sRGB passes\n * through exactly `#808080` — a dead grey — because the channels cancel. In OKLab the same\n * transition keeps measurable chroma the whole way across. Any gradient spanning more than about a\n * quadrant of the hue circle hits some version of this.\n *\n * **Where sRGB merely differs: neighbouring hues.** For `#0275f4 → #9f0550` (blue to crimson,\n * ~104° apart) sRGB actually produces a *more* saturated midpoint, because it cuts the chord\n * straight through the colour solid. What it does not preserve is perceived *lightness* — the sRGB\n * path dips darker in the middle, so the transition reads as uneven even though it is vivid. OKLab\n * holds lightness steady, which is what makes a gradient feel smooth rather than lumpy.\n *\n * Use `oklch` when you want maximum vividness across distant hues; it travels the hue circle rather\n * than cutting across it, keeping chroma high throughout.\n */\n\nexport interface MixOptions {\n /** Space to interpolate through. Default `'oklab'`. */\n space?: ColorSpace\n /** Which way around the hue circle, for cylindrical spaces. Default `'shorter'`. */\n hue?: HueDirection\n /**\n * Gamut-map the result rather than clipping it.\n *\n * Slightly more expensive (a short binary search) but preserves hue and lightness for\n * out-of-gamut intermediates. Default `true` for `oklch`, `false` otherwise — `oklch`\n * interpolation is the one that routinely leaves the gamut.\n */\n gamutMap?: boolean\n}\n\n/**\n * Interpolate between two colours.\n *\n * `t` is clamped to `[0, 1]`. Alpha is always interpolated linearly, independent of space —\n * premultiplying would darken transitions to transparent, which is almost never wanted for\n * UI gradients.\n */\nexport function mixColors(from: ColorInput, to: ColorInput, t: number, options?: MixOptions): Rgb {\n const a = parseColor(from)\n const b = parseColor(to)\n return mixParsed(a, b, clamp(t, 0, 1), options)\n}\n\n/** The allocation-light path used by gradients, which have already parsed their stops. */\nexport function mixParsed(a: Rgb, b: Rgb, t: number, options?: MixOptions): Rgb {\n const space = options?.space ?? 'oklab'\n const alpha = lerp(a.a, b.a, t)\n\n switch (space) {\n case 'srgb':\n return { r: lerp(a.r, b.r, t), g: lerp(a.g, b.g, t), b: lerp(a.b, b.b, t), a: alpha }\n\n case 'lrgb': {\n const la = rgbToLinear(a)\n const lb = rgbToLinear(b)\n return linearToRgb({\n r: lerp(la.r, lb.r, t),\n g: lerp(la.g, lb.g, t),\n b: lerp(la.b, lb.b, t),\n a: alpha,\n })\n }\n\n case 'hsl': {\n const ha = rgbToHsl(a)\n const hb = rgbToHsl(b)\n return hslToRgb({\n h: lerpHue(ha.h, hb.h, t, options?.hue ?? 'shorter'),\n s: lerp(ha.s, hb.s, t),\n l: lerp(ha.l, hb.l, t),\n a: alpha,\n })\n }\n\n case 'oklch': {\n const ca = rgbToOklch(a)\n const cb = rgbToOklch(b)\n // A grey endpoint has an arbitrary hue; borrow the other end's so the transition\n // doesn't swing through unrelated colours on its way out of grey.\n const hueA = ca.c < 1e-5 ? cb.h : ca.h\n const hueB = cb.c < 1e-5 ? ca.h : cb.h\n const result = {\n l: lerp(ca.l, cb.l, t),\n c: lerp(ca.c, cb.c, t),\n h: lerpHue(hueA, hueB, t, options?.hue ?? 'shorter'),\n alpha,\n }\n return options?.gamutMap === false\n ? oklabToRgb({\n l: result.l,\n a: Math.cos((result.h * Math.PI) / 180) * result.c,\n b: Math.sin((result.h * Math.PI) / 180) * result.c,\n alpha,\n })\n : oklchToRgbMapped(result)\n }\n\n case 'oklab':\n default: {\n const la = rgbToOklab(a)\n const lb = rgbToOklab(b)\n return oklabToRgb({\n l: lerp(la.l, lb.l, t),\n a: lerp(la.a, lb.a, t),\n b: lerp(la.b, lb.b, t),\n alpha,\n })\n }\n }\n}\n\n/** Interpolate two hue angles, honouring the requested direction of travel. */\nexport function lerpHue(from: number, to: number, t: number, direction: HueDirection): number {\n const a = wrap(from, 0, 360)\n const b = wrap(to, 0, 360)\n let delta = b - a\n\n switch (direction) {\n case 'increasing':\n if (delta < 0) delta += 360\n break\n case 'decreasing':\n if (delta > 0) delta -= 360\n break\n case 'longer':\n // Take the long way round — produces rainbow sweeps rather than direct transitions.\n if (Math.abs(delta) < 180) delta += delta >= 0 ? -360 : 360\n break\n case 'shorter':\n default:\n if (delta > 180) delta -= 360\n else if (delta < -180) delta += 360\n break\n }\n\n return wrap(a + delta * t, 0, 360)\n}\n\n// ---------------------------------------------------------------------------\n// Gradients\n// ---------------------------------------------------------------------------\n\nexport interface GradientStop {\n /** Position in `[0, 1]`. */\n offset: number\n color: ColorInput\n}\n\nexport interface GradientOptions extends MixOptions {\n /**\n * Easing applied to the position *within each segment*, not across the whole gradient.\n *\n * This is how you get a gradient that lingers near one colour: `easeInQuad` compresses\n * the transition toward the end of each segment. Default linear.\n */\n easing?: EasingInput\n}\n\nexport interface Gradient {\n /** Colour at position `t` in `[0, 1]`. */\n at(t: number): Rgb\n /** Colour at position `t`, formatted for `fillStyle`. */\n cssAt(t: number): string\n /** Evenly sample the gradient into `count` colours. */\n sample(count: number): Rgb[]\n /** A `linear-gradient(...)` string with `count` stops, for CSS backgrounds. */\n toCss(direction?: string, count?: number): string\n readonly stops: readonly GradientStop[]\n}\n\n/**\n * Build a multi-stop gradient.\n *\n * Accepts either a flat list of colours (distributed evenly) or explicit stops. Any number of\n * colours is supported — there is no cap, and no assumption of two.\n */\nexport function createGradient(\n input: readonly ColorInput[] | readonly GradientStop[],\n options?: GradientOptions,\n): Gradient {\n const stops = normalizeStops(input)\n if (stops.length === 0) {\n throw new RangeError('[ansh] createGradient() requires at least one colour stop.')\n }\n\n const parsed = stops.map((s) => parseColor(s.color))\n const offsets = stops.map((s) => s.offset)\n const ease = resolveEasing(options?.easing)\n const mixOptions: MixOptions = {\n space: options?.space ?? 'oklab',\n hue: options?.hue ?? 'shorter',\n gamutMap: options?.gamutMap,\n }\n\n const at = (t: number): Rgb => {\n const clamped = clamp(t, 0, 1)\n const last = parsed.length - 1\n if (last === 0) return parsed[0]\n if (clamped <= offsets[0]) return parsed[0]\n if (clamped >= offsets[last]) return parsed[last]\n\n // Stops are sorted, so a linear scan is fine — gradients have a handful of stops, and a\n // scan beats a binary search at this size while keeping the code obvious.\n let i = 0\n while (i < last && offsets[i + 1] < clamped) i++\n\n const span = offsets[i + 1] - offsets[i]\n const local = span <= 0 ? 0 : (clamped - offsets[i]) / span\n return mixParsed(parsed[i], parsed[i + 1], ease(local), mixOptions)\n }\n\n return {\n at,\n cssAt: (t) => toRgbString(at(t)),\n sample(count) {\n const n = Math.max(1, Math.floor(count))\n const out: Rgb[] = new Array(n)\n for (let i = 0; i < n; i++) out[i] = at(n === 1 ? 0 : i / (n - 1))\n return out\n },\n toCss(direction = 'to right', count = 16) {\n const n = Math.max(2, Math.floor(count))\n const parts: string[] = []\n for (let i = 0; i < n; i++) {\n const t = i / (n - 1)\n parts.push(`${toRgbString(at(t))} ${(t * 100).toFixed(2)}%`)\n }\n return `linear-gradient(${direction}, ${parts.join(', ')})`\n },\n stops,\n }\n}\n\nfunction normalizeStops(input: readonly ColorInput[] | readonly GradientStop[]): GradientStop[] {\n if (input.length === 0) return []\n\n const isStopList =\n typeof input[0] === 'object' && input[0] !== null && 'offset' in (input[0] as object)\n\n const stops: GradientStop[] = isStopList\n ? (input as readonly GradientStop[]).map((s) => ({\n offset: clamp(s.offset, 0, 1),\n color: s.color,\n }))\n : (input as readonly ColorInput[]).map((color, i, arr) => ({\n offset: arr.length === 1 ? 0 : i / (arr.length - 1),\n color,\n }))\n\n return stops.sort((a, b) => a.offset - b.offset)\n}\n\n/**\n * Apply the gradient's stops to a native canvas gradient object.\n *\n * We can't hand the canvas our stops directly — it would interpolate them in sRGB and undo\n * the whole point. Instead we sample our own interpolation into `resolution` intermediate\n * stops, so the browser only ever interpolates over tiny intervals where the space barely\n * matters. 24 stops is visually indistinguishable from continuous.\n */\nexport function applyGradientStops(\n target: CanvasGradient,\n gradient: Gradient,\n resolution = 24,\n): CanvasGradient {\n const n = Math.max(2, Math.floor(resolution))\n for (let i = 0; i < n; i++) {\n const t = i / (n - 1)\n target.addColorStop(t, toRgbString(gradient.at(t)))\n }\n return target\n}\n\n/**\n * Blend a colour toward another by a fixed amount, in a chosen space.\n * Shorthand for the common \"10% lighter\" adjustment.\n */\nexport function blend(base: ColorInput, over: ColorInput, amount = 0.5, space?: ColorSpace): Rgb {\n return mixColors(base, over, amount, { space })\n}\n\n/**\n * Composite `over` onto `base` using its alpha — the \"source-over\" Porter-Duff operator,\n * evaluated in linear light so it matches what the GPU does.\n */\nexport function composite(base: ColorInput, over: ColorInput): Rgb {\n const b = rgbToLinear(parseColor(base))\n const o = rgbToLinear(parseColor(over))\n const alpha = o.a + b.a * (1 - o.a)\n if (alpha <= 0) return { r: 0, g: 0, b: 0, a: 0 }\n return linearToRgb({\n r: (o.r * o.a + b.r * b.a * (1 - o.a)) / alpha,\n g: (o.g * o.a + b.g * b.a * (1 - o.a)) / alpha,\n b: (o.b * o.a + b.b * b.a * (1 - o.a)) / alpha,\n a: alpha,\n })\n}\n","import { clamp, lerp, wrap } from '../math/scalar'\nimport { createRng } from '../math/random'\nimport { rgbToOklch } from './convert'\nimport { maxChroma, oklchToRgbMapped } from './gamut'\nimport { parseColor } from './parse'\nimport { createGradient } from './interpolate'\nimport { toHex } from './format'\nimport type { ColorInput, Rgb } from './types'\n\n/**\n * Palette generation in OKLCH.\n *\n * Generating a scale by scaling HSL lightness produces the familiar problem where the\n * \"same\" adjustment makes yellow wash out and blue go muddy — because HSL lightness is not\n * perceptual. Doing it in OKLCH means step 500 of a blue scale and step 500 of a yellow scale\n * have genuinely matching visual weight, which is what makes a generated theme usable.\n */\n\nexport type HarmonyKind =\n | 'analogous'\n | 'complementary'\n | 'splitComplementary'\n | 'triadic'\n | 'tetradic'\n | 'square'\n | 'monochromatic'\n\n/** Hue offsets in degrees for each classical harmony, relative to the base hue. */\nconst HARMONY_OFFSETS: Record<HarmonyKind, readonly number[]> = {\n analogous: [-30, 0, 30],\n complementary: [0, 180],\n splitComplementary: [0, 150, 210],\n triadic: [0, 120, 240],\n tetradic: [0, 60, 180, 240],\n square: [0, 90, 180, 270],\n monochromatic: [0],\n}\n\n/**\n * Derive a set of harmonious colours from a base.\n *\n * Chroma and lightness are preserved from the base and each result is gamut-mapped, so a\n * harmony built from a displayable colour is always itself displayable.\n */\nexport function harmony(base: ColorInput, kind: HarmonyKind = 'analogous'): Rgb[] {\n const lch = rgbToOklch(parseColor(base))\n const offsets = HARMONY_OFFSETS[kind]\n\n if (kind === 'monochromatic') {\n // A single hue varied by lightness instead — the only sensible reading of \"monochromatic\".\n return [0.35, 0.5, 0.65, 0.8].map((l) =>\n oklchToRgbMapped({ l, c: lch.c, h: lch.h, alpha: lch.alpha }),\n )\n }\n\n return offsets.map((offset) =>\n oklchToRgbMapped({ l: lch.l, c: lch.c, h: wrap(lch.h + offset, 0, 360), alpha: lch.alpha }),\n )\n}\n\nexport interface ScaleOptions {\n /**\n * Number of steps. `11` matches the Tailwind convention (50–950) and is the default,\n * because that is the shape most consumers will slot this into.\n */\n steps?: number\n /** Lightness of the lightest step, in OKLCH `[0, 1]`. Default `0.97`. */\n lightest?: number\n /** Lightness of the darkest step. Default `0.18`. */\n darkest?: number\n /**\n * How much chroma falls off at the extremes, in `[0, 1]`.\n *\n * Real pigments lose saturation as they approach white or black, and scales that hold\n * chroma constant look artificial at the ends. `0.35` is a natural-looking default.\n */\n chromaFalloff?: number\n /**\n * Hue drift across the scale, in degrees.\n *\n * Slightly warming the light end and cooling the dark end (or vice versa) is what makes\n * hand-tuned scales feel considered. Default `0` — opt in deliberately.\n */\n hueShift?: number\n}\n\nexport interface ColorScale {\n /** The generated colours, lightest first. */\n colors: Rgb[]\n /** Hex strings, lightest first. Convenient for theme output. */\n hex: string[]\n /** Tailwind-style numeric keys when `steps` is 11, otherwise `0..steps-1`. */\n byKey: Record<string, string>\n}\n\nconst TAILWIND_KEYS = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950']\n\n/**\n * Build a lightness scale from a single seed colour.\n *\n * The seed's own hue and chroma anchor the scale; its lightness is *not* preserved, since the\n * point of a scale is to span the range. Use `scale.colors[5]` (or key `500`) as the closest\n * equivalent of the input.\n */\nexport function createScale(base: ColorInput, options: ScaleOptions = {}): ColorScale {\n const steps = Math.max(2, Math.floor(options.steps ?? 11))\n const lightest = clamp(options.lightest ?? 0.97, 0, 1)\n const darkest = clamp(options.darkest ?? 0.18, 0, 1)\n const falloff = clamp(options.chromaFalloff ?? 0.35, 0, 1)\n const hueShift = options.hueShift ?? 0\n\n const lch = rgbToOklch(parseColor(base))\n\n const colors: Rgb[] = []\n for (let i = 0; i < steps; i++) {\n const t = i / (steps - 1)\n const l = lerp(lightest, darkest, t)\n\n // Chroma peaks in the middle of the scale and eases off toward both ends. `sin(πt)`\n // gives exactly that shape with no branching.\n const envelope = Math.sin(Math.PI * t)\n const chromaFactor = 1 - falloff * (1 - envelope)\n const c = Math.min(lch.c * chromaFactor, maxChroma(l, lch.h))\n\n const h = wrap(lch.h + hueShift * (t - 0.5) * 2, 0, 360)\n colors.push(oklchToRgbMapped({ l, c, h, alpha: 1 }))\n }\n\n const hex = colors.map((c) => toHex(c))\n const keys = steps === 11 ? TAILWIND_KEYS : colors.map((_, i) => String(i))\n const byKey: Record<string, string> = {}\n keys.forEach((key, i) => {\n byKey[key] = hex[i]\n })\n\n return { colors, hex, byKey }\n}\n\nexport interface PaletteOptions {\n /** Number of colours to generate. Default `5`. */\n count?: number\n /** Seed for the stochastic variation. Same seed ⇒ same palette. Default `1`. */\n seed?: number | string\n /**\n * Overall lightness of the palette in `[0, 1]`. `0.75` reads as pastel, `0.5` as vivid,\n * `0.3` as moody. Default `0.65`.\n */\n lightness?: number\n /** Chroma as a fraction of the maximum available at each hue, in `[0, 1]`. Default `0.85`. */\n saturation?: number\n /** Total hue span in degrees the palette covers. Default `120`. */\n spread?: number\n /** Starting hue in degrees. Random (but seeded) when omitted. */\n baseHue?: number\n /** Random variation applied to lightness and chroma, in `[0, 1]`. Default `0.12`. */\n variance?: number\n}\n\n/**\n * Generate a coherent palette from scratch.\n *\n * Hues are distributed with a golden-ratio walk rather than evenly, because even spacing\n * produces the flat, obviously-computed look of an auto-generated chart palette. The walk\n * gives spacing that reads as deliberate.\n */\nexport function generatePalette(options: PaletteOptions = {}): Rgb[] {\n const count = Math.max(1, Math.floor(options.count ?? 5))\n const rng = createRng(options.seed ?? 1)\n const lightness = clamp(options.lightness ?? 0.65, 0.05, 0.98)\n const saturation = clamp(options.saturation ?? 0.85, 0, 1)\n const spread = options.spread ?? 120\n const variance = clamp(options.variance ?? 0.12, 0, 1)\n const baseHue = options.baseHue ?? rng.next() * 360\n\n const GOLDEN_ANGLE = 137.507764\n const colors: Rgb[] = []\n\n for (let i = 0; i < count; i++) {\n // Constrain the golden walk to the requested spread so the palette stays coherent.\n const walk = count === 1 ? 0 : ((i * GOLDEN_ANGLE) % 360) / 360\n const h = wrap(baseHue + (walk - 0.5) * spread, 0, 360)\n\n const l = clamp(lightness + (rng.next() * 2 - 1) * variance * 0.5, 0.05, 0.98)\n const c = maxChroma(l, h) * clamp(saturation + (rng.next() * 2 - 1) * variance, 0, 1)\n\n colors.push(oklchToRgbMapped({ l, c, h, alpha: 1 }))\n }\n\n return colors\n}\n\n/**\n * Extend a short palette to `count` colours by interpolating between the ones given.\n *\n * Effects that need N colours (a mesh gradient with 6 control points, say) shouldn't force\n * the author to supply exactly N. This fills the gap perceptually, so the extras look like\n * they belong to the same palette rather than like interpolation artefacts.\n */\nexport function expandPalette(colors: readonly ColorInput[], count: number): Rgb[] {\n const n = Math.max(1, Math.floor(count))\n if (colors.length === 0) throw new RangeError('[ansh] expandPalette() needs at least one colour.')\n if (colors.length === 1) return new Array(n).fill(parseColor(colors[0]))\n if (colors.length >= n) return colors.slice(0, n).map((c) => parseColor(c))\n\n return createGradient(colors, { space: 'oklch' }).sample(n)\n}\n\n/**\n * Sort a palette by perceived lightness. Ascending puts the darkest first.\n * Layered effects use this so that lighter colours land on top by default.\n */\nexport function sortByLightness(colors: readonly ColorInput[], ascending = true): Rgb[] {\n return colors\n .map((c) => parseColor(c))\n .sort((a, b) => {\n const delta = rgbToOklch(a).l - rgbToOklch(b).l\n return ascending ? delta : -delta\n })\n}\n\n/**\n * Derive a palette suited to a dark surface from one designed for light (or vice versa).\n *\n * Not a lightness inversion — that ruins hue relationships. Instead lightness is reflected\n * about the midpoint while chroma is *raised*, compensating for the fact that saturated\n * colours read as less vivid against dark backgrounds (the Helmholtz–Kohlrausch effect).\n */\nexport function invertForSurface(colors: readonly ColorInput[], chromaBoost = 1.15): Rgb[] {\n return colors.map((input) => {\n const lch = rgbToOklch(parseColor(input))\n const l = clamp(1 - lch.l, 0.08, 0.95)\n const c = Math.min(lch.c * chromaBoost, maxChroma(l, lch.h))\n return oklchToRgbMapped({ l, c, h: lch.h, alpha: lch.alpha })\n })\n}\n\n/**\n * The Ansh signature palettes.\n *\n * These are the defaults every effect falls back to when no colours are supplied. They are\n * chosen so that a developer who writes `<AuroraBackground />` with no props gets something\n * that looks like a considered design decision rather than a debug view.\n */\nexport const palettes = {\n /** Deep blue → violet → magenta. The house palette. */\n ansh: ['#0275f4', '#5b3df5', '#9f0550'],\n /** Cool northern lights: teal, green, indigo. */\n aurora: ['#00d4ff', '#22e39a', '#4f46e5'],\n /** Warm dusk: amber through rose. */\n ember: ['#ff9d00', '#ff4d6d', '#c026d3'],\n /** Oceanic blues and cyans. */\n abyss: ['#012a4a', '#0275f4', '#00d4ff'],\n /** Monochrome with a cool cast — for restrained, editorial designs. */\n graphite: ['#f8fafc', '#94a3b8', '#0f172a'],\n /** High-energy neon for AI and developer-tool aesthetics. */\n neon: ['#00d4ff', '#8a2be2', '#ff0066'],\n /** Soft pastel wash for marketing and onboarding. */\n bloom: ['#fbcfe8', '#c7d2fe', '#a7f3d0'],\n /** Gold and bronze — luxury, premium tiers, testimonials. */\n gilded: ['#fde68a', '#d97706', '#78350f'],\n} as const satisfies Record<string, readonly string[]>\n\nexport type PaletteName = keyof typeof palettes\n\n/** Resolve a palette name, an explicit colour list, or `undefined` (→ the house palette). */\nexport function resolvePalette(\n input: PaletteName | readonly ColorInput[] | undefined,\n fallback: PaletteName = 'ansh',\n): Rgb[] {\n if (input === undefined) return palettes[fallback].map((c) => parseColor(c))\n if (typeof input === 'string') {\n const named = palettes[input as PaletteName]\n return (named ?? palettes[fallback]).map((c) => parseColor(c))\n }\n if (input.length === 0) return palettes[fallback].map((c) => parseColor(c))\n return input.map((c) => parseColor(c))\n}\n"]}
@@ -890,7 +890,7 @@ function trackPointer(element, options = {}) {
890
890
  var CapabilityError = class extends Error {
891
891
  constructor(capability, hint) {
892
892
  super(
893
- `[ansh] Missing capability "${capability}".` + (hint ? ` ${hint}` : "") + ` See https://ansh.dev/docs/capabilities for the full list.`
893
+ `[ansh] Missing capability "${capability}".` + (hint ? ` ${hint}` : "") + ` See https://ansh.techiesofepi.com/showcase for the full list.`
894
894
  );
895
895
  this.capability = capability;
896
896
  this.name = "CapabilityError";
@@ -1056,5 +1056,5 @@ exports.resolveMotion = resolveMotion;
1056
1056
  exports.setReducedMotionMode = setReducedMotionMode;
1057
1057
  exports.setTicker = setTicker;
1058
1058
  exports.trackPointer = trackPointer;
1059
- //# sourceMappingURL=chunk-MMO7KO53.cjs.map
1060
- //# sourceMappingURL=chunk-MMO7KO53.cjs.map
1059
+ //# sourceMappingURL=chunk-FNR4B3KY.cjs.map
1060
+ //# sourceMappingURL=chunk-FNR4B3KY.cjs.map