UNPKG

tinte

Version:

Beautiful editor themes with the best DX - install themes instantly to VS Code, Cursor, and Zed

1 lines 307 kB
{"version":3,"sources":["../../node_modules/culori/src/rgb/parseNumber.js","../../node_modules/culori/src/colors/named.js","../../node_modules/culori/src/rgb/parseNamed.js","../../node_modules/culori/src/rgb/parseHex.js","../../node_modules/culori/src/util/regex.js","../../node_modules/culori/src/rgb/parseRgbLegacy.js","../../node_modules/culori/src/_prepare.js","../../node_modules/culori/src/converter.js","../../node_modules/culori/src/modes.js","../../node_modules/culori/src/parse.js","../../node_modules/culori/src/rgb/parseRgb.js","../../node_modules/culori/src/rgb/parseTransparent.js","../../node_modules/culori/src/interpolate/lerp.js","../../node_modules/culori/src/interpolate/piecewise.js","../../node_modules/culori/src/interpolate/linear.js","../../node_modules/culori/src/fixup/alpha.js","../../node_modules/culori/src/rgb/definition.js","../../node_modules/culori/src/a98/convertA98ToXyz65.js","../../node_modules/culori/src/a98/convertXyz65ToA98.js","../../node_modules/culori/src/lrgb/convertRgbToLrgb.js","../../node_modules/culori/src/xyz65/convertRgbToXyz65.js","../../node_modules/culori/src/lrgb/convertLrgbToRgb.js","../../node_modules/culori/src/xyz65/convertXyz65ToRgb.js","../../node_modules/culori/src/a98/definition.js","../../node_modules/culori/src/util/normalizeHue.js","../../node_modules/culori/src/fixup/hue.js","../../node_modules/culori/src/cubehelix/constants.js","../../node_modules/culori/src/cubehelix/convertRgbToCubehelix.js","../../node_modules/culori/src/cubehelix/convertCubehelixToRgb.js","../../node_modules/culori/src/difference.js","../../node_modules/culori/src/average.js","../../node_modules/culori/src/cubehelix/definition.js","../../node_modules/culori/src/lch/convertLabToLch.js","../../node_modules/culori/src/lch/convertLchToLab.js","../../node_modules/culori/src/xyz65/constants.js","../../node_modules/culori/src/constants.js","../../node_modules/culori/src/lab65/convertLab65ToXyz65.js","../../node_modules/culori/src/lab65/convertLab65ToRgb.js","../../node_modules/culori/src/lab65/convertXyz65ToLab65.js","../../node_modules/culori/src/lab65/convertRgbToLab65.js","../../node_modules/culori/src/dlch/constants.js","../../node_modules/culori/src/dlch/convertDlchToLab65.js","../../node_modules/culori/src/dlch/convertLab65ToDlch.js","../../node_modules/culori/src/dlab/definition.js","../../node_modules/culori/src/dlch/definition.js","../../node_modules/culori/src/hsi/convertHsiToRgb.js","../../node_modules/culori/src/hsi/convertRgbToHsi.js","../../node_modules/culori/src/hsi/definition.js","../../node_modules/culori/src/hsl/convertHslToRgb.js","../../node_modules/culori/src/hsl/convertRgbToHsl.js","../../node_modules/culori/src/util/hue.js","../../node_modules/culori/src/hsl/parseHslLegacy.js","../../node_modules/culori/src/hsl/parseHsl.js","../../node_modules/culori/src/hsl/definition.js","../../node_modules/culori/src/hsv/convertHsvToRgb.js","../../node_modules/culori/src/hsv/convertRgbToHsv.js","../../node_modules/culori/src/hsv/definition.js","../../node_modules/culori/src/hwb/convertHwbToRgb.js","../../node_modules/culori/src/hwb/convertRgbToHwb.js","../../node_modules/culori/src/hwb/parseHwb.js","../../node_modules/culori/src/hwb/definition.js","../../node_modules/culori/src/hdr/transfer.js","../../node_modules/culori/src/itp/convertItpToXyz65.js","../../node_modules/culori/src/itp/convertXyz65ToItp.js","../../node_modules/culori/src/itp/definition.js","../../node_modules/culori/src/jab/convertXyz65ToJab.js","../../node_modules/culori/src/jab/convertJabToXyz65.js","../../node_modules/culori/src/jab/convertRgbToJab.js","../../node_modules/culori/src/jab/convertJabToRgb.js","../../node_modules/culori/src/jab/definition.js","../../node_modules/culori/src/jch/convertJabToJch.js","../../node_modules/culori/src/jch/convertJchToJab.js","../../node_modules/culori/src/jch/definition.js","../../node_modules/culori/src/xyz50/constants.js","../../node_modules/culori/src/lab/convertLabToXyz50.js","../../node_modules/culori/src/xyz50/convertXyz50ToRgb.js","../../node_modules/culori/src/lab/convertLabToRgb.js","../../node_modules/culori/src/xyz50/convertRgbToXyz50.js","../../node_modules/culori/src/lab/convertXyz50ToLab.js","../../node_modules/culori/src/lab/convertRgbToLab.js","../../node_modules/culori/src/lab/parseLab.js","../../node_modules/culori/src/lab/definition.js","../../node_modules/culori/src/lab65/definition.js","../../node_modules/culori/src/lch/parseLch.js","../../node_modules/culori/src/lch/definition.js","../../node_modules/culori/src/lch65/definition.js","../../node_modules/culori/src/lchuv/convertLuvToLchuv.js","../../node_modules/culori/src/lchuv/convertLchuvToLuv.js","../../node_modules/culori/src/luv/convertXyz50ToLuv.js","../../node_modules/culori/src/luv/convertLuvToXyz50.js","../../node_modules/culori/src/lchuv/definition.js","../../node_modules/culori/src/lrgb/definition.js","../../node_modules/culori/src/luv/definition.js","../../node_modules/culori/src/oklab/convertLrgbToOklab.js","../../node_modules/culori/src/oklab/convertRgbToOklab.js","../../node_modules/culori/src/oklab/convertOklabToLrgb.js","../../node_modules/culori/src/oklab/convertOklabToRgb.js","../../node_modules/culori/src/okhsl/helpers.js","../../node_modules/culori/src/okhsl/convertOklabToOkhsl.js","../../node_modules/culori/src/okhsl/convertOkhslToOklab.js","../../node_modules/culori/src/okhsl/modeOkhsl.js","../../node_modules/culori/src/okhsv/convertOklabToOkhsv.js","../../node_modules/culori/src/okhsv/convertOkhsvToOklab.js","../../node_modules/culori/src/okhsv/modeOkhsv.js","../../node_modules/culori/src/oklab/parseOklab.js","../../node_modules/culori/src/oklab/definition.js","../../node_modules/culori/src/oklch/parseOklch.js","../../node_modules/culori/src/oklch/definition.js","../../node_modules/culori/src/p3/convertP3ToXyz65.js","../../node_modules/culori/src/p3/convertXyz65ToP3.js","../../node_modules/culori/src/p3/definition.js","../../node_modules/culori/src/prophoto/convertXyz50ToProphoto.js","../../node_modules/culori/src/prophoto/convertProphotoToXyz50.js","../../node_modules/culori/src/prophoto/definition.js","../../node_modules/culori/src/rec2020/convertXyz65ToRec2020.js","../../node_modules/culori/src/rec2020/convertRec2020ToXyz65.js","../../node_modules/culori/src/rec2020/definition.js","../../node_modules/culori/src/xyb/constants.js","../../node_modules/culori/src/xyb/convertRgbToXyb.js","../../node_modules/culori/src/xyb/convertXybToRgb.js","../../node_modules/culori/src/xyb/definition.js","../../node_modules/culori/src/xyz50/definition.js","../../node_modules/culori/src/xyz65/convertXyz65ToXyz50.js","../../node_modules/culori/src/xyz65/convertXyz50ToXyz65.js","../../node_modules/culori/src/xyz65/definition.js","../../node_modules/culori/src/yiq/convertRgbToYiq.js","../../node_modules/culori/src/yiq/convertYiqToRgb.js","../../node_modules/culori/src/yiq/definition.js","../../node_modules/culori/src/round.js","../../node_modules/culori/src/formatter.js","../../node_modules/culori/src/map.js","../../node_modules/culori/src/util/normalizePositions.js","../../node_modules/culori/src/easing/midpoint.js","../../node_modules/culori/src/interpolate/interpolate.js","../../node_modules/culori/src/index.js","../src/lib/providers/zed.ts","../src/tinte-cli.ts"],"sourcesContent":["const parseNumber = (color, len) => {\n\tif (typeof color !== 'number') return;\n\n\t// hex3: #c93 -> #cc9933\n\tif (len === 3) {\n\t\treturn {\n\t\t\tmode: 'rgb',\n\t\t\tr: (((color >> 8) & 0xf) | ((color >> 4) & 0xf0)) / 255,\n\t\t\tg: (((color >> 4) & 0xf) | (color & 0xf0)) / 255,\n\t\t\tb: ((color & 0xf) | ((color << 4) & 0xf0)) / 255\n\t\t};\n\t}\n\n\t// hex4: #c931 -> #cc993311\n\tif (len === 4) {\n\t\treturn {\n\t\t\tmode: 'rgb',\n\t\t\tr: (((color >> 12) & 0xf) | ((color >> 8) & 0xf0)) / 255,\n\t\t\tg: (((color >> 8) & 0xf) | ((color >> 4) & 0xf0)) / 255,\n\t\t\tb: (((color >> 4) & 0xf) | (color & 0xf0)) / 255,\n\t\t\talpha: ((color & 0xf) | ((color << 4) & 0xf0)) / 255\n\t\t};\n\t}\n\n\t// hex6: #f0f1f2\n\tif (len === 6) {\n\t\treturn {\n\t\t\tmode: 'rgb',\n\t\t\tr: ((color >> 16) & 0xff) / 255,\n\t\t\tg: ((color >> 8) & 0xff) / 255,\n\t\t\tb: (color & 0xff) / 255\n\t\t};\n\t}\n\n\t// hex8: #f0f1f2ff\n\tif (len === 8) {\n\t\treturn {\n\t\t\tmode: 'rgb',\n\t\t\tr: ((color >> 24) & 0xff) / 255,\n\t\t\tg: ((color >> 16) & 0xff) / 255,\n\t\t\tb: ((color >> 8) & 0xff) / 255,\n\t\t\talpha: (color & 0xff) / 255\n\t\t};\n\t}\n};\n\nexport default parseNumber;\n","const named = {\n\taliceblue: 0xf0f8ff,\n\tantiquewhite: 0xfaebd7,\n\taqua: 0x00ffff,\n\taquamarine: 0x7fffd4,\n\tazure: 0xf0ffff,\n\tbeige: 0xf5f5dc,\n\tbisque: 0xffe4c4,\n\tblack: 0x000000,\n\tblanchedalmond: 0xffebcd,\n\tblue: 0x0000ff,\n\tblueviolet: 0x8a2be2,\n\tbrown: 0xa52a2a,\n\tburlywood: 0xdeb887,\n\tcadetblue: 0x5f9ea0,\n\tchartreuse: 0x7fff00,\n\tchocolate: 0xd2691e,\n\tcoral: 0xff7f50,\n\tcornflowerblue: 0x6495ed,\n\tcornsilk: 0xfff8dc,\n\tcrimson: 0xdc143c,\n\tcyan: 0x00ffff,\n\tdarkblue: 0x00008b,\n\tdarkcyan: 0x008b8b,\n\tdarkgoldenrod: 0xb8860b,\n\tdarkgray: 0xa9a9a9,\n\tdarkgreen: 0x006400,\n\tdarkgrey: 0xa9a9a9,\n\tdarkkhaki: 0xbdb76b,\n\tdarkmagenta: 0x8b008b,\n\tdarkolivegreen: 0x556b2f,\n\tdarkorange: 0xff8c00,\n\tdarkorchid: 0x9932cc,\n\tdarkred: 0x8b0000,\n\tdarksalmon: 0xe9967a,\n\tdarkseagreen: 0x8fbc8f,\n\tdarkslateblue: 0x483d8b,\n\tdarkslategray: 0x2f4f4f,\n\tdarkslategrey: 0x2f4f4f,\n\tdarkturquoise: 0x00ced1,\n\tdarkviolet: 0x9400d3,\n\tdeeppink: 0xff1493,\n\tdeepskyblue: 0x00bfff,\n\tdimgray: 0x696969,\n\tdimgrey: 0x696969,\n\tdodgerblue: 0x1e90ff,\n\tfirebrick: 0xb22222,\n\tfloralwhite: 0xfffaf0,\n\tforestgreen: 0x228b22,\n\tfuchsia: 0xff00ff,\n\tgainsboro: 0xdcdcdc,\n\tghostwhite: 0xf8f8ff,\n\tgold: 0xffd700,\n\tgoldenrod: 0xdaa520,\n\tgray: 0x808080,\n\tgreen: 0x008000,\n\tgreenyellow: 0xadff2f,\n\tgrey: 0x808080,\n\thoneydew: 0xf0fff0,\n\thotpink: 0xff69b4,\n\tindianred: 0xcd5c5c,\n\tindigo: 0x4b0082,\n\tivory: 0xfffff0,\n\tkhaki: 0xf0e68c,\n\tlavender: 0xe6e6fa,\n\tlavenderblush: 0xfff0f5,\n\tlawngreen: 0x7cfc00,\n\tlemonchiffon: 0xfffacd,\n\tlightblue: 0xadd8e6,\n\tlightcoral: 0xf08080,\n\tlightcyan: 0xe0ffff,\n\tlightgoldenrodyellow: 0xfafad2,\n\tlightgray: 0xd3d3d3,\n\tlightgreen: 0x90ee90,\n\tlightgrey: 0xd3d3d3,\n\tlightpink: 0xffb6c1,\n\tlightsalmon: 0xffa07a,\n\tlightseagreen: 0x20b2aa,\n\tlightskyblue: 0x87cefa,\n\tlightslategray: 0x778899,\n\tlightslategrey: 0x778899,\n\tlightsteelblue: 0xb0c4de,\n\tlightyellow: 0xffffe0,\n\tlime: 0x00ff00,\n\tlimegreen: 0x32cd32,\n\tlinen: 0xfaf0e6,\n\tmagenta: 0xff00ff,\n\tmaroon: 0x800000,\n\tmediumaquamarine: 0x66cdaa,\n\tmediumblue: 0x0000cd,\n\tmediumorchid: 0xba55d3,\n\tmediumpurple: 0x9370db,\n\tmediumseagreen: 0x3cb371,\n\tmediumslateblue: 0x7b68ee,\n\tmediumspringgreen: 0x00fa9a,\n\tmediumturquoise: 0x48d1cc,\n\tmediumvioletred: 0xc71585,\n\tmidnightblue: 0x191970,\n\tmintcream: 0xf5fffa,\n\tmistyrose: 0xffe4e1,\n\tmoccasin: 0xffe4b5,\n\tnavajowhite: 0xffdead,\n\tnavy: 0x000080,\n\toldlace: 0xfdf5e6,\n\tolive: 0x808000,\n\tolivedrab: 0x6b8e23,\n\torange: 0xffa500,\n\torangered: 0xff4500,\n\torchid: 0xda70d6,\n\tpalegoldenrod: 0xeee8aa,\n\tpalegreen: 0x98fb98,\n\tpaleturquoise: 0xafeeee,\n\tpalevioletred: 0xdb7093,\n\tpapayawhip: 0xffefd5,\n\tpeachpuff: 0xffdab9,\n\tperu: 0xcd853f,\n\tpink: 0xffc0cb,\n\tplum: 0xdda0dd,\n\tpowderblue: 0xb0e0e6,\n\tpurple: 0x800080,\n\n\t// Added in CSS Colors Level 4:\n\t// https://drafts.csswg.org/css-color/#changes-from-3\n\trebeccapurple: 0x663399,\n\n\tred: 0xff0000,\n\trosybrown: 0xbc8f8f,\n\troyalblue: 0x4169e1,\n\tsaddlebrown: 0x8b4513,\n\tsalmon: 0xfa8072,\n\tsandybrown: 0xf4a460,\n\tseagreen: 0x2e8b57,\n\tseashell: 0xfff5ee,\n\tsienna: 0xa0522d,\n\tsilver: 0xc0c0c0,\n\tskyblue: 0x87ceeb,\n\tslateblue: 0x6a5acd,\n\tslategray: 0x708090,\n\tslategrey: 0x708090,\n\tsnow: 0xfffafa,\n\tspringgreen: 0x00ff7f,\n\tsteelblue: 0x4682b4,\n\ttan: 0xd2b48c,\n\tteal: 0x008080,\n\tthistle: 0xd8bfd8,\n\ttomato: 0xff6347,\n\tturquoise: 0x40e0d0,\n\tviolet: 0xee82ee,\n\twheat: 0xf5deb3,\n\twhite: 0xffffff,\n\twhitesmoke: 0xf5f5f5,\n\tyellow: 0xffff00,\n\tyellowgreen: 0x9acd32\n};\n\nexport default named;\n","import parseNumber from './parseNumber.js';\nimport named from '../colors/named.js';\n\n// Also supports the `transparent` color as defined in:\n// https://drafts.csswg.org/css-color/#transparent-black\nconst parseNamed = color => {\n\treturn parseNumber(named[color.toLowerCase()], 6);\n};\n\nexport default parseNamed;\n","import parseNumber from './parseNumber.js';\n\nconst hex = /^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i;\n\nconst parseHex = color => {\n\tlet match;\n\t// eslint-disable-next-line no-cond-assign\n\treturn (match = color.match(hex))\n\t\t? parseNumber(parseInt(match[1], 16), match[1].length)\n\t\t: undefined;\n};\n\nexport default parseHex;\n","/*\n\tBasic building blocks for color regexes\n\t---------------------------------------\n\n\tThese regexes are expressed as strings\n\tto be interpolated in the color regexes.\n */\n\n// <number>\nexport const num = '([+-]?\\\\d*\\\\.?\\\\d+(?:[eE][+-]?\\\\d+)?)';\n\n// <number> or 'none'\nexport const num_none = `(?:${num}|none)`;\n\n// <percentage>\nexport const per = `${num}%`;\n\n// <percent> or 'none'\nexport const per_none = `(?:${num}%|none)`;\n\n// <number-percentage> (<alpha-value>)\nexport const num_per = `(?:${num}%|${num})`;\n\n// <number-percentage> (<alpha-value>) or 'none'\nexport const num_per_none = `(?:${num}%|${num}|none)`;\n\n// <hue>\nexport const hue = `(?:${num}(deg|grad|rad|turn)|${num})`;\n\n// <hue> or 'none'\nexport const hue_none = `(?:${num}(deg|grad|rad|turn)|${num}|none)`;\n\nexport const c = `\\\\s*,\\\\s*`; // comma\nexport const so = '\\\\s*'; // space, optional\nexport const s = `\\\\s+`; // space\n\nexport const rx_num_per_none = new RegExp('^' + num_per_none + '$');\n","import { num, per, num_per, c } from '../util/regex.js';\n\n/*\n\trgb() regular expressions for legacy format\n\tReference: https://drafts.csswg.org/css-color/#rgb-functions\n */\nconst rgb_num_old = new RegExp(\n\t`^rgba?\\\\(\\\\s*${num}${c}${num}${c}${num}\\\\s*(?:,\\\\s*${num_per}\\\\s*)?\\\\)$`\n);\n\nconst rgb_per_old = new RegExp(\n\t`^rgba?\\\\(\\\\s*${per}${c}${per}${c}${per}\\\\s*(?:,\\\\s*${num_per}\\\\s*)?\\\\)$`\n);\n\nconst parseRgbLegacy = color => {\n\tlet res = { mode: 'rgb' };\n\tlet match;\n\tif ((match = color.match(rgb_num_old))) {\n\t\tif (match[1] !== undefined) {\n\t\t\tres.r = match[1] / 255;\n\t\t}\n\t\tif (match[2] !== undefined) {\n\t\t\tres.g = match[2] / 255;\n\t\t}\n\t\tif (match[3] !== undefined) {\n\t\t\tres.b = match[3] / 255;\n\t\t}\n\t} else if ((match = color.match(rgb_per_old))) {\n\t\tif (match[1] !== undefined) {\n\t\t\tres.r = match[1] / 100;\n\t\t}\n\t\tif (match[2] !== undefined) {\n\t\t\tres.g = match[2] / 100;\n\t\t}\n\t\tif (match[3] !== undefined) {\n\t\t\tres.b = match[3] / 100;\n\t\t}\n\t} else {\n\t\treturn undefined;\n\t}\n\n\tif (match[4] !== undefined) {\n\t\tres.alpha = Math.max(0, Math.min(1, match[4] / 100));\n\t} else if (match[5] !== undefined) {\n\t\tres.alpha = Math.max(0, Math.min(1, +match[5]));\n\t}\n\n\treturn res;\n};\n\nexport default parseRgbLegacy;\n","import parse from './parse.js';\n\nconst prepare = (color, mode) =>\n\tcolor === undefined\n\t\t? undefined\n\t\t: typeof color !== 'object'\n\t\t? parse(color)\n\t\t: color.mode !== undefined\n\t\t? color\n\t\t: mode\n\t\t? { ...color, mode }\n\t\t: undefined;\n\nexport default prepare;\n","import { converters } from './modes.js';\nimport prepare from './_prepare.js';\n\nconst converter =\n\t(target_mode = 'rgb') =>\n\tcolor =>\n\t\t(color = prepare(color, target_mode)) !== undefined\n\t\t\t? // if the color's mode corresponds to our target mode\n\t\t\t color.mode === target_mode\n\t\t\t\t? // then just return the color\n\t\t\t\t color\n\t\t\t\t: // otherwise check to see if we have a dedicated\n\t\t\t\t// converter for the target mode\n\t\t\t\tconverters[color.mode][target_mode]\n\t\t\t\t? // and return its result...\n\t\t\t\t converters[color.mode][target_mode](color)\n\t\t\t\t: // ...otherwise pass through RGB as an intermediary step.\n\t\t\t\t// if the target mode is RGB...\n\t\t\t\ttarget_mode === 'rgb'\n\t\t\t\t? // just return the RGB\n\t\t\t\t converters[color.mode].rgb(color)\n\t\t\t\t: // otherwise convert color.mode -> RGB -> target_mode\n\t\t\t\t converters.rgb[target_mode](converters[color.mode].rgb(color))\n\t\t\t: undefined;\n\nexport default converter;\n","import converter from './converter.js';\n\nconst converters = {};\nconst modes = {};\n\nconst parsers = [];\nconst colorProfiles = {};\n\nconst identity = v => v;\n\nconst useMode = definition => {\n\tconverters[definition.mode] = {\n\t\t...converters[definition.mode],\n\t\t...definition.toMode\n\t};\n\n\tObject.keys(definition.fromMode || {}).forEach(k => {\n\t\tif (!converters[k]) {\n\t\t\tconverters[k] = {};\n\t\t}\n\t\tconverters[k][definition.mode] = definition.fromMode[k];\n\t});\n\n\t// Color space channel ranges\n\tif (!definition.ranges) {\n\t\tdefinition.ranges = {};\n\t}\n\n\tif (!definition.difference) {\n\t\tdefinition.difference = {};\n\t}\n\n\tdefinition.channels.forEach(channel => {\n\t\t// undefined channel ranges default to the [0, 1] interval\n\t\tif (definition.ranges[channel] === undefined) {\n\t\t\tdefinition.ranges[channel] = [0, 1];\n\t\t}\n\n\t\tif (!definition.interpolate[channel]) {\n\t\t\tthrow new Error(`Missing interpolator for: ${channel}`);\n\t\t}\n\n\t\tif (typeof definition.interpolate[channel] === 'function') {\n\t\t\tdefinition.interpolate[channel] = {\n\t\t\t\tuse: definition.interpolate[channel]\n\t\t\t};\n\t\t}\n\n\t\tif (!definition.interpolate[channel].fixup) {\n\t\t\tdefinition.interpolate[channel].fixup = identity;\n\t\t}\n\t});\n\n\tmodes[definition.mode] = definition;\n\t(definition.parse || []).forEach(parser => {\n\t\tuseParser(parser, definition.mode);\n\t});\n\n\treturn converter(definition.mode);\n};\n\nconst getMode = mode => modes[mode];\n\nconst useParser = (parser, mode) => {\n\tif (typeof parser === 'string') {\n\t\tif (!mode) {\n\t\t\tthrow new Error(`'mode' required when 'parser' is a string`);\n\t\t}\n\t\tcolorProfiles[parser] = mode;\n\t} else if (typeof parser === 'function') {\n\t\tif (parsers.indexOf(parser) < 0) {\n\t\t\tparsers.push(parser);\n\t\t}\n\t}\n};\n\nconst removeParser = parser => {\n\tif (typeof parser === 'string') {\n\t\tdelete colorProfiles[parser];\n\t} else if (typeof parser === 'function') {\n\t\tconst idx = parsers.indexOf(parser);\n\t\tif (idx > 0) {\n\t\t\tparsers.splice(idx, 1);\n\t\t}\n\t}\n};\n\nexport {\n\tuseMode,\n\tgetMode,\n\tuseParser,\n\tremoveParser,\n\tconverters,\n\tparsers,\n\tcolorProfiles\n};\n","import { parsers, colorProfiles, getMode } from './modes.js';\n\n/* eslint-disable-next-line no-control-regex */\nconst IdentStartCodePoint = /[^\\x00-\\x7F]|[a-zA-Z_]/;\n\n/* eslint-disable-next-line no-control-regex */\nconst IdentCodePoint = /[^\\x00-\\x7F]|[-\\w]/;\n\nexport const Tok = {\n\tFunction: 'function',\n\tIdent: 'ident',\n\tNumber: 'number',\n\tPercentage: 'percentage',\n\tParenClose: ')',\n\tNone: 'none',\n\tHue: 'hue',\n\tAlpha: 'alpha'\n};\n\nlet _i = 0;\n\n/*\n\t4.3.10. Check if three code points would start a number\n\thttps://drafts.csswg.org/css-syntax/#starts-with-a-number\n */\nfunction is_num(chars) {\n\tlet ch = chars[_i];\n\tlet ch1 = chars[_i + 1];\n\tif (ch === '-' || ch === '+') {\n\t\treturn /\\d/.test(ch1) || (ch1 === '.' && /\\d/.test(chars[_i + 2]));\n\t}\n\tif (ch === '.') {\n\t\treturn /\\d/.test(ch1);\n\t}\n\treturn /\\d/.test(ch);\n}\n\n/*\n\tCheck if the stream starts with an identifier.\n */\n\nfunction is_ident(chars) {\n\tif (_i >= chars.length) {\n\t\treturn false;\n\t}\n\tlet ch = chars[_i];\n\tif (IdentStartCodePoint.test(ch)) {\n\t\treturn true;\n\t}\n\tif (ch === '-') {\n\t\tif (chars.length - _i < 2) {\n\t\t\treturn false;\n\t\t}\n\t\tlet ch1 = chars[_i + 1];\n\t\tif (ch1 === '-' || IdentStartCodePoint.test(ch1)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\treturn false;\n}\n\n/*\n\t4.3.3. Consume a numeric token\n\thttps://drafts.csswg.org/css-syntax/#consume-numeric-token\n */\n\nconst huenits = {\n\tdeg: 1,\n\trad: 180 / Math.PI,\n\tgrad: 9 / 10,\n\tturn: 360\n};\n\nfunction num(chars) {\n\tlet value = '';\n\tif (chars[_i] === '-' || chars[_i] === '+') {\n\t\tvalue += chars[_i++];\n\t}\n\tvalue += digits(chars);\n\tif (chars[_i] === '.' && /\\d/.test(chars[_i + 1])) {\n\t\tvalue += chars[_i++] + digits(chars);\n\t}\n\tif (chars[_i] === 'e' || chars[_i] === 'E') {\n\t\tif (\n\t\t\t(chars[_i + 1] === '-' || chars[_i + 1] === '+') &&\n\t\t\t/\\d/.test(chars[_i + 2])\n\t\t) {\n\t\t\tvalue += chars[_i++] + chars[_i++] + digits(chars);\n\t\t} else if (/\\d/.test(chars[_i + 1])) {\n\t\t\tvalue += chars[_i++] + digits(chars);\n\t\t}\n\t}\n\tif (is_ident(chars)) {\n\t\tlet id = ident(chars);\n\t\tif (id === 'deg' || id === 'rad' || id === 'turn' || id === 'grad') {\n\t\t\treturn { type: Tok.Hue, value: value * huenits[id] };\n\t\t}\n\t\treturn undefined;\n\t}\n\tif (chars[_i] === '%') {\n\t\t_i++;\n\t\treturn { type: Tok.Percentage, value: +value };\n\t}\n\treturn { type: Tok.Number, value: +value };\n}\n\n/*\n\tConsume digits.\n */\nfunction digits(chars) {\n\tlet v = '';\n\twhile (/\\d/.test(chars[_i])) {\n\t\tv += chars[_i++];\n\t}\n\treturn v;\n}\n\n/*\n\tConsume an identifier.\n */\nfunction ident(chars) {\n\tlet v = '';\n\twhile (_i < chars.length && IdentCodePoint.test(chars[_i])) {\n\t\tv += chars[_i++];\n\t}\n\treturn v;\n}\n\n/*\n\tConsume an ident-like token.\n */\nfunction identlike(chars) {\n\tlet v = ident(chars);\n\tif (chars[_i] === '(') {\n\t\t_i++;\n\t\treturn { type: Tok.Function, value: v };\n\t}\n\tif (v === 'none') {\n\t\treturn { type: Tok.None, value: undefined };\n\t}\n\treturn { type: Tok.Ident, value: v };\n}\n\nexport function tokenize(str = '') {\n\tlet chars = str.trim();\n\tlet tokens = [];\n\tlet ch;\n\n\t/* reset counter */\n\t_i = 0;\n\n\twhile (_i < chars.length) {\n\t\tch = chars[_i++];\n\n\t\t/*\n\t\t\tConsume whitespace without emitting it\n\t\t */\n\t\tif (ch === '\\n' || ch === '\\t' || ch === ' ') {\n\t\t\twhile (\n\t\t\t\t_i < chars.length &&\n\t\t\t\t(chars[_i] === '\\n' || chars[_i] === '\\t' || chars[_i] === ' ')\n\t\t\t) {\n\t\t\t\t_i++;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (ch === ',') {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (ch === ')') {\n\t\t\ttokens.push({ type: Tok.ParenClose });\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (ch === '+') {\n\t\t\t_i--;\n\t\t\tif (is_num(chars)) {\n\t\t\t\ttokens.push(num(chars));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (ch === '-') {\n\t\t\t_i--;\n\t\t\tif (is_num(chars)) {\n\t\t\t\ttokens.push(num(chars));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (is_ident(chars)) {\n\t\t\t\ttokens.push({ type: Tok.Ident, value: ident(chars) });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (ch === '.') {\n\t\t\t_i--;\n\t\t\tif (is_num(chars)) {\n\t\t\t\ttokens.push(num(chars));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (ch === '/') {\n\t\t\twhile (\n\t\t\t\t_i < chars.length &&\n\t\t\t\t(chars[_i] === '\\n' || chars[_i] === '\\t' || chars[_i] === ' ')\n\t\t\t) {\n\t\t\t\t_i++;\n\t\t\t}\n\t\t\tlet alpha;\n\t\t\tif (is_num(chars)) {\n\t\t\t\talpha = num(chars);\n\t\t\t\tif (alpha.type !== Tok.Hue) {\n\t\t\t\t\ttokens.push({ type: Tok.Alpha, value: alpha });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (is_ident(chars)) {\n\t\t\t\tif (ident(chars) === 'none') {\n\t\t\t\t\ttokens.push({\n\t\t\t\t\t\ttype: Tok.Alpha,\n\t\t\t\t\t\tvalue: { type: Tok.None, value: undefined }\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (/\\d/.test(ch)) {\n\t\t\t_i--;\n\t\t\ttokens.push(num(chars));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (IdentStartCodePoint.test(ch)) {\n\t\t\t_i--;\n\t\t\ttokens.push(identlike(chars));\n\t\t\tcontinue;\n\t\t}\n\n\t\t/*\n\t\t\tTreat everything not already handled as an error.\n\t\t */\n\t\treturn undefined;\n\t}\n\n\treturn tokens;\n}\n\nexport function parseColorSyntax(tokens) {\n\ttokens._i = 0;\n\tlet token = tokens[tokens._i++];\n\tif (!token || token.type !== Tok.Function || token.value !== 'color') {\n\t\treturn undefined;\n\t}\n\ttoken = tokens[tokens._i++];\n\tif (token.type !== Tok.Ident) {\n\t\treturn undefined;\n\t}\n\tconst mode = colorProfiles[token.value];\n\tif (!mode) {\n\t\treturn undefined;\n\t}\n\tconst res = { mode };\n\tconst coords = consumeCoords(tokens, false);\n\tif (!coords) {\n\t\treturn undefined;\n\t}\n\tconst channels = getMode(mode).channels;\n\tfor (let ii = 0, c, ch; ii < channels.length; ii++) {\n\t\tc = coords[ii];\n\t\tch = channels[ii];\n\t\tif (c.type !== Tok.None) {\n\t\t\tres[ch] = c.type === Tok.Number ? c.value : c.value / 100;\n\t\t\tif (ch === 'alpha') {\n\t\t\t\tres[ch] = Math.max(0, Math.min(1, res[ch]));\n\t\t\t}\n\t\t}\n\t}\n\treturn res;\n}\n\nfunction consumeCoords(tokens, includeHue) {\n\tconst coords = [];\n\tlet token;\n\twhile (tokens._i < tokens.length) {\n\t\ttoken = tokens[tokens._i++];\n\t\tif (\n\t\t\ttoken.type === Tok.None ||\n\t\t\ttoken.type === Tok.Number ||\n\t\t\ttoken.type === Tok.Alpha ||\n\t\t\ttoken.type === Tok.Percentage ||\n\t\t\t(includeHue && token.type === Tok.Hue)\n\t\t) {\n\t\t\tcoords.push(token);\n\t\t\tcontinue;\n\t\t}\n\t\tif (token.type === Tok.ParenClose) {\n\t\t\tif (tokens._i < tokens.length) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tif (coords.length < 3 || coords.length > 4) {\n\t\treturn undefined;\n\t}\n\n\tif (coords.length === 4) {\n\t\tif (coords[3].type !== Tok.Alpha) {\n\t\t\treturn undefined;\n\t\t}\n\t\tcoords[3] = coords[3].value;\n\t}\n\tif (coords.length === 3) {\n\t\tcoords.push({ type: Tok.None, value: undefined });\n\t}\n\n\treturn coords.every(c => c.type !== Tok.Alpha) ? coords : undefined;\n}\n\nexport function parseModernSyntax(tokens, includeHue) {\n\ttokens._i = 0;\n\tlet token = tokens[tokens._i++];\n\tif (!token || token.type !== Tok.Function) {\n\t\treturn undefined;\n\t}\n\tlet coords = consumeCoords(tokens, includeHue);\n\tif (!coords) {\n\t\treturn undefined;\n\t}\n\tcoords.unshift(token.value);\n\treturn coords;\n}\n\nconst parse = color => {\n\tif (typeof color !== 'string') {\n\t\treturn undefined;\n\t}\n\tconst tokens = tokenize(color);\n\tconst parsed = tokens ? parseModernSyntax(tokens, true) : undefined;\n\tlet result = undefined;\n\tlet i = 0;\n\tlet len = parsers.length;\n\twhile (i < len) {\n\t\tif ((result = parsers[i++](color, parsed)) !== undefined) {\n\t\t\treturn result;\n\t\t}\n\t}\n\treturn tokens ? parseColorSyntax(tokens) : undefined;\n};\n\nexport default parse;\n","import { Tok } from '../parse.js';\n\nfunction parseRgb(color, parsed) {\n\tif (!parsed || (parsed[0] !== 'rgb' && parsed[0] !== 'rgba')) {\n\t\treturn undefined;\n\t}\n\tconst res = { mode: 'rgb' };\n\tconst [, r, g, b, alpha] = parsed;\n\tif (r.type === Tok.Hue || g.type === Tok.Hue || b.type === Tok.Hue) {\n\t\treturn undefined;\n\t}\n\tif (r.type !== Tok.None) {\n\t\tres.r = r.type === Tok.Number ? r.value / 255 : r.value / 100;\n\t}\n\tif (g.type !== Tok.None) {\n\t\tres.g = g.type === Tok.Number ? g.value / 255 : g.value / 100;\n\t}\n\tif (b.type !== Tok.None) {\n\t\tres.b = b.type === Tok.Number ? b.value / 255 : b.value / 100;\n\t}\n\tif (alpha.type !== Tok.None) {\n\t\tres.alpha = Math.min(\n\t\t\t1,\n\t\t\tMath.max(\n\t\t\t\t0,\n\t\t\t\talpha.type === Tok.Number ? alpha.value : alpha.value / 100\n\t\t\t)\n\t\t);\n\t}\n\n\treturn res;\n}\n\nexport default parseRgb;\n","const parseTransparent = c =>\n\tc === 'transparent'\n\t\t? { mode: 'rgb', r: 0, g: 0, b: 0, alpha: 0 }\n\t\t: undefined;\n\nexport default parseTransparent;\n","const lerp = (a, b, t) => a + t * (b - a);\nconst unlerp = (a, b, v) => (v - a) / (b - a);\n\nconst blerp = (a00, a01, a10, a11, tx, ty) => {\n\treturn lerp(lerp(a00, a01, tx), lerp(a10, a11, tx), ty);\n};\n\nconst trilerp = (\n\ta000,\n\ta010,\n\ta100,\n\ta110,\n\ta001,\n\ta011,\n\ta101,\n\ta111,\n\ttx,\n\tty,\n\ttz\n) => {\n\treturn lerp(\n\t\tblerp(a000, a010, a100, a110, tx, ty),\n\t\tblerp(a001, a011, a101, a111, tx, ty),\n\t\ttz\n\t);\n};\n\nexport { lerp, blerp, trilerp, unlerp };\n","const get_classes = arr => {\n\tlet classes = [];\n\tfor (let i = 0; i < arr.length - 1; i++) {\n\t\tlet a = arr[i];\n\t\tlet b = arr[i + 1];\n\t\tif (a === undefined && b === undefined) {\n\t\t\tclasses.push(undefined);\n\t\t} else if (a !== undefined && b !== undefined) {\n\t\t\tclasses.push([a, b]);\n\t\t} else {\n\t\t\tclasses.push(a !== undefined ? [a, a] : [b, b]);\n\t\t}\n\t}\n\treturn classes;\n};\n\nconst interpolatorPiecewise = interpolator => arr => {\n\tlet classes = get_classes(arr);\n\treturn t => {\n\t\tlet cls = t * classes.length;\n\t\tlet idx = t >= 1 ? classes.length - 1 : Math.max(Math.floor(cls), 0);\n\t\tlet pair = classes[idx];\n\t\treturn pair === undefined\n\t\t\t? undefined\n\t\t\t: interpolator(pair[0], pair[1], cls - idx);\n\t};\n};\n\nexport { interpolatorPiecewise };\n","import { lerp } from './lerp.js';\nimport { interpolatorPiecewise } from './piecewise.js';\n\nexport const interpolatorLinear = interpolatorPiecewise(lerp);\n","const fixupAlpha = arr => {\n\tlet some_defined = false;\n\tlet res = arr.map(v => {\n\t\tif (v !== undefined) {\n\t\t\tsome_defined = true;\n\t\t\treturn v;\n\t\t}\n\t\treturn 1;\n\t});\n\treturn some_defined ? res : arr;\n};\n\nexport { fixupAlpha };\n","import parseNamed from './parseNamed.js';\nimport parseHex from './parseHex.js';\nimport parseRgbLegacy from './parseRgbLegacy.js';\nimport parseRgb from './parseRgb.js';\nimport parseTransparent from './parseTransparent.js';\nimport { interpolatorLinear } from '../interpolate/linear.js';\nimport { fixupAlpha } from '../fixup/alpha.js';\n\n/*\n\tsRGB color space\n */\n\nconst definition = {\n\tmode: 'rgb',\n\tchannels: ['r', 'g', 'b', 'alpha'],\n\tparse: [\n\t\tparseRgb,\n\t\tparseHex,\n\t\tparseRgbLegacy,\n\t\tparseNamed,\n\t\tparseTransparent,\n\t\t'srgb'\n\t],\n\tserialize: 'srgb',\n\tinterpolate: {\n\t\tr: interpolatorLinear,\n\t\tg: interpolatorLinear,\n\t\tb: interpolatorLinear,\n\t\talpha: { use: interpolatorLinear, fixup: fixupAlpha }\n\t},\n\tgamut: true,\n\twhite: { r: 1, g: 1, b: 1 },\n\tblack: { r: 0, g: 0, b: 0 }\n};\n\nexport default definition;\n","/*\n\tConvert A98 RGB values to CIE XYZ D65\n\n\tReferences:\n\t\t* https://drafts.csswg.org/css-color/#color-conversion-code\n\t\t* http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html\n\t\t* https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf\n*/\n\nconst linearize = (v = 0) => Math.pow(Math.abs(v), 563 / 256) * Math.sign(v);\n\nconst convertA98ToXyz65 = a98 => {\n\tlet r = linearize(a98.r);\n\tlet g = linearize(a98.g);\n\tlet b = linearize(a98.b);\n\tlet res = {\n\t\tmode: 'xyz65',\n\t\tx:\n\t\t\t0.5766690429101305 * r +\n\t\t\t0.1855582379065463 * g +\n\t\t\t0.1882286462349947 * b,\n\t\ty:\n\t\t\t0.297344975250536 * r +\n\t\t\t0.6273635662554661 * g +\n\t\t\t0.0752914584939979 * b,\n\t\tz:\n\t\t\t0.0270313613864123 * r +\n\t\t\t0.0706888525358272 * g +\n\t\t\t0.9913375368376386 * b\n\t};\n\tif (a98.alpha !== undefined) {\n\t\tres.alpha = a98.alpha;\n\t}\n\treturn res;\n};\n\nexport default convertA98ToXyz65;\n","/*\n\tConvert CIE XYZ D65 values to A98 RGB\n\n\tReferences:\n\t\t* https://drafts.csswg.org/css-color/#color-conversion-code\n\t\t* http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html\n*/\n\nconst gamma = v => Math.pow(Math.abs(v), 256 / 563) * Math.sign(v);\n\nconst convertXyz65ToA98 = ({ x, y, z, alpha }) => {\n\tif (x === undefined) x = 0;\n\tif (y === undefined) y = 0;\n\tif (z === undefined) z = 0;\n\tlet res = {\n\t\tmode: 'a98',\n\t\tr: gamma(\n\t\t\tx * 2.0415879038107465 -\n\t\t\t\ty * 0.5650069742788597 -\n\t\t\t\t0.3447313507783297 * z\n\t\t),\n\t\tg: gamma(\n\t\t\tx * -0.9692436362808798 +\n\t\t\t\ty * 1.8759675015077206 +\n\t\t\t\t0.0415550574071756 * z\n\t\t),\n\t\tb: gamma(\n\t\t\tx * 0.0134442806320312 -\n\t\t\t\ty * 0.1183623922310184 +\n\t\t\t\t1.0151749943912058 * z\n\t\t)\n\t};\n\tif (alpha !== undefined) {\n\t\tres.alpha = alpha;\n\t}\n\treturn res;\n};\n\nexport default convertXyz65ToA98;\n","const fn = (c = 0) => {\n\tconst abs = Math.abs(c);\n\tif (abs <= 0.04045) {\n\t\treturn c / 12.92;\n\t}\n\treturn (Math.sign(c) || 1) * Math.pow((abs + 0.055) / 1.055, 2.4);\n};\n\nconst convertRgbToLrgb = ({ r, g, b, alpha }) => {\n\tlet res = {\n\t\tmode: 'lrgb',\n\t\tr: fn(r),\n\t\tg: fn(g),\n\t\tb: fn(b)\n\t};\n\tif (alpha !== undefined) res.alpha = alpha;\n\treturn res;\n};\n\nexport default convertRgbToLrgb;\n","/*\n\tConvert sRGB values to CIE XYZ D65\n\n\tReferences:\n\t\t* https://drafts.csswg.org/css-color/#color-conversion-code\n\t\t* http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html\n\t\t* https://observablehq.com/@danburzo/color-matrix-calculator\n*/\n\nimport convertRgbToLrgb from '../lrgb/convertRgbToLrgb.js';\n\nconst convertRgbToXyz65 = rgb => {\n\tlet { r, g, b, alpha } = convertRgbToLrgb(rgb);\n\tlet res = {\n\t\tmode: 'xyz65',\n\t\tx:\n\t\t\t0.4123907992659593 * r +\n\t\t\t0.357584339383878 * g +\n\t\t\t0.1804807884018343 * b,\n\t\ty:\n\t\t\t0.2126390058715102 * r +\n\t\t\t0.715168678767756 * g +\n\t\t\t0.0721923153607337 * b,\n\t\tz:\n\t\t\t0.0193308187155918 * r +\n\t\t\t0.119194779794626 * g +\n\t\t\t0.9505321522496607 * b\n\t};\n\tif (alpha !== undefined) {\n\t\tres.alpha = alpha;\n\t}\n\treturn res;\n};\n\nexport default convertRgbToXyz65;\n","const fn = (c = 0) => {\n\tconst abs = Math.abs(c);\n\tif (abs > 0.0031308) {\n\t\treturn (Math.sign(c) || 1) * (1.055 * Math.pow(abs, 1 / 2.4) - 0.055);\n\t}\n\treturn c * 12.92;\n};\n\nconst convertLrgbToRgb = ({ r, g, b, alpha }, mode = 'rgb') => {\n\tlet res = {\n\t\tmode,\n\t\tr: fn(r),\n\t\tg: fn(g),\n\t\tb: fn(b)\n\t};\n\tif (alpha !== undefined) res.alpha = alpha;\n\treturn res;\n};\n\nexport default convertLrgbToRgb;\n","/*\n\tCIE XYZ D65 values to sRGB.\n\n\tReferences:\n\t\t* https://drafts.csswg.org/css-color/#color-conversion-code\n\t\t* http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html\n\t\t* https://observablehq.com/@danburzo/color-matrix-calculator\n*/\n\nimport convertLrgbToRgb from '../lrgb/convertLrgbToRgb.js';\n\nconst convertXyz65ToRgb = ({ x, y, z, alpha }) => {\n\tif (x === undefined) x = 0;\n\tif (y === undefined) y = 0;\n\tif (z === undefined) z = 0;\n\tlet res = convertLrgbToRgb({\n\t\tr:\n\t\t\tx * 3.2409699419045226 -\n\t\t\ty * 1.5373831775700939 -\n\t\t\t0.4986107602930034 * z,\n\t\tg:\n\t\t\tx * -0.9692436362808796 +\n\t\t\ty * 1.8759675015077204 +\n\t\t\t0.0415550574071756 * z,\n\t\tb:\n\t\t\tx * 0.0556300796969936 -\n\t\t\ty * 0.2039769588889765 +\n\t\t\t1.0569715142428784 * z\n\t});\n\tif (alpha !== undefined) {\n\t\tres.alpha = alpha;\n\t}\n\treturn res;\n};\n\nexport default convertXyz65ToRgb;\n","import rgb from '../rgb/definition.js';\n\nimport convertA98ToXyz65 from './convertA98ToXyz65.js';\nimport convertXyz65ToA98 from './convertXyz65ToA98.js';\nimport convertRgbToXyz65 from '../xyz65/convertRgbToXyz65.js';\nimport convertXyz65ToRgb from '../xyz65/convertXyz65ToRgb.js';\n\nconst definition = {\n\t...rgb,\n\tmode: 'a98',\n\tparse: ['a98-rgb'],\n\tserialize: 'a98-rgb',\n\n\tfromMode: {\n\t\trgb: color => convertXyz65ToA98(convertRgbToXyz65(color)),\n\t\txyz65: convertXyz65ToA98\n\t},\n\n\ttoMode: {\n\t\trgb: color => convertXyz65ToRgb(convertA98ToXyz65(color)),\n\t\txyz65: convertA98ToXyz65\n\t}\n};\n\nexport default definition;\n","const normalizeHue = hue => ((hue = hue % 360) < 0 ? hue + 360 : hue);\n\nexport default normalizeHue;\n","import normalizeHue from '../util/normalizeHue.js';\n\nconst hue = (hues, fn) => {\n\treturn hues\n\t\t.map((hue, idx, arr) => {\n\t\t\tif (hue === undefined) {\n\t\t\t\treturn hue;\n\t\t\t}\n\t\t\tlet normalized = normalizeHue(hue);\n\t\t\tif (idx === 0 || hues[idx - 1] === undefined) {\n\t\t\t\treturn normalized;\n\t\t\t}\n\t\t\treturn fn(normalized - normalizeHue(arr[idx - 1]));\n\t\t})\n\t\t.reduce((acc, curr) => {\n\t\t\tif (\n\t\t\t\t!acc.length ||\n\t\t\t\tcurr === undefined ||\n\t\t\t\tacc[acc.length - 1] === undefined\n\t\t\t) {\n\t\t\t\tacc.push(curr);\n\t\t\t\treturn acc;\n\t\t\t}\n\t\t\tacc.push(curr + acc[acc.length - 1]);\n\t\t\treturn acc;\n\t\t}, []);\n};\n\nconst fixupHueShorter = arr =>\n\thue(arr, d => (Math.abs(d) <= 180 ? d : d - 360 * Math.sign(d)));\nconst fixupHueLonger = arr =>\n\thue(arr, d => (Math.abs(d) >= 180 || d === 0 ? d : d - 360 * Math.sign(d)));\nconst fixupHueIncreasing = arr => hue(arr, d => (d >= 0 ? d : d + 360));\nconst fixupHueDecreasing = arr => hue(arr, d => (d <= 0 ? d : d - 360));\n\nexport {\n\tfixupHueShorter,\n\tfixupHueLonger,\n\tfixupHueIncreasing,\n\tfixupHueDecreasing\n};\n","export const M = [-0.14861, 1.78277, -0.29227, -0.90649, 1.97294, 0];\n\nexport const degToRad = Math.PI / 180;\nexport const radToDeg = 180 / Math.PI;\n","/*\n\tConvert a RGB color to the Cubehelix HSL color space.\n\n\tThis computation is not present in Green's paper:\n\thttps://arxiv.org/pdf/1108.5083.pdf\n\n\t...but can be derived from the inverse, HSL to RGB conversion.\n\n\tIt matches the math in Mike Bostock's D3 implementation:\n\n\thttps://github.com/d3/d3-color/blob/master/src/cubehelix.js\n */\n\nimport { radToDeg, M } from './constants.js';\n\nlet DE = M[3] * M[4];\nlet BE = M[1] * M[4];\nlet BCAD = M[1] * M[2] - M[0] * M[3];\n\nconst convertRgbToCubehelix = ({ r, g, b, alpha }) => {\n\tif (r === undefined) r = 0;\n\tif (g === undefined) g = 0;\n\tif (b === undefined) b = 0;\n\tlet l = (BCAD * b + r * DE - g * BE) / (BCAD + DE - BE);\n\tlet x = b - l;\n\tlet y = (M[4] * (g - l) - M[2] * x) / M[3];\n\n\tlet res = {\n\t\tmode: 'cubehelix',\n\t\tl: l,\n\t\ts:\n\t\t\tl === 0 || l === 1\n\t\t\t\t? undefined\n\t\t\t\t: Math.sqrt(x * x + y * y) / (M[4] * l * (1 - l))\n\t};\n\n\tif (res.s) res.h = Math.atan2(y, x) * radToDeg - 120;\n\tif (alpha !== undefined) res.alpha = alpha;\n\n\treturn res;\n};\n\nexport default convertRgbToCubehelix;\n","import { degToRad, M } from './constants.js';\n\nconst convertCubehelixToRgb = ({ h, s, l, alpha }) => {\n\tlet res = { mode: 'rgb' };\n\n\th = (h === undefined ? 0 : h + 120) * degToRad;\n\tif (l === undefined) l = 0;\n\n\tlet amp = s === undefined ? 0 : s * l * (1 - l);\n\n\tlet cosh = Math.cos(h);\n\tlet sinh = Math.sin(h);\n\n\tres.r = l + amp * (M[0] * cosh + M[1] * sinh);\n\tres.g = l + amp * (M[2] * cosh + M[3] * sinh);\n\tres.b = l + amp * (M[4] * cosh + M[5] * sinh);\n\n\tif (alpha !== undefined) res.alpha = alpha;\n\treturn res;\n};\n\nexport default convertCubehelixToRgb;\n","import { getMode } from './modes.js';\nimport converter from './converter.js';\nimport normalizeHue from './util/normalizeHue.js';\n\nconst differenceHueSaturation = (std, smp) => {\n\tif (std.h === undefined || smp.h === undefined || !std.s || !smp.s) {\n\t\treturn 0;\n\t}\n\tlet std_h = normalizeHue(std.h);\n\tlet smp_h = normalizeHue(smp.h);\n\tlet dH = Math.sin((((smp_h - std_h + 360) / 2) * Math.PI) / 180);\n\treturn 2 * Math.sqrt(std.s * smp.s) * dH;\n};\n\nconst differenceHueNaive = (std, smp) => {\n\tif (std.h === undefined || smp.h === undefined) {\n\t\treturn 0;\n\t}\n\tlet std_h = normalizeHue(std.h);\n\tlet smp_h = normalizeHue(smp.h);\n\tif (Math.abs(smp_h - std_h) > 180) {\n\t\t// todo should this be normalized once again?\n\t\treturn std_h - (smp_h - 360 * Math.sign(smp_h - std_h));\n\t}\n\treturn smp_h - std_h;\n};\n\nconst differenceHueChroma = (std, smp) => {\n\tif (std.h === undefined || smp.h === undefined || !std.c || !smp.c) {\n\t\treturn 0;\n\t}\n\tlet std_h = normalizeHue(std.h);\n\tlet smp_h = normalizeHue(smp.h);\n\tlet dH = Math.sin((((smp_h - std_h + 360) / 2) * Math.PI) / 180);\n\treturn 2 * Math.sqrt(std.c * smp.c) * dH;\n};\n\nconst differenceEuclidean = (mode = 'rgb', weights = [1, 1, 1, 0]) => {\n\tlet def = getMode(mode);\n\tlet channels = def.channels;\n\tlet diffs = def.difference;\n\tlet conv = converter(mode);\n\treturn (std, smp) => {\n\t\tlet ConvStd = conv(std);\n\t\tlet ConvSmp = conv(smp);\n\t\treturn Math.sqrt(\n\t\t\tchannels.reduce((sum, k, idx) => {\n\t\t\t\tlet delta = diffs[k]\n\t\t\t\t\t? diffs[k](ConvStd, ConvSmp)\n\t\t\t\t\t: ConvStd[k] - ConvSmp[k];\n\t\t\t\treturn (\n\t\t\t\t\tsum +\n\t\t\t\t\t(weights[idx] || 0) * Math.pow(isNaN(delta) ? 0 : delta, 2)\n\t\t\t\t);\n\t\t\t}, 0)\n\t\t);\n\t};\n};\n\nconst differenceCie76 = () => differenceEuclidean('lab65');\n\nconst differenceCie94 = (kL = 1, K1 = 0.045, K2 = 0.015) => {\n\tlet lab = converter('lab65');\n\n\treturn (std, smp) => {\n\t\tlet LabStd = lab(std);\n\t\tlet LabSmp = lab(smp);\n\n\t\t// Extract Lab values, and compute Chroma\n\t\tlet lStd = LabStd.l;\n\t\tlet aStd = LabStd.a;\n\t\tlet bStd = LabStd.b;\n\t\tlet cStd = Math.sqrt(aStd * aStd + bStd * bStd);\n\n\t\tlet lSmp = LabSmp.l;\n\t\tlet aSmp = LabSmp.a;\n\t\tlet bSmp = LabSmp.b;\n\t\tlet cSmp = Math.sqrt(aSmp * aSmp + bSmp * bSmp);\n\n\t\tlet dL2 = Math.pow(lStd - lSmp, 2);\n\t\tlet dC2 = Math.pow(cStd - cSmp, 2);\n\t\tlet dH2 = Math.pow(aStd - aSmp, 2) + Math.pow(bStd - bSmp, 2) - dC2;\n\n\t\treturn Math.sqrt(\n\t\t\tdL2 / Math.pow(kL, 2) +\n\t\t\t\tdC2 / Math.pow(1 + K1 * cStd, 2) +\n\t\t\t\tdH2 / Math.pow(1 + K2 * cStd, 2)\n\t\t);\n\t};\n};\n\n/*\n\tCIEDE2000 color difference, original Matlab implementation by Gaurav Sharma\n\tBased on \"The CIEDE2000 Color-Difference Formula: Implementation Notes, Supplementary Test Data, and Mathematical Observations\" \n\tby Gaurav Sharma, Wencheng Wu, Edul N. Dalal in Color Research and Application, vol. 30. No. 1, pp. 21-30, February 2005.\n\thttp://www2.ece.rochester.edu/~gsharma/ciede2000/\n */\n\nconst differenceCiede2000 = (Kl = 1, Kc = 1, Kh = 1) => {\n\tlet lab = converter('lab65');\n\treturn (std, smp) => {\n\t\tlet LabStd = lab(std);\n\t\tlet LabSmp = lab(smp);\n\n\t\tlet lStd = LabStd.l;\n\t\tlet aStd = LabStd.a;\n\t\tlet bStd = LabStd.b;\n\t\tlet cStd = Math.sqrt(aStd * aStd + bStd * bStd);\n\n\t\tlet lSmp = LabSmp.l;\n\t\tlet aSmp = LabSmp.a;\n\t\tlet bSmp = LabSmp.b;\n\t\tlet cSmp = Math.sqrt(aSmp * aSmp + bSmp * bSmp);\n\n\t\tlet cAvg = (cStd + cSmp) / 2;\n\n\t\tlet G =\n\t\t\t0.5 *\n\t\t\t(1 -\n\t\t\t\tMath.sqrt(\n\t\t\t\t\tMath.pow(cAvg, 7) / (Math.pow(cAvg, 7) + Math.pow(25, 7))\n\t\t\t\t));\n\n\t\tlet apStd = aStd * (1 + G);\n\t\tlet apSmp = aSmp * (1 + G);\n\n\t\tlet cpStd = Math.sqrt(apStd * apStd + bStd * bStd);\n\t\tlet cpSmp = Math.sqrt(apSmp * apSmp + bSmp * bSmp);\n\n\t\tlet hpStd =\n\t\t\tMath.abs(apStd) + Math.abs(bStd) === 0\n\t\t\t\t? 0\n\t\t\t\t: Math.atan2(bStd, apStd);\n\t\thpStd += (hpStd < 0) * 2 * Math.PI;\n\n\t\tlet hpSmp =\n\t\t\tMath.abs(apSmp) + Math.abs(bSmp) === 0\n\t\t\t\t? 0\n\t\t\t\t: Math.atan2(bSmp, apSmp);\n\t\thpSmp += (hpSmp < 0) * 2 * Math.PI;\n\n\t\tlet dL = lSmp - lStd;\n\t\tlet dC = cpSmp - cpStd;\n\n\t\tlet dhp = cpStd * cpSmp === 0 ? 0 : hpSmp - hpStd;\n\t\tdhp -= (dhp > Math.PI) * 2 * Math.PI;\n\t\tdhp += (dhp < -Math.PI) * 2 * Math.PI;\n\n\t\tlet dH = 2 * Math.sqrt(cpStd * cpSmp) * Math.sin(dhp / 2);\n\n\t\tlet Lp = (lStd + lSmp) / 2;\n\t\tlet Cp = (cpStd + cpSmp) / 2;\n\n\t\tlet hp;\n\t\tif (cpStd * cpSmp === 0) {\n\t\t\thp = hpStd + hpSmp;\n\t\t} else {\n\t\t\thp = (hpStd + hpSmp) / 2;\n\t\t\thp -= (Math.abs(hpStd - hpSmp) > Math.PI) * Math.PI;\n\t\t\thp += (hp < 0) * 2 * Math.PI;\n\t\t}\n\n\t\tlet Lpm50 = Math.pow(Lp - 50, 2);\n\t\tlet T =\n\t\t\t1 -\n\t\t\t0.17 * Math.cos(hp - Math.PI / 6) +\n\t\t\t0.24 * Math.cos(2 * hp) +\n\t\t\t0.32 * Math.cos(3 * hp + Math.PI / 30) -\n\t\t\t0.2 * Math.cos(4 * hp - (63 * Math.PI) / 180);\n\n\t\tlet Sl = 1 + (0.015 * Lpm50) / Math.sqrt(20 + Lpm50);\n\t\tlet Sc = 1 + 0.045 * Cp;\n\t\tlet Sh = 1 + 0.015 * Cp * T;\n\n\t\tlet deltaTheta =\n\t\t\t((30 * Math.PI) / 180) *\n\t\t\tMath.exp(-1 * Math.pow(((180 / Math.PI) * hp - 275) / 25, 2));\n\t\tlet Rc =\n\t\t\t2 *\n\t\t\tMath.sqrt(Math.pow(Cp, 7) / (Math.pow(Cp, 7) + Math.pow(25, 7)));\n\n\t\tlet Rt = -1 * Math.sin(2 * deltaTheta) * Rc;\n\n\t\treturn Math.sqrt(\n\t\t\tMath.pow(dL / (Kl * Sl), 2) +\n\t\t\t\tMath.pow(dC / (Kc * Sc), 2) +\n\t\t\t\tMath.pow(dH / (Kh * Sh), 2) +\n\t\t\t\t(((Rt * dC) / (Kc * Sc)) * dH) / (Kh * Sh)\n\t\t);\n\t};\n};\n\n/*\n\tCMC (l:c) difference formula\n\n\tReferences:\n\t\thttps://en.wikipedia.org/wiki/Color_difference#CMC_l:c_(1984)\n\t\thttp://www.brucelindbloom.com/index.html?Eqn_DeltaE_CMC.html\n */\nconst differenceCmc = (l = 1, c = 1) => {\n\tlet lab = converter('lab65');\n\n\t/*\n\t\tComparte two colors:\n\t\tstd - standard (first) color\n\t\tsmp - sample (second) color\n\t */\n\treturn (std, smp) => {\n\t\t// convert standard color to Lab\n\t\tlet LabStd = lab(std);\n\t\tlet lStd = LabStd.l;\n\t\tlet aStd = LabStd.a;\n\t\tlet bStd = LabStd.b;\n\n\t\t// Obtain hue/chroma\n\t\tlet cStd = Math.sqrt(aStd * aStd + bStd * bStd);\n\t\tlet hStd = Math.atan2(bStd, aStd);\n\t\thStd = hStd + 2 * Math.PI * (hStd < 0);\n\n\t\t// convert sample color to Lab, obtain LCh\n\t\tlet LabSmp = lab(smp);\n\t\tlet lSmp = LabSmp.l;\n\t\tlet aSmp = LabSmp.a;\n\t\tlet bSmp = LabSmp.b;\n\n\t\t// Obtain chroma\n\t\tlet cSmp = Math.sqrt(aSmp * aSmp + bSmp * bSmp);\n\n\t\t// lightness delta squared\n\t\tlet dL2 = Math.pow(lStd - lSmp, 2);\n\n\t\t// chroma delta squared\n\t\tlet dC2 = Math.pow(cStd - cSmp, 2);\n\n\t\t// hue delta squared\n\t\tlet dH2 = Math.pow(aStd - aSmp, 2) + Math.pow(bStd - bSmp, 2) - dC2;\n\n\t\tlet F = Math.sqrt(Math.pow(cStd, 4) / (Math.pow(cStd, 4) + 1900));\n\t\tlet T =\n\t\t\thStd >= (164 / 180) * Math.PI && hStd <= (345 / 180) * Math.PI\n\t\t\t\t? 0.56 + Math.abs(0.2 * Math.cos(hStd + (168 / 180) * Math.PI))\n\t\t\t\t: 0.36 + Math.abs(0.4 * Math.cos(hStd + (35 / 180) * Math.PI));\n\n\t\tlet Sl = lStd < 16 ? 0.511 : (0.040975 * lStd) / (1 + 0.01765 * lStd);\n\t\tlet Sc = (0.0638 * cStd) / (1 + 0.0131 * cStd) + 0.638;\n\t\tlet Sh = Sc * (F * T + 1 - F);\n\n\t\treturn Math.sqrt(\n\t\t\tdL2 / Math.pow(l * Sl, 2) +\n\t\t\t\tdC2 / Math.pow(c * Sc, 2) +\n\t\t\t\tdH2 / Math.pow(Sh, 2)\n\t\t);\n\t};\n};\n\n/*\n\n\tHyAB color difference formula, introduced in:\n\n\t\tAbasi S, Amani Tehran M, Fairchild MD. \n\t\t\"Distance metrics for very large color differences.\"\n\t\tColor Res Appl. 2019; 1–16. \n\t\thttps://doi.org/10.1002/col.22451\n\n\tPDF available at:\n\t\n\t\thttp://markfairchild.org/PDFs/PAP40.pdf\n */\nconst differenceHyab = () => {\n\tlet lab = converter('lab65');\n\treturn (std, smp) => {\n\t\tlet LabStd = lab(std);\n\t\tlet LabSmp = lab(smp);\n\t\tlet dL = LabStd.l - LabSmp.l;\n\t\tlet dA = LabStd.a - LabSmp.a;\n\t\tlet dB = LabStd.b - LabSmp.b;\n\t\treturn Math.abs(dL) + Math.sqrt(dA * dA + dB * dB);\n\t};\n};\n\n/*\n\t\"Measuring perceived color difference using YIQ NTSC\n\ttransmission color space in mobile applications\"\n\t\t\n\t\tby Yuriy Kotsarenko, Fernando Ramos in:\n\t\tProgramación Matemática y Software (2010) \n\n\tAvailable at:\n\t\t\n\t\thttp://www.progmat.uaem.mx:8080/artVol2Num2/Articulo3Vol2Num2.pdf\n */\nconst differenceKotsarenkoRamos = () =>\n\tdifferenceEuclidean('yiq', [0.5053, 0.299, 0.1957]);\n\n/*\n\tΔE_ITP, as defined in Rec. ITU-R BT.2124:\n\n\thttps://www.itu.int/rec/R-REC-BT.2124/en\n*/\nconst differenceItp = () =>\n\tdifferenceEuclidean('itp', [518400, 129600, 518400]);\n\nexport {\n\tdifferenceHueChroma,\n\tdifferenceHueSaturation,\n\tdifferenceHueNaive,\n\tdifferenceEuclidean,\n\tdifferenceCie76,\n\tdifferenceCie94,\n\tdifferenceCiede2000,\n\tdifferenceCmc,\n\tdifferenceHyab,\n\tdifferenceKotsarenkoRamos,\n\tdifferenceItp\n};\n","import converter from './converter.js';\nimport { getMode } from './modes.js';\n\nconst averageAngle = val => {\n\t// See: https://en.wikipedia.org/wiki/Mean_of_circular_quantities\n\tlet sum = val.reduce(\n\t\t(sum, val) => {\n\t\t\tif (val !== undefined) {\n\t\t\t\tlet rad = (val * Math.PI) / 180;\n\t\t\t\tsum.sin += Math.sin(rad);\n\t\t\t\tsum.cos += Math.cos(rad);\n\t\t\t}\n\t\t\treturn sum;\n\t\t},\n\t\t{ sin: 0, cos: 0 }\n\t);\n\tlet angle = (Math.atan2(sum.sin, sum.cos) * 180) / Math.PI;\n\treturn angle < 0 ? 360 + angle : angle;\n};\n\nconst averageNumber = val => {\n\tlet a = val.filter(v => v !== undefined);\n\treturn a.length ? a.reduce((sum, v) => sum + v, 0) / a.length : undefined;\n};\n\nconst isfn = o => typeof o === 'function';\n\nfunction average(colors, mode = 'rgb', overrides) {\n\tlet def = getMode(mode);\n\tlet cc = colors.map(converter(mode));\n\treturn def.channels.reduce(\n\t\t(res, ch) => {\n\t\t\tlet arr = cc.map(c => c[ch]).filter(val => val !== undefined);\n\t\t\tif (arr.length) {\n\t\t\t\tlet fn;\n\t\t\t\tif (isfn(overrides)) {\n\t\t\t\t\tfn = overrides;\n\t\t\t\t} else if (overrides && isfn(overrides[ch])) {\n\t\t\t\t\tfn = overrides[ch];\n\t\t\t\t} else if (def.average && isfn(def.average[ch])) {\n\t\t\t\t\tfn = def.average[ch];\n\t\t\t\t} else {\n\t\t\t\t\tfn = averageNumber;\n\t\t\t\t}\n\t\t\t\tres[ch] = fn(arr, ch);\n\t\t\t}\n\t\t\treturn res;\n\t\t},\n\t\t{ mode }\n\t);\n}\n\nexport { average, averageAngle, averageNumber };\n","/* \n\tDave Green's Cubehelix\n\t----------------------\n\n\tGreen, D. A., 2011, \"A colour scheme for the display of astronomical intensity images\", \n\tBulletin of the Astronomical Society of India, 39, 289. (2011BASI...39..289G at ADS.) \n\n\thttps://www.mrao.cam.ac.uk/%7Edag/CUBEHELIX/\n\thttps://arxiv.org/pdf/1108.5083.pdf\n\n\tAlthough Cubehelix was defined to be a method to obtain a colour scheme,\n\tit actually contains a definition of a colour space, as identified by \n\tMike Bostock and implemented in D3.js.\n\n\tGreen's paper introduces the following terminology:\n\n\t* \ta `lightness` dimension in the interval [0, 1] \n\t\ton which we interpolate to obtain the colour scheme\n\t*\ta `start` colour that is analogous to a Hue in HSL space\n\t*\ta n