{"version":3,"file":"index.cjs","sources":["../../../../../../../../../../.yarn/berry/cache/chroma-js-npm-3.2.0-d5c39f5077-10c0.zip/node_modules/chroma-js/src/io/named/index.js"],"sourcesContent":["import Color from '../../Color.js';\nimport input from '../input.js';\nimport { type } from '../../utils/index.js';\n\nimport w3cx11 from '../../colors/w3cx11.js';\nimport hex2rgb from '../hex/hex2rgb.js';\nimport rgb2hex from '../hex/rgb2hex.js';\n\nColor.prototype.name = function () {\n    const hex = rgb2hex(this._rgb, 'rgb');\n    for (let n of Object.keys(w3cx11)) {\n        if (w3cx11[n] === hex) return n.toLowerCase();\n    }\n    return hex;\n};\n\ninput.format.named = (name) => {\n    name = name.toLowerCase();\n    if (w3cx11[name]) return hex2rgb(w3cx11[name]);\n    throw new Error('unknown color name: ' + name);\n};\n\ninput.autodetect.push({\n    p: 5,\n    test: (h, ...rest) => {\n        if (!rest.length && type(h) === 'string' && w3cx11[h.toLowerCase()]) {\n            return 'named';\n        }\n    }\n});\n"],"names":[],"mappings":";;;;;;;AAQA,MAAM,UAAU,OAAO,WAAY;AAC/B,QAAM,MAAM,QAAQ,KAAK,MAAM,KAAK;AACpC,WAAS,KAAK,OAAO,KAAK,MAAM,GAAG;AAC/B,QAAI,OAAO,CAAC,MAAM,IAAK,QAAO,EAAE,YAAW;AAAA,EAC/C;AACA,SAAO;AACX;AAEA,MAAM,OAAO,QAAQ,CAAC,SAAS;AAC3B,SAAO,KAAK,YAAW;AACvB,MAAI,OAAO,IAAI,EAAG,QAAO,QAAQ,OAAO,IAAI,CAAC;AAC7C,QAAM,IAAI,MAAM,yBAAyB,IAAI;AACjD;AAEA,MAAM,WAAW,KAAK;AAAA,EAClB,GAAG;AAAA,EACH,MAAM,CAAC,MAAM,SAAS;AAClB,QAAI,CAAC,KAAK,UAAU,KAAK,CAAC,MAAM,YAAY,OAAO,EAAE,YAAW,CAAE,GAAG;AACjE,aAAO;AAAA,IACX;AAAA,EACJ;AACJ,CAAC;","x_google_ignoreList":[0]}