File: /www/wwwroot/www.waciwang.com/wp-content/plugins/gutenberg/build/scripts/theme/index.min.js.map
{
"version": 3,
"sources": ["package-external:@wordpress/private-apis", "package-external:@wordpress/element", "vendor-external:react/jsx-runtime", "../../../packages/theme/src/lock-unlock.ts", "../../../packages/theme/src/theme-provider.tsx", "../../../packages/theme/src/style.module.css", "../../../packages/theme/src/context.ts", "../../../packages/theme/node_modules/colorjs.io/src/multiply-matrices.js", "../../../packages/theme/node_modules/colorjs.io/src/util.js", "../../../packages/theme/node_modules/colorjs.io/src/Type.js", "../../../packages/theme/node_modules/colorjs.io/src/Format.js", "../../../packages/theme/node_modules/colorjs.io/src/hooks.js", "../../../packages/theme/node_modules/colorjs.io/src/adapt.js", "../../../packages/theme/node_modules/colorjs.io/src/defaults.js", "../../../packages/theme/node_modules/colorjs.io/src/parse.js", "../../../packages/theme/node_modules/colorjs.io/src/getColor.js", "../../../packages/theme/node_modules/colorjs.io/src/ColorSpace.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/xyz-d65.js", "../../../packages/theme/node_modules/colorjs.io/src/RGBColorSpace.js", "../../../packages/theme/node_modules/colorjs.io/src/getAll.js", "../../../packages/theme/node_modules/colorjs.io/src/get.js", "../../../packages/theme/node_modules/colorjs.io/src/setAll.js", "../../../packages/theme/node_modules/colorjs.io/src/set.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/xyz-d50.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/lab.js", "../../../packages/theme/node_modules/colorjs.io/src/angles.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/lch.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaE2000.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/oklab.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaEOK.js", "../../../packages/theme/node_modules/colorjs.io/src/inGamut.js", "../../../packages/theme/node_modules/colorjs.io/src/clone.js", "../../../packages/theme/node_modules/colorjs.io/src/distance.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaE76.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaECMC.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/xyz-abs-d65.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/jzazbz.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/jzczhz.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaEJz.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/ictcp.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaEITP.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaEOK2.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/cam16.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/hct.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaEHCT.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/index.js", "../../../packages/theme/node_modules/colorjs.io/src/toGamut.js", "../../../packages/theme/node_modules/colorjs.io/src/to.js", "../../../packages/theme/node_modules/colorjs.io/src/serialize.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/p3-linear.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/srgb-linear.js", "../../../packages/theme/node_modules/colorjs.io/src/keywords.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/srgb.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/p3.js", "../../../packages/theme/node_modules/colorjs.io/src/luminance.js", "../../../packages/theme/node_modules/colorjs.io/src/contrast/WCAG21.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/hsl.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/oklch.js", "../../../node_modules/memize/dist/index.js", "../../../packages/theme/src/use-theme-provider-styles.ts", "../../../packages/theme/src/color-ramps/lib/register-color-spaces.ts", "../../../packages/theme/src/prebuilt/ts/color-tokens.ts", "../../../packages/theme/src/color-ramps/lib/color-utils.ts", "../../../packages/theme/src/color-ramps/lib/constants.ts", "../../../packages/theme/src/color-ramps/lib/utils.ts", "../../../packages/theme/src/color-ramps/lib/taper-chroma.ts", "../../../packages/theme/src/color-ramps/lib/find-color-with-constraints.ts", "../../../packages/theme/src/color-ramps/lib/index.ts", "../../../packages/theme/src/color-ramps/lib/ramp-configs.ts", "../../../packages/theme/src/color-ramps/index.ts", "../../../packages/theme/src/private-apis.ts"],
"sourcesContent": ["module.exports = window.wp.privateApis;", "module.exports = window.wp.element;", "module.exports = window.ReactJSXRuntime;", "/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/theme'\n\t);\n", "/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useId } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ThemeContext } from './context';\nimport { useThemeProviderStyles } from './use-theme-provider-styles';\nimport { type ThemeProviderProps } from './types';\nimport styles from './style.module.css';\n\nfunction cssObjectToText( values: CSSProperties ) {\n\treturn Object.entries( values )\n\t\t.map( ( [ key, value ] ) => `${ key }: ${ value };` )\n\t\t.join( '' );\n}\n\nfunction generateCSSSelector( {\n\tinstanceId,\n\tisRoot,\n}: {\n\tinstanceId: string;\n\tisRoot: boolean;\n} ) {\n\tconst rootSel = `[data-wpds-root-provider=\"true\"]`;\n\tconst instanceIdSel = `[data-wpds-theme-provider-id=\"${ instanceId }\"]`;\n\n\tconst selectors = [];\n\n\tif ( isRoot ) {\n\t\tselectors.push(\n\t\t\t`:root:has(.${ styles.root }${ rootSel }${ instanceIdSel })`\n\t\t);\n\t}\n\n\tselectors.push( `.${ styles.root }.${ styles.root }${ instanceIdSel }` );\n\n\treturn selectors.join( ',' );\n}\n\nexport const ThemeProvider = ( {\n\tchildren,\n\tcolor = {},\n\tisRoot = false,\n\tdensity,\n}: ThemeProviderProps ) => {\n\tconst instanceId = useId();\n\n\tconst { themeProviderStyles, resolvedSettings } = useThemeProviderStyles( {\n\t\tcolor,\n\t} );\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tresolvedSettings,\n\t\t} ),\n\t\t[ resolvedSettings ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ themeProviderStyles ? (\n\t\t\t\t<style>\n\t\t\t\t\t{ `${ generateCSSSelector( {\n\t\t\t\t\t\tinstanceId,\n\t\t\t\t\t\tisRoot,\n\t\t\t\t\t} ) } {${ cssObjectToText( themeProviderStyles ) }}` }\n\t\t\t\t</style>\n\t\t\t) : null }\n\t\t\t<div\n\t\t\t\tdata-wpds-theme-provider-id={ instanceId }\n\t\t\t\tdata-wpds-root-provider={ isRoot }\n\t\t\t\tdata-wpds-density={ density }\n\t\t\t\tclassName={ styles.root }\n\t\t\t>\n\t\t\t\t<ThemeContext.Provider value={ contextValue }>\n\t\t\t\t\t{ children }\n\t\t\t\t</ThemeContext.Provider>\n\t\t\t</div>\n\t\t</>\n\t);\n};\n", "const css = `.style-module__root__26kw6 {\n\tdisplay: contents;\n}\n`;\ndocument.head\n .appendChild(document.createElement(\"style\"))\n .appendChild(document.createTextNode(css));\nexport {css};\nexport default {\n \"root\": \"style-module__root__26kw6\"\n};", "/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { ThemeProviderSettings } from './types';\n\ninterface ThemeContextType {\n\tresolvedSettings: ThemeProviderSettings;\n}\n\nexport const ThemeContext = createContext< ThemeContextType >( {\n\tresolvedSettings: {\n\t\tcolor: {},\n\t},\n} );\n", "/** @import { Matrix3x3, Vector3 } from \"./types.js\" */\n\n/**\n * A is m x n. B is n x p. product is m x p.\n *\n * Array arguments are treated like vectors:\n * - A becomes 1 x n\n * - B becomes n x 1\n *\n * Returns Matrix m x p or equivalent array or number\n *\n * @overload\n * @param {number[]} A Vector 1 x n\n * @param {number[]} B Vector n x 1\n * @returns {number} Scalar number\n *\n * @overload\n * @param {number[][]} A Matrix m x n\n * @param {number[]} B Vector n x 1\n * @returns {number[]} Array with length m\n *\n * @overload\n * @param {number[]} A Vector 1 x n\n * @param {number[][]} B Matrix n x p\n * @returns {number[]} Array with length p\n *\n * @overload\n * @param {number[][]} A Matrix m x n\n * @param {number[][]} B Matrix n x p\n * @returns {number[][]} Matrix m x p\n *\n * @param {number[] | number[][]} A Matrix m x n or a vector\n * @param {number[] | number[][]} B Matrix n x p or a vector\n * @returns {number | number[] | number[][]} Matrix m x p or equivalent array or number\n */\nexport default function multiplyMatrices (A, B) {\n\tlet m = A.length;\n\t/** @type {number[][]} */\n\tlet AM;\n\t/** @type {number[][]} */\n\tlet BM;\n\tlet aVec = false;\n\tlet bVec = false;\n\n\tif (!Array.isArray(A[0])) {\n\t\t// A is vector, convert to [[a, b, c, ...]]\n\t\tAM = [/** @type {number[]} */ (A)];\n\t\tm = AM.length;\n\t\taVec = true;\n\t}\n\telse {\n\t\tAM = /** @type {number[][]} */ (A);\n\t}\n\n\tif (!Array.isArray(B[0])) {\n\t\t// B is vector, convert to [[a], [b], [c], ...]]\n\t\tBM = B.length > 0 ? B.map(x => [x]) : [[]]; // Avoid mapping empty array\n\t\tbVec = true;\n\t}\n\telse {\n\t\tBM = /** @type {number[][]} */ (B);\n\t}\n\n\tlet p = BM[0].length;\n\tlet BM_cols = BM[0].map((_, i) => BM.map(x => x[i])); // transpose B\n\t/** @type {number[] | number[][]} */\n\tlet product = AM.map(row =>\n\t\tBM_cols.map(col => {\n\t\t\tlet ret = 0;\n\n\t\t\tif (!Array.isArray(row)) {\n\t\t\t\tfor (let c of col) {\n\t\t\t\t\tret += row * c;\n\t\t\t\t}\n\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\tfor (let i = 0; i < row.length; i++) {\n\t\t\t\tret += row[i] * (col[i] || 0);\n\t\t\t}\n\n\t\t\treturn ret;\n\t\t}));\n\n\tif (m === 1 && aVec) {\n\t\tproduct = product[0]; // Avoid [[a, b, c, ...]]\n\t}\n\tif (p === 1 && bVec) {\n\t\tif (m === 1 && aVec) {\n\t\t\treturn product[0]; // Avoid [[a]], return a number\n\t\t}\n\t\telse {\n\t\t\treturn product.map(x => x[0]); // Avoid [[a], [b], [c], ...]]\n\t\t}\n\t}\n\n\treturn product;\n}\n\n// dot3 and transform functions adapted from https://github.com/texel-org/color/blob/9793c7d4d02b51f068e0f3fd37131129a4270396/src/core.js\n//\n// The MIT License (MIT)\n// Copyright (c) 2024 Matt DesLauriers\n\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE\n// OR OTHER DEALINGS IN THE SOFTWARE.\n\n/**\n * Returns the dot product of two vectors each with a length of 3.\n *\n * @param {Vector3} a\n * @param {Vector3} b\n * @returns {number}\n */\nfunction dot3 (a, b) {\n\treturn a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n\n/**\n * Transforms a vector of length 3 by a 3x3 matrix. Specify the same input and output\n * vector to transform in place.\n *\n * @param {Vector3} input\n * @param {Matrix3x3} matrix\n * @param {Vector3} [out]\n * @returns {Vector3}\n */\nexport function multiply_v3_m3x3 (input, matrix, out = [0, 0, 0]) {\n\tconst x = dot3(input, matrix[0]);\n\tconst y = dot3(input, matrix[1]);\n\tconst z = dot3(input, matrix[2]);\n\tout[0] = x;\n\tout[1] = y;\n\tout[2] = z;\n\treturn out;\n}\n", "/**\n * Various utility functions\n */\n\nexport { default as multiplyMatrices, multiply_v3_m3x3 } from \"./multiply-matrices.js\";\n\n/**\n * Check if a value is a string (including a String object)\n * @param {any} str - Value to check\n * @returns {str is string}\n */\nexport function isString (str) {\n\treturn type(str) === \"string\";\n}\n\n/**\n * Determine the internal JavaScript [[Class]] of an object.\n * @param {any} o - Value to check\n * @returns {string}\n */\nexport function type (o) {\n\tlet str = Object.prototype.toString.call(o);\n\n\treturn (str.match(/^\\[object\\s+(.*?)\\]$/)[1] || \"\").toLowerCase();\n}\n\n/**\n * @param {number} n\n * @param {{ precision?: number | undefined, unit?: string | undefined }} options\n * @returns {string}\n */\nexport function serializeNumber (n, { precision = 16, unit }) {\n\tif (isNone(n)) {\n\t\treturn \"none\";\n\t}\n\n\tn = +toPrecision(n, precision);\n\n\treturn n + (unit ?? \"\");\n}\n\n/**\n * Check if a value corresponds to a none argument\n * @param {any} n - Value to check\n * @returns {n is null}\n */\nexport function isNone (n) {\n\treturn n === null;\n}\n\n/**\n * Replace none values with 0\n * @param {number | null} n\n * @returns {number}\n */\nexport function skipNone (n) {\n\treturn isNone(n) ? 0 : n;\n}\n\n/**\n * Round a number to a certain number of significant digits\n * @param {number} n - The number to round\n * @param {number} precision - Number of significant digits\n */\nexport function toPrecision (n, precision) {\n\tif (n === 0) {\n\t\treturn 0;\n\t}\n\tlet integer = ~~n;\n\tlet digits = 0;\n\tif (integer && precision) {\n\t\tdigits = ~~Math.log10(Math.abs(integer)) + 1;\n\t}\n\tconst multiplier = 10.0 ** (precision - digits);\n\treturn Math.floor(n * multiplier + 0.5) / multiplier;\n}\n\n/**\n * @param {number} start\n * @param {number} end\n * @param {number} p\n */\nexport function interpolate (start, end, p) {\n\tif (isNaN(start)) {\n\t\treturn end;\n\t}\n\n\tif (isNaN(end)) {\n\t\treturn start;\n\t}\n\n\treturn start + (end - start) * p;\n}\n\n/**\n * @param {number} start\n * @param {number} end\n * @param {number} value\n */\nexport function interpolateInv (start, end, value) {\n\treturn (value - start) / (end - start);\n}\n\n/**\n * @param {[number, number]} from\n * @param {[number, number]} to\n * @param {number} value\n */\nexport function mapRange (from, to, value) {\n\tif (\n\t\t!from ||\n\t\t!to ||\n\t\tfrom === to ||\n\t\t(from[0] === to[0] && from[1] === to[1]) ||\n\t\tisNaN(value) ||\n\t\tvalue === null\n\t) {\n\t\t// Ranges missing or the same\n\t\treturn value;\n\t}\n\n\treturn interpolate(to[0], to[1], interpolateInv(from[0], from[1], value));\n}\n\n/**\n * Clamp value between the minimum and maximum\n * @param {number} min minimum value to return\n * @param {number} val the value to return if it is between min and max\n * @param {number} max maximum value to return\n */\nexport function clamp (min, val, max) {\n\treturn Math.max(Math.min(max, val), min);\n}\n\n/**\n * Copy sign of one value to another.\n * @param {number} to - Number to copy sign to\n * @param {number} from - Number to copy sign from\n */\nexport function copySign (to, from) {\n\treturn Math.sign(to) === Math.sign(from) ? to : -to;\n}\n\n/**\n * Perform pow on a signed number and copy sign to result\n * @param {number} base The base number\n * @param {number} exp The exponent\n */\nexport function spow (base, exp) {\n\treturn copySign(Math.abs(base) ** exp, base);\n}\n\n/**\n * Perform a divide, but return zero if the denominator is zero\n * @param {number} n The numerator\n * @param {number} d The denominator\n */\nexport function zdiv (n, d) {\n\treturn d === 0 ? 0 : n / d;\n}\n\n/**\n * Perform a bisect on a sorted list and locate the insertion point for\n * a value in arr to maintain sorted order.\n * @param {number[]} arr - array of sorted numbers\n * @param {number} value - value to find insertion point for\n * @param {number} lo - used to specify a the low end of a subset of the list\n * @param {number} hi - used to specify a the high end of a subset of the list\n */\nexport function bisectLeft (arr, value, lo = 0, hi = arr.length) {\n\twhile (lo < hi) {\n\t\tconst mid = (lo + hi) >> 1;\n\t\tif (arr[mid] < value) {\n\t\t\tlo = mid + 1;\n\t\t}\n\t\telse {\n\t\t\thi = mid;\n\t\t}\n\t}\n\treturn lo;\n}\n\n/**\n * Determines whether an argument is an instance of a constructor, including subclasses.\n * This is done by first just checking `instanceof`,\n * and then comparing the string names of the constructors if that fails.\n * @param {any} arg\n * @param {C} constructor\n * @template {new (...args: any) => any} C\n * @returns {arg is InstanceType<C>}\n */\nexport function isInstance (arg, constructor) {\n\tif (arg instanceof constructor) {\n\t\treturn true;\n\t}\n\n\tconst targetName = constructor.name;\n\n\twhile (arg) {\n\t\tconst proto = Object.getPrototypeOf(arg);\n\t\tconst constructorName = proto?.constructor?.name;\n\t\tif (constructorName === targetName) {\n\t\t\treturn true;\n\t\t}\n\t\tif (!constructorName || constructorName === \"Object\") {\n\t\t\treturn false;\n\t\t}\n\t\targ = proto;\n\t}\n\n\treturn false;\n}\n", "import { serializeNumber, mapRange, isInstance } from \"./util.js\";\n\nexport default class Type {\n\t// Class properties - declared here so that type inference works\n\ttype;\n\tcoordMeta;\n\tcoordRange;\n\t/** @type {[number, number]} */\n\trange;\n\n\t/**\n\t * @param {any} type\n\t * @param {import(\"./types.js\").CoordMeta} coordMeta\n\t */\n\tconstructor (type, coordMeta) {\n\t\tif (typeof type === \"object\") {\n\t\t\tthis.coordMeta = type;\n\t\t}\n\n\t\tif (coordMeta) {\n\t\t\tthis.coordMeta = coordMeta;\n\t\t\tthis.coordRange = coordMeta.range ?? coordMeta.refRange;\n\t\t}\n\n\t\tif (typeof type === \"string\") {\n\t\t\tlet params = type\n\t\t\t\t.trim()\n\t\t\t\t.match(/^(?<type><[a-z]+>)(\\[(?<min>-?[.\\d]+),\\s*(?<max>-?[.\\d]+)\\])?$/);\n\n\t\t\tif (!params) {\n\t\t\t\tthrow new TypeError(`Cannot parse ${type} as a type definition.`);\n\t\t\t}\n\n\t\t\tthis.type = params.groups.type;\n\t\t\tlet { min, max } = params.groups;\n\n\t\t\tif (min || max) {\n\t\t\t\tthis.range = [+min, +max];\n\t\t\t}\n\t\t}\n\t}\n\n\t/** @returns {[number, number]} */\n\tget computedRange () {\n\t\tif (this.range) {\n\t\t\treturn this.range;\n\t\t}\n\t\tif (this.type === \"<percentage>\") {\n\t\t\treturn this.percentageRange();\n\t\t}\n\t\telse if (this.type === \"<angle>\") {\n\t\t\treturn [0, 360];\n\t\t}\n\t\treturn null;\n\t}\n\n\tget unit () {\n\t\tif (this.type === \"<percentage>\") {\n\t\t\treturn \"%\";\n\t\t}\n\t\telse if (this.type === \"<angle>\") {\n\t\t\treturn \"deg\";\n\t\t}\n\n\t\treturn \"\";\n\t}\n\n\t/**\n\t * Map a number to the internal representation\n\t * @param {number} number\n\t */\n\tresolve (number) {\n\t\tif (this.type === \"<angle>\") {\n\t\t\treturn number;\n\t\t}\n\n\t\tlet fromRange = this.computedRange;\n\t\tlet toRange = this.coordRange;\n\n\t\tif (this.type === \"<percentage>\") {\n\t\t\ttoRange ??= this.percentageRange();\n\t\t}\n\n\t\treturn mapRange(fromRange, toRange, number);\n\t}\n\n\t/**\n\t * Serialize a number from the internal representation to a string\n\t * @param {number} number\n\t * @param {number} [precision]\n\t */\n\tserialize (number, precision) {\n\t\tlet toRange = this.type === \"<percentage>\" ? this.percentageRange(100) : this.computedRange;\n\n\t\tlet unit = this.unit;\n\n\t\tnumber = mapRange(this.coordRange, toRange, number);\n\t\treturn serializeNumber(number, { unit, precision });\n\t}\n\n\ttoString () {\n\t\tlet ret = this.type;\n\n\t\tif (this.range) {\n\t\t\tlet [min = \"\", max = \"\"] = this.range;\n\t\t\tret += `[${min},${max}]`;\n\t\t}\n\n\t\treturn ret;\n\t}\n\n\t/**\n\t * Returns a percentage range for values of this type\n\t * @param {number} scale\n\t * @returns {[number, number]}\n\t */\n\tpercentageRange (scale = 1) {\n\t\tlet range;\n\t\tif (\n\t\t\t(this.coordMeta && this.coordMeta.range) ||\n\t\t\t(this.coordRange && this.coordRange[0] >= 0)\n\t\t) {\n\t\t\trange = [0, 1];\n\t\t}\n\t\telse {\n\t\t\trange = [-1, 1];\n\t\t}\n\t\treturn [range[0] * scale, range[1] * scale];\n\t}\n\n\tstatic get (type, coordMeta) {\n\t\tif (isInstance(type, this)) {\n\t\t\treturn type;\n\t\t}\n\n\t\treturn new this(type, coordMeta);\n\t}\n}\n", "import { isInstance, isNone } from \"./util.js\";\nimport Type from \"./Type.js\";\n\n/** @import { ColorSpace, Coords } from \"./types.js\" */\n\n// Type re-exports\n/** @typedef {import(\"./types.js\").Format} FormatInterface */\n\n/**\n * @internal\n * Used to index {@link FormatInterface Format} objects and store an instance.\n * Not meant for external use\n */\nexport const instance = Symbol(\"instance\");\n\n/**\n * Remove the first element of an array type\n * @template {any[]} T\n * @typedef {T extends [any, ...infer R] ? R : T[number][]} RemoveFirstElement\n */\n\n/**\n * @class Format\n * @implements {Omit<FormatInterface, \"coords\" | \"serializeCoords\">}\n * Class to hold a color serialization format\n */\nexport default class Format {\n\t// Class properties - declared here so that type inference works\n\ttype;\n\tname;\n\tspaceCoords;\n\t/** @type {Type[][]} */\n\tcoords;\n\t/** @type {string | undefined} */\n\tid;\n\t/** @type {boolean | undefined} */\n\talpha;\n\n\t/**\n\t * @param {FormatInterface} format\n\t * @param {ColorSpace} space\n\t */\n\tconstructor (format, space = format.space) {\n\t\tformat[instance] = this;\n\t\tthis.type = \"function\";\n\t\tthis.name = \"color\";\n\n\t\tObject.assign(this, format);\n\n\t\tthis.space = space;\n\n\t\tif (this.type === \"custom\") {\n\t\t\t// Nothing else to do here\n\t\t\treturn;\n\t\t}\n\n\t\tthis.spaceCoords = Object.values(space.coords);\n\n\t\tif (!this.coords) {\n\t\t\t// @ts-expect-error Strings are converted to the correct type later\n\t\t\tthis.coords = this.spaceCoords.map(coordMeta => {\n\t\t\t\tlet ret = [\"<number>\", \"<percentage>\"];\n\n\t\t\t\tif (coordMeta.type === \"angle\") {\n\t\t\t\t\tret.push(\"<angle>\");\n\t\t\t\t}\n\n\t\t\t\treturn ret;\n\t\t\t});\n\t\t}\n\n\t\tthis.coords = this.coords.map(\n\t\t\t/** @param {string | string[] | Type[]} types */ (types, i) => {\n\t\t\t\tlet coordMeta = this.spaceCoords[i];\n\n\t\t\t\tif (typeof types === \"string\") {\n\t\t\t\t\ttypes = types.trim().split(/\\s*\\|\\s*/);\n\t\t\t\t}\n\n\t\t\t\treturn types.map(type => Type.get(type, coordMeta));\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * @param {Coords} coords\n\t * @param {number} precision\n\t * @param {Type[]} types\n\t */\n\tserializeCoords (coords, precision, types) {\n\t\ttypes = coords.map((_, i) =>\n\t\t\tType.get(types?.[i] ?? this.coords[i][0], this.spaceCoords[i]));\n\t\treturn coords.map((c, i) => types[i].serialize(c, precision));\n\t}\n\n\t/**\n\t * Validates the coordinates of a color against a format's coord grammar and\n\t * maps the coordinates to the range or refRange of the coordinates.\n\t * @param {Coords} coords\n\t * @param {[string, string, string]} types\n\t */\n\tcoerceCoords (coords, types) {\n\t\treturn Object.entries(this.space.coords).map(([id, coordMeta], i) => {\n\t\t\tlet arg = coords[i];\n\n\t\t\tif (isNone(arg) || isNaN(arg)) {\n\t\t\t\t// Nothing to do here\n\t\t\t\treturn arg;\n\t\t\t}\n\n\t\t\t// Find grammar alternative that matches the provided type\n\t\t\t// Non-strict equals is intentional because we are comparing w/ string objects\n\t\t\tlet providedType = types[i];\n\t\t\tlet type = this.coords[i].find(c => c.type == providedType);\n\n\t\t\t// Check that each coord conforms to its grammar\n\t\t\tif (!type) {\n\t\t\t\t// Type does not exist in the grammar, throw\n\t\t\t\tlet coordName = coordMeta.name || id;\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`${providedType ?? /** @type {any} */ (arg)?.raw ?? arg} not allowed for ${coordName} in ${this.name}()`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\targ = type.resolve(arg);\n\n\t\t\tif (type.range) {\n\t\t\t\t// Adjust type to include range\n\t\t\t\ttypes[i] = type.toString();\n\t\t\t}\n\n\t\t\treturn arg;\n\t\t});\n\t}\n\n\t/**\n\t * @returns {boolean | Required<FormatInterface>[\"serialize\"]}\n\t */\n\tcanSerialize () {\n\t\treturn this.type === \"function\" || /** @type {any} */ (this).serialize;\n\t}\n\n\t/**\n\t * @param {string} str\n\t * @returns {(import(\"./types.js\").ColorConstructor) | undefined | null}\n\t */\n\tparse (str) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * @param {Format | FormatInterface} format\n\t * @param {RemoveFirstElement<ConstructorParameters<typeof Format>>} args\n\t * @returns {Format}\n\t */\n\tstatic get (format, ...args) {\n\t\tif (!format || isInstance(format, this)) {\n\t\t\treturn /** @type {Format} */ (format);\n\t\t}\n\n\t\tif (format[instance]) {\n\t\t\treturn format[instance];\n\t\t}\n\n\t\treturn new Format(format, ...args);\n\t}\n}\n", "/**\n * A class for adding deep extensibility to any piece of JS code\n */\nexport class Hooks {\n\tadd (name, callback, first) {\n\t\tif (typeof arguments[0] != \"string\") {\n\t\t\t// Multiple hooks\n\t\t\tfor (var name in arguments[0]) {\n\t\t\t\tthis.add(name, arguments[0][name], arguments[1]);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\t(Array.isArray(name) ? name : [name]).forEach(function (name) {\n\t\t\tthis[name] = this[name] || [];\n\n\t\t\tif (callback) {\n\t\t\t\tthis[name][first ? \"unshift\" : \"push\"](callback);\n\t\t\t}\n\t\t}, this);\n\t}\n\n\trun (name, env) {\n\t\tthis[name] = this[name] || [];\n\t\tthis[name].forEach(function (callback) {\n\t\t\tcallback.call(env && env.context ? env.context : env, env);\n\t\t});\n\t}\n}\n\n/**\n * The instance of {@link Hooks} used throughout Color.js\n */\nconst hooks = new Hooks();\n\nexport default hooks;\n", "import hooks from \"./hooks.js\";\nimport { multiply_v3_m3x3 } from \"./util.js\";\n\n// Type re-exports\n/** @typedef {import(\"./types.js\").White} White */\n\n/** @type {Record<string, White>} */\n// prettier-ignore\nexport const WHITES = {\n\t// for compatibility, the four-digit chromaticity-derived ones everyone else uses\n\tD50: [0.3457 / 0.3585, 1.00000, (1.0 - 0.3457 - 0.3585) / 0.3585],\n\tD65: [0.3127 / 0.3290, 1.00000, (1.0 - 0.3127 - 0.3290) / 0.3290],\n};\n\n/**\n *\n * @param {string | White} name\n * @returns {White}\n */\nexport function getWhite (name) {\n\tif (Array.isArray(name)) {\n\t\treturn name;\n\t}\n\n\treturn WHITES[name];\n}\n\n/**\n * Adapt XYZ from white point W1 to W2\n * @param {White | string} W1\n * @param {White | string} W2\n * @param {[number, number, number]} XYZ\n * @param {{ method?: string | undefined }} options\n * @returns {[number, number, number]}\n */\nexport default function adapt (W1, W2, XYZ, options = {}) {\n\tW1 = getWhite(W1);\n\tW2 = getWhite(W2);\n\n\tif (!W1 || !W2) {\n\t\tthrow new TypeError(\n\t\t\t`Missing white point to convert ${!W1 ? \"from\" : \"\"}${!W1 && !W2 ? \"/\" : \"\"}${!W2 ? \"to\" : \"\"}`,\n\t\t);\n\t}\n\n\tif (W1 === W2) {\n\t\t// Same whitepoints, no conversion needed\n\t\treturn XYZ;\n\t}\n\n\tlet env = { W1, W2, XYZ, options };\n\n\thooks.run(\"chromatic-adaptation-start\", env);\n\n\tif (!env.M) {\n\t\tif (env.W1 === WHITES.D65 && env.W2 === WHITES.D50) {\n\t\t\t// prettier-ignore\n\t\t\tenv.M = [\n\t\t\t\t[ 1.0479297925449969, 0.022946870601609652, -0.05019226628920524 ],\n\t\t\t\t[ 0.02962780877005599, 0.9904344267538799, -0.017073799063418826 ],\n\t\t\t\t[ -0.009243040646204504, 0.015055191490298152, 0.7518742814281371 ],\n\t\t\t];\n\t\t}\n\t\telse if (env.W1 === WHITES.D50 && env.W2 === WHITES.D65) {\n\t\t\t// prettier-ignore\n\t\t\tenv.M = [\n\t\t\t\t[ 0.955473421488075, -0.02309845494876471, 0.06325924320057072 ],\n\t\t\t\t[ -0.0283697093338637, 1.0099953980813041, 0.021041441191917323 ],\n\t\t\t\t[ 0.012314014864481998, -0.020507649298898964, 1.330365926242124 ],\n\t\t\t];\n\t\t}\n\t}\n\n\thooks.run(\"chromatic-adaptation-end\", env);\n\n\tif (env.M) {\n\t\treturn multiply_v3_m3x3(env.XYZ, env.M);\n\t}\n\telse {\n\t\tthrow new TypeError(\"Only Bradford CAT with white points D50 and D65 supported for now.\");\n\t}\n}\n", "// Global defaults one may want to configure\nexport default {\n\tgamut_mapping: \"css\",\n\tprecision: 5,\n\tdeltaE: \"76\", // Default deltaE method\n\tverbose: globalThis?.process?.env?.NODE_ENV?.toLowerCase() !== \"test\",\n\twarn: function warn (msg) {\n\t\tif (this.verbose) {\n\t\t\tglobalThis?.console?.warn?.(msg);\n\t\t}\n\t},\n};\n", "import { isNone, clamp } from \"./util.js\";\nimport hooks from \"./hooks.js\";\nimport ColorSpace from \"./ColorSpace.js\";\nimport defaults from \"./defaults.js\";\n\n/** @import { ColorConstructor } from \"./types.js\" */\n\n// Type re-exports\n/** @typedef {import(\"./types.js\").ArgumentMeta} ArgumentMeta */\n/** @typedef {import(\"./types.js\").ParseFunctionReturn} ParseFunctionReturn */\n/** @typedef {import(\"./types.js\").ParseOptions} ParseOptions */\n\n/**\n * Convert a CSS Color string to a color object\n * @param {string} str\n * @param {ParseOptions} [options]\n * @returns {ColorConstructor}\n */\nexport default function parse (str, options) {\n\tlet env = {\n\t\tstr: String(str)?.trim(),\n\t\toptions,\n\t};\n\n\thooks.run(\"parse-start\", env);\n\n\tif (env.color) {\n\t\treturn env.color;\n\t}\n\n\tenv.parsed = parseFunction(env.str);\n\tlet ret;\n\tlet meta = env.options ? (env.options.parseMeta ?? env.options.meta) : null;\n\n\tif (env.parsed) {\n\t\t// Is a functional syntax\n\t\tlet name = env.parsed.name;\n\t\tlet format;\n\t\tlet space;\n\t\tlet coords = env.parsed.args;\n\t\tlet types = coords.map((c, i) => env.parsed.argMeta[i]?.type);\n\n\t\tif (name === \"color\") {\n\t\t\t// color() function\n\t\t\tlet id = coords.shift();\n\t\t\ttypes.shift();\n\t\t\t// Check against both <dashed-ident> and <ident> versions\n\t\t\tlet alternateId = id.startsWith(\"--\") ? id.substring(2) : `--${id}`;\n\t\t\tlet ids = [id, alternateId];\n\t\t\tformat = ColorSpace.findFormat({ name, id: ids, type: \"function\" });\n\n\t\t\tif (!format) {\n\t\t\t\t// Not found\n\t\t\t\tlet didYouMean;\n\n\t\t\t\tlet registryId = id in ColorSpace.registry ? id : alternateId;\n\t\t\t\tif (registryId in ColorSpace.registry) {\n\t\t\t\t\t// Used color space id instead of color() id, these are often different\n\t\t\t\t\tlet cssId = ColorSpace.registry[registryId].formats?.color?.id;\n\n\t\t\t\t\tif (cssId) {\n\t\t\t\t\t\tlet altColor = str.replace(\"color(\" + id, \"color(\" + cssId);\n\t\t\t\t\t\tdidYouMean = `Did you mean ${altColor}?`;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Cannot parse ${env.str}. ` + (didYouMean ?? \"Missing a plugin?\"),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tspace = format.space;\n\n\t\t\tif (format.id.startsWith(\"--\") && !id.startsWith(\"--\")) {\n\t\t\t\tdefaults.warn(\n\t\t\t\t\t`${space.name} is a non-standard space and not currently supported in the CSS spec. ` +\n\t\t\t\t\t\t`Use prefixed color(${format.id}) instead of color(${id}).`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (id.startsWith(\"--\") && !format.id.startsWith(\"--\")) {\n\t\t\t\tdefaults.warn(\n\t\t\t\t\t`${space.name} is a standard space and supported in the CSS spec. ` +\n\t\t\t\t\t\t`Use color(${format.id}) instead of prefixed color(${id}).`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tformat = ColorSpace.findFormat({ name, type: \"function\" });\n\t\t\tspace = format.space;\n\t\t}\n\n\t\tif (meta) {\n\t\t\tObject.assign(meta, {\n\t\t\t\tformat,\n\t\t\t\tformatId: format.name,\n\t\t\t\ttypes,\n\t\t\t\tcommas: env.parsed.commas,\n\t\t\t});\n\t\t}\n\n\t\tlet alpha = 1;\n\n\t\tif (env.parsed.lastAlpha) {\n\t\t\talpha = env.parsed.args.pop();\n\n\t\t\tif (meta) {\n\t\t\t\tmeta.alphaType = types.pop();\n\t\t\t}\n\t\t}\n\n\t\tlet coordCount = format.coords.length;\n\n\t\tif (coords.length !== coordCount) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Expected ${coordCount} coordinates for ${space.id} in ${env.str}), got ${coords.length}`,\n\t\t\t);\n\t\t}\n\n\t\tcoords = format.coerceCoords(coords, types);\n\n\t\tret = { spaceId: space.id, coords, alpha };\n\t}\n\telse {\n\t\t// Custom, colorspace-specific format\n\t\tspaceloop: for (let space of ColorSpace.all) {\n\t\t\tfor (let formatId in space.formats) {\n\t\t\t\tlet format = space.formats[formatId];\n\n\t\t\t\tif (format.type !== \"custom\") {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (format.test && !format.test(env.str)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Convert to Format object\n\t\t\t\tlet formatObject = space.getFormat(format);\n\n\t\t\t\tlet color = formatObject.parse(env.str);\n\n\t\t\t\tif (color) {\n\t\t\t\t\tif (meta) {\n\t\t\t\t\t\tObject.assign(meta, { format: formatObject, formatId });\n\t\t\t\t\t}\n\n\t\t\t\t\tret = color;\n\t\t\t\t\tbreak spaceloop;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!ret) {\n\t\t// If we're here, we couldn't parse\n\t\tthrow new TypeError(`Could not parse ${str} as a color. Missing a plugin?`);\n\t}\n\n\t// Clamp alpha to [0, 1]\n\tret.alpha = isNone(ret.alpha)\n\t\t? ret.alpha\n\t\t: ret.alpha === undefined\n\t\t\t? 1\n\t\t\t: clamp(0, ret.alpha, 1);\n\n\treturn ret;\n}\n\n/**\n * Units and multiplication factors for the internally stored numbers\n */\nexport const units = {\n\t\"%\": 0.01,\n\tdeg: 1,\n\tgrad: 0.9,\n\trad: 180 / Math.PI,\n\tturn: 360,\n};\n\nexport const regex = {\n\t// Need to list calc(NaN) explicitly as otherwise its ending paren would terminate the function call\n\tfunction: /^([a-z]+)\\(((?:calc\\(NaN\\)|.)+?)\\)$/i,\n\tnumber: /^([-+]?(?:[0-9]*\\.)?[0-9]+(e[-+]?[0-9]+)?)$/i,\n\tunitValue: RegExp(`(${Object.keys(units).join(\"|\")})$`),\n\n\t// NOTE The -+ are not just for prefix, but also for idents, and e+N notation!\n\tsingleArgument: /\\/?\\s*(none|NaN|calc\\(NaN\\)|[-+\\w.]+(?:%|deg|g?rad|turn)?)/g,\n};\n\n/**\n * Parse a single function argument\n * @param {string} rawArg\n * @returns {{value: number, meta: ArgumentMeta}}\n */\nexport function parseArgument (rawArg) {\n\t/** @type {Partial<ArgumentMeta>} */\n\tlet meta = {};\n\tlet unit = rawArg.match(regex.unitValue)?.[0];\n\t/** @type {string | number} */\n\tlet value = (meta.raw = rawArg);\n\n\tif (unit) {\n\t\t// It\u2019s a dimension token\n\t\tmeta.type = unit === \"%\" ? \"<percentage>\" : \"<angle>\";\n\t\tmeta.unit = unit;\n\t\tmeta.unitless = Number(value.slice(0, -unit.length)); // unitless number\n\n\t\tvalue = meta.unitless * units[unit];\n\t}\n\telse if (regex.number.test(value)) {\n\t\t// It's a number\n\t\t// Convert numerical args to numbers\n\t\tvalue = Number(value);\n\t\tmeta.type = \"<number>\";\n\t}\n\telse if (value === \"none\") {\n\t\tvalue = null;\n\t}\n\telse if (value === \"NaN\" || value === \"calc(NaN)\") {\n\t\tvalue = NaN;\n\t\tmeta.type = \"<number>\";\n\t}\n\telse {\n\t\tmeta.type = \"<ident>\";\n\t}\n\n\treturn { value: /** @type {number} */ (value), meta: /** @type {ArgumentMeta} */ (meta) };\n}\n\n/**\n * Parse a CSS function, regardless of its name and arguments\n * @param {string} str String to parse\n * @return {ParseFunctionReturn | void}\n */\nexport function parseFunction (str) {\n\tif (!str) {\n\t\treturn;\n\t}\n\n\tstr = str.trim();\n\n\tlet parts = str.match(regex.function);\n\n\tif (parts) {\n\t\t// It is a function, parse args\n\t\tlet args = [];\n\t\tlet argMeta = [];\n\t\tlet lastAlpha = false;\n\t\tlet name = parts[1].toLowerCase();\n\n\t\tlet separators = parts[2].replace(regex.singleArgument, ($0, rawArg) => {\n\t\t\tlet { value, meta } = parseArgument(rawArg);\n\n\t\t\tif (\n\t\t\t\t// If there's a slash here, it's modern syntax\n\t\t\t\t$0.startsWith(\"/\") ||\n\t\t\t\t// If there's still elements to process after there's already 3 in `args` (and the we're not dealing with \"color()\"), it's likely to be a legacy color like \"hsl(0, 0%, 0%, 0.5)\"\n\t\t\t\t(name !== \"color\" && args.length === 3)\n\t\t\t) {\n\t\t\t\t// It's alpha\n\t\t\t\tlastAlpha = true;\n\t\t\t}\n\n\t\t\targs.push(value);\n\t\t\targMeta.push(meta);\n\t\t\treturn \"\";\n\t\t});\n\n\t\treturn {\n\t\t\tname,\n\t\t\targs,\n\t\t\targMeta,\n\t\t\tlastAlpha,\n\t\t\tcommas: separators.includes(\",\"),\n\t\t\trawName: parts[1],\n\t\t\trawArgs: parts[2],\n\t\t};\n\t}\n}\n", "import ColorSpace from \"./ColorSpace.js\";\nimport { isString, isInstance } from \"./util.js\";\nimport parse from \"./parse.js\";\n\n/** @import { ColorTypes, ParseOptions as GetColorOptions, PlainColorObject } from \"./types.js\" */\n\n/**\n * Resolves a color reference (object or string) to a plain color object\n * @overload\n * @param {ColorTypes} color\n * @param {GetColorOptions} [options]\n * @returns {PlainColorObject}\n */\n/**\n * @overload\n * @param {ColorTypes[]} color\n * @param {GetColorOptions} [options]\n * @returns {PlainColorObject[]}\n */\nexport default function getColor (color, options) {\n\tif (Array.isArray(color)) {\n\t\treturn color.map(c => getColor(c, options));\n\t}\n\n\tif (!color) {\n\t\tthrow new TypeError(\"Empty color reference\");\n\t}\n\n\tif (isString(color)) {\n\t\tcolor = parse(color, options);\n\t}\n\n\t// Object fixup\n\tlet space = color.space || color.spaceId;\n\n\tif (typeof space === \"string\") {\n\t\t// Convert string id to color space object\n\t\tcolor.space = ColorSpace.get(space);\n\t}\n\n\tif (color.alpha === undefined) {\n\t\tcolor.alpha = 1;\n\t}\n\n\treturn color;\n}\n", "/**\n * @packageDocumentation\n * Defines the class and other types related to creating color spaces.\n * For the builtin color spaces, see the `spaces` module.\n */\nimport { type, isNone, isInstance } from \"./util.js\";\nimport Format from \"./Format.js\";\nimport { getWhite } from \"./adapt.js\";\nimport hooks from \"./hooks.js\";\nimport getColor from \"./getColor.js\";\n\nconst \u03B5 = 0.000075;\n\n/**\n * Class to represent a color space\n */\nexport default class ColorSpace {\n\tconstructor (options) {\n\t\tthis.id = options.id;\n\t\tthis.name = options.name;\n\t\tthis.base = options.base ? ColorSpace.get(options.base) : null;\n\t\tthis.aliases = options.aliases;\n\n\t\tif (this.base) {\n\t\t\tthis.fromBase = options.fromBase;\n\t\t\tthis.toBase = options.toBase;\n\t\t}\n\n\t\t// Coordinate metadata\n\n\t\tlet coords = options.coords ?? this.base.coords;\n\n\t\tfor (let name in coords) {\n\t\t\tif (!(\"name\" in coords[name])) {\n\t\t\t\tcoords[name].name = name;\n\t\t\t}\n\t\t}\n\t\tthis.coords = coords;\n\n\t\t// White point\n\n\t\tlet white = options.white ?? this.base.white ?? \"D65\";\n\t\tthis.white = getWhite(white);\n\n\t\t// Sort out formats\n\n\t\tthis.formats = options.formats ?? {};\n\n\t\tfor (let name in this.formats) {\n\t\t\tlet format = this.formats[name];\n\t\t\tformat.type ||= \"function\";\n\t\t\tformat.name ||= name;\n\t\t}\n\n\t\tif (!this.formats.color?.id) {\n\t\t\tthis.formats.color = {\n\t\t\t\t...(this.formats.color ?? {}),\n\t\t\t\tid: options.cssId || this.id,\n\t\t\t};\n\t\t}\n\n\t\t// Gamut space\n\n\t\tif (options.gamutSpace) {\n\t\t\t// Gamut space explicitly specified\n\t\t\tthis.gamutSpace =\n\t\t\t\toptions.gamutSpace === \"self\" ? this : ColorSpace.get(options.gamutSpace);\n\t\t}\n\t\telse {\n\t\t\t// No gamut space specified, calculate a sensible default\n\t\t\tif (this.isPolar) {\n\t\t\t\t// Do not check gamut through polar coordinates\n\t\t\t\tthis.gamutSpace = this.base;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.gamutSpace = this;\n\t\t\t}\n\t\t}\n\n\t\t// Optimize inGamut for unbounded spaces\n\t\tif (this.gamutSpace.isUnbounded) {\n\t\t\tthis.inGamut = (coords, options) => {\n\t\t\t\treturn true;\n\t\t\t};\n\t\t}\n\n\t\t// Other stuff\n\t\tthis.referred = options.referred;\n\n\t\t// Compute ancestors and store them, since they will never change\n\t\tObject.defineProperty(this, \"path\", {\n\t\t\tvalue: getPath(this).reverse(),\n\t\t\twritable: false,\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\n\t\thooks.run(\"colorspace-init-end\", this);\n\t}\n\n\tinGamut (coords, { epsilon = \u03B5 } = {}) {\n\t\tif (!this.equals(this.gamutSpace)) {\n\t\t\tcoords = this.to(this.gamutSpace, coords);\n\t\t\treturn this.gamutSpace.inGamut(coords, { epsilon });\n\t\t}\n\n\t\tlet coordMeta = Object.values(this.coords);\n\n\t\treturn coords.every((c, i) => {\n\t\t\tlet meta = coordMeta[i];\n\n\t\t\tif (meta.type !== \"angle\" && meta.range) {\n\t\t\t\tif (isNone(c)) {\n\t\t\t\t\t// NaN is always in gamut\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tlet [min, max] = meta.range;\n\t\t\t\treturn (\n\t\t\t\t\t(min === undefined || c >= min - epsilon) &&\n\t\t\t\t\t(max === undefined || c <= max + epsilon)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\t}\n\n\tget isUnbounded () {\n\t\treturn Object.values(this.coords).every(coord => !(\"range\" in coord));\n\t}\n\n\tget cssId () {\n\t\treturn this.formats?.color?.id || this.id;\n\t}\n\n\tget isPolar () {\n\t\tfor (let id in this.coords) {\n\t\t\tif (this.coords[id].type === \"angle\") {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Lookup a format in this color space\n\t * @param {string | object | Format} format - Format id if string. If object, it's converted to a `Format` object and returned.\n\t * @returns {Format}\n\t */\n\tgetFormat (format) {\n\t\tif (!format) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (format === \"default\") {\n\t\t\tformat = Object.values(this.formats)[0];\n\t\t}\n\t\telse if (typeof format === \"string\") {\n\t\t\tformat = this.formats[format];\n\t\t}\n\n\t\tlet ret = Format.get(format, this);\n\n\t\tif (ret !== format && format.name in this.formats) {\n\t\t\t// Update the format we have on file so we can find it more quickly next time\n\t\t\tthis.formats[format.name] = ret;\n\t\t}\n\n\t\treturn ret;\n\t}\n\n\t/**\n\t * Check if this color space is the same as another color space reference.\n\t * Allows proxying color space objects and comparing color spaces with ids.\n\t * @param {string | ColorSpace} space ColorSpace object or id to compare to\n\t * @returns {boolean}\n\t */\n\tequals (space) {\n\t\tif (!space) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this === space || this.id === space || this.id === space.id;\n\t}\n\n\tto (space, coords) {\n\t\tif (arguments.length === 1) {\n\t\t\tconst color = getColor(space);\n\t\t\t[space, coords] = [color.space, color.coords];\n\t\t}\n\n\t\tspace = ColorSpace.get(space);\n\n\t\tif (this.equals(space)) {\n\t\t\t// Same space, no change needed\n\t\t\treturn coords;\n\t\t}\n\n\t\t// Convert NaN to 0, which seems to be valid in every coordinate of every color space\n\t\tcoords = coords.map(c => (isNone(c) ? 0 : c));\n\n\t\t// Find connection space = lowest common ancestor in the base tree\n\t\tlet myPath = this.path;\n\t\tlet otherPath = space.path;\n\n\t\tlet connectionSpace, connectionSpaceIndex;\n\n\t\tfor (let i = 0; i < myPath.length; i++) {\n\t\t\tif (myPath[i].equals(otherPath[i])) {\n\t\t\t\tconnectionSpace = myPath[i];\n\t\t\t\tconnectionSpaceIndex = i;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (!connectionSpace) {\n\t\t\t// This should never happen\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot convert between color spaces ${this} and ${space}: no connection space was found`,\n\t\t\t);\n\t\t}\n\n\t\t// Go up from current space to connection space\n\t\tfor (let i = myPath.length - 1; i > connectionSpaceIndex; i--) {\n\t\t\tcoords = myPath[i].toBase(coords);\n\t\t}\n\n\t\t// Go down from connection space to target space\n\t\tfor (let i = connectionSpaceIndex + 1; i < otherPath.length; i++) {\n\t\t\tcoords = otherPath[i].fromBase(coords);\n\t\t}\n\n\t\treturn coords;\n\t}\n\n\tfrom (space, coords) {\n\t\tif (arguments.length === 1) {\n\t\t\tconst color = getColor(space);\n\t\t\t[space, coords] = [color.space, color.coords];\n\t\t}\n\n\t\tspace = ColorSpace.get(space);\n\n\t\treturn space.to(this, coords);\n\t}\n\n\ttoString () {\n\t\treturn `${this.name} (${this.id})`;\n\t}\n\n\tgetMinCoords () {\n\t\tlet ret = [];\n\n\t\tfor (let id in this.coords) {\n\t\t\tlet meta = this.coords[id];\n\t\t\tlet range = meta.range || meta.refRange;\n\t\t\tret.push(range?.min ?? 0);\n\t\t}\n\n\t\treturn ret;\n\t}\n\n\tstatic registry = {};\n\n\t// Returns array of unique color spaces\n\tstatic get all () {\n\t\treturn [...new Set(Object.values(ColorSpace.registry))];\n\t}\n\n\tstatic register (id, space) {\n\t\tif (arguments.length === 1) {\n\t\t\tspace = arguments[0];\n\t\t\tid = space.id;\n\t\t}\n\n\t\tspace = this.get(space);\n\n\t\tif (this.registry[id] && this.registry[id] !== space) {\n\t\t\tthrow new Error(`Duplicate color space registration: '${id}'`);\n\t\t}\n\t\tthis.registry[id] = space;\n\n\t\t// Register aliases when called without an explicit ID.\n\t\tif (arguments.length === 1 && space.aliases) {\n\t\t\tfor (let alias of space.aliases) {\n\t\t\t\tthis.register(alias, space);\n\t\t\t}\n\t\t}\n\n\t\treturn space;\n\t}\n\n\t/**\n\t * Lookup ColorSpace object by name\n\t * @param {ColorSpace | string} name\n\t */\n\tstatic get (space, ...alternatives) {\n\t\tif (!space || isInstance(space, this)) {\n\t\t\treturn space;\n\t\t}\n\n\t\tlet argType = type(space);\n\n\t\tif (argType === \"string\") {\n\t\t\t// It's a color space id\n\t\t\tlet ret = ColorSpace.registry[space.toLowerCase()];\n\n\t\t\tif (!ret) {\n\t\t\t\tthrow new TypeError(`No color space found with id = \"${space}\"`);\n\t\t\t}\n\n\t\t\treturn ret;\n\t\t}\n\n\t\tif (alternatives.length) {\n\t\t\treturn ColorSpace.get(...alternatives);\n\t\t}\n\n\t\tthrow new TypeError(`${space} is not a valid color space`);\n\t}\n\n\t/**\n\t * Look up all color spaces for a format that matches certain criteria\n\t * @param {object | string} filters\n\t * @param {Array<ColorSpace>} [spaces=ColorSpace.all]\n\t * @returns {Format | null}\n\t */\n\tstatic findFormat (filters, spaces = ColorSpace.all) {\n\t\tif (!filters) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (typeof filters === \"string\") {\n\t\t\tfilters = { name: filters };\n\t\t}\n\n\t\tfor (let space of spaces) {\n\t\t\tfor (let [name, format] of Object.entries(space.formats)) {\n\t\t\t\tformat.name ??= name;\n\t\t\t\tformat.type ??= \"function\";\n\n\t\t\t\tlet matches =\n\t\t\t\t\t(!filters.name || format.name === filters.name) &&\n\t\t\t\t\t(!filters.type || format.type === filters.type);\n\n\t\t\t\tif (filters.id) {\n\t\t\t\t\tlet ids = format.ids || [format.id];\n\t\t\t\t\tlet filterIds = Array.isArray(filters.id) ? filters.id : [filters.id];\n\t\t\t\t\tmatches &&= filterIds.some(id => ids.includes(id));\n\t\t\t\t}\n\n\t\t\t\tif (matches) {\n\t\t\t\t\tlet ret = Format.get(format, space);\n\n\t\t\t\t\tif (ret !== format) {\n\t\t\t\t\t\tspace.formats[format.name] = ret;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn ret;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Get metadata about a coordinate of a color space\n\t *\n\t * @static\n\t * @param {Array | string} ref\n\t * @param {ColorSpace | string} [workingSpace]\n\t * @return {Object}\n\t */\n\tstatic resolveCoord (ref, workingSpace) {\n\t\tlet coordType = type(ref);\n\t\tlet space, coord;\n\n\t\tif (coordType === \"string\") {\n\t\t\tif (ref.includes(\".\")) {\n\t\t\t\t// Absolute coordinate\n\t\t\t\t[space, coord] = ref.split(\".\");\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative coordinate\n\t\t\t\t[space, coord] = [, ref];\n\t\t\t}\n\t\t}\n\t\telse if (Array.isArray(ref)) {\n\t\t\t[space, coord] = ref;\n\t\t}\n\t\telse {\n\t\t\t// Object\n\t\t\tspace = ref.space;\n\t\t\tcoord = ref.coordId;\n\t\t}\n\n\t\tspace = ColorSpace.get(space);\n\n\t\tif (!space) {\n\t\t\tspace = workingSpace;\n\t\t}\n\n\t\tif (!space) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Cannot resolve coordinate reference ${ref}: No color space specified and relative references are not allowed here`,\n\t\t\t);\n\t\t}\n\n\t\tcoordType = type(coord);\n\n\t\tif (coordType === \"number\" || (coordType === \"string\" && coord >= 0)) {\n\t\t\t// Resolve numerical coord\n\t\t\tlet meta = Object.entries(space.coords)[coord];\n\n\t\t\tif (meta) {\n\t\t\t\treturn { space, id: meta[0], index: coord, ...meta[1] };\n\t\t\t}\n\t\t}\n\n\t\tspace = ColorSpace.get(space);\n\n\t\tlet normalizedCoord = coord.toLowerCase();\n\n\t\tlet i = 0;\n\t\tfor (let id in space.coords) {\n\t\t\tlet meta = space.coords[id];\n\n\t\t\tif (\n\t\t\t\tid.toLowerCase() === normalizedCoord ||\n\t\t\t\tmeta.name?.toLowerCase() === normalizedCoord\n\t\t\t) {\n\t\t\t\treturn { space, id, index: i, ...meta };\n\t\t\t}\n\n\t\t\ti++;\n\t\t}\n\n\t\tthrow new TypeError(\n\t\t\t`No \"${coord}\" coordinate found in ${space.name}. Its coordinates are: ${Object.keys(space.coords).join(\", \")}`,\n\t\t);\n\t}\n\n\tstatic DEFAULT_FORMAT = {\n\t\ttype: \"functions\",\n\t\tname: \"color\",\n\t};\n}\n\nfunction getPath (space) {\n\tlet ret = [space];\n\n\tfor (let s = space; (s = s.base); ) {\n\t\tret.push(s);\n\t}\n\n\treturn ret;\n}\n", "import ColorSpace from \"../ColorSpace.js\";\n\nexport default new ColorSpace({\n\tid: \"xyz-d65\",\n\tname: \"XYZ D65\",\n\tcoords: {\n\t\tx: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"X\",\n\t\t},\n\t\ty: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"Y\",\n\t\t},\n\t\tz: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"Z\",\n\t\t},\n\t},\n\twhite: \"D65\",\n\tformats: {\n\t\tcolor: {\n\t\t\tids: [\"xyz-d65\", \"xyz\"],\n\t\t},\n\t},\n\taliases: [\"xyz\"],\n});\n", "import ColorSpace from \"./ColorSpace.js\";\nimport { multiply_v3_m3x3 } from \"./util.js\";\nimport adapt from \"./adapt.js\";\nimport XYZ_D65 from \"./spaces/xyz-d65.js\";\n\n// Type re-exports\n/** @typedef {import(\"./types.js\").RGBOptions} RGBOptions */\n\n/** Convenience class for RGB color spaces */\nexport default class RGBColorSpace extends ColorSpace {\n\t/**\n\t * Creates a new RGB ColorSpace.\n\t * If coords are not specified, they will use the default RGB coords.\n\t * Instead of `fromBase()` and `toBase()` functions,\n\t * you can specify to/from XYZ matrices and have `toBase()` and `fromBase()` automatically generated.\n\t * @param {RGBOptions} options\n\t */\n\tconstructor (options) {\n\t\tif (!options.coords) {\n\t\t\toptions.coords = {\n\t\t\t\tr: {\n\t\t\t\t\trange: [0, 1],\n\t\t\t\t\tname: \"Red\",\n\t\t\t\t},\n\t\t\t\tg: {\n\t\t\t\t\trange: [0, 1],\n\t\t\t\t\tname: \"Green\",\n\t\t\t\t},\n\t\t\t\tb: {\n\t\t\t\t\trange: [0, 1],\n\t\t\t\t\tname: \"Blue\",\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (!options.base) {\n\t\t\toptions.base = XYZ_D65;\n\t\t}\n\n\t\tif (options.toXYZ_M && options.fromXYZ_M) {\n\t\t\toptions.toBase ??= rgb => {\n\t\t\t\tlet xyz = multiply_v3_m3x3(rgb, options.toXYZ_M);\n\n\t\t\t\tif (this.white !== this.base.white) {\n\t\t\t\t\t// Perform chromatic adaptation\n\t\t\t\t\txyz = adapt(this.white, this.base.white, xyz);\n\t\t\t\t}\n\n\t\t\t\treturn xyz;\n\t\t\t};\n\n\t\t\toptions.fromBase ??= xyz => {\n\t\t\t\txyz = adapt(this.base.white, this.white, xyz);\n\t\t\t\treturn multiply_v3_m3x3(xyz, options.fromXYZ_M);\n\t\t\t};\n\t\t}\n\n\t\toptions.referred ??= \"display\";\n\n\t\tsuper(options);\n\t}\n}\n", "import ColorSpace from \"./ColorSpace.js\";\nimport getColor from \"./getColor.js\";\nimport { toPrecision } from \"./util.js\";\n\n/** @import { ColorTypes, Coords } from \"./types.js\" */\n\n/**\n * Options for {@link getAll}\n * @typedef GetAllOptions\n * @property {string | ColorSpace | undefined} [space]\n * The color space to convert to. Defaults to the color's current space\n * @property {number | undefined} [precision]\n * The number of significant digits to round the coordinates to\n */\n\n/**\n * Get the coordinates of a color in any color space\n * @overload\n * @param {ColorTypes} color\n * @param {string | ColorSpace} [options=color.space] The color space to convert to. Defaults to the color's current space\n * @returns {Coords} The color coordinates in the given color space\n */\n/**\n * @overload\n * @param {ColorTypes} color\n * @param {GetAllOptions} [options]\n * @returns {Coords} The color coordinates in the given color space\n */\nexport default function getAll (color, options) {\n\tcolor = getColor(color);\n\n\tlet space = ColorSpace.get(options, options?.space);\n\tlet precision = options?.precision;\n\n\tlet coords;\n\tif (!space || color.space.equals(space)) {\n\t\t// No conversion needed\n\t\tcoords = color.coords.slice();\n\t}\n\telse {\n\t\tcoords = space.from(color);\n\t}\n\n\treturn precision === undefined ? coords : coords.map(coord => toPrecision(coord, precision));\n}\n", "import ColorSpace from \"./ColorSpace.js\";\nimport getAll from \"./getAll.js\";\nimport getColor from \"./getColor.js\";\n\n/** @import { ColorTypes, Ref } from \"./types.js\" */\n\n/**\n * @param {ColorTypes} color\n * @param {Ref} prop\n * @returns {number}\n */\nexport default function get (color, prop) {\n\tcolor = getColor(color);\n\n\tif (prop === \"alpha\") {\n\t\treturn color.alpha ?? 1;\n\t}\n\n\tlet { space, index } = ColorSpace.resolveCoord(prop, color.space);\n\tlet coords = getAll(color, space);\n\treturn coords[index];\n}\n", "import ColorSpace from \"./ColorSpace.js\";\nimport getColor from \"./getColor.js\";\n\n/** @import { ColorTypes, Coords, PlainColorObject } from \"./types.js\" */\n\n/**\n * Set all coordinates of a color at once, in its own color space or another.\n * Modifies the color in place.\n * @overload\n * @param {ColorTypes} color\n * @param {Coords} coords Array of coordinates\n * @param {number} [alpha]\n * @returns {PlainColorObject}\n */\n/**\n * @overload\n * @param {ColorTypes} color\n * @param {string | ColorSpace} space The color space of the provided coordinates.\n * @param {Coords} coords Array of coordinates\n * @param {number} [alpha]\n * @returns {PlainColorObject}\n */\nexport default function setAll (color, space, coords, alpha) {\n\tcolor = getColor(color);\n\n\tif (Array.isArray(space)) {\n\t\t// Space is omitted\n\t\t[space, coords, alpha] = [color.space, space, coords];\n\t}\n\n\tspace = ColorSpace.get(space); // Make sure we have a ColorSpace object\n\tcolor.coords = space === color.space ? coords.slice() : space.to(color.space, coords);\n\n\tif (alpha !== undefined) {\n\t\tcolor.alpha = alpha;\n\t}\n\n\treturn color;\n}\n\n/** @type {\"color\"} */\nsetAll.returns = \"color\";\n", "import ColorSpace from \"./ColorSpace.js\";\nimport getColor from \"./getColor.js\";\nimport get from \"./get.js\";\nimport getAll from \"./getAll.js\";\nimport setAll from \"./setAll.js\";\nimport { type } from \"./util.js\";\n\n/** @import { ColorTypes, PlainColorObject, Ref } from \"./types.js\" */\n\n/**\n * Set properties and return current instance\n * @overload\n * @param {ColorTypes} color\n * @param {Ref} prop\n * @param {number | ((coord: number) => number)} value\n * @returns {PlainColorObject}\n */\n/**\n * @overload\n * @param {ColorTypes} color\n * @param {Record<string, number | ((coord: number) => number)>} props\n * @returns {PlainColorObject}\n */\nexport default function set (color, prop, value) {\n\tcolor = getColor(color);\n\n\tif (arguments.length === 2 && type(arguments[1]) === \"object\") {\n\t\t// Argument is an object literal\n\t\tlet object = arguments[1];\n\t\tfor (let p in object) {\n\t\t\tset(color, p, object[p]);\n\t\t}\n\t}\n\telse {\n\t\tif (typeof value === \"function\") {\n\t\t\tvalue = value(get(color, prop));\n\t\t}\n\n\t\tif (prop === \"alpha\") {\n\t\t\tcolor.alpha = value;\n\t\t}\n\t\telse {\n\t\t\tlet { space, index } = ColorSpace.resolveCoord(prop, color.space);\n\t\t\tlet coords = getAll(color, space);\n\t\t\tcoords[index] = value;\n\t\t\tsetAll(color, space, coords);\n\t\t}\n\t}\n\n\treturn color;\n}\n\n/** @type {\"color\"} */\nset.returns = \"color\";\n", "import ColorSpace from \"../ColorSpace.js\";\nimport adapt from \"../adapt.js\";\nimport XYZ_D65 from \"./xyz-d65.js\";\n\nexport default new ColorSpace({\n\tid: \"xyz-d50\",\n\tname: \"XYZ D50\",\n\twhite: \"D50\",\n\tbase: XYZ_D65,\n\tfromBase: coords => adapt(XYZ_D65.white, \"D50\", coords),\n\ttoBase: coords => adapt(\"D50\", XYZ_D65.white, coords),\n});\n", "import ColorSpace from \"../ColorSpace.js\";\nimport { WHITES } from \"../adapt.js\";\nimport xyz_d50 from \"./xyz-d50.js\";\n\n// \u03BA * \u03B5 = 2^3 = 8\nconst \u03B5 = 216 / 24389; // 6^3/29^3 == (24/116)^3\nconst \u03B53 = 24 / 116;\nconst \u03BA = 24389 / 27; // 29^3/3^3\n\nlet white = WHITES.D50;\n\nexport default new ColorSpace({\n\tid: \"lab\",\n\tname: \"Lab\",\n\tcoords: {\n\t\tl: {\n\t\t\trefRange: [0, 100],\n\t\t\tname: \"Lightness\",\n\t\t},\n\t\ta: {\n\t\t\trefRange: [-125, 125],\n\t\t},\n\t\tb: {\n\t\t\trefRange: [-125, 125],\n\t\t},\n\t},\n\n\t// Assuming XYZ is relative to D50, convert to CIE Lab\n\t// from CIE standard, which now defines these as a rational fraction\n\twhite,\n\n\tbase: xyz_d50,\n\t// Convert D50-adapted XYX to Lab\n\t// CIE 15.3:2004 section 8.2.1.1\n\tfromBase (XYZ) {\n\t\t// XYZ scaled relative to reference white\n\t\tlet xyz = XYZ.map((value, i) => value / white[i]);\n\t\tlet f = xyz.map(value => (value > \u03B5 ? Math.cbrt(value) : (\u03BA * value + 16) / 116));\n\n\t\tlet L = 116 * f[1] - 16;\n\t\tlet a = 500 * (f[0] - f[1]);\n\t\tlet b = 200 * (f[1] - f[2]);\n\n\t\treturn [L, a, b];\n\t},\n\t// Convert Lab to D50-adapted XYZ\n\t// Same result as CIE 15.3:2004 Appendix D although the derivation is different\n\t// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html\n\ttoBase (Lab) {\n\t\t// compute f, starting with the luminance-related term\n\t\tlet [L, a, b] = Lab;\n\t\tlet f = [];\n\t\tf[1] = (L + 16) / 116;\n\t\tf[0] = a / 500 + f[1];\n\t\tf[2] = f[1] - b / 200;\n\n\t\t// compute xyz\n\t\t// prettier-ignore\n\t\tlet xyz = [\n\t\t\tf[0] > \u03B53 ? Math.pow(f[0], 3) : (116 * f[0] - 16) / \u03BA,\n\t\t\tLab[0] > 8 ? Math.pow((Lab[0] + 16) / 116, 3) : Lab[0] / \u03BA,\n\t\t\tf[2] > \u03B53 ? Math.pow(f[2], 3) : (116 * f[2] - 16) / \u03BA,\n\t\t];\n\n\t\t// Compute XYZ by scaling xyz by reference white\n\t\treturn xyz.map((value, i) => value * white[i]);\n\t},\n\n\tformats: {\n\t\tlab: {\n\t\t\tcoords: [\n\t\t\t\t\"<percentage> | <number>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t],\n\t\t},\n\t},\n});\n", "import * as util from \"./util.js\";\n\n/**\n * Constrain an angle to 360 degrees\n * @param {number} angle\n * @returns {number}\n */\nexport function constrain (angle) {\n\tif (typeof angle !== \"number\") {\n\t\treturn angle;\n\t}\n\n\treturn ((angle % 360) + 360) % 360;\n}\n\n/**\n * @param {\"raw\" | \"increasing\" | \"decreasing\" | \"longer\" | \"shorter\"} arc\n * @param {[number, number]} angles\n * @returns {[number, number]}\n */\nexport function adjust (arc, angles) {\n\tlet [a1, a2] = angles;\n\n\tlet none1 = util.isNone(a1);\n\tlet none2 = util.isNone(a2);\n\n\tif (none1 && none2) {\n\t\treturn [a1, a2];\n\t}\n\telse if (none1) {\n\t\ta1 = a2;\n\t}\n\telse if (none2) {\n\t\ta2 = a1;\n\t}\n\n\tif (arc === \"raw\") {\n\t\treturn angles;\n\t}\n\n\ta1 = constrain(a1);\n\ta2 = constrain(a2);\n\n\tlet angleDiff = a2 - a1;\n\n\tif (arc === \"increasing\") {\n\t\tif (angleDiff < 0) {\n\t\t\ta2 += 360;\n\t\t}\n\t}\n\telse if (arc === \"decreasing\") {\n\t\tif (angleDiff > 0) {\n\t\t\ta1 += 360;\n\t\t}\n\t}\n\telse if (arc === \"longer\") {\n\t\tif (-180 < angleDiff && angleDiff < 180) {\n\t\t\tif (angleDiff > 0) {\n\t\t\t\ta1 += 360;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ta2 += 360;\n\t\t\t}\n\t\t}\n\t}\n\telse if (arc === \"shorter\") {\n\t\tif (angleDiff > 180) {\n\t\t\ta1 += 360;\n\t\t}\n\t\telse if (angleDiff < -180) {\n\t\t\ta2 += 360;\n\t\t}\n\t}\n\n\treturn [a1, a2];\n}\n", "import ColorSpace from \"../ColorSpace.js\";\nimport Lab from \"./lab.js\";\nimport { constrain as constrainAngle } from \"../angles.js\";\nimport { isNone } from \"../util.js\";\n\nexport default new ColorSpace({\n\tid: \"lch\",\n\tname: \"LCH\",\n\tcoords: {\n\t\tl: {\n\t\t\trefRange: [0, 100],\n\t\t\tname: \"Lightness\",\n\t\t},\n\t\tc: {\n\t\t\trefRange: [0, 150],\n\t\t\tname: \"Chroma\",\n\t\t},\n\t\th: {\n\t\t\trefRange: [0, 360],\n\t\t\ttype: \"angle\",\n\t\t\tname: \"Hue\",\n\t\t},\n\t},\n\n\tbase: Lab,\n\tfromBase (Lab) {\n\t\t// These methods are used for other polar forms as well, so we can't hardcode the \u03B5\n\t\tif (this.\u03B5 === undefined) {\n\t\t\t// @ts-expect-error Property 'coords' does not exist on type 'string | ColorSpace'\n\t\t\tlet range = Object.values(this.base.coords)[1].refRange;\n\t\t\tlet extent = range[1] - range[0];\n\t\t\tthis.\u03B5 = extent / 100000;\n\t\t}\n\n\t\t// Convert to polar form\n\t\tlet [L, a, b] = Lab;\n\t\tlet isAchromatic = Math.abs(a) < this.\u03B5 && Math.abs(b) < this.\u03B5;\n\t\tlet h = isAchromatic ? null : constrainAngle((Math.atan2(b, a) * 180) / Math.PI);\n\t\tlet C = isAchromatic ? 0 : Math.sqrt(a ** 2 + b ** 2);\n\n\t\treturn [L, C, h];\n\t},\n\ttoBase (lch) {\n\t\t// Convert from polar form\n\t\tlet [L, C, h] = lch;\n\t\tlet a = null,\n\t\t\tb = null;\n\n\t\tif (!isNone(h)) {\n\t\t\tC = C < 0 ? 0 : C; // Clamp negative Chroma\n\t\t\ta = C * Math.cos((h * Math.PI) / 180);\n\t\t\tb = C * Math.sin((h * Math.PI) / 180);\n\t\t}\n\n\t\treturn [L, a, b];\n\t},\n\n\tformats: {\n\t\tlch: {\n\t\t\tcoords: [\"<percentage> | <number>\", \"<number> | <percentage>\", \"<number> | <angle>\"],\n\t\t},\n\t},\n});\n", "import defaults from \"../defaults.js\";\nimport lab from \"../spaces/lab.js\";\nimport lch from \"../spaces/lch.js\";\nimport getColor from \"../getColor.js\";\n\n// deltaE2000 is a statistically significant improvement\n// and is recommended by the CIE and Idealliance\n// especially for color differences less than 10 deltaE76\n// but is wicked complicated\n// and many implementations have small errors!\n// DeltaE2000 is also discontinuous; in case this\n// matters to you, use deltaECMC instead.\n\nconst Gfactor = 25 ** 7;\nconst \u03C0 = Math.PI;\nconst r2d = 180 / \u03C0;\nconst d2r = \u03C0 / 180;\n\nfunction pow7 (x) {\n\t// Faster than x ** 7 or Math.pow(x, 7)\n\n\tconst x2 = x * x;\n\tconst x7 = x2 * x2 * x2 * x;\n\n\treturn x7;\n}\n\n/**\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @param {{ kL?: number | undefined; kC?: number | undefined; kH?: number | undefined }} options\n * @returns {number}\n */\nexport default function (color, sample, { kL = 1, kC = 1, kH = 1 } = {}) {\n\t[color, sample] = getColor([color, sample]);\n\n\t// Given this color as the reference\n\t// and the function parameter as the sample,\n\t// calculate deltaE 2000.\n\n\t// This implementation assumes the parametric\n\t// weighting factors kL, kC and kH\n\t// for the influence of viewing conditions\n\t// are all 1, as sadly seems typical.\n\t// kL should be increased for lightness texture or noise\n\t// and kC increased for chroma noise\n\n\tlet [L1, a1, b1] = lab.from(color);\n\tlet C1 = lch.from(lab, [L1, a1, b1])[1];\n\tlet [L2, a2, b2] = lab.from(sample);\n\tlet C2 = lch.from(lab, [L2, a2, b2])[1];\n\n\t// Check for negative Chroma,\n\t// which might happen through\n\t// direct user input of LCH values\n\n\tif (C1 < 0) {\n\t\tC1 = 0;\n\t}\n\tif (C2 < 0) {\n\t\tC2 = 0;\n\t}\n\n\tlet Cbar = (C1 + C2) / 2; // mean Chroma\n\n\t// calculate a-axis asymmetry factor from mean Chroma\n\t// this turns JND ellipses for near-neutral colors back into circles\n\tlet C7 = pow7(Cbar);\n\n\tlet G = 0.5 * (1 - Math.sqrt(C7 / (C7 + Gfactor)));\n\n\t// scale a axes by asymmetry factor\n\t// this by the way is why there is no Lab2000 colorspace\n\tlet adash1 = (1 + G) * a1;\n\tlet adash2 = (1 + G) * a2;\n\n\t// calculate new Chroma from scaled a and original b axes\n\tlet Cdash1 = Math.sqrt(adash1 ** 2 + b1 ** 2);\n\tlet Cdash2 = Math.sqrt(adash2 ** 2 + b2 ** 2);\n\n\t// calculate new hues, with zero hue for true neutrals\n\t// and in degrees, not radians\n\n\tlet h1 = adash1 === 0 && b1 === 0 ? 0 : Math.atan2(b1, adash1);\n\tlet h2 = adash2 === 0 && b2 === 0 ? 0 : Math.atan2(b2, adash2);\n\n\tif (h1 < 0) {\n\t\th1 += 2 * \u03C0;\n\t}\n\tif (h2 < 0) {\n\t\th2 += 2 * \u03C0;\n\t}\n\n\th1 *= r2d;\n\th2 *= r2d;\n\n\t// Lightness and Chroma differences; sign matters\n\tlet \u0394L = L2 - L1;\n\tlet \u0394C = Cdash2 - Cdash1;\n\n\t// Hue difference, getting the sign correct\n\tlet hdiff = h2 - h1;\n\tlet hsum = h1 + h2;\n\tlet habs = Math.abs(hdiff);\n\tlet \u0394h;\n\n\tif (Cdash1 * Cdash2 === 0) {\n\t\t\u0394h = 0;\n\t}\n\telse if (habs <= 180) {\n\t\t\u0394h = hdiff;\n\t}\n\telse if (hdiff > 180) {\n\t\t\u0394h = hdiff - 360;\n\t}\n\telse if (hdiff < -180) {\n\t\t\u0394h = hdiff + 360;\n\t}\n\telse {\n\t\tdefaults.warn(\"the unthinkable has happened\");\n\t}\n\n\t// weighted Hue difference, more for larger Chroma\n\tlet \u0394H = 2 * Math.sqrt(Cdash2 * Cdash1) * Math.sin((\u0394h * d2r) / 2);\n\n\t// calculate mean Lightness and Chroma\n\tlet Ldash = (L1 + L2) / 2;\n\tlet Cdash = (Cdash1 + Cdash2) / 2;\n\tlet Cdash7 = pow7(Cdash);\n\n\t// Compensate for non-linearity in the blue region of Lab.\n\t// Four possibilities for hue weighting factor,\n\t// depending on the angles, to get the correct sign\n\tlet hdash;\n\tif (Cdash1 * Cdash2 === 0) {\n\t\thdash = hsum; // which should be zero\n\t}\n\telse if (habs <= 180) {\n\t\thdash = hsum / 2;\n\t}\n\telse if (hsum < 360) {\n\t\thdash = (hsum + 360) / 2;\n\t}\n\telse {\n\t\thdash = (hsum - 360) / 2;\n\t}\n\n\t// positional corrections to the lack of uniformity of CIELAB\n\t// These are all trying to make JND ellipsoids more like spheres\n\n\t// SL Lightness crispening factor\n\t// a background with L=50 is assumed\n\tlet lsq = (Ldash - 50) ** 2;\n\tlet SL = 1 + (0.015 * lsq) / Math.sqrt(20 + lsq);\n\n\t// SC Chroma factor, similar to those in CMC and deltaE 94 formulae\n\tlet SC = 1 + 0.045 * Cdash;\n\n\t// Cross term T for blue non-linearity\n\tlet T = 1;\n\tT -= 0.17 * Math.cos((hdash - 30) * d2r);\n\tT += 0.24 * Math.cos(2 * hdash * d2r);\n\tT += 0.32 * Math.cos((3 * hdash + 6) * d2r);\n\tT -= 0.2 * Math.cos((4 * hdash - 63) * d2r);\n\n\t// SH Hue factor depends on Chroma,\n\t// as well as adjusted hue angle like deltaE94.\n\tlet SH = 1 + 0.015 * Cdash * T;\n\n\t// RT Hue rotation term compensates for rotation of JND ellipses\n\t// and Munsell constant hue lines\n\t// in the medium-high Chroma blue region\n\t// (Hue 225 to 315)\n\tlet \u0394\u03B8 = 30 * Math.exp(-1 * ((hdash - 275) / 25) ** 2);\n\tlet RC = 2 * Math.sqrt(Cdash7 / (Cdash7 + Gfactor));\n\tlet RT = -1 * Math.sin(2 * \u0394\u03B8 * d2r) * RC;\n\n\t// Finally calculate the deltaE, term by term as root sume of squares\n\tlet dE = (\u0394L / (kL * SL)) ** 2;\n\tdE += (\u0394C / (kC * SC)) ** 2;\n\tdE += (\u0394H / (kH * SH)) ** 2;\n\tdE += RT * (\u0394C / (kC * SC)) * (\u0394H / (kH * SH));\n\treturn Math.sqrt(dE);\n\t// Yay!!!\n}\n", "import ColorSpace from \"../ColorSpace.js\";\nimport { multiply_v3_m3x3 } from \"../util.js\";\nimport XYZ_D65 from \"./xyz-d65.js\";\n\n/** @import { Matrix3x3 } from \"../types.js\" */\n\n// Recalculated for consistent reference white\n// see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst XYZtoLMS_M = [\n\t[ 0.8190224379967030, 0.3619062600528904, -0.1288737815209879 ],\n\t[ 0.0329836539323885, 0.9292868615863434, 0.0361446663506424 ],\n\t[ 0.0481771893596242, 0.2642395317527308, 0.6335478284694309 ],\n];\n// inverse of XYZtoLMS_M\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst LMStoXYZ_M = [\n\t[ 1.2268798758459243, -0.5578149944602171, 0.2813910456659647 ],\n\t[ -0.0405757452148008, 1.1122868032803170, -0.0717110580655164 ],\n\t[ -0.0763729366746601, -0.4214933324022432, 1.5869240198367816 ],\n];\n/** @type {Matrix3x3} */\n// prettier-ignore\nexport const LMStoLab_M = [\n\t[ 0.2104542683093140, 0.7936177747023054, -0.0040720430116193 ],\n\t[ 1.9779985324311684, -2.4285922420485799, 0.4505937096174110 ],\n\t[ 0.0259040424655478, 0.7827717124575296, -0.8086757549230774 ],\n];\n// LMStoIab_M inverted\n/** @type {Matrix3x3} */\n// prettier-ignore\nexport const LabtoLMS_M = [\n\t[ 1.0000000000000000, 0.3963377773761749, 0.2158037573099136 ],\n\t[ 1.0000000000000000, -0.1055613458156586, -0.0638541728258133 ],\n\t[ 1.0000000000000000, -0.0894841775298119, -1.2914855480194092 ],\n];\n\nexport default new ColorSpace({\n\tid: \"oklab\",\n\tname: \"Oklab\",\n\tcoords: {\n\t\tl: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"Lightness\",\n\t\t},\n\t\ta: {\n\t\t\trefRange: [-0.4, 0.4],\n\t\t},\n\t\tb: {\n\t\t\trefRange: [-0.4, 0.4],\n\t\t},\n\t},\n\n\t// Note that XYZ is relative to D65\n\twhite: \"D65\",\n\tbase: XYZ_D65,\n\tfromBase (XYZ) {\n\t\t// move to LMS cone domain\n\t\tlet LMS = multiply_v3_m3x3(XYZ, XYZtoLMS_M);\n\n\t\t// non-linearity\n\t\tLMS[0] = Math.cbrt(LMS[0]);\n\t\tLMS[1] = Math.cbrt(LMS[1]);\n\t\tLMS[2] = Math.cbrt(LMS[2]);\n\n\t\treturn multiply_v3_m3x3(LMS, LMStoLab_M, LMS);\n\t},\n\ttoBase (OKLab) {\n\t\t// move to LMS cone domain\n\t\tlet LMSg = multiply_v3_m3x3(OKLab, LabtoLMS_M);\n\n\t\t// restore linearity\n\t\tLMSg[0] = LMSg[0] ** 3;\n\t\tLMSg[1] = LMSg[1] ** 3;\n\t\tLMSg[2] = LMSg[2] ** 3;\n\n\t\treturn multiply_v3_m3x3(LMSg, LMStoXYZ_M, LMSg);\n\t},\n\n\tformats: {\n\t\toklab: {\n\t\t\tcoords: [\n\t\t\t\t\"<percentage> | <number>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t],\n\t\t},\n\t},\n});\n", "import oklab from \"../spaces/oklab.js\";\nimport getColor from \"../getColor.js\";\n\n/**\n * More accurate color-difference formulae\n * than the simple 1976 Euclidean distance in CIE Lab\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @returns {number}\n */\nexport default function (color, sample) {\n\t[color, sample] = getColor([color, sample]);\n\n\t// Given this color as the reference\n\t// and a sample,\n\t// calculate deltaEOK, term by term as root sum of squares\n\tlet [L1, a1, b1] = oklab.from(color);\n\tlet [L2, a2, b2] = oklab.from(sample);\n\tlet \u0394L = L1 - L2;\n\tlet \u0394a = a1 - a2;\n\tlet \u0394b = b1 - b2;\n\treturn Math.sqrt(\u0394L ** 2 + \u0394a ** 2 + \u0394b ** 2);\n}\n", "import ColorSpace from \"./ColorSpace.js\";\nimport getColor from \"./getColor.js\";\n\n/** @import { ColorTypes } from \"./types.js\" */\n\nconst \u03B5 = 0.000075;\n\n/**\n * Check if a color is in gamut of either its own or another color space\n * @param {ColorTypes} color\n * @param {string | ColorSpace} [space]\n * @param {{ epsilon?: number | undefined }} [param2]\n * @returns {boolean}\n */\nexport default function inGamut (color, space, { epsilon = \u03B5 } = {}) {\n\tcolor = getColor(color);\n\n\tif (!space) {\n\t\tspace = color.space;\n\t}\n\n\tspace = ColorSpace.get(space);\n\tlet coords = color.coords;\n\n\tif (space !== color.space) {\n\t\tcoords = space.from(color);\n\t}\n\n\treturn space.inGamut(coords, { epsilon });\n}\n", "/** @import { Coords, PlainColorObject } from \"./types.js\" */\n\n/**\n * @param {PlainColorObject} color\n * @returns {PlainColorObject}\n */\nexport default function clone (color) {\n\treturn {\n\t\tspace: color.space,\n\t\tcoords: /** @type {Coords} */ (color.coords.slice()),\n\t\talpha: color.alpha,\n\t};\n}\n", "import ColorSpace from \"./ColorSpace.js\";\nimport { isNone } from \"./util.js\";\n\n/** @import { ColorTypes } from \"./types.js\" */\n\n/**\n * Euclidean distance of colors in an arbitrary color space\n * @param {ColorTypes} color1\n * @param {ColorTypes} color2\n * @param {string | ColorSpace} space\n * @returns {number}\n */\nexport default function distance (color1, color2, space = \"lab\") {\n\tspace = ColorSpace.get(space);\n\n\t// Assume getColor() is called on color in space.from()\n\tlet coords1 = space.from(color1);\n\tlet coords2 = space.from(color2);\n\n\treturn Math.sqrt(\n\t\tcoords1.reduce((acc, c1, i) => {\n\t\t\tlet c2 = coords2[i];\n\t\t\tif (isNone(c1) || isNone(c2)) {\n\t\t\t\treturn acc;\n\t\t\t}\n\n\t\t\treturn acc + (c2 - c1) ** 2;\n\t\t}, 0),\n\t);\n}\n", "import distance from \"../distance.js\";\nimport getColor from \"../getColor.js\";\n\n/**\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @returns {number}\n */\nexport default function deltaE76 (color, sample) {\n\t// Assume getColor() is called in the distance function\n\treturn distance(color, sample, \"lab\");\n}\n", "import lab from \"../spaces/lab.js\";\nimport lch from \"../spaces/lch.js\";\nimport getColor from \"../getColor.js\";\nimport { isNone } from \"../util.js\";\n\n// More accurate color-difference formulae\n// than the simple 1976 Euclidean distance in Lab\n\n// CMC by the Color Measurement Committee of the\n// Bradford Society of Dyeists and Colorsts, 1994.\n// Uses LCH rather than Lab,\n// with different weights for L, C and H differences\n// A nice increase in accuracy for modest increase in complexity\nconst \u03C0 = Math.PI;\nconst d2r = \u03C0 / 180;\n\n/**\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @param {{ l?: number | undefined; c?: number | undefined }} options\n * @returns {number}\n */\nexport default function (color, sample, { l = 2, c = 1 } = {}) {\n\t[color, sample] = getColor([color, sample]);\n\n\t// Given this color as the reference\n\t// and a sample,\n\t// calculate deltaE CMC.\n\n\t// This implementation assumes the parametric\n\t// weighting factors l:c are 2:1\n\t// which is typical for non-textile uses.\n\n\tlet [L1, a1, b1] = lab.from(color);\n\tlet [, C1, H1] = lch.from(lab, [L1, a1, b1]);\n\tlet [L2, a2, b2] = lab.from(sample);\n\tlet C2 = lch.from(lab, [L2, a2, b2])[1];\n\n\t// let [L1, a1, b1] = color.getAll(lab);\n\t// let C1 = color.get(\"lch.c\");\n\t// let H1 = color.get(\"lch.h\");\n\t// let [L2, a2, b2] = sample.getAll(lab);\n\t// let C2 = sample.get(\"lch.c\");\n\n\t// Check for negative Chroma,\n\t// which might happen through\n\t// direct user input of LCH values\n\n\tif (C1 < 0) {\n\t\tC1 = 0;\n\t}\n\tif (C2 < 0) {\n\t\tC2 = 0;\n\t}\n\n\t// we don't need H2 as \u0394H is calculated from \u0394a, \u0394b and \u0394C\n\n\t// Lightness and Chroma differences\n\t// These are (color - sample), unlike deltaE2000\n\tlet \u0394L = L1 - L2;\n\tlet \u0394C = C1 - C2;\n\n\tlet \u0394a = a1 - a2;\n\tlet \u0394b = b1 - b2;\n\n\t// weighted Hue difference, less for larger Chroma difference\n\n\tlet H2 = \u0394a ** 2 + \u0394b ** 2 - \u0394C ** 2;\n\t// due to roundoff error it is possible that, for zero a and b,\n\t// \u0394C > \u0394a + \u0394b is 0, resulting in attempting\n\t// to take the square root of a negative number\n\n\t// trying instead the equation from Industrial Color Physics\n\t// By Georg A. Klein\n\n\t// let \u0394H = ((a1 * b2) - (a2 * b1)) / Math.sqrt(0.5 * ((C2 * C1) + (a2 * a1) + (b2 * b1)));\n\t// console.log({\u0394H});\n\t// This gives the same result to 12 decimal places\n\t// except it sometimes NaNs when trying to root a negative number\n\n\t// let \u0394H = Math.sqrt(H2); we never actually use the root, it gets squared again!!\n\n\t// positional corrections to the lack of uniformity of CIELAB\n\t// These are all trying to make JND ellipsoids more like spheres\n\n\t// SL Lightness crispening factor, depends entirely on L1 not L2\n\tlet SL = 0.511; // linear portion of the Y to L transfer function\n\tif (L1 >= 16) {\n\t\t// cubic portion\n\t\tSL = (0.040975 * L1) / (1 + 0.01765 * L1);\n\t}\n\n\t// SC Chroma factor\n\tlet SC = (0.0638 * C1) / (1 + 0.0131 * C1) + 0.638;\n\n\t// Cross term T for blue non-linearity\n\tlet T;\n\tif (isNone(H1)) {\n\t\tH1 = 0;\n\t}\n\n\tif (H1 >= 164 && H1 <= 345) {\n\t\tT = 0.56 + Math.abs(0.2 * Math.cos((H1 + 168) * d2r));\n\t}\n\telse {\n\t\tT = 0.36 + Math.abs(0.4 * Math.cos((H1 + 35) * d2r));\n\t}\n\t// console.log({T});\n\n\t// SH Hue factor also depends on C1,\n\tlet C4 = Math.pow(C1, 4);\n\tlet F = Math.sqrt(C4 / (C4 + 1900));\n\tlet SH = SC * (F * T + 1 - F);\n\n\t// Finally calculate the deltaE, term by term as root sume of squares\n\tlet dE = (\u0394L / (l * SL)) ** 2;\n\tdE += (\u0394C / (c * SC)) ** 2;\n\tdE += H2 / SH ** 2;\n\t// dE += (\u0394H / SH) ** 2;\n\treturn Math.sqrt(dE);\n\t// Yay!!!\n}\n", "import ColorSpace from \"../ColorSpace.js\";\nimport XYZ_D65 from \"./xyz-d65.js\";\n\nconst Yw = 203; // absolute luminance of media white\n\nexport default new ColorSpace({\n\t// Absolute CIE XYZ, with a D65 whitepoint,\n\t// as used in most HDR colorspaces as a starting point.\n\t// SDR spaces are converted per BT.2048\n\t// so that diffuse, media white is 203 cd/m\u00B2\n\tid: \"xyz-abs-d65\",\n\tcssId: \"--xyz-abs-d65\",\n\tname: \"Absolute XYZ D65\",\n\tcoords: {\n\t\tx: {\n\t\t\trefRange: [0, 9504.7],\n\t\t\tname: \"Xa\",\n\t\t},\n\t\ty: {\n\t\t\trefRange: [0, 10000],\n\t\t\tname: \"Ya\",\n\t\t},\n\t\tz: {\n\t\t\trefRange: [0, 10888.3],\n\t\t\tname: \"Za\",\n\t\t},\n\t},\n\n\tbase: XYZ_D65,\n\tfromBase (XYZ) {\n\t\t// Make XYZ absolute, not relative to media white\n\t\t// Maximum luminance in PQ is 10,000 cd/m\u00B2\n\t\t// Relative XYZ has Y=1 for media white\n\t\treturn XYZ.map(v => v * Yw);\n\t},\n\ttoBase (AbsXYZ) {\n\t\t// Convert to media-white relative XYZ\n\t\treturn AbsXYZ.map(v => v / Yw);\n\t},\n});\n", "import ColorSpace from \"../ColorSpace.js\";\nimport { multiply_v3_m3x3 } from \"../util.js\";\nimport XYZ_Abs_D65 from \"./xyz-abs-d65.js\";\nimport { spow } from \"../util.js\";\n\n/** @import { Matrix3x3, Vector3 } from \"../types.js\" */\n\nconst b = 1.15;\nconst g = 0.66;\nconst n = 2610 / 2 ** 14;\nconst ninv = 2 ** 14 / 2610;\nconst c1 = 3424 / 2 ** 12;\nconst c2 = 2413 / 2 ** 7;\nconst c3 = 2392 / 2 ** 7;\nconst p = (1.7 * 2523) / 2 ** 5;\nconst pinv = 2 ** 5 / (1.7 * 2523);\nconst d = -0.56;\nconst d0 = 1.6295499532821566e-11;\n\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst XYZtoCone_M = [\n\t[ 0.41478972, 0.579999, 0.0146480 ],\n\t[ -0.2015100, 1.120649, 0.0531008 ],\n\t[ -0.0166008, 0.264800, 0.6684799 ],\n];\n// XYZtoCone_M inverted\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst ConetoXYZ_M = [\n\t[ 1.9242264357876067, -1.0047923125953657, 0.037651404030618 ],\n\t[ 0.35031676209499907, 0.7264811939316552, -0.06538442294808501 ],\n\t[ -0.09098281098284752, -0.3127282905230739, 1.5227665613052603 ],\n];\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst ConetoIab_M = [\n\t[ 0.5, 0.5, 0 ],\n\t[ 3.524000, -4.066708, 0.542708 ],\n\t[ 0.199076, 1.096799, -1.295875 ],\n];\n// ConetoIab_M inverted\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst IabtoCone_M = [\n\t[ 1, 0.13860504327153927, 0.05804731615611883 ],\n\t[ 1, -0.1386050432715393, -0.058047316156118904 ],\n\t[ 1, -0.09601924202631895, -0.81189189605603900 ],\n];\n\nexport default new ColorSpace({\n\tid: \"jzazbz\",\n\tname: \"Jzazbz\",\n\tcoords: {\n\t\tjz: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"Jz\",\n\t\t},\n\t\taz: {\n\t\t\trefRange: [-0.21, 0.21],\n\t\t},\n\t\tbz: {\n\t\t\trefRange: [-0.21, 0.21],\n\t\t},\n\t},\n\n\tbase: XYZ_Abs_D65,\n\tfromBase (XYZ) {\n\t\t// First make XYZ absolute, not relative to media white\n\t\t// Maximum luminance in PQ is 10,000 cd/m\u00B2\n\t\t// Relative XYZ has Y=1 for media white\n\t\t// BT.2048 says media white Y=203 at PQ 58\n\n\t\tlet [Xa, Ya, Za] = XYZ;\n\n\t\t// modify X and Y to minimize blue curvature\n\t\tlet Xm = b * Xa - (b - 1) * Za;\n\t\tlet Ym = g * Ya - (g - 1) * Xa;\n\n\t\t// move to LMS cone domain\n\t\tlet LMS = multiply_v3_m3x3([Xm, Ym, Za], XYZtoCone_M);\n\n\t\t// PQ-encode LMS\n\t\tlet PQLMS = /** @type {Vector3} } */ (\n\t\t\tLMS.map(function (val) {\n\t\t\t\tlet num = c1 + c2 * spow(val / 10000, n);\n\t\t\t\tlet denom = 1 + c3 * spow(val / 10000, n);\n\n\t\t\t\treturn spow(num / denom, p);\n\t\t\t})\n\t\t);\n\n\t\t// almost there, calculate Iz az bz\n\t\tlet [Iz, az, bz] = multiply_v3_m3x3(PQLMS, ConetoIab_M);\n\t\t// console.log({Iz, az, bz});\n\n\t\tlet Jz = ((1 + d) * Iz) / (1 + d * Iz) - d0;\n\t\treturn [Jz, az, bz];\n\t},\n\ttoBase (Jzazbz) {\n\t\tlet [Jz, az, bz] = Jzazbz;\n\t\tlet Iz = (Jz + d0) / (1 + d - d * (Jz + d0));\n\n\t\t// bring into LMS cone domain\n\t\tlet PQLMS = multiply_v3_m3x3([Iz, az, bz], IabtoCone_M);\n\n\t\t// convert from PQ-coded to linear-light\n\t\tlet LMS = /** @type {Vector3} } */ (\n\t\t\tPQLMS.map(function (val) {\n\t\t\t\tlet num = c1 - spow(val, pinv);\n\t\t\t\tlet denom = c3 * spow(val, pinv) - c2;\n\t\t\t\tlet x = 10000 * spow(num / denom, ninv);\n\n\t\t\t\treturn x; // luminance relative to diffuse white, [0, 70 or so].\n\t\t\t})\n\t\t);\n\n\t\t// modified abs XYZ\n\t\tlet [Xm, Ym, Za] = multiply_v3_m3x3(LMS, ConetoXYZ_M);\n\n\t\t// un-modify X and Y to get D65 XYZ, relative to media white\n\t\tlet Xa = (Xm + (b - 1) * Za) / b;\n\t\tlet Ya = (Ym + (g - 1) * Xa) / g;\n\t\treturn [Xa, Ya, Za];\n\t},\n\n\tformats: {\n\t\t// https://drafts.csswg.org/css-color-hdr/#Jzazbz\n\t\tjzazbz: {\n\t\t\tcoords: [\n\t\t\t\t\"<percentage> | <number>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t],\n\t\t},\n\t},\n});\n", "import ColorSpace from \"../ColorSpace.js\";\nimport Jzazbz from \"./jzazbz.js\";\nimport lch from \"./lch.js\";\n\nexport default new ColorSpace({\n\tid: \"jzczhz\",\n\tname: \"JzCzHz\",\n\tcoords: {\n\t\tjz: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"Jz\",\n\t\t},\n\t\tcz: {\n\t\t\trefRange: [0, 0.26],\n\t\t\tname: \"Chroma\",\n\t\t},\n\t\thz: {\n\t\t\trefRange: [0, 360],\n\t\t\ttype: \"angle\",\n\t\t\tname: \"Hue\",\n\t\t},\n\t},\n\n\tbase: Jzazbz,\n\tfromBase: lch.fromBase,\n\ttoBase: lch.toBase,\n\n\tformats: {\n\t\t// https://drafts.csswg.org/css-color-hdr/#JzCzhz\n\t\tjzczhz: {\n\t\t\tcoords: [\"<percentage> | <number>\", \"<number> | <percentage>\", \"<number> | <angle>\"],\n\t\t},\n\t},\n});\n", "import jzczhz from \"../spaces/jzczhz.js\";\nimport getColor from \"../getColor.js\";\nimport { isNone } from \"../util.js\";\n\n/**\n * More accurate color-difference formulae\n * than the simple 1976 Euclidean distance in Lab\n *\n * Uses JzCzHz, which has improved perceptual uniformity\n * and thus a simple Euclidean root-sum of \u0394L\u00B2 \u0394C\u00B2 \u0394H\u00B2\n * gives good results.\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @returns {number}\n */\nexport default function (color, sample) {\n\t[color, sample] = getColor([color, sample]);\n\n\t// Given this color as the reference\n\t// and a sample,\n\t// calculate deltaE in JzCzHz.\n\tlet [Jz1, Cz1, Hz1] = jzczhz.from(color);\n\tlet [Jz2, Cz2, Hz2] = jzczhz.from(sample);\n\n\t// Lightness and Chroma differences\n\t// sign does not matter as they are squared.\n\tlet \u0394J = Jz1 - Jz2;\n\tlet \u0394C = Cz1 - Cz2;\n\n\t// length of chord for \u0394H\n\tif (isNone(Hz1) && isNone(Hz2)) {\n\t\t// both undefined hues\n\t\tHz1 = 0;\n\t\tHz2 = 0;\n\t}\n\telse if (isNone(Hz1)) {\n\t\t// one undefined, set to the defined hue\n\t\tHz1 = Hz2;\n\t}\n\telse if (isNone(Hz2)) {\n\t\tHz2 = Hz1;\n\t}\n\n\tlet \u0394h = Hz1 - Hz2;\n\tlet \u0394H = 2 * Math.sqrt(Cz1 * Cz2) * Math.sin((\u0394h / 2) * (Math.PI / 180));\n\n\treturn Math.sqrt(\u0394J ** 2 + \u0394C ** 2 + \u0394H ** 2);\n}\n", "import ColorSpace from \"../ColorSpace.js\";\nimport { multiply_v3_m3x3 } from \"../util.js\";\nimport XYZ_Abs_D65 from \"./xyz-abs-d65.js\";\n\n/** @import { Matrix3x3, Vector3 } from \"../types.js\" */\n\nconst c1 = 3424 / 4096;\nconst c2 = 2413 / 128;\nconst c3 = 2392 / 128;\nconst m1 = 2610 / 16384;\nconst m2 = 2523 / 32;\nconst im1 = 16384 / 2610;\nconst im2 = 32 / 2523;\n\n// The matrix below includes the 4% crosstalk components\n// and is from the Dolby \"What is ICtCp\" paper\"\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst XYZtoLMS_M = [\n\t[ 0.3592832590121217, 0.6976051147779502, -0.0358915932320290 ],\n\t[ -0.1920808463704993, 1.1004767970374321, 0.0753748658519118 ],\n\t[ 0.0070797844607479, 0.0748396662186362, 0.8433265453898765 ],\n];\n// linear-light Rec.2020 to LMS, again with crosstalk\n// rational terms from Jan Fr\u00F6hlich,\n// Encoding High Dynamic Range andWide Color Gamut Imagery, p.97\n// and ITU-R BT.2124-0 p.2\n/*\nconst Rec2020toLMS_M = [\n\t[ 1688 / 4096, 2146 / 4096, 262 / 4096 ],\n\t[ 683 / 4096, 2951 / 4096, 462 / 4096 ],\n\t[ 99 / 4096, 309 / 4096, 3688 / 4096 ]\n];\n*/\n// this includes the Ebner LMS coefficients,\n// the rotation, and the scaling to [-0.5,0.5] range\n// rational terms from Fr\u00F6hlich p.97\n// and ITU-R BT.2124-0 pp.2-3\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst LMStoIPT_M = [\n\t[ 2048 / 4096, 2048 / 4096, 0 ],\n\t[ 6610 / 4096, -13613 / 4096, 7003 / 4096 ],\n\t[ 17933 / 4096, -17390 / 4096, -543 / 4096 ],\n];\n\n// inverted matrices, calculated from the above\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst IPTtoLMS_M = [\n\t[ 0.9999999999999998, 0.0086090370379328, 0.1110296250030260 ],\n\t[ 0.9999999999999998, -0.0086090370379328, -0.1110296250030259 ],\n\t[ 0.9999999999999998, 0.5600313357106791, -0.3206271749873188 ],\n];\n/*\n// prettier-ignore\nconst LMStoRec2020_M = [\n\t[ 3.4375568932814012112, -2.5072112125095058195, 0.069654319228104608382],\n\t[-0.79142868665644156125, 1.9838372198740089874, -0.19240853321756742626 ],\n\t[-0.025646662911506476363, -0.099240248643945566751, 1.1248869115554520431 ]\n];\n*/\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst LMStoXYZ_M = [\n\t[ 2.0701522183894223, -1.3263473389671563, 0.2066510476294053 ],\n\t[ 0.3647385209748072, 0.6805660249472273, -0.0453045459220347 ],\n\t[ -0.0497472075358123, -0.0492609666966131, 1.1880659249923042 ],\n];\n\n// Only the PQ form of ICtCp is implemented here. There is also an HLG form.\n// from Dolby, \"WHAT IS ICTCP?\"\n// https://professional.dolby.com/siteassets/pdfs/ictcp_dolbywhitepaper_v071.pdf\n// and\n// Dolby, \"Perceptual Color Volume\n// Measuring the Distinguishable Colors of HDR and WCG Displays\"\n// https://professional.dolby.com/siteassets/pdfs/dolby-vision-measuring-perceptual-color-volume-v7.1.pdf\nexport default new ColorSpace({\n\tid: \"ictcp\",\n\tname: \"ICTCP\",\n\t// From BT.2100-2 page 7:\n\t// During production, signal values are expected to exceed the\n\t// range E\u2032 = [0.0 : 1.0]. This provides processing headroom and avoids\n\t// signal degradation during cascaded processing. Such values of E\u2032,\n\t// below 0.0 or exceeding 1.0, should not be clipped during production\n\t// and exchange.\n\t// Values below 0.0 should not be clipped in reference displays (even\n\t// though they represent \u201Cnegative\u201D light) to allow the black level of\n\t// the signal (LB) to be properly set using test signals known as \u201CPLUGE\u201D\n\tcoords: {\n\t\ti: {\n\t\t\trefRange: [0, 1], // Constant luminance,\n\t\t\tname: \"I\",\n\t\t},\n\t\tct: {\n\t\t\trefRange: [-0.5, 0.5], // Full BT.2020 gamut in range [-0.5, 0.5]\n\t\t\tname: \"CT\",\n\t\t},\n\t\tcp: {\n\t\t\trefRange: [-0.5, 0.5],\n\t\t\tname: \"CP\",\n\t\t},\n\t},\n\n\tbase: XYZ_Abs_D65,\n\tfromBase (XYZ) {\n\t\t// move to LMS cone domain\n\t\tlet LMS = multiply_v3_m3x3(XYZ, XYZtoLMS_M);\n\n\t\treturn LMStoICtCp(LMS);\n\t},\n\ttoBase (ICtCp) {\n\t\tlet LMS = ICtCptoLMS(ICtCp);\n\n\t\treturn multiply_v3_m3x3(LMS, LMStoXYZ_M);\n\t},\n\n\tformats: {\n\t\tictcp: {\n\t\t\tcoords: [\n\t\t\t\t\"<percentage> | <number>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t],\n\t\t},\n\t},\n});\n\n/**\n *\n * @param {Vector3} LMS\n * @returns {Vector3}\n */\nfunction LMStoICtCp (LMS) {\n\t// apply the PQ EOTF\n\t// we can't ever be dividing by zero because of the \"1 +\" in the denominator\n\tlet PQLMS = /** @type {Vector3} */ (\n\t\tLMS.map(function (val) {\n\t\t\tlet num = c1 + c2 * (val / 10000) ** m1;\n\t\t\tlet denom = 1 + c3 * (val / 10000) ** m1;\n\n\t\t\treturn (num / denom) ** m2;\n\t\t})\n\t);\n\n\t// LMS to IPT, with rotation for Y'C'bC'r compatibility\n\treturn multiply_v3_m3x3(PQLMS, LMStoIPT_M);\n}\n\n/**\n *\n * @param {Vector3} ICtCp\n * @returns {Vector3}\n */\nfunction ICtCptoLMS (ICtCp) {\n\tlet PQLMS = multiply_v3_m3x3(ICtCp, IPTtoLMS_M);\n\n\t// From BT.2124-0 Annex 2 Conversion 3\n\tlet LMS = /** @type {Vector3} */ (\n\t\tPQLMS.map(function (val) {\n\t\t\tlet num = Math.max(val ** im2 - c1, 0);\n\t\t\tlet denom = c2 - c3 * val ** im2;\n\t\t\treturn 10000 * (num / denom) ** im1;\n\t\t})\n\t);\n\n\treturn LMS;\n}\n", "import ictcp from \"../spaces/ictcp.js\";\nimport getColor from \"../getColor.js\";\n\n/**\n * Delta E in ICtCp space,\n * which the ITU calls Delta E ITP, which is shorter.\n * Formulae from ITU Rec. ITU-R BT.2124-0\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @returns {number}\n */\nexport default function (color, sample) {\n\t[color, sample] = getColor([color, sample]);\n\n\t// Given this color as the reference\n\t// and a sample,\n\t// calculate deltaE in ICtCp\n\t// which is simply the Euclidean distance\n\n\tlet [I1, T1, P1] = ictcp.from(color);\n\tlet [I2, T2, P2] = ictcp.from(sample);\n\n\t// the 0.25 factor is to undo the encoding scaling in Ct\n\t// the 720 is so that 1 deltaE = 1 JND\n\t// per ITU-R BT.2124-0 p.3\n\n\treturn 720 * Math.sqrt((I1 - I2) ** 2 + 0.25 * (T1 - T2) ** 2 + (P1 - P2) ** 2);\n}\n", "import oklab from \"../spaces/oklab.js\";\nimport getColor from \"../getColor.js\";\n\n/**\n * More accurate color-difference formulae\n * than the simple 1976 Euclidean distance in CIE Lab\n * The Oklab a and b axes are scaled relative to the L axis, for better uniformity\n * Bj\u00F6rn Ottosson said:\n * \"I've recently done some tests with color distance datasets as implemented\n * in Colorio and on both the Combvd dataset and the OSA-UCS dataset a\n * scale factor of slightly more than 2 for a and b would give the best results\n * (2.016 works best for Combvd and 2.045 for the OSA-UCS dataset).\"\n * @see {@link <https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-945714988>}\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @returns {number}\n */\nexport default function (color, sample) {\n\t[color, sample] = getColor([color, sample]);\n\n\t// Given this color as the reference\n\t// and a sample,\n\t// calculate deltaEOK2, term by term as root sum of squares\n\tlet abscale = 2;\n\tlet [L1, a1, b1] = oklab.from(color);\n\tlet [L2, a2, b2] = oklab.from(sample);\n\tlet \u0394L = L1 - L2;\n\tlet \u0394a = abscale * (a1 - a2);\n\tlet \u0394b = abscale * (b1 - b2);\n\treturn Math.sqrt(\u0394L ** 2 + \u0394a ** 2 + \u0394b ** 2);\n}\n", "import ColorSpace from \"../ColorSpace.js\";\nimport { multiply_v3_m3x3, interpolate, copySign, spow, zdiv, bisectLeft } from \"../util.js\";\nimport { constrain } from \"../angles.js\";\nimport xyz_d65 from \"./xyz-d65.js\";\nimport { WHITES } from \"../adapt.js\";\n\n/** @import { Coords, Matrix3x3, Vector3 } from \"../types.js\" */\n\n// Type re-exports\n/** @typedef {import(\"../types.js\").Cam16Object} Cam16Object */\n/** @typedef {import(\"../types.js\").Cam16Input} Cam16Input */\n/** @typedef {import(\"../types.js\").Cam16Environment} Cam16Environment */\n\nconst white = WHITES.D65;\nconst adaptedCoef = 0.42;\nconst adaptedCoefInv = 1 / adaptedCoef;\nconst tau = 2 * Math.PI;\n\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst cat16 = [\n\t[ 0.401288, 0.650173, -0.051461 ],\n\t[ -0.250268, 1.204414, 0.045854 ],\n\t[ -0.002079, 0.048952, 0.953127 ],\n];\n\n/** @type {Matrix3x3} */\nconst cat16Inv = [\n\t[1.8620678550872327, -1.0112546305316843, 0.14918677544445175],\n\t[0.38752654323613717, 0.6214474419314753, -0.008973985167612518],\n\t[-0.015841498849333856, -0.03412293802851557, 1.0499644368778496],\n];\n\n/** @type {Matrix3x3} */\nconst m1 = [\n\t[460.0, 451.0, 288.0],\n\t[460.0, -891.0, -261.0],\n\t[460.0, -220.0, -6300.0],\n];\n\nconst surroundMap = {\n\tdark: [0.8, 0.525, 0.8],\n\tdim: [0.9, 0.59, 0.9],\n\taverage: [1, 0.69, 1],\n};\n\nconst hueQuadMap = {\n\t// Red, Yellow, Green, Blue, Red\n\th: [20.14, 90.0, 164.25, 237.53, 380.14],\n\te: [0.8, 0.7, 1.0, 1.2, 0.8],\n\tH: [0.0, 100.0, 200.0, 300.0, 400.0],\n};\n\nconst rad2deg = 180 / Math.PI;\nconst deg2rad = Math.PI / 180;\n\n/**\n * @param {Coords} coords\n * @param {number} fl\n * @returns {[number, number, number]}\n */\nexport function adapt (coords, fl) {\n\tconst temp = /** @type {[number, number, number]} */ (\n\t\tcoords.map(c => {\n\t\t\tconst x = spow(fl * Math.abs(c) * 0.01, adaptedCoef);\n\t\t\treturn (400 * copySign(x, c)) / (x + 27.13);\n\t\t})\n\t);\n\treturn temp;\n}\n\n/**\n * @param {Coords} adapted\n * @param {number} fl\n * @returns {[number, number, number]}\n */\nexport function unadapt (adapted, fl) {\n\tconst constant = (100 / fl) * 27.13 ** adaptedCoefInv;\n\treturn /** @type {[number, number, number]} */ (\n\t\tadapted.map(c => {\n\t\t\tconst cabs = Math.abs(c);\n\t\t\treturn copySign(constant * spow(cabs / (400 - cabs), adaptedCoefInv), c);\n\t\t})\n\t);\n}\n\n/**\n * @param {number} h\n */\nexport function hueQuadrature (h) {\n\tlet hp = constrain(h);\n\tif (hp <= hueQuadMap.h[0]) {\n\t\thp += 360;\n\t}\n\n\tconst i = bisectLeft(hueQuadMap.h, hp) - 1;\n\tconst [hi, hii] = hueQuadMap.h.slice(i, i + 2);\n\tconst [ei, eii] = hueQuadMap.e.slice(i, i + 2);\n\tconst Hi = hueQuadMap.H[i];\n\n\tconst t = (hp - hi) / ei;\n\treturn Hi + (100 * t) / (t + (hii - hp) / eii);\n}\n\n/**\n * @param {number} H\n */\nexport function invHueQuadrature (H) {\n\tlet Hp = ((H % 400) + 400) % 400;\n\tconst i = Math.floor(0.01 * Hp);\n\tHp = Hp % 100;\n\tconst [hi, hii] = hueQuadMap.h.slice(i, i + 2);\n\tconst [ei, eii] = hueQuadMap.e.slice(i, i + 2);\n\n\treturn constrain((Hp * (eii * hi - ei * hii) - 100 * hi * eii) / (Hp * (eii - ei) - 100 * eii));\n}\n\n/**\n * @param {[number, number, number]} refWhite\n * @param {number} adaptingLuminance\n * @param {number} backgroundLuminance\n * @param {keyof typeof surroundMap} surround\n * @param {boolean} discounting\n * @returns {Cam16Environment}\n */\nexport function environment (\n\trefWhite,\n\tadaptingLuminance,\n\tbackgroundLuminance,\n\tsurround,\n\tdiscounting,\n) {\n\tconst env = {};\n\n\tenv.discounting = discounting;\n\tenv.refWhite = refWhite;\n\tenv.surround = surround;\n\tconst xyzW = /** @type {Vector3} */ (\n\t\trefWhite.map(c => {\n\t\t\treturn c * 100;\n\t\t})\n\t);\n\n\t// The average luminance of the environment in `cd/m^2cd/m` (a.k.a. nits)\n\tenv.la = adaptingLuminance;\n\t// The relative luminance of the nearby background\n\tenv.yb = backgroundLuminance;\n\t// Absolute luminance of the reference white.\n\tconst yw = xyzW[1];\n\n\t// Cone response for reference white\n\tconst rgbW = multiply_v3_m3x3(xyzW, cat16);\n\n\t// Surround: dark, dim, and average\n\tlet values = surroundMap[env.surround];\n\tconst f = values[0];\n\tenv.c = values[1];\n\tenv.nc = values[2];\n\n\tconst k = 1 / (5 * env.la + 1);\n\tconst k4 = k ** 4;\n\n\t// Factor of luminance level adaptation\n\tenv.fl = k4 * env.la + 0.1 * (1 - k4) * (1 - k4) * Math.cbrt(5 * env.la);\n\tenv.flRoot = env.fl ** 0.25;\n\n\tenv.n = env.yb / yw;\n\tenv.z = 1.48 + Math.sqrt(env.n);\n\tenv.nbb = 0.725 * env.n ** -0.2;\n\tenv.ncb = env.nbb;\n\n\t// Degree of adaptation calculating if not discounting\n\t// illuminant (assumed eye is fully adapted)\n\tconst d = discounting\n\t\t? 1\n\t\t: Math.max(Math.min(f * (1 - (1 / 3.6) * Math.exp((-env.la - 42) / 92)), 1), 0);\n\tenv.dRgb = /** @type {[number, number, number]} */ (\n\t\trgbW.map(c => {\n\t\t\treturn interpolate(1, yw / c, d);\n\t\t})\n\t);\n\tenv.dRgbInv = /** @type {[number, number, number]} */ (\n\t\tenv.dRgb.map(c => {\n\t\t\treturn 1 / c;\n\t\t})\n\t);\n\n\t// Achromatic response\n\tconst rgbCW = /** @type {[number, number, number]} */ (\n\t\trgbW.map((c, i) => {\n\t\t\treturn c * env.dRgb[i];\n\t\t})\n\t);\n\tconst rgbAW = adapt(rgbCW, env.fl);\n\tenv.aW = env.nbb * (2 * rgbAW[0] + rgbAW[1] + 0.05 * rgbAW[2]);\n\n\t// console.log(env);\n\n\treturn env;\n}\n\n// Pre-calculate everything we can with the viewing conditions\nconst viewingConditions = environment(white, (64 / Math.PI) * 0.2, 20, \"average\", false);\n\n/**\n * @param {Cam16Input} cam16\n * @param {Cam16Environment} env\n * @returns {[number, number, number]}\n */\nexport function fromCam16 (cam16, env) {\n\t// These check ensure one, and only one attribute for a\n\t// given category is provided.\n\t// @ts-expect-error The '^` operator is not allowed for boolean types\n\tif (!((cam16.J !== undefined) ^ (cam16.Q !== undefined))) {\n\t\tthrow new Error(\"Conversion requires one and only one: 'J' or 'Q'\");\n\t}\n\n\t// @ts-expect-error - The '^` operator is not allowed for boolean types\n\tif (!((cam16.C !== undefined) ^ (cam16.M !== undefined) ^ (cam16.s !== undefined))) {\n\t\tthrow new Error(\"Conversion requires one and only one: 'C', 'M' or 's'\");\n\t}\n\n\t// Hue is absolutely required\n\t// @ts-expect-error - The '^` operator is not allowed for boolean types\n\tif (!((cam16.h !== undefined) ^ (cam16.H !== undefined))) {\n\t\tthrow new Error(\"Conversion requires one and only one: 'h' or 'H'\");\n\t}\n\n\t// Black\n\tif (cam16.J === 0.0 || cam16.Q === 0.0) {\n\t\treturn [0.0, 0.0, 0.0];\n\t}\n\n\t// Break hue into Cartesian components\n\tlet hRad = 0.0;\n\tif (cam16.h !== undefined) {\n\t\thRad = constrain(cam16.h) * deg2rad;\n\t}\n\telse {\n\t\thRad = invHueQuadrature(cam16.H) * deg2rad;\n\t}\n\n\tconst cosh = Math.cos(hRad);\n\tconst sinh = Math.sin(hRad);\n\n\t// Calculate `Jroot` from one of the lightness derived coordinates.\n\tlet Jroot = 0.0;\n\tif (cam16.J !== undefined) {\n\t\tJroot = spow(cam16.J, 1 / 2) * 0.1;\n\t}\n\telse if (cam16.Q !== undefined) {\n\t\tJroot = (0.25 * env.c * cam16.Q) / ((env.aW + 4) * env.flRoot);\n\t}\n\n\t// Calculate the `t` value from one of the chroma derived coordinates\n\tlet alpha = 0.0;\n\tif (cam16.C !== undefined) {\n\t\talpha = cam16.C / Jroot;\n\t}\n\telse if (cam16.M !== undefined) {\n\t\talpha = cam16.M / env.flRoot / Jroot;\n\t}\n\telse if (cam16.s !== undefined) {\n\t\talpha = (0.0004 * cam16.s ** 2 * (env.aW + 4)) / env.c;\n\t}\n\tconst t = spow(alpha * Math.pow(1.64 - Math.pow(0.29, env.n), -0.73), 10 / 9);\n\n\t// Eccentricity\n\tconst et = 0.25 * (Math.cos(hRad + 2) + 3.8);\n\n\t// Achromatic response\n\tconst A = env.aW * spow(Jroot, 2 / env.c / env.z);\n\n\t// Calculate red-green and yellow-blue components\n\tconst p1 = (5e4 / 13) * env.nc * env.ncb * et;\n\tconst p2 = A / env.nbb;\n\tconst r = 23 * (p2 + 0.305) * zdiv(t, 23 * p1 + t * (11 * cosh + 108 * sinh));\n\tconst a = r * cosh;\n\tconst b = r * sinh;\n\n\t// Calculate back from cone response to XYZ\n\tconst rgb_c = unadapt(\n\t\t/** @type {Vector3} */\n\t\t(\n\t\t\tmultiply_v3_m3x3([p2, a, b], m1).map(c => {\n\t\t\t\treturn (c * 1) / 1403;\n\t\t\t})\n\t\t),\n\t\tenv.fl,\n\t);\n\treturn /** @type {Vector3} */ (\n\t\tmultiply_v3_m3x3(\n\t\t\t/** @type {Vector3} */ (\n\t\t\t\trgb_c.map((c, i) => {\n\t\t\t\t\treturn c * env.dRgbInv[i];\n\t\t\t\t})\n\t\t\t),\n\t\t\tcat16Inv,\n\t\t).map(c => {\n\t\t\treturn c / 100;\n\t\t})\n\t);\n}\n\n/**\n * @param {[number, number, number]} xyzd65\n * @param {Cam16Environment} env\n * @returns {Cam16Object}\n */\nexport function toCam16 (xyzd65, env) {\n\t// Cone response\n\tconst xyz100 = /** @type {Vector3} */ (\n\t\txyzd65.map(c => {\n\t\t\treturn c * 100;\n\t\t})\n\t);\n\tconst rgbA = adapt(\n\t\t/** @type {[number, number, number]} */\n\t\t(\n\t\t\tmultiply_v3_m3x3(xyz100, cat16).map((c, i) => {\n\t\t\t\treturn c * env.dRgb[i];\n\t\t\t})\n\t\t),\n\t\tenv.fl,\n\t);\n\n\t// Calculate hue from red-green and yellow-blue components\n\tconst a = rgbA[0] + (-12 * rgbA[1] + rgbA[2]) / 11;\n\tconst b = (rgbA[0] + rgbA[1] - 2 * rgbA[2]) / 9;\n\tconst hRad = ((Math.atan2(b, a) % tau) + tau) % tau;\n\n\t// Eccentricity\n\tconst et = 0.25 * (Math.cos(hRad + 2) + 3.8);\n\n\tconst t =\n\t\t(5e4 / 13) *\n\t\tenv.nc *\n\t\tenv.ncb *\n\t\tzdiv(et * Math.sqrt(a ** 2 + b ** 2), rgbA[0] + rgbA[1] + 1.05 * rgbA[2] + 0.305);\n\tconst alpha = spow(t, 0.9) * Math.pow(1.64 - Math.pow(0.29, env.n), 0.73);\n\n\t// Achromatic response\n\tconst A = env.nbb * (2 * rgbA[0] + rgbA[1] + 0.05 * rgbA[2]);\n\n\tconst Jroot = spow(A / env.aW, 0.5 * env.c * env.z);\n\n\t// Lightness\n\tconst J = 100 * spow(Jroot, 2);\n\n\t// Brightness\n\tconst Q = (4 / env.c) * Jroot * (env.aW + 4) * env.flRoot;\n\n\t// Chroma\n\tconst C = alpha * Jroot;\n\n\t// Colorfulness\n\tconst M = C * env.flRoot;\n\n\t// Hue\n\tconst h = constrain(hRad * rad2deg);\n\n\t// Hue quadrature\n\tconst H = hueQuadrature(h);\n\n\t// Saturation\n\tconst s = 50 * spow((env.c * alpha) / (env.aW + 4), 1 / 2);\n\n\t// console.log({J: J, C: C, h: h, s: s, Q: Q, M: M, H: H});\n\n\treturn { J: J, C: C, h: h, s: s, Q: Q, M: M, H: H };\n}\n\n// Provided as a way to directly evaluate the CAM16 model\n// https://observablehq.com/@jrus/cam16: reference implementation\n// https://arxiv.org/pdf/1802.06067.pdf: Nico Schl\u00F6mer\n// https://onlinelibrary.wiley.com/doi/pdf/10.1002/col.22324: hue quadrature\n// https://www.researchgate.net/publication/318152296_Comprehensive_color_solutions_CAM16_CAT16_and_CAM16-UCS\n// Results compared against: https://github.com/colour-science/colour\nexport default new ColorSpace({\n\tid: \"cam16-jmh\",\n\tcssId: \"--cam16-jmh\",\n\tname: \"CAM16-JMh\",\n\tcoords: {\n\t\tj: {\n\t\t\trefRange: [0, 100],\n\t\t\tname: \"J\",\n\t\t},\n\t\tm: {\n\t\t\trefRange: [0, 105.0],\n\t\t\tname: \"Colorfulness\",\n\t\t},\n\t\th: {\n\t\t\trefRange: [0, 360],\n\t\t\ttype: \"angle\",\n\t\t\tname: \"Hue\",\n\t\t},\n\t},\n\n\tbase: xyz_d65,\n\n\tfromBase (xyz) {\n\t\t// If another derivation is created, \u03B5 could vary, so we can't hardcode\n\t\tif (this.\u03B5 === undefined) {\n\t\t\tthis.\u03B5 = Object.values(this.coords)[1].refRange[1] / 100000;\n\t\t}\n\t\tconst cam16 = toCam16(xyz, viewingConditions);\n\t\tconst isAchromatic = Math.abs(cam16.M) < this.\u03B5;\n\t\treturn [cam16.J, isAchromatic ? 0 : cam16.M, isAchromatic ? null : cam16.h];\n\t},\n\ttoBase (cam16) {\n\t\treturn fromCam16({ J: cam16[0], M: cam16[1], h: cam16[2] }, viewingConditions);\n\t},\n});\n", "import ColorSpace from \"../ColorSpace.js\";\nimport { constrain } from \"../angles.js\";\nimport xyz_d65 from \"./xyz-d65.js\";\nimport { fromCam16, toCam16, environment } from \"./cam16.js\";\nimport { WHITES } from \"../adapt.js\";\n\nconst white = WHITES.D65;\nconst \u03B5 = 216 / 24389; // 6^3/29^3 == (24/116)^3\nconst \u03BA = 24389 / 27; // 29^3/3^3\n\nfunction toLstar (y) {\n\t// Convert XYZ Y to L*\n\n\tconst fy = y > \u03B5 ? Math.cbrt(y) : (\u03BA * y + 16) / 116;\n\treturn 116.0 * fy - 16.0;\n}\n\nfunction fromLstar (lstar) {\n\t// Convert L* back to XYZ Y\n\n\treturn lstar > 8 ? Math.pow((lstar + 16) / 116, 3) : lstar / \u03BA;\n}\n\nfunction fromHct (coords, env) {\n\t// Use Newton's method to try and converge as quick as possible or\n\t// converge as close as we can. While the requested precision is achieved\n\t// most of the time, it may not always be achievable. Especially past the\n\t// visible spectrum, the algorithm will likely struggle to get the same\n\t// precision. If, for whatever reason, we cannot achieve the accuracy we\n\t// seek in the allotted iterations, just return the closest we were able to\n\t// get.\n\n\tlet [h, c, t] = coords;\n\tlet xyz = [];\n\tlet j = 0;\n\n\t// Shortcut out for black\n\tif (t === 0) {\n\t\treturn [0.0, 0.0, 0.0];\n\t}\n\n\t// Calculate the Y we need to target\n\tlet y = fromLstar(t);\n\n\t// A better initial guess yields better results. Polynomials come from\n\t// curve fitting the T vs J response.\n\tif (t > 0) {\n\t\tj = 0.00379058511492914 * t ** 2 + 0.608983189401032 * t + 0.9155088574762233;\n\t}\n\telse {\n\t\tj = 9.514440756550361e-6 * t ** 2 + 0.08693057439788597 * t - 21.928975842194614;\n\t}\n\n\t// Threshold of how close is close enough, and max number of attempts.\n\t// More precision and more attempts means more time spent iterating. Higher\n\t// required precision gives more accuracy but also increases the chance of\n\t// not hitting the goal. 2e-12 allows us to convert round trip with\n\t// reasonable accuracy of six decimal places or more.\n\tconst threshold = 2e-12;\n\tconst max_attempts = 15;\n\n\tlet attempt = 0;\n\tlet last = Infinity;\n\tlet best = j;\n\n\t// Try to find a J such that the returned y matches the returned y of the L*\n\twhile (attempt <= max_attempts) {\n\t\txyz = fromCam16({ J: j, C: c, h: h }, env);\n\n\t\t// If we are within range, return XYZ\n\t\t// If we are closer than last time, save the values\n\t\tconst delta = Math.abs(xyz[1] - y);\n\t\tif (delta < last) {\n\t\t\tif (delta <= threshold) {\n\t\t\t\treturn xyz;\n\t\t\t}\n\t\t\tbest = j;\n\t\t\tlast = delta;\n\t\t}\n\n\t\t// f(j_root) = (j ** (1 / 2)) * 0.1\n\t\t// f(j) = ((f(j_root) * 100) ** 2) / j - 1 = 0\n\t\t// f(j_root) = Y = y / 100\n\t\t// f(j) = (y ** 2) / j - 1\n\t\t// f'(j) = (2 * y) / j\n\t\tj = j - ((xyz[1] - y) * j) / (2 * xyz[1]);\n\n\t\tattempt += 1;\n\t}\n\n\t// We could not acquire the precision we desired,\n\t// return our closest attempt.\n\treturn fromCam16({ J: j, C: c, h: h }, env);\n}\n\nfunction toHct (xyz, env) {\n\t// Calculate HCT by taking the L* of CIE LCh D65 and CAM16 chroma and hue.\n\n\tconst t = toLstar(xyz[1]);\n\tif (t === 0.0) {\n\t\treturn [0.0, 0.0, 0.0];\n\t}\n\tconst cam16 = toCam16(xyz, viewingConditions);\n\treturn [constrain(cam16.h), cam16.C, t];\n}\n\n// Pre-calculate everything we can with the viewing conditions\nexport const viewingConditions = environment(\n\twhite,\n\t(200 / Math.PI) * fromLstar(50.0),\n\tfromLstar(50.0) * 100,\n\t\"average\",\n\tfalse,\n);\n\n// https://material.io/blog/science-of-color-design\n// This is not a port of the material-color-utilities,\n// but instead implements the full color space as described,\n// combining CAM16 JCh and Lab D65. This does not clamp conversion\n// to HCT to specific chroma bands and provides support for wider\n// gamuts than Google currently supports and does so at a greater\n// precision (> 8 bits back to sRGB).\n// This implementation comes from https://github.com/facelessuser/coloraide\n// which is licensed under MIT.\nexport default new ColorSpace({\n\tid: \"hct\",\n\tname: \"HCT\",\n\tcoords: {\n\t\th: {\n\t\t\trefRange: [0, 360],\n\t\t\ttype: \"angle\",\n\t\t\tname: \"Hue\",\n\t\t},\n\t\tc: {\n\t\t\trefRange: [0, 145],\n\t\t\tname: \"Colorfulness\",\n\t\t},\n\t\tt: {\n\t\t\trefRange: [0, 100],\n\t\t\tname: \"Tone\",\n\t\t},\n\t},\n\n\tbase: xyz_d65,\n\n\tfromBase (xyz) {\n\t\tif (this.\u03B5 === undefined) {\n\t\t\tthis.\u03B5 = Object.values(this.coords)[1].refRange[1] / 100000;\n\t\t}\n\t\tlet hct = toHct(xyz, viewingConditions);\n\t\tif (hct[1] < this.\u03B5) {\n\t\t\thct[1] = 0.0;\n\t\t\thct[0] = null;\n\t\t}\n\t\treturn hct;\n\t},\n\ttoBase (hct) {\n\t\treturn fromHct(hct, viewingConditions);\n\t},\n\tformats: {\n\t\tcolor: {\n\t\t\tid: \"--hct\",\n\t\t\tcoords: [\"<number> | <angle>\", \"<percentage> | <number>\", \"<percentage> | <number>\"],\n\t\t},\n\t},\n});\n", "import hct from \"../spaces/hct.js\";\nimport { viewingConditions } from \"../spaces/hct.js\";\nimport getColor from \"../getColor.js\";\n\n/** @import { Coords } from \"../types.js\" */\n\nconst rad2deg = 180 / Math.PI;\nconst deg2rad = Math.PI / 180;\nconst ucsCoeff = [1.0, 0.007, 0.0228];\n\n/**\n * Convert HCT chroma and hue (CAM16 JMh colorfulness and hue) using UCS logic for a and b.\n * @param {Coords} coords - HCT coordinates.\n * @return {number[]}\n */\nfunction convertUcsAb (coords) {\n\t// We want the distance between the actual color.\n\t// If chroma is negative, it will throw off our calculations.\n\t// Normally, converting back to the base and forward will correct it.\n\t// If we have a negative chroma after this, then we have a color that\n\t// cannot resolve to positive chroma.\n\tif (coords[1] < 0) {\n\t\tcoords = hct.fromBase(hct.toBase(coords));\n\t}\n\n\t// Only in extreme cases (usually outside the visible spectrum)\n\t// can the input value for log become negative.\n\t// Avoid domain error by forcing a zero result via \"max\" if necessary.\n\tconst M =\n\t\tMath.log(Math.max(1 + ucsCoeff[2] * coords[1] * viewingConditions.flRoot, 1.0)) /\n\t\tucsCoeff[2];\n\tconst hrad = coords[0] * deg2rad;\n\tconst a = M * Math.cos(hrad);\n\tconst b = M * Math.sin(hrad);\n\n\treturn [coords[2], a, b];\n}\n\n/**\n * Color distance using HCT.\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @returns {number}\n */\nexport default function (color, sample) {\n\t[color, sample] = getColor([color, sample]);\n\n\tlet [t1, a1, b1] = convertUcsAb(hct.from(color));\n\tlet [t2, a2, b2] = convertUcsAb(hct.from(sample));\n\n\t// Use simple euclidean distance with a and b using UCS conversion\n\t// and LCh lightness (HCT tone).\n\treturn Math.sqrt((t1 - t2) ** 2 + (a1 - a2) ** 2 + (b1 - b2) ** 2);\n}\n", "/**\n * @packageDocumentation\n * This module defines all the builtin deltaE methods.\n */\nimport deltaE76 from \"./deltaE76.js\";\nimport deltaECMC from \"./deltaECMC.js\";\nimport deltaE2000 from \"./deltaE2000.js\";\nimport deltaEJz from \"./deltaEJz.js\";\nimport deltaEITP from \"./deltaEITP.js\";\nimport deltaEOK from \"./deltaEOK.js\";\nimport deltaEOK2 from \"./deltaEOK2.js\";\nimport deltaEHCT from \"./deltaEHCT.js\";\n\nexport { deltaE76, deltaECMC, deltaE2000, deltaEJz, deltaEITP, deltaEOK, deltaEOK2, deltaEHCT };\n\nexport default {\n\tdeltaE76,\n\tdeltaECMC,\n\tdeltaE2000,\n\tdeltaEJz,\n\tdeltaEITP,\n\tdeltaEOK,\n\tdeltaEOK2,\n\tdeltaEHCT,\n};\n\n/** @typedef {keyof typeof import(\"./index.js\").default extends `deltaE${infer Method}` ? Method : string} Methods */\n", "import * as util from \"./util.js\";\nimport ColorSpace from \"./ColorSpace.js\";\nimport defaults from \"./defaults.js\";\nimport deltaE2000 from \"./deltaE/deltaE2000.js\";\nimport deltaEOK from \"./deltaE/deltaEOK.js\";\nimport inGamut from \"./inGamut.js\";\nimport to from \"./to.js\";\nimport get from \"./get.js\";\nimport oklab from \"./spaces/oklab.js\";\nimport set from \"./set.js\";\nimport clone from \"./clone.js\";\nimport getColor from \"./getColor.js\";\nimport deltaEMethods from \"./deltaE/index.js\";\nimport { WHITES } from \"./adapt.js\";\n\n/** @import { ColorTypes, PlainColorObject } from \"./types.js\" */\n\n// Type re-exports\n/** @typedef {import(\"./types.js\").ToGamutOptions} ToGamutOptions */\n\n/**\n * Calculate the epsilon to 2 degrees smaller than the specified JND.\n * @param {number} jnd The target \"just noticeable difference\".\n * @returns {number}\n */\nfunction calcEpsilon (jnd) {\n\t// Calculate the epsilon to 2 degrees smaller than the specified JND.\n\n\tconst order = !jnd ? 0 : Math.floor(Math.log10(Math.abs(jnd)));\n\t// Limit to an arbitrary value to ensure value is never too small and causes infinite loops.\n\treturn Math.max(parseFloat(`1e${order - 2}`), 1e-6);\n}\n\nconst GMAPPRESET = {\n\thct: {\n\t\tmethod: \"hct.c\",\n\t\tjnd: 2,\n\t\tdeltaEMethod: \"hct\",\n\t\tblackWhiteClamp: {},\n\t},\n\t\"hct-tonal\": {\n\t\tmethod: \"hct.c\",\n\t\tjnd: 0,\n\t\tdeltaEMethod: \"hct\",\n\t\tblackWhiteClamp: { channel: \"hct.t\", min: 0, max: 100 },\n\t},\n};\n\n/**\n * Force coordinates to be in gamut of a certain color space.\n * Mutates the color it is passed.\n * @overload\n * @param {ColorTypes} color\n * @param {ToGamutOptions} [options]\n * @returns {PlainColorObject}\n */\n/**\n * @overload\n * @param {ColorTypes} color\n * @param {string} [space]\n * @returns {PlainColorObject}\n */\n/**\n * @param {ColorTypes} color\n * @param {string & Partial<ToGamutOptions> | ToGamutOptions} [space]\n * @returns {PlainColorObject}\n */\nexport default function toGamut (\n\tcolor,\n\t{\n\t\tmethod = defaults.gamut_mapping,\n\t\tspace = undefined,\n\t\tdeltaEMethod = \"\",\n\t\tjnd = 2,\n\t\tblackWhiteClamp = undefined,\n\t} = {},\n) {\n\tcolor = getColor(color);\n\n\tif (util.isString(arguments[1])) {\n\t\tspace = arguments[1];\n\t}\n\telse if (!space) {\n\t\tspace = color.space;\n\t}\n\n\tspace = ColorSpace.get(space);\n\n\t// 3 spaces:\n\t// color.space: current color space\n\t// space: space whose gamut we are mapping to\n\t// mapSpace: space with the coord we're reducing\n\n\tif (inGamut(color, space, { epsilon: 0 })) {\n\t\treturn /** @type {PlainColorObject} */ (color);\n\t}\n\n\tlet spaceColor;\n\tif (method === \"css\") {\n\t\tspaceColor = toGamutCSS(color, { space });\n\t}\n\telse {\n\t\tif (method !== \"clip\" && !inGamut(color, space)) {\n\t\t\tif (Object.prototype.hasOwnProperty.call(GMAPPRESET, method)) {\n\t\t\t\t({ method, jnd, deltaEMethod, blackWhiteClamp } = GMAPPRESET[method]);\n\t\t\t}\n\n\t\t\t// Get the correct delta E method\n\t\t\tlet de = deltaE2000;\n\t\t\tif (deltaEMethod !== \"\") {\n\t\t\t\tfor (let m in deltaEMethods) {\n\t\t\t\t\tif (\"deltae\" + deltaEMethod.toLowerCase() === m.toLowerCase()) {\n\t\t\t\t\t\tde = deltaEMethods[m];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (jnd === 0) {\n\t\t\t\tjnd = 1e-16;\n\t\t\t}\n\n\t\t\tlet clipped = toGamut(to(color, space), { method: \"clip\", space });\n\t\t\tif (de(color, clipped) > jnd) {\n\t\t\t\t// Clamp to SDR white and black if required\n\t\t\t\tif (blackWhiteClamp && Object.keys(blackWhiteClamp).length === 3) {\n\t\t\t\t\tlet channelMeta = ColorSpace.resolveCoord(blackWhiteClamp.channel);\n\t\t\t\t\tlet channel = get(to(color, channelMeta.space), channelMeta.id);\n\t\t\t\t\tif (util.isNone(channel)) {\n\t\t\t\t\t\tchannel = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (channel >= blackWhiteClamp.max) {\n\t\t\t\t\t\treturn to({ space: \"xyz-d65\", coords: WHITES[\"D65\"] }, color.space);\n\t\t\t\t\t}\n\t\t\t\t\telse if (channel <= blackWhiteClamp.min) {\n\t\t\t\t\t\treturn to({ space: \"xyz-d65\", coords: [0, 0, 0] }, color.space);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Reduce a coordinate of a certain color space until the color is in gamut\n\t\t\t\tlet coordMeta = ColorSpace.resolveCoord(method);\n\t\t\t\tlet mapSpace = coordMeta.space;\n\t\t\t\tlet coordId = coordMeta.id;\n\n\t\t\t\tlet mappedColor = to(color, mapSpace);\n\t\t\t\t// If we were already in the mapped color space, we need to resolve undefined channels\n\t\t\t\tmappedColor.coords.forEach((c, i) => {\n\t\t\t\t\tif (util.isNone(c)) {\n\t\t\t\t\t\tmappedColor.coords[i] = 0;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tlet bounds = coordMeta.range || coordMeta.refRange;\n\t\t\t\tlet min = bounds[0];\n\t\t\t\tlet \u03B5 = calcEpsilon(jnd);\n\t\t\t\tlet low = min;\n\t\t\t\tlet high = get(mappedColor, coordId);\n\n\t\t\t\twhile (high - low > \u03B5) {\n\t\t\t\t\tlet clipped = clone(mappedColor);\n\t\t\t\t\tclipped = toGamut(clipped, { space, method: \"clip\" });\n\t\t\t\t\tlet deltaE = de(mappedColor, clipped);\n\n\t\t\t\t\tif (deltaE - jnd < \u03B5) {\n\t\t\t\t\t\tlow = get(mappedColor, coordId);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\thigh = get(mappedColor, coordId);\n\t\t\t\t\t}\n\n\t\t\t\t\tset(mappedColor, coordId, (low + high) / 2);\n\t\t\t\t}\n\n\t\t\t\tspaceColor = to(mappedColor, space);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tspaceColor = clipped;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tspaceColor = to(color, space);\n\t\t}\n\n\t\tif (\n\t\t\tmethod === \"clip\" || // Dumb coord clipping\n\t\t\t// finish off smarter gamut mapping with clip to get rid of \u03B5, see #17\n\t\t\t!inGamut(spaceColor, space, { epsilon: 0 })\n\t\t) {\n\t\t\tlet bounds = Object.values(space.coords).map(c => c.range || []);\n\n\t\t\tspaceColor.coords = /** @type {[number, number, number]} */ (\n\t\t\t\tspaceColor.coords.map((c, i) => {\n\t\t\t\t\tlet [min, max] = bounds[i];\n\n\t\t\t\t\tif (min !== undefined) {\n\t\t\t\t\t\tc = Math.max(min, c);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (max !== undefined) {\n\t\t\t\t\t\tc = Math.min(c, max);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn c;\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t}\n\n\tif (space !== color.space) {\n\t\tspaceColor = to(spaceColor, color.space);\n\t}\n\n\tcolor.coords = spaceColor.coords;\n\treturn /** @type {PlainColorObject} */ (color);\n}\n\n/** @type {\"color\"} */\ntoGamut.returns = \"color\";\n\n/**\n * The reference colors to be used if lightness is out of the range 0-1 in the\n * `Oklch` space. These are created in the `Oklab` space, as it is used by the\n * DeltaEOK calculation, so it is guaranteed to be imported.\n * @satisfies {Record<string, ColorTypes>}\n */\nconst COLORS = {\n\tWHITE: { space: oklab, coords: [1, 0, 0], alpha: 1 },\n\tBLACK: { space: oklab, coords: [0, 0, 0], alpha: 1 },\n};\n\n/**\n * Given a color `origin`, returns a new color that is in gamut using\n * the CSS Gamut Mapping Algorithm. If `space` is specified, it will be in gamut\n * in `space`, and returned in `space`. Otherwise, it will be in gamut and\n * returned in the color space of `origin`.\n * @param {ColorTypes} origin\n * @param {{ space?: string | ColorSpace | undefined }} param1\n * @returns {PlainColorObject}\n */\nexport function toGamutCSS (origin, { space } = {}) {\n\tconst JND = 0.02;\n\tconst \u03B5 = 0.0001;\n\n\torigin = getColor(origin);\n\n\tif (!space) {\n\t\tspace = origin.space;\n\t}\n\n\tspace = ColorSpace.get(space);\n\tconst oklchSpace = ColorSpace.get(\"oklch\");\n\n\tif (space.isUnbounded) {\n\t\treturn to(origin, space);\n\t}\n\n\tconst origin_OKLCH = to(origin, oklchSpace);\n\tlet L = origin_OKLCH.coords[0];\n\n\t// return media white or black, if lightness is out of range\n\tif (L >= 1) {\n\t\tconst white = to(COLORS.WHITE, space);\n\t\twhite.alpha = origin.alpha;\n\t\treturn to(white, space);\n\t}\n\tif (L <= 0) {\n\t\tconst black = to(COLORS.BLACK, space);\n\t\tblack.alpha = origin.alpha;\n\t\treturn to(black, space);\n\t}\n\n\tif (inGamut(origin_OKLCH, space, { epsilon: 0 })) {\n\t\treturn to(origin_OKLCH, space);\n\t}\n\n\tfunction clip (_color) {\n\t\tconst destColor = to(_color, space);\n\t\tconst spaceCoords = Object.values(/** @type {ColorSpace} */ (space).coords);\n\t\tdestColor.coords = /** @type {[number, number, number]} */ (\n\t\t\tdestColor.coords.map((coord, index) => {\n\t\t\t\tif (\"range\" in spaceCoords[index]) {\n\t\t\t\t\tconst [min, max] = spaceCoords[index].range;\n\t\t\t\t\treturn util.clamp(min, coord, max);\n\t\t\t\t}\n\t\t\t\treturn coord;\n\t\t\t})\n\t\t);\n\t\treturn destColor;\n\t}\n\tlet min = 0;\n\tlet max = origin_OKLCH.coords[1];\n\tlet min_inGamut = true;\n\tlet current = clone(origin_OKLCH);\n\tlet clipped = clip(current);\n\n\tlet E = deltaEOK(clipped, current);\n\tif (E < JND) {\n\t\treturn clipped;\n\t}\n\n\twhile (max - min > \u03B5) {\n\t\tconst chroma = (min + max) / 2;\n\t\tcurrent.coords[1] = chroma;\n\t\tif (min_inGamut && inGamut(current, space, { epsilon: 0 })) {\n\t\t\tmin = chroma;\n\t\t}\n\t\telse {\n\t\t\tclipped = clip(current);\n\t\t\tE = deltaEOK(clipped, current);\n\t\t\tif (E < JND) {\n\t\t\t\tif (JND - E < \u03B5) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tmin_inGamut = false;\n\t\t\t\t\tmin = chroma;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmax = chroma;\n\t\t\t}\n\t\t}\n\t}\n\treturn clipped;\n}\n", "import getColor from \"./getColor.js\";\nimport ColorSpace from \"./ColorSpace.js\";\nimport toGamut from \"./toGamut.js\";\n\n/** @import { ColorTypes, PlainColorObject, ToGamutOptions } from \"./types.js\" */\n\n/**\n * Convert to color space and return a new color\n * @param {ColorTypes} color\n * @param {string | ColorSpace} space\n * @param {{ inGamut?: boolean | ToGamutOptions | undefined }} options\n * @returns {PlainColorObject}\n */\nexport default function to (color, space, { inGamut } = {}) {\n\tcolor = getColor(color);\n\tspace = ColorSpace.get(space);\n\n\tlet coords = space.from(color);\n\tlet ret = { space, coords, alpha: color.alpha };\n\n\tif (inGamut) {\n\t\tret = toGamut(ret, inGamut === true ? undefined : inGamut);\n\t}\n\n\treturn ret;\n}\n\n/** @type {\"color\"} */\nto.returns = \"color\";\n", "// @ts-nocheck\n\nimport * as util from \"./util.js\";\nimport ColorSpace from \"./ColorSpace.js\";\nimport defaults from \"./defaults.js\";\nimport getColor from \"./getColor.js\";\nimport to from \"./to.js\";\nimport checkInGamut from \"./inGamut.js\";\nimport toGamut from \"./toGamut.js\";\nimport clone from \"./clone.js\";\n\n/** @import { ColorTypes, ParseOptions, PlainColorObject } from \"./types.js\" */\n\n// Type re-exports\n/** @typedef {import(\"./types.js\").SerializeOptions} SerializeOptions */\n\n/**\n * Generic toString() method, outputs a color(spaceId ...coords) function, a functional syntax, or custom formats defined by the color space\n * @param {ColorTypes} color\n * @param {SerializeOptions & Record<string, any>} options\n * @returns {string}\n */\nexport default function serialize (color, options = {}) {\n\tlet {\n\t\tprecision = defaults.precision,\n\t\tformat,\n\t\tinGamut = true,\n\t\tcoords: coordFormat,\n\t\talpha: alphaFormat,\n\t\tcommas,\n\t} = options;\n\tlet ret;\n\n\tlet colorWithMeta = /** @type {PlainColorObject & ParseOptions} */ (getColor(color));\n\n\tlet formatId = format;\n\tlet parseMeta = colorWithMeta.parseMeta;\n\n\tif (parseMeta && !format) {\n\t\tif (parseMeta.format.canSerialize()) {\n\t\t\tformat = parseMeta.format;\n\t\t\tformatId = parseMeta.formatId;\n\t\t}\n\n\t\tcoordFormat ??= parseMeta.types;\n\t\talphaFormat ??= parseMeta.alphaType;\n\t\tcommas ??= parseMeta.commas;\n\t}\n\n\tif (formatId) {\n\t\t// A format is explicitly specified\n\t\tformat = colorWithMeta.space.getFormat(format) ?? ColorSpace.findFormat(formatId);\n\t}\n\n\tif (!format) {\n\t\t// No format specified, or format not found\n\t\tformat = colorWithMeta.space.getFormat(\"default\") ?? ColorSpace.DEFAULT_FORMAT;\n\t\tformatId = format.name;\n\t}\n\n\tif (format && format.space && format.space !== colorWithMeta.space) {\n\t\t// Format specified belongs to a different color space,\n\t\t// need to convert to it first\n\t\tcolorWithMeta = to(colorWithMeta, format.space);\n\t}\n\n\t// The assignment to coords and inGamut needs to stay in the order they are now\n\t// The order of the assignment was changed as a workaround for a bug in Next.js\n\t// See this issue for details: https://github.com/color-js/color.js/issues/260\n\n\tlet coords = colorWithMeta.coords.slice(); // clone so we can manipulate it\n\n\tinGamut ||= format.toGamut;\n\n\tif (inGamut && !checkInGamut(colorWithMeta)) {\n\t\t// FIXME what happens if the color contains none values?\n\t\tcoords = toGamut(clone(colorWithMeta), inGamut === true ? undefined : inGamut).coords;\n\t}\n\n\tif (format.type === \"custom\") {\n\t\tif (format.serialize) {\n\t\t\tret = format.serialize(coords, colorWithMeta.alpha, options);\n\t\t}\n\t\telse {\n\t\t\tthrow new TypeError(\n\t\t\t\t`format ${formatId} can only be used to parse colors, not for serialization`,\n\t\t\t);\n\t\t}\n\t}\n\telse {\n\t\t// Functional syntax\n\t\tlet name = format.name || \"color\";\n\n\t\tlet args = format.serializeCoords(coords, precision, coordFormat);\n\n\t\tif (name === \"color\") {\n\t\t\t// If output is a color() function, add colorspace id as first argument\n\t\t\tlet cssId =\n\t\t\t\tformat.id || format.ids?.[0] || colorWithMeta.space.cssId || colorWithMeta.space.id;\n\t\t\targs.unshift(cssId);\n\t\t}\n\n\t\t// Serialize alpha?\n\t\t/** @type {string | number} */\n\t\tlet alpha = colorWithMeta.alpha;\n\n\t\tif (alphaFormat !== undefined && !(typeof alphaFormat === \"object\")) {\n\t\t\talphaFormat =\n\t\t\t\ttypeof alphaFormat === \"string\" ? { type: alphaFormat } : { include: alphaFormat };\n\t\t}\n\n\t\tlet alphaType = alphaFormat?.type ?? \"<number>\";\n\t\tlet serializeAlpha =\n\t\t\talphaFormat?.include === true ||\n\t\t\tformat.alpha === true ||\n\t\t\t(alphaFormat?.include !== false && format.alpha !== false && alpha < 1);\n\t\tlet strAlpha = \"\";\n\n\t\tcommas ??= format.commas;\n\n\t\tif (serializeAlpha) {\n\t\t\tif (precision !== null) {\n\t\t\t\tlet unit;\n\n\t\t\t\tif (alphaType === \"<percentage>\") {\n\t\t\t\t\tunit = \"%\";\n\t\t\t\t\talpha *= 100;\n\t\t\t\t}\n\n\t\t\t\talpha = util.serializeNumber(alpha, { precision, unit });\n\t\t\t}\n\n\t\t\tstrAlpha = `${commas ? \",\" : \" /\"} ${alpha}`;\n\t\t}\n\n\t\tret = `${name}(${args.join(commas ? \", \" : \" \")}${strAlpha})`;\n\t}\n\n\treturn ret;\n}\n", "import RGBColorSpace from \"../RGBColorSpace.js\";\n\n/** @import { Matrix3x3 } from \"../types.js\" */\n\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst toXYZ_M = [\n\t[0.4865709486482162, 0.26566769316909306, 0.1982172852343625],\n\t[0.2289745640697488, 0.6917385218365064, 0.079286914093745],\n\t[0.0000000000000000, 0.04511338185890264, 1.043944368900976],\n];\n\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst fromXYZ_M = [\n\t[ 2.493496911941425, -0.9313836179191239, -0.40271078445071684],\n\t[-0.8294889695615747, 1.7626640603183463, 0.023624685841943577],\n\t[ 0.03584583024378447, -0.07617238926804182, 0.9568845240076872],\n];\n\nexport default new RGBColorSpace({\n\tid: \"p3-linear\",\n\tcssId: \"display-p3-linear\",\n\tname: \"Linear P3\",\n\twhite: \"D65\",\n\ttoXYZ_M,\n\tfromXYZ_M,\n});\n", "import RGBColorSpace from \"../RGBColorSpace.js\";\n\n/** @import { Matrix3x3 } from \"../types.js\" */\n\n// This is the linear-light version of sRGB\n// as used for example in SVG filters\n// or in Canvas\n\n// This matrix was calculated directly from the RGB and white chromaticities\n// when rounded to 8 decimal places, it agrees completely with the official matrix\n// see https://github.com/w3c/csswg-drafts/issues/5922\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst toXYZ_M = [\n\t[ 0.41239079926595934, 0.357584339383878, 0.1804807884018343 ],\n\t[ 0.21263900587151027, 0.715168678767756, 0.07219231536073371 ],\n\t[ 0.01933081871559182, 0.11919477979462598, 0.9505321522496607 ],\n];\n\n// This matrix is the inverse of the above;\n// again it agrees with the official definition when rounded to 8 decimal places\n/** @type {Matrix3x3} */\n// prettier-ignore\nexport const fromXYZ_M = [\n\t[ 3.2409699419045226, -1.537383177570094, -0.4986107602930034 ],\n\t[ -0.9692436362808796, 1.8759675015077202, 0.04155505740717559 ],\n\t[ 0.05563007969699366, -0.20397695888897652, 1.0569715142428786 ],\n];\n\nexport default new RGBColorSpace({\n\tid: \"srgb-linear\",\n\tname: \"Linear sRGB\",\n\twhite: \"D65\",\n\ttoXYZ_M,\n\tfromXYZ_M,\n});\n", "// To produce: Visit https://www.w3.org/TR/css-color-4/#named-colors\n// and run in the console:\n// copy($$(\"tr\", $(\".named-color-table tbody\")).map(tr => `\"${tr.cells[2].textContent.trim()}\": [${tr.cells[4].textContent.trim().split(/\\s+/).map(c => c === \"0\"? \"0\" : c === \"255\"? \"1\" : c + \" / 255\").join(\", \")}]`).join(\",\\n\"))\n\n/** List of CSS color keywords\n * Note that this does not include currentColor, transparent,\n * or system colors\n *\n * @type {Record<string, [number, number, number]>}\n */\nexport default {\n\taliceblue: [240 / 255, 248 / 255, 1],\n\tantiquewhite: [250 / 255, 235 / 255, 215 / 255],\n\taqua: [0, 1, 1],\n\taquamarine: [127 / 255, 1, 212 / 255],\n\tazure: [240 / 255, 1, 1],\n\tbeige: [245 / 255, 245 / 255, 220 / 255],\n\tbisque: [1, 228 / 255, 196 / 255],\n\tblack: [0, 0, 0],\n\tblanchedalmond: [1, 235 / 255, 205 / 255],\n\tblue: [0, 0, 1],\n\tblueviolet: [138 / 255, 43 / 255, 226 / 255],\n\tbrown: [165 / 255, 42 / 255, 42 / 255],\n\tburlywood: [222 / 255, 184 / 255, 135 / 255],\n\tcadetblue: [95 / 255, 158 / 255, 160 / 255],\n\tchartreuse: [127 / 255, 1, 0],\n\tchocolate: [210 / 255, 105 / 255, 30 / 255],\n\tcoral: [1, 127 / 255, 80 / 255],\n\tcornflowerblue: [100 / 255, 149 / 255, 237 / 255],\n\tcornsilk: [1, 248 / 255, 220 / 255],\n\tcrimson: [220 / 255, 20 / 255, 60 / 255],\n\tcyan: [0, 1, 1],\n\tdarkblue: [0, 0, 139 / 255],\n\tdarkcyan: [0, 139 / 255, 139 / 255],\n\tdarkgoldenrod: [184 / 255, 134 / 255, 11 / 255],\n\tdarkgray: [169 / 255, 169 / 255, 169 / 255],\n\tdarkgreen: [0, 100 / 255, 0],\n\tdarkgrey: [169 / 255, 169 / 255, 169 / 255],\n\tdarkkhaki: [189 / 255, 183 / 255, 107 / 255],\n\tdarkmagenta: [139 / 255, 0, 139 / 255],\n\tdarkolivegreen: [85 / 255, 107 / 255, 47 / 255],\n\tdarkorange: [1, 140 / 255, 0],\n\tdarkorchid: [153 / 255, 50 / 255, 204 / 255],\n\tdarkred: [139 / 255, 0, 0],\n\tdarksalmon: [233 / 255, 150 / 255, 122 / 255],\n\tdarkseagreen: [143 / 255, 188 / 255, 143 / 255],\n\tdarkslateblue: [72 / 255, 61 / 255, 139 / 255],\n\tdarkslategray: [47 / 255, 79 / 255, 79 / 255],\n\tdarkslategrey: [47 / 255, 79 / 255, 79 / 255],\n\tdarkturquoise: [0, 206 / 255, 209 / 255],\n\tdarkviolet: [148 / 255, 0, 211 / 255],\n\tdeeppink: [1, 20 / 255, 147 / 255],\n\tdeepskyblue: [0, 191 / 255, 1],\n\tdimgray: [105 / 255, 105 / 255, 105 / 255],\n\tdimgrey: [105 / 255, 105 / 255, 105 / 255],\n\tdodgerblue: [30 / 255, 144 / 255, 1],\n\tfirebrick: [178 / 255, 34 / 255, 34 / 255],\n\tfloralwhite: [1, 250 / 255, 240 / 255],\n\tforestgreen: [34 / 255, 139 / 255, 34 / 255],\n\tfuchsia: [1, 0, 1],\n\tgainsboro: [220 / 255, 220 / 255, 220 / 255],\n\tghostwhite: [248 / 255, 248 / 255, 1],\n\tgold: [1, 215 / 255, 0],\n\tgoldenrod: [218 / 255, 165 / 255, 32 / 255],\n\tgray: [128 / 255, 128 / 255, 128 / 255],\n\tgreen: [0, 128 / 255, 0],\n\tgreenyellow: [173 / 255, 1, 47 / 255],\n\tgrey: [128 / 255, 128 / 255, 128 / 255],\n\thoneydew: [240 / 255, 1, 240 / 255],\n\thotpink: [1, 105 / 255, 180 / 255],\n\tindianred: [205 / 255, 92 / 255, 92 / 255],\n\tindigo: [75 / 255, 0, 130 / 255],\n\tivory: [1, 1, 240 / 255],\n\tkhaki: [240 / 255, 230 / 255, 140 / 255],\n\tlavender: [230 / 255, 230 / 255, 250 / 255],\n\tlavenderblush: [1, 240 / 255, 245 / 255],\n\tlawngreen: [124 / 255, 252 / 255, 0],\n\tlemonchiffon: [1, 250 / 255, 205 / 255],\n\tlightblue: [173 / 255, 216 / 255, 230 / 255],\n\tlightcoral: [240 / 255, 128 / 255, 128 / 255],\n\tlightcyan: [224 / 255, 1, 1],\n\tlightgoldenrodyellow: [250 / 255, 250 / 255, 210 / 255],\n\tlightgray: [211 / 255, 211 / 255, 211 / 255],\n\tlightgreen: [144 / 255, 238 / 255, 144 / 255],\n\tlightgrey: [211 / 255, 211 / 255, 211 / 255],\n\tlightpink: [1, 182 / 255, 193 / 255],\n\tlightsalmon: [1, 160 / 255, 122 / 255],\n\tlightseagreen: [32 / 255, 178 / 255, 170 / 255],\n\tlightskyblue: [135 / 255, 206 / 255, 250 / 255],\n\tlightslategray: [119 / 255, 136 / 255, 153 / 255],\n\tlightslategrey: [119 / 255, 136 / 255, 153 / 255],\n\tlightsteelblue: [176 / 255, 196 / 255, 222 / 255],\n\tlightyellow: [1, 1, 224 / 255],\n\tlime: [0, 1, 0],\n\tlimegreen: [50 / 255, 205 / 255, 50 / 255],\n\tlinen: [250 / 255, 240 / 255, 230 / 255],\n\tmagenta: [1, 0, 1],\n\tmaroon: [128 / 255, 0, 0],\n\tmediumaquamarine: [102 / 255, 205 / 255, 170 / 255],\n\tmediumblue: [0, 0, 205 / 255],\n\tmediumorchid: [186 / 255, 85 / 255, 211 / 255],\n\tmediumpurple: [147 / 255, 112 / 255, 219 / 255],\n\tmediumseagreen: [60 / 255, 179 / 255, 113 / 255],\n\tmediumslateblue: [123 / 255, 104 / 255, 238 / 255],\n\tmediumspringgreen: [0, 250 / 255, 154 / 255],\n\tmediumturquoise: [72 / 255, 209 / 255, 204 / 255],\n\tmediumvioletred: [199 / 255, 21 / 255, 133 / 255],\n\tmidnightblue: [25 / 255, 25 / 255, 112 / 255],\n\tmintcream: [245 / 255, 1, 250 / 255],\n\tmistyrose: [1, 228 / 255, 225 / 255],\n\tmoccasin: [1, 228 / 255, 181 / 255],\n\tnavajowhite: [1, 222 / 255, 173 / 255],\n\tnavy: [0, 0, 128 / 255],\n\toldlace: [253 / 255, 245 / 255, 230 / 255],\n\tolive: [128 / 255, 128 / 255, 0],\n\tolivedrab: [107 / 255, 142 / 255, 35 / 255],\n\torange: [1, 165 / 255, 0],\n\torangered: [1, 69 / 255, 0],\n\torchid: [218 / 255, 112 / 255, 214 / 255],\n\tpalegoldenrod: [238 / 255, 232 / 255, 170 / 255],\n\tpalegreen: [152 / 255, 251 / 255, 152 / 255],\n\tpaleturquoise: [175 / 255, 238 / 255, 238 / 255],\n\tpalevioletred: [219 / 255, 112 / 255, 147 / 255],\n\tpapayawhip: [1, 239 / 255, 213 / 255],\n\tpeachpuff: [1, 218 / 255, 185 / 255],\n\tperu: [205 / 255, 133 / 255, 63 / 255],\n\tpink: [1, 192 / 255, 203 / 255],\n\tplum: [221 / 255, 160 / 255, 221 / 255],\n\tpowderblue: [176 / 255, 224 / 255, 230 / 255],\n\tpurple: [128 / 255, 0, 128 / 255],\n\trebeccapurple: [102 / 255, 51 / 255, 153 / 255],\n\tred: [1, 0, 0],\n\trosybrown: [188 / 255, 143 / 255, 143 / 255],\n\troyalblue: [65 / 255, 105 / 255, 225 / 255],\n\tsaddlebrown: [139 / 255, 69 / 255, 19 / 255],\n\tsalmon: [250 / 255, 128 / 255, 114 / 255],\n\tsandybrown: [244 / 255, 164 / 255, 96 / 255],\n\tseagreen: [46 / 255, 139 / 255, 87 / 255],\n\tseashell: [1, 245 / 255, 238 / 255],\n\tsienna: [160 / 255, 82 / 255, 45 / 255],\n\tsilver: [192 / 255, 192 / 255, 192 / 255],\n\tskyblue: [135 / 255, 206 / 255, 235 / 255],\n\tslateblue: [106 / 255, 90 / 255, 205 / 255],\n\tslategray: [112 / 255, 128 / 255, 144 / 255],\n\tslategrey: [112 / 255, 128 / 255, 144 / 255],\n\tsnow: [1, 250 / 255, 250 / 255],\n\tspringgreen: [0, 1, 127 / 255],\n\tsteelblue: [70 / 255, 130 / 255, 180 / 255],\n\ttan: [210 / 255, 180 / 255, 140 / 255],\n\tteal: [0, 128 / 255, 128 / 255],\n\tthistle: [216 / 255, 191 / 255, 216 / 255],\n\ttomato: [1, 99 / 255, 71 / 255],\n\tturquoise: [64 / 255, 224 / 255, 208 / 255],\n\tviolet: [238 / 255, 130 / 255, 238 / 255],\n\twheat: [245 / 255, 222 / 255, 179 / 255],\n\twhite: [1, 1, 1],\n\twhitesmoke: [245 / 255, 245 / 255, 245 / 255],\n\tyellow: [1, 1, 0],\n\tyellowgreen: [154 / 255, 205 / 255, 50 / 255],\n};\n", "import RGBColorSpace from \"../RGBColorSpace.js\";\nimport sRGBLinear from \"./srgb-linear.js\";\nimport KEYWORDS from \"../keywords.js\";\n\n/** @import { Coords } from \"../types.js\" */\n\nlet coordGrammar = Array(3).fill(\"<percentage> | <number>[0, 255]\");\nlet coordGrammarNumber = Array(3).fill(\"<number>[0, 255]\");\n\nexport default new RGBColorSpace({\n\tid: \"srgb\",\n\tname: \"sRGB\",\n\tbase: sRGBLinear,\n\tfromBase: rgb => {\n\t\t// convert an array of linear-light sRGB values in the range 0.0-1.0\n\t\t// to gamma corrected form\n\t\t// https://en.wikipedia.org/wiki/SRGB\n\t\treturn rgb.map(val => {\n\t\t\tlet sign = val < 0 ? -1 : 1;\n\t\t\tlet abs = val * sign;\n\n\t\t\tif (abs > 0.0031308) {\n\t\t\t\treturn sign * (1.055 * abs ** (1 / 2.4) - 0.055);\n\t\t\t}\n\n\t\t\treturn 12.92 * val;\n\t\t});\n\t},\n\ttoBase: rgb => {\n\t\t// convert an array of sRGB values in the range 0.0 - 1.0\n\t\t// to linear light (un-companded) form.\n\t\t// https://en.wikipedia.org/wiki/SRGB\n\t\treturn rgb.map(val => {\n\t\t\tlet sign = val < 0 ? -1 : 1;\n\t\t\tlet abs = val * sign;\n\n\t\t\tif (abs <= 0.04045) {\n\t\t\t\treturn val / 12.92;\n\t\t\t}\n\n\t\t\treturn sign * ((abs + 0.055) / 1.055) ** 2.4;\n\t\t});\n\t},\n\tformats: {\n\t\trgb: {\n\t\t\tcoords: coordGrammar,\n\t\t},\n\t\trgb_number: {\n\t\t\tname: \"rgb\",\n\t\t\tcommas: true,\n\t\t\tcoords: coordGrammarNumber,\n\t\t\talpha: false,\n\t\t},\n\t\tcolor: {\n\t\t\t/* use defaults */\n\t\t},\n\t\trgba: {\n\t\t\tcoords: coordGrammar,\n\t\t\tcommas: true,\n\t\t\talpha: true,\n\t\t},\n\t\trgba_number: {\n\t\t\tname: \"rgba\",\n\t\t\tcommas: true,\n\t\t\tcoords: coordGrammarNumber,\n\t\t},\n\t\thex: {\n\t\t\ttype: \"custom\",\n\t\t\ttoGamut: true,\n\t\t\ttest: str => /^#(([a-f0-9]{2}){3,4}|[a-f0-9]{3,4})$/i.test(str),\n\t\t\tparse (str) {\n\t\t\t\tif (str.length <= 5) {\n\t\t\t\t\t// #rgb or #rgba, duplicate digits\n\t\t\t\t\tstr = str.replace(/[a-f0-9]/gi, \"$&$&\");\n\t\t\t\t}\n\n\t\t\t\t/** @type {number[]} */\n\t\t\t\tlet rgba = [];\n\t\t\t\t// @ts-expect-error Type 'void' is not assignable to type 'string'\n\t\t\t\tstr.replace(/[a-f0-9]{2}/gi, component => {\n\t\t\t\t\trgba.push(parseInt(component, 16) / 255);\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\tspaceId: \"srgb\",\n\t\t\t\t\tcoords: /** @type {Coords} */ (rgba.slice(0, 3)),\n\t\t\t\t\talpha: /** @type {number} */ (rgba.slice(3)[0]),\n\t\t\t\t};\n\t\t\t},\n\t\t\tserialize: (\n\t\t\t\tcoords,\n\t\t\t\talpha,\n\t\t\t\t{\n\t\t\t\t\tcollapse = true, // collapse to 3-4 digit hex when possible?\n\t\t\t\t\talpha: alphaFormat,\n\t\t\t\t} = {},\n\t\t\t) => {\n\t\t\t\tif ((alphaFormat !== false && alpha < 1) || alphaFormat === true) {\n\t\t\t\t\tcoords.push(alpha);\n\t\t\t\t}\n\n\t\t\t\tcoords = /** @type {[number, number, number]} */ (\n\t\t\t\t\tcoords.map(c => Math.round(c * 255))\n\t\t\t\t);\n\n\t\t\t\tlet collapsible = collapse && coords.every(c => c % 17 === 0);\n\n\t\t\t\tlet hex = coords\n\t\t\t\t\t.map(c => {\n\t\t\t\t\t\tif (collapsible) {\n\t\t\t\t\t\t\treturn (c / 17).toString(16);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn c.toString(16).padStart(2, \"0\");\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\");\n\n\t\t\t\treturn \"#\" + hex;\n\t\t\t},\n\t\t},\n\t\tkeyword: {\n\t\t\ttype: \"custom\",\n\t\t\ttest: str => /^[a-z]+$/i.test(str),\n\t\t\tparse (str) {\n\t\t\t\tstr = str.toLowerCase();\n\t\t\t\tlet ret = { spaceId: \"srgb\", coords: null, alpha: 1 };\n\n\t\t\t\tif (str === \"transparent\") {\n\t\t\t\t\tret.coords = KEYWORDS.black;\n\t\t\t\t\tret.alpha = 0;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tret.coords = KEYWORDS[str];\n\t\t\t\t}\n\n\t\t\t\tif (ret.coords) {\n\t\t\t\t\treturn ret;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n});\n", "import RGBColorSpace from \"../RGBColorSpace.js\";\nimport P3Linear from \"./p3-linear.js\";\nimport sRGB from \"./srgb.js\";\n\nexport default new RGBColorSpace({\n\tid: \"p3\",\n\tcssId: \"display-p3\",\n\tname: \"P3\",\n\tbase: P3Linear,\n\t// Gamma encoding/decoding is the same as sRGB\n\tfromBase: sRGB.fromBase,\n\ttoBase: sRGB.toBase,\n});\n", "/**\n * Relative luminance\n */\nimport get from \"./get.js\";\nimport set from \"./set.js\";\nimport xyz_d65 from \"./spaces/xyz-d65.js\";\n\n/** @import { ColorTypes } from \"./types.js\" */\n\n/**\n *\n * @param {ColorTypes} color\n * @returns {number}\n */\nexport function getLuminance (color) {\n\t// Assume getColor() is called on color in get()\n\treturn get(color, [xyz_d65, \"y\"]);\n}\n\n/**\n * @param {ColorTypes} color\n * @param {number | ((coord: number) => number)} value\n */\nexport function setLuminance (color, value) {\n\t// Assume getColor() is called on color in set()\n\tset(color, [xyz_d65, \"y\"], value);\n}\n\n/**\n * @param {typeof import(\"./color.js\").default} Color\n */\nexport function register (Color) {\n\tObject.defineProperty(Color.prototype, \"luminance\", {\n\t\tget () {\n\t\t\treturn getLuminance(this);\n\t\t},\n\t\tset (value) {\n\t\t\tsetLuminance(this, value);\n\t\t},\n\t});\n}\n", "// WCAG 2.0 contrast https://www.w3.org/TR/WCAG20-TECHS/G18.html\n// Simple contrast, with fixed 5% viewing flare contribution\n// Symmetric, does not matter which is foreground and which is background\n\nimport getColor from \"../getColor.js\";\nimport { getLuminance } from \"../luminance.js\";\n\n/**\n * @param {import(\"../types.js\").ColorTypes} color1\n * @param {import(\"../types.js\").ColorTypes} color2\n * @returns {number}\n */\nexport default function contrastWCAG21 (color1, color2) {\n\tcolor1 = getColor(color1);\n\tcolor2 = getColor(color2);\n\n\tlet Y1 = Math.max(getLuminance(color1), 0);\n\tlet Y2 = Math.max(getLuminance(color2), 0);\n\n\tif (Y2 > Y1) {\n\t\t[Y1, Y2] = [Y2, Y1];\n\t}\n\n\treturn (Y1 + 0.05) / (Y2 + 0.05);\n}\n", "import ColorSpace from \"../ColorSpace.js\";\nimport sRGB from \"./srgb.js\";\n\nexport default new ColorSpace({\n\tid: \"hsl\",\n\tname: \"HSL\",\n\tcoords: {\n\t\th: {\n\t\t\trefRange: [0, 360],\n\t\t\ttype: \"angle\",\n\t\t\tname: \"Hue\",\n\t\t},\n\t\ts: {\n\t\t\trange: [0, 100],\n\t\t\tname: \"Saturation\",\n\t\t},\n\t\tl: {\n\t\t\trange: [0, 100],\n\t\t\tname: \"Lightness\",\n\t\t},\n\t},\n\n\tbase: sRGB,\n\n\t// Adapted from https://drafts.csswg.org/css-color-4/better-rgbToHsl.js\n\tfromBase: rgb => {\n\t\tlet max = Math.max(...rgb);\n\t\tlet min = Math.min(...rgb);\n\t\tlet [r, g, b] = rgb;\n\t\tlet [h, s, l] = [null, 0, (min + max) / 2];\n\t\tlet d = max - min;\n\n\t\tif (d !== 0) {\n\t\t\ts = l === 0 || l === 1 ? 0 : (max - l) / Math.min(l, 1 - l);\n\n\t\t\tswitch (max) {\n\t\t\t\tcase r:\n\t\t\t\t\th = (g - b) / d + (g < b ? 6 : 0);\n\t\t\t\t\tbreak;\n\t\t\t\tcase g:\n\t\t\t\t\th = (b - r) / d + 2;\n\t\t\t\t\tbreak;\n\t\t\t\tcase b:\n\t\t\t\t\th = (r - g) / d + 4;\n\t\t\t}\n\n\t\t\th = h * 60;\n\t\t}\n\n\t\t// Very out of gamut colors can produce negative saturation\n\t\t// If so, just rotate the hue by 180 and use a positive saturation\n\t\t// see https://github.com/w3c/csswg-drafts/issues/9222\n\t\tif (s < 0) {\n\t\t\th += 180;\n\t\t\ts = Math.abs(s);\n\t\t}\n\n\t\tif (h >= 360) {\n\t\t\th -= 360;\n\t\t}\n\n\t\treturn [h, s * 100, l * 100];\n\t},\n\n\t// Adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative\n\ttoBase: hsl => {\n\t\tlet [h, s, l] = hsl;\n\t\th = h % 360;\n\n\t\tif (h < 0) {\n\t\t\th += 360;\n\t\t}\n\n\t\ts /= 100;\n\t\tl /= 100;\n\n\t\tfunction f (n) {\n\t\t\tlet k = (n + h / 30) % 12;\n\t\t\tlet a = s * Math.min(l, 1 - l);\n\t\t\treturn l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n\t\t}\n\n\t\treturn [f(0), f(8), f(4)];\n\t},\n\n\tformats: {\n\t\thsl: {\n\t\t\tcoords: [\"<number> | <angle>\", \"<percentage> | <number>\", \"<percentage> | <number>\"],\n\t\t},\n\t\thsla: {\n\t\t\tcoords: [\"<number> | <angle>\", \"<percentage> | <number>\", \"<percentage> | <number>\"],\n\t\t\tcommas: true,\n\t\t\talpha: true,\n\t\t},\n\t},\n});\n", "import ColorSpace from \"../ColorSpace.js\";\nimport OKLab from \"./oklab.js\";\nimport lch from \"./lch.js\";\n\nexport default new ColorSpace({\n\tid: \"oklch\",\n\tname: \"OkLCh\",\n\tcoords: {\n\t\tl: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"Lightness\",\n\t\t},\n\t\tc: {\n\t\t\trefRange: [0, 0.4],\n\t\t\tname: \"Chroma\",\n\t\t},\n\t\th: {\n\t\t\trefRange: [0, 360],\n\t\t\ttype: \"angle\",\n\t\t\tname: \"Hue\",\n\t\t},\n\t},\n\twhite: \"D65\",\n\n\tbase: OKLab,\n\tfromBase: lch.fromBase,\n\ttoBase: lch.toBase,\n\n\tformats: {\n\t\toklch: {\n\t\t\tcoords: [\"<percentage> | <number>\", \"<number> | <percentage>\", \"<number> | <angle>\"],\n\t\t},\n\t},\n});\n", "/**\n * Memize options object.\n *\n * @typedef MemizeOptions\n *\n * @property {number} [maxSize] Maximum size of the cache.\n */\n\n/**\n * Internal cache entry.\n *\n * @typedef MemizeCacheNode\n *\n * @property {?MemizeCacheNode|undefined} [prev] Previous node.\n * @property {?MemizeCacheNode|undefined} [next] Next node.\n * @property {Array<*>} args Function arguments for cache\n * entry.\n * @property {*} val Function result.\n */\n\n/**\n * Properties of the enhanced function for controlling cache.\n *\n * @typedef MemizeMemoizedFunction\n *\n * @property {()=>void} clear Clear the cache.\n */\n\n/**\n * Accepts a function to be memoized, and returns a new memoized function, with\n * optional options.\n *\n * @template {(...args: any[]) => any} F\n *\n * @param {F} fn Function to memoize.\n * @param {MemizeOptions} [options] Options object.\n *\n * @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function.\n */\nfunction memize(fn, options) {\n\tvar size = 0;\n\n\t/** @type {?MemizeCacheNode|undefined} */\n\tvar head;\n\n\t/** @type {?MemizeCacheNode|undefined} */\n\tvar tail;\n\n\toptions = options || {};\n\n\tfunction memoized(/* ...args */) {\n\t\tvar node = head,\n\t\t\tlen = arguments.length,\n\t\t\targs,\n\t\t\ti;\n\n\t\tsearchCache: while (node) {\n\t\t\t// Perform a shallow equality test to confirm that whether the node\n\t\t\t// under test is a candidate for the arguments passed. Two arrays\n\t\t\t// are shallowly equal if their length matches and each entry is\n\t\t\t// strictly equal between the two sets. Avoid abstracting to a\n\t\t\t// function which could incur an arguments leaking deoptimization.\n\n\t\t\t// Check whether node arguments match arguments length\n\t\t\tif (node.args.length !== arguments.length) {\n\t\t\t\tnode = node.next;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Check whether node arguments match arguments values\n\t\t\tfor (i = 0; i < len; i++) {\n\t\t\t\tif (node.args[i] !== arguments[i]) {\n\t\t\t\t\tnode = node.next;\n\t\t\t\t\tcontinue searchCache;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// At this point we can assume we've found a match\n\n\t\t\t// Surface matched node to head if not already\n\t\t\tif (node !== head) {\n\t\t\t\t// As tail, shift to previous. Must only shift if not also\n\t\t\t\t// head, since if both head and tail, there is no previous.\n\t\t\t\tif (node === tail) {\n\t\t\t\t\ttail = node.prev;\n\t\t\t\t}\n\n\t\t\t\t// Adjust siblings to point to each other. If node was tail,\n\t\t\t\t// this also handles new tail's empty `next` assignment.\n\t\t\t\t/** @type {MemizeCacheNode} */ (node.prev).next = node.next;\n\t\t\t\tif (node.next) {\n\t\t\t\t\tnode.next.prev = node.prev;\n\t\t\t\t}\n\n\t\t\t\tnode.next = head;\n\t\t\t\tnode.prev = null;\n\t\t\t\t/** @type {MemizeCacheNode} */ (head).prev = node;\n\t\t\t\thead = node;\n\t\t\t}\n\n\t\t\t// Return immediately\n\t\t\treturn node.val;\n\t\t}\n\n\t\t// No cached value found. Continue to insertion phase:\n\n\t\t// Create a copy of arguments (avoid leaking deoptimization)\n\t\targs = new Array(len);\n\t\tfor (i = 0; i < len; i++) {\n\t\t\targs[i] = arguments[i];\n\t\t}\n\n\t\tnode = {\n\t\t\targs: args,\n\n\t\t\t// Generate the result from original function\n\t\t\tval: fn.apply(null, args),\n\t\t};\n\n\t\t// Don't need to check whether node is already head, since it would\n\t\t// have been returned above already if it was\n\n\t\t// Shift existing head down list\n\t\tif (head) {\n\t\t\thead.prev = node;\n\t\t\tnode.next = head;\n\t\t} else {\n\t\t\t// If no head, follows that there's no tail (at initial or reset)\n\t\t\ttail = node;\n\t\t}\n\n\t\t// Trim tail if we're reached max size and are pending cache insertion\n\t\tif (size === /** @type {MemizeOptions} */ (options).maxSize) {\n\t\t\ttail = /** @type {MemizeCacheNode} */ (tail).prev;\n\t\t\t/** @type {MemizeCacheNode} */ (tail).next = null;\n\t\t} else {\n\t\t\tsize++;\n\t\t}\n\n\t\thead = node;\n\n\t\treturn node.val;\n\t}\n\n\tmemoized.clear = function () {\n\t\thead = null;\n\t\ttail = null;\n\t\tsize = 0;\n\t};\n\n\t// Ignore reason: There's not a clear solution to create an intersection of\n\t// the function with additional properties, where the goal is to retain the\n\t// function signature of the incoming argument and add control properties\n\t// on the return value.\n\n\t// @ts-ignore\n\treturn memoized;\n}\n\nexport { memize as default };\n", "/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\nimport {\n\tclone,\n\tset,\n\tto,\n\tsRGB,\n\tHSL,\n\ttype PlainColorObject,\n} from 'colorjs.io/fn';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport './color-ramps/lib/register-color-spaces';\nimport { ThemeContext } from './context';\nimport colorTokens from './prebuilt/ts/color-tokens';\nimport {\n\tbuildBgRamp,\n\tbuildAccentRamp,\n\tDEFAULT_SEED_COLORS,\n\ttype RampResult,\n} from './color-ramps';\nimport { getColorString } from './color-ramps/lib/color-utils';\nimport type { ThemeProviderProps } from './types';\n\ntype Entry = [ string, string ];\n\nconst getCachedBgRamp = memoize( buildBgRamp, { maxSize: 10 } );\nconst getCachedAccentRamp = memoize( buildAccentRamp, { maxSize: 10 } );\n\nconst legacyWpComponentsOverridesCSS: Entry[] = [\n\t[ '--wp-components-color-accent', 'var(--wp-admin-theme-color)' ],\n\t[\n\t\t'--wp-components-color-accent-darker-10',\n\t\t'var(--wp-admin-theme-color-darker-10)',\n\t],\n\t[\n\t\t'--wp-components-color-accent-darker-20',\n\t\t'var(--wp-admin-theme-color-darker-20)',\n\t],\n\t[\n\t\t'--wp-components-color-accent-inverted',\n\t\t'var(--wpds-color-fg-interactive-brand-strong)',\n\t],\n\t[\n\t\t'--wp-components-color-background',\n\t\t'var(--wpds-color-bg-surface-neutral-strong)',\n\t],\n\t[\n\t\t'--wp-components-color-foreground',\n\t\t'var(--wpds-color-fg-content-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-foreground-inverted',\n\t\t'var(--wpds-color-bg-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-100',\n\t\t'var(--wpds-color-bg-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-200',\n\t\t'var(--wpds-color-stroke-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-300',\n\t\t'var(--wpds-color-stroke-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-400',\n\t\t'var(--wpds-color-stroke-interactive-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-600',\n\t\t'var(--wpds-color-stroke-interactive-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-700',\n\t\t'var(--wpds-color-fg-content-neutral-weak)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-800',\n\t\t'var(--wpds-color-fg-content-neutral)',\n\t],\n];\n\nfunction customRgbFormat( color: PlainColorObject ): string {\n\tconst rgb = to( color, sRGB );\n\treturn rgb.coords\n\t\t.map( ( n ) => Math.round( ( n ?? 0 ) * 255 ) )\n\t\t.join( ', ' );\n}\n\nfunction legacyWpAdminThemeOverridesCSS( accent: string ): Entry[] {\n\tconst parsedAccent = to( accent, HSL );\n\tconst parsedL = parsedAccent.coords[ 2 ] ?? 0;\n\n\t// Create darker version of accent \u2014\n\tconst darker10 = set(\n\t\tclone( parsedAccent ),\n\t\t[ HSL, 'l' ],\n\t\tMath.max( 0, parsedL - 5 ) // L reduced by 5%\n\t);\n\tconst darker20 = set(\n\t\tclone( parsedAccent ),\n\t\t[ HSL, 'l' ],\n\t\tMath.max( 0, parsedL - 10 ) // L reduced by 10%\n\t);\n\n\treturn [\n\t\t[ '--wp-admin-theme-color', getColorString( parsedAccent ) ],\n\t\t[ '--wp-admin-theme-color--rgb', customRgbFormat( parsedAccent ) ],\n\t\t[ '--wp-admin-theme-color-darker-10', getColorString( darker10 ) ],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-10--rgb',\n\t\t\tcustomRgbFormat( darker10 ),\n\t\t],\n\t\t[ '--wp-admin-theme-color-darker-20', getColorString( darker20 ) ],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-20--rgb',\n\t\t\tcustomRgbFormat( darker20 ),\n\t\t],\n\t];\n}\n\nfunction colorTokensCSS(\n\tcomputedColorRamps: Map< string, RampResult >\n): Entry[] {\n\tconst entries: Entry[] = [];\n\n\tfor ( const [ rampName, { ramp } ] of computedColorRamps ) {\n\t\tfor ( const [ tokenName, tokenValue ] of Object.entries( ramp ) ) {\n\t\t\tconst key = `${ rampName }-${ tokenName }`;\n\t\t\tconst aliasedBy = colorTokens[ key ] ?? [];\n\t\t\tfor ( const aliasedId of aliasedBy ) {\n\t\t\t\tentries.push( [ `--wpds-color-${ aliasedId }`, tokenValue ] );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\nfunction generateStyles( {\n\tprimary,\n\tcomputedColorRamps,\n}: {\n\tprimary: string;\n\tcomputedColorRamps: Map< string, RampResult >;\n} ): CSSProperties {\n\treturn Object.fromEntries(\n\t\t[\n\t\t\t// Semantic color tokens\n\t\t\tcolorTokensCSS( computedColorRamps ),\n\t\t\t// Legacy overrides\n\t\t\tlegacyWpAdminThemeOverridesCSS( primary ),\n\t\t\tlegacyWpComponentsOverridesCSS,\n\t\t].flat()\n\t);\n}\n\nexport function useThemeProviderStyles( {\n\tcolor = {},\n}: {\n\tcolor?: ThemeProviderProps[ 'color' ];\n} = {} ) {\n\tconst { resolvedSettings: inheritedSettings } = useContext( ThemeContext );\n\n\t// Compute settings:\n\t// - used provided prop value;\n\t// - otherwise, use inherited value from parent instance;\n\t// - otherwise, use fallback value (where applicable).\n\tconst primary =\n\t\tcolor.primary ??\n\t\tinheritedSettings.color?.primary ??\n\t\tDEFAULT_SEED_COLORS.primary;\n\tconst bg =\n\t\tcolor.bg ?? inheritedSettings.color?.bg ?? DEFAULT_SEED_COLORS.bg;\n\n\tconst resolvedSettings = useMemo(\n\t\t() => ( {\n\t\t\tcolor: {\n\t\t\t\tprimary,\n\t\t\t\tbg,\n\t\t\t},\n\t\t} ),\n\t\t[ primary, bg ]\n\t);\n\n\tconst themeProviderStyles = useMemo( () => {\n\t\t// Determine which seeds are needed for generating ramps.\n\t\tconst seeds = {\n\t\t\t...DEFAULT_SEED_COLORS,\n\t\t\tbg,\n\t\t\tprimary,\n\t\t};\n\n\t\t// Generate ramps.\n\t\tconst computedColorRamps = new Map< string, RampResult >();\n\t\tconst bgRamp = getCachedBgRamp( seeds.bg );\n\t\tObject.entries( seeds ).forEach( ( [ rampName, seed ] ) => {\n\t\t\tif ( rampName === 'bg' ) {\n\t\t\t\tcomputedColorRamps.set( rampName, bgRamp );\n\t\t\t} else {\n\t\t\t\tcomputedColorRamps.set(\n\t\t\t\t\trampName,\n\t\t\t\t\tgetCachedAccentRamp( seed, bgRamp )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn generateStyles( {\n\t\t\tprimary: seeds.primary,\n\t\t\tcomputedColorRamps,\n\t\t} );\n\t}, [ primary, bg ] );\n\n\treturn {\n\t\tresolvedSettings,\n\t\tthemeProviderStyles,\n\t};\n}\n", "/**\n * External dependencies\n */\nimport { ColorSpace, OKLCH, P3, sRGB, HSL } from 'colorjs.io/fn';\n\n// Ensures that all color spaces used in color ramps are registered globally, a\n// requirement for using colorjs.io's procedural API.\n//\n// See: https://colorjs.io/docs/procedural\nColorSpace.register( sRGB );\nColorSpace.register( OKLCH );\nColorSpace.register( P3 );\nColorSpace.register( HSL );\n", "/*\n * This file is generated by the @wordpress/terrazzo-plugin-inline-alias-values plugin.\n * Do not edit this file directly.\n */\n\nexport default {\n\t'primary-bgFill1': [ 'bg-interactive-brand-strong' ],\n\t'primary-fgFill': [\n\t\t'fg-interactive-brand-strong',\n\t\t'fg-interactive-brand-strong-active',\n\t],\n\t'primary-bgFill2': [ 'bg-interactive-brand-strong-active' ],\n\t'primary-surface4': [ 'bg-interactive-brand-weak-active' ],\n\t'primary-fgSurface3': [\n\t\t'fg-interactive-brand',\n\t\t'fg-interactive-brand-active',\n\t],\n\t'primary-stroke3': [\n\t\t'bg-thumb-brand',\n\t\t'bg-thumb-brand-active',\n\t\t'stroke-focus-brand',\n\t\t'stroke-interactive-brand',\n\t\t'stroke-surface-brand-strong',\n\t],\n\t'primary-stroke4': [ 'stroke-interactive-brand-active' ],\n\t'primary-stroke1': [ 'stroke-surface-brand' ],\n\t'primary-surface1': [ 'bg-surface-brand' ],\n\t'info-surface2': [ 'bg-surface-info-weak' ],\n\t'info-surface4': [ 'bg-surface-info' ],\n\t'info-fgSurface4': [ 'fg-content-info' ],\n\t'info-fgSurface3': [ 'fg-content-info-weak' ],\n\t'info-stroke3': [ 'stroke-surface-info-strong' ],\n\t'info-stroke1': [ 'stroke-surface-info' ],\n\t'success-surface2': [ 'bg-surface-success-weak' ],\n\t'success-surface4': [ 'bg-surface-success' ],\n\t'success-fgSurface4': [ 'fg-content-success' ],\n\t'success-fgSurface3': [ 'fg-content-success-weak' ],\n\t'success-stroke3': [ 'stroke-surface-success-strong' ],\n\t'success-stroke1': [ 'stroke-surface-success' ],\n\t'warning-surface2': [ 'bg-surface-warning-weak' ],\n\t'warning-surface4': [ 'bg-surface-warning' ],\n\t'warning-fgSurface4': [ 'fg-content-warning' ],\n\t'warning-fgSurface3': [ 'fg-content-warning-weak' ],\n\t'warning-stroke3': [ 'stroke-surface-warning-strong' ],\n\t'warning-stroke1': [ 'stroke-surface-warning' ],\n\t'error-bgFill1': [ 'bg-interactive-error-strong' ],\n\t'error-fgFill': [\n\t\t'fg-interactive-error-strong',\n\t\t'fg-interactive-error-strong-active',\n\t],\n\t'error-bgFill2': [ 'bg-interactive-error-strong-active' ],\n\t'error-surface2': [\n\t\t'bg-interactive-error-active',\n\t\t'bg-surface-error-weak',\n\t],\n\t'error-surface4': [\n\t\t'bg-interactive-error-weak-active',\n\t\t'bg-surface-error',\n\t],\n\t'error-fgSurface4': [ 'fg-content-error' ],\n\t'error-fgSurface3': [\n\t\t'fg-content-error-weak',\n\t\t'fg-interactive-error',\n\t\t'fg-interactive-error-active',\n\t],\n\t'error-stroke3': [\n\t\t'stroke-interactive-error',\n\t\t'stroke-interactive-error-strong',\n\t\t'stroke-surface-error-strong',\n\t],\n\t'error-stroke4': [ 'stroke-interactive-error-active' ],\n\t'error-stroke1': [ 'stroke-surface-error' ],\n\t'bg-surface2': [ 'bg-surface-neutral' ],\n\t'bg-surface5': [ 'bg-interactive-neutral-strong-disabled' ],\n\t'bg-surface4': [ 'bg-interactive-neutral-weak-active' ],\n\t'bg-surface3': [ 'bg-surface-neutral-strong' ],\n\t'bg-fgSurface4': [\n\t\t'fg-content-neutral',\n\t\t'fg-interactive-neutral',\n\t\t'fg-interactive-neutral-active',\n\t],\n\t'bg-fgSurface3': [\n\t\t'fg-content-neutral-weak',\n\t\t'fg-interactive-neutral-weak',\n\t],\n\t'bg-fgSurface2': [\n\t\t'fg-interactive-neutral-disabled',\n\t\t'fg-interactive-neutral-strong-disabled',\n\t\t'fg-interactive-neutral-weak-disabled',\n\t],\n\t'bg-stroke3': [\n\t\t'bg-thumb-neutral-weak',\n\t\t'stroke-interactive-neutral',\n\t\t'stroke-surface-neutral-strong',\n\t],\n\t'bg-stroke4': [\n\t\t'bg-thumb-neutral-weak-active',\n\t\t'stroke-interactive-neutral-active',\n\t\t'stroke-interactive-neutral-strong',\n\t],\n\t'bg-stroke2': [\n\t\t'bg-thumb-neutral-disabled',\n\t\t'bg-track-neutral',\n\t\t'stroke-interactive-neutral-disabled',\n\t\t'stroke-surface-neutral',\n\t],\n\t'bg-stroke1': [ 'bg-track-neutral-weak', 'stroke-surface-neutral-weak' ],\n\t'bg-bgFillInverted2': [ 'bg-interactive-neutral-strong-active' ],\n\t'bg-bgFillInverted1': [ 'bg-interactive-neutral-strong' ],\n\t'bg-fgFillInverted': [\n\t\t'fg-interactive-neutral-strong',\n\t\t'fg-interactive-neutral-strong-active',\n\t],\n\t'bg-surface1': [ 'bg-surface-neutral-weak' ],\n\t'caution-surface2': [ 'bg-surface-caution-weak' ],\n\t'caution-surface4': [ 'bg-surface-caution' ],\n\t'caution-fgSurface4': [ 'fg-content-caution' ],\n\t'caution-fgSurface3': [ 'fg-content-caution-weak' ],\n} as Record< string, string[] >;\n", "/**\n * External dependencies\n */\nimport {\n\tto,\n\ttoGamut,\n\tserialize,\n\tcontrastWCAG21,\n\tsRGB,\n\tOKLCH,\n\ttype ColorTypes,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\n\n/**\n * Get string representation of a color\n * @param color Color object to stringify\n * @return String representation\n */\nexport function getColorString( color: ColorTypes ): string {\n\tconst rgbRounded = serialize( to( color, sRGB ) );\n\treturn serialize( rgbRounded, { format: 'hex' } );\n}\n\n/**\n * Get contrast value between two colors\n * @param colorA First color\n * @param colorB Second color\n * @return WCAG 2.1 contrast ratio\n */\nexport function getContrast( colorA: ColorTypes, colorB: ColorTypes ): number {\n\treturn contrastWCAG21( colorA, colorB );\n}\n\n/**\n * Make sure that a color is valid in the sRGB gamut and convert it to OKLCH.\n * @param c\n */\nexport function clampToGamut( c: ColorTypes ) {\n\t// map into sRGB using CSS OKLCH method\n\treturn to( toGamut( c, { space: sRGB, method: 'css' } ), OKLCH );\n}\n", "/**\n * External dependencies\n */\nimport { to, OKLCH } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport type { Ramp } from './types';\n\nexport const WHITE = to( 'white', OKLCH );\nexport const BLACK = to( 'black', OKLCH );\n\n// Margin added to target contrasts to counter for algorithm approximations and rounding errors.\n// - the `CONTRAST_EPSILON` value is 0.004, so the real contrast can be lower by this amount.\n// - the max contrast between adjacent RGB values is 1.016, so 0.016 is the maximum total rounding error between two values.\n// - the sum is 0.02: the margin we add to ensure that the target contrast is met after all the rounding.\nexport const UNIVERSAL_CONTRAST_TOPUP = 0.02;\n\n// When enabling \"lighter direction\" bias, this is the amount by which\n// black text contrast needs to be greater than white text contrast.\n// The higher the value, the stronger the preference for white text.\n// The current value has been determined empirically as the highest value\n// that won't cause the algo not to be able to correctly solve all contrasts.\nexport const WHITE_TEXT_CONTRAST_MARGIN = 3.1;\n\n// These values are used as thresholds when trying to match the background\n// ramp's lightness while calculating an accent ramp. They prevent the accent\n// scale from being pinned to lightness values in the middle of the range,\n// which would cause the algorithm to struggle to satisfy the accent scale\n// constraints and therefore produce unexpected results.\nexport const ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS = {\n\tlighter: { min: 0.2, max: 0.4 },\n\tdarker: { min: 0.75, max: 0.98 },\n} as const;\n\n// Contrast precision we aim for. Approximately 1/256, resolution of an 8-bit number.\nexport const CONTRAST_EPSILON = 4e-3;\n\nexport const MAX_BISECTION_ITERATIONS = 10;\n\nexport const CONTRAST_COMBINATIONS: {\n\tbgs: ( keyof Ramp )[];\n\tfgs: ( keyof Ramp )[];\n\ttarget: number;\n}[] = [\n\t{\n\t\tbgs: [ 'surface1', 'surface2', 'surface3' ],\n\t\tfgs: [ 'fgSurface3', 'fgSurface4' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'surface4', 'surface5' ],\n\t\tfgs: [ 'fgSurface4' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'bgFill1' ],\n\t\tfgs: [ 'fgFill' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'bgFillInverted1' ],\n\t\tfgs: [ 'fgFillInverted' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'bgFillInverted1' ],\n\t\tfgs: [ 'fgFillInverted' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'surface1', 'surface2', 'surface3' ],\n\t\tfgs: [ 'stroke3' ],\n\t\ttarget: 3,\n\t},\n];\n\n// Used when generating the DTCG tokens and the static color ramps.\nexport const DEFAULT_SEED_COLORS = {\n\tbg: '#f8f8f8',\n\tprimary: '#3858e9',\n\tinfo: '#0090ff',\n\tsuccess: '#4ab866',\n\tcaution: '#f0d149',\n\twarning: '#f0b849',\n\terror: '#cc1818',\n};\n", "/**\n * External dependencies\n */\nimport { type ColorTypes } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport {\n\tWHITE,\n\tBLACK,\n\tUNIVERSAL_CONTRAST_TOPUP,\n\tWHITE_TEXT_CONTRAST_MARGIN,\n\tACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS,\n\tMAX_BISECTION_ITERATIONS,\n\tCONTRAST_EPSILON,\n} from './constants';\nimport type { Ramp, RampConfig, RampDirection } from './types';\nimport { getContrast } from './color-utils';\n\n/**\n * Build a dependency graph from the steps configuration\n * @param config - The steps configuration object\n */\nfunction buildDependencyGraph( config: RampConfig ): {\n\tdependencies: Map< keyof Ramp, ( keyof Ramp | 'seed' )[] >;\n\tdependents: Map< keyof Ramp | 'seed', ( keyof Ramp )[] >;\n} {\n\tconst dependencies = new Map< keyof Ramp, ( keyof Ramp | 'seed' )[] >();\n\tconst dependents = new Map< keyof Ramp | 'seed', ( keyof Ramp )[] >();\n\n\t// Initialize maps\n\tObject.keys( config ).forEach( ( step ) => {\n\t\tdependencies.set( step as keyof Ramp, [] );\n\t} );\n\tdependents.set( 'seed', [] );\n\tObject.keys( config ).forEach( ( step ) => {\n\t\tdependents.set( step as keyof Ramp, [] );\n\t} );\n\n\t// Build the graph\n\tObject.entries( config ).forEach( ( [ stepName, stepConfig ] ) => {\n\t\tconst step = stepName as keyof Ramp;\n\t\tconst reference = stepConfig.contrast.reference;\n\n\t\tdependencies.get( step )!.push( reference );\n\t\tdependents.get( reference )!.push( step );\n\n\t\t// Add dependency for sameAsIfPossible\n\t\tif ( stepConfig.sameAsIfPossible ) {\n\t\t\tdependencies.get( step )!.push( stepConfig.sameAsIfPossible );\n\t\t\tdependents.get( stepConfig.sameAsIfPossible )!.push( step );\n\t\t}\n\t} );\n\n\treturn { dependencies, dependents };\n}\n\n/**\n * Topologically sort steps based on their dependencies\n * @param config - The steps configuration object\n */\nexport function sortByDependency( config: RampConfig ): ( keyof Ramp )[] {\n\tconst { dependents } = buildDependencyGraph( config );\n\tconst result: ( keyof Ramp )[] = [];\n\tconst visited = new Set< keyof Ramp | 'seed' >();\n\tconst visiting = new Set< keyof Ramp | 'seed' >();\n\n\tfunction visit( node: keyof Ramp | 'seed' ): void {\n\t\tif ( visiting.has( node ) ) {\n\t\t\tthrow new Error(\n\t\t\t\t`Circular dependency detected involving step: ${ String(\n\t\t\t\t\tnode\n\t\t\t\t) }`\n\t\t\t);\n\t\t}\n\t\tif ( visited.has( node ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tvisiting.add( node );\n\n\t\t// Visit all dependents (steps that depend on this node)\n\t\tconst nodeDependents = dependents.get( node ) || [];\n\t\tnodeDependents.forEach( ( dependent ) => {\n\t\t\tvisit( dependent );\n\t\t} );\n\n\t\tvisiting.delete( node );\n\t\tvisited.add( node );\n\n\t\t// Add to result only if it's a step (not 'seed')\n\t\tif ( node !== 'seed' ) {\n\t\t\tresult.unshift( node ); // Add to front for correct topological order\n\t\t}\n\t}\n\n\t// Start with seed - this will recursively visit all reachable nodes\n\tvisit( 'seed' );\n\n\treturn result;\n}\n/**\n * Return minimal set of steps that are needed to calculate `stepName` from the seed.\n * @param stepName Name of the step.\n * @param config Configuration of the ramp.\n * @return Array of steps that `stepName` depends on.\n */\nexport function stepsForStep(\n\tstepName: keyof Ramp,\n\tconfig: RampConfig\n): ( keyof Ramp )[] {\n\tconst result = new Set< keyof Ramp >();\n\tfunction visit( step: keyof Ramp | 'seed' ) {\n\t\tif ( step === 'seed' || result.has( step ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst stepConfig = config[ step ];\n\t\tif ( ! stepConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tvisit( stepConfig.contrast.reference );\n\t\tif ( stepConfig.sameAsIfPossible ) {\n\t\t\tvisit( stepConfig.sameAsIfPossible );\n\t\t}\n\n\t\tresult.add( step );\n\t}\n\tvisit( stepName );\n\treturn Array.from( result );\n}\n\n/**\n * Finds out whether a lighter or a darker foreground color achieves a better\n * contrast against the seed\n * @param seed\n * @param preferLighter Whether the check should favor white foreground color\n * @return An object with \"better\" and \"worse\" properties, each holding a\n * ramp direction value.\n */\nexport function computeBetterFgColorDirection(\n\tseed: ColorTypes,\n\tpreferLighter?: boolean\n): {\n\tbetter: RampDirection;\n\tworse: RampDirection;\n} {\n\tconst contrastAgainstBlack = getContrast( seed, BLACK );\n\tconst contrastAgainstWhite = getContrast( seed, WHITE );\n\n\treturn contrastAgainstBlack >\n\t\tcontrastAgainstWhite +\n\t\t\t( preferLighter ? WHITE_TEXT_CONTRAST_MARGIN : 0 )\n\t\t? { better: 'darker', worse: 'lighter' }\n\t\t: { better: 'lighter', worse: 'darker' };\n}\n\nexport function adjustContrastTarget( target: number ) {\n\tif ( target === 1 ) {\n\t\treturn 1;\n\t}\n\n\t// Add a little top up to take into account any rounding error and algo imprecisions.\n\treturn target + UNIVERSAL_CONTRAST_TOPUP;\n}\n\n/**\n * Prevent the accent scale from referencing a lightness value that\n * would prevent the algorithm from complying with the requirements\n * and cause it to generate unexpected results.\n * @param rawLightness\n * @param direction\n * @return The clamped lightness value\n */\nexport function clampAccentScaleReferenceLightness(\n\trawLightness: number,\n\tdirection: RampDirection\n) {\n\tconst thresholds = ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS[ direction ];\n\treturn Math.max( thresholds.min, Math.min( thresholds.max, rawLightness ) );\n}\n\n/**\n * Find the value of of `L` (luminance) that produces a `C` (color) that has a\n * `value` (contrast delta) equal to zero.\n * @param calculateC Calculate `C` from a given `L`.\n * @param calculateValue Calculate value (delta) for a given `C`.\n * @param initLowerL Initial lower value of `L`.\n * @param initLowerValue Initial lower delta (negative).\n * @param initUpperL Initial upper value of `L`.\n * @param initUpperValue Initial upper delta (positive).\n * @return Resulting value of type `C`.\n */\nexport function solveWithBisect< C >(\n\tcalculateC: ( l: number ) => C,\n\tcalculateValue: ( t: C ) => number,\n\tinitLowerL: number,\n\tinitLowerValue: number,\n\tinitUpperL: number,\n\tinitUpperValue: number\n): C {\n\tlet lowerL = initLowerL;\n\tlet lowerValue = initLowerValue;\n\tlet lowerReplaced = false;\n\n\tlet upperL = initUpperL;\n\tlet upperValue = initUpperValue;\n\tlet upperReplaced = false;\n\n\tlet bestC: C;\n\tlet bestValue: number;\n\tlet iterations = 0;\n\n\twhile ( true ) {\n\t\titerations++;\n\n\t\t// Linear interpolation: find the point where a line would cross the zero axis.\n\t\tconst newL =\n\t\t\t( lowerL * upperValue - upperL * lowerValue ) /\n\t\t\t( upperValue - lowerValue );\n\n\t\tbestC = calculateC( newL );\n\t\tbestValue = calculateValue( bestC );\n\n\t\tif (\n\t\t\tMath.abs( bestValue ) <= CONTRAST_EPSILON ||\n\t\t\titerations >= MAX_BISECTION_ITERATIONS\n\t\t) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// Update the lower/upper bracket values. When only one side is repeatedly updated,\n\t\t// apply so-called \"Illinois trick\" for faster convergence: halve the opposite value.\n\t\tif ( bestValue <= 0 ) {\n\t\t\tlowerL = newL;\n\t\t\tlowerValue = bestValue;\n\t\t\tif ( lowerReplaced ) {\n\t\t\t\tupperValue /= 2;\n\t\t\t}\n\t\t\tlowerReplaced = true;\n\t\t\tupperReplaced = false;\n\t\t} else {\n\t\t\tupperL = newL;\n\t\t\tupperValue = bestValue;\n\t\t\tif ( upperReplaced ) {\n\t\t\t\tlowerValue /= 2;\n\t\t\t}\n\t\t\tupperReplaced = true;\n\t\t\tlowerReplaced = false;\n\t\t}\n\t}\n\n\treturn bestC;\n}\n", "/**\n * External dependencies\n */\nimport {\n\tget,\n\ttoGamut,\n\tOKLCH,\n\tsRGB,\n\ttype PlainColorObject,\n\ttype ColorSpace,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\n\nexport interface TaperChromaOptions {\n\tgamut?: ColorSpace; // target gamut (default `sRGB`)\n\talpha?: number; // base fraction of Cmax at target (default 0.62)\n\tcarry?: number; // seed vividness carry exponent \u03B2 in [0..1] (default 0.5)\n\tcUpperBound?: number; // hard search cap for C (default 0.45)\n\t// Continuous taper around the seed (desaturate both sides slightly)\n\tradiusLight?: number; // distance in L where kLight is reached (default 0.20)\n\tradiusDark?: number; // distance in L where kDark is reached (default 0.20)\n\tkLight?: number; // floor multiplier near lighter side (default 0.85)\n\tkDark?: number; // floor multiplier near darker side (default 0.85)\n\t// Achromatic handling\n\thueFallback?: number; // degrees: if seed is achromatic and you still want color\n\tachromaEpsilon?: number; // \u2264 this chroma \u2192 treat as achromatic (default 0.005)\n}\n\n/**\n * Given the seed and the target lightness, tapers the chroma smoothly.\n * - C_intended = Cmax(Lt,H0) * alpha * (seedRelative^carry)\n * - Continuous taper vs |Lt - Ls| to softly reduce chroma for neighbors\n * - Downward-only clamp on C (preserve L & H)\n * @param seed\n * @param lTarget\n * @param options\n */\nexport function taperChroma(\n\tseed: PlainColorObject, // already OKLCH\n\tlTarget: number, // [0..1]\n\toptions: TaperChromaOptions = {}\n): { l: number; c: number } | PlainColorObject {\n\tconst gamut = options.gamut ?? sRGB;\n\tconst alpha = options.alpha ?? 0.65; // 0.7-0.8 works well for accent surface\n\tconst carry = options.carry ?? 0.5;\n\tconst cUpperBound = options.cUpperBound ?? 0.45;\n\tconst radiusLight = options.radiusLight ?? 0.2;\n\tconst radiusDark = options.radiusDark ?? 0.2;\n\tconst kLight = options.kLight ?? 0.85;\n\tconst kDark = options.kDark ?? 0.85;\n\tconst achromaEpsilon = options.achromaEpsilon ?? 0.005;\n\n\tconst cSeed = Math.max( 0, get( seed, [ OKLCH, 'c' ] ) );\n\tlet hSeed = get( seed, [ OKLCH, 'h' ] );\n\n\tconst chromaIsTiny = cSeed < achromaEpsilon;\n\tconst hueIsInvalid = hSeed === null || ! Number.isFinite( hSeed );\n\n\tif ( chromaIsTiny || hueIsInvalid ) {\n\t\tif ( typeof options.hueFallback === 'number' ) {\n\t\t\thSeed = normalizeHue( options.hueFallback );\n\t\t} else {\n\t\t\t// Respect achromatic intent: grayscale at target L\n\t\t\treturn {\n\t\t\t\tspace: OKLCH,\n\t\t\t\tcoords: [ clamp01( lTarget ), 0, 0 ],\n\t\t\t\talpha: 1,\n\t\t\t};\n\t\t}\n\t}\n\n\t// Capacity at seed and target\n\tconst lSeed = clamp01( get( seed, [ OKLCH, 'l' ] ) );\n\tconst cmaxSeed = getCachedMaxChromaAtLH( lSeed, hSeed, gamut, cUpperBound );\n\tconst cmaxTarget = getCachedMaxChromaAtLH(\n\t\tclamp01( lTarget ),\n\t\thSeed,\n\t\tgamut,\n\t\tcUpperBound\n\t);\n\n\t// Seed vividness ratio (hue-fair normalization)\n\tlet seedRelative = 0;\n\tconst denom = cmaxSeed > 0 ? cmaxSeed : 1e-6;\n\tseedRelative = clamp01( cSeed / denom );\n\n\t// Intended chroma from local capacity, tempered by seed vividness\n\tconst cIntendedBase = alpha * cmaxTarget;\n\tconst cWithCarry =\n\t\tcIntendedBase * Math.pow( seedRelative, clamp01( carry ) );\n\n\t// Gentle, symmetric desaturation vs distance in L\n\tconst t = continuousTaper( lSeed, lTarget, {\n\t\tradiusLight,\n\t\tradiusDark,\n\t\tkLight,\n\t\tkDark,\n\t} );\n\tconst cPlanned = cWithCarry * t;\n\n\t// Downward-only clamp (preserve L & H)\n\tconst lOut = clamp01( lTarget );\n\n\treturn { l: lOut, c: cPlanned };\n}\n\n/* ---------------- helpers & caches ---------------- */\n\nfunction clamp01( x: number ): number {\n\tif ( x < 0 ) {\n\t\treturn 0;\n\t}\n\tif ( x > 1 ) {\n\t\treturn 1;\n\t}\n\treturn x;\n}\nfunction normalizeHue( h: number ): number {\n\tlet hue = h % 360;\n\tif ( hue < 0 ) {\n\t\thue += 360;\n\t}\n\treturn hue;\n}\nfunction raisedCosine( u: number ): number {\n\tconst x = clamp01( u );\n\treturn 0.5 - 0.5 * Math.cos( Math.PI * x );\n}\n\n/**\n * smooth, distance-from-seed chroma taper (raised-cosine per side)\n * @param seedL\n * @param targetL\n * @param opts\n * @param opts.radiusLight\n * @param opts.radiusDark\n * @param opts.kLight\n * @param opts.kDark\n */\nfunction continuousTaper(\n\tseedL: number,\n\ttargetL: number,\n\topts: {\n\t\tradiusLight: number;\n\t\tradiusDark: number;\n\t\tkLight: number;\n\t\tkDark: number;\n\t}\n): number {\n\tconst d = targetL - seedL;\n\tif ( d >= 0 ) {\n\t\tconst u = opts.radiusLight > 0 ? Math.abs( d ) / opts.radiusLight : 1;\n\t\tconst w = raisedCosine( u > 1 ? 1 : u );\n\t\treturn 1 - ( 1 - opts.kLight ) * w;\n\t}\n\tconst u = opts.radiusDark > 0 ? Math.abs( d ) / opts.radiusDark : 1;\n\tconst w = raisedCosine( u > 1 ? 1 : u );\n\treturn 1 - ( 1 - opts.kDark ) * w;\n}\n\n/* ---- chroma-capacity queries with small caches ---- */\n\nconst maxChromaCache = new Map< string, number >();\nfunction keyMax( l: number, h: number, gamut: string, cap: number ): string {\n\t// Quantize to keep cache compact\n\tconst lq = quantize( l, 0.05 );\n\tconst hq = quantize( normalizeHue( h ), 10 );\n\tconst cq = quantize( cap, 0.05 );\n\treturn `${ gamut }|L:${ lq }|H:${ hq }|cap:${ cq }`;\n}\n\nfunction quantize( x: number, step: number ): number {\n\tconst k = Math.round( x / step );\n\treturn k * step;\n}\n\nfunction getCachedMaxChromaAtLH(\n\tl: number,\n\th: number,\n\tgamutSpace: ColorSpace,\n\tcap: number\n): number {\n\tconst gamut = gamutSpace.id;\n\tconst key = keyMax( l, h, gamut, cap );\n\tconst hit = maxChromaCache.get( key );\n\tif ( typeof hit === 'number' ) {\n\t\treturn hit;\n\t}\n\n\tconst computed = maxInGamutChromaAtLH( l, h, gamutSpace, cap );\n\tmaxChromaCache.set( key, computed );\n\treturn computed;\n}\n\n/**\n * Find the max in-gamut chroma at fixed (L,H) in the target gamut\n * @param l\n * @param h\n * @param gamutSpace\n * @param cap\n */\nfunction maxInGamutChromaAtLH(\n\tl: number,\n\th: number,\n\tgamutSpace: ColorSpace,\n\tcap: number\n): number {\n\t// Construct a color with maximum chroma.\n\tconst probe: PlainColorObject = {\n\t\tspace: OKLCH,\n\t\tcoords: [ l, cap, h ],\n\t\talpha: 1,\n\t};\n\n\t// Let `toGamut` reduce the chroma to the gamut maximum.\n\tconst clamped = toGamut( probe, { space: gamutSpace, method: 'css' } );\n\n\treturn get( clamped, [ OKLCH, 'c' ] );\n}\n", "/**\n * External dependencies\n */\nimport { get, OKLCH, type PlainColorObject } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport { solveWithBisect } from './utils';\nimport { WHITE, BLACK, CONTRAST_EPSILON } from './constants';\nimport { clampToGamut, getContrast } from './color-utils';\nimport { type TaperChromaOptions, taperChroma } from './taper-chroma';\n\n/**\n * Difference of contrast values that grows linearly with the Y luminance.\n * We get more precise linear interpolations when we use this.\n * @param c1 First contrast.\n * @param c2 Second contrast.\n * @return Difference of logarithms.\n */\nfunction cdiff( c1: number, c2: number ) {\n\treturn Math.log( c1 / c2 );\n}\n\n/**\n * Solve for L such that:\n * - the L applied to the seed meets the contrast target against the reference\n * - the search is performed in one direction (ie lighter / darker)\n * - more constraints can be applied around lightness\n * @param reference\n * @param seed\n * @param target\n * @param direction\n * @param options\n * @param options.lightnessConstraint\n * @param options.lightnessConstraint.type\n * @param options.lightnessConstraint.value\n * @param options.taperChromaOptions\n */\nexport function findColorMeetingRequirements(\n\treference: PlainColorObject,\n\tseed: PlainColorObject,\n\ttarget: number,\n\tdirection: 'lighter' | 'darker',\n\t{\n\t\tlightnessConstraint,\n\t\ttaperChromaOptions,\n\t}: {\n\t\tlightnessConstraint?: {\n\t\t\ttype: 'force' | 'onlyIfSucceeds';\n\t\t\tvalue: number;\n\t\t};\n\t\ttaperChromaOptions?: TaperChromaOptions;\n\t} = {}\n): {\n\tcolor: PlainColorObject;\n\treached: boolean;\n\tachieved: number;\n\tdeficit?: number;\n} {\n\t// A target of 1 means same color.\n\t// A target lower than 1 doesn't make sense.\n\tif ( target <= 1 ) {\n\t\treturn {\n\t\t\tcolor: reference,\n\t\t\treached: true,\n\t\t\tachieved: 1,\n\t\t};\n\t}\n\n\tfunction getColorForL( l: number ): PlainColorObject {\n\t\tlet newL = l;\n\t\tlet newC = get( seed, [ OKLCH, 'c' ] );\n\n\t\tif ( taperChromaOptions ) {\n\t\t\tconst tapered = taperChroma( seed, newL, taperChromaOptions );\n\t\t\t// taperChroma returns either { l, c } or a ColorObject\n\t\t\tif ( 'l' in tapered && 'c' in tapered ) {\n\t\t\t\tnewL = tapered.l;\n\t\t\t\tnewC = tapered.c;\n\t\t\t} else {\n\t\t\t\t// It's already a ColorObject, return it directly\n\t\t\t\treturn tapered;\n\t\t\t}\n\t\t}\n\n\t\treturn clampToGamut( {\n\t\t\tspaceId: 'oklch',\n\t\t\tcoords: [ newL, newC, get( seed, [ OKLCH, 'h' ] ) ],\n\t\t} );\n\t}\n\n\t// Set the boundary based on the direction.\n\tconst mostContrastingL = direction === 'lighter' ? 1 : 0;\n\tconst mostContrastingColor = direction === 'lighter' ? WHITE : BLACK;\n\tconst highestContrast = getContrast( reference, mostContrastingColor );\n\n\tif ( lightnessConstraint ) {\n\t\t// Apply a specific L value.\n\t\t// Useful when pinning a step to a specific lightness, of to specify\n\t\t// min/max L values.\n\t\tconst colorWithExactL = getColorForL( lightnessConstraint.value );\n\t\tconst exactLContrast = getContrast( reference, colorWithExactL );\n\t\tconst exactLContrastMeetsTarget =\n\t\t\tcdiff( exactLContrast, target ) >= -CONTRAST_EPSILON;\n\n\t\t// If the L constraint is of \"force\" type, apply it even when it doesn't\n\t\t// meet the contrast target.\n\t\tif (\n\t\t\texactLContrastMeetsTarget ||\n\t\t\tlightnessConstraint.type === 'force'\n\t\t) {\n\t\t\treturn {\n\t\t\t\tcolor: colorWithExactL,\n\t\t\t\treached: exactLContrastMeetsTarget,\n\t\t\t\tachieved: exactLContrast,\n\t\t\t\tdeficit: exactLContrastMeetsTarget\n\t\t\t\t\t? cdiff( exactLContrast, highestContrast )\n\t\t\t\t\t: cdiff( target, exactLContrast ),\n\t\t\t};\n\t\t}\n\t}\n\n\t// If even the most contrasting color can't reach the target, the target is unreachable.\n\t// On the other hand, if the contrast is very close to the target, we consider it reached.\n\tif ( cdiff( highestContrast, target ) <= CONTRAST_EPSILON ) {\n\t\treturn {\n\t\t\tcolor: mostContrastingColor,\n\t\t\treached: cdiff( highestContrast, target ) >= -CONTRAST_EPSILON,\n\t\t\tachieved: highestContrast,\n\t\t\tdeficit: cdiff( target, highestContrast ),\n\t\t};\n\t}\n\n\t// Bracket: low fails, high meets.\n\t// Originally this was seed.oklch.l \u2014 although it's an assumption that works\n\t// only when we know for sure the direction of the search.\n\t// TODO: can we bring this back to seed.oklch.l ?\n\tconst lowerL = get( reference, [ OKLCH, 'l' ] );\n\tconst lowerContrast = cdiff( 1, target );\n\tconst upperL = mostContrastingL;\n\tconst upperContrast = cdiff( highestContrast, target );\n\n\tconst bestColor = solveWithBisect(\n\t\tgetColorForL,\n\t\t( c ) => cdiff( getContrast( reference, c ), target ),\n\t\tlowerL,\n\t\tlowerContrast,\n\t\tupperL,\n\t\tupperContrast\n\t);\n\n\treturn {\n\t\tcolor: bestColor,\n\t\treached: true,\n\t\tachieved: target,\n\t\t// Negative number that specifies how much room we have.\n\t\tdeficit: cdiff( target, highestContrast ),\n\t};\n}\n", "/**\n * External dependencies\n */\nimport {\n\tclone,\n\tget,\n\tOKLCH,\n\tset,\n\ttype ColorTypes,\n\ttype PlainColorObject,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport { clampToGamut, getContrast, getColorString } from './color-utils';\nimport { findColorMeetingRequirements } from './find-color-with-constraints';\nimport {\n\tsortByDependency,\n\tcomputeBetterFgColorDirection,\n\tadjustContrastTarget,\n\tstepsForStep,\n\tsolveWithBisect,\n} from './utils';\n\nimport type {\n\tFollowDirection,\n\tRamp,\n\tRampDirection,\n\tRampConfig,\n\tRampResult,\n} from './types';\nimport { CONTRAST_EPSILON } from './constants';\n\n/**\n * Calculate a complete color ramp based on the provided configuration.\n *\n * @param params - The calculation parameters\n * @param params.seed - The base color to build the ramp from\n * @param params.sortedSteps - Steps sorted in dependency order\n * @param params.config - Ramp configuration defining contrast requirements\n * @param params.mainDir - Primary direction for the ramp (lighter/darker)\n * @param params.oppDir - Opposite direction from mainDir\n * @param params.pinLightness - Optional lightness override for a given step\n * @param params.pinLightness.stepName\n * @param params.pinLightness.value\n * @return Object containing ramp results and satisfaction status\n */\nfunction calculateRamp( {\n\tseed,\n\tsortedSteps,\n\tconfig,\n\tmainDir,\n\toppDir,\n\tpinLightness,\n}: {\n\tseed: PlainColorObject;\n\tsortedSteps: ( keyof Ramp )[];\n\tconfig: RampConfig;\n\tmainDir: RampDirection;\n\toppDir: RampDirection;\n\tpinLightness?: {\n\t\tstepName: keyof Ramp;\n\t\tvalue: number;\n\t};\n} ) {\n\tconst rampResults = {} as Record< keyof Ramp, string >;\n\tlet warnings: string[] | undefined;\n\tlet maxDeficit = -Infinity;\n\tlet maxDeficitDirection: RampDirection = 'lighter';\n\tlet maxDeficitStep;\n\n\t// Keep track of the calculated colors, as they are going to be useful\n\t// when other colors reference them.\n\tconst calculatedColors = new Map< keyof Ramp | 'seed', PlainColorObject >();\n\tcalculatedColors.set( 'seed', seed );\n\n\tfor ( const stepName of sortedSteps ) {\n\t\tconst {\n\t\t\tcontrast,\n\t\t\tlightness: stepLightnessConstraint,\n\t\t\ttaperChromaOptions,\n\t\t\tsameAsIfPossible,\n\t\t} = config[ stepName ];\n\n\t\tconst referenceColor = calculatedColors.get( contrast.reference );\n\t\tif ( ! referenceColor ) {\n\t\t\tthrow new Error(\n\t\t\t\t`Reference color for step ${ stepName } not found: ${ contrast.reference }`\n\t\t\t);\n\t\t}\n\n\t\t// Check if we can reuse color from the `sameAsIfPossible` config option\n\t\tif ( sameAsIfPossible ) {\n\t\t\tconst candidateColor = calculatedColors.get( sameAsIfPossible );\n\t\t\tif ( ! candidateColor ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Same-as color for step ${ stepName } not found: ${ sameAsIfPossible }`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst candidateContrast = getContrast(\n\t\t\t\treferenceColor,\n\t\t\t\tcandidateColor\n\t\t\t);\n\t\t\tconst adjustedTarget = adjustContrastTarget( contrast.target );\n\t\t\t// If the candidate meets the contrast requirement, use it\n\t\t\tif ( candidateContrast >= adjustedTarget ) {\n\t\t\t\t// Store the reused color\n\t\t\t\tcalculatedColors.set( stepName, candidateColor );\n\t\t\t\trampResults[ stepName ] = getColorString( candidateColor );\n\n\t\t\t\tcontinue; // Skip to next step\n\t\t\t}\n\t\t}\n\n\t\tfunction computeDirection(\n\t\t\tcolor: ColorTypes,\n\t\t\tfollowDirection: FollowDirection\n\t\t): RampDirection {\n\t\t\tif ( followDirection === 'main' ) {\n\t\t\t\treturn mainDir;\n\t\t\t}\n\n\t\t\tif ( followDirection === 'opposite' ) {\n\t\t\t\treturn oppDir;\n\t\t\t}\n\n\t\t\tif ( followDirection === 'best' ) {\n\t\t\t\treturn computeBetterFgColorDirection(\n\t\t\t\t\tcolor,\n\t\t\t\t\tcontrast.preferLighter\n\t\t\t\t).better;\n\t\t\t}\n\n\t\t\treturn followDirection;\n\t\t}\n\n\t\tconst computedDir = computeDirection(\n\t\t\treferenceColor,\n\t\t\tcontrast.followDirection\n\t\t);\n\n\t\tconst adjustedTarget = adjustContrastTarget( contrast.target );\n\n\t\t// Define the lightness constraint, if needed.\n\t\tlet lightnessConstraint;\n\t\tif ( pinLightness?.stepName === stepName ) {\n\t\t\tlightnessConstraint = {\n\t\t\t\tvalue: pinLightness.value,\n\t\t\t\ttype: 'force',\n\t\t\t} as const;\n\t\t} else if ( stepLightnessConstraint ) {\n\t\t\tlightnessConstraint = {\n\t\t\t\tvalue: stepLightnessConstraint( computedDir ),\n\t\t\t\ttype: 'onlyIfSucceeds',\n\t\t\t} as const;\n\t\t}\n\n\t\t// Calculate the color meeting the requirements\n\t\tconst searchResults = findColorMeetingRequirements(\n\t\t\treferenceColor,\n\t\t\tseed,\n\t\t\tadjustedTarget,\n\t\t\tcomputedDir,\n\t\t\t{\n\t\t\t\tlightnessConstraint,\n\t\t\t\ttaperChromaOptions,\n\t\t\t}\n\t\t);\n\n\t\t// When the target contrast is not met, take note of it and use\n\t\t// that information to guide the ramp calculation bisection.\n\t\tif (\n\t\t\t! contrast.ignoreWhenAdjustingSeed &&\n\t\t\tsearchResults.deficit &&\n\t\t\tsearchResults.deficit > maxDeficit\n\t\t) {\n\t\t\tmaxDeficit = searchResults.deficit;\n\t\t\tmaxDeficitDirection = computedDir;\n\t\t\tmaxDeficitStep = stepName;\n\t\t}\n\n\t\t// Store calculated color for future dependencies\n\t\tcalculatedColors.set( stepName, searchResults.color );\n\n\t\t// Add to results\n\t\trampResults[ stepName ] = getColorString( searchResults.color );\n\n\t\tif ( ! searchResults.reached && ! contrast.ignoreWhenAdjustingSeed ) {\n\t\t\twarnings ??= [];\n\t\t\twarnings.push( stepName );\n\t\t}\n\t}\n\n\treturn {\n\t\trampResults,\n\t\twarnings,\n\t\tmaxDeficit,\n\t\tmaxDeficitDirection,\n\t\tmaxDeficitStep,\n\t};\n}\n\nexport function buildRamp(\n\tseedArg: string,\n\tconfig: RampConfig,\n\t{\n\t\tmainDirection,\n\t\tpinLightness,\n\t\trescaleToFitContrastTargets = true,\n\t}: {\n\t\tmainDirection?: RampDirection;\n\t\tpinLightness?: {\n\t\t\tstepName: keyof Ramp;\n\t\t\tvalue: number;\n\t\t};\n\t\trescaleToFitContrastTargets?: boolean;\n\t} = {}\n): RampResult {\n\tlet seed: PlainColorObject;\n\ttry {\n\t\tseed = clampToGamut( seedArg );\n\t} catch ( error ) {\n\t\tthrow new Error(\n\t\t\t`Invalid seed color \"${ seedArg }\": ${\n\t\t\t\terror instanceof Error ? error.message : 'Unknown error'\n\t\t\t}`\n\t\t);\n\t}\n\n\tlet mainDir: RampDirection = 'lighter';\n\tlet oppDir: RampDirection = 'darker';\n\n\tif ( mainDirection ) {\n\t\tmainDir = mainDirection;\n\t\toppDir = mainDirection === 'darker' ? 'lighter' : 'darker';\n\t} else {\n\t\tconst { better, worse } = computeBetterFgColorDirection( seed );\n\t\tmainDir = better;\n\t\toppDir = worse;\n\t}\n\n\t// Get the correct calculation order based on dependencies\n\tconst sortedSteps = sortByDependency( config );\n\n\t// Calculate the ramp with the initial seed.\n\tconst {\n\t\trampResults,\n\t\twarnings,\n\t\tmaxDeficit,\n\t\tmaxDeficitDirection,\n\t\tmaxDeficitStep,\n\t} = calculateRamp( {\n\t\tseed,\n\t\tsortedSteps,\n\t\tconfig,\n\t\tmainDir,\n\t\toppDir,\n\t\tpinLightness,\n\t} );\n\n\tlet bestRamp = rampResults;\n\n\tif ( maxDeficit > CONTRAST_EPSILON && rescaleToFitContrastTargets ) {\n\t\tconst iterSteps = stepsForStep( maxDeficitStep!, config );\n\n\t\tfunction getSeedForL( l: number ): PlainColorObject {\n\t\t\treturn clampToGamut( set( clone( seed ), [ OKLCH, 'l' ], l ) );\n\t\t}\n\n\t\tfunction getDeficitForSeed( s: PlainColorObject ): number {\n\t\t\tconst iterationResults = calculateRamp( {\n\t\t\t\tseed: s,\n\t\t\t\tsortedSteps: iterSteps,\n\t\t\t\tconfig,\n\t\t\t\tmainDir,\n\t\t\t\toppDir,\n\t\t\t\tpinLightness,\n\t\t\t} );\n\n\t\t\t// If the constraints start failing in the opposite direction to the original\n\t\t\t// iteration's direction, that means we've moved too far away from the target.\n\t\t\t// Don't use the `maxDeficit` value because it's not related to our search,\n\t\t\t// and might even be positive, which would confuse the bisection algorithm.\n\t\t\treturn iterationResults.maxDeficitDirection === maxDeficitDirection\n\t\t\t\t? iterationResults.maxDeficit\n\t\t\t\t: -maxDeficit;\n\t\t}\n\n\t\t// For a scale with the \"lighter\" direction, the contrast can be improved\n\t\t// by darkening the seed. For \"darker\" direction, by lightening the seed.\n\t\tconst lowerSeedL = maxDeficitDirection === 'lighter' ? 0 : 1;\n\t\tconst lowerDeficit = -maxDeficit;\n\t\tconst upperSeedL = get( seed, [ OKLCH, 'l' ] );\n\t\tconst upperDeficit = maxDeficit;\n\n\t\tconst bestSeed = solveWithBisect(\n\t\t\tgetSeedForL,\n\t\t\tgetDeficitForSeed,\n\t\t\tlowerSeedL,\n\t\t\tlowerDeficit,\n\t\t\tupperSeedL,\n\t\t\tupperDeficit\n\t\t);\n\n\t\t// Calculate the final ramp with adjusted seed.\n\t\tbestRamp = calculateRamp( {\n\t\t\tseed: bestSeed,\n\t\t\tsortedSteps,\n\t\t\tconfig,\n\t\t\tmainDir,\n\t\t\toppDir,\n\t\t\tpinLightness,\n\t\t} ).rampResults;\n\t}\n\n\t// Swap surface1 and surface3 for darker ramps to maintain visual elevation hierarchy.\n\t// This ensures surface1 appears \"behind\" surface2, and surface3 appears \"in front\",\n\t// regardless of the ramp's main direction.\n\tif ( mainDir === 'darker' ) {\n\t\tconst tmpSurface1 = bestRamp.surface1;\n\t\tbestRamp.surface1 = bestRamp.surface3;\n\t\tbestRamp.surface3 = tmpSurface1;\n\t}\n\n\treturn {\n\t\tramp: bestRamp,\n\t\twarnings,\n\t\tdirection: mainDir,\n\t};\n}\n", "/**\n * Internal dependencies\n */\nimport type { RampStepConfig, RampConfig, RampDirection } from './types';\nimport type { TaperChromaOptions } from './taper-chroma';\n\nconst lightnessConstraintForegroundHighContrast = (\n\tdirection: RampDirection\n) =>\n\tdirection === 'lighter'\n\t\t? 0.9551 // lightness of #f0f0f0 (ie $gray-100)\n\t\t: 0.235; // lightness of #1e1e1e (ie $gray-900)\nconst lightnessConstraintForegroundMediumContrast = (\n\tdirection: RampDirection\n) =>\n\tdirection === 'lighter'\n\t\t? 0.77 // lightness of #b4b4b4\n\t\t: 0.56; // lightness of #747474\nconst lightnessConstraintBgFill = ( direction: RampDirection ) =>\n\tdirection === 'lighter'\n\t\t? 0.67 // lightness of #969696 (7:1 vs black)\n\t\t: 0.45; // lightness of #555555 (7:1 vs white)\n\nconst BG_SURFACE_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.7,\n};\nconst FG_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.6,\n\tkLight: 0.2,\n\tkDark: 0.2,\n};\nconst STROKE_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.6,\n\tradiusDark: 0.01,\n\tradiusLight: 0.01,\n\tkLight: 0.8,\n\tkDark: 0.8,\n};\nconst ACCENT_SURFACE_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.75,\n\tradiusDark: 0.01,\n\tradiusLight: 0.01,\n};\n\nconst fgSurface4Config: RampStepConfig = {\n\tcontrast: {\n\t\treference: 'surface3',\n\t\tfollowDirection: 'main',\n\t\ttarget: 7,\n\t\tpreferLighter: true,\n\t},\n\tlightness: lightnessConstraintForegroundHighContrast,\n\ttaperChromaOptions: FG_TAPER_CHROMA,\n};\n\nexport const BG_RAMP_CONFIG: RampConfig = {\n\t// Surface\n\tsurface1: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: 1.06,\n\t\t\tignoreWhenAdjustingSeed: true,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface2: {\n\t\tcontrast: {\n\t\t\treference: 'seed',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1,\n\t\t},\n\t},\n\tsurface3: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.06,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface4: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.12,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface5: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.2,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface6: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.4,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\t// Bg fill\n\tbgFill1: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 4,\n\t\t},\n\t\tlightness: lightnessConstraintBgFill,\n\t},\n\tbgFill2: {\n\t\tcontrast: {\n\t\t\treference: 'bgFill1',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.2,\n\t\t},\n\t},\n\tbgFillInverted1: {\n\t\tcontrast: {\n\t\t\treference: 'bgFillInverted2',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: 1.2,\n\t\t},\n\t},\n\tbgFillInverted2: fgSurface4Config,\n\tbgFillDark: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'darker', // This is what causes the token to be always dark\n\t\t\ttarget: 7,\n\t\t\tignoreWhenAdjustingSeed: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundHighContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\t// Stroke\n\tstroke1: {\n\t\tcontrast: {\n\t\t\treference: 'stroke3',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: 2.6,\n\t\t},\n\t\ttaperChromaOptions: STROKE_TAPER_CHROMA,\n\t},\n\tstroke2: {\n\t\tcontrast: {\n\t\t\treference: 'stroke3',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: 2.4,\n\t\t},\n\t\ttaperChromaOptions: STROKE_TAPER_CHROMA,\n\t},\n\tstroke3: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 3,\n\t\t},\n\t\ttaperChromaOptions: STROKE_TAPER_CHROMA,\n\t},\n\tstroke4: {\n\t\tcontrast: {\n\t\t\treference: 'stroke3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.5,\n\t\t},\n\t\ttaperChromaOptions: STROKE_TAPER_CHROMA,\n\t},\n\t// fgSurface\n\tfgSurface1: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 2,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgSurface2: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 3,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgSurface3: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 4.5,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundMediumContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgSurface4: fgSurface4Config,\n\t// fgFill\n\tfgFill: {\n\t\tcontrast: {\n\t\t\treference: 'bgFill1',\n\t\t\tfollowDirection: 'best',\n\t\t\ttarget: 4.5,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundHighContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgFillInverted: {\n\t\tcontrast: {\n\t\t\treference: 'bgFillInverted1',\n\t\t\tfollowDirection: 'best',\n\t\t\ttarget: 4.5,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundHighContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgFillDark: {\n\t\tcontrast: {\n\t\t\treference: 'bgFillDark',\n\t\t\tfollowDirection: 'best',\n\t\t\ttarget: 4.5,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundHighContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n};\n\n// BG_RAMP: seed => surface2 => {bgFill, surface3 => all other tokens}\n// ACCENT_RAMP: seed => bgFill1 => surface2 => surface3 => all other tokens\nexport const ACCENT_RAMP_CONFIG: RampConfig = {\n\t...BG_RAMP_CONFIG,\n\tsurface1: {\n\t\t...BG_RAMP_CONFIG.surface1,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface2: {\n\t\tcontrast: {\n\t\t\treference: 'bgFill1',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: BG_RAMP_CONFIG.bgFill1.contrast.target,\n\t\t\tignoreWhenAdjustingSeed: true,\n\t\t},\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface3: {\n\t\t...BG_RAMP_CONFIG.surface3,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface4: {\n\t\t...BG_RAMP_CONFIG.surface4,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface5: {\n\t\t...BG_RAMP_CONFIG.surface5,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface6: {\n\t\t...BG_RAMP_CONFIG.surface6,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tbgFill1: {\n\t\tcontrast: {\n\t\t\treference: 'seed',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1,\n\t\t},\n\t},\n\tstroke1: {\n\t\t...BG_RAMP_CONFIG.stroke1,\n\t},\n\tstroke2: {\n\t\t...BG_RAMP_CONFIG.stroke2,\n\t},\n\tstroke3: {\n\t\t...BG_RAMP_CONFIG.stroke3,\n\t\tsameAsIfPossible: 'fgSurface3',\n\t\ttaperChromaOptions: undefined,\n\t},\n\tstroke4: {\n\t\t...BG_RAMP_CONFIG.stroke4,\n\t\ttaperChromaOptions: undefined,\n\t},\n\t// fgSurface: do not de-saturate\n\tfgSurface1: {\n\t\t...BG_RAMP_CONFIG.fgSurface1,\n\t\ttaperChromaOptions: undefined,\n\t},\n\tfgSurface2: {\n\t\t...BG_RAMP_CONFIG.fgSurface2,\n\t\ttaperChromaOptions: undefined,\n\t},\n\tfgSurface3: {\n\t\t...BG_RAMP_CONFIG.fgSurface3,\n\t\ttaperChromaOptions: undefined,\n\t\tsameAsIfPossible: 'bgFill1',\n\t},\n\tfgSurface4: {\n\t\t...BG_RAMP_CONFIG.fgSurface4,\n\t\ttaperChromaOptions: undefined,\n\t},\n};\n", "/**\n * External dependencies\n */\nimport { get, OKLCH } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './lib/register-color-spaces';\nimport { buildRamp } from './lib/index';\nimport { clampAccentScaleReferenceLightness } from './lib/utils';\nimport { BG_RAMP_CONFIG, ACCENT_RAMP_CONFIG } from './lib/ramp-configs';\nimport type {\n\tRampResult as InternalRampResult,\n\tRampDirection,\n\tRamp,\n} from './lib/types';\nimport { getContrast } from './lib/color-utils';\nimport { CONTRAST_COMBINATIONS } from './lib/constants';\nexport { DEFAULT_SEED_COLORS } from './lib/constants';\n\n/**\n * Creates a background ramp.\n * @param seed The seed color for the background ramp.\n */\nexport function buildBgRamp( seed: string ) {\n\tif ( typeof seed !== 'string' || seed.trim() === '' ) {\n\t\tthrow new Error( 'Seed color must be a non-empty string' );\n\t}\n\n\treturn buildRamp( seed, BG_RAMP_CONFIG );\n}\n\nconst STEP_TO_PIN = 'surface2';\nfunction getBgRampInfo( ramp: InternalRampResult ): {\n\tmainDirection: RampDirection;\n\tpinLightness: {\n\t\tstepName: keyof Ramp;\n\t\tvalue: number;\n\t};\n} {\n\treturn {\n\t\tmainDirection: ramp.direction,\n\t\tpinLightness: {\n\t\t\tstepName: STEP_TO_PIN,\n\t\t\tvalue: clampAccentScaleReferenceLightness(\n\t\t\t\tget( ramp.ramp[ STEP_TO_PIN ], [ OKLCH, 'l' ] ),\n\t\t\t\tramp.direction\n\t\t\t),\n\t\t},\n\t};\n}\n\n/**\n * Creates an accent ramp (ie used by primary, success, info, warning and error\n * ramps).\n * @param seed The seed color for the accent ramp.\n * @param bgRamp The ramp of the background on which the accent is shown.\n */\nexport function buildAccentRamp(\n\tseed: string,\n\tbgRamp?: InternalRampResult\n): InternalRampResult {\n\tif ( typeof seed !== 'string' || seed.trim() === '' ) {\n\t\tthrow new Error( 'Seed color must be a non-empty string' );\n\t}\n\n\tconst bgRampInfo = bgRamp ? getBgRampInfo( bgRamp ) : undefined;\n\treturn buildRamp( seed, ACCENT_RAMP_CONFIG, bgRampInfo );\n}\n\n/**\n * Checks that all bg/fg combinations generated by the ramps meet contrast\n * targets.\n * @param params\n * @param params.bgRamp\n * @param params.accentRamps\n */\nexport function checkAccessibleCombinations( {\n\tbgRamp,\n\taccentRamps = [],\n}: {\n\tbgRamp: InternalRampResult;\n\taccentRamps?: InternalRampResult[];\n} ) {\n\tconst unmetTargets: {\n\t\tbgName: keyof Ramp;\n\t\tbgColor: string;\n\t\tfgName: keyof Ramp;\n\t\tfgColor: string;\n\t\tunmetContrast: number;\n\t\tachievedContrast: number;\n\t}[] = [];\n\n\t// Assess combinations within each ramp\n\t[ bgRamp, ...accentRamps ].forEach( ( ramp ) => {\n\t\tCONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {\n\t\t\tfor ( const bg of bgs ) {\n\t\t\t\tfor ( const fg of fgs ) {\n\t\t\t\t\tconst bgColor = ramp.ramp[ bg ];\n\t\t\t\t\tconst fgColor = ramp.ramp[ fg ];\n\t\t\t\t\tconst achievedContrast = getContrast( bgColor, fgColor );\n\t\t\t\t\tif ( achievedContrast < target ) {\n\t\t\t\t\t\tunmetTargets.push( {\n\t\t\t\t\t\t\tbgName: bg,\n\t\t\t\t\t\t\tbgColor,\n\t\t\t\t\t\t\tfgName: fg,\n\t\t\t\t\t\t\tfgColor,\n\t\t\t\t\t\t\tunmetContrast: target,\n\t\t\t\t\t\t\tachievedContrast,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t} );\n\t// Assess each accent ramp's fg color against bg ramp\n\taccentRamps.forEach( ( ramp ) => {\n\t\tCONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {\n\t\t\tfor ( const bg of bgs ) {\n\t\t\t\tfor ( const fg of fgs ) {\n\t\t\t\t\tconst bgColor = bgRamp.ramp[ bg ];\n\t\t\t\t\tconst fgColor = ramp.ramp[ fg ];\n\t\t\t\t\tconst achievedContrast = getContrast( bgColor, fgColor );\n\t\t\t\t\tif ( achievedContrast < target ) {\n\t\t\t\t\t\tunmetTargets.push( {\n\t\t\t\t\t\t\tbgName: bg,\n\t\t\t\t\t\t\tbgColor,\n\t\t\t\t\t\t\tfgName: fg,\n\t\t\t\t\t\t\tfgColor,\n\t\t\t\t\t\t\tunmetContrast: target,\n\t\t\t\t\t\t\tachievedContrast,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t} );\n\n\treturn unmetTargets;\n}\n\nexport type RampResult = InternalRampResult;\n", "/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\nimport { ThemeProvider } from './theme-provider';\nimport { useThemeProviderStyles } from './use-theme-provider-styles';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tThemeProvider,\n\tuseThemeProviderStyles,\n} );\n"],
"mappings": "0pBAAA,IAAAA,GAAAC,GAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAO,QAAU,OAAO,GAAG,cCA3B,IAAAC,GAAAC,GAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAO,QAAU,OAAO,GAAG,UCA3B,IA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in", "exports", "module", "require_element", "__commonJSMin", "exports", "module", "require_jsx_runtime", "__commonJSMin", "exports", "module", "import_private_apis", "lock", "unlock", "import_element", "import_element", "ThemeContext", "dot3", "a", "b", "multiply_v3_m3x3", "input", "matrix", "out", "x", "y", "z", "isString", "str", "type", "o", "serializeNumber", "n", "precision", "unit", "isNone", "toPrecision", "toPrecision", "n", "precision", "integer", "digits", "multiplier", "interpolate", "start", "end", "p", "interpolateInv", "value", "mapRange", "from", "to", "clamp", "min", "val", "max", "copySign", "spow", "base", "exp", "zdiv", "d", "bisectLeft", "arr", "lo", "hi", "mid", "isInstance", "arg", "constructor", "targetName", "proto", "constructorName", "Type", "type", "coordMeta", "params", "min", "max", "number", "fromRange", "toRange", "mapRange", "precision", "unit", "serializeNumber", "ret", "scale", "range", "isInstance", "instance", "Format", "_Format", "format", "space", "coordMeta", "ret", "types", "i", "type", "Type", "coords", "precision", "_", "c", "id", "arg", "isNone", "providedType", "coordName", "str", "args", "isInstance", "Hooks", "name", "callback", "first", "env", "hooks", "hooks_default", "WHITES", "getWhite", "name", "adapt", "W1", "W2", "XYZ", "options", "env", "hooks_default", "multiply_v3_m3x3", "defaults_default", "msg", "parse", "str", "options", "env", "hooks_default", "parseFunction", "ret", "meta", "name", "format", "space", "coords", "types", "i", "id", "alternateId", "ids", "ColorSpace", "didYouMean", "registryId", "cssId", "defaults_default", "alpha", "coordCount", "spaceloop", "formatId", "formatObject", "color", "isNone", "clamp", "units", "regex", "parseArgument", "rawArg", "unit", "value", "parts", "args", "argMeta", "lastAlpha", "separators", "$0", "getColor", "color", "options", "c", "isString", "parse", "space", "ColorSpace", "\u03B5", "ColorSpace", "_ColorSpace", "options", "coords", "name", "white", "getWhite", "format", "getPath", "hooks_default", "epsilon", "coordMeta", "c", "i", "meta", "isNone", "min", "max", "coord", "id", "ret", "Format", "space", "color", "getColor", "myPath", "otherPath", "connectionSpace", "connectionSpaceIndex", "range", "alias", "alternatives", "isInstance", "type", "filters", "spaces", "matches", "ids", "filterIds", "ref", "workingSpace", "coordType", "normalizedCoord", "s", "xyz_d65_default", "ColorSpace", "RGBColorSpace", "ColorSpace", "options", "xyz_d65_default", "rgb", "xyz", "multiply_v3_m3x3", "adapt", "getAll", "color", "options", "getColor", "space", "ColorSpace", "precision", "coords", "coord", "toPrecision", "get", "color", "prop", "getColor", "space", "index", "ColorSpace", "getAll", "setAll", "color", "space", "coords", "alpha", "getColor", "ColorSpace", "set", "color", "prop", "value", "getColor", "type", "object", "p", "get", "space", "index", "ColorSpace", "coords", "getAll", "setAll", "xyz_d50_default", "ColorSpace", "xyz_d65_default", "coords", "adapt", "\u03B5", "\u03B53", "\u03BA", "white", "WHITES", "lab_default", "ColorSpace", "xyz_d50_default", "XYZ", "f", "value", "L", "b", "Lab", "a", "constrain", "angle", "lch_default", "ColorSpace", "lab_default", "Lab", "range", "extent", "L", "a", "b", "isAchromatic", "h", "constrain", "C", "lch", "isNone", "Gfactor", "\u03C0", "r2d", "d2r", "pow7", "x", "x2", "deltaE2000_default", "color", "sample", "kL", "kC", "kH", "getColor", "L1", "a1", "b1", "lab_default", "C1", "lch_default", "L2", "a2", "b2", "C2", "Cbar", "C7", "G", "adash1", "adash2", "Cdash1", "Cdash2", "h1", "h2", "\u0394L", "\u0394C", "hdiff", "hsum", "habs", "\u0394h", "defaults_default", "\u0394H", "Ldash", "Cdash", "Cdash7", "hdash", "lsq", "SL", "SC", "T", "SH", "\u0394\u03B8", "RC", "RT", "dE", "XYZtoLMS_M", "LMStoXYZ_M", "LMStoLab_M", "LabtoLMS_M", "oklab_default", "ColorSpace", "xyz_d65_default", "XYZ", "LMS", "multiply_v3_m3x3", "OKLab", "LMSg", "deltaEOK_default", "color", "sample", "getColor", "L1", "a1", "b1", "oklab_default", "L2", "a2", "b2", "\u0394L", "\u0394a", "\u0394b", "\u03B5", "inGamut", "color", "space", "epsilon", "getColor", "ColorSpace", "coords", "clone", "color", "distance", "color1", "color2", "space", "ColorSpace", "coords1", "coords2", "acc", "c1", "c2", "isNone", "deltaE76", "color", "sample", "distance", "\u03C0", "d2r", "deltaECMC_default", "color", "sample", "l", "c", "getColor", "L1", "a1", "b1", "lab_default", "C1", "H1", "lch_default", "L2", "a2", "b2", "C2", "\u0394L", "\u0394C", "\u0394a", "\u0394b", "H2", "SL", "SC", "T", "isNone", "C4", "F", "SH", "dE", "Yw", "xyz_abs_d65_default", "ColorSpace", "xyz_d65_default", "XYZ", "v", "AbsXYZ", "b", "g", "n", "ninv", "c1", "c2", "c3", "p", "pinv", "d", "d0", "XYZtoCone_M", "ConetoXYZ_M", "ConetoIab_M", "IabtoCone_M", "jzazbz_default", "ColorSpace", "xyz_abs_d65_default", "XYZ", "Xa", "Ya", "Za", "Xm", "Ym", "PQLMS", "multiply_v3_m3x3", "val", "num", "spow", "denom", "Iz", "az", "bz", "Jzazbz", "Jz", "LMS", "jzczhz_default", "ColorSpace", "jzazbz_default", "lch_default", "deltaEJz_default", "color", "sample", "getColor", "Jz1", "Cz1", "Hz1", "jzczhz_default", "Jz2", "Cz2", "Hz2", "\u0394J", "\u0394C", "isNone", "\u0394h", "\u0394H", "c1", "c2", "c3", "m1", "m2", "im1", "im2", "XYZtoLMS_M", "LMStoIPT_M", "IPTtoLMS_M", "LMStoXYZ_M", "ictcp_default", "ColorSpace", "xyz_abs_d65_default", "XYZ", "LMS", "multiply_v3_m3x3", "LMStoICtCp", "ICtCp", "ICtCptoLMS", "PQLMS", "val", "num", "denom", "deltaEITP_default", "color", "sample", "getColor", "I1", "T1", "P1", "ictcp_default", "I2", "T2", "P2", "deltaEOK2_default", "color", "sample", "getColor", "abscale", "L1", "a1", "b1", "oklab_default", "L2", "a2", "b2", "\u0394L", "\u0394a", "\u0394b", "white", "WHITES", "adaptedCoef", "adaptedCoefInv", "tau", "cat16", "cat16Inv", "m1", "surroundMap", "hueQuadMap", "rad2deg", "deg2rad", "adapt", "coords", "fl", "c", "x", "spow", "copySign", "unadapt", "adapted", "constant", "cabs", "hueQuadrature", "h", "hp", "constrain", "i", "bisectLeft", "hi", "hii", "ei", "eii", "Hi", "t", "invHueQuadrature", "H", "Hp", "environment", "refWhite", "adaptingLuminance", "backgroundLuminance", "surround", "discounting", "env", "xyzW", "yw", "rgbW", "multiply_v3_m3x3", "values", "f", "k4", "d", "interpolate", "rgbCW", "rgbAW", "viewingConditions", "fromCam16", "cam16", "hRad", "cosh", "sinh", "Jroot", "alpha", "et", "A", "p1", "p2", "r", "zdiv", "a", "b", "rgb_c", "toCam16", "xyzd65", "xyz100", "rgbA", "J", "Q", "C", "M", "s", "cam16_default", "ColorSpace", "xyz_d65_default", "xyz", "isAchromatic", "white", "WHITES", "\u03B5", "\u03BA", "toLstar", "y", "fromLstar", "lstar", "fromHct", "coords", "env", "h", "c", "t", "xyz", "j", "threshold", "max_attempts", "attempt", "last", "best", "fromCam16", "delta", "toHct", "cam16", "toCam16", "viewingConditions", "constrain", "environment", "hct_default", "ColorSpace", "xyz_d65_default", "hct", "rad2deg", "deg2rad", "ucsCoeff", "convertUcsAb", "coords", "hct_default", "M", "viewingConditions", "hrad", "a", "b", "deltaEHCT_default", "color", "sample", "getColor", "t1", "a1", "b1", "t2", "a2", "b2", "deltaE_default", "deltaE76", "deltaECMC_default", "deltaE2000_default", "deltaEJz_default", "deltaEITP_default", "deltaEOK_default", "deltaEOK2_default", "deltaEHCT_default", "calcEpsilon", "jnd", "order", "GMAPPRESET", "toGamut", "color", "method", "defaults_default", "space", "deltaEMethod", "blackWhiteClamp", "getColor", "isString", "ColorSpace", "inGamut", "spaceColor", "toGamutCSS", "de", "deltaE2000_default", "m", "deltaE_default", "clipped", "to", "channelMeta", "channel", "get", "isNone", "WHITES", "coordMeta", "mapSpace", "coordId", "mappedColor", "c", "i", "min", "\u03B5", "low", "high", "clone", "set", "bounds", "max", "COLORS", "oklab_default", "origin", "oklchSpace", "origin_OKLCH", "L", "white", "black", "clip", "_color", "destColor", "spaceCoords", "coord", "index", "clamp", "min_inGamut", "current", "E", "deltaEOK_default", "chroma", "to", "color", "space", "inGamut", "getColor", "ColorSpace", "coords", "ret", "toGamut", "serialize", "color", "options", "precision", "defaults_default", "format", "inGamut", "coordFormat", "alphaFormat", "commas", "ret", "colorWithMeta", "getColor", "formatId", "parseMeta", "ColorSpace", "to", "coords", "toGamut", "clone", "name", "args", "cssId", "alpha", "alphaType", "serializeAlpha", "strAlpha", "unit", "serializeNumber", "toXYZ_M", "fromXYZ_M", "p3_linear_default", "RGBColorSpace", "toXYZ_M", "fromXYZ_M", "srgb_linear_default", "RGBColorSpace", "keywords_default", "coordGrammar", "coordGrammarNumber", "srgb_default", "RGBColorSpace", "srgb_linear_default", "rgb", "val", "sign", "abs", "str", "rgba", "component", "coords", "alpha", "collapse", "alphaFormat", "c", "collapsible", "ret", "keywords_default", "p3_default", "RGBColorSpace", "p3_linear_default", "srgb_default", "getLuminance", "color", "get", "xyz_d65_default", "contrastWCAG21", "color1", "color2", "getColor", "Y1", "getLuminance", "Y2", "hsl_default", "ColorSpace", "srgb_default", "rgb", "max", "min", "r", "g", "b", "h", "s", "d", "hsl", "l", "f", "n", "k", "a", "oklch_default", "ColorSpace", "oklab_default", "lch_default", "memize", "fn", "options", "size", "head", "tail", "memoized", "node", "len", "args", "i", "searchCache", "import_element", "ColorSpace", "srgb_default", "oklch_default", "p3_default", "hsl_default", "color_tokens_default", "getColorString", "color", "rgbRounded", "serialize", "to", "srgb_default", "getContrast", "colorA", "colorB", "contrastWCAG21", "clampToGamut", "c", "toGamut", "oklch_default", "WHITE", "to", "oklch_default", "BLACK", "UNIVERSAL_CONTRAST_TOPUP", "WHITE_TEXT_CONTRAST_MARGIN", "ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS", "CONTRAST_EPSILON", "MAX_BISECTION_ITERATIONS", "DEFAULT_SEED_COLORS", "buildDependencyGraph", "config", "dependencies", "dependents", "step", "stepName", "stepConfig", "reference", "sortByDependency", "result", "visited", "visiting", "visit", "node", "dependent", "stepsForStep", "computeBetterFgColorDirection", "seed", "preferLighter", "contrastAgainstBlack", "getContrast", "BLACK", "contrastAgainstWhite", "WHITE", "WHITE_TEXT_CONTRAST_MARGIN", "adjustContrastTarget", "target", "UNIVERSAL_CONTRAST_TOPUP", "clampAccentScaleReferenceLightness", "rawLightness", "direction", "thresholds", "ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS", "solveWithBisect", "calculateC", "calculateValue", "initLowerL", "initLowerValue", "initUpperL", "initUpperValue", "lowerL", "lowerValue", "lowerReplaced", "upperL", "upperValue", "upperReplaced", "bestC", "bestValue", "iterations", "newL", "CONTRAST_EPSILON", "MAX_BISECTION_ITERATIONS", "taperChroma", "seed", "lTarget", "options", "gamut", "srgb_default", "alpha", "carry", "cUpperBound", "radiusLight", "radiusDark", "kLight", "kDark", "achromaEpsilon", "cSeed", "get", "oklch_default", "hSeed", "chromaIsTiny", "hueIsInvalid", "normalizeHue", "clamp01", "lSeed", "cmaxSeed", "getCachedMaxChromaAtLH", "cmaxTarget", "seedRelative", "denom", "cWithCarry", "t", "continuousTaper", "cPlanned", "x", "h", "hue", "raisedCosine", "u", "seedL", "targetL", "opts", "d", "w", "maxChromaCache", "keyMax", "l", "cap", "lq", "quantize", "hq", "cq", "step", "gamutSpace", "key", "hit", "computed", "maxInGamutChromaAtLH", "clamped", "toGamut", "cdiff", "c1", "c2", "findColorMeetingRequirements", "reference", "seed", "target", "direction", "lightnessConstraint", "taperChromaOptions", "getColorForL", "l", "newL", "newC", "get", "oklch_default", "tapered", "taperChroma", "clampToGamut", "mostContrastingL", "mostContrastingColor", "WHITE", "BLACK", "highestContrast", "getContrast", "colorWithExactL", "exactLContrast", "exactLContrastMeetsTarget", "CONTRAST_EPSILON", "lowerL", "lowerContrast", "upperL", "upperContrast", "solveWithBisect", "c", "calculateRamp", "seed", "sortedSteps", "config", "mainDir", "oppDir", "pinLightness", "rampResults", "warnings", "maxDeficit", "maxDeficitDirection", "maxDeficitStep", "calculatedColors", "stepName", "computeDirection", "color", "followDirection", "computeBetterFgColorDirection", "contrast", "stepLightnessConstraint", "taperChromaOptions", "sameAsIfPossible", "referenceColor", "candidateColor", "candidateContrast", "getContrast", "adjustedTarget", "adjustContrastTarget", "getColorString", "computedDir", "lightnessConstraint", "searchResults", "findColorMeetingRequirements", "buildRamp", "seedArg", "mainDirection", "rescaleToFitContrastTargets", "clampToGamut", "error", "better", "worse", "sortByDependency", "bestRamp", "CONTRAST_EPSILON", "getSeedForL", "l", "set", "clone", "oklch_default", "getDeficitForSeed", "s", "iterationResults", "iterSteps", "stepsForStep", "lowerSeedL", "lowerDeficit", "upperSeedL", "get", "bestSeed", "solveWithBisect", "tmpSurface1", "lightnessConstraintForegroundHighContrast", "direction", "lightnessConstraintForegroundMediumContrast", "lightnessConstraintBgFill", "BG_SURFACE_TAPER_CHROMA", "FG_TAPER_CHROMA", "STROKE_TAPER_CHROMA", "ACCENT_SURFACE_TAPER_CHROMA", "fgSurface4Config", "BG_RAMP_CONFIG", "ACCENT_RAMP_CONFIG", "buildBgRamp", "seed", "buildRamp", "BG_RAMP_CONFIG", "STEP_TO_PIN", "getBgRampInfo", "ramp", "clampAccentScaleReferenceLightness", "get", "oklch_default", "buildAccentRamp", "bgRamp", "bgRampInfo", "ACCENT_RAMP_CONFIG", "getCachedBgRamp", "memize", "buildBgRamp", "getCachedAccentRamp", "buildAccentRamp", "legacyWpComponentsOverridesCSS", "customRgbFormat", "color", "to", "srgb_default", "n", "legacyWpAdminThemeOverridesCSS", "accent", "parsedAccent", "hsl_default", "parsedL", "darker10", "set", "clone", "darker20", "getColorString", "colorTokensCSS", "computedColorRamps", "entries", "rampName", "ramp", "tokenName", "tokenValue", "key", "aliasedBy", "color_tokens_default", "aliasedId", "generateStyles", "primary", "useThemeProviderStyles", "inheritedSettings", "ThemeContext", "DEFAULT_SEED_COLORS", "bg", "resolvedSettings", "themeProviderStyles", "seeds", "bgRamp", "seed", "import_jsx_runtime", "css", "style_default", "cssObjectToText", "values", "key", "value", "generateCSSSelector", "instanceId", "isRoot", "rootSel", "instanceIdSel", "selectors", "ThemeProvider", "children", "color", "density", "themeProviderStyles", "resolvedSettings", "useThemeProviderStyles", "contextValue", "ThemeContext", "privateApis", "lock", "ThemeProvider", "useThemeProviderStyles"]
}